@nimiplatform/nimi-coding 0.1.0 → 0.2.1

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 (126) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/CODE_OF_CONDUCT.md +28 -0
  3. package/CONTRIBUTING.md +45 -0
  4. package/README.md +371 -344
  5. package/README.zh-CN.md +307 -0
  6. package/SECURITY.md +26 -0
  7. package/adapters/oh-my-codex/README.md +8 -9
  8. package/cli/commands/audit-sweep.mjs +10 -10
  9. package/cli/commands/classify-spec-tree.mjs +5 -0
  10. package/cli/commands/closeout.mjs +3 -0
  11. package/cli/commands/generate-spec-derived-docs.mjs +20 -0
  12. package/cli/commands/generate-spec-migration-plan.mjs +30 -0
  13. package/cli/commands/start.mjs +5 -1
  14. package/cli/commands/surface-validator-command.mjs +49 -0
  15. package/cli/commands/sweep-design.mjs +295 -0
  16. package/cli/commands/sweep.mjs +22 -0
  17. package/cli/commands/sync.mjs +132 -0
  18. package/cli/commands/topic-formatters.mjs +8 -8
  19. package/cli/commands/validate-ai-governance.mjs +167 -46
  20. package/cli/commands/validate-domain-admission.mjs +5 -0
  21. package/cli/commands/validate-guidance-bodies.mjs +5 -0
  22. package/cli/commands/validate-placement.mjs +5 -0
  23. package/cli/commands/validate-projection-edges.mjs +5 -0
  24. package/cli/commands/validate-spec-audit.mjs +5 -1
  25. package/cli/commands/validate-table-family.mjs +5 -0
  26. package/cli/commands/validate-tracked-output-admission.mjs +5 -0
  27. package/cli/constants.mjs +5 -49
  28. package/cli/help.mjs +33 -11
  29. package/cli/index.mjs +20 -2
  30. package/cli/lib/audit-sweep-runtime/admissions.mjs +38 -29
  31. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +8 -0
  32. package/cli/lib/audit-sweep-runtime/chunks.mjs +11 -11
  33. package/cli/lib/audit-sweep-runtime/closeout.mjs +8 -8
  34. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +3 -3
  35. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +10 -10
  36. package/cli/lib/audit-sweep-runtime/common.mjs +7 -7
  37. package/cli/lib/audit-sweep-runtime/format.mjs +3 -3
  38. package/cli/lib/audit-sweep-runtime/ingest.mjs +8 -8
  39. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +24 -27
  40. package/cli/lib/audit-sweep-runtime/inventory.mjs +58 -18
  41. package/cli/lib/audit-sweep-runtime/ledger.mjs +1 -1
  42. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +2 -2
  43. package/cli/lib/audit-sweep-runtime/remediation.mjs +6 -6
  44. package/cli/lib/audit-sweep-runtime/rerun.mjs +6 -6
  45. package/cli/lib/audit-sweep-runtime/status.mjs +1 -1
  46. package/cli/lib/audit-sweep-runtime/validators.mjs +2 -2
  47. package/cli/lib/authority-convergence.mjs +397 -2
  48. package/cli/lib/blueprint-audit.mjs +5 -5
  49. package/cli/lib/closeout.mjs +126 -3
  50. package/cli/lib/contracts.mjs +21 -17
  51. package/cli/lib/handoff.mjs +29 -11
  52. package/cli/lib/high-risk-admission.mjs +60 -11
  53. package/cli/lib/high-risk-decision.mjs +31 -2
  54. package/cli/lib/high-risk-ingest.mjs +5 -1
  55. package/cli/lib/high-risk-review.mjs +5 -1
  56. package/cli/lib/internal/contracts-parse.mjs +195 -24
  57. package/cli/lib/internal/contracts-validators.mjs +3 -2
  58. package/cli/lib/internal/doctor-bootstrap-surface.mjs +82 -35
  59. package/cli/lib/internal/doctor-delegated-surface.mjs +1 -1
  60. package/cli/lib/internal/doctor-finalize.mjs +12 -8
  61. package/cli/lib/internal/doctor-inspectors.mjs +34 -1
  62. package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +74 -12
  63. package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +24 -6
  64. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +18 -23
  65. package/cli/lib/internal/surface-taxonomy-validators.mjs +931 -0
  66. package/cli/lib/internal/validators-spec.mjs +229 -20
  67. package/cli/lib/sweep-design-runtime/common.mjs +246 -0
  68. package/cli/lib/sweep-design-runtime/engine.mjs +733 -0
  69. package/cli/lib/sweep-design-runtime/fix-topic.mjs +414 -0
  70. package/cli/lib/sweep-design-runtime/lifecycle.mjs +54 -0
  71. package/cli/lib/sweep-design-runtime/results.mjs +324 -0
  72. package/cli/lib/sweep-design.mjs +8 -0
  73. package/cli/lib/sync.mjs +143 -0
  74. package/cli/lib/topic-artifacts.mjs +186 -0
  75. package/cli/lib/topic-authority-coverage.mjs +73 -0
  76. package/cli/lib/topic-closeout.mjs +560 -0
  77. package/cli/lib/topic-common.mjs +404 -0
  78. package/cli/lib/topic-decisions.mjs +332 -0
  79. package/cli/lib/topic-draft-packets.mjs +126 -7
  80. package/cli/lib/topic-execution.mjs +515 -0
  81. package/cli/lib/topic-goal.mjs +112 -33
  82. package/cli/lib/topic-ledger.mjs +281 -0
  83. package/cli/lib/topic-lifecycle-artifacts.mjs +173 -0
  84. package/cli/lib/topic-root-validation.mjs +288 -0
  85. package/cli/lib/topic-runner-commands.mjs +174 -0
  86. package/cli/lib/topic-runner-deferral.mjs +532 -0
  87. package/cli/lib/topic-runner-stale-gates.mjs +114 -0
  88. package/cli/lib/topic-runner-validation.mjs +138 -0
  89. package/cli/lib/topic-runner.mjs +109 -154
  90. package/cli/lib/topic-scaffold.mjs +252 -0
  91. package/cli/lib/topic-waves.mjs +403 -0
  92. package/cli/lib/topic.mjs +81 -93
  93. package/cli/lib/value-helpers.mjs +6 -1
  94. package/cli/seeds/bootstrap.mjs +96 -20
  95. package/cli/seeds/seed-policy.yaml +67 -0
  96. package/config/bootstrap.yaml +1 -1
  97. package/config/skill-manifest.yaml +4 -2
  98. package/config/spec-generation-inputs.yaml +41 -19
  99. package/contracts/audit-remediation-map.schema.yaml +1 -0
  100. package/contracts/audit-sweep-result.yaml +4 -0
  101. package/contracts/domain-admission.schema.yaml +56 -0
  102. package/contracts/migration-inventory.schema.yaml +80 -0
  103. package/contracts/negative-fixtures.yaml +91 -0
  104. package/contracts/placement-contract.schema.yaml +163 -0
  105. package/contracts/projection-edge.schema.yaml +130 -0
  106. package/contracts/shared-enums.yaml +68 -0
  107. package/contracts/spec-generation-audit.schema.yaml +19 -4
  108. package/contracts/spec-generation-inputs.schema.yaml +130 -29
  109. package/contracts/spec-reconstruction-result.yaml +9 -5
  110. package/contracts/surface-taxonomy.schema.yaml +201 -0
  111. package/contracts/sweep-design-result.yaml +349 -0
  112. package/contracts/table-family.schema.yaml +121 -0
  113. package/contracts/topic-goal.schema.yaml +10 -1
  114. package/contracts/tracked-output-admission.schema.yaml +70 -0
  115. package/contracts/workflow-consumer.schema.yaml +112 -0
  116. package/methodology/audit-sweep-p0p1-recall.yaml +1 -1
  117. package/methodology/spec-reconstruction.yaml +53 -30
  118. package/package.json +19 -4
  119. package/spec/_meta/command-gating-matrix.yaml +33 -0
  120. package/spec/_meta/generate-drift-migration-checklist.yaml +44 -62
  121. package/spec/_meta/governance-routing-cutover-checklist.yaml +3 -3
  122. package/spec/_meta/phase2-impacted-surface-matrix.yaml +14 -14
  123. package/spec/_meta/spec-authority-cutover-readiness.yaml +3 -5
  124. package/spec/_meta/spec-tree-model.yaml +104 -36
  125. package/spec/bootstrap-state.yaml +36 -36
  126. package/spec/product-scope.yaml +13 -10
