@nimiplatform/nimi-coding 0.4.0 → 0.6.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 (70) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +92 -55
  4. package/README.zh-CN.md +93 -56
  5. package/cli/commands/authority.mjs +80 -125
  6. package/cli/commands/clear.mjs +3 -2
  7. package/cli/commands/code.mjs +225 -0
  8. package/cli/commands/start.mjs +3 -2
  9. package/cli/constants.mjs +2 -1
  10. package/cli/dev/check-authority-surface.mjs +17 -8
  11. package/cli/dev/check-product-conformance.mjs +4 -32
  12. package/cli/dev/run-cli-smoke.mjs +6 -0
  13. package/cli/help.mjs +8 -3
  14. package/cli/index.mjs +3 -2
  15. package/cli/lib/authority/audit.mjs +262 -185
  16. package/cli/lib/authority/change-candidates.mjs +807 -0
  17. package/cli/lib/authority/closed-sets.mjs +7 -8
  18. package/cli/lib/authority/compile.mjs +6 -24
  19. package/cli/lib/authority/compiled-snapshot.mjs +143 -0
  20. package/cli/lib/authority/consumers.mjs +69 -19
  21. package/cli/lib/authority/diagnostics.mjs +10 -2
  22. package/cli/lib/authority/diff.mjs +77 -54
  23. package/cli/lib/authority/format.mjs +4 -32
  24. package/cli/lib/authority/git-snapshot.mjs +34 -379
  25. package/cli/lib/authority/graph.mjs +10 -10
  26. package/cli/lib/authority/impact.mjs +17 -144
  27. package/cli/lib/authority/review.mjs +33 -43
  28. package/cli/lib/authority/sarif.mjs +1 -8
  29. package/cli/lib/authority/source-yaml.mjs +0 -4
  30. package/cli/lib/authority/surface.mjs +19 -1
  31. package/cli/lib/authority/terms.mjs +10 -9
  32. package/cli/lib/authority/validate.mjs +6 -14
  33. package/cli/lib/code/authority-annotation-response.mjs +43 -0
  34. package/cli/lib/code/authority-annotation-scan.mjs +162 -0
  35. package/cli/lib/code/authority-annotations.mjs +293 -0
  36. package/cli/lib/code/context.mjs +710 -0
  37. package/cli/lib/code/response.mjs +165 -0
  38. package/cli/lib/doctor.mjs +3 -2
  39. package/cli/lib/entrypoints.mjs +13 -5
  40. package/cli/seeds/seed-policy.yaml +2 -2
  41. package/contracts/authority-source.schema.yaml +0 -6
  42. package/contracts/authority-verifier-bindings.schema.yaml +21 -10
  43. package/methodology/authority-authoring.yaml +68 -70
  44. package/methodology/core.yaml +10 -6
  45. package/package.json +5 -3
  46. package/spec/authority-audit.yaml +56 -52
  47. package/spec/authority-authoring.yaml +3 -16
  48. package/spec/authority-change-candidates.yaml +146 -0
  49. package/spec/authority-consumers.yaml +7 -0
  50. package/spec/authority-discovery.yaml +2 -2
  51. package/spec/authority-graph.yaml +1 -1
  52. package/spec/authority-impact.yaml +16 -39
  53. package/spec/authority-review.yaml +29 -47
  54. package/spec/authority-terms.yaml +5 -1
  55. package/spec/code-authority-annotations.yaml +42 -0
  56. package/spec/code-context.yaml +38 -0
  57. package/spec/product-scope.yaml +15 -9
  58. package/cli/commands/validate-ai-governance.mjs +0 -335
  59. package/cli/lib/authority/evidence-snapshot.mjs +0 -1
  60. package/cli/lib/authority/evidence.mjs +0 -1432
  61. package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +0 -377
  62. package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +0 -376
  63. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +0 -155
  64. package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +0 -173
  65. package/cli/lib/internal/governance/config.mjs +0 -114
  66. package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +0 -49
  67. package/contracts/authority-evidence-bindings.schema.yaml +0 -53
  68. package/contracts/authority-evidence-probe-results.schema.yaml +0 -38
  69. package/contracts/authority-impact-dispositions.schema.yaml +0 -13
  70. package/spec/authority-evidence.yaml +0 -200
package/README.zh-CN.md CHANGED
@@ -4,13 +4,13 @@
4
4
 
5
5
  **面向 AI Coding 系统和第三方扩展的确定性 authority 控制层。**
6
6
 
7
- Nimi Coding 将项目自行拥有的规范性规则转化为稳定身份、精确源码位置、显式关系和有界、fail-closed 的机器产品。AI host、agent framework、CI、编辑器工具和第三方扩展可以据此发现 authority、组装证据、导航关系并审查精确变更,而不把模型推断当作 repository truth。
7
+ Nimi Coding 将项目自行拥有的规范性规则转化为稳定身份、精确源码位置、显式关系和有界、fail-closed 的机器产品。它也能从明确的 repository、source、symbol 和 tsconfig 输入即时派生一份有界、只读的 TypeScript outbound context。AI host 可以使用这些产品,而不把模型推断当作 repository truth。
8
8
 
