@nimiplatform/nimi-coding 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +3 -3
- package/README.md +297 -41
- package/README.zh-CN.md +306 -31
- package/bin/nimicoding.mjs +1 -1
- package/cli/commands/authority.mjs +804 -0
- package/cli/commands/clear.mjs +27 -7
- package/cli/commands/doctor.mjs +10 -1
- package/cli/commands/start.mjs +23 -27
- package/cli/commands/sync.mjs +21 -101
- package/cli/constants.mjs +7 -31
- package/cli/dev/check-authority-surface.mjs +182 -0
- package/cli/dev/check-product-conformance.mjs +889 -0
- package/cli/help.mjs +10 -17
- package/cli/index.mjs +6 -47
- package/cli/lib/authority/anchors.mjs +491 -0
- package/cli/lib/authority/audit.mjs +567 -0
- package/cli/lib/authority/change-candidates.mjs +807 -0
- package/cli/lib/authority/closed-sets.mjs +645 -0
- package/cli/lib/authority/compile.mjs +92 -0
- package/cli/lib/authority/compiled-snapshot.mjs +143 -0
- package/cli/lib/authority/consumers.mjs +520 -0
- package/cli/lib/authority/diagnostics.mjs +93 -0
- package/cli/lib/authority/diff.mjs +310 -0
- package/cli/lib/authority/discover.mjs +447 -0
- package/cli/lib/authority/format.mjs +169 -0
- package/cli/lib/authority/git-snapshot.mjs +720 -0
- package/cli/lib/authority/graph.mjs +351 -0
- package/cli/lib/authority/impact.mjs +125 -0
- package/cli/lib/authority/lexicon.mjs +55 -0
- package/cli/lib/authority/query.mjs +162 -0
- package/cli/lib/authority/repository-corpus.mjs +37 -0
- package/cli/lib/authority/repository-inventory.mjs +34 -0
- package/cli/lib/authority/review.mjs +212 -0
- package/cli/lib/authority/sarif.mjs +174 -0
- package/cli/lib/authority/scope-bindings.mjs +225 -0
- package/cli/lib/authority/source-map.mjs +105 -0
- package/cli/lib/authority/source-markdown.mjs +167 -0
- package/cli/lib/authority/source-yaml.mjs +308 -0
- package/cli/lib/authority/surface.mjs +97 -0
- package/cli/lib/authority/terms.mjs +422 -0
- package/cli/lib/authority/tracked-text.mjs +70 -0
- package/cli/lib/authority/validate.mjs +300 -0
- package/cli/lib/bootstrap.mjs +55 -71
- package/cli/lib/doctor.mjs +40 -123
- package/cli/lib/entrypoints.mjs +104 -105
- package/cli/lib/fs-helpers.mjs +139 -15
- package/cli/lib/internal/governance/config.mjs +0 -36
- package/cli/lib/shared.mjs +8 -21
- package/cli/lib/sync.mjs +81 -92
- package/cli/lib/value-helpers.mjs +0 -26
- package/cli/lib/yaml-helpers.mjs +1 -124
- package/cli/seeds/bootstrap.mjs +31 -87
- package/cli/seeds/seed-policy.yaml +9 -63
- package/contracts/authority-scope-bindings.schema.yaml +15 -0
- package/contracts/authority-source.schema.yaml +58 -0
- package/contracts/authority-verifier-bindings.schema.yaml +31 -0
- package/methodology/authority-authoring.yaml +127 -0
- package/methodology/core.yaml +34 -27
- package/package.json +10 -6
- package/spec/authority-anchors.yaml +99 -0
- package/spec/authority-audit.yaml +89 -0
- package/spec/authority-authoring.yaml +137 -0
- package/spec/authority-change-candidates.yaml +146 -0
- package/spec/authority-closed-sets.yaml +65 -0
- package/spec/authority-consumers.yaml +77 -0
- package/spec/authority-context.yaml +50 -0
- package/spec/authority-discovery.yaml +119 -0
- package/spec/authority-graph.yaml +59 -0
- package/spec/authority-impact.yaml +61 -0
- package/spec/authority-review.yaml +71 -0
- package/spec/authority-terms.yaml +63 -0
- package/spec/product-scope.yaml +37 -23
- package/cli/commands/blueprint-audit.mjs +0 -91
- package/cli/commands/classify-spec-tree.mjs +0 -5
- package/cli/commands/generate-spec-derived-docs.mjs +0 -151
- package/cli/commands/generate-spec-migration-plan.mjs +0 -30
- package/cli/commands/surface-validator-command.mjs +0 -49
- package/cli/commands/validate-domain-admission.mjs +0 -5
- package/cli/commands/validate-guidance-bodies.mjs +0 -5
- package/cli/commands/validate-placement.mjs +0 -5
- package/cli/commands/validate-projection-edges.mjs +0 -5
- package/cli/commands/validate-spec-audit.mjs +0 -27
- package/cli/commands/validate-spec-governance.mjs +0 -144
- package/cli/commands/validate-spec-tree.mjs +0 -27
- package/cli/commands/validate-table-family.mjs +0 -5
- package/cli/commands/validate-tracked-output-admission.mjs +0 -5
- package/cli/lib/blueprint-audit.mjs +0 -363
- package/cli/lib/contracts.mjs +0 -21
- package/cli/lib/internal/contracts-loaders.mjs +0 -47
- package/cli/lib/internal/contracts-parse.mjs +0 -192
- package/cli/lib/internal/governance/runner.mjs +0 -35
- package/cli/lib/internal/surface-taxonomy-validators.mjs +0 -1147
- package/cli/lib/internal/validators-shared.mjs +0 -12
- package/cli/lib/internal/validators-spec-helpers.mjs +0 -52
- package/cli/lib/internal/validators-spec.mjs +0 -380
- package/cli/lib/validators.mjs +0 -30
- package/config/bootstrap.yaml +0 -6
- package/config/spec-generation-inputs.yaml +0 -41
- package/contracts/domain-admission.schema.yaml +0 -56
- package/contracts/migration-inventory.schema.yaml +0 -15
- package/contracts/negative-fixtures.yaml +0 -26
- package/contracts/placement-contract.schema.yaml +0 -127
- package/contracts/projection-edge.schema.yaml +0 -46
- package/contracts/shared-enums.yaml +0 -63
- package/contracts/spec-generation-audit.schema.yaml +0 -46
- package/contracts/spec-generation-inputs.schema.yaml +0 -43
- package/contracts/spec-layout.schema.yaml +0 -32
- package/contracts/surface-taxonomy.schema.yaml +0 -139
- package/contracts/table-family.schema.yaml +0 -133
- package/contracts/tracked-output-admission.schema.yaml +0 -17
- package/methodology/four-closure-policy.yaml +0 -20
- package/methodology/role-separation-policy.yaml +0 -22
- package/methodology/spec-reconstruction.yaml +0 -69
- package/spec/_meta/spec-tree-model.yaml +0 -44
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SPEC_GENERATION_AUDIT_COVERAGE_STATUS_ENUM,
|
|
3
|
-
SPEC_GENERATION_AUDIT_REQUIRED_TOP_LEVEL_FIELDS,
|
|
4
|
-
SPEC_GENERATION_AUDIT_SOURCE_BASIS_ENUM,
|
|
5
|
-
} from "../../constants.mjs";
|
|
6
|
-
import { arraysEqual, isPlainObject, toStringArray } from "../value-helpers.mjs";
|
|
7
|
-
import { parseYamlText } from "../yaml-helpers.mjs";
|
|
8
|
-
|
|
9
|
-
const ACCEPTANCE_MODES = [
|
|
10
|
-
"semantic_and_structural_parity_when_blueprint_exists",
|
|
11
|
-
"placement_validity_before_generation",
|
|
12
|
-
];
|
|
13
|
-
const SPEC_GENERATION_INPUT_FIELDS = [
|
|
14
|
-
"mode",
|
|
15
|
-
"canonical_target_root",
|
|
16
|
-
"code_inputs",
|
|
17
|
-
"docs_inputs",
|
|
18
|
-
"structure_inputs",
|
|
19
|
-
"local_inputs",
|
|
20
|
-
"forbidden_source_classes",
|
|
21
|
-
"generation_order",
|
|
22
|
-
"inference_rules",
|
|
23
|
-
"acceptance_mode",
|
|
24
|
-
];
|
|
25
|
-
const SPEC_GENERATION_INPUT_DOCUMENT_FIELDS = [
|
|
26
|
-
"version",
|
|
27
|
-
"contract_ref",
|
|
28
|
-
"spec_generation_inputs",
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
function toStringOrNull(value) {
|
|
32
|
-
return typeof value === "string" ? value : null;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function hasExactFields(value, expectedFields) {
|
|
36
|
-
return isPlainObject(value)
|
|
37
|
-
&& arraysEqual(Object.keys(value).sort(), [...expectedFields].sort());
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function isAllowedAuthorityRoot(root) {
|
|
41
|
-
return typeof root === "string"
|
|
42
|
-
&& (root === ".nimi/spec" || root.startsWith(".nimi/spec/"))
|
|
43
|
-
&& !root.includes("..");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function parseSpecGenerationAuditContract(text) {
|
|
47
|
-
const parsed = parseYamlText(text);
|
|
48
|
-
const requiredTopLevelFields = toStringArray(parsed?.required_top_level_fields);
|
|
49
|
-
const requiredFileEntryFields = toStringArray(parsed?.required_file_entry_fields);
|
|
50
|
-
const sourceBasisEnum = toStringArray(parsed?.source_basis_enum);
|
|
51
|
-
const coverageStatusEnum = toStringArray(parsed?.coverage_status_enum);
|
|
52
|
-
const hardConstraints = toStringArray(parsed?.hard_constraints);
|
|
53
|
-
const expectedTopLevelFields = [
|
|
54
|
-
...SPEC_GENERATION_AUDIT_REQUIRED_TOP_LEVEL_FIELDS.slice(0, 4),
|
|
55
|
-
"placement_report_ref",
|
|
56
|
-
...SPEC_GENERATION_AUDIT_REQUIRED_TOP_LEVEL_FIELDS.slice(4),
|
|
57
|
-
];
|
|
58
|
-
const expectedFileEntryFields = [
|
|
59
|
-
"canonical_path",
|
|
60
|
-
"surface_class",
|
|
61
|
-
"source_refs",
|
|
62
|
-
"source_basis",
|
|
63
|
-
"coverage_status",
|
|
64
|
-
"unresolved_items",
|
|
65
|
-
];
|
|
66
|
-
|
|
67
|
-
return {
|
|
68
|
-
ok: parsed?.version === 2
|
|
69
|
-
&& String(parsed?.audit_contract?.id ?? "") === "canonical_spec_generation_audit"
|
|
70
|
-
&& String(parsed?.audit_contract?.target_ref ?? "") === ".nimi/local/state/spec-generation/spec-generation-audit.yaml"
|
|
71
|
-
&& arraysEqual(requiredTopLevelFields, expectedTopLevelFields)
|
|
72
|
-
&& arraysEqual(requiredFileEntryFields, expectedFileEntryFields)
|
|
73
|
-
&& arraysEqual(sourceBasisEnum, SPEC_GENERATION_AUDIT_SOURCE_BASIS_ENUM)
|
|
74
|
-
&& arraysEqual(coverageStatusEnum, SPEC_GENERATION_AUDIT_COVERAGE_STATUS_ENUM)
|
|
75
|
-
&& hardConstraints.includes("every_generated_canonical_file_requires_a_matching_audit_entry")
|
|
76
|
-
&& hardConstraints.includes("required_canonical_files_must_not_be_placeholder_not_allowed")
|
|
77
|
-
&& hardConstraints.includes("unresolved_or_inferred_content_must_be_explicit")
|
|
78
|
-
&& hardConstraints.includes("source_refs_must_stay_within_class_filtered_declared_inputs")
|
|
79
|
-
&& hardConstraints.includes("no_empty_success_looking_audit_entries"),
|
|
80
|
-
requiredTopLevelFields,
|
|
81
|
-
requiredFileEntryFields,
|
|
82
|
-
sourceBasisEnum,
|
|
83
|
-
coverageStatusEnum,
|
|
84
|
-
hardConstraints,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function parseSpecGenerationInputsContract(text) {
|
|
89
|
-
const parsed = parseYamlText(text);
|
|
90
|
-
const contract = parsed?.input_contract;
|
|
91
|
-
const requiredFields = toStringArray(parsed?.required_fields);
|
|
92
|
-
const generationOrderEnum = toStringArray(parsed?.generation_order_enum);
|
|
93
|
-
const hardConstraints = toStringArray(parsed?.hard_constraints);
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
ok: parsed?.version === 3
|
|
97
|
-
&& String(contract?.id ?? "") === "canonical_spec_generation_inputs"
|
|
98
|
-
&& String(contract?.owner ?? "") === "nimi-coding"
|
|
99
|
-
&& arraysEqual(toStringArray(parsed?.mode_enum), ["class_filtered"])
|
|
100
|
-
&& arraysEqual(requiredFields, SPEC_GENERATION_INPUT_FIELDS)
|
|
101
|
-
&& generationOrderEnum.includes("classify_inputs")
|
|
102
|
-
&& generationOrderEnum.includes("validate_placement")
|
|
103
|
-
&& hardConstraints.includes("docs_roots_blanket_ingestion_is_forbidden")
|
|
104
|
-
&& hardConstraints.includes("each_input_file_must_have_an_accepted_surface_class_before_render"),
|
|
105
|
-
requiredFields,
|
|
106
|
-
generationOrderEnum,
|
|
107
|
-
hardConstraints,
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function parseSpecGenerationInputsConfig(text) {
|
|
112
|
-
const parsed = parseYamlText(text);
|
|
113
|
-
const config = parsed?.spec_generation_inputs;
|
|
114
|
-
const codeInputs = Array.isArray(config?.code_inputs) ? config.code_inputs : [];
|
|
115
|
-
const docsInputs = Array.isArray(config?.docs_inputs) ? config.docs_inputs : [];
|
|
116
|
-
const structureInputs = Array.isArray(config?.structure_inputs) ? config.structure_inputs : [];
|
|
117
|
-
const localInputs = Array.isArray(config?.local_inputs) ? config.local_inputs : [];
|
|
118
|
-
const forbiddenSourceClasses = toStringArray(config?.forbidden_source_classes);
|
|
119
|
-
const generationOrder = toStringArray(config?.generation_order);
|
|
120
|
-
const inferenceRules = toStringArray(config?.inference_rules);
|
|
121
|
-
const acceptanceMode = toStringOrNull(config?.acceptance_mode);
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
ok: hasExactFields(parsed, SPEC_GENERATION_INPUT_DOCUMENT_FIELDS)
|
|
125
|
-
&& hasExactFields(config, SPEC_GENERATION_INPUT_FIELDS)
|
|
126
|
-
&& parsed.version === 3
|
|
127
|
-
&& String(parsed?.contract_ref ?? "") === ".nimi/contracts/spec-generation-inputs.schema.yaml"
|
|
128
|
-
&& config?.mode === "class_filtered"
|
|
129
|
-
&& config?.canonical_target_root === ".nimi/spec"
|
|
130
|
-
&& docsInputs.length > 0
|
|
131
|
-
&& docsInputs.every((entry) => isPlainObject(entry)
|
|
132
|
-
&& isAllowedAuthorityRoot(entry.root)
|
|
133
|
-
&& Array.isArray(entry.allowed_surface_classes)
|
|
134
|
-
&& Array.isArray(entry.forbidden_surface_classes)
|
|
135
|
-
&& entry.use_as_authority === true)
|
|
136
|
-
&& Array.isArray(codeInputs)
|
|
137
|
-
&& Array.isArray(structureInputs)
|
|
138
|
-
&& Array.isArray(localInputs)
|
|
139
|
-
&& forbiddenSourceClasses.length > 0
|
|
140
|
-
&& generationOrder.includes("classify_inputs")
|
|
141
|
-
&& generationOrder.includes("validate_placement")
|
|
142
|
-
&& inferenceRules.includes("no_blanket_docs_roots")
|
|
143
|
-
&& ACCEPTANCE_MODES.includes(acceptanceMode),
|
|
144
|
-
mode: toStringOrNull(config?.mode),
|
|
145
|
-
canonicalTargetRoot: toStringOrNull(config?.canonical_target_root),
|
|
146
|
-
codeRoots: codeInputs.map((entry) => String(entry?.root ?? "")).filter(Boolean),
|
|
147
|
-
docsRoots: docsInputs.map((entry) => String(entry?.root ?? "")).filter(Boolean),
|
|
148
|
-
structureRoots: structureInputs.map((entry) => String(entry?.root ?? "")).filter(Boolean),
|
|
149
|
-
localRoots: localInputs.map((entry) => String(entry?.root ?? "")).filter(Boolean),
|
|
150
|
-
humanNotePaths: [],
|
|
151
|
-
benchmarkBlueprintRoot: null,
|
|
152
|
-
benchmarkMode: "none",
|
|
153
|
-
acceptanceMode,
|
|
154
|
-
generationOrder,
|
|
155
|
-
inferenceRules,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function parseBlueprintReference(text) {
|
|
160
|
-
if (!text) {
|
|
161
|
-
return {
|
|
162
|
-
ok: true,
|
|
163
|
-
present: false,
|
|
164
|
-
mode: null,
|
|
165
|
-
root: null,
|
|
166
|
-
canonicalTargetRoot: null,
|
|
167
|
-
equivalenceContractRef: null,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const parsed = parseYamlText(text);
|
|
172
|
-
const reference = parsed?.blueprint_reference;
|
|
173
|
-
const mode = toStringOrNull(reference?.mode);
|
|
174
|
-
const root = toStringOrNull(reference?.root);
|
|
175
|
-
const canonicalTargetRoot = toStringOrNull(reference?.canonical_target_root);
|
|
176
|
-
const equivalenceContractRef = toStringOrNull(reference?.equivalence_contract_ref);
|
|
177
|
-
const localRefValid = equivalenceContractRef === null
|
|
178
|
-
|| (equivalenceContractRef.startsWith(".nimi/local/") && !equivalenceContractRef.includes(".."));
|
|
179
|
-
|
|
180
|
-
return {
|
|
181
|
-
ok: parsed?.version === 2
|
|
182
|
-
&& ["repo_spec_blueprint", "custom_blueprint"].includes(mode)
|
|
183
|
-
&& typeof root === "string"
|
|
184
|
-
&& canonicalTargetRoot === ".nimi/spec"
|
|
185
|
-
&& localRefValid,
|
|
186
|
-
present: true,
|
|
187
|
-
mode,
|
|
188
|
-
root,
|
|
189
|
-
canonicalTargetRoot,
|
|
190
|
-
equivalenceContractRef,
|
|
191
|
-
};
|
|
192
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { spawnSync } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
export function runNodeScript(scriptPath, args = [], options = {}) {
|
|
4
|
-
const result = spawnSync(process.execPath, [scriptPath, ...args], {
|
|
5
|
-
cwd: options.cwd ?? process.cwd(),
|
|
6
|
-
env: { ...process.env, ...(options.env ?? {}) },
|
|
7
|
-
stdio: "pipe",
|
|
8
|
-
encoding: "utf8",
|
|
9
|
-
shell: false,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
ok: result.status === 0,
|
|
14
|
-
exitCode: result.status ?? 1,
|
|
15
|
-
stdout: result.stdout || "",
|
|
16
|
-
stderr: result.stderr || "",
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function runCommand(command, options = {}) {
|
|
21
|
-
const result = spawnSync(command, {
|
|
22
|
-
cwd: options.cwd ?? process.cwd(),
|
|
23
|
-
env: { ...process.env, ...(options.env ?? {}) },
|
|
24
|
-
stdio: "pipe",
|
|
25
|
-
encoding: "utf8",
|
|
26
|
-
shell: true,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
return {
|
|
30
|
-
ok: result.status === 0,
|
|
31
|
-
exitCode: result.status ?? 1,
|
|
32
|
-
stdout: result.stdout || "",
|
|
33
|
-
stderr: result.stderr || "",
|
|
34
|
-
};
|
|
35
|
-
}
|