@nimiplatform/nimi-coding 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/CONTRIBUTING.md +3 -1
- package/README.md +52 -25
- package/README.zh-CN.md +52 -25
- package/cli/commands/clear.mjs +3 -2
- package/cli/commands/code.mjs +225 -0
- package/cli/commands/start.mjs +3 -2
- package/cli/constants.mjs +2 -1
- package/cli/dev/run-cli-smoke.mjs +6 -0
- package/cli/help.mjs +8 -3
- package/cli/index.mjs +3 -2
- package/cli/lib/authority/diagnostics.mjs +3 -1
- package/cli/lib/code/authority-annotation-response.mjs +43 -0
- package/cli/lib/code/authority-annotation-scan.mjs +115 -0
- package/cli/lib/code/authority-annotations.mjs +293 -0
- package/cli/lib/code/context.mjs +710 -0
- package/cli/lib/code/response.mjs +165 -0
- package/cli/lib/doctor.mjs +3 -2
- package/cli/lib/entrypoints.mjs +12 -5
- package/cli/seeds/seed-policy.yaml +2 -2
- package/methodology/authority-authoring.yaml +70 -52
- package/methodology/core.yaml +7 -4
- package/package.json +5 -3
- package/spec/code-authority-annotations.yaml +47 -0
- package/spec/code-context.yaml +38 -0
- package/spec/product-scope.yaml +8 -3
- package/cli/commands/validate-ai-governance.mjs +0 -335
- package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +0 -377
- package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +0 -376
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +0 -155
- package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +0 -173
- package/cli/lib/internal/governance/config.mjs +0 -114
- package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +0 -49
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
|
|
3
|
+
export const CODE_CONTEXT_FORMAT = "nimicoding.code-context-response/v1";
|
|
4
|
+
export const MIN_CODE_CONTEXT_BYTES = 512;
|
|
5
|
+
|
|
6
|
+
const MAX_ERROR_MESSAGE_BYTES = 160;
|
|
7
|
+
|
|
8
|
+
function serialized(value) {
|
|
9
|
+
return JSON.stringify(value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function serializedBytes(value) {
|
|
13
|
+
return Buffer.byteLength(value, "utf8");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function prefixByteLengths(fragments) {
|
|
17
|
+
const totals = [0];
|
|
18
|
+
for (const fragment of fragments) {
|
|
19
|
+
totals.push(totals.at(-1) + serializedBytes(fragment));
|
|
20
|
+
}
|
|
21
|
+
return totals;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function arrayBytes(prefixTotals, count) {
|
|
25
|
+
return 2 + prefixTotals[count] + Math.max(0, count - 1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function arrayText(fragments, count) {
|
|
29
|
+
return `[${fragments.slice(0, count).join(",")}]`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function refusedCodeResponse(code, message) {
|
|
33
|
+
if (Buffer.byteLength(message, "utf8") > MAX_ERROR_MESSAGE_BYTES) {
|
|
34
|
+
throw new Error("code response error message exceeds its fixed protocol bound");
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
format: CODE_CONTEXT_FORMAT,
|
|
38
|
+
status: "refused",
|
|
39
|
+
scope: null,
|
|
40
|
+
coverage: null,
|
|
41
|
+
missing_frontier: null,
|
|
42
|
+
result: null,
|
|
43
|
+
error: { code, message },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function serializeCodeResponse(response) {
|
|
48
|
+
return `${serialized(response)}\n`;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function targetCountsBySemanticPrefix(targets, semanticItems) {
|
|
52
|
+
const known = new Set();
|
|
53
|
+
const counts = [0];
|
|
54
|
+
for (const item of semanticItems) {
|
|
55
|
+
if (item.target_id !== undefined && item.target_id !== null) known.add(item.target_id);
|
|
56
|
+
counts.push(known.size);
|
|
57
|
+
}
|
|
58
|
+
if (known.size !== targets.length) throw new Error("semantic projection contains an unused target descriptor");
|
|
59
|
+
return counts;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function responseParts({ scopeText, rootText, targetFragments, semanticFragments, sourceFragments }, state) {
|
|
63
|
+
const coverage = {
|
|
64
|
+
semantic_items: state.semanticCount === semanticFragments.length ? "complete" : "truncated",
|
|
65
|
+
source_units: state.sourceCount === sourceFragments.length ? "complete" : "truncated",
|
|
66
|
+
};
|
|
67
|
+
const complete = state.semanticCount === semanticFragments.length && state.sourceCount === sourceFragments.length;
|
|
68
|
+
const frontier = complete ? null : {
|
|
69
|
+
next_semantic_site: state.nextSemanticSite,
|
|
70
|
+
next_source_target: state.nextSourceTarget,
|
|
71
|
+
};
|
|
72
|
+
if (!complete && frontier.next_semantic_site === null && frontier.next_source_target === null) {
|
|
73
|
+
throw new Error("partial code response has no missing frontier");
|
|
74
|
+
}
|
|
75
|
+
const head = [
|
|
76
|
+
`{"format":${serialized(CODE_CONTEXT_FORMAT)}`,
|
|
77
|
+
`,"status":${serialized(complete ? "completed" : "partial")}`,
|
|
78
|
+
`,"scope":${scopeText}`,
|
|
79
|
+
`,"coverage":${serialized(coverage)}`,
|
|
80
|
+
`,"missing_frontier":${serialized(frontier)}`,
|
|
81
|
+
`,"result":{"root":${rootText},"targets":`,
|
|
82
|
+
].join("");
|
|
83
|
+
return {
|
|
84
|
+
head,
|
|
85
|
+
betweenTargetsAndSemantic: ",\"semantic_items\":",
|
|
86
|
+
betweenSemanticAndSources: ",\"source_units\":",
|
|
87
|
+
tail: "},\"error\":null}\n",
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function codeResponseBytes(parts, targetBytes, semanticBytes, sourceBytes, state) {
|
|
92
|
+
return serializedBytes(parts.head)
|
|
93
|
+
+ arrayBytes(targetBytes, state.targetCount)
|
|
94
|
+
+ serializedBytes(parts.betweenTargetsAndSemantic)
|
|
95
|
+
+ arrayBytes(semanticBytes, state.semanticCount)
|
|
96
|
+
+ serializedBytes(parts.betweenSemanticAndSources)
|
|
97
|
+
+ arrayBytes(sourceBytes, state.sourceCount)
|
|
98
|
+
+ serializedBytes(parts.tail);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function stateForPrefix({ targets, semanticItems, sourceUnits, targetCounts }, prefix) {
|
|
102
|
+
const semanticCount = Math.min(prefix, semanticItems.length);
|
|
103
|
+
const sourceCount = prefix <= semanticItems.length ? 0 : prefix - semanticItems.length;
|
|
104
|
+
const targetCount = targetCounts[semanticCount];
|
|
105
|
+
const nextSemantic = semanticItems[semanticCount];
|
|
106
|
+
let nextSourceTarget = null;
|
|
107
|
+
if (semanticCount === semanticItems.length) {
|
|
108
|
+
nextSourceTarget = sourceUnits[sourceCount]?.target_id ?? null;
|
|
109
|
+
} else if (sourceUnits.length > 0) {
|
|
110
|
+
const targetIndex = targets.findIndex((target) => target.id === sourceUnits[0].target_id);
|
|
111
|
+
if (targetIndex >= 0 && targetIndex < targetCount) nextSourceTarget = sourceUnits[0].target_id;
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
semanticCount,
|
|
115
|
+
sourceCount,
|
|
116
|
+
targetCount,
|
|
117
|
+
nextSemanticSite: nextSemantic === undefined ? null : {
|
|
118
|
+
line: nextSemantic.site.range.start_line,
|
|
119
|
+
column: nextSemantic.site.range.start_column,
|
|
120
|
+
},
|
|
121
|
+
nextSourceTarget,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function renderContextResponse({ scope, projection, maxBytes }) {
|
|
126
|
+
const scopeText = serialized(scope);
|
|
127
|
+
const rootText = serialized(projection.root);
|
|
128
|
+
const targetFragments = projection.targets.map(serialized);
|
|
129
|
+
const semanticFragments = projection.semanticItems.map(serialized);
|
|
130
|
+
const sourceFragments = projection.sourceUnits.map(serialized);
|
|
131
|
+
const targetBytes = prefixByteLengths(targetFragments);
|
|
132
|
+
const semanticBytes = prefixByteLengths(semanticFragments);
|
|
133
|
+
const sourceBytes = prefixByteLengths(sourceFragments);
|
|
134
|
+
const targetCounts = targetCountsBySemanticPrefix(projection.targets, projection.semanticItems);
|
|
135
|
+
const totalItems = semanticFragments.length + sourceFragments.length;
|
|
136
|
+
let selected = null;
|
|
137
|
+
|
|
138
|
+
for (let prefix = 0; prefix <= totalItems; prefix += 1) {
|
|
139
|
+
const state = stateForPrefix({
|
|
140
|
+
targets: projection.targets,
|
|
141
|
+
semanticItems: projection.semanticItems,
|
|
142
|
+
sourceUnits: projection.sourceUnits,
|
|
143
|
+
targetCounts,
|
|
144
|
+
}, prefix);
|
|
145
|
+
const parts = responseParts({ scopeText, rootText, targetFragments, semanticFragments, sourceFragments }, state);
|
|
146
|
+
const bytes = codeResponseBytes(parts, targetBytes, semanticBytes, sourceBytes, state);
|
|
147
|
+
if (bytes <= maxBytes) selected = { state, parts, bytes };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (selected === null) return null;
|
|
151
|
+
const { state, parts, bytes } = selected;
|
|
152
|
+
const text = [
|
|
153
|
+
parts.head,
|
|
154
|
+
arrayText(targetFragments, state.targetCount),
|
|
155
|
+
parts.betweenTargetsAndSemantic,
|
|
156
|
+
arrayText(semanticFragments, state.semanticCount),
|
|
157
|
+
parts.betweenSemanticAndSources,
|
|
158
|
+
arrayText(sourceFragments, state.sourceCount),
|
|
159
|
+
parts.tail,
|
|
160
|
+
].join("");
|
|
161
|
+
if (serializedBytes(text) !== bytes || bytes > maxBytes) {
|
|
162
|
+
throw new Error("code response renderer byte accounting is inconsistent");
|
|
163
|
+
}
|
|
164
|
+
return { text, bytes, status: state.semanticCount === semanticFragments.length && state.sourceCount === sourceFragments.length ? "completed" : "partial" };
|
|
165
|
+
}
|
package/cli/lib/doctor.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readdir } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
|
|
4
|
+
import { PROJECT_LOCAL_CLI_INVOCATION } from "../constants.mjs";
|
|
4
5
|
import { getBootstrapSeedEntries } from "../seeds/bootstrap.mjs";
|
|
5
6
|
import { pathExists, preflightManagedProjectPaths } from "./fs-helpers.mjs";
|
|
6
7
|
import { runSeedSync, SYNC_MODE } from "./sync.mjs";
|
|
@@ -34,7 +35,7 @@ export async function inspectDoctorState(projectRoot) {
|
|
|
34
35
|
true,
|
|
35
36
|
"info",
|
|
36
37
|
specPresent
|
|
37
|
-
?
|
|
38
|
+
? `canonical authority is present; run ${PROJECT_LOCAL_CLI_INVOCATION} authority check .nimi/spec for admission`
|
|
38
39
|
: "canonical authority has not been authored; the project owns all product semantics under .nimi/spec",
|
|
39
40
|
),
|
|
40
41
|
];
|
|
@@ -74,7 +75,7 @@ export function formatDoctorResult(result, options = {}) {
|
|
|
74
75
|
if (visible.length === 0) lines.push(` - ${localize("No blocking integration issues found.", "没有发现阻塞性的集成问题。")}`);
|
|
75
76
|
else for (const entry of visible) lines.push(` - [${entry.ok ? "info" : entry.severity}] ${entry.detail}`);
|
|
76
77
|
if (!result.spec.present) {
|
|
77
|
-
lines.push("", styleLabel(localize("Next:", "下一步:")),
|
|
78
|
+
lines.push("", styleLabel(localize("Next:", "下一步:")), ` - Author canonical authority under .nimi/spec, format changed files, then run ${PROJECT_LOCAL_CLI_INVOCATION} authority check .nimi/spec.`);
|
|
78
79
|
}
|
|
79
80
|
return `${lines.join("\n")}\n`;
|
|
80
81
|
}
|
package/cli/lib/entrypoints.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
AGENTS_END,
|
|
7
7
|
CLAUDE_BEGIN,
|
|
8
8
|
CLAUDE_END,
|
|
9
|
+
PROJECT_LOCAL_CLI_INVOCATION,
|
|
9
10
|
} from "../constants.mjs";
|
|
10
11
|
import { pathExists, preflightManagedProjectPaths, readUtf8FileFatal } from "./fs-helpers.mjs";
|
|
11
12
|
|
|
@@ -18,14 +19,20 @@ export class ManagedBlockError extends Error {
|
|
|
18
19
|
|
|
19
20
|
function authorityAuthoringLines() {
|
|
20
21
|
return [
|
|
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\`.`,
|
|
21
23
|
"- Product authority lives under `.nimi/spec/**`.",
|
|
22
24
|
"- For canonical authority authoring, read only `.nimi/methodology/authority-authoring.yaml`, the affected authority files or bounded task context, and CLI diagnostics.",
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
`- 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
|
+
`- 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
|
+
`- 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 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.`,
|
|
30
|
+
`- 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.`,
|
|
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.`,
|
|
32
|
+
`- 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.`,
|
|
26
33
|
"- Under `.nimi/spec/**`, author only closed multi-unit `*.authority.yaml` containers or single-unit `*.authority.md`; historical document formats are unsupported and never inferred.",
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
`- 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.`,
|
|
29
36
|
"- Keep derived and local verification output under `.nimi/local/**`; it is never product authority.",
|
|
30
37
|
];
|
|
31
38
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
policy_id: nimicoding.seed-projection.v3
|
|
2
|
-
description: Exact downstream projection registry for
|
|
2
|
+
description: Exact downstream projection registry for authority authoring and bounded implementation navigation.
|
|
3
3
|
projections:
|
|
4
4
|
- source: methodology/authority-authoring.yaml
|
|
5
5
|
output: .nimi/methodology/authority-authoring.yaml
|
|
6
6
|
ownership: package_canonical
|
|
7
|
-
downstream_consumer: project AI reads the compact
|
|
7
|
+
downstream_consumer: project AI reads the compact authority and implementation-navigation guide
|
|
8
8
|
deprecated_projections:
|
|
9
9
|
- .nimi/config/spec-generation-inputs.yaml
|
|
10
10
|
- .nimi/contracts/domain-admission.schema.yaml
|
|
@@ -1,45 +1,65 @@
|
|
|
1
|
-
version:
|
|
1
|
+
version: 7
|
|
2
2
|
id: nimicoding.authority-authoring
|
|
3
|
-
purpose: Author explicit
|
|
3
|
+
purpose: Author explicit authority and navigate current implementation without inference.
|
|
4
4
|
authority_boundary:
|
|
5
5
|
canonical_root: .nimi/spec
|
|
6
6
|
sources: ["*.authority.yaml", "*.authority.md"]
|
|
7
|
-
rule: The project owns
|
|
8
|
-
AI_inputs: [this_guide, task_authority,
|
|
7
|
+
rule: The project owns meaning; nimicoding formats, validates, and derives read-only results.
|
|
8
|
+
AI_inputs: [this_guide, task_authority, bounded_authority_or_code_query, diagnostics]
|
|
9
9
|
do_not_read: [complete_authority_corpus, contracts, package_internal_specs]
|
|
10
10
|
|
|
11
|
+
cli_execution:
|
|
12
|
+
cwd: repository_root
|
|
13
|
+
command_prefix: pnpm exec nimicoding
|
|
14
|
+
rule: Resolve the pinned local package; never probe global PATH. Failure blocks only the requested CLI product.
|
|
15
|
+
|
|
11
16
|
daily_workflow:
|
|
12
|
-
-
|
|
13
|
-
- Select
|
|
14
|
-
- Modify only project
|
|
15
|
-
- Run nimicoding authority fmt <changed-file> for each changed file.
|
|
16
|
-
- Run nimicoding authority check <complete-path> [--scope-bindings <file>] --json
|
|
17
|
-
- For semantic changes, run diff and impact with
|
|
18
|
-
- Never continue from
|
|
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.
|
|
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
|
+
- Modify only project authority; never infer product values or relations.
|
|
20
|
+
- Run pnpm exec nimicoding authority fmt <changed-file> for each changed file.
|
|
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
|
+
- 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
|
+
|
|
25
|
+
implementation_navigation:
|
|
26
|
+
authority_to_code: pnpm exec nimicoding code authority --repo <root> --authority <exact-id> --max-files <n> --max-bytes <n>
|
|
27
|
+
code_to_authority: pnpm exec nimicoding code authority --repo <root> --source <tracked-path> --max-files <n> --max-bytes <n>
|
|
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]}
|
|
30
|
+
markers:
|
|
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 near key semantic owners; comment context is not proved. Deprecated requires direct authority/product failure and is removed 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.
|
|
37
|
+
|
|
38
|
+
managed_surfaces:
|
|
39
|
+
check: pnpm exec nimicoding sync --check
|
|
40
|
+
restore: pnpm exec nimicoding sync --apply
|
|
41
|
+
doctor: pnpm exec nimicoding doctor
|
|
42
|
+
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.
|
|
19
43
|
|
|
20
44
|
source_profiles:
|
|
21
45
|
yaml:
|
|
22
|
-
shape: "Closed
|
|
23
|
-
defaults: owner/rule scope inherit; unit
|
|
24
|
-
omissions: lifecycle
|
|
46
|
+
shape: "Closed nimicoding.authority/v2 mapping with optional owner/scope defaults and units."
|
|
47
|
+
defaults: owner/rule scope inherit; unit values override; definitions have no scope.
|
|
48
|
+
omissions: active lifecycle and empty relations may be omitted; removed reason stays explicit.
|
|
25
49
|
format: nimicoding.authority/v2_only_without_legacy_migration_or_history_input
|
|
26
50
|
markdown:
|
|
27
|
-
shape: One unit per file
|
|
51
|
+
shape: One unit per file; front matter carries fields and relations.
|
|
28
52
|
title: One plain H1.
|
|
29
53
|
sections:
|
|
30
54
|
active_definition: [Meaning]
|
|
31
55
|
active_rule: [Statement, Condition, Failure]
|
|
32
56
|
removed_unit: [Removal reason]
|
|
33
|
-
boundary:
|
|
34
|
-
shared_text_rule: Text
|
|
57
|
+
boundary: One plain-text line per section; no free prose or unknown structures.
|
|
58
|
+
shared_text_rule: Text is non-empty trimmed single-line Unicode.
|
|
35
59
|
|
|
36
60
|
common_fields:
|
|
37
|
-
id: Stable
|
|
38
|
-
|
|
39
|
-
owner: Accountable dotted lower-case unit or container value.
|
|
40
|
-
lifecycle: active or explicit removed.
|
|
41
|
-
title: Required display label.
|
|
42
|
-
relations: Type/target pairs; omitted means [].
|
|
61
|
+
id: Stable lower-case dot identity; never reuse a removed ID.
|
|
62
|
+
owner: Accountable lower-case dotted identity.
|
|
43
63
|
|
|
44
64
|
unit_shapes:
|
|
45
65
|
active_definition:
|
|
@@ -50,38 +70,37 @@ unit_shapes:
|
|
|
50
70
|
required: [id, kind, title, modality, statement, condition, failure]
|
|
51
71
|
fixed: {kind: rule, lifecycle: active}
|
|
52
72
|
modality: must or must_not.
|
|
53
|
-
scope:
|
|
54
|
-
condition:
|
|
55
|
-
failure:
|
|
73
|
+
scope: Unique non-empty unit list or inherited container value.
|
|
74
|
+
condition: Actual condition; use Always. only when unconditional.
|
|
75
|
+
failure: Observable failure, never pseudo-success or fallback.
|
|
56
76
|
forbidden: [meaning, reason]
|
|
57
77
|
removed_tombstone:
|
|
58
78
|
required: [id, kind, lifecycle, title, reason]
|
|
59
79
|
fixed: {lifecycle: removed}
|
|
60
|
-
boundary: Preserve
|
|
80
|
+
boundary: Preserve identity/kind; reason is rationale, not replacement content.
|
|
61
81
|
forbidden: [meaning, modality, scope, statement, condition, failure]
|
|
62
82
|
|
|
63
83
|
relation_rules:
|
|
64
|
-
applies_to:
|
|
65
|
-
supersedes: Optional
|
|
66
|
-
resolution:
|
|
84
|
+
applies_to: Each active rule targets one or more active definitions only.
|
|
85
|
+
supersedes: Optional edge to one removed unit of the same kind; one incoming/outgoing maximum, acyclic.
|
|
86
|
+
resolution: Exact IDs in complete input; invalid, dangling, mismatched, cyclic, duplicate, or inferred edges fail.
|
|
67
87
|
|
|
68
88
|
formatter_and_diagnostics:
|
|
69
|
-
- fmt canonicalizes
|
|
70
|
-
-
|
|
71
|
-
- check/compile use
|
|
72
|
-
- Diagnostics give locations
|
|
73
|
-
- Fix values only from task or product authority. Do not invent container defaults, fallback data, historical inference, internal contracts, or wildcard corpus reading.
|
|
89
|
+
- fmt canonicalizes v2 and strips redundant unit defaults.
|
|
90
|
+
- Non-v2 input fails fmt/check/compile/diff/impact/review.
|
|
91
|
+
- check/compile use complete paths and emit no public/partial AuthorityIR.
|
|
92
|
+
- Diagnostics give locations and repair categories, never product values.
|
|
74
93
|
|
|
75
94
|
change_workflow:
|
|
76
|
-
diff: nimicoding authority diff <before-path> <after-path> --max-bytes <positive-integer> --json
|
|
77
|
-
candidates: nimicoding authority change-candidates <before-path> <after-path> --channels <comma-separated-closed-set> --max-candidates <positive-safe-integer> --max-reasons <positive-safe-integer> --max-bytes <positive-safe-integer> --json
|
|
78
|
-
impact: nimicoding authority impact <before-path> <after-path> --max-bytes <positive-integer> --json
|
|
95
|
+
diff: pnpm exec nimicoding authority diff <before-path> <after-path> --max-bytes <positive-integer> --json
|
|
96
|
+
candidates: pnpm exec nimicoding authority change-candidates <before-path> <after-path> --channels <comma-separated-closed-set> --max-candidates <positive-safe-integer> --max-reasons <positive-safe-integer> --max-bytes <positive-safe-integer> --json
|
|
97
|
+
impact: pnpm exec nimicoding authority impact <before-path> <after-path> --max-bytes <positive-integer> --json
|
|
79
98
|
boundaries:
|
|
80
99
|
- Diff compares complete canonical inputs; formatting, profile, file, and order-only changes are semantic zero.
|
|
81
|
-
-
|
|
82
|
-
- Impact
|
|
83
|
-
- Diff/impact
|
|
84
|
-
- Impact accepts no disposition, receipt, external result, test outcome, or completion state
|
|
100
|
+
- Candidates cover only requested exact channels, never semantic judgment.
|
|
101
|
+
- Impact reports declared reverse-relation consumers and one test target per impacted active rule.
|
|
102
|
+
- Diff/impact budget failure returns no partial result.
|
|
103
|
+
- Impact accepts no disposition, receipt, external result, test outcome, or completion state; workflow stays host-owned.
|
|
85
104
|
|
|
86
105
|
canonical_examples:
|
|
87
106
|
complete_yaml_lifecycle: |
|
|
@@ -92,13 +111,13 @@ canonical_examples:
|
|
|
92
111
|
kind: definition
|
|
93
112
|
owner: team.identity
|
|
94
113
|
lifecycle: removed
|
|
95
|
-
title:
|
|
96
|
-
reason: Replaced by
|
|
114
|
+
title: Old session
|
|
115
|
+
reason: Replaced by definition.session.
|
|
97
116
|
- id: definition.session
|
|
98
117
|
kind: definition
|
|
99
118
|
owner: team.identity
|
|
100
119
|
title: Session
|
|
101
|
-
meaning: A server-issued identity
|
|
120
|
+
meaning: A server-issued request identity.
|
|
102
121
|
relations:
|
|
103
122
|
- type: supersedes
|
|
104
123
|
target: definition.session-v0
|
|
@@ -106,16 +125,16 @@ canonical_examples:
|
|
|
106
125
|
kind: rule
|
|
107
126
|
owner: team.checkout
|
|
108
127
|
lifecycle: removed
|
|
109
|
-
title:
|
|
110
|
-
reason: Replaced by
|
|
128
|
+
title: Old checkout rule
|
|
129
|
+
reason: Replaced by rule.checkout-no-anonymous.
|
|
111
130
|
- id: rule.checkout-no-anonymous
|
|
112
131
|
kind: rule
|
|
113
132
|
owner: team.checkout
|
|
114
|
-
title:
|
|
133
|
+
title: Require checkout session
|
|
115
134
|
modality: must_not
|
|
116
|
-
statement: Checkout creates an order without a
|
|
135
|
+
statement: Checkout creates an order without a session.
|
|
117
136
|
condition: Always.
|
|
118
|
-
failure: Reject
|
|
137
|
+
failure: Reject before creating the order.
|
|
119
138
|
relations:
|
|
120
139
|
- type: applies_to
|
|
121
140
|
target: definition.session
|
|
@@ -123,5 +142,4 @@ canonical_examples:
|
|
|
123
142
|
target: rule.checkout-no-anonymous-v0
|
|
124
143
|
|
|
125
144
|
final_boundaries:
|
|
126
|
-
-
|
|
127
|
-
- Derived reads are bounded and read-only; none selects authority, supplies complete task context, or proves completion.
|
|
145
|
+
- Only project-authored sources under .nimi/spec are authority; derived/local output is not.
|
package/methodology/core.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
version:
|
|
1
|
+
version: 7
|
|
2
2
|
methodology:
|
|
3
3
|
id: nimi-coding
|
|
4
|
-
mission: Preserve explicit project-authored canonical authority
|
|
4
|
+
mission: Preserve explicit project-authored canonical authority and derive bounded read-only code context or explicit authored code links from current implementation inputs.
|
|
5
5
|
package_boundary:
|
|
6
6
|
owns:
|
|
7
7
|
- compact_canonical_authority_authoring_methodology
|
|
@@ -14,7 +14,8 @@ methodology:
|
|
|
14
14
|
- bounded_explicit_relation_graph_navigation
|
|
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_physical_code_authority_marker_lookup_and_lifecycle_audit_for_TypeScript_TSX_Go_Python_and_Rust
|
|
18
19
|
does_not_own:
|
|
19
20
|
- project_product_semantics
|
|
20
21
|
- historical_document_reconstruction_or_inference
|
|
@@ -24,6 +25,7 @@ methodology:
|
|
|
24
25
|
- implementation_or_review_completion
|
|
25
26
|
- host_workflow_commands
|
|
26
27
|
- storage_semantic_search_visualization_or_Atlas
|
|
28
|
+
- code_location_inbound_impact_structural_advice_semantic_code_context_for_non_TypeScript_languages_or_task_completion
|
|
27
29
|
authority_order:
|
|
28
30
|
- host_canonical_authority_under_.nimi/spec
|
|
29
31
|
- projected_compact_authoring_methodology
|
|
@@ -36,5 +38,6 @@ methodology:
|
|
|
36
38
|
graph: bounded_explicit_relation_navigation_not_semantic_inference_or_raw_IR
|
|
37
39
|
audit: explicit_project_verifier_bindings_not_prose_inference_plugin_execution_or_product_authority
|
|
38
40
|
impact: declared_relation_impact_and_host_follow_up_targets_not_implementation_consumer_or_test_sync_proof
|
|
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
|
|
39
43
|
authority_admission: nimicoding_authority_check_on_complete_canonical_root
|
|
40
|
-
optional_repository_governance: separate_L3_not_authority_admission
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/nimi-coding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Canonical authority
|
|
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": {
|
|
@@ -33,12 +33,14 @@
|
|
|
33
33
|
"keywords": [
|
|
34
34
|
"ai",
|
|
35
35
|
"coding",
|
|
36
|
-
"
|
|
36
|
+
"authority",
|
|
37
|
+
"code-intelligence",
|
|
37
38
|
"methodology",
|
|
38
39
|
"spec",
|
|
39
40
|
"nimicoding"
|
|
40
41
|
],
|
|
41
42
|
"dependencies": {
|
|
43
|
+
"typescript": "5.9.3",
|
|
42
44
|
"yaml": "^2.8.1"
|
|
43
45
|
},
|
|
44
46
|
"files": [
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
spec:
|
|
3
|
+
id: nimicoding.code-authority-annotations.v1
|
|
4
|
+
owner: nimi-coding
|
|
5
|
+
status: experimental
|
|
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
|
+
markers:
|
|
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>"
|
|
14
|
+
optional: true
|
|
15
|
+
attachment: source_file_with_exact_marker_and_bounded_nearby_source_only
|
|
16
|
+
language_comment_context: not_evaluated
|
|
17
|
+
declaration_ownership: not_evaluated
|
|
18
|
+
deprecated_pairing: not_evaluated
|
|
19
|
+
scan:
|
|
20
|
+
authority_corpus: complete_repository_.nimi/spec
|
|
21
|
+
source_inventory: Git_tracked_current_filesystem
|
|
22
|
+
source_languages: [TypeScript, TSX, Go, Python, Rust]
|
|
23
|
+
marker_detection: exact_physical_line_without_language_parser
|
|
24
|
+
persistent_index_or_cache: none
|
|
25
|
+
ordering: deterministic
|
|
26
|
+
operations:
|
|
27
|
+
authority_to_code: all_exact_marker_occurrences_in_the_complete_admitted_source_scan
|
|
28
|
+
code_to_authority: exact_marker_occurrences_in_one_tracked_source_file
|
|
29
|
+
lifecycle_audit: [active-reference, explicit-deprecated, removed-reference, superseded-reference, missing-reference, invalid-annotation]
|
|
30
|
+
response:
|
|
31
|
+
format: nimicoding.code-authority-response/v1
|
|
32
|
+
transport: one_compact_JSON_object_on_stdout_with_terminating_newline
|
|
33
|
+
stderr: empty_for_recognized_code_operations
|
|
34
|
+
statuses: [completed, findings, refused]
|
|
35
|
+
public_budgets: [max-files, max-bytes]
|
|
36
|
+
minimum_valid_max_bytes: 512
|
|
37
|
+
partial_results: forbidden
|
|
38
|
+
boundaries:
|
|
39
|
+
annotation_is_authority: false
|
|
40
|
+
annotation_proves_conformance: false
|
|
41
|
+
unannotated_source: not_evaluated
|
|
42
|
+
active_authority_statement_drift: not_evaluated
|
|
43
|
+
automatic_legacy_detection: false
|
|
44
|
+
annotation_coverage_gate: false
|
|
45
|
+
scope_binding_dependency: none
|
|
46
|
+
writes_repository: false
|
|
47
|
+
workflow_task_or_completion_state: none
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
spec:
|
|
3
|
+
id: nimicoding.code-context.v1
|
|
4
|
+
owner: nimi-coding
|
|
5
|
+
status: experimental
|
|
6
|
+
product_claim: explicit_TypeScript_root_returns_one_bounded_root_direct_static_outbound_projection_or_fails
|
|
7
|
+
command: 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
|
|
8
|
+
compiler:
|
|
9
|
+
language: TypeScript_TSX
|
|
10
|
+
version: 5.9.3
|
|
11
|
+
source: nearest_repo_contained_tsconfig_owner_package
|
|
12
|
+
program: fresh_complete_selected_config_without_project_references
|
|
13
|
+
root:
|
|
14
|
+
selector: one_exact_top_level_Identifier
|
|
15
|
+
admitted: [function, class, interface, type_alias, single_declarator_variable_statement]
|
|
16
|
+
merged_overloaded_nested_member_namespace_enum_or_declaration_root: refused
|
|
17
|
+
projection:
|
|
18
|
+
scope: selected_root_AST_only
|
|
19
|
+
relations: [static_value_binding, static_type_binding, static_constructor_binding, static_JSX_binding]
|
|
20
|
+
target: complete_nonempty_portable_declaration_set
|
|
21
|
+
target_source: optional_single_repository_declaration_syntactic_slice
|
|
22
|
+
runtime_dispatch: not_evaluated
|
|
23
|
+
response:
|
|
24
|
+
format: nimicoding.code-context-response/v1
|
|
25
|
+
transport: one_compact_JSON_object_on_stdout_with_terminating_newline
|
|
26
|
+
stderr: empty_for_recognized_code_operations
|
|
27
|
+
statuses: [completed, partial, refused]
|
|
28
|
+
public_budget: complete_UTF-8_response_max_bytes
|
|
29
|
+
minimum_valid_max_bytes: 512
|
|
30
|
+
partial: deterministic_longest_atomic_prefix_with_first_missing_frontier
|
|
31
|
+
boundaries:
|
|
32
|
+
writes_repository: false
|
|
33
|
+
persistent_index_or_cache: none
|
|
34
|
+
authority_association: not_claimed
|
|
35
|
+
source_location_or_inbound_impact: not_admitted
|
|
36
|
+
structural_advice: not_admitted
|
|
37
|
+
task_workflow_verification_or_completion: not_admitted
|
|
38
|
+
other_languages: not_admitted
|
package/spec/product-scope.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
version:
|
|
1
|
+
version: 12
|
|
2
2
|
product:
|
|
3
3
|
package_name: "@nimiplatform/nimi-coding"
|
|
4
|
-
mission:
|
|
4
|
+
mission: canonical_authority_products_bounded_read_only_code_context_and_explicit_code_authority_marker_lookup
|
|
5
5
|
owned_surfaces:
|
|
6
6
|
- compact_authority_authoring_methodology
|
|
7
7
|
- exact_authority_guide_projection_and_managed_instruction_blocks
|
|
@@ -12,7 +12,8 @@ owned_surfaces:
|
|
|
12
12
|
- bounded_direct_references_exact_relation_paths_and_local_subgraphs
|
|
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_Go_Python_and_Rust_source
|
|
16
17
|
canonical_boundary:
|
|
17
18
|
host_product_authority: .nimi/spec/**/*.authority.{yaml,md}
|
|
18
19
|
sole_conformance_gate: nimicoding_authority_check_complete_.nimi/spec
|
|
@@ -31,6 +32,8 @@ out_of_scope:
|
|
|
31
32
|
- host_workflow_command_aggregation
|
|
32
33
|
- external_probe_result_attestation_test_execution_or_proof_packet_aggregation
|
|
33
34
|
- sqlite_cache_incremental_embedding_semantic_search_visualization_AI_execution_or_Atlas
|
|
35
|
+
- code_location_inbound_impact_structural_advice_other_semantic_languages_or_task_completeness
|
|
36
|
+
- annotation_coverage_ownership_conformance_inference_or_unannotated_legacy_detection
|
|
34
37
|
claims:
|
|
35
38
|
discovery: bounded_deterministic_exact_filtered_lexical_candidates_with_SourceMapped_field_snippets_and_optional_M1_direct_authored_relation_preview_not_semantic_search_selection_context_or_absence_proof
|
|
36
39
|
change_candidates: complete_union_of_caller_requested_exact_channels_with_raw_fields_modality_and_reasons_not_semantic_relevance_conflict_retirement_absence_or_conformance
|
|
@@ -39,3 +42,5 @@ claims:
|
|
|
39
42
|
graph: complete_bounded_explicit_relation_navigation_not_semantic_inference_or_raw_IR
|
|
40
43
|
audit: configured_graph_and_exact_case_sensitive_lexical_results_not_prose_predicate_inference_semantic_synonym_or_plugin_execution
|
|
41
44
|
review: immutable_base_OID_and_stable_worktree_exact_snapshots_composed_through_existing_compiler_diff_impact_and_current_audit_oracles_with_business_and_implementation_status_not_evaluated
|
|
45
|
+
code_context: complete_selected_TypeScript_Program_root_direct_static_outbound_projection_with_output_budget_and_explicit_frontier_not_location_impact_runtime_dispatch_or_task_context
|
|
46
|
+
code_authority: complete_transient_scan_of_selected_tracked_current_source_scope_for_exact_authored_markers_and_current_canonical_lifecycle_not_attachment_ownership_conformance_or_unannotated_semantics
|