9
9
  大多数最终用户不需要直接调用 `nimicoding`。当前主要 integration surface 是已文档化的 CLI 及其 purpose-specific JSON 产品。Nimi Coding 不是 AI agent、planner、代码生成器、审批 workflow 或万能规范语言。
10
10
 
11
11
  ## 为什么需要 Nimi Coding
12
12
 
13
- AI 模型擅长生成代码,却不总能可靠判断:哪份文档真正权威、搜索结果是否完整、规则移动文件后是否还是同一规则、一次修改影响哪些显式关系,以及现有 evidence 是否真的证明 conformance。
13
+ AI 模型擅长生成代码,却不总能可靠判断:哪份文档真正权威、搜索结果是否完整、规则移动文件后是否还是同一规则、一次修改影响哪些显式关系,以及某个确定性检查究竟评价了什么。
14
14
 
15
15
  Nimi Coding 把这些问题变成显式产品语义:
16
16
 
@@ -19,11 +19,14 @@ Nimi Coding 把这些问题变成显式产品语义:
19
19
  | 多份文档看起来都像 authority | 一个封闭的 canonical authority 边界 |
20
20
  | 路径和 heading 发生变化 | 与文件和顺序无关的稳定 logical unit ID |
21
21
  | 搜索产生噪声或被截断的上下文 | 有界 discovery、exact query、declared context 和 graph 产品 |
22
+ | 选定 TypeScript symbol 后仍需宽泛读取文件 | 一份有显式预算的 root-direct outbound code-context projection |
23
+ | Authority-to-code 链接依赖名称或邻近文本猜测 | 可选的 exact authored marker 与确定性双向查询 |
24
+ | Semantic hard cut 在 declared relations 之外留下 unchanged survivors | 基于 caller-selected exact owner/scope/term/relation/Definition channels 的 change-derived recall |
22
25
  | 模型无法精确引用规则来源 | 字段级和关系级的 portable SourceMap location |
23
26
  | 文本 diff 掩盖真实语义变化 | Stable-ID semantic diff 和 declared impact obligations |
24
- | “没有结果”被展示为“clean” | 显式 budget、completeness、gap、refusal 和 failure 语义 |
27
+ | “没有结果”被展示为“clean” | 显式 budget、窄作用域 status、refusal 和 failure 语义 |
25
28
  | Git review 可能混入移动中的输入 | Immutable base OID 加完整 worktree race revalidation |
26
- | 文件或测试名称被当作符合性证明 | Evidence 与 conformance 是不同的产品状态 |
29
+ | 结构检查被扩大解释为产品 conformance | Business semantics 与 implementation conformance 固定显式为 `not_evaluated` |
27
30
 
28
31
  ## 产品模型
29
32
 
@@ -38,7 +41,7 @@ Authority Foundation
38
41
  ▼
39
42
  Spec Intelligence Plane
40
43
  discover · query · context · refs/path/subgraph
41
- diff · impact · audit · review · evidence
44
+ diff · change-candidates · impact · audit · review
42
45
  │
43
46
  ▼
44
47
  Purpose-specific JSON / human output / SARIF(仅 audit)
@@ -51,17 +54,24 @@ AI host · 第三方扩展 · CI · future editor/UI surfaces
51
54
 
52
55
  ## 当前已经可用的能力
53
56
 
54
- | 层 | 当前能力 | 证明边界 |
57
+ | 层 | 当前能力 | 事实边界 |
55
58
  | --- | --- | --- |
56
59
  | Authority Foundation | Canonical YAML/Markdown、formatter、完整 root check、private deterministic compiler 和 SourceMap | 未知或 unsupported canonical input 会被拒绝,不会被忽略 |
57
60
  | Discovery 和 exact read | Exact kind/owner/scope/lifecycle filters、normalized lexical snippets、可选 direct relation preview、exact query、bounded declared context | 不提供 semantic search、自动 authority selection 或 absence proof |
58
61
  | Graph navigation | `applies_to`/`supersedes` 上的 incoming/outgoing refs、deterministic path 和 bounded subgraph | 只使用 authored relations,不生成 inferred semantic graph |
