@nimiplatform/nimi-coding 0.1.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 (186) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +348 -0
  3. package/adapters/README.md +25 -0
  4. package/adapters/claude/README.md +89 -0
  5. package/adapters/claude/profile.yaml +70 -0
  6. package/adapters/codex/README.md +53 -0
  7. package/adapters/codex/profile.yaml +78 -0
  8. package/adapters/oh-my-codex/README.md +185 -0
  9. package/adapters/oh-my-codex/profile.yaml +46 -0
  10. package/bin/nimicoding.mjs +6 -0
  11. package/cli/commands/admit-high-risk-decision.mjs +108 -0
  12. package/cli/commands/audit-sweep.mjs +341 -0
  13. package/cli/commands/blueprint-audit.mjs +91 -0
  14. package/cli/commands/clear.mjs +168 -0
  15. package/cli/commands/closeout.mjs +183 -0
  16. package/cli/commands/decide-high-risk-execution.mjs +124 -0
  17. package/cli/commands/doctor.mjs +53 -0
  18. package/cli/commands/generate-spec-derived-docs.mjs +131 -0
  19. package/cli/commands/handoff.mjs +123 -0
  20. package/cli/commands/ingest-high-risk-execution.mjs +95 -0
  21. package/cli/commands/review-high-risk-execution.mjs +95 -0
  22. package/cli/commands/start.mjs +717 -0
  23. package/cli/commands/topic-formatters.mjs +382 -0
  24. package/cli/commands/topic-goal.mjs +33 -0
  25. package/cli/commands/topic-options-shared.mjs +27 -0
  26. package/cli/commands/topic-options-workflow.mjs +767 -0
  27. package/cli/commands/topic-options.mjs +626 -0
  28. package/cli/commands/topic-runner.mjs +169 -0
  29. package/cli/commands/topic.mjs +795 -0
  30. package/cli/commands/validate-acceptance.mjs +5 -0
  31. package/cli/commands/validate-ai-governance.mjs +214 -0
  32. package/cli/commands/validate-execution-packet.mjs +5 -0
  33. package/cli/commands/validate-orchestration-state.mjs +5 -0
  34. package/cli/commands/validate-prompt.mjs +5 -0
  35. package/cli/commands/validate-spec-audit.mjs +27 -0
  36. package/cli/commands/validate-spec-governance.mjs +124 -0
  37. package/cli/commands/validate-spec-tree.mjs +27 -0
  38. package/cli/commands/validate-worker-output.mjs +5 -0
  39. package/cli/constants.mjs +489 -0
  40. package/cli/help.mjs +134 -0
  41. package/cli/index.mjs +103 -0
  42. package/cli/lib/adapter-profiles.mjs +403 -0
  43. package/cli/lib/audit-execution.mjs +52 -0
  44. package/cli/lib/audit-sweep-runtime/admissions.mjs +381 -0
  45. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +333 -0
  46. package/cli/lib/audit-sweep-runtime/chunks.mjs +697 -0
  47. package/cli/lib/audit-sweep-runtime/closeout.mjs +144 -0
  48. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +639 -0
  49. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +515 -0
  50. package/cli/lib/audit-sweep-runtime/common.mjs +329 -0
  51. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +172 -0
  52. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +152 -0
  53. package/cli/lib/audit-sweep-runtime/format.mjs +57 -0
  54. package/cli/lib/audit-sweep-runtime/ingest.mjs +486 -0
  55. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +198 -0
  56. package/cli/lib/audit-sweep-runtime/inventory.mjs +728 -0
  57. package/cli/lib/audit-sweep-runtime/ledger.mjs +315 -0
  58. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +101 -0
  59. package/cli/lib/audit-sweep-runtime/remediation.mjs +349 -0
  60. package/cli/lib/audit-sweep-runtime/rerun.mjs +129 -0
  61. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +300 -0
  62. package/cli/lib/audit-sweep-runtime/status.mjs +62 -0
  63. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +215 -0
  64. package/cli/lib/audit-sweep-runtime/validators.mjs +758 -0
  65. package/cli/lib/audit-sweep.mjs +18 -0
  66. package/cli/lib/authority-convergence.mjs +309 -0
  67. package/cli/lib/blueprint-audit.mjs +370 -0
  68. package/cli/lib/bootstrap.mjs +228 -0
  69. package/cli/lib/closeout.mjs +623 -0
  70. package/cli/lib/codex-sdk-runner.mjs +76 -0
  71. package/cli/lib/contracts.mjs +180 -0
  72. package/cli/lib/doctor.mjs +18 -0
  73. package/cli/lib/entrypoints.mjs +274 -0
  74. package/cli/lib/external-execution.mjs +101 -0
  75. package/cli/lib/fs-helpers.mjs +33 -0
  76. package/cli/lib/handoff.mjs +785 -0
  77. package/cli/lib/high-risk-admission.mjs +442 -0
  78. package/cli/lib/high-risk-decision.mjs +324 -0
  79. package/cli/lib/high-risk-ingest.mjs +317 -0
  80. package/cli/lib/high-risk-review.mjs +263 -0
  81. package/cli/lib/internal/contracts-loaders.mjs +132 -0
  82. package/cli/lib/internal/contracts-parse-high-risk.mjs +131 -0
  83. package/cli/lib/internal/contracts-parse.mjs +457 -0
  84. package/cli/lib/internal/contracts-validators.mjs +398 -0
  85. package/cli/lib/internal/doctor-bootstrap-surface.mjs +359 -0
  86. package/cli/lib/internal/doctor-delegated-surface.mjs +256 -0
  87. package/cli/lib/internal/doctor-finalize.mjs +385 -0
  88. package/cli/lib/internal/doctor-format.mjs +286 -0
  89. package/cli/lib/internal/doctor-inspectors.mjs +294 -0
  90. package/cli/lib/internal/doctor-state.mjs +205 -0
  91. package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +315 -0
  92. package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +358 -0
  93. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +155 -0
  94. package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +173 -0
  95. package/cli/lib/internal/governance/config.mjs +150 -0
  96. package/cli/lib/internal/governance/runner.mjs +35 -0
  97. package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +49 -0
  98. package/cli/lib/internal/validators-artifacts.mjs +515 -0
  99. package/cli/lib/internal/validators-shared.mjs +28 -0
  100. package/cli/lib/internal/validators-spec-helpers.mjs +186 -0
  101. package/cli/lib/internal/validators-spec.mjs +410 -0
  102. package/cli/lib/shared.mjs +83 -0
  103. package/cli/lib/topic-draft-packets.mjs +48 -0
  104. package/cli/lib/topic-goal.mjs +361 -0
  105. package/cli/lib/topic-runner.mjs +772 -0
  106. package/cli/lib/topic.mjs +93 -0
  107. package/cli/lib/ui.mjs +178 -0
  108. package/cli/lib/validators.mjs +78 -0
  109. package/cli/lib/value-helpers.mjs +24 -0
  110. package/cli/lib/yaml-helpers.mjs +133 -0
  111. package/cli/nimicoding.mjs +1 -0
  112. package/cli/seeds/bootstrap.mjs +47 -0
  113. package/config/audit-execution-artifacts.yaml +20 -0
  114. package/config/bootstrap.yaml +6 -0
  115. package/config/external-execution-artifacts.yaml +16 -0
  116. package/config/host-adapter.yaml +30 -0
  117. package/config/host-profile.yaml +29 -0
  118. package/config/installer-evidence.yaml +31 -0
  119. package/config/skill-installer.yaml +23 -0
  120. package/config/skill-manifest.yaml +46 -0
  121. package/config/skills.yaml +30 -0
  122. package/config/spec-generation-inputs.yaml +25 -0
  123. package/contracts/acceptance.schema.yaml +16 -0
  124. package/contracts/admission-checklist.schema.yaml +15 -0
  125. package/contracts/audit-chunk.schema.yaml +110 -0
  126. package/contracts/audit-closeout.schema.yaml +51 -0
  127. package/contracts/audit-finding.schema.yaml +61 -0
  128. package/contracts/audit-ledger.schema.yaml +138 -0
  129. package/contracts/audit-plan.schema.yaml +123 -0
  130. package/contracts/audit-remediation-map.schema.yaml +51 -0
  131. package/contracts/audit-rerun.schema.yaml +31 -0
  132. package/contracts/audit-sweep-result.yaml +49 -0
  133. package/contracts/authority-convergence-audit.schema.yaml +19 -0
  134. package/contracts/closeout.schema.yaml +25 -0
  135. package/contracts/decision-review.schema.yaml +16 -0
  136. package/contracts/doc-spec-audit-result.yaml +19 -0
  137. package/contracts/execution-packet.schema.yaml +49 -0
  138. package/contracts/external-host-compatibility.yaml +22 -0
  139. package/contracts/forbidden-shortcuts.catalog.yaml +23 -0
  140. package/contracts/high-risk-admission.schema.yaml +23 -0
  141. package/contracts/high-risk-execution-result.yaml +20 -0
  142. package/contracts/orchestration-state.schema.yaml +41 -0
  143. package/contracts/overflow-continuation.schema.yaml +12 -0
  144. package/contracts/packet.schema.yaml +30 -0
  145. package/contracts/pending-note.schema.yaml +17 -0
  146. package/contracts/prompt.schema.yaml +12 -0
  147. package/contracts/remediation.schema.yaml +16 -0
  148. package/contracts/result.schema.yaml +24 -0
  149. package/contracts/spec-generation-audit.schema.yaml +31 -0
  150. package/contracts/spec-generation-inputs.schema.yaml +39 -0
  151. package/contracts/spec-reconstruction-result.yaml +37 -0
  152. package/contracts/topic-goal.schema.yaml +78 -0
  153. package/contracts/topic-run-ledger.schema.yaml +72 -0
  154. package/contracts/topic-step-decision.schema.yaml +45 -0
  155. package/contracts/topic.schema.yaml +65 -0
  156. package/contracts/true-close.schema.yaml +15 -0
  157. package/contracts/wave.schema.yaml +29 -0
  158. package/contracts/worker-output.schema.yaml +15 -0
  159. package/methodology/audit-sweep-p0p1-recall.yaml +45 -0
  160. package/methodology/authority-convergence-policy.yaml +42 -0
  161. package/methodology/core.yaml +25 -0
  162. package/methodology/four-closure-policy.yaml +28 -0
  163. package/methodology/overflow-continuation-policy.yaml +14 -0
  164. package/methodology/role-separation-policy.yaml +28 -0
  165. package/methodology/skill-exchange-projection.yaml +114 -0
  166. package/methodology/skill-handoff.yaml +34 -0
  167. package/methodology/skill-installer-result.yaml +27 -0
  168. package/methodology/skill-installer-summary-projection.yaml +181 -0
  169. package/methodology/skill-runtime.yaml +23 -0
  170. package/methodology/spec-reconstruction.yaml +63 -0
  171. package/methodology/spec-target-truth-profile.yaml +53 -0
  172. package/methodology/topic-lifecycle-report.yaml +144 -0
  173. package/methodology/topic-lifecycle.yaml +37 -0
  174. package/methodology/topic-naming-ontology.yaml +21 -0
  175. package/methodology/topic-ontology.yaml +38 -0
  176. package/methodology/topic-validation-policy.yaml +9 -0
  177. package/methodology/wave-dag-policy.yaml +14 -0
  178. package/package.json +50 -0
  179. package/spec/_meta/command-gating-matrix.yaml +110 -0
  180. package/spec/_meta/generate-drift-migration-checklist.yaml +155 -0
  181. package/spec/_meta/governance-routing-cutover-checklist.yaml +35 -0
  182. package/spec/_meta/phase2-impacted-surface-matrix.yaml +44 -0
  183. package/spec/_meta/spec-authority-cutover-readiness.yaml +104 -0
  184. package/spec/_meta/spec-tree-model.yaml +72 -0
  185. package/spec/bootstrap-state.yaml +99 -0
  186. package/spec/product-scope.yaml +56 -0
