doc-organizer-analyze.mjs 的 TRUTH 基线串 L19 仍写"生成主线=模板驱动", 系 C2 旧框架(LLM 直出 GameConfig+固定模板),已被 HJ-GEN-001 终审 (2026-06-12)整条 supersede;所有 knowledge/架构档均写"agent 写码于插件库"。 基线串是 doc-organizer 检测全仓文档漂移的真相源,写错会反向把正确档判漂移 或漏判旧档,故纠。纯字符串内容改、语法中性(改前后 node --check 同报预存的 顶层 return;L19 串两版均正常解析)。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
90 lines
4.9 KiB
JavaScript
90 lines
4.9 KiB
JavaScript
export const meta = {
|
||
name: 'doc-organizer-analyze',
|
||
description: '文档整理·分析相:按三轴 fan-out 分类窗口内/热目录候选文档,返回结构化处置建议(只读,绝不改文件)',
|
||
phases: [
|
||
{ title: '轴①过期分类', detail: '每候选档判 KEEP/ARCHIVE/COMPRESS/EVICT/DELETE' },
|
||
{ title: '轴②核心档措辞', detail: '每 stale 档逐处判当现行=改/已降级=放过' },
|
||
],
|
||
}
|
||
|
||
// args = { candidates:[{file,lines,type}], staleDocs:[{file,suspect}], ledgerGap }
|
||
// 防御:Workflow 工具有时把 args 当 JSON 字符串透传(非对象)→ 字符串则解析,保证 candidates/staleDocs 取得到。
|
||
let A = args || {}
|
||
if (typeof A === 'string') { try { A = JSON.parse(A) } catch (e) { A = {} } }
|
||
const candidates = Array.isArray(A.candidates) ? A.candidates : []
|
||
const staleDocs = Array.isArray(A.staleDocs) ? A.staleDocs : []
|
||
|
||
// 现行真相基准(与 .agents/knowledge/tech-decisions.md + AGENTS §3 对齐;子代理仍须自读权威源核实)
|
||
const TRUTH =
|
||
'现行真相:生成主线=agent 写码于插件库(HJ-GEN-001 终审 2026-06-12;旧"模板驱动/LLM 直出 GameConfig"已废) via new-api 网关(Dify/OpenGame 降 long-term·MVP 从不部署);' +
|
||
'引擎=LittleJS 增强发行版(55KB gz,勿写13/15KB)+Runner v2(game-host.d.ts),自研 Canvas<15KB 已废;' +
|
||
'模板=LittleJS 插件;游戏模板/填参线已废(W-CLEAN),玩法模板(品类框架·引导生成·非pre-built代码)未废=有效待建但非最高优先级(最高=Tier0生成可靠,玩法模板排其后;HJ-DEMO-AUDIT-001 创始人06-17);agentic=SAA(Spring AI Alibaba GA v1.1.2.2)裸图(HJ-AGI-002),AgentScope 降 long-term;' +
|
||
'美术/音乐=mmx-cli,ComfyUI 退备选;RocketMQ/Nacos=框架自带但 MVP 未部署=future-state(勿删);命名空间=com.wanxiang.huijing;品牌=绘境AI'
|
||
|
||
const CLS = {
|
||
type: 'object',
|
||
required: ['action', 'status', 'rationale'],
|
||
properties: {
|
||
action: { type: 'string', enum: ['KEEP', 'ARCHIVE', 'COMPRESS', 'EVICT', 'DELETE'] },
|
||
status: { type: 'string', enum: ['ACTIVE', 'SHIPPED', 'SUPERSEDED', 'SPIKE-DONE', 'DUP'] },
|
||
pointer: { type: 'string', description: '收口报告/.agents skill/commit/memory/替代档' },
|
||
rationale: { type: 'string', description: '一句话理由' },
|
||
},
|
||
}
|
||
|
||
const STALE = {
|
||
type: 'object',
|
||
required: ['revise', 'findings'],
|
||
properties: {
|
||
revise: { type: 'boolean', description: '是否需改(有把废弃选型当现行的句)' },
|
||
bigRewrite: { type: 'boolean', description: '是否>200行重写/多图重画需先单独出计划' },
|
||
findings: {
|
||
type: 'array',
|
||
items: {
|
||
type: 'object',
|
||
required: ['line', 'verdict'],
|
||
properties: {
|
||
line: { type: 'string', description: '行号或定位' },
|
||
verdict: { type: 'string', enum: ['改', '放过'] },
|
||
fix: { type: 'string', description: 'verdict=改时:现行口径一句' },
|
||
},
|
||
},
|
||
},
|
||
},
|
||
}
|
||
|
||
// 轴① 过期历史档分类(判据=§10/_index;每片自读 head+tail+MEMORY.md+_index.md)
|
||
phase('轴①过期分类')
|
||
const axis1 = await parallel(
|
||
candidates.map((c) => () =>
|
||
agent(
|
||
`只读分类 docs/agent-specs/${c.file}(${c.lines || '?'}行,${c.type || '?'})。` +
|
||
`先读其前45+后25行 + /root/.claude/projects/-root-games-development-ai/memory/MEMORY.md + docs/agent-specs/_index.md。` +
|
||
`判据:review/政策含"为什么"=KEEP或ARCHIVE;execution/edit-plan 一次性=COMPRESS;代码/证据/原始输出=EVICT;机器噪声=DELETE。` +
|
||
`KEEP=仍管当前/未来工作 或 某线唯一 SoT(决策/收口)。绝不改任何文件。`,
|
||
{ label: `cls:${c.file}`, phase: '轴①过期分类', model: 'opus', schema: CLS }
|
||
).then((r) => ({ file: c.file, ...r }))
|
||
)
|
||
)
|
||
|
||
// 轴② 核心设计档措辞对齐(基准=tech-decisions.md+AGENTS §3;事实核查据 contracts/Flyway)
|
||
phase('轴②核心档措辞')
|
||
const axis2 = await parallel(
|
||
staleDocs.map((d) => () =>
|
||
agent(
|
||
`只读审 ${d.file}(${d.suspect || '?'}处疑似)残留废弃选型词。逐处判"把废弃选型当现行架构/默认/MVP在用"=改, "已标降级/future-state/删除线/决策史/甘特蓝图"=放过。` +
|
||
`${TRUTH}。基准先读 .agents/knowledge/tech-decisions.md + AGENTS.md §3。` +
|
||
`事实核查勿臆造:字段名/MQ是否真部署 据 contracts/+DB Flyway 实测,虚构字段才删、规划项标 future-state 勿删。绝不改文件,只产 findings。`,
|
||
{ label: `stale:${d.file}`, phase: '轴②核心档措辞', model: 'opus', schema: STALE }
|
||
).then((r) => ({ file: d.file, ...r }))
|
||
)
|
||
)
|
||
|
||
// 返回结构化结果供主代理编译"清理计划"(主代理写计划档→另派评审子代理→呈创始人审批→批准后才执行)
|
||
return {
|
||
axis1: axis1.filter(Boolean),
|
||
axis2: axis2.filter(Boolean),
|
||
ledgerGap: A.ledgerGap || null,
|
||
note: '本结果仅供编计划;任何归档/压缩/改写须等创始人批准后由阶段二执行',
|
||
}
|