@nimiplatform/nimi-coding 0.6.0 → 0.6.2

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 CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.6.2
6
+
7
+ - Made managed authority/code queries depend on task-relevant uncertainty, including static-dependency questions for `code context`, while preserving authority admission and result boundaries.
8
+ - Scoped failed or incomplete query handling to dependent decisions, allowing independent authorized work to continue without treating diagnostics, hypotheses, or partial output as complete authority context.
9
+ - Fixed a `code context` crash on local export aliases without a module specifier; affected sites retain the existing explicit `unresolved` result instead of inventing a dependency.
10
+
11
+ ## 0.6.1
12
+
13
+ - Extended experimental `nimicoding code authority` marker lookup and lifecycle audit to tracked current Python and Rust source while keeping `code context` TypeScript/TSX-only.
14
+ - Shipped a breaking fix to the experimental marker spelling: the reserved standalone `@nimi-authority` / `@nimi-deprecated` physical-line protocol replaces the 0.6.0 spelling without compatibility, and exact matching physical lines are intentional markers regardless of lexical context. Language comment parsing was removed.
15
+
5
16
  ## 0.6.0
6
17
 
7
18
  - Made all AI-visible operational guidance resolve the pinned project-local CLI through repository-root `pnpm exec nimicoding`, removing the false global-`PATH` availability assumption.
package/CONTRIBUTING.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Nimi Coding accepts changes to canonical-authority products, formatter/compiler primitives, exact managed projections, and bounded read-only code queries over explicit inputs or markers. Historical-format reconstruction, product-semantic generation, AI-host control, provider execution, task-state management, and review-state management are outside this package. Code queries remain request-local and do not establish implementation conformance.
4
4
 
5
+ `code authority` uses reserved standalone `// @nimi-*` physical lines in TypeScript/TSX, Go, and Rust, and `# @nimi-*` lines in Python; it does not prove language comment context, so an exact line in a multiline literal is also a marker. `code context` remains TypeScript/TSX-only.
6
+
5
7
  Before opening a change:
6
8
 
7
9
  ```bash
package/README.md CHANGED
@@ -63,16 +63,18 @@ Projects own all product meaning. Nimi Coding admits, locates, relates, and deri
63
63
  | 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 |
64
64
  | 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` |
65
65
  | 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, TypeScript 5.9.3, outbound only; no locating, inbound impact, runtime dispatch, or task-completeness claim |
66
- | Explicit code-authority links | Transient Authority→Code, Code→Authority, and lifecycle audit over optional exact markers in tracked current `.ts`, `.tsx`, and `.go` source | Marker location only; no declaration ownership, annotation coverage, implementation conformance, or unannotated legacy detection |
66
+ | 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 | Marker location only; no declaration ownership, annotation coverage, implementation conformance, or unannotated legacy detection |
67
67
 
68
68
  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.
69
69
 
70
- ## Using the 0.6 code surface
70
+ ## Using the code surface
71
71
 
72
- `start` writes package-managed guidance into the marked blocks in `AGENTS.md` and `CLAUDE.md`. On an existing installation, `doctor` diagnoses drift in that guidance and the compact methodology projection; `sync --apply` restores the exact current package projections while preserving host-owned text outside the managed blocks. An AI host that honors repository instructions can therefore learn when to request `code authority` or `code context`, and when a changed authority-governed feature warrants a small number of `nimi-authority` markers at key semantic owners.
72
+ `start` writes package-managed guidance into the marked blocks in `AGENTS.md` and `CLAUDE.md`. On an existing installation, `doctor` diagnoses drift in that guidance and the compact methodology projection; `sync --apply` restores the exact current package projections while preserving host-owned text outside the managed blocks. An AI host that honors repository instructions can therefore learn when to request `code authority` or `code context`, and when a changed authority-governed feature warrants a small number of `@nimi-authority` markers at key semantic owners.
73
73
 
74
74
  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. The host decides whether a query is useful for the current coding task. `code authority` only recalls explicit markers and current authority lifecycle; `code context` only returns the admitted root-direct TypeScript projection. Neither result proves conformance, replaces affected builds and tests, or evaluates unannotated code.
75
75
 
76
+ Use queries to resolve uncertainties that affect the task, and reuse sufficient current evidence. Selecting a TS/TSX consumer alone does not require `code context`; an unresolved static-dependency question does. A failed invocation supplies no usable result. Pause decisions that require refused, missing, or incomplete results while continuing independent authorized work. Diagnostics guide repair, and partial output never establishes complete context. Query boundaries do not limit host reasoning, but hypotheses must remain distinct from project authority.
77
+
76
78
  ## Five-minute adoption path
77
79
 
78
80
  Install and initialize the package:
