@nimiplatform/nimi-coding 0.2.8 → 0.3.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.
Files changed (206) hide show
  1. package/CHANGELOG.md +10 -90
  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/commands/validate-spec-governance.mjs +20 -0
  8. package/cli/constants.mjs +9 -417
  9. package/cli/help.mjs +28 -145
  10. package/cli/index.mjs +5 -33
  11. package/cli/lib/blueprint-audit.mjs +5 -12
  12. package/cli/lib/bootstrap.mjs +0 -9
  13. package/cli/lib/contracts.mjs +0 -163
  14. package/cli/lib/doctor.mjs +155 -10
  15. package/cli/lib/entrypoints.mjs +63 -167
  16. package/cli/lib/internal/contracts-loaders.mjs +0 -85
  17. package/cli/lib/internal/contracts-parse.mjs +84 -520
  18. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
  19. package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
  20. package/cli/lib/internal/validators-shared.mjs +0 -16
  21. package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
  22. package/cli/lib/internal/validators-spec.mjs +103 -342
  23. package/cli/lib/shared.mjs +1 -42
  24. package/cli/lib/validators.mjs +0 -48
  25. package/cli/seeds/seed-policy.yaml +0 -3
  26. package/config/bootstrap.yaml +4 -4
  27. package/config/spec-generation-inputs.yaml +6 -12
  28. package/contracts/domain-admission.schema.yaml +3 -3
  29. package/contracts/migration-inventory.schema.yaml +12 -75
  30. package/contracts/negative-fixtures.yaml +19 -99
  31. package/contracts/placement-contract.schema.yaml +49 -78
  32. package/contracts/projection-edge.schema.yaml +37 -121
  33. package/contracts/shared-enums.yaml +4 -8
  34. package/contracts/spec-generation-inputs.schema.yaml +15 -112
  35. package/contracts/spec-layout.schema.yaml +32 -0
  36. package/contracts/surface-taxonomy.schema.yaml +43 -94
  37. package/contracts/table-family.schema.yaml +1 -1
  38. package/contracts/tracked-output-admission.schema.yaml +13 -66
  39. package/methodology/core.yaml +33 -25
  40. package/methodology/four-closure-policy.yaml +18 -26
  41. package/methodology/role-separation-policy.yaml +21 -27
  42. package/methodology/spec-reconstruction.yaml +17 -34
  43. package/package.json +2 -4
  44. package/spec/_meta/spec-tree-model.yaml +5 -101
  45. package/spec/product-scope.yaml +25 -57
  46. package/adapters/README.md +0 -25
  47. package/adapters/claude/README.md +0 -89
  48. package/adapters/claude/profile.yaml +0 -70
  49. package/adapters/codex/README.md +0 -53
  50. package/adapters/codex/profile.yaml +0 -78
  51. package/adapters/oh-my-codex/README.md +0 -184
  52. package/adapters/oh-my-codex/profile.yaml +0 -46
  53. package/cli/commands/admit-high-risk-decision.mjs +0 -108
  54. package/cli/commands/audit-sweep.mjs +0 -364
  55. package/cli/commands/closeout.mjs +0 -186
  56. package/cli/commands/decide-high-risk-execution.mjs +0 -124
  57. package/cli/commands/handoff.mjs +0 -123
  58. package/cli/commands/ingest-high-risk-execution.mjs +0 -95
  59. package/cli/commands/review-high-risk-execution.mjs +0 -95
  60. package/cli/commands/sweep-design.mjs +0 -295
  61. package/cli/commands/sweep.mjs +0 -22
  62. package/cli/commands/topic-formatters.mjs +0 -382
  63. package/cli/commands/topic-goal.mjs +0 -33
  64. package/cli/commands/topic-options-shared.mjs +0 -27
  65. package/cli/commands/topic-options-workflow.mjs +0 -767
  66. package/cli/commands/topic-options.mjs +0 -626
  67. package/cli/commands/topic-runner.mjs +0 -169
  68. package/cli/commands/topic.mjs +0 -795
  69. package/cli/commands/validate-acceptance.mjs +0 -5
  70. package/cli/commands/validate-execution-packet.mjs +0 -5
  71. package/cli/commands/validate-orchestration-state.mjs +0 -5
  72. package/cli/commands/validate-prompt.mjs +0 -5
  73. package/cli/commands/validate-worker-output.mjs +0 -5
  74. package/cli/lib/adapter-profiles.mjs +0 -403
  75. package/cli/lib/audit-execution.mjs +0 -52
  76. package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
  77. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
  78. package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
  79. package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
  80. package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
  81. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
  82. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
  83. package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
  84. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
  85. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
  86. package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
  87. package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
  88. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
  89. package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
  90. package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
  91. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
  92. package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
  93. package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
  94. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
  95. package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
  96. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
  97. package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
  98. package/cli/lib/audit-sweep.mjs +0 -19
  99. package/cli/lib/authority-convergence.mjs +0 -720
  100. package/cli/lib/closeout.mjs +0 -732
  101. package/cli/lib/codex-sdk-runner.mjs +0 -76
  102. package/cli/lib/external-execution.mjs +0 -101
  103. package/cli/lib/handoff.mjs +0 -812
  104. package/cli/lib/high-risk-admission.mjs +0 -512
  105. package/cli/lib/high-risk-decision.mjs +0 -353
  106. package/cli/lib/high-risk-ingest.mjs +0 -321
  107. package/cli/lib/high-risk-review.mjs +0 -267
  108. package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
  109. package/cli/lib/internal/contracts-validators.mjs +0 -399
  110. package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
  111. package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
  112. package/cli/lib/internal/doctor-finalize.mjs +0 -383
  113. package/cli/lib/internal/doctor-format.mjs +0 -286
  114. package/cli/lib/internal/doctor-inspectors.mjs +0 -327
  115. package/cli/lib/internal/doctor-state.mjs +0 -205
  116. package/cli/lib/internal/validators-artifacts.mjs +0 -515
  117. package/cli/lib/sweep-design-runtime/common.mjs +0 -246
  118. package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
  119. package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
  120. package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
  121. package/cli/lib/sweep-design-runtime/results.mjs +0 -324
  122. package/cli/lib/sweep-design.mjs +0 -8
  123. package/cli/lib/topic-artifacts.mjs +0 -186
  124. package/cli/lib/topic-authority-coverage.mjs +0 -73
  125. package/cli/lib/topic-closeout.mjs +0 -560
  126. package/cli/lib/topic-common.mjs +0 -404
  127. package/cli/lib/topic-decisions.mjs +0 -332
  128. package/cli/lib/topic-draft-packets.mjs +0 -167
  129. package/cli/lib/topic-execution.mjs +0 -533
  130. package/cli/lib/topic-goal.mjs +0 -440
  131. package/cli/lib/topic-ledger.mjs +0 -281
  132. package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
  133. package/cli/lib/topic-root-validation.mjs +0 -288
  134. package/cli/lib/topic-runner-commands.mjs +0 -174
  135. package/cli/lib/topic-runner-deferral.mjs +0 -532
  136. package/cli/lib/topic-runner-stale-gates.mjs +0 -114
  137. package/cli/lib/topic-runner-validation.mjs +0 -138
  138. package/cli/lib/topic-runner.mjs +0 -727
  139. package/cli/lib/topic-scaffold.mjs +0 -252
  140. package/cli/lib/topic-waves.mjs +0 -403
  141. package/cli/lib/topic.mjs +0 -81
  142. package/config/audit-execution-artifacts.yaml +0 -20
  143. package/config/external-execution-artifacts.yaml +0 -16
  144. package/config/host-adapter.yaml +0 -30
  145. package/config/host-profile.yaml +0 -29
  146. package/config/installer-evidence.yaml +0 -31
  147. package/config/skill-installer.yaml +0 -23
  148. package/config/skill-manifest.yaml +0 -48
  149. package/config/skills.yaml +0 -30
  150. package/contracts/acceptance.schema.yaml +0 -16
  151. package/contracts/admission-checklist.schema.yaml +0 -15
  152. package/contracts/audit-chunk.schema.yaml +0 -123
  153. package/contracts/audit-closeout.schema.yaml +0 -51
  154. package/contracts/audit-finding.schema.yaml +0 -61
  155. package/contracts/audit-ledger.schema.yaml +0 -138
  156. package/contracts/audit-plan.schema.yaml +0 -138
  157. package/contracts/audit-remediation-map.schema.yaml +0 -52
  158. package/contracts/audit-rerun.schema.yaml +0 -31
  159. package/contracts/audit-sweep-result.yaml +0 -53
  160. package/contracts/authority-convergence-audit.schema.yaml +0 -19
  161. package/contracts/closeout.schema.yaml +0 -25
  162. package/contracts/decision-review.schema.yaml +0 -16
  163. package/contracts/doc-spec-audit-result.yaml +0 -19
  164. package/contracts/execution-packet.schema.yaml +0 -49
  165. package/contracts/external-host-compatibility.yaml +0 -22
  166. package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
  167. package/contracts/high-risk-admission.schema.yaml +0 -23
  168. package/contracts/high-risk-execution-result.yaml +0 -20
  169. package/contracts/orchestration-state.schema.yaml +0 -41
  170. package/contracts/overflow-continuation.schema.yaml +0 -12
  171. package/contracts/packet.schema.yaml +0 -30
  172. package/contracts/pending-note.schema.yaml +0 -17
  173. package/contracts/prompt.schema.yaml +0 -12
  174. package/contracts/remediation.schema.yaml +0 -16
  175. package/contracts/result.schema.yaml +0 -24
  176. package/contracts/spec-reconstruction-result.yaml +0 -41
  177. package/contracts/sweep-design-result.yaml +0 -349
  178. package/contracts/topic-goal.schema.yaml +0 -87
  179. package/contracts/topic-run-ledger.schema.yaml +0 -72
  180. package/contracts/topic-step-decision.schema.yaml +0 -45
  181. package/contracts/topic.schema.yaml +0 -65
  182. package/contracts/true-close.schema.yaml +0 -15
  183. package/contracts/wave.schema.yaml +0 -29
  184. package/contracts/worker-output.schema.yaml +0 -15
  185. package/contracts/workflow-consumer.schema.yaml +0 -110
  186. package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
  187. package/methodology/authority-convergence-policy.yaml +0 -42
  188. package/methodology/overflow-continuation-policy.yaml +0 -14
  189. package/methodology/skill-exchange-projection.yaml +0 -114
  190. package/methodology/skill-handoff.yaml +0 -34
  191. package/methodology/skill-installer-result.yaml +0 -27
  192. package/methodology/skill-installer-summary-projection.yaml +0 -181
  193. package/methodology/skill-runtime.yaml +0 -23
  194. package/methodology/spec-target-truth-profile.yaml +0 -46
  195. package/methodology/topic-lifecycle-report.yaml +0 -144
  196. package/methodology/topic-lifecycle.yaml +0 -37
  197. package/methodology/topic-naming-ontology.yaml +0 -21
  198. package/methodology/topic-ontology.yaml +0 -38
  199. package/methodology/topic-validation-policy.yaml +0 -9
  200. package/methodology/wave-dag-policy.yaml +0 -14
  201. package/spec/_meta/command-gating-matrix.yaml +0 -143
  202. package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
  203. package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
  204. package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
  205. package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
  206. package/spec/bootstrap-state.yaml +0 -99