@@ -0,0 +1,767 @@
1
+ import { localize } from "../lib/ui.mjs";
2
+ import { validateTopicSlug, validateWaveId } from "../lib/topic.mjs";
3
+ import { requireOptionValue, validateEnumOption } from "./topic-options-shared.mjs";
4
+
5
+ const TOPIC_RESULT_KIND_INPUT_ENUM = ["worker", "implementation", "audit", "preflight", "judgement"];
6
+
7
+ function normalizeResultKindInput(value) {
8
+ if (value === "worker") {
9
+ return "implementation";
10
+ }
11
+ return value;
12
+ }
13
+ export function parseWaveAddOptions(args) {
14
+ const [topicInput, waveId, slug, ...rest] = args;
15
+ if (!topicInput || !waveId || !slug) {
16
+ return {
17
+ ok: false,
18
+ error: `${localize(
19
+ "nimicoding topic wave add refused: expected <topic-id> <wave-id> <slug>.",
20
+ "nimicoding topic wave add 已拒绝:需要 <topic-id> <wave-id> <slug>。",
21
+ )}\n`,
22
+ };
23
+ }
24
+ if (!validateWaveId(waveId)) {
25
+ return {
26
+ ok: false,
27
+ error: `${localize(
28
+ `nimicoding topic wave add refused: invalid wave id ${waveId}. Use wave-<...>.`,
29
+ `nimicoding topic wave add 已拒绝:无效 wave id ${waveId}。请使用 wave-<...>。`,
30
+ )}\n`,
31
+ };
32
+ }
33
+ if (!validateTopicSlug(slug)) {
34
+ return {
35
+ ok: false,
36
+ error: `${localize(
37
+ `nimicoding topic wave add refused: invalid slug ${slug}.`,
38
+ `nimicoding topic wave add 已拒绝:无效 slug ${slug}。`,
39
+ )}\n`,
40
+ };
41
+ }
42
+ const options = {
43
+ topicInput,
44
+ waveId,
45
+ slug,
46
+ goal: null,
47
+ ownerDomain: null,
48
+ parallelizableAfter: "stable_contract",
49
+ deps: [],
50
+ json: false,
51
+ };
52
+ for (let index = 0; index < rest.length; index += 1) {
53
+ const arg = rest[index];
54
+ const next = rest[index + 1];
55
+ if (arg === "--json") {
56
+ options.json = true;
57
+ continue;
58
+ }
59
+ if (arg === "--goal") {
60
+ const valueCheck = requireOptionValue("--goal", next, "nimicoding topic wave add refused");
61
+ if (!valueCheck.ok) {
62
+ return valueCheck;
63
+ }
64
+ options.goal = next;
65
+ index += 1;
66
+ continue;
67
+ }
68
+ if (arg === "--owner-domain") {
69
+ const valueCheck = requireOptionValue("--owner-domain", next, "nimicoding topic wave add refused");
70
+ if (!valueCheck.ok) {
71
+ return valueCheck;
72
+ }
73
+ options.ownerDomain = next;
74
+ index += 1;
75
+ continue;
76
+ }
77
+ if (arg === "--parallelizable-after") {
78
+ const valueCheck = requireOptionValue("--parallelizable-after", next, "nimicoding topic wave add refused");
79
+ if (!valueCheck.ok) {
80
+ return valueCheck;
81
+ }
82
+ options.parallelizableAfter = next;
83
+ index += 1;
84
+ continue;
85
+ }
86
+ if (arg === "--dep") {
87
+ const valueCheck = requireOptionValue("--dep", next, "nimicoding topic wave add refused");
88
+ if (!valueCheck.ok) {
89
+ return valueCheck;
90
+ }
91
+ options.deps.push(next);
92
+ index += 1;
93
+ continue;
94
+ }
95
+ return {
96
+ ok: false,
97
+ error: `${localize(
98
+ `nimicoding topic wave add refused: unknown option ${arg}.`,
99
+ `nimicoding topic wave add 已拒绝:未知选项 ${arg}。`,
100
+ )}\n`,
101
+ };
102
+ }
103
+ if (!options.goal || !options.ownerDomain) {
104
+ return {
105
+ ok: false,
106
+ error: `${localize(
107
+ "nimicoding topic wave add refused: --goal and --owner-domain are required.",
108
+ "nimicoding topic wave add 已拒绝:必须提供 --goal 和 --owner-domain。",
109
+ )}\n`,
110
+ };
111
+ }
112
+ return { ok: true, options };
113
+ }
114
+ export function parseWaveActionOptions(args, action) {
115
+ const [topicInput, waveId, ...rest] = args;
116
+ if (!topicInput || !waveId) {
117
+ return {
118
+ ok: false,
119
+ error: `${localize(
120
+ `nimicoding topic wave ${action} refused: expected <topic-id> <wave-id>.`,
121
+ `nimicoding topic wave ${action} 已拒绝:需要 <topic-id> <wave-id>。`,
122
+ )}\n`,
123
+ };
124
+ }
125
+ const options = { topicInput, waveId, json: false };
126
+ for (const arg of rest) {
127
+ if (arg === "--json") {
128
+ options.json = true;
129
+ continue;
130
+ }
131
+ return {
132
+ ok: false,
133
+ error: `${localize(
134
+ `nimicoding topic wave ${action} refused: unknown option ${arg}.`,
135
+ `nimicoding topic wave ${action} 已拒绝:未知选项 ${arg}。`,
136
+ )}\n`,
137
+ };
138
+ }
139
+ return { ok: true, options };
140
+ }
141
+ export function parsePacketFreezeOptions(args) {
142
+ const [topicInput, ...rest] = args;
143
+ if (!topicInput) {
144
+ return {
145
+ ok: false,
146
+ error: `${localize(
147
+ "nimicoding topic packet freeze refused: expected <topic-id> and --from <draft-path>.",
148
+ "nimicoding topic packet freeze 已拒绝:需要 <topic-id> 和 --from <draft-path>。",
149
+ )}\n`,
150
+ };
151
+ }
152
+ const options = { topicInput, from: null, json: false };
153
+ for (let index = 0; index < rest.length; index += 1) {
154
+ const arg = rest[index];
155
+ const next = rest[index + 1];
156
+ if (arg === "--json") {
157
+ options.json = true;
158
+ continue;
159
+ }
160
+ if (arg === "--from") {
161
+ const valueCheck = requireOptionValue("--from", next, "nimicoding topic packet freeze refused");
162
+ if (!valueCheck.ok) {
163
+ return valueCheck;
164
+ }
165
+ options.from = next;
166
+ index += 1;
167
+ continue;
168
+ }
169
+ return {
170
+ ok: false,
171
+ error: `${localize(
172
+ `nimicoding topic packet freeze refused: unknown option ${arg}.`,
173
+ `nimicoding topic packet freeze 已拒绝:未知选项 ${arg}。`,
174
+ )}\n`,
175
+ };
176
+ }
177
+ if (!options.from) {
178
+ return {
179
+ ok: false,
180
+ error: `${localize(
181
+ "nimicoding topic packet freeze refused: --from is required.",
182
+ "nimicoding topic packet freeze 已拒绝:必须提供 --from。",
183
+ )}\n`,
184
+ };
185
+ }
186
+ return { ok: true, options };
187
+ }
188
+ export function parseDispatchOptions(args, role) {
189
+ const [topicInput, ...rest] = args;
190
+ if (!topicInput) {
191
+ return {
192
+ ok: false,
193
+ error: `${localize(
194
+ `nimicoding topic ${role} dispatch refused: expected <topic-id> and --packet <packet-id>.`,
195
+ `nimicoding topic ${role} dispatch 已拒绝:需要 <topic-id> 和 --packet <packet-id>。`,
196
+ )}\n`,
197
+ };
198
+ }
199
+ const options = { topicInput, packetId: null, json: false };
200
+ for (let index = 0; index < rest.length; index += 1) {
201
+ const arg = rest[index];
202
+ const next = rest[index + 1];
203
+ if (arg === "--json") {
204
+ options.json = true;
205
+ continue;
206
+ }
207
+ if (arg === "--packet") {
208
+ const valueCheck = requireOptionValue("--packet", next, `nimicoding topic ${role} dispatch refused`);
209
+ if (!valueCheck.ok) {
210
+ return valueCheck;
211
+ }
212
+ options.packetId = next;
213
+ index += 1;
214
+ continue;
215
+ }
216
+ return {
217
+ ok: false,
218
+ error: `${localize(
219
+ `nimicoding topic ${role} dispatch refused: unknown option ${arg}.`,
220
+ `nimicoding topic ${role} dispatch 已拒绝:未知选项 ${arg}。`,
221
+ )}\n`,
222
+ };
223
+ }
224
+ if (!options.packetId) {
225
+ return {
226
+ ok: false,
227
+ error: `${localize(
228
+ `nimicoding topic ${role} dispatch refused: --packet is required.`,
229
+ `nimicoding topic ${role} dispatch 已拒绝:必须提供 --packet。`,
230
+ )}\n`,
231
+ };
232
+ }
233
+ return { ok: true, options };
234
+ }
235
+ export function parseResultRecordOptions(args) {
236
+ const [topicInput, ...rest] = args;
237
+ if (!topicInput) {
238
+ return {
239
+ ok: false,
240
+ error: `${localize(
241
+ "nimicoding topic result record refused: expected <topic-id> and required options.",
242
+ "nimicoding topic result record 已拒绝:需要 <topic-id> 和必填选项。",
243
+ )}\n`,
244
+ };
245
+ }
246
+ const options = {
247
+ topicInput,
248
+ kind: null,
249
+ verdict: null,
250
+ from: null,
251
+ verifiedAt: null,
252
+ json: false,
253
+ };
254
+ for (let index = 0; index < rest.length; index += 1) {
255
+ const arg = rest[index];
256
+ const next = rest[index + 1];
257
+ if (arg === "--json") {
258
+ options.json = true;
259
+ continue;
260
+ }
261
+ if (arg === "--kind") {
262
+ const valueCheck = requireOptionValue("--kind", next, "nimicoding topic result record refused");
263
+ if (!valueCheck.ok) {
264
+ return valueCheck;
265
+ }
266
+ const normalized = normalizeResultKindInput(next);
267
+ const enumCheck = validateEnumOption("--kind", next, TOPIC_RESULT_KIND_INPUT_ENUM, "nimicoding topic result record refused");
268
+ if (!enumCheck.ok) {
269
+ return {
270
+ ok: false,
271
+ error: `${localize(
272
+ `nimicoding topic result record refused: unsupported --kind value ${next}.`,
273
+ `nimicoding topic result record 已拒绝:不支持的 --kind 值 ${next}。`,
274
+ )}\n`,
275
+ };
276
+ }
277
+ options.kind = normalized;
278
+ index += 1;
279
+ continue;
280
+ }
281
+ if (arg === "--verdict") {
282
+ const valueCheck = requireOptionValue("--verdict", next, "nimicoding topic result record refused");
283
+ if (!valueCheck.ok) {
284
+ return valueCheck;
285
+ }
286
+ options.verdict = next;
287
+ index += 1;
288
+ continue;
289
+ }
290
+ if (arg === "--from") {
291
+ const valueCheck = requireOptionValue("--from", next, "nimicoding topic result record refused");
292
+ if (!valueCheck.ok) {
293
+ return valueCheck;
294
+ }
295
+ options.from = next;
296
+ index += 1;
297
+ continue;
298
+ }
299
+ if (arg === "--verified-at") {
300
+ const valueCheck = requireOptionValue("--verified-at", next, "nimicoding topic result record refused");
301
+ if (!valueCheck.ok) {
302
+ return valueCheck;
303
+ }
304
+ options.verifiedAt = next;
305
+ index += 1;
306
+ continue;
307
+ }
308
+ return {
309
+ ok: false,
310
+ error: `${localize(
311
+ `nimicoding topic result record refused: unknown option ${arg}.`,
312
+ `nimicoding topic result record 已拒绝:未知选项 ${arg}。`,
313
+ )}\n`,
314
+ };
315
+ }
316
+ if (!options.kind || !options.verdict || !options.from || !options.verifiedAt) {
317
+ return {
318
+ ok: false,
319
+ error: `${localize(
320
+ "nimicoding topic result record refused: --kind, --verdict, --from, and --verified-at are required.",
321
+ "nimicoding topic result record 已拒绝:必须提供 --kind、--verdict、--from 和 --verified-at。",
322
+ )}\n`,
323
+ };
324
+ }
325
+ return { ok: true, options };
326
+ }
327
+ export function parseDecisionReviewOptions(args) {
328
+ const [topicInput, slug, ...rest] = args;
329
+ if (!topicInput || !slug) {
330
+ return {
331
+ ok: false,
332
+ error: `${localize(
333
+ "nimicoding topic decision-review refused: expected <topic-id> <slug> and required options.",
334
+ "nimicoding topic decision-review 已拒绝:需要 <topic-id> <slug> 和必填选项。",
335
+ )}\n`,
336
+ };
337
+ }
338
+ const options = {
339
+ topicInput,
340
+ slug,
341
+ decision: null,
342
+ replacedScope: null,
343
+ activeReplacementScope: null,
344
+ disposition: "unchanged",
345
+ targetWaveId: null,
346
+ date: new Date().toISOString().slice(0, 10),
347
+ json: false,
348
+ };
349
+ for (let index = 0; index < rest.length; index += 1) {
350
+ const arg = rest[index];
351
+ const next = rest[index + 1];
352
+ if (arg === "--json") {
353
+ options.json = true;
354
+ continue;
355
+ }
356
+ if (arg === "--decision") {
357
+ const valueCheck = requireOptionValue("--decision", next, "nimicoding topic decision-review refused");
358
+ if (!valueCheck.ok) {
359
+ return valueCheck;
360
+ }
361
+ options.decision = next;
362
+ index += 1;
363
+ continue;
364
+ }
365
+ if (arg === "--replaced-scope") {
366
+ const valueCheck = requireOptionValue("--replaced-scope", next, "nimicoding topic decision-review refused");
367
+ if (!valueCheck.ok) {
368
+ return valueCheck;
369
+ }
370
+ options.replacedScope = next;
371
+ index += 1;
372
+ continue;
373
+ }
374
+ if (arg === "--active-replacement-scope") {
375
+ const valueCheck = requireOptionValue("--active-replacement-scope", next, "nimicoding topic decision-review refused");
376
+ if (!valueCheck.ok) {
377
+ return valueCheck;
378
+ }
379
+ options.activeReplacementScope = next;
380
+ index += 1;
381
+ continue;
382
+ }
383
+ if (arg === "--disposition") {
384
+ const valueCheck = requireOptionValue("--disposition", next, "nimicoding topic decision-review refused");
385
+ if (!valueCheck.ok) {
386
+ return valueCheck;
387
+ }
388
+ options.disposition = next;
389
+ index += 1;
390
+ continue;
391
+ }
392
+ if (arg === "--target-wave") {
393
+ const valueCheck = requireOptionValue("--target-wave", next, "nimicoding topic decision-review refused");
394
+ if (!valueCheck.ok) {
395
+ return valueCheck;
396
+ }
397
+ if (!validateWaveId(next)) {
398
+ return {
399
+ ok: false,
400
+ error: `${localize(
401
+ `nimicoding topic decision-review refused: invalid --target-wave value ${next}.`,
402
+ `nimicoding topic decision-review 已拒绝:无效 --target-wave 值 ${next}。`,
403
+ )}\n`,
404
+ };
405
+ }
406
+ options.targetWaveId = next;
407
+ index += 1;
408
+ continue;
409
+ }
410
+ if (arg === "--date") {
411
+ const valueCheck = requireOptionValue("--date", next, "nimicoding topic decision-review refused");
412
+ if (!valueCheck.ok) {
413
+ return valueCheck;
414
+ }
415
+ options.date = next;
416
+ index += 1;
417
+ continue;
418
+ }
419
+ return {
420
+ ok: false,
421
+ error: `${localize(
422
+ `nimicoding topic decision-review refused: unknown option ${arg}.`,
423
+ `nimicoding topic decision-review 已拒绝:未知选项 ${arg}。`,
424
+ )}\n`,
425
+ };
426
+ }
427
+ if (!options.decision || !options.replacedScope || !options.activeReplacementScope) {
428
+ return {
429
+ ok: false,
430
+ error: `${localize(
431
+ "nimicoding topic decision-review refused: --decision, --replaced-scope, and --active-replacement-scope are required.",
432
+ "nimicoding topic decision-review 已拒绝:必须提供 --decision、--replaced-scope 和 --active-replacement-scope。",
433
+ )}\n`,
434
+ };
435
+ }
436
+ return { ok: true, options };
437
+ }
438
+ export function parseRemediationOpenOptions(args) {
439
+ const [topicInput, ...rest] = args;
440
+ if (!topicInput) {
441
+ return {
442
+ ok: false,
443
+ error: `${localize(
444
+ "nimicoding topic remediation open refused: expected <topic-id> and required options.",
445
+ "nimicoding topic remediation open 已拒绝:需要 <topic-id> 和必填选项。",
446
+ )}\n`,
447
+ };
448
+ }
449
+ const options = {
450
+ topicInput,
451
+ kind: null,
452
+ reason: null,
453
+ overflowedPacketId: null,
454
+ json: false,
455
+ };
456
+ for (let index = 0; index < rest.length; index += 1) {
457
+ const arg = rest[index];
458
+ const next = rest[index + 1];
459
+ if (arg === "--json") {
460
+ options.json = true;
461
+ continue;
462
+ }
463
+ if (arg === "--kind") {
464
+ const valueCheck = requireOptionValue("--kind", next, "nimicoding topic remediation open refused");
465
+ if (!valueCheck.ok) {
466
+ return valueCheck;
467
+ }
468
+ const normalized = next.replaceAll("-", "_");
469
+ options.kind = normalized;
470
+ index += 1;
471
+ continue;
472
+ }
473
+ if (arg === "--reason") {
474
+ const valueCheck = requireOptionValue("--reason", next, "nimicoding topic remediation open refused");
475
+ if (!valueCheck.ok) {
476
+ return valueCheck;
477
+ }
478
+ if (!validateTopicSlug(next)) {
479
+ return {
480
+ ok: false,
481
+ error: `${localize(
482
+ `nimicoding topic remediation open refused: --reason must be lowercase kebab-case, found ${next}.`,
483
+ `nimicoding topic remediation open 已拒绝:--reason 必须是小写 kebab-case,当前为 ${next}。`,
484
+ )}\n`,
485
+ };
486
+ }
487
+ options.reason = next;
488
+ index += 1;
489
+ continue;
490
+ }
491
+ if (arg === "--overflowed-packet") {
492
+ const valueCheck = requireOptionValue("--overflowed-packet", next, "nimicoding topic remediation open refused");
493
+ if (!valueCheck.ok) {
494
+ return valueCheck;
495
+ }
496
+ options.overflowedPacketId = next;
497
+ index += 1;
498
+ continue;
499
+ }
500
+ return {
501
+ ok: false,
502
+ error: `${localize(
503
+ `nimicoding topic remediation open refused: unknown option ${arg}.`,
504
+ `nimicoding topic remediation open 已拒绝:未知选项 ${arg}。`,
505
+ )}\n`,
506
+ };
507
+ }
508
+ if (!options.kind || !options.reason) {
509
+ return {
510
+ ok: false,
511
+ error: `${localize(
512
+ "nimicoding topic remediation open refused: --kind and --reason are required.",
513
+ "nimicoding topic remediation open 已拒绝:必须提供 --kind 和 --reason。",
514
+ )}\n`,
515
+ };
516
+ }
517
+ return { ok: true, options };
518
+ }
519
+ export function parseOverflowContinueOptions(args) {
520
+ const [topicInput, ...rest] = args;
521
+ if (!topicInput) {
522
+ return {
523
+ ok: false,
524
+ error: `${localize(
525
+ "nimicoding topic overflow continue refused: expected <topic-id> and required options.",
526
+ "nimicoding topic overflow continue 已拒绝:需要 <topic-id> 和必填选项。",
527
+ )}\n`,
528
+ };
529
+ }
530
+ const options = {
531
+ topicInput,
532
+ continuationPacketId: null,
533
+ overflowedPacketId: null,
534
+ managerJudgement: null,
535
+ sameOwnerDomain: false,
536
+ json: false,
537
+ };
538
+ for (let index = 0; index < rest.length; index += 1) {
539
+ const arg = rest[index];
540
+ const next = rest[index + 1];
541
+ if (arg === "--json") {
542
+ options.json = true;
543
+ continue;
544
+ }
545
+ if (arg === "--packet") {
546
+ const valueCheck = requireOptionValue("--packet", next, "nimicoding topic overflow continue refused");
547
+ if (!valueCheck.ok) {
548
+ return valueCheck;
549
+ }
550
+ options.continuationPacketId = next;
551
+ index += 1;
552
+ continue;
553
+ }
554
+ if (arg === "--overflowed-packet") {
555
+ const valueCheck = requireOptionValue("--overflowed-packet", next, "nimicoding topic overflow continue refused");
556
+ if (!valueCheck.ok) {
557
+ return valueCheck;
558
+ }
559
+ options.overflowedPacketId = next;
560
+ index += 1;
561
+ continue;
562
+ }
563
+ if (arg === "--manager-judgement") {
564
+ const valueCheck = requireOptionValue("--manager-judgement", next, "nimicoding topic overflow continue refused");
565
+ if (!valueCheck.ok) {
566
+ return valueCheck;
567
+ }
568
+ options.managerJudgement = next;
569
+ index += 1;
570
+ continue;
571
+ }
572
+ if (arg === "--same-owner-domain") {
573
+ options.sameOwnerDomain = true;
574
+ continue;
575
+ }
576
+ return {
577
+ ok: false,
578
+ error: `${localize(
579
+ `nimicoding topic overflow continue refused: unknown option ${arg}.`,
580
+ `nimicoding topic overflow continue 已拒绝:未知选项 ${arg}。`,
581
+ )}\n`,
582
+ };
583
+ }
584
+ if (!options.continuationPacketId || !options.overflowedPacketId || !options.managerJudgement || options.sameOwnerDomain !== true) {
585
+ return {
586
+ ok: false,
587
+ error: `${localize(
588
+ "nimicoding topic overflow continue refused: --packet, --overflowed-packet, --manager-judgement, and --same-owner-domain are required.",
589
+ "nimicoding topic overflow continue 已拒绝:必须提供 --packet、--overflowed-packet、--manager-judgement 和 --same-owner-domain。",
590
+ )}\n`,
591
+ };
592
+ }
593
+ return { ok: true, options };
594
+ }
595
+ export function parseCloseoutOptions(args, scope) {
596
+ const [topicInput, maybeWaveId, ...rest] = args;
597
+ if (!topicInput || (scope === "wave" && !maybeWaveId)) {
598
+ return {
599
+ ok: false,
600
+ error: `${localize(
601
+ scope === "wave"
602
+ ? "nimicoding topic closeout wave refused: expected <topic-id> <wave-id> and required closure options."
603
+ : "nimicoding topic closeout topic refused: expected <topic-id> and required closure options.",
604
+ scope === "wave"
605
+ ? "nimicoding topic closeout wave 已拒绝:需要 <topic-id> <wave-id> 和必填 closure 选项。"
606
+ : "nimicoding topic closeout topic 已拒绝:需要 <topic-id> 和必填 closure 选项。",
607
+ )}\n`,
608
+ };
609
+ }
610
+ const options = {
611
+ topicInput,
612
+ waveId: scope === "wave" ? maybeWaveId : null,
613
+ authorityClosure: null,
614
+ semanticClosure: null,
615
+ consumerClosure: null,
616
+ driftResistanceClosure: null,
617
+ disposition: null,
618
+ json: false,
619
+ };
620
+ const remaining = scope === "wave" ? rest : [maybeWaveId, ...rest].filter((entry) => entry !== undefined);
621
+ for (let index = 0; index < remaining.length; index += 1) {
622
+ const arg = remaining[index];
623
+ const next = remaining[index + 1];
624
+ if (arg === "--json") {
625
+ options.json = true;
626
+ continue;
627
+ }
628
+ if (arg === "--authority") {
629
+ const valueCheck = requireOptionValue("--authority", next, `nimicoding topic closeout ${scope} refused`);
630
+ if (!valueCheck.ok) {
631
+ return valueCheck;
632
+ }
633
+ options.authorityClosure = next;
634
+ index += 1;
635
+ continue;
636
+ }
637
+ if (arg === "--semantic") {
638
+ const valueCheck = requireOptionValue("--semantic", next, `nimicoding topic closeout ${scope} refused`);
639
+ if (!valueCheck.ok) {
640
+ return valueCheck;
641
+ }
642
+ options.semanticClosure = next;
643
+ index += 1;
644
+ continue;
645
+ }
646
+ if (arg === "--consumer") {
647
+ const valueCheck = requireOptionValue("--consumer", next, `nimicoding topic closeout ${scope} refused`);
648
+ if (!valueCheck.ok) {
649
+ return valueCheck;
650
+ }
651
+ options.consumerClosure = next;
652
+ index += 1;
653
+ continue;
654
+ }
655
+ if (arg === "--drift-resistance") {
656
+ const valueCheck = requireOptionValue("--drift-resistance", next, `nimicoding topic closeout ${scope} refused`);
657
+ if (!valueCheck.ok) {
658
+ return valueCheck;
659
+ }
660
+ options.driftResistanceClosure = next;
661
+ index += 1;
662
+ continue;
663
+ }
664
+ if (arg === "--disposition") {
665
+ const valueCheck = requireOptionValue("--disposition", next, `nimicoding topic closeout ${scope} refused`);
666
+ if (!valueCheck.ok) {
667
+ return valueCheck;
668
+ }
669
+ options.disposition = next;
670
+ index += 1;
671
+ continue;
672
+ }
673
+ return {
674
+ ok: false,
675
+ error: `${localize(
676
+ `nimicoding topic closeout ${scope} refused: unknown option ${arg}.`,
677
+ `nimicoding topic closeout ${scope} 已拒绝:未知选项 ${arg}。`,
678
+ )}\n`,
679
+ };
680
+ }
681
+ if (!options.authorityClosure || !options.semanticClosure || !options.consumerClosure || !options.driftResistanceClosure || !options.disposition) {
682
+ return {
683
+ ok: false,
684
+ error: `${localize(
685
+ `nimicoding topic closeout ${scope} refused: all four closures and --disposition are required.`,
686
+ `nimicoding topic closeout ${scope} 已拒绝:必须提供四个 closure 和 --disposition。`,
687
+ )}\n`,
688
+ };
689
+ }
690
+ return { ok: true, options };
691
+ }
692
+ export function parseTrueCloseAuditOptions(args) {
693
+ const [topicInput, ...rest] = args;
694
+ if (!topicInput) {
695
+ return {
696
+ ok: false,
697
+ error: `${localize(
698
+ "nimicoding topic true-close-audit refused: expected <topic-id> and --judgement <text>.",
699
+ "nimicoding topic true-close-audit 已拒绝:需要 <topic-id> 和 --judgement <text>。",
700
+ )}\n`,
701
+ };
702
+ }
703
+ const options = {
704
+ topicInput,
705
+ judgement: null,
706
+ json: false,
707
+ };
708
+ for (let index = 0; index < rest.length; index += 1) {
709
+ const arg = rest[index];
710
+ const next = rest[index + 1];
711
+ if (arg === "--json") {
712
+ options.json = true;
713
+ continue;
714
+ }
715
+ if (arg === "--judgement") {
716
+ const valueCheck = requireOptionValue("--judgement", next, "nimicoding topic true-close-audit refused");
717
+ if (!valueCheck.ok) {
718
+ return valueCheck;
719
+ }
720
+ options.judgement = next;
721
+ index += 1;
722
+ continue;
723
+ }
724
+ return {
725
+ ok: false,
726
+ error: `${localize(
727
+ `nimicoding topic true-close-audit refused: unknown option ${arg}.`,
728
+ `nimicoding topic true-close-audit 已拒绝:未知选项 ${arg}。`,
729
+ )}\n`,
730
+ };
731
+ }
732
+ if (!options.judgement) {
733
+ return {
734
+ ok: false,
735
+ error: `${localize(
736
+ "nimicoding topic true-close-audit refused: --judgement is required.",
737
+ "nimicoding topic true-close-audit 已拒绝:必须提供 --judgement。",
738
+ )}\n`,
739
+ };
740
+ }
741
+ return { ok: true, options };
742
+ }
743
+ export function parseGraphValidateOptions(args, commandLabel) {
744
+ const options = { topicInput: null, waveId: null, json: false };
745
+ for (const arg of args) {
746
+ if (arg === "--json") {
747
+ options.json = true;
748
+ continue;
749
+ }
750
+ if (options.topicInput === null) {
751
+ options.topicInput = arg;
752
+ continue;
753
+ }
754
+ if (options.waveId === null) {
755
+ options.waveId = arg;
756
+ continue;
757
+ }
758
+ return {
759
+ ok: false,
760
+ error: `${localize(
761
+ `nimicoding topic ${commandLabel} refused: unknown option ${arg}.`,
762
+ `nimicoding topic ${commandLabel} 已拒绝:未知选项 ${arg}。`,
763
+ )}\n`,
764
+ };
765
+ }
766
+ return { ok: true, options };
767
+ }