ld-vibe-harness 0.2.0 → 0.4.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.
- package/.codex-plugin/plugin.json +5 -4
- package/.mcp.json +6 -0
- package/CHANGELOG.md +155 -73
- package/README.en.md +114 -104
- package/README.md +153 -145
- package/adapters/antigravity/installer.js +26 -8
- package/adapters/codex/agent-profiles.js +42 -0
- package/adapters/codex/installer.js +20 -8
- package/adapters/codex/native-plugin.js +104 -0
- package/adapters/dsh/index.js +376 -240
- package/adapters/dsh/installer.js +8 -8
- package/adapters/dsh/package.json +2 -2
- package/agents/ldvh-experience-recorder.md +3 -4
- package/agents/ldvh-post-work-reviewer.md +0 -1
- package/agents/ldvh-pre-action-reviewer.md +0 -1
- package/agents/ldvh-researcher.md +1 -2
- package/cli/ldvh.mjs +173 -9
- package/cordis.patch.yml +1 -1
- package/docs/ARCHITECTURE.md +40 -39
- package/docs/DETAIL.md +39 -0
- package/docs/PRIVACY.md +7 -6
- package/docs/screenshots/01-focus.png +0 -0
- package/docs/screenshots/02-facts.png +0 -0
- package/docs/screenshots/03-diagnostics.png +0 -0
- package/docs/screenshots/04-help.png +0 -0
- package/hooks/_client.mjs +1 -12
- package/hooks/codex.json +75 -0
- package/hooks/codex.mjs +108 -0
- package/hooks/hook-engine.js +849 -86
- package/lib/capture-notice.js +8 -22
- package/lib/client.js +1558 -0
- package/lib/codex-agent-roles.js +8 -0
- package/lib/codex-host-seams.js +51 -0
- package/lib/codex-session.js +154 -0
- package/lib/commit-validation.js +4 -61
- package/lib/data-paths.js +73 -68
- package/lib/experience-arming.js +44 -18
- package/lib/gate-events.js +55 -2
- package/lib/git-gate-runner.js +87 -35
- package/lib/goal-anchor.js +17 -45
- package/lib/goal-tools.js +4 -26
- package/lib/goal-writer.js +5 -18
- package/lib/governed-projects.js +18 -7
- package/lib/guidance-budget.js +2 -2
- package/lib/guidance-text.js +8 -7
- package/lib/hook-manager.js +42 -14
- package/lib/hook-repair.js +77 -13
- package/lib/host-api.js +7 -3
- package/lib/host-doctor.js +174 -0
- package/lib/host-seams.js +921 -869
- package/lib/idle-settings.js +1 -4
- package/lib/intent-tools.js +11 -16
- package/lib/intent-trace-tools.js +484 -0
- package/lib/intent-writer.js +12 -45
- package/lib/ldvh-tools.js +93 -78
- package/lib/norm-tools.js +1 -1
- package/lib/object-identifier.js +0 -2
- package/lib/object-reference.js +0 -2
- package/lib/operation-declarations.bundle.json +30 -66
- package/lib/pitfall-tools.js +75 -9
- package/lib/recall-criteria.bundle.json +2 -69
- package/lib/recall-criteria.js +0 -2
- package/lib/recall-evaluation.js +301 -0
- package/lib/recall-injection.js +2 -6
- package/lib/recall-synonyms.js +1 -3
- package/lib/report-tools.js +140 -74
- package/lib/report-writer.js +79 -17
- package/lib/research-consult-tools.js +204 -19
- package/lib/research-consult.js +49 -27
- package/lib/research-session.js +124 -13
- package/lib/review-ask-tool.js +533 -437
- package/lib/review-ask.js +337 -317
- package/lib/review-dispatch-template.js +9 -0
- package/lib/review-receipt-tools.js +300 -0
- package/lib/session-signature.js +356 -298
- package/lib/source-recall.js +6 -16
- package/lib/web-mount.js +497 -488
- package/lib/web-preferences.js +2 -2
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +136 -101
- package/plugin-specs/experience-accumulation-system-foundation.yaml +7 -27
- package/plugin-specs/fact-model-common.yaml +3 -14
- package/plugin-specs/gate-consult-system-foundation.yaml +44 -33
- package/plugin-specs/goal-fact-type.yaml +20 -67
- package/plugin-specs/goal-planning-system-foundation.yaml +27 -98
- package/plugin-specs/intent-fact-type.yaml +13 -22
- package/plugin-specs/intent-record-system-foundation.yaml +1 -2
- package/plugin-specs/ldvh-root.yaml +6 -6
- package/plugin-specs/norm-fact-type.yaml +1 -1
- package/plugin-specs/pitfall-fact-type.yaml +5 -49
- package/plugin-specs/report-fact-type.yaml +23 -35
- package/plugin-specs/research-system-foundation.yaml +18 -15
- package/plugin.json +4 -4
- package/rules/AGENTS.md +4 -4
- package/server/local-daemon.js +86 -28
- package/server/mcp-server.js +299 -76
- package/server/tool-registry.js +0 -23
- package/skills/ldvh-governance-flow/SKILL.md +28 -16
- package/skills/ldvh-onboarding/SKILL.md +4 -3
- package/web/api-js/app.js +172 -0
- package/web/api-js/index.js +4 -0
- package/web/api-js/routes/auth.js +15 -0
- package/web/api-js/routes/changelog.js +38 -0
- package/web/api-js/routes/cognition.js +484 -0
- package/web/api-js/routes/diagnostics.js +56 -0
- package/web/api-js/routes/docs.js +51 -0
- package/web/api-js/routes/federation.js +129 -0
- package/web/api-js/routes/objects.js +244 -0
- package/web/api-js/routes/project-files.js +361 -0
- package/web/api-js/routes/settings.js +57 -0
- package/web/api-js/server.js +21 -0
- package/web/api-js/services/crossWorktreeMerger.js +80 -0
- package/web/api-js/services/factFieldContract.js +83 -0
- package/web/api-js/services/facts.js +363 -0
- package/web/api-js/services/git.js +257 -0
- package/web/api-js/services/governanceScope.js +174 -0
- package/web/api-js/services/governedProjectsSettings.js +218 -0
- package/web/api-js/services/localFactReader.js +346 -0
- package/web/api-js/services/projectFiles.js +119 -0
- package/web/api-js/services/pytools.js +7 -0
- package/web/api-js/services/requestScope.js +40 -0
- package/web/api-js/services/runtimeDiagnostics.js +405 -0
- package/web/api-js/services/time.js +63 -0
- package/web/api-js/services/typeColors.js +12 -0
- package/web/api-js/services/workspaceWorktrees.js +146 -0
- package/web/dist/assets/index-BzWFRVF4.js +573 -0
- package/web/dist/assets/index-BzWFRVF4.js.gz +0 -0
- package/web/dist/assets/index-DVsO2qQa.css +1 -0
- package/web/dist/assets/index-DVsO2qQa.css.gz +0 -0
- package/web/dist/assets/ldvh-plugin-icon-DFJztt0E.png +0 -0
- package/web/dist/index.html +15 -0
- package/web/dist/index.html.gz +0 -0
- package/web/dist/ldvh-plugin-icon-180.png +0 -0
- package/web/dist/ldvh-plugin-icon-32.png +0 -0
- package/web/shared-js/factChangeLog.js +71 -0
- package/web/shared-js/factIdentity.js +4 -0
- package/web/shared-js/gateCorrelation.js +10 -0
- package/web/shared-js/projectColors.js +29 -0
- package/web/shared-js/signature.js +34 -0
- package/web/shared-js/timestamp.js +83 -0
- package/.claude-plugin/plugin.json +0 -16
- package/agents/ldvh-friction-recorder.md +0 -27
- package/lib/aux-task-registry.js +0 -129
- package/lib/friction-discovery.js +0 -383
- package/lib/friction-failure-registration.js +0 -56
- package/lib/friction-observation-buffer.js +0 -889
- package/lib/friction-promotion-lock.js +0 -124
- package/lib/friction-review-promotion.js +0 -193
- package/lib/friction-tools.js +0 -829
- package/lib/friction-writer.js +0 -1123
- package/lib/milestone-tools.js +0 -684
- package/lib/milestone-writer.js +0 -707
- package/lib/verification-run.js +0 -195
- package/plugin-specs/friction-fact-type.yaml +0 -333
- package/plugin-specs/friction-settlement-system-foundation.yaml +0 -334
- package/plugin-specs/milestone-fact-type.yaml +0 -212
package/README.md
CHANGED
|
@@ -1,145 +1,153 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<img src="assets/ldvh-plugin-icon-128.png" width="88" alt="LDVH 图标" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
<h1 align="center">LDVH · LD Vibe Harness</h1>
|
|
6
|
-
|
|
7
|
-
<p align="center"><b>把目标、规范、意图与踩坑经验落成随 Git 演进的结构化事实,用轻量索引召回、人工门禁与 Git Gate 约束 AI 协作。</b></p>
|
|
8
|
-
|
|
9
|
-
<p align="center">
|
|
10
|
-
<a href="README.en.md">English</a> ·
|
|
11
|
-
<a href="#支持的宿主">支持的宿主</a> ·
|
|
12
|
-
<a href="#快速开始">快速开始</a> ·
|
|
13
|
-
<a href="#web-看板">Web 看板</a> ·
|
|
14
|
-
<a href="CHANGELOG.md">更新日志</a> ·
|
|
15
|
-
<a href="RELEASING.md">发布流程</a> ·
|
|
16
|
-
<a href="https://github.com/dingminhua/ld-vibe-harness/issues">问题反馈</a>
|
|
17
|
-
</p>
|
|
18
|
-
|
|
19
|
-
<p align="center">
|
|
20
|
-
<a href="https://www.npmjs.com/package/ld-vibe-harness"><img src="https://img.shields.io/npm/v/ld-vibe-harness?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
|
|
21
|
-
<a href="https://www.npmjs.com/package/ld-vibe-harness"><img src="https://img.shields.io/npm/d18m/ld-vibe-harness?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
|
|
22
|
-
<a href="https://github.com/dingminhua/ld-vibe-harness/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/dingminhua/ld-vibe-harness/ci.yml?branch=main&style=flat-square&label=tests" alt="test status"></a>
|
|
23
|
-
<a href="LICENSE"><img src="https://img.shields.io/github/license/dingminhua/ld-vibe-harness?style=flat-square" alt="MIT license"></a>
|
|
24
|
-
<a href="https://github.com/dingminhua/ld-vibe-harness/stargazers"><img src="https://img.shields.io/github/stars/dingminhua/ld-vibe-harness?style=flat-square" alt="GitHub stars"></a>
|
|
25
|
-
</p>
|
|
26
|
-
|
|
27
|
-
**LD Vibe Harness** 是 LaoDing 基于长期 AI 协作开发经验所作的一种探索,为 Human 与 AI 协同推进长期项目提供清晰边界、可靠依据和可复用的经验、规则与能力,帮助工作持续接续,并为项目在实际积累中逐步变得更稳定、更可控、更高效创造条件,简称为 **LDVH**。
|
|
28
|
-
|
|
29
|
-
AI 编程的两个老问题:
|
|
30
|
-
|
|
31
|
-
- **Vibe 漂移**:会话一长或换会话,AI 就忘了项目目标、既定规矩与未决想法,开始凭感觉改代码。
|
|
32
|
-
- **Coding 失控**:AI
|
|
33
|
-
|
|
34
|
-
LDVH 给 AI
|
|
35
|
-
|
|
36
|
-
## 支持的宿主
|
|
37
|
-
|
|
38
|
-
| 宿主 | 接入方式 | MCP 工具 | Hook 自动注入 | 人工门禁 | 子代理把关 | 内嵌看板 |
|
|
39
|
-
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
40
|
-
| Antigravity | `plugin.json` + `mcp_config.json` + `hooks.json` | ✅ | ✅(兼容直连与 `call_mcp_tool`) | Hook `
|
|
41
|
-
| Codex |
|
|
42
|
-
| DSH | `adapters/dsh`(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
|
52
|
-
|
|
|
53
|
-
| 对齐 Vibe |
|
|
54
|
-
| 对齐 Vibe |
|
|
55
|
-
|
|
|
56
|
-
| 协调 Coding |
|
|
57
|
-
| 协调 Coding |
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
cd
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
登记一个受管辖项目(需要你明确确认):
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
node cli/ldvh.mjs governed-project install --project /abs/path/to/repo --id my-repo --human-confirmed
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
##
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="assets/ldvh-plugin-icon-128.png" width="88" alt="LDVH 图标" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">LDVH · LD Vibe Harness</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center"><b>把目标、规范、意图与踩坑经验落成随 Git 演进的结构化事实,用轻量索引召回、人工门禁与 Git Gate 约束 AI 协作。</b></p>
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="README.en.md">English</a> ·
|
|
11
|
+
<a href="#支持的宿主">支持的宿主</a> ·
|
|
12
|
+
<a href="#快速开始">快速开始</a> ·
|
|
13
|
+
<a href="#web-看板">Web 看板</a> ·
|
|
14
|
+
<a href="CHANGELOG.md">更新日志</a> ·
|
|
15
|
+
<a href="RELEASING.md">发布流程</a> ·
|
|
16
|
+
<a href="https://github.com/dingminhua/ld-vibe-harness/issues">问题反馈</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p align="center">
|
|
20
|
+
<a href="https://www.npmjs.com/package/ld-vibe-harness"><img src="https://img.shields.io/npm/v/ld-vibe-harness?style=flat-square&label=npm&color=cb3837" alt="npm version"></a>
|
|
21
|
+
<a href="https://www.npmjs.com/package/ld-vibe-harness"><img src="https://img.shields.io/npm/d18m/ld-vibe-harness?style=flat-square&label=downloads&color=cb3837" alt="npm downloads"></a>
|
|
22
|
+
<a href="https://github.com/dingminhua/ld-vibe-harness/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/dingminhua/ld-vibe-harness/ci.yml?branch=main&style=flat-square&label=tests" alt="test status"></a>
|
|
23
|
+
<a href="LICENSE"><img src="https://img.shields.io/github/license/dingminhua/ld-vibe-harness?style=flat-square" alt="MIT license"></a>
|
|
24
|
+
<a href="https://github.com/dingminhua/ld-vibe-harness/stargazers"><img src="https://img.shields.io/github/stars/dingminhua/ld-vibe-harness?style=flat-square" alt="GitHub stars"></a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
**LD Vibe Harness** 是 LaoDing 基于长期 AI 协作开发经验所作的一种探索,为 Human 与 AI 协同推进长期项目提供清晰边界、可靠依据和可复用的经验、规则与能力,帮助工作持续接续,并为项目在实际积累中逐步变得更稳定、更可控、更高效创造条件,简称为 **LDVH**。
|
|
28
|
+
|
|
29
|
+
AI 编程的两个老问题:
|
|
30
|
+
|
|
31
|
+
- **Vibe 漂移**:会话一长或换会话,AI 就忘了项目目标、既定规矩与未决想法,开始凭感觉改代码。
|
|
32
|
+
- **Coding 失控**:AI 自己写、自己说“改好了”;踩过的坑和工具卡点下周重踩;关键约定被顺手改掉也没人拦。
|
|
33
|
+
|
|
34
|
+
LDVH 给 AI 套一副工程缰绳:把目标、想法、规范、经验沉淀成**结构化事实**,每轮动手前自动召回,高风险写入必须人工点头,提交前由 Git Gate 机械把关。
|
|
35
|
+
|
|
36
|
+
## 支持的宿主
|
|
37
|
+
|
|
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/agents` | ✅ | ✅(审核并信任 Hooks 后) | MCP 审批 + `human_confirmed` / Web / CLI | ✅(独立 Codex 代理) | 浏览器 |
|
|
42
|
+
| DSH | `adapters/dsh` + `lib/client.js`(Host + Client 双平面) | ✅ | — | 内嵌交互 | ✅ | ✅(宿主内设置页 + 对话/侧边栏 Tab) |
|
|
43
|
+
|
|
44
|
+
“—”表示该接入目前没有对应的自动化能力。Codex 会话署名读取本机 Codex 保存的会话与回合记录。
|
|
45
|
+
|
|
46
|
+
三个宿主默认**共享同一个数据目录 `~/.ldvh`**:在 Antigravity 里记下的目标与经验,换到 Codex 或 DSH 照样能召回。需要隔离时设置环境变量 `LDVH_DATA_DIR`。
|
|
47
|
+
|
|
48
|
+
## 六个业务系统
|
|
49
|
+
|
|
50
|
+
| 价值 | 业务系统 | 作用 |
|
|
51
|
+
| :--- | :--- | :--- |
|
|
52
|
+
| 对齐 Vibe | 目标规划 | Goal 承载项目长期目标陈述与达成边界 |
|
|
53
|
+
| 对齐 Vibe | 意图记录 | Intent 承接项目跨行动要推进的事情与待决方向线 |
|
|
54
|
+
| 对齐 Vibe | 双源召回 | 每轮动手前按预算从规范源与事实源注入轻量候选索引、常驻 Goal 锚点与同回合路径上下文提醒,支持按节渐进式精读 |
|
|
55
|
+
| 协调 Coding | 把关请示 | 统一三类提请题面:行动前审方案、收口前复核结果(三选一),遇复杂外部难题先内查再二选一请示是否联网(人主动提出不重复请示) |
|
|
56
|
+
| 协调 Coding | 调研吸收 | 主控先内查再亲自联网取证(可选派发 `ldvh-researcher` 局部辅助),按内容性质沉淀三形态 Report(`research` 外部调研 `urls` 溯源 / `summary` 阶段总结禁 `urls` 内部锚点逐字摘录 / `reference` 未验证信息禁 `urls` 免内部锚点校验,创建后不可变更) |
|
|
57
|
+
| 协调 Coding | 经验积累 | 已验证失败机制与反复卡点有效临时规避统一沉淀为 Pitfall,由后台代理异步查重创建 |
|
|
58
|
+
|
|
59
|
+
四层防线:主控自查 → 机械校验(受控写入、写后回读、Git Gate)→ 可选代理审核 → 可选代理复核。登记/取消管辖、Intent/Norm 创建与终态等高风险写入始终走人工门禁(Human 确认后若机械校验失败,授权保留供修正参数直接重试,直至落盘成功才失效)。
|
|
60
|
+
|
|
61
|
+
## 快速开始
|
|
62
|
+
|
|
63
|
+
需要 Node.js ≥ 22.15(通过 npm 包安装已预含 `web/dist`、`web/api-js`、`web/shared-js` 与 `lib/*.bundle.json`;从源码仓库直接运行需先构建前端看板)。
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
git clone https://github.com/dingminhua/ld-vibe-harness.git
|
|
67
|
+
cd ld-vibe-harness
|
|
68
|
+
npm install
|
|
69
|
+
(cd web && pnpm install && pnpm run build:dsh) # 构建 Web 看板(web/dist 不入库)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
查看支持的宿主与接入状态:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
node cli/ldvh.mjs host list
|
|
76
|
+
node cli/ldvh.mjs host inspect --host antigravity
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
各宿主接入(不加 `--apply` 只演练、不写盘):
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Antigravity:同步到 ~/.gemini/config/plugins/ldvh
|
|
83
|
+
node cli/ldvh.mjs host setup --host antigravity --apply
|
|
84
|
+
|
|
85
|
+
# Codex:注册 LDVH Local 插件目录并安装原生代理
|
|
86
|
+
node cli/ldvh.mjs host setup --host codex --plugin --apply
|
|
87
|
+
|
|
88
|
+
# DSH:用 DSH 自带命令登记
|
|
89
|
+
dsh plugin --profile <profile> add ./adapters/dsh
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Codex 安装后开一条本地会话,在桌面端的「设置 → Hooks」或 CLI 的 `/hooks` 中审核并信任 LDVH 的插件 Hooks。安装器为本机生成绝对运行入口。移动源码或 npm 安装目录后重新运行安装命令。省略 `--plugin` 可使用 MCP 直连和技能,自动召回与代理授权绑定由原生插件 Hooks 提供。
|
|
93
|
+
|
|
94
|
+
登记一个受管辖项目(需要你明确确认):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
node cli/ldvh.mjs governed-project install --project /abs/path/to/repo --id my-repo --human-confirmed
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### 跨宿主复核与诊断
|
|
101
|
+
|
|
102
|
+
- `ldvh_review_receipt` 可生成、交还和核对带暂存内容身份的复核回执。收口请示携带 `bind_staged_content=true` 和待核对的 `claims` 时,独立复核任务书会附上内容身份。预检可显式带入回执,查看它与当前暂存区是否相符。
|
|
103
|
+
- `ldvh_trace_intent` 使用已完成 Intent 的 UID 定位当前项目 Goal、明示的 Norm / Report 引用、断链和本地 Git 证据。
|
|
104
|
+
- `ldvh_report_session` 用 `export` 交出版本化证据快照,再在另一会话用 `restore` 恢复。`ldvh_pitfall_arm_delegate` 的可选 `evidence` 包含失败输出、复现位置与步骤、验证方法及结果,随回执交给已授权记录代理。
|
|
105
|
+
- `node cli/ldvh.mjs recall evaluate` 运行固定召回基线。需要测自己的仓库时,传 `--cases FILE --project PATH`,JSON 用例格式可从默认评测的 `--json` 输出中查看每项 `input`。
|
|
106
|
+
- `node cli/ldvh.mjs host doctor --host codex --project .` 只读检查接入状态,也可指定 `antigravity` 或 `dsh`。看板「诊断」页可按会话、回合、代理、事实或快照查找关联事件。
|
|
107
|
+
|
|
108
|
+
## Web 看板
|
|
109
|
+
|
|
110
|
+
- **多端访问**:本地守护服务默认监听 `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` 同样全功能直连可用;插件同步或异常关闭时支持热重载与并发自愈。
|
|
111
|
+
- **核心页面**:聚焦(项目/分支两级视角、Goal 目标陈述、Intent 健康度与近期动态)、五类事实对象看板、目录、变更、提交、诊断(单页统一观测面板,直读 `~/.ldvh/ldvh/gate-events.jsonl`,聚合 `MCP` / `DSH` / `Hook` / `CLI` / `Git Gate` 渠道并区分异常拦截与待确认流程中,支持按会话、回合、代理、事实、提交快照与复核内容追踪关联事件)、设置(独立的「自主召回预算」`10–50 KB`、「经验积累」、「把关请示与审查开关」与「管辖项目与 Git Gate 管理」,支持系统原生目录选择框及三层垂直布局的管辖项目卡片以适配窄侧栏)以及 5 章节帮助手册(`/help`)。
|
|
112
|
+
- **预编译直跑**:前端构建产物包含 `web/api-js` 与 `web/shared-js` 预编译后端,免实时转译启动。
|
|
113
|
+
|
|
114
|
+
| 聚焦总览(Goal / 意图健康度 / 近期动态) | 结构化事实看板(五类对象管理) |
|
|
115
|
+
| :---: | :---: |
|
|
116
|
+
|  |  |
|
|
117
|
+
| **诊断与事件账(MCP / DSH / Hook / CLI / Git Gate)** | **五章节交互式帮助手册** |
|
|
118
|
+
|  |  |
|
|
119
|
+
|
|
120
|
+
## 受控提交与统一署名
|
|
121
|
+
|
|
122
|
+
- 仓库提供 **28 个模型可见 MCP 工具**(含只读路由自查工具 `ldvh_session_signature`、复核回执 `ldvh_review_receipt` 与已完成 Intent 追溯 `ldvh_trace_intent`)及 app-only 隧道工具 `ldvh_app_api_proxy`。
|
|
123
|
+
- 在受管辖仓库中,AI 发起任何 `git commit` 均统一先查询 `ldvh_session_signature`,使用中文标题、`关键变更:` 以及 `LDVH-Provider` / `LDVH-Model` trailer 署名;Git Gate 仅在暂存区触及 `ldvh-base/`、`specs/` 或 `plugin-specs/` 时强拦,不阻碍人类手工提交与 `git merge`。
|
|
124
|
+
- **术语提示**:v2 已将 `Spark → Intent`(`ldvh-base/intents/`),并移除 `Milestone` 与 `Friction` 层级(旧仓残留目录自动忽略,推进事项统一收敛至 `Intent`,反复卡点有效临时规避沉淀为 `Pitfall`);Report 已精简为 `research` / `summary` / `reference` 三形态(移除 `audit` 与 `action`,历史文件可归档至 `docs/`),旧仓迁移指引见看板帮助页「自检与排错」。
|
|
125
|
+
|
|
126
|
+
## 目录结构
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
plugin.json mcp_config.json hooks.json Antigravity 清单
|
|
130
|
+
.codex-plugin/plugin.json .mcp.json hooks/codex.json Codex 清单
|
|
131
|
+
lib/ server/ hooks/ cli/ 宿主无关核心:事实源、MCP 服务、Hook 引擎、命令行
|
|
132
|
+
adapters/ 多宿主薄适配层与安装器
|
|
133
|
+
skills/ agents/ rules/ 操作指引、子代理与治理锚点
|
|
134
|
+
plugin-specs/ 随包内置的运行时结构化规范(16 份 YAML)
|
|
135
|
+
web/ React 看板与 Express 接口
|
|
136
|
+
specs/ 开发期完整中文规范原文(不随 npm 包分发)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
更多设计见 [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md),版本变化见 [CHANGELOG.md](CHANGELOG.md)。
|
|
140
|
+
|
|
141
|
+
## 开发
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npm run check # 依次执行 build:bundles + lint + build:web + check:pii + test
|
|
145
|
+
npm run lint
|
|
146
|
+
npm test
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 隐私、发布与许可
|
|
150
|
+
|
|
151
|
+
- **隐私与数据边界**:全本地运行、零遥测,详见 [docs/PRIVACY.md](docs/PRIVACY.md)。
|
|
152
|
+
- **发布流程**:详见 [RELEASING.md](RELEASING.md)。
|
|
153
|
+
- **开源许可**:[MIT](LICENSE)(Copyright (c) 2026 LaoDing)。旧版代码归档在分支 `backup/main-legacy`。
|
|
@@ -64,38 +64,56 @@ function plan() {
|
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
async function
|
|
67
|
+
async function reloadRunningDaemonWeb(dataDir) {
|
|
68
68
|
const dataPath = createDataPathResolver(dataDir);
|
|
69
69
|
const runtimeFile = dataPath("ldvh", "runtime.json");
|
|
70
70
|
let runtime;
|
|
71
71
|
try {
|
|
72
72
|
runtime = JSON.parse(await readFile(runtimeFile, "utf8"));
|
|
73
73
|
} catch {
|
|
74
|
-
return { attempted: false, restarted: false, reason: "no_runtime_file" };
|
|
74
|
+
return { attempted: false, reloaded: false, restarted: false, reason: "no_runtime_file" };
|
|
75
75
|
}
|
|
76
76
|
if (!runtime || typeof runtime.port !== "number" || typeof runtime.token !== "string") {
|
|
77
|
-
return { attempted: false, restarted: false, reason: "invalid_runtime_file" };
|
|
77
|
+
return { attempted: false, reloaded: false, restarted: false, reason: "invalid_runtime_file" };
|
|
78
78
|
}
|
|
79
79
|
const hostAddr = typeof runtime.host === "string" && runtime.host.length > 0 ? runtime.host : "127.0.0.1";
|
|
80
80
|
const controller = new AbortController();
|
|
81
81
|
const timer = setTimeout(() => controller.abort(), 1500);
|
|
82
82
|
try {
|
|
83
|
-
const res = await fetch(`http://${hostAddr}:${runtime.port}/admin/
|
|
83
|
+
const res = await fetch(`http://${hostAddr}:${runtime.port}/admin/reload-web`, {
|
|
84
84
|
method: "POST",
|
|
85
85
|
headers: { "x-ldvh-token": runtime.token },
|
|
86
86
|
signal: controller.signal,
|
|
87
87
|
});
|
|
88
88
|
if (res.ok) {
|
|
89
|
-
return {
|
|
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
|
+
};
|
|
90
107
|
}
|
|
91
108
|
return {
|
|
92
109
|
attempted: true,
|
|
110
|
+
reloaded: false,
|
|
93
111
|
restarted: false,
|
|
94
|
-
reason:
|
|
112
|
+
reason: `http_${res.status}`,
|
|
95
113
|
pid: runtime.pid ?? null,
|
|
96
114
|
};
|
|
97
115
|
} catch {
|
|
98
|
-
return { attempted: true, restarted: false, reason: "daemon_unreachable", pid: runtime.pid ?? null };
|
|
116
|
+
return { attempted: true, reloaded: false, restarted: false, reason: "daemon_unreachable", pid: runtime.pid ?? null };
|
|
99
117
|
} finally {
|
|
100
118
|
clearTimeout(timer);
|
|
101
119
|
}
|
|
@@ -135,7 +153,7 @@ export async function install({ repoRoot, targetDir = defaultTargetDir(), apply
|
|
|
135
153
|
nodeModules: await linkDependencyDir(join(root, "node_modules"), join(target, "node_modules")),
|
|
136
154
|
webNodeModules: await linkDependencyDir(join(root, "web", "node_modules"), join(target, "web", "node_modules")),
|
|
137
155
|
};
|
|
138
|
-
const daemon = restartDaemon ? await
|
|
156
|
+
const daemon = restartDaemon ? await reloadRunningDaemonWeb(dataDir) : { attempted: false, reloaded: false, restarted: false, reason: "skipped" };
|
|
139
157
|
const after = await inspect({ repoRoot: root, targetDir: target });
|
|
140
158
|
return { ok: after.realDirectory && after.upToDate, host, applied: true, targetDir: target, removed, links, daemon, state: after };
|
|
141
159
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { parse } from "yaml";
|
|
4
|
+
import { CODEX_LDVH_AGENTS } from "../../lib/codex-agent-roles.js";
|
|
5
|
+
import { writeFileAtomic } from "../../lib/atomic-write.js";
|
|
6
|
+
import { pathKind } from "../_fs.js";
|
|
7
|
+
|
|
8
|
+
const COMMENT = "# Managed by LDVH";
|
|
9
|
+
|
|
10
|
+
export async function prepareAgentProfiles(repoRoot, home) {
|
|
11
|
+
const profiles = [];
|
|
12
|
+
for (const name of CODEX_LDVH_AGENTS) {
|
|
13
|
+
const markdown = await readFile(join(repoRoot, "agents", name + ".md"), "utf8");
|
|
14
|
+
const header = markdown.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n/);
|
|
15
|
+
const metadata = header ? parse(header[1]) : null;
|
|
16
|
+
if (metadata?.name !== name || typeof metadata.description !== "string") {
|
|
17
|
+
throw new Error("Invalid LDVH agent profile: " + name);
|
|
18
|
+
}
|
|
19
|
+
const target = join(home, "agents", name + ".toml");
|
|
20
|
+
const kind = await pathKind(target);
|
|
21
|
+
const previous = kind === "file" ? await readFile(target, "utf8") : "";
|
|
22
|
+
if ((kind !== "missing" && kind !== "file") || (kind === "file" && previous.split(/\r?\n/, 1)[0] !== COMMENT)) {
|
|
23
|
+
throw new Error("Existing Codex agent profile is not managed by LDVH: " + target);
|
|
24
|
+
}
|
|
25
|
+
const instructions = markdown.slice(header[0].length).trim();
|
|
26
|
+
const text = [
|
|
27
|
+
COMMENT,
|
|
28
|
+
"name = " + JSON.stringify(name),
|
|
29
|
+
"description = " + JSON.stringify(metadata.description),
|
|
30
|
+
"developer_instructions = " + JSON.stringify(instructions),
|
|
31
|
+
"",
|
|
32
|
+
].join("\n");
|
|
33
|
+
profiles.push({ name, target, text, changed: text !== previous });
|
|
34
|
+
}
|
|
35
|
+
return profiles;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function syncAgentProfiles(profiles) {
|
|
39
|
+
for (const profile of profiles) {
|
|
40
|
+
if (profile.changed) await writeFileAtomic(profile.target, profile.text);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -3,14 +3,16 @@ import { homedir } from "node:os";
|
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { writeFileAtomic } from "../../lib/atomic-write.js";
|
|
5
5
|
import { pathKind } from "../_fs.js";
|
|
6
|
+
import { prepareAgentProfiles, syncAgentProfiles } from "./agent-profiles.js";
|
|
7
|
+
import { installCodexPlugin } from "./native-plugin.js";
|
|
6
8
|
|
|
7
9
|
export const host = "codex";
|
|
8
10
|
export const displayName = "Codex";
|
|
9
|
-
export const manifestPaths = Object.freeze([".codex-plugin/plugin.json", ".mcp.json", "skills/"]);
|
|
11
|
+
export const manifestPaths = Object.freeze([".codex-plugin/plugin.json", ".mcp.json", "hooks/codex.json", "skills/"]);
|
|
10
12
|
export const capabilities = Object.freeze({
|
|
11
13
|
mcp: true,
|
|
12
|
-
hooks:
|
|
13
|
-
subagents:
|
|
14
|
+
hooks: true,
|
|
15
|
+
subagents: true,
|
|
14
16
|
embeddedUi: false,
|
|
15
17
|
webDashboard: true,
|
|
16
18
|
gitGate: true,
|
|
@@ -19,7 +21,7 @@ export const capabilities = Object.freeze({
|
|
|
19
21
|
const SERVER_NAME = "ldvh";
|
|
20
22
|
|
|
21
23
|
export function defaultCodexHome() {
|
|
22
|
-
return join(homedir(), ".codex");
|
|
24
|
+
return process.env.CODEX_HOME || join(homedir(), ".codex");
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
function slash(path) {
|
|
@@ -33,9 +35,12 @@ export function renderMcpToml({ repoRoot, serverName = SERVER_NAME } = {}) {
|
|
|
33
35
|
`[mcp_servers.${serverName}]`,
|
|
34
36
|
`command = "node"`,
|
|
35
37
|
`args = ["${root}/server/mcp-server.js"]`,
|
|
38
|
+
`env_vars = ["CODEX_HOME", "LDVH_DATA_DIR"]`,
|
|
36
39
|
``,
|
|
37
40
|
`[mcp_servers.${serverName}.env]`,
|
|
38
41
|
`PLUGIN_ROOT = "${root}"`,
|
|
42
|
+
`LDVH_HOST = "codex"`,
|
|
43
|
+
`LDVH_BIND_HOST = "127.0.0.1"`,
|
|
39
44
|
``,
|
|
40
45
|
].join("\n");
|
|
41
46
|
}
|
|
@@ -79,14 +84,20 @@ export async function inspect({ repoRoot, codexHome = defaultCodexHome(), server
|
|
|
79
84
|
};
|
|
80
85
|
}
|
|
81
86
|
|
|
82
|
-
export async function install({ repoRoot, codexHome = defaultCodexHome(), apply = false, serverName = SERVER_NAME } = {}) {
|
|
87
|
+
export async function install({ repoRoot, codexHome = defaultCodexHome(), apply = false, serverName = SERVER_NAME, native = false } = {}) {
|
|
83
88
|
const home = resolve(codexHome);
|
|
89
|
+
if (native) {
|
|
90
|
+
const directConfigured = hasServer(await readConfig(home), SERVER_NAME);
|
|
91
|
+
return installCodexPlugin({ repoRoot: resolve(repoRoot), home, apply, directConfigured });
|
|
92
|
+
}
|
|
84
93
|
const tomlSnippet = renderMcpToml({ repoRoot, serverName });
|
|
85
94
|
const skills = await listSkills(repoRoot);
|
|
95
|
+
const profiles = await prepareAgentProfiles(repoRoot, home);
|
|
86
96
|
const state = await inspect({ repoRoot, codexHome: home, serverName });
|
|
87
97
|
const plan = {
|
|
88
98
|
appendMcpSection: !state.mcpConfigured,
|
|
89
99
|
syncSkills: skills,
|
|
100
|
+
syncAgents: profiles.map((profile) => profile.name),
|
|
90
101
|
configPath: join(home, "config.toml"),
|
|
91
102
|
};
|
|
92
103
|
if (apply !== true) {
|
|
@@ -103,6 +114,7 @@ export async function install({ repoRoot, codexHome = defaultCodexHome(), apply
|
|
|
103
114
|
for (const name of skills) {
|
|
104
115
|
await cp(join(resolve(repoRoot), "skills", name), join(home, "skills", name), { recursive: true, force: true });
|
|
105
116
|
}
|
|
117
|
+
await syncAgentProfiles(profiles);
|
|
106
118
|
const after = await inspect({ repoRoot, codexHome: home, serverName });
|
|
107
119
|
return {
|
|
108
120
|
ok: after.mcpConfigured && after.skillsMissing.length === 0,
|
|
@@ -117,9 +129,9 @@ export function describeSetup({ repoRoot } = {}) {
|
|
|
117
129
|
const cli = join(resolve(repoRoot ?? "."), "cli", "ldvh.mjs");
|
|
118
130
|
return [
|
|
119
131
|
"Codex 接入(二选一):",
|
|
120
|
-
`A.
|
|
121
|
-
"
|
|
122
|
-
"
|
|
132
|
+
`A. 原生插件:node "${cli}" host setup --host codex --plugin --apply,安装 LDVH Local 并同步原生代理。`,
|
|
133
|
+
"在 Codex 打开新会话,审核并信任插件 Hooks 后即可自动召回和绑定经验记录授权。",
|
|
134
|
+
`B. MCP 直连:node "${cli}" host setup --host codex --apply,配置 MCP 和技能。自动召回与授权绑定请使用原生插件。`,
|
|
123
135
|
].join("\n");
|
|
124
136
|
}
|
|
125
137
|
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { cp, mkdir, readFile } from "node:fs/promises";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
5
|
+
import { promisify } from "node:util";
|
|
6
|
+
import { writeFileAtomic } from "../../lib/atomic-write.js";
|
|
7
|
+
import { pathKind } from "../_fs.js";
|
|
8
|
+
import { prepareAgentProfiles, syncAgentProfiles } from "./agent-profiles.js";
|
|
9
|
+
|
|
10
|
+
const run = promisify(execFile);
|
|
11
|
+
const MARKETPLACE = "ldvh-local";
|
|
12
|
+
const PLUGIN_ID = "ldvh@" + MARKETPLACE;
|
|
13
|
+
const SOURCE_PATH = "./plugins/ldvh-codex";
|
|
14
|
+
|
|
15
|
+
async function copyPath(root, target, relative) {
|
|
16
|
+
await mkdir(dirname(join(target, relative)), { recursive: true });
|
|
17
|
+
await cp(join(root, relative), join(target, relative), { recursive: true });
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function writeJson(path, value) {
|
|
21
|
+
return writeFileAtomic(path, JSON.stringify(value, null, 2) + "\n");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function codex(home, args) {
|
|
25
|
+
return run(process.platform === "win32" ? "codex.exe" : "codex", args, {
|
|
26
|
+
encoding: "utf8", windowsHide: true, timeout: 45000,
|
|
27
|
+
env: { ...process.env, CODEX_HOME: home },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function existingDirectServer(home) {
|
|
32
|
+
try {
|
|
33
|
+
const { stdout } = await codex(home, ["mcp", "get", "ldvh", "--json"]);
|
|
34
|
+
const transport = JSON.parse(stdout).transport;
|
|
35
|
+
const entry = transport?.args?.[0];
|
|
36
|
+
if (typeof entry === "string" && /[\\/]server[\\/]mcp-server\.js$/.test(entry)) {
|
|
37
|
+
const source = JSON.parse(await readFile(join(dirname(entry), "..", "package.json"), "utf8"));
|
|
38
|
+
if (source.name === "ld-vibe-harness") return true;
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
// An unrecognized server can shadow the plugin. Only migrate the known LDVH entry.
|
|
42
|
+
}
|
|
43
|
+
throw new Error("A different direct MCP server already uses the name ldvh in this Codex profile.");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function installCodexPlugin({ repoRoot, home, apply, directConfigured }) {
|
|
47
|
+
const marketplace = join(home, "plugins", "ldvh-local-marketplace");
|
|
48
|
+
const target = join(marketplace, SOURCE_PATH);
|
|
49
|
+
const index = join(marketplace, ".agents", "plugins", "marketplace.json");
|
|
50
|
+
const profiles = await prepareAgentProfiles(repoRoot, home);
|
|
51
|
+
const plan = { marketplace, pluginId: PLUGIN_ID, source: repoRoot, syncAgents: profiles.map((p) => p.name) };
|
|
52
|
+
if (!apply) return { ok: true, host: "codex", applied: false, plan };
|
|
53
|
+
if (directConfigured) await existingDirectServer(home);
|
|
54
|
+
|
|
55
|
+
const prior = await readFile(index, "utf8").catch((error) => {
|
|
56
|
+
if (error?.code === "ENOENT") return null;
|
|
57
|
+
throw error;
|
|
58
|
+
});
|
|
59
|
+
const catalog = prior === null
|
|
60
|
+
? { name: MARKETPLACE, interface: { displayName: "LDVH Local" }, plugins: [] }
|
|
61
|
+
: JSON.parse(prior);
|
|
62
|
+
if (catalog.name !== MARKETPLACE || !Array.isArray(catalog.plugins)) {
|
|
63
|
+
throw new Error("Unexpected marketplace configuration at " + index);
|
|
64
|
+
}
|
|
65
|
+
const current = catalog.plugins.find((plugin) => plugin.name === "ldvh");
|
|
66
|
+
if (current && ![SOURCE_PATH, "./plugins/ldvh"].includes(current.source?.path)) {
|
|
67
|
+
throw new Error("LDVH already points to a different local plugin source at " + index);
|
|
68
|
+
}
|
|
69
|
+
if (await pathKind(target) === "symlink") throw new Error("LDVH plugin staging directory is a symbolic link: " + target);
|
|
70
|
+
|
|
71
|
+
for (const item of [".codex-plugin/plugin.json", "hooks/codex.json", "skills", "assets", "docs/screenshots"]) {
|
|
72
|
+
if (await pathKind(join(repoRoot, item)) !== "missing") await copyPath(repoRoot, target, item);
|
|
73
|
+
}
|
|
74
|
+
// This Codex loader doesn't substitute PLUGIN_ROOT for MCP. Generate an
|
|
75
|
+
// absolute runtime entry, while keeping the installed hook and UI manifests.
|
|
76
|
+
const mcp = JSON.parse(await readFile(join(repoRoot, ".mcp.json"), "utf8"));
|
|
77
|
+
mcp.mcpServers.ldvh.command = process.execPath;
|
|
78
|
+
mcp.mcpServers.ldvh.args = [join(repoRoot, "server", "mcp-server.js")];
|
|
79
|
+
mcp.mcpServers.ldvh.env.CODEX_HOME = home;
|
|
80
|
+
await writeJson(join(target, ".mcp.json"), mcp);
|
|
81
|
+
const entry = pathToFileURL(join(repoRoot, "hooks", "codex.mjs"));
|
|
82
|
+
await writeFileAtomic(join(target, "hooks", "codex.mjs"),
|
|
83
|
+
"export { runCodexHook } from " + JSON.stringify(entry.href) + ";\n");
|
|
84
|
+
const plugin = {
|
|
85
|
+
...(current ?? { name: "ldvh", category: "Engineering", policy: { installation: "AVAILABLE", authentication: "ON_INSTALL" } }),
|
|
86
|
+
source: { source: "local", path: SOURCE_PATH },
|
|
87
|
+
};
|
|
88
|
+
catalog.plugins = [...catalog.plugins.filter((item) => item.name !== "ldvh"), plugin];
|
|
89
|
+
await writeJson(index, catalog);
|
|
90
|
+
try {
|
|
91
|
+
await codex(home, ["plugin", "marketplace", "add", marketplace, "--json"]);
|
|
92
|
+
const result = await codex(home, ["plugin", "add", PLUGIN_ID, "--json"]);
|
|
93
|
+
const installed = JSON.parse(result.stdout);
|
|
94
|
+
if (installed.pluginId !== PLUGIN_ID || typeof installed.installedPath !== "string") {
|
|
95
|
+
throw new Error("Codex did not report an installed path for " + PLUGIN_ID);
|
|
96
|
+
}
|
|
97
|
+
await syncAgentProfiles(profiles);
|
|
98
|
+
if (directConfigured) await codex(home, ["mcp", "remove", "ldvh"]);
|
|
99
|
+
return { ok: true, host: "codex", applied: true, plan, installed };
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (prior !== null) await writeFileAtomic(index, prior);
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|