@nimiplatform/nimi-coding 0.2.8 → 0.3.1

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 (206) hide show
  1. package/CHANGELOG.md +10 -90
  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/commands/validate-spec-governance.mjs +20 -0
  8. package/cli/constants.mjs +9 -417
  9. package/cli/help.mjs +28 -145
  10. package/cli/index.mjs +5 -33
  11. package/cli/lib/blueprint-audit.mjs +5 -12
  12. package/cli/lib/bootstrap.mjs +0 -9
  13. package/cli/lib/contracts.mjs +0 -163
  14. package/cli/lib/doctor.mjs +155 -10
  15. package/cli/lib/entrypoints.mjs +63 -167
  16. package/cli/lib/internal/contracts-loaders.mjs +0 -85
  17. package/cli/lib/internal/contracts-parse.mjs +84 -520
  18. package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
  19. package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
  20. package/cli/lib/internal/validators-shared.mjs +0 -16
  21. package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
  22. package/cli/lib/internal/validators-spec.mjs +103 -342
  23. package/cli/lib/shared.mjs +1 -42
  24. package/cli/lib/validators.mjs +0 -48
  25. package/cli/seeds/seed-policy.yaml +0 -3
  26. package/config/bootstrap.yaml +4 -4
  27. package/config/spec-generation-inputs.yaml +6 -12
  28. package/contracts/domain-admission.schema.yaml +3 -3
  29. package/contracts/migration-inventory.schema.yaml +12 -75
  30. package/contracts/negative-fixtures.yaml +19 -99
  31. package/contracts/placement-contract.schema.yaml +49 -78
  32. package/contracts/projection-edge.schema.yaml +37 -121
  33. package/contracts/shared-enums.yaml +4 -8
  34. package/contracts/spec-generation-inputs.schema.yaml +15 -112
  35. package/contracts/spec-layout.schema.yaml +32 -0
  36. package/contracts/surface-taxonomy.schema.yaml +43 -94
  37. package/contracts/table-family.schema.yaml +1 -1
  38. package/contracts/tracked-output-admission.schema.yaml +13 -66
  39. package/methodology/core.yaml +33 -25
  40. package/methodology/four-closure-policy.yaml +18 -26
  41. package/methodology/role-separation-policy.yaml +21 -27
  42. package/methodology/spec-reconstruction.yaml +17 -34
  43. package/package.json +2 -4
  44. package/spec/_meta/spec-tree-model.yaml +5 -101
  45. package/spec/product-scope.yaml +25 -57
  46. package/adapters/README.md +0 -25
  47. package/adapters/claude/README.md +0 -89
  48. package/adapters/claude/profile.yaml +0 -70
  49. package/adapters/codex/README.md +0 -53
  50. package/adapters/codex/profile.yaml +0 -78
  51. package/adapters/oh-my-codex/README.md +0 -184
  52. package/adapters/oh-my-codex/profile.yaml +0 -46
  53. package/cli/commands/admit-high-risk-decision.mjs +0 -108
  54. package/cli/commands/audit-sweep.mjs +0 -364
  55. package/cli/commands/closeout.mjs +0 -186
  56. package/cli/commands/decide-high-risk-execution.mjs +0 -124
  57. package/cli/commands/handoff.mjs +0 -123
  58. package/cli/commands/ingest-high-risk-execution.mjs +0 -95
  59. package/cli/commands/review-high-risk-execution.mjs +0 -95
  60. package/cli/commands/sweep-design.mjs +0 -295
  61. package/cli/commands/sweep.mjs +0 -22
  62. package/cli/commands/topic-formatters.mjs +0 -382
  63. package/cli/commands/topic-goal.mjs +0 -33
  64. package/cli/commands/topic-options-shared.mjs +0 -27
  65. package/cli/commands/topic-options-workflow.mjs +0 -767
  66. package/cli/commands/topic-options.mjs +0 -626
  67. package/cli/commands/topic-runner.mjs +0 -169
  68. package/cli/commands/topic.mjs +0 -795
  69. package/cli/commands/validate-acceptance.mjs +0 -5
  70. package/cli/commands/validate-execution-packet.mjs +0 -5
  71. package/cli/commands/validate-orchestration-state.mjs +0 -5
  72. package/cli/commands/validate-prompt.mjs +0 -5
  73. package/cli/commands/validate-worker-output.mjs +0 -5
  74. package/cli/lib/adapter-profiles.mjs +0 -403
  75. package/cli/lib/audit-execution.mjs +0 -52
  76. package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
  77. package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
  78. package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
  79. package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
  80. package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
  81. package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
  82. package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
  83. package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
  84. package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
  85. package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
  86. package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
  87. package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
  88. package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
  89. package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
  90. package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
  91. package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
  92. package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
  93. package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
  94. package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
  95. package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
  96. package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
  97. package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
  98. package/cli/lib/audit-sweep.mjs +0 -19
  99. package/cli/lib/authority-convergence.mjs +0 -720
  100. package/cli/lib/closeout.mjs +0 -732
  101. package/cli/lib/codex-sdk-runner.mjs +0 -76
  102. package/cli/lib/external-execution.mjs +0 -101
  103. package/cli/lib/handoff.mjs +0 -812
  104. package/cli/lib/high-risk-admission.mjs +0 -512
  105. package/cli/lib/high-risk-decision.mjs +0 -353
  106. package/cli/lib/high-risk-ingest.mjs +0 -321
  107. package/cli/lib/high-risk-review.mjs +0 -267
  108. package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
  109. package/cli/lib/internal/contracts-validators.mjs +0 -399
  110. package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
  111. package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
  112. package/cli/lib/internal/doctor-finalize.mjs +0 -383
  113. package/cli/lib/internal/doctor-format.mjs +0 -286
  114. package/cli/lib/internal/doctor-inspectors.mjs +0 -327
  115. package/cli/lib/internal/doctor-state.mjs +0 -205
  116. package/cli/lib/internal/validators-artifacts.mjs +0 -515
  117. package/cli/lib/sweep-design-runtime/common.mjs +0 -246
  118. package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
  119. package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
  120. package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
  121. package/cli/lib/sweep-design-runtime/results.mjs +0 -324
  122. package/cli/lib/sweep-design.mjs +0 -8
  123. package/cli/lib/topic-artifacts.mjs +0 -186
  124. package/cli/lib/topic-authority-coverage.mjs +0 -73
  125. package/cli/lib/topic-closeout.mjs +0 -560
  126. package/cli/lib/topic-common.mjs +0 -404
  127. package/cli/lib/topic-decisions.mjs +0 -332
  128. package/cli/lib/topic-draft-packets.mjs +0 -167
  129. package/cli/lib/topic-execution.mjs +0 -533
  130. package/cli/lib/topic-goal.mjs +0 -440
  131. package/cli/lib/topic-ledger.mjs +0 -281
  132. package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
  133. package/cli/lib/topic-root-validation.mjs +0 -288
  134. package/cli/lib/topic-runner-commands.mjs +0 -174
  135. package/cli/lib/topic-runner-deferral.mjs +0 -532
  136. package/cli/lib/topic-runner-stale-gates.mjs +0 -114
  137. package/cli/lib/topic-runner-validation.mjs +0 -138
  138. package/cli/lib/topic-runner.mjs +0 -727
  139. package/cli/lib/topic-scaffold.mjs +0 -252
  140. package/cli/lib/topic-waves.mjs +0 -403
  141. package/cli/lib/topic.mjs +0 -81
  142. package/config/audit-execution-artifacts.yaml +0 -20
  143. package/config/external-execution-artifacts.yaml +0 -16
  144. package/config/host-adapter.yaml +0 -30
  145. package/config/host-profile.yaml +0 -29
  146. package/config/installer-evidence.yaml +0 -31
  147. package/config/skill-installer.yaml +0 -23
  148. package/config/skill-manifest.yaml +0 -48
  149. package/config/skills.yaml +0 -30
  150. package/contracts/acceptance.schema.yaml +0 -16
  151. package/contracts/admission-checklist.schema.yaml +0 -15
  152. package/contracts/audit-chunk.schema.yaml +0 -123
  153. package/contracts/audit-closeout.schema.yaml +0 -51
  154. package/contracts/audit-finding.schema.yaml +0 -61
  155. package/contracts/audit-ledger.schema.yaml +0 -138
  156. package/contracts/audit-plan.schema.yaml +0 -138
  157. package/contracts/audit-remediation-map.schema.yaml +0 -52
  158. package/contracts/audit-rerun.schema.yaml +0 -31
  159. package/contracts/audit-sweep-result.yaml +0 -53
  160. package/contracts/authority-convergence-audit.schema.yaml +0 -19
  161. package/contracts/closeout.schema.yaml +0 -25
  162. package/contracts/decision-review.schema.yaml +0 -16
  163. package/contracts/doc-spec-audit-result.yaml +0 -19
  164. package/contracts/execution-packet.schema.yaml +0 -49
  165. package/contracts/external-host-compatibility.yaml +0 -22
  166. package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
  167. package/contracts/high-risk-admission.schema.yaml +0 -23
  168. package/contracts/high-risk-execution-result.yaml +0 -20
  169. package/contracts/orchestration-state.schema.yaml +0 -41
  170. package/contracts/overflow-continuation.schema.yaml +0 -12
  171. package/contracts/packet.schema.yaml +0 -30
  172. package/contracts/pending-note.schema.yaml +0 -17
  173. package/contracts/prompt.schema.yaml +0 -12
  174. package/contracts/remediation.schema.yaml +0 -16
  175. package/contracts/result.schema.yaml +0 -24
  176. package/contracts/spec-reconstruction-result.yaml +0 -41
  177. package/contracts/sweep-design-result.yaml +0 -349
  178. package/contracts/topic-goal.schema.yaml +0 -87
  179. package/contracts/topic-run-ledger.schema.yaml +0 -72
  180. package/contracts/topic-step-decision.schema.yaml +0 -45
  181. package/contracts/topic.schema.yaml +0 -65
  182. package/contracts/true-close.schema.yaml +0 -15
  183. package/contracts/wave.schema.yaml +0 -29
  184. package/contracts/worker-output.schema.yaml +0 -15
  185. package/contracts/workflow-consumer.schema.yaml +0 -110
  186. package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
  187. package/methodology/authority-convergence-policy.yaml +0 -42
  188. package/methodology/overflow-continuation-policy.yaml +0 -14
  189. package/methodology/skill-exchange-projection.yaml +0 -114
  190. package/methodology/skill-handoff.yaml +0 -34
  191. package/methodology/skill-installer-result.yaml +0 -27
  192. package/methodology/skill-installer-summary-projection.yaml +0 -181
  193. package/methodology/skill-runtime.yaml +0 -23
  194. package/methodology/spec-target-truth-profile.yaml +0 -46
  195. package/methodology/topic-lifecycle-report.yaml +0 -144
  196. package/methodology/topic-lifecycle.yaml +0 -37
  197. package/methodology/topic-naming-ontology.yaml +0 -21
  198. package/methodology/topic-ontology.yaml +0 -38
  199. package/methodology/topic-validation-policy.yaml +0 -9
  200. package/methodology/wave-dag-policy.yaml +0 -14
  201. package/spec/_meta/command-gating-matrix.yaml +0 -143
  202. package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
  203. package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
  204. package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
  205. package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
  206. package/spec/bootstrap-state.yaml +0 -99