59
- | Change intelligence | Stable-ID semantic diff 和 relation-derived impact obligations | Impact 是 review requirement,不是同步证明 |
60
- | Deterministic audit | Project-owned verifier bindings、observation/finding/required gap、JSON 和 SARIF 2.1.0 | 当前 built-in detector 是窄 governance verifier,不是自然语言矛盾引擎 |
61
- | Git-aware review | Immutable base commit 加 exact、race-checked current worktree snapshot,并复用 compile/diff/impact/audit | 只读;不管理 branch、PR、approval 或 release |
62
- | Authority-to-code evidence | Exact authority/scope 到 declared package-script command/test target reachability | 只是静态窄 slice;不执行 command/test,completed evidence 的 conformance 保持 `not_evaluated` |
62
+ | Change intelligence | Stable-ID semantic diff、change-derived active-survivor recall 和 relation-derived impact obligations | Candidate completeness 只覆盖显式 channels;impact 不接受 disposition 或 completion state |
63
+ | Deterministic audit | Project-owned graph verifier 与 exact lexical invariant bindings,输出 JSON 和 SARIF 2.1.0 | 只做大小写敏感的 exact token/phrase 检查;不做 synonym、embedding 或自然语言矛盾推断 |
64
+ | Git-aware review | Immutable base commit 加 exact、race-checked current worktree snapshot,并复用 compile/diff/impact/audit | 只读;business semantics 与 implementation conformance 固定为 `not_evaluated` |
65
+ | TypeScript code context | Root declaration source、root-direct static bindings、portable declaration loci 和符合条件的 target source slices | 明确的 `.ts`/`.tsx` root 与 tsconfig、TypeScript 5.9.3、仅 outbound;不承诺 locating、inbound impact、runtime dispatch 或 task completeness |
66
+ | 显式 code-authority 链接 | 对 Git tracked 当前 `.ts`、`.tsx`、`.go` 源码中的可选 exact marker 提供 transient Authority→Code、Code→Authority 和 lifecycle audit | 只声明 marker location;不声明 declaration ownership、annotation coverage、implementation conformance 或未标注 legacy detection |
63
67
 
64
- 当前 Nimi-realm 验证 corpus 包含 38 个 canonical containers、793 个 authority units 和 1,260 条 authored relations。这些数字证明了真实大型 corpus replay,不是 package 上限,也不代表 grammar 已覆盖所有领域。
68
+ 当前 Nimi-realm 验证 corpus 包含 33 个 canonical containers、2,212 个 authority units 和 2,159 条 authored relations。这些数字证明了真实大型 corpus replay,不是 package 上限,也不代表 grammar 已覆盖所有领域。
69
+
70
+ ## 使用 0.6 code surface
71
+
72
+ `start` 会把 package 管理的指导写入 `AGENTS.md` 和 `CLAUDE.md` 的 marked blocks。对于已有安装,`doctor` 会诊断这些指导及 compact methodology projection 的 drift,`sync --apply` 则恢复当前 package 的精确 projections,同时保留 managed blocks 之外的宿主文本。因此,遵守 repository instructions 的 AI host 可以知道何时按需调用 `code authority` 或 `code context`,以及何时只在发生变更、受 authority 约束的功能中,为少数关键语义 owner 添加 `nimi-authority` marker。
73
+
74
+ 这是一种基于 instruction 的集成,不是自动执行层。Nimi Coding 不安装 hook 或 daemon,不拦截 task,不要求固定 preflight,也不拥有 task 或 completion state。是否需要查询由 host 根据当前 coding task 决定。`code authority` 只召回显式 marker 和当前 authority lifecycle;`code context` 只返回 admitted root-direct TypeScript projection。两者都不证明 conformance,不替代 affected build/tests,也不评价未标注代码。
65
75
 
66
76
  ## 五分钟接入
67
77
 
@@ -74,6 +84,8 @@ pnpm exec nimicoding start --yes
74
84
 
75
85
  `start` 创建紧凑的 AI-visible authoring guide、`AGENTS.md`/`CLAUDE.md` 中的 managed instruction blocks,以及 ignored `.nimi/local/` root。它不会生成产品语义,也不会替项目创建 `.nimi/spec`。
76
86
 
87
+ `pnpm exec nimicoding` 是受支持的宿主调用方式:应从仓库根目录执行,使自动化解析到项目锁定的本地 package。既不要求全局 `PATH` 中存在 `nimicoding`,也不能用它判断 CLI 是否可用。
88
+
77
89
  创建一个完整 canonical source,例如 `.nimi/spec/checkout.authority.yaml`:
78
90
 
79
91
  ```yaml
@@ -97,7 +109,7 @@ units:
97
109
  target: definition.checkout-session
98
110
  ```
99
111
 
100
- > 示例为当前 v2 authoring 格式:容器承载 `owner` 与单值 `scope`,unit 省略 `lifecycle` 与空 `relations`。`nimicoding.authority/v1` 仅为迁移输入——`fmt --upgrade` 读取它并产出 v2,面向历史的命令仍可读取——不是可用于编写的格式。
112
+ > `nimicoding.authority/v2` 是唯一 admitted source format。容器承载 `owner` 与单值 `scope`,unit 可以省略 `lifecycle` 与空 `relations`。旧 source format 在格式化、admission、compile 和 history-facing analysis 中一律 fail closed;恢复依据是 Git history,而不是 compatibility input。
101
113
 
102
114
  格式化变更文件、admit 完整 root,并查询一个 exact unit:
103
115
 
