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",