@nimiplatform/nimi-coding 0.2.7 → 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.
Files changed (207) hide show
  1. package/CHANGELOG.md +8 -80
  2. package/CONTRIBUTING.md +5 -34
  3. package/README.md +47 -350
  4. package/README.zh-CN.md +33 -287
  5. package/cli/commands/start.mjs +48 -688
  6. package/cli/commands/validate-spec-audit.mjs +1 -5
  7. package/cli/constants.mjs +9 -417
  8. package/cli/dev/run-cli-smoke.mjs +24 -0
  9. package/cli/dev/run-suite.mjs +17 -0
  10. package/cli/help.mjs +28 -145
  11. package/cli/index.mjs +5 -33
  12. package/cli/lib/blueprint-audit.mjs +5 -12
  13. package/cli/lib/bootstrap.mjs +0 -9
  14. package/cli/lib/contracts.mjs +0 -163
  15. package/cli/lib/doctor.mjs +155 -10
  16. package/cli/lib/entrypoints.mjs +63 -167
  17. package/cli/lib/internal/contracts-loaders.mjs +0 -85
  18. package/cli/lib/internal/contracts-parse.mjs +84 -520
  19. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
  20. package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
  21. package/cli/lib/internal/validators-shared.mjs +0 -16
  22. package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
  23. package/cli/lib/internal/validators-spec.mjs +103 -342
  24. package/cli/lib/shared.mjs +1 -42
  25. package/cli/lib/validators.mjs +0 -48
  26. package/cli/seeds/seed-policy.yaml +0 -3
  27. package/config/bootstrap.yaml +4 -4
  28. package/config/spec-generation-inputs.yaml +6 -12
  29. package/contracts/domain-admission.schema.yaml +3 -3
  30. package/contracts/migration-inventory.schema.yaml +12 -75
  31. package/contracts/negative-fixtures.yaml +19 -99
  32. package/contracts/placement-contract.schema.yaml +49 -78
  33. package/contracts/projection-edge.schema.yaml +37 -121
  34. package/contracts/shared-enums.yaml +4 -8
  35. package/contracts/spec-generation-inputs.schema.yaml +15 -112
  36. package/contracts/spec-layout.schema.yaml +32 -0
  37. package/contracts/surface-taxonomy.schema.yaml +43 -94
  38. package/contracts/table-family.schema.yaml +1 -1
  39. package/contracts/tracked-output-admission.schema.yaml +13 -66
  40. package/methodology/core.yaml +33 -25
  41. package/methodology/four-closure-policy.yaml +18 -26
  42. package/methodology/role-separation-policy.yaml +21 -27
  43. package/methodology/spec-reconstruction.yaml +17 -34
  44. package/package.json +4 -6
  45. package/spec/_meta/spec-tree-model.yaml +5 -101
  46. package/spec/product-scope.yaml +25 -57
  47. package/adapters/README.md +0 -25
  48. package/adapters/claude/README.md +0 -89
  49. package/adapters/claude/profile.yaml +0 -70
  50. package/adapters/codex/README.md +0 -53
  51. package/adapters/codex/profile.yaml +0 -78
  52. package/adapters/oh-my-codex/README.md +0 -184
  53. package/adapters/oh-my-codex/profile.yaml +0 -46
  54. package/cli/commands/admit-high-risk-decision.mjs +0 -108
  55. package/cli/commands/audit-sweep.mjs +0 -364
  56. package/cli/commands/closeout.mjs +0 -186
  57. package/cli/commands/decide-high-risk-execution.mjs +0 -124
  58. package/cli/commands/handoff.mjs +0 -123
  59. package/cli/commands/ingest-high-risk-execution.mjs +0 -95
  60. package/cli/commands/review-high-risk-execution.mjs +0 -95
  61. package/cli/commands/sweep-design.mjs +0 -295
  62. package/cli/commands/sweep.mjs +0 -22
  63. package/cli/commands/topic-formatters.mjs +0 -382
  64. package/cli/commands/topic-goal.mjs +0 -33
  65. package/cli/commands/topic-options-shared.mjs +0 -27
  66. package/cli/commands/topic-options-workflow.mjs +0 -767
  67. package/cli/commands/topic-options.mjs +0 -626
  68. package/cli/commands/topic-runner.mjs +0 -169
  69. package/cli/commands/topic.mjs +0 -795
  70. package/cli/commands/validate-acceptance.mjs +0 -5
  71. package/cli/commands/validate-execution-packet.mjs +0 -5
  72. package/cli/commands/validate-orchestration-state.mjs +0 -5
  73. package/cli/commands/validate-prompt.mjs +0 -5
  74. package/cli/commands/validate-worker-output.mjs +0 -5
  75. package/cli/lib/adapter-profiles.mjs +0 -403
  76. package/cli/lib/audit-execution.mjs +0 -52
  77. package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
  78. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
  79. package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
  80. package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -647
  81. package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
  82. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
  83. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -516
  84. package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
  85. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
  86. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
  87. package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
  88. package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
  89. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
  90. package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
  91. package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
  92. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
  93. package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
  94. package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
  95. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
  96. package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
  97. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
  98. package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
  99. package/cli/lib/audit-sweep.mjs +0 -19
  100. package/cli/lib/authority-convergence.mjs +0 -704
  101. package/cli/lib/closeout.mjs +0 -732
  102. package/cli/lib/codex-sdk-runner.mjs +0 -76
  103. package/cli/lib/external-execution.mjs +0 -101
  104. package/cli/lib/handoff.mjs +0 -812
  105. package/cli/lib/high-risk-admission.mjs +0 -512
  106. package/cli/lib/high-risk-decision.mjs +0 -353
  107. package/cli/lib/high-risk-ingest.mjs +0 -321
  108. package/cli/lib/high-risk-review.mjs +0 -267
  109. package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
  110. package/cli/lib/internal/contracts-validators.mjs +0 -399
  111. package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
  112. package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
  113. package/cli/lib/internal/doctor-finalize.mjs +0 -383
  114. package/cli/lib/internal/doctor-format.mjs +0 -286
  115. package/cli/lib/internal/doctor-inspectors.mjs +0 -327
  116. package/cli/lib/internal/doctor-state.mjs +0 -205
  117. package/cli/lib/internal/validators-artifacts.mjs +0 -515
  118. package/cli/lib/sweep-design-runtime/common.mjs +0 -246
  119. package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
  120. package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
  121. package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
  122. package/cli/lib/sweep-design-runtime/results.mjs +0 -324
  123. package/cli/lib/sweep-design.mjs +0 -8
  124. package/cli/lib/topic-artifacts.mjs +0 -186
  125. package/cli/lib/topic-authority-coverage.mjs +0 -73
  126. package/cli/lib/topic-closeout.mjs +0 -560
  127. package/cli/lib/topic-common.mjs +0 -404
  128. package/cli/lib/topic-decisions.mjs +0 -332
  129. package/cli/lib/topic-draft-packets.mjs +0 -167
  130. package/cli/lib/topic-execution.mjs +0 -515
  131. package/cli/lib/topic-goal.mjs +0 -440
  132. package/cli/lib/topic-ledger.mjs +0 -281
  133. package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
  134. package/cli/lib/topic-root-validation.mjs +0 -288
  135. package/cli/lib/topic-runner-commands.mjs +0 -174
  136. package/cli/lib/topic-runner-deferral.mjs +0 -532
  137. package/cli/lib/topic-runner-stale-gates.mjs +0 -114
  138. package/cli/lib/topic-runner-validation.mjs +0 -138
  139. package/cli/lib/topic-runner.mjs +0 -727
  140. package/cli/lib/topic-scaffold.mjs +0 -252
  141. package/cli/lib/topic-waves.mjs +0 -403
  142. package/cli/lib/topic.mjs +0 -81
  143. package/config/audit-execution-artifacts.yaml +0 -20
  144. package/config/external-execution-artifacts.yaml +0 -16
  145. package/config/host-adapter.yaml +0 -30
  146. package/config/host-profile.yaml +0 -29
  147. package/config/installer-evidence.yaml +0 -31
  148. package/config/skill-installer.yaml +0 -23
  149. package/config/skill-manifest.yaml +0 -48
  150. package/config/skills.yaml +0 -30
  151. package/contracts/acceptance.schema.yaml +0 -16
  152. package/contracts/admission-checklist.schema.yaml +0 -15
  153. package/contracts/audit-chunk.schema.yaml +0 -123
  154. package/contracts/audit-closeout.schema.yaml +0 -51
  155. package/contracts/audit-finding.schema.yaml +0 -61
  156. package/contracts/audit-ledger.schema.yaml +0 -138
  157. package/contracts/audit-plan.schema.yaml +0 -138
  158. package/contracts/audit-remediation-map.schema.yaml +0 -52
  159. package/contracts/audit-rerun.schema.yaml +0 -31
  160. package/contracts/audit-sweep-result.yaml +0 -53
  161. package/contracts/authority-convergence-audit.schema.yaml +0 -19
  162. package/contracts/closeout.schema.yaml +0 -25
  163. package/contracts/decision-review.schema.yaml +0 -16
  164. package/contracts/doc-spec-audit-result.yaml +0 -19
  165. package/contracts/execution-packet.schema.yaml +0 -49
  166. package/contracts/external-host-compatibility.yaml +0 -22
  167. package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
  168. package/contracts/high-risk-admission.schema.yaml +0 -23
  169. package/contracts/high-risk-execution-result.yaml +0 -20
  170. package/contracts/orchestration-state.schema.yaml +0 -41
  171. package/contracts/overflow-continuation.schema.yaml +0 -12
  172. package/contracts/packet.schema.yaml +0 -30
  173. package/contracts/pending-note.schema.yaml +0 -17
  174. package/contracts/prompt.schema.yaml +0 -12
  175. package/contracts/remediation.schema.yaml +0 -16
  176. package/contracts/result.schema.yaml +0 -24
  177. package/contracts/spec-reconstruction-result.yaml +0 -41
  178. package/contracts/sweep-design-result.yaml +0 -349
  179. package/contracts/topic-goal.schema.yaml +0 -87
  180. package/contracts/topic-run-ledger.schema.yaml +0 -72
  181. package/contracts/topic-step-decision.schema.yaml +0 -45
  182. package/contracts/topic.schema.yaml +0 -65
  183. package/contracts/true-close.schema.yaml +0 -15
  184. package/contracts/wave.schema.yaml +0 -29
  185. package/contracts/worker-output.schema.yaml +0 -15
  186. package/contracts/workflow-consumer.schema.yaml +0 -110
  187. package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
  188. package/methodology/authority-convergence-policy.yaml +0 -42
  189. package/methodology/overflow-continuation-policy.yaml +0 -14
  190. package/methodology/skill-exchange-projection.yaml +0 -114
  191. package/methodology/skill-handoff.yaml +0 -34
  192. package/methodology/skill-installer-result.yaml +0 -27
  193. package/methodology/skill-installer-summary-projection.yaml +0 -181
  194. package/methodology/skill-runtime.yaml +0 -23
  195. package/methodology/spec-target-truth-profile.yaml +0 -46
  196. package/methodology/topic-lifecycle-report.yaml +0 -144
  197. package/methodology/topic-lifecycle.yaml +0 -37
  198. package/methodology/topic-naming-ontology.yaml +0 -21
  199. package/methodology/topic-ontology.yaml +0 -38
  200. package/methodology/topic-validation-policy.yaml +0 -9
  201. package/methodology/wave-dag-policy.yaml +0 -14
  202. package/spec/_meta/command-gating-matrix.yaml +0 -143
  203. package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
  204. package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
  205. package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
  206. package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
  207. package/spec/bootstrap-state.yaml +0 -99
