@nimiplatform/nimi-coding 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/CHANGELOG.md +8 -92
  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/help.mjs +28 -145
  9. package/cli/index.mjs +5 -33
  10. package/cli/lib/blueprint-audit.mjs +5 -12
  11. package/cli/lib/bootstrap.mjs +0 -9
  12. package/cli/lib/contracts.mjs +0 -163
  13. package/cli/lib/doctor.mjs +155 -10
  14. package/cli/lib/entrypoints.mjs +63 -167
  15. package/cli/lib/internal/contracts-loaders.mjs +0 -85
  16. package/cli/lib/internal/contracts-parse.mjs +84 -520
  17. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
  18. package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
  19. package/cli/lib/internal/validators-shared.mjs +0 -16
  20. package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
  21. package/cli/lib/internal/validators-spec.mjs +103 -342
  22. package/cli/lib/shared.mjs +1 -42
  23. package/cli/lib/validators.mjs +0 -48
  24. package/cli/seeds/seed-policy.yaml +0 -3
  25. package/config/bootstrap.yaml +4 -4
  26. package/config/spec-generation-inputs.yaml +6 -12
  27. package/contracts/domain-admission.schema.yaml +3 -3
  28. package/contracts/migration-inventory.schema.yaml +12 -75
  29. package/contracts/negative-fixtures.yaml +19 -99
  30. package/contracts/placement-contract.schema.yaml +49 -78
  31. package/contracts/projection-edge.schema.yaml +37 -121
  32. package/contracts/shared-enums.yaml +4 -8
  33. package/contracts/spec-generation-inputs.schema.yaml +15 -112
  34. package/contracts/spec-layout.schema.yaml +32 -0
  35. package/contracts/surface-taxonomy.schema.yaml +43 -94
  36. package/contracts/table-family.schema.yaml +1 -1
  37. package/contracts/tracked-output-admission.schema.yaml +13 -66
  38. package/methodology/core.yaml +33 -25
  39. package/methodology/four-closure-policy.yaml +18 -26
  40. package/methodology/role-separation-policy.yaml +21 -27
  41. package/methodology/spec-reconstruction.yaml +17 -34
  42. package/package.json +2 -4
  43. package/spec/_meta/spec-tree-model.yaml +5 -101
  44. package/spec/product-scope.yaml +25 -57
  45. package/adapters/README.md +0 -25
  46. package/adapters/claude/README.md +0 -89
  47. package/adapters/claude/profile.yaml +0 -70
  48. package/adapters/codex/README.md +0 -53
  49. package/adapters/codex/profile.yaml +0 -78
  50. package/adapters/oh-my-codex/README.md +0 -184
  51. package/adapters/oh-my-codex/profile.yaml +0 -46
  52. package/cli/commands/admit-high-risk-decision.mjs +0 -108
  53. package/cli/commands/audit-sweep.mjs +0 -364
  54. package/cli/commands/closeout.mjs +0 -186
  55. package/cli/commands/decide-high-risk-execution.mjs +0 -124
  56. package/cli/commands/handoff.mjs +0 -123
  57. package/cli/commands/ingest-high-risk-execution.mjs +0 -95
  58. package/cli/commands/review-high-risk-execution.mjs +0 -95
  59. package/cli/commands/sweep-design.mjs +0 -295
  60. package/cli/commands/sweep.mjs +0 -22
  61. package/cli/commands/topic-formatters.mjs +0 -382
  62. package/cli/commands/topic-goal.mjs +0 -33
  63. package/cli/commands/topic-options-shared.mjs +0 -27
  64. package/cli/commands/topic-options-workflow.mjs +0 -767
  65. package/cli/commands/topic-options.mjs +0 -626
  66. package/cli/commands/topic-runner.mjs +0 -169
  67. package/cli/commands/topic.mjs +0 -795
  68. package/cli/commands/validate-acceptance.mjs +0 -5
  69. package/cli/commands/validate-execution-packet.mjs +0 -5
  70. package/cli/commands/validate-orchestration-state.mjs +0 -5
  71. package/cli/commands/validate-prompt.mjs +0 -5
  72. package/cli/commands/validate-worker-output.mjs +0 -5
  73. package/cli/lib/adapter-profiles.mjs +0 -403
  74. package/cli/lib/audit-execution.mjs +0 -52
  75. package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
  76. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
  77. package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
  78. package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
  79. package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
  80. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
  81. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
  82. package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
  83. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
  84. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
  85. package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
  86. package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
  87. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
  88. package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
  89. package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
  90. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
  91. package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
  92. package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
  93. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
  94. package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
  95. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
  96. package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
  97. package/cli/lib/audit-sweep.mjs +0 -19
  98. package/cli/lib/authority-convergence.mjs +0 -720
  99. package/cli/lib/closeout.mjs +0 -732
  100. package/cli/lib/codex-sdk-runner.mjs +0 -76
  101. package/cli/lib/external-execution.mjs +0 -101
  102. package/cli/lib/handoff.mjs +0 -812
  103. package/cli/lib/high-risk-admission.mjs +0 -512
  104. package/cli/lib/high-risk-decision.mjs +0 -353
  105. package/cli/lib/high-risk-ingest.mjs +0 -321
  106. package/cli/lib/high-risk-review.mjs +0 -267
  107. package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
  108. package/cli/lib/internal/contracts-validators.mjs +0 -399
  109. package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
  110. package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
  111. package/cli/lib/internal/doctor-finalize.mjs +0 -383
  112. package/cli/lib/internal/doctor-format.mjs +0 -286
  113. package/cli/lib/internal/doctor-inspectors.mjs +0 -327
  114. package/cli/lib/internal/doctor-state.mjs +0 -205
  115. package/cli/lib/internal/validators-artifacts.mjs +0 -515
  116. package/cli/lib/sweep-design-runtime/common.mjs +0 -246
  117. package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
  118. package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
  119. package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
  120. package/cli/lib/sweep-design-runtime/results.mjs +0 -324
  121. package/cli/lib/sweep-design.mjs +0 -8
  122. package/cli/lib/topic-artifacts.mjs +0 -186
  123. package/cli/lib/topic-authority-coverage.mjs +0 -73
  124. package/cli/lib/topic-closeout.mjs +0 -560
  125. package/cli/lib/topic-common.mjs +0 -404
  126. package/cli/lib/topic-decisions.mjs +0 -332
  127. package/cli/lib/topic-draft-packets.mjs +0 -167
  128. package/cli/lib/topic-execution.mjs +0 -533
  129. package/cli/lib/topic-goal.mjs +0 -440
  130. package/cli/lib/topic-ledger.mjs +0 -281
  131. package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
  132. package/cli/lib/topic-root-validation.mjs +0 -288
  133. package/cli/lib/topic-runner-commands.mjs +0 -174
  134. package/cli/lib/topic-runner-deferral.mjs +0 -532
  135. package/cli/lib/topic-runner-stale-gates.mjs +0 -114
  136. package/cli/lib/topic-runner-validation.mjs +0 -138
  137. package/cli/lib/topic-runner.mjs +0 -727
  138. package/cli/lib/topic-scaffold.mjs +0 -252
  139. package/cli/lib/topic-waves.mjs +0 -403
  140. package/cli/lib/topic.mjs +0 -81
  141. package/config/audit-execution-artifacts.yaml +0 -20
  142. package/config/external-execution-artifacts.yaml +0 -16
  143. package/config/host-adapter.yaml +0 -30
  144. package/config/host-profile.yaml +0 -29
  145. package/config/installer-evidence.yaml +0 -31
  146. package/config/skill-installer.yaml +0 -23
  147. package/config/skill-manifest.yaml +0 -48
  148. package/config/skills.yaml +0 -30
  149. package/contracts/acceptance.schema.yaml +0 -16
  150. package/contracts/admission-checklist.schema.yaml +0 -15
  151. package/contracts/audit-chunk.schema.yaml +0 -123
  152. package/contracts/audit-closeout.schema.yaml +0 -51
  153. package/contracts/audit-finding.schema.yaml +0 -61
  154. package/contracts/audit-ledger.schema.yaml +0 -138
  155. package/contracts/audit-plan.schema.yaml +0 -138
  156. package/contracts/audit-remediation-map.schema.yaml +0 -52
  157. package/contracts/audit-rerun.schema.yaml +0 -31
  158. package/contracts/audit-sweep-result.yaml +0 -53
  159. package/contracts/authority-convergence-audit.schema.yaml +0 -19
  160. package/contracts/closeout.schema.yaml +0 -25
  161. package/contracts/decision-review.schema.yaml +0 -16
  162. package/contracts/doc-spec-audit-result.yaml +0 -19
  163. package/contracts/execution-packet.schema.yaml +0 -49
  164. package/contracts/external-host-compatibility.yaml +0 -22
  165. package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
  166. package/contracts/high-risk-admission.schema.yaml +0 -23
  167. package/contracts/high-risk-execution-result.yaml +0 -20
  168. package/contracts/orchestration-state.schema.yaml +0 -41
  169. package/contracts/overflow-continuation.schema.yaml +0 -12
  170. package/contracts/packet.schema.yaml +0 -30
  171. package/contracts/pending-note.schema.yaml +0 -17
  172. package/contracts/prompt.schema.yaml +0 -12
  173. package/contracts/remediation.schema.yaml +0 -16
  174. package/contracts/result.schema.yaml +0 -24
  175. package/contracts/spec-reconstruction-result.yaml +0 -41
  176. package/contracts/sweep-design-result.yaml +0 -349
  177. package/contracts/topic-goal.schema.yaml +0 -87
  178. package/contracts/topic-run-ledger.schema.yaml +0 -72
  179. package/contracts/topic-step-decision.schema.yaml +0 -45
  180. package/contracts/topic.schema.yaml +0 -65
  181. package/contracts/true-close.schema.yaml +0 -15
  182. package/contracts/wave.schema.yaml +0 -29
  183. package/contracts/worker-output.schema.yaml +0 -15
  184. package/contracts/workflow-consumer.schema.yaml +0 -110
  185. package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
  186. package/methodology/authority-convergence-policy.yaml +0 -42
  187. package/methodology/overflow-continuation-policy.yaml +0 -14
  188. package/methodology/skill-exchange-projection.yaml +0 -114
  189. package/methodology/skill-handoff.yaml +0 -34
  190. package/methodology/skill-installer-result.yaml +0 -27
  191. package/methodology/skill-installer-summary-projection.yaml +0 -181
  192. package/methodology/skill-runtime.yaml +0 -23
  193. package/methodology/spec-target-truth-profile.yaml +0 -46
  194. package/methodology/topic-lifecycle-report.yaml +0 -144
  195. package/methodology/topic-lifecycle.yaml +0 -37
  196. package/methodology/topic-naming-ontology.yaml +0 -21
  197. package/methodology/topic-ontology.yaml +0 -38
  198. package/methodology/topic-validation-policy.yaml +0 -9
  199. package/methodology/wave-dag-policy.yaml +0 -14
  200. package/spec/_meta/command-gating-matrix.yaml +0 -143
  201. package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
  202. package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
  203. package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
  204. package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
  205. package/spec/bootstrap-state.yaml +0 -99
@@ -1,767 +0,0 @@
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
- }