Deterministic authority for AI coding systems and third-party extensions.
Nimi Coding turns project-owned normative specifications into stable identities, exact source locations, authored relations, and bounded fail-closed machine products. It also derives one bounded, read-only TypeScript outbound context from explicit repository, source, symbol, and tsconfig inputs. AI hosts can use these products without treating model inference as repository truth.
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.
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.
Nimi Coding makes those questions explicit:
| AI coding problem | Nimi Coding control |
|---|---|
| Several documents appear authoritative | One closed canonical authority boundary |
| Paths and headings change | Stable logical unit IDs independent of files and order |
| Search returns noisy or truncated context | Bounded discovery, exact query, declared context, and graph products |
| A selected TypeScript symbol still requires broad file reading | One explicitly bounded root-direct outbound code-context projection |
| Authority-to-code links are guessed from names or nearby text | Optional exact authored markers with deterministic bidirectional lookup |
| A semantic cut leaves unchanged survivors outside declared relations | Change-derived recall over caller-selected exact owner/scope/term/relation/Definition channels |
| A model cannot cite the exact source | Portable field- and relation-level SourceMap locations |
| Textual diffs obscure semantic change | Stable-ID semantic diff and declared impact obligations |
| “No result” is presented as “clean” | Explicit budgets, scoped statuses, refusal, and failure semantics |
| A Git review may mix moving inputs | Immutable base OID plus race-checked complete worktree capture |
| Structural checks are read as product conformance | Business semantics and implementation conformance remain explicitly not_evaluated |
Project-owned canonical authority
.nimi/spec/**/*.authority.{yaml,md}
│
▼
Authority Foundation
fmt · check · compile CLI over private AuthorityIR/SourceMap
│
▼
Spec Intelligence Plane
discover · query · context · refs/path/subgraph
diff · change-candidates · impact · audit · review
│
▼
Purpose-specific JSON / human output / SARIF (audit only)
│
▼
AI hosts · third-party extensions · CI · future editor/UI surfaces
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.
Install and initialize the package:
pnpm add -D @nimiplatform/nimi-coding
pnpm exec nimicoding start --yesstart creates the compact AI-visible authoring guide (.nimi/methodology/authority-authoring.yaml), a concise managed routing block in AGENTS.md, and the ignored .nimi/local/ root. It does not generate product semantics or create .nimi/spec for the project.
pnpm exec nimicoding is the supported host invocation: run it from the repository root so automation resolves the pinned project-local package. A global nimicoding binary in PATH is neither required nor a valid availability check.
Author a complete canonical source such as .nimi/spec/checkout.authority.yaml:
format: nimicoding.authority/v2
owner: team.checkout
scope: api.checkout
units:
- id: definition.checkout-session
kind: definition
title: Checkout session
meaning: A server-owned session representing an active checkout.
- id: rule.checkout-session
kind: rule
title: Checkout requires a server-owned session
modality: must
statement: Checkout operations use a server-owned checkout session.
condition: Whenever a checkout operation begins.
failure: Reject the operation.
relations:
- type: applies_to
target: definition.checkout-session
nimicoding.authority/v2is the only admitted source format. The container carriesownerand a singlescope, and units may omitlifecycleand emptyrelations. Older source formats fail closed in formatting, admission, compilation, and history-facing analysis; Git history remains the recovery record rather than a compatibility input.
Format changed files, admit the complete root, and query one exact unit:
pnpm exec nimicoding authority fmt .nimi/spec/checkout.authority.yaml
pnpm exec nimicoding authority check .nimi/spec --json
pnpm exec nimicoding authority query .nimi/spec rule.checkout-session --max-bytes 32768 --jsonauthority 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 without resolving repository paths.
Canonical YAML is a closed format plus non-empty units container; Canonical Markdown is a strict single-unit profile. The model stays intentionally compact: Rule and Definition, active and removed, must and must_not, plus authored applies_to and linear supersedes relations. Keep member-level APIs, schemas, enums, state machines, formulas, catalogs, and long rationale in specialized artifacts outside .nimi/spec/** rather than adding ad-hoc fields—unknown canonical fields fail closed so no consumer can silently ignore intended authority.
Active units and removed tombstones may be physically deleted. Keep a tombstone only when the project needs to retain that identity or a supersedes lineage, update or remove any incoming relations, and delete a source file when its last unit is removed. Across compared snapshots, authority diff emits nimicoding.authority-diff/v2 with complete unit_removed records, impact and Git-aware review retain before-side consumer/test targets, and change-candidates (nimicoding.authority-change-candidates/v2) uses deleted units as before-side recall roots. Retained IDs across compared snapshots cannot change kind or reactivate from removed; IDs absent from the before snapshot are treated as additions (Git preserves history without a permanent ID registry).
Static authority anchors (authority anchors lexical specification)
authority anchors performs bounded, read-only lexical validation against one exact Git worktree root:
pnpm exec nimicoding authority anchors . \
--spec .nimi/spec \
--scope-bindings .nimi/config/authority-scope-bindings.yaml \
--max-units 1024 \
--max-anchors 4096 \
--max-bytes 2097152 \
--jsonThe anchor grammar is closed and case-sensitive. A token is one maximal non-whitespace sequence; punctuation attached without whitespace remains part of that token.
- 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 asC:\orC:/, 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-rootgit ls-filestracked-file inventory. There is no path normalization, prefix removal, or inferred match. - 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 builtinsadd,audit,create,dlx,exec,install,link,list,outdated,patch,publish,remove,run,update, andwhyare excluded before exact own-key resolution against the rootpackage.jsonscriptsobject. Nothing is executed.
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.
All capabilities and their exact truth boundaries are summarized in one place below:
| Layer | Current capability | Truth boundary |
|---|---|---|
| Authority Foundation | Canonical YAML/Markdown (*.authority.yaml, *.authority.md under .nimi/spec/** only), formatter, complete-root check, private deterministic compiler and SourceMap |
Unknown or unsupported canonical input is rejected; IDs, relations, owners, and scopes are declared facts only (never inferred from prose); .nimi/local/** is derived output, never product authority |
| Discovery and exact reads | Exact kind/owner/scope/lifecycle filters, normalized lexical snippets, optional direct relation preview, exact query, bounded declared context |
discover is lexical candidate retrieval (not semantic search, automatic selection, context assembly, or absence proof); context is the outgoing interpretation closure only, not complete task context |
| Graph navigation | Incoming/outgoing refs, deterministic path, bounded subgraph over applies_to and supersedes |
Authored relations only; no inferred semantic graph |
| Change intelligence | Stable-ID semantic diff, explicit-channel change-candidates active-survivor recall, and relation-derived impact obligations |
change-candidates completeness covers only caller-requested exact channels (no ranking, conflict/retirement inference, or absence proof outside them); impact reports host-owned follow-up targets and accepts no disposition or completion state |
| Static anchors and corpus reports | Bounded anchors, consumers, terms, and closed-sets reports over Git-tracked files and canonical authority |
Closed lexical/structural extraction only; nothing is executed; module/command scope bindings remain structure-only |
| Deterministic audit | Project-owned bindings for graph verifiers and exact lexical invariants, with JSON and SARIF 2.1.0 | Exact case-sensitive token/phrase checks only; does not prove all business rules are non-contradictory; no synonym, embedding, or natural-language contradiction inference |
| Git-aware review | Immutable base commit OID plus race-checked complete current worktree snapshot composed through compile/diff/impact/audit | Read-only; audits the captured current snapshot without attributing findings to the change; businessSemanticStatus and implementationConformanceStatus remain explicitly not_evaluated |
| TypeScript code context | Root declaration source plus root-direct static bindings, portable declaration loci, and eligible target source slices | Explicit .ts/.tsx root and tsconfig; stable project-local TypeScript 5.9.3 through 6.x (actual compiler version reported); outbound only; no locating, inbound impact, runtime dispatch, or task-completeness claim |
| Explicit code-authority links | Transient Authority→Code, Code→Authority, and lifecycle audit over optional exact markers in tracked current .ts, .tsx, .go, .py, and .rs source |
Exact standalone physical lines only (comment context is not parsed); marker location and authority lifecycle only; no declaration ownership, annotation coverage, implementation conformance, or unannotated legacy detection |
| Package and platform boundaries | Package-private AuthorityIR, SourceMap internals, and compiler; managed start/sync/doctor/clear projections |
No public JavaScript API (exports is empty); on win32, Node.js lacks O_NOFOLLOW/O_DIRECTORY, so snapshot capture uses surrounding lstat/realpath validation without descriptor-level no-follow guarantees; sync/doctor check owned projections and compatibility only |
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.
start writes a concise managed routing block into AGENTS.md and projects the full guide to .nimi/methodology/authority-authoring.yaml. On an existing installation, doctor diagnoses drift in those managed surfaces, and sync --apply restores the exact current package projections while preserving host-owned text outside the managed block.
This is instruction-based integration, not an automatic execution layer. Nimi Coding installs no hook or daemon, intercepts no task, requires no fixed preflight, and owns no task or completion state. Routine implementation against settled contracts needs no authority call; invoke code authority or code context only when an unresolved explicit-link or TS/TSX static-dependency question affects the current task, and reuse sufficient current evidence. When an invocation is refused, missing, or incomplete, pause only decisions that depend on it while continuing independent authorized work, and keep hypotheses distinct from project authority.
Task has no exact authority ID
→ discover bounded lexical candidates
→ host or project authority chooses an exact ID
→ query/context/refs/path/subgraph
→ host plans and edits
→ fmt changed sources + check the complete root
→ review immutable base versus exact worktree
(semantic diff + declared impact + current audit)
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.
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.
In a configured Git project, use exact Git-aware review for one composed authority change product:
pnpm exec nimicoding authority review . \
--base origin/main \
--bindings .nimi/config/authority-verifiers.yaml \
--max-units 1024 \
--max-edges 4096 \
--max-bytes 2097152 \
--jsonThis 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 policy files.
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.
For a redesign or rename that can leave unchanged active survivors outside the declared graph, run change-derived recall over an explicit channel set:
pnpm exec nimicoding authority change-candidates path/to/before-spec .nimi/spec \
--channels direct_relation,definition_identity,definition_title \
--max-candidates 2048 \
--max-reasons 20000 \
--max-bytes 33554432 \
--jsonThe result contains each recalled active non-root unit, its raw normative fields and modality, and exact side-qualified reasons. Owner, scope, and changed-term channels are available when the host explicitly wants broader recall. Source-container proximity is excluded because regrouping is non-semantic and a complete annotation would grow as the root/candidate Cartesian product.
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.
“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.
| Dimension | Pre-refactor Nimi spec system | Current Nimi Coding | Mature conventional spec stack |
|---|---|---|---|
| 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 |
| 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 |
| 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 |
| 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 |
| Human rationale | Rich contracts and generated guides | Deliberately compact; long rationale belongs outside canonical authority | ADRs and design documents are strongest |
| Admission | Multiple profile-specific validators and generators | One complete-root, fail-closed admission oracle | Strong per structured format; Markdown and cross-format admission vary |
| 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 |
| 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 |
| 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 |
| Source traceability | Different profiles exposed locations differently | Uniform portable SourceMap for units, fields, and authored relations | Good within individual tools, inconsistent across tools |
| 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 |
| 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 |
| 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 |
| 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 |
| Git review | No unified exact authority snapshot product | Immutable-base, race-checked worktree review | Usually Git diff plus independent format-specific checks |
| Spec-to-code relationship | Direct paths were detailed but could become stale | Authority core stores no mapping; optional exact code markers provide authored locating only, with unannotated code and conformance not evaluated | Codegen, type checking, and contract tests can be substantially stronger |
| Executable conformance | Some custom scripts checked specific project facts | Explicitly not_evaluated by review |
High-quality tests and executable contracts are strongest |
| 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 |
| 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 |
| 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 |
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.
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.
Three levels of product truth should remain distinct:
- Strong today: stable identity, fail-closed admission, exact SourceMap, authored graph navigation, bounded machine products, semantic diff, and exact Git review.
- Improved but incomplete: optional authored marker lookup and bounded TypeScript outbound context reduce implementation navigation, while complete task context, unannotated code, and conformance remain unevaluated. Contradiction judgment itself is not a deterministic product.
- Intentionally not solved: universal business-semantic completeness, automatic authority selection, executable code conformance, model reasoning, and AI workflow orchestration.
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.
Version 0.7 intentionally stops at the current request-local products. No next phase is implied. A later iteration should begin with one real adopter failure and add only the smallest missing mechanism:
- Add a typed host adapter only if direct CLI invocation proves insufficient in actual use.
- Add unsaved-buffer support only if a sustained editor journey requires it.
- Add storage, semantic retrieval, or multi-repository composition only after measured use demonstrates a concrete loss that the current transient exact products cannot address.
- AI planning, delegation, execution, approval, task state, model/provider orchestration, implementation conformance, and completion tracking remain outside the core package.
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.
| Purpose | Commands |
|---|---|
| Author and admit | authority fmt, authority check, authority compile |
| Find and read | authority discover, authority query, authority context |
| Navigate | authority refs, authority path, authority subgraph |
| Analyze and review | authority audit, authority diff, authority change-candidates, authority impact, authority review |
| Validate lexical anchors and corpus reports | authority anchors, authority consumers, authority terms, authority closed-sets |
| Read implementation context and explicit links | code context, code authority |
| Project lifecycle | start, sync, doctor, clear |
Complete authority command syntax
nimicoding authority fmt <file> [--check] [--json]
nimicoding authority check <path> [--scope-bindings <file>] [--json]
nimicoding authority compile <path> [--json]
nimicoding authority anchors <repository-path> --spec <corpus-path> [--scope-bindings <file>] [--embedded-paths] --max-units <n> --max-anchors <n> --max-bytes <n> [--json]
nimicoding authority consumers <repository-path> --spec <corpus-path> [--external-root <scheme>=<path>]... --max-files <n> --max-refs <n> --max-bytes <n> [--json]
nimicoding authority terms <repository-path> --spec <corpus-path> [--term <t>] [--code] --max-units <n> --max-terms <n> --max-bytes <n> [--json]
nimicoding authority closed-sets <repository-path> --spec <corpus-path> --max-units <n> --max-sets <n> --max-bytes <n> [--json]
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]
nimicoding authority query <path> <id> --max-bytes <n> [--json]
nimicoding authority context <path> <id> --max-units <n> --max-bytes <n> [--json]
nimicoding authority refs <path> <id> --direction <incoming|outgoing|both> --relations <comma-separated-relation-types> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
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]
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]
nimicoding authority audit <path> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json|--sarif]
nimicoding authority diff <before-path> <after-path> --max-bytes <n> [--json]
nimicoding authority change-candidates <before-path> <after-path> --channels <comma-separated-closed-set> --max-candidates <n> --max-reasons <n> --max-bytes <n> [--json]
nimicoding authority impact <before-path> <after-path> --max-bytes <n> [--json]
nimicoding authority review <repository-path> --base <git-ref> --bindings <file> --max-units <n> --max-edges <n> --max-bytes <n> [--json]
Explicit code-authority marker syntax
// @nimi-authority: <exact-authority-id>
// @nimi-deprecated: <exact-authority-id>
# @nimi-authority: <exact-authority-id>
# @nimi-deprecated: <exact-authority-id>
nimicoding code authority --repo <exact-git-worktree-root> (--authority <exact-id>|--source <repo-relative-.ts-.tsx-.go-.py-or-.rs-path>|--audit) --max-files <integer> --max-bytes <integer>=512
Markers are optional reserved standalone physical lines. TypeScript/TSX, Go, and Rust use //; Python uses #. The scanner recognizes the exact standalone @nimi-* form without parsing the host language's comment context, so an exact matching line inside a multiline literal is also treated as a marker. Keep this reserved form out of examples and source data unless the link is intentional. The command compiles the repository's complete canonical .nimi/spec, scans the selected Git-tracked current-filesystem source scope once, and returns one complete compact JSON result or refuses. @nimi-deprecated records an explicit developer judgment surfaced by --audit; unannotated code remains valid and not_evaluated. No index, cache, scope binding, report, or task state is written.
TypeScript code context syntax
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
The command reads the current filesystem and writes one compact JSON response to stdout. completed covers only its closed root-direct static-binding policy; partial reports the first output-budget frontier; refused contains no usable context product. The command neither edits the repository nor selects, runs, or records verification.
completed can include explicitly unresolved sites. In particular, an alias chain through a local export without a module specifier is reported as unresolved with reason alias_resolution_not_unique; it is not a proven dependency.
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.
Project lifecycle and global syntax
nimicoding start [--yes]
nimicoding sync [--apply|--check|--dry-run] [--json]
nimicoding clear [--yes]
nimicoding doctor [--verbose|--json]
Global presentation options are --lang en|zh, --color, and --no-color.
Projection ownership is exact: start/sync own only their documented managed paths and marked instruction block. Files outside those exact managed surfaces are not inspected or modified by projection sync. Code queries are request-local and do not participate in authority admission or host task execution.
pnpm install
pnpm test
pnpm check:pack
pnpm check:ciRequires Node.js 24+ and pnpm 10+.