@loucompanion/forge-bridge 0.1.3-dev.b6be5e7f9668 → 0.1.3-dev.bf78fdcaa623
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 +44 -0
- package/dist/bridge/bridge.base.d.ts +5 -1
- package/dist/bridge/bridge.service.d.ts +36 -2
- package/dist/bridge/bridge.service.js +588 -18
- package/dist/bridge/bridge.types.d.ts +114 -1
- package/dist/cli/cli.help.d.ts +2 -0
- package/dist/cli/cli.help.js +183 -0
- package/dist/cli/cli.service.d.ts +12 -0
- package/dist/cli/cli.service.js +176 -184
- package/dist/cli/local-config.d.ts +2 -0
- package/dist/cli/local-config.js +6 -2
- package/dist/sandbox/command-runner.d.ts +4 -0
- package/dist/sandbox/command-runner.js +47 -0
- package/dist/sandbox/contract.d.ts +5 -0
- package/dist/sandbox/contract.js +276 -0
- package/dist/sandbox/event-budget.d.ts +11 -0
- package/dist/sandbox/event-budget.js +27 -0
- package/dist/sandbox/image-policy.d.ts +33 -0
- package/dist/sandbox/image-policy.js +245 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +5 -0
- package/dist/sandbox/lease-watchdog.d.ts +18 -0
- package/dist/sandbox/lease-watchdog.js +67 -0
- package/dist/sandbox/preflight.d.ts +36 -0
- package/dist/sandbox/preflight.js +239 -0
- package/dist/sandbox/process.d.ts +20 -0
- package/dist/sandbox/process.js +124 -0
- package/dist/sandbox/provider-auth/codex.d.ts +26 -0
- package/dist/sandbox/provider-auth/codex.js +212 -0
- package/dist/sandbox/repository-lock.d.ts +5 -0
- package/dist/sandbox/repository-lock.js +83 -0
- package/dist/sandbox/runtime.d.ts +216 -0
- package/dist/sandbox/runtime.js +1658 -0
- package/dist/sandbox/sandbox.types.d.ts +83 -0
- package/dist/sandbox/sandbox.types.js +1 -0
- package/dist/sandbox/worker-supervisor.d.ts +13 -0
- package/dist/sandbox/worker-supervisor.js +36 -0
- package/dist/sandbox/worker.d.ts +1 -0
- package/dist/sandbox/worker.js +228 -0
- package/dist/sandbox/workspace.service.d.ts +12 -0
- package/dist/sandbox/workspace.service.js +49 -0
- package/dist/session/phase-completion.artifacts.d.ts +10 -0
- package/dist/session/phase-completion.artifacts.js +620 -0
- package/dist/session/phase-completion.d.ts +32 -44
- package/dist/session/phase-completion.helpers.d.ts +112 -0
- package/dist/session/phase-completion.helpers.js +660 -0
- package/dist/session/phase-completion.js +28 -3485
- package/dist/session/phase-completion.prompts.d.ts +14 -0
- package/dist/session/phase-completion.prompts.js +220 -0
- package/dist/session/phase-completion.runtime.d.ts +36 -0
- package/dist/session/phase-completion.runtime.js +609 -0
- package/dist/session/phase-completion.schemas.d.ts +3 -0
- package/dist/session/phase-completion.schemas.js +707 -0
- package/dist/session/phase-completion.validation.d.ts +34 -0
- package/dist/session/phase-completion.validation.js +724 -0
- package/dist/session/provider-cli/provider-cli.artifacts.d.ts +93 -0
- package/dist/session/provider-cli/provider-cli.artifacts.js +754 -0
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.d.ts +12 -0
- package/dist/session/provider-cli/provider-cli.deterministic-payloads.js +279 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +14 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +329 -0
- package/dist/session/provider-cli/provider-cli.process.d.ts +32 -0
- package/dist/session/provider-cli/provider-cli.process.js +287 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +44 -0
- package/dist/session/provider-cli/provider-cli.prompts.js +528 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.d.ts +11 -0
- package/dist/session/provider-cli/provider-cli.qa-sidecars.js +65 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +9 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +40 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +9 -53
- package/dist/session/provider-cli/provider-cli.service.js +161 -2527
- package/dist/session/provider-cli/provider-cli.types.d.ts +1 -0
- package/dist/session/provider-cli/provider-output-state.d.ts +20 -0
- package/dist/session/provider-cli/provider-output-state.js +445 -0
- package/dist/session/session.service.js +34 -24
- package/dist/session/session.types.d.ts +106 -1
- package/dist/session/session.types.js +248 -3
- package/dist/shared/process/windows-launch.d.ts +8 -0
- package/dist/shared/process/windows-launch.js +41 -0
- package/dist/shared/provider-capabilities.d.ts +1 -0
- package/dist/shared/provider-capabilities.js +3 -0
- package/dist/shared/redaction/redaction.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +39 -6
- package/dist/worktree/dependency-warmer.d.ts +11 -0
- package/dist/worktree/dependency-warmer.js +45 -1
- package/dist/worktree/worktree.service.d.ts +2 -1
- package/dist/worktree/worktree.service.js +32 -12
- package/package.json +4 -2
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
1
2
|
import fs from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
2
4
|
import path from "node:path";
|
|
3
5
|
import { NodeProcessRunner } from "../shared/process/process.js";
|
|
6
|
+
import { buildWindowsCmdLaunch } from "../shared/process/windows-launch.js";
|
|
4
7
|
import { isSubPath } from "../shared/path/path.js";
|
|
5
8
|
const SKIP_DIR_NAMES = new Set([
|
|
6
9
|
".git",
|
|
@@ -184,7 +187,8 @@ async function runInstallFallback(entry, worktreePath, reason, executor) {
|
|
|
184
187
|
if (entry.ecosystem === "node") {
|
|
185
188
|
const lockPath = path.join(cwd, "package-lock.json");
|
|
186
189
|
const args = (await pathExists(lockPath)) ? ["ci"] : ["install"];
|
|
187
|
-
|
|
190
|
+
const launch = resolveNpmLaunch(args);
|
|
191
|
+
await executor.run(cwd, launch.command, launch.args);
|
|
188
192
|
return { ecosystem: entry.ecosystem, packageRoot: entry.packageRoot, reason, command: `npm ${args.join(" ")}` };
|
|
189
193
|
}
|
|
190
194
|
if (entry.ecosystem === "python") {
|
|
@@ -286,6 +290,46 @@ async function sha256File(filePath) {
|
|
|
286
290
|
const content = await fs.readFile(filePath);
|
|
287
291
|
return crypto.createHash("sha256").update(content).digest("hex");
|
|
288
292
|
}
|
|
293
|
+
export function resolveNpmLaunch(args, options = {}) {
|
|
294
|
+
const env = options.env ?? process.env;
|
|
295
|
+
const execPath = options.execPath ?? process.execPath;
|
|
296
|
+
const npmExecPath = env.npm_execpath;
|
|
297
|
+
if (npmExecPath) {
|
|
298
|
+
return { command: execPath, args: [npmExecPath, ...args] };
|
|
299
|
+
}
|
|
300
|
+
const platform = options.platform ?? process.platform;
|
|
301
|
+
if (platform === "win32") {
|
|
302
|
+
const comSpec = options.env ? env.ComSpec ?? "cmd.exe" : env.ComSpec;
|
|
303
|
+
return buildWindowsCmdLaunch("npm.cmd", args, comSpec);
|
|
304
|
+
}
|
|
305
|
+
for (const candidate of options.candidates ?? defaultNpmCliCandidates(execPath, options.homeDir ?? os.homedir())) {
|
|
306
|
+
const resolvedCandidate = tryResolveNpmCandidate(candidate);
|
|
307
|
+
if (resolvedCandidate) {
|
|
308
|
+
return { command: execPath, args: [resolvedCandidate, ...args] };
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return { command: "npm", args };
|
|
312
|
+
}
|
|
313
|
+
function tryResolveNpmCandidate(candidate) {
|
|
314
|
+
try {
|
|
315
|
+
if (!existsSync(candidate)) {
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
318
|
+
return realpathSync(candidate);
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function defaultNpmCliCandidates(execPath, homeDir) {
|
|
325
|
+
const candidates = [];
|
|
326
|
+
const execDir = path.dirname(execPath);
|
|
327
|
+
if (path.isAbsolute(execDir)) {
|
|
328
|
+
candidates.push(path.join(execDir, "npm"), path.join(execDir, "npm-cli.js"), path.join(execDir, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js"));
|
|
329
|
+
}
|
|
330
|
+
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"));
|
|
331
|
+
return candidates;
|
|
332
|
+
}
|
|
289
333
|
const defaultCommandExecutor = {
|
|
290
334
|
async run(cwd, command, args) {
|
|
291
335
|
const result = await defaultProcessRunner.run({ command, cwd, args });
|
|
@@ -9,7 +9,8 @@ export declare class GitWorktreeService implements WorktreeService {
|
|
|
9
9
|
private resolveRepoPath;
|
|
10
10
|
private findExistingRepoPath;
|
|
11
11
|
private resolveMatchingRepo;
|
|
12
|
-
private
|
|
12
|
+
private resolveBaseStartPoint;
|
|
13
|
+
private resetWorktreeToBase;
|
|
13
14
|
private gitRefExists;
|
|
14
15
|
private currentBranch;
|
|
15
16
|
private ensureGitIdentity;
|
|
@@ -14,7 +14,7 @@ export class GitWorktreeService {
|
|
|
14
14
|
const baseBranch = normalizeBranchName(request.baseBranch, "develop");
|
|
15
15
|
const repoPath = await this.resolveRepoPath(request.repo, allowedRoot, baseBranch);
|
|
16
16
|
await this.ensureGitIdentity(repoPath);
|
|
17
|
-
await this.
|
|
17
|
+
const baseStartPoint = await this.resolveBaseStartPoint(repoPath, baseBranch);
|
|
18
18
|
const shortId = request.workItem.id.replace(/-/g, "").slice(0, 12);
|
|
19
19
|
const kind = safeSegment(request.workItem.kind, "work-item");
|
|
20
20
|
const fallbackWorktreeKey = `${kind}/${shortId}`;
|
|
@@ -30,7 +30,7 @@ export class GitWorktreeService {
|
|
|
30
30
|
const exists = await directoryExists(worktreePath);
|
|
31
31
|
let resolvedWorktreePath;
|
|
32
32
|
if (!exists) {
|
|
33
|
-
await this.git.run(repoPath, ["worktree", "add", "-B", branchName, worktreePath,
|
|
33
|
+
await this.git.run(repoPath, ["worktree", "add", "-B", branchName, worktreePath, baseStartPoint]);
|
|
34
34
|
resolvedWorktreePath = await resolveExistingDirectoryPath(worktreePath);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
@@ -42,6 +42,9 @@ export class GitWorktreeService {
|
|
|
42
42
|
if (currentBranch !== branchName) {
|
|
43
43
|
throw new Error(`Existing worktree ${resolvedWorktreePath} is on branch '${currentBranch}', expected '${branchName}'.`);
|
|
44
44
|
}
|
|
45
|
+
if (shouldResetExistingWorktree(request)) {
|
|
46
|
+
await this.resetWorktreeToBase(resolvedWorktreePath, baseStartPoint);
|
|
47
|
+
}
|
|
45
48
|
}
|
|
46
49
|
await this.ensureGitIdentity(resolvedWorktreePath);
|
|
47
50
|
await clearRunArtifactRoots(resolvedWorktreePath, request);
|
|
@@ -164,21 +167,27 @@ export class GitWorktreeService {
|
|
|
164
167
|
const resolved = await resolveExistingDirectoryPath(candidate);
|
|
165
168
|
return isSubPath(allowedRoot, resolved) ? resolved : null;
|
|
166
169
|
}
|
|
167
|
-
async
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
170
|
+
async resolveBaseStartPoint(repoPath, baseBranch) {
|
|
171
|
+
const localRef = `refs/heads/${baseBranch}`;
|
|
172
|
+
const remoteRef = `refs/remotes/origin/${baseBranch}`;
|
|
171
173
|
const origin = await this.git.run(repoPath, ["remote", "get-url", "origin"]).catch(() => "");
|
|
172
|
-
if (origin.trim().length
|
|
173
|
-
|
|
174
|
+
if (origin.trim().length > 0) {
|
|
175
|
+
const fetched = await this.git.run(repoPath, ["fetch", "--prune", "origin"])
|
|
176
|
+
.then(() => true)
|
|
177
|
+
.catch(() => false);
|
|
178
|
+
if (fetched && await this.gitRefExists(repoPath, remoteRef)) {
|
|
179
|
+
return remoteRef;
|
|
180
|
+
}
|
|
174
181
|
}
|
|
175
|
-
await this.
|
|
176
|
-
|
|
177
|
-
await this.git.run(repoPath, ["branch", baseBranch, `refs/remotes/origin/${baseBranch}`]);
|
|
178
|
-
return;
|
|
182
|
+
if (await this.gitRefExists(repoPath, localRef)) {
|
|
183
|
+
return localRef;
|
|
179
184
|
}
|
|
180
185
|
throw new Error(`Base branch '${baseBranch}' was not found locally or on origin.`);
|
|
181
186
|
}
|
|
187
|
+
async resetWorktreeToBase(worktreePath, baseStartPoint) {
|
|
188
|
+
await this.git.run(worktreePath, ["reset", "--hard", baseStartPoint]);
|
|
189
|
+
await this.git.run(worktreePath, ["clean", "-fd"]);
|
|
190
|
+
}
|
|
182
191
|
async gitRefExists(repoPath, gitRef) {
|
|
183
192
|
return this.git.run(repoPath, ["show-ref", "--verify", "--quiet", gitRef]).then(() => true).catch(() => false);
|
|
184
193
|
}
|
|
@@ -269,6 +278,17 @@ function normalizeOwnerType(value) {
|
|
|
269
278
|
}
|
|
270
279
|
return null;
|
|
271
280
|
}
|
|
281
|
+
function shouldResetExistingWorktree(request) {
|
|
282
|
+
const lane = request.lane.trim().toLowerCase();
|
|
283
|
+
const phase = request.phase.trim().toLowerCase().replace(/-/g, "_");
|
|
284
|
+
if (lane === "develop" && (phase === "implementation" || phase === "self_review" || phase === "validation")) {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
if (lane === "qa" || phase === "qa") {
|
|
288
|
+
return false;
|
|
289
|
+
}
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
272
292
|
function qaReworkPacketFileName(packetPath) {
|
|
273
293
|
const normalized = packetPath.trim().replace(/\\/g, "/");
|
|
274
294
|
const fileName = normalized.split("/").filter(Boolean).at(-1) ?? "";
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.3-dev.
|
|
3
|
+
"version": "0.1.3-dev.bf78fdcaa623",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
+
"forge": "dist/cli/bin.js",
|
|
8
9
|
"forge-bridge": "dist/cli/bin.js"
|
|
9
10
|
},
|
|
10
11
|
"main": "./dist/index.js",
|
|
@@ -43,7 +44,8 @@
|
|
|
43
44
|
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\""
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
|
-
"@microsoft/signalr": "^8.0.17"
|
|
47
|
+
"@microsoft/signalr": "^8.0.17",
|
|
48
|
+
"yaml": "^2.9.0"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
51
|
"@eslint/js": "^10.0.1",
|