@nimiplatform/nimi-coding 0.2.8 → 0.3.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 +8 -92
- package/CONTRIBUTING.md +5 -34
- package/README.md +47 -350
- package/README.zh-CN.md +33 -287
- package/cli/commands/start.mjs +48 -688
- package/cli/commands/validate-spec-audit.mjs +1 -5
- package/cli/constants.mjs +9 -417
- package/cli/help.mjs +28 -145
- package/cli/index.mjs +5 -33
- package/cli/lib/blueprint-audit.mjs +5 -12
- package/cli/lib/bootstrap.mjs +0 -9
- package/cli/lib/contracts.mjs +0 -163
- package/cli/lib/doctor.mjs +155 -10
- package/cli/lib/entrypoints.mjs +63 -167
- package/cli/lib/internal/contracts-loaders.mjs +0 -85
- package/cli/lib/internal/contracts-parse.mjs +84 -520
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
- package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
- package/cli/lib/internal/validators-shared.mjs +0 -16
- package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
- package/cli/lib/internal/validators-spec.mjs +103 -342
- package/cli/lib/shared.mjs +1 -42
- package/cli/lib/validators.mjs +0 -48
- package/cli/seeds/seed-policy.yaml +0 -3
- package/config/bootstrap.yaml +4 -4
- package/config/spec-generation-inputs.yaml +6 -12
- package/contracts/domain-admission.schema.yaml +3 -3
- package/contracts/migration-inventory.schema.yaml +12 -75
- package/contracts/negative-fixtures.yaml +19 -99
- package/contracts/placement-contract.schema.yaml +49 -78
- package/contracts/projection-edge.schema.yaml +37 -121
- package/contracts/shared-enums.yaml +4 -8
- package/contracts/spec-generation-inputs.schema.yaml +15 -112
- package/contracts/spec-layout.schema.yaml +32 -0
- package/contracts/surface-taxonomy.schema.yaml +43 -94
- package/contracts/table-family.schema.yaml +1 -1
- package/contracts/tracked-output-admission.schema.yaml +13 -66
- package/methodology/core.yaml +33 -25
- package/methodology/four-closure-policy.yaml +18 -26
- package/methodology/role-separation-policy.yaml +21 -27
- package/methodology/spec-reconstruction.yaml +17 -34
- package/package.json +2 -4
- package/spec/_meta/spec-tree-model.yaml +5 -101
- package/spec/product-scope.yaml +25 -57
- package/adapters/README.md +0 -25
- package/adapters/claude/README.md +0 -89
- package/adapters/claude/profile.yaml +0 -70
- package/adapters/codex/README.md +0 -53
- package/adapters/codex/profile.yaml +0 -78
- package/adapters/oh-my-codex/README.md +0 -184
- package/adapters/oh-my-codex/profile.yaml +0 -46
- package/cli/commands/admit-high-risk-decision.mjs +0 -108
- package/cli/commands/audit-sweep.mjs +0 -364
- package/cli/commands/closeout.mjs +0 -186
- package/cli/commands/decide-high-risk-execution.mjs +0 -124
- package/cli/commands/handoff.mjs +0 -123
- package/cli/commands/ingest-high-risk-execution.mjs +0 -95
- package/cli/commands/review-high-risk-execution.mjs +0 -95
- package/cli/commands/sweep-design.mjs +0 -295
- package/cli/commands/sweep.mjs +0 -22
- package/cli/commands/topic-formatters.mjs +0 -382
- package/cli/commands/topic-goal.mjs +0 -33
- package/cli/commands/topic-options-shared.mjs +0 -27
- package/cli/commands/topic-options-workflow.mjs +0 -767
- package/cli/commands/topic-options.mjs +0 -626
- package/cli/commands/topic-runner.mjs +0 -169
- package/cli/commands/topic.mjs +0 -795
- package/cli/commands/validate-acceptance.mjs +0 -5
- package/cli/commands/validate-execution-packet.mjs +0 -5
- package/cli/commands/validate-orchestration-state.mjs +0 -5
- package/cli/commands/validate-prompt.mjs +0 -5
- package/cli/commands/validate-worker-output.mjs +0 -5
- package/cli/lib/adapter-profiles.mjs +0 -403
- package/cli/lib/audit-execution.mjs +0 -52
- package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
- package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
- package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
- package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
- package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
- package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
- package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
- package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
- package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
- package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
- package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
- package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
- package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
- package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
- package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
- package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
- package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
- package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
- package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
- package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
- package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
- package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
- package/cli/lib/audit-sweep.mjs +0 -19
- package/cli/lib/authority-convergence.mjs +0 -720
- package/cli/lib/closeout.mjs +0 -732
- package/cli/lib/codex-sdk-runner.mjs +0 -76
- package/cli/lib/external-execution.mjs +0 -101
- package/cli/lib/handoff.mjs +0 -812
- package/cli/lib/high-risk-admission.mjs +0 -512
- package/cli/lib/high-risk-decision.mjs +0 -353
- package/cli/lib/high-risk-ingest.mjs +0 -321
- package/cli/lib/high-risk-review.mjs +0 -267
- package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
- package/cli/lib/internal/contracts-validators.mjs +0 -399
- package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
- package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
- package/cli/lib/internal/doctor-finalize.mjs +0 -383
- package/cli/lib/internal/doctor-format.mjs +0 -286
- package/cli/lib/internal/doctor-inspectors.mjs +0 -327
- package/cli/lib/internal/doctor-state.mjs +0 -205
- package/cli/lib/internal/validators-artifacts.mjs +0 -515
- package/cli/lib/sweep-design-runtime/common.mjs +0 -246
- package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
- package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
- package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
- package/cli/lib/sweep-design-runtime/results.mjs +0 -324
- package/cli/lib/sweep-design.mjs +0 -8
- package/cli/lib/topic-artifacts.mjs +0 -186
- package/cli/lib/topic-authority-coverage.mjs +0 -73
- package/cli/lib/topic-closeout.mjs +0 -560
- package/cli/lib/topic-common.mjs +0 -404
- package/cli/lib/topic-decisions.mjs +0 -332
- package/cli/lib/topic-draft-packets.mjs +0 -167
- package/cli/lib/topic-execution.mjs +0 -533
- package/cli/lib/topic-goal.mjs +0 -440
- package/cli/lib/topic-ledger.mjs +0 -281
- package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
- package/cli/lib/topic-root-validation.mjs +0 -288
- package/cli/lib/topic-runner-commands.mjs +0 -174
- package/cli/lib/topic-runner-deferral.mjs +0 -532
- package/cli/lib/topic-runner-stale-gates.mjs +0 -114
- package/cli/lib/topic-runner-validation.mjs +0 -138
- package/cli/lib/topic-runner.mjs +0 -727
- package/cli/lib/topic-scaffold.mjs +0 -252
- package/cli/lib/topic-waves.mjs +0 -403
- package/cli/lib/topic.mjs +0 -81
- package/config/audit-execution-artifacts.yaml +0 -20
- package/config/external-execution-artifacts.yaml +0 -16
- package/config/host-adapter.yaml +0 -30
- package/config/host-profile.yaml +0 -29
- package/config/installer-evidence.yaml +0 -31
- package/config/skill-installer.yaml +0 -23
- package/config/skill-manifest.yaml +0 -48
- package/config/skills.yaml +0 -30
- package/contracts/acceptance.schema.yaml +0 -16
- package/contracts/admission-checklist.schema.yaml +0 -15
- package/contracts/audit-chunk.schema.yaml +0 -123
- package/contracts/audit-closeout.schema.yaml +0 -51
- package/contracts/audit-finding.schema.yaml +0 -61
- package/contracts/audit-ledger.schema.yaml +0 -138
- package/contracts/audit-plan.schema.yaml +0 -138
- package/contracts/audit-remediation-map.schema.yaml +0 -52
- package/contracts/audit-rerun.schema.yaml +0 -31
- package/contracts/audit-sweep-result.yaml +0 -53
- package/contracts/authority-convergence-audit.schema.yaml +0 -19
- package/contracts/closeout.schema.yaml +0 -25
- package/contracts/decision-review.schema.yaml +0 -16
- package/contracts/doc-spec-audit-result.yaml +0 -19
- package/contracts/execution-packet.schema.yaml +0 -49
- package/contracts/external-host-compatibility.yaml +0 -22
- package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
- package/contracts/high-risk-admission.schema.yaml +0 -23
- package/contracts/high-risk-execution-result.yaml +0 -20
- package/contracts/orchestration-state.schema.yaml +0 -41
- package/contracts/overflow-continuation.schema.yaml +0 -12
- package/contracts/packet.schema.yaml +0 -30
- package/contracts/pending-note.schema.yaml +0 -17
- package/contracts/prompt.schema.yaml +0 -12
- package/contracts/remediation.schema.yaml +0 -16
- package/contracts/result.schema.yaml +0 -24
- package/contracts/spec-reconstruction-result.yaml +0 -41
- package/contracts/sweep-design-result.yaml +0 -349
- package/contracts/topic-goal.schema.yaml +0 -87
- package/contracts/topic-run-ledger.schema.yaml +0 -72
- package/contracts/topic-step-decision.schema.yaml +0 -45
- package/contracts/topic.schema.yaml +0 -65
- package/contracts/true-close.schema.yaml +0 -15
- package/contracts/wave.schema.yaml +0 -29
- package/contracts/worker-output.schema.yaml +0 -15
- package/contracts/workflow-consumer.schema.yaml +0 -110
- package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
- package/methodology/authority-convergence-policy.yaml +0 -42
- package/methodology/overflow-continuation-policy.yaml +0 -14
- package/methodology/skill-exchange-projection.yaml +0 -114
- package/methodology/skill-handoff.yaml +0 -34
- package/methodology/skill-installer-result.yaml +0 -27
- package/methodology/skill-installer-summary-projection.yaml +0 -181
- package/methodology/skill-runtime.yaml +0 -23
- package/methodology/spec-target-truth-profile.yaml +0 -46
- package/methodology/topic-lifecycle-report.yaml +0 -144
- package/methodology/topic-lifecycle.yaml +0 -37
- package/methodology/topic-naming-ontology.yaml +0 -21
- package/methodology/topic-ontology.yaml +0 -38
- package/methodology/topic-validation-policy.yaml +0 -9
- package/methodology/wave-dag-policy.yaml +0 -14
- package/spec/_meta/command-gating-matrix.yaml +0 -143
- package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
- package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
- package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
- package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
- package/spec/bootstrap-state.yaml +0 -99
package/cli/index.mjs
CHANGED
|
@@ -1,56 +1,31 @@
|
|
|
1
1
|
import { runBlueprintAudit } from "./commands/blueprint-audit.mjs";
|
|
2
|
+
import { runClassifySpecTree } from "./commands/classify-spec-tree.mjs";
|
|
2
3
|
import { runClear } from "./commands/clear.mjs";
|
|
3
|
-
import { runCloseout } from "./commands/closeout.mjs";
|
|
4
|
-
import { runAdmitHighRiskDecision } from "./commands/admit-high-risk-decision.mjs";
|
|
5
|
-
import { runSweep } from "./commands/sweep.mjs";
|
|
6
|
-
import { runDecideHighRiskExecution } from "./commands/decide-high-risk-execution.mjs";
|
|
7
4
|
import { runDoctor } from "./commands/doctor.mjs";
|
|
8
|
-
import { runHandoff } from "./commands/handoff.mjs";
|
|
9
|
-
import { runIngestHighRiskExecution } from "./commands/ingest-high-risk-execution.mjs";
|
|
10
|
-
import { runReviewHighRiskExecution } from "./commands/review-high-risk-execution.mjs";
|
|
11
|
-
import { runStart } from "./commands/start.mjs";
|
|
12
|
-
import { runSync } from "./commands/sync.mjs";
|
|
13
|
-
import { runTopic } from "./commands/topic.mjs";
|
|
14
|
-
import { runTopicRunnerCommand } from "./commands/topic-runner.mjs";
|
|
15
|
-
import { runValidateAcceptance } from "./commands/validate-acceptance.mjs";
|
|
16
5
|
import { runGenerateSpecDerivedDocs } from "./commands/generate-spec-derived-docs.mjs";
|
|
17
6
|
import { runGenerateSpecMigrationPlan } from "./commands/generate-spec-migration-plan.mjs";
|
|
18
|
-
import {
|
|
7
|
+
import { runStart } from "./commands/start.mjs";
|
|
8
|
+
import { runSync } from "./commands/sync.mjs";
|
|
19
9
|
import { runValidateAiGovernance } from "./commands/validate-ai-governance.mjs";
|
|
20
10
|
import { runValidateDomainAdmission } from "./commands/validate-domain-admission.mjs";
|
|
21
|
-
import { runValidateExecutionPacket } from "./commands/validate-execution-packet.mjs";
|
|
22
11
|
import { runValidateGuidanceBodies } from "./commands/validate-guidance-bodies.mjs";
|
|
23
|
-
import { runValidateOrchestrationState } from "./commands/validate-orchestration-state.mjs";
|
|
24
12
|
import { runValidatePlacement } from "./commands/validate-placement.mjs";
|
|
25
13
|
import { runValidateProjectionEdges } from "./commands/validate-projection-edges.mjs";
|
|
26
|
-
import { runValidateSpecGovernance } from "./commands/validate-spec-governance.mjs";
|
|
27
14
|
import { runValidateSpecAudit } from "./commands/validate-spec-audit.mjs";
|
|
15
|
+
import { runValidateSpecGovernance } from "./commands/validate-spec-governance.mjs";
|
|
28
16
|
import { runValidateSpecTree } from "./commands/validate-spec-tree.mjs";
|
|
29
17
|
import { runValidateTableFamily } from "./commands/validate-table-family.mjs";
|
|
30
18
|
import { runValidateTrackedOutputAdmission } from "./commands/validate-tracked-output-admission.mjs";
|
|
31
|
-
import { runValidatePrompt } from "./commands/validate-prompt.mjs";
|
|
32
|
-
import { runValidateWorkerOutput } from "./commands/validate-worker-output.mjs";
|
|
33
19
|
import { helpText } from "./help.mjs";
|
|
34
|
-
import { configureCliUi, localize, parseGlobalUiOptions } from "./lib/ui.mjs";
|
|
35
20
|
import { VERSION } from "./constants.mjs";
|
|
21
|
+
import { configureCliUi, localize, parseGlobalUiOptions } from "./lib/ui.mjs";
|
|
36
22
|
|
|
37
23
|
const COMMANDS = {
|
|
38
24
|
start: runStart,
|
|
39
25
|
sync: runSync,
|
|
40
|
-
topic: runTopic,
|
|
41
|
-
"topic-runner": runTopicRunnerCommand,
|
|
42
26
|
clear: runClear,
|
|
43
27
|
doctor: runDoctor,
|
|
44
28
|
"blueprint-audit": runBlueprintAudit,
|
|
45
|
-
handoff: runHandoff,
|
|
46
|
-
closeout: runCloseout,
|
|
47
|
-
sweep: runSweep,
|
|
48
|
-
"admit-high-risk-decision": runAdmitHighRiskDecision,
|
|
49
|
-
"decide-high-risk-execution": runDecideHighRiskExecution,
|
|
50
|
-
"ingest-high-risk-execution": runIngestHighRiskExecution,
|
|
51
|
-
"review-high-risk-execution": runReviewHighRiskExecution,
|
|
52
|
-
"validate-execution-packet": runValidateExecutionPacket,
|
|
53
|
-
"validate-orchestration-state": runValidateOrchestrationState,
|
|
54
29
|
"validate-spec-governance": runValidateSpecGovernance,
|
|
55
30
|
"validate-spec-audit": runValidateSpecAudit,
|
|
56
31
|
"validate-spec-tree": runValidateSpecTree,
|
|
@@ -64,9 +39,6 @@ const COMMANDS = {
|
|
|
64
39
|
"generate-spec-derived-docs": runGenerateSpecDerivedDocs,
|
|
65
40
|
"generate-spec-migration-plan": runGenerateSpecMigrationPlan,
|
|
66
41
|
"validate-ai-governance": runValidateAiGovernance,
|
|
67
|
-
"validate-prompt": runValidatePrompt,
|
|
68
|
-
"validate-worker-output": runValidateWorkerOutput,
|
|
69
|
-
"validate-acceptance": runValidateAcceptance,
|
|
70
42
|
};
|
|
71
43
|
|
|
72
44
|
export async function runCli(args) {
|
|
@@ -2,7 +2,7 @@ import { mkdir, readFile, readdir, writeFile } from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import YAML from "yaml";
|
|
4
4
|
|
|
5
|
-
import { loadBlueprintReference, loadSpecGenerationInputsConfig
|
|
5
|
+
import { loadBlueprintReference, loadSpecGenerationInputsConfig } from "./contracts.mjs";
|
|
6
6
|
import { pathExists } from "./fs-helpers.mjs";
|
|
7
7
|
import {
|
|
8
8
|
localize,
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
styleStatus,
|
|
12
12
|
} from "./ui.mjs";
|
|
13
13
|
|
|
14
|
-
const BLUEPRINT_AUDIT_CONTRACT_VERSION = "nimicoding.blueprint-audit.
|
|
15
|
-
const DEFAULT_REPORT_PATH = ".nimi/local/
|
|
14
|
+
const BLUEPRINT_AUDIT_CONTRACT_VERSION = "nimicoding.blueprint-audit.v2";
|
|
15
|
+
const DEFAULT_REPORT_PATH = ".nimi/local/state/spec-generation/blueprint-equivalence-audit.json";
|
|
16
16
|
|
|
17
17
|
async function collectFiles(rootPath, relativePrefix = "") {
|
|
18
18
|
const info = await pathExists(rootPath);
|
|
@@ -186,12 +186,11 @@ async function compareRuleIds(blueprintAbsoluteRoot, canonicalAbsoluteRoot, pres
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
export async function buildBlueprintAuditPayload(projectRoot, options = {}) {
|
|
189
|
-
const specTreeModel = await loadSpecTreeModelContract(projectRoot);
|
|
190
189
|
const blueprintReference = await loadBlueprintReference(projectRoot);
|
|
191
190
|
const specGenerationInputs = await loadSpecGenerationInputsConfig(projectRoot);
|
|
192
191
|
|
|
193
192
|
const canonicalRoot = options.canonicalRoot
|
|
194
|
-
??
|
|
193
|
+
?? specGenerationInputs.canonicalTargetRoot
|
|
195
194
|
?? ".nimi/spec";
|
|
196
195
|
const blueprintRoot = options.blueprintRoot
|
|
197
196
|
?? blueprintReference.root
|
|
@@ -246,7 +245,7 @@ export async function buildBlueprintAuditPayload(projectRoot, options = {}) {
|
|
|
246
245
|
const reportPath = path.join(projectRoot, DEFAULT_REPORT_PATH);
|
|
247
246
|
const nextSteps = [];
|
|
248
247
|
if (missingDomains.length > 0 || kernelMarkdown.missing.length > 0 || kernelTables.missing.length > 0 || !indexPresent) {
|
|
249
|
-
nextSteps.push("
|
|
248
|
+
nextSteps.push("Resolve the missing blueprint structure under `/.nimi/spec/**` before claiming equivalence.");
|
|
250
249
|
}
|
|
251
250
|
if (domainGuides.missing.length > 0) {
|
|
252
251
|
nextSteps.push("Thin and map domain guides only after kernel coverage is in place.");
|
|
@@ -263,12 +262,6 @@ export async function buildBlueprintAuditPayload(projectRoot, options = {}) {
|
|
|
263
262
|
blueprintRoot,
|
|
264
263
|
canonicalRoot,
|
|
265
264
|
blueprintReference,
|
|
266
|
-
specTreeModel: {
|
|
267
|
-
ok: specTreeModel.ok,
|
|
268
|
-
profile: specTreeModel.profile,
|
|
269
|
-
canonicalRoot: specTreeModel.canonicalRoot,
|
|
270
|
-
authorityMode: specTreeModel.authorityMode,
|
|
271
|
-
},
|
|
272
265
|
specGenerationInputs: {
|
|
273
266
|
ok: specGenerationInputs.ok,
|
|
274
267
|
mode: specGenerationInputs.mode,
|
package/cli/lib/bootstrap.mjs
CHANGED
|
@@ -189,15 +189,6 @@ export async function inspectBootstrapCompatibility(projectRoot) {
|
|
|
189
189
|
const contractId = readYamlScalar(bootstrapConfigText, "bootstrap_contract");
|
|
190
190
|
const contractVersion = readYamlScalar(bootstrapConfigText, "bootstrap_contract_version");
|
|
191
191
|
|
|
192
|
-
if (!contractId && !contractVersion) {
|
|
193
|
-
return {
|
|
194
|
-
status: initializedBy === PACKAGE_NAME ? "legacy" : "unsupported",
|
|
195
|
-
initializedBy,
|
|
196
|
-
contractId,
|
|
197
|
-
contractVersion,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
192
|
if (initializedBy !== PACKAGE_NAME) {
|
|
202
193
|
return {
|
|
203
194
|
status: "unsupported",
|
package/cli/lib/contracts.mjs
CHANGED
|
@@ -1,52 +1,13 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
|
|
4
1
|
import {
|
|
5
2
|
loadBlueprintReference as loadBlueprintReferenceInternal,
|
|
6
|
-
loadCommandGatingMatrix as loadCommandGatingMatrixInternal,
|
|
7
|
-
loadAuditSweepContract as loadAuditSweepContractInternal,
|
|
8
|
-
loadDocSpecAuditContract as loadDocSpecAuditContractInternal,
|
|
9
|
-
loadExternalHostCompatibilityContract as loadExternalHostCompatibilityContractInternal,
|
|
10
|
-
loadHighRiskAdmissionContract as loadHighRiskAdmissionContractInternal,
|
|
11
|
-
loadHighRiskExecutionContract as loadHighRiskExecutionContractInternal,
|
|
12
|
-
loadHighRiskSchemaContracts as loadHighRiskSchemaContractsInternal,
|
|
13
3
|
loadSpecGenerationAuditContract as loadSpecGenerationAuditContractInternal,
|
|
14
4
|
loadSpecGenerationInputsConfig as loadSpecGenerationInputsConfigInternal,
|
|
15
5
|
loadSpecGenerationInputsContract as loadSpecGenerationInputsContractInternal,
|
|
16
|
-
loadSpecReconstructionContract as loadSpecReconstructionContractInternal,
|
|
17
|
-
loadSpecTreeModelContract as loadSpecTreeModelContractInternal,
|
|
18
6
|
} from "./internal/contracts-loaders.mjs";
|
|
19
|
-
import { readTextIfFile } from "./fs-helpers.mjs";
|
|
20
|
-
import { parseYamlText } from "./yaml-helpers.mjs";
|
|
21
|
-
import { matchCommandGatingRule } from "./internal/contracts-parse.mjs";
|
|
22
|
-
import {
|
|
23
|
-
validateAuditSweepSummary as validateAuditSweepSummaryInternal,
|
|
24
|
-
validateDocSpecAuditSummary as validateDocSpecAuditSummaryInternal,
|
|
25
|
-
validateHighRiskAdmissionRecord as validateHighRiskAdmissionRecordInternal,
|
|
26
|
-
validateHighRiskAdmissionsSpec as validateHighRiskAdmissionsSpecInternal,
|
|
27
|
-
validateHighRiskExecutionSummary as validateHighRiskExecutionSummaryInternal,
|
|
28
|
-
validateSpecReconstructionSummary as validateSpecReconstructionSummaryInternal,
|
|
29
|
-
} from "./internal/contracts-validators.mjs";
|
|
30
|
-
|
|
31
|
-
const PACKAGE_REF_PREFIX = "package://@nimiplatform/nimi-coding/";
|
|
32
|
-
const PACKAGE_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
33
|
-
|
|
34
|
-
export function findCommandGatingRule(commandGatingMatrix, command, skillId = null) {
|
|
35
|
-
return matchCommandGatingRule(commandGatingMatrix, command, skillId);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function loadSpecReconstructionContract(projectRoot) {
|
|
39
|
-
return loadSpecReconstructionContractInternal(projectRoot);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function loadSpecTreeModelContract(projectRoot) {
|
|
43
|
-
return loadSpecTreeModelContractInternal(projectRoot);
|
|
44
|
-
}
|
|
45
7
|
|
|
46
8
|
export function loadSpecGenerationInputsContract(projectRoot) {
|
|
47
9
|
return loadSpecGenerationInputsContractInternal(projectRoot);
|
|
48
10
|
}
|
|
49
|
-
|
|
50
11
|
export function loadSpecGenerationAuditContract(projectRoot) {
|
|
51
12
|
return loadSpecGenerationAuditContractInternal(projectRoot);
|
|
52
13
|
}
|
|
@@ -55,130 +16,6 @@ export function loadSpecGenerationInputsConfig(projectRoot) {
|
|
|
55
16
|
return loadSpecGenerationInputsConfigInternal(projectRoot);
|
|
56
17
|
}
|
|
57
18
|
|
|
58
|
-
export function loadCommandGatingMatrix(projectRoot) {
|
|
59
|
-
return loadCommandGatingMatrixInternal(projectRoot);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
19
|
export function loadBlueprintReference(projectRoot) {
|
|
63
20
|
return loadBlueprintReferenceInternal(projectRoot);
|
|
64
21
|
}
|
|
65
|
-
|
|
66
|
-
export function loadDocSpecAuditContract(projectRoot) {
|
|
67
|
-
return loadDocSpecAuditContractInternal(projectRoot);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function loadAuditSweepContract(projectRoot) {
|
|
71
|
-
return loadAuditSweepContractInternal(projectRoot);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function loadHighRiskExecutionContract(projectRoot) {
|
|
75
|
-
return loadHighRiskExecutionContractInternal(projectRoot);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function loadHighRiskAdmissionContract(projectRoot) {
|
|
79
|
-
return loadHighRiskAdmissionContractInternal(projectRoot);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function loadExternalHostCompatibilityContract(projectRoot) {
|
|
83
|
-
return loadExternalHostCompatibilityContractInternal(projectRoot);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function loadHighRiskSchemaContracts(projectRoot) {
|
|
87
|
-
return loadHighRiskSchemaContractsInternal(projectRoot);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export function validateSpecReconstructionSummary(summary, contract, verifiedAt) {
|
|
91
|
-
return validateSpecReconstructionSummaryInternal(summary, contract, verifiedAt);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function validateDocSpecAuditSummary(summary, contract, verifiedAt) {
|
|
95
|
-
return validateDocSpecAuditSummaryInternal(summary, contract, verifiedAt);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export function validateAuditSweepSummary(summary, contract, verifiedAt) {
|
|
99
|
-
return validateAuditSweepSummaryInternal(summary, contract, verifiedAt);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function validateHighRiskExecutionSummary(summary, contract, verifiedAt) {
|
|
103
|
-
return validateHighRiskExecutionSummaryInternal(summary, contract, verifiedAt);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function validateHighRiskAdmissionRecord(record, contract) {
|
|
107
|
-
return validateHighRiskAdmissionRecordInternal(record, contract);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function validateHighRiskAdmissionsSpec(spec, contract) {
|
|
111
|
-
return validateHighRiskAdmissionsSpecInternal(spec, contract);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async function loadYamlWithFallback(projectRoot, primaryRef, fallbackRef) {
|
|
115
|
-
const primaryText = await readTextIfFile(path.join(projectRoot, primaryRef));
|
|
116
|
-
if (primaryText !== null) {
|
|
117
|
-
return {
|
|
118
|
-
path: primaryRef,
|
|
119
|
-
text: primaryText,
|
|
120
|
-
data: parseYamlText(primaryText),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
const fallbackText = await readTextIfFile(path.join(PACKAGE_ROOT, fallbackRef));
|
|
125
|
-
return {
|
|
126
|
-
path: `${PACKAGE_REF_PREFIX}${fallbackRef}`,
|
|
127
|
-
text: fallbackText,
|
|
128
|
-
data: parseYamlText(fallbackText),
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export async function loadTopicRuntimeContracts(projectRoot) {
|
|
133
|
-
const [
|
|
134
|
-
topicSchema,
|
|
135
|
-
waveSchema,
|
|
136
|
-
packetSchema,
|
|
137
|
-
resultSchema,
|
|
138
|
-
closeoutSchema,
|
|
139
|
-
remediationSchema,
|
|
140
|
-
decisionReviewSchema,
|
|
141
|
-
pendingNoteSchema,
|
|
142
|
-
topicStepDecisionSchema,
|
|
143
|
-
topicRunLedgerSchema,
|
|
144
|
-
forbiddenShortcutsCatalog,
|
|
145
|
-
lifecycleReport,
|
|
146
|
-
fourClosurePolicy,
|
|
147
|
-
validationPolicy,
|
|
148
|
-
authorityConvergencePolicy,
|
|
149
|
-
] = await Promise.all([
|
|
150
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/topic.schema.yaml", "contracts/topic.schema.yaml"),
|
|
151
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/wave.schema.yaml", "contracts/wave.schema.yaml"),
|
|
152
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/packet.schema.yaml", "contracts/packet.schema.yaml"),
|
|
153
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/result.schema.yaml", "contracts/result.schema.yaml"),
|
|
154
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/closeout.schema.yaml", "contracts/closeout.schema.yaml"),
|
|
155
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/remediation.schema.yaml", "contracts/remediation.schema.yaml"),
|
|
156
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/decision-review.schema.yaml", "contracts/decision-review.schema.yaml"),
|
|
157
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/pending-note.schema.yaml", "contracts/pending-note.schema.yaml"),
|
|
158
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/topic-step-decision.schema.yaml", "contracts/topic-step-decision.schema.yaml"),
|
|
159
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/topic-run-ledger.schema.yaml", "contracts/topic-run-ledger.schema.yaml"),
|
|
160
|
-
loadYamlWithFallback(projectRoot, ".nimi/contracts/forbidden-shortcuts.catalog.yaml", "contracts/forbidden-shortcuts.catalog.yaml"),
|
|
161
|
-
loadYamlWithFallback(projectRoot, ".nimi/methodology/topic-lifecycle-report.yaml", "methodology/topic-lifecycle-report.yaml"),
|
|
162
|
-
loadYamlWithFallback(projectRoot, ".nimi/methodology/four-closure-policy.yaml", "methodology/four-closure-policy.yaml"),
|
|
163
|
-
loadYamlWithFallback(projectRoot, ".nimi/methodology/topic-validation-policy.yaml", "methodology/topic-validation-policy.yaml"),
|
|
164
|
-
loadYamlWithFallback(projectRoot, ".nimi/methodology/authority-convergence-policy.yaml", "methodology/authority-convergence-policy.yaml"),
|
|
165
|
-
]);
|
|
166
|
-
|
|
167
|
-
return {
|
|
168
|
-
topicSchema,
|
|
169
|
-
waveSchema,
|
|
170
|
-
packetSchema,
|
|
171
|
-
resultSchema,
|
|
172
|
-
closeoutSchema,
|
|
173
|
-
remediationSchema,
|
|
174
|
-
decisionReviewSchema,
|
|
175
|
-
pendingNoteSchema,
|
|
176
|
-
topicStepDecisionSchema,
|
|
177
|
-
topicRunLedgerSchema,
|
|
178
|
-
forbiddenShortcutsCatalog,
|
|
179
|
-
lifecycleReport,
|
|
180
|
-
fourClosurePolicy,
|
|
181
|
-
validationPolicy,
|
|
182
|
-
authorityConvergencePolicy,
|
|
183
|
-
};
|
|
184
|
-
}
|
package/cli/lib/doctor.mjs
CHANGED
|
@@ -1,18 +1,163 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
import { SPEC_GENERATION_AUDIT_REF } from "../constants.mjs";
|
|
5
|
+
import { getBootstrapSeedEntries } from "../seeds/bootstrap.mjs";
|
|
6
|
+
import { inspectBootstrapCompatibility } from "./bootstrap.mjs";
|
|
7
|
+
import { loadSpecGenerationInputsConfig } from "./contracts.mjs";
|
|
8
|
+
import { pathExists, readTextIfFile } from "./fs-helpers.mjs";
|
|
9
|
+
import { runSeedSync, SYNC_MODE } from "./sync.mjs";
|
|
10
|
+
import { localize, styleHeading, styleLabel, styleStatus } from "./ui.mjs";
|
|
11
|
+
|
|
12
|
+
function check(id, ok, severity, detail) {
|
|
13
|
+
return { id, ok, severity: ok ? "ok" : severity, detail };
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function directoryHasFiles(root) {
|
|
17
|
+
const info = await pathExists(root);
|
|
18
|
+
if (!info || !info.isDirectory()) return false;
|
|
19
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
20
|
+
return entries.length > 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function managedEntrypoints(projectRoot) {
|
|
24
|
+
const refs = [];
|
|
25
|
+
for (const ref of ["AGENTS.md", "CLAUDE.md"]) {
|
|
26
|
+
const text = await readTextIfFile(path.join(projectRoot, ref));
|
|
27
|
+
if (text?.includes("nimicoding:managed:")) refs.push(ref);
|
|
28
|
+
}
|
|
29
|
+
return refs;
|
|
30
|
+
}
|
|
5
31
|
|
|
6
32
|
export async function inspectDoctorState(projectRoot) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
33
|
+
const checks = [];
|
|
34
|
+
const bootstrap = await inspectBootstrapCompatibility(projectRoot);
|
|
35
|
+
checks.push(check(
|
|
36
|
+
"bootstrap_contract",
|
|
37
|
+
bootstrap.status === "supported",
|
|
38
|
+
"error",
|
|
39
|
+
bootstrap.status === "supported"
|
|
40
|
+
? "bootstrap contract is supported"
|
|
41
|
+
: "bootstrap contract is missing or unsupported",
|
|
42
|
+
));
|
|
43
|
+
|
|
44
|
+
let seedSync = null;
|
|
45
|
+
if (bootstrap.status === "supported") {
|
|
46
|
+
seedSync = await runSeedSync(projectRoot, SYNC_MODE.CHECK);
|
|
47
|
+
checks.push(check(
|
|
48
|
+
"managed_projection",
|
|
49
|
+
seedSync.ok,
|
|
50
|
+
"error",
|
|
51
|
+
seedSync.ok
|
|
52
|
+
? `all ${seedSync.summary.total} package-managed files are aligned`
|
|
53
|
+
: `${seedSync.checkFailures.length} package-managed files are missing or drifted`,
|
|
54
|
+
));
|
|
10
55
|
}
|
|
11
56
|
|
|
12
|
-
const
|
|
13
|
-
|
|
57
|
+
const generationInputs = await loadSpecGenerationInputsConfig(projectRoot);
|
|
58
|
+
checks.push(check(
|
|
59
|
+
"spec_generation_inputs",
|
|
60
|
+
generationInputs.ok && generationInputs.mode === "class_filtered",
|
|
61
|
+
"error",
|
|
62
|
+
generationInputs.ok && generationInputs.mode === "class_filtered"
|
|
63
|
+
? "spec generation inputs use class-filtered authority"
|
|
64
|
+
: "spec generation inputs are missing or invalid",
|
|
65
|
+
));
|
|
66
|
+
|
|
67
|
+
const specRoot = path.join(projectRoot, ".nimi", "spec");
|
|
68
|
+
const specPresent = await directoryHasFiles(specRoot);
|
|
69
|
+
checks.push(check(
|
|
70
|
+
"spec_tree",
|
|
71
|
+
true,
|
|
72
|
+
"info",
|
|
73
|
+
specPresent
|
|
74
|
+
? "canonical spec tree is present; conformance is checked by validate-spec-tree or project-specific validators"
|
|
75
|
+
: "canonical spec tree has not been constructed yet",
|
|
76
|
+
));
|
|
77
|
+
|
|
78
|
+
const auditPath = path.join(projectRoot, SPEC_GENERATION_AUDIT_REF);
|
|
79
|
+
const auditPresent = Boolean(await pathExists(auditPath));
|
|
80
|
+
checks.push(check(
|
|
81
|
+
"spec_generation_audit",
|
|
82
|
+
true,
|
|
83
|
+
"info",
|
|
84
|
+
auditPresent
|
|
85
|
+
? "spec generation audit is present; conformance is checked by validate-spec-audit"
|
|
86
|
+
: "spec generation audit is not present",
|
|
87
|
+
));
|
|
88
|
+
|
|
89
|
+
const entrypoints = await managedEntrypoints(projectRoot);
|
|
90
|
+
checks.push(check(
|
|
91
|
+
"entrypoint_integration",
|
|
92
|
+
true,
|
|
93
|
+
"info",
|
|
94
|
+
entrypoints.length > 0
|
|
95
|
+
? `managed methodology guidance is present in ${entrypoints.join(", ")}`
|
|
96
|
+
: "managed methodology guidance is not installed",
|
|
97
|
+
));
|
|
98
|
+
|
|
99
|
+
const seedEntries = await getBootstrapSeedEntries();
|
|
100
|
+
const ok = checks.every((entry) => entry.severity !== "error");
|
|
101
|
+
|
|
102
|
+
return {
|
|
103
|
+
ok,
|
|
104
|
+
projectRoot,
|
|
105
|
+
bootstrap,
|
|
106
|
+
managedProjection: seedSync,
|
|
107
|
+
generationInputs: {
|
|
108
|
+
ok: generationInputs.ok,
|
|
109
|
+
mode: generationInputs.mode ?? null,
|
|
110
|
+
canonicalTargetRoot: generationInputs.canonicalTargetRoot ?? null,
|
|
111
|
+
},
|
|
112
|
+
spec: {
|
|
113
|
+
present: specPresent,
|
|
114
|
+
ok: null,
|
|
115
|
+
summary: null,
|
|
116
|
+
},
|
|
117
|
+
generationAudit: {
|
|
118
|
+
present: auditPresent,
|
|
119
|
+
ok: null,
|
|
120
|
+
summary: null,
|
|
121
|
+
},
|
|
122
|
+
entrypoints,
|
|
123
|
+
managedFileCount: seedEntries.length,
|
|
124
|
+
checks,
|
|
125
|
+
};
|
|
14
126
|
}
|
|
15
127
|
|
|
16
128
|
export function formatDoctorResult(result, options = {}) {
|
|
17
|
-
|
|
129
|
+
const lines = [
|
|
130
|
+
styleHeading(`nimicoding doctor: ${result.projectRoot}`),
|
|
131
|
+
"",
|
|
132
|
+
styleLabel(localize("Summary:", "摘要:")),
|
|
133
|
+
` - ${localize("status", "状态")}: ${styleStatus(result.ok ? "ok" : "needs_attention")}`,
|
|
134
|
+
` - bootstrap: ${result.bootstrap.status}`,
|
|
135
|
+
` - managed_projection: ${result.managedProjection?.ok === true ? "aligned" : "invalid"}`,
|
|
136
|
+
` - spec: ${!result.spec.present ? "not_constructed" : "present_not_validated"}`,
|
|
137
|
+
` - generation_audit: ${!result.generationAudit.present ? "not_present" : "present_not_validated"}`,
|
|
138
|
+
"",
|
|
139
|
+
styleLabel(localize("Checks:", "检查项:")),
|
|
140
|
+
];
|
|
141
|
+
|
|
142
|
+
const visibleChecks = options.verbose
|
|
143
|
+
? result.checks
|
|
144
|
+
: result.checks.filter((entry) => entry.severity !== "ok" || !entry.ok);
|
|
145
|
+
if (visibleChecks.length === 0) {
|
|
146
|
+
lines.push(` - ${localize("No blocking issues found.", "没有发现阻塞问题。")}`);
|
|
147
|
+
} else {
|
|
148
|
+
for (const entry of visibleChecks) {
|
|
149
|
+
const marker = entry.ok ? "info" : entry.severity;
|
|
150
|
+
lines.push(` - [${marker}] ${entry.detail}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!result.spec.present) {
|
|
155
|
+
lines.push(
|
|
156
|
+
"",
|
|
157
|
+
styleLabel(localize("Next:", "下一步:")),
|
|
158
|
+
" - Build canonical product authority under .nimi/spec, then run nimicoding validate-spec-tree.",
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return `${lines.join("\n")}\n`;
|
|
18
163
|
}
|