@@ -0,0 +1,307 @@
1
+ # @nimiplatform/nimi-coding
2
+
3
+ [English](README.md) · **简体中文**
4
+
5
+ [![npm](https://img.shields.io/npm/v/@nimiplatform/nimi-coding.svg?label=npm)](https://www.npmjs.com/package/@nimiplatform/nimi-coding)
6
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
+ [![node](https://img.shields.io/badge/node-%3E%3D24-brightgreen.svg)](#环境要求)
8
+
9
+ > 一套**厂商中立、AI 原生的方法论工具**(vendor-neutral, AI-native
10
+ > methodology toolkit),专门用于治理高风险的 AI 辅助软件开发。它在项目里
11
+ > 搭建一层 `.nimi/**` 真相面,配套 `nimicoding` CLI,把"AI 看起来做完了"
12
+ > 变成"四个闭合维度都有证据。"
13
+
14
+ 读者文档:<https://docs.nimi.ai/nimicoding>
15
+ npm 包:[`@nimiplatform/nimi-coding`](https://www.npmjs.com/package/@nimiplatform/nimi-coding)
16
+
17
+ ---
18
+
19
+ ## 为什么需要这个项目
20
+
21
+ AI 辅助实现经常会产出**能编译、能跑通现有测试、Reviewer 看着合理、但实际上在权威、范围、语义或产品意义上是错的**代码。这些不是传统意义上的 bug——它们是*闭合失败*(closure failures):在闭合条件还没真正成立的状态下,工作就被声明为"完成"了。
22
+
23
+ Nimi Coding 专门拦截的几种失败形态(非穷举):
24
+
25
+ - **过期文档锚定**:模型跟随了一份看似权威、但已经偏离活跃 spec 的文档。
26
+ - **隐式范围扩张**:模型"顺手"改了相邻表面,所有权悄悄发生了转移。
27
+ - **看似合理的捏造**:缺乏权威源时,模型编造一个跟真实答案无法区分的连贯回答。
28
+ - **旧路径保留**:模型"为了安全迁移"在旧路径旁边加了新路径——而旧路径本来应该被删掉。
29
+ - **构建通过即闭合**:因为测试跑过了就宣告完成,但消费方面对的行为是错的。
30
+ - **伪成功**:强类型契约失败被一段返回"某种东西"的回退路径掩盖,没有 fail-closed(失败即关闭)。
31
+
32
+ 更好的 Prompt 和更全的测试都解决不了这个问题。**审查 AI 输出的回路,和产出这个 AI 输出的,是同一个回路。** Nimi Coding 引入的是**结构性的分离**。
33
+
34
+ ## Nimi Coding 是什么(不是什么)
35
+
36
+ Nimi Coding **不是**另一个 AI 写代码工具。它不写代码、不调度 provider、不跑 agent loop。
37
+
38
+ 它是**独立的、host-agnostic 的边界包**(standalone host-agnostic boundary package),作为治理层坐落在你使用的任意 AI host(Claude、Codex、Gemini、OMX 或自建)下面。它交付:
39
+
40
+ - 包内自有的**方法论**源(`methodology/**`)
41
+ - 强类型**契约**(`contracts/**`)
42
+ - **bootstrap + host profile** 配置(`config/**`)
43
+ - **bootstrap spec 种子**(`spec/**`)
44
+ - **`nimicoding` CLI**:用于 bootstrap、校验、skill 握手、本地 closeout、topic 生命周期、sweep audit、sweep design、高风险执行闸门
45
+ - 外部 AI host 的**适配器** profile overlay
46
+
47
+ 它**刻意不**交付:
48
+
49
+ - 一个 packet 绑定的运行内核
50
+ - provider-backed 的 AI 执行
51
+ - 一个调度器
52
+ - 通知基础设施
53
+ - 自动化后端
54
+ - 自托管方法论执行
55
+
56
+ 运行时所有权留在外部 AI host 那里。方法论和契约保持可移植。明天你想换 AI host,方法论合同不需要改。
57
+
58
+ 当一个 host project 跑 `nimicoding start` 时,包内自有的源会被**投影**到该项目的 `.nimi/{config,contracts,methodology,spec}/**`。被采纳的项目随后拥有自己 `.nimi/spec/**` 下的产品权威。**包不会让 host 直接读取包源路径**——被采纳的项目永远读它自己投影出来的 `.nimi/**`。
59
+
60
+ ## 心智模型
61
+
62
+ 让 Nimi Coding 区别于"另一个 checklist"的四个动作:
63
+
64
+ | 动作 | 含义 |
65
+ | --- | --- |
66
+ | **权威被显式命名** | 每次变更都先写清楚真相住在哪里(`.nimi/spec/**`)、表面归谁所有、属于哪一类工作。 |
67
+ | **执行被 packet 化** | 实现被一份开工前冻结的 packet 限定边界——允许的读、允许的写、验收恒定式、负面测试、停止线、重开条件。worker 不允许扩张范围。 |
68
+ | **闭合是多维的** | 四个独立闭合闸门——权威(Authority)、语义(Semantic)、消费方(Consumer,即真实用户/读者/运维有没有真的用上)、抗漂移(Drift Resistance)——必须全部成立。过三缺一不算关闭。 |
69
+ | **角色分离** | Manager 负责切边界和准入;Worker 在 packet 写集合内执行;Auditor 来自**结构上独立的回路**(另一个 AI 会话、另一家厂商)。 |
70
+
71
+ 完整框架见 [Four Closures](https://docs.nimi.ai/nimicoding/four-closures) 与 [The Paradigm](https://docs.nimi.ai/nimicoding/the-paradigm)。
72
+
73
+ ## 适合谁用
74
+
75
+ | 角色 | 收益 |
76
+ | --- | --- |
77
+ | 用 AI 推大项目的独立开发者 | 不需要团队就能拿到团队规模的复核纪律——同一台笔记本起第二个 AI 会话当 auditor |
78
+ | 小团队(2–5 人)引入 AI | 不需要扩招就能拿到结构性的复核冗余 |
79
+ | 接受 AI 辅助 PR 的开源维护者 | 可证的贡献纪律——packet 边界、强类型证据、四闭合闸门 |
80
+ | 有 AI 编程合规压力的工程组织 | 独立于任一 AI 厂商的审计轨迹和结构化验收 |
81
+ | 研究 AI 工程实践的研究者 | 一个可观测的方法论语料库,跑在真实仓库历史上 |
82
+
83
+ 如果你见过 AI 辅助的变更在所有信号上看起来完成了——类型检查绿、测试绿、Reviewer 批了——结果在权威、范围或产品意义上是错的,那这个包就是为你做的。
84
+
85
+ ## 环境要求
86
+
87
+ | 项 | 版本 |
88
+ | --- | --- |
89
+ | Node.js | `>=24.0.0` |
90
+ | 包管理器(消费方) | npm、pnpm、yarn 或兼容工具 |
91
+ | pnpm(仓库开发) | `>=10.0.0` |
92
+
93
+ 建议在版本控制下的项目里使用——`start` 会创建文件。
94
+
95
+ ## 安装
96
+
97
+ 在需要接入 `.nimi/**` 治理层的项目里:
98
+
99
+ ```bash
100
+ npm install --save-dev @nimiplatform/nimi-coding
101
+ # 或
102
+ pnpm add -D @nimiplatform/nimi-coding
103
+ ```
104
+
105
+ 确认 CLI:
106
+
107
+ ```bash
108
+ npx nimicoding --version
109
+ npx nimicoding --help
110
+ ```
111
+
112
+ ## 5 分钟最小路径
113
+
114
+ 大部分项目都应该从小路径开始。第一条跑通的路径是:
115
+
116
+ ```bash
117
+ # 1. 在项目根目录 bootstrap .nimi/**
118
+ npx nimicoding start
119
+
120
+ # 2. 检查 bootstrap 健康
121
+ npx nimicoding doctor --json
122
+
123
+ # 3. 把权威 spec 重建任务握手交给你的 AI host
124
+ npx nimicoding handoff --skill spec_reconstruction --json
125
+
126
+ # 4. host 消费该 payload 并落地 .nimi/spec/** 后,校验权威树
127
+ npx nimicoding validate-spec-tree .nimi/spec
128
+ npx nimicoding validate-spec-audit
129
+ ```
130
+
131
+ 走完这条路径,你会拥有:项目本地的 `.nimi/**` 真相面、一份重建到 `.nimi/spec/**` 的强类型项目权威,以及可以在每次变更上重跑的机械校验器。
132
+
133
+ `handoff` 导出的是权威任务 payload。它不会调用 AI provider,也不会自己执行 reconstruction;外部 host 必须消费 payload,写入或返回预期工件,然后本地校验器检查结果。
134
+
135
+ **普通的低风险改动不需要创建 topic、冻结 packet、跑高风险闸门。** 那些工具是给权威级、跨模块、多 wave 或对审计敏感的工作准备的。
136
+
137
+ 如果想从测试项目里只移除包托管的 bootstrap 内容(保留 `.nimi/spec/**`、`.nimi/local/**`、`.nimi/cache/**` 和被本地修改过的 bootstrap 文件):
138
+
139
+ ```bash
140
+ npx nimicoding clear --yes
141
+ ```
142
+
143
+ ## 需要进阶时:Topic、Wave、Packet
144
+
145
+ 权威级、高风险或跨模块的工作,升级到 topic 生命周期。Topic 装一次战略性变更;wave 把 topic 拆成有边界的工作单元;每个 wave 在 worker 动手前冻结一份 **packet**。
146
+
147
+ ```bash
148
+ nimicoding topic create <slug> --justification <text>
149
+ nimicoding topic wave add <topic-id> <wave-id> <slug> \
150
+ --goal <text> --owner-domain <domain>
151
+ nimicoding topic packet freeze <topic-id> --from <draft-path>
152
+ nimicoding handoff --skill high_risk_execution --json
153
+ nimicoding ingest-high-risk-execution --from result.json
154
+ nimicoding review-high-risk-execution --from ingest.json
155
+ nimicoding decide-high-risk-execution --from review.json \
156
+ --acceptance accept.md --verified-at <iso8601>
157
+ ```
158
+
159
+ 每一步都被强类型校验约束。跳步或者偷塞字段,CLI 直接拒绝(fail closed,没有例外)。
160
+
161
+ ## 四个声明 Skill
162
+
163
+ 外部 AI host 实现这些 skill;`handoff` CLI 为每一个发出机器可读 payload:
164
+
165
+ | Skill | 用途 | Bootstrap 必需 |
166
+ | --- | --- | --- |
167
+ | `spec_reconstruction` | 把项目权威重建到 `.nimi/spec/**`,带源依据和未决 gap 追踪 | 是 |
168
+ | `doc_spec_audit` | 对照权威树校验每个文件的 grounding 和 inference | 是 |
169
+ | `audit_sweep` | 把目标根切成可审计的 chunk,记录强类型证据 | 否 |
170
+ | `high_risk_execution` | 在准入的高风险 packet 上执行,附带 packet / orchestration / prompt / worker-output / acceptance 强类型证据 | 否 |
171
+
172
+ 契约细节见 [Skills](https://docs.nimi.ai/nimicoding/skills)。
173
+
174
+ ## CLI 总览
175
+
176
+ 按使用场景分组的常用命令:
177
+
178
+ ```bash
179
+ # Bootstrap
180
+ nimicoding start
181
+ nimicoding sync --check
182
+ nimicoding doctor --json
183
+ nimicoding clear --yes
184
+
185
+ # Skill 握手与本地 closeout
186
+ nimicoding handoff --skill <id> --json
187
+ nimicoding closeout --from result.json --write-local
188
+
189
+ # Spec 审计
190
+ nimicoding validate-spec-tree .nimi/spec
191
+ nimicoding validate-spec-audit
192
+ nimicoding blueprint-audit
193
+
194
+ # Topic 生命周期
195
+ nimicoding topic create <slug> --justification <text>
196
+ nimicoding topic wave add|select|admit ...
197
+ nimicoding topic packet freeze ...
198
+ nimicoding topic worker dispatch ...
199
+ nimicoding topic result record ...
200
+ nimicoding topic closeout ...
201
+ nimicoding topic true-close-audit ...
202
+ nimicoding topic run-next-step <topic-id> --json
203
+
204
+ # Sweep audit / sweep design
205
+ nimicoding sweep audit plan --root <dir> --json
206
+ nimicoding sweep audit chunk ...
207
+ nimicoding sweep design intake|packet-build|result-ingest|finalize ...
208
+
209
+ # 高风险执行闸门
210
+ nimicoding admit-high-risk-decision --from <json> --admitted-at <iso8601>
211
+ nimicoding ingest-high-risk-execution --from <json>
212
+ nimicoding review-high-risk-execution --from <json>
213
+ nimicoding decide-high-risk-execution --from <json> \
214
+ --acceptance <path> --verified-at <iso8601>
215
+
216
+ # 机械工件校验器
217
+ nimicoding validate-execution-packet <path>
218
+ nimicoding validate-orchestration-state <path>
219
+ nimicoding validate-prompt <path>
220
+ nimicoding validate-worker-output <path>
221
+ nimicoding validate-acceptance <path>
222
+ ```
223
+
224
+ CLI 概念总览:<https://docs.nimi.ai/nimicoding/cli>
225
+ 字段级 reference:<https://docs.nimi.ai/nimicoding/reference/cli-commands>
226
+
227
+ ## 它和 X 是什么关系
228
+
229
+ | | Cursor / Copilot / Claude Code | Lint / TDD / Code review | Nimi Coding |
230
+ | --- | --- | --- | --- |
231
+ | 写代码 | ✅ | ❌ | **❌** |
232
+ | 抓局部 bug | 部分 | ✅ | n/a |
233
+ | 抓权威漂移 | ❌ | ❌ | **✅** |
234
+ | 抓消费方闭合失败 | ❌ | ❌ | **✅** |
235
+ | 厂商绑定 | 有(按工具) | 无 | **无——host-agnostic** |
236
+ | 跨 AI 会话的审计轨迹 | 聊天记录 | PR 评论 | **`.nimi/**` 下的强类型证据** |
237
+
238
+ Nimi Coding 坐在你已经用的 AI host *底下*。它是让 AI 做完的工作从"看起来完成"晋升到"四维闭合、有证据"的机器装置。
239
+
240
+ ## 仓库结构
241
+
242
+ | 路径 | 用途 |
243
+ | --- | --- |
244
+ | `bin/nimicoding.mjs` | 可执行的包二进制 |
245
+ | `cli/**` | CLI 实现 |
246
+ | `config/**` | 包内自有的 bootstrap 与 host profile 源 |
247
+ | `contracts/**` | 包内自有的机器可读 schema 与契约 |
248
+ | `methodology/**` | 包内自有的方法论源(policy) |
249
+ | `spec/**` | bootstrap spec 种子和包 scope 源 |
250
+ | `adapters/**` | 外部 host 适配器 profile overlay(例如 `oh-my-codex`) |
251
+ | `test/**` | Node 测试套件与 fixture |
252
+
253
+ 被采纳的项目使用 `.nimi/**` 作为投影层。这个仓库自身把包内自有源直接放在 `config/**`、`contracts/**`、`methodology/**`、`spec/**` 下。
254
+
255
+ ## 开发
256
+
257
+ ```bash
258
+ pnpm install
259
+ pnpm test # 跑 node:test 套件(0.2.1 共 329 用例)
260
+ pnpm check:pack # npm pack --dry-run
261
+ pnpm check:ci # test + pack + CLI help/version smoke
262
+ ```
263
+
264
+ 本地 CLI smoke:
265
+
266
+ ```bash
267
+ node ./bin/nimicoding.mjs --version
268
+ node ./bin/nimicoding.mjs --help
269
+ ```
270
+
271
+ 提交 PR 前请读 [CONTRIBUTING.md](CONTRIBUTING.md)。简版要求:改动有边界、守住 host-agnostic 边界、除非方法论合同显式重设计否则不引入运行时所有权、自称完成前跑过相关测试。
272
+
273
+ ## 发布
274
+
275
+ Release 由 tag 触发 GitHub Actions。一个 `vX.Y.Z` tag 在 test、pack dry-run、CLI smoke 都通过后,发布与 `package.json` 版本相匹配的包。Workflow 也支持手动的 dry-run release 闸门。
276
+
277
+ 包以启用 npm provenance 发布。
278
+
279
+ ## 安全
280
+
281
+ 不要在公开 GitHub issue 里披露漏洞。请走私密渠道:
282
+
283
+ - GitHub 私密安全公告:[`nimiplatform/nimi-coding`](https://github.com/nimiplatform/nimi-coding/security/advisories/new)
284
+ - `security@nimi.ai`
285
+
286
+ 支持的上报路径见 [SECURITY.md](SECURITY.md)。
287
+
288
+ ## 文档
289
+
290
+ 完整读者文档:<https://docs.nimi.ai/nimicoding>,包括:
291
+
292
+ - [The Paradigm](https://docs.nimi.ai/nimicoding/the-paradigm)
293
+ - [Four Closures](https://docs.nimi.ai/nimicoding/four-closures)
294
+ - [False Closure Typology](https://docs.nimi.ai/nimicoding/false-closure-typology)
295
+ - [Forbidden Shortcuts](https://docs.nimi.ai/nimicoding/forbidden-shortcuts)
296
+ - [Role Separation](https://docs.nimi.ai/nimicoding/role-separation)
297
+ - [Topic Lifecycle](https://docs.nimi.ai/nimicoding/topic-lifecycle)
298
+ - [The Package](https://docs.nimi.ai/nimicoding/the-package)
299
+ - [CLI Surface](https://docs.nimi.ai/nimicoding/cli)
300
+ - [Installation](https://docs.nimi.ai/nimicoding/installation)
301
+ - [Adoption Path](https://docs.nimi.ai/nimicoding/adoption-path)
302
+ - [Comparison](https://docs.nimi.ai/nimicoding/comparison)
303
+ - [Walkthrough](https://docs.nimi.ai/nimicoding/walkthrough)
304
+
305
+ ## 许可
306
+
307
+ MIT。见 [LICENSE](LICENSE)。
package/SECURITY.md ADDED
@@ -0,0 +1,26 @@
1
+ # Security Policy
2
+
3
+ ## Supported Versions
4
+
5
+ Security fixes target the latest published version of
6
+ `@nimiplatform/nimi-coding`.
7
+
8
+ ## Reporting A Vulnerability
9
+
10
+ Do not disclose vulnerabilities in public GitHub issues.
11
+
12
+ Use one of these private channels:
13
+
14
+ - GitHub private security advisory for
15
+ `https://github.com/nimiplatform/nimi-coding/security/advisories/new`
16
+ - `security@nimi.ai`
17
+
18
+ Please include:
19
+
20
+ - affected version or commit
21
+ - reproduction steps
22
+ - expected impact
23
+ - any relevant logs, payloads, or proof-of-concept material
24
+
25
+ We will acknowledge valid reports privately and coordinate disclosure after a
26
+ fix or mitigation is available.
@@ -97,8 +97,8 @@ nimicoding handoff --skill spec_reconstruction --json
97
97
  Use the JSON payload as OMX's machine contract. `--prompt` may still be used
98
98
  as a host briefing, but it is not the authoritative surface. OMX should
99
99
  return only the declared canonical tree outputs and must not invent new semantic
100
- owners. In this monorepo the explicit cutover batch has already made
101
- `.nimi/spec/**` the current authority root; OMX still must not redefine that
100
+ owners. In a host project, `.nimi/spec/**` is current authority only when the
101
+ host has admitted or reconstructed it; OMX still must not redefine that
102
102
  authority or promote its own runtime state into semantic truth.
103
103
 
104
104
  Then project the closeout locally:
@@ -152,13 +152,12 @@ For now, treat OMX output as execution candidate material:
152
152
 
153
153
  In practice, this means the first real user can use OMX as the execution host
154
154
  today, while standalone `nimicoding` remains the host-agnostic semantic and
155
- interop boundary package. The promoted internal
156
- [`nimi-coding`](/Users/snwozy/nimi-realm/nimi/nimi-coding) still owns
157
- packet-bound runtime, provider-backed execution, scheduler, notification, and
158
- automation surfaces, even though standalone
159
- `nimicoding closeout` can now import a fail-closed local-only execution
160
- summary and `nimicoding ingest-high-risk-execution` can mechanically validate
161
- the referenced packet/prompt/output candidates while
155
+ interop boundary package. The standalone package intentionally does not own
156
+ packet-bound runtime, provider-backed execution, scheduler, notification, or
157
+ automation surfaces yet, even though `nimicoding closeout` can import a
158
+ fail-closed local-only execution summary and
159
+ `nimicoding ingest-high-risk-execution` can mechanically validate the
160
+ referenced packet/prompt/output candidates while
162
161
  `nimicoding review-high-risk-execution` can project a manager-ready local
163
162
  attachment bundle, `nimicoding decide-high-risk-execution` can record a
164
163
  manager-owned local disposition, and `nimicoding admit-high-risk-decision`
@@ -22,8 +22,8 @@ function readRequiredValue(args, index, optionName, commandName) {
22
22
  return {
23
23
  ok: false,
24
24
  error: `${localize(
25
- `nimicoding audit-sweep ${commandName} refused: ${optionName} requires a value.`,
26
- `nimicoding audit-sweep ${commandName} 已拒绝:${optionName} 需要一个值。`,
25
+ `nimicoding sweep audit ${commandName} refused: ${optionName} requires a value.`,
26
+ `nimicoding sweep audit ${commandName} 已拒绝:${optionName} 需要一个值。`,
27
27
  )}\n`,
28
28
  };
29
29
  }
@@ -34,8 +34,8 @@ function unknownOption(commandName, arg) {
34
34
  return {
35
35
  ok: false,
36
36
  error: `${localize(
37
- `nimicoding audit-sweep ${commandName} refused: unknown option ${arg}.`,
38
- `nimicoding audit-sweep ${commandName} 已拒绝:未知选项 ${arg}。`,
37
+ `nimicoding sweep audit ${commandName} refused: unknown option ${arg}.`,
38
+ `nimicoding sweep audit ${commandName} 已拒绝:未知选项 ${arg}。`,
39
39
  )}\n`,
40
40
  };
41
41
  }
@@ -65,8 +65,8 @@ function parseOptions(args, commandName, spec) {
65
65
  return {
66
66
  ok: false,
67
67
  error: `${localize(
68
- `nimicoding audit-sweep ${commandName} refused: ${arg} must be a positive integer.`,
69
- `nimicoding audit-sweep ${commandName} 已拒绝:${arg} 必须是正整数。`,
68
+ `nimicoding sweep audit ${commandName} refused: ${arg} must be a positive integer.`,
69
+ `nimicoding sweep audit ${commandName} 已拒绝:${arg} 必须是正整数。`,
70
70
  )}\n`,
71
71
  };
72
72
  }
@@ -85,8 +85,8 @@ function parseOptions(args, commandName, spec) {
85
85
  return {
86
86
  ok: false,
87
87
  error: `${localize(
88
- `nimicoding audit-sweep ${commandName} refused: missing required options: ${missing.join(", ")}.`,
89
- `nimicoding audit-sweep ${commandName} 已拒绝:缺少必填选项:${missing.join(", ")}。`,
88
+ `nimicoding sweep audit ${commandName} refused: missing required options: ${missing.join(", ")}.`,
89
+ `nimicoding sweep audit ${commandName} 已拒绝:缺少必填选项:${missing.join(", ")}。`,
90
90
  )}\n`,
91
91
  };
92
92
  }
@@ -269,8 +269,8 @@ function parseAuditSweepOptions(args) {
269
269
  return {
270
270
  ok: false,
271
271
  error: `${localize(
272
- "nimicoding audit-sweep refused: expected one of `plan`, `chunk dispatch`, `chunk audit-codex`, `chunk ingest`, `chunk review`, `chunk skip`, `ledger build`, `remediation-map build`, `remediation-map admit`, `finding resolve`, `closeout summary`, `status`, or `validate`.",
273
- "nimicoding audit-sweep 已拒绝:需要使用 `plan`、`chunk dispatch`、`chunk ingest`、`chunk review`、`chunk skip`、`ledger build`、`remediation-map build`、`remediation-map admit`、`finding resolve`、`closeout summary`、`status` 或 `validate`。",
272
+ "nimicoding sweep audit refused: expected one of `plan`, `chunk dispatch`, `chunk audit-codex`, `chunk ingest`, `chunk review`, `chunk skip`, `ledger build`, `remediation-map build`, `remediation-map admit`, `finding resolve`, `closeout summary`, `status`, or `validate`.",
273
+ "nimicoding sweep audit 已拒绝:需要使用 `plan`、`chunk dispatch`、`chunk ingest`、`chunk review`、`chunk skip`、`ledger build`、`remediation-map build`、`remediation-map admit`、`finding resolve`、`closeout summary`、`status` 或 `validate`。",
274
274
  )}\n`,
275
275
  };
276
276
  }
@@ -0,0 +1,5 @@
1
+ import { runSurfaceValidatorCommand } from "./surface-validator-command.mjs";
2
+
3
+ export function runClassifySpecTree(args) {
4
+ return runSurfaceValidatorCommand(args, "classify-spec-tree");
5
+ }
@@ -163,6 +163,9 @@ export async function runCloseout(args) {
163
163
  const payload = await buildCloseoutPayload(process.cwd(), effectiveOptions);
164
164
  if (payload.inputError) {
165
165
  process.stderr.write(payload.error);
166
+ if (parsed.options.json) {
167
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
168
+ }
166
169
  return payload.exitCode;
167
170
  }
168
171
 
@@ -1,6 +1,13 @@
1
+ import { readFile } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
1
5
  import { localize } from "../lib/ui.mjs";
2
6
  import { loadGovernanceConfig, requireProfile } from "../lib/internal/governance/config.mjs";
3
7
  import { runCommand } from "../lib/internal/governance/runner.mjs";
8
+ import { parseSpecGenerationInputsConfig } from "../lib/internal/contracts-parse.mjs";
9
+
10
+ const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
4
11
 
5
12
  function parseOptions(args) {
6
13
  const options = {
@@ -100,6 +107,19 @@ export async function runGenerateSpecDerivedDocs(args) {
100
107
  return 2;
101
108
  }
102
109
 
110
+ const packageInputsText = await readFile(
111
+ path.join(PACKAGE_ROOT, "config", "spec-generation-inputs.yaml"),
112
+ "utf8",
113
+ );
114
+ const packageInputs = parseSpecGenerationInputsConfig(packageInputsText);
115
+ if (!packageInputs.ok || !packageInputs.generationOrder.includes("validate_placement")) {
116
+ process.stderr.write(localize(
117
+ "nimicoding generate-spec-derived-docs refused: package spec generation inputs must be class-filtered and include placement validation.\n",
118
+ "nimicoding generate-spec-derived-docs 已拒绝:package spec generation inputs 必须按 surface class 过滤并包含 placement validation。\n",
119
+ ));
120
+ return 2;
121
+ }
122
+
103
123
  let failed = false;
104
124
  for (const scope of scopeResolution.scopes) {
105
125
  const commands = governance.config.specGovernance.generateCommands[scope] || [];
@@ -0,0 +1,30 @@
1
+ import {
2
+ generateSpecMigrationPlan,
3
+ parseSurfaceValidatorOptions,
4
+ writeMigrationPlanIfRequested,
5
+ } from "../lib/internal/surface-taxonomy-validators.mjs";
6
+ import { localize } from "../lib/ui.mjs";
7
+
8
+ export async function runGenerateSpecMigrationPlan(args) {
9
+ const parsed = parseSurfaceValidatorOptions(args);
10
+ if (!parsed.ok) {
11
+ process.stderr.write(localize(
12
+ `nimicoding generate-spec-migration-plan refused: ${parsed.error}\n`,
13
+ `nimicoding generate-spec-migration-plan 已拒绝:${parsed.error}\n`,
14
+ ));
15
+ return 2;
16
+ }
17
+
18
+ try {
19
+ const report = await generateSpecMigrationPlan(process.cwd(), parsed.options);
20
+ await writeMigrationPlanIfRequested(report, parsed.options.emit, process.cwd());
21
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
22
+ return report.ok ? 0 : 1;
23
+ } catch (error) {
24
+ process.stderr.write(localize(
25
+ `nimicoding generate-spec-migration-plan refused: ${error.message}\n`,
26
+ `nimicoding generate-spec-migration-plan 已拒绝:${error.message}\n`,
27
+ ));
28
+ return 2;
29
+ }
30
+ }
@@ -343,8 +343,12 @@ function buildTaskStageLines(mode) {
343
343
  }
344
344
 
345
345
  function canonicalTreeReady(doctorResult) {
346
- return doctorResult.lifecycleState?.treeState === "canonical_tree_ready"
346
+ const v2Ready = doctorResult.specGenerationInputs?.mode === "class_filtered"
347
+ && doctorResult.canonicalTree?.requiredFilesValid === true
348
+ && doctorResult.specGenerationAudit?.ok === true;
349
+ const legacyReady = doctorResult.lifecycleState?.treeState === "canonical_tree_ready"
347
350
  && doctorResult.canonicalTree?.requiredFilesValid === true;
351
+ return v2Ready || legacyReady;
348
352
  }
349
353
 
350
354
  function determineWizardStage(doctorResult) {
@@ -0,0 +1,49 @@
1
+ import {
2
+ classifySpecSurface,
3
+ parseSurfaceValidatorOptions,
4
+ validateDomainAdmission,
5
+ validateGuidanceBodies,
6
+ validatePlacement,
7
+ validateProjectionEdges,
8
+ validateTableFamily,
9
+ validateTrackedOutputAdmission,
10
+ writeInventoryIfRequested,
11
+ } from "../lib/internal/surface-taxonomy-validators.mjs";
12
+ import { localize } from "../lib/ui.mjs";
13
+
14
+ const VALIDATORS = {
15
+ "classify-spec-tree": classifySpecSurface,
16
+ "validate-placement": validatePlacement,
17
+ "validate-table-family": validateTableFamily,
18
+ "validate-projection-edges": validateProjectionEdges,
19
+ "validate-guidance-bodies": validateGuidanceBodies,
20
+ "validate-domain-admission": validateDomainAdmission,
21
+ "validate-tracked-output-admission": validateTrackedOutputAdmission,
22
+ };
23
+
24
+ export async function runSurfaceValidatorCommand(args, validatorName) {
25
+ const parsed = parseSurfaceValidatorOptions(args);
26
+ if (!parsed.ok) {
27
+ process.stderr.write(localize(
28
+ `nimicoding ${validatorName} refused: ${parsed.error}\n`,
29
+ `nimicoding ${validatorName} 已拒绝:${parsed.error}\n`,
30
+ ));
31
+ return 2;
32
+ }
33
+
34
+ const validator = VALIDATORS[validatorName];
35
+ if (!validator) {
36
+ process.stderr.write(localize(
37
+ `nimicoding ${validatorName} refused: unknown surface validator.\n`,
38
+ `nimicoding ${validatorName} 已拒绝:未知 surface validator。\n`,
39
+ ));
40
+ return 2;
41
+ }
42
+
43
+ const report = await validator(process.cwd(), parsed.options);
44
+ if (validatorName === "classify-spec-tree") {
45
+ await writeInventoryIfRequested(report, parsed.options.emit, process.cwd());
46
+ }
47
+ process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
48
+ return report.ok ? 0 : 1;
49
+ }