@nimiplatform/nimi-coding 0.3.1 → 0.5.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/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +3 -3
- package/README.md +297 -41
- package/README.zh-CN.md +306 -31
- package/bin/nimicoding.mjs +1 -1
- package/cli/commands/authority.mjs +804 -0
- package/cli/commands/clear.mjs +27 -7
- package/cli/commands/doctor.mjs +10 -1
- package/cli/commands/start.mjs +23 -27
- package/cli/commands/sync.mjs +21 -101
- package/cli/constants.mjs +7 -31
- package/cli/dev/check-authority-surface.mjs +182 -0
- package/cli/dev/check-product-conformance.mjs +889 -0
- package/cli/help.mjs +10 -17
- package/cli/index.mjs +6 -47
- package/cli/lib/authority/anchors.mjs +491 -0
- package/cli/lib/authority/audit.mjs +567 -0
- package/cli/lib/authority/change-candidates.mjs +807 -0
- package/cli/lib/authority/closed-sets.mjs +645 -0
- package/cli/lib/authority/compile.mjs +92 -0
- package/cli/lib/authority/compiled-snapshot.mjs +143 -0
- package/cli/lib/authority/consumers.mjs +520 -0
- package/cli/lib/authority/diagnostics.mjs +93 -0
- package/cli/lib/authority/diff.mjs +310 -0
- package/cli/lib/authority/discover.mjs +447 -0
- package/cli/lib/authority/format.mjs +169 -0
- package/cli/lib/authority/git-snapshot.mjs +720 -0
- package/cli/lib/authority/graph.mjs +351 -0
- package/cli/lib/authority/impact.mjs +125 -0
- package/cli/lib/authority/lexicon.mjs +55 -0
- package/cli/lib/authority/query.mjs +162 -0
- package/cli/lib/authority/repository-corpus.mjs +37 -0
- package/cli/lib/authority/repository-inventory.mjs +34 -0
- package/cli/lib/authority/review.mjs +212 -0
- package/cli/lib/authority/sarif.mjs +174 -0
- package/cli/lib/authority/scope-bindings.mjs +225 -0
- package/cli/lib/authority/source-map.mjs +105 -0
- package/cli/lib/authority/source-markdown.mjs +167 -0
- package/cli/lib/authority/source-yaml.mjs +308 -0
- package/cli/lib/authority/surface.mjs +97 -0
- package/cli/lib/authority/terms.mjs +422 -0
- package/cli/lib/authority/tracked-text.mjs +70 -0
- package/cli/lib/authority/validate.mjs +300 -0
- package/cli/lib/bootstrap.mjs +55 -71
- package/cli/lib/doctor.mjs +40 -123
- package/cli/lib/entrypoints.mjs +104 -105
- package/cli/lib/fs-helpers.mjs +139 -15
- package/cli/lib/internal/governance/config.mjs +0 -36
- package/cli/lib/shared.mjs +8 -21
- package/cli/lib/sync.mjs +81 -92
- package/cli/lib/value-helpers.mjs +0 -26
- package/cli/lib/yaml-helpers.mjs +1 -124
- package/cli/seeds/bootstrap.mjs +31 -87
- package/cli/seeds/seed-policy.yaml +9 -63
- package/contracts/authority-scope-bindings.schema.yaml +15 -0
- package/contracts/authority-source.schema.yaml +58 -0
- package/contracts/authority-verifier-bindings.schema.yaml +31 -0
- package/methodology/authority-authoring.yaml +127 -0
- package/methodology/core.yaml +34 -27
- package/package.json +10 -6
- package/spec/authority-anchors.yaml +99 -0
- package/spec/authority-audit.yaml +89 -0
- package/spec/authority-authoring.yaml +137 -0
- package/spec/authority-change-candidates.yaml +146 -0
- package/spec/authority-closed-sets.yaml +65 -0
- package/spec/authority-consumers.yaml +77 -0
- package/spec/authority-context.yaml +50 -0
- package/spec/authority-discovery.yaml +119 -0
- package/spec/authority-graph.yaml +59 -0
- package/spec/authority-impact.yaml +61 -0
- package/spec/authority-review.yaml +71 -0
- package/spec/authority-terms.yaml +63 -0
- package/spec/product-scope.yaml +37 -23
- package/cli/commands/blueprint-audit.mjs +0 -91
- package/cli/commands/classify-spec-tree.mjs +0 -5
- package/cli/commands/generate-spec-derived-docs.mjs +0 -151
- package/cli/commands/generate-spec-migration-plan.mjs +0 -30
- package/cli/commands/surface-validator-command.mjs +0 -49
- package/cli/commands/validate-domain-admission.mjs +0 -5
- package/cli/commands/validate-guidance-bodies.mjs +0 -5
- package/cli/commands/validate-placement.mjs +0 -5
- package/cli/commands/validate-projection-edges.mjs +0 -5
- package/cli/commands/validate-spec-audit.mjs +0 -27
- package/cli/commands/validate-spec-governance.mjs +0 -144
- package/cli/commands/validate-spec-tree.mjs +0 -27
- package/cli/commands/validate-table-family.mjs +0 -5
- package/cli/commands/validate-tracked-output-admission.mjs +0 -5
- package/cli/lib/blueprint-audit.mjs +0 -363
- package/cli/lib/contracts.mjs +0 -21
- package/cli/lib/internal/contracts-loaders.mjs +0 -47
- package/cli/lib/internal/contracts-parse.mjs +0 -192
- package/cli/lib/internal/governance/runner.mjs +0 -35
- package/cli/lib/internal/surface-taxonomy-validators.mjs +0 -1147
- package/cli/lib/internal/validators-shared.mjs +0 -12
- package/cli/lib/internal/validators-spec-helpers.mjs +0 -52
- package/cli/lib/internal/validators-spec.mjs +0 -380
- package/cli/lib/validators.mjs +0 -30
- package/config/bootstrap.yaml +0 -6
- package/config/spec-generation-inputs.yaml +0 -41
- package/contracts/domain-admission.schema.yaml +0 -56
- package/contracts/migration-inventory.schema.yaml +0 -15
- package/contracts/negative-fixtures.yaml +0 -26
- package/contracts/placement-contract.schema.yaml +0 -127
- package/contracts/projection-edge.schema.yaml +0 -46
- package/contracts/shared-enums.yaml +0 -63
- package/contracts/spec-generation-audit.schema.yaml +0 -46
- package/contracts/spec-generation-inputs.schema.yaml +0 -43
- package/contracts/spec-layout.schema.yaml +0 -32
- package/contracts/surface-taxonomy.schema.yaml +0 -139
- package/contracts/table-family.schema.yaml +0 -133
- package/contracts/tracked-output-admission.schema.yaml +0 -17
- package/methodology/four-closure-policy.yaml +0 -20
- package/methodology/role-separation-policy.yaml +0 -22
- package/methodology/spec-reconstruction.yaml +0 -69
- package/spec/_meta/spec-tree-model.yaml +0 -44
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
- Hard-cut canonical source admission to `nimicoding.authority/v2`; removed `fmt --upgrade`, `check --require-format`, and all v1 migration/history compatibility paths.
|
|
8
|
+
- Hard-cut the public `authority evidence` surface and impact-disposition contract; implementation/test/gate execution and conformance remain host-project responsibilities.
|
|
9
|
+
- Revised `authority audit`, `authority impact`, and `authority review` to v2 contracts: audit evaluates explicit graph and exact lexical-invariant bindings without positive proof packets, impact is pure before/after analysis, and review reports narrow assurance dimensions with business semantics and implementation conformance explicitly not evaluated.
|
|
10
|
+
- Added explicit-channel `authority change-candidates`, immutable per-invocation compiler snapshots with transient indexes, acronym-bearing term support, and focused source-string escape handling for authority consumer paths; no SQLite, cache, ranking, inferred relation, or semantic judgment is introduced.
|
|
11
|
+
- Reused one immutable snapshot pair across diff and change-derived recall, made audit consume the same read model, normalized fail-closed `partial: false` envelopes, hardened segment-aware path containment, and added corpus-bound audit surface consistency checks.
|
|
12
|
+
- Renamed graph and audit traversal accounting away from proof terminology while preserving complete fail-closed budget enforcement.
|
|
13
|
+
|
|
14
|
+
## 0.4.0
|
|
15
|
+
|
|
16
|
+
- Added bounded fail-closed `authority anchors` validation for closed lexical file/script anchors and optional tracked-file scope globs against an exact Git repository root.
|
|
17
|
+
- Added optional fail-closed `authority check --scope-bindings <file>` enforcement for exact bidirectional registration of active-rule scopes without repository path resolution.
|
|
18
|
+
- Added strict single-unit Canonical Markdown and closed multi-unit Canonical YAML `authority fmt`, `authority check`, and package-private deterministic compilation with SourceMaps.
|
|
19
|
+
- Added `nimicoding.authority/v2` container defaults plus deterministic `fmt --upgrade` from v1 while retaining v1 only as an explicit migration and history-facing input.
|
|
20
|
+
- Hard-cut read-only fail-closed `authority discover` to `nimicoding.authority-discovery/v2`, adding singular exact kind/owner/scope/lifecycle filters, SourceMapped deterministic normalized-term snippets, and an optional complete M1 direct-authored relation preview; the ranking tuple is unchanged, and the product never selects authority, supplies context, or performs semantic search.
|
|
21
|
+
- Added exact-ID `authority query` and complete fail-closed bounded `authority context` over admitted compiler products.
|
|
22
|
+
- Added byte-bounded compiler-output `authority diff` and explicit-relation `authority impact` with retained tombstones and fail-closed consumer/test dispositions.
|
|
23
|
+
- Added fail-closed `authority refs`, `authority path`, and `authority subgraph` over explicit admitted relations with portable SourceMap locations, deterministic traversal, and hop/unit/edge/UTF-8 byte budgets.
|
|
24
|
+
- Added repository-bound `authority consumers`, `authority terms`, and `authority closed-sets` reports for deterministic spec-consumption inventory, exact identifier cross-reference, and paired closed-vocabulary drift detection.
|
|
25
|
+
- Added project-bound deterministic `authority audit` with governance-bound observations/findings, required-coverage gaps, stable fingerprints, and SARIF 2.1.0 projection.
|
|
26
|
+
- Added Git-aware exact `authority review`: one immutable base commit and one race-checked current worktree snapshot compose the existing compiler, diff, impact, and current-audit products without changing Git or authority.
|
|
27
|
+
- Added machine-first current-worktree `authority evidence` with exact authority/package-script/test-target bindings, independent content identities, a closed static `package-script-target-reachability/v1` probe, and identity-bound external supplied results; it executes nothing and always leaves conformance not evaluated.
|
|
28
|
+
- Corrected public CLI pipe flushing so large JSON diagnostics and bounded semantic payloads complete before process exit.
|
|
29
|
+
- Hard-cut the legacy reconstruction, taxonomy, table, generation-audit, placement, and spec-governance command plane; `authority check` is now the sole `.nimi/spec` conformance gate.
|
|
30
|
+
- Contracted bootstrap/sync to one exact compact-guide projection plus managed instruction blocks; unrelated host files are ignored and exact deprecated projection paths fail closed.
|
|
31
|
+
- Retained `validate-ai-governance` only as optional L3 repository governance, separate from authority admission and host task execution.
|
|
32
|
+
- Hardened managed project paths with no-follow/shared-inode preflight, fatal UTF-8 host-envelope reads, strict managed-block topology, exact-span clear behavior, and effective-final `.gitignore` rule matching; failed preflight performs no managed mutation.
|
|
33
|
+
- Added behavioural product-conformance gates that verify the repository-bound command contracts against worktree and packed-package implementations.
|
|
34
|
+
|
|
3
35
|
## 0.3.1
|
|
4
36
|
|
|
5
37
|
- Made `validate-spec-governance --scope all` fail closed on the canonical spec tree before running project-configured checks.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Contributing
|
|
2
2
|
|
|
3
|
-
Nimi Coding accepts changes to methodology,
|
|
3
|
+
Nimi Coding accepts changes to canonical-authority methodology, formatter/compiler primitives, exact managed projections, deterministic authority gates, and optional L3 repository checks. Historical-format reconstruction, product-semantic generation, AI-host control, provider execution, task-state management, and review-state management are outside this package.
|
|
4
4
|
|
|
5
5
|
Before opening a change:
|
|
6
6
|
|
|
@@ -11,6 +11,6 @@ pnpm check:pack
|
|
|
11
11
|
pnpm check:ci
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Contract changes must update their parser or validator, negative cases, documentation, and package projection tests together. Do not add
|
|
14
|
+
Contract changes must update their parser or validator, negative cases, documentation, and package projection tests together. Do not add historical-format compatibility; Git history is the recovery evidence.
|
|
15
15
|
|
|
16
|
-
Never commit `.nimi/local/**`,
|
|
16
|
+
Never commit `.nimi/local/**`, credentials, provider transcripts, or private repository evidence.
|
package/README.md
CHANGED
|
@@ -1,64 +1,320 @@
|
|
|
1
1
|
# Nimi Coding
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[简体中文](./README.zh-CN.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Deterministic authority for AI coding systems and third-party extensions.**
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Nimi Coding turns project-owned normative specifications into stable identities, exact source locations, authored relations, and bounded fail-closed machine products. AI hosts, agent frameworks, CI systems, editor tooling, and third-party extensions can use those products to discover authority, navigate relationships, and review exact changes without treating model inference as repository truth.
|
|
8
|
+
|
|
9
|
+
Most end users should not need to invoke `nimicoding` directly. The primary integration surface is the documented CLI and its purpose-specific JSON products. Nimi Coding is not an AI agent, planner, code generator, approval workflow, or universal specification language.
|
|
10
|
+
|
|
11
|
+
## Why it exists
|
|
12
|
+
|
|
13
|
+
AI models are good at generating code. They are less reliable at determining which document is authoritative, whether a search result is complete, how a rule moved across files, which declared relationships a change affects, or what a deterministic check actually evaluated.
|
|
14
|
+
|
|
15
|
+
Nimi Coding makes those questions explicit:
|
|
16
|
+
|
|
17
|
+
| AI coding problem | Nimi Coding control |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| Several documents appear authoritative | One closed canonical authority boundary |
|
|
20
|
+
| Paths and headings change | Stable logical unit IDs independent of files and order |
|
|
21
|
+
| Search returns noisy or truncated context | Bounded discovery, exact query, declared context, and graph products |
|
|
22
|
+
| A semantic cut leaves unchanged survivors outside declared relations | Change-derived recall over caller-selected exact owner/scope/term/relation/Definition channels |
|
|
23
|
+
| A model cannot cite the exact source | Portable field- and relation-level SourceMap locations |
|
|
24
|
+
| Textual diffs obscure semantic change | Stable-ID semantic diff and declared impact obligations |
|
|
25
|
+
| “No result” is presented as “clean” | Explicit budgets, scoped statuses, refusal, and failure semantics |
|
|
26
|
+
| A Git review may mix moving inputs | Immutable base OID plus race-checked complete worktree capture |
|
|
27
|
+
| Structural checks are read as product conformance | Business semantics and implementation conformance remain explicitly `not_evaluated` |
|
|
28
|
+
|
|
29
|
+
## Product model
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
Project-owned canonical authority
|
|
33
|
+
.nimi/spec/**/*.authority.{yaml,md}
|
|
34
|
+
│
|
|
35
|
+
▼
|
|
36
|
+
Authority Foundation
|
|
37
|
+
fmt · check · compile CLI over private AuthorityIR/SourceMap
|
|
38
|
+
│
|
|
39
|
+
▼
|
|
40
|
+
Spec Intelligence Plane
|
|
41
|
+
discover · query · context · refs/path/subgraph
|
|
42
|
+
diff · change-candidates · impact · audit · review
|
|
43
|
+
│
|
|
44
|
+
▼
|
|
45
|
+
Purpose-specific JSON / human output / SARIF (audit only)
|
|
46
|
+
│
|
|
47
|
+
▼
|
|
48
|
+
AI hosts · third-party extensions · CI · future editor/UI surfaces
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Projects own all product meaning. Nimi Coding admits, locates, relates, and derives bounded products from that meaning; it does not invent it. OpenAPI, JSON Schema, Protobuf, tests, ADRs, and design documents remain the right tools for specialized structure, executable verification, rationale, examples, and diagrams.
|
|
52
|
+
|
|
53
|
+
## What works today
|
|
54
|
+
|
|
55
|
+
| Layer | Current capability | Truth boundary |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| Authority Foundation | Canonical YAML/Markdown, formatter, complete-root check, private deterministic compiler and SourceMap | Unknown or unsupported canonical input is rejected, not ignored |
|
|
58
|
+
| Discovery and exact reads | Exact kind/owner/scope/lifecycle filters, normalized lexical snippets, optional direct relation preview, exact query, bounded declared context | No semantic search, automatic authority selection, or absence proof |
|
|
59
|
+
| Graph navigation | Incoming/outgoing refs, deterministic paths, bounded subgraphs over `applies_to` and `supersedes` | Only authored relations; no inferred semantic graph |
|
|
60
|
+
| Change intelligence | Stable-ID semantic diff, change-derived active-survivor recall, and relation-derived impact obligations | Candidate completeness is scoped to explicit channels; impact accepts no disposition or completion state |
|
|
61
|
+
| Deterministic audit | Project-owned bindings for the graph verifier and exact lexical invariants, with JSON and SARIF 2.1.0 | Exact case-sensitive token/phrase checks only; no synonym, embedding, or natural-language contradiction inference |
|
|
62
|
+
| Git-aware review | Immutable base commit plus exact, race-checked current worktree snapshot composed through compile/diff/impact/audit | Read-only; business semantics and implementation conformance are explicitly `not_evaluated` |
|
|
63
|
+
|
|
64
|
+
The current Nimi-realm validation corpus contains 33 canonical containers, 2,212 authority units, and 2,159 authored relations. Those figures demonstrate a real large-corpus replay; they are not package limits or a claim that the grammar covers every possible domain.
|
|
65
|
+
|
|
66
|
+
## Five-minute adoption path
|
|
67
|
+
|
|
68
|
+
Install and initialize the package:
|
|
8
69
|
|
|
9
70
|
```bash
|
|
10
71
|
pnpm add -D @nimiplatform/nimi-coding
|
|
11
72
|
pnpm exec nimicoding start --yes
|
|
12
73
|
```
|
|
13
74
|
|
|
14
|
-
|
|
75
|
+
`start` creates the compact AI-visible authoring guide, managed instruction blocks in `AGENTS.md` and `CLAUDE.md`, and the ignored `.nimi/local/` root. It does not generate product semantics or create `.nimi/spec` for the project.
|
|
15
76
|
|
|
16
|
-
|
|
17
|
-
- `.nimi/contracts/**` — authority, taxonomy, placement, and audit contracts
|
|
18
|
-
- `.nimi/methodology/**` — reasoning and spec-construction methodology
|
|
19
|
-
- managed guidance blocks in `AGENTS.md` and `CLAUDE.md`
|
|
77
|
+
Author a complete canonical source such as `.nimi/spec/checkout.authority.yaml`:
|
|
20
78
|
|
|
21
|
-
|
|
79
|
+
```yaml
|
|
80
|
+
format: nimicoding.authority/v2
|
|
81
|
+
owner: team.checkout
|
|
82
|
+
scope: api.checkout
|
|
83
|
+
units:
|
|
84
|
+
- id: definition.checkout-session
|
|
85
|
+
kind: definition
|
|
86
|
+
title: Checkout session
|
|
87
|
+
meaning: A server-owned session representing an active checkout.
|
|
88
|
+
- id: rule.checkout-session
|
|
89
|
+
kind: rule
|
|
90
|
+
title: Checkout requires a server-owned session
|
|
91
|
+
modality: must
|
|
92
|
+
statement: Checkout operations use a server-owned checkout session.
|
|
93
|
+
condition: Whenever a checkout operation begins.
|
|
94
|
+
failure: Reject the operation.
|
|
95
|
+
relations:
|
|
96
|
+
- type: applies_to
|
|
97
|
+
target: definition.checkout-session
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
> `nimicoding.authority/v2` is the only admitted source format. The container carries `owner` and a single `scope`, and units may omit `lifecycle` and empty `relations`. Older source formats fail closed in formatting, admission, compilation, and history-facing analysis; Git history remains the recovery record rather than a compatibility input.
|
|
22
101
|
|
|
23
|
-
|
|
102
|
+
Format changed files, admit the complete root, and query one exact unit:
|
|
24
103
|
|
|
25
104
|
```bash
|
|
26
|
-
|
|
27
|
-
pnpm exec nimicoding
|
|
28
|
-
pnpm exec nimicoding
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
105
|
+
pnpm exec nimicoding authority fmt .nimi/spec/checkout.authority.yaml
|
|
106
|
+
pnpm exec nimicoding authority check .nimi/spec --json
|
|
107
|
+
pnpm exec nimicoding authority query .nimi/spec rule.checkout-session --max-bytes 32768 --json
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`authority check` on the complete root is the sole .nimi/spec conformance gate. Formatting a file does not admit its semantics, and checking only a changed file cannot replace the complete-root check. When `--scope-bindings <file>` is supplied, check also requires an exact bidirectional match between registered scopes and active-rule scope use; it validates binding declarations without resolving repository paths.
|
|
111
|
+
|
|
112
|
+
### Static authority anchors
|
|
113
|
+
|
|
114
|
+
`authority anchors` performs bounded, read-only lexical validation against one exact Git worktree root:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm exec nimicoding authority anchors . \
|
|
118
|
+
--spec .nimi/spec \
|
|
119
|
+
--scope-bindings .nimi/config/authority-scope-bindings.yaml \
|
|
120
|
+
--max-units 1024 \
|
|
121
|
+
--max-anchors 4096 \
|
|
122
|
+
--max-bytes 2097152 \
|
|
123
|
+
--json
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
The anchor grammar is closed and case-sensitive. A **token** is one maximal non-whitespace sequence; punctuation attached without whitespace remains part of that token.
|
|
127
|
+
|
|
128
|
+
- **Class A — file path:** a token containing at least one `/` and ending exactly in one of `.mjs`, `.js`, `.ts`, `.tsx`, `.rs`, `.go`, `.yaml`, `.yml`, `.md`, `.json`, `.proto`, or `.ps1`. Tokens beginning with `~` (including `~/`), `/`, an ASCII-letter Windows drive prefix such as `C:\` or `C:/`, or `\\` (UNC) are excluded by deterministic prefix checks because they denote runtime or host paths rather than repository paths. Every admitted token must equal a path returned by the repository-root `git ls-files` tracked-file inventory. There is no path normalization, prefix removal, or inferred match.
|
|
129
|
+
- **Class B — package script:** the token `pnpm`, exactly one ASCII space, then one maximal non-whitespace script-name token. The name is admitted when it contains `:` or fully matches `[a-z][a-z0-9:-]*`; pnpm builtins `add`, `audit`, `create`, `dlx`, `exec`, `install`, `link`, `list`, `outdated`, `patch`, `publish`, `remove`, `run`, `update`, and `why` are excluded before exact own-key resolution against the root `package.json` `scripts` object. Nothing is executed.
|
|
130
|
+
|
|
131
|
+
Only active-unit `meaning`, `statement`, `condition`, and `failure` fields are scanned. With `--scope-bindings`, every `path_glob` must match at least one tracked file; `*` excludes `/`, `?` matches one non-`/` character, and `**` crosses path segments. `module` and `command` bindings remain structure-only in this version. Human and JSON results report `{units, anchorsChecked, diagnostics}`; anchor diagnostics are ordered by unit ID, anchor text, field, and class and identify the exact unit and field. Unit, anchor, and compact UTF-8 result-byte budgets reject the whole validation rather than truncating it.
|
|
132
|
+
|
|
133
|
+
Canonical YAML is a closed `format` plus non-empty `units` container. Canonical Markdown is a strict single-unit profile. The model is intentionally compact: `Rule` and `Definition`, `active` and `removed`, `must` and `must_not`, plus authored `applies_to` and linear `supersedes` relations.
|
|
134
|
+
|
|
135
|
+
If a domain needs member-level API, schema, enum, state-machine, formula, or catalog structure that this grammar does not support, keep that precision in a specialized artifact outside the canonical grammar. Connect it through a project-owned adapter when a real integration requires it. Do not add arbitrary canonical fields: unknown fields fail closed so that no consumer can silently ignore intended authority.
|
|
136
|
+
|
|
137
|
+
## AI host and extension journey
|
|
138
|
+
|
|
139
|
+
```text
|
|
140
|
+
Task has no exact authority ID
|
|
141
|
+
→ discover bounded lexical candidates
|
|
142
|
+
→ host or project authority chooses an exact ID
|
|
143
|
+
→ query/context/refs/path/subgraph
|
|
144
|
+
→ host plans and edits
|
|
145
|
+
→ fmt changed sources + check the complete root
|
|
146
|
+
→ review immutable base versus exact worktree
|
|
147
|
+
(semantic diff + declared impact + current audit)
|
|
50
148
|
```
|
|
51
149
|
|
|
52
|
-
|
|
150
|
+
The host owns authority selection, planning, editing, retries, remediation, review state, and completion. Nimi Coding owns request validation, deterministic computation, explicit budgets, exact locations, and honest result boundaries.
|
|
151
|
+
|
|
152
|
+
For machine integration, invoke the CLI with an argument array and consume both its exit status and JSON envelope. Read each product's scoped operation, analysis, and blocking status; never infer business or implementation conformance from an empty candidate/finding array. Invalid usage or internal failure and a completed-but-blocked product have distinct command-specific exits.
|
|
153
|
+
|
|
154
|
+
In a configured Git project, use exact Git-aware review for one composed authority change product:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
pnpm exec nimicoding authority review . \
|
|
158
|
+
--base origin/main \
|
|
159
|
+
--bindings .nimi/config/authority-verifiers.yaml \
|
|
160
|
+
--max-units 1024 \
|
|
161
|
+
--max-edges 4096 \
|
|
162
|
+
--max-bytes 2097152 \
|
|
163
|
+
--json
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
This example assumes that the repository already owns valid verifier bindings and that `origin/main` resolves to a commit containing `.nimi/spec`. `start` intentionally creates none of those project semantics or governance files.
|
|
167
|
+
|
|
168
|
+
The base ref is resolved once to a full commit OID. The base `.nimi/spec` tree is read from Git objects; the complete current `.nimi/spec` filesystem tree includes tracked unchanged files, edits, deletions, untracked files, and unsupported entries. Capture races, missing objects, invalid corpora, malformed bindings, and insufficient budgets refuse the result instead of publishing mixed analysis. The command never checks out, stashes, resets, stages, commits, or manages a PR.
|
|
169
|
+
|
|
170
|
+
For a redesign or rename that can leave unchanged active survivors outside the declared graph, run change-derived recall over an explicit channel set:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
pnpm exec nimicoding authority change-candidates path/to/before-spec .nimi/spec \
|
|
174
|
+
--channels direct_relation,definition_identity,definition_title \
|
|
175
|
+
--max-candidates 2048 \
|
|
176
|
+
--max-reasons 20000 \
|
|
177
|
+
--max-bytes 33554432 \
|
|
178
|
+
--json
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The result contains each recalled active non-root unit, its raw normative fields and modality, and exact side-qualified reasons. `complete: true` means the full union and all reasons for the caller-requested channels—not semantic relevance, conflict, retirement, authority validity, or implementation conformance. Owner, scope, and changed-term channels are available when the host explicitly wants their broader recall. Source-container proximity is excluded because regrouping is non-semantic and a complete annotation would grow as the root/candidate Cartesian product.
|
|
182
|
+
|
|
183
|
+
Diff, review, and change-derived recall reuse immutable per-invocation compiler snapshots with transient `byId`, owner, scope, container, incoming, and outgoing indexes. Nothing is persisted: SQLite, cache invalidation, incremental compilation, embeddings, and cleanup state remain outside the product until a measured workload justifies them.
|
|
184
|
+
|
|
185
|
+
## Comparison: old Nimi, current Nimi Coding, and a mature conventional spec stack
|
|
186
|
+
|
|
187
|
+
“Conventional spec” here means a serious combination of Markdown/ADR, OpenAPI, JSON Schema or Protobuf, tests, and repository conventions—not an artificially weak pile of prose.
|
|
188
|
+
|
|
189
|
+
| Dimension | Pre-refactor Nimi spec system | Current Nimi Coding | Mature conventional spec stack |
|
|
190
|
+
| --- | --- | --- | --- |
|
|
191
|
+
| Authority boundary | Human contracts, tables, generated views, maps, and profile rules required precedence conventions | One closed canonical authority root | Several specialized sources of truth, usually without one cross-format boundary |
|
|
192
|
+
| Reference corpus shape | 144 mixed files: 101 Markdown, 43 YAML, including 33 generated views and 42 tables | 33 canonical containers compiling to 2,212 stable units | Project-specific and heterogeneous |
|
|
193
|
+
| Identity | Contract IDs, `R-*` anchors, paths, and table rows were not universal | One stable ID per unit, independent of file, order, move, or regroup | Strong inside some formats, inconsistent across formats |
|
|
194
|
+
| Domain-internal precision | Some tables modeled entities, required fields, API operations, Prisma/OpenAPI/service locators directly | Many enum/schema/state/catalog details remain atomic prose inside a Definition | OpenAPI, Schema, Protobuf, and dedicated DSLs are strongest in their domains |
|
|
195
|
+
| Human rationale | Rich contracts and generated guides | Deliberately compact; long rationale belongs outside canonical authority | ADRs and design documents are strongest |
|
|
196
|
+
| Admission | Multiple profile-specific validators and generators | One complete-root, fail-closed admission oracle | Strong per structured format; Markdown and cross-format admission vary |
|
|
197
|
+
| Unknown input | Behavior depended on the consuming profile/tool | Rejected everywhere under the canonical root | Often preserved or silently ignored unless a schema/linter forbids it |
|
|
198
|
+
| Duplication and drift | Human/table/generated/alignment representations could diverge | One canonical unit representation; derived products are rebuildable | Cross-document and cross-format drift remains common |
|
|
199
|
+
| AI retrieval | Search and project-specific projections had duplicate/noisy inputs | Bounded discovery, exact query, and purpose-specific JSON | Full-text/RAG is flexible but completeness and noise vary |
|
|
200
|
+
| Source traceability | Different profiles exposed locations differently | Uniform portable SourceMap for units, fields, and authored relations | Good within individual tools, inconsistent across tools |
|
|
201
|
+
| Relationship graph | Links, maps, custom fields, and Atlas-like projections | One authored, bounded `applies_to`/`supersedes` graph | `$ref`, links, imports, and conventions remain format-specific |
|
|
202
|
+
| Conflict discovery | Custom checks could find project-specific drift | Structural conflicts are deterministic; prose contradictions still require AI/human analysis | Format-local conflicts can be strong; cross-format conflict remains difficult |
|
|
203
|
+
| Semantic change | File diff and generated drift dominated | Stable-ID semantic diff; rename/regroup/format-only changes can be semantic zero | Prose is line-diffed; specialized formats may have excellent domain diff tools |
|
|
204
|
+
| Impact and audit | Project scripts, maps, and team knowledge | Declared relation impact plus configured graph and exact lexical findings | Build graphs, CODEOWNERS, linters, and tests are strong but fragmented |
|
|
205
|
+
| Git review | No unified exact authority snapshot product | Immutable-base, race-checked worktree review | Usually Git diff plus independent format-specific checks |
|
|
206
|
+
| Spec-to-code relationship | Direct paths were detailed but could become stale | Not currently modeled by the authority core | Codegen, type checking, and contract tests can be substantially stronger |
|
|
207
|
+
| Executable conformance | Some custom scripts checked specific project facts | Explicitly `not_evaluated` by review | High-quality tests and executable contracts are strongest |
|
|
208
|
+
| Ecosystem | Highly project-specific | Stable CLI/JSON products, but no public JS SDK or model/tool standard yet | OpenAPI/Schema/test ecosystems and third-party interoperability are mature |
|
|
209
|
+
| Authoring cost | Multiple representations and generators were expensive | IDs, owners, scopes, lifecycles, and relations require discipline | Lowest during exploration; governance cost rises with corpus size |
|
|
210
|
+
| Best fit | A project-specific integrated spec system | Stable normative authority control alongside a large, AI-consumed estate of specialized specs | Exploration and specialized API/data/behavior contracts |
|
|
211
|
+
|
|
212
|
+
The redesign is not a universal win on every axis. It is a deliberate exchange: current Nimi Coding gains a uniform authority coordinate system, deterministic machine consumption, and exact review semantics, while specialized formats retain domain precision, executable verification, ecosystem maturity, and human explanation.
|
|
213
|
+
|
|
214
|
+
## Comprehensive assessment
|
|
215
|
+
|
|
216
|
+
The current architecture is already a strong substrate for AI coding because it addresses authority identity, retrieval, traceability, change review, and false-clean prevention without depending on a particular model.
|
|
217
|
+
|
|
218
|
+
Three levels of product truth should remain distinct:
|
|
219
|
+
|
|
220
|
+
1. **Strong today:** stable identity, fail-closed admission, exact SourceMap, authored graph navigation, bounded machine products, semantic diff, and exact Git review.
|
|
221
|
+
2. **Improved but incomplete:** locating and tracing the exact inputs for human/AI conflict review, task-context assembly, owner/scope accountability, and spec-to-code traceability. Contradiction judgment itself is not a deterministic product.
|
|
222
|
+
3. **Intentionally not solved:** universal business-semantic completeness, automatic authority selection, executable code conformance, model reasoning, and AI workflow orchestration.
|
|
223
|
+
|
|
224
|
+
The long-term ceiling is high if Nimi Coding standardizes the authority protocol rather than attempting to absorb every domain language. A model-native ecosystem could train AI systems to discover before guessing, resolve exact IDs, distinguish authored facts from inference, honor refusal and scoped status, and request bounded analysis after edits. Deterministic runtime products must remain the oracle; model familiarity must never replace admission or the project's real tests and gates.
|
|
225
|
+
|
|
226
|
+
## Safety and truth boundaries
|
|
227
|
+
|
|
228
|
+
- Only `*.authority.yaml` and `*.authority.md` under `.nimi/spec/**` are canonical product authority.
|
|
229
|
+
- IDs, relations, owners, and scopes are declared facts. Nimi Coding does not infer relations or organizational truth from prose.
|
|
230
|
+
- `discover` is deterministic lexical candidate retrieval, not semantic search, selection, context assembly, or absence proof.
|
|
231
|
+
- `change-candidates` returns the complete union only for explicitly requested deterministic channels. It does not rank, infer conflict, choose retirement, or prove absence outside those channels.
|
|
232
|
+
- `context` is a complete bounded outgoing interpretation closure, not complete task context.
|
|
233
|
+
- `audit` evaluates explicitly bound deterministic governance checks; it does not prove that all business rules are non-contradictory.
|
|
234
|
+
- `impact` reports declared relation impact and host-owned consumer/test follow-up targets. It accepts no disposition or completion state.
|
|
235
|
+
- `review` audits the captured current snapshot and reports `businessSemanticStatus` and `implementationConformanceStatus` as `not_evaluated`; it does not attribute a current finding to the change.
|
|
236
|
+
- Snapshot no-follow hardening is platform-dependent. On `win32`, Node.js does not expose `O_NOFOLLOW`/`O_DIRECTORY`, so snapshot capture uses surrounding `lstat`/`realpath` validation without descriptor-level no-follow guarantees.
|
|
237
|
+
- Raw AuthorityIR, SourceMap internals, and compiler implementation are package-private. There is currently no public JavaScript API (`exports` is empty).
|
|
238
|
+
- `.nimi/local/**` is derived or local output, never product authority.
|
|
239
|
+
|
|
240
|
+
## Future roadmap
|
|
241
|
+
|
|
242
|
+
The roadmap is paused at the current validated baseline. The entries below are candidate lanes, not implementation authorization, release promises, or an implied sequence. A future iteration should select one real adopter journey at a time.
|
|
243
|
+
|
|
244
|
+
| Candidate lane | Intended product | Entry condition |
|
|
245
|
+
| --- | --- | --- |
|
|
246
|
+
| Stateless AI tool adapter | Typed tools over current bounded JSON products, potentially via MCP or an extension API | A real host integration demonstrates that direct CLI invocation is insufficient |
|
|
247
|
+
| Read-only unit/code locator | Exact project-declared unit → declaration/test/gate bindings and reverse lookup | A real implementation-alignment journey demonstrates stable explicit bindings; no execution or conformance status is added |
|
|
248
|
+
| D2 IDE/LSP | Live diagnostics, exact-ID navigation/completion, full-snapshot unsaved-buffer overlays | A sustained editor journey justifies a separate delivery unit |
|
|
249
|
+
| D3 local Studio | Read-only unit/graph/diff/impact/audit exploration | Several real review/exploration journeys are validated first |
|
|
250
|
+
| D4 external semantic candidates | Model/embedding/reranking candidates with provenance and abstention | Lexical/graph shortcomings are measured on an owner-approved task corpus |
|
|
251
|
+
| E1 multi-repository Atlas | Visibility-filtered composition of canonical repository snapshots | Ecosystem repositories, identity, visibility, ownership, and workspace membership are explicit |
|
|
252
|
+
|
|
253
|
+
Conditional work remains separate:
|
|
254
|
+
|
|
255
|
+
- Structured Definitions, replacement DAGs, owner/scope registries, or a public library API require demonstrated authoring/query/consumer loss.
|
|
256
|
+
- Storage, SQLite, cache, or incremental compilation require a real workload to violate a predeclared SLO and profiling to identify repeated parse/index/join as the cause.
|
|
257
|
+
- Version bump, tag, publish, ecosystem activation, and release compatibility are independent release decisions.
|
|
258
|
+
- AI planning, delegation, execution, approval, task state, model/provider orchestration, and inferred model findings do not belong in the core package.
|
|
259
|
+
|
|
260
|
+
## Command reference
|
|
261
|
+
|
|
262
|
+
The current public integration surface is the CLI. All budgets are explicit positive safe integers; a product that cannot fit its required budget refuses rather than truncating a blocking-capable result.
|
|
263
|
+
|
|
264
|
+
| Purpose | Commands |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| Author and admit | `authority fmt`, `authority check`, `authority compile` |
|
|
267
|
+
| Find and read | `authority discover`, `authority query`, `authority context` |
|
|
268
|
+
| Navigate | `authority refs`, `authority path`, `authority subgraph` |
|
|
269
|
+
| Analyze and review | `authority audit`, `authority diff`, `authority change-candidates`, `authority impact`, `authority review` |
|
|
270
|
+
| Validate lexical anchors | `authority anchors` |
|
|
271
|
+
| Project lifecycle | `start`, `sync`, `doctor`, `clear` |
|
|
272
|
+
| Optional L3 repository governance | `validate-ai-governance` |
|
|
273
|
+
|
|
274
|
+
<details>
|
|
275
|
+
<summary>Complete authority command syntax</summary>
|
|
276
|
+
|
|
277
|
+
```text
|
|
278
|
+
nimicoding authority fmt <file> [--check] [--json]
|
|
279
|
+
nimicoding authority check <path> [--scope-bindings <file>] [--json]
|
|
280
|
+
nimicoding authority compile <path> [--json]
|
|
281
|
+
nimicoding authority anchors <repository-path> --spec <corpus-path> [--scope-bindings <file>] [--embedded-paths] --max-units <n> --max-anchors <n> --max-bytes <n> [--json]
|
|
282
|
+
nimicoding authority consumers <repository-path> --spec <corpus-path> [--external-root <scheme>=<path>]... --max-files <n> --max-refs <n> --max-bytes <n> [--json]
|
|
283
|
+
nimicoding authority terms <repository-path> --spec <corpus-path> [--term <t>] [--code] --max-units <n> --max-terms <n> --max-bytes <n> [--json]
|
|
284
|
+
nimicoding authority closed-sets <repository-path> --spec <corpus-path> --max-units <n> --max-sets <n> --max-bytes <n> [--json]
|
|
285
|
+
nimicoding authority discover <path> <query> [--kind <definition|rule>] [--owner <exact-owner>] [--scope <exact-scope>] [--lifecycle <active|removed>] --max-candidates <n> --max-snippet-terms <n> --max-bytes <n> [--preview-direction <incoming|outgoing|both> --relations <comma-separated-relation-types> --max-edges <n>] [--json]
|
|
286
|
+
nimicoding authority query <path> <id> --max-bytes <n> [--json]
|
|
287
|
+
nimicoding authority context <path> <id> --max-units <n> --max-bytes <n> [--json]
|
|
288
|
+
nimicoding authority refs <path> <id> --direction <incoming|outgoing|both> --relations <comma-separated-relation-types> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
|
|
289
|
+
nimicoding authority path <path> <from-id> <to-id> --traversal <directed|incidence> --relations <comma-separated-relation-types> --max-hops <n> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
|
|
290
|
+
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]
|
|
291
|
+
nimicoding authority audit <path> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json|--sarif]
|
|
292
|
+
nimicoding authority diff <before-path> <after-path> --max-bytes <n> [--json]
|
|
293
|
+
nimicoding authority change-candidates <before-path> <after-path> --channels <comma-separated-closed-set> --max-candidates <n> --max-reasons <n> --max-bytes <n> [--json]
|
|
294
|
+
nimicoding authority impact <before-path> <after-path> --max-bytes <n> [--json]
|
|
295
|
+
nimicoding authority review <repository-path> --base <git-ref> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
</details>
|
|
299
|
+
|
|
300
|
+
Relation types are a non-empty unique subset of the closed set `applies_to,supersedes`; discovery relation preview requires direction, relation types, and edge budget together.
|
|
301
|
+
|
|
302
|
+
<details>
|
|
303
|
+
<summary>Project lifecycle, governance, and global syntax</summary>
|
|
304
|
+
|
|
305
|
+
```text
|
|
306
|
+
nimicoding start [--yes]
|
|
307
|
+
nimicoding sync [--apply|--check|--dry-run] [--json]
|
|
308
|
+
nimicoding clear [--yes]
|
|
309
|
+
nimicoding doctor [--verbose|--json]
|
|
310
|
+
nimicoding validate-ai-governance --profile <profile-id> --scope <all|agents-freshness|context-budget|structure-budget|high-risk-doc-metadata> [--json]
|
|
311
|
+
```
|
|
53
312
|
|
|
54
|
-
|
|
313
|
+
Global presentation options are `--lang en|zh`, `--color`, and `--no-color`.
|
|
55
314
|
|
|
56
|
-
|
|
57
|
-
2. Package methodology and contracts remain package authority and project into `.nimi/{methodology,contracts,config}/**`.
|
|
58
|
-
3. Generated views, audit evidence, and operational state are non-authoritative.
|
|
59
|
-
4. Unknown placement or unresolved semantic ambiguity fails closed.
|
|
315
|
+
</details>
|
|
60
316
|
|
|
61
|
-
|
|
317
|
+
Projection ownership is exact: `start`/`sync` own only their documented managed paths and marked instruction blocks. Files outside those exact managed surfaces are not inspected or modified by projection sync. Optional `validate-ai-governance` remains separate from authority admission and host task execution.
|
|
62
318
|
|
|
63
319
|
## Development
|
|
64
320
|
|