@@ -1,267 +0,0 @@
1
- import path from "node:path";
2
-
3
- import {
4
- HIGH_RISK_EXECUTION_RESULT_CONTRACT_REF,
5
- HIGH_RISK_REVIEW_PAYLOAD_CONTRACT_VERSION,
6
- } from "../constants.mjs";
7
- import { inspectDoctorState } from "./doctor.mjs";
8
- import { readTextIfFile } from "./fs-helpers.mjs";
9
- import {
10
- localize,
11
- styleCommand,
12
- styleHeading,
13
- styleLabel,
14
- styleStatus,
15
- } from "./ui.mjs";
16
- import { isPlainObject } from "./value-helpers.mjs";
17
-
18
- function translateReviewReason(reason) {
19
- const translations = new Map([
20
- ["imported ingest payload must declare contractVersion nimicoding.high-risk-ingest.v1", "导入的 ingest payload 必须声明 contractVersion nimicoding.high-risk-ingest.v1"],
21
- ["imported ingest payload must declare skill.id high_risk_execution", "导入的 ingest payload 必须声明 skill.id 为 high_risk_execution"],
22
- ["imported ingest payload must remain localOnly true", "导入的 ingest payload 必须保持 localOnly 为 true"],
23
- ["review-high-risk-execution requires an ingest payload with ok true", "review-high-risk-execution 需要一个 ok 为 true 的 ingest payload"],
24
- ["imported ingest payload must include validations", "导入的 ingest payload 必须包含 validations"],
25
- ["review-high-risk-execution requires all ingest validations to be mechanically ok", "review-high-risk-execution 需要所有 ingest 校验均机械通过"],
26
- ["Bootstrap or handoff validation is failing; repair doctor errors before projecting review-ready artifacts", "bootstrap 或 handoff 校验失败;请先修复 doctor 报错,再投影 review-ready 产物"],
27
- ["High-risk review projection requires the canonical tree under `.nimi/spec`", "high-risk review 投影需要 `.nimi/spec` 下的 canonical tree"],
28
- ["Candidate artifacts are ready for manager-owned semantic review", "候选产物已准备好供 manager 执行语义审查"],
29
- ]);
30
- return translations.get(reason) ?? reason;
31
- }
32
-
33
- async function loadImportedIngestPayload(projectRoot, fromPath) {
34
- const absolutePath = path.resolve(projectRoot, fromPath);
35
- const rawText = await readTextIfFile(absolutePath);
36
-
37
- if (rawText === null) {
38
- return {
39
- ok: false,
40
- error: `${localize(
41
- `nimicoding review-high-risk-execution refused: cannot read imported ingest JSON at ${absolutePath}.`,
42
- `nimicoding review-high-risk-execution 已拒绝:无法读取 ${absolutePath} 处的导入 ingest JSON。`,
43
- )}\n`,
44
- };
45
- }
46
-
47
- let parsed;
48
- try {
49
- parsed = JSON.parse(rawText);
50
- } catch {
51
- return {
52
- ok: false,
53
- error: `${localize(
54
- `nimicoding review-high-risk-execution refused: imported ingest JSON at ${absolutePath} is invalid JSON.`,
55
- `nimicoding review-high-risk-execution 已拒绝:${absolutePath} 处的导入 ingest JSON 不是合法 JSON。`,
56
- )}\n`,
57
- };
58
- }
59
-
60
- if (!isPlainObject(parsed)) {
61
- return {
62
- ok: false,
63
- error: `${localize(
64
- "nimicoding review-high-risk-execution refused: imported ingest JSON must be an object.",
65
- "nimicoding review-high-risk-execution 已拒绝:导入的 ingest JSON 必须是对象。",
66
- )}\n`,
67
- };
68
- }
69
-
70
- return {
71
- ok: true,
72
- path: absolutePath,
73
- payload: parsed,
74
- };
75
- }
76
-
77
- function validateImportedIngestPayload(payload) {
78
- if (payload.contractVersion !== "nimicoding.high-risk-ingest.v1") {
79
- return {
80
- ok: false,
81
- reason: "imported ingest payload must declare contractVersion nimicoding.high-risk-ingest.v1",
82
- };
83
- }
84
-
85
- if (payload.skill?.id !== "high_risk_execution") {
86
- return {
87
- ok: false,
88
- reason: "imported ingest payload must declare skill.id high_risk_execution",
89
- };
90
- }
91
-
92
- if (payload.localOnly !== true) {
93
- return {
94
- ok: false,
95
- reason: "imported ingest payload must remain localOnly true",
96
- };
97
- }
98
-
99
- if (payload.ok !== true) {
100
- return {
101
- ok: false,
102
- reason: "review-high-risk-execution requires an ingest payload with ok true",
103
- };
104
- }
105
-
106
- const validations = payload.validations;
107
- if (!isPlainObject(validations)) {
108
- return {
109
- ok: false,
110
- reason: "imported ingest payload must include validations",
111
- };
112
- }
113
-
114
- const requiredValidationKeys = [
115
- "executionPacket",
116
- "orchestrationState",
117
- "prompt",
118
- "workerOutput",
119
- "evidence",
120
- ];
121
- for (const key of requiredValidationKeys) {
122
- if (!(key in validations)) {
123
- return {
124
- ok: false,
125
- reason: `imported ingest payload validations are missing ${key}`,
126
- };
127
- }
128
- }
129
-
130
- if (
131
- validations.executionPacket?.ok !== true
132
- || validations.orchestrationState?.ok !== true
133
- || validations.prompt?.ok !== true
134
- || validations.workerOutput?.ok !== true
135
- || !Array.isArray(validations.evidence)
136
- || validations.evidence.some((entry) => !entry || entry.ok !== true)
137
- ) {
138
- return {
139
- ok: false,
140
- reason: "review-high-risk-execution requires all ingest validations to be mechanically ok",
141
- };
142
- }
143
-
144
- return { ok: true };
145
- }
146
-
147
- function evaluateHighRiskReviewReadiness(doctorResult) {
148
- if (!doctorResult.ok || !doctorResult.handoffReadiness.ok) {
149
- return {
150
- ok: false,
151
- reason: "Bootstrap or handoff validation is failing; repair doctor errors before projecting review-ready artifacts",
152
- };
153
- }
154
-
155
- const v2Ready = doctorResult.specGenerationInputs?.mode === "class_filtered"
156
- && doctorResult.canonicalTree?.requiredFilesValid === true;
157
- const legacyReady = doctorResult.lifecycleState?.treeState === "canonical_tree_ready"
158
- && doctorResult.canonicalTree?.requiredFilesValid === true;
159
- if (!v2Ready && !legacyReady) {
160
- return {
161
- ok: false,
162
- reason: "High-risk review projection requires canonical_tree_ready with declared canonical files present",
163
- };
164
- }
165
-
166
- return {
167
- ok: true,
168
- reason: "Candidate artifacts are ready for manager-owned semantic review",
169
- };
170
- }
171
-
172
- export async function buildHighRiskReviewPayload(projectRoot, fromPath, options = {}) {
173
- const imported = await loadImportedIngestPayload(projectRoot, fromPath);
174
- if (!imported.ok) {
175
- return {
176
- ok: false,
177
- exitCode: 2,
178
- inputError: true,
179
- error: imported.error,
180
- };
181
- }
182
-
183
- const inputValidation = validateImportedIngestPayload(imported.payload);
184
- if (!inputValidation.ok) {
185
- return {
186
- ok: false,
187
- exitCode: 2,
188
- inputError: true,
189
- error: `${localize(
190
- `nimicoding review-high-risk-execution refused: ${inputValidation.reason}.`,
191
- `nimicoding review-high-risk-execution 已拒绝:${translateReviewReason(inputValidation.reason)}。`,
192
- )}\n`,
193
- };
194
- }
195
-
196
- const doctorResult = await inspectDoctorState(projectRoot);
197
- const readiness = evaluateHighRiskReviewReadiness(doctorResult);
198
- const artifactPath = path.join(
199
- projectRoot,
200
- ".nimi",
201
- "local",
202
- "handoff-results",
203
- "high_risk_execution.review.json",
204
- );
205
-
206
- return {
207
- contractVersion: HIGH_RISK_REVIEW_PAYLOAD_CONTRACT_VERSION,
208
- ok: readiness.ok,
209
- exitCode: readiness.ok ? 0 : 1,
210
- projectRoot,
211
- sourceIngestRef: imported.path,
212
- localOnly: true,
213
- artifactPath,
214
- skill: {
215
- id: "high_risk_execution",
216
- resultContractRef: HIGH_RISK_EXECUTION_RESULT_CONTRACT_REF,
217
- },
218
- verifiedAt: imported.payload.verifiedAt,
219
- reviewStatus: readiness.ok ? "ready_for_manager_review" : "blocked",
220
- managerReviewOwner: doctorResult.delegatedContracts.semanticReviewOwner,
221
- summary: imported.payload.summary,
222
- attachmentRefs: {
223
- packet_ref: imported.payload.summary.packet_ref,
224
- orchestration_state_ref: imported.payload.summary.orchestration_state_ref,
225
- prompt_ref: imported.payload.summary.prompt_ref,
226
- worker_output_ref: imported.payload.summary.worker_output_ref,
227
- evidence_refs: imported.payload.summary.evidence_refs,
228
- },
229
- ingestValidations: imported.payload.validations,
230
- readiness,
231
- doctor: {
232
- ok: doctorResult.ok,
233
- handoffReadiness: doctorResult.handoffReadiness,
234
- delegatedContracts: doctorResult.delegatedContracts,
235
- },
236
- nextAction: readiness.ok
237
- ? options.writeLocal
238
- ? `Write the high-risk review artifact to ${artifactPath}.`
239
- : "Review the review-ready payload or write it locally with `--write-local`."
240
- : readiness.reason,
241
- };
242
- }
243
-
244
- export function formatHighRiskReviewPayload(payload) {
245
- const nextAction = payload.readiness.ok
246
- ? payload.nextAction.startsWith("Write the high-risk review artifact to ")
247
- ? localize(payload.nextAction, `将 high-risk review 产物写入 ${payload.artifactPath}。`)
248
- : localize(
249
- payload.nextAction,
250
- `检查 review-ready payload,或使用 ${styleCommand("--write-local")} 将其写入本地。`,
251
- )
252
- : translateReviewReason(payload.nextAction);
253
- const lines = [
254
- styleHeading(`nimicoding review-high-risk-execution: ${payload.projectRoot}`),
255
- "",
256
- styleLabel(localize("Result:", "结果:")),
257
- ` - review_status: ${payload.reviewStatus}`,
258
- ` - manager_review_owner: ${payload.managerReviewOwner ?? localize("unknown", "未知")}`,
259
- ` - ready: ${styleStatus(payload.readiness.ok ? "ready" : "needs_attention")}`,
260
- ` - local_only: ${payload.localOnly ? "true" : "false"}`,
261
- "",
262
- styleLabel(localize("Next:", "下一步:")),
263
- ` - ${nextAction}`,
264
- ];
265
-
266
- return `${lines.join("\n")}\n`;
267
- }
@@ -1,131 +0,0 @@
1
- import {
2
- AUDIT_SWEEP_SUMMARY_REQUIRED_FIELDS,
3
- AUDIT_SWEEP_SUMMARY_STATUS,
4
- DOC_SPEC_AUDIT_DEFAULT_COMPARED_PATHS,
5
- DOC_SPEC_AUDIT_SUMMARY_REQUIRED_FIELDS,
6
- DOC_SPEC_AUDIT_SUMMARY_STATUS,
7
- EXTERNAL_HOST_COMPATIBILITY_FORBIDDEN_BEHAVIOR,
8
- EXTERNAL_HOST_COMPATIBILITY_REQUIRED_BEHAVIOR,
9
- EXTERNAL_HOST_COMPATIBILITY_SUPPORTED_HOST_EXAMPLES,
10
- EXTERNAL_HOST_COMPATIBILITY_SUPPORTED_POSTURE,
11
- HIGH_RISK_ADMISSION_DISPOSITION_ENUM,
12
- HIGH_RISK_ADMISSION_RECORD_REQUIRED_FIELDS,
13
- HIGH_RISK_ADMISSION_REQUIRED_TOP_LEVEL_KEYS,
14
- HIGH_RISK_EXECUTION_SUMMARY_REQUIRED_FIELDS,
15
- HIGH_RISK_EXECUTION_SUMMARY_STATUS,
16
- HIGH_RISK_SCHEMA_SPECS,
17
- } from "../../constants.mjs";
18
- import { arraysEqual, toStringArray } from "../value-helpers.mjs";
19
- import { parseYamlText } from "../yaml-helpers.mjs";
20
-
21
- export function parseDocSpecAuditContract(text) {
22
- const parsed = parseYamlText(text);
23
- const summaryRequiredFields = toStringArray(parsed?.summary_required_fields);
24
- const summaryStatusEnum = toStringArray(parsed?.summary_status_enum);
25
- const defaultComparedPaths = toStringArray(parsed?.default_compared_paths);
26
-
27
- return {
28
- ok: arraysEqual(summaryRequiredFields, DOC_SPEC_AUDIT_SUMMARY_REQUIRED_FIELDS)
29
- && arraysEqual(summaryStatusEnum, DOC_SPEC_AUDIT_SUMMARY_STATUS)
30
- && arraysEqual(defaultComparedPaths, DOC_SPEC_AUDIT_DEFAULT_COMPARED_PATHS),
31
- summaryRequiredFields,
32
- summaryStatusEnum,
33
- defaultComparedPaths,
34
- };
35
- }
36
-
37
- export function parseAuditSweepContract(text) {
38
- const parsed = parseYamlText(text);
39
- const summaryRequiredFields = toStringArray(parsed?.summary_required_fields);
40
- const summaryStatusEnum = toStringArray(parsed?.summary_status_enum);
41
-
42
- return {
43
- ok: arraysEqual(summaryRequiredFields, AUDIT_SWEEP_SUMMARY_REQUIRED_FIELDS)
44
- && arraysEqual(summaryStatusEnum, AUDIT_SWEEP_SUMMARY_STATUS),
45
- summaryRequiredFields,
46
- summaryStatusEnum,
47
- };
48
- }
49
-
50
- export function parseHighRiskExecutionContract(text) {
51
- const parsed = parseYamlText(text);
52
- const summaryRequiredFields = toStringArray(parsed?.summary_required_fields);
53
- const summaryStatusEnum = toStringArray(parsed?.summary_status_enum);
54
-
55
- return {
56
- ok: arraysEqual(summaryRequiredFields, HIGH_RISK_EXECUTION_SUMMARY_REQUIRED_FIELDS)
57
- && arraysEqual(summaryStatusEnum, HIGH_RISK_EXECUTION_SUMMARY_STATUS),
58
- summaryRequiredFields,
59
- summaryStatusEnum,
60
- };
61
- }
62
-
63
- export function parseHighRiskAdmissionContract(text) {
64
- const parsed = parseYamlText(text);
65
- const topLevelRequiredKeys = toStringArray(parsed?.top_level_required_keys);
66
- const admissionRequiredFields = toStringArray(parsed?.admission_required_fields);
67
- const dispositionEnum = toStringArray(parsed?.disposition_enum);
68
-
69
- return {
70
- ok: String(parsed?.truth_contract?.id ?? "") === "local_high_risk_admission_evidence"
71
- && arraysEqual(topLevelRequiredKeys, HIGH_RISK_ADMISSION_REQUIRED_TOP_LEVEL_KEYS)
72
- && arraysEqual(admissionRequiredFields, HIGH_RISK_ADMISSION_RECORD_REQUIRED_FIELDS)
73
- && arraysEqual(dispositionEnum, HIGH_RISK_ADMISSION_DISPOSITION_ENUM),
74
- topLevelRequiredKeys,
75
- admissionRequiredFields,
76
- dispositionEnum,
77
- };
78
- }
79
-
80
- export function parseExternalHostCompatibilityContract(text) {
81
- const parsed = parseYamlText(text);
82
- const supportedHostPosture = toStringArray(parsed?.supported_host_posture);
83
- const supportedHostExamples = toStringArray(parsed?.supported_host_examples);
84
- const requiredBehavior = toStringArray(parsed?.required_behavior);
85
- const forbiddenBehavior = toStringArray(parsed?.forbidden_behavior);
86
-
87
- return {
88
- ok: String(parsed?.compatibility_contract?.id ?? "") === "external_host_boundary_compatibility"
89
- && String(parsed?.compatibility_contract?.completion_profile ?? "") === "boundary_complete"
90
- && arraysEqual(supportedHostPosture, EXTERNAL_HOST_COMPATIBILITY_SUPPORTED_POSTURE)
91
- && arraysEqual(supportedHostExamples, EXTERNAL_HOST_COMPATIBILITY_SUPPORTED_HOST_EXAMPLES)
92
- && arraysEqual(requiredBehavior, EXTERNAL_HOST_COMPATIBILITY_REQUIRED_BEHAVIOR)
93
- && arraysEqual(forbiddenBehavior, EXTERNAL_HOST_COMPATIBILITY_FORBIDDEN_BEHAVIOR),
94
- supportedHostPosture,
95
- supportedHostExamples,
96
- requiredBehavior,
97
- forbiddenBehavior,
98
- };
99
- }
100
-
101
- export function parseHighRiskSchemaContract(text, schemaRef) {
102
- const parsed = parseYamlText(text);
103
- const spec = HIGH_RISK_SCHEMA_SPECS[schemaRef];
104
-
105
- if (!spec || !parsed) {
106
- return {
107
- ok: false,
108
- id: null,
109
- kind: null,
110
- listFieldMatches: [],
111
- rulesMatch: false,
112
- };
113
- }
114
-
115
- const listFieldMatches = Object.entries(spec.listFields).map(([field, expectedValues]) => ({
116
- field,
117
- ok: arraysEqual(toStringArray(parsed[field]), expectedValues),
118
- }));
119
- const rulesMatch = arraysEqual(toStringArray(parsed.rules), spec.requiredRules);
120
-
121
- return {
122
- ok: String(parsed.id ?? "") === spec.id
123
- && String(parsed.kind ?? "") === spec.kind
124
- && listFieldMatches.every((entry) => entry.ok)
125
- && rulesMatch,
126
- id: String(parsed.id ?? ""),
127
- kind: String(parsed.kind ?? ""),
128
- listFieldMatches,
129
- rulesMatch,
130
- };
131
- }