@loucompanion/forge-bridge 0.1.4-dev.04a1e5b9e484 → 0.1.4-dev.1ec1b222a073
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/README.md +3 -3
- package/dist/bridge/bridge.service.d.ts +14 -1
- package/dist/bridge/bridge.service.js +80 -9
- package/dist/bridge/bridge.types.d.ts +11 -0
- package/dist/bridge/dispatch-result-outbox.d.ts +11 -1
- package/dist/bridge/dispatch-result-outbox.js +31 -6
- package/dist/bridge/runner-host-capabilities.d.ts +2 -0
- package/dist/bridge/runner-host-capabilities.js +4 -0
- package/dist/bridge/test-postgres-capability.d.ts +14 -0
- package/dist/bridge/test-postgres-capability.js +120 -0
- package/dist/cli/cli.help.js +2 -2
- package/dist/cli/cli.service.js +3 -1
- package/dist/runtime/attempt-process-supervisor.d.ts +19 -0
- package/dist/runtime/attempt-process-supervisor.js +50 -0
- package/dist/runtime/host-database-capability-boundary.d.ts +1 -1
- package/dist/runtime/host-database-capability-boundary.js +1 -0
- package/dist/runtime/host-facts.d.ts +35 -0
- package/dist/runtime/host-facts.js +95 -0
- package/dist/runtime/host-load-admission.d.ts +52 -0
- package/dist/runtime/host-load-admission.js +84 -0
- package/dist/runtime/host-load-child-environment.d.ts +22 -0
- package/dist/runtime/host-load-child-environment.js +65 -0
- package/dist/runtime/host-load-forge-cgroups.d.ts +49 -0
- package/dist/runtime/host-load-forge-cgroups.js +140 -0
- package/dist/runtime/host-load-governor-config.d.ts +34 -0
- package/dist/runtime/host-load-governor-config.js +46 -0
- package/dist/runtime/host-load-governor.d.ts +172 -0
- package/dist/runtime/host-load-governor.js +519 -0
- package/dist/runtime/host-load-ledger-lock.d.ts +69 -0
- package/dist/runtime/host-load-ledger-lock.js +185 -0
- package/dist/runtime/host-load-sampler.d.ts +126 -0
- package/dist/runtime/host-load-sampler.js +232 -0
- package/dist/runtime/host-load-step-class.d.ts +68 -0
- package/dist/runtime/host-load-step-class.js +106 -0
- package/dist/runtime/host-load-step-reaper.d.ts +27 -0
- package/dist/runtime/host-load-step-reaper.js +95 -0
- package/dist/runtime/host-load-step-run.d.ts +73 -0
- package/dist/runtime/host-load-step-run.js +102 -0
- package/dist/runtime/host-load-token-ledger.d.ts +174 -0
- package/dist/runtime/host-load-token-ledger.js +421 -0
- package/dist/runtime/host-pressure-stall.d.ts +61 -0
- package/dist/runtime/host-pressure-stall.js +168 -0
- package/dist/runtime/host-runtime-contract.d.ts +4 -0
- package/dist/runtime/host-runtime-contract.js +6 -1
- package/dist/runtime/host-runtime-lease.d.ts +17 -3
- package/dist/runtime/host-runtime-lease.js +138 -13
- package/dist/runtime/host-runtime-promotion.js +12 -0
- package/dist/runtime/host-runtime-requirements-check.d.ts +17 -0
- package/dist/runtime/host-runtime-requirements-check.js +29 -0
- package/dist/runtime/host-runtime-requirements.d.ts +36 -0
- package/dist/runtime/host-runtime-requirements.js +117 -0
- package/dist/runtime/managed-command-teardown.d.ts +62 -0
- package/dist/runtime/managed-command-teardown.js +607 -0
- package/dist/runtime/playwright-browser-cache.d.ts +39 -0
- package/dist/runtime/playwright-browser-cache.js +227 -0
- package/dist/runtime/playwright-host-runtime-adapter.d.ts +11 -0
- package/dist/runtime/playwright-host-runtime-adapter.js +48 -54
- package/dist/sandbox/host-capacity-broker.d.ts +107 -0
- package/dist/sandbox/host-capacity-broker.js +315 -0
- package/dist/sandbox/runtime.d.ts +10 -1
- package/dist/sandbox/runtime.js +45 -2
- package/dist/sandbox/sandbox-cgroups.d.ts +14 -0
- package/dist/sandbox/sandbox-cgroups.js +42 -0
- package/dist/session/managed-attempt-tools.d.ts +27 -0
- package/dist/session/managed-attempt-tools.js +356 -40
- package/dist/session/managed-build-coordinator.d.ts +1 -1
- package/dist/session/managed-build-coordinator.js +4 -1
- package/dist/session/managed-command-host-load.d.ts +45 -0
- package/dist/session/managed-command-host-load.js +82 -0
- package/dist/session/mcp-argument-coercion.d.ts +23 -0
- package/dist/session/mcp-argument-coercion.js +121 -0
- package/dist/session/phase-completion.artifacts.d.ts +7 -0
- package/dist/session/phase-completion.artifacts.js +98 -25
- package/dist/session/phase-completion.command-validation.d.ts +7 -0
- package/dist/session/phase-completion.command-validation.js +77 -0
- package/dist/session/phase-completion.d.ts +4 -0
- package/dist/session/phase-completion.helpers.js +13 -12
- package/dist/session/phase-completion.js +4 -0
- package/dist/session/phase-completion.prompts.js +6 -1
- package/dist/session/phase-completion.runtime.d.ts +5 -3
- package/dist/session/phase-completion.runtime.js +70 -35
- package/dist/session/phase-completion.schema-parts.d.ts +19 -0
- package/dist/session/phase-completion.schema-parts.js +188 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -3
- package/dist/session/phase-completion.schemas.js +184 -209
- package/dist/session/phase-completion.validation.d.ts +2 -3
- package/dist/session/phase-completion.validation.js +46 -92
- package/dist/session/pre-publication-host-load.d.ts +27 -0
- package/dist/session/pre-publication-host-load.js +111 -0
- package/dist/session/pre-publication-process.d.ts +23 -0
- package/dist/session/pre-publication-process.js +109 -0
- package/dist/session/pre-publication-skipped-tests.d.ts +21 -0
- package/dist/session/pre-publication-skipped-tests.js +109 -0
- package/dist/session/pre-publication-step-execution.d.ts +11 -0
- package/dist/session/pre-publication-step-execution.js +49 -0
- package/dist/session/pre-publication-validation.d.ts +9 -9
- package/dist/session/pre-publication-validation.js +48 -112
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +2 -1
- package/dist/session/provider-cli/provider-cli.artifacts.js +21 -15
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +89 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +310 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +37 -1
- package/dist/session/provider-cli/provider-cli.process.js +299 -25
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +5 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +16 -1
- package/dist/session/provider-cli/provider-cli.service.js +141 -33
- package/dist/session/provider-cli/provider-cli.types.d.ts +4 -0
- package/dist/session/provider-cli/provider-in-flight-work.d.ts +6 -0
- package/dist/session/provider-cli/provider-in-flight-work.js +47 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +6 -0
- package/dist/session/provider-cli/provider-output-state.js +9 -0
- package/dist/session/provider-cli/provider-usage.d.ts +2 -1
- package/dist/session/publishable-worktree-changes.d.ts +54 -0
- package/dist/session/publishable-worktree-changes.js +193 -0
- package/dist/session/sandbox-host-capacity-gate.d.ts +30 -0
- package/dist/session/sandbox-host-capacity-gate.js +229 -0
- package/dist/session/session.base.d.ts +3 -0
- package/dist/session/session.service.d.ts +2 -0
- package/dist/session/session.service.js +21 -4
- package/dist/session/session.types.d.ts +3 -0
- package/dist/session/session.types.js +14 -2
- package/dist/shared/process/host-process-supervisor.d.ts +1 -0
- package/dist/shared/process/host-process-supervisor.js +1 -1
- package/dist/shared/process/process-tree.d.ts +52 -0
- package/dist/shared/process/process-tree.js +144 -0
- package/dist/shared/process/process.d.ts +67 -0
- package/dist/shared/process/process.js +213 -11
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/dependency-warmer.d.ts +25 -0
- package/dist/worktree/dependency-warmer.js +120 -10
- package/dist/worktree/worktree.service.d.ts +6 -1
- package/dist/worktree/worktree.service.js +14 -2
- package/dist/worktree/worktree.types.d.ts +7 -0
- package/package.json +1 -1
|
@@ -9,6 +9,9 @@ import { NodeProcessRunner } from "../shared/process/process.js";
|
|
|
9
9
|
import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
|
|
10
10
|
import { isSubPath } from "../shared/path/path.js";
|
|
11
11
|
import { defaultWorktreeCoordinatorStateRoot } from "./worktree-paths.js";
|
|
12
|
+
import { dependencyInstallStepClass } from "../runtime/host-load-step-class.js";
|
|
13
|
+
import { runHostGovernedStep } from "../runtime/host-load-step-run.js";
|
|
14
|
+
import { captureHostProcessIdentity } from "../shared/process/host-process-supervisor.js";
|
|
12
15
|
const SKIP_DIR_NAMES = new Set([
|
|
13
16
|
".git",
|
|
14
17
|
"node_modules",
|
|
@@ -36,6 +39,7 @@ const dependencyPreparationCoordinator = new RepositoryCoordinatorLock(defaultWo
|
|
|
36
39
|
export async function detectWarmPaths(repoRoot, warmPathOverrides = []) {
|
|
37
40
|
const entries = new Map();
|
|
38
41
|
await collectDetectedPaths(repoRoot, repoRoot, entries, 0);
|
|
42
|
+
await collectSolutionProjectRestores(repoRoot, entries);
|
|
39
43
|
for (const override of warmPathOverrides) {
|
|
40
44
|
const normalized = normalizeRelativePath(override);
|
|
41
45
|
if (!normalized) {
|
|
@@ -77,7 +81,7 @@ export async function warmWorktreeDependencies(request, executor = defaultComman
|
|
|
77
81
|
continue;
|
|
78
82
|
}
|
|
79
83
|
installedNodeRoots.add(packageKey);
|
|
80
|
-
const preparation = await ensureInstallFallback({ ...entry, packageRoot: installPackageRoot }, worktreePath, "Managed worktrees require isolated Node dependencies.", executor, request.preparationPolicy);
|
|
84
|
+
const preparation = await ensureInstallFallback({ ...entry, packageRoot: installPackageRoot }, worktreePath, "Managed worktrees require isolated Node dependencies.", executor, request.preparationPolicy, request.hostLoad, request.signal);
|
|
81
85
|
receipts.push(preparation.receipt);
|
|
82
86
|
if (preparation.install)
|
|
83
87
|
fallbacks.push(preparation.install);
|
|
@@ -92,7 +96,7 @@ export async function warmWorktreeDependencies(request, executor = defaultComman
|
|
|
92
96
|
continue;
|
|
93
97
|
}
|
|
94
98
|
restoredDotNetRoots.add(packageKey);
|
|
95
|
-
const preparation = await ensureInstallFallback(entry, worktreePath, "Managed worktrees require isolated .NET build outputs.", executor, request.preparationPolicy);
|
|
99
|
+
const preparation = await ensureInstallFallback(entry, worktreePath, "Managed worktrees require isolated .NET build outputs.", executor, request.preparationPolicy, request.hostLoad, request.signal);
|
|
96
100
|
receipts.push(preparation.receipt);
|
|
97
101
|
if (preparation.install)
|
|
98
102
|
fallbacks.push(preparation.install);
|
|
@@ -101,7 +105,7 @@ export async function warmWorktreeDependencies(request, executor = defaultComman
|
|
|
101
105
|
const sourceExists = await directoryExists(sourcePath);
|
|
102
106
|
const fallbackReason = await resolveFallbackReason(entry, baseCheckoutPath, worktreePath, sourceExists);
|
|
103
107
|
if (fallbackReason) {
|
|
104
|
-
const preparation = await ensureInstallFallback(entry, worktreePath, fallbackReason, executor, request.preparationPolicy);
|
|
108
|
+
const preparation = await ensureInstallFallback(entry, worktreePath, fallbackReason, executor, request.preparationPolicy, request.hostLoad, request.signal);
|
|
105
109
|
receipts.push(preparation.receipt);
|
|
106
110
|
if (preparation.install)
|
|
107
111
|
fallbacks.push(preparation.install);
|
|
@@ -241,7 +245,7 @@ export async function lockfilesDiffer(baseCheckoutPath, worktreePath, packageRoo
|
|
|
241
245
|
}
|
|
242
246
|
return false;
|
|
243
247
|
}
|
|
244
|
-
async function ensureInstallFallback(entry, worktreePath, reason, executor, policy) {
|
|
248
|
+
async function ensureInstallFallback(entry, worktreePath, reason, executor, policy, hostLoad, signal) {
|
|
245
249
|
const startedAt = performance.now();
|
|
246
250
|
const cwd = path.resolve(worktreePath, entry.packageRoot === "." ? "" : entry.packageRoot);
|
|
247
251
|
assertWithinRoot(path.resolve(worktreePath), cwd, "Dependency package root");
|
|
@@ -270,7 +274,32 @@ async function ensureInstallFallback(entry, worktreePath, reason, executor, poli
|
|
|
270
274
|
},
|
|
271
275
|
};
|
|
272
276
|
}
|
|
273
|
-
|
|
277
|
+
// Inside the per-root lock, and only on a real install: a verified receipt never queues.
|
|
278
|
+
const install = await runHostGovernedStep(hostLoad?.gate, {
|
|
279
|
+
classification: dependencyInstallStepClass,
|
|
280
|
+
label: `${command} (${entry.packageRoot})`,
|
|
281
|
+
dispatchAttemptId: hostLoad?.dispatchAttemptId ?? null,
|
|
282
|
+
priority: hostLoad?.priority ?? "foreground",
|
|
283
|
+
// Attempt cancellation ends the wait for capacity too.
|
|
284
|
+
signal,
|
|
285
|
+
}, async (_waitMs, hostLoadControl) => {
|
|
286
|
+
// The install stops when the attempt is cancelled, its token is lost, or its
|
|
287
|
+
// process group cannot be recorded on the token. The runner settles only once
|
|
288
|
+
// the whole group is gone, so the token is never returned while it still runs.
|
|
289
|
+
const unrecorded = new AbortController();
|
|
290
|
+
const stop = [signal, hostLoadControl.fenced, unrecorded.signal].filter((value) => value !== undefined);
|
|
291
|
+
return await runInstallFallback(entry, worktreePath, reason, executor, {
|
|
292
|
+
signal: AbortSignal.any(stop),
|
|
293
|
+
processGroup: true,
|
|
294
|
+
onSpawn: hostLoadControl.attachProcess
|
|
295
|
+
? pid => void hostLoadControl.attachProcess({
|
|
296
|
+
rootPid: pid,
|
|
297
|
+
rootIdentity: captureHostProcessIdentity(pid),
|
|
298
|
+
processGroup: process.platform !== "win32",
|
|
299
|
+
}).catch((error) => unrecorded.abort(error))
|
|
300
|
+
: undefined,
|
|
301
|
+
});
|
|
302
|
+
});
|
|
274
303
|
// npm is allowed to omit node_modules when the package graph is empty. Keep
|
|
275
304
|
// an isolated, ignored output directory so the durable receipt still has a
|
|
276
305
|
// concrete marker whose removal invalidates reuse.
|
|
@@ -448,7 +477,7 @@ async function persistDependencyPreparationReceipt(receiptPath, receipt) {
|
|
|
448
477
|
function sha256Text(value) {
|
|
449
478
|
return createHash("sha256").update(value).digest("hex");
|
|
450
479
|
}
|
|
451
|
-
async function runInstallFallback(entry, worktreePath, reason, executor) {
|
|
480
|
+
async function runInstallFallback(entry, worktreePath, reason, executor, control = {}) {
|
|
452
481
|
assertHostDatabaseCapabilityBoundary();
|
|
453
482
|
const cwd = path.join(worktreePath, entry.packageRoot === "." ? "" : entry.packageRoot);
|
|
454
483
|
if (entry.ecosystem === "node") {
|
|
@@ -462,6 +491,7 @@ async function runInstallFallback(entry, worktreePath, reason, executor) {
|
|
|
462
491
|
requiredPathDirectories: launch.requiredPathDirectories,
|
|
463
492
|
}),
|
|
464
493
|
windowsVerbatimArguments: launch.windowsVerbatimArguments,
|
|
494
|
+
...control,
|
|
465
495
|
});
|
|
466
496
|
return { ecosystem: entry.ecosystem, packageRoot: entry.packageRoot, reason, command: `pnpm ${args.join(" ")}` };
|
|
467
497
|
}
|
|
@@ -474,16 +504,17 @@ async function runInstallFallback(entry, worktreePath, reason, executor) {
|
|
|
474
504
|
requiredPathDirectories: launch.requiredPathDirectories,
|
|
475
505
|
}),
|
|
476
506
|
windowsVerbatimArguments: launch.windowsVerbatimArguments,
|
|
507
|
+
...control,
|
|
477
508
|
});
|
|
478
509
|
return { ecosystem: entry.ecosystem, packageRoot: entry.packageRoot, reason, command: `npm ${args.join(" ")}` };
|
|
479
510
|
}
|
|
480
511
|
if (entry.ecosystem === "python") {
|
|
481
512
|
const environment = unattendedDependencyEnvironment();
|
|
482
|
-
await executor.run(cwd, "python", ["-m", "venv", ".venv"], { env: environment });
|
|
513
|
+
await executor.run(cwd, "python", ["-m", "venv", ".venv"], { env: environment, ...control });
|
|
483
514
|
const requirements = path.join(cwd, "requirements.txt");
|
|
484
515
|
if (await pathExists(requirements)) {
|
|
485
516
|
const pip = process.platform === "win32" ? path.join(".venv", "Scripts", "pip") : path.join(".venv", "bin", "pip");
|
|
486
|
-
await executor.run(cwd, pip, ["install", "-r", "requirements.txt"], { env: environment });
|
|
517
|
+
await executor.run(cwd, pip, ["install", "-r", "requirements.txt"], { env: environment, ...control });
|
|
487
518
|
return {
|
|
488
519
|
ecosystem: entry.ecosystem,
|
|
489
520
|
packageRoot: entry.packageRoot,
|
|
@@ -498,7 +529,7 @@ async function runInstallFallback(entry, worktreePath, reason, executor) {
|
|
|
498
529
|
command: "python -m venv .venv"
|
|
499
530
|
};
|
|
500
531
|
}
|
|
501
|
-
await executor.run(cwd, "dotnet", ["restore"], { env: unattendedDependencyEnvironment() });
|
|
532
|
+
await executor.run(cwd, "dotnet", ["restore"], { env: unattendedDependencyEnvironment(), ...control });
|
|
502
533
|
return {
|
|
503
534
|
ecosystem: entry.ecosystem,
|
|
504
535
|
packageRoot: entry.packageRoot,
|
|
@@ -539,6 +570,79 @@ async function hasPythonMarker(dir) {
|
|
|
539
570
|
return (await pathExists(path.join(dir, "pyproject.toml")))
|
|
540
571
|
|| (await pathExists(path.join(dir, "requirements.txt")));
|
|
541
572
|
}
|
|
573
|
+
const solutionProjectPattern = /^Project\("\{[0-9A-Fa-f-]+\}"\)\s*=\s*"[^"]*"\s*,\s*"([^"]+\.(?:cs|fs|vb)proj)"/gimu;
|
|
574
|
+
const slnxProjectPattern = /<Project\b[^>]*\bPath\s*=\s*"([^"]+\.(?:cs|fs|vb)proj)"/giu;
|
|
575
|
+
const projectFilePattern = /\.(?:cs|fs|vb)proj$/iu;
|
|
576
|
+
const solutionFilePattern = /\.(?:sln|slnx|slnf)$/iu;
|
|
577
|
+
/**
|
|
578
|
+
* A worktree built from a never-built base checkout (a fresh runner clone has no bin/ or obj/)
|
|
579
|
+
* still needs its .NET projects restored, or the --no-restore runtime build fails with NETSDK1004.
|
|
580
|
+
* Restore exactly the projects the root solution(s) (.sln, .slnx, .slnf) list, or a lone root
|
|
581
|
+
* project when there is no solution. Other projects (fixtures, samples) keep the base-checkout
|
|
582
|
+
* output heuristic above.
|
|
583
|
+
*/
|
|
584
|
+
async function collectSolutionProjectRestores(repoRoot, entries) {
|
|
585
|
+
const rootNames = await fs.readdir(repoRoot).catch(() => []);
|
|
586
|
+
const solutions = rootNames.filter((name) => solutionFilePattern.test(name));
|
|
587
|
+
if (solutions.length === 0) {
|
|
588
|
+
const rootProjects = rootNames.filter((name) => name.toLowerCase().endsWith(".csproj"));
|
|
589
|
+
if (rootProjects.length === 1) {
|
|
590
|
+
addEntry(entries, repoRoot, "", "obj", "dotnet", "obj");
|
|
591
|
+
}
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
for (const solution of solutions) {
|
|
595
|
+
for (const listed of await readSolutionProjectPaths(repoRoot, solution)) {
|
|
596
|
+
const projectPath = path.posix.normalize(normalizeRelativePath(listed));
|
|
597
|
+
if (!projectPath || projectPath === ".." || projectPath.startsWith("../") || path.posix.isAbsolute(projectPath)) {
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
const absoluteProject = path.resolve(repoRoot, ...projectPath.split("/"));
|
|
601
|
+
if (!isSubPath(repoRoot, absoluteProject) || !(await pathExists(absoluteProject))) {
|
|
602
|
+
continue;
|
|
603
|
+
}
|
|
604
|
+
const projectDir = path.posix.dirname(projectPath);
|
|
605
|
+
// The fallback runs a bare `dotnet restore` in the project's directory. Beside the solution,
|
|
606
|
+
// or next to another project file, that restore is ambiguous (MSB1011); leave those layouts
|
|
607
|
+
// to the base-checkout output heuristic.
|
|
608
|
+
if (projectDir === "." || (await countProjectFiles(path.dirname(absoluteProject))) !== 1) {
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
addEntry(entries, repoRoot, projectDir, "obj", "dotnet", joinRelative(projectDir, "obj"));
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
/** Project paths a root solution lists, relative to the repo root (forward slashes). */
|
|
616
|
+
async function readSolutionProjectPaths(repoRoot, solution) {
|
|
617
|
+
const text = await fs.readFile(path.join(repoRoot, solution), "utf8").catch(() => "");
|
|
618
|
+
const lower = solution.toLowerCase();
|
|
619
|
+
if (lower.endsWith(".sln")) {
|
|
620
|
+
return [...text.matchAll(solutionProjectPattern)].map((match) => match[1].replace(/\\/g, "/"));
|
|
621
|
+
}
|
|
622
|
+
if (lower.endsWith(".slnx")) {
|
|
623
|
+
return [...text.matchAll(slnxProjectPattern)].map((match) => match[1].replace(/\\/g, "/"));
|
|
624
|
+
}
|
|
625
|
+
// .slnf: {"solution": {"path": "<solution>", "projects": [...]}}, projects relative to that solution.
|
|
626
|
+
let filter;
|
|
627
|
+
try {
|
|
628
|
+
filter = JSON.parse(text.replace(/^\uFEFF/u, ""));
|
|
629
|
+
}
|
|
630
|
+
catch {
|
|
631
|
+
return [];
|
|
632
|
+
}
|
|
633
|
+
const body = filter?.solution;
|
|
634
|
+
if (!body || typeof body.path !== "string" || !Array.isArray(body.projects)) {
|
|
635
|
+
return [];
|
|
636
|
+
}
|
|
637
|
+
const solutionDir = path.posix.dirname(body.path.replace(/\\/g, "/"));
|
|
638
|
+
return body.projects
|
|
639
|
+
.filter((project) => typeof project === "string" && projectFilePattern.test(project))
|
|
640
|
+
.map((project) => path.posix.join(solutionDir, project.replace(/\\/g, "/")));
|
|
641
|
+
}
|
|
642
|
+
async function countProjectFiles(dir) {
|
|
643
|
+
const names = await fs.readdir(dir).catch(() => []);
|
|
644
|
+
return names.filter((name) => projectFilePattern.test(name)).length;
|
|
645
|
+
}
|
|
542
646
|
async function hasDotNetMarker(dir) {
|
|
543
647
|
const entries = await fs.readdir(dir).catch(() => []);
|
|
544
648
|
return entries.some((name) => name.endsWith(".csproj") || name.endsWith(".sln"));
|
|
@@ -886,7 +990,8 @@ function defaultNpmCliCandidates(execPath, homeDir) {
|
|
|
886
990
|
candidates.push("/usr/bin/npm", "/usr/local/bin/npm", path.join(homeDir, ".npm-global", "bin", "npm"), path.join(homeDir, ".npm-global", "lib", "node_modules", "npm", "bin", "npm-cli.js"));
|
|
887
991
|
return candidates;
|
|
888
992
|
}
|
|
889
|
-
|
|
993
|
+
/** Runs dependency installs; exported for tests. */
|
|
994
|
+
export const defaultCommandExecutor = {
|
|
890
995
|
async run(cwd, command, args, options) {
|
|
891
996
|
const result = await defaultProcessRunner.run({
|
|
892
997
|
command,
|
|
@@ -894,6 +999,11 @@ const defaultCommandExecutor = {
|
|
|
894
999
|
args,
|
|
895
1000
|
env: options?.env,
|
|
896
1001
|
windowsVerbatimArguments: options?.windowsVerbatimArguments,
|
|
1002
|
+
signal: options?.signal,
|
|
1003
|
+
onSpawn: options?.onSpawn,
|
|
1004
|
+
processGroup: options?.processGroup,
|
|
1005
|
+
// Only a failure excerpt is ever reported; a noisy install keeps its last 1 MiB.
|
|
1006
|
+
maxOutputChars: 1024 * 1024,
|
|
897
1007
|
});
|
|
898
1008
|
if (result.exitCode !== 0) {
|
|
899
1009
|
const output = formatCommandFailureOutput(result.stdout, result.stderr);
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { GitClient } from "../shared/git/git.js";
|
|
2
|
+
import type { HostLoadStepGate } from "../runtime/host-load-governor.js";
|
|
2
3
|
import type { WorktreeLifecycleCoordinator, WorktreeService } from "./worktree.base.js";
|
|
3
4
|
import type { WorktreeHandle, WorktreePrepareRequest } from "./worktree.types.js";
|
|
4
5
|
export declare class GitWorktreeService implements WorktreeService {
|
|
5
6
|
private readonly git;
|
|
6
7
|
private readonly coordinator;
|
|
7
|
-
|
|
8
|
+
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
9
|
+
private readonly hostLoadGate?;
|
|
10
|
+
constructor(git?: GitClient, coordinator?: WorktreeLifecycleCoordinator,
|
|
11
|
+
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
12
|
+
hostLoadGate?: HostLoadStepGate | undefined);
|
|
8
13
|
prepare(request: WorktreePrepareRequest): Promise<WorktreeHandle>;
|
|
9
14
|
private trackedForgePaths;
|
|
10
15
|
private registeredManagedWorktreePath;
|
|
@@ -12,9 +12,13 @@ import { defaultWorktreeCoordinatorStateRoot, managedRepoRoot, resolveManagedWor
|
|
|
12
12
|
export class GitWorktreeService {
|
|
13
13
|
git;
|
|
14
14
|
coordinator;
|
|
15
|
-
|
|
15
|
+
hostLoadGate;
|
|
16
|
+
constructor(git = new GitClient(), coordinator = new RepositoryCoordinatorLock(defaultWorktreeCoordinatorStateRoot()),
|
|
17
|
+
/** Gates dependency install fallbacks; inert unless the governor is on. */
|
|
18
|
+
hostLoadGate) {
|
|
16
19
|
this.git = git;
|
|
17
20
|
this.coordinator = coordinator;
|
|
21
|
+
this.hostLoadGate = hostLoadGate;
|
|
18
22
|
}
|
|
19
23
|
async prepare(request) {
|
|
20
24
|
const allowedRoot = await ensureDirectory(request.allowedRepoRoot);
|
|
@@ -102,7 +106,15 @@ export class GitWorktreeService {
|
|
|
102
106
|
baseCheckoutPath: repoPath,
|
|
103
107
|
worktreePath: resolvedWorktreePath,
|
|
104
108
|
allowedRoot,
|
|
105
|
-
warmPathOverrides: request.warmPathOverrides
|
|
109
|
+
warmPathOverrides: request.warmPathOverrides,
|
|
110
|
+
hostLoad: this.hostLoadGate?.enabled
|
|
111
|
+
? {
|
|
112
|
+
gate: this.hostLoadGate,
|
|
113
|
+
dispatchAttemptId: request.hostLoadOwner?.dispatchAttemptId ?? null,
|
|
114
|
+
priority: request.hostLoadOwner?.priority ?? "foreground",
|
|
115
|
+
}
|
|
116
|
+
: undefined,
|
|
117
|
+
signal: request.signal,
|
|
106
118
|
})
|
|
107
119
|
: undefined;
|
|
108
120
|
return {
|
|
@@ -21,6 +21,13 @@ export interface WorktreePrepareRequest {
|
|
|
21
21
|
readonly warmPathOverrides?: readonly string[];
|
|
22
22
|
readonly applicationRuntimeRequired?: boolean;
|
|
23
23
|
readonly preserveExistingState?: boolean;
|
|
24
|
+
/** The attempt dependency installs reserve host capacity for (decision 0013). */
|
|
25
|
+
readonly hostLoadOwner?: {
|
|
26
|
+
readonly dispatchAttemptId: string | null;
|
|
27
|
+
readonly priority: "foreground" | "background";
|
|
28
|
+
};
|
|
29
|
+
/** The attempt's cancellation: queued installs stop waiting and running ones are stopped. */
|
|
30
|
+
readonly signal?: AbortSignal;
|
|
24
31
|
}
|
|
25
32
|
export interface WorktreeHandle {
|
|
26
33
|
readonly repoPath: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.4-dev.
|
|
3
|
+
"version": "0.1.4-dev.1ec1b222a073",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|