ld-vibe-harness 0.1.0 → 0.3.0

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.
Files changed (128) hide show
  1. package/.claude-plugin/plugin.json +2 -2
  2. package/.codex-plugin/plugin.json +4 -4
  3. package/CHANGELOG.md +65 -0
  4. package/README.en.md +19 -18
  5. package/README.md +29 -28
  6. package/adapters/antigravity/installer.js +61 -4
  7. package/adapters/dsh/index.js +83 -3
  8. package/adapters/dsh/package.json +2 -2
  9. package/agents/ldvh-experience-recorder.md +2 -3
  10. package/agents/ldvh-post-work-reviewer.md +0 -1
  11. package/agents/ldvh-pre-action-reviewer.md +0 -1
  12. package/agents/ldvh-researcher.md +1 -2
  13. package/cli/ldvh.mjs +137 -5
  14. package/docs/ARCHITECTURE.md +37 -37
  15. package/docs/PRIVACY.md +7 -6
  16. package/hooks/_client.mjs +9 -0
  17. package/hooks/hook-engine.js +1158 -84
  18. package/hooks.json +1 -1
  19. package/lib/capture-notice.js +29 -0
  20. package/lib/carrier-ref.js +11 -0
  21. package/lib/commit-validation.js +2 -61
  22. package/lib/data-paths.js +0 -1
  23. package/lib/experience-arming.js +10 -4
  24. package/lib/gate-events.js +27 -2
  25. package/lib/git-gate-runner.js +83 -34
  26. package/lib/goal-anchor.js +72 -0
  27. package/lib/goal-tools.js +32 -31
  28. package/lib/goal-writer.js +5 -18
  29. package/lib/governed-projects.js +18 -7
  30. package/lib/guidance-budget.js +2 -2
  31. package/lib/guidance-text.js +10 -10
  32. package/lib/hook-manager.js +40 -14
  33. package/lib/hook-repair.js +77 -13
  34. package/lib/host-api.js +7 -3
  35. package/lib/host-seams.js +123 -78
  36. package/lib/idle-settings.js +1 -4
  37. package/lib/intent-tools.js +44 -21
  38. package/lib/intent-writer.js +12 -45
  39. package/lib/ldvh-tools.js +88 -295
  40. package/lib/norm-tools.js +44 -9
  41. package/lib/object-identifier.js +0 -2
  42. package/lib/object-reference.js +0 -2
  43. package/lib/operation-declarations.bundle.json +250 -0
  44. package/lib/pitfall-tools.js +38 -7
  45. package/lib/progressive-read.js +250 -0
  46. package/lib/read-body-render.js +27 -3
  47. package/lib/recall-criteria.bundle.json +144 -0
  48. package/lib/recall-criteria.js +246 -2
  49. package/lib/recall-injection.js +159 -70
  50. package/lib/recall-synonyms.js +97 -0
  51. package/lib/report-tools.js +44 -13
  52. package/lib/research-consult-tools.js +201 -19
  53. package/lib/research-consult.js +49 -27
  54. package/lib/review-ask-tool.js +258 -66
  55. package/lib/review-ask.js +75 -25
  56. package/lib/review-dispatch-template.js +75 -40
  57. package/lib/runtime-carrier-reader.js +811 -0
  58. package/lib/runtime-carrier-validator.js +948 -0
  59. package/lib/source-recall.js +448 -160
  60. package/lib/spec-registry.js +121 -5
  61. package/lib/web-preferences.js +2 -2
  62. package/package.json +11 -5
  63. package/plugin-specs/controlled-commit.yaml +233 -0
  64. package/plugin-specs/experience-accumulation-system-foundation.yaml +288 -0
  65. package/plugin-specs/fact-model-common.yaml +302 -0
  66. package/plugin-specs/gate-consult-system-foundation.yaml +347 -0
  67. package/plugin-specs/goal-fact-type.yaml +158 -0
  68. package/plugin-specs/goal-planning-system-foundation.yaml +225 -0
  69. package/plugin-specs/intent-fact-type.yaml +234 -0
  70. package/plugin-specs/intent-record-system-foundation.yaml +280 -0
  71. package/plugin-specs/ldvh-root.yaml +251 -0
  72. package/plugin-specs/norm-fact-type.yaml +172 -0
  73. package/plugin-specs/pitfall-fact-type.yaml +248 -0
  74. package/plugin-specs/report-fact-type.yaml +152 -0
  75. package/plugin-specs/research-system-foundation.yaml +309 -0
  76. package/plugin-specs/rule-compliance-recall.yaml +250 -0
  77. package/plugin-specs/rule-compliance-verification.yaml +207 -0
  78. package/plugin-specs/service-contract.yaml +218 -0
  79. package/plugin.json +4 -4
  80. package/rules/AGENTS.md +5 -5
  81. package/server/local-daemon.js +125 -26
  82. package/server/mcp-app-html.js +44 -1
  83. package/server/mcp-server.js +231 -52
  84. package/server/tool-registry.js +0 -23
  85. package/skills/ldvh-governance-flow/SKILL.md +14 -24
  86. package/skills/ldvh-onboarding/SKILL.md +2 -2
  87. package/lib/aux-task-registry.js +0 -129
  88. package/lib/friction-discovery.js +0 -383
  89. package/lib/friction-failure-registration.js +0 -56
  90. package/lib/friction-observation-buffer.js +0 -889
  91. package/lib/friction-promotion-lock.js +0 -124
  92. package/lib/friction-review-promotion.js +0 -193
  93. package/lib/friction-tools.js +0 -798
  94. package/lib/friction-writer.js +0 -1123
  95. package/lib/milestone-tools.js +0 -652
  96. package/lib/milestone-writer.js +0 -707
  97. package/lib/verification-run.js +0 -195
  98. package/specs/00-/347/220/206/345/277/265/344/270/216/346/236/204/346/210/220.md +0 -304
  99. package/specs/01-/350/247/204/350/214/203/346/272/220/344/270/216/350/247/204/350/214/203/346/250/241/345/236/213/345/237/272/347/241/200/350/247/204/350/214/203.md +0 -611
  100. package/specs/02-/344/272/213/345/256/236/346/272/220/344/270/216/344/272/213/345/256/236/346/250/241/345/236/213/345/237/272/347/241/200/350/247/204/350/214/203.md +0 -646
  101. package/specs/03-/344/270/232/345/212/241/347/263/273/347/273/237/345/237/272/347/241/200/350/247/204/350/214/203.md +0 -518
  102. package/specs/04-/346/243/200/346/237/245/344/270/216/350/276/205/345/212/251/346/234/272/345/210/266/350/247/204/350/214/203.md +0 -326
  103. package/specs/05-LDVH CLI /347/241/256/345/256/232/346/200/247/346/234/215/345/212/241/350/247/204/350/214/203.md" +0 -289
  104. package/specs/06-Code /345/256/236/350/267/265/344/270/216/346/265/213/350/257/225/350/247/204/350/214/203.md" +0 -364
  105. package/specs/07-Web /345/221/210/347/216/260/344/270/216/344/272/244/344/272/222/350/247/204/350/214/203.md" +0 -280
  106. package/specs/08-/347/256/241/350/276/226/350/214/203/345/233/264/350/247/204/350/214/203.md +0 -262
  107. package/specs/09-/345/217/227/346/216/247/346/217/220/344/272/244/344/270/216/346/234/272/346/242/260/345/256/210/346/212/244/350/247/204/350/214/203.md +0 -291
  108. package/specs/10-DSH /347/216/257/345/242/203/346/216/245/345/205/245/344/270/216/346/217/222/344/273/266/345/217/221/345/270/203/350/247/204/350/214/203.md" +0 -317
  109. package/specs/20-Goal-/351/241/271/347/233/256/347/233/256/346/240/207.md +0 -271
  110. package/specs/21-Milestone-/351/207/214/347/250/213/347/242/221.md +0 -413
  111. package/specs/22-Intent-/346/204/217/345/233/276.md +0 -459
  112. package/specs/23-Norm-/344/272/213/345/256/236/350/247/204/350/214/203.md +0 -397
  113. package/specs/24-Report-/346/212/245/345/221/212.md +0 -562
  114. package/specs/25-Pitfall-/350/270/251/345/235/221/347/273/217/351/252/214.md +0 -358
  115. package/specs/26-Friction-/346/221/251/346/223/246/350/264/246/346/234/254.md +0 -409
  116. package/specs/30-/347/233/256/346/240/207/350/247/204/345/210/222/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -408
  117. package/specs/31-/346/204/217/345/233/276/350/256/260/345/275/225/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -463
  118. package/specs/32-/346/212/212/345/205/263/350/257/267/347/244/272/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -420
  119. package/specs/33-/350/260/203/347/240/224/345/220/270/346/224/266/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -653
  120. package/specs/34-/345/217/214/346/272/220/345/217/254/345/233/236/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -492
  121. package/specs/35-/347/273/217/351/252/214/347/247/257/347/264/257/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -471
  122. package/specs/36-/346/221/251/346/223/246/351/224/200/350/264/246/347/263/273/347/273/237/350/247/204/350/214/203.md +0 -488
  123. package/specs/attachments/01.Att.01-LDVH/345/217/214/350/257/255/346/234/257/350/257/255/350/241/250.md +0 -128
  124. package/specs/attachments/01.Att.02-/350/247/204/350/214/203/350/272/253/344/273/275/345/255/227/346/256/265/350/241/250.md +0 -107
  125. package/specs/attachments/01.Att.03-/350/247/204/350/214/203/345/205/263/347/263/273/344/270/216/345/261/202/347/272/247/350/241/250.md +0 -63
  126. package/specs/attachments/02.Att.01-/344/272/213/345/256/236/345/217/254/345/233/236/345/210/206/345/261/202/350/241/250.md +0 -22
  127. package/specs/attachments/08.Att.01-/347/256/241/350/276/226/347/231/273/350/256/260/350/275/275/344/275/223Schema/350/241/250.md +0 -29
  128. package/specs/attachments/23.Att.01-Norm/346/226/271/345/220/221/346/270/205/345/215/225.md +0 -102
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ldvh",
3
- "version": "0.1.0",
4
- "description": "把项目目标、里程碑、意图、规范、报告、踩坑经验与摩擦账本落盘为随 Git 演进的结构化事实(ldvh-base/);每轮动手前按预算只注入轻量候选索引(不灌全文、按需精读),高风险写入强制 Human 确认,支持零上下文子代理审方案、核结果与联网取证,提交由 Git Gate 校验并附会话签名,配本地/远程 Web 看板。",
3
+ "version": "0.3.0",
4
+ "description": "把项目目标、意图、规范、报告与踩坑经验落盘为随 Git 演进的结构化事实(ldvh-base/);每轮动手前按预算只注入轻量候选索引(不灌全文、按需精读),高风险写入强制 Human 确认,支持零上下文子代理审方案、核结果与异步沉淀经验,遇外部难题先内查再请示联网取证,提交由 Git Gate 校验并附会话签名,配本地/远程 Web 看板。",
5
5
  "author": {
6
6
  "name": "LaoDing",
7
7
  "url": "https://github.com/dingminhua"
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.1.0",
2
+ "version": "0.3.0",
3
3
  "name": "ldvh",
4
- "description": "把项目目标、里程碑、意图、规范、报告、踩坑经验与摩擦账本落盘为随 Git 演进的结构化事实(ldvh-base/);每轮动手前按预算只注入轻量候选索引(不灌全文、按需精读),高风险写入强制 Human 确认,支持零上下文子代理审方案、核结果与联网取证,提交由 Git Gate 校验并附会话签名,配本地/远程 Web 看板。",
4
+ "description": "把项目目标、意图、规范、报告与踩坑经验落盘为随 Git 演进的结构化事实(ldvh-base/);每轮动手前按预算只注入轻量候选索引(不灌全文、按需精读),高风险写入强制 Human 确认,支持零上下文子代理审方案、核结果与异步沉淀经验,遇外部难题先内查再请示联网取证,提交由 Git Gate 校验并附会话签名,配本地/远程 Web 看板。",
5
5
  "author": {
6
6
  "name": "LaoDing",
7
7
  "url": "https://github.com/dingminhua"
@@ -15,13 +15,13 @@
15
15
  "interface": {
16
16
  "displayName": "LDVH",
17
17
  "shortDescription": "随 Git 演进的 AI 协作事实源与工程护栏:自动召回、人工门禁、独立复核与 Git Gate",
18
- "longDescription": "AI 编程的根本矛盾在于:模型推理是概率性的、对话上下文会遗忘和稀释,而长期软件项目需要确定性的依据、边界与接续。LD Vibe Harness(LDVH)在项目仓库的 ldvh-base/ 中沉淀 Goal、Milestone、Intent、Norm、Report、Pitfall、Friction 七类结构化事实,并在执行链上挂接四项机械保障:动手前按预算仅注入轻量候选索引(不灌全文、按需精读)、高风险写入强制 Human 确认、可选零上下文子代理行动前审查与收口前复核、以及带会话签名的 Git Gate 终闸,同时提供本地与远程 Web 看板,且在 Antigravity、Codex、DSH 与 Claude Code 间共享 ~/.ldvh 数据目录。",
18
+ "longDescription": "AI 编程的根本矛盾在于:模型推理是概率性的、对话上下文会遗忘和稀释,而长期软件项目需要确定性的依据、边界与接续。LD Vibe Harness(LDVH)在项目仓库的 ldvh-base/ 中沉淀 Goal、Intent、Norm、Report、Pitfall 五类结构化事实,并在执行链上挂接四项机械保障:动手前按预算仅注入轻量候选索引(不灌全文、按需精读)、高风险写入强制 Human 确认、可选零上下文子代理行动前审查与收口前复核、以及带会话签名的 Git Gate 终闸,同时提供本地与远程 Web 看板,且在 Antigravity、Codex、DSH 与 Claude Code 间共享 ~/.ldvh 数据目录。",
19
19
  "developerName": "LaoDing",
20
20
  "category": "Engineering",
21
21
  "capabilities": ["Interactive", "Read", "Write"],
22
22
  "websiteURL": "https://github.com/dingminhua/ld-vibe-harness",
23
23
  "defaultPrompt": [
24
- "检查当前项目是否受 LDVH 管辖,并展示项目目标与待决定事项"
24
+ "检查当前项目是否受 LDVH 管辖,并展示项目目标与待推进意图"
25
25
  ],
26
26
  "brandColor": "#10B981",
27
27
  "composerIcon": "./assets/ldvh-plugin-icon-128.png",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # 变更日志
2
2
 
3
+ ## [0.3.0] - 2026-12-02
4
+
5
+ 收敛五类事实模型与 26 个模型可见 MCP 工具,升级两选项中文 Human Gate 与全产品统一提请题面格式,改版联网调查为主控二选一与亲自调研闭环,并完善单页四渠道诊断、内嵌看板热重载/自愈与设置页独立卡片体验。
6
+
7
+ ### 新增
8
+
9
+ - **单页四渠道诊断面板**:诊断页取消旧分页标签,扩展采集并聚合 `MCP`、`Hook`、`CLI`、`Git Gate` 四渠道事件账,区分「实际异常/拦截」与「待确认/半程流转」。
10
+ - **内嵌看板热重载与并发自愈**:新增 `POST /admin/reload-web` 热重载端点(`host setup --apply` 自动触发,不再误杀守护进程),支持 `/admin/shutdown` 后并发代理自动拉起自愈。
11
+ - **实战踩坑经验沉淀**:在 `ldvh-base/pitfalls/` 沉淀 4 条排障经验(Git Hook 迁移路径比对、Windows 尾反斜杠解析、内嵌 daemon 被 shutdown 失联、`webApiProcess.dispose` 不可逆 503)。
12
+
13
+ ### 变更
14
+
15
+ - **五类事实模型与 26 工具收敛**:统一收敛为 `Goal`、`Intent`、`Norm`、`Report`、`Pitfall` 五类结构化事实与 26 个模型可见 MCP 工具(另含 app-only `ldvh_app_api_proxy`);随包运行期规范收口为 16 份 `plugin-specs/*.yaml`。
16
+ - **Human Gate 与全产品提请题面统一**:升级高风险写入门禁为 Hook 验签两选项中文审批(`确认执行` / `拒绝取消`)并自动补全对象标题;统一全产品 Human Gate、行动前/收口前把关与联网调查提请题面为 `LDVH <类别> - 是否<动作>:<对象>?`。
17
+ - **联网调查闭环改版**:遇复杂外部难题时由主控先检索内部事实源,仍缺再以二选一请示「联网调查 / 不调查」(人主动要求时不重复请示),获准后由主控亲自执行完整调研工序(`ldvh-researcher` 作为可选局部辅助)。
18
+ - **设置页卡片拆分与窄宽修复**:将「自主召回预算」与「经验积累」拆分为独立控制卡片,修复受管辖项目卡片在窄宽度下的挤压折行异常。
19
+ - **文档、帮助手册与截图同步**:全面更新 `README.md`、`README.en.md`、`RELEASING.md`、`docs/ARCHITECTURE.md`、`docs/PRIVACY.md`、多宿主清单描述、看板 5 章节帮助页及 4 张看板截图。
20
+
21
+ ### 修复
22
+
23
+ - **Hook 门禁与冷启动状态修复**:修复 `ask_question` 识别 `questions: [...]` 与 `A1: 确认执行` 时触发的死循环,同步修复同类 `PostToolUse` 与冷启动状态判定问题。
24
+ - **本地看板 `fetch failed` 与 503 根治**:修复陈旧指纹淘汰、`webApiProcess.dispose` 不可逆与守护进程同步关停导致的看板失联。
25
+ - **Git Hook 迁移路径误判**:修复插件安装目录迁移或升级且旧目录仍留在磁盘时 `hook-manager` 误判 `managed` 跳过升级的问题。
26
+
27
+ ### 移除
28
+
29
+ - **移除 `Friction` 业务系统与 `Milestone` 层级**:全产品彻底清除摩擦账本与里程碑层级,待推进事项收敛至 `Intent`,反复卡点有效临时规避沉淀为 `Pitfall`。
30
+
31
+ ### 升级提示
32
+
33
+ - **旧仓目录兼容与插件刷新**:旧仓库内残留的 `ldvh-base/milestones/` 与 `ldvh-base/frictions/` 目录会自动忽略不报错(建议清理或将未完事项迁入 `Intent`);同步插件(`host setup --host antigravity --apply`)后请在宿主管理页刷新 MCP 服务。
34
+
35
+ ## [0.2.0] - 2026-11-30
36
+
37
+ 面向外部开箱可用性的关键修复与核心能力升级:运行时规范打包解耦、Hook 注入与远程 MCP App 修复、双源召回优先级与零向量同义词/路径增量补强、7 类事实对象渐进式精读以及经验/摩擦独立子代理全权落盘。
38
+
39
+ ### 新增
40
+
41
+ - **随包精简运行时规范载体**:将运行期规范收口为 19 份 `plugin-specs/*.yaml` 与构建期生成的 `lib/*.bundle.json`(`specs/` 仅留存仓库作开发设计参考,不再打入 npm 包)。
42
+ - **确定性零向量同义词补漏**:新增 `lib/recall-synonyms.js`(21 组封闭工程与 LDVH 领域词组,兼容中文 bigram 粒度、排除泛词),接入事实源与载体召回,在原生弱命中/未命中时低权补漏并标注 `原词→扩展词`。
43
+ - **工具后路径上下文增量提醒**:`PostToolUse` 在受管辖仓库通过独立 `turn-paths/<hash>.json` 记录刚触及的源码相对路径(Windows realpath 归一化、排除 `ldvh-base/`),同回合后续 `PreInvocation` 按路径定向提醒 `active Norm` 与 `active Pitfall`(回合级去重、纯读取回合排除、`Stop` 自动清理)。
44
+ - **全系 7 类事实对象渐进式精读**:新增 `lib/progressive-read.js` 并重构 `lib/read-body-render.js`,统一接入 `ldvh_{goal,milestone,intent,norm,pitfall,friction,report}_read`,支持磁盘 1-based `headings` 目录、`include_body: false` 仅读大纲与 `sections` 按 H2 节选(显式披露 `missing_sections`、`outcome: "partial"` 与 CAS 写前全量回读警示)。
45
+ - **运行时载体条款级行号定位**:`lib/runtime-carrier-reader.js` 使用 `yaml` `LineCounter` 剥离尾空行精确提取 `requirements` 起止行号,`lib/recall-injection.js` 在预算允许时附带缩进式条款行号子行并透出实际送达的 `renderedFactUids`。
46
+ - **经验与摩擦独立子代理落盘**:新增 `agents/ldvh-friction-recorder.md` 与 `lib/capture-notice.js`;确立主控只发现可回指材料并后台派发子代理(经验由 `ldvh-experience-recorder` 授权直写,摩擦由 `ldvh-friction-recorder` 写观察缓冲并在同源满 3 次时由工具以子代理会话签名自动晋升),同时升级 `Stop` Hook 收口防死循环护栏。
47
+ - **双源召回高优锚点与基准评测**:新增 `lib/goal-anchor.js` 常驻目标与活跃里程碑锚点及 `scripts/eval-recall.mjs` 7 场景召回基准评测脚本。
48
+
49
+ ### 变更
50
+
51
+ - **双源召回优先级重构**:确立高优先权重(目标/里程碑/事实规范居首、踩坑经验次之,`FACT_TYPE_PRIORITY`),支持标识符子词拆解(`expandIdentifierSubtokens`)、显式路径上下文提权、运行时载体泛词停用治理及跨进程 `hook-turn-state.json` 同回合去重。
52
+ - **34 个模型可见 MCP 工具**:下线旧规范全文读取工具 `ldvh_read_specification_candidates` 与 `ldvh_read_specification_content`(运行时改走轻量载体定位 + 按行号按需读取)。
53
+ - **术语与把关点位统一**:清理 `plugin-specs/*.yaml` 中残留中文旧术语(`火花` → `意图`、`子目标` → `里程碑`);`ldvh_review_ask` 对齐 `pre-action`(`candidate_summary`)、`post-work`(`conclusion_summary`)摘要校验与 `point="research"` 统一请示点位;Git Gate 强拦范围扩展覆盖 `plugin-specs/`。
54
+
55
+ ### 修复
56
+
57
+ - **独立发布依赖与 Windows CRLF 兼容**:补齐 `web/api-js` 运行时依赖(`compression`、`cors`、`dotenv`、`express`、`js-yaml`)至根 `package.json`;修复 `lib/spec-registry.js` 在 Windows CRLF 换行下的解析失败。
58
+ - **Antigravity Hook 注入静默丢失与陈旧 daemon 淘汰**:移除 `PreInvocation` / `SessionStart` 中触发宿主静默丢弃的 `metadata.user_markdown`;在 `server/local-daemon.js` 与 `hooks/_client.mjs` 增加 `codeFingerprint` 与 `POST /admin/shutdown` 自动优雅淘汰陈旧常驻服务。
59
+ - **远程 MCP App 2 MiB 超限 500 故障**:`ObjectDetail.tsx` 改用 `PrismLight`(18 种语言)、仅开发环境启用 `react-dev-locator`、`server/mcp-app-html.js` 增设 1.4 MiB 自动 gzip + `DecompressionStream` 自解压兜底,将单文件序列化体积压至约 1.14 MiB(守卫阈值 `< 1.5 MiB`)。
60
+ - **事实源直写拦截与多宿主 Human Gate 闭环**:`hooks/hook-engine.js` 拦截受管辖项目 `write_file` / `edit_file` 直写 `ldvh-base/`(使用 `realpathSync.native` 兼容 Windows 8.3 短路径);非 Hook 宿主(Codex / Claude Code)支持 `human_confirmed: true` 闭环(Antigravity 下仍强制 `force_ask` 不可绕过);拦截子代理直调 `ldvh_friction_write`。
61
+ - **DSH 适配器补全与泛目录线索过滤**:`adapters/dsh/index.js` 补全 `/ldvh/api/plugin-settings` GET/POST 接口与 `systemPrompt` 注册;修复 `git status --porcelain` 对未跟踪目录产出纯目录线索导致路径召回误命中的缺陷。
62
+
63
+ ### 移除
64
+
65
+ - 模型可见工具 `ldvh_read_specification_candidates`、`ldvh_read_specification_content`。
66
+ - npm 发布包中的 `specs/` 目录(仍保留于仓库用于开发参考)。
67
+
3
68
  ## [0.1.0] - 2026-11-30
4
69
 
5
70
  多宿主「单核多壳」架构重构后的首个正式发布版本(旧版代码归档在分支 `backup/main-legacy`)。
package/README.en.md CHANGED
@@ -29,32 +29,32 @@
29
29
  Two chronic problems with AI coding:
30
30
 
31
31
  - **Vibe drift** — over a long session, or a new one, the AI forgets the project's goals, agreed rules and open ideas, and starts coding on a hunch.
32
- - **Coding out of control** — the AI writes and declares "done" itself; yesterday's pitfalls get stepped on again; recurring blockers go unrecorded; key conventions get changed in passing.
32
+ - **Coding out of control** — the AI writes and declares "done" itself; yesterday's pitfalls and tooling snags get stepped on again; key conventions get changed in passing.
33
33
 
34
- LDVH puts a harness on the AI. Goals, ideas, norms, lessons and frictions become **structured facts**, recalled automatically before each action. High-risk writes need a human's explicit approval, and a Git Gate checks commits mechanically.
34
+ LDVH puts a harness on the AI. Goals, ideas, norms, and lessons become **structured facts**, recalled automatically before each action. High-risk writes need a human's explicit approval, and a Git Gate checks commits mechanically.
35
35
 
36
36
  ## Supported hosts
37
37
 
38
- | Host | Integration | MCP tools | Hook injection | Sub-agent review | Embedded dashboard |
39
- | :--- | :--- | :---: | :---: | :---: | :---: |
40
- | Antigravity | `plugin.json` + `mcp_config.json` + `hooks.json` | ✅ | ✅ (direct & `call_mcp_tool`) | ✅ | ✅ (local + remote self-contained MCP App) |
41
- | Codex | `.codex-plugin/plugin.json` + `.mcp.json` | ✅ | — | — | browser |
42
- | DSH | `adapters/dsh` (Cordis plugin) | ✅ | — | ✅ | ✅ |
43
- | Claude Code | `.claude-plugin/plugin.json` (reserved) | ✅ | — | — | browser |
38
+ | Host | Integration | MCP tools | Hook injection | Human Gate | Sub-agent review | Embedded dashboard |
39
+ | :--- | :--- | :---: | :---: | :---: | :---: | :---: |
40
+ | Antigravity | `plugin.json` + `mcp_config.json` + `hooks.json` | ✅ | ✅ (direct & `call_mcp_tool`) | Hook-verified 2-option Human Gate (`ask_question`) | ✅ | ✅ (local + remote self-contained MCP App) |
41
+ | Codex | `.codex-plugin/plugin.json` + `.mcp.json` | ✅ | — | `human_confirmed` / Web / CLI | — | browser |
42
+ | DSH | `adapters/dsh` (Cordis plugin) | ✅ | — | Embedded UI | ✅ | ✅ |
43
+ | Claude Code | `.claude-plugin/plugin.json` (reserved) | ✅ | — | `human_confirmed` / Web / CLI | — | browser |
44
44
 
45
45
  "—" means the host has no equivalent interface yet; that capability falls back to the model following the guidance in `skills/`. The fact store, tools and Git Gate are unaffected.
46
46
 
47
47
  All hosts share one data directory, **`~/.ldvh`** by default, so a goal recorded in Antigravity is recalled in Codex or DSH too. Set `LDVH_DATA_DIR` to isolate.
48
48
 
49
- ## Seven business systems
49
+ ## Six business systems
50
50
 
51
- Goal planning · Intent capture · Dual-source recall · Gate consultation (pre-action review, post-work review, internal lookup before asking to search the web) · Research absorption · Experience accumulation · Friction write-off.
51
+ Goal planning (Goal) · Intent capture (Intent) · Dual-source recall (lightweight candidate index within budget, always-on Goal anchor, in-turn path-context reminders, progressive section read) · Gate consultation (unified prompt titles: 3-option pre-action/post-work review, 2-option web research consult after internal lookup) · Research absorption (controller-led verification & three-state Report, with optional `ldvh-researcher` helper) · Experience accumulation (verified pitfalls & recurring workarounds recorded asynchronously as `Pitfall`).
52
52
 
53
53
  Four lines of defence: self-check → mechanical verification (controlled writes, read-back, Git Gate) → optional agent review → optional agent re-check.
54
54
 
55
55
  ## Quick start
56
56
 
57
- Requires Node.js ≥ 22.15.
57
+ Requires Node.js ≥ 22.15 (npm tarball already ships prebuilt `web/dist`, `web/api-js`, `web/shared-js`, and `lib/*.bundle.json`; running from a git clone builds the dashboard first).
58
58
 
59
59
  ```bash
60
60
  git clone https://github.com/dingminhua/ld-vibe-harness.git
@@ -72,27 +72,28 @@ Without `--apply`, `host setup` is a dry run.
72
72
 
73
73
  ## Web dashboard
74
74
 
75
- - **Local, LAN & Remote**: The daemon listens on `0.0.0.0:3299` by default (random free port on conflict): `http://127.0.0.1:3299/ldvh/`. The Antigravity MCP App (`ui://ldvh/app.html`) is bundled as a self-contained single HTML file tunneling API calls via `ldvh_app_api_proxy`, so it works cleanly even on remote `antigravity.google.com`.
76
- - **Pages**: Focus (project/branch switcher), 7 fact-type views, Directory, Changes, Commits, Diagnostics (`~/.ldvh/ldvh/gate-events.jsonl` & friction counters), Settings (native OS folder picker & review/assist toggles), and a redesigned 5-chapter Help guide (`/help`).
75
+ - **Local, LAN & Remote**: The daemon listens on `0.0.0.0:3299` by default (random free port on conflict): `http://127.0.0.1:3299/ldvh/`. The Antigravity MCP App (`ui://ldvh/app.html`) is bundled as a self-contained single HTML file tunneling API calls via `ldvh_app_api_proxy`, so it works cleanly even on remote `antigravity.google.com`, with hot-reload and self-healing on sync/shutdown.
76
+ - **Pages**: Focus (project/branch switcher, Goal, Intent health, recent activity), 5 fact-type views, Directory, Changes, Commits, Diagnostics (single unified ledger view reading `~/.ldvh/ldvh/gate-events.jsonl` across MCP / Hook / CLI / Git Gate, separating errors from pending gates), Settings (separate Recall Budget `10–50 KB` and Experience Accumulation cards, review gate switches, native OS folder picker, narrow-width responsive project cards), and a 5-chapter Help guide (`/help`).
77
77
  - **Prebuilt API**: `pnpm run build:dsh` outputs precompiled `web/api-js` and `web/shared-js` for instant startup.
78
78
 
79
- | Focus Overview (Goal / Milestones / Recent Activity) | Structured Facts Board (7 Fact Types) |
79
+ | Focus Overview (Goal / Intent Health / Recent Activity) | Structured Facts Board (5 Fact Types) |
80
80
  | :---: | :---: |
81
81
  | ![Focus Overview](docs/screenshots/01-focus.png) | ![Structured Facts Board](docs/screenshots/02-facts.png) |
82
- | **Diagnostics & Gate Events** | **5-Chapter Interactive Help Guide** |
82
+ | **Diagnostics & 4-Channel Event Ledger** | **5-Chapter Interactive Help Guide** |
83
83
  | ![Diagnostics](docs/screenshots/03-diagnostics.png) | ![Help Guide](docs/screenshots/04-help.png) |
84
84
 
85
85
  ## Controlled commits & unified signing
86
86
 
87
- - Exposes **36 model-visible MCP tools** (including read-only `ldvh_session_signature`) plus app-only `ldvh_app_api_proxy`.
88
- - In governed repos, AI-initiated commits query `ldvh_session_signature` and attach `LDVH-Provider` / `LDVH-Model` trailers, while Git Gate only enforces strict checks when `ldvh-base/` or `specs/` are staged (leaving manual human commits and `git merge` unhindered).
89
- - **Terminology**: v2 standardized `Intent` (replacing `Spark`) and `Milestone` (replacing `SubGoal`); see the Help page's Verify & FAQ chapter for legacy repo migration steps.
87
+ - Exposes **26 model-visible MCP tools** (including read-only `ldvh_session_signature`) plus app-only `ldvh_app_api_proxy`. Runtime recall uses **16 bundled `plugin-specs/*.yaml`** (`specs/` stays in the git repo only and is excluded from the npm tarball).
88
+ - In governed repos, AI-initiated commits query `ldvh_session_signature` and attach `LDVH-Provider` / `LDVH-Model` trailers, while Git Gate only enforces strict checks when `ldvh-base/`, `specs/`, or `plugin-specs/` are staged (leaving manual human commits and `git merge` unhindered).
89
+ - **Terminology**: v2 standardized `Intent` (replacing `Spark`) and removed both `Milestone` and `Friction` (legacy folders are ignored harmlessly; ongoing work converges into `Intent` and recurring workarounds are persisted as `Pitfall`); see the Help page's Verify & FAQ chapter for legacy repo migration steps.
90
90
 
91
91
  See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) (Chinese) and [CHANGELOG.md](CHANGELOG.md). Legacy code lives on the `backup/main-legacy` branch.
92
92
 
93
93
  ## Development
94
94
 
95
95
  ```bash
96
+ npm run check # runs build:bundles + lint + build:web + check:pii + test
96
97
  npm run lint
97
98
  npm test
98
99
  ```
package/README.md CHANGED
@@ -29,40 +29,39 @@
29
29
  AI 编程的两个老问题:
30
30
 
31
31
  - **Vibe 漂移**:会话一长或换会话,AI 就忘了项目目标、既定规矩与未决想法,开始凭感觉改代码。
32
- - **Coding 失控**:AI 自己写、自己说“改好了”;踩过的坑下周重踩;反复卡壳的毛病没人记账;关键约定被顺手改掉也没人拦。
32
+ - **Coding 失控**:AI 自己写、自己说“改好了”;踩过的坑和工具卡点下周重踩;关键约定被顺手改掉也没人拦。
33
33
 
34
- LDVH 给 AI 套一副工程缰绳:把目标、想法、规范、经验、摩擦沉淀成**结构化事实**,每轮动手前自动召回,高风险写入必须人工点头,提交前由 Git Gate 机械把关。
34
+ LDVH 给 AI 套一副工程缰绳:把目标、想法、规范、经验沉淀成**结构化事实**,每轮动手前自动召回,高风险写入必须人工点头,提交前由 Git Gate 机械把关。
35
35
 
36
36
  ## 支持的宿主
37
37
 
38
- | 宿主 | 接入方式 | MCP 工具 | Hook 自动注入 | 子代理把关 | 内嵌看板 |
39
- | :--- | :--- | :---: | :---: | :---: | :---: |
40
- | Antigravity | `plugin.json` + `mcp_config.json` + `hooks.json` | ✅ | ✅(兼容直连与 `call_mcp_tool`) | ✅ | ✅(本地 + 远程自包含 MCP App) |
41
- | Codex | `.codex-plugin/plugin.json` + `.mcp.json` | ✅ | — | — | 浏览器 |
42
- | DSH | `adapters/dsh`(Cordis 插件) | ✅ | — | ✅ | ✅ |
43
- | Claude Code | `.claude-plugin/plugin.json`(预留) | ✅ | — | — | 浏览器 |
38
+ | 宿主 | 接入方式 | MCP 工具 | Hook 自动注入 | 人工门禁 | 子代理把关 | 内嵌看板 |
39
+ | :--- | :--- | :---: | :---: | :---: | :---: | :---: |
40
+ | Antigravity | `plugin.json` + `mcp_config.json` + `hooks.json` | ✅ | ✅(兼容直连与 `call_mcp_tool`) | Hook 验签 Human Gate(2 选项 `ask_question` 统一题面审批) | ✅ | ✅(本地 + 远程自包含 MCP App) |
41
+ | Codex | `.codex-plugin/plugin.json` + `.mcp.json` | ✅ | — | `human_confirmed` / Web / CLI | — | 浏览器 |
42
+ | DSH | `adapters/dsh`(Cordis 插件) | ✅ | — | 内嵌交互 | ✅ | ✅ |
43
+ | Claude Code | `.claude-plugin/plugin.json`(预留) | ✅ | — | `human_confirmed` / Web / CLI | — | 浏览器 |
44
44
 
45
45
  “—”表示该宿主暂无等价接口,对应能力退化为按 `skills/` 指引由主控自觉执行;事实源、工具与 Git Gate 不受影响。
46
46
 
47
- 三个宿主默认**共享同一个数据目录 `~/.ldvh`**:在 Antigravity 里记下的目标与经验,换到 Codex 或 DSH 照样能召回。需要隔离时设置环境变量 `LDVH_DATA_DIR`。
47
+ 四个宿主默认**共享同一个数据目录 `~/.ldvh`**:在 Antigravity 里记下的目标与经验,换到 Codex 或 DSH 照样能召回。需要隔离时设置环境变量 `LDVH_DATA_DIR`。
48
48
 
49
- ## 七个业务系统
49
+ ## 六个业务系统
50
50
 
51
51
  | 价值 | 业务系统 | 作用 |
52
52
  | :--- | :--- | :--- |
53
- | 对齐 Vibe | 目标规划 | Goal / Milestone 承载长期意图与可核对的达成条件 |
54
- | 对齐 Vibe | 意图记录 | Intent 承接值得跨行动推进的想法与未决问题 |
55
- | 对齐 Vibe | 双源召回 | 每轮动手前从规范源与事实源召回相关候选 |
56
- | 协调 Coding | 把关请示 | 行动前审方案、收口前复核结果、不掌握时先内查再请示联网 |
57
- | 协调 Coding | 调研吸收 | 零上下文调研子代理联网取证并沉淀报告 |
58
- | 协调 Coding | 经验积累 | 踩坑沉淀为 Pitfall,由后台代理异步记录 |
59
- | 协调 Coding | 摩擦销账 | 系统性阻碍先进缓冲,累计到阈值自动晋升为待修 Friction |
53
+ | 对齐 Vibe | 目标规划 | Goal 承载项目长期目标陈述与达成边界 |
54
+ | 对齐 Vibe | 意图记录 | Intent 承接项目跨行动要推进的事情与待决方向线 |
55
+ | 对齐 Vibe | 双源召回 | 每轮动手前按预算从规范源与事实源注入轻量候选索引、常驻 Goal 锚点与同回合路径上下文提醒,支持按节渐进式精读 |
56
+ | 协调 Coding | 把关请示 | 统一三类提请题面:行动前审方案、收口前复核结果(三选一),遇复杂外部难题先内查再二选一请示是否联网(人主动提出不重复请示) |
57
+ | 协调 Coding | 调研吸收 | 主控先内查再亲自联网取证(可选派发 `ldvh-researcher` 局部辅助),输出三态证据与逐字引证并按需沉淀 Report |
58
+ | 协调 Coding | 经验积累 | 已验证失败机制与反复卡点有效临时规避统一沉淀为 Pitfall,由后台代理异步查重创建 |
60
59
 
61
- 四层防线:主控自查 → 机械校验(受控写入、回读、Git Gate)→ 可选代理审核 → 可选代理复核。登记/取消管辖、Intent/Norm 创建与终态等高风险写入始终走人工门禁。
60
+ 四层防线:主控自查 → 机械校验(受控写入、写后回读、Git Gate)→ 可选代理审核 → 可选代理复核。登记/取消管辖、Intent/Norm 创建与终态等高风险写入始终走人工门禁。
62
61
 
63
62
  ## 快速开始
64
63
 
65
- 需要 Node.js ≥ 22.15。
64
+ 需要 Node.js ≥ 22.15(通过 npm 包安装已预含 `web/dist`、`web/api-js`、`web/shared-js` 与 `lib/*.bundle.json`;从源码仓库直接运行需先构建前端看板)。
66
65
 
67
66
  ```bash
68
67
  git clone https://github.com/dingminhua/ld-vibe-harness.git
@@ -99,21 +98,21 @@ node cli/ldvh.mjs governed-project install --project /abs/path/to/repo --id my-r
99
98
 
100
99
  ## Web 看板
101
100
 
102
- - **多端访问**:本地守护服务默认监听 `0.0.0.0:3299`(端口冲突自动顺延),本机与局域网设备均可访问 `http://127.0.0.1:3299/ldvh/`。Antigravity 面板内的 MCP App(`ui://ldvh/app.html`)采用单文件自包含打包并通过 `ldvh_app_api_proxy` 隧道代理请求,在远程 `antigravity.google.com` 同样全功能直连可用。
103
- - **核心页面**:聚焦(项目/分支两级视角)、七类事实对象看板、目录、变更、提交、诊断(直读 `~/.ldvh/ldvh/gate-events.jsonl` 与摩擦观察进度)、设置(支持跨平台系统原生目录选择框与把关/积累开关)以及全新 5 章节帮助手册(`/help`)。
101
+ - **多端访问**:本地守护服务默认监听 `0.0.0.0:3299`(端口冲突自动顺延),本机与局域网设备均可访问 `http://127.0.0.1:3299/ldvh/`。Antigravity 面板内的 MCP App(`ui://ldvh/app.html`)采用单文件自包含打包并通过 `ldvh_app_api_proxy` 隧道代理请求,在远程 `antigravity.google.com` 同样全功能直连可用;插件同步或异常关闭时支持热重载与并发自愈。
102
+ - **核心页面**:聚焦(项目/分支两级视角、Goal 目标陈述、Intent 健康度与近期动态)、五类事实对象看板、目录、变更、提交、诊断(单页统一观测面板,直读 `~/.ldvh/ldvh/gate-events.jsonl`,聚合 `MCP` / `Hook` / `CLI` / `Git Gate` 四渠道并区分异常拦截与待确认流程中)、设置(独立的「自主召回预算」`10–50 KB`、「经验积累」、「把关请示与审查开关」与「管辖项目与 Git Gate 管理」,支持系统原生目录选择框及窄宽自适应)以及 5 章节帮助手册(`/help`)。
104
103
  - **预编译直跑**:前端构建产物包含 `web/api-js` 与 `web/shared-js` 预编译后端,免实时转译启动。
105
104
 
106
- | 聚焦总览(Goal / Milestone / 事实概览) | 结构化事实看板(七类对象管理) |
105
+ | 聚焦总览(Goal / 意图健康度 / 近期动态) | 结构化事实看板(五类对象管理) |
107
106
  | :---: | :---: |
108
107
  | ![聚焦总览](docs/screenshots/01-focus.png) | ![结构化事实看板](docs/screenshots/02-facts.png) |
109
- | **诊断与事件账(Hook / Gate Events)** | **五章节交互式帮助手册** |
108
+ | **诊断与四渠道事件账(MCP / Hook / CLI / Git Gate)** | **五章节交互式帮助手册** |
110
109
  | ![诊断与事件账](docs/screenshots/03-diagnostics.png) | ![帮助手册](docs/screenshots/04-help.png) |
111
110
 
112
111
  ## 受控提交与统一署名
113
112
 
114
- - 仓库提供 **36 个模型可见 MCP 工具**(含只读路由自查工具 `ldvh_session_signature`)及 app-only 隧道工具 `ldvh_app_api_proxy`。
115
- - 在受管辖仓库中,AI 发起任何 `git commit` 均统一先查询 `ldvh_session_signature`,使用中文标题、`关键变更:` 以及 `LDVH-Provider` / `LDVH-Model` trailer 署名;Git Gate 仅在暂存区触及 `ldvh-base/` 或 `specs/` 时强拦,不阻碍人类手工提交与 `git merge`。
116
- - **术语提示**:v2 已将 `Spark → Intent`(`ldvh-base/intents/`)、`SubGoal → Milestone`(`ldvh-base/milestones/`)彻底统一;旧仓迁移指引见看板帮助页「自检与排错」。
113
+ - 仓库提供 **26 个模型可见 MCP 工具**(含只读路由自查工具 `ldvh_session_signature`)及 app-only 隧道工具 `ldvh_app_api_proxy`。
114
+ - 在受管辖仓库中,AI 发起任何 `git commit` 均统一先查询 `ldvh_session_signature`,使用中文标题、`关键变更:` 以及 `LDVH-Provider` / `LDVH-Model` trailer 署名;Git Gate 仅在暂存区触及 `ldvh-base/`、`specs/` 或 `plugin-specs/` 时强拦,不阻碍人类手工提交与 `git merge`。
115
+ - **术语提示**:v2 已将 `Spark → Intent`(`ldvh-base/intents/`),并移除 `Milestone` 与 `Friction` 层级(旧仓残留目录自动忽略,推进事项统一收敛至 `Intent`,反复卡点有效临时规避沉淀为 `Pitfall`);旧仓迁移指引见看板帮助页「自检与排错」。
117
116
 
118
117
  ## 目录结构
119
118
 
@@ -122,10 +121,11 @@ plugin.json mcp_config.json hooks.json Antigravity 清单
122
121
  .codex-plugin/plugin.json .mcp.json Codex 清单(.mcp.json 同时供 Claude Code 使用)
123
122
  .claude-plugin/plugin.json Claude Code 清单
124
123
  lib/ server/ hooks/ cli/ 宿主无关核心:事实源、MCP 服务、Hook 引擎、命令行
125
- adapters/ 三宿主薄适配层与安装器
124
+ adapters/ 多宿主薄适配层与安装器
126
125
  skills/ agents/ rules/ 操作指引、子代理与治理锚点
126
+ plugin-specs/ 随包内置的运行时结构化规范(16 份 YAML)
127
127
  web/ React 看板与 Express 接口
128
- specs/ 规范原文
128
+ specs/ 开发期完整中文规范原文(不随 npm 包分发)
129
129
  ```
130
130
 
131
131
  更多设计见 [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md),版本变化见 [CHANGELOG.md](CHANGELOG.md)。
@@ -133,6 +133,7 @@ specs/ 规范原文
133
133
  ## 开发
134
134
 
135
135
  ```bash
136
+ npm run check # 依次执行 build:bundles + lint + build:web + check:pii + test
136
137
  npm run lint
137
138
  npm test
138
139
  ```
@@ -1,6 +1,7 @@
1
- import { rm } from "node:fs/promises";
1
+ import { readFile, rm } from "node:fs/promises";
2
2
  import { homedir } from "node:os";
3
3
  import { join, resolve } from "node:path";
4
+ import { createDataPathResolver } from "../../lib/data-paths.js";
4
5
  import { copyFileTo, linkDependencyDir, mirrorDir, pathKind, readJsonIfExists } from "../_fs.js";
5
6
 
6
7
  export const host = "antigravity";
@@ -16,7 +17,7 @@ export const capabilities = Object.freeze({
16
17
  });
17
18
 
18
19
  const FILES = Object.freeze(["plugin.json", "mcp_config.json", "hooks.json", "package.json", "LICENSE"]);
19
- const MIRRORED_DIRS = Object.freeze(["lib", "server", "hooks", "cli", "adapters", "specs", "rules", "skills", "agents", "assets"]);
20
+ const MIRRORED_DIRS = Object.freeze(["lib", "server", "hooks", "cli", "adapters", "plugin-specs", "rules", "skills", "agents", "assets"]);
20
21
  const WEB_MIRRORED = Object.freeze(["api", "api-js", "shared", "shared-js", "src", "public", "scripts", "dist"]);
21
22
  const WEB_FILES = Object.freeze([
22
23
  "package.json", "pnpm-lock.yaml", "pnpm-workspace.yaml", "tsconfig.json", "tsconfig.app.json",
@@ -63,7 +64,62 @@ function plan() {
63
64
  };
64
65
  }
65
66
 
66
- export async function install({ repoRoot, targetDir = defaultTargetDir(), apply = false } = {}) {
67
+ async function reloadRunningDaemonWeb(dataDir) {
68
+ const dataPath = createDataPathResolver(dataDir);
69
+ const runtimeFile = dataPath("ldvh", "runtime.json");
70
+ let runtime;
71
+ try {
72
+ runtime = JSON.parse(await readFile(runtimeFile, "utf8"));
73
+ } catch {
74
+ return { attempted: false, reloaded: false, restarted: false, reason: "no_runtime_file" };
75
+ }
76
+ if (!runtime || typeof runtime.port !== "number" || typeof runtime.token !== "string") {
77
+ return { attempted: false, reloaded: false, restarted: false, reason: "invalid_runtime_file" };
78
+ }
79
+ const hostAddr = typeof runtime.host === "string" && runtime.host.length > 0 ? runtime.host : "127.0.0.1";
80
+ const controller = new AbortController();
81
+ const timer = setTimeout(() => controller.abort(), 1500);
82
+ try {
83
+ const res = await fetch(`http://${hostAddr}:${runtime.port}/admin/reload-web`, {
84
+ method: "POST",
85
+ headers: { "x-ldvh-token": runtime.token },
86
+ signal: controller.signal,
87
+ });
88
+ if (res.ok) {
89
+ return {
90
+ attempted: true,
91
+ reloaded: true,
92
+ restarted: false,
93
+ reason: "web_reloaded",
94
+ pid: runtime.pid ?? null,
95
+ note: "已热重载看板 Web API 子进程;若改动了 server/lib/hooks,请在 Antigravity 插件管理页刷新 MCP 服务",
96
+ };
97
+ }
98
+ if (res.status === 404) {
99
+ return {
100
+ attempted: true,
101
+ reloaded: false,
102
+ restarted: false,
103
+ reason: "legacy_daemon_no_reload_endpoint",
104
+ pid: runtime.pid ?? null,
105
+ note: "运行中的旧版 daemon 不支持热重载端点,未关停看板;请在 Antigravity 插件管理页刷新 MCP 服务",
106
+ };
107
+ }
108
+ return {
109
+ attempted: true,
110
+ reloaded: false,
111
+ restarted: false,
112
+ reason: `http_${res.status}`,
113
+ pid: runtime.pid ?? null,
114
+ };
115
+ } catch {
116
+ return { attempted: true, reloaded: false, restarted: false, reason: "daemon_unreachable", pid: runtime.pid ?? null };
117
+ } finally {
118
+ clearTimeout(timer);
119
+ }
120
+ }
121
+
122
+ export async function install({ repoRoot, targetDir = defaultTargetDir(), apply = false, dataDir, restartDaemon = true } = {}) {
67
123
  const root = resolve(repoRoot);
68
124
  const target = resolve(targetDir);
69
125
  const steps = plan();
@@ -97,8 +153,9 @@ export async function install({ repoRoot, targetDir = defaultTargetDir(), apply
97
153
  nodeModules: await linkDependencyDir(join(root, "node_modules"), join(target, "node_modules")),
98
154
  webNodeModules: await linkDependencyDir(join(root, "web", "node_modules"), join(target, "web", "node_modules")),
99
155
  };
156
+ const daemon = restartDaemon ? await reloadRunningDaemonWeb(dataDir) : { attempted: false, reloaded: false, restarted: false, reason: "skipped" };
100
157
  const after = await inspect({ repoRoot: root, targetDir: target });
101
- return { ok: after.realDirectory && after.upToDate, host, applied: true, targetDir: target, removed, links, state: after };
158
+ return { ok: after.realDirectory && after.upToDate, host, applied: true, targetDir: target, removed, links, daemon, state: after };
102
159
  }
103
160
 
104
161
  export function describeSetup({ repoRoot } = {}) {
@@ -1,12 +1,14 @@
1
1
  import { join } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { collectLdvhTools } from "../../server/tool-registry.js";
4
- import { createDataPathResolver } from "../../lib/data-paths.js";
4
+ import { createDataPathResolver, readPluginSettings, writePluginSettings } from "../../lib/data-paths.js";
5
5
  import { createGovernanceHandler } from "../../lib/host-api.js";
6
6
  import { createHostSeams } from "../../lib/host-seams.js";
7
7
  import { ensureRegistrationCarrier } from "../../lib/governed-projects.js";
8
8
  import { repairHooksOnStartup } from "../../lib/hook-repair.js";
9
9
  import { createProxyHandler, createSpaHandler, createWebApiProcess } from "../../lib/web-mount.js";
10
+ import { resolveGovernanceScope } from "../../lib/governance-scope.js";
11
+ import { createAssembleHandler } from "../../lib/guidance.js";
10
12
 
11
13
  /**
12
14
  * DSH 宿主薄适配层。核心逻辑全部来自根仓 lib/ 与 server/,这里只做三件事:
@@ -32,7 +34,6 @@ const DEFAULT_CONFIG = Object.freeze({
32
34
  researchConsultAskEnabled: false,
33
35
  reviewAskSilentRunEnabled: false,
34
36
  experienceAccumulationEnabled: true,
35
- frictionDiscoveryEnabled: true,
36
37
  });
37
38
 
38
39
  /** 配置面:装有 schemastery 时返回带校验的 Schema,否则降级为纯对象默认值。 */
@@ -49,7 +50,6 @@ export async function createConfigSchema() {
49
50
  researchConsultAskEnabled: volatile(z.boolean().default(false)),
50
51
  reviewAskSilentRunEnabled: volatile(z.boolean().default(false)),
51
52
  experienceAccumulationEnabled: volatile(z.boolean().default(true)),
52
- frictionDiscoveryEnabled: volatile(z.boolean().default(true)),
53
53
  });
54
54
  } catch {
55
55
  return { ...DEFAULT_CONFIG };
@@ -69,6 +69,50 @@ function json(res, statusCode, body) {
69
69
  res.end(JSON.stringify(body));
70
70
  }
71
71
 
72
+ const ALLOWED_BUDGET_TIERS = new Set([10, 20, 30, 40, 50]);
73
+ const BOOLEAN_SETTING_KEYS = new Set([
74
+ "webEnabled",
75
+ "preActionReviewAskEnabled",
76
+ "postWorkReviewAskEnabled",
77
+ "researchConsultAskEnabled",
78
+ "reviewAskSilentRunEnabled",
79
+ "experienceAccumulationEnabled",
80
+ ]);
81
+
82
+ async function readJsonBody(req) {
83
+ const chunks = [];
84
+ let total = 0;
85
+ for await (const chunk of req) {
86
+ total += chunk.length;
87
+ if (total > 1024 * 1024) throw new Error("Request body too large");
88
+ chunks.push(chunk);
89
+ }
90
+ const text = Buffer.concat(chunks).toString("utf8").trim();
91
+ return text ? JSON.parse(text) : {};
92
+ }
93
+
94
+ function validateSettingsPatch(raw) {
95
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
96
+ return { ok: false, error: "Request body must be a JSON object" };
97
+ }
98
+ const clean = {};
99
+ for (const [key, value] of Object.entries(raw)) {
100
+ if (BOOLEAN_SETTING_KEYS.has(key)) {
101
+ if (typeof value !== "boolean") return { ok: false, error: `Setting "${key}" must be a boolean` };
102
+ clean[key] = value;
103
+ continue;
104
+ }
105
+ if (key === "injectionBudgetTier") {
106
+ const numeric = Number(value);
107
+ if (!Number.isInteger(numeric) || !ALLOWED_BUDGET_TIERS.has(numeric)) {
108
+ return { ok: false, error: "injectionBudgetTier must be one of 10, 20, 30, 40, 50" };
109
+ }
110
+ clean.injectionBudgetTier = numeric;
111
+ }
112
+ }
113
+ return { ok: true, patch: clean };
114
+ }
115
+
72
116
  export function apply(ctx, config = {}) {
73
117
  const dataPath = createDataPathResolver();
74
118
  const settings = () => ({
@@ -92,6 +136,20 @@ export function apply(ctx, config = {}) {
92
136
  ctx.logger?.info?.("[ldvh] host seam %s: %s (%s)", seam.state, seam.seam, seam.detail);
93
137
  }
94
138
 
139
+ // 若 DSH 宿主提供 systemPrompt 装配扩展,接入治理引导;未提供时安全降级不报错
140
+ try {
141
+ const sp = ctx.get?.("systemPrompt") ?? ctx.systemPrompt;
142
+ if (typeof sp?.register === "function") {
143
+ disposers.push(sp.register((agent) => createAssembleHandler(agent, {
144
+ resolve: (cwd) => resolveGovernanceScope(dataPath, cwd),
145
+ syncTools: () => {},
146
+ recordScope: () => {},
147
+ })));
148
+ }
149
+ } catch {
150
+ // 宿主未提供 systemPrompt 扩展时安全降级
151
+ }
152
+
95
153
  ctx.inject(["webServer"], (webCtx) => {
96
154
  const webServer = webCtx.webServer;
97
155
  if (webServer === undefined || readValue(config?.webEnabled, true) === false) return;
@@ -126,6 +184,28 @@ export function apply(ctx, config = {}) {
126
184
  json(res, 200, { ok: true, service: "ld-vibe-harness", host: "dsh" });
127
185
  return;
128
186
  }
187
+ if (path === `${API_PREFIX}/plugin-settings`) {
188
+ if (req.method === "GET") {
189
+ const current = await readPluginSettings(dataPath);
190
+ json(res, 200, { ok: true, settings: current, runtime: { host: "dsh", platform: process.platform } });
191
+ return;
192
+ }
193
+ if (req.method === "POST") {
194
+ try {
195
+ const raw = await readJsonBody(req);
196
+ const validated = validateSettingsPatch(raw);
197
+ if (!validated.ok) {
198
+ json(res, 400, { ok: false, error: validated.error });
199
+ return;
200
+ }
201
+ const updated = await writePluginSettings(dataPath, validated.patch);
202
+ json(res, 200, { ok: true, settings: updated });
203
+ } catch (error) {
204
+ json(res, 400, { ok: false, error: String(error?.message ?? error) });
205
+ }
206
+ return;
207
+ }
208
+ }
129
209
  if ((await governance(req, res)) !== false) return;
130
210
  const url = new URL(req.url ?? "/", "http://ldvh.local");
131
211
  await proxy(req, res, path.slice(API_PREFIX.length) || "/", url.search);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ldvh-dsh-adapter",
3
- "version": "0.1.0",
4
- "description": "LDVH 的 DSH Cordis 适配层:把仓库内七类结构化事实源工具、受控写入守卫与本地 Web 看板接入 DSH,并与 Antigravity / Codex 共享 ~/.ldvh 数据目录。",
3
+ "version": "0.3.0",
4
+ "description": "LDVH 的 DSH Cordis 适配层:把仓库内五类结构化事实源工具(Goal、Intent、Norm、Report、Pitfall)、受控写入守卫与本地 Web 看板接入 DSH,并与 Antigravity / Codex 共享 ~/.ldvh 数据目录。",
5
5
  "private": true,
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: ldvh-experience-recorder
3
- description: LDVH 经验记录代理。主控授权后,把已验证的失败机制起草并创建为一条结构化 Pitfall;先查重,只允许创建,禁止改动或终态既有经验。
3
+ description: LDVH 经验记录代理。主控授权后,把已验证的失败机制或反复卡点有效临时规避起草并创建为一条结构化 Pitfall;先查重,只允许创建,禁止改动或终态既有经验。
4
4
  ---
5
5
 
6
6
  # LDVH 经验记录者
7
7
 
8
- 你负责把一个**已验证的失败机制**沉淀为项目经验(Pitfall)。你只有一次授权窗口,且只能创建。
8
+ 你负责把一个**已验证的失败机制或反复卡点有效临时规避**沉淀为项目经验(Pitfall)。你只有一次授权窗口,且只能创建。
9
9
 
10
10
  ## 前提
11
11
 
@@ -30,4 +30,3 @@ description: LDVH 经验记录代理。主控授权后,把已验证的失败
30
30
 
31
31
  - 只允许 `ldvh_pitfall_write(action="create")`;禁止更新、勘误、转终态,也不触碰其他类型事实对象的写入入口。
32
32
  - 不调用 `ldvh_pitfall_arm_delegate`(仅主控可授权)。
33
- - 若在整理材料时发现规则冲突或反复出现的卡点,可调用 `ldvh_friction_record_observation` 记一条摩擦观察。
@@ -35,4 +35,3 @@ description: LDVH 收口前独立复核代理(零上下文视角)。对已
35
35
  - 不修改文件,不替主控补做,不绕过门禁。
36
36
  - 只陈述自己实际看到、跑到的内容;没跑的就写没跑。
37
37
  - 你的结论不构成完成依据或 Human 授权,最终由主控与 Human 决定。
38
- - 若发现规则与实现互相冲突、工具缺陷或反复出现的卡点,可顺手调用 `ldvh_friction_record_observation` 记一条摩擦观察(写“观察到什么”,不写结论,逐字引证)。
@@ -35,4 +35,3 @@ description: LDVH 行动前独立方案审查代理(零上下文视角)。
35
35
 
36
36
  - 不修改任何文件,不替主控动手,不绕过门禁。
37
37
  - 你的结论不构成授权凭据,也不是完成依据,最终由主控与 Human 决定。
38
- - 若发现规则与实现互相冲突、工具缺陷或反复出现的卡点,可顺手调用 `ldvh_friction_record_observation` 记一条摩擦观察(写“观察到什么”,不写结论,逐字引证)。
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: ldvh-researcher
3
- description: LDVH 零上下文联网调研代理。围绕主控给定的 need、scope 与子问题做外部取证,每个子问题给出“已证实 / 存在冲突或不确定 / 未查到”三态结论与逐字引证。只调研,不写库。
3
+ description: LDVH 可选零上下文联网调研辅助代理(常规联网调查由主控亲自执行完整工序;仅在主控按需拆分局部有界检索子任务时委派)。围绕主控给定的 need、scope 与子问题做外部取证,每个子问题给出“已证实 / 存在冲突或不确定 / 未查到”三态结论与逐字引证。只调研,不写库。
4
4
  ---
5
5
 
6
6
  # LDVH 零上下文调研者
@@ -38,4 +38,3 @@ description: LDVH 零上下文联网调研代理。围绕主控给定的 need、
38
38
 
39
39
  - 不写入任何事实源。需要沉淀为报告,交还主控,由主控通过 `ldvh_report_session` / `ldvh_report_write` 走审核与受控写入。
40
40
  - 你的结论只是证据,不是决定;采纳与否由主控与 Human 决定。
41
- - 若发现规则与实现互相冲突、工具缺陷或反复出现的卡点,可顺手调用 `ldvh_friction_record_observation` 记一条摩擦观察。