@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,795 @@
|
|
|
1
|
+
import process from "node:process";
|
|
2
|
+
import {
|
|
3
|
+
addWaveToTopic,
|
|
4
|
+
closeoutTopicInTopic,
|
|
5
|
+
closeoutWaveInTopic,
|
|
6
|
+
continueTopicOverflow,
|
|
7
|
+
createDecisionReview,
|
|
8
|
+
admitWaveInTopic,
|
|
9
|
+
createTopic,
|
|
10
|
+
decideTopicNextStep,
|
|
11
|
+
deriveCreateDefaults,
|
|
12
|
+
dispatchTopicPacket,
|
|
13
|
+
freezePacketForTopic,
|
|
14
|
+
holdTopicInPending,
|
|
15
|
+
initTopicRunLedger,
|
|
16
|
+
loadTopicRuntimeAuthority,
|
|
17
|
+
openTopicRemediation,
|
|
18
|
+
readTopicRunLedger,
|
|
19
|
+
recordTopicResult,
|
|
20
|
+
recordTopicRunEvent,
|
|
21
|
+
resumePendingTopic,
|
|
22
|
+
buildTopicRunLedger,
|
|
23
|
+
runTopicTrueCloseAudit,
|
|
24
|
+
resolveTopicProjectRoot,
|
|
25
|
+
selectWaveInTopic,
|
|
26
|
+
validateWaveClosure,
|
|
27
|
+
validateTopicGraph,
|
|
28
|
+
validateTopicRoot,
|
|
29
|
+
validateWaveAdmission,
|
|
30
|
+
} from "../lib/topic.mjs";
|
|
31
|
+
import { localize } from "../lib/ui.mjs";
|
|
32
|
+
import { runTopicGoal } from "./topic-goal.mjs";
|
|
33
|
+
import {
|
|
34
|
+
buildJsonReport,
|
|
35
|
+
formatAdmissionValidate,
|
|
36
|
+
formatCloseout,
|
|
37
|
+
formatClosureValidate,
|
|
38
|
+
formatDecisionReview,
|
|
39
|
+
formatDispatch,
|
|
40
|
+
formatGraphValidate,
|
|
41
|
+
formatNextStep,
|
|
42
|
+
formatOverflowContinuation,
|
|
43
|
+
formatPacketFreeze,
|
|
44
|
+
formatPendingTransition,
|
|
45
|
+
formatRemediation,
|
|
46
|
+
formatResultRecord,
|
|
47
|
+
formatRunLedger,
|
|
48
|
+
formatTopicCreate,
|
|
49
|
+
formatTopicStatus,
|
|
50
|
+
formatTopicValidate,
|
|
51
|
+
formatTrueCloseAudit,
|
|
52
|
+
formatWaveMutation,
|
|
53
|
+
writeJson,
|
|
54
|
+
} from "./topic-formatters.mjs";
|
|
55
|
+
import {
|
|
56
|
+
parseCloseoutOptions,
|
|
57
|
+
parseDecisionReviewOptions,
|
|
58
|
+
parseDispatchOptions,
|
|
59
|
+
parseGraphValidateOptions,
|
|
60
|
+
parseOverflowContinueOptions,
|
|
61
|
+
parsePacketFreezeOptions,
|
|
62
|
+
parseRemediationOpenOptions,
|
|
63
|
+
parseResultRecordOptions,
|
|
64
|
+
parseRunLedgerOptions,
|
|
65
|
+
parseRunNextStepOptions,
|
|
66
|
+
parseTopicCreateOptions,
|
|
67
|
+
parseTopicHoldOptions,
|
|
68
|
+
parseTopicReadOptions,
|
|
69
|
+
parseTopicResumeOptions,
|
|
70
|
+
parseTrueCloseAuditOptions,
|
|
71
|
+
parseWaveActionOptions,
|
|
72
|
+
parseWaveAddOptions,
|
|
73
|
+
} from "./topic-options.mjs";
|
|
74
|
+
function validateEnumOption(name, value, allowed, errorPrefix) {
|
|
75
|
+
if (!allowed.includes(value)) {
|
|
76
|
+
return {
|
|
77
|
+
ok: false,
|
|
78
|
+
error: `${localize(
|
|
79
|
+
`${errorPrefix}: unsupported ${name} value ${value}.`,
|
|
80
|
+
`${errorPrefix}:不支持的 ${name} 值 ${value}。`,
|
|
81
|
+
)}\n`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return { ok: true };
|
|
85
|
+
}
|
|
86
|
+
async function runTopicCreate(args) {
|
|
87
|
+
const parsed = parseTopicCreateOptions(args);
|
|
88
|
+
if (!parsed.ok) {
|
|
89
|
+
process.stderr.write(parsed.error);
|
|
90
|
+
return 2;
|
|
91
|
+
}
|
|
92
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
93
|
+
const authority = await loadTopicRuntimeAuthority(projectRoot);
|
|
94
|
+
const createEnumChecks = [
|
|
95
|
+
["--mode", parsed.options.mode, authority.topicEnums.mode],
|
|
96
|
+
["--posture", parsed.options.posture, authority.topicEnums.posture],
|
|
97
|
+
["--design-policy", parsed.options.designPolicy, authority.topicEnums.designPolicy],
|
|
98
|
+
["--parallel-truth", parsed.options.parallelTruth, authority.topicEnums.parallelTruth],
|
|
99
|
+
["--layering", parsed.options.layering, authority.topicEnums.layering],
|
|
100
|
+
["--risk", parsed.options.risk, authority.topicEnums.risk],
|
|
101
|
+
["--applicability", parsed.options.applicability, authority.topicEnums.applicability],
|
|
102
|
+
["--execution-mode", parsed.options.executionMode, authority.topicEnums.executionMode],
|
|
103
|
+
];
|
|
104
|
+
for (const [flag, value, allowed] of createEnumChecks) {
|
|
105
|
+
if (value === null) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const enumCheck = validateEnumOption(flag, value, allowed, "nimicoding topic create refused");
|
|
109
|
+
if (!enumCheck.ok) {
|
|
110
|
+
process.stderr.write(enumCheck.error);
|
|
111
|
+
return 2;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const defaults = deriveCreateDefaults(parsed.options);
|
|
115
|
+
const createReport = await createTopic(projectRoot, {
|
|
116
|
+
...parsed.options,
|
|
117
|
+
...defaults,
|
|
118
|
+
title: parsed.options.title ?? parsed.options.slug
|
|
119
|
+
.replace(/^\d{4}-\d{2}-\d{2}-/, "")
|
|
120
|
+
.split("-")
|
|
121
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
122
|
+
.join(" "),
|
|
123
|
+
});
|
|
124
|
+
if (!createReport.ok) {
|
|
125
|
+
process.stderr.write(`${createReport.error}\n`);
|
|
126
|
+
return 1;
|
|
127
|
+
}
|
|
128
|
+
if (parsed.options.json) {
|
|
129
|
+
writeJson(buildJsonReport("topic.create", createReport));
|
|
130
|
+
} else {
|
|
131
|
+
process.stdout.write(formatTopicCreate(createReport));
|
|
132
|
+
}
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
async function runTopicStatus(args) {
|
|
136
|
+
const parsed = parseTopicReadOptions(args, "status");
|
|
137
|
+
if (!parsed.ok) {
|
|
138
|
+
process.stderr.write(parsed.error);
|
|
139
|
+
return 2;
|
|
140
|
+
}
|
|
141
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
142
|
+
const report = await validateTopicRoot(projectRoot, parsed.options.input);
|
|
143
|
+
if (parsed.options.json) {
|
|
144
|
+
writeJson(buildJsonReport("topic.status", report));
|
|
145
|
+
} else if (report.ok) {
|
|
146
|
+
process.stdout.write(formatTopicStatus(report));
|
|
147
|
+
} else {
|
|
148
|
+
process.stderr.write(`${report.error}\n`);
|
|
149
|
+
}
|
|
150
|
+
return report.ok ? 0 : 1;
|
|
151
|
+
}
|
|
152
|
+
async function runTopicNextStep(args) {
|
|
153
|
+
const parsed = parseRunNextStepOptions(args);
|
|
154
|
+
if (!parsed.ok) {
|
|
155
|
+
process.stderr.write(parsed.error);
|
|
156
|
+
return 2;
|
|
157
|
+
}
|
|
158
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
159
|
+
const report = await decideTopicNextStep(projectRoot, parsed.options.topicInput);
|
|
160
|
+
if (!report.ok) {
|
|
161
|
+
process.stderr.write(`${report.error}\n`);
|
|
162
|
+
return 1;
|
|
163
|
+
}
|
|
164
|
+
if (parsed.options.json) {
|
|
165
|
+
writeJson(buildJsonReport("topic.run-next-step", report));
|
|
166
|
+
} else {
|
|
167
|
+
process.stdout.write(formatNextStep(report));
|
|
168
|
+
}
|
|
169
|
+
return 0;
|
|
170
|
+
}
|
|
171
|
+
async function runTopicRunLedger(args) {
|
|
172
|
+
const parsed = parseRunLedgerOptions(args);
|
|
173
|
+
if (!parsed.ok) {
|
|
174
|
+
process.stderr.write(parsed.error);
|
|
175
|
+
return 2;
|
|
176
|
+
}
|
|
177
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
178
|
+
const options = parsed.options;
|
|
179
|
+
let report;
|
|
180
|
+
if (options.action === "init") {
|
|
181
|
+
report = await initTopicRunLedger(projectRoot, options.topicInput, options.runId);
|
|
182
|
+
} else if (options.action === "record") {
|
|
183
|
+
report = await recordTopicRunEvent(projectRoot, options.topicInput, {
|
|
184
|
+
runId: options.runId,
|
|
185
|
+
eventKind: options.eventKind,
|
|
186
|
+
stopClass: options.stopClass,
|
|
187
|
+
recommendedAction: options.recommendedAction,
|
|
188
|
+
sourceRef: options.sourceRef,
|
|
189
|
+
summary: options.summary,
|
|
190
|
+
recordedAt: options.verifiedAt,
|
|
191
|
+
waveId: options.waveId,
|
|
192
|
+
artifactRefs: options.artifactRefs,
|
|
193
|
+
});
|
|
194
|
+
} else if (options.action === "build") {
|
|
195
|
+
report = await buildTopicRunLedger(projectRoot, options.topicInput, options.runId);
|
|
196
|
+
} else {
|
|
197
|
+
report = await readTopicRunLedger(projectRoot, options.topicInput, options.runId);
|
|
198
|
+
}
|
|
199
|
+
if (!report.ok) {
|
|
200
|
+
process.stderr.write(`${report.error}\n`);
|
|
201
|
+
return 1;
|
|
202
|
+
}
|
|
203
|
+
if (options.json) {
|
|
204
|
+
writeJson(buildJsonReport(`topic.run-ledger.${options.action}`, report));
|
|
205
|
+
} else {
|
|
206
|
+
process.stdout.write(formatRunLedger(report, options.action));
|
|
207
|
+
}
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
async function runTopicHold(args) {
|
|
211
|
+
const parsed = parseTopicHoldOptions(args);
|
|
212
|
+
if (!parsed.ok) {
|
|
213
|
+
process.stderr.write(parsed.error);
|
|
214
|
+
return 2;
|
|
215
|
+
}
|
|
216
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
217
|
+
const report = await holdTopicInPending(projectRoot, parsed.options.topicInput, parsed.options);
|
|
218
|
+
if (!report.ok) {
|
|
219
|
+
process.stderr.write(`${report.error}\n`);
|
|
220
|
+
return 1;
|
|
221
|
+
}
|
|
222
|
+
if (parsed.options.json) {
|
|
223
|
+
writeJson(buildJsonReport("topic.hold", report));
|
|
224
|
+
} else {
|
|
225
|
+
process.stdout.write(formatPendingTransition(report, "hold"));
|
|
226
|
+
}
|
|
227
|
+
return 0;
|
|
228
|
+
}
|
|
229
|
+
async function runTopicResume(args) {
|
|
230
|
+
const parsed = parseTopicResumeOptions(args);
|
|
231
|
+
if (!parsed.ok) {
|
|
232
|
+
process.stderr.write(parsed.error);
|
|
233
|
+
return 2;
|
|
234
|
+
}
|
|
235
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
236
|
+
const report = await resumePendingTopic(projectRoot, parsed.options.topicInput, parsed.options);
|
|
237
|
+
if (!report.ok) {
|
|
238
|
+
process.stderr.write(`${report.error}\n`);
|
|
239
|
+
return 1;
|
|
240
|
+
}
|
|
241
|
+
if (parsed.options.json) {
|
|
242
|
+
writeJson(buildJsonReport("topic.resume", report));
|
|
243
|
+
} else {
|
|
244
|
+
process.stdout.write(formatPendingTransition(report, "resume"));
|
|
245
|
+
}
|
|
246
|
+
return 0;
|
|
247
|
+
}
|
|
248
|
+
async function runTopicValidate(args) {
|
|
249
|
+
if (args[0] === "graph") {
|
|
250
|
+
const parsed = parseGraphValidateOptions(args.slice(1), "validate graph");
|
|
251
|
+
if (!parsed.ok) {
|
|
252
|
+
process.stderr.write(parsed.error);
|
|
253
|
+
return 2;
|
|
254
|
+
}
|
|
255
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
256
|
+
const report = await validateTopicGraph(projectRoot, parsed.options.topicInput);
|
|
257
|
+
if (parsed.options.json) {
|
|
258
|
+
writeJson(buildJsonReport("topic.validate.graph", report));
|
|
259
|
+
} else if (report.topicId) {
|
|
260
|
+
process.stdout.write(formatGraphValidate(report));
|
|
261
|
+
} else {
|
|
262
|
+
process.stderr.write(`${report.error}\n`);
|
|
263
|
+
}
|
|
264
|
+
return report.ok ? 0 : 1;
|
|
265
|
+
}
|
|
266
|
+
if (args[0] === "admission") {
|
|
267
|
+
const parsed = parseGraphValidateOptions(args.slice(1), "validate admission");
|
|
268
|
+
if (!parsed.ok) {
|
|
269
|
+
process.stderr.write(parsed.error);
|
|
270
|
+
return 2;
|
|
271
|
+
}
|
|
272
|
+
if (!parsed.options.topicInput || !parsed.options.waveId) {
|
|
273
|
+
process.stderr.write(`${localize(
|
|
274
|
+
"nimicoding topic validate admission refused: expected <topic-id> <wave-id>.",
|
|
275
|
+
"nimicoding topic validate admission 已拒绝:需要 <topic-id> <wave-id>。",
|
|
276
|
+
)}\n`);
|
|
277
|
+
return 2;
|
|
278
|
+
}
|
|
279
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
280
|
+
const report = await validateWaveAdmission(projectRoot, parsed.options.topicInput, parsed.options.waveId);
|
|
281
|
+
if (parsed.options.json) {
|
|
282
|
+
writeJson(buildJsonReport("topic.validate.admission", report));
|
|
283
|
+
} else {
|
|
284
|
+
if (report.topicId) {
|
|
285
|
+
process.stdout.write(formatAdmissionValidate(report, parsed.options.waveId));
|
|
286
|
+
} else {
|
|
287
|
+
process.stderr.write(`${report.error}\n`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
return report.ok ? 0 : 1;
|
|
291
|
+
}
|
|
292
|
+
if (args[0] === "closure") {
|
|
293
|
+
const parsed = parseGraphValidateOptions(args.slice(1), "validate closure");
|
|
294
|
+
if (!parsed.ok) {
|
|
295
|
+
process.stderr.write(parsed.error);
|
|
296
|
+
return 2;
|
|
297
|
+
}
|
|
298
|
+
if (!parsed.options.topicInput || !parsed.options.waveId) {
|
|
299
|
+
process.stderr.write(`${localize(
|
|
300
|
+
"nimicoding topic validate closure refused: expected <topic-id> <wave-id>.",
|
|
301
|
+
"nimicoding topic validate closure 已拒绝:需要 <topic-id> <wave-id>。",
|
|
302
|
+
)}\n`);
|
|
303
|
+
return 2;
|
|
304
|
+
}
|
|
305
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
306
|
+
const report = await validateWaveClosure(projectRoot, parsed.options.topicInput, parsed.options.waveId);
|
|
307
|
+
if (parsed.options.json) {
|
|
308
|
+
writeJson(buildJsonReport("topic.validate.closure", report));
|
|
309
|
+
} else if (report.topicId) {
|
|
310
|
+
process.stdout.write(formatClosureValidate(report, parsed.options.waveId));
|
|
311
|
+
} else {
|
|
312
|
+
process.stderr.write(`${report.error}\n`);
|
|
313
|
+
}
|
|
314
|
+
return report.ok ? 0 : 1;
|
|
315
|
+
}
|
|
316
|
+
const parsed = parseTopicReadOptions(args, "validate");
|
|
317
|
+
if (!parsed.ok) {
|
|
318
|
+
process.stderr.write(parsed.error);
|
|
319
|
+
return 2;
|
|
320
|
+
}
|
|
321
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
322
|
+
const report = await validateTopicRoot(projectRoot, parsed.options.input);
|
|
323
|
+
if (parsed.options.json) {
|
|
324
|
+
writeJson(buildJsonReport("topic.validate", report));
|
|
325
|
+
} else if (report.ok) {
|
|
326
|
+
process.stdout.write(formatTopicValidate(report));
|
|
327
|
+
} else {
|
|
328
|
+
process.stderr.write(`${report.error}\n`);
|
|
329
|
+
}
|
|
330
|
+
return report.ok ? 0 : 1;
|
|
331
|
+
}
|
|
332
|
+
async function runTopicWave(args) {
|
|
333
|
+
const [action, ...rest] = args;
|
|
334
|
+
if (!action) {
|
|
335
|
+
process.stderr.write(`${localize(
|
|
336
|
+
"nimicoding topic wave refused: expected `add`, `select`, or `admit`.",
|
|
337
|
+
"nimicoding topic wave 已拒绝:需要 `add`、`select` 或 `admit`。",
|
|
338
|
+
)}\n`);
|
|
339
|
+
return 2;
|
|
340
|
+
}
|
|
341
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
342
|
+
if (action === "add") {
|
|
343
|
+
const parsed = parseWaveAddOptions(rest);
|
|
344
|
+
if (!parsed.ok) {
|
|
345
|
+
process.stderr.write(parsed.error);
|
|
346
|
+
return 2;
|
|
347
|
+
}
|
|
348
|
+
const report = await addWaveToTopic(projectRoot, parsed.options.topicInput, {
|
|
349
|
+
wave_id: parsed.options.waveId,
|
|
350
|
+
slug: parsed.options.slug,
|
|
351
|
+
state: "candidate",
|
|
352
|
+
primary_closure_goal: parsed.options.goal,
|
|
353
|
+
deps: parsed.options.deps,
|
|
354
|
+
owner_domain: parsed.options.ownerDomain,
|
|
355
|
+
parallelizable_after: parsed.options.parallelizableAfter,
|
|
356
|
+
selected: false,
|
|
357
|
+
});
|
|
358
|
+
if (!report.ok) {
|
|
359
|
+
process.stderr.write(`${report.error}\n`);
|
|
360
|
+
return 1;
|
|
361
|
+
}
|
|
362
|
+
if (parsed.options.json) {
|
|
363
|
+
writeJson(buildJsonReport("topic.wave.add", report));
|
|
364
|
+
} else {
|
|
365
|
+
process.stdout.write(formatWaveMutation(report, "wave add"));
|
|
366
|
+
}
|
|
367
|
+
return 0;
|
|
368
|
+
}
|
|
369
|
+
if (action === "select") {
|
|
370
|
+
const parsed = parseWaveActionOptions(rest, "select");
|
|
371
|
+
if (!parsed.ok) {
|
|
372
|
+
process.stderr.write(parsed.error);
|
|
373
|
+
return 2;
|
|
374
|
+
}
|
|
375
|
+
const report = await selectWaveInTopic(projectRoot, parsed.options.topicInput, parsed.options.waveId);
|
|
376
|
+
if (!report.ok) {
|
|
377
|
+
process.stderr.write(`${report.error}\n`);
|
|
378
|
+
return 1;
|
|
379
|
+
}
|
|
380
|
+
if (parsed.options.json) {
|
|
381
|
+
writeJson(buildJsonReport("topic.wave.select", report));
|
|
382
|
+
} else {
|
|
383
|
+
process.stdout.write(formatWaveMutation(report, "wave select"));
|
|
384
|
+
}
|
|
385
|
+
return 0;
|
|
386
|
+
}
|
|
387
|
+
if (action === "admit") {
|
|
388
|
+
const parsed = parseWaveActionOptions(rest, "admit");
|
|
389
|
+
if (!parsed.ok) {
|
|
390
|
+
process.stderr.write(parsed.error);
|
|
391
|
+
return 2;
|
|
392
|
+
}
|
|
393
|
+
const report = await admitWaveInTopic(projectRoot, parsed.options.topicInput, parsed.options.waveId);
|
|
394
|
+
if (!report.ok) {
|
|
395
|
+
if (parsed.options.json) {
|
|
396
|
+
writeJson(buildJsonReport("topic.wave.admit", report));
|
|
397
|
+
} else if (report.checks) {
|
|
398
|
+
process.stdout.write(formatAdmissionValidate(report, parsed.options.waveId));
|
|
399
|
+
} else {
|
|
400
|
+
process.stderr.write(`${report.error}\n`);
|
|
401
|
+
}
|
|
402
|
+
return 1;
|
|
403
|
+
}
|
|
404
|
+
if (parsed.options.json) {
|
|
405
|
+
writeJson(buildJsonReport("topic.wave.admit", report));
|
|
406
|
+
} else {
|
|
407
|
+
process.stdout.write(formatWaveMutation(report, "wave admit"));
|
|
408
|
+
}
|
|
409
|
+
return 0;
|
|
410
|
+
}
|
|
411
|
+
process.stderr.write(`${localize(
|
|
412
|
+
`nimicoding topic wave refused: unknown subcommand ${action}.`,
|
|
413
|
+
`nimicoding topic wave 已拒绝:未知子命令 ${action}。`,
|
|
414
|
+
)}\n`);
|
|
415
|
+
return 2;
|
|
416
|
+
}
|
|
417
|
+
async function runTopicPacket(args) {
|
|
418
|
+
const [action, ...rest] = args;
|
|
419
|
+
if (action !== "freeze") {
|
|
420
|
+
process.stderr.write(`${localize(
|
|
421
|
+
"nimicoding topic packet refused: expected `freeze`.",
|
|
422
|
+
"nimicoding topic packet 已拒绝:需要 `freeze`。",
|
|
423
|
+
)}\n`);
|
|
424
|
+
return 2;
|
|
425
|
+
}
|
|
426
|
+
const parsed = parsePacketFreezeOptions(rest);
|
|
427
|
+
if (!parsed.ok) {
|
|
428
|
+
process.stderr.write(parsed.error);
|
|
429
|
+
return 2;
|
|
430
|
+
}
|
|
431
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
432
|
+
const report = await freezePacketForTopic(projectRoot, parsed.options.topicInput, parsed.options.from);
|
|
433
|
+
if (!report.ok) {
|
|
434
|
+
process.stderr.write(`${report.error}\n`);
|
|
435
|
+
return 1;
|
|
436
|
+
}
|
|
437
|
+
if (parsed.options.json) {
|
|
438
|
+
writeJson(buildJsonReport("topic.packet.freeze", report));
|
|
439
|
+
} else {
|
|
440
|
+
process.stdout.write(formatPacketFreeze(report));
|
|
441
|
+
}
|
|
442
|
+
return 0;
|
|
443
|
+
}
|
|
444
|
+
async function runTopicDispatch(args, role) {
|
|
445
|
+
const parsed = parseDispatchOptions(args, role);
|
|
446
|
+
if (!parsed.ok) {
|
|
447
|
+
process.stderr.write(parsed.error);
|
|
448
|
+
return 2;
|
|
449
|
+
}
|
|
450
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
451
|
+
const report = await dispatchTopicPacket(projectRoot, parsed.options.topicInput, parsed.options.packetId, role);
|
|
452
|
+
if (!report.ok) {
|
|
453
|
+
process.stderr.write(`${report.error}\n`);
|
|
454
|
+
return 1;
|
|
455
|
+
}
|
|
456
|
+
if (parsed.options.json) {
|
|
457
|
+
writeJson(buildJsonReport(`topic.${role}.dispatch`, report));
|
|
458
|
+
} else {
|
|
459
|
+
process.stdout.write(formatDispatch(report));
|
|
460
|
+
}
|
|
461
|
+
return 0;
|
|
462
|
+
}
|
|
463
|
+
async function runTopicRole(args, role) {
|
|
464
|
+
const [action, ...rest] = args;
|
|
465
|
+
if (action !== "dispatch") {
|
|
466
|
+
process.stderr.write(`${localize(
|
|
467
|
+
`nimicoding topic ${role} refused: expected \`dispatch\`.`,
|
|
468
|
+
`nimicoding topic ${role} 已拒绝:需要 \`dispatch\`。`,
|
|
469
|
+
)}\n`);
|
|
470
|
+
return 2;
|
|
471
|
+
}
|
|
472
|
+
return runTopicDispatch(rest, role);
|
|
473
|
+
}
|
|
474
|
+
async function runTopicResult(args) {
|
|
475
|
+
const [action, ...rest] = args;
|
|
476
|
+
if (action !== "record") {
|
|
477
|
+
process.stderr.write(`${localize(
|
|
478
|
+
"nimicoding topic result refused: expected `record`.",
|
|
479
|
+
"nimicoding topic result 已拒绝:需要 `record`。",
|
|
480
|
+
)}\n`);
|
|
481
|
+
return 2;
|
|
482
|
+
}
|
|
483
|
+
const parsed = parseResultRecordOptions(rest);
|
|
484
|
+
if (!parsed.ok) {
|
|
485
|
+
process.stderr.write(parsed.error);
|
|
486
|
+
return 2;
|
|
487
|
+
}
|
|
488
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
489
|
+
const authority = await loadTopicRuntimeAuthority(projectRoot);
|
|
490
|
+
const verdictCheck = validateEnumOption(
|
|
491
|
+
"--verdict",
|
|
492
|
+
parsed.options.verdict,
|
|
493
|
+
authority.resultVerdicts,
|
|
494
|
+
"nimicoding topic result record refused",
|
|
495
|
+
);
|
|
496
|
+
if (!verdictCheck.ok) {
|
|
497
|
+
process.stderr.write(verdictCheck.error);
|
|
498
|
+
return 2;
|
|
499
|
+
}
|
|
500
|
+
const kindCheck = validateEnumOption(
|
|
501
|
+
"--kind",
|
|
502
|
+
parsed.options.kind,
|
|
503
|
+
authority.resultKinds,
|
|
504
|
+
"nimicoding topic result record refused",
|
|
505
|
+
);
|
|
506
|
+
if (!kindCheck.ok) {
|
|
507
|
+
process.stderr.write(kindCheck.error);
|
|
508
|
+
return 2;
|
|
509
|
+
}
|
|
510
|
+
const report = await recordTopicResult(
|
|
511
|
+
projectRoot,
|
|
512
|
+
parsed.options.topicInput,
|
|
513
|
+
parsed.options.kind,
|
|
514
|
+
parsed.options.verdict,
|
|
515
|
+
parsed.options.from,
|
|
516
|
+
parsed.options.verifiedAt,
|
|
517
|
+
);
|
|
518
|
+
if (!report.ok) {
|
|
519
|
+
process.stderr.write(`${report.error}\n`);
|
|
520
|
+
return 1;
|
|
521
|
+
}
|
|
522
|
+
if (parsed.options.json) {
|
|
523
|
+
writeJson(buildJsonReport("topic.result.record", report));
|
|
524
|
+
} else {
|
|
525
|
+
process.stdout.write(formatResultRecord(report));
|
|
526
|
+
}
|
|
527
|
+
return 0;
|
|
528
|
+
}
|
|
529
|
+
async function runTopicDecisionReview(args) {
|
|
530
|
+
const parsed = parseDecisionReviewOptions(args);
|
|
531
|
+
if (!parsed.ok) {
|
|
532
|
+
process.stderr.write(parsed.error);
|
|
533
|
+
return 2;
|
|
534
|
+
}
|
|
535
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
536
|
+
const authority = await loadTopicRuntimeAuthority(projectRoot);
|
|
537
|
+
const dispositionCheck = validateEnumOption(
|
|
538
|
+
"--disposition",
|
|
539
|
+
parsed.options.disposition,
|
|
540
|
+
authority.decisionDispositions,
|
|
541
|
+
"nimicoding topic decision-review refused",
|
|
542
|
+
);
|
|
543
|
+
if (!dispositionCheck.ok) {
|
|
544
|
+
process.stderr.write(dispositionCheck.error);
|
|
545
|
+
return 2;
|
|
546
|
+
}
|
|
547
|
+
const report = await createDecisionReview(projectRoot, parsed.options.topicInput, parsed.options.slug, {
|
|
548
|
+
date: parsed.options.date,
|
|
549
|
+
decision: parsed.options.decision,
|
|
550
|
+
replacedScope: parsed.options.replacedScope,
|
|
551
|
+
activeReplacementScope: parsed.options.activeReplacementScope,
|
|
552
|
+
disposition: parsed.options.disposition,
|
|
553
|
+
targetWaveId: parsed.options.targetWaveId,
|
|
554
|
+
});
|
|
555
|
+
if (!report.ok) {
|
|
556
|
+
process.stderr.write(`${report.error}\n`);
|
|
557
|
+
return 1;
|
|
558
|
+
}
|
|
559
|
+
if (parsed.options.json) {
|
|
560
|
+
writeJson(buildJsonReport("topic.decision-review", report));
|
|
561
|
+
} else {
|
|
562
|
+
process.stdout.write(formatDecisionReview(report));
|
|
563
|
+
}
|
|
564
|
+
return 0;
|
|
565
|
+
}
|
|
566
|
+
async function runTopicRemediation(args) {
|
|
567
|
+
const [action, ...rest] = args;
|
|
568
|
+
if (action !== "open") {
|
|
569
|
+
process.stderr.write(`${localize(
|
|
570
|
+
"nimicoding topic remediation refused: expected `open`.",
|
|
571
|
+
"nimicoding topic remediation 已拒绝:需要 `open`。",
|
|
572
|
+
)}\n`);
|
|
573
|
+
return 2;
|
|
574
|
+
}
|
|
575
|
+
const parsed = parseRemediationOpenOptions(rest);
|
|
576
|
+
if (!parsed.ok) {
|
|
577
|
+
process.stderr.write(parsed.error);
|
|
578
|
+
return 2;
|
|
579
|
+
}
|
|
580
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
581
|
+
const authority = await loadTopicRuntimeAuthority(projectRoot);
|
|
582
|
+
const kindCheck = validateEnumOption(
|
|
583
|
+
"--kind",
|
|
584
|
+
parsed.options.kind,
|
|
585
|
+
authority.remediationKinds,
|
|
586
|
+
"nimicoding topic remediation open refused",
|
|
587
|
+
);
|
|
588
|
+
if (!kindCheck.ok) {
|
|
589
|
+
process.stderr.write(kindCheck.error);
|
|
590
|
+
return 2;
|
|
591
|
+
}
|
|
592
|
+
const report = await openTopicRemediation(projectRoot, parsed.options.topicInput, {
|
|
593
|
+
kind: parsed.options.kind,
|
|
594
|
+
reason: parsed.options.reason,
|
|
595
|
+
overflowedPacketId: parsed.options.overflowedPacketId,
|
|
596
|
+
});
|
|
597
|
+
if (!report.ok) {
|
|
598
|
+
process.stderr.write(`${report.error}\n`);
|
|
599
|
+
return 1;
|
|
600
|
+
}
|
|
601
|
+
if (parsed.options.json) {
|
|
602
|
+
writeJson(buildJsonReport("topic.remediation.open", report));
|
|
603
|
+
} else {
|
|
604
|
+
process.stdout.write(formatRemediation(report));
|
|
605
|
+
}
|
|
606
|
+
return 0;
|
|
607
|
+
}
|
|
608
|
+
async function runTopicOverflow(args) {
|
|
609
|
+
const [action, ...rest] = args;
|
|
610
|
+
if (action !== "continue") {
|
|
611
|
+
process.stderr.write(`${localize(
|
|
612
|
+
"nimicoding topic overflow refused: expected `continue`.",
|
|
613
|
+
"nimicoding topic overflow 已拒绝:需要 `continue`。",
|
|
614
|
+
)}\n`);
|
|
615
|
+
return 2;
|
|
616
|
+
}
|
|
617
|
+
const parsed = parseOverflowContinueOptions(rest);
|
|
618
|
+
if (!parsed.ok) {
|
|
619
|
+
process.stderr.write(parsed.error);
|
|
620
|
+
return 2;
|
|
621
|
+
}
|
|
622
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
623
|
+
const report = await continueTopicOverflow(projectRoot, parsed.options.topicInput, {
|
|
624
|
+
continuationPacketId: parsed.options.continuationPacketId,
|
|
625
|
+
overflowedPacketId: parsed.options.overflowedPacketId,
|
|
626
|
+
managerJudgement: parsed.options.managerJudgement,
|
|
627
|
+
sameOwnerDomain: parsed.options.sameOwnerDomain,
|
|
628
|
+
});
|
|
629
|
+
if (!report.ok) {
|
|
630
|
+
process.stderr.write(`${report.error}\n`);
|
|
631
|
+
return 1;
|
|
632
|
+
}
|
|
633
|
+
if (parsed.options.json) {
|
|
634
|
+
writeJson(buildJsonReport("topic.overflow.continue", report));
|
|
635
|
+
} else {
|
|
636
|
+
process.stdout.write(formatOverflowContinuation(report));
|
|
637
|
+
}
|
|
638
|
+
return 0;
|
|
639
|
+
}
|
|
640
|
+
async function runTopicCloseout(args) {
|
|
641
|
+
const [scope, ...rest] = args;
|
|
642
|
+
if (scope !== "wave" && scope !== "topic") {
|
|
643
|
+
process.stderr.write(`${localize(
|
|
644
|
+
"nimicoding topic closeout refused: expected `wave` or `topic`.",
|
|
645
|
+
"nimicoding topic closeout 已拒绝:需要 `wave` 或 `topic`。",
|
|
646
|
+
)}\n`);
|
|
647
|
+
return 2;
|
|
648
|
+
}
|
|
649
|
+
const parsed = parseCloseoutOptions(rest, scope);
|
|
650
|
+
if (!parsed.ok) {
|
|
651
|
+
process.stderr.write(parsed.error);
|
|
652
|
+
return 2;
|
|
653
|
+
}
|
|
654
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
655
|
+
const authority = await loadTopicRuntimeAuthority(projectRoot);
|
|
656
|
+
const closureChecks = [
|
|
657
|
+
["--authority", parsed.options.authorityClosure],
|
|
658
|
+
["--semantic", parsed.options.semanticClosure],
|
|
659
|
+
["--consumer", parsed.options.consumerClosure],
|
|
660
|
+
["--drift-resistance", parsed.options.driftResistanceClosure],
|
|
661
|
+
];
|
|
662
|
+
for (const [flag, value] of closureChecks) {
|
|
663
|
+
const enumCheck = validateEnumOption(flag, value, authority.closureStates, `nimicoding topic closeout ${scope} refused`);
|
|
664
|
+
if (!enumCheck.ok) {
|
|
665
|
+
process.stderr.write(enumCheck.error);
|
|
666
|
+
return 2;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
const dispositionCheck = validateEnumOption(
|
|
670
|
+
"--disposition",
|
|
671
|
+
parsed.options.disposition,
|
|
672
|
+
authority.closeoutDispositions,
|
|
673
|
+
`nimicoding topic closeout ${scope} refused`,
|
|
674
|
+
);
|
|
675
|
+
if (!dispositionCheck.ok) {
|
|
676
|
+
process.stderr.write(dispositionCheck.error);
|
|
677
|
+
return 2;
|
|
678
|
+
}
|
|
679
|
+
if (scope === "wave") {
|
|
680
|
+
const report = await closeoutWaveInTopic(projectRoot, parsed.options.topicInput, parsed.options.waveId, parsed.options);
|
|
681
|
+
if (!report.ok) {
|
|
682
|
+
if (parsed.options.json) {
|
|
683
|
+
writeJson(buildJsonReport("topic.closeout.wave", report));
|
|
684
|
+
} else if (report.checks) {
|
|
685
|
+
process.stdout.write(formatClosureValidate(report, parsed.options.waveId));
|
|
686
|
+
} else {
|
|
687
|
+
process.stderr.write(`${report.error}\n`);
|
|
688
|
+
}
|
|
689
|
+
return 1;
|
|
690
|
+
}
|
|
691
|
+
if (parsed.options.json) {
|
|
692
|
+
writeJson(buildJsonReport("topic.closeout.wave", report));
|
|
693
|
+
} else {
|
|
694
|
+
process.stdout.write(formatCloseout(report, "wave"));
|
|
695
|
+
}
|
|
696
|
+
return 0;
|
|
697
|
+
}
|
|
698
|
+
const report = await closeoutTopicInTopic(projectRoot, parsed.options.topicInput, parsed.options);
|
|
699
|
+
if (!report.ok) {
|
|
700
|
+
if (parsed.options.json) {
|
|
701
|
+
writeJson(buildJsonReport("topic.closeout.topic", report));
|
|
702
|
+
} else if (report.checks) {
|
|
703
|
+
process.stdout.write(formatTrueCloseAudit(report));
|
|
704
|
+
} else {
|
|
705
|
+
process.stderr.write(`${report.error}\n`);
|
|
706
|
+
}
|
|
707
|
+
return 1;
|
|
708
|
+
}
|
|
709
|
+
if (parsed.options.json) {
|
|
710
|
+
writeJson(buildJsonReport("topic.closeout.topic", report));
|
|
711
|
+
} else {
|
|
712
|
+
process.stdout.write(formatCloseout(report, "topic"));
|
|
713
|
+
}
|
|
714
|
+
return 0;
|
|
715
|
+
}
|
|
716
|
+
async function runTopicTrueCloseAuditCommand(args) {
|
|
717
|
+
const parsed = parseTrueCloseAuditOptions(args);
|
|
718
|
+
if (!parsed.ok) {
|
|
719
|
+
process.stderr.write(parsed.error);
|
|
720
|
+
return 2;
|
|
721
|
+
}
|
|
722
|
+
const projectRoot = await resolveTopicProjectRoot(process.cwd());
|
|
723
|
+
const report = await runTopicTrueCloseAudit(projectRoot, parsed.options.topicInput, parsed.options.judgement);
|
|
724
|
+
if (parsed.options.json) {
|
|
725
|
+
writeJson(buildJsonReport("topic.true-close-audit", report));
|
|
726
|
+
} else if (report.topicId) {
|
|
727
|
+
process.stdout.write(formatTrueCloseAudit(report));
|
|
728
|
+
} else {
|
|
729
|
+
process.stderr.write(`${report.error}\n`);
|
|
730
|
+
}
|
|
731
|
+
return report.ok ? 0 : 1;
|
|
732
|
+
}
|
|
733
|
+
export async function runTopic(args) {
|
|
734
|
+
const [subcommand, ...rest] = args;
|
|
735
|
+
if (!subcommand) {
|
|
736
|
+
process.stderr.write(`${localize(
|
|
737
|
+
"nimicoding topic refused: expected a subcommand (`create`, `status`, `goal`, `run-next-step`, `run-ledger`, `validate`, `wave`, `packet`, `worker`, `audit`, `result`, `remediation`, `overflow`, `hold`, `resume`, `closeout`, `true-close-audit`, or `decision-review`).",
|
|
738
|
+
"nimicoding topic 已拒绝:需要子命令(`create`、`status`、`goal`、`run-next-step`、`run-ledger`、`validate`、`wave`、`packet`、`worker`、`audit`、`result`、`remediation`、`overflow`、`hold`、`resume`、`closeout`、`true-close-audit` 或 `decision-review`)。",
|
|
739
|
+
)}\n`);
|
|
740
|
+
return 2;
|
|
741
|
+
}
|
|
742
|
+
if (subcommand === "create") {
|
|
743
|
+
return runTopicCreate(rest);
|
|
744
|
+
}
|
|
745
|
+
if (subcommand === "status") {
|
|
746
|
+
return runTopicStatus(rest);
|
|
747
|
+
}
|
|
748
|
+
if (subcommand === "goal") return runTopicGoal(rest);
|
|
749
|
+
if (subcommand === "run-next-step") {
|
|
750
|
+
return runTopicNextStep(rest);
|
|
751
|
+
}
|
|
752
|
+
if (subcommand === "run-ledger") {
|
|
753
|
+
return runTopicRunLedger(rest);
|
|
754
|
+
}
|
|
755
|
+
if (subcommand === "validate") {
|
|
756
|
+
return runTopicValidate(rest);
|
|
757
|
+
}
|
|
758
|
+
if (subcommand === "wave") {
|
|
759
|
+
return runTopicWave(rest);
|
|
760
|
+
}
|
|
761
|
+
if (subcommand === "packet") {
|
|
762
|
+
return runTopicPacket(rest);
|
|
763
|
+
}
|
|
764
|
+
if (subcommand === "worker") {
|
|
765
|
+
return runTopicRole(rest, "worker");
|
|
766
|
+
}
|
|
767
|
+
if (subcommand === "audit") {
|
|
768
|
+
return runTopicRole(rest, "audit");
|
|
769
|
+
}
|
|
770
|
+
if (subcommand === "result") {
|
|
771
|
+
return runTopicResult(rest);
|
|
772
|
+
}
|
|
773
|
+
if (subcommand === "remediation") {
|
|
774
|
+
return runTopicRemediation(rest);
|
|
775
|
+
}
|
|
776
|
+
if (subcommand === "overflow") {
|
|
777
|
+
return runTopicOverflow(rest);
|
|
778
|
+
}
|
|
779
|
+
if (subcommand === "hold") {
|
|
780
|
+
return runTopicHold(rest);
|
|
781
|
+
}
|
|
782
|
+
if (subcommand === "resume") return runTopicResume(rest);
|
|
783
|
+
if (subcommand === "closeout") {
|
|
784
|
+
return runTopicCloseout(rest);
|
|
785
|
+
}
|
|
786
|
+
if (subcommand === "true-close-audit") {
|
|
787
|
+
return runTopicTrueCloseAuditCommand(rest);
|
|
788
|
+
}
|
|
789
|
+
if (subcommand === "decision-review") return runTopicDecisionReview(rest);
|
|
790
|
+
process.stderr.write(`${localize(
|
|
791
|
+
`nimicoding topic refused: unknown subcommand ${subcommand}.`,
|
|
792
|
+
`nimicoding topic 已拒绝:未知子命令 ${subcommand}。`,
|
|
793
|
+
)}\n`);
|
|
794
|
+
return 2;
|
|
795
|
+
}
|