@@ -132,7 +144,7 @@ pnpm exec nimicoding authority anchors . \
132
144
 
133
145
  Canonical YAML 是封闭的 `format` 加非空 `units` container;Canonical Markdown 是严格的 single-unit profile。当前模型刻意保持紧凑:`Rule` 和 `Definition`、`active` 和 `removed`、`must` 和 `must_not`,以及 authored `applies_to` 和线性 `supersedes` 关系。
134
146
 
135
- 如果某个领域需要 grammar 尚不支持的 API、schema、enum、state machine、formula 或 catalog 成员级结构,应把精度保留在 canonical grammar 之外的专业 artifact 中。只有存在显式 admitted project binding 或 adapter 时才能连接;当前 built-in evidence slice 只支持 package-script targets,不支持通用 API、schema、consumer 或 runtime integration。不要向 canonical authority 随意添加字段:unknown field 必须 fail closed,才能避免 consumer 静默忽略原本想表达的 authority。
147
+ 如果某个领域需要 grammar 尚不支持的 API、schema、enum、state machine、formula 或 catalog 成员级结构,应把精度保留在 canonical grammar 之外的专业 artifact 中;真实 integration 有需要时由项目自己的 adapter 显式连接。不要向 canonical authority 随意添加字段:unknown field 必须 fail closed,才能避免 consumer 静默忽略原本想表达的 authority。
136
148
 
137
149
  ## AI host 和第三方扩展的调用旅程
138
150
 
@@ -145,12 +157,11 @@ Canonical YAML 是封闭的 `format` 加非空 `units` container;Canonical Mar
145
157
  → fmt 变更 sources + check 完整 root
146
158
  → review immutable base 与 exact worktree
147
159
  (semantic diff + declared impact + current audit)
148
- → 如果已配置,再独立检查 current-worktree evidence
149
160
  ```
150
161
 
151
162
  Host 负责 authority selection、planning、editing、retry、remediation、review state 和 completion。Nimi Coding 负责 request validation、deterministic computation、explicit budgets、exact locations 和诚实的结果边界。
152
163
 
153
- Machine integration 应使用 argument array 调用 CLI,并同时消费 exit status 和 JSON envelope。必须读取 product-specific operation、completeness、policy、gap 和 evidence states,不能从空 candidate/finding array 推断 clean。Invalid usage/internal failure 与 completed 但 blocking/incomplete 的产品具有不同的 command-specific exit。
164
+ Machine integration 应使用 argument array 调用 CLI,并同时消费 exit status 和 JSON envelope。必须读取各产品窄作用域的 operation、analysis 与 blocking status,不能从空 candidate/finding array 推断业务或实现 conformance。Invalid usage/internal failure 与 completed 但 blocked 的产品具有不同的 command-specific exit。
154
165
 
155
166
  在已经配置好的 Git 项目中,可以使用 Git-aware exact review 获得一份组合后的 authority change product:
156
167
 
@@ -158,16 +169,30 @@ Machine integration 应使用 argument array 调用 CLI,并同时消费 exit s
158
169
  pnpm exec nimicoding authority review . \
159
170
  --base origin/main \
160
171
  --bindings .nimi/config/authority-verifiers.yaml \
161
- --dispositions .nimi/local/authority-impact-dispositions.yaml \
162
172
  --max-units 1024 \
163
173
  --max-edges 4096 \
164
174
  --max-bytes 2097152 \
165
175
  --json
166
176
  ```
167
177
 
168
- 这个例子假设 repository 已经拥有合法 verifier bindings 和 impact dispositions,并且 `origin/main` 能解析到包含 `.nimi/spec` 的 commit。`start` 刻意不会创建这些项目语义或 governance files。
178
+ 这个例子假设 repository 已经拥有合法 verifier bindings,并且 `origin/main` 能解析到包含 `.nimi/spec` 的 commit。`start` 刻意不会创建这些项目语义或 policy files。
179
+
180
+ Base ref 在开始时只解析一次并固定为 full commit OID。Base `.nimi/spec` tree 从 Git objects 读取;完整 current `.nimi/spec` filesystem tree 包含 tracked unchanged files、edits、deletions、untracked files 和 unsupported entries。Capture race、missing object、invalid corpus、malformed binding 或 budget 不足都会拒绝结果,而不是发布混合分析。该命令不会 checkout、stash、reset、stage、commit,也不管理 PR。
181
+
182
+ Redesign 或 rename 可能在 declared graph 之外留下 unchanged active survivors 时,应对显式 channel set 执行 change-derived recall:
183
+
184
+ ```bash
185
+ pnpm exec nimicoding authority change-candidates path/to/before-spec .nimi/spec \
186
+ --channels direct_relation,definition_identity,definition_title \
187
+ --max-candidates 2048 \
188
+ --max-reasons 20000 \
189
+ --max-bytes 33554432 \
190
+ --json
191
+ ```
192
+
193
+ 结果包含每个被召回的 active non-root unit、原始 normative fields、modality,以及 side-qualified exact reasons。`complete: true` 只表示 caller-requested channels 的完整 union 和全部 reasons,不表示 semantic relevance、conflict、retirement、authority validity 或 implementation conformance。Host 明确需要更宽召回时可选择 owner、scope 和 changed-term channels。Source-container proximity 不进入产品:regrouping 是 non-semantic change,而完整 annotation 会形成 roots 与 candidates 的笛卡尔积。
169
194
 
