dsh-harness-kit 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/README.zh-CN.md +3 -3
- package/client.js +46 -11
- package/kernel/commands.js +18 -4
- package/kernel/models.js +1 -0
- package/kernel/panel.js +37 -4
- package/kernel/setup.js +18 -30
- package/package.json +1 -1
- package/packs/ai-coding/agents/project-manager.md +16 -0
- package/packs/ai-coding/assets/scripts/memory_index.py +323 -0
- package/packs/ai-coding/rules/core.md +7 -0
- package/packs/ai-coding/templates/memory-README.md +56 -0
- package/packs/ai-coding/templates/memory-entry.md +6 -0
package/README.md
CHANGED
|
@@ -137,7 +137,7 @@ environment.
|
|
|
137
137
|
### Model cost: spend where it matters
|
|
138
138
|
|
|
139
139
|
Use strong models for design and difficult review, fast models for routine work. The mapping lives
|
|
140
|
-
in `.harness/kit.json
|
|
140
|
+
in `.harness/kit.json`, includes an optional reasoning effort per binding, and is not tied to one provider.
|
|
141
141
|
|
|
142
142
|
### Assets compound, especially solo
|
|
143
143
|
|
|
@@ -234,7 +234,7 @@ go only to the provider you configure.
|
|
|
234
234
|
**Plugins → Add plugin**, then enter:
|
|
235
235
|
|
|
236
236
|
```
|
|
237
|
-
dsh-harness-kit@0.1.
|
|
237
|
+
dsh-harness-kit@0.1.5
|
|
238
238
|
```
|
|
239
239
|
|
|
240
240
|
Enable the bundle after installation.
|
|
@@ -242,7 +242,7 @@ Enable the bundle after installation.
|
|
|
242
242
|
### Command line
|
|
243
243
|
|
|
244
244
|
```sh
|
|
245
|
-
dsh plugin --profile desktop add dsh-harness-kit@0.1.
|
|
245
|
+
dsh plugin --profile desktop add dsh-harness-kit@0.1.5
|
|
246
246
|
```
|
|
247
247
|
|
|
248
248
|
Quit DSH Desktop first; replace `desktop` with your profile name for other profiles.
|
package/README.zh-CN.md
CHANGED
|
@@ -110,7 +110,7 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
|
|
|
110
110
|
|
|
111
111
|
### 模型成本:好钢用在刀刃上
|
|
112
112
|
|
|
113
|
-
方案和难审代码用强模型,样板任务用快模型;映射写在 `.harness/kit.json
|
|
113
|
+
方案和难审代码用强模型,样板任务用快模型;映射写在 `.harness/kit.json`,可给每条绑定设置推理等级,不绑死某个 provider。
|
|
114
114
|
|
|
115
115
|
### 资产沉淀:一个人用尤其明显
|
|
116
116
|
|
|
@@ -200,7 +200,7 @@ AI 写得越快,需要看的越多。固定角色让 CR/TE 各自只做一件
|
|
|
200
200
|
**Plugins → Add plugin**,输入:
|
|
201
201
|
|
|
202
202
|
```
|
|
203
|
-
dsh-harness-kit@0.1.
|
|
203
|
+
dsh-harness-kit@0.1.5
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
安装后启用 bundle。
|
|
@@ -208,7 +208,7 @@ dsh-harness-kit@0.1.4
|
|
|
208
208
|
### 命令行
|
|
209
209
|
|
|
210
210
|
```sh
|
|
211
|
-
dsh plugin --profile desktop add dsh-harness-kit@0.1.
|
|
211
|
+
dsh plugin --profile desktop add dsh-harness-kit@0.1.5
|
|
212
212
|
```
|
|
213
213
|
|
|
214
214
|
需要先完全退出 DSH Desktop;其他 profile 把 `desktop` 换成实际名称。
|
package/client.js
CHANGED
|
@@ -849,14 +849,31 @@ window.__ModuleLoader__.load({
|
|
|
849
849
|
function ConfigView({ config, syncMeta, ws, busy, saveConfig, runInit, onOrchestrate, catalog, toast }) {
|
|
850
850
|
const k = config.kit;
|
|
851
851
|
const initGap = (ws?.attention ?? []).find((a) => a.kind === 'init-incomplete') ?? null;
|
|
852
|
+
const modelEntry = (provider, model) => (catalog ?? [])
|
|
853
|
+
.find((c) => c.provider === (provider || ''))?.models?.find((mo) => mo.id === model);
|
|
854
|
+
const reasoningEfforts = (provider, model) => modelEntry(provider, model)?.reasoning?.efforts ?? [];
|
|
855
|
+
// 默认 low:模型声明支持 low 时用它;不支持时回退该模型自己的默认(不硬塞一个
|
|
856
|
+
// 它不认识的等级,DSH 会在派发前拒绝 unsupported explicit effort)。
|
|
857
|
+
const defaultEffort = (provider, model) => {
|
|
858
|
+
const efforts = reasoningEfforts(provider, model);
|
|
859
|
+
if (efforts.some((e) => e.id === 'low')) return 'low';
|
|
860
|
+
return modelEntry(provider, model)?.reasoning?.defaultEffort ?? '';
|
|
861
|
+
};
|
|
862
|
+
const providerMissing = (m) => !!m.provider && (catalog ?? []).length > 0 && !(catalog ?? []).some((c) => c.provider === m.provider);
|
|
863
|
+
const toModelRow = (name, m) => ({
|
|
864
|
+
name,
|
|
865
|
+
provider: m.provider ?? '',
|
|
866
|
+
model: m.model ?? '',
|
|
867
|
+
reasoning_effort: m.reasoning_effort ?? defaultEffort(m.provider ?? '', m.model ?? ''),
|
|
868
|
+
});
|
|
852
869
|
const [branches, setBranches] = useState(() => Object.fromEntries((k.sources ?? []).map((s) => [s.name, s.branch ?? ''])));
|
|
853
870
|
const [autoSync, setAutoSync] = useState(k.assets?.autoSync === true);
|
|
854
|
-
const [models, setModels] = useState(() => Object.entries(k.models ?? {}).map(([name, m]) => (
|
|
871
|
+
const [models, setModels] = useState(() => Object.entries(k.models ?? {}).map(([name, m]) => toModelRow(name, m)));
|
|
855
872
|
const [applyMode, setApplyMode] = useState(k.applyMode ?? 'auto');
|
|
856
873
|
useEffect(() => {
|
|
857
874
|
setBranches(Object.fromEntries((k.sources ?? []).map((s) => [s.name, s.branch ?? ''])));
|
|
858
875
|
setAutoSync(k.assets?.autoSync === true);
|
|
859
|
-
setModels(Object.entries(k.models ?? {}).map(([name, m]) => (
|
|
876
|
+
setModels(Object.entries(k.models ?? {}).map(([name, m]) => toModelRow(name, m)));
|
|
860
877
|
setApplyMode(k.applyMode ?? 'auto');
|
|
861
878
|
}, [ws.id]);
|
|
862
879
|
const kv = (label, value) => h('div', { style: S.kv }, h('span', { style: { color: V.sub, minWidth: 96 } }, label), h('span', null, value ?? '—'));
|
|
@@ -923,7 +940,9 @@ window.__ModuleLoader__.load({
|
|
|
923
940
|
h('div', { style: S.section },
|
|
924
941
|
h('div', { style: S.secTitle }, 'Worker 模型映射'),
|
|
925
942
|
h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
|
|
926
|
-
'
|
|
943
|
+
'键支持角色名(优先)或逻辑名(fast / coding / reasoning);未配置的角色走会话默认。'),
|
|
944
|
+
h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } },
|
|
945
|
+
'推理等级随模型能力变化;新增默认 low,模型不支持时用该模型默认。'),
|
|
927
946
|
models.length === 0 && h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } }, '尚未配置,全部角色走默认模型'),
|
|
928
947
|
models.map((m, i) => h('div', { key: i, style: { display: 'flex', gap: 6, marginBottom: 6, alignItems: 'center' } },
|
|
929
948
|
// 角色名下拉:流程角色(BA/SA/Dev/CR/TE 等,宿主扫 agents/ 目录)+ 已映射的逻辑模型名 + 自由输入
|
|
@@ -940,28 +959,44 @@ window.__ModuleLoader__.load({
|
|
|
940
959
|
h('select', {
|
|
941
960
|
style: { ...S.select, width: 110 },
|
|
942
961
|
value: m.provider ?? '',
|
|
943
|
-
onChange: (e) => setModels(models.map((x, j) => j === i ? { ...x, provider: e.target.value, model: '' } : x)),
|
|
962
|
+
onChange: (e) => setModels(models.map((x, j) => j === i ? { ...x, provider: e.target.value, model: '', reasoning_effort: '' } : x)),
|
|
944
963
|
}, [
|
|
945
964
|
h('option', { key: '', value: '' }, '(会话默认)'),
|
|
946
|
-
...(m.provider && !(catalog ?? []).some((c) => c.provider === m.provider)
|
|
947
|
-
? [h('option', { key: '__missing', value: m.provider }, `⚠ ${m.provider}(不可用)`)] : []),
|
|
948
965
|
...(catalog ?? []).map((c) => h('option', { key: c.provider, value: c.provider }, c.provider)),
|
|
949
966
|
]),
|
|
967
|
+
providerMissing(m) && h('span', { style: { fontSize: 11, color: V.warn } }, '原 provider 不可用,请重选'),
|
|
950
968
|
// model 下拉:所选 provider 的模型清单 + 自由输入
|
|
951
969
|
h(Combobox, {
|
|
952
970
|
style: { flex: 1 },
|
|
953
971
|
value: m.model, placeholder: 'model',
|
|
954
972
|
options: (catalog ?? []).find((c) => c.provider === (m.provider || ''))?.models?.map((mo) => mo.id) ?? [],
|
|
955
|
-
onChange: (v) => setModels(models.map((x, j) => j === i ? { ...x, model: v } : x)),
|
|
973
|
+
onChange: (v) => setModels(models.map((x, j) => j === i ? { ...x, model: v, reasoning_effort: defaultEffort(x.provider, v) } : x)),
|
|
956
974
|
}),
|
|
975
|
+
// 推理等级:选项来自当前模型能力;不同厂商不是同一套枚举(DeepSeek off/low/high/max,
|
|
976
|
+
// 其他模型可能 minimal/low/medium/high 或没有),不在这里硬编码“通用等级”。
|
|
977
|
+
h('select', {
|
|
978
|
+
style: { ...S.select, width: 100 },
|
|
979
|
+
title: m.reasoning_effort ? `reasoning_effort=${m.reasoning_effort}` : '该模型未声明推理等级,使用默认',
|
|
980
|
+
value: m.reasoning_effort ?? '',
|
|
981
|
+
onChange: (e) => setModels(models.map((x, j) => j === i ? { ...x, reasoning_effort: e.target.value } : x)),
|
|
982
|
+
}, [
|
|
983
|
+
h('option', { key: '', value: '' }, '默认'),
|
|
984
|
+
...reasoningEfforts(m.provider, m.model).map((e) => h('option', { key: e.id, value: e.id }, e.name || e.id)),
|
|
985
|
+
...(m.reasoning_effort && !reasoningEfforts(m.provider, m.model).some((e) => e.id === m.reasoning_effort)
|
|
986
|
+
? [h('option', { key: '__missing', value: m.reasoning_effort }, `⚠ ${m.reasoning_effort}`)] : []),
|
|
987
|
+
]),
|
|
957
988
|
h('button', { style: S.iconBtn, title: '删除', onClick: () => setModels(models.filter((_, j) => j !== i)) }, '×'))),
|
|
958
989
|
(catalog ?? []).length === 0 && h('div', { style: { fontSize: 12, color: V.sub, marginBottom: 8 } }, '未发现可用模型清单(宿主未注册 LLM 或接口不可用),仍可手动输入'),
|
|
959
990
|
h('div', { style: { display: 'flex', gap: 8, marginTop: 8 } },
|
|
960
|
-
h('button', { style: S.btn(false), onClick: () => setModels([...models, { name: '', provider: '', model: '' }]) }, '+ 添加映射'),
|
|
991
|
+
h('button', { style: S.btn(false), onClick: () => setModels([...models, { name: '', provider: '', model: '', reasoning_effort: '' }]) }, '+ 添加映射'),
|
|
961
992
|
h('button', {
|
|
962
|
-
style: S.btn(busy || models.some((m) => !m.name.trim() || !m.model.trim()), true),
|
|
963
|
-
disabled: busy || models.some((m) => !m.name.trim() || !m.model.trim()),
|
|
964
|
-
onClick: () => saveConfig({ models: Object.fromEntries(models.map((m) => [m.name.trim(), {
|
|
993
|
+
style: S.btn(busy || models.some((m) => !m.name.trim() || !m.model.trim() || providerMissing(m)), true),
|
|
994
|
+
disabled: busy || models.some((m) => !m.name.trim() || !m.model.trim() || providerMissing(m)),
|
|
995
|
+
onClick: () => saveConfig({ models: Object.fromEntries(models.map((m) => [m.name.trim(), {
|
|
996
|
+
...(m.provider.trim() ? { provider: m.provider.trim() } : {}),
|
|
997
|
+
model: m.model.trim(),
|
|
998
|
+
...(m.reasoning_effort ? { reasoning_effort: m.reasoning_effort } : {}),
|
|
999
|
+
}])) }, '模型映射已保存'),
|
|
965
1000
|
}, '保存'))),
|
|
966
1001
|
// ③ 初始化与子工程(面板化的 /hk-init、/hk-setup --add)
|
|
967
1002
|
h('div', { style: S.section },
|
package/kernel/commands.js
CHANGED
|
@@ -754,11 +754,13 @@ async function hkArchive({ agent, rawInput }) {
|
|
|
754
754
|
'',
|
|
755
755
|
'## 2. Memory Merge',
|
|
756
756
|
`- 从 \`_archive/${task}/\` 本轮各文档(dev-log / test-report / code-review)提取可复用踩坑与经验,并入 \`.harness/memory/\``,
|
|
757
|
-
'- **每条新条目必须遵循
|
|
758
|
-
'-
|
|
757
|
+
'- **每条新条目必须遵循 `.harness/memory/templates/entry.md`**:文件名 `YYYY-MM-DD_<scope>_<slug>.md`,frontmatter 含 id/date/scope/tags(建议补 areas/symptoms/pinned),正文含症状/根因/修复/防复发/复发检测;tooling/infra/shared 类必须含「流程优化排除」节',
|
|
758
|
+
'- 不再手写 `memory/index.md`:新增/修改 entry 后运行 `python3 .harness/scripts/memory_index.py sync` 重建 hot/cold 索引;默认 hot 只读,cold 仅在 hot 无匹配时搜索',
|
|
759
|
+
'- 归档时执行一次自动降温:`python3 .harness/scripts/memory_index.py cool --days 60 --max-hot 30 --apply`,再运行 `check`;cold 只移出默认上下文,不删除条目',
|
|
760
|
+
'- 本轮实际读取并起作用的 memory,运行 `python3 .harness/scripts/memory_index.py touch <id>` 提升/保活;高风险条目在 frontmatter 标 `pinned: true`',
|
|
759
761
|
'- 流程优先决策门:若经验属于 tooling/infra/shared 级,应改 harness 资产本身(模板/角色/流程定义),而不是只写记忆',
|
|
760
762
|
'',
|
|
761
|
-
'
|
|
763
|
+
'完成后向人汇报两个合并的结果清单(含 hot/cold 数量)。',
|
|
762
764
|
].join('\n');
|
|
763
765
|
steer(agent, mergePrompt);
|
|
764
766
|
mergeNote = 'Spec/Memory Merge 收尾剧本已提交 PM(基于归档段执行);';
|
|
@@ -898,8 +900,9 @@ async function hkDoctor({ agent }) {
|
|
|
898
900
|
'scripts/harness_init.py', 'scripts/harness.py', 'scripts/lib.py',
|
|
899
901
|
'scripts/verify.py', 'scripts/spec_lint.py', 'scripts/env_auto.py',
|
|
900
902
|
'scripts/check_codegraph.py', 'scripts/run_field.py', 'scripts/codebase_guide_init.py',
|
|
901
|
-
'scripts/update_board.py',
|
|
903
|
+
'scripts/update_board.py', 'scripts/memory_index.py',
|
|
902
904
|
'rules/code-standards.md', 'specs/spec-template.md', 'memory/templates/entry.md',
|
|
905
|
+
'memory/README.md', 'memory/cold.md',
|
|
903
906
|
];
|
|
904
907
|
const missing = assetChecks.filter((rel) => !fs.existsSync(path.join(harnessDir(ws), rel)));
|
|
905
908
|
const templatesOk = fs.existsSync(path.join(harnessDir(ws), 'templates')) && fs.readdirSync(path.join(harnessDir(ws), 'templates')).length > 0;
|
|
@@ -919,6 +922,17 @@ async function hkDoctor({ agent }) {
|
|
|
919
922
|
lines.push(`- 看板体检:${chk.code === 0 ? '✅ 全行合规' : `❌ 列格式违规 → python3 .harness/scripts/update_board.py --repair --write 修复\n${(chk.stdout || '').trim().split('\n').map((l) => ` ${l}`).join('\n')}`}`);
|
|
920
923
|
}
|
|
921
924
|
}
|
|
925
|
+
// memory hot/cold 索引体检(脚本存在时;老工作区尚未迁移时给出明确提示)
|
|
926
|
+
const memIndex = path.join(harnessDir(ws), 'scripts', 'memory_index.py');
|
|
927
|
+
if (fs.existsSync(memIndex)) {
|
|
928
|
+
if (fs.existsSync(path.join(harnessDir(ws), 'memory', 'index.md')) && fs.existsSync(path.join(harnessDir(ws), 'memory', 'cold.md'))) {
|
|
929
|
+
const mc = await run('python3', [memIndex, 'check'], { cwd: ws, timeoutMs: 15_000 });
|
|
930
|
+
lines.push(`- 记忆 hot/cold 索引:${mc.code === 0 ? `✅ ${(mc.stdout || '').trim()}` : `❌ ${(mc.stdout || mc.stderr || '').trim()}`}`);
|
|
931
|
+
} else {
|
|
932
|
+
lines.push('- 记忆 hot/cold 索引:⚠️ 尚未迁移(缺 memory/index.md 或 cold.md),运行 `/hk-init` 后执行 `python3 .harness/scripts/memory_index.py sync`');
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
922
936
|
// pack 管理运行时漂移:scripts 内容与 pack 不一致 → 重跑 /hk-init 刷新(scripts 不入库,漂移只来自手改或 pack 升级后未刷新)
|
|
923
937
|
const packScripts = path.join(packDir(kit), 'assets', 'scripts');
|
|
924
938
|
const wsScripts = path.join(harnessDir(ws), 'scripts');
|
package/kernel/models.js
CHANGED
|
@@ -82,6 +82,7 @@ export function dispatchSection(kit, workers) {
|
|
|
82
82
|
'- Worker/subagent 一律用 subagent 工具派发:prompt 自包含(任务背景 + handoff 路径 + 产出路径 + 读写范围约束;阶段指定 Worker 角色时另需先读角色文件并内嵌定义全文)。',
|
|
83
83
|
'- 派发前更新 `handoff.md` 的「读取清单」;Worker 只读 handoff + 清单中的章节,不整份重读 requirements/design/spec。',
|
|
84
84
|
'- 等待纪律:优先结束当前回合,靠子代理完成通知继续;必须阻塞时只调用一次 `wait_agent`(timeout_ms ≤ 3600000),禁止 5 分钟轮询,禁止用 send_message 问进度。',
|
|
85
|
+
'- 编排噪音:看板只在阶段边界写;相关 git status/log/branch 合并成一条 bash;日志只取失败摘要,不整段回贴。',
|
|
85
86
|
'- Worker 产物写入活目录对应文件;Worker 只能写其 write_scopes 声明的范围。',
|
|
86
87
|
'- 任何时候信息不足或口径模糊:先向人反问,不要自行补全。',
|
|
87
88
|
'',
|
package/kernel/panel.js
CHANGED
|
@@ -304,7 +304,7 @@ export function parseGitLog(text) {
|
|
|
304
304
|
|
|
305
305
|
/**
|
|
306
306
|
* 受控更新 kit.json(M4b 配置视图第 2 层)。
|
|
307
|
-
* patch: { sources?: [{name, branch}], autoSync?: boolean, models?: {logical: {provider?, model}} }
|
|
307
|
+
* patch: { sources?: [{name, branch}], autoSync?: boolean, models?: {logical: {provider?, model, reasoning_effort?}} }
|
|
308
308
|
* 返回 { ok: true, kit } 或 { error }。
|
|
309
309
|
*/
|
|
310
310
|
export function updateKit(ws, patch) {
|
|
@@ -340,13 +340,25 @@ export function updateKit(ws, patch) {
|
|
|
340
340
|
for (const [k, v] of Object.entries(patch.models)) {
|
|
341
341
|
if (v == null) continue; // null = 删除映射
|
|
342
342
|
if (typeof v !== 'object' || typeof v.model !== 'string' || !v.model.trim()) {
|
|
343
|
-
return { error: `models.${k} 需为 {provider?, model}` };
|
|
343
|
+
return { error: `models.${k} 需为 {provider?, model, reasoning_effort?}` };
|
|
344
|
+
}
|
|
345
|
+
if (v.reasoning_effort !== undefined && v.reasoning_effort !== null
|
|
346
|
+
&& (typeof v.reasoning_effort !== 'string' || !v.reasoning_effort.trim())) {
|
|
347
|
+
return { error: `models.${k}.reasoning_effort 必须是非空字符串` };
|
|
344
348
|
}
|
|
345
349
|
}
|
|
346
350
|
kit.models = kit.models ?? {};
|
|
347
351
|
for (const [k, v] of Object.entries(patch.models)) {
|
|
348
352
|
if (v == null) delete kit.models[k];
|
|
349
|
-
else
|
|
353
|
+
else {
|
|
354
|
+
const previous = kit.models[k] ?? {};
|
|
355
|
+
const next = { ...(v.provider ? { provider: v.provider } : {}), model: v.model.trim() };
|
|
356
|
+
const effort = v.reasoning_effort !== undefined
|
|
357
|
+
? (v.reasoning_effort == null ? '' : v.reasoning_effort.trim())
|
|
358
|
+
: (previous.reasoning_effort ?? '');
|
|
359
|
+
if (effort) next.reasoning_effort = effort;
|
|
360
|
+
kit.models[k] = next;
|
|
361
|
+
}
|
|
350
362
|
}
|
|
351
363
|
}
|
|
352
364
|
writeKit(ws, kit);
|
|
@@ -438,7 +450,28 @@ export async function listModelCatalog(llm) {
|
|
|
438
450
|
for (const p of providers) {
|
|
439
451
|
let models = [];
|
|
440
452
|
try { models = (await llm.listModels?.(p.id)) ?? []; } catch { /* 单 provider 失败不拖垮整体 */ }
|
|
441
|
-
|
|
453
|
+
const resolved = [];
|
|
454
|
+
for (const m of models) {
|
|
455
|
+
let info = null;
|
|
456
|
+
// 推理等级是模型能力,不是全局枚举:DeepSeek 是 off/low/high/max,
|
|
457
|
+
// 其他厂商可能是 minimal/low/medium/high 或没有推理等级。只透传宿主
|
|
458
|
+
// resolveModelInfo 返回的 efforts,不在前端硬编码一个“通用”列表。
|
|
459
|
+
if (typeof llm.resolveModelInfo === 'function') {
|
|
460
|
+
try { info = await llm.resolveModelInfo(p.id, m.id); } catch { /* 单模型探测失败不拖垮整体 */ }
|
|
461
|
+
}
|
|
462
|
+
const reasoning = info?.reasoning && Array.isArray(info.reasoning.efforts) && info.reasoning.efforts.length > 0
|
|
463
|
+
? {
|
|
464
|
+
defaultEffort: info.reasoning.defaultEffort ?? null,
|
|
465
|
+
efforts: info.reasoning.efforts.map((e) => ({
|
|
466
|
+
id: e.id,
|
|
467
|
+
name: e.name ?? e.id,
|
|
468
|
+
description: e.description ?? '',
|
|
469
|
+
})),
|
|
470
|
+
}
|
|
471
|
+
: null;
|
|
472
|
+
resolved.push({ id: m.id, name: m.name ?? m.id, reasoning });
|
|
473
|
+
}
|
|
474
|
+
out.push({ provider: p.id, name: p.name ?? p.id, models: resolved });
|
|
442
475
|
}
|
|
443
476
|
return out;
|
|
444
477
|
} catch { return []; }
|
package/kernel/setup.js
CHANGED
|
@@ -232,44 +232,31 @@ export async function runInit(ws, { assets, branch, sources = [], onProgress } =
|
|
|
232
232
|
}
|
|
233
233
|
for (const [file, content] of [
|
|
234
234
|
['tasks/board.md', boardTemplate()],
|
|
235
|
-
// memory/index.md
|
|
235
|
+
// memory/index.md 只是 hot 路由表;规则/写入纪律在 memory/README.md,cold 默认不读。
|
|
236
236
|
['memory/index.md', [
|
|
237
|
-
'#
|
|
237
|
+
'# 工程记忆索引(hot)',
|
|
238
238
|
'',
|
|
239
|
-
'>
|
|
239
|
+
'> 默认只读本文件;cold 索引见 `cold.md`,仅在 hot 无匹配时按需搜索。',
|
|
240
|
+
'> 规则、写入纪律与降温阈值见 `README.md`;条目全文在 `entries/`。',
|
|
240
241
|
'',
|
|
241
|
-
'##
|
|
242
|
+
'## hot 条目',
|
|
242
243
|
'',
|
|
243
|
-
'|
|
|
244
|
-
'
|
|
245
|
-
'
|
|
246
|
-
'| id | `M-YYYYMMDD-<scope>-<slug>` | `M-20260422-shared-pm-heartbeat-drift` | 写在 frontmatter,不随文件名改 |',
|
|
247
|
-
'| scope | 六选一 | backend / frontend / mobile / tooling / infra / shared | 不许自造;跨多域优先 shared |',
|
|
248
|
-
'| slug | 描述根因/机制 | `pagination-limit-nan` | 不要描述现象(如 `list-broken`) |',
|
|
249
|
-
'| tags | YAML 数组 | `[pagination, env, NaN]` | 3-5 个关键词 |',
|
|
244
|
+
'| scope | tags | 症状 / 触发 | entry |',
|
|
245
|
+
'|---|---|---|---|',
|
|
246
|
+
'<!-- 由 memory_index.py sync 生成/更新,勿手写 -->',
|
|
250
247
|
'',
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
'
|
|
254
|
-
'',
|
|
255
|
-
'| 写 | 不写 |',
|
|
256
|
-
'|----|------|',
|
|
257
|
-
'| CR REJECT / TE FAIL(实现层 bug) | 一次通过、0 REJECT/FAIL 的任务 |',
|
|
258
|
-
'| 开发中踩坑 ≥2 次尝试才解决 | 需求/方案本身错(应反馈到 proposal) |',
|
|
259
|
-
'| OS/依赖/配置类坑(有强复现性) | 同一任务内反复调试小细节(如 CSS 间距) |',
|
|
260
|
-
'| 编排层出现漂移(PM/Agent 契约不一致) | 没踩坑就没有经验要沉淀 |',
|
|
261
|
-
'',
|
|
262
|
-
'## 流程优先决策门(tooling / infra / shared 三类专属)',
|
|
248
|
+
].join('\n')],
|
|
249
|
+
['memory/cold.md', [
|
|
250
|
+
'# 工程记忆冷索引(cold)',
|
|
263
251
|
'',
|
|
264
|
-
'>
|
|
265
|
-
'>
|
|
266
|
-
'> 只有外部依赖/第三方行为/平台固有语义改不掉的,才写条目,且正文必须含「流程优化排除」节说明理由。',
|
|
252
|
+
'> 默认不读。hot 无匹配时,按 scope/tags/symptom 搜索本文件,再读命中的 entry。',
|
|
253
|
+
'> 条目文件仍在 `entries/`,不删除;使用后运行 `memory_index.py touch <id>` 提升回 hot。',
|
|
267
254
|
'',
|
|
268
|
-
'##
|
|
255
|
+
'## cold 条目',
|
|
269
256
|
'',
|
|
270
|
-
'|
|
|
271
|
-
'
|
|
272
|
-
'<!--
|
|
257
|
+
'| scope | tags | 症状 / 触发 | entry |',
|
|
258
|
+
'|---|---|---|---|',
|
|
259
|
+
'<!-- 由 memory_index.py sync 生成/更新,勿手写 -->',
|
|
273
260
|
'',
|
|
274
261
|
].join('\n')],
|
|
275
262
|
['codebase-guide/index.md', [
|
|
@@ -417,6 +404,7 @@ export async function runInit(ws, { assets, branch, sources = [], onProgress } =
|
|
|
417
404
|
// 1b. 内容包模板/规则物化(spec/memory 格式契约 + 跨端编码底线;create-only)
|
|
418
405
|
for (const [file, tpl] of [
|
|
419
406
|
['memory/templates/entry.md', 'memory-entry.md'],
|
|
407
|
+
['memory/README.md', 'memory-README.md'],
|
|
420
408
|
['specs/spec-template.md', 'spec-template.md'],
|
|
421
409
|
]) {
|
|
422
410
|
const abs = path.join(hd, file);
|
package/package.json
CHANGED
|
@@ -116,6 +116,14 @@ LOG_FILE=<仓库根绝对路径>/.harness/.logs/<TASK_NAME>/worker-<role>.log
|
|
|
116
116
|
|
|
117
117
|
模板见 `.harness/templates/handoff.md`(`/hk-init` 物化到工作区)。
|
|
118
118
|
|
|
119
|
+
## Memory 读取纪律(2026-11-19 定)
|
|
120
|
+
|
|
121
|
+
- 默认只读 `memory/index.md`(hot);cold 只在 hot 无强匹配、或明确排查历史问题时搜索。
|
|
122
|
+
- 匹配条件:`scope` 精确匹配,并且 `tags` / `areas` / `symptoms` 至少命中一项;不要 scope 对了就加载全部。
|
|
123
|
+
- 单任务最多读 3 条 memory;超过时由 PM 选最相关,记录到 `handoff.md` 的「使用的资产」。
|
|
124
|
+
- 实际读取并起作用的条目,归档时用 `python3 .harness/scripts/memory_index.py touch <id>` 保活/提升回 hot。
|
|
125
|
+
- 高风险但低频的条目在 frontmatter 标 `pinned: true`,不参与自动降温。
|
|
126
|
+
|
|
119
127
|
## 子代理等待纪律(2026-11-19 定)
|
|
120
128
|
|
|
121
129
|
- 派发后优先结束当前回合,靠子代理完成通知继续;只有串行依赖必须阻塞时才等待。
|
|
@@ -123,6 +131,13 @@ LOG_FILE=<仓库根绝对路径>/.harness/.logs/<TASK_NAME>/worker-<role>.log
|
|
|
123
131
|
- 禁止用 `send_message` 问「进度如何/完成了吗」;完成会自动通知。只有补充信息才发消息。
|
|
124
132
|
- 超时后先做独立工作或向人汇报,不得连续重新 poll;等待期间不重复更新看板。
|
|
125
133
|
|
|
134
|
+
## 看板与命令批处理纪律(2026-11-19 定)
|
|
135
|
+
|
|
136
|
+
- `update_board.py` 只在阶段边界写:审批通过/打回、Worker 收工、阶段切换、归档。禁止每个工具调用后或每次心跳都刷新看板;同一阶段最多一次。
|
|
137
|
+
- 同一轮相关的 `git status` / `git log` / `git branch` / `ls` 合并成一条 bash;不要对同一状态重复执行相同命令。
|
|
138
|
+
- 日志只看摘要:用 `tail`/`grep` 取失败行或最后几行,不整段回贴;测试命令一次跑完,不反复轮询。
|
|
139
|
+
- PM 心跳保持现状(本次不调整心跳频率)。
|
|
140
|
+
|
|
126
141
|
## Propose 与 Apply 调度模式
|
|
127
142
|
|
|
128
143
|
| 阶段 | 模式 | 理由 |
|
|
@@ -143,6 +158,7 @@ apply-mode 决定 CR PASS 后是否进入人工审查点:
|
|
|
143
158
|
|
|
144
159
|
- `deliverables/<任务名>/proposal.md` — 人机协作定稿的标准化提案
|
|
145
160
|
- `.harness/specs/_index.md` — 系统能力索引
|
|
161
|
+
- `.harness/memory/index.md` — hot 记忆索引;cold 仅在 hot 无匹配时搜索,默认不读
|
|
146
162
|
- `codebase-guide/overview.md` — 项目架构总览
|
|
147
163
|
- `tasks/board.md` — 任务看板
|
|
148
164
|
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Maintain the hot/cold memory indexes.
|
|
3
|
+
|
|
4
|
+
The entries are the source of truth; index.md (hot) and cold.md are generated
|
|
5
|
+
routing tables. Cooling never deletes an entry: it moves the entry out of the
|
|
6
|
+
default hot index while keeping the full document searchable.
|
|
7
|
+
|
|
8
|
+
Usage:
|
|
9
|
+
memory_index.py sync [--root PATH]
|
|
10
|
+
memory_index.py cool --days 60 --max-hot 30 [--apply] [--root PATH]
|
|
11
|
+
memory_index.py promote <id> [--root PATH]
|
|
12
|
+
memory_index.py touch <id> [--root PATH]
|
|
13
|
+
memory_index.py check [--root PATH]
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import argparse
|
|
18
|
+
import datetime as _dt
|
|
19
|
+
import os
|
|
20
|
+
import re
|
|
21
|
+
import sys
|
|
22
|
+
from pathlib import Path
|
|
23
|
+
|
|
24
|
+
SCOPES = ("backend", "frontend", "mobile", "tooling", "infra", "shared")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def memory_root(args) -> Path:
|
|
28
|
+
if getattr(args, "root", None):
|
|
29
|
+
return Path(args.root).resolve()
|
|
30
|
+
return Path(__file__).resolve().parents[1] / "memory"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def split_frontmatter(text: str):
|
|
34
|
+
if not text.startswith("---"):
|
|
35
|
+
return {}, text
|
|
36
|
+
m = re.match(r"^---\s*\n(.*?)\n---\s*\n?", text, re.S)
|
|
37
|
+
if not m:
|
|
38
|
+
return {}, text
|
|
39
|
+
fm_text = m.group(1)
|
|
40
|
+
fm = {}
|
|
41
|
+
for line in fm_text.splitlines():
|
|
42
|
+
if ":" not in line or line.lstrip().startswith("#"):
|
|
43
|
+
continue
|
|
44
|
+
key, val = line.split(":", 1)
|
|
45
|
+
fm[key.strip()] = val.strip()
|
|
46
|
+
return fm, text[m.end():]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def parse_list(value: str):
|
|
50
|
+
value = (value or "").strip()
|
|
51
|
+
if value.startswith("[") and value.endswith("]"):
|
|
52
|
+
value = value[1:-1]
|
|
53
|
+
return [x.strip().strip("'\"") for x in value.split(",") if x.strip()]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def parse_bool(value: str) -> bool:
|
|
57
|
+
return str(value).strip().lower() in ("1", "true", "yes", "y")
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def parse_date(value: str):
|
|
61
|
+
value = (value or "").strip().strip("'\"")
|
|
62
|
+
try:
|
|
63
|
+
return _dt.date.fromisoformat(value[:10])
|
|
64
|
+
except (ValueError, TypeError):
|
|
65
|
+
return None
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def set_frontmatter(path: Path, updates: dict) -> None:
|
|
69
|
+
text = path.read_text(encoding="utf-8")
|
|
70
|
+
if not text.startswith("---"):
|
|
71
|
+
text = "---\n---\n" + text
|
|
72
|
+
m = re.match(r"^---\s*\n(.*?)\n---\s*\n?", text, re.S)
|
|
73
|
+
if not m:
|
|
74
|
+
raise SystemExit(f"bad frontmatter: {path}")
|
|
75
|
+
body = text[m.end():]
|
|
76
|
+
lines = m.group(1).splitlines()
|
|
77
|
+
rendered = {}
|
|
78
|
+
for key, value in updates.items():
|
|
79
|
+
if isinstance(value, bool):
|
|
80
|
+
rendered[key] = "true" if value else "false"
|
|
81
|
+
elif isinstance(value, (list, tuple)):
|
|
82
|
+
rendered[key] = "[" + ", ".join(str(x) for x in value) + "]"
|
|
83
|
+
else:
|
|
84
|
+
rendered[key] = str(value)
|
|
85
|
+
seen = set()
|
|
86
|
+
out = []
|
|
87
|
+
for line in lines:
|
|
88
|
+
key = line.split(":", 1)[0].strip() if ":" in line else ""
|
|
89
|
+
if key in rendered:
|
|
90
|
+
out.append(f"{key}: {rendered[key]}")
|
|
91
|
+
seen.add(key)
|
|
92
|
+
else:
|
|
93
|
+
out.append(line)
|
|
94
|
+
for key, value in rendered.items():
|
|
95
|
+
if key not in seen:
|
|
96
|
+
out.append(f"{key}: {value}")
|
|
97
|
+
path.write_text("---\n" + "\n".join(out) + "\n---\n" + body, encoding="utf-8")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def load_entries(root: Path):
|
|
101
|
+
entries = []
|
|
102
|
+
for path in sorted((root / "entries").glob("*.md")):
|
|
103
|
+
text = path.read_text(encoding="utf-8")
|
|
104
|
+
fm, body = split_frontmatter(text)
|
|
105
|
+
title = ""
|
|
106
|
+
for line in body.splitlines():
|
|
107
|
+
if line.startswith("# "):
|
|
108
|
+
title = line[2:].strip()
|
|
109
|
+
break
|
|
110
|
+
status = (fm.get("status") or "hot").strip().lower()
|
|
111
|
+
if status not in ("hot", "cold", "retired"):
|
|
112
|
+
status = "hot"
|
|
113
|
+
entries.append({
|
|
114
|
+
"path": path,
|
|
115
|
+
"file": path.name,
|
|
116
|
+
"id": (fm.get("id") or path.stem).strip(),
|
|
117
|
+
"scope": (fm.get("scope") or "shared").strip().lower(),
|
|
118
|
+
"date": (fm.get("date") or "").strip(),
|
|
119
|
+
"tags": parse_list(fm.get("tags", "")),
|
|
120
|
+
"areas": parse_list(fm.get("areas", "")),
|
|
121
|
+
"symptoms": parse_list(fm.get("symptoms", "")),
|
|
122
|
+
"pinned": parse_bool(fm.get("pinned", "")),
|
|
123
|
+
"last_used": (fm.get("last_used") or "").strip(),
|
|
124
|
+
"use_count": int(fm.get("use_count") or 0),
|
|
125
|
+
"status": status,
|
|
126
|
+
"title": title or (fm.get("id") or path.stem),
|
|
127
|
+
})
|
|
128
|
+
return entries
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def cell(value: str, limit: int = 220) -> str:
|
|
132
|
+
value = re.sub(r"\s+", " ", value or "").strip().replace("|", "\\|")
|
|
133
|
+
return value if len(value) <= limit else value[: limit - 1] + "…"
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def render_table(entries):
|
|
137
|
+
lines = ["| scope | tags | 症状 / 触发 | entry |", "|---|---|---|---|"]
|
|
138
|
+
for e in entries:
|
|
139
|
+
tags = ", ".join(e["tags"][:5]) or "—"
|
|
140
|
+
extra = []
|
|
141
|
+
if e["areas"]:
|
|
142
|
+
extra.append("area: " + ", ".join(e["areas"][:3]))
|
|
143
|
+
if e["symptoms"]:
|
|
144
|
+
extra.append("symptom: " + ", ".join(e["symptoms"][:3]))
|
|
145
|
+
symptom = cell(e["title"])
|
|
146
|
+
if extra:
|
|
147
|
+
symptom += "(" + cell("; ".join(extra), 120) + ")"
|
|
148
|
+
lines.append(f"| {cell(e['scope'], 20)} | {cell(tags, 100)} | {symptom} | [link](entries/{e['file']}) |")
|
|
149
|
+
return lines
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def write_indexes(root: Path):
|
|
153
|
+
entries = load_entries(root)
|
|
154
|
+
hot = [e for e in entries if e["status"] == "hot"]
|
|
155
|
+
cold = [e for e in entries if e["status"] == "cold"]
|
|
156
|
+
retired = [e for e in entries if e["status"] == "retired"]
|
|
157
|
+
|
|
158
|
+
def order(items):
|
|
159
|
+
return sorted(items, key=lambda e: (not e["pinned"], e["scope"], e["date"]), reverse=False)
|
|
160
|
+
|
|
161
|
+
hot.sort(key=lambda e: (e["scope"], not e["pinned"], e["date"], e["title"]))
|
|
162
|
+
cold.sort(key=lambda e: (e["scope"], e["date"], e["title"]))
|
|
163
|
+
|
|
164
|
+
hot_lines = [
|
|
165
|
+
"# 工程记忆索引(hot)",
|
|
166
|
+
"",
|
|
167
|
+
"> 默认只读本文件;cold 索引见 `cold.md`,仅在 hot 无匹配时按需搜索。规则与阈值见 `README.md`。",
|
|
168
|
+
f"> hot {len(hot)} 条 · cold {len(cold)} 条 · retired {len(retired)} 条 · 更新 { _dt.date.today().isoformat() }",
|
|
169
|
+
"",
|
|
170
|
+
"## hot 条目",
|
|
171
|
+
"",
|
|
172
|
+
] + render_table(hot) + [""]
|
|
173
|
+
cold_lines = [
|
|
174
|
+
"# 工程记忆冷索引(cold)",
|
|
175
|
+
"",
|
|
176
|
+
"> 默认不读。hot 无匹配时,按 scope/tags/symptom 搜索本文件,再读命中的 entry。",
|
|
177
|
+
f"> cold {len(cold)} 条 · 条目文件仍在 `entries/`,不删除。",
|
|
178
|
+
"",
|
|
179
|
+
"## cold 条目",
|
|
180
|
+
"",
|
|
181
|
+
] + render_table(cold) + [""]
|
|
182
|
+
(root / "index.md").write_text("\n".join(hot_lines), encoding="utf-8")
|
|
183
|
+
(root / "cold.md").write_text("\n".join(cold_lines), encoding="utf-8")
|
|
184
|
+
return hot, cold, retired
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def find_entry(entries, ident: str):
|
|
188
|
+
ident = ident.strip()
|
|
189
|
+
for e in entries:
|
|
190
|
+
if e["id"] == ident or e["file"] == ident or e["file"].startswith(ident):
|
|
191
|
+
return e
|
|
192
|
+
raise SystemExit(f"memory entry not found: {ident}")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def cmd_sync(args):
|
|
196
|
+
root = memory_root(args)
|
|
197
|
+
hot, cold, retired = write_indexes(root)
|
|
198
|
+
print(f"memory indexes synced: hot={len(hot)} cold={len(cold)} retired={len(retired)}")
|
|
199
|
+
return 0
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def cmd_cool(args):
|
|
203
|
+
root = memory_root(args)
|
|
204
|
+
cutoff = _dt.date.today() - _dt.timedelta(days=max(1, args.days))
|
|
205
|
+
entries = load_entries(root)
|
|
206
|
+
candidates = []
|
|
207
|
+
for e in entries:
|
|
208
|
+
if e["status"] != "hot" or e["pinned"]:
|
|
209
|
+
continue
|
|
210
|
+
ref = parse_date(e["last_used"]) or parse_date(e["date"])
|
|
211
|
+
if ref is not None and ref <= cutoff:
|
|
212
|
+
candidates.append(e)
|
|
213
|
+
# Age is the primary signal. If hot is still over budget, cool the oldest
|
|
214
|
+
# non-pinned entries until it fits; pinned entries are never auto-cooled.
|
|
215
|
+
hot = [e for e in entries if e["status"] == "hot"]
|
|
216
|
+
if len(hot) - len(candidates) > args.max_hot:
|
|
217
|
+
rest = [e for e in hot if e not in candidates and not e["pinned"]]
|
|
218
|
+
rest.sort(key=lambda e: (e["date"] or "9999-99-99", e["file"]))
|
|
219
|
+
need = len(hot) - len(candidates) - args.max_hot
|
|
220
|
+
for e in rest[:need]:
|
|
221
|
+
candidates.append(e)
|
|
222
|
+
for e in candidates:
|
|
223
|
+
print(f"COOL {e['scope']:8} {e['date'] or '?':10} {e['file']}")
|
|
224
|
+
if not candidates:
|
|
225
|
+
print(f"no hot entries older than {args.days} days (cutoff {cutoff.isoformat()})")
|
|
226
|
+
return 0
|
|
227
|
+
if args.apply:
|
|
228
|
+
for e in candidates:
|
|
229
|
+
set_frontmatter(e["path"], {"status": "cold"})
|
|
230
|
+
write_indexes(root)
|
|
231
|
+
print(f"applied: moved {len(candidates)} entries to cold")
|
|
232
|
+
else:
|
|
233
|
+
print("dry-run: pass --apply to move them to cold")
|
|
234
|
+
return 0
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def cmd_promote(args):
|
|
238
|
+
root = memory_root(args)
|
|
239
|
+
entries = load_entries(root)
|
|
240
|
+
e = find_entry(entries, args.id)
|
|
241
|
+
set_frontmatter(e["path"], {"status": "hot", "last_used": _dt.date.today().isoformat()})
|
|
242
|
+
write_indexes(root)
|
|
243
|
+
print(f"promoted: {e['id']}")
|
|
244
|
+
return 0
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def cmd_touch(args):
|
|
248
|
+
root = memory_root(args)
|
|
249
|
+
entries = load_entries(root)
|
|
250
|
+
e = find_entry(entries, args.id)
|
|
251
|
+
set_frontmatter(e["path"], {
|
|
252
|
+
"status": "hot",
|
|
253
|
+
"last_used": _dt.date.today().isoformat(),
|
|
254
|
+
"use_count": e["use_count"] + 1,
|
|
255
|
+
})
|
|
256
|
+
write_indexes(root)
|
|
257
|
+
print(f"touched: {e['id']} (use_count={e['use_count'] + 1})")
|
|
258
|
+
return 0
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
def cmd_check(args):
|
|
262
|
+
root = memory_root(args)
|
|
263
|
+
entries = load_entries(root)
|
|
264
|
+
errors = []
|
|
265
|
+
ids = {}
|
|
266
|
+
for e in entries:
|
|
267
|
+
if e["id"] in ids:
|
|
268
|
+
errors.append(f"duplicate id: {e['id']} ({ids[e['id']]} / {e['file']})")
|
|
269
|
+
ids[e["id"]] = e["file"]
|
|
270
|
+
indexed = {}
|
|
271
|
+
for name in ("index.md", "cold.md"):
|
|
272
|
+
path = root / name
|
|
273
|
+
if not path.exists():
|
|
274
|
+
errors.append(f"missing index: {name}")
|
|
275
|
+
continue
|
|
276
|
+
text = path.read_text(encoding="utf-8")
|
|
277
|
+
for rel in re.findall(r"\(entries/([^)]+\.md)\)", text):
|
|
278
|
+
if not (root / "entries" / rel).is_file():
|
|
279
|
+
errors.append(f"broken link in {name}: {rel}")
|
|
280
|
+
if rel in indexed:
|
|
281
|
+
errors.append(f"entry appears in both indexes: {rel}")
|
|
282
|
+
indexed[rel] = name
|
|
283
|
+
for e in entries:
|
|
284
|
+
if e["status"] != "retired" and e["file"] not in indexed:
|
|
285
|
+
errors.append(f"entry missing from indexes: {e['file']}")
|
|
286
|
+
hot = [e for e in entries if e["status"] == "hot"]
|
|
287
|
+
if len(hot) > args.max_hot:
|
|
288
|
+
errors.append(f"hot index has {len(hot)} entries (max {args.max_hot})")
|
|
289
|
+
if errors:
|
|
290
|
+
print("memory index check FAILED")
|
|
291
|
+
for item in errors:
|
|
292
|
+
print(" -", item)
|
|
293
|
+
return 1
|
|
294
|
+
print(f"memory index check PASS (hot={len(hot)} cold={len([e for e in entries if e['status'] == 'cold'])} entries={len(entries)})")
|
|
295
|
+
return 0
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
def main(argv=None):
|
|
299
|
+
parser = argparse.ArgumentParser(description=__doc__)
|
|
300
|
+
parser.add_argument("--root", help="memory directory (default: .harness/memory next to this script)")
|
|
301
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
302
|
+
p = sub.add_parser("sync", help="regenerate index.md/cold.md from frontmatter")
|
|
303
|
+
p.set_defaults(func=cmd_sync)
|
|
304
|
+
p = sub.add_parser("cool", help="move old unused hot entries to cold")
|
|
305
|
+
p.add_argument("--days", type=int, default=60)
|
|
306
|
+
p.add_argument("--max-hot", type=int, default=30)
|
|
307
|
+
p.add_argument("--apply", action="store_true")
|
|
308
|
+
p.set_defaults(func=cmd_cool)
|
|
309
|
+
p = sub.add_parser("promote", help="move an entry back to hot")
|
|
310
|
+
p.add_argument("id")
|
|
311
|
+
p.set_defaults(func=cmd_promote)
|
|
312
|
+
p = sub.add_parser("touch", help="record use and keep an entry hot")
|
|
313
|
+
p.add_argument("id")
|
|
314
|
+
p.set_defaults(func=cmd_touch)
|
|
315
|
+
p = sub.add_parser("check", help="validate entries and indexes")
|
|
316
|
+
p.add_argument("--max-hot", type=int, default=30)
|
|
317
|
+
p.set_defaults(func=cmd_check)
|
|
318
|
+
args = parser.parse_args(argv)
|
|
319
|
+
return args.func(args)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
if __name__ == "__main__":
|
|
323
|
+
raise SystemExit(main())
|
|
@@ -101,3 +101,10 @@ Bootstrap 阶段 PM 调度阶段
|
|
|
101
101
|
- **工具输出只留结论**:测试/构建日志用 `tail`/`grep` 取失败摘要;不要把整段日志或整份报告贴回上下文。
|
|
102
102
|
- **交接摘要代替全文转发**:PM 在 `handoff.md` 中写本轮决策、AC、读取清单和风险;Worker 不通过复制上游全文来获得上下文。
|
|
103
103
|
- **子代理输入自包含但不冗长**:派发消息给任务背景、产出路径、读写范围、handoff 路径和必要章节,不内嵌整份上游文档。
|
|
104
|
+
|
|
105
|
+
## 11. 编排噪音纪律(2026-11-19 定)
|
|
106
|
+
|
|
107
|
+
- **看板只在阶段边界写**:审批、打回、Worker 收工、阶段切换、归档时各写一次;禁止每个工具调用/心跳后刷新看板。
|
|
108
|
+
- **命令合并**:同一轮相关的 `git status` / `git log` / `git branch` / `ls` 合并为一条 bash;不重复执行相同命令。
|
|
109
|
+
- **日志只取摘要**:测试/构建日志用 `tail`/`grep` 取失败行,不整段回贴;一次跑完,不反复轮询。
|
|
110
|
+
- **PM 心跳保持现状**:本次只收敛看板和命令噪音,不改变心跳频率。
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# 工程记忆规则
|
|
2
|
+
|
|
3
|
+
> `entries/` 是事实源;`index.md` 是 hot 路由表;`cold.md` 是 cold 路由表。
|
|
4
|
+
> 默认只读 `index.md`,cold 仅在 hot 无匹配时按需搜索。冷索引不删除条目。
|
|
5
|
+
|
|
6
|
+
## 命名
|
|
7
|
+
|
|
8
|
+
| 字段 | 格式 | 示例 | 约束 |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| 文件 | `YYYY-MM-DD_<scope>_<slug>.md` | `2026-04-22_shared_pm-heartbeat-drift.md` | 双下划线分隔;scope 小写;slug kebab-case、3-6 词 |
|
|
11
|
+
| id | `M-YYYYMMDD-<scope>-<slug>` | `M-20260422-shared-pm-heartbeat-drift` | frontmatter 稳定 id,不随文件名改 |
|
|
12
|
+
| scope | 六选一 | backend / frontend / mobile / tooling / infra / shared | 不许自造;跨多域优先 shared |
|
|
13
|
+
| tags | YAML 数组 | `[pagination, env, NaN]` | 3-5 个关键词 |
|
|
14
|
+
| areas | YAML 数组(可选) | `[phm/**, kafka-common/**]` | 模块/路径 glob,提升命中率 |
|
|
15
|
+
| symptoms | YAML 数组(可选) | `["Invalid keystore format", "getArgument"]` | 错误文本/方法名/配置键 |
|
|
16
|
+
| pinned | 布尔(可选) | `true` | 高风险条目,不自动降温 |
|
|
17
|
+
|
|
18
|
+
## 何时写 / 不写
|
|
19
|
+
|
|
20
|
+
| 写 | 不写 |
|
|
21
|
+
|---|---|
|
|
22
|
+
| CR REJECT / TE FAIL(实现层 bug) | 一次通过、0 REJECT/FAIL 的任务 |
|
|
23
|
+
| 开发中踩坑 ≥2 次尝试才解决 | 需求/方案本身错(应反馈到 proposal) |
|
|
24
|
+
| OS/依赖/配置类坑(有强复现性) | 同一任务内反复调试小细节(如 CSS 间距) |
|
|
25
|
+
| 编排层出现漂移(PM/Agent 契约不一致) | 没踩坑就没有经验要沉淀 |
|
|
26
|
+
|
|
27
|
+
## 流程优先
|
|
28
|
+
|
|
29
|
+
tooling / infra / shared 三类先问“能不能改流程(脚本·门禁·模板·命令·规则)”;能改流程就不写记忆,必须写时在条目里说明「流程优化排除」。
|
|
30
|
+
|
|
31
|
+
## 索引格式
|
|
32
|
+
|
|
33
|
+
条目一行,scope 放第一列:
|
|
34
|
+
|
|
35
|
+
```markdown
|
|
36
|
+
| scope | tags | 症状 / 触发 | entry |
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
匹配规则:`scope` 精确匹配,并且 `tags` / `areas` / `symptoms` 至少命中一项;不要 scope 对了就全部加载。单任务最多读 3 条。
|
|
40
|
+
|
|
41
|
+
## hot / cold
|
|
42
|
+
|
|
43
|
+
- `index.md`:hot,默认只读;每 scope 5–10 条,全局不超过 30 条。
|
|
44
|
+
- `cold.md`:cold,默认不读;仅 hot 无匹配时按 scope/tags/symptom 搜索。
|
|
45
|
+
- 自动降温:hot 条目超过 60 天未使用且未 `pinned` → 移入 cold。
|
|
46
|
+
- 冷条目再次使用后运行 `memory_index.py touch <id>` 提升回 hot。
|
|
47
|
+
- cold 不自动删除;只有人工确认退役/合并后才移出。
|
|
48
|
+
|
|
49
|
+
## 命令
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
python3 .harness/scripts/memory_index.py sync
|
|
53
|
+
python3 .harness/scripts/memory_index.py cool --days 60 --max-hot 30 --apply
|
|
54
|
+
python3 .harness/scripts/memory_index.py touch <id>
|
|
55
|
+
python3 .harness/scripts/memory_index.py check
|
|
56
|
+
```
|
|
@@ -3,6 +3,12 @@ id: M-YYYYMMDD-scope-slug # 稳定 id,不随文件名改
|
|
|
3
3
|
date: YYYY-MM-DD
|
|
4
4
|
scope: backend|frontend|mobile|tooling|infra|shared
|
|
5
5
|
tags: [keyword1, keyword2] # 3-5 个关键词,检索辅助
|
|
6
|
+
areas: [] # 可选:模块/路径 glob,如 [phm/**, kafka-common/**]
|
|
7
|
+
symptoms: [] # 可选:错误文本/方法名/配置键
|
|
8
|
+
pinned: false # 高风险条目置 true,不自动降温
|
|
9
|
+
last_used: # 由 memory_index.py touch 维护
|
|
10
|
+
use_count: 0
|
|
11
|
+
status: hot # hot | cold | retired
|
|
6
12
|
---
|
|
7
13
|
|
|
8
14
|
# <标题:一句话描述根因机制>
|