@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.
- package/CHANGELOG.md +10 -90
- package/CONTRIBUTING.md +5 -34
- package/README.md +47 -350
- package/README.zh-CN.md +33 -287
- package/cli/commands/start.mjs +48 -688
- package/cli/commands/validate-spec-audit.mjs +1 -5
- package/cli/commands/validate-spec-governance.mjs +20 -0
- package/cli/constants.mjs +9 -417
- package/cli/help.mjs +28 -145
- package/cli/index.mjs +5 -33
- package/cli/lib/blueprint-audit.mjs +5 -12
- package/cli/lib/bootstrap.mjs +0 -9
- package/cli/lib/contracts.mjs +0 -163
- package/cli/lib/doctor.mjs +155 -10
- package/cli/lib/entrypoints.mjs +63 -167
- package/cli/lib/internal/contracts-loaders.mjs +0 -85
- package/cli/lib/internal/contracts-parse.mjs +84 -520
- package/cli/lib/internal/governance/ai/check-agents-freshness.mjs +13 -8
- package/cli/lib/internal/surface-taxonomy-validators.mjs +316 -66
- package/cli/lib/internal/validators-shared.mjs +0 -16
- package/cli/lib/internal/validators-spec-helpers.mjs +7 -140
- package/cli/lib/internal/validators-spec.mjs +103 -342
- package/cli/lib/shared.mjs +1 -42
- package/cli/lib/validators.mjs +0 -48
- package/cli/seeds/seed-policy.yaml +0 -3
- package/config/bootstrap.yaml +4 -4
- package/config/spec-generation-inputs.yaml +6 -12
- package/contracts/domain-admission.schema.yaml +3 -3
- package/contracts/migration-inventory.schema.yaml +12 -75
- package/contracts/negative-fixtures.yaml +19 -99
- package/contracts/placement-contract.schema.yaml +49 -78
- package/contracts/projection-edge.schema.yaml +37 -121
- package/contracts/shared-enums.yaml +4 -8
- package/contracts/spec-generation-inputs.schema.yaml +15 -112
- package/contracts/spec-layout.schema.yaml +32 -0
- package/contracts/surface-taxonomy.schema.yaml +43 -94
- package/contracts/table-family.schema.yaml +1 -1
- package/contracts/tracked-output-admission.schema.yaml +13 -66
- package/methodology/core.yaml +33 -25
- package/methodology/four-closure-policy.yaml +18 -26
- package/methodology/role-separation-policy.yaml +21 -27
- package/methodology/spec-reconstruction.yaml +17 -34
- package/package.json +2 -4
- package/spec/_meta/spec-tree-model.yaml +5 -101
- package/spec/product-scope.yaml +25 -57
- package/adapters/README.md +0 -25
- package/adapters/claude/README.md +0 -89
- package/adapters/claude/profile.yaml +0 -70
- package/adapters/codex/README.md +0 -53
- package/adapters/codex/profile.yaml +0 -78
- package/adapters/oh-my-codex/README.md +0 -184
- package/adapters/oh-my-codex/profile.yaml +0 -46
- package/cli/commands/admit-high-risk-decision.mjs +0 -108
- package/cli/commands/audit-sweep.mjs +0 -364
- package/cli/commands/closeout.mjs +0 -186
- package/cli/commands/decide-high-risk-execution.mjs +0 -124
- package/cli/commands/handoff.mjs +0 -123
- package/cli/commands/ingest-high-risk-execution.mjs +0 -95
- package/cli/commands/review-high-risk-execution.mjs +0 -95
- package/cli/commands/sweep-design.mjs +0 -295
- package/cli/commands/sweep.mjs +0 -22
- package/cli/commands/topic-formatters.mjs +0 -382
- package/cli/commands/topic-goal.mjs +0 -33
- package/cli/commands/topic-options-shared.mjs +0 -27
- package/cli/commands/topic-options-workflow.mjs +0 -767
- package/cli/commands/topic-options.mjs +0 -626
- package/cli/commands/topic-runner.mjs +0 -169
- package/cli/commands/topic.mjs +0 -795
- package/cli/commands/validate-acceptance.mjs +0 -5
- package/cli/commands/validate-execution-packet.mjs +0 -5
- package/cli/commands/validate-orchestration-state.mjs +0 -5
- package/cli/commands/validate-prompt.mjs +0 -5
- package/cli/commands/validate-worker-output.mjs +0 -5
- package/cli/lib/adapter-profiles.mjs +0 -403
- package/cli/lib/audit-execution.mjs +0 -52
- package/cli/lib/audit-sweep-runtime/admissions.mjs +0 -508
- package/cli/lib/audit-sweep-runtime/audit-validity.mjs +0 -356
- package/cli/lib/audit-sweep-runtime/chunks.mjs +0 -697
- package/cli/lib/audit-sweep-runtime/claude-auditor.mjs +0 -658
- package/cli/lib/audit-sweep-runtime/closeout.mjs +0 -144
- package/cli/lib/audit-sweep-runtime/codex-auditor-evidence.mjs +0 -654
- package/cli/lib/audit-sweep-runtime/codex-auditor.mjs +0 -527
- package/cli/lib/audit-sweep-runtime/common.mjs +0 -341
- package/cli/lib/audit-sweep-runtime/coverage-quality.mjs +0 -172
- package/cli/lib/audit-sweep-runtime/evidence-assignment.mjs +0 -155
- package/cli/lib/audit-sweep-runtime/format.mjs +0 -57
- package/cli/lib/audit-sweep-runtime/ingest.mjs +0 -486
- package/cli/lib/audit-sweep-runtime/inventory-spec-chunks.mjs +0 -425
- package/cli/lib/audit-sweep-runtime/inventory.mjs +0 -798
- package/cli/lib/audit-sweep-runtime/ledger.mjs +0 -315
- package/cli/lib/audit-sweep-runtime/p0p1-profile.mjs +0 -101
- package/cli/lib/audit-sweep-runtime/remediation.mjs +0 -349
- package/cli/lib/audit-sweep-runtime/rerun.mjs +0 -129
- package/cli/lib/audit-sweep-runtime/risk-budget.mjs +0 -300
- package/cli/lib/audit-sweep-runtime/status.mjs +0 -62
- package/cli/lib/audit-sweep-runtime/validators-ledger.mjs +0 -215
- package/cli/lib/audit-sweep-runtime/validators.mjs +0 -797
- package/cli/lib/audit-sweep.mjs +0 -19
- package/cli/lib/authority-convergence.mjs +0 -720
- package/cli/lib/closeout.mjs +0 -732
- package/cli/lib/codex-sdk-runner.mjs +0 -76
- package/cli/lib/external-execution.mjs +0 -101
- package/cli/lib/handoff.mjs +0 -812
- package/cli/lib/high-risk-admission.mjs +0 -512
- package/cli/lib/high-risk-decision.mjs +0 -353
- package/cli/lib/high-risk-ingest.mjs +0 -321
- package/cli/lib/high-risk-review.mjs +0 -267
- package/cli/lib/internal/contracts-parse-high-risk.mjs +0 -131
- package/cli/lib/internal/contracts-validators.mjs +0 -399
- package/cli/lib/internal/doctor-bootstrap-surface.mjs +0 -406
- package/cli/lib/internal/doctor-delegated-surface.mjs +0 -256
- package/cli/lib/internal/doctor-finalize.mjs +0 -383
- package/cli/lib/internal/doctor-format.mjs +0 -286
- package/cli/lib/internal/doctor-inspectors.mjs +0 -327
- package/cli/lib/internal/doctor-state.mjs +0 -205
- package/cli/lib/internal/validators-artifacts.mjs +0 -515
- package/cli/lib/sweep-design-runtime/common.mjs +0 -246
- package/cli/lib/sweep-design-runtime/engine.mjs +0 -733
- package/cli/lib/sweep-design-runtime/fix-topic.mjs +0 -414
- package/cli/lib/sweep-design-runtime/lifecycle.mjs +0 -54
- package/cli/lib/sweep-design-runtime/results.mjs +0 -324
- package/cli/lib/sweep-design.mjs +0 -8
- package/cli/lib/topic-artifacts.mjs +0 -186
- package/cli/lib/topic-authority-coverage.mjs +0 -73
- package/cli/lib/topic-closeout.mjs +0 -560
- package/cli/lib/topic-common.mjs +0 -404
- package/cli/lib/topic-decisions.mjs +0 -332
- package/cli/lib/topic-draft-packets.mjs +0 -167
- package/cli/lib/topic-execution.mjs +0 -533
- package/cli/lib/topic-goal.mjs +0 -440
- package/cli/lib/topic-ledger.mjs +0 -281
- package/cli/lib/topic-lifecycle-artifacts.mjs +0 -173
- package/cli/lib/topic-root-validation.mjs +0 -288
- package/cli/lib/topic-runner-commands.mjs +0 -174
- package/cli/lib/topic-runner-deferral.mjs +0 -532
- package/cli/lib/topic-runner-stale-gates.mjs +0 -114
- package/cli/lib/topic-runner-validation.mjs +0 -138
- package/cli/lib/topic-runner.mjs +0 -727
- package/cli/lib/topic-scaffold.mjs +0 -252
- package/cli/lib/topic-waves.mjs +0 -403
- package/cli/lib/topic.mjs +0 -81
- package/config/audit-execution-artifacts.yaml +0 -20
- package/config/external-execution-artifacts.yaml +0 -16
- package/config/host-adapter.yaml +0 -30
- package/config/host-profile.yaml +0 -29
- package/config/installer-evidence.yaml +0 -31
- package/config/skill-installer.yaml +0 -23
- package/config/skill-manifest.yaml +0 -48
- package/config/skills.yaml +0 -30
- package/contracts/acceptance.schema.yaml +0 -16
- package/contracts/admission-checklist.schema.yaml +0 -15
- package/contracts/audit-chunk.schema.yaml +0 -123
- package/contracts/audit-closeout.schema.yaml +0 -51
- package/contracts/audit-finding.schema.yaml +0 -61
- package/contracts/audit-ledger.schema.yaml +0 -138
- package/contracts/audit-plan.schema.yaml +0 -138
- package/contracts/audit-remediation-map.schema.yaml +0 -52
- package/contracts/audit-rerun.schema.yaml +0 -31
- package/contracts/audit-sweep-result.yaml +0 -53
- package/contracts/authority-convergence-audit.schema.yaml +0 -19
- package/contracts/closeout.schema.yaml +0 -25
- package/contracts/decision-review.schema.yaml +0 -16
- package/contracts/doc-spec-audit-result.yaml +0 -19
- package/contracts/execution-packet.schema.yaml +0 -49
- package/contracts/external-host-compatibility.yaml +0 -22
- package/contracts/forbidden-shortcuts.catalog.yaml +0 -23
- package/contracts/high-risk-admission.schema.yaml +0 -23
- package/contracts/high-risk-execution-result.yaml +0 -20
- package/contracts/orchestration-state.schema.yaml +0 -41
- package/contracts/overflow-continuation.schema.yaml +0 -12
- package/contracts/packet.schema.yaml +0 -30
- package/contracts/pending-note.schema.yaml +0 -17
- package/contracts/prompt.schema.yaml +0 -12
- package/contracts/remediation.schema.yaml +0 -16
- package/contracts/result.schema.yaml +0 -24
- package/contracts/spec-reconstruction-result.yaml +0 -41
- package/contracts/sweep-design-result.yaml +0 -349
- package/contracts/topic-goal.schema.yaml +0 -87
- package/contracts/topic-run-ledger.schema.yaml +0 -72
- package/contracts/topic-step-decision.schema.yaml +0 -45
- package/contracts/topic.schema.yaml +0 -65
- package/contracts/true-close.schema.yaml +0 -15
- package/contracts/wave.schema.yaml +0 -29
- package/contracts/worker-output.schema.yaml +0 -15
- package/contracts/workflow-consumer.schema.yaml +0 -110
- package/methodology/audit-sweep-p0p1-recall.yaml +0 -45
- package/methodology/authority-convergence-policy.yaml +0 -42
- package/methodology/overflow-continuation-policy.yaml +0 -14
- package/methodology/skill-exchange-projection.yaml +0 -114
- package/methodology/skill-handoff.yaml +0 -34
- package/methodology/skill-installer-result.yaml +0 -27
- package/methodology/skill-installer-summary-projection.yaml +0 -181
- package/methodology/skill-runtime.yaml +0 -23
- package/methodology/spec-target-truth-profile.yaml +0 -46
- package/methodology/topic-lifecycle-report.yaml +0 -144
- package/methodology/topic-lifecycle.yaml +0 -37
- package/methodology/topic-naming-ontology.yaml +0 -21
- package/methodology/topic-ontology.yaml +0 -38
- package/methodology/topic-validation-policy.yaml +0 -9
- package/methodology/wave-dag-policy.yaml +0 -14
- package/spec/_meta/command-gating-matrix.yaml +0 -143
- package/spec/_meta/generate-drift-migration-checklist.yaml +0 -137
- package/spec/_meta/governance-routing-cutover-checklist.yaml +0 -35
- package/spec/_meta/phase2-impacted-surface-matrix.yaml +0 -44
- package/spec/_meta/spec-authority-cutover-readiness.yaml +0 -102
- package/spec/bootstrap-state.yaml +0 -99
package/cli/commands/handoff.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildHandoffPayload,
|
|
3
|
-
formatHandoffPayload,
|
|
4
|
-
writeHandoffPromptArtifacts,
|
|
5
|
-
} from "../lib/shared.mjs";
|
|
6
|
-
import {
|
|
7
|
-
localize,
|
|
8
|
-
styleCommand,
|
|
9
|
-
styleHeading,
|
|
10
|
-
styleLabel,
|
|
11
|
-
} from "../lib/ui.mjs";
|
|
12
|
-
|
|
13
|
-
function parseHandoffOptions(args) {
|
|
14
|
-
const options = {
|
|
15
|
-
json: false,
|
|
16
|
-
prompt: false,
|
|
17
|
-
skill: null,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
21
|
-
const arg = args[index];
|
|
22
|
-
|
|
23
|
-
if (arg === "--json") {
|
|
24
|
-
options.json = true;
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (arg === "--prompt") {
|
|
29
|
-
options.prompt = true;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (arg === "--skill") {
|
|
34
|
-
const next = args[index + 1];
|
|
35
|
-
if (!next || next.startsWith("--")) {
|
|
36
|
-
return {
|
|
37
|
-
ok: false,
|
|
38
|
-
error: localize(
|
|
39
|
-
"nimicoding handoff refused: --skill requires a skill id.\n",
|
|
40
|
-
"nimicoding handoff 拒绝执行:--skill 需要一个 skill id。\n",
|
|
41
|
-
),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
options.skill = next;
|
|
45
|
-
index += 1;
|
|
46
|
-
continue;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
ok: false,
|
|
51
|
-
error: localize(
|
|
52
|
-
`nimicoding handoff refused: unknown option ${arg}.\n`,
|
|
53
|
-
`nimicoding handoff 拒绝执行:未知选项 ${arg}。\n`,
|
|
54
|
-
),
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!options.skill) {
|
|
59
|
-
return {
|
|
60
|
-
ok: false,
|
|
61
|
-
error: localize(
|
|
62
|
-
"nimicoding handoff refused: explicit --skill is required.\n",
|
|
63
|
-
"nimicoding handoff 拒绝执行:必须显式提供 --skill。\n",
|
|
64
|
-
),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (options.json && options.prompt) {
|
|
69
|
-
return {
|
|
70
|
-
ok: false,
|
|
71
|
-
error: localize(
|
|
72
|
-
"nimicoding handoff refused: --json and --prompt are mutually exclusive.\n",
|
|
73
|
-
"nimicoding handoff 拒绝执行:--json 与 --prompt 不能同时使用。\n",
|
|
74
|
-
),
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
ok: true,
|
|
80
|
-
options,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export async function runHandoff(args) {
|
|
85
|
-
const parsed = parseHandoffOptions(args);
|
|
86
|
-
if (!parsed.ok) {
|
|
87
|
-
process.stderr.write(parsed.error);
|
|
88
|
-
return 2;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const payload = await buildHandoffPayload(process.cwd(), parsed.options.skill);
|
|
92
|
-
if (parsed.options.json) {
|
|
93
|
-
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
94
|
-
} else if (parsed.options.prompt) {
|
|
95
|
-
if (!payload.ok) {
|
|
96
|
-
process.stderr.write(`${localize(payload.nextAction, payload.nextAction
|
|
97
|
-
.replace("Bootstrap or handoff validation is failing; repair doctor errors before exporting handoff payloads", "bootstrap 或 handoff 校验失败;请先修复 doctor 报错,再导出 handoff payload")
|
|
98
|
-
.replace("Projects may delegate spec reconstruction to an external AI host when lifecycle repair or reconstruction work is needed", "当需要 lifecycle repair 或 reconstruction 工作时,项目可以将 spec reconstruction 委托给外部 AI host")
|
|
99
|
-
.replace("This skill requires the canonical tree under `.nimi/spec` before handoff", "该 skill 在 handoff 前需要 `.nimi/spec` 下的 canonical tree")
|
|
100
|
-
.replace("Skill prerequisites are satisfied by the current project-local truth", "当前项目本地 truth 已满足该 skill 的前置条件"))}\n`);
|
|
101
|
-
return payload.exitCode;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const refs = await writeHandoffPromptArtifacts(process.cwd(), payload);
|
|
105
|
-
process.stdout.write(`${styleHeading(localize(`Prepared local handoff refs for ${payload.skill.id}`, `已为 ${payload.skill.id} 准备本地 handoff ref`))}
|
|
106
|
-
|
|
107
|
-
${styleLabel(localize("Created:", "已创建:"))}
|
|
108
|
-
- ${refs.jsonRef}
|
|
109
|
-
- ${refs.promptRef}
|
|
110
|
-
|
|
111
|
-
${styleLabel(localize("Use:", "使用方式:"))}
|
|
112
|
-
- ${localize(`Treat ${refs.jsonRef} as the authoritative machine contract`, `将 ${refs.jsonRef} 作为权威机器契约`)}
|
|
113
|
-
- ${localize(`Paste the contents of ${refs.promptRef} into the external AI host when needed`, `需要时将 ${refs.promptRef} 的内容粘贴给外部 AI host`)}
|
|
114
|
-
- ${localize("Optional command preview:", "可选命令预览:")} ${styleCommand(`nimicoding handoff --skill ${payload.skill.id} --json`)}
|
|
115
|
-
`);
|
|
116
|
-
} else {
|
|
117
|
-
process.stdout.write(formatHandoffPayload(payload));
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return payload.exitCode;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export { parseHandoffOptions };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
buildHighRiskIngestPayload,
|
|
6
|
-
formatHighRiskIngestPayload,
|
|
7
|
-
} from "../lib/high-risk-ingest.mjs";
|
|
8
|
-
import { localize } from "../lib/ui.mjs";
|
|
9
|
-
|
|
10
|
-
function parseIngestHighRiskExecutionOptions(args) {
|
|
11
|
-
const options = {
|
|
12
|
-
fromPath: null,
|
|
13
|
-
json: false,
|
|
14
|
-
writeLocal: false,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
18
|
-
const arg = args[index];
|
|
19
|
-
|
|
20
|
-
if (arg === "--json") {
|
|
21
|
-
options.json = true;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (arg === "--write-local") {
|
|
26
|
-
options.writeLocal = true;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (arg === "--from") {
|
|
31
|
-
const next = args[index + 1];
|
|
32
|
-
if (!next || next.startsWith("--")) {
|
|
33
|
-
return {
|
|
34
|
-
ok: false,
|
|
35
|
-
error: `${localize(
|
|
36
|
-
"nimicoding ingest-high-risk-execution refused: --from requires a value.",
|
|
37
|
-
"nimicoding ingest-high-risk-execution 已拒绝:`--from` 需要一个值。",
|
|
38
|
-
)}\n`,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
options.fromPath = next;
|
|
42
|
-
index += 1;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
ok: false,
|
|
48
|
-
error: `${localize(
|
|
49
|
-
`nimicoding ingest-high-risk-execution refused: unknown option ${arg}.`,
|
|
50
|
-
`nimicoding ingest-high-risk-execution 已拒绝:未知选项 ${arg}。`,
|
|
51
|
-
)}\n`,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!options.fromPath) {
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
error: `${localize(
|
|
59
|
-
"nimicoding ingest-high-risk-execution refused: explicit --from is required.",
|
|
60
|
-
"nimicoding ingest-high-risk-execution 已拒绝:必须显式提供 `--from`。",
|
|
61
|
-
)}\n`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return { ok: true, options };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function runIngestHighRiskExecution(args) {
|
|
69
|
-
const parsed = parseIngestHighRiskExecutionOptions(args);
|
|
70
|
-
if (!parsed.ok) {
|
|
71
|
-
process.stderr.write(parsed.error);
|
|
72
|
-
return 2;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const payload = await buildHighRiskIngestPayload(process.cwd(), parsed.options.fromPath, parsed.options);
|
|
76
|
-
if (payload.inputError) {
|
|
77
|
-
process.stderr.write(payload.error);
|
|
78
|
-
return payload.exitCode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (parsed.options.writeLocal && payload.ok) {
|
|
82
|
-
await mkdir(path.dirname(payload.artifactPath), { recursive: true });
|
|
83
|
-
await writeFile(payload.artifactPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (parsed.options.json) {
|
|
87
|
-
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
88
|
-
} else {
|
|
89
|
-
process.stdout.write(formatHighRiskIngestPayload(payload));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return payload.exitCode;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { parseIngestHighRiskExecutionOptions };
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
buildHighRiskReviewPayload,
|
|
6
|
-
formatHighRiskReviewPayload,
|
|
7
|
-
} from "../lib/high-risk-review.mjs";
|
|
8
|
-
import { localize } from "../lib/ui.mjs";
|
|
9
|
-
|
|
10
|
-
function parseReviewHighRiskExecutionOptions(args) {
|
|
11
|
-
const options = {
|
|
12
|
-
fromPath: null,
|
|
13
|
-
json: false,
|
|
14
|
-
writeLocal: false,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
18
|
-
const arg = args[index];
|
|
19
|
-
|
|
20
|
-
if (arg === "--json") {
|
|
21
|
-
options.json = true;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (arg === "--write-local") {
|
|
26
|
-
options.writeLocal = true;
|
|
27
|
-
continue;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (arg === "--from") {
|
|
31
|
-
const next = args[index + 1];
|
|
32
|
-
if (!next || next.startsWith("--")) {
|
|
33
|
-
return {
|
|
34
|
-
ok: false,
|
|
35
|
-
error: `${localize(
|
|
36
|
-
"nimicoding review-high-risk-execution refused: --from requires a value.",
|
|
37
|
-
"nimicoding review-high-risk-execution 已拒绝:`--from` 需要一个值。",
|
|
38
|
-
)}\n`,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
options.fromPath = next;
|
|
42
|
-
index += 1;
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
ok: false,
|
|
48
|
-
error: `${localize(
|
|
49
|
-
`nimicoding review-high-risk-execution refused: unknown option ${arg}.`,
|
|
50
|
-
`nimicoding review-high-risk-execution 已拒绝:未知选项 ${arg}。`,
|
|
51
|
-
)}\n`,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (!options.fromPath) {
|
|
56
|
-
return {
|
|
57
|
-
ok: false,
|
|
58
|
-
error: `${localize(
|
|
59
|
-
"nimicoding review-high-risk-execution refused: explicit --from is required.",
|
|
60
|
-
"nimicoding review-high-risk-execution 已拒绝:必须显式提供 `--from`。",
|
|
61
|
-
)}\n`,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return { ok: true, options };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function runReviewHighRiskExecution(args) {
|
|
69
|
-
const parsed = parseReviewHighRiskExecutionOptions(args);
|
|
70
|
-
if (!parsed.ok) {
|
|
71
|
-
process.stderr.write(parsed.error);
|
|
72
|
-
return 2;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const payload = await buildHighRiskReviewPayload(process.cwd(), parsed.options.fromPath, parsed.options);
|
|
76
|
-
if (payload.inputError) {
|
|
77
|
-
process.stderr.write(payload.error);
|
|
78
|
-
return payload.exitCode;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (parsed.options.writeLocal && payload.ok) {
|
|
82
|
-
await mkdir(path.dirname(payload.artifactPath), { recursive: true });
|
|
83
|
-
await writeFile(payload.artifactPath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (parsed.options.json) {
|
|
87
|
-
process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
|
|
88
|
-
} else {
|
|
89
|
-
process.stdout.write(formatHighRiskReviewPayload(payload));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return payload.exitCode;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export { parseReviewHighRiskExecutionOptions };
|
|
@@ -1,295 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
runAuditorPrompt,
|
|
3
|
-
runFinalize,
|
|
4
|
-
runFixTopic,
|
|
5
|
-
runIntake,
|
|
6
|
-
runLedgerValidate,
|
|
7
|
-
runPacketBuild,
|
|
8
|
-
runPacketBuildBatch,
|
|
9
|
-
runResultIngest,
|
|
10
|
-
runWavePlan,
|
|
11
|
-
} from "../lib/sweep-design.mjs";
|
|
12
|
-
import { localize } from "../lib/ui.mjs";
|
|
13
|
-
|
|
14
|
-
function readRequiredValue(args, index, optionName, commandName) {
|
|
15
|
-
const next = args[index + 1];
|
|
16
|
-
if (!next || next.startsWith("--")) {
|
|
17
|
-
return {
|
|
18
|
-
ok: false,
|
|
19
|
-
error: `${localize(
|
|
20
|
-
`nimicoding sweep design ${commandName} refused: ${optionName} requires a value.`,
|
|
21
|
-
`nimicoding sweep design ${commandName} 已拒绝:${optionName} 需要一个值。`,
|
|
22
|
-
)}\n`,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
return { ok: true, value: next };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function unknownOption(commandName, arg) {
|
|
29
|
-
return {
|
|
30
|
-
ok: false,
|
|
31
|
-
error: `${localize(
|
|
32
|
-
`nimicoding sweep design ${commandName} refused: unknown option ${arg}.`,
|
|
33
|
-
`nimicoding sweep design ${commandName} 已拒绝:未知选项 ${arg}。`,
|
|
34
|
-
)}\n`,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseOptions(args, commandName, spec) {
|
|
39
|
-
const options = Object.fromEntries(Object.entries(spec).map(([name, config]) => [name, config.default ?? null]));
|
|
40
|
-
for (let index = 0; index < args.length; index += 1) {
|
|
41
|
-
const arg = args[index];
|
|
42
|
-
if (arg === "--json") {
|
|
43
|
-
options.json = true;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
const entry = Object.entries(spec).find(([, config]) => config.flag === arg);
|
|
47
|
-
if (!entry) {
|
|
48
|
-
return unknownOption(commandName, arg);
|
|
49
|
-
}
|
|
50
|
-
const [name] = entry;
|
|
51
|
-
if (entry[1].type === "boolean") {
|
|
52
|
-
options[name] = true;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
const value = readRequiredValue(args, index, arg, commandName);
|
|
56
|
-
if (!value.ok) return value;
|
|
57
|
-
options[name] = value.value;
|
|
58
|
-
index += 1;
|
|
59
|
-
}
|
|
60
|
-
const missing = Object.entries(spec)
|
|
61
|
-
.filter(([, config]) => config.required)
|
|
62
|
-
.filter(([name]) => !options[name])
|
|
63
|
-
.map(([, config]) => config.flag);
|
|
64
|
-
if (missing.length > 0) {
|
|
65
|
-
return {
|
|
66
|
-
ok: false,
|
|
67
|
-
error: `${localize(
|
|
68
|
-
`nimicoding sweep design ${commandName} refused: missing required options: ${missing.join(", ")}.`,
|
|
69
|
-
`nimicoding sweep design ${commandName} 已拒绝:缺少必填选项:${missing.join(", ")}。`,
|
|
70
|
-
)}\n`,
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return { ok: true, options };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function parseSweepDesignOptions(args) {
|
|
77
|
-
const [phase] = args;
|
|
78
|
-
if (phase === "intake") {
|
|
79
|
-
return {
|
|
80
|
-
ok: true,
|
|
81
|
-
action: "intake",
|
|
82
|
-
parsed: parseOptions(args.slice(1), "intake", {
|
|
83
|
-
sweepId: { flag: "--sweep-id", required: true },
|
|
84
|
-
runId: { flag: "--run-id" },
|
|
85
|
-
verifiedAt: { flag: "--verified-at" },
|
|
86
|
-
json: { default: false },
|
|
87
|
-
}),
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
if (phase === "packet-build") {
|
|
91
|
-
return {
|
|
92
|
-
ok: true,
|
|
93
|
-
action: "packet-build",
|
|
94
|
-
parsed: parseOptions(args.slice(1), "packet-build", {
|
|
95
|
-
runId: { flag: "--run-id", required: true },
|
|
96
|
-
packetId: { flag: "--packet-id", required: true },
|
|
97
|
-
findingId: { flag: "--finding-id" },
|
|
98
|
-
findingIds: { flag: "--finding-ids" },
|
|
99
|
-
explicitQuestion: { flag: "--explicit-question" },
|
|
100
|
-
explicitQuestions: { flag: "--explicit-questions" },
|
|
101
|
-
priorDesignStateRefs: { flag: "--prior-design-state-refs" },
|
|
102
|
-
priorDesignStateMarker: { flag: "--prior-design-state-marker" },
|
|
103
|
-
currentClusterRefs: { flag: "--current-cluster-refs" },
|
|
104
|
-
currentWaveRefs: { flag: "--current-wave-refs" },
|
|
105
|
-
authorityOnly: { flag: "--authority-only", type: "boolean", default: false },
|
|
106
|
-
verifiedAt: { flag: "--verified-at" },
|
|
107
|
-
json: { default: false },
|
|
108
|
-
}),
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
if (phase === "packet-build-batch") {
|
|
112
|
-
return {
|
|
113
|
-
ok: true,
|
|
114
|
-
action: "packet-build-batch",
|
|
115
|
-
parsed: parseOptions(args.slice(1), "packet-build-batch", {
|
|
116
|
-
runId: { flag: "--run-id", required: true },
|
|
117
|
-
batchSize: { flag: "--batch-size", required: true },
|
|
118
|
-
findingIds: { flag: "--finding-ids" },
|
|
119
|
-
packetPrefix: { flag: "--packet-prefix" },
|
|
120
|
-
manifestId: { flag: "--manifest-id" },
|
|
121
|
-
explicitQuestion: { flag: "--explicit-question" },
|
|
122
|
-
explicitQuestions: { flag: "--explicit-questions" },
|
|
123
|
-
priorDesignStateRefs: { flag: "--prior-design-state-refs" },
|
|
124
|
-
priorDesignStateMarker: { flag: "--prior-design-state-marker" },
|
|
125
|
-
currentClusterRefs: { flag: "--current-cluster-refs" },
|
|
126
|
-
currentWaveRefs: { flag: "--current-wave-refs" },
|
|
127
|
-
authorityOnly: { flag: "--authority-only", type: "boolean", default: false },
|
|
128
|
-
verifiedAt: { flag: "--verified-at" },
|
|
129
|
-
json: { default: false },
|
|
130
|
-
}),
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
if (phase === "result-ingest") {
|
|
134
|
-
return {
|
|
135
|
-
ok: true,
|
|
136
|
-
action: "result-ingest",
|
|
137
|
-
parsed: parseOptions(args.slice(1), "result-ingest", {
|
|
138
|
-
runId: { flag: "--run-id", required: true },
|
|
139
|
-
from: { flag: "--from", required: true },
|
|
140
|
-
mode: { flag: "--mode", default: "focused" },
|
|
141
|
-
allowSyntheticTrial: { flag: "--allow-synthetic-trial", type: "boolean", default: false },
|
|
142
|
-
verifiedAt: { flag: "--verified-at" },
|
|
143
|
-
json: { default: false },
|
|
144
|
-
}),
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
if (phase === "auditor-prompt") {
|
|
148
|
-
return {
|
|
149
|
-
ok: true,
|
|
150
|
-
action: "auditor-prompt",
|
|
151
|
-
parsed: parseOptions(args.slice(1), "auditor-prompt", {
|
|
152
|
-
runId: { flag: "--run-id", required: true },
|
|
153
|
-
packetId: { flag: "--packet-id", required: true },
|
|
154
|
-
verifiedAt: { flag: "--verified-at" },
|
|
155
|
-
json: { default: false },
|
|
156
|
-
}),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
if (phase === "finalize") {
|
|
160
|
-
return {
|
|
161
|
-
ok: true,
|
|
162
|
-
action: "finalize",
|
|
163
|
-
parsed: parseOptions(args.slice(1), "finalize", {
|
|
164
|
-
runId: { flag: "--run-id", required: true },
|
|
165
|
-
allowSyntheticCloseout: { flag: "--allow-synthetic-closeout", type: "boolean", default: false },
|
|
166
|
-
verifiedAt: { flag: "--verified-at" },
|
|
167
|
-
json: { default: false },
|
|
168
|
-
}),
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
if (phase === "ledger-validate") {
|
|
172
|
-
return {
|
|
173
|
-
ok: true,
|
|
174
|
-
action: "ledger-validate",
|
|
175
|
-
parsed: parseOptions(args.slice(1), "ledger-validate", {
|
|
176
|
-
runId: { flag: "--run-id", required: true },
|
|
177
|
-
verifiedAt: { flag: "--verified-at" },
|
|
178
|
-
json: { default: false },
|
|
179
|
-
}),
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
if (phase === "wave-plan") {
|
|
183
|
-
return {
|
|
184
|
-
ok: true,
|
|
185
|
-
action: "wave-plan",
|
|
186
|
-
parsed: parseOptions(args.slice(1), "wave-plan", {
|
|
187
|
-
runId: { flag: "--run-id", required: true },
|
|
188
|
-
topicId: { flag: "--topic-id", required: true },
|
|
189
|
-
allowSyntheticTrial: { flag: "--allow-synthetic-trial", type: "boolean", default: false },
|
|
190
|
-
verifiedAt: { flag: "--verified-at" },
|
|
191
|
-
json: { default: false },
|
|
192
|
-
}),
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
if (phase === "fix-topic") {
|
|
196
|
-
return {
|
|
197
|
-
ok: true,
|
|
198
|
-
action: "fix-topic",
|
|
199
|
-
parsed: parseOptions(args.slice(1), "fix-topic", {
|
|
200
|
-
runId: { flag: "--run-id", required: true },
|
|
201
|
-
slug: { flag: "--slug" },
|
|
202
|
-
title: { flag: "--title" },
|
|
203
|
-
admitFirstWave: { flag: "--admit-first-wave", type: "boolean", default: false },
|
|
204
|
-
admitWaveId: { flag: "--admit-wave-id" },
|
|
205
|
-
verifiedAt: { flag: "--verified-at" },
|
|
206
|
-
json: { default: false },
|
|
207
|
-
}),
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
ok: false,
|
|
212
|
-
error: `${localize(
|
|
213
|
-
"nimicoding sweep design refused: expected intake, packet-build, packet-build-batch, auditor-prompt, result-ingest, ledger-validate, finalize, wave-plan, or fix-topic.",
|
|
214
|
-
"nimicoding sweep design 已拒绝:需要 intake、packet-build、packet-build-batch、auditor-prompt、result-ingest、ledger-validate、finalize、wave-plan 或 fix-topic。",
|
|
215
|
-
)}\n`,
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
function emitResult(result, json) {
|
|
220
|
-
if (result.inputError) {
|
|
221
|
-
process.stderr.write(result.error);
|
|
222
|
-
return result.exitCode ?? 2;
|
|
223
|
-
}
|
|
224
|
-
if (!result.ok) {
|
|
225
|
-
process.stderr.write(result.error ?? "nimicoding sweep design failed.\n");
|
|
226
|
-
return result.exitCode ?? 1;
|
|
227
|
-
}
|
|
228
|
-
if (json) {
|
|
229
|
-
process.stdout.write(`${JSON.stringify({ command: "sweep.design", ...result }, null, 2)}\n`);
|
|
230
|
-
} else {
|
|
231
|
-
const lines = ["sweep design result"];
|
|
232
|
-
for (const [label, value] of [
|
|
233
|
-
["run", result.runId],
|
|
234
|
-
["inventory", result.inventoryRef],
|
|
235
|
-
["ledger", result.ledgerRef],
|
|
236
|
-
["packet", result.packetRef],
|
|
237
|
-
["auditor prompt", result.promptRef],
|
|
238
|
-
["auditor result", result.resultRef],
|
|
239
|
-
["decision queue", result.decisionQueueRef],
|
|
240
|
-
["final state report", result.finalStateReportRef],
|
|
241
|
-
["wave plan", result.wavePlanRef],
|
|
242
|
-
["topic", result.topicRef],
|
|
243
|
-
["sweep fix source", result.sourceRef],
|
|
244
|
-
["wave catalog", result.waveCatalogRef],
|
|
245
|
-
]) {
|
|
246
|
-
if (value !== undefined && value !== null) {
|
|
247
|
-
lines.push(`${label}: ${value}`);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
for (const [label, value] of [
|
|
251
|
-
["findings", result.findingCount],
|
|
252
|
-
["finding outcomes", result.findingOutcomeCount],
|
|
253
|
-
["revision entries", result.revisionEntryCount],
|
|
254
|
-
["total findings", result.totalFindingCount],
|
|
255
|
-
["final findings", result.finalFindingCount],
|
|
256
|
-
["transient findings", result.transientFindingCount],
|
|
257
|
-
["waves", result.waveCount],
|
|
258
|
-
["admitted wave", result.admittedWaveId],
|
|
259
|
-
["stop class", result.stopClass],
|
|
260
|
-
["stop reason", result.stopReason],
|
|
261
|
-
]) {
|
|
262
|
-
if (value !== undefined && value !== null) {
|
|
263
|
-
lines.push(`${label}: ${value}`);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
process.stdout.write(`${lines.join("\n")}\n`);
|
|
267
|
-
}
|
|
268
|
-
return result.exitCode ?? 0;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export async function runSweepDesign(args) {
|
|
272
|
-
const parsedAction = parseSweepDesignOptions(args);
|
|
273
|
-
if (!parsedAction.ok) {
|
|
274
|
-
process.stderr.write(parsedAction.error);
|
|
275
|
-
return 2;
|
|
276
|
-
}
|
|
277
|
-
if (!parsedAction.parsed.ok) {
|
|
278
|
-
process.stderr.write(parsedAction.parsed.error);
|
|
279
|
-
return 2;
|
|
280
|
-
}
|
|
281
|
-
const options = parsedAction.parsed.options;
|
|
282
|
-
const projectRoot = process.cwd();
|
|
283
|
-
const actions = {
|
|
284
|
-
intake: runIntake,
|
|
285
|
-
"packet-build": runPacketBuild,
|
|
286
|
-
"packet-build-batch": runPacketBuildBatch,
|
|
287
|
-
"auditor-prompt": runAuditorPrompt,
|
|
288
|
-
"result-ingest": runResultIngest,
|
|
289
|
-
"ledger-validate": runLedgerValidate,
|
|
290
|
-
finalize: runFinalize,
|
|
291
|
-
"wave-plan": runWavePlan,
|
|
292
|
-
"fix-topic": runFixTopic,
|
|
293
|
-
};
|
|
294
|
-
return emitResult(await actions[parsedAction.action](projectRoot, options), options.json);
|
|
295
|
-
}
|
package/cli/commands/sweep.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { runAuditSweep } from "./audit-sweep.mjs";
|
|
2
|
-
import { runSweepDesign } from "./sweep-design.mjs";
|
|
3
|
-
import { localize } from "../lib/ui.mjs";
|
|
4
|
-
|
|
5
|
-
export async function runSweep(args) {
|
|
6
|
-
const [command] = args;
|
|
7
|
-
const rest = args.slice(1);
|
|
8
|
-
|
|
9
|
-
if (command === "audit") {
|
|
10
|
-
return runAuditSweep(rest);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (command === "design") {
|
|
14
|
-
return runSweepDesign(rest);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
process.stderr.write(localize(
|
|
18
|
-
"nimicoding sweep refused: expected `audit` or `design`.\n",
|
|
19
|
-
"nimicoding sweep 已拒绝:需要使用 `audit` 或 `design`。\n",
|
|
20
|
-
));
|
|
21
|
-
return 2;
|
|
22
|
-
}
|