@deftai/directive-core 0.107.0 → 0.108.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/dist/architecture/sor-preflight.js +2 -0
- package/dist/check/cached-orchestrator.js +28 -3
- package/dist/check/named-cause.js +18 -3
- package/dist/codebase/provider.js +7 -1
- package/dist/delivery-attempt/handoff.js +1 -1
- package/dist/design-critique/citation-grammar.d.ts +53 -0
- package/dist/design-critique/citation-grammar.js +303 -0
- package/dist/design-critique/completed-arc-record.d.ts +62 -0
- package/dist/design-critique/completed-arc-record.js +232 -0
- package/dist/freshness/bind.d.ts +32 -3
- package/dist/freshness/bind.js +58 -12
- package/dist/hooks/classify/host-session-identity.d.ts +76 -0
- package/dist/hooks/classify/host-session-identity.js +470 -0
- package/dist/hooks/classify/index.d.ts +3 -2
- package/dist/hooks/classify/index.js +3 -2
- package/dist/hooks/classify/paths.d.ts +7 -0
- package/dist/hooks/classify/paths.js +35 -0
- package/dist/hooks/classify/stdin.d.ts +5 -0
- package/dist/hooks/classify/stdin.js +27 -0
- package/dist/hooks/dispatcher.d.ts +52 -1
- package/dist/hooks/dispatcher.js +538 -45
- package/dist/hooks/fixtures/cases.d.ts +16 -2
- package/dist/hooks/fixtures/cases.js +175 -0
- package/dist/hooks/scope.js +3 -1
- package/dist/init-deposit/agent-hooks.d.ts +2 -1
- package/dist/init-deposit/agent-hooks.js +8 -1
- package/dist/init-deposit/hook-runtime-travel.d.ts +77 -0
- package/dist/init-deposit/hook-runtime-travel.js +269 -0
- package/dist/intake/clause-derivation.js +9 -3
- package/dist/intake/issue-ingest.js +62 -2
- package/dist/intake/platform-capabilities.d.ts +9 -2
- package/dist/intake/platform-capabilities.js +38 -9
- package/dist/orphan-active/evaluate.d.ts +25 -0
- package/dist/orphan-active/evaluate.js +193 -128
- package/dist/orphan-active/index.d.ts +1 -0
- package/dist/orphan-active/index.js +1 -0
- package/dist/orphan-active/issue-state.d.ts +121 -0
- package/dist/orphan-active/issue-state.js +278 -0
- package/dist/platform/cursor-managed-runtime.d.ts +95 -0
- package/dist/platform/cursor-managed-runtime.js +241 -0
- package/dist/platform/index.d.ts +1 -0
- package/dist/platform/index.js +1 -0
- package/dist/platform/platform-capabilities.d.ts +23 -1
- package/dist/platform/platform-capabilities.js +55 -15
- package/dist/policy/ceremony-dial.js +5 -9
- package/dist/policy/host-hooks.js +4 -9
- package/dist/policy/org-force-on-migration.js +5 -10
- package/dist/policy/plan-extensions.d.ts +14 -2
- package/dist/policy/plan-extensions.js +24 -3
- package/dist/policy/product-signal.js +5 -10
- package/dist/policy/require-human-merge.js +5 -9
- package/dist/policy/resolve.js +77 -16
- package/dist/policy/value-feedback.js +9 -18
- package/dist/pr-closeout-attestable/evaluate.d.ts +80 -0
- package/dist/pr-closeout-attestable/evaluate.js +306 -0
- package/dist/pr-closeout-attestable/index.d.ts +2 -0
- package/dist/pr-closeout-attestable/index.js +2 -0
- package/dist/pr-protected-issues/gh.d.ts +6 -2
- package/dist/pr-protected-issues/gh.js +7 -3
- package/dist/pr-wait-mergeable/cascade.d.ts +9 -1
- package/dist/pr-wait-mergeable/cascade.js +21 -1
- package/dist/pr-wait-mergeable/types.d.ts +2 -0
- package/dist/pr-wait-mergeable/wrappers.d.ts +6 -0
- package/dist/pr-wait-mergeable/wrappers.js +11 -0
- package/dist/preflight/evaluate.d.ts +15 -0
- package/dist/preflight/evaluate.js +29 -3
- package/dist/product-first-done-gate/acceptance-resolver.d.ts +14 -2
- package/dist/product-first-done-gate/acceptance-resolver.js +13 -2
- package/dist/product-first-done-gate/evaluate.js +17 -7
- package/dist/release/cli-drift-report.d.ts +68 -0
- package/dist/release/cli-drift-report.js +189 -0
- package/dist/release/index.d.ts +1 -0
- package/dist/release/index.js +1 -0
- package/dist/release/issue-state-fetch.d.ts +5 -3
- package/dist/release/issue-state-fetch.js +86 -21
- package/dist/release/native-steps.js +1 -0
- package/dist/release/pipeline.js +19 -0
- package/dist/release/types.d.ts +14 -0
- package/dist/render/constants.d.ts +4 -0
- package/dist/render/constants.js +11 -8
- package/dist/render/export-spec.js +31 -5
- package/dist/render/index.d.ts +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/prd-render.d.ts +4 -1
- package/dist/render/prd-render.js +82 -23
- package/dist/render/project-render.js +14 -7
- package/dist/render/scope-outlook.d.ts +2 -0
- package/dist/render/scope-outlook.js +3 -0
- package/dist/render/spec-render.js +2 -2
- package/dist/resolution/package-manager.d.ts +33 -4
- package/dist/resolution/package-manager.js +210 -9
- package/dist/review-monitor/constants.d.ts +7 -0
- package/dist/review-monitor/constants.js +7 -0
- package/dist/review-monitor/github-lease.d.ts +98 -1
- package/dist/review-monitor/github-lease.js +182 -1
- package/dist/review-monitor/lease-comment.d.ts +36 -0
- package/dist/review-monitor/lease-comment.js +103 -2
- package/dist/scm/call.js +12 -3
- package/dist/scm/design-critique-chip.d.ts +1 -0
- package/dist/scm/design-critique-chip.js +22 -6
- package/dist/scm/gh-rest.d.ts +9 -1
- package/dist/scm/gh-rest.js +103 -0
- package/dist/scm/readiness.d.ts +2 -0
- package/dist/scm/readiness.js +28 -4
- package/dist/scope/project-definition-sync.js +14 -7
- package/dist/session/git.d.ts +24 -0
- package/dist/session/git.js +138 -2
- package/dist/session/occupancy.d.ts +238 -12
- package/dist/session/occupancy.js +815 -29
- package/dist/session/ritual-sentinel.d.ts +5 -0
- package/dist/session/ritual-sentinel.js +5 -0
- package/dist/session/session-ready.d.ts +5 -1
- package/dist/session/session-ready.js +98 -8
- package/dist/session/session-start.d.ts +5 -1
- package/dist/session/session-start.js +32 -17
- package/dist/session/toolchain-preflight.d.ts +13 -3
- package/dist/session/toolchain-preflight.js +93 -18
- package/dist/session/verify-session-ritual.d.ts +11 -0
- package/dist/session/verify-session-ritual.js +60 -15
- package/dist/slice/constants.d.ts +1 -1
- package/dist/spec-authority/constants.d.ts +10 -2
- package/dist/spec-authority/constants.js +53 -8
- package/dist/spec-authority/resolver.d.ts +3 -0
- package/dist/spec-authority/resolver.js +55 -7
- package/dist/subprocess/max-buffer.d.ts +14 -0
- package/dist/subprocess/max-buffer.js +15 -0
- package/dist/swarm/complete-cohort.d.ts +2 -0
- package/dist/swarm/complete-cohort.js +21 -13
- package/dist/swarm/index.d.ts +1 -0
- package/dist/swarm/index.js +1 -0
- package/dist/swarm/launch-cli.js +53 -33
- package/dist/swarm/launch.d.ts +8 -0
- package/dist/swarm/launch.js +63 -43
- package/dist/swarm/pre-dispatch-cli.js +2 -1
- package/dist/swarm/pre-dispatch.js +10 -1
- package/dist/swarm/subagent-status-dir.d.ts +27 -0
- package/dist/swarm/subagent-status-dir.js +42 -0
- package/dist/swarm/worktrees.d.ts +17 -3
- package/dist/swarm/worktrees.js +48 -4
- package/dist/triage/scope/mutations-core.d.ts +2 -6
- package/dist/triage/scope/mutations-core.js +23 -55
- package/dist/triage/scope-drift/add-ignore.js +5 -39
- package/dist/triage/subscribe/index.d.ts +2 -6
- package/dist/triage/subscribe/index.js +15 -65
- package/dist/triage/welcome/writers.js +15 -74
- package/dist/vbrief-build/index.d.ts +2 -1
- package/dist/vbrief-build/index.js +2 -1
- package/dist/vbrief-build/parity-scenarios.js +5 -5
- package/dist/vbrief-build/project-definition-io.d.ts +63 -3
- package/dist/vbrief-build/project-definition-io.js +357 -31
- package/dist/vbrief-build/project-definition-mutation.d.ts +32 -0
- package/dist/vbrief-build/project-definition-mutation.js +43 -0
- package/dist/vbrief-validate/conformance.d.ts +1 -0
- package/dist/vbrief-validate/conformance.js +85 -8
- package/dist/vbrief-validate/main.js +2 -0
- package/dist/vbrief-validate/precutover.js +5 -10
- package/dist/verify-ac/clauses.d.ts +62 -2
- package/dist/verify-ac/clauses.js +183 -111
- package/dist/verify-ac/index.d.ts +1 -1
- package/dist/verify-ac/index.js +1 -1
- package/dist/verify-env/node-runtime.d.ts +8 -4
- package/dist/verify-env/node-runtime.js +9 -6
- package/dist/verify-env/toolchain-check.d.ts +35 -3
- package/dist/verify-env/toolchain-check.js +155 -36
- package/dist/verify-source/project-definition-mutation-boundary.d.ts +104 -0
- package/dist/verify-source/project-definition-mutation-boundary.js +326 -0
- package/package.json +7 -3
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
/** Node/
|
|
2
|
-
|
|
1
|
+
/** Node/package-manager presence contract for TS-backed consumer gates. */
|
|
2
|
+
import type { PackageManager } from "../resolution/package-manager.js";
|
|
3
|
+
/** All supported Node/package-manager tool names across consumer projects. */
|
|
4
|
+
export declare const NODE_RUNTIME_TOOL_NAMES: readonly ["node", "npm", "pnpm"];
|
|
3
5
|
export declare const NODE_RUNTIME_REMEDIATION = "Node.js and pnpm are required for TS-backed deft gates. Install Node 20+ (see .nvmrc), then run: corepack enable && corepack prepare pnpm@latest --activate. See UPGRADING.md \u00A7 Node runtime.";
|
|
4
|
-
/**
|
|
5
|
-
export declare
|
|
6
|
+
/** npm ships with the supported Node distribution; Corepack/pnpm is not required. */
|
|
7
|
+
export declare const NPM_RUNTIME_REMEDIATION = "Node.js and npm are required for TS-backed deft gates. Install or repair Node 20+ (see .nvmrc; npm is bundled), then re-run the consumer check. See UPGRADING.md \u00A7 Node runtime.";
|
|
8
|
+
/** Append remediation lines for node or the package manager selected by the project. */
|
|
9
|
+
export declare function nodeRuntimeRemediationLines(failed: readonly string[], packageManager?: PackageManager): readonly string[];
|
|
6
10
|
//# sourceMappingURL=node-runtime.d.ts.map
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
/** Node/
|
|
2
|
-
|
|
1
|
+
/** Node/package-manager presence contract for TS-backed consumer gates. */
|
|
2
|
+
/** All supported Node/package-manager tool names across consumer projects. */
|
|
3
|
+
export const NODE_RUNTIME_TOOL_NAMES = ["node", "npm", "pnpm"];
|
|
3
4
|
export const NODE_RUNTIME_REMEDIATION = "Node.js and pnpm are required for TS-backed deft gates. Install Node 20+ (see .nvmrc), then run: corepack enable && corepack prepare pnpm@latest --activate. See UPGRADING.md § Node runtime.";
|
|
4
|
-
/**
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/** npm ships with the supported Node distribution; Corepack/pnpm is not required. */
|
|
6
|
+
export const NPM_RUNTIME_REMEDIATION = "Node.js and npm are required for TS-backed deft gates. Install or repair Node 20+ (see .nvmrc; npm is bundled), then re-run the consumer check. See UPGRADING.md § Node runtime.";
|
|
7
|
+
/** Append remediation lines for node or the package manager selected by the project. */
|
|
8
|
+
export function nodeRuntimeRemediationLines(failed, packageManager = "pnpm") {
|
|
9
|
+
if (failed.includes("node") || failed.includes(packageManager)) {
|
|
10
|
+
return [packageManager === "npm" ? NPM_RUNTIME_REMEDIATION : NODE_RUNTIME_REMEDIATION];
|
|
8
11
|
}
|
|
9
12
|
return [];
|
|
10
13
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
+
import { type PackageManager, type PackageManagerResolutionSource } from "../resolution/package-manager.js";
|
|
1
2
|
export interface ToolCheck {
|
|
2
3
|
readonly name: string;
|
|
3
4
|
readonly command: readonly string[];
|
|
4
5
|
}
|
|
5
6
|
export declare const MAINTAINER_TOOLS: readonly ToolCheck[];
|
|
6
|
-
/** Consumer
|
|
7
|
+
/** Consumer prerequisites shared by npm and pnpm projects. */
|
|
7
8
|
export declare const CONSUMER_TOOLS: readonly ToolCheck[];
|
|
8
9
|
/** @deprecated use MAINTAINER_TOOLS */
|
|
9
10
|
export declare const TOOLS: readonly ToolCheck[];
|
|
10
|
-
export type CommandRunner = (command: readonly string[], timeoutMs: number) => {
|
|
11
|
+
export type CommandRunner = (command: readonly string[], timeoutMs: number, options?: CommandRunnerOptions) => {
|
|
11
12
|
returncode: number;
|
|
12
13
|
stdout: string;
|
|
13
14
|
stderr: string;
|
|
@@ -15,11 +16,38 @@ export type CommandRunner = (command: readonly string[], timeoutMs: number) => {
|
|
|
15
16
|
error: "not-found" | "exception";
|
|
16
17
|
message: string;
|
|
17
18
|
};
|
|
19
|
+
export interface CommandRunnerOptions {
|
|
20
|
+
/** Working directory whose package-manager contract the probe must observe. */
|
|
21
|
+
readonly cwd?: string;
|
|
22
|
+
/** Environment used for PATH lookup and subprocess execution. */
|
|
23
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
24
|
+
}
|
|
18
25
|
export interface ToolchainCheckResult {
|
|
19
26
|
readonly lines: readonly string[];
|
|
20
27
|
readonly exitCode: 0 | 1;
|
|
28
|
+
readonly packageManager?: PackageManager;
|
|
29
|
+
readonly packageManagerSource?: PackageManagerResolutionSource;
|
|
30
|
+
}
|
|
31
|
+
export interface ToolchainExecFileOptions {
|
|
32
|
+
readonly encoding: "utf8";
|
|
33
|
+
readonly timeout: number;
|
|
34
|
+
readonly stdio: ["ignore", "pipe", "pipe"];
|
|
35
|
+
readonly shell: boolean;
|
|
36
|
+
readonly windowsVerbatimArguments?: boolean;
|
|
37
|
+
readonly cwd?: string;
|
|
38
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
39
|
+
}
|
|
40
|
+
export type ToolchainExecFileSync = (bin: string, args: readonly string[], options: ToolchainExecFileOptions) => string;
|
|
41
|
+
export interface DefaultCommandRunnerOptions extends CommandRunnerOptions {
|
|
42
|
+
readonly platform?: NodeJS.Platform;
|
|
43
|
+
readonly execFileSync?: ToolchainExecFileSync;
|
|
44
|
+
readonly exists?: (path: string) => boolean;
|
|
21
45
|
}
|
|
22
|
-
|
|
46
|
+
/** Child-env transport for Windows shim paths (#3814 option F). */
|
|
47
|
+
export declare const RESOLVED_PACKAGE_MANAGER_SHIM_ENV = "DEFT_RESOLVED_PACKAGE_MANAGER_SHIM";
|
|
48
|
+
export declare function childEnvWithResolvedPackageManagerShim(baseEnv: NodeJS.ProcessEnv, shimPath: string): NodeJS.ProcessEnv;
|
|
49
|
+
/** Execute one fixed tool argv with Windows `.cmd` fallback. */
|
|
50
|
+
export declare function defaultCommandRunner(command: readonly string[], timeoutMs: number, options?: DefaultCommandRunnerOptions): {
|
|
23
51
|
returncode: number;
|
|
24
52
|
stdout: string;
|
|
25
53
|
stderr: string;
|
|
@@ -29,6 +57,10 @@ export declare function defaultCommandRunner(command: readonly string[], timeout
|
|
|
29
57
|
};
|
|
30
58
|
export interface ToolchainCheckOptions {
|
|
31
59
|
readonly consumer?: boolean;
|
|
60
|
+
/** Consumer project root used for package.json/lockfile resolution. */
|
|
61
|
+
readonly projectRoot?: string;
|
|
62
|
+
/** Environment map used for package-manager precedence. */
|
|
63
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
32
64
|
}
|
|
33
65
|
/** Run maintainer or consumer toolchain probe (mirrors scripts/toolchain-check.py). */
|
|
34
66
|
export declare function runToolchainCheck(runner?: CommandRunner, options?: ToolchainCheckOptions, tools?: readonly ToolCheck[]): ToolchainCheckResult;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as childProcess from "node:child_process";
|
|
2
|
+
import { win32 } from "node:path";
|
|
3
|
+
import { pythonSplitlines } from "../encoding/text.js";
|
|
4
|
+
import { packageManagerSourceLabel, resolveProjectPackageManager, sanitizeSingleLineDiagnostic, } from "../resolution/package-manager.js";
|
|
5
|
+
import { resolveCommandOnPath } from "./command-spawn.js";
|
|
2
6
|
import { nodeRuntimeRemediationLines } from "./node-runtime.js";
|
|
3
7
|
export const MAINTAINER_TOOLS = [
|
|
4
8
|
{ name: "go", command: ["go", "version"] },
|
|
@@ -8,87 +12,202 @@ export const MAINTAINER_TOOLS = [
|
|
|
8
12
|
{ name: "node", command: ["node", "--version"] },
|
|
9
13
|
{ name: "pnpm", command: ["pnpm", "--version"] },
|
|
10
14
|
];
|
|
11
|
-
/** Consumer
|
|
15
|
+
/** Consumer prerequisites shared by npm and pnpm projects. */
|
|
12
16
|
export const CONSUMER_TOOLS = [
|
|
13
17
|
{ name: "git", command: ["git", "--version"] },
|
|
14
18
|
{ name: "gh", command: ["gh", "--version"] },
|
|
15
19
|
{ name: "node", command: ["node", "--version"] },
|
|
16
|
-
{ name: "pnpm", command: ["pnpm", "--version"] },
|
|
17
|
-
{ name: "task", command: ["task", "--version"] },
|
|
18
20
|
];
|
|
21
|
+
const PACKAGE_MANAGER_TOOLS = {
|
|
22
|
+
npm: { name: "npm", command: ["npm", "--version"] },
|
|
23
|
+
pnpm: { name: "pnpm", command: ["pnpm", "--version"] },
|
|
24
|
+
};
|
|
19
25
|
/** @deprecated use MAINTAINER_TOOLS */
|
|
20
26
|
export const TOOLS = MAINTAINER_TOOLS;
|
|
21
27
|
const DEFAULT_TIMEOUT_MS = 10_000;
|
|
22
|
-
|
|
28
|
+
function executionFailure(error) {
|
|
29
|
+
return error;
|
|
30
|
+
}
|
|
31
|
+
function failedExecution(error) {
|
|
32
|
+
const failure = executionFailure(error);
|
|
33
|
+
return {
|
|
34
|
+
returncode: typeof failure.status === "number" ? failure.status : 1,
|
|
35
|
+
stdout: typeof failure.stdout === "string" ? failure.stdout : "",
|
|
36
|
+
stderr: typeof failure.stderr === "string" ? failure.stderr : String(failure.message ?? error),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function windowsShellReportsMissing(error) {
|
|
40
|
+
const failure = executionFailure(error);
|
|
41
|
+
if (failure.code === "ENOENT")
|
|
42
|
+
return true;
|
|
43
|
+
const diagnostic = `${failure.stderr ?? ""}\n${failure.message ?? ""}`;
|
|
44
|
+
return /is not recognized as an internal or external command|command not found/i.test(diagnostic);
|
|
45
|
+
}
|
|
46
|
+
function isFixedWindowsPackageManagerProbe(bin, args) {
|
|
47
|
+
return (bin === "npm" || bin === "pnpm") && args.length === 1 && args[0] === "--version";
|
|
48
|
+
}
|
|
49
|
+
/** Child-env transport for Windows shim paths (#3814 option F). */
|
|
50
|
+
export const RESOLVED_PACKAGE_MANAGER_SHIM_ENV = "DEFT_RESOLVED_PACKAGE_MANAGER_SHIM";
|
|
51
|
+
export function childEnvWithResolvedPackageManagerShim(baseEnv, shimPath) {
|
|
52
|
+
const childEnv = { ...baseEnv };
|
|
53
|
+
const targetLower = RESOLVED_PACKAGE_MANAGER_SHIM_ENV.toLowerCase();
|
|
54
|
+
for (const key of Object.keys(childEnv)) {
|
|
55
|
+
if (key.toLowerCase() === targetLower) {
|
|
56
|
+
delete childEnv[key];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
childEnv[RESOLVED_PACKAGE_MANAGER_SHIM_ENV] = shimPath;
|
|
60
|
+
return childEnv;
|
|
61
|
+
}
|
|
62
|
+
function windowsCommandInterpreter(env) {
|
|
63
|
+
return win32.join(env.SystemRoot ?? "C:\\Windows", "System32", "cmd.exe");
|
|
64
|
+
}
|
|
65
|
+
/** Execute one fixed tool argv with Windows `.cmd` fallback. */
|
|
66
|
+
export function defaultCommandRunner(command, timeoutMs, options = {}) {
|
|
23
67
|
const bin = command[0] ?? "";
|
|
24
68
|
const args = command.slice(1);
|
|
25
|
-
const
|
|
69
|
+
const platform = options.platform ?? process.platform;
|
|
70
|
+
const env = options.env ?? process.env;
|
|
71
|
+
const execFileSync = options.execFileSync ??
|
|
72
|
+
((file, fileArgs, execOptions) => childProcess.execFileSync(file, [...fileArgs], execOptions));
|
|
73
|
+
const execOptions = {
|
|
26
74
|
encoding: "utf8",
|
|
27
75
|
timeout: timeoutMs,
|
|
28
76
|
stdio: ["ignore", "pipe", "pipe"],
|
|
29
|
-
shell,
|
|
30
|
-
|
|
77
|
+
shell: false,
|
|
78
|
+
cwd: options.cwd,
|
|
79
|
+
env,
|
|
80
|
+
};
|
|
81
|
+
// Windows package-manager shims are commonly .cmd files. Resolve an
|
|
82
|
+
// absolute PATH candidate first so cmd.exe cannot select a repo-local shim,
|
|
83
|
+
// then invoke the fixed `--version` probe through the system interpreter.
|
|
84
|
+
if (platform === "win32" && isFixedWindowsPackageManagerProbe(bin, args)) {
|
|
85
|
+
const resolvedBin = resolveCommandOnPath(bin, {
|
|
86
|
+
env,
|
|
87
|
+
platform,
|
|
88
|
+
exists: options.exists,
|
|
89
|
+
});
|
|
90
|
+
if (resolvedBin === null) {
|
|
91
|
+
return { error: "not-found", message: "" };
|
|
92
|
+
}
|
|
93
|
+
const isCommandShim = /\.(?:cmd|bat)$/i.test(resolvedBin);
|
|
94
|
+
const executable = isCommandShim ? windowsCommandInterpreter(env) : resolvedBin;
|
|
95
|
+
const shimEnv = isCommandShim ? childEnvWithResolvedPackageManagerShim(env, resolvedBin) : env;
|
|
96
|
+
const commandLine = `"%${RESOLVED_PACKAGE_MANAGER_SHIM_ENV}%" --version`;
|
|
97
|
+
const executableArgs = isCommandShim ? ["/d", "/s", "/c", `"${commandLine}"`] : args;
|
|
98
|
+
// Mirror Node's cmd.exe shell plan: the outer command quote satisfies /s,
|
|
99
|
+
// while verbatim arguments prevent libuv from re-escaping the command line.
|
|
100
|
+
const commandOptions = isCommandShim
|
|
101
|
+
? { ...execOptions, env: shimEnv, windowsVerbatimArguments: true }
|
|
102
|
+
: execOptions;
|
|
103
|
+
try {
|
|
104
|
+
const stdout = execFileSync(executable, executableArgs, commandOptions);
|
|
105
|
+
return { returncode: 0, stdout: typeof stdout === "string" ? stdout : "", stderr: "" };
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (windowsShellReportsMissing(error)) {
|
|
109
|
+
return { error: "not-found", message: "" };
|
|
110
|
+
}
|
|
111
|
+
return failedExecution(error);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
31
114
|
try {
|
|
32
|
-
const stdout =
|
|
115
|
+
const stdout = execFileSync(bin, args, execOptions);
|
|
33
116
|
return { returncode: 0, stdout: typeof stdout === "string" ? stdout : "", stderr: "" };
|
|
34
117
|
}
|
|
35
118
|
catch (err) {
|
|
36
|
-
const e = err;
|
|
37
|
-
// win32: npm global shims are `.cmd` and need shell/PATHEXT (#2467 / #2415).
|
|
38
|
-
if (e.code === "ENOENT" && process.platform === "win32") {
|
|
39
|
-
try {
|
|
40
|
-
const stdout = trySpawn(true);
|
|
41
|
-
return { returncode: 0, stdout: typeof stdout === "string" ? stdout : "", stderr: "" };
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
// Shell still failed — binary is absent (cmd.exe often exits 1, not ENOENT).
|
|
45
|
-
return { error: "not-found", message: "" };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
119
|
+
const e = executionFailure(err);
|
|
48
120
|
if (e.code === "ENOENT") {
|
|
49
121
|
return { error: "not-found", message: "" };
|
|
50
122
|
}
|
|
51
|
-
return
|
|
52
|
-
returncode: typeof e.status === "number" ? e.status : 1,
|
|
53
|
-
stdout: typeof e.stdout === "string" ? e.stdout : "",
|
|
54
|
-
stderr: typeof e.stderr === "string" ? e.stderr : String(e.message ?? err),
|
|
55
|
-
};
|
|
123
|
+
return failedExecution(err);
|
|
56
124
|
}
|
|
57
125
|
}
|
|
58
126
|
/** Run maintainer or consumer toolchain probe (mirrors scripts/toolchain-check.py). */
|
|
59
127
|
export function runToolchainCheck(runner = defaultCommandRunner, options = {}, tools) {
|
|
60
|
-
const selectedTools = tools ?? (options.consumer ? CONSUMER_TOOLS : MAINTAINER_TOOLS);
|
|
61
128
|
const lines = [];
|
|
129
|
+
const projectRoot = options.projectRoot ?? process.cwd();
|
|
130
|
+
const env = options.env ?? process.env;
|
|
131
|
+
let packageManager = "pnpm";
|
|
132
|
+
let packageManagerSource;
|
|
133
|
+
let selectedTools;
|
|
134
|
+
if (tools !== undefined) {
|
|
135
|
+
selectedTools = tools;
|
|
136
|
+
}
|
|
137
|
+
else if (options.consumer) {
|
|
138
|
+
const resolution = resolveProjectPackageManager({
|
|
139
|
+
projectRoot,
|
|
140
|
+
env,
|
|
141
|
+
});
|
|
142
|
+
if (!resolution.ok) {
|
|
143
|
+
lines.push(` package manager: ERROR - ${resolution.message}`);
|
|
144
|
+
lines.push("");
|
|
145
|
+
lines.push("Package manager selection failed");
|
|
146
|
+
return { lines, exitCode: 1 };
|
|
147
|
+
}
|
|
148
|
+
packageManager = resolution.packageManager;
|
|
149
|
+
packageManagerSource = resolution.source;
|
|
150
|
+
lines.push(` package manager: ${packageManager} (${packageManagerSourceLabel(packageManagerSource)})`);
|
|
151
|
+
selectedTools = [...CONSUMER_TOOLS, PACKAGE_MANAGER_TOOLS[packageManager]];
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
selectedTools = MAINTAINER_TOOLS;
|
|
155
|
+
}
|
|
156
|
+
const missing = [];
|
|
62
157
|
const failed = [];
|
|
63
158
|
for (const tool of selectedTools) {
|
|
64
|
-
const result = runner(tool.command, DEFAULT_TIMEOUT_MS);
|
|
159
|
+
const result = runner(tool.command, DEFAULT_TIMEOUT_MS, { cwd: projectRoot, env });
|
|
65
160
|
if ("error" in result) {
|
|
66
161
|
if (result.error === "not-found") {
|
|
67
|
-
|
|
162
|
+
missing.push(tool.name);
|
|
68
163
|
lines.push(` ${tool.name}: NOT FOUND`);
|
|
69
164
|
}
|
|
70
165
|
else {
|
|
71
166
|
failed.push(tool.name);
|
|
72
|
-
|
|
167
|
+
const diagnostic = firstSafeDiagnostic(result.message);
|
|
168
|
+
lines.push(` ${tool.name}: ERROR${diagnostic === "" ? "" : ` - ${diagnostic}`}`);
|
|
73
169
|
}
|
|
74
170
|
continue;
|
|
75
171
|
}
|
|
76
|
-
const version = (result.stdout || result.stderr)
|
|
172
|
+
const version = firstSafeOutputLine(result.stdout || result.stderr);
|
|
77
173
|
if (result.returncode === 0) {
|
|
78
174
|
lines.push(` ${tool.name}: ${version}`);
|
|
79
175
|
}
|
|
80
176
|
else {
|
|
81
177
|
failed.push(tool.name);
|
|
82
|
-
|
|
178
|
+
const diagnostic = firstSafeDiagnostic(result.stderr || result.stdout);
|
|
179
|
+
lines.push(` ${tool.name}: FAILED (exit ${result.returncode})${diagnostic === "" ? "" : ` - ${diagnostic}`}`);
|
|
83
180
|
}
|
|
84
181
|
}
|
|
85
182
|
lines.push("");
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
183
|
+
const unavailable = [...missing, ...failed];
|
|
184
|
+
if (unavailable.length > 0) {
|
|
185
|
+
if (missing.length > 0)
|
|
186
|
+
lines.push(`Missing tools: ${missing.join(", ")}`);
|
|
187
|
+
if (failed.length > 0)
|
|
188
|
+
lines.push(`Failed tools: ${failed.join(", ")}`);
|
|
189
|
+
lines.push(...nodeRuntimeRemediationLines(unavailable, packageManager));
|
|
190
|
+
return {
|
|
191
|
+
lines,
|
|
192
|
+
exitCode: 1,
|
|
193
|
+
...(options.consumer ? { packageManager, packageManagerSource } : {}),
|
|
194
|
+
};
|
|
90
195
|
}
|
|
91
196
|
lines.push("All required tools available");
|
|
92
|
-
return {
|
|
197
|
+
return {
|
|
198
|
+
lines,
|
|
199
|
+
exitCode: 0,
|
|
200
|
+
...(options.consumer ? { packageManager, packageManagerSource } : {}),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
function firstSafeOutputLine(text) {
|
|
204
|
+
const first = pythonSplitlines(text)
|
|
205
|
+
.map((line) => line.trim())
|
|
206
|
+
.find((line) => line.length > 0);
|
|
207
|
+
return first === undefined ? "" : sanitizeSingleLineDiagnostic(first);
|
|
208
|
+
}
|
|
209
|
+
function firstSafeDiagnostic(text) {
|
|
210
|
+
const first = firstSafeOutputLine(text);
|
|
211
|
+
return /^[A-Z][A-Z0-9_]*=/.test(first) ? "" : first;
|
|
93
212
|
}
|
|
94
213
|
//# sourceMappingURL=toolchain-check.js.map
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* project-definition-mutation-boundary.ts -- mechanized production inventory for
|
|
3
|
+
* PROJECT-DEFINITION mutation identity (#3796).
|
|
4
|
+
*
|
|
5
|
+
* A convention that mutators "should" use the shared lock is not checkable: a
|
|
6
|
+
* caller can take the lock and then resolve, read, or write the artifact through
|
|
7
|
+
* its own path, and a helper-level test still passes while a production family
|
|
8
|
+
* split-brains. This scanner replaces that convention with a boundary.
|
|
9
|
+
*
|
|
10
|
+
* Two things are enforced:
|
|
11
|
+
*
|
|
12
|
+
* 1. **Boundary** -- outside the modules that own the protocol, no production
|
|
13
|
+
* source may call the raw lock, the raw write sink, or the raw loader, and no
|
|
14
|
+
* file that mutates PROJECT-DEFINITION may re-resolve the artifact path. The
|
|
15
|
+
* mutation capability is the only way in.
|
|
16
|
+
* 2. **Inventory** -- the per-file census of mutation call expressions is
|
|
17
|
+
* recorded. Adding or removing a mutation site is a deliberate edit to
|
|
18
|
+
* {@link PRODUCTION_MUTATION_INVENTORY}, not a silent drift.
|
|
19
|
+
*
|
|
20
|
+
* Consumed fail-closed by `project-definition-mutation-boundary.test.ts`.
|
|
21
|
+
*/
|
|
22
|
+
/** The capability that owns load/parse/persist against the captured path. */
|
|
23
|
+
export declare const MUTATION_CAPABILITY_MODULE = "packages/core/src/vbrief-build/project-definition-mutation.ts";
|
|
24
|
+
/** The module that owns the lock protocol and the raw primitives it wraps. */
|
|
25
|
+
export declare const MUTATION_PROTOCOL_MODULE = "packages/core/src/vbrief-build/project-definition-io.ts";
|
|
26
|
+
/**
|
|
27
|
+
* This scanner. Excluded from its own scan: it names every pattern it looks for
|
|
28
|
+
* in prose and regex literals, so scanning it would count the rules as call
|
|
29
|
+
* sites and let the inventory drift by editing the gate.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MUTATION_BOUNDARY_MODULE = "packages/core/src/verify-source/project-definition-mutation-boundary.ts";
|
|
32
|
+
/**
|
|
33
|
+
* Raw primitives and the only production files allowed to call them. Anything
|
|
34
|
+
* else reaching for these is a bypass of the captured-path identity.
|
|
35
|
+
*/
|
|
36
|
+
export declare const RAW_MUTATION_CALL_RULES: readonly {
|
|
37
|
+
readonly label: string;
|
|
38
|
+
readonly pattern: RegExp;
|
|
39
|
+
readonly allowedFiles: readonly string[];
|
|
40
|
+
}[];
|
|
41
|
+
/** Resolver calls that would give a mutation section a second artifact identity. */
|
|
42
|
+
export declare const RESOLVER_CALL_PATTERNS: readonly RegExp[];
|
|
43
|
+
/**
|
|
44
|
+
* Character offsets of each `withProjectDefinitionMutation(...)` argument list.
|
|
45
|
+
*
|
|
46
|
+
* Scoping to the section is what keeps the resolver rule precise: resolving the
|
|
47
|
+
* path *before* acquiring the lock is ordinary pre-check work, while resolving it
|
|
48
|
+
* *inside* the critical section is the second identity the contract forbids.
|
|
49
|
+
* String, template, and comment spans are skipped so their braces and parens do
|
|
50
|
+
* not throw off the match.
|
|
51
|
+
*/
|
|
52
|
+
export declare function extractMutationSections(text: string): Array<[number, number]>;
|
|
53
|
+
/**
|
|
54
|
+
* Production mutation call expressions, per file.
|
|
55
|
+
*
|
|
56
|
+
* The counts are the #3796 census: **18** call expressions across 13 core files
|
|
57
|
+
* that previously took the shared lock, plus the **2** `packages/cli` policy
|
|
58
|
+
* writers (`wipCap`, `swarmSubagentBackend`) that previously wrote
|
|
59
|
+
* PROJECT-DEFINITION with no lock at all. `parity-scenarios.ts` is the fixture
|
|
60
|
+
* harness for the same protocol and is counted separately below.
|
|
61
|
+
*/
|
|
62
|
+
export declare const PRODUCTION_MUTATION_INVENTORY: Readonly<Record<string, number>>;
|
|
63
|
+
/**
|
|
64
|
+
* The #3796 census, split by provenance so a drift failure says which family
|
|
65
|
+
* moved. 18 core call expressions across 13 files already took the shared lock;
|
|
66
|
+
* the 2 `packages/cli` policy writers did not; `parity-scenarios.ts` is the
|
|
67
|
+
* fixture harness for the same protocol.
|
|
68
|
+
*/
|
|
69
|
+
export declare const PREVIOUSLY_LOCKED_CORE_CALL_EXPRESSIONS = 18;
|
|
70
|
+
export declare const PREVIOUSLY_LOCKED_CORE_FILES = 13;
|
|
71
|
+
export declare const PREVIOUSLY_UNLOCKED_CLI_WRITERS = 2;
|
|
72
|
+
export declare const PARITY_HARNESS_CALL_EXPRESSIONS = 1;
|
|
73
|
+
export interface MutationBoundaryFinding {
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly line: number;
|
|
76
|
+
readonly rule: string;
|
|
77
|
+
readonly text: string;
|
|
78
|
+
}
|
|
79
|
+
export interface MutationBoundaryScan {
|
|
80
|
+
readonly findings: readonly MutationBoundaryFinding[];
|
|
81
|
+
/** Mutation call expressions per production file, posix-relative. */
|
|
82
|
+
readonly inventory: Readonly<Record<string, number>>;
|
|
83
|
+
readonly filesScanned: number;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Scan production TypeScript for mutation-identity bypasses and build the
|
|
87
|
+
* mutation call-expression inventory. The scan reads the filesystem, not the git
|
|
88
|
+
* index, so an unstaged or brand-new bypass is still caught.
|
|
89
|
+
*/
|
|
90
|
+
export declare function scanProjectDefinitionMutationBoundary(projectRoot: string): MutationBoundaryScan;
|
|
91
|
+
/** Render findings as a stable, reviewable report. */
|
|
92
|
+
export declare function formatMutationBoundaryFindings(findings: readonly MutationBoundaryFinding[]): string;
|
|
93
|
+
export interface MutationBoundaryVerdict {
|
|
94
|
+
readonly ok: boolean;
|
|
95
|
+
readonly errors: readonly string[];
|
|
96
|
+
readonly scan: MutationBoundaryScan;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The fail-closed verdict: no bypass, and the mutation inventory still matches
|
|
100
|
+
* the recorded census. Adding or removing a mutation site is a deliberate edit
|
|
101
|
+
* to {@link PRODUCTION_MUTATION_INVENTORY} and the census constants above.
|
|
102
|
+
*/
|
|
103
|
+
export declare function evaluateProjectDefinitionMutationBoundary(projectRoot: string): MutationBoundaryVerdict;
|
|
104
|
+
//# sourceMappingURL=project-definition-mutation-boundary.d.ts.map
|