@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.
- package/LICENSE +21 -0
- package/README.md +348 -0
- package/adapters/README.md +25 -0
- package/adapters/claude/README.md +89 -0
- package/adapters/claude/profile.yaml +70 -0
- package/adapters/codex/README.md +53 -0
- package/adapters/codex/profile.yaml +78 -0
- package/adapters/oh-my-codex/README.md +185 -0
- package/adapters/oh-my-codex/profile.yaml +46 -0
- package/bin/nimicoding.mjs +6 -0
- package/cli/commands/admit-high-risk-decision.mjs +108 -0
- package/cli/commands/audit-sweep.mjs +341 -0
- package/cli/commands/blueprint-audit.mjs +91 -0
- package/cli/commands/clear.mjs +168 -0
- package/cli/commands/closeout.mjs +183 -0
- package/cli/commands/decide-high-risk-execution.mjs +124 -0
- package/cli/commands/doctor.mjs +53 -0
- package/cli/commands/generate-spec-derived-docs.mjs +131 -0
- package/cli/commands/handoff.mjs +123 -0
- package/cli/commands/ingest-high-risk-execution.mjs +95 -0
- package/cli/commands/review-high-risk-execution.mjs +95 -0
- package/cli/commands/start.mjs +717 -0
- package/cli/commands/topic-formatters.mjs +382 -0
- package/cli/commands/topic-goal.mjs +33 -0
- package/cli/commands/topic-options-shared.mjs +27 -0
- package/cli/commands/topic-options-workflow.mjs +767 -0
- package/cli/commands/topic-options.mjs +626 -0
- package/cli/commands/topic-runner.mjs +169 -0
- package/cli/commands/topic.mjs +795 -0
- package/cli/commands/validate-acceptance.mjs +5 -0
- package/cli/commands/validate-ai-governance.mjs +214 -0
- package/cli/commands/validate-execution-packet.mjs +5 -0
- package/cli/commands/validate-orchestration-state.mjs +5 -0
- package/cli/commands/validate-prompt.mjs +5 -0
- package/cli/commands/validate-spec-audit.mjs +27 -0
- package/cli/commands/validate-spec-governance.mjs +124 -0
- package/cli/commands/validate-spec-tree.mjs +27 -0
- package/cli/commands/validate-worker-output.mjs +5 -0
- package/cli/constants.mjs +489 -0
- package/cli/help.mjs +134 -0
- package/cli/index.mjs +103 -0
- package/cli/lib/adapter-profiles.mjs +403 -0
- package/cli/lib/audit-execution.mjs +52 -0
- package/cli/lib/audit-sweep-runtime/admissions.mjs +381 -0
- package/cli/lib/audit-sweep-runtime/audit-validity.mjs +333 -0
- package/cli/lib/audit-sweep-runtime/chunks.mjs +697 -0
- package/cli/lib/audit-sweep-runtime/closeout.mjs +144 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +639 -0
- package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +515 -0
- package/cli/lib/audit-sweep-runtime/common.mjs +329 -0
- package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +172 -0
- package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +152 -0
- package/cli/lib/audit-sweep-runtime/format.mjs +57 -0
- package/cli/lib/audit-sweep-runtime/ingest.mjs +486 -0
- package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +198 -0
- package/cli/lib/audit-sweep-runtime/inventory.mjs +728 -0
- package/cli/lib/audit-sweep-runtime/ledger.mjs +315 -0
- package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +101 -0
- package/cli/lib/audit-sweep-runtime/remediation.mjs +349 -0
- package/cli/lib/audit-sweep-runtime/rerun.mjs +129 -0
- package/cli/lib/audit-sweep-runtime/risk-budget.mjs +300 -0
- package/cli/lib/audit-sweep-runtime/status.mjs +62 -0
- package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +215 -0
- package/cli/lib/audit-sweep-runtime/validators.mjs +758 -0
- package/cli/lib/audit-sweep.mjs +18 -0
- package/cli/lib/authority-convergence.mjs +309 -0
- package/cli/lib/blueprint-audit.mjs +370 -0
- package/cli/lib/bootstrap.mjs +228 -0
- package/cli/lib/closeout.mjs +623 -0
- package/cli/lib/codex-sdk-runner.mjs +76 -0
- package/cli/lib/contracts.mjs +180 -0
- package/cli/lib/doctor.mjs +18 -0
- package/cli/lib/entrypoints.mjs +274 -0
- package/cli/lib/external-execution.mjs +101 -0
- package/cli/lib/fs-helpers.mjs +33 -0
- package/cli/lib/handoff.mjs +785 -0
- package/cli/lib/high-risk-admission.mjs +442 -0
- package/cli/lib/high-risk-decision.mjs +324 -0
- package/cli/lib/high-risk-ingest.mjs +317 -0
- package/cli/lib/high-risk-review.mjs +263 -0
- package/cli/lib/internal/contracts-loaders.mjs +132 -0
- package/cli/lib/internal/contracts-parse-high-risk.mjs +131 -0
- package/cli/lib/internal/contracts-parse.mjs +457 -0
- package/cli/lib/internal/contracts-validators.mjs +398 -0
- package/cli/lib/internal/doctor-bootstrap-surface.mjs +359 -0
- package/cli/lib/internal/doctor-delegated-surface.mjs +256 -0
- package/cli/lib/internal/doctor-finalize.mjs +385 -0
- package/cli/lib/internal/doctor-format.mjs +286 -0
- package/cli/lib/internal/doctor-inspectors.mjs +294 -0
- package/cli/lib/internal/doctor-state.mjs +205 -0
- package/cli/lib/internal/governance/ai/ai-context-budget-core.mjs +315 -0
- package/cli/lib/internal/governance/ai/ai-structure-budget-core.mjs +358 -0
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +155 -0
- package/cli/lib/internal/governance/ai/check-high-risk-doc-metadata-core.mjs +173 -0
- package/cli/lib/internal/governance/config.mjs +150 -0
- package/cli/lib/internal/governance/runner.mjs +35 -0
- package/cli/lib/internal/governance/shared/read-yaml-with-fragments.mjs +49 -0
- package/cli/lib/internal/validators-artifacts.mjs +515 -0
- package/cli/lib/internal/validators-shared.mjs +28 -0
- package/cli/lib/internal/validators-spec-helpers.mjs +186 -0
- package/cli/lib/internal/validators-spec.mjs +410 -0
- package/cli/lib/shared.mjs +83 -0
- package/cli/lib/topic-draft-packets.mjs +48 -0
- package/cli/lib/topic-goal.mjs +361 -0
- package/cli/lib/topic-runner.mjs +772 -0
- package/cli/lib/topic.mjs +93 -0
- package/cli/lib/ui.mjs +178 -0
- package/cli/lib/validators.mjs +78 -0
- package/cli/lib/value-helpers.mjs +24 -0
- package/cli/lib/yaml-helpers.mjs +133 -0
- package/cli/nimicoding.mjs +1 -0
- package/cli/seeds/bootstrap.mjs +47 -0
- package/config/audit-execution-artifacts.yaml +20 -0
- package/config/bootstrap.yaml +6 -0
- package/config/external-execution-artifacts.yaml +16 -0
- package/config/host-adapter.yaml +30 -0
- package/config/host-profile.yaml +29 -0
- package/config/installer-evidence.yaml +31 -0
- package/config/skill-installer.yaml +23 -0
- package/config/skill-manifest.yaml +46 -0
- package/config/skills.yaml +30 -0
- package/config/spec-generation-inputs.yaml +25 -0
- package/contracts/acceptance.schema.yaml +16 -0
- package/contracts/admission-checklist.schema.yaml +15 -0
- package/contracts/audit-chunk.schema.yaml +110 -0
- package/contracts/audit-closeout.schema.yaml +51 -0
- package/contracts/audit-finding.schema.yaml +61 -0
- package/contracts/audit-ledger.schema.yaml +138 -0
- package/contracts/audit-plan.schema.yaml +123 -0
- package/contracts/audit-remediation-map.schema.yaml +51 -0
- package/contracts/audit-rerun.schema.yaml +31 -0
- package/contracts/audit-sweep-result.yaml +49 -0
- package/contracts/authority-convergence-audit.schema.yaml +19 -0
- package/contracts/closeout.schema.yaml +25 -0
- package/contracts/decision-review.schema.yaml +16 -0
- package/contracts/doc-spec-audit-result.yaml +19 -0
- package/contracts/execution-packet.schema.yaml +49 -0
- package/contracts/external-host-compatibility.yaml +22 -0
- package/contracts/forbidden-shortcuts.catalog.yaml +23 -0
- package/contracts/high-risk-admission.schema.yaml +23 -0
- package/contracts/high-risk-execution-result.yaml +20 -0
- package/contracts/orchestration-state.schema.yaml +41 -0
- package/contracts/overflow-continuation.schema.yaml +12 -0
- package/contracts/packet.schema.yaml +30 -0
- package/contracts/pending-note.schema.yaml +17 -0
- package/contracts/prompt.schema.yaml +12 -0
- package/contracts/remediation.schema.yaml +16 -0
- package/contracts/result.schema.yaml +24 -0
- package/contracts/spec-generation-audit.schema.yaml +31 -0
- package/contracts/spec-generation-inputs.schema.yaml +39 -0
- package/contracts/spec-reconstruction-result.yaml +37 -0
- package/contracts/topic-goal.schema.yaml +78 -0
- package/contracts/topic-run-ledger.schema.yaml +72 -0
- package/contracts/topic-step-decision.schema.yaml +45 -0
- package/contracts/topic.schema.yaml +65 -0
- package/contracts/true-close.schema.yaml +15 -0
- package/contracts/wave.schema.yaml +29 -0
- package/contracts/worker-output.schema.yaml +15 -0
- package/methodology/audit-sweep-p0p1-recall.yaml +45 -0
- package/methodology/authority-convergence-policy.yaml +42 -0
- package/methodology/core.yaml +25 -0
- package/methodology/four-closure-policy.yaml +28 -0
- package/methodology/overflow-continuation-policy.yaml +14 -0
- package/methodology/role-separation-policy.yaml +28 -0
- package/methodology/skill-exchange-projection.yaml +114 -0
- package/methodology/skill-handoff.yaml +34 -0
- package/methodology/skill-installer-result.yaml +27 -0
- package/methodology/skill-installer-summary-projection.yaml +181 -0
- package/methodology/skill-runtime.yaml +23 -0
- package/methodology/spec-reconstruction.yaml +63 -0
- package/methodology/spec-target-truth-profile.yaml +53 -0
- package/methodology/topic-lifecycle-report.yaml +144 -0
- package/methodology/topic-lifecycle.yaml +37 -0
- package/methodology/topic-naming-ontology.yaml +21 -0
- package/methodology/topic-ontology.yaml +38 -0
- package/methodology/topic-validation-policy.yaml +9 -0
- package/methodology/wave-dag-policy.yaml +14 -0
- package/package.json +50 -0
- package/spec/_meta/command-gating-matrix.yaml +110 -0
- package/spec/_meta/generate-drift-migration-checklist.yaml +155 -0
- package/spec/_meta/governance-routing-cutover-checklist.yaml +35 -0
- package/spec/_meta/phase2-impacted-surface-matrix.yaml +44 -0
- package/spec/_meta/spec-authority-cutover-readiness.yaml +104 -0
- package/spec/_meta/spec-tree-model.yaml +72 -0
- package/spec/bootstrap-state.yaml +99 -0
- package/spec/product-scope.yaml +56 -0
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
import { localize } from "../lib/ui.mjs";
|
|
2
|
+
import { validateTopicId, validateTopicSlug } from "../lib/topic.mjs";
|
|
3
|
+
import { requireOptionValue } from "./topic-options-shared.mjs";
|
|
4
|
+
|
|
5
|
+
export function parseTopicCreateOptions(args) {
|
|
6
|
+
const [slug, ...rest] = args;
|
|
7
|
+
if (!slug) {
|
|
8
|
+
return {
|
|
9
|
+
ok: false,
|
|
10
|
+
error: `${localize(
|
|
11
|
+
"nimicoding topic create refused: expected a slug argument.",
|
|
12
|
+
"nimicoding topic create 已拒绝:需要提供 slug 参数。",
|
|
13
|
+
)}\n`,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (!validateTopicSlug(slug) && !validateTopicId(slug)) {
|
|
17
|
+
return {
|
|
18
|
+
ok: false,
|
|
19
|
+
error: `${localize(
|
|
20
|
+
`nimicoding topic create refused: slug must be lowercase kebab-case or a full topic id: ${slug}.`,
|
|
21
|
+
`nimicoding topic create 已拒绝:slug 必须是小写 kebab-case 或完整 topic id:${slug}。`,
|
|
22
|
+
)}\n`,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const options = {
|
|
26
|
+
slug,
|
|
27
|
+
title: null,
|
|
28
|
+
justification: null,
|
|
29
|
+
mode: null,
|
|
30
|
+
posture: null,
|
|
31
|
+
designPolicy: null,
|
|
32
|
+
parallelTruth: null,
|
|
33
|
+
layering: null,
|
|
34
|
+
risk: null,
|
|
35
|
+
applicability: null,
|
|
36
|
+
executionMode: null,
|
|
37
|
+
json: false,
|
|
38
|
+
};
|
|
39
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
40
|
+
const arg = rest[index];
|
|
41
|
+
const next = rest[index + 1];
|
|
42
|
+
if (arg === "--json") {
|
|
43
|
+
options.json = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (arg === "--title") {
|
|
47
|
+
const valueCheck = requireOptionValue("--title", next, "nimicoding topic create refused");
|
|
48
|
+
if (!valueCheck.ok) {
|
|
49
|
+
return valueCheck;
|
|
50
|
+
}
|
|
51
|
+
options.title = next;
|
|
52
|
+
index += 1;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (arg === "--justification") {
|
|
56
|
+
const valueCheck = requireOptionValue("--justification", next, "nimicoding topic create refused");
|
|
57
|
+
if (!valueCheck.ok) {
|
|
58
|
+
return valueCheck;
|
|
59
|
+
}
|
|
60
|
+
options.justification = next;
|
|
61
|
+
index += 1;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (arg === "--mode") {
|
|
65
|
+
const valueCheck = requireOptionValue("--mode", next, "nimicoding topic create refused");
|
|
66
|
+
if (!valueCheck.ok) {
|
|
67
|
+
return valueCheck;
|
|
68
|
+
}
|
|
69
|
+
options.mode = next;
|
|
70
|
+
index += 1;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
if (arg === "--posture") {
|
|
74
|
+
const valueCheck = requireOptionValue("--posture", next, "nimicoding topic create refused");
|
|
75
|
+
if (!valueCheck.ok) {
|
|
76
|
+
return valueCheck;
|
|
77
|
+
}
|
|
78
|
+
const normalized = next.replaceAll("-", "_");
|
|
79
|
+
options.posture = normalized;
|
|
80
|
+
index += 1;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (arg === "--design-policy") {
|
|
84
|
+
const valueCheck = requireOptionValue("--design-policy", next, "nimicoding topic create refused");
|
|
85
|
+
if (!valueCheck.ok) {
|
|
86
|
+
return valueCheck;
|
|
87
|
+
}
|
|
88
|
+
const normalized = next.replaceAll("-", "_");
|
|
89
|
+
options.designPolicy = normalized;
|
|
90
|
+
index += 1;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (arg === "--parallel-truth") {
|
|
94
|
+
const valueCheck = requireOptionValue("--parallel-truth", next, "nimicoding topic create refused");
|
|
95
|
+
if (!valueCheck.ok) {
|
|
96
|
+
return valueCheck;
|
|
97
|
+
}
|
|
98
|
+
const normalized = next.replaceAll("-", "_");
|
|
99
|
+
options.parallelTruth = normalized;
|
|
100
|
+
index += 1;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (arg === "--layering") {
|
|
104
|
+
const valueCheck = requireOptionValue("--layering", next, "nimicoding topic create refused");
|
|
105
|
+
if (!valueCheck.ok) {
|
|
106
|
+
return valueCheck;
|
|
107
|
+
}
|
|
108
|
+
const normalized = next.replaceAll("-", "_");
|
|
109
|
+
options.layering = normalized;
|
|
110
|
+
index += 1;
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (arg === "--risk") {
|
|
114
|
+
const valueCheck = requireOptionValue("--risk", next, "nimicoding topic create refused");
|
|
115
|
+
if (!valueCheck.ok) {
|
|
116
|
+
return valueCheck;
|
|
117
|
+
}
|
|
118
|
+
options.risk = next;
|
|
119
|
+
index += 1;
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
if (arg === "--applicability") {
|
|
123
|
+
const valueCheck = requireOptionValue("--applicability", next, "nimicoding topic create refused");
|
|
124
|
+
if (!valueCheck.ok) {
|
|
125
|
+
return valueCheck;
|
|
126
|
+
}
|
|
127
|
+
const normalized = next.replaceAll("-", "_");
|
|
128
|
+
options.applicability = normalized;
|
|
129
|
+
index += 1;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (arg === "--execution-mode") {
|
|
133
|
+
const valueCheck = requireOptionValue("--execution-mode", next, "nimicoding topic create refused");
|
|
134
|
+
if (!valueCheck.ok) {
|
|
135
|
+
return valueCheck;
|
|
136
|
+
}
|
|
137
|
+
const normalized = next.replaceAll("-", "_");
|
|
138
|
+
options.executionMode = normalized;
|
|
139
|
+
index += 1;
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
ok: false,
|
|
144
|
+
error: `${localize(
|
|
145
|
+
`nimicoding topic create refused: unknown option ${arg}.`,
|
|
146
|
+
`nimicoding topic create 已拒绝:未知选项 ${arg}。`,
|
|
147
|
+
)}\n`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
if (!options.justification) {
|
|
151
|
+
return {
|
|
152
|
+
ok: false,
|
|
153
|
+
error: `${localize(
|
|
154
|
+
"nimicoding topic create refused: --justification is required so topic entry remains explicit.",
|
|
155
|
+
"nimicoding topic create 已拒绝:必须提供 --justification,确保 topic entry 保持显式。",
|
|
156
|
+
)}\n`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
return {
|
|
160
|
+
ok: true,
|
|
161
|
+
options,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
export function parseTopicReadOptions(args, command) {
|
|
165
|
+
const options = {
|
|
166
|
+
input: null,
|
|
167
|
+
json: false,
|
|
168
|
+
};
|
|
169
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
170
|
+
const arg = args[index];
|
|
171
|
+
if (arg === "--json") {
|
|
172
|
+
options.json = true;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (options.input === null) {
|
|
176
|
+
options.input = arg;
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
return {
|
|
180
|
+
ok: false,
|
|
181
|
+
error: `${localize(
|
|
182
|
+
`nimicoding topic ${command} refused: unexpected argument ${arg}.`,
|
|
183
|
+
`nimicoding topic ${command} 已拒绝:存在未预期参数 ${arg}。`,
|
|
184
|
+
)}\n`,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
ok: true,
|
|
189
|
+
options,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export function parseTopicGoalOptions(args) {
|
|
193
|
+
const [topicInput, ...rest] = args;
|
|
194
|
+
if (!topicInput) {
|
|
195
|
+
return {
|
|
196
|
+
ok: false,
|
|
197
|
+
error: `${localize(
|
|
198
|
+
"nimicoding topic goal refused: expected <topic-id>.",
|
|
199
|
+
"nimicoding topic goal 已拒绝:需要 <topic-id>。",
|
|
200
|
+
)}\n`,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const options = {
|
|
204
|
+
topicInput,
|
|
205
|
+
format: "slash",
|
|
206
|
+
wave: null,
|
|
207
|
+
profile: null,
|
|
208
|
+
};
|
|
209
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
210
|
+
const arg = rest[index];
|
|
211
|
+
const next = rest[index + 1];
|
|
212
|
+
if (arg === "--json") {
|
|
213
|
+
options.format = "json";
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (arg === "--format") {
|
|
217
|
+
const valueCheck = requireOptionValue("--format", next, "nimicoding topic goal refused");
|
|
218
|
+
if (!valueCheck.ok) {
|
|
219
|
+
return valueCheck;
|
|
220
|
+
}
|
|
221
|
+
if (!["slash", "json"].includes(next)) {
|
|
222
|
+
return {
|
|
223
|
+
ok: false,
|
|
224
|
+
error: `${localize(
|
|
225
|
+
`nimicoding topic goal refused: unsupported --format value ${next}.`,
|
|
226
|
+
`nimicoding topic goal 已拒绝:不支持的 --format 值 ${next}。`,
|
|
227
|
+
)}\n`,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
options.format = next;
|
|
231
|
+
index += 1;
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (arg === "--wave") {
|
|
235
|
+
const valueCheck = requireOptionValue("--wave", next, "nimicoding topic goal refused");
|
|
236
|
+
if (!valueCheck.ok) {
|
|
237
|
+
return valueCheck;
|
|
238
|
+
}
|
|
239
|
+
options.wave = next;
|
|
240
|
+
index += 1;
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
if (arg === "--profile") {
|
|
244
|
+
const valueCheck = requireOptionValue("--profile", next, "nimicoding topic goal refused");
|
|
245
|
+
if (!valueCheck.ok) {
|
|
246
|
+
return valueCheck;
|
|
247
|
+
}
|
|
248
|
+
options.profile = next;
|
|
249
|
+
index += 1;
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
return {
|
|
253
|
+
ok: false,
|
|
254
|
+
error: `${localize(
|
|
255
|
+
`nimicoding topic goal refused: unknown option ${arg}.`,
|
|
256
|
+
`nimicoding topic goal 已拒绝:未知选项 ${arg}。`,
|
|
257
|
+
)}\n`,
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
return { ok: true, options };
|
|
261
|
+
}
|
|
262
|
+
export function parseRunNextStepOptions(args) {
|
|
263
|
+
const [topicInput, ...rest] = args;
|
|
264
|
+
if (!topicInput) {
|
|
265
|
+
return {
|
|
266
|
+
ok: false,
|
|
267
|
+
error: `${localize(
|
|
268
|
+
"nimicoding topic run-next-step refused: expected <topic-id>.",
|
|
269
|
+
"nimicoding topic run-next-step 已拒绝:需要 <topic-id>。",
|
|
270
|
+
)}\n`,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
const options = { topicInput, json: false };
|
|
274
|
+
for (const arg of rest) {
|
|
275
|
+
if (arg === "--json") {
|
|
276
|
+
options.json = true;
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
ok: false,
|
|
281
|
+
error: `${localize(
|
|
282
|
+
`nimicoding topic run-next-step refused: unknown option ${arg}.`,
|
|
283
|
+
`nimicoding topic run-next-step 已拒绝:未知选项 ${arg}。`,
|
|
284
|
+
)}\n`,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return { ok: true, options };
|
|
288
|
+
}
|
|
289
|
+
function parseArtifactRef(value) {
|
|
290
|
+
const separator = value.indexOf("=");
|
|
291
|
+
if (separator <= 0 || separator === value.length - 1) {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
return [value.slice(0, separator), value.slice(separator + 1)];
|
|
295
|
+
}
|
|
296
|
+
export function parseRunLedgerOptions(args) {
|
|
297
|
+
const [action, topicInput, ...rest] = args;
|
|
298
|
+
if (!action || !topicInput) {
|
|
299
|
+
return {
|
|
300
|
+
ok: false,
|
|
301
|
+
error: `${localize(
|
|
302
|
+
"nimicoding topic run-ledger refused: expected <init|record|build|status> <topic-id>.",
|
|
303
|
+
"nimicoding topic run-ledger 已拒绝:需要 <init|record|build|status> <topic-id>。",
|
|
304
|
+
)}\n`,
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
if (!["init", "record", "build", "status"].includes(action)) {
|
|
308
|
+
return {
|
|
309
|
+
ok: false,
|
|
310
|
+
error: `${localize(
|
|
311
|
+
`nimicoding topic run-ledger refused: unknown action ${action}.`,
|
|
312
|
+
`nimicoding topic run-ledger 已拒绝:未知动作 ${action}。`,
|
|
313
|
+
)}\n`,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const options = {
|
|
317
|
+
action,
|
|
318
|
+
topicInput,
|
|
319
|
+
runId: null,
|
|
320
|
+
eventKind: null,
|
|
321
|
+
stopClass: null,
|
|
322
|
+
recommendedAction: null,
|
|
323
|
+
sourceRef: null,
|
|
324
|
+
summary: null,
|
|
325
|
+
verifiedAt: null,
|
|
326
|
+
waveId: null,
|
|
327
|
+
artifactRefs: {},
|
|
328
|
+
json: false,
|
|
329
|
+
};
|
|
330
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
331
|
+
const arg = rest[index];
|
|
332
|
+
const next = rest[index + 1];
|
|
333
|
+
if (arg === "--json") {
|
|
334
|
+
options.json = true;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (arg === "--run-id") {
|
|
338
|
+
const valueCheck = requireOptionValue("--run-id", next, "nimicoding topic run-ledger refused");
|
|
339
|
+
if (!valueCheck.ok) {
|
|
340
|
+
return valueCheck;
|
|
341
|
+
}
|
|
342
|
+
options.runId = next;
|
|
343
|
+
index += 1;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
if (arg === "--event") {
|
|
347
|
+
const valueCheck = requireOptionValue("--event", next, "nimicoding topic run-ledger record refused");
|
|
348
|
+
if (!valueCheck.ok) {
|
|
349
|
+
return valueCheck;
|
|
350
|
+
}
|
|
351
|
+
options.eventKind = next;
|
|
352
|
+
index += 1;
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (arg === "--stop-class") {
|
|
356
|
+
const valueCheck = requireOptionValue("--stop-class", next, "nimicoding topic run-ledger record refused");
|
|
357
|
+
if (!valueCheck.ok) {
|
|
358
|
+
return valueCheck;
|
|
359
|
+
}
|
|
360
|
+
options.stopClass = next;
|
|
361
|
+
index += 1;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
if (arg === "--action") {
|
|
365
|
+
const valueCheck = requireOptionValue("--action", next, "nimicoding topic run-ledger record refused");
|
|
366
|
+
if (!valueCheck.ok) {
|
|
367
|
+
return valueCheck;
|
|
368
|
+
}
|
|
369
|
+
options.recommendedAction = next;
|
|
370
|
+
index += 1;
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (arg === "--source") {
|
|
374
|
+
const valueCheck = requireOptionValue("--source", next, "nimicoding topic run-ledger record refused");
|
|
375
|
+
if (!valueCheck.ok) {
|
|
376
|
+
return valueCheck;
|
|
377
|
+
}
|
|
378
|
+
options.sourceRef = next;
|
|
379
|
+
index += 1;
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
if (arg === "--summary") {
|
|
383
|
+
const valueCheck = requireOptionValue("--summary", next, "nimicoding topic run-ledger record refused");
|
|
384
|
+
if (!valueCheck.ok) {
|
|
385
|
+
return valueCheck;
|
|
386
|
+
}
|
|
387
|
+
options.summary = next;
|
|
388
|
+
index += 1;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
if (arg === "--verified-at") {
|
|
392
|
+
const valueCheck = requireOptionValue("--verified-at", next, "nimicoding topic run-ledger record refused");
|
|
393
|
+
if (!valueCheck.ok) {
|
|
394
|
+
return valueCheck;
|
|
395
|
+
}
|
|
396
|
+
options.verifiedAt = next;
|
|
397
|
+
index += 1;
|
|
398
|
+
continue;
|
|
399
|
+
}
|
|
400
|
+
if (arg === "--wave") {
|
|
401
|
+
const valueCheck = requireOptionValue("--wave", next, "nimicoding topic run-ledger record refused");
|
|
402
|
+
if (!valueCheck.ok) {
|
|
403
|
+
return valueCheck;
|
|
404
|
+
}
|
|
405
|
+
options.waveId = next;
|
|
406
|
+
index += 1;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (arg === "--artifact") {
|
|
410
|
+
const valueCheck = requireOptionValue("--artifact", next, "nimicoding topic run-ledger record refused");
|
|
411
|
+
if (!valueCheck.ok) {
|
|
412
|
+
return valueCheck;
|
|
413
|
+
}
|
|
414
|
+
const parsed = parseArtifactRef(next);
|
|
415
|
+
if (!parsed) {
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
error: `${localize(
|
|
419
|
+
`nimicoding topic run-ledger record refused: --artifact must use key=ref, found ${next}.`,
|
|
420
|
+
`nimicoding topic run-ledger record 已拒绝:--artifact 必须使用 key=ref,当前为 ${next}。`,
|
|
421
|
+
)}\n`,
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
options.artifactRefs[parsed[0]] = parsed[1];
|
|
425
|
+
index += 1;
|
|
426
|
+
continue;
|
|
427
|
+
}
|
|
428
|
+
return {
|
|
429
|
+
ok: false,
|
|
430
|
+
error: `${localize(
|
|
431
|
+
`nimicoding topic run-ledger refused: unknown option ${arg}.`,
|
|
432
|
+
`nimicoding topic run-ledger 已拒绝:未知选项 ${arg}。`,
|
|
433
|
+
)}\n`,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
if (!options.runId) {
|
|
437
|
+
return {
|
|
438
|
+
ok: false,
|
|
439
|
+
error: `${localize(
|
|
440
|
+
"nimicoding topic run-ledger refused: --run-id is required.",
|
|
441
|
+
"nimicoding topic run-ledger 已拒绝:必须提供 --run-id。",
|
|
442
|
+
)}\n`,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
if (action === "record" && (
|
|
446
|
+
!options.eventKind
|
|
447
|
+
|| !options.stopClass
|
|
448
|
+
|| !options.recommendedAction
|
|
449
|
+
|| !options.sourceRef
|
|
450
|
+
|| !options.summary
|
|
451
|
+
|| !options.verifiedAt
|
|
452
|
+
)) {
|
|
453
|
+
return {
|
|
454
|
+
ok: false,
|
|
455
|
+
error: `${localize(
|
|
456
|
+
"nimicoding topic run-ledger record refused: --event, --stop-class, --action, --source, --summary, and --verified-at are required.",
|
|
457
|
+
"nimicoding topic run-ledger record 已拒绝:必须提供 --event、--stop-class、--action、--source、--summary 和 --verified-at。",
|
|
458
|
+
)}\n`,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return { ok: true, options };
|
|
462
|
+
}
|
|
463
|
+
export function parseTopicHoldOptions(args) {
|
|
464
|
+
const [topicInput, ...rest] = args;
|
|
465
|
+
if (!topicInput) {
|
|
466
|
+
return {
|
|
467
|
+
ok: false,
|
|
468
|
+
error: `${localize(
|
|
469
|
+
"nimicoding topic hold refused: expected <topic-id> and required options.",
|
|
470
|
+
"nimicoding topic hold 已拒绝:需要 <topic-id> 和必填选项。",
|
|
471
|
+
)}\n`,
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
const options = {
|
|
475
|
+
topicInput,
|
|
476
|
+
reason: null,
|
|
477
|
+
summary: null,
|
|
478
|
+
reopenCriteria: null,
|
|
479
|
+
closeTrigger: null,
|
|
480
|
+
json: false,
|
|
481
|
+
};
|
|
482
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
483
|
+
const arg = rest[index];
|
|
484
|
+
const next = rest[index + 1];
|
|
485
|
+
if (arg === "--json") {
|
|
486
|
+
options.json = true;
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
if (arg === "--reason") {
|
|
490
|
+
const valueCheck = requireOptionValue("--reason", next, "nimicoding topic hold refused");
|
|
491
|
+
if (!valueCheck.ok) {
|
|
492
|
+
return valueCheck;
|
|
493
|
+
}
|
|
494
|
+
if (!validateTopicSlug(next)) {
|
|
495
|
+
return {
|
|
496
|
+
ok: false,
|
|
497
|
+
error: `${localize(
|
|
498
|
+
`nimicoding topic hold refused: --reason must be lowercase kebab-case, found ${next}.`,
|
|
499
|
+
`nimicoding topic hold 已拒绝:--reason 必须是小写 kebab-case,当前为 ${next}。`,
|
|
500
|
+
)}\n`,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
options.reason = next;
|
|
504
|
+
index += 1;
|
|
505
|
+
continue;
|
|
506
|
+
}
|
|
507
|
+
if (arg === "--summary") {
|
|
508
|
+
const valueCheck = requireOptionValue("--summary", next, "nimicoding topic hold refused");
|
|
509
|
+
if (!valueCheck.ok) {
|
|
510
|
+
return valueCheck;
|
|
511
|
+
}
|
|
512
|
+
options.summary = next;
|
|
513
|
+
index += 1;
|
|
514
|
+
continue;
|
|
515
|
+
}
|
|
516
|
+
if (arg === "--reopen-criteria") {
|
|
517
|
+
const valueCheck = requireOptionValue("--reopen-criteria", next, "nimicoding topic hold refused");
|
|
518
|
+
if (!valueCheck.ok) {
|
|
519
|
+
return valueCheck;
|
|
520
|
+
}
|
|
521
|
+
options.reopenCriteria = next;
|
|
522
|
+
index += 1;
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
if (arg === "--close-trigger") {
|
|
526
|
+
const valueCheck = requireOptionValue("--close-trigger", next, "nimicoding topic hold refused");
|
|
527
|
+
if (!valueCheck.ok) {
|
|
528
|
+
return valueCheck;
|
|
529
|
+
}
|
|
530
|
+
options.closeTrigger = next;
|
|
531
|
+
index += 1;
|
|
532
|
+
continue;
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
ok: false,
|
|
536
|
+
error: `${localize(
|
|
537
|
+
`nimicoding topic hold refused: unknown option ${arg}.`,
|
|
538
|
+
`nimicoding topic hold 已拒绝:未知选项 ${arg}。`,
|
|
539
|
+
)}\n`,
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
if (!options.reason || !options.summary) {
|
|
543
|
+
return {
|
|
544
|
+
ok: false,
|
|
545
|
+
error: `${localize(
|
|
546
|
+
"nimicoding topic hold refused: --reason and --summary are required.",
|
|
547
|
+
"nimicoding topic hold 已拒绝:必须提供 --reason 和 --summary。",
|
|
548
|
+
)}\n`,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
if (!options.reopenCriteria && !options.closeTrigger) {
|
|
552
|
+
return {
|
|
553
|
+
ok: false,
|
|
554
|
+
error: `${localize(
|
|
555
|
+
"nimicoding topic hold refused: --reopen-criteria or --close-trigger is required.",
|
|
556
|
+
"nimicoding topic hold 已拒绝:必须提供 --reopen-criteria 或 --close-trigger。",
|
|
557
|
+
)}\n`,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
return { ok: true, options };
|
|
561
|
+
}
|
|
562
|
+
export function parseTopicResumeOptions(args) {
|
|
563
|
+
const [topicInput, ...rest] = args;
|
|
564
|
+
if (!topicInput) {
|
|
565
|
+
return {
|
|
566
|
+
ok: false,
|
|
567
|
+
error: `${localize(
|
|
568
|
+
"nimicoding topic resume refused: expected <topic-id> and --criteria-met <text>.",
|
|
569
|
+
"nimicoding topic resume 已拒绝:需要 <topic-id> 和 --criteria-met <text>。",
|
|
570
|
+
)}\n`,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
const options = {
|
|
574
|
+
topicInput,
|
|
575
|
+
criteriaMet: null,
|
|
576
|
+
json: false,
|
|
577
|
+
};
|
|
578
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
579
|
+
const arg = rest[index];
|
|
580
|
+
const next = rest[index + 1];
|
|
581
|
+
if (arg === "--json") {
|
|
582
|
+
options.json = true;
|
|
583
|
+
continue;
|
|
584
|
+
}
|
|
585
|
+
if (arg === "--criteria-met") {
|
|
586
|
+
const valueCheck = requireOptionValue("--criteria-met", next, "nimicoding topic resume refused");
|
|
587
|
+
if (!valueCheck.ok) {
|
|
588
|
+
return valueCheck;
|
|
589
|
+
}
|
|
590
|
+
options.criteriaMet = next;
|
|
591
|
+
index += 1;
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
ok: false,
|
|
596
|
+
error: `${localize(
|
|
597
|
+
`nimicoding topic resume refused: unknown option ${arg}.`,
|
|
598
|
+
`nimicoding topic resume 已拒绝:未知选项 ${arg}。`,
|
|
599
|
+
)}\n`,
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
if (!options.criteriaMet) {
|
|
603
|
+
return {
|
|
604
|
+
ok: false,
|
|
605
|
+
error: `${localize(
|
|
606
|
+
"nimicoding topic resume refused: --criteria-met is required.",
|
|
607
|
+
"nimicoding topic resume 已拒绝:必须提供 --criteria-met。",
|
|
608
|
+
)}\n`,
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
return { ok: true, options };
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export {
|
|
615
|
+
parseWaveAddOptions,
|
|
616
|
+
parseWaveActionOptions,
|
|
617
|
+
parsePacketFreezeOptions,
|
|
618
|
+
parseDispatchOptions,
|
|
619
|
+
parseResultRecordOptions,
|
|
620
|
+
parseDecisionReviewOptions,
|
|
621
|
+
parseRemediationOpenOptions,
|
|
622
|
+
parseOverflowContinueOptions,
|
|
623
|
+
parseCloseoutOptions,
|
|
624
|
+
parseTrueCloseAuditOptions,
|
|
625
|
+
parseGraphValidateOptions,
|
|
626
|
+
} from "./topic-options-workflow.mjs";
|