@@ -302,13 +304,15 @@ nimicoding authority review <repository-path> --base <git-ref> --bindings <file>
302
304
  <summary>Explicit code-authority marker syntax</summary>
303
305
 
304
306
  ```text
305
- // nimi-authority: <exact-authority-id>
306
- // nimi-deprecated: <exact-authority-id>
307
+ // @nimi-authority: <exact-authority-id>
308
+ // @nimi-deprecated: <exact-authority-id>
309
+ # @nimi-authority: <exact-authority-id>
310
+ # @nimi-deprecated: <exact-authority-id>
307
311
 
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
312
+ 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
309
313
  ```
310
314
 
311
- Markers are optional exact authored links. 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 and is reported by the audit; the tool does not infer that judgment or prove marker pairing, declaration ownership, conformance, or hard-cut completion. Unannotated code remains valid and `not_evaluated`. No index, cache, scope binding, report, or task state is written.
315
+ Markers are optional reserved physical lines. TypeScript/TSX, Go, and Rust use `//`; Python uses `#`. The scanner recognizes the exact standalone `@nimi-*` form without parsing or proving the host language's comment context; an exact matching line inside a multiline literal is therefore also 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 and is reported by the audit; the tool does not infer that judgment or prove marker pairing, declaration ownership, conformance, or hard-cut completion. Unannotated code remains valid and `not_evaluated`. No index, cache, scope binding, report, or task state is written.
312
316
 
313
317
  </details>
314
318
 
@@ -321,6 +325,8 @@ nimicoding code context <repo-relative-.ts-or-.tsx-path> --repo <exact-git-workt
321
325
 
322
326
  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.
323
327
 
328
+ `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.
329
+
324
330
  </details>
325
331
 
326
332
  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.
package/README.zh-CN.md CHANGED
@@ -63,16 +63,18 @@ AI host · 第三方扩展 · CI · future editor/UI surfaces
63
63
  | Deterministic audit | Project-owned graph verifier 与 exact lexical invariant bindings,输出 JSON 和 SARIF 2.1.0 | 只做大小写敏感的 exact token/phrase 检查;不做 synonym、embedding 或自然语言矛盾推断 |
64
64
  | Git-aware review | Immutable base commit 加 exact、race-checked current worktree snapshot,并复用 compile/diff/impact/audit | 只读;business semantics 与 implementation conformance 固定为 `not_evaluated` |
65
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 |
66
+ | 显式 code-authority 链接 | 对 Git tracked 当前 `.ts`、`.tsx`、`.go`、`.py`、`.rs` 源码中的可选 exact marker 提供 transient Authority→Code、Code→Authority 和 lifecycle audit | 只声明 marker location;不声明 declaration ownership、annotation coverage、implementation conformance 或未标注 legacy detection |
67
67
 
68
68
  当前 Nimi-realm 验证 corpus 包含 33 个 canonical containers、2,212 个 authority units 和 2,159 条 authored relations。这些数字证明了真实大型 corpus replay,不是 package 上限,也不代表 grammar 已覆盖所有领域。
69
69
 
70
- ## 使用 0.6 code surface
70
+ ## 使用 code surface
71
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。
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
73
 
74
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,也不评价未标注代码。
75
75
 
76
+ 查询用于解决会影响当前任务的不确定性,已有依据充分时直接复用。选定 TS/TSX consumer 本身不要求调用 `code context`;仍有静态依赖疑问时才使用。失败的调用不提供可用结果;暂停依赖被拒绝、缺失或不完整结果的判断,同时继续独立且已授权的工作。诊断用于修复,局部输出不能证明上下文完整。查询边界不限制 host 的推理,但假设必须与项目 authority 区分。
77
+
76
78
  ## 五分钟接入
77
79
 
78
80
  安装并初始化:
@@ -302,13 +304,15 @@ nimicoding authority review <repository-path> --base <git-ref> --bindings <file>
302
304
  <summary>显式 code-authority marker syntax</summary>
303
305
 
304
306
  ```text
305
- // nimi-authority: <exact-authority-id>
306
- // nimi-deprecated: <exact-authority-id>
307
+ // @nimi-authority: <exact-authority-id>
308
+ // @nimi-deprecated: <exact-authority-id>
309
+ # @nimi-authority: <exact-authority-id>
310
+ # @nimi-deprecated: <exact-authority-id>
307
311
 
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
312
+ 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
309
313
  ```
310
314
 
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。
315
+ Marker 是可选的保留物理行。TypeScript/TSX、Go、Rust 使用 `//`,Python 使用 `#`。扫描器只识别独占一行的 exact `@nimi-*` 格式,不解析或证明它在宿主语言中确实属于注释;因此,多行字符串中完全匹配的物理行也会被当作 marker。除非确实要建立链接,不要在示例或源码数据中使用该保留格式。命令编译 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
316
 
