audit-tools 0.55.15 → 0.55.17
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/dist/audit/cli/auditStep.d.ts.map +1 -1
- package/dist/audit/cli/auditStep.js +4 -3
- package/dist/audit/cli/auditStep.js.map +1 -1
- package/dist/audit/cli/charterComparisonPrompt.d.ts.map +1 -1
- package/dist/audit/cli/charterComparisonPrompt.js +8 -1
- package/dist/audit/cli/charterComparisonPrompt.js.map +1 -1
- package/dist/audit/cli/conceptualDispatch.d.ts.map +1 -1
- package/dist/audit/cli/conceptualDispatch.js +9 -5
- package/dist/audit/cli/conceptualDispatch.js.map +1 -1
- package/dist/audit/cli/confirmIntentStep.d.ts.map +1 -1
- package/dist/audit/cli/confirmIntentStep.js +0 -1
- package/dist/audit/cli/confirmIntentStep.js.map +1 -1
- package/dist/audit/cli/dispatch/hostHandoff.d.ts +86 -1
- package/dist/audit/cli/dispatch/hostHandoff.d.ts.map +1 -1
- package/dist/audit/cli/dispatch/hostHandoff.js +460 -161
- package/dist/audit/cli/dispatch/hostHandoff.js.map +1 -1
- package/dist/audit/cli/fanoutLanes.d.ts +1 -1
- package/dist/audit/cli/fanoutLanes.d.ts.map +1 -1
- package/dist/audit/cli/fanoutLanes.js +4 -2
- package/dist/audit/cli/fanoutLanes.js.map +1 -1
- package/dist/audit/cli/nextStepCommand.d.ts.map +1 -1
- package/dist/audit/cli/nextStepCommand.js +17 -15
- package/dist/audit/cli/nextStepCommand.js.map +1 -1
- package/dist/audit/cli/nextStepHelpers.d.ts.map +1 -1
- package/dist/audit/cli/nextStepHelpers.js +4 -3
- package/dist/audit/cli/nextStepHelpers.js.map +1 -1
- package/dist/audit/cli/prompts.d.ts +2 -0
- package/dist/audit/cli/prompts.d.ts.map +1 -1
- package/dist/audit/cli/prompts.js +12 -1
- package/dist/audit/cli/prompts.js.map +1 -1
- package/dist/audit/cli/semanticReviewStep.d.ts.map +1 -1
- package/dist/audit/cli/semanticReviewStep.js +71 -6
- package/dist/audit/cli/semanticReviewStep.js.map +1 -1
- package/dist/audit/cli/submitCommand.d.ts +26 -0
- package/dist/audit/cli/submitCommand.d.ts.map +1 -0
- package/dist/audit/cli/submitCommand.js +79 -0
- package/dist/audit/cli/submitCommand.js.map +1 -0
- package/dist/audit/cli/validateResultsCommand.d.ts +11 -0
- package/dist/audit/cli/validateResultsCommand.d.ts.map +1 -1
- package/dist/audit/cli/validateResultsCommand.js +56 -4
- package/dist/audit/cli/validateResultsCommand.js.map +1 -1
- package/dist/audit/cli.d.ts.map +1 -1
- package/dist/audit/cli.js +4 -1
- package/dist/audit/cli.js.map +1 -1
- package/dist/audit/contracts/findingContractPrompt.d.ts +229 -0
- package/dist/audit/contracts/findingContractPrompt.d.ts.map +1 -1
- package/dist/audit/contracts/findingContractPrompt.js +31 -20
- package/dist/audit/contracts/findingContractPrompt.js.map +1 -1
- package/dist/audit/decompose/buildStructureDecomposition.d.ts +11 -5
- package/dist/audit/decompose/buildStructureDecomposition.d.ts.map +1 -1
- package/dist/audit/decompose/buildStructureDecomposition.js +17 -8
- package/dist/audit/decompose/buildStructureDecomposition.js.map +1 -1
- package/dist/audit/extractors/designAssessment.d.ts.map +1 -1
- package/dist/audit/extractors/designAssessment.js.map +1 -1
- package/dist/audit/extractors/graph.d.ts +1 -1
- package/dist/audit/extractors/graph.js +1 -1
- package/dist/audit/extractors/graphSignals.d.ts +8 -0
- package/dist/audit/extractors/graphSignals.d.ts.map +1 -1
- package/dist/audit/extractors/graphSignals.js +12 -1
- package/dist/audit/extractors/graphSignals.js.map +1 -1
- package/dist/audit/extractors/pathPatterns.d.ts +3 -0
- package/dist/audit/extractors/pathPatterns.d.ts.map +1 -1
- package/dist/audit/extractors/pathPatterns.js +9 -4
- package/dist/audit/extractors/pathPatterns.js.map +1 -1
- package/dist/audit/extractors/surfaces.d.ts.map +1 -1
- package/dist/audit/extractors/surfaces.js +6 -1
- package/dist/audit/extractors/surfaces.js.map +1 -1
- package/dist/audit/io/runArtifacts.d.ts +6 -0
- package/dist/audit/io/runArtifacts.d.ts.map +1 -1
- package/dist/audit/io/runArtifacts.js +9 -0
- package/dist/audit/io/runArtifacts.js.map +1 -1
- package/dist/audit/orchestrator/advance.d.ts.map +1 -1
- package/dist/audit/orchestrator/advance.js +3 -0
- package/dist/audit/orchestrator/advance.js.map +1 -1
- package/dist/audit/orchestrator/architectureDiscovery.d.ts +9 -0
- package/dist/audit/orchestrator/architectureDiscovery.d.ts.map +1 -1
- package/dist/audit/orchestrator/architectureDiscovery.js +11 -1
- package/dist/audit/orchestrator/architectureDiscovery.js.map +1 -1
- package/dist/audit/orchestrator/charterPackets.d.ts +36 -7
- package/dist/audit/orchestrator/charterPackets.d.ts.map +1 -1
- package/dist/audit/orchestrator/charterPackets.js +88 -21
- package/dist/audit/orchestrator/charterPackets.js.map +1 -1
- package/dist/audit/orchestrator/dependencyMap.d.ts.map +1 -1
- package/dist/audit/orchestrator/dependencyMap.js +16 -13
- package/dist/audit/orchestrator/dependencyMap.js.map +1 -1
- package/dist/audit/orchestrator/dependencySlices.d.ts.map +1 -1
- package/dist/audit/orchestrator/dependencySlices.js +26 -11
- package/dist/audit/orchestrator/dependencySlices.js.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.d.ts.map +1 -1
- package/dist/audit/orchestrator/designReviewPrompt.js +38 -6
- package/dist/audit/orchestrator/designReviewPrompt.js.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/intentCheckpointExecutor.js +3 -2
- package/dist/audit/orchestrator/intentCheckpointExecutor.js.map +1 -1
- package/dist/audit/orchestrator/state.js +1 -1
- package/dist/audit/orchestrator/state.js.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts +9 -0
- package/dist/audit/orchestrator/systemicChallengeExecutor.d.ts.map +1 -1
- package/dist/audit/orchestrator/systemicChallengeExecutor.js +12 -2
- package/dist/audit/orchestrator/systemicChallengeExecutor.js.map +1 -1
- package/dist/audit/orchestrator/unitBuilder.d.ts.map +1 -1
- package/dist/audit/orchestrator/unitBuilder.js +29 -8
- package/dist/audit/orchestrator/unitBuilder.js.map +1 -1
- package/dist/audit/reporting/criticalFlowFallbackPrompt.d.ts +6 -0
- package/dist/audit/reporting/criticalFlowFallbackPrompt.d.ts.map +1 -1
- package/dist/audit/reporting/criticalFlowFallbackPrompt.js +55 -34
- package/dist/audit/reporting/criticalFlowFallbackPrompt.js.map +1 -1
- package/dist/audit/systemic/reviewFileMap.d.ts +92 -45
- package/dist/audit/systemic/reviewFileMap.d.ts.map +1 -1
- package/dist/audit/systemic/reviewFileMap.js +171 -94
- package/dist/audit/systemic/reviewFileMap.js.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts +15 -6
- package/dist/audit/systemic/secondOrderAdversaryPrompt.d.ts.map +1 -1
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js +119 -36
- package/dist/audit/systemic/secondOrderAdversaryPrompt.js.map +1 -1
- package/dist/audit/types/designAssessment.d.ts +11 -0
- package/dist/audit/types/designAssessment.d.ts.map +1 -1
- package/dist/audit/types/designAssessment.js +23 -1
- package/dist/audit/types/designAssessment.js.map +1 -1
- package/dist/remediate/index.d.ts.map +1 -1
- package/dist/remediate/index.js +44 -0
- package/dist/remediate/index.js.map +1 -1
- package/dist/remediate/steps/dispatch/hostHandoff.d.ts +29 -0
- package/dist/remediate/steps/dispatch/hostHandoff.d.ts.map +1 -1
- package/dist/remediate/steps/dispatch/hostHandoff.js +63 -4
- package/dist/remediate/steps/dispatch/hostHandoff.js.map +1 -1
- package/dist/remediate/steps/submitResult.d.ts +13 -0
- package/dist/remediate/steps/submitResult.d.ts.map +1 -0
- package/dist/remediate/steps/submitResult.js +24 -0
- package/dist/remediate/steps/submitResult.js.map +1 -0
- package/dist/shared/decompose/charterExtraction.d.ts +117 -17
- package/dist/shared/decompose/charterExtraction.d.ts.map +1 -1
- package/dist/shared/decompose/charterExtraction.js +27 -3
- package/dist/shared/decompose/charterExtraction.js.map +1 -1
- package/dist/shared/decompose/systemicChallenge.d.ts.map +1 -1
- package/dist/shared/decompose/systemicChallenge.js +4 -1
- package/dist/shared/decompose/systemicChallenge.js.map +1 -1
- package/dist/shared/index.d.ts +2 -2
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -2
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/mcp/submitServer.d.ts +26 -0
- package/dist/shared/mcp/submitServer.d.ts.map +1 -0
- package/dist/shared/mcp/submitServer.js +74 -0
- package/dist/shared/mcp/submitServer.js.map +1 -0
- package/dist/shared/submission/hostHandoffCore.d.ts +10 -0
- package/dist/shared/submission/hostHandoffCore.d.ts.map +1 -1
- package/dist/shared/submission/hostHandoffCore.js +19 -0
- package/dist/shared/submission/hostHandoffCore.js.map +1 -1
- package/dist/shared/submission/submissionClassifier.d.ts +7 -0
- package/dist/shared/submission/submissionClassifier.d.ts.map +1 -1
- package/dist/shared/submission/submissionClassifier.js +9 -0
- package/dist/shared/submission/submissionClassifier.js.map +1 -1
- package/dist/shared/submission/submissionScan.d.ts +7 -0
- package/dist/shared/submission/submissionScan.d.ts.map +1 -1
- package/dist/shared/submission/submissionScan.js +6 -2
- package/dist/shared/submission/submissionScan.js.map +1 -1
- package/package.json +2 -1
- package/scripts/audit/postinstall.mjs +21 -7
- package/scripts/remediate/postinstall.mjs +44 -1
- package/scripts/shared/install-host-assets.mjs +134 -1
- package/wrapper/audit-code-wrapper-lib.mjs +9 -46
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// sites-pinned: tests/shared/postinstall-mcp-registration.test.ts, tests/audit/postinstall-contract.test.ts
|
|
1
2
|
// Shared postinstall driver for the audit-code and remediate-code host-asset
|
|
2
3
|
// deployers (scripts/audit/postinstall.mjs, scripts/remediate/postinstall.mjs).
|
|
3
4
|
//
|
|
@@ -10,7 +11,8 @@
|
|
|
10
11
|
// config-merge functions locally — those differ in exact merge behavior
|
|
11
12
|
// between audit-code and remediate-code and must not be forced into parity.
|
|
12
13
|
import { dirname, join } from "node:path";
|
|
13
|
-
import { mkdirSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
14
|
+
import { mkdirSync, existsSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
15
|
+
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Read a source file that is required for the install to proceed at all
|
|
@@ -54,6 +56,137 @@ export function objectValue(value) {
|
|
|
54
56
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
/**
|
|
60
|
+
* The ONE stdio launch of a bin's submit-only MCP server (decision 4,
|
|
61
|
+
* 2026-11-06). Absolute node plus the package's own entry script, never the
|
|
62
|
+
* bare bin name: a host that spawns without a shell cannot run the Windows
|
|
63
|
+
* `.cmd` shim npm installs, and an absolute path needs no PATH lookup. Each
|
|
64
|
+
* reinstall rewrites it, so a moved package or a new node is picked up then.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} pkgRoot
|
|
67
|
+
* @param {string} toolName
|
|
68
|
+
* @returns {{command: string, args: string[]}}
|
|
69
|
+
*/
|
|
70
|
+
export function mcpServerLaunch(pkgRoot, toolName) {
|
|
71
|
+
return { command: process.execPath, args: [join(pkgRoot, `${toolName}.mjs`), "mcp"] };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The OpenCode `mcp` object with this tool's server registered under
|
|
76
|
+
* `mcp.servers` (the current schema; the flat `mcp.<name>` form is deprecated).
|
|
77
|
+
* The retired repo-local server's flat `auditor` entry is removed only when it
|
|
78
|
+
* still launches that server, so a user's own entry of that name survives.
|
|
79
|
+
*/
|
|
80
|
+
export function mergeOpenCodeMcpServer(existingMcp, toolName, launch) {
|
|
81
|
+
const mcp = { ...objectValue(existingMcp) };
|
|
82
|
+
const stale = objectValue(mcp.auditor).command;
|
|
83
|
+
if (Array.isArray(stale) && stale.some((part) => String(part).includes("run-mcp-server"))) {
|
|
84
|
+
delete mcp.auditor;
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
...mcp,
|
|
88
|
+
servers: {
|
|
89
|
+
...objectValue(mcp.servers),
|
|
90
|
+
[toolName]: { type: "local", command: [launch.command, ...launch.args] },
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Append this tool's `[mcp_servers.<tool>]` table to the Codex config. The
|
|
97
|
+
* user's file is never re-serialized (that would drop their comments and
|
|
98
|
+
* layout): an absent entry is appended as text, an identical one is left, and
|
|
99
|
+
* a different one is the user's edit and is left too, with a note.
|
|
100
|
+
*
|
|
101
|
+
* The file is written only when the COMPOSED text still parses. An appended
|
|
102
|
+
* table cannot extend an inline `mcp_servers = { ... }` (TOML closes inline
|
|
103
|
+
* tables), and a file that does not parse today cannot be judged at all: both
|
|
104
|
+
* return "manual" and leave the file as it is, never making it invalid and
|
|
105
|
+
* never failing the install over a user's own config.
|
|
106
|
+
*
|
|
107
|
+
* @returns {"installed" | "unchanged" | "kept" | "manual"}
|
|
108
|
+
*/
|
|
109
|
+
function registerCodexMcpServer(path, toolName, launch) {
|
|
110
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
111
|
+
const parsesAs = (text) => {
|
|
112
|
+
try {
|
|
113
|
+
return parseToml(text);
|
|
114
|
+
} catch {
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const current = parsesAs(existing);
|
|
119
|
+
if (current === undefined) return "manual";
|
|
120
|
+
const entry = objectValue(objectValue(current.mcp_servers)[toolName]);
|
|
121
|
+
if (Object.keys(entry).length > 0) {
|
|
122
|
+
// Compare by field, not by serialized text: the same entry with its keys in
|
|
123
|
+
// another order is unchanged, not an edit to report as kept.
|
|
124
|
+
const sameLaunch =
|
|
125
|
+
Object.keys(entry).length === 2 &&
|
|
126
|
+
entry.command === launch.command &&
|
|
127
|
+
JSON.stringify(entry.args) === JSON.stringify(launch.args);
|
|
128
|
+
return sameLaunch ? "unchanged" : "kept";
|
|
129
|
+
}
|
|
130
|
+
const table = stringifyToml({ mcp_servers: { [toolName]: launch } });
|
|
131
|
+
const separator = existing === "" || existing.endsWith("\n\n") ? "" : existing.endsWith("\n") ? "\n" : "\n\n";
|
|
132
|
+
const next = `${existing}${separator}${table}${table.endsWith("\n") ? "" : "\n"}`;
|
|
133
|
+
if (parsesAs(next) === undefined) return "manual";
|
|
134
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
135
|
+
// The user's own config: temp-then-rename, so a crash mid-write leaves the
|
|
136
|
+
// old file whole instead of a truncated one.
|
|
137
|
+
const temp = `${path}.${process.pid}.tmp`;
|
|
138
|
+
writeFileSync(temp, next, "utf8");
|
|
139
|
+
renameSync(temp, path);
|
|
140
|
+
return "installed";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Register a bin's submit-only MCP server with the hosts whose format each
|
|
145
|
+
* keeps in a file this package owns or appends to: the tool's Claude plugin
|
|
146
|
+
* (`.mcp.json`), its Antigravity plugin (`mcp_config.json`) and the Codex
|
|
147
|
+
* config. OpenCode is registered inside each tool's merged global config
|
|
148
|
+
* (`mergeOpenCodeMcpServer`). Each host is its own counted step.
|
|
149
|
+
*
|
|
150
|
+
* @param {{toolName: string, homeDir: string, launch: {command: string, args: string[]}, claudePluginDir: string}} options
|
|
151
|
+
* @param {{succeeded: number, failed: number}} counts
|
|
152
|
+
*/
|
|
153
|
+
export function installMcpServerRegistrations({ toolName, homeDir, launch, claudePluginDir }, counts) {
|
|
154
|
+
const declaration = Buffer.from(JSON.stringify({ mcpServers: { [toolName]: launch } }, null, 2) + "\n");
|
|
155
|
+
/** @type {Array<[string, string, (path: string) => string]>} */
|
|
156
|
+
const steps = [
|
|
157
|
+
["Claude plugin MCP server", join(claudePluginDir, ".mcp.json"), (path) => writeGeneratedFile(path, declaration)],
|
|
158
|
+
[
|
|
159
|
+
"Antigravity plugin MCP server",
|
|
160
|
+
join(homeDir, ".gemini", "config", "plugins", toolName, "mcp_config.json"),
|
|
161
|
+
(path) => writeGeneratedFile(path, declaration),
|
|
162
|
+
],
|
|
163
|
+
["Codex MCP server", join(homeDir, ".codex", "config.toml"), (path) => registerCodexMcpServer(path, toolName, launch)],
|
|
164
|
+
];
|
|
165
|
+
for (const [label, path, install] of steps) {
|
|
166
|
+
try {
|
|
167
|
+
const action = install(path);
|
|
168
|
+
if (action === "kept") {
|
|
169
|
+
console.log(
|
|
170
|
+
`${toolName}: kept the ${label} entry you edited in ${path}; the launch this release would write is ` +
|
|
171
|
+
`${JSON.stringify(launch)}`,
|
|
172
|
+
);
|
|
173
|
+
} else if (action === "manual") {
|
|
174
|
+
console.log(
|
|
175
|
+
`${toolName}: left ${path} unchanged — appending the ${label} table would not parse there ` +
|
|
176
|
+
`(an inline mcp_servers table, or a file that does not parse today). Add it by hand: ` +
|
|
177
|
+
`[mcp_servers.${toolName}] command = ${JSON.stringify(launch.command)} args = ${JSON.stringify(launch.args)}`,
|
|
178
|
+
);
|
|
179
|
+
} else {
|
|
180
|
+
console.log(`${toolName}: ${action} ${label} at ${path}`);
|
|
181
|
+
}
|
|
182
|
+
counts.succeeded++;
|
|
183
|
+
} catch (err) {
|
|
184
|
+
console.warn(`${toolName}: could not register the ${label} at ${path} (${/** @type {any} */ (err).message})`);
|
|
185
|
+
counts.failed++;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
57
190
|
/** Strip YAML frontmatter from a text file, returning only the body. */
|
|
58
191
|
export function splitFrontmatter(text) {
|
|
59
192
|
const normalized = text.replace(/\r\n/g, "\n");
|
|
@@ -255,7 +255,9 @@ function printHelp({ usageName, preferredEntrypoint }) {
|
|
|
255
255
|
// per-verb help cannot disagree. They were hand-restated here and had
|
|
256
256
|
// already drifted from it on two of the four.
|
|
257
257
|
...installerVerbSummaries('/audit-code'),
|
|
258
|
-
|
|
258
|
+
// sites-pinned: none — help text; it asserts no behaviour
|
|
259
|
+
'- mcp serves the submit-only MCP tool (submit_result) over stdio',
|
|
260
|
+
'- submit --work-item ID --from FILE checks one work item result and writes it to its bound path only when it passes',
|
|
259
261
|
'- validate checks the current artifact bundle and canonical session intent and exits non-zero when issues exist',
|
|
260
262
|
'- validate-results --results FILE validates AuditResult payloads against the active task manifest without ingesting them',
|
|
261
263
|
'- explain-task <task_id> prints the resolved file coverage and current status for a task id',
|
|
@@ -307,41 +309,6 @@ async function runDistCommand(commandName, argv, { ensureArtifactsDir = false }
|
|
|
307
309
|
});
|
|
308
310
|
}
|
|
309
311
|
|
|
310
|
-
async function runDistCommandInline(commandName, argv, { ensureArtifactsDir = false } = {}) {
|
|
311
|
-
const commandArgs = [...argv];
|
|
312
|
-
// Same discovery as runDistCommand — the two paths must not answer "which
|
|
313
|
-
// repository is this?" differently.
|
|
314
|
-
const rootValue = resolveWrapperRoot(getFlag(commandArgs, '--root'));
|
|
315
|
-
const artifactsDir = resolve(getFlag(commandArgs, '--artifacts-dir') ?? join(rootValue, '.audit-tools', 'audit'));
|
|
316
|
-
|
|
317
|
-
setFlag(commandArgs, '--root', rootValue);
|
|
318
|
-
setFlag(commandArgs, '--artifacts-dir', artifactsDir);
|
|
319
|
-
|
|
320
|
-
// Gate the mkdir behind the same ensureArtifactsDir flag as runDistCommand so
|
|
321
|
-
// "the artifacts directory is created only for designated stateful commands"
|
|
322
|
-
// holds on this path too (CE-001); mcp is a designated stateful command and
|
|
323
|
-
// opts in explicitly at its call site.
|
|
324
|
-
if (ensureArtifactsDir) {
|
|
325
|
-
await mkdir(artifactsDir, { recursive: true });
|
|
326
|
-
}
|
|
327
|
-
await ensureBuilt();
|
|
328
|
-
|
|
329
|
-
// Propagate the invocation hint into this (long-lived) server process so it
|
|
330
|
-
// and the wrapper subprocesses it spawns emit continuation commands that
|
|
331
|
-
// match how the backend was launched. Safe here: this path is only the `mcp`
|
|
332
|
-
// server, not a shared/test process.
|
|
333
|
-
Object.assign(process.env, selfInvocationEnv());
|
|
334
|
-
|
|
335
|
-
// Import the module that exports runCli (dist/cli.js). dist/index.js has no
|
|
336
|
-
// exports — it is the bare entrypoint that runs `runCli(process.argv)` as an
|
|
337
|
-
// import side effect — so importing it here both fails to provide runCli and
|
|
338
|
-
// double-starts the command from this process's argv.
|
|
339
|
-
const distCliEntry = join(repoRoot, 'dist', 'cli.js');
|
|
340
|
-
const distUrl = new URL(`file:///${distCliEntry.replace(/\\/g, '/')}`);
|
|
341
|
-
const cli = await import(distUrl.href);
|
|
342
|
-
await cli.runCli([process.execPath, distCliEntry, commandName, ...commandArgs]);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
312
|
/** @param {{usageName: string, argv?: string[], preferredEntrypoint?: string}} options */
|
|
346
313
|
export async function runAuditCodeWrapper({
|
|
347
314
|
usageName,
|
|
@@ -393,19 +360,15 @@ export async function runAuditCodeWrapper({
|
|
|
393
360
|
return;
|
|
394
361
|
}
|
|
395
362
|
|
|
396
|
-
// Commands that need special wrapper handling stay explicit:
|
|
397
|
-
//
|
|
398
|
-
//
|
|
399
|
-
//
|
|
400
|
-
//
|
|
401
|
-
//
|
|
363
|
+
// Commands that need special wrapper handling stay explicit: the
|
|
364
|
+
// artifact-dir-bootstrapping commands pass { ensureArtifactsDir: true }
|
|
365
|
+
// because they may be the FIRST call in a fresh repo and must create the run
|
|
366
|
+
// directory before dist reads it. `mcp` needs no branch: the child inherits
|
|
367
|
+
// stdio and ensureBuilt writes to stderr, so the forwarded server's stdout
|
|
368
|
+
// stays the protocol stream.
|
|
402
369
|
const commandArgv = argv.slice(1);
|
|
403
370
|
// Help is informational: it must not create the artifacts directory.
|
|
404
371
|
const ensureArtifactsDir = !commandArgv.some((arg) => arg === '--help' || arg === '-h');
|
|
405
|
-
if (argv[0] === 'mcp') {
|
|
406
|
-
await runDistCommandInline('mcp', commandArgv, { ensureArtifactsDir });
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
372
|
|
|
410
373
|
if (argv[0] === 'next-step') {
|
|
411
374
|
await runDistCommand('next-step', commandArgv, { ensureArtifactsDir });
|