@@ -1,382 +0,0 @@
1
- import { localize, styleHeading, styleLabel, styleMuted } from "../lib/ui.mjs";
2
-
3
- export function buildJsonReport(command, report) {
4
- return {
5
- contract: "nimicoding.topic-command-result.v1",
6
- command,
7
- ...report,
8
- };
9
- }
10
- export function writeJson(report) {
11
- process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
12
- }
13
- export function formatTopicGoalRefusal(report) {
14
- const blockingChecks = report.readiness?.checks?.filter((entry) => entry.status === "fail") ?? [];
15
- const lines = [
16
- "nimicoding topic goal refused: topic is not goal-ready.",
17
- "",
18
- `Topic: ${report.topic_id ?? "unknown"}`,
19
- `State: ${report.topic_state ?? "unknown"}`,
20
- `Selected Next Target: ${report.selected_next_target ?? "none"}`,
21
- "",
22
- "Blocking checks:",
23
- ...blockingChecks.map((entry) => `- ${entry.id}: ${entry.message}`),
24
- "",
25
- "Fix the topic admission artifacts first, then rerun:",
26
- `pnpm exec nimicoding topic goal ${report.topic_id ?? "<topic-id>"}`,
27
- ];
28
- return `${lines.join("\n")}\n`;
29
- }
30
- export function formatTopicStatus(report) {
31
- const lines = [
32
- styleHeading(`nimicoding topic status: ${report.topicId}`),
33
- "",
34
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
35
- `${styleLabel(localize("State", "状态"))}: ${report.state}`,
36
- `${styleLabel(localize("Schema", "Schema"))}: ${report.schemaMode}`,
37
- `${styleLabel(localize("Title", "标题"))}: ${report.title ?? localize("none", "无")}`,
38
- `${styleLabel(localize("Selected Next Target", "当前下一目标"))}: ${report.selectedNextTarget ?? localize("none", "无")}`,
39
- `${styleLabel(localize("True-Close", "True-Close"))}: ${report.currentTrueCloseStatus ?? localize("none", "无")}`,
40
- `${styleLabel(localize("Pending Note", "Pending Note"))}: ${report.pendingNoteStatus ?? localize("none", "无")}`,
41
- `${styleLabel(localize("Migration Posture", "迁移姿态"))}: ${report.migrationPosture ?? localize("none", "无")}`,
42
- `${styleLabel(localize("Validation Disposition", "校验姿态"))}: ${report.validationDisposition ?? "strict"}`,
43
- `${styleLabel(localize("Canonical Validated", "Canonical 校验"))}: ${report.canonicalValidated ? "true" : "false"}`,
44
- `${styleLabel(localize("Ignored By Policy", "策略忽略"))}: ${report.ignoredByPolicy ? "true" : "false"}`,
45
- ];
46
- if (report.ignoredByPolicy && report.ignorePolicyReason) {
47
- lines.push(`${styleLabel(localize("Ignore Reason", "忽略原因"))}: ${report.ignorePolicyReason}`);
48
- }
49
- if (report.artifactSummary) {
50
- lines.push(
51
- "",
52
- styleLabel(localize("Artifacts", "Artifacts")),
53
- `- files=${report.artifactSummary.files} packets=${report.artifactSummary.packets} results=${report.artifactSummary.results} closeouts=${report.artifactSummary.closeouts}`,
54
- `- decision_reviews=${report.artifactSummary.decision_reviews} remediations=${report.artifactSummary.remediations} overflow_continuations=${report.artifactSummary.overflow_continuations}`,
55
- `- exec_packs=${report.artifactSummary.exec_packs} true_close_artifacts=${report.artifactSummary.true_close_artifacts}`,
56
- );
57
- }
58
- if (report.featureFlags) {
59
- lines.push(
60
- "",
61
- styleLabel(localize("Feature Flags", "Feature Flags")),
62
- ...Object.entries(report.featureFlags).map(([key, value]) => `- ${key}: ${value ? "true" : "false"}`),
63
- );
64
- }
65
- if (Array.isArray(report.observedWaves) && report.observedWaves.length > 0) {
66
- lines.push(
67
- "",
68
- styleLabel(localize("Observed Waves", "Observed Waves")),
69
- ...report.observedWaves.slice(0, 8).map((entry) => (
70
- `- ${entry.wave_id}: ${entry.observed_lineage} packets=${entry.packets} results=${entry.results} closeouts=${entry.closeouts} exec_packs=${entry.exec_packs}`
71
- )),
72
- );
73
- if (report.observedWaves.length > 8) {
74
- lines.push(styleMuted(`- ... ${report.observedWaves.length - 8} more wave observations`));
75
- }
76
- }
77
- if (report.warnings.length > 0) {
78
- lines.push(
79
- "",
80
- styleLabel(localize("Warnings", "警告")),
81
- ...report.warnings.map((entry) => styleMuted(`- ${entry}`)),
82
- );
83
- }
84
- return `${lines.join("\n")}\n`;
85
- }
86
- export function formatTopicValidate(report) {
87
- const lines = [
88
- styleHeading(`nimicoding topic validate: ${report.topicId}`),
89
- "",
90
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
91
- `${styleLabel(localize("State", "状态"))}: ${report.state}`,
92
- `${styleLabel(localize("Schema", "Schema"))}: ${report.schemaMode}`,
93
- `${styleLabel(localize("Result", "结果"))}: ${report.ok ? localize("ok", "通过") : localize("failed", "失败")}`,
94
- `${styleLabel(localize("Pending Note", "Pending Note"))}: ${report.pendingNoteStatus ?? localize("none", "无")}`,
95
- `${styleLabel(localize("Migration Posture", "迁移姿态"))}: ${report.migrationPosture ?? localize("none", "无")}`,
96
- `${styleLabel(localize("Validation Disposition", "校验姿态"))}: ${report.validationDisposition ?? "strict"}`,
97
- `${styleLabel(localize("Canonical Validated", "Canonical 校验"))}: ${report.canonicalValidated ? "true" : "false"}`,
98
- `${styleLabel(localize("Ignored By Policy", "策略忽略"))}: ${report.ignoredByPolicy ? "true" : "false"}`,
99
- "",
100
- styleLabel(localize("Checks", "检查项")),
101
- ...report.checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`),
102
- ];
103
- if (report.ignoredByPolicy && report.ignorePolicyReason) {
104
- lines.push(`${styleLabel(localize("Ignore Reason", "忽略原因"))}: ${report.ignorePolicyReason}`);
105
- }
106
- if (report.artifactSummary) {
107
- lines.push(
108
- "",
109
- styleLabel(localize("Artifacts", "Artifacts")),
110
- `- files=${report.artifactSummary.files} packets=${report.artifactSummary.packets} results=${report.artifactSummary.results} closeouts=${report.artifactSummary.closeouts}`,
111
- `- decision_reviews=${report.artifactSummary.decision_reviews} remediations=${report.artifactSummary.remediations} overflow_continuations=${report.artifactSummary.overflow_continuations}`,
112
- `- exec_packs=${report.artifactSummary.exec_packs} true_close_artifacts=${report.artifactSummary.true_close_artifacts}`,
113
- );
114
- }
115
- if (report.featureFlags) {
116
- lines.push(
117
- "",
118
- styleLabel(localize("Feature Flags", "Feature Flags")),
119
- ...Object.entries(report.featureFlags).map(([key, value]) => `- ${key}: ${value ? "true" : "false"}`),
120
- );
121
- }
122
- if (Array.isArray(report.observedWaves) && report.observedWaves.length > 0) {
123
- lines.push(
124
- "",
125
- styleLabel(localize("Observed Waves", "Observed Waves")),
126
- ...report.observedWaves.slice(0, 8).map((entry) => (
127
- `- ${entry.wave_id}: ${entry.observed_lineage} packets=${entry.packets} results=${entry.results} closeouts=${entry.closeouts} exec_packs=${entry.exec_packs}`
128
- )),
129
- );
130
- if (report.observedWaves.length > 8) {
131
- lines.push(styleMuted(`- ... ${report.observedWaves.length - 8} more wave observations`));
132
- }
133
- }
134
- if (report.warnings.length > 0) {
135
- lines.push(
136
- "",
137
- styleLabel(localize("Warnings", "警告")),
138
- ...report.warnings.map((entry) => styleMuted(`- ${entry}`)),
139
- );
140
- }
141
- return `${lines.join("\n")}\n`;
142
- }
143
- export function formatNextStep(report) {
144
- const decision = report.decision;
145
- const lines = [
146
- styleHeading(`nimicoding topic run-next-step: ${report.topicId}`),
147
- "",
148
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
149
- `${styleLabel(localize("Stop Class", "Stop Class"))}: ${decision.stop_class}`,
150
- `${styleLabel(localize("Action", "Action"))}: ${decision.recommended_action}`,
151
- `${styleLabel(localize("Reason", "Reason"))}: ${decision.reason_code}`,
152
- `${styleLabel(localize("Human Confirmation", "Human Confirmation"))}: ${decision.requires_human_confirmation ? "true" : "false"}`,
153
- `${styleLabel(localize("Recommendation", "Recommendation"))}: ${decision.recommended_decision}`,
154
- `${styleLabel(localize("Rationale", "Rationale"))}: ${decision.recommendation_rationale}`,
155
- ];
156
- if (decision.next_command_ref) {
157
- lines.push(`${styleLabel(localize("Next Command", "Next Command"))}: ${decision.next_command_ref}`);
158
- }
159
- if (Array.isArray(decision.expected_artifacts) && decision.expected_artifacts.length > 0) {
160
- lines.push("", styleLabel(localize("Expected Artifacts", "Expected Artifacts")));
161
- lines.push(...decision.expected_artifacts.map((entry) => `- ${entry}`));
162
- }
163
- if (Array.isArray(decision.blocking_checks) && decision.blocking_checks.length > 0) {
164
- lines.push("", styleLabel(localize("Blocking Checks", "Blocking Checks")));
165
- lines.push(...decision.blocking_checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`));
166
- }
167
- return `${lines.join("\n")}\n`;
168
- }
169
- export function formatRunLedger(report, action) {
170
- const ledger = report.ledger ?? {};
171
- const lines = [
172
- styleHeading(`nimicoding topic run-ledger ${action}: ${report.topicId}`),
173
- "",
174
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
175
- `${styleLabel(localize("Run", "Run"))}: ${report.runId}`,
176
- `${styleLabel(localize("Ledger", "Ledger"))}: ${report.ledgerRef}`,
177
- `${styleLabel(localize("Status", "Status"))}: ${report.runStatus ?? ledger.run_status}`,
178
- `${styleLabel(localize("Events", "Events"))}: ${report.eventCount ?? ledger.event_count ?? 0}`,
179
- ];
180
- if (report.eventRef) {
181
- lines.push(`${styleLabel(localize("Event", "Event"))}: ${report.eventRef}`);
182
- }
183
- if (ledger.current_human_gate) {
184
- lines.push(`${styleLabel(localize("Human Gate", "Human Gate"))}: ${ledger.current_human_gate.summary}`);
185
- }
186
- return `${lines.join("\n")}\n`;
187
- }
188
- export function formatGraphValidate(report) {
189
- const lines = [
190
- styleHeading(`nimicoding topic validate graph: ${report.topicId}`),
191
- "",
192
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
193
- `${styleLabel(localize("Wave Count", "Wave 数量"))}: ${report.waveCount ?? 0}`,
194
- `${styleLabel(localize("Result", "结果"))}: ${report.ok ? localize("ok", "通过") : localize("failed", "失败")}`,
195
- "",
196
- styleLabel(localize("Checks", "检查项")),
197
- ...report.checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`),
198
- ];
199
- if (report.warnings.length > 0) {
200
- lines.push("", styleLabel(localize("Warnings", "警告")), ...report.warnings.map((entry) => styleMuted(`- ${entry}`)));
201
- }
202
- return `${lines.join("\n")}\n`;
203
- }
204
- export function formatAdmissionValidate(report, waveId) {
205
- const lines = [
206
- styleHeading(`nimicoding topic validate admission: ${report.topicId} / ${waveId}`),
207
- "",
208
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
209
- `${styleLabel(localize("Result", "结果"))}: ${report.ok ? localize("ok", "通过") : localize("failed", "失败")}`,
210
- "",
211
- styleLabel(localize("Checks", "检查项")),
212
- ...report.checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`),
213
- ];
214
- if (report.warnings.length > 0) {
215
- lines.push("", styleLabel(localize("Warnings", "警告")), ...report.warnings.map((entry) => styleMuted(`- ${entry}`)));
216
- }
217
- return `${lines.join("\n")}\n`;
218
- }
219
- export function formatClosureValidate(report, waveId) {
220
- const lines = [
221
- styleHeading(`nimicoding topic validate closure: ${report.topicId} / ${waveId}`),
222
- "",
223
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
224
- `${styleLabel(localize("Result", "结果"))}: ${report.ok ? localize("ok", "通过") : localize("failed", "失败")}`,
225
- "",
226
- styleLabel(localize("Checks", "检查项")),
227
- ...report.checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`),
228
- ];
229
- if (report.closeoutRef) {
230
- lines.push("", `${styleLabel(localize("Closeout Ref", "Closeout 路径"))}: ${report.closeoutRef}`);
231
- }
232
- if (report.warnings.length > 0) {
233
- lines.push("", styleLabel(localize("Warnings", "警告")), ...report.warnings.map((entry) => styleMuted(`- ${entry}`)));
234
- }
235
- return `${lines.join("\n")}\n`;
236
- }
237
- export function formatWaveMutation(report, action) {
238
- const lines = [
239
- styleHeading(`nimicoding topic ${action}: ${report.topicId}`),
240
- "",
241
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
242
- `${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}`,
243
- ];
244
- if (report.waveState) {
245
- lines.push(`${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}`);
246
- }
247
- if (report.selectedNextTarget) {
248
- lines.push(`${styleLabel(localize("Selected Next Target", "当前下一目标"))}: ${report.selectedNextTarget}`);
249
- }
250
- if (report.state) {
251
- lines.push(`${styleLabel(localize("Topic State", "Topic 状态"))}: ${report.state}`);
252
- }
253
- return `${lines.join("\n")}\n`;
254
- }
255
- export function formatPacketFreeze(report) {
256
- return `${styleHeading(`nimicoding topic packet freeze: ${report.topicId}`)}
257
- ${styleLabel(localize("Path", "路径"))}: ${report.topicRef}
258
- ${styleLabel(localize("Packet", "Packet"))}: ${report.packetId}
259
- ${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}
260
- ${styleLabel(localize("Packet Ref", "Packet 路径"))}: ${report.packetRef}
261
- ${styleLabel(localize("Status", "状态"))}: ${report.status}
262
- `;
263
- }
264
- export function formatDispatch(report) {
265
- return `${styleHeading(`nimicoding topic ${report.role} dispatch: ${report.topicId}`)}
266
- ${styleLabel(localize("Path", "路径"))}: ${report.topicRef}
267
- ${styleLabel(localize("Packet", "Packet"))}: ${report.packetId}
268
- ${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}
269
- ${styleLabel(localize("Packet Ref", "Packet 路径"))}: ${report.packetRef}
270
- ${styleLabel(localize("Prompt Ref", "Prompt 路径"))}: ${report.promptRef}
271
- ${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}
272
- `;
273
- }
274
- export function formatResultRecord(report) {
275
- return `${styleHeading(`nimicoding topic result record: ${report.topicId}`)}
276
- ${styleLabel(localize("Path", "路径"))}: ${report.topicRef}
277
- ${styleLabel(localize("Result", "Result"))}: ${report.resultId}
278
- ${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}
279
- ${styleLabel(localize("Kind", "类别"))}: ${report.resultKind}
280
- ${styleLabel(localize("Verdict", "结论"))}: ${report.verdict}
281
- ${styleLabel(localize("Result Ref", "Result 路径"))}: ${report.resultRef}
282
- ${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}
283
- `;
284
- }
285
- export function formatDecisionReview(report) {
286
- const lines = [
287
- styleHeading(`nimicoding topic decision-review: ${report.topicId}`),
288
- "",
289
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
290
- `${styleLabel(localize("Decision Review", "Decision Review"))}: ${report.decisionReviewId}`,
291
- `${styleLabel(localize("Disposition", "Disposition"))}: ${report.disposition}`,
292
- `${styleLabel(localize("Review Ref", "Review 路径"))}: ${report.decisionReviewRef}`,
293
- ];
294
- if (report.targetWaveId) {
295
- lines.push(`${styleLabel(localize("Target Wave", "目标 Wave"))}: ${report.targetWaveId}`);
296
- }
297
- return `${lines.join("\n")}\n`;
298
- }
299
- export function formatRemediation(report) {
300
- return `${styleHeading(`nimicoding topic remediation open: ${report.topicId}`)}
301
- ${styleLabel(localize("Path", "路径"))}: ${report.topicRef}
302
- ${styleLabel(localize("Remediation", "Remediation"))}: ${report.remediationId}
303
- ${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}
304
- ${styleLabel(localize("Kind", "类别"))}: ${report.kind}
305
- ${styleLabel(localize("Reason", "原因"))}: ${report.reason}
306
- ${styleLabel(localize("Remediation Ref", "Remediation 路径"))}: ${report.remediationRef}
307
- ${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}
308
- `;
309
- }
310
- export function formatOverflowContinuation(report) {
311
- return `${styleHeading(`nimicoding topic overflow continue: ${report.topicId}`)}
312
- ${styleLabel(localize("Path", "路径"))}: ${report.topicRef}
313
- ${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}
314
- ${styleLabel(localize("Overflowed Packet", "Overflowed Packet"))}: ${report.overflowedPacketId}
315
- ${styleLabel(localize("Continuation Packet", "Continuation Packet"))}: ${report.continuationPacketId}
316
- ${styleLabel(localize("Continuation Ref", "Continuation 路径"))}: ${report.continuationRef}
317
- ${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}
318
- `;
319
- }
320
- export function formatPendingTransition(report, action) {
321
- const lines = [
322
- styleHeading(`nimicoding topic ${action}: ${report.topicId}`),
323
- "",
324
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
325
- `${styleLabel(localize("Topic State", "Topic 状态"))}: ${report.state}`,
326
- `${styleLabel(localize("Pending Note Ref", "Pending Note 路径"))}: ${report.pendingNoteRef}`,
327
- ];
328
- if (report.reason) {
329
- lines.push(`${styleLabel(localize("Reason", "原因"))}: ${report.reason}`);
330
- }
331
- if (report.criteriaMet) {
332
- lines.push(`${styleLabel(localize("Criteria Met", "条件满足"))}: ${report.criteriaMet}`);
333
- }
334
- return `${lines.join("\n")}\n`;
335
- }
336
- export function formatCloseout(report, scope) {
337
- const lines = [
338
- styleHeading(`nimicoding topic closeout ${scope}: ${report.topicId}`),
339
- "",
340
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
341
- `${styleLabel(localize("Closeout Ref", "Closeout 路径"))}: ${report.closeoutRef}`,
342
- ];
343
- if (report.waveId) {
344
- lines.push(`${styleLabel(localize("Wave", "Wave"))}: ${report.waveId}`);
345
- lines.push(`${styleLabel(localize("Wave State", "Wave 状态"))}: ${report.waveState}`);
346
- }
347
- if (report.state) {
348
- lines.push(`${styleLabel(localize("Topic State", "Topic 状态"))}: ${report.state}`);
349
- }
350
- if (report.currentTrueCloseStatus) {
351
- lines.push(`${styleLabel(localize("True-Close", "True-Close"))}: ${report.currentTrueCloseStatus}`);
352
- }
353
- if (report.trueCloseRef) {
354
- lines.push(`${styleLabel(localize("True-Close Ref", "True-Close 路径"))}: ${report.trueCloseRef}`);
355
- }
356
- return `${lines.join("\n")}\n`;
357
- }
358
- export function formatTrueCloseAudit(report) {
359
- const lines = [
360
- styleHeading(`nimicoding topic true-close-audit: ${report.topicId}`),
361
- "",
362
- `${styleLabel(localize("Path", "路径"))}: ${report.topicRef}`,
363
- `${styleLabel(localize("Status", "状态"))}: ${report.status}`,
364
- `${styleLabel(localize("Audit Ref", "Audit 路径"))}: ${report.auditRef}`,
365
- `${styleLabel(localize("Judgement Ref", "Judgement 路径"))}: ${report.judgementRef}`,
366
- "",
367
- styleLabel(localize("Checks", "检查项")),
368
- ...report.checks.map((entry) => `- [${entry.ok ? "ok" : "fail"}] ${entry.id}: ${entry.reason}`),
369
- ];
370
- return `${lines.join("\n")}\n`;
371
- }
372
- export function formatTopicCreate(report) {
373
- return `${styleHeading(`nimicoding topic create: ${report.topicId}`)}
374
- ${styleLabel(localize("Created", "已创建"))}: ${report.topicRef}
375
- ${styleLabel(localize("State", "状态"))}: ${report.state}
376
- ${styleLabel(localize("Title", "标题"))}: ${report.title}
377
- ${styleMuted(localize(
378
- "Next step: freeze the first bounded wave before admitted execution.",
379
- "下一步:在 admitted execution 之前冻结第一个 bounded wave。",
380
- ))}
381
- `;
382
- }
@@ -1,33 +0,0 @@
1
- import process from "node:process";
2
-
3
- import { buildTopicGoal } from "../lib/topic-goal.mjs";
4
- import { resolveTopicProjectRoot } from "../lib/topic.mjs";
5
- import { formatTopicGoalRefusal, writeJson } from "./topic-formatters.mjs";
6
- import { parseTopicGoalOptions } from "./topic-options.mjs";
7
-
8
- export async function runTopicGoal(args) {
9
- const parsed = parseTopicGoalOptions(args);
10
- if (!parsed.ok) {
11
- process.stderr.write(parsed.error);
12
- return 3;
13
- }
14
- try {
15
- const projectRoot = await resolveTopicProjectRoot(process.cwd());
16
- const report = await buildTopicGoal(projectRoot, parsed.options);
17
- if (report.inputError) {
18
- process.stderr.write(`${report.error}\n`);
19
- return 3;
20
- }
21
- if (parsed.options.format === "json") {
22
- writeJson(report);
23
- } else if (report.ok) {
24
- process.stdout.write(`${report.goal_command}\n`);
25
- } else {
26
- process.stderr.write(formatTopicGoalRefusal(report));
27
- }
28
- return report.ok ? 0 : 2;
29
- } catch (error) {
30
- process.stderr.write(`nimicoding topic goal failed: ${error?.message ?? String(error)}\n`);
31
- return 1;
32
- }
33
- }
@@ -1,27 +0,0 @@
1
- import { localize } from "../lib/ui.mjs";
2
-
3
- export function requireOptionValue(name, next, errorPrefix) {
4
- if (!next || next.startsWith("--")) {
5
- return {
6
- ok: false,
7
- error: `${localize(
8
- `${errorPrefix}: ${name} requires a value.`,
9
- `${errorPrefix}:${name} 需要一个值。`,
10
- )}\n`,
11
- };
12
- }
13
- return { ok: true };
14
- }
15
-
16
- export function validateEnumOption(name, value, allowed, errorPrefix) {
17
- if (!allowed.includes(value)) {
18
- return {
19
- ok: false,
20
- error: `${localize(
21
- `${errorPrefix}: unsupported ${name} value ${value}.`,
22
- `${errorPrefix}:不支持的 ${name} 值 ${value}。`,
23
- )}\n`,
24
- };
25
- }
26
- return { ok: true };
27
- }