313
317
  </details>
314
318
 
@@ -321,6 +325,8 @@ nimicoding code context <repo-relative-.ts-or-.tsx-path> --repo <exact-git-workt
321
325
 
322
326
  该命令读取当前文件系统,并向 stdout 写入一个 compact JSON response。`completed` 只覆盖封闭的 root-direct static-binding policy;`partial` 返回首个 output-budget frontier;`refused` 不包含可用 context product。命令不会编辑 repository,也不会选择、运行或保存 verification。
323
327
 
328
+ `completed` 可以包含明确未解析的 site。特别是经过无 module specifier 的本地 export 的 alias chain,会返回 `unresolved` 和既有原因 `alias_resolution_not_unique`;该 site 不是已证明的依赖。
329
+
324
330
  </details>
325
331
 
326
332
  Relation types 是 closed set `applies_to,supersedes` 的非空、无重复 subset;discovery relation preview 必须同时提供 direction、relation types 和 edge budget。
@@ -16,7 +16,7 @@ import {
16
16
  } from "../lib/code/response.mjs";
17
17
 
18
18
  export const CODE_CONTEXT_USAGE = "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";
19
- export const CODE_AUTHORITY_USAGE = "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";
19
+ export const CODE_AUTHORITY_USAGE = "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";
20
20
  export const CODE_COMMAND_USAGE = [CODE_CONTEXT_USAGE, CODE_AUTHORITY_USAGE];
21
21
 
22
22
  const GLOBAL_FLAG_OPTIONS = new Set(["--color", "--no-color"]);
package/cli/constants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export const VERSION = "0.6.0";
1
+ export const VERSION = "0.6.2";
2
2
  export const PACKAGE_NAME = "@nimiplatform/nimi-coding";
3
3
  export const PROJECT_LOCAL_CLI_INVOCATION = "pnpm exec nimicoding";
4
4
  export const LOCAL_GITIGNORE_ENTRIES = [".nimi/local/"];
@@ -1,12 +1,15 @@
1
1
  import { Buffer } from "node:buffer";
2
2
 
3
- import ts from "typescript";
4
-
5
3
  import { compareText, createLocator } from "../authority/diagnostics.mjs";
6
4
 
7
- const EXACT_MARKER = /^\/\/ nimi-(authority|deprecated): ([^\s]+)$/u;
8
- const MARKER_CANDIDATE = /^\/\/[ \t]*nimi-(?:authority|deprecated)\b/u;
9
- const PHYSICAL_CANDIDATE = /^[ \t]*\/\/[ \t]*nimi-(?:authority|deprecated)\b/mu;
5
+ const SLASH_MARKER = {
6
+ exact: /^\/\/ @nimi-(authority|deprecated): ([^\s]+)$/u,
7
+ candidate: /^\/\/[ \t]*@nimi-(?:authority|deprecated)\b/u,
8
+ };
9
+ const HASH_MARKER = {
10
+ exact: /^# @nimi-(authority|deprecated): ([^\s]+)$/u,
11
+ candidate: /^#[ \t]*@nimi-(?:authority|deprecated)\b/u,
12
+ };
10
13
  const NEARBY_SOURCE_BYTES = 512;
11
14
 
12
15
  function comparePosition(left, right) {
@@ -37,13 +40,10 @@ function nearbySource(path, text, locator, markerEnd) {
37
40
  };
38
41
  }
39
42
 
