@loucompanion/forge-bridge 0.2.1-dev.4f11ffc822f9 → 0.2.1-dev.7171bf414613
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 +41 -3
- package/dist/bridge/bridge-state-io.d.ts +6 -2
- package/dist/bridge/bridge-state-io.js +22 -4
- package/dist/bridge/bridge.service.d.ts +10 -0
- package/dist/bridge/bridge.service.js +63 -101
- package/dist/bridge/bridge.types.d.ts +16 -0
- package/dist/bridge/bridge.types.js +2 -1
- package/dist/bridge/default-session-service.d.ts +13 -0
- package/dist/bridge/default-session-service.js +22 -0
- package/dist/bridge/dispatch-offer-policy.d.ts +22 -0
- package/dist/bridge/dispatch-offer-policy.js +58 -0
- package/dist/bridge/runner-host-capabilities.js +14 -1
- package/dist/bridge/windows-bash-resolution.d.ts +31 -0
- package/dist/bridge/windows-bash-resolution.js +153 -0
- package/dist/cleanup/cleanup-wip.js +3 -3
- package/dist/cleanup/forge-owned-paths.d.ts +2 -0
- package/dist/cleanup/forge-owned-paths.js +9 -0
- package/dist/cli/cli.help.js +1 -1
- package/dist/cli/cli.service.js +11 -43
- package/dist/cli/local-config.d.ts +12 -1
- package/dist/cli/local-config.js +35 -1
- package/dist/cli/provider-cli-advertising.d.ts +24 -0
- package/dist/cli/provider-cli-advertising.js +88 -0
- package/dist/runtime/host-load-admission.d.ts +5 -0
- package/dist/runtime/host-load-capacity.d.ts +198 -0
- package/dist/runtime/host-load-capacity.js +353 -0
- package/dist/runtime/host-load-child-environment.d.ts +13 -0
- package/dist/runtime/host-load-child-environment.js +35 -1
- package/dist/runtime/host-load-governor-config.d.ts +33 -3
- package/dist/runtime/host-load-governor-config.js +24 -3
- package/dist/runtime/host-load-governor.d.ts +89 -2
- package/dist/runtime/host-load-governor.js +217 -18
- package/dist/runtime/host-load-live-test-slots.d.ts +61 -0
- package/dist/runtime/host-load-live-test-slots.js +193 -0
- package/dist/runtime/host-load-sampler.d.ts +17 -0
- package/dist/runtime/host-load-sampler.js +24 -0
- package/dist/runtime/host-load-step-run.d.ts +37 -3
- package/dist/runtime/host-load-step-run.js +63 -7
- package/dist/runtime/host-load-test-slot.d.ts +3 -0
- package/dist/runtime/host-load-test-slot.js +26 -7
- package/dist/runtime/host-runtime-contract.js +6 -4
- package/dist/runtime/prepared-runtime-readiness.d.ts +12 -2
- package/dist/runtime/prepared-runtime-readiness.js +35 -11
- package/dist/sandbox/runtime.d.ts +1 -2
- package/dist/sandbox/runtime.js +8 -14
- package/dist/sandbox/sandbox-input.d.ts +22 -0
- package/dist/sandbox/sandbox-input.js +49 -0
- package/dist/sandbox/workspace.service.js +15 -2
- package/dist/session/managed-attempt-tools.js +6 -29
- package/dist/session/managed-build-receipt.d.ts +3 -1
- package/dist/session/managed-build-receipt.js +5 -2
- package/dist/session/managed-command-environment.d.ts +8 -0
- package/dist/session/managed-command-environment.js +28 -0
- package/dist/session/managed-command-host-load.d.ts +10 -5
- package/dist/session/managed-command-host-load.js +18 -14
- package/dist/session/phase-completion.artifact-bundle.d.ts +20 -0
- package/dist/session/phase-completion.artifact-bundle.js +167 -0
- package/dist/session/phase-completion.artifacts.d.ts +2 -17
- package/dist/session/phase-completion.artifacts.js +63 -165
- package/dist/session/phase-completion.d.ts +25 -2
- package/dist/session/phase-completion.helpers.js +5 -53
- package/dist/session/phase-completion.js +15 -32
- package/dist/session/phase-completion.mcp-args.js +69 -2
- package/dist/session/phase-completion.phase-aliases.d.ts +5 -0
- package/dist/session/phase-completion.phase-aliases.js +43 -0
- package/dist/session/phase-completion.pr-review-schema.d.ts +1 -0
- package/dist/session/phase-completion.pr-review-schema.js +75 -0
- package/dist/session/phase-completion.pr-review-threads.d.ts +34 -0
- package/dist/session/phase-completion.pr-review-threads.js +90 -0
- package/dist/session/phase-completion.pr-review-validation.d.ts +11 -0
- package/dist/session/phase-completion.pr-review-validation.js +215 -0
- package/dist/session/phase-completion.pr-review.d.ts +36 -0
- package/dist/session/phase-completion.pr-review.js +294 -0
- package/dist/session/phase-completion.prompts.d.ts +1 -1
- package/dist/session/phase-completion.prompts.js +14 -0
- package/dist/session/phase-completion.runtime.js +9 -3
- package/dist/session/phase-completion.schemas.js +12 -2
- package/dist/session/phase-completion.validation.d.ts +1 -0
- package/dist/session/phase-completion.validation.js +9 -1
- package/dist/session/pr-review-diff-base.d.ts +18 -0
- package/dist/session/pr-review-diff-base.js +45 -0
- package/dist/session/pr-review-placement.d.ts +50 -0
- package/dist/session/pr-review-placement.js +91 -0
- package/dist/session/pre-publication-change-set.d.ts +62 -0
- package/dist/session/pre-publication-change-set.js +166 -0
- package/dist/session/pre-publication-host-load.js +6 -5
- package/dist/session/pre-publication-process.js +3 -2
- package/dist/session/pre-publication-validation.d.ts +2 -1
- package/dist/session/pre-publication-validation.js +31 -36
- package/dist/session/provider-cli/dispatch-target-branch.d.ts +7 -0
- package/dist/session/provider-cli/dispatch-target-branch.js +8 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.d.ts +83 -0
- package/dist/session/provider-cli/pr-review-credential-isolation.js +144 -0
- package/dist/session/provider-cli/pr-review-guardrails.d.ts +70 -0
- package/dist/session/provider-cli/pr-review-guardrails.js +360 -0
- package/dist/session/provider-cli/pr-review-prompt.d.ts +11 -0
- package/dist/session/provider-cli/pr-review-prompt.js +132 -0
- package/dist/session/provider-cli/pre-publication-repair.js +8 -3
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.deterministic.js +5 -0
- package/dist/session/provider-cli/provider-cli.merge-integrity.d.ts +6 -3
- package/dist/session/provider-cli/provider-cli.merge-integrity.js +29 -10
- package/dist/session/provider-cli/provider-cli.pr-review.d.ts +23 -0
- package/dist/session/provider-cli/provider-cli.pr-review.js +213 -0
- package/dist/session/provider-cli/provider-cli.prompts.d.ts +10 -3
- package/dist/session/provider-cli/provider-cli.prompts.js +123 -70
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.d.ts +10 -0
- package/dist/session/provider-cli/provider-cli.reapply-conflicts.js +37 -0
- package/dist/session/provider-cli/provider-cli.runtime.d.ts +7 -0
- package/dist/session/provider-cli/provider-cli.runtime.js +14 -0
- package/dist/session/provider-cli/provider-cli.service-support.d.ts +37 -0
- package/dist/session/provider-cli/provider-cli.service-support.js +146 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +11 -17
- package/dist/session/provider-cli/provider-cli.service.js +33 -148
- package/dist/session/provider-cli/provider-cli.types.d.ts +7 -2
- package/dist/session/sandbox-host-capacity-gate.js +29 -7
- package/dist/session/session-host-project.d.ts +22 -0
- package/dist/session/session-host-project.js +98 -0
- package/dist/session/session.parse-helpers.d.ts +10 -0
- package/dist/session/session.parse-helpers.js +84 -0
- package/dist/session/session.runtime-refresh.d.ts +46 -0
- package/dist/session/session.runtime-refresh.js +116 -0
- package/dist/session/session.service.d.ts +2 -1
- package/dist/session/session.service.js +57 -158
- package/dist/session/session.types.d.ts +5 -0
- package/dist/session/session.types.js +8 -78
- package/dist/session/session.types.pr-review.d.ts +59 -0
- package/dist/session/session.types.pr-review.js +53 -0
- package/dist/shared/provider-capabilities.d.ts +2 -0
- package/dist/shared/provider-capabilities.js +9 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.js +24 -0
- package/dist/worktree/wip-git.d.ts +25 -0
- package/dist/worktree/wip-git.js +64 -4
- package/dist/worktree/wip-refs.d.ts +23 -0
- package/dist/worktree/wip-refs.js +52 -2
- package/dist/worktree/wip-restore.d.ts +13 -0
- package/dist/worktree/wip-restore.js +159 -25
- package/dist/worktree/wip-snapshot.d.ts +5 -2
- package/dist/worktree/wip-snapshot.js +15 -13
- package/dist/worktree/worktree-origin-sync.d.ts +1 -0
- package/dist/worktree/worktree-origin-sync.js +1 -0
- package/dist/worktree/worktree-wip-events.d.ts +2 -0
- package/dist/worktree/worktree-wip-events.js +53 -3
- package/dist/worktree/worktree-wip.d.ts +7 -0
- package/dist/worktree/worktree-wip.js +17 -2
- package/dist/worktree/worktree.service.d.ts +23 -1
- package/dist/worktree/worktree.service.js +122 -15
- package/dist/worktree/worktree.types.d.ts +16 -0
- package/package.json +1 -1
|
@@ -6,10 +6,10 @@ import { GitClient } from "../shared/git/git.js";
|
|
|
6
6
|
import { ensureDirectory, isSubPath, resolveExistingDirectoryPath, safeSegment } from "../shared/path/path.js";
|
|
7
7
|
import { warmWorktreeDependencies } from "./dependency-warmer.js";
|
|
8
8
|
import { materializeWorktreeInputs } from "./worktree-inputs.js";
|
|
9
|
-
import { guardBranchReset, guardWorktreeRelease, guardWorktreeReset, relinkOrphanedWorktree, restoreWorktreeWip, settleSessionWip, sweepBranchesAfterRelease, worktreeReleased, } from "./worktree-wip.js";
|
|
9
|
+
import { guardBranchReset, guardWorktreeRelease, guardWorktreeReset, relinkOrphanedWorktree, restoreWorktreeWip, unresolvedWorktreeReapplyConflicts, settleSessionWip, sweepBranchesAfterRelease, worktreeReleased, } from "./worktree-wip.js";
|
|
10
10
|
import { defaultWorktreeCoordinatorStateRoot, managedRepoRoot, resolveManagedWorktreeRoot, } from "./worktree-paths.js";
|
|
11
11
|
import { describeNewWorktreeStart, refuseStaleFallbackAfterFetchFailure, syncReusedWorktreeToOrigin, writeBridgeLog, } from "./worktree-origin-sync.js";
|
|
12
|
-
export { emitWipRestoreEvent, sessionWipOutcome, settleWorktree } from "./worktree-wip-events.js";
|
|
12
|
+
export { deferredProjectStartEvent, emitWipRestoreEvent, sessionWipOutcome, settleWorktree } from "./worktree-wip-events.js";
|
|
13
13
|
export { emitWorktreePreparedEvents } from "./worktree-origin-sync.js";
|
|
14
14
|
export { clearRunArtifactRoots } from "./worktree-inputs.js";
|
|
15
15
|
// Bounds the branch sweep that runs after each release, so one release never holds the repository lock long.
|
|
@@ -36,10 +36,10 @@ export class GitWorktreeService {
|
|
|
36
36
|
async prepare(request) {
|
|
37
37
|
const allowedRoot = await ensureDirectory(request.allowedRepoRoot);
|
|
38
38
|
const baseBranch = normalizeBranchName(request.baseBranch, "develop");
|
|
39
|
+
const detachedHeadSha = normalizeDetachedHeadSha(request.detachedHeadSha);
|
|
39
40
|
const shortId = request.workItem.id.replace(/-/g, "").slice(0, 12);
|
|
40
41
|
const kind = safeSegment(request.workItem.kind, "work-item");
|
|
41
|
-
const
|
|
42
|
-
const worktreeKey = request.worktreeKey?.trim() || fallbackWorktreeKey;
|
|
42
|
+
const worktreeKey = request.worktreeKey?.trim() || `${kind}/${shortId}`;
|
|
43
43
|
const worktreeSegments = worktreeKeySegments(worktreeKey, kind, shortId);
|
|
44
44
|
const branchName = normalizeBranchName(worktreeSegments.join("/"), "work-item/unknown");
|
|
45
45
|
const creationCoordinationPath = this.repoCreationCoordinationPath(request.repo, allowedRoot);
|
|
@@ -48,7 +48,9 @@ export class GitWorktreeService {
|
|
|
48
48
|
});
|
|
49
49
|
const { worktreePath: resolvedWorktreePath, ...preparedState } = await this.coordinator.withLock(repoPath, async () => {
|
|
50
50
|
await this.ensureGitIdentity(repoPath);
|
|
51
|
-
const baseStartPoint =
|
|
51
|
+
const baseStartPoint = detachedHeadSha
|
|
52
|
+
? await this.resolveReviewHead(repoPath, detachedHeadSha)
|
|
53
|
+
: await this.resolveBaseStartPoint(repoPath, baseBranch, branchName);
|
|
52
54
|
const worktreeRoot = resolveManagedWorktreeRoot(allowedRoot, repoPath);
|
|
53
55
|
const worktreePath = path.join(worktreeRoot, ...worktreeSegments);
|
|
54
56
|
const resolvedWorktreeParent = await ensureDirectory(path.dirname(worktreePath));
|
|
@@ -63,8 +65,7 @@ export class GitWorktreeService {
|
|
|
63
65
|
await this.git.run(repoPath, ["worktree", "prune", "--expire", "now"]);
|
|
64
66
|
const registeredWorktreePath = await this.registeredManagedWorktreePath(repoPath, branchName, allowedRoot, worktreeSegments);
|
|
65
67
|
if (!registeredWorktreePath) {
|
|
66
|
-
|
|
67
|
-
return await this.withRestoredWip(request, repoPath, branchName, await resolveExistingDirectoryPath(worktreePath), originSync);
|
|
68
|
+
return await this.createWorktree(request, { repoPath, branchName, worktreePath, baseStartPoint, detachedHeadSha });
|
|
68
69
|
}
|
|
69
70
|
// The selected checkout can change when a Bridge reconnects or a local
|
|
70
71
|
// runner takes over. Its managed root therefore changes even though the
|
|
@@ -85,13 +86,17 @@ export class GitWorktreeService {
|
|
|
85
86
|
allowedRoot,
|
|
86
87
|
});
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
return await this.reuseWorktree(request, {
|
|
90
|
+
repoPath,
|
|
91
|
+
branchName,
|
|
92
|
+
worktreePath: existingWorktreePath,
|
|
93
|
+
baseStartPoint,
|
|
94
|
+
detachedHeadSha,
|
|
95
|
+
});
|
|
94
96
|
});
|
|
97
|
+
if (detachedHeadSha) {
|
|
98
|
+
await this.assertDetachedAtHead(resolvedWorktreePath, detachedHeadSha);
|
|
99
|
+
}
|
|
95
100
|
const { hydratedPriorPhaseArtifactCount, qaReworkPacketPath } = await materializeWorktreeInputs(resolvedWorktreePath, request, this.git);
|
|
96
101
|
const dependencyWarm = await this.warmDependencies(request, repoPath, resolvedWorktreePath, allowedRoot);
|
|
97
102
|
return {
|
|
@@ -105,9 +110,82 @@ export class GitWorktreeService {
|
|
|
105
110
|
hydratedPriorPhaseArtifactCount,
|
|
106
111
|
sessionId: request.sessionId ?? null,
|
|
107
112
|
lane: request.lane,
|
|
113
|
+
wipAttempt: request.wipAttempt ?? null,
|
|
108
114
|
...preparedState,
|
|
115
|
+
...(detachedHeadSha ? { detachedHeadSha } : {}),
|
|
109
116
|
};
|
|
110
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* Creates the lease's worktree. A review's is detached at the review head: no lease branch is
|
|
120
|
+
* created and no WIP is restored. Any other is on the lease branch with the story's WIP restored.
|
|
121
|
+
*/
|
|
122
|
+
async createWorktree(request, checkout) {
|
|
123
|
+
const { repoPath, branchName, worktreePath, baseStartPoint, detachedHeadSha } = checkout;
|
|
124
|
+
if (detachedHeadSha) {
|
|
125
|
+
await this.git.run(repoPath, ["worktree", "add", "--detach", worktreePath, detachedHeadSha]);
|
|
126
|
+
return { worktreePath: await resolveExistingDirectoryPath(worktreePath) };
|
|
127
|
+
}
|
|
128
|
+
const originSync = await this.addWorktree(request, repoPath, branchName, worktreePath, baseStartPoint);
|
|
129
|
+
return await this.withRestoredWip(request, repoPath, branchName, await resolveExistingDirectoryPath(worktreePath), originSync);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Readies a surviving worktree. A review reads one exact commit, so whatever state a prior attempt
|
|
133
|
+
* left behind is discarded. Any other must still be on the lease branch; it is refreshed for this
|
|
134
|
+
* pass and given the story's WIP.
|
|
135
|
+
*/
|
|
136
|
+
async reuseWorktree(request, checkout) {
|
|
137
|
+
const { repoPath, branchName, worktreePath, baseStartPoint, detachedHeadSha } = checkout;
|
|
138
|
+
if (detachedHeadSha) {
|
|
139
|
+
await this.git.run(worktreePath, ["checkout", "--force", "--detach", detachedHeadSha]);
|
|
140
|
+
await this.git.run(worktreePath, ["reset", "--hard", detachedHeadSha]);
|
|
141
|
+
await this.git.run(worktreePath, ["clean", "-fd"]);
|
|
142
|
+
return { worktreePath };
|
|
143
|
+
}
|
|
144
|
+
const currentBranch = await this.currentBranch(worktreePath);
|
|
145
|
+
if (currentBranch !== branchName) {
|
|
146
|
+
throw new Error(`Existing worktree ${worktreePath} is on branch '${currentBranch}', expected '${branchName}'.`);
|
|
147
|
+
}
|
|
148
|
+
const originSync = await this.refreshReusedWorktree(request, worktreePath, branchName, baseStartPoint);
|
|
149
|
+
return await this.withRestoredWip(request, repoPath, branchName, worktreePath, originSync);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Finds the review head in the repository, fetching it when the local clone has not seen it
|
|
153
|
+
* yet, and returns the full commit id.
|
|
154
|
+
*/
|
|
155
|
+
async resolveReviewHead(repoPath, headSha) {
|
|
156
|
+
const resolve = async () => {
|
|
157
|
+
const resolved = await this.git.run(repoPath, ["rev-parse", "--verify", "--quiet", `${headSha}^{commit}`])
|
|
158
|
+
.then((value) => value.trim())
|
|
159
|
+
.catch(() => "");
|
|
160
|
+
return /^[0-9a-f]{40,64}$/iu.test(resolved) ? resolved : null;
|
|
161
|
+
};
|
|
162
|
+
const local = await resolve();
|
|
163
|
+
if (local) {
|
|
164
|
+
return local;
|
|
165
|
+
}
|
|
166
|
+
const origin = await this.git.run(repoPath, ["remote", "get-url", "origin"]).catch(() => "");
|
|
167
|
+
if (origin.trim().length > 0) {
|
|
168
|
+
await this.git.run(repoPath, ["fetch", "--prune", "origin"]).catch(() => undefined);
|
|
169
|
+
const afterFetch = await resolve();
|
|
170
|
+
if (afterFetch) {
|
|
171
|
+
return afterFetch;
|
|
172
|
+
}
|
|
173
|
+
await this.git.run(repoPath, ["fetch", "origin", headSha]).catch(() => undefined);
|
|
174
|
+
const afterShaFetch = await resolve();
|
|
175
|
+
if (afterShaFetch) {
|
|
176
|
+
return afterShaFetch;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
throw new Error(`Review head ${headSha} was not found in the repository or on origin.`);
|
|
180
|
+
}
|
|
181
|
+
async assertDetachedAtHead(worktreePath, headSha) {
|
|
182
|
+
const head = (await this.git.run(worktreePath, ["rev-parse", "HEAD"])).trim().toLowerCase();
|
|
183
|
+
const detached = await this.git.run(worktreePath, ["symbolic-ref", "--quiet", "HEAD"]).then(() => false).catch(() => true);
|
|
184
|
+
const expected = (await this.git.run(worktreePath, ["rev-parse", "--verify", `${headSha}^{commit}`])).trim().toLowerCase();
|
|
185
|
+
if (head !== expected || !detached) {
|
|
186
|
+
throw new Error(`Review worktree ${worktreePath} must be detached at ${headSha}, found ${detached ? "detached" : "a branch"} HEAD ${head}.`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
111
189
|
async warmDependencies(request, repoPath, worktreePath, allowedRoot) {
|
|
112
190
|
if (!requiresMutableEnvironmentPreparation(request))
|
|
113
191
|
return undefined;
|
|
@@ -129,7 +207,8 @@ export class GitWorktreeService {
|
|
|
129
207
|
/** Restores the story's saved WIP (still under the repository lock, before the provider starts). */
|
|
130
208
|
async withRestoredWip(request, repoPath, branchName, worktreePath, originSync) {
|
|
131
209
|
const wipRestore = await restoreWorktreeWip({ worktreePath, repoPath, branchName, sessionId: request.sessionId, lane: request.lane });
|
|
132
|
-
|
|
210
|
+
const reapplyConflicts = await unresolvedWorktreeReapplyConflicts(worktreePath);
|
|
211
|
+
return { worktreePath, reapplyConflicts, ...(wipRestore ? { wipRestore } : {}), ...(originSync ? { originSync } : {}) };
|
|
133
212
|
}
|
|
134
213
|
/** Creates the lease's worktree; see describeNewWorktreeStart for what it reports. */
|
|
135
214
|
async addWorktree(request, repoPath, branchName, worktreePath, baseStartPoint) {
|
|
@@ -168,10 +247,15 @@ export class GitWorktreeService {
|
|
|
168
247
|
branchName,
|
|
169
248
|
sessionId: request.sessionId,
|
|
170
249
|
lane: request.lane,
|
|
250
|
+
wipAttempt: request.wipAttempt,
|
|
171
251
|
log: this.log,
|
|
172
252
|
});
|
|
173
253
|
}
|
|
174
254
|
async settleWip(handle, outcome) {
|
|
255
|
+
// A review worktree holds the reviewed head plus whatever the review session left in it. That is
|
|
256
|
+
// never saved or published: a WIP snapshot would push it to a ref anyone who can read the repo can list.
|
|
257
|
+
if (handle.detachedHeadSha)
|
|
258
|
+
return {};
|
|
175
259
|
return await settleSessionWip(handle, outcome);
|
|
176
260
|
}
|
|
177
261
|
async registeredManagedWorktreePath(repoPath, branchName, allowedRoot, worktreeSegments) {
|
|
@@ -198,7 +282,10 @@ export class GitWorktreeService {
|
|
|
198
282
|
return;
|
|
199
283
|
}
|
|
200
284
|
await this.coordinator.withLock(handle.repoPath, async () => {
|
|
201
|
-
if (
|
|
285
|
+
if (handle.detachedHeadSha) {
|
|
286
|
+
await this.removeReviewWorktree(handle);
|
|
287
|
+
}
|
|
288
|
+
else if (await directoryExists(handle.worktreePath)) {
|
|
202
289
|
// Never delete work that could not be saved: this throws and keeps the worktree.
|
|
203
290
|
await guardWorktreeRelease(handle);
|
|
204
291
|
// On Windows, `git worktree remove` can delete the `.git` link and then
|
|
@@ -228,6 +315,16 @@ export class GitWorktreeService {
|
|
|
228
315
|
await sweepBranchesAfterRelease(this.git, handle, this.leaseStateRoot, releaseSweepLimit);
|
|
229
316
|
});
|
|
230
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Removes a review worktree without saving anything from it (see settleWip). A failed removal leaves
|
|
320
|
+
* the folder for the next prepare of that head, which resets and cleans it, or for stale cleanup.
|
|
321
|
+
*/
|
|
322
|
+
async removeReviewWorktree(handle) {
|
|
323
|
+
if (!(await directoryExists(handle.worktreePath)))
|
|
324
|
+
return;
|
|
325
|
+
await this.git.run(handle.repoPath, ["worktree", "remove", "--force", handle.worktreePath]).catch(() => undefined);
|
|
326
|
+
await fs.rm(handle.worktreePath, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }).catch(() => undefined);
|
|
327
|
+
}
|
|
231
328
|
async restoreOrphanedWorktree(input) {
|
|
232
329
|
const orphanStat = await fs.lstat(input.worktreePath);
|
|
233
330
|
if (orphanStat.isSymbolicLink() || !orphanStat.isDirectory()) {
|
|
@@ -558,6 +655,16 @@ async function overlayEntry(input) {
|
|
|
558
655
|
backupPath: preservedBasePath,
|
|
559
656
|
});
|
|
560
657
|
}
|
|
658
|
+
function normalizeDetachedHeadSha(value) {
|
|
659
|
+
const trimmed = value?.trim().toLowerCase() ?? "";
|
|
660
|
+
if (trimmed.length === 0) {
|
|
661
|
+
return null;
|
|
662
|
+
}
|
|
663
|
+
if (!/^[0-9a-f]{40}$|^[0-9a-f]{64}$/u.test(trimmed)) {
|
|
664
|
+
throw new Error("Review head_sha must be a full 40 or 64 character commit id.");
|
|
665
|
+
}
|
|
666
|
+
return trimmed;
|
|
667
|
+
}
|
|
561
668
|
export function normalizeBranchName(value, fallback) {
|
|
562
669
|
const branch = (value?.trim() || fallback).trim();
|
|
563
670
|
if (branch.length === 0 ||
|
|
@@ -24,8 +24,15 @@ export interface WorktreePrepareRequest {
|
|
|
24
24
|
readonly warmPathOverrides?: readonly string[];
|
|
25
25
|
readonly applicationRuntimeRequired?: boolean;
|
|
26
26
|
readonly preserveExistingState?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Review-only checkout: the worktree is detached at exactly this commit and verified with
|
|
29
|
+
* `git rev-parse HEAD`. The lease branch is never created or advanced.
|
|
30
|
+
*/
|
|
31
|
+
readonly detachedHeadSha?: string | null;
|
|
27
32
|
/** The session this worktree is prepared for; names its WIP snapshots and enables restoring one. */
|
|
28
33
|
readonly sessionId?: string | null;
|
|
34
|
+
/** Forge's issued attempt for this dispatch (sandbox.wipAttempt), stamped on its WIP refs: newest work wins. */
|
|
35
|
+
readonly wipAttempt?: number | null;
|
|
29
36
|
/** The attempt dependency installs reserve host capacity for (decision 0013). */
|
|
30
37
|
readonly hostLoadOwner?: {
|
|
31
38
|
readonly dispatchAttemptId: string | null;
|
|
@@ -43,10 +50,19 @@ export interface WorktreeHandle {
|
|
|
43
50
|
readonly dependencyWarm?: WarmDependenciesResult;
|
|
44
51
|
readonly qaReworkPacketPath?: string;
|
|
45
52
|
readonly hydratedPriorPhaseArtifactCount?: number;
|
|
53
|
+
/** Set when the worktree was checked out detached at a review head. */
|
|
54
|
+
readonly detachedHeadSha?: string;
|
|
46
55
|
readonly sessionId?: string | null;
|
|
47
56
|
readonly lane?: string;
|
|
57
|
+
/** Forge's issued attempt for the dispatch the worktree was prepared for; null from older servers. */
|
|
58
|
+
readonly wipAttempt?: number | null;
|
|
48
59
|
/** What happened to the story's saved WIP when this worktree was prepared. */
|
|
49
60
|
readonly wipRestore?: WipRestoreOutcome;
|
|
61
|
+
/**
|
|
62
|
+
* Recorded WIP re-apply conflicts the worktree still has (unresolvedWorktreeReapplyConflicts); the
|
|
63
|
+
* session defers the project start on them. Prepare fails when they cannot be read.
|
|
64
|
+
*/
|
|
65
|
+
readonly reapplyConflicts?: readonly string[];
|
|
50
66
|
/** Set when prepare moved a stale local branch or reused worktree up to origin's head. */
|
|
51
67
|
readonly originSync?: OriginSync;
|
|
52
68
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.2.1-dev.
|
|
3
|
+
"version": "0.2.1-dev.7171bf414613",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|