170
- Base ref 在开始时只解析一次并固定为 full commit OID。Base `.nimi/spec` tree 从 Git objects 读取;完整 current `.nimi/spec` filesystem tree 包含 tracked unchanged files、edits、deletions、untracked files 和 unsupported entries。Capture race、missing object、invalid corpus、malformed binding/disposition 或 budget 不足都会拒绝结果,而不是发布 mixed 或 false-clean review。该命令不会 checkout、stash、reset、stage、commit,也不管理 PR。
195
+ Diff、review 与 change-derived recall 复用 per-invocation immutable compiler snapshots,并构建 transient `byId`、owner、scope、container、incoming 和 outgoing indexes。所有数据都不持久化:SQLite、cache invalidation、incremental compilation、embedding 和 cleanup state 继续在产品边界之外,直到真实 workload 与 profiling 证明其必要性。
171
196
 
172
197
  ## 多维比较:旧 Nimi、当前 Nimi Coding 与成熟普通 spec
173
198
 
@@ -176,7 +201,7 @@ Base ref 在开始时只解析一次并固定为 full commit OID。Base `.nimi/s
176
201
  | 维度 | 重构前 Nimi spec 系统 | 当前 Nimi Coding | 成熟普通 spec 组合 |
177
202
  | --- | --- | --- | --- |
178
203
  | Authority 边界 | Human contracts、tables、generated views、maps 和 profile rules 依赖 precedence 约定 | 一个封闭 canonical authority root | 多个专业 source of truth,通常没有跨格式统一边界 |
179
- | Reference corpus 形态 | 144 个混合文件:101 Markdown、43 YAML,其中包括 33 generated views 和 42 tables | 38 canonical containers 编译为 793 个稳定 units | 由项目决定,通常高度异构 |
204
+ | Reference corpus 形态 | 144 个混合文件:101 Markdown、43 YAML,其中包括 33 generated views 和 42 tables | 33 canonical containers 编译为 2,212 个稳定 units | 由项目决定,通常高度异构 |
180
205
  | 身份 | Contract ID、`R-*` anchor、路径和 table row 没有统一覆盖所有对象 | 每个 unit 一个 stable ID,不依赖文件、顺序、移动或 regroup | 部分格式内部很强,跨格式不统一 |
181
206
  | 领域内部精度 | 部分 tables 能直接建模 entity、required field、API operation、Prisma/OpenAPI/service locator | 很多 enum/schema/state/catalog 细节仍是 Definition 内的原子 prose | OpenAPI、Schema、Protobuf 和专业 DSL 在各自领域最强 |
182
207
  | 人类 rationale | Rich contracts 和 generated guides | 刻意紧凑;长篇理由应放在 canonical authority 之外 | ADR 和 design docs 最强 |
@@ -188,10 +213,10 @@ Base ref 在开始时只解析一次并固定为 full commit OID。Base `.nimi/s
188
213
  | Relationship graph | Links、maps、custom fields 和 Atlas-like projections 共同表达 | 一个 authored、有界的 `applies_to`/`supersedes` graph | `$ref`、links、imports 和 conventions 仍按格式分散 |
189
214
  | 冲突发现 | Custom checks 能发现项目特定 drift | 结构冲突可确定发现;prose 矛盾仍需 AI/人判断 | 格式内可很强,跨格式冲突仍困难 |
190
215
  | Semantic change | File diff 和 generated drift 占主导 | Stable-ID semantic diff;rename/regroup/format-only 可为 semantic zero | Prose 多为 line diff;专业格式可能有优秀 domain diff |
191
- | Impact 与 audit | Project scripts、maps 和团队知识共同决定 | Declared relation impact 加 project-bound finding/gap 语义 | Build graph、CODEOWNERS、linters 和 tests 很强但分散 |
216
+ | Impact 与 audit | Project scripts、maps 和团队知识共同决定 | Declared relation impact 加 configured graph 与 exact lexical findings | Build graph、CODEOWNERS、linters 和 tests 很强但分散 |
192
217
  | Git review | 没有统一 exact authority snapshot product | Immutable-base、race-checked worktree review | 通常是 Git diff 加多个独立 format-specific checks |
