@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,364 +0,0 @@
1
- import {
2
- buildAuditSweepCloseoutImport,
3
- buildAuditSweepLedger,
4
- buildAuditSweepRemediationMap,
5
- createAuditSweepPlan,
6
- admitAuditSweepRemediationMap,
7
- dispatchAuditSweepChunk,
8
- formatAuditSweepPayload,
9
- getAuditSweepStatus,
10
- ingestAuditSweepChunk,
11
- resolveAuditSweepFinding,
12
- reviewAuditSweepChunk,
13
- runClaudeAuditSweepChunk,
14
- runCodexAuditSweepChunk,
15
- skipAuditSweepChunk,
16
- validateAuditSweepArtifacts,
17
- } from "../lib/audit-sweep.mjs";
18
- import { localize } from "../lib/ui.mjs";
19
-
20
- function readRequiredValue(args, index, optionName, commandName) {
21
- const next = args[index + 1];
22
- if (!next || next.startsWith("--")) {
23
- return {
24
- ok: false,
25
- error: `${localize(
26
- `nimicoding sweep audit ${commandName} refused: ${optionName} requires a value.`,
27
- `nimicoding sweep audit ${commandName} 已拒绝:${optionName} 需要一个值。`,
28
- )}\n`,
29
- };
30
- }
31
- return { ok: true, value: next };
32
- }
33
-
34
- function unknownOption(commandName, arg) {
35
- return {
36
- ok: false,
37
- error: `${localize(
38
- `nimicoding sweep audit ${commandName} refused: unknown option ${arg}.`,
39
- `nimicoding sweep audit ${commandName} 已拒绝:未知选项 ${arg}。`,
40
- )}\n`,
41
- };
42
- }
43
-
44
- function parseOptions(args, commandName, spec) {
45
- const options = Object.fromEntries(Object.entries(spec).map(([name, config]) => [name, config.default ?? null]));
46
-
47
- for (let index = 0; index < args.length; index += 1) {
48
- const arg = args[index];
49
- if (arg === "--json") {
50
- options.json = true;
51
- continue;
52
- }
53
-
54
- const entry = Object.entries(spec).find(([, config]) => config.flag === arg);
55
- if (!entry) {
56
- return unknownOption(commandName, arg);
57
- }
58
- const [name, config] = entry;
59
- const value = readRequiredValue(args, index, arg, commandName);
60
- if (!value.ok) {
61
- return value;
62
- }
63
- if (config.type === "positive-int") {
64
- const parsed = Number(value.value);
65
- if (!Number.isInteger(parsed) || parsed <= 0) {
66
- return {
67
- ok: false,
68
- error: `${localize(
69
- `nimicoding sweep audit ${commandName} refused: ${arg} must be a positive integer.`,
70
- `nimicoding sweep audit ${commandName} 已拒绝:${arg} 必须是正整数。`,
71
- )}\n`,
72
- };
73
- }
74
- options[name] = parsed;
75
- } else {
76
- options[name] = value.value;
77
- }
78
- index += 1;
79
- }
80
-
81
- const missing = Object.entries(spec)
82
- .filter(([, config]) => config.required)
83
- .filter(([name]) => !options[name])
84
- .map(([, config]) => config.flag);
85
- if (missing.length > 0) {
86
- return {
87
- ok: false,
88
- error: `${localize(
89
- `nimicoding sweep audit ${commandName} refused: missing required options: ${missing.join(", ")}.`,
90
- `nimicoding sweep audit ${commandName} 已拒绝:缺少必填选项:${missing.join(", ")}。`,
91
- )}\n`,
92
- };
93
- }
94
-
95
- return { ok: true, options };
96
- }
97
-
98
- function parsePlanOptions(args) {
99
- return parseOptions(args, "plan", {
100
- root: { flag: "--root", required: true },
101
- chunkBasis: { flag: "--chunk-basis" },
102
- criteria: { flag: "--criteria" },
103
- exclude: { flag: "--exclude" },
104
- ignore: { flag: "--ignore" },
105
- ignoreOwner: { flag: "--ignore-owner" },
106
- ignoreReason: { flag: "--ignore-reason" },
107
- maxFilesPerChunk: { flag: "--max-files", type: "positive-int" },
108
- maxSweepFindings: { flag: "--max-sweep-findings", type: "positive-int" },
109
- maxDomainFindings: { flag: "--max-domain-findings", type: "positive-int" },
110
- maxSweepHighRiskFindings: { flag: "--max-sweep-high-risk-findings", type: "positive-int" },
111
- maxDomainHighRiskFindings: { flag: "--max-domain-high-risk-findings", type: "positive-int" },
112
- sweepId: { flag: "--sweep-id" },
113
- json: { default: false },
114
- });
115
- }
116
-
117
- function parseChunkDispatchOptions(args) {
118
- return parseOptions(args, "chunk dispatch", {
119
- sweepId: { flag: "--sweep-id", required: true },
120
- chunkId: { flag: "--chunk-id", required: true },
121
- dispatchedAt: { flag: "--dispatched-at", required: true },
122
- auditor: { flag: "--auditor" },
123
- json: { default: false },
124
- });
125
- }
126
-
127
- function parseChunkIngestOptions(args) {
128
- return parseOptions(args, "chunk ingest", {
129
- sweepId: { flag: "--sweep-id", required: true },
130
- chunkId: { flag: "--chunk-id", required: true },
131
- fromPath: { flag: "--from", required: true },
132
- verifiedAt: { flag: "--verified-at", required: true },
133
- json: { default: false },
134
- });
135
- }
136
-
137
- function parseChunkAuditCodexOptions(args) {
138
- return parseOptions(args, "chunk audit-codex", {
139
- sweepId: { flag: "--sweep-id", required: true },
140
- chunkId: { flag: "--chunk-id", required: true },
141
- dispatchedAt: { flag: "--dispatched-at", required: true },
142
- verifiedAt: { flag: "--verified-at", required: true },
143
- reviewedAt: { flag: "--reviewed-at", required: true },
144
- auditor: { flag: "--auditor" },
145
- reviewer: { flag: "--reviewer" },
146
- summary: { flag: "--summary" },
147
- codexBin: { flag: "--codex-bin" },
148
- fromRawOutput: { flag: "--from-raw-output" },
149
- timeoutMs: { flag: "--timeout-ms", type: "positive-int" },
150
- json: { default: false },
151
- });
152
- }
153
-
154
- function parseChunkAuditClaudeOptions(args) {
155
- return parseOptions(args, "chunk audit-claude", {
156
- sweepId: { flag: "--sweep-id", required: true },
157
- chunkId: { flag: "--chunk-id", required: true },
158
- dispatchedAt: { flag: "--dispatched-at", required: true },
159
- verifiedAt: { flag: "--verified-at", required: true },
160
- reviewedAt: { flag: "--reviewed-at", required: true },
161
- auditor: { flag: "--auditor" },
162
- reviewer: { flag: "--reviewer" },
163
- summary: { flag: "--summary" },
164
- claudeBin: { flag: "--claude-bin" },
165
- fromRawOutput: { flag: "--from-raw-output" },
166
- timeoutMs: { flag: "--timeout-ms", type: "positive-int" },
167
- json: { default: false },
168
- });
169
- }
170
-
171
- function parseChunkReviewOptions(args) {
172
- return parseOptions(args, "chunk review", {
173
- sweepId: { flag: "--sweep-id", required: true },
174
- chunkId: { flag: "--chunk-id", required: true },
175
- verdict: { flag: "--verdict", required: true },
176
- reviewedAt: { flag: "--reviewed-at", required: true },
177
- reviewer: { flag: "--reviewer" },
178
- summary: { flag: "--summary" },
179
- json: { default: false },
180
- });
181
- }
182
-
183
- function parseChunkSkipOptions(args) {
184
- return parseOptions(args, "chunk skip", {
185
- sweepId: { flag: "--sweep-id", required: true },
186
- chunkId: { flag: "--chunk-id", required: true },
187
- reason: { flag: "--reason", required: true },
188
- skippedAt: { flag: "--skipped-at", required: true },
189
- json: { default: false },
190
- });
191
- }
192
-
193
- function parseLedgerBuildOptions(args) {
194
- return parseOptions(args, "ledger build", {
195
- sweepId: { flag: "--sweep-id", required: true },
196
- verifiedAt: { flag: "--verified-at" },
197
- json: { default: false },
198
- });
199
- }
200
-
201
- function parseRemediationMapBuildOptions(args) {
202
- return parseOptions(args, "remediation-map build", {
203
- sweepId: { flag: "--sweep-id", required: true },
204
- verifiedAt: { flag: "--verified-at" },
205
- maxFindingsPerWave: { flag: "--max-findings", type: "positive-int" },
206
- json: { default: false },
207
- });
208
- }
209
-
210
- function parseRemediationMapAdmitOptions(args) {
211
- return parseOptions(args, "remediation-map admit", {
212
- sweepId: { flag: "--sweep-id", required: true },
213
- topicId: { flag: "--topic-id", required: true },
214
- json: { default: false },
215
- });
216
- }
217
-
218
- function parseFindingResolveOptions(args) {
219
- return parseOptions(args, "finding resolve", {
220
- sweepId: { flag: "--sweep-id", required: true },
221
- findingId: { flag: "--finding-id", required: true },
222
- disposition: { flag: "--disposition", required: true },
223
- fromPath: { flag: "--from", required: true },
224
- verifiedAt: { flag: "--verified-at", required: true },
225
- json: { default: false },
226
- });
227
- }
228
-
229
- function parseSweepIdOptions(args, commandName, timestampRequired = false) {
230
- return parseOptions(args, commandName, {
231
- sweepId: { flag: "--sweep-id", required: true },
232
- verifiedAt: { flag: "--verified-at", required: timestampRequired },
233
- json: { default: false },
234
- });
235
- }
236
-
237
- function parseValidateOptions(args) {
238
- return parseOptions(args, "validate", {
239
- sweepId: { flag: "--sweep-id", required: true },
240
- scope: { flag: "--scope", default: "all" },
241
- json: { default: false },
242
- });
243
- }
244
-
245
- function parseAuditSweepOptions(args) {
246
- const [command, subcommand] = args;
247
- if (command === "plan") {
248
- return { ok: true, action: "plan", parsed: parsePlanOptions(args.slice(1)) };
249
- }
250
- if (command === "chunk" && subcommand === "dispatch") {
251
- return { ok: true, action: "chunk-dispatch", parsed: parseChunkDispatchOptions(args.slice(2)) };
252
- }
253
- if (command === "chunk" && subcommand === "ingest") {
254
- return { ok: true, action: "chunk-ingest", parsed: parseChunkIngestOptions(args.slice(2)) };
255
- }
256
- if (command === "chunk" && subcommand === "audit-codex") {
257
- return { ok: true, action: "chunk-audit-codex", parsed: parseChunkAuditCodexOptions(args.slice(2)) };
258
- }
259
- if (command === "chunk" && subcommand === "audit-claude") {
260
- return { ok: true, action: "chunk-audit-claude", parsed: parseChunkAuditClaudeOptions(args.slice(2)) };
261
- }
262
- if (command === "chunk" && subcommand === "review") {
263
- return { ok: true, action: "chunk-review", parsed: parseChunkReviewOptions(args.slice(2)) };
264
- }
265
- if (command === "chunk" && subcommand === "skip") {
266
- return { ok: true, action: "chunk-skip", parsed: parseChunkSkipOptions(args.slice(2)) };
267
- }
268
- if (command === "ledger" && subcommand === "build") {
269
- return { ok: true, action: "ledger-build", parsed: parseLedgerBuildOptions(args.slice(2)) };
270
- }
271
- if (command === "remediation-map" && subcommand === "build") {
272
- return { ok: true, action: "remediation-map-build", parsed: parseRemediationMapBuildOptions(args.slice(2)) };
273
- }
274
- if (command === "remediation-map" && subcommand === "admit") {
275
- return { ok: true, action: "remediation-map-admit", parsed: parseRemediationMapAdmitOptions(args.slice(2)) };
276
- }
277
- if (command === "finding" && subcommand === "resolve") {
278
- return { ok: true, action: "finding-resolve", parsed: parseFindingResolveOptions(args.slice(2)) };
279
- }
280
- if (command === "closeout" && subcommand === "summary") {
281
- return { ok: true, action: "closeout-summary", parsed: parseSweepIdOptions(args.slice(2), "closeout summary", true) };
282
- }
283
- if (command === "status") {
284
- return { ok: true, action: "status", parsed: parseSweepIdOptions(args.slice(1), "status") };
285
- }
286
- if (command === "validate") {
287
- return { ok: true, action: "validate", parsed: parseValidateOptions(args.slice(1)) };
288
- }
289
-
290
- return {
291
- ok: false,
292
- error: `${localize(
293
- "nimicoding sweep audit refused: expected one of `plan`, `chunk dispatch`, `chunk audit-codex`, `chunk audit-claude`, `chunk ingest`, `chunk review`, `chunk skip`, `ledger build`, `remediation-map build`, `remediation-map admit`, `finding resolve`, `closeout summary`, `status`, or `validate`.",
294
- "nimicoding sweep audit 已拒绝:需要使用 `plan`、`chunk dispatch`、`chunk audit-codex`、`chunk audit-claude`、`chunk ingest`、`chunk review`、`chunk skip`、`ledger build`、`remediation-map build`、`remediation-map admit`、`finding resolve`、`closeout summary`、`status` 或 `validate`。",
295
- )}\n`,
296
- };
297
- }
298
-
299
- function writeStream(stream, text) {
300
- return new Promise((resolve, reject) => {
301
- stream.write(text, (error) => {
302
- if (error) {
303
- reject(error);
304
- return;
305
- }
306
- resolve();
307
- });
308
- });
309
- }
310
-
311
- export async function runAuditSweep(args) {
312
- const selected = parseAuditSweepOptions(args);
313
- if (!selected.ok) {
314
- process.stderr.write(selected.error);
315
- return 2;
316
- }
317
- if (!selected.parsed.ok) {
318
- process.stderr.write(selected.parsed.error);
319
- return 2;
320
- }
321
-
322
- const runners = {
323
- plan: createAuditSweepPlan,
324
- "chunk-dispatch": dispatchAuditSweepChunk,
325
- "chunk-ingest": ingestAuditSweepChunk,
326
- "chunk-audit-codex": runCodexAuditSweepChunk,
327
- "chunk-audit-claude": runClaudeAuditSweepChunk,
328
- "chunk-review": reviewAuditSweepChunk,
329
- "chunk-skip": skipAuditSweepChunk,
330
- "ledger-build": buildAuditSweepLedger,
331
- "remediation-map-build": buildAuditSweepRemediationMap,
332
- "remediation-map-admit": admitAuditSweepRemediationMap,
333
- "finding-resolve": resolveAuditSweepFinding,
334
- "closeout-summary": buildAuditSweepCloseoutImport,
335
- status: getAuditSweepStatus,
336
- validate: validateAuditSweepArtifacts,
337
- };
338
- const payload = await runners[selected.action](process.cwd(), selected.parsed.options);
339
- if (payload.inputError) {
340
- process.stderr.write(payload.error);
341
- return payload.exitCode;
342
- }
343
- if (selected.parsed.options.json) {
344
- await writeStream(process.stdout, `${JSON.stringify(payload, null, 2)}\n`);
345
- } else {
346
- await writeStream(process.stdout, formatAuditSweepPayload(payload));
347
- }
348
- return payload.exitCode;
349
- }
350
-
351
- export {
352
- parseAuditSweepOptions,
353
- parseChunkAuditClaudeOptions,
354
- parseChunkAuditCodexOptions,
355
- parseChunkDispatchOptions,
356
- parseChunkIngestOptions,
357
- parseChunkReviewOptions,
358
- parseChunkSkipOptions,
359
- parseFindingResolveOptions,
360
- parsePlanOptions,
361
- parseRemediationMapAdmitOptions,
362
- parseRemediationMapBuildOptions,
363
- parseValidateOptions,
364
- };
@@ -1,186 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
-
4
- import {
5
- buildCloseoutPayload,
6
- formatCloseoutPayload,
7
- loadImportedCloseoutOptions,
8
- } from "../lib/shared.mjs";
9
- import { localize } from "../lib/ui.mjs";
10
-
11
- function parseCloseoutOptions(args) {
12
- const options = {
13
- json: false,
14
- writeLocal: false,
15
- fromPath: null,
16
- skill: null,
17
- outcome: null,
18
- verifiedAt: null,
19
- };
20
-
21
- for (let index = 0; index < args.length; index += 1) {
22
- const arg = args[index];
23
-
24
- if (arg === "--json") {
25
- options.json = true;
26
- continue;
27
- }
28
-
29
- if (arg === "--write-local") {
30
- options.writeLocal = true;
31
- continue;
32
- }
33
-
34
- if (arg === "--skill" || arg === "--outcome" || arg === "--verified-at" || arg === "--from") {
35
- const next = args[index + 1];
36
- if (!next || next.startsWith("--")) {
37
- return {
38
- ok: false,
39
- error: `${localize(
40
- `nimicoding closeout refused: ${arg} requires a value.`,
41
- `nimicoding closeout 已拒绝:${arg} 需要一个值。`,
42
- )}\n`,
43
- };
44
- }
45
-
46
- if (arg === "--skill") {
47
- options.skill = next;
48
- } else if (arg === "--outcome") {
49
- options.outcome = next;
50
- } else if (arg === "--from") {
51
- options.fromPath = next;
52
- } else {
53
- options.verifiedAt = next;
54
- }
55
- index += 1;
56
- continue;
57
- }
58
-
59
- return {
60
- ok: false,
61
- error: `${localize(
62
- `nimicoding closeout refused: unknown option ${arg}.`,
63
- `nimicoding closeout 已拒绝:未知选项 ${arg}。`,
64
- )}\n`,
65
- };
66
- }
67
-
68
- if (options.fromPath && (options.skill || options.outcome || options.verifiedAt)) {
69
- return {
70
- ok: false,
71
- error: `${localize(
72
- "nimicoding closeout refused: --from cannot be combined with --skill, --outcome, or --verified-at.",
73
- "nimicoding closeout 已拒绝:`--from` 不能与 `--skill`、`--outcome` 或 `--verified-at` 同时使用。",
74
- )}\n`,
75
- };
76
- }
77
-
78
- if (options.fromPath) {
79
- return {
80
- ok: true,
81
- options,
82
- };
83
- }
84
-
85
- if (!options.skill) {
86
- return {
87
- ok: false,
88
- error: `${localize(
89
- "nimicoding closeout refused: explicit --skill is required.",
90
- "nimicoding closeout 已拒绝:必须显式提供 `--skill`。",
91
- )}\n`,
92
- };
93
- }
94
-
95
- if (!options.outcome) {
96
- return {
97
- ok: false,
98
- error: `${localize(
99
- "nimicoding closeout refused: explicit --outcome is required.",
100
- "nimicoding closeout 已拒绝:必须显式提供 `--outcome`。",
101
- )}\n`,
102
- };
103
- }
104
-
105
- if (!["completed", "blocked", "failed"].includes(options.outcome)) {
106
- return {
107
- ok: false,
108
- error: `${localize(
109
- `nimicoding closeout refused: unsupported outcome ${options.outcome}.`,
110
- `nimicoding closeout 已拒绝:不支持的 outcome ${options.outcome}。`,
111
- )}\n`,
112
- };
113
- }
114
-
115
- if (!options.verifiedAt) {
116
- return {
117
- ok: false,
118
- error: `${localize(
119
- "nimicoding closeout refused: explicit --verified-at is required.",
120
- "nimicoding closeout 已拒绝:必须显式提供 `--verified-at`。",
121
- )}\n`,
122
- };
123
- }
124
-
125
- const verifiedDate = new Date(options.verifiedAt);
126
- if (Number.isNaN(verifiedDate.getTime()) || verifiedDate.toISOString() !== options.verifiedAt) {
127
- return {
128
- ok: false,
129
- error: `${localize(
130
- "nimicoding closeout refused: --verified-at must be an ISO-8601 UTC timestamp.",
131
- "nimicoding closeout 已拒绝:`--verified-at` 必须是 ISO-8601 UTC 时间戳。",
132
- )}\n`,
133
- };
134
- }
135
-
136
- return {
137
- ok: true,
138
- options,
139
- };
140
- }
141
-
142
- export async function runCloseout(args) {
143
- const parsed = parseCloseoutOptions(args);
144
- if (!parsed.ok) {
145
- process.stderr.write(parsed.error);
146
- return 2;
147
- }
148
-
149
- let effectiveOptions = parsed.options;
150
- if (parsed.options.fromPath) {
151
- const imported = await loadImportedCloseoutOptions(process.cwd(), parsed.options.fromPath);
152
- if (!imported.ok) {
153
- process.stderr.write(imported.error);
154
- return 2;
155
- }
156
-
157
- effectiveOptions = {
158
- ...parsed.options,
159
- ...imported.options,
160
- };
161
- }
162
-
163
- const payload = await buildCloseoutPayload(process.cwd(), effectiveOptions);
164
- if (payload.inputError) {
165
- process.stderr.write(payload.error);
166
- if (parsed.options.json) {
167
- process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
168
- }
169
- return payload.exitCode;
170
- }
171
-
172
- if (payload.ok && parsed.options.writeLocal) {
173
- await mkdir(path.dirname(payload.artifactPath), { recursive: true });
174
- await writeFile(payload.artifactPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
175
- }
176
-
177
- if (parsed.options.json) {
178
- process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
179
- } else {
180
- process.stdout.write(formatCloseoutPayload(payload));
181
- }
182
-
183
- return payload.exitCode;
184
- }
185
-
186
- export { parseCloseoutOptions };
@@ -1,124 +0,0 @@
1
- import { mkdir, writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
-
4
- import {
5
- buildHighRiskDecisionPayload,
6
- formatHighRiskDecisionPayload,
7
- } from "../lib/high-risk-decision.mjs";
8
- import { localize } from "../lib/ui.mjs";
9
-
10
- function parseDecideHighRiskExecutionOptions(args) {
11
- const options = {
12
- fromPath: null,
13
- acceptancePath: null,
14
- verifiedAt: null,
15
- json: false,
16
- writeLocal: false,
17
- };
18
-
19
- for (let index = 0; index < args.length; index += 1) {
20
- const arg = args[index];
21
-
22
- if (arg === "--json") {
23
- options.json = true;
24
- continue;
25
- }
26
-
27
- if (arg === "--write-local") {
28
- options.writeLocal = true;
29
- continue;
30
- }
31
-
32
- if (arg === "--from" || arg === "--acceptance" || arg === "--verified-at") {
33
- const next = args[index + 1];
34
- if (!next || next.startsWith("--")) {
35
- return {
36
- ok: false,
37
- error: `${localize(
38
- `nimicoding decide-high-risk-execution refused: ${arg} requires a value.`,
39
- `nimicoding decide-high-risk-execution 已拒绝:${arg} 需要一个值。`,
40
- )}\n`,
41
- };
42
- }
43
-
44
- if (arg === "--from") {
45
- options.fromPath = next;
46
- } else if (arg === "--acceptance") {
47
- options.acceptancePath = next;
48
- } else {
49
- options.verifiedAt = next;
50
- }
51
- index += 1;
52
- continue;
53
- }
54
-
55
- return {
56
- ok: false,
57
- error: `${localize(
58
- `nimicoding decide-high-risk-execution refused: unknown option ${arg}.`,
59
- `nimicoding decide-high-risk-execution 已拒绝:未知选项 ${arg}。`,
60
- )}\n`,
61
- };
62
- }
63
-
64
- if (!options.fromPath) {
65
- return {
66
- ok: false,
67
- error: `${localize(
68
- "nimicoding decide-high-risk-execution refused: explicit --from is required.",
69
- "nimicoding decide-high-risk-execution 已拒绝:必须显式提供 `--from`。",
70
- )}\n`,
71
- };
72
- }
73
-
74
- if (!options.acceptancePath) {
75
- return {
76
- ok: false,
77
- error: `${localize(
78
- "nimicoding decide-high-risk-execution refused: explicit --acceptance is required.",
79
- "nimicoding decide-high-risk-execution 已拒绝:必须显式提供 `--acceptance`。",
80
- )}\n`,
81
- };
82
- }
83
-
84
- if (!options.verifiedAt) {
85
- return {
86
- ok: false,
87
- error: `${localize(
88
- "nimicoding decide-high-risk-execution refused: explicit --verified-at is required.",
89
- "nimicoding decide-high-risk-execution 已拒绝:必须显式提供 `--verified-at`。",
90
- )}\n`,
91
- };
92
- }
93
-
94
- return { ok: true, options };
95
- }
96
-
97
- export async function runDecideHighRiskExecution(args) {
98
- const parsed = parseDecideHighRiskExecutionOptions(args);
99
- if (!parsed.ok) {
100
- process.stderr.write(parsed.error);
101
- return 2;
102
- }
103
-
104
- const payload = await buildHighRiskDecisionPayload(process.cwd(), parsed.options);
105
- if (payload.inputError) {
106
- process.stderr.write(payload.error);
107
- return payload.exitCode;
108
- }
109
-
110
- if (parsed.options.writeLocal && payload.ok) {
111
- await mkdir(path.dirname(payload.artifactPath), { recursive: true });
112
- await writeFile(payload.artifactPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
113
- }
114
-
115
- if (parsed.options.json) {
116
- process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
117
- } else {
118
- process.stdout.write(formatHighRiskDecisionPayload(payload));
119
- }
120
-
121
- return payload.exitCode;
122
- }
123
-
124
- export { parseDecideHighRiskExecutionOptions };