From b524fa2288d2d8b5babaaed7838f5681e1cccb8f Mon Sep 17 00:00:00 2001 From: yibo Date: Sat, 15 Aug 2026 17:16:56 +0800 Subject: [PATCH] fix(company): _registry.json 写入补末尾换行,消除每次写入的伪 diff --- server/routes/company.js | 4 ++-- server/services/company-service.js | 4 ++-- system/templates/_registry.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/routes/company.js b/server/routes/company.js index 1a47852..8d06c12 100644 --- a/server/routes/company.js +++ b/server/routes/company.js @@ -83,7 +83,7 @@ router.patch('/templates/:templateId', (req, res) => { if (name !== undefined) entry.name = name.trim(); if (type !== undefined) entry.type = type.trim(); if (description !== undefined) entry.description = description.trim(); - fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2), 'utf-8'); + fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2) + '\n', 'utf-8'); } } catch {} } @@ -117,7 +117,7 @@ router.delete('/templates/:templateId', (req, res) => { try { let registry = JSON.parse(fs.readFileSync(registryPath, 'utf-8')); registry = registry.filter(t => t.id !== templateId); - fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2), 'utf-8'); + fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2) + '\n', 'utf-8'); } catch {} } diff --git a/server/services/company-service.js b/server/services/company-service.js index e4117c3..5c0f9da 100644 --- a/server/services/company-service.js +++ b/server/services/company-service.js @@ -371,7 +371,7 @@ class CompanyService { trainedAt: new Date().toISOString().slice(0, 10), usedCount: 0, }); - fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2), 'utf-8'); + fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2) + '\n', 'utf-8'); // 将 Agent 状态从 training → active const configPath = path.join(agentDir, 'config.json'); @@ -821,7 +821,7 @@ class CompanyService { const entry = registry.find(t => t.id === templateId); if (entry) { entry.usedCount = (entry.usedCount || 0) + 1; - fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2), 'utf-8'); + fs.writeFileSync(registryPath, JSON.stringify(registry, null, 2) + '\n', 'utf-8'); } } catch (err) { console.warn(`[Company] ⚠️ 更新模板使用次数失败: ${err.message}`); diff --git a/system/templates/_registry.json b/system/templates/_registry.json index 299d914..4103871 100644 --- a/system/templates/_registry.json +++ b/system/templates/_registry.json @@ -15,7 +15,7 @@ "description": "质量验收、OKR 进度审查、标准化仲裁", "benchmarkScore": 95, "trainedAt": "2026-03-25", - "usedCount": 7 + "usedCount": 8 }, { "id": "base", -- libgit2 0.21.4