193
- | Spec-to-code | Direct paths 很细,但可能 stale | 已有窄、identity-bound package-script evidence slice | Codegen、type checking 和 contract tests 可能明显更强 |
194
- | Executable conformance | 部分 custom scripts 验证具体项目事实 | 当前 evidence 刻意不声称 conformance | 高质量 tests 和 executable contracts 最强 |
218
+ | Spec-to-code | Direct paths 很细,但可能 stale | Authority core 不保存 mapping;可选 exact code marker 只提供 authored locating,未标注代码与 conformance 均保持 `not_evaluated` | Codegen、type checking 和 contract tests 可能明显更强 |
219
+ | Executable conformance | 部分 custom scripts 验证具体项目事实 | Review 显式固定为 `not_evaluated` | 高质量 tests 和 executable contracts 最强 |
195
220
  | 生态 | 高度 project-specific | 有稳定 CLI/JSON products,但还没有 public JS SDK 或模型/tool 标准 | OpenAPI/Schema/test 生态与第三方互操作最成熟 |
196
221
  | Authoring 成本 | 多种表示和 generators 成本高 | 必须维护 ID、owner、scope、lifecycle 和 relation | 探索期最低;corpus 扩大后治理成本上升 |
197
222
  | 最佳适用场景 | 项目专用的一体化 spec 系统 | 与大型、主要由 AI 消费的专业 spec estate 并行工作的稳定 normative authority control | 探索期和专业 API/data/behavior contracts |