40
- function parseComment(path, text, locator, start, end, identifier) {
41
- const lineStart = text.lastIndexOf("\n", start - 1) + 1;
42
- if (text.slice(lineStart, start).trim().length > 0) return { occurrence: null, finding: null };
43
- const raw = text.slice(start, end).replace(/\r$/u, "");
44
- if (!MARKER_CANDIDATE.test(raw)) return { occurrence: null, finding: null };
43
+ function parseMarkerLine(path, text, locator, start, end, identifier, grammar) {
44
+ const raw = text.slice(start, end);
45
45
  const location = { path, range: locator.range(start, end) };
46
- const match = EXACT_MARKER.exec(raw);
46
+ const match = grammar.exact.exec(raw);
47
47
  if (match === null || !identifier.test(match[2])) {
48
48
  return {
49
49
  occurrence: null,
@@ -67,78 +67,31 @@ function parseComment(path, text, locator, start, end, identifier) {
67
67
  };
68
68
  }
69
69
 
70
- function typeScriptLineComments(path, text) {
71
- const scriptKind = path.endsWith(".tsx") ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
72
- const sourceFile = ts.createSourceFile(path, text, ts.ScriptTarget.Latest, true, scriptKind);
73
- const comments = new Map();
74
- const jsxTextRanges = [];
75
- function add(ranges) {
76
- for (const range of ranges ?? []) {
77
- if (range.kind === ts.SyntaxKind.SingleLineCommentTrivia) {
78
- comments.set(`${range.pos}:${range.end}`, { start: range.pos, end: range.end });
79
- }
80
- }
81
- }
82
- const pending = [sourceFile];
83
- while (pending.length > 0) {
84
- const node = pending.pop();
85
- if (ts.isJsxText(node)) jsxTextRanges.push({ start: node.pos, end: node.end });
86
- add(ts.getLeadingCommentRanges(text, node.pos));
87
- add(ts.getTrailingCommentRanges(text, node.end));
88
- pending.push(...node.getChildren(sourceFile));
89
- }
90
- return [...comments.values()]
91
- .filter((comment) => !jsxTextRanges.some((range) => comment.start >= range.start && comment.end <= range.end))
92
- .sort((left, right) => left.start - right.start || left.end - right.end);
93
- }
94
-
95
- function goLineComments(text) {
96
- const comments = [];
97
- let index = 0;
98
- while (index < text.length) {
99
- const character = text[index];
100
- if (character === "/" && text[index + 1] === "/") {
101
- const start = index;
102
- index += 2;
103
- while (index < text.length && text[index] !== "\n") index += 1;
104
- comments.push({ start, end: index });
105
- continue;
106
- }
107
- if (character === "/" && text[index + 1] === "*") {
108
- const close = text.indexOf("*/", index + 2);
109
- index = close < 0 ? text.length : close + 2;
110
- continue;
111
- }
112
- if (character === "`" || character === "\"" || character === "'") {
113
- const quote = character;
114
- index += 1;
115
- while (index < text.length) {
116
- if (quote !== "`" && text[index] === "\\") {
117
- index += Math.min(2, text.length - index);
118
- continue;
119
- }
120
- if (text[index] === quote) {
121
- index += 1;
122
- break;
123
- }
124
- index += 1;
125
- }
126
- continue;
127
- }
128
- index += 1;
70
+ function physicalMarkerLines(text, grammar) {
71
+ const markers = [];
72
+ let lineStart = 0;
73
+ while (lineStart < text.length) {
74
+ const newline = text.indexOf("\n", lineStart);
75
+ const lineEnd = newline < 0 ? text.length : newline;
76
+ const contentEnd = lineEnd > lineStart && text[lineEnd - 1] === "\r" ? lineEnd - 1 : lineEnd;
77
+ let start = lineStart;
78
+ while (start < contentEnd && (text[start] === " " || text[start] === "\t")) start += 1;
79
+ if (grammar.candidate.test(text.slice(start, contentEnd))) markers.push({ start, end: contentEnd });
80
+ lineStart = newline < 0 ? text.length : newline + 1;
129
81
  }
130
- return comments;
82
+ return markers;
131
83
  }
132
84
 
133
85
  export function scanAuthorityAnnotations(path, text, identifierPattern) {
134
- if (!PHYSICAL_CANDIDATE.test(text)) return { occurrences: [], findings: [] };
86
+ const grammar = path.endsWith(".py") ? HASH_MARKER : SLASH_MARKER;
87
+ if (!text.includes("@nimi-")) return { occurrences: [], findings: [] };
135
88
  const locator = createLocator(text);
136
89
  const identifier = new RegExp(identifierPattern, "u");
137
- const comments = path.endsWith(".go") ? goLineComments(text) : typeScriptLineComments(path, text);
90
+ const markerLines = physicalMarkerLines(text, grammar);
138
91
  const occurrences = [];
139
92
  const findings = [];
140
- for (const comment of comments) {
141
- const parsed = parseComment(path, text, locator, comment.start, comment.end, identifier);
93
+ for (const markerLine of markerLines) {
94
+ const parsed = parseMarkerLine(path, text, locator, markerLine.start, markerLine.end, identifier, grammar);
142
95
  if (parsed.occurrence !== null) occurrences.push(parsed.occurrence);
143
96
  if (parsed.finding !== null) findings.push(parsed.finding);
144
97
  }
@@ -14,7 +14,7 @@ import {
14
14
  scanAuthorityAnnotations,
15
15
  } from "./authority-annotation-scan.mjs";
16
16
 
17
- const SUPPORTED_SOURCE = /(?:\.d)?\.tsx?$|\.go$/u;
17
+ const SUPPORTED_SOURCE = /(?:\.d)?\.tsx?$|\.go$|\.py$|\.rs$/u;
18
18
  const UTF8 = new TextDecoder("utf-8", { fatal: true });
19
19
  const CLASSIFICATION_ORDER = new Map([
20
20
  ["active-reference", 0],
@@ -214,7 +214,7 @@ export async function queryCodeAuthority({ repository: repositoryPath, selector,
214
214
  if (selector.kind === "source") {
215
215
  const normalized = normalizeSourceSelector(selector.path);
216
216
  if (normalized === null || !SUPPORTED_SOURCE.test(normalized) || !tracked.has(normalized) || gitlinks.has(normalized)) {
217
- fail("CODE_AUTHORITY_SOURCE_INVALID", "source selector must name one tracked .ts, .tsx, or .go file");
217
+ fail("CODE_AUTHORITY_SOURCE_INVALID", "source selector must name one tracked .ts, .tsx, .go, .py, or .rs file");
218
218
  }
219
219
  sourcePaths = [normalized];
220
220
  } else {
@@ -279,7 +279,7 @@ export async function queryCodeAuthority({ repository: repositoryPath, selector,
279
279
  }
280
280
  return {
281
281
  operation: "lifecycle-audit",
282
- scope: { repository: ".", source_languages: ["go", "typescript", "tsx"] },
282
+ scope: { repository: ".", source_languages: ["go", "python", "rust", "typescript", "tsx"] },
283
283
  result: {
284
284
  conclusion: findings.length === 0
285
285
  ? "annotated implementation surface has no deterministic authority lifecycle residue"
@@ -479,7 +479,9 @@ function moduleSpecifierForAlias(compiler, declaration) {
479
479
  let current = declaration;
480
480
  while (current !== undefined) {
481
481
  if (compiler.isImportDeclaration(current) || compiler.isExportDeclaration(current)) {
482
- return compiler.isStringLiteral(current.moduleSpecifier) ? current.moduleSpecifier.text : null;
482
+ return current.moduleSpecifier !== undefined && compiler.isStringLiteral(current.moduleSpecifier)
483
+ ? current.moduleSpecifier.text
484
+ : null;
483
485
  }
484
486
  if (compiler.isImportEqualsDeclaration(current)) {
485
487
  const reference = current.moduleReference;
@@ -21,18 +21,19 @@ function authorityAuthoringLines() {
21
21
  return [
22
22
  `- From the repository root, invoke the pinned project-local CLI as \`${PROJECT_LOCAL_CLI_INVOCATION}\`; do not probe or rely on a global \`nimicoding\` binary in \`PATH\`.`,
23
23
  "- Product authority lives under `.nimi/spec/**`.",
24
+ "- Choose authority and code queries when their declared scope can resolve an uncertainty that affects the current task; reuse sufficient current evidence. Query scope is not the limit of host reasoning or authorized work, and hypotheses are not product authority.",
24
25
  "- For canonical authority authoring, read only `.nimi/methodology/authority-authoring.yaml`, the affected authority files or bounded task context, and CLI diagnostics.",
25
26
  `- Use \`${PROJECT_LOCAL_CLI_INVOCATION} authority context <path> <id> --max-units <n> --max-bytes <n> --json\` only for the complete declared outgoing interpretation closure; it is not complete task context, and failure never permits guessed or partial context.`,
26
27
  `- Use \`${PROJECT_LOCAL_CLI_INVOCATION} authority diff\` and \`${PROJECT_LOCAL_CLI_INVOCATION} authority impact\` with explicit \`--max-bytes\`; impact reports declared review obligations and does not prove implementation, consumers, or tests are synchronized.`,
27
28
  `- Use \`${PROJECT_LOCAL_CLI_INVOCATION} authority change-candidates\` only with explicit channels and budgets; its complete union is recall input, never conflict, retirement, absence, authority, or conformance judgment.`,
28
- `- For implementation audits with an exact authority ID, use \`${PROJECT_LOCAL_CLI_INVOCATION} code authority --repo <root> --authority <id> --max-files <n> --max-bytes <n>\` to locate annotated code, and use \`--source <path>\` for code-to-authority lookup. Results cover only explicit markers and authority lifecycle; they do not prove implementation conformance or evaluate unannotated code.`,
29
- `- For a new or changed authority-governed feature, add \`// nimi-authority: <exact-id>\` only at the small number of key semantic owner files or declarations. Multiple markers are allowed; do not blanket-annotate mechanical helpers or tests.`,
30
- `- Use \`// nimi-deprecated: <exact-id>\` only after direct authority evidence or a real product failure confirms obsolete semantics; find it with \`${PROJECT_LOCAL_CLI_INVOCATION} code authority --repo <root> --audit --max-files <n> --max-bytes <n>\` and remove the marker with the hard cut.`,
31
- `- After selecting an explicit TypeScript or TSX consumer, use \`${PROJECT_LOCAL_CLI_INVOCATION} code context <path> --repo <root> --symbol <identifier> --tsconfig <path> --max-bytes <n>\` for bounded root-direct static dependencies; it is not inbound impact, runtime dispatch, or complete task context.`,
29
+ `- When explicit authority links are needed, use \`${PROJECT_LOCAL_CLI_INVOCATION} code authority --repo <root> --authority <id> --max-files <n> --max-bytes <n>\` to locate annotated code, and use \`--source <path>\` for code-to-authority lookup. Results cover only explicit markers and authority lifecycle; they do not prove implementation conformance or evaluate unannotated code.`,
30
+ `- For a new or changed authority-governed feature, add the reserved standalone physical line \`// @nimi-authority: <exact-id>\` in TypeScript/TSX, Go, or Rust, and \`# @nimi-authority: <exact-id>\` in Python. The scanner does not prove language comment context, so use this reserved form only for intentional links at a few key semantic owners.`,
31
+ `- Use \`// @nimi-deprecated: <exact-id>\`, or \`# @nimi-deprecated: <exact-id>\` in Python, only after direct authority evidence or a real product failure confirms obsolete semantics; find it with \`${PROJECT_LOCAL_CLI_INVOCATION} code authority --repo <root> --audit --max-files <n> --max-bytes <n>\` and remove it with the hard cut.`,
32
+ `- When a selected TypeScript or TSX consumer still has a static-dependency question, use \`${PROJECT_LOCAL_CLI_INVOCATION} code context <path> --repo <root> --symbol <identifier> --tsconfig <path> --max-bytes <n>\` for bounded root-direct static dependencies; it is not inbound impact, runtime dispatch, or complete task context.`,
32
33
  `- Use \`${PROJECT_LOCAL_CLI_INVOCATION} sync --check\` to diagnose drift in package-owned managed projections, \`${PROJECT_LOCAL_CLI_INVOCATION} sync --apply\` to restore them, and \`${PROJECT_LOCAL_CLI_INVOCATION} doctor\` to diagnose package/managed compatibility. These commands do not validate product authority, implementation conformance, or task readiness.`,
33
34
  "- Under `.nimi/spec/**`, author only closed multi-unit `*.authority.yaml` containers or single-unit `*.authority.md`; historical document formats are unsupported and never inferred.",
34
35
  `- Run \`${PROJECT_LOCAL_CLI_INVOCATION} authority fmt\` on each changed file, then \`${PROJECT_LOCAL_CLI_INVOCATION} authority check\` on the complete authority input set.`,
35
- `- A failed project-local \`${PROJECT_LOCAL_CLI_INVOCATION} ...\` invocation blocks only the requested CLI product and never permits guessed, partial, corpus-wide, or fallback context; choose repair values only from product/task authority.`,
36
+ `- A failed project-local \`${PROJECT_LOCAL_CLI_INVOCATION} ...\` invocation supplies no usable result. Pause decisions that require refused, missing, or incomplete results; continue independent authorized work. Never substitute guessed, corpus-wide, or fallback context, or treat diagnostics or partial output as complete context; choose repair values only from product/task authority.`,
36
37
  "- Keep derived and local verification output under `.nimi/local/**`; it is never product authority.",
37
38
  ];
38
39
  }
@@ -1,4 +1,4 @@
1
- version: 6
1
+ version: 8
2
2
  id: nimicoding.authority-authoring
3
3
  purpose: Author explicit authority and navigate current implementation without inference.
4
4
  authority_boundary:
@@ -11,32 +11,35 @@ authority_boundary:
11
11
  cli_execution:
12
12
  cwd: repository_root
13
13
  command_prefix: pnpm exec nimicoding
14
- rule: Resolve the pinned local package; never probe global PATH. Failure blocks only the requested CLI product.
14
+ rule: Use the pinned local package, never global PATH. Refused, missing or partial results block dependent decisions, not independent authorized work. No guessed/corpus-wide/fallback context; repair only from task/product authority.
15
15
 
16
16
  daily_workflow:
17
- - Without an exact ID, run pnpm exec nimicoding authority discover <path> <query> --max-candidates 10 --max-snippet-terms 24 --max-bytes 131072 --json. It returns candidates, never selection or absence proof.
17
+ - For needed authority selection without an ID, use pnpm exec nimicoding authority discover <path> <query> --max-candidates 10 --max-snippet-terms 24 --max-bytes 131072 --json. Candidates never prove selection or absence.
18
18
  - Select IDs only from task/product authority. pnpm exec nimicoding authority query <path> <id> --max-bytes <n> --json returns one unit; pnpm exec nimicoding authority context <path> <id> --max-units <n> --max-bytes <n> --json returns its outgoing applies_to/supersedes closure, not task context.
19
19
  - Modify only project authority; never infer product values or relations.
20
20
  - Run pnpm exec nimicoding authority fmt <changed-file> for each changed file.
21
21
  - Run pnpm exec nimicoding authority check <complete-path> [--scope-bindings <file>] --json, then pnpm exec nimicoding authority compile <complete-path> --json. For anchors run pnpm exec nimicoding authority anchors <repo> --spec <corpus> [--scope-bindings <file>] --max-units <n> --max-anchors <n> --max-bytes <n> --json.
22
22
  - For semantic changes, run complete-input diff and impact with budgets; obligations are host follow-up targets, not results.
23
- - Never continue from diagnostics, unknown IDs, budget failures, or guessed/partial results.
24
23
 
25
24
  implementation_navigation:
25
+ query_use: Query for unresolved task questions; reuse sufficient current evidence. Use code context for remaining TS/TSX static-dependency questions. Hypotheses are not authority.
26
26
  authority_to_code: pnpm exec nimicoding code authority --repo <root> --authority <exact-id> --max-files <n> --max-bytes <n>
27
27
  code_to_authority: pnpm exec nimicoding code authority --repo <root> --source <tracked-path> --max-files <n> --max-bytes <n>
28
28
  context: pnpm exec nimicoding code context <ts-or-tsx-path> --repo <root> --symbol <top-level-identifier> --tsconfig <path> --max-bytes <n>
29
+ languages: {slash: [TypeScript, TSX, Go, Rust], hash: [Python], context: [TypeScript, TSX]}
29
30
  markers:
30
- authority: "// nimi-authority: <exact-id>"
31
- deprecated: "// nimi-deprecated: <same-exact-id>"
32
- rule: Put optional markers near key semantic owners; add deprecated only from direct authority/product failure, then remove with the hard cut.
33
- boundary: Markers return authored locations/lifecycle; TypeScript context is root-direct static outbound only. Neither evaluates unannotated code, conformance, inbound impact, runtime dispatch, or completion.
31
+ authority_slash: "// @nimi-authority: <exact-id>"
32
+ deprecated_slash: "// @nimi-deprecated: <same-exact-id>"
33
+ authority_python: "# @nimi-authority: <exact-id>"
34
+ deprecated_python: "# @nimi-deprecated: <same-exact-id>"
35
+ rule: Optional markers are reserved standalone physical lines at key semantic owners; comment context is not proved. Deprecation needs authority/product failure evidence; remove with hard cut.
36
+ boundary: Marker lines return locations/lifecycle; TypeScript context is root-direct static outbound only. Neither evaluates unannotated code, conformance, inbound impact, runtime dispatch, or completion.
34
37
 
35
38
  managed_surfaces:
36
39
  check: pnpm exec nimicoding sync --check
37
40
  restore: pnpm exec nimicoding sync --apply
38
41
  doctor: pnpm exec nimicoding doctor
39
- boundary: Sync diagnoses exact package-owned projection/block drift and apply restores it; doctor diagnoses package/managed compatibility. Neither validates authority, code, or task readiness.
42
+ boundary: Sync checks/restores owned projections; doctor checks compatibility. Neither validates authority, code, or task readiness.
40
43
 
41
44
  source_profiles:
42
45
  yaml:
@@ -86,7 +89,6 @@ formatter_and_diagnostics:
86
89
  - fmt canonicalizes v2 and strips redundant unit defaults.
87
90
  - Non-v2 input fails fmt/check/compile/diff/impact/review.
88
91
  - check/compile use complete paths and emit no public/partial AuthorityIR.
89
- - Diagnostics give locations and repair categories, never product values.
90
92
 
91
93
  change_workflow:
92
94
  diff: pnpm exec nimicoding authority diff <before-path> <after-path> --max-bytes <positive-integer> --json
@@ -139,4 +141,4 @@ canonical_examples:
139
141
  target: rule.checkout-no-anonymous-v0
140
142
 
141
143
  final_boundaries:
142
- - Only project-authored sources under .nimi/spec are authority; derived/local output is not.
144
+ - Derived/local output is never authority.
@@ -15,7 +15,7 @@ methodology:
15
15
  - project_bound_deterministic_authority_audit_and_SARIF_projection
16
16
  - semantic_diff_and_declared_review_obligations
17
17
  - explicit_TypeScript_5_9_3_root_direct_bounded_code_context
18
- - transient_exact_code_authority_marker_lookup_and_lifecycle_audit
18
+ - transient_exact_physical_code_authority_marker_lookup_and_lifecycle_audit_for_TypeScript_TSX_Go_Python_and_Rust
19
19
  does_not_own:
20
20
  - project_product_semantics
21
21
  - historical_document_reconstruction_or_inference
@@ -25,7 +25,7 @@ methodology:
25
25
  - implementation_or_review_completion
26
26
  - host_workflow_commands
27
27
  - storage_semantic_search_visualization_or_Atlas
28
- - code_location_inbound_impact_structural_advice_other_languages_or_task_completion
28
+ - code_location_inbound_impact_structural_advice_semantic_code_context_for_non_TypeScript_languages_or_task_completion
29
29
  authority_order:
30
30
  - host_canonical_authority_under_.nimi/spec
31
31
  - projected_compact_authoring_methodology
@@ -39,4 +39,5 @@ methodology:
39
39
  audit: explicit_project_verifier_bindings_not_prose_inference_plugin_execution_or_product_authority
40
40
  impact: declared_relation_impact_and_host_follow_up_targets_not_implementation_consumer_or_test_sync_proof
41
41
  code_context: current_filesystem_complete_selected_TypeScript_Program_root_direct_static_outbound_projection_not_location_impact_runtime_dispatch_or_task_context
42
+ code_authority: reserved_exact_physical_markers_in_tracked_current_TypeScript_TSX_Go_Python_and_Rust_not_language_comment_proof_or_implementation_conformance
42
43
  authority_admission: nimicoding_authority_check_on_complete_canonical_root
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@nimiplatform/nimi-coding",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
- "description": "Canonical authority products and bounded read-only code context for AI coding systems.",
5
+ "description": "Canonical authority products and bounded read-only code queries for AI coding systems.",
6
6
  "license": "MIT",
7
7
  "homepage": "https://docs.nimi.ai/nimicoding",
8
8
  "repository": {
@@ -3,19 +3,24 @@ spec:
3
3
  id: nimicoding.code-authority-annotations.v1
4
4
  owner: nimi-coding
5
5
  status: experimental
6
- product_claim: exact_standalone_markers_link_selected_tracked_current_source_to_current_canonical_authority_lifecycle
7
- command: 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
6
+ product_claim: reserved_exact_standalone_physical_markers_link_selected_tracked_current_source_to_current_canonical_authority_lifecycle
7
+ command: 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
8
8
  markers:
9
- authority: "// nimi-authority: <exact-authority-id>"
10
- deprecated: "// nimi-deprecated: <exact-authority-id>"
9
+ slash_prefix_languages: [TypeScript, TSX, Go, Rust]
10
+ slash_authority: "// @nimi-authority: <exact-authority-id>"
11
+ slash_deprecated: "// @nimi-deprecated: <exact-authority-id>"
12
+ python_authority: "# @nimi-authority: <exact-authority-id>"
13
+ python_deprecated: "# @nimi-deprecated: <exact-authority-id>"
11
14
  optional: true
12
15
  attachment: source_file_with_exact_marker_and_bounded_nearby_source_only
16
+ language_comment_context: not_evaluated
13
17
  declaration_ownership: not_evaluated
14
18
  deprecated_pairing: not_evaluated
15
19
  scan:
16
20
  authority_corpus: complete_repository_.nimi/spec
17
21
  source_inventory: Git_tracked_current_filesystem
18
- source_languages: [TypeScript, TSX, Go]
22
+ source_languages: [TypeScript, TSX, Go, Python, Rust]
23
+ marker_detection: exact_physical_line_without_language_parser
19
24
  persistent_index_or_cache: none
20
25
  ordering: deterministic
21
26
  operations:
@@ -1,4 +1,4 @@
1
- version: 11
1
+ version: 12
2
2
  product:
3
3
  package_name: "@nimiplatform/nimi-coding"
4
4
  mission: canonical_authority_products_bounded_read_only_code_context_and_explicit_code_authority_marker_lookup
@@ -13,7 +13,7 @@ owned_surfaces:
13
13
  - project_bound_deterministic_graph_and_exact_lexical_authority_audit_and_SARIF_projection
14
14
  - git_aware_exact_read_only_authority_change_review
15
15
  - explicit_TypeScript_5_9_3_root_direct_bounded_code_context
16
- - transient_exact_code_authority_marker_lookup_and_lifecycle_audit_for_tracked_current_TypeScript_TSX_and_Go_source
16
+ - transient_exact_code_authority_marker_lookup_and_lifecycle_audit_for_tracked_current_TypeScript_TSX_Go_Python_and_Rust_source
17
17
  canonical_boundary:
18
18
  host_product_authority: .nimi/spec/**/*.authority.{yaml,md}
19
19
  sole_conformance_gate: nimicoding_authority_check_complete_.nimi/spec