@@ -1,383 +0,0 @@
1
- import path from "node:path";
2
- import { realpath } from "node:fs/promises";
3
- import { fileURLToPath } from "node:url";
4
-
5
- import {
6
- AGENTS_BEGIN,
7
- AUDIT_SWEEP_RESULT_CONTRACT_REF,
8
- CLAUDE_BEGIN,
9
- EXTERNAL_HOST_COMPATIBILITY_CONTRACT_REF,
10
- HIGH_RISK_ADMISSION_CONTRACT_REF,
11
- STANDALONE_COMPLETION_STATUS,
12
- } from "../../constants.mjs";
13
- import {
14
- loadAdmittedAdapterProfiles,
15
- selectAdapterProfile,
16
- } from "../adapter-profiles.mjs";
17
- import {
18
- loadAuditSweepContract,
19
- loadDocSpecAuditContract,
20
- loadExternalHostCompatibilityContract,
21
- loadHighRiskAdmissionContract,
22
- loadHighRiskExecutionContract,
23
- loadHighRiskSchemaContracts,
24
- loadSpecReconstructionContract,
25
- } from "../contracts.mjs";
26
- import { loadAuditExecutionArtifactsConfig } from "../audit-execution.mjs";
27
- import { loadExternalExecutionArtifactsConfig } from "../external-execution.mjs";
28
- import { readTextIfFile } from "../fs-helpers.mjs";
29
- import { buildCheck } from "./doctor-state.mjs";
30
- import {
31
- buildHostCompatibilityReport,
32
- inspectLocalDocSpecAuditArtifact,
33
- inspectPackageBoundaryTruth,
34
- } from "./doctor-inspectors.mjs";
35
-
36
- const PACKAGE_REPO_ROOT = fileURLToPath(new URL("../../..", import.meta.url));
37
-
38
- function deriveV2LifecycleState(bootstrapSurface) {
39
- const treeReady = bootstrapSurface.canonicalTree.requiredFilesValid === true;
40
- const benchmarkMode = bootstrapSurface.specGenerationInputs?.benchmarkMode
41
- ?? bootstrapSurface.blueprintReference?.mode
42
- ?? "none";
43
-
44
- return {
45
- mode: "class_filtered",
46
- treeState: treeReady ? "canonical_tree_ready" : "canonical_tree_in_progress",
47
- authorityMode: "surface_class_validated",
48
- blueprintMode: benchmarkMode,
49
- reconstructionRequired: !treeReady,
50
- readyForAiReconstruction: !treeReady,
51
- cutoverReadiness: {},
52
- activeAuthorityRoot: bootstrapSurface.specGenerationInputs?.canonicalTargetRoot ?? ".nimi/spec",
53
- };
54
- }
55
-
56
- export async function finalizeDoctorState(projectRoot, bootstrapSurface, delegatedSurface) {
57
- const checks = [...bootstrapSurface.checks, ...delegatedSurface.checks];
58
- const usesV2SurfaceModel = bootstrapSurface.specGenerationInputs?.mode === "class_filtered";
59
-
60
- const specContract = await loadSpecReconstructionContract(projectRoot);
61
- const auditContract = await loadDocSpecAuditContract(projectRoot);
62
- const auditSweepContract = await loadAuditSweepContract(projectRoot);
63
- const externalHostCompatibilityContract = await loadExternalHostCompatibilityContract(projectRoot);
64
- const highRiskExecutionContract = await loadHighRiskExecutionContract(projectRoot);
65
- const highRiskAdmissionContract = await loadHighRiskAdmissionContract(projectRoot);
66
- const auditExecutionArtifacts = await loadAuditExecutionArtifactsConfig(projectRoot);
67
- const externalExecutionArtifacts = await loadExternalExecutionArtifactsConfig(projectRoot);
68
- const highRiskSchemaContracts = await loadHighRiskSchemaContracts(projectRoot);
69
- checks.push(
70
- buildCheck(
71
- "spec_reconstruction_result_contract",
72
- specContract.ok,
73
- specContract.ok
74
- ? "spec-reconstruction result contract is present and structurally valid"
75
- : "spec-reconstruction result contract is missing or malformed",
76
- ),
77
- );
78
- checks.push(
79
- buildCheck(
80
- "doc_spec_audit_result_contract",
81
- auditContract.ok,
82
- auditContract.ok
83
- ? "doc-spec-audit result contract is present and structurally valid"
84
- : "doc-spec-audit result contract is missing or malformed",
85
- ),
86
- );
87
- checks.push(
88
- buildCheck(
89
- "audit_sweep_result_contract",
90
- auditSweepContract.ok,
91
- auditSweepContract.ok
92
- ? "audit-sweep result contract is present and structurally valid"
93
- : `${AUDIT_SWEEP_RESULT_CONTRACT_REF} is missing or malformed`,
94
- ),
95
- );
96
- checks.push(
97
- buildCheck(
98
- "external_host_compatibility_contract",
99
- externalHostCompatibilityContract.ok,
100
- externalHostCompatibilityContract.ok
101
- ? "Packaged external host compatibility contract is present and aligned"
102
- : `${EXTERNAL_HOST_COMPATIBILITY_CONTRACT_REF} is missing or malformed`,
103
- ),
104
- );
105
- checks.push(
106
- buildCheck(
107
- "high_risk_execution_result_contract",
108
- highRiskExecutionContract.ok,
109
- highRiskExecutionContract.ok
110
- ? "high-risk-execution result contract is present and structurally valid"
111
- : "high-risk-execution result contract is missing or malformed",
112
- ),
113
- );
114
- checks.push(
115
- buildCheck(
116
- "high_risk_admission_contract",
117
- highRiskAdmissionContract.ok,
118
- highRiskAdmissionContract.ok
119
- ? "Packaged high-risk admission schema contract is present and aligned"
120
- : `${HIGH_RISK_ADMISSION_CONTRACT_REF} is missing or malformed`,
121
- ),
122
- );
123
- checks.push(
124
- buildCheck(
125
- "audit_execution_artifacts_contract",
126
- auditExecutionArtifacts.ok,
127
- auditExecutionArtifacts.ok
128
- ? "audit execution artifact landing-path contract is present and structurally valid"
129
- : "audit execution artifact landing-path contract is missing or malformed",
130
- ),
131
- );
132
- checks.push(
133
- buildCheck(
134
- "external_execution_artifacts_contract",
135
- externalExecutionArtifacts.ok,
136
- externalExecutionArtifacts.ok
137
- ? "external execution artifact landing-path contract is present and structurally valid"
138
- : "external execution artifact landing-path contract is missing or malformed",
139
- ),
140
- );
141
- checks.push(
142
- buildCheck(
143
- "high_risk_schema_contracts",
144
- highRiskSchemaContracts.every((entry) => entry.ok),
145
- highRiskSchemaContracts.every((entry) => entry.ok)
146
- ? "High-risk execution schema seeds are present and structurally valid"
147
- : `High-risk execution schema seeds are missing or malformed: ${highRiskSchemaContracts.filter((entry) => !entry.ok).map((entry) => entry.path).join(", ")}`,
148
- ),
149
- );
150
-
151
- const adapterProfiles = await loadAdmittedAdapterProfiles(delegatedSurface.admittedAdapterIds);
152
- adapterProfiles.selected = selectAdapterProfile(adapterProfiles, delegatedSurface.selectedAdapterId);
153
- const adapterProfilesValid = adapterProfiles.invalid.length === 0;
154
- checks.push(
155
- buildCheck(
156
- "adapter_profile_overlays",
157
- adapterProfilesValid,
158
- adapterProfilesValid
159
- ? adapterProfiles.admitted.length === 0
160
- ? "No package-owned adapter profile overlays are currently admitted"
161
- : `Package-owned adapter profile overlays are present and valid: ${adapterProfiles.admitted.map((profile) => profile.id).join(", ")}`
162
- : `Package-owned adapter profile overlays are missing or malformed: ${adapterProfiles.invalid.map((profile) => `${profile.id} -> ${profile.reason}`).join(", ")}`,
163
- ),
164
- );
165
-
166
- const lifecycleAligned = usesV2SurfaceModel || (
167
- bootstrapSurface.bootstrapStateContract.treeState === "bootstrap_only"
168
- && bootstrapSurface.canonicalTree.ready === false
169
- ) || (
170
- bootstrapSurface.bootstrapStateContract.treeState === "spec_tree_seeded"
171
- && bootstrapSurface.canonicalTree.ready === false
172
- ) || (
173
- bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_in_progress"
174
- && bootstrapSurface.canonicalTree.ready === false
175
- ) || (
176
- bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_ready"
177
- && bootstrapSurface.canonicalTree.requiredFilesValid === true
178
- );
179
- checks.push(
180
- buildCheck(
181
- "bootstrap_lifecycle_alignment",
182
- lifecycleAligned,
183
- usesV2SurfaceModel
184
- ? "v2 host-local surface model does not require bootstrap-state lifecycle alignment"
185
- : lifecycleAligned
186
- ? `bootstrap-state lifecycle ${bootstrapSurface.bootstrapStateContract.treeState ?? "unknown"} is aligned with the current canonical tree readiness`
187
- : bootstrapSurface.bootstrapStateContract.treeState === "canonical_tree_ready"
188
- ? "bootstrap-state declares canonical_tree_ready but required canonical files are still missing"
189
- : "bootstrap-state lifecycle drifted away from the current canonical tree readiness",
190
- ),
191
- );
192
-
193
- const auditArtifact = await inspectLocalDocSpecAuditArtifact(projectRoot, auditContract);
194
- checks.push({
195
- id: "doc_spec_audit_artifact",
196
- ok: !auditArtifact.present || auditArtifact.ok,
197
- severity: !auditArtifact.present ? "info" : auditArtifact.ok ? "ok" : "warn",
198
- detail: auditArtifact.reason,
199
- });
200
-
201
- const auditArtifactConsistent = usesV2SurfaceModel
202
- || !auditArtifact.present
203
- || auditArtifact.outcome !== "completed"
204
- || bootstrapSurface.canonicalTree.requiredFilesValid;
205
- checks.push(
206
- buildCheck(
207
- "doc_spec_audit_state_alignment",
208
- auditArtifactConsistent,
209
- auditArtifactConsistent
210
- ? "Local doc_spec_audit artifact is consistent with the current reconstruction state"
211
- : "Completed local doc_spec_audit artifact requires the canonical tree to remain ready",
212
- ),
213
- );
214
-
215
- const entrypointStatuses = [];
216
- for (const [relativePath, beginToken] of [
217
- ["AGENTS.md", AGENTS_BEGIN],
218
- ["CLAUDE.md", CLAUDE_BEGIN],
219
- ]) {
220
- const entryText = await readTextIfFile(path.join(projectRoot, relativePath));
221
- if (entryText && entryText.includes(beginToken)) {
222
- entrypointStatuses.push(relativePath);
223
- }
224
- }
225
- checks.push({
226
- id: "entrypoint_integration",
227
- ok: true,
228
- severity: "info",
229
- detail: entrypointStatuses.length === 0
230
- ? "No managed AI entrypoint blocks detected; this is optional"
231
- : `Managed AI entrypoint blocks detected in: ${entrypointStatuses.join(", ")}`,
232
- });
233
-
234
- let packageBoundaryTruthOk = true;
235
- let packageSelfAuditActive = false;
236
- try {
237
- packageSelfAuditActive = (await realpath(projectRoot)) === (await realpath(PACKAGE_REPO_ROOT));
238
- } catch {
239
- packageSelfAuditActive = false;
240
- }
241
-
242
- if (packageSelfAuditActive) {
243
- const boundariesText = await readTextIfFile(path.join(projectRoot, ".nimi", "spec", "boundaries.yaml"));
244
- const changePolicyText = await readTextIfFile(path.join(projectRoot, ".nimi", "spec", "change-policy.yaml"));
245
- const packageBoundaryTruth = inspectPackageBoundaryTruth(boundariesText, changePolicyText);
246
- packageBoundaryTruthOk = packageBoundaryTruth.ok;
247
- checks.push(
248
- buildCheck(
249
- "package_boundary_truth",
250
- packageBoundaryTruth.ok,
251
- packageBoundaryTruth.ok
252
- ? "Repo-local boundaries and change-policy keep runtime surfaces explicitly deferred under the boundary-complete standalone posture"
253
- : "Repo-local boundaries or change-policy drifted away from the declared boundary-complete standalone posture",
254
- ),
255
- );
256
- }
257
-
258
- const hasErrors = checks.some((check) => check.severity === "error");
259
- const lifecycleState = usesV2SurfaceModel
260
- ? deriveV2LifecycleState(bootstrapSurface)
261
- : {
262
- mode: bootstrapSurface.bootstrapStateContract.mode,
263
- treeState: bootstrapSurface.bootstrapStateContract.treeState,
264
- authorityMode: bootstrapSurface.bootstrapStateContract.authorityMode,
265
- blueprintMode: bootstrapSurface.bootstrapStateContract.blueprintMode,
266
- reconstructionRequired: bootstrapSurface.bootstrapStateContract.reconstructionRequired,
267
- readyForAiReconstruction: bootstrapSurface.bootstrapStateContract.readyForAiReconstruction,
268
- cutoverReadiness: bootstrapSurface.bootstrapStateContract.cutoverReadiness,
269
- activeAuthorityRoot: bootstrapSurface.bootstrapStateContract.activeAuthorityRoot,
270
- };
271
- const reconstructionRequired = lifecycleState.reconstructionRequired === true;
272
-
273
- const handoffReadiness = {
274
- ok: delegatedSurface.handoffContextOk
275
- && delegatedSurface.referenceChecks.every(Boolean)
276
- && delegatedSurface.contractRuntimeOwnersAligned
277
- && delegatedSurface.delegatedModeAligned
278
- && delegatedSurface.selfHostedAligned
279
- && (usesV2SurfaceModel || bootstrapSurface.completionTruth.ok)
280
- && delegatedSurface.resultContractAlignment
281
- && delegatedSurface.adapterSelectionValid
282
- && adapterProfilesValid
283
- && delegatedSurface.adapterBoundaryAligned
284
- && specContract.ok
285
- && auditContract.ok
286
- && externalHostCompatibilityContract.ok
287
- && highRiskExecutionContract.ok
288
- && highRiskAdmissionContract.ok
289
- && externalExecutionArtifacts.ok
290
- && packageBoundaryTruthOk
291
- && (usesV2SurfaceModel || bootstrapSurface.specTreeModel.ok)
292
- && bootstrapSurface.specGenerationInputsContract.ok
293
- && bootstrapSurface.specGenerationAuditContract.ok
294
- && bootstrapSurface.specGenerationInputs.ok
295
- && (!bootstrapSurface.canonicalTree.requiredFilesValid || bootstrapSurface.specGenerationAudit.ok)
296
- && (usesV2SurfaceModel || bootstrapSurface.commandGatingMatrix.ok)
297
- && bootstrapSurface.blueprintReferenceAligned
298
- && lifecycleAligned,
299
- requiredContextOrder: delegatedSurface.handoffRequiredContext,
300
- missingContextEntries: delegatedSurface.missingHandoffContextEntries,
301
- missingPaths: delegatedSurface.missingHandoffPaths,
302
- };
303
-
304
- const nextSteps = [];
305
- if (hasErrors) {
306
- nextSteps.push("Repair the failing bootstrap checks, then rerun `nimicoding doctor`.");
307
- } else if (!bootstrapSurface.canonicalTree.requiredFilesValid) {
308
- nextSteps.push("Use an external AI host to reconstruct the declared canonical tree under `.nimi/spec`.");
309
- }
310
- if (bootstrapSurface.canonicalTree.requiredFilesValid && bootstrapSurface.benchmarkAuditReadiness.ready) {
311
- nextSteps.push("Run `nimicoding blueprint-audit --write-local` after canonical tree generation when a benchmark blueprint is declared.");
312
- }
313
- if (bootstrapSurface.canonicalTree.requiredFilesValid && !bootstrapSurface.specGenerationAudit.ok) {
314
- nextSteps.push("Run `nimicoding validate-spec-audit` after generating the local spec generation audit for the canonical tree.");
315
- }
316
- if (!auditArtifact.present && bootstrapSurface.canonicalTree.requiredFilesValid) {
317
- nextSteps.push("Run `nimicoding handoff --skill doc_spec_audit` and close out the result locally when the audit is complete.");
318
- }
319
- if (!delegatedSurface.runtimeInstalled) {
320
- nextSteps.push("Keep runtime ownership delegated; do not assume local skill installation or self-hosting.");
321
- }
322
- if (!delegatedSurface.adapterSelected && !hasErrors) {
323
- nextSteps.push("If you want a constrained external execution host, select one in `.nimi/config/host-adapter.yaml`.");
324
- }
325
-
326
- const executionContracts = {
327
- total: highRiskSchemaContracts.length,
328
- valid: highRiskSchemaContracts.filter((entry) => entry.ok).length,
329
- invalid: highRiskSchemaContracts
330
- .filter((entry) => !entry.ok)
331
- .map((entry) => entry.path),
332
- contracts: highRiskSchemaContracts.map((entry) => ({
333
- path: entry.path,
334
- ok: entry.ok,
335
- })),
336
- };
337
-
338
- const completionStatus = (!usesV2SurfaceModel && !bootstrapSurface.completionTruth.ok) || !packageBoundaryTruthOk
339
- ? STANDALONE_COMPLETION_STATUS.DRIFTED
340
- : !hasErrors
341
- ? STANDALONE_COMPLETION_STATUS.COMPLETE
342
- : STANDALONE_COMPLETION_STATUS.INCOMPLETE;
343
-
344
- const hostCompatibility = buildHostCompatibilityReport(
345
- externalHostCompatibilityContract,
346
- adapterProfiles,
347
- delegatedSurface.selectedAdapterId,
348
- );
349
-
350
- return {
351
- projectRoot,
352
- ok: !hasErrors,
353
- bootstrapPresent: true,
354
- reconstructionRequired,
355
- runtimeInstalled: delegatedSurface.runtimeInstalled,
356
- bootstrapContract: {
357
- status: bootstrapSurface.bootstrapCompatibility.status,
358
- id: bootstrapSurface.bootstrapCompatibility.contractId,
359
- version: bootstrapSurface.bootstrapCompatibility.contractVersion,
360
- },
361
- lifecycleState,
362
- specTreeModel: bootstrapSurface.specTreeModel,
363
- specGenerationInputs: bootstrapSurface.specGenerationInputs,
364
- canonicalTree: bootstrapSurface.canonicalTree,
365
- specGenerationAudit: bootstrapSurface.specGenerationAudit,
366
- commandGating: bootstrapSurface.commandGatingMatrix,
367
- blueprintReference: bootstrapSurface.blueprintReference,
368
- benchmarkAuditReadiness: bootstrapSurface.benchmarkAuditReadiness,
369
- completionProfile: bootstrapSurface.completionTruth.completionProfile,
370
- completionStatus,
371
- completedSurfaces: bootstrapSurface.completionTruth.completedSurfaces,
372
- deferredExecutionSurfaces: bootstrapSurface.completionTruth.deferredExecutionSurfaces,
373
- promotedParityGapSummary: bootstrapSurface.completionTruth.promotedParityGapSummary,
374
- hostCompatibility,
375
- delegatedContracts: delegatedSurface.delegatedContracts,
376
- adapterProfiles,
377
- handoffReadiness,
378
- checks,
379
- auditArtifact,
380
- executionContracts,
381
- nextSteps,
382
- };
383
- }