🔧 Address code review feedback: extract magic numbers as constants

Co-authored-by: qinfendebingshuo <207279273+qinfendebingshuo@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-03-16 09:49:07 +00:00
parent dc9b77a637
commit 0336d99d1e
2 changed files with 9 additions and 3 deletions

View File

@ -31,6 +31,9 @@ const REPO_OWNER = 'qinfendebingshuo';
// ━━━ 人格体签名正则 ━━━ // ━━━ 人格体签名正则 ━━━
const PERSONA_SIGNATURE_REGEX = /\[PER-(\d{3})\]/; const PERSONA_SIGNATURE_REGEX = /\[PER-(\d{3})\]/;
// ━━━ 显示长度限制 ━━━
const MAX_COMMIT_DISPLAY = 80;
// ━━━ 安全读取 JSON ━━━ // ━━━ 安全读取 JSON ━━━
function readJSON(filePath) { function readJSON(filePath) {
try { try {
@ -186,7 +189,7 @@ function main() {
const commitMessage = process.env.COMMIT_MESSAGE || ''; const commitMessage = process.env.COMMIT_MESSAGE || '';
console.log(`🚦 铸渊·智能门禁 v2 · 判定引擎启动`); console.log(`🚦 铸渊·智能门禁 v2 · 判定引擎启动`);
console.log(` 推送者: ${actor}`); console.log(` 推送者: ${actor}`);
console.log(` Commit: ${commitMessage.substring(0, 80)}`); console.log(` Commit: ${commitMessage.substring(0, MAX_COMMIT_DISPLAY)}`);
// 0. 仓库主人 → 永远放行 // 0. 仓库主人 → 永远放行
if (actor === REPO_OWNER) { if (actor === REPO_OWNER) {

View File

@ -24,6 +24,9 @@ const BRAIN_DIR = path.join(ROOT, '.github/persona-brain');
const NOTION_TOKEN = process.env.NOTION_TOKEN; const NOTION_TOKEN = process.env.NOTION_TOKEN;
const PERSONA_DB_ID = process.env.SKYEYE_PERSONA_DB_ID; const PERSONA_DB_ID = process.env.SKYEYE_PERSONA_DB_ID;
const MAX_NOTION_RICH_TEXT = 2000;
const MAX_COMMIT_DISPLAY = 80;
// ━━━ Notion API 请求 ━━━ // ━━━ Notion API 请求 ━━━
function notionRequest(method, apiPath, body) { function notionRequest(method, apiPath, body) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -184,7 +187,7 @@ async function writeBack(personaId, data) {
} }
if (data.gate_result) { if (data.gate_result) {
properties['门禁记录'] = { properties['门禁记录'] = {
rich_text: [{ type: 'text', text: { content: data.gate_result.substring(0, 2000) } }] rich_text: [{ type: 'text', text: { content: data.gate_result.substring(0, MAX_NOTION_RICH_TEXT) } }]
}; };
} }
@ -254,7 +257,7 @@ async function fullSync() {
updated++; updated++;
} }
config.updated_at = new Date().toISOString().slice(0, 10); config.updated_at = new Date().toISOString().split('T')[0];
fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n'); fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
console.log(`✅ 已更新 ${updated} 个人格体配置`); console.log(`✅ 已更新 ${updated} 个人格体配置`);