@@ -205,44 +230,33 @@ Base ref 在开始时只解析一次并固定为 full commit OID。Base `.nimi/s
205
230
  必须始终区分三层产品事实:
206
231
 
207
232
  1. **当前已经很强:** stable identity、fail-closed admission、exact SourceMap、authored graph navigation、bounded machine products、semantic diff 和 exact Git review。
208
- 2. **已经改善但仍不完整:** 为人/AI conflict review 定位和追踪 exact inputs、task-context assembly、owner/scope accountability 和 spec-to-code traceability;矛盾判定本身不是 deterministic product。
233
+ 2. **已经改善但仍不完整:** 可选 authored marker lookup 和 bounded TypeScript outbound context 减少 implementation navigation;完整 task context、未标注代码和 conformance 仍不评价。矛盾判定本身不是 deterministic product。
209
234
  3. **刻意没有解决:** 通用业务语义完备性、自动 authority selection、可执行 code conformance、模型推理和 AI workflow orchestration。
210
235
 
211
- 如果 Nimi Coding 标准化的是 authority protocol,而不是试图吞并所有领域语言,它的长期上限很高。Model-native 生态可以训练 AI:先 discover 再猜测、解析 exact ID、区分 authored fact 与 inference、尊重 gap/completeness,并在编辑后主动请求 review/evidence。但 deterministic runtime product 必须继续作为 oracle;模型熟悉 Nimi Coding 不能替代 admission 或 evidence。
236
+ 如果 Nimi Coding 标准化的是 authority protocol,而不是试图吞并所有领域语言,它的长期上限很高。Model-native 生态可以训练 AI:先 discover 再猜测、解析 exact ID、区分 authored fact 与 inference、尊重 refusal 与窄作用域 status,并在编辑后主动请求有界分析。但 deterministic runtime product 必须继续作为 oracle;模型熟悉 Nimi Coding 不能替代 admission 或项目真实的 tests 和 gates。
212
237
 
213
238
  ## 安全与 truth 边界
214
239
 
215
240
  - 只有 `.nimi/spec/**` 下的 `*.authority.yaml` 和 `*.authority.md` 是 canonical product authority。
216
241
  - ID、relation、owner 和 scope 都是 declared facts。Nimi Coding 不从 prose 推断关系或现实组织责任。
217
242
  - `discover` 是 deterministic lexical candidate retrieval,不是 semantic search、selection、context assembly 或 absence proof。
243
+ - `change-candidates` 只对显式请求的 deterministic channels 返回完整 union;它不 ranking、不推断 conflict、不选择 retirement,也不证明这些 channels 之外不存在候选。
218
244
  - `context` 是 complete bounded outgoing interpretation closure,不是 complete task context。
219
245
  - `audit` 执行显式绑定的 deterministic governance check,不证明全部业务规则不存在矛盾。
220
- - `impact` 生成 declared review obligations;disposition 不证明 implementation 或 tests 已同步。
221
- - `review` 评价 captured current snapshot;除非未来产品显式比较 finding fingerprints,否则不把 current finding 归因为本次 change。
246
+ - `impact` 报告 declared relation impact 和 host-owned consumer/test follow-up targets;它不接受 disposition 或 completion state。
247
+ - `review` 评价 captured current snapshot,并把 `businessSemanticStatus` 与 `implementationConformanceStatus` 固定报告为 `not_evaluated`;它不把 current finding 归因为本次 change。
222
248
  - Snapshot no-follow 加固受平台能力限制。在 `win32` 上,Node.js 不提供 `O_NOFOLLOW`/`O_DIRECTORY`,因此 snapshot capture 仅使用外围 `lstat`/`realpath` 校验,不具备 descriptor-level no-follow 保证。
223
- - `evidence` 当前只证明 declared package-script target reachability。它不执行 command/test;每个 completed evidence product 都报告 `conformanceStatus: not_evaluated`,refused input 则不返回 evidence product。
224
249
  - Raw AuthorityIR、SourceMap internals 和 compiler implementation 都是 package-private。当前没有 public JavaScript API(`exports` 为空)。
225
- - `.nimi/local/**` 是 derived/local evidence,永远不是 product authority。
226
-
227
- ## Future roadmap
250
+ - `.nimi/local/**` 是 derived/local output,永远不是 product authority。
228
251
 
229
- Roadmap 当前暂停在已经验证的 baseline。以下是 future candidate lanes,不代表 implementation authorization、release promise 或隐含顺序。未来每次迭代应只选择一个真实 adopter journey。
252
+ ## Future work
230
253
 
231
- | Candidate lane | 目标产品 | Entry condition |
232
- | --- | --- | --- |
233
- | Stateless AI tool adapter | 在现有 bounded JSON products 上提供 typed tools,可采用 MCP 或 extension API | 真实 host integration 证明直接调用 CLI 不足 |
234
- | General M4 API/consumer evidence | API/consumer locators 和 producer → API → consumer reachability | 存在真实 canonical-authority seam;不得从当前 package-script slice 外推 |
235
- | D2 IDE/LSP | Live diagnostics、exact-ID navigation/completion、full-snapshot unsaved-buffer overlay | 持续 editor journey 足以支持独立 delivery unit |
236
- | D3 local Studio | Read-only unit/graph/diff/impact/audit/evidence exploration | 先验证多个真实 review/exploration journeys |
237
- | D4 external semantic candidates | 带 provenance 和 abstention 的 model/embedding/reranking candidates | 在 owner-approved task corpus 上量化 lexical/graph 不足 |
238
- | E1 multi-repository Atlas | Visibility-filtered canonical repository snapshot composition | Ecosystem repositories、identity、visibility、ownership 和 workspace membership 都已明确 |
239
-
240
- 以下工作必须独立、按条件进入:
254
+ 0.6 有意停在当前 request-local products,不暗示下一阶段。后续迭代应从一个真实 adopter failure 开始,并且只增加解决它所需的最小机制:
241
255
 
242
- - Structured Definitions、replacement DAG、owner/scope registry 或 public library API,必须先证明真实 authoring/query/consumer loss。
243
- - Storage、SQLite、cache 或 incremental compilation,必须先有真实 workload 违反预先声明的 SLO,并由 profiling 证明瓶颈来自 repeated parse/index/join。
244
- - Version bump、tag、publish、ecosystem activation 和 release compatibility 都属于独立 release decision。
245
- - AI planning、delegation、execution、approval、task state、model/provider orchestration 和 inferred model findings 不属于 core package。
256
+ - 只有真实使用证明直接调用 CLI 不足时,才增加 typed host adapter。
257
+ - 只有持续的 editor journey 确实需要时,才增加 unsaved-buffer 支持。
258
+ - 只有实测使用证明当前 transient exact products 无法解决具体损失时,才增加 storage、semantic retrieval 或 multi-repository composition。
259
+ - AI planning、delegation、execution、approval、task state、model/provider orchestration、implementation conformance 和 completion tracking 继续位于 core package 之外。
246
260
 
247
261
  ## Command reference
248
262
 
@@ -253,18 +267,17 @@ Roadmap 当前暂停在已经验证的 baseline。以下是 future candidate lan
253
267
  | Author 和 admit | `authority fmt`、`authority check`、`authority compile` |
254
268
  | Find 和 read | `authority discover`、`authority query`、`authority context` |
255
269
  | Navigate | `authority refs`、`authority path`、`authority subgraph` |
256
- | Analyze 和 review | `authority audit`、`authority diff`、`authority impact`、`authority review` |
270
+ | Analyze 和 review | `authority audit`、`authority diff`、`authority change-candidates`、`authority impact`、`authority review` |
257
271
  | 校验词法 anchors | `authority anchors` |
258
- | 连接 bounded evidence | `authority evidence` |
272
+ | 读取 implementation context 与显式链接 | `code context`、`code authority` |
259
273
  | Project lifecycle | `start`、`sync`、`doctor`、`clear` |
260
- | 可选 L3 repository governance | `validate-ai-governance` |
261
274
 
262
275
  <details>
263
276
  <summary>完整 authority command syntax</summary>
264
277
 
265
278
  ```text
266
- nimicoding authority fmt <file> [--check] [--upgrade] [--json]
267
- nimicoding authority check <path> [--scope-bindings <file>] [--require-format <format>] [--json]
279
+ nimicoding authority fmt <file> [--check] [--json]
280
+ nimicoding authority check <path> [--scope-bindings <file>] [--json]
268
281
  nimicoding authority compile <path> [--json]
269
282
  nimicoding authority anchors <repository-path> --spec <corpus-path> [--scope-bindings <file>] [--embedded-paths] --max-units <n> --max-anchors <n> --max-bytes <n> [--json]
270
283
  nimicoding authority consumers <repository-path> --spec <corpus-path> [--external-root <scheme>=<path>]... --max-files <n> --max-refs <n> --max-bytes <n> [--json]
@@ -278,31 +291,55 @@ nimicoding authority path <path> <from-id> <to-id> --traversal <directed|inciden
278
291
  nimicoding authority subgraph <path> <id> --direction <incoming|outgoing|both> --relations <comma-separated-relation-types> --depth <n> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
279
292
  nimicoding authority audit <path> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json|--sarif]
280
293
  nimicoding authority diff <before-path> <after-path> --max-bytes <n> [--json]
281
- nimicoding authority impact <before-path> <after-path> --dispositions <file> --max-bytes <n> [--json]
282
- nimicoding authority review <repository-path> --base <git-ref> --bindings <file> --dispositions <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
283
- nimicoding authority evidence <repository-path> --bindings <tracked-.nimi/config-path> [--probe-results <.nimi/local-path>] --max-units <n> --max-bindings <n> --max-locators <n> --max-edges <n> --max-input-bytes <n> --max-bytes <n> [--json]
294
+ nimicoding authority change-candidates <before-path> <after-path> --channels <comma-separated-closed-set> --max-candidates <n> --max-reasons <n> --max-bytes <n> [--json]
295
+ nimicoding authority impact <before-path> <after-path> --max-bytes <n> [--json]
296
+ nimicoding authority review <repository-path> --base <git-ref> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
284
297
  ```
285
298
 
286
299
  </details>
287
300
 
301
+ <details>
302
+ <summary>显式 code-authority marker syntax</summary>
303
+
304
+ ```text
305
+ // nimi-authority: <exact-authority-id>
306
+ // nimi-deprecated: <exact-authority-id>
307
+
308
+ nimicoding code authority --repo <exact-git-worktree-root> (--authority <exact-id>|--source <repo-relative-.ts-.tsx-or-.go-path>|--audit) --max-files <integer> --max-bytes <integer>=512
309
+ ```
310
+
311
+ Marker 是可选的 exact authored link。命令编译 repository 的完整 canonical `.nimi/spec`,一次扫描所选 Git tracked 当前文件系统源码范围,并返回一个完整 compact JSON result,否则拒绝。`nimi-deprecated` 记录开发者的显式判断并由 audit 报告;工具不推断该判断,也不证明 marker pairing、declaration ownership、conformance 或 hard-cut completion。未标注代码仍然合法并保持 `not_evaluated`。命令不写入 index、cache、scope binding、report 或 task state。
312
+
313
+ </details>
314
+
315
+ <details>
316
+ <summary>TypeScript code context syntax</summary>
317
+
318
+ ```text
319
+ nimicoding code context <repo-relative-.ts-or-.tsx-path> --repo <exact-git-worktree-root> --symbol <top-level-identifier> --tsconfig <repo-relative-tsconfig> --max-bytes <integer>=512
320
+ ```
321
+
322
+ 该命令读取当前文件系统,并向 stdout 写入一个 compact JSON response。`completed` 只覆盖封闭的 root-direct static-binding policy;`partial` 返回首个 output-budget frontier;`refused` 不包含可用 context product。命令不会编辑 repository,也不会选择、运行或保存 verification。
323
+
324
+ </details>
325
+
288
326
  Relation types 是 closed set `applies_to,supersedes` 的非空、无重复 subset;discovery relation preview 必须同时提供 direction、relation types 和 edge budget。
289
327
 
290
328
  <details>
291
- <summary>Project lifecycle、governance 和 global syntax</summary>
329
+ <summary>Project lifecycle 和 global syntax</summary>
292
330
 
293
331
  ```text
294
332
  nimicoding start [--yes]
295
333
  nimicoding sync [--apply|--check|--dry-run] [--json]
296
334
  nimicoding clear [--yes]
297
335
  nimicoding doctor [--verbose|--json]
298
- nimicoding validate-ai-governance --profile <profile-id> --scope <all|agents-freshness|context-budget|structure-budget|high-risk-doc-metadata> [--json]
299
336
  ```
300
337
 
301
338
  Global presentation options 是 `--lang en|zh`、`--color` 和 `--no-color`。
302
339
 
303
340
  </details>
304
341
 
305
- Projection ownership 是精确的:`start`/`sync` 只拥有其已文档化的 managed paths 和 marked instruction blocks。Projection sync 不检查或修改这些 exact managed surfaces 之外的 files。可选 `validate-ai-governance` 与 authority admission、host task execution 保持分离。
342
+ Projection ownership 是精确的:`start`/`sync` 只拥有其已文档化的 managed paths 和 marked instruction blocks。Projection sync 不检查或修改这些 exact managed surfaces 之外的 files。Code queries 是 request-local 的,不参与 authority admission 或 host task execution。
306
343
 
307
344
  ## Development
308
345