@loucompanion/forge-bridge 0.1.1-dev.ac486debe210 → 0.1.1-dev.c5b751411a2b
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/bridge/bridge.service.js +68 -9
- package/dist/bridge/bridge.types.d.ts +9 -0
- package/dist/cli/local-config.js +18 -1
- package/dist/session/internals.d.ts +1 -1
- package/dist/session/phase-completion.d.ts +30 -2
- package/dist/session/phase-completion.js +1486 -22
- package/dist/session/provider-cli/provider-cli.base.d.ts +1 -0
- package/dist/session/provider-cli/provider-cli.service.d.ts +3 -0
- package/dist/session/provider-cli/provider-cli.service.js +882 -153
- package/dist/session/qa-sidecar-validation.d.ts +3 -0
- package/dist/session/qa-sidecar-validation.js +44 -0
- package/dist/session/session.service.js +12 -4
- package/dist/session/session.types.d.ts +48 -0
- package/dist/session/session.types.js +108 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worktree/artifact-injector.d.ts +1 -0
- package/dist/worktree/artifact-injector.js +78 -1
- package/dist/worktree/worktree.service.js +5 -3
- package/dist/worktree/worktree.types.d.ts +2 -0
- package/package.json +8 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function isPathUnderRoot(root: string, target: string): boolean;
|
|
2
|
+
export declare function ensureNoSymbolicLinkPathSegments(root: string, targetDirectory: string, errorMessage: string): Promise<void>;
|
|
3
|
+
export declare function sha256File(filePath: string): Promise<string>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { createReadStream } from "node:fs";
|
|
3
|
+
import fs from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
export function isPathUnderRoot(root, target) {
|
|
6
|
+
const relative = path.relative(path.resolve(root), path.resolve(target));
|
|
7
|
+
return Boolean(relative)
|
|
8
|
+
&& relative !== ".."
|
|
9
|
+
&& !relative.startsWith(`..${path.sep}`)
|
|
10
|
+
&& !path.isAbsolute(relative);
|
|
11
|
+
}
|
|
12
|
+
export async function ensureNoSymbolicLinkPathSegments(root, targetDirectory, errorMessage) {
|
|
13
|
+
const resolvedRoot = path.resolve(root);
|
|
14
|
+
const resolvedTargetDirectory = path.resolve(targetDirectory);
|
|
15
|
+
const relative = path.relative(resolvedRoot, resolvedTargetDirectory);
|
|
16
|
+
if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
17
|
+
throw new Error(errorMessage);
|
|
18
|
+
}
|
|
19
|
+
let current = resolvedRoot;
|
|
20
|
+
const rootStat = await fs.lstat(current);
|
|
21
|
+
if (rootStat.isSymbolicLink()) {
|
|
22
|
+
throw new Error(errorMessage);
|
|
23
|
+
}
|
|
24
|
+
if (!relative) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
for (const segment of relative.split(path.sep)) {
|
|
28
|
+
if (!segment) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
current = path.join(current, segment);
|
|
32
|
+
const stat = await fs.lstat(current);
|
|
33
|
+
if (stat.isSymbolicLink()) {
|
|
34
|
+
throw new Error(errorMessage);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export async function sha256File(filePath) {
|
|
39
|
+
const hash = crypto.createHash("sha256");
|
|
40
|
+
for await (const chunk of createReadStream(filePath)) {
|
|
41
|
+
hash.update(chunk);
|
|
42
|
+
}
|
|
43
|
+
return hash.digest("hex");
|
|
44
|
+
}
|
|
@@ -13,7 +13,9 @@ export class BridgeSessionService {
|
|
|
13
13
|
const redactionSecrets = exactSecrets(dispatch);
|
|
14
14
|
const events = [];
|
|
15
15
|
const emit = async (event) => {
|
|
16
|
-
|
|
16
|
+
if (signal?.aborted) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
17
19
|
const redacted = redactSecrets(event, redactionSecrets);
|
|
18
20
|
events.push(redacted);
|
|
19
21
|
await sink.emit(redacted);
|
|
@@ -29,6 +31,8 @@ export class BridgeSessionService {
|
|
|
29
31
|
repo: dispatch.repo,
|
|
30
32
|
workItem: dispatch.workItem,
|
|
31
33
|
baseBranch: dispatch.cycleRun.baseBranch || dispatch.cycleRun.requestedBase,
|
|
34
|
+
lane: dispatch.execution.lane,
|
|
35
|
+
phase: dispatch.cycleRun.phase,
|
|
32
36
|
allowedRepoRoot: dispatch.serverLocal.repoRoot,
|
|
33
37
|
cleanupWorktrees: dispatch.serverLocal.cleanupWorktrees,
|
|
34
38
|
artifacts: dispatch.artifacts,
|
|
@@ -49,6 +53,7 @@ export class BridgeSessionService {
|
|
|
49
53
|
const lane = dispatch.execution.lane.toLowerCase();
|
|
50
54
|
const role = dispatch.execution.role.toLowerCase();
|
|
51
55
|
const isQa = role === "qa" || lane === "qa";
|
|
56
|
+
const isArchitect = role === "architect" || lane === "architect" || dispatch.cycleRun.kind.toLowerCase() === "architect";
|
|
52
57
|
const isConflictResolve = role === "conflict_resolve" || lane === "conflict_resolve";
|
|
53
58
|
const context = {
|
|
54
59
|
dispatch,
|
|
@@ -58,9 +63,12 @@ export class BridgeSessionService {
|
|
|
58
63
|
};
|
|
59
64
|
const run = isQa
|
|
60
65
|
? await this.providerCli.runQa(context)
|
|
61
|
-
:
|
|
62
|
-
? await this.providerCli.
|
|
63
|
-
:
|
|
66
|
+
: isArchitect
|
|
67
|
+
? await this.providerCli.runArchitect(context)
|
|
68
|
+
: isConflictResolve
|
|
69
|
+
? await this.providerCli.runConflictResolve(context)
|
|
70
|
+
: await this.providerCli.runImplementation(context);
|
|
71
|
+
throwIfAborted(signal);
|
|
64
72
|
const phaseArtifacts = run.artifacts?.length ? run.artifacts : run.artifact ? [run.artifact] : [];
|
|
65
73
|
return redactSecrets({
|
|
66
74
|
schemaVersion: 1,
|
|
@@ -8,9 +8,50 @@ export interface RunOnceDispatchPacket {
|
|
|
8
8
|
readonly lease: DispatchLease;
|
|
9
9
|
readonly execution: DispatchExecution;
|
|
10
10
|
readonly serverLocal: DispatchServerLocalConfig;
|
|
11
|
+
readonly pullRequest?: DispatchPullRequestContext | null;
|
|
11
12
|
readonly apiKeySecretGrant?: ApiKeySecretGrant | null;
|
|
12
13
|
readonly artifacts: readonly DispatchResolvedArtifact[];
|
|
13
14
|
readonly warmPathOverrides?: readonly string[];
|
|
15
|
+
readonly qaBrowser?: DispatchQaBrowserContext | null;
|
|
16
|
+
readonly qaRework?: DispatchQaReworkContext | null;
|
|
17
|
+
}
|
|
18
|
+
export interface DispatchQaBrowserContext {
|
|
19
|
+
readonly required: boolean;
|
|
20
|
+
readonly launchTarget?: DispatchQaAppLaunchTarget | null;
|
|
21
|
+
readonly artifactsPath: string;
|
|
22
|
+
readonly missingTargetReason?: string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface DispatchQaAppLaunchTarget {
|
|
25
|
+
readonly url?: string | null;
|
|
26
|
+
readonly command?: string | null;
|
|
27
|
+
readonly working_directory?: string | null;
|
|
28
|
+
readonly ready_url?: string | null;
|
|
29
|
+
readonly routes: readonly string[];
|
|
30
|
+
readonly notes?: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface DispatchQaReworkContext {
|
|
33
|
+
readonly attempt: number;
|
|
34
|
+
readonly maxAttempts: number;
|
|
35
|
+
readonly packetPath: string;
|
|
36
|
+
readonly packetJson: string;
|
|
37
|
+
readonly findingIds: readonly string[];
|
|
38
|
+
readonly findings: readonly Record<string, unknown>[];
|
|
39
|
+
}
|
|
40
|
+
export interface DispatchPullRequestContext {
|
|
41
|
+
readonly number: number;
|
|
42
|
+
readonly provider: string;
|
|
43
|
+
readonly title: string;
|
|
44
|
+
readonly sourceBranch: string;
|
|
45
|
+
readonly targetBranch: string;
|
|
46
|
+
readonly url: string;
|
|
47
|
+
readonly state: string;
|
|
48
|
+
readonly checkState: string;
|
|
49
|
+
readonly mergeState: string;
|
|
50
|
+
readonly requiredChecksPassed: number;
|
|
51
|
+
readonly requiredChecksTotal: number;
|
|
52
|
+
readonly unresolvedThreads: number;
|
|
53
|
+
readonly humanApproved: boolean;
|
|
54
|
+
readonly hasMergeConflicts: boolean;
|
|
14
55
|
}
|
|
15
56
|
export interface DispatchResolvedArtifact {
|
|
16
57
|
readonly kind: string;
|
|
@@ -41,6 +82,9 @@ export interface DispatchRepo {
|
|
|
41
82
|
}
|
|
42
83
|
export interface DispatchCycleRun {
|
|
43
84
|
readonly id: string;
|
|
85
|
+
readonly ownerType?: string | null;
|
|
86
|
+
readonly ownerId?: string | null;
|
|
87
|
+
readonly workItemId?: string | null;
|
|
44
88
|
readonly kind: string;
|
|
45
89
|
readonly phase: string;
|
|
46
90
|
readonly requestedBase: string;
|
|
@@ -56,6 +100,9 @@ export interface DispatchSession {
|
|
|
56
100
|
}
|
|
57
101
|
export interface DispatchLease {
|
|
58
102
|
readonly id: string;
|
|
103
|
+
readonly ownerType?: string | null;
|
|
104
|
+
readonly ownerId?: string | null;
|
|
105
|
+
readonly workItemId?: string | null;
|
|
59
106
|
readonly worktreeKey: string;
|
|
60
107
|
readonly lane: string;
|
|
61
108
|
readonly fencingToken: string;
|
|
@@ -71,6 +118,7 @@ export interface DispatchExecution {
|
|
|
71
118
|
readonly role: string;
|
|
72
119
|
readonly lane: string;
|
|
73
120
|
readonly requiresApiKeySecretGrant: boolean;
|
|
121
|
+
readonly runnerRepoLocalPath?: string | null;
|
|
74
122
|
}
|
|
75
123
|
export interface ApiKeySecretGrant {
|
|
76
124
|
readonly grantId: string;
|
|
@@ -15,9 +15,12 @@ export function parseRunOnceDispatchPacket(value) {
|
|
|
15
15
|
lease: parseLease(packet.lease),
|
|
16
16
|
execution: parseExecution(packet.execution),
|
|
17
17
|
serverLocal: parseServerLocal(packet.serverLocal),
|
|
18
|
+
pullRequest: parsePullRequest(packet.pullRequest),
|
|
18
19
|
apiKeySecretGrant: parseApiKeySecretGrant(packet.apiKeySecretGrant),
|
|
19
20
|
artifacts: parseArtifacts(packet.artifacts),
|
|
20
|
-
warmPathOverrides: parseWarmPathOverrides(packet.warmPathOverrides)
|
|
21
|
+
warmPathOverrides: parseWarmPathOverrides(packet.warmPathOverrides),
|
|
22
|
+
qaBrowser: parseQaBrowser(packet.qaBrowser),
|
|
23
|
+
qaRework: parseQaRework(packet.qaRework)
|
|
21
24
|
};
|
|
22
25
|
}
|
|
23
26
|
export function failureResult(summary, events = []) {
|
|
@@ -55,6 +58,9 @@ function parseCycleRun(value) {
|
|
|
55
58
|
const cycle = asObject(value, "cycleRun");
|
|
56
59
|
return {
|
|
57
60
|
id: requiredString(cycle, "id"),
|
|
61
|
+
ownerType: optionalString(cycle, "ownerType"),
|
|
62
|
+
ownerId: optionalString(cycle, "ownerId"),
|
|
63
|
+
workItemId: optionalString(cycle, "workItemId"),
|
|
58
64
|
kind: requiredString(cycle, "kind"),
|
|
59
65
|
phase: requiredString(cycle, "phase"),
|
|
60
66
|
requestedBase: optionalString(cycle, "requestedBase") ?? "develop",
|
|
@@ -76,6 +82,9 @@ function parseLease(value) {
|
|
|
76
82
|
const lease = asObject(value, "lease");
|
|
77
83
|
return {
|
|
78
84
|
id: requiredString(lease, "id"),
|
|
85
|
+
ownerType: optionalString(lease, "ownerType"),
|
|
86
|
+
ownerId: optionalString(lease, "ownerId"),
|
|
87
|
+
workItemId: optionalString(lease, "workItemId"),
|
|
79
88
|
worktreeKey: requiredString(lease, "worktreeKey"),
|
|
80
89
|
lane: requiredString(lease, "lane"),
|
|
81
90
|
fencingToken: requiredString(lease, "fencingToken"),
|
|
@@ -93,7 +102,8 @@ function parseExecution(value) {
|
|
|
93
102
|
repoId: requiredString(execution, "repoId"),
|
|
94
103
|
role: requiredString(execution, "role"),
|
|
95
104
|
lane: requiredString(execution, "lane"),
|
|
96
|
-
requiresApiKeySecretGrant: requiredBoolean(execution, "requiresApiKeySecretGrant")
|
|
105
|
+
requiresApiKeySecretGrant: requiredBoolean(execution, "requiresApiKeySecretGrant"),
|
|
106
|
+
runnerRepoLocalPath: optionalString(execution, "runnerRepoLocalPath")
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
109
|
function parseApiKeySecretGrant(value) {
|
|
@@ -115,6 +125,28 @@ function parseServerLocal(value) {
|
|
|
115
125
|
cleanupWorktrees: requiredBoolean(serverLocal, "cleanupWorktrees")
|
|
116
126
|
};
|
|
117
127
|
}
|
|
128
|
+
function parsePullRequest(value) {
|
|
129
|
+
if (value === undefined || value === null) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
const pullRequest = asObject(value, "pullRequest");
|
|
133
|
+
return {
|
|
134
|
+
number: requiredNumber(pullRequest, "number"),
|
|
135
|
+
provider: requiredString(pullRequest, "provider"),
|
|
136
|
+
title: optionalString(pullRequest, "title") ?? "",
|
|
137
|
+
sourceBranch: requiredString(pullRequest, "sourceBranch"),
|
|
138
|
+
targetBranch: requiredString(pullRequest, "targetBranch"),
|
|
139
|
+
url: optionalString(pullRequest, "url") ?? "",
|
|
140
|
+
state: requiredString(pullRequest, "state"),
|
|
141
|
+
checkState: requiredString(pullRequest, "checkState"),
|
|
142
|
+
mergeState: requiredString(pullRequest, "mergeState"),
|
|
143
|
+
requiredChecksPassed: requiredNumber(pullRequest, "requiredChecksPassed"),
|
|
144
|
+
requiredChecksTotal: requiredNumber(pullRequest, "requiredChecksTotal"),
|
|
145
|
+
unresolvedThreads: requiredNumber(pullRequest, "unresolvedThreads"),
|
|
146
|
+
humanApproved: requiredBoolean(pullRequest, "humanApproved"),
|
|
147
|
+
hasMergeConflicts: requiredBoolean(pullRequest, "hasMergeConflicts")
|
|
148
|
+
};
|
|
149
|
+
}
|
|
118
150
|
function parseWarmPathOverrides(value) {
|
|
119
151
|
if (value === undefined || value === null) {
|
|
120
152
|
return [];
|
|
@@ -138,6 +170,70 @@ function parseWarmPathOverride(entry, index) {
|
|
|
138
170
|
}
|
|
139
171
|
return segments.join("/");
|
|
140
172
|
}
|
|
173
|
+
function parseQaBrowser(value) {
|
|
174
|
+
if (value === undefined || value === null) {
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
const qaBrowser = asObject(value, "qaBrowser");
|
|
178
|
+
return {
|
|
179
|
+
required: optionalBoolean(qaBrowser, "required") ?? false,
|
|
180
|
+
launchTarget: parseQaAppLaunchTarget(qaBrowser.launchTarget ?? qaBrowser.launch_target),
|
|
181
|
+
artifactsPath: optionalString(qaBrowser, "artifactsPath") ?? optionalString(qaBrowser, "artifacts_path") ?? "",
|
|
182
|
+
missingTargetReason: optionalString(qaBrowser, "missingTargetReason") ?? optionalString(qaBrowser, "missing_target_reason")
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function parseQaAppLaunchTarget(value) {
|
|
186
|
+
if (value === undefined || value === null) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
const launchTarget = asObject(value, "qaBrowser.launchTarget");
|
|
190
|
+
const routes = launchTarget.routes;
|
|
191
|
+
if (routes !== undefined && routes !== null && !Array.isArray(routes)) {
|
|
192
|
+
throw new Error("qaBrowser.launchTarget.routes must be an array when provided.");
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
url: optionalString(launchTarget, "url"),
|
|
196
|
+
command: optionalString(launchTarget, "command"),
|
|
197
|
+
working_directory: optionalString(launchTarget, "working_directory"),
|
|
198
|
+
ready_url: optionalString(launchTarget, "ready_url"),
|
|
199
|
+
routes: Array.isArray(routes)
|
|
200
|
+
? routes.map((entry, index) => {
|
|
201
|
+
if (typeof entry !== "string") {
|
|
202
|
+
throw new Error(`qaBrowser.launchTarget.routes[${index}] must be a string.`);
|
|
203
|
+
}
|
|
204
|
+
return entry;
|
|
205
|
+
}).filter((entry) => entry.trim().length > 0)
|
|
206
|
+
: [],
|
|
207
|
+
notes: optionalString(launchTarget, "notes")
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function parseQaRework(value) {
|
|
211
|
+
if (value === undefined || value === null) {
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
const qaRework = asObject(value, "qaRework");
|
|
215
|
+
const findingIdsValue = qaRework.findingIds;
|
|
216
|
+
if (!Array.isArray(findingIdsValue)) {
|
|
217
|
+
throw new Error("qaRework.findingIds must be an array.");
|
|
218
|
+
}
|
|
219
|
+
const findingsValue = qaRework.findings;
|
|
220
|
+
if (!Array.isArray(findingsValue)) {
|
|
221
|
+
throw new Error("qaRework.findings must be an array.");
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
attempt: requiredNumber(qaRework, "attempt"),
|
|
225
|
+
maxAttempts: requiredNumber(qaRework, "maxAttempts"),
|
|
226
|
+
packetPath: requiredString(qaRework, "packetPath"),
|
|
227
|
+
packetJson: requiredString(qaRework, "packetJson"),
|
|
228
|
+
findingIds: findingIdsValue.map((entry, index) => {
|
|
229
|
+
if (typeof entry !== "string" || entry.trim().length === 0) {
|
|
230
|
+
throw new Error(`qaRework.findingIds[${index}] must be a non-empty string.`);
|
|
231
|
+
}
|
|
232
|
+
return entry;
|
|
233
|
+
}),
|
|
234
|
+
findings: findingsValue.map((entry, index) => asObject(entry, `qaRework.findings[${index}]`))
|
|
235
|
+
};
|
|
236
|
+
}
|
|
141
237
|
function parseArtifacts(value) {
|
|
142
238
|
if (value === undefined || value === null) {
|
|
143
239
|
return [];
|
|
@@ -189,6 +285,16 @@ function requiredBoolean(source, key) {
|
|
|
189
285
|
}
|
|
190
286
|
return value;
|
|
191
287
|
}
|
|
288
|
+
function optionalBoolean(source, key) {
|
|
289
|
+
const value = source[key];
|
|
290
|
+
if (value === undefined || value === null) {
|
|
291
|
+
return null;
|
|
292
|
+
}
|
|
293
|
+
if (typeof value !== "boolean") {
|
|
294
|
+
throw new Error(`${key} must be a boolean when provided.`);
|
|
295
|
+
}
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
192
298
|
function optionalPositiveInteger(source, key) {
|
|
193
299
|
const value = source[key];
|
|
194
300
|
if (value === undefined || value === null) {
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const forgeBridgeVersion = "0.1.1-dev.
|
|
1
|
+
export declare const forgeBridgeVersion = "0.1.1-dev.c5b751411a2b";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const forgeBridgeVersion = "0.1.1-dev.
|
|
1
|
+
export const forgeBridgeVersion = "0.1.1-dev.c5b751411a2b";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DispatchResolvedArtifact } from "../session/session.types.js";
|
|
2
2
|
export declare function injectWorktreeArtifacts(worktreePath: string, artifacts: readonly DispatchResolvedArtifact[]): Promise<void>;
|
|
3
|
+
export declare function filterArtifactsForLane(artifacts: readonly DispatchResolvedArtifact[], lane: string, phase: string): readonly DispatchResolvedArtifact[];
|
|
3
4
|
export declare function writeArtifact(worktreePath: string, artifact: DispatchResolvedArtifact): Promise<void>;
|
|
4
5
|
export declare function selectLaneCommand(artifacts: readonly DispatchResolvedArtifact[], lane: string, phase: string): DispatchResolvedArtifact | undefined;
|
|
5
6
|
export declare function resolveCommandSlug(lane: string, phase: string): string;
|
|
@@ -1,11 +1,52 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
const DEBUG_OPERATIONAL_SKILLS = new Set(["debug-repro", "debug-root-cause", "debug-fix", "debug-regression"]);
|
|
5
|
+
const DEBUG_OPERATIONAL_HOOKS = new Set(["debug-gate", "debug-tool-hook", "debug-rework"]);
|
|
6
|
+
const ARCHITECT_OPERATIONAL_SKILLS = new Set([
|
|
7
|
+
"architect-repo-map",
|
|
8
|
+
"architect-acceptance-map",
|
|
9
|
+
"architect-contract-designer",
|
|
10
|
+
"architect-dag-planner",
|
|
11
|
+
"architect-test-plan-designer",
|
|
12
|
+
"architect-risk-review",
|
|
13
|
+
"architect-integration-strategy",
|
|
14
|
+
"architect-handoff-writer",
|
|
15
|
+
"architect-mcp-contract",
|
|
16
|
+
"architect-semantic-validator"
|
|
17
|
+
]);
|
|
18
|
+
const ARCHITECT_OPERATIONAL_HOOKS = new Set([
|
|
19
|
+
"architect-preflight",
|
|
20
|
+
"architect-context",
|
|
21
|
+
"architect-repo-map",
|
|
22
|
+
"architect-acceptance-map",
|
|
23
|
+
"architect-contracts",
|
|
24
|
+
"architect-plan",
|
|
25
|
+
"architect-qa-seed",
|
|
26
|
+
"architect-integration",
|
|
27
|
+
"architect-mcp-contract",
|
|
28
|
+
"architect-validate-plan",
|
|
29
|
+
"architect-risk-gate",
|
|
30
|
+
"architect-mcp-complete",
|
|
31
|
+
"architect-complete",
|
|
32
|
+
"architect-revise"
|
|
33
|
+
]);
|
|
4
34
|
export async function injectWorktreeArtifacts(worktreePath, artifacts) {
|
|
5
35
|
for (const artifact of artifacts) {
|
|
6
36
|
await writeArtifact(worktreePath, artifact);
|
|
7
37
|
}
|
|
8
38
|
}
|
|
39
|
+
export function filterArtifactsForLane(artifacts, lane, phase) {
|
|
40
|
+
const normalizedLane = lane.trim().toLowerCase();
|
|
41
|
+
const commandSlug = resolveCommandSlug(lane, phase).toLowerCase();
|
|
42
|
+
if (normalizedLane === "debug") {
|
|
43
|
+
return artifacts.filter((artifact) => shouldInjectDebugArtifact(artifact, commandSlug));
|
|
44
|
+
}
|
|
45
|
+
if (normalizedLane === "architect") {
|
|
46
|
+
return artifacts.filter((artifact) => shouldInjectArchitectArtifact(artifact, commandSlug));
|
|
47
|
+
}
|
|
48
|
+
return artifacts;
|
|
49
|
+
}
|
|
9
50
|
export async function writeArtifact(worktreePath, artifact) {
|
|
10
51
|
const writtenHash = sha256(artifact.body);
|
|
11
52
|
if (writtenHash !== artifact.contentHash.toLowerCase()) {
|
|
@@ -29,11 +70,15 @@ export function selectLaneCommand(artifacts, lane, phase) {
|
|
|
29
70
|
return artifacts.find((artifact) => normalizedArtifactKind(artifact.kind) === "command" && artifact.slug.trim().toLowerCase() === slug);
|
|
30
71
|
}
|
|
31
72
|
export function resolveCommandSlug(lane, phase) {
|
|
73
|
+
const normalizedLane = lane.trim().toLowerCase();
|
|
74
|
+
if (normalizedLane === "debug") {
|
|
75
|
+
return "debug-prompt";
|
|
76
|
+
}
|
|
32
77
|
const normalizedPhase = phase.trim().toLowerCase().replace(/-/g, "_");
|
|
33
78
|
if (normalizedPhase === "rework") {
|
|
34
79
|
return "rework-prompt";
|
|
35
80
|
}
|
|
36
|
-
switch (
|
|
81
|
+
switch (normalizedLane) {
|
|
37
82
|
case "architect":
|
|
38
83
|
return "architect-prompt";
|
|
39
84
|
case "qa":
|
|
@@ -42,6 +87,38 @@ export function resolveCommandSlug(lane, phase) {
|
|
|
42
87
|
return "dev-prompt";
|
|
43
88
|
}
|
|
44
89
|
}
|
|
90
|
+
function shouldInjectDebugArtifact(artifact, commandSlug) {
|
|
91
|
+
if (artifact.scope.trim().toLowerCase() !== "operational") {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
const slug = artifact.slug.trim().toLowerCase();
|
|
95
|
+
switch (normalizedArtifactKind(artifact.kind)) {
|
|
96
|
+
case "command":
|
|
97
|
+
return slug === commandSlug;
|
|
98
|
+
case "skill":
|
|
99
|
+
return DEBUG_OPERATIONAL_SKILLS.has(slug);
|
|
100
|
+
case "hook":
|
|
101
|
+
return DEBUG_OPERATIONAL_HOOKS.has(slug);
|
|
102
|
+
default:
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function shouldInjectArchitectArtifact(artifact, commandSlug) {
|
|
107
|
+
if (artifact.scope.trim().toLowerCase() !== "operational") {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const slug = artifact.slug.trim().toLowerCase();
|
|
111
|
+
switch (normalizedArtifactKind(artifact.kind)) {
|
|
112
|
+
case "command":
|
|
113
|
+
return slug === commandSlug;
|
|
114
|
+
case "skill":
|
|
115
|
+
return ARCHITECT_OPERATIONAL_SKILLS.has(slug);
|
|
116
|
+
case "hook":
|
|
117
|
+
return ARCHITECT_OPERATIONAL_HOOKS.has(slug);
|
|
118
|
+
default:
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
45
122
|
export function buildSpecBody(laneCommand, workItem, phase = "implementation") {
|
|
46
123
|
const prompt = laneCommand.body.replaceAll("{workItemId}", workItem.id);
|
|
47
124
|
return `---
|
|
@@ -2,7 +2,7 @@ import fs from "node:fs/promises";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { GitClient } from "../shared/git/git.js";
|
|
4
4
|
import { ensureDirectory, isSubPath, resolveExistingDirectoryPath, safeSegment } from "../shared/path/path.js";
|
|
5
|
-
import { injectWorktreeArtifacts } from "./artifact-injector.js";
|
|
5
|
+
import { filterArtifactsForLane, injectWorktreeArtifacts } from "./artifact-injector.js";
|
|
6
6
|
import { warmWorktreeDependencies } from "./dependency-warmer.js";
|
|
7
7
|
export class GitWorktreeService {
|
|
8
8
|
git;
|
|
@@ -37,8 +37,9 @@ export class GitWorktreeService {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
await this.ensureGitIdentity(resolvedWorktreePath);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const artifacts = filterArtifactsForLane(request.artifacts, request.lane, request.phase);
|
|
41
|
+
if (artifacts.length > 0) {
|
|
42
|
+
await injectWorktreeArtifacts(resolvedWorktreePath, artifacts);
|
|
42
43
|
}
|
|
43
44
|
const dependencyWarm = await warmWorktreeDependencies({
|
|
44
45
|
baseCheckoutPath: repoPath,
|
|
@@ -204,6 +205,7 @@ export function normalizeBranchName(value, fallback) {
|
|
|
204
205
|
branch.endsWith(".") ||
|
|
205
206
|
branch.toLowerCase().endsWith(".lock") ||
|
|
206
207
|
/\s/.test(branch) ||
|
|
208
|
+
// eslint-disable-next-line no-control-regex -- Git branch validation must reject ASCII control characters.
|
|
207
209
|
/[\u0000-\u001f~^:?*[\\]/.test(branch) ||
|
|
208
210
|
branch.split("/").some((part) => part.length === 0 || part.startsWith(".") || part.toLowerCase().endsWith(".lock"))) {
|
|
209
211
|
throw new Error("Git branch name must be valid, without whitespace, and cannot start with '-'.");
|
|
@@ -4,6 +4,8 @@ export interface WorktreePrepareRequest {
|
|
|
4
4
|
readonly repo: DispatchRepo;
|
|
5
5
|
readonly workItem: DispatchWorkItem;
|
|
6
6
|
readonly baseBranch: string;
|
|
7
|
+
readonly lane: string;
|
|
8
|
+
readonly phase: string;
|
|
7
9
|
readonly allowedRepoRoot: string;
|
|
8
10
|
readonly cleanupWorktrees: boolean;
|
|
9
11
|
readonly artifacts: readonly DispatchResolvedArtifact[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loucompanion/forge-bridge",
|
|
3
|
-
"version": "0.1.1-dev.
|
|
3
|
+
"version": "0.1.1-dev.c5b751411a2b",
|
|
4
4
|
"description": "Forge runner bridge CLI for connecting local developer machines to Forge dispatch.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"type": "module",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"url": "https://github.com/coleman399/Forge/issues"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=22.
|
|
33
|
+
"node": ">=22.13.0"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
@@ -39,14 +39,19 @@
|
|
|
39
39
|
"build": "tsc -p tsconfig.json",
|
|
40
40
|
"test": "vitest run",
|
|
41
41
|
"test:watch": "vitest",
|
|
42
|
-
"smoke:package": "npm run build && node scripts/smoke-package.mjs"
|
|
42
|
+
"smoke:package": "npm run build && node scripts/smoke-package.mjs",
|
|
43
|
+
"lint": "eslint \"src/**/*.ts\" \"scripts/**/*.mjs\" \"vitest.config.ts\""
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"@microsoft/signalr": "^8.0.17"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
49
|
+
"@eslint/js": "^10.0.1",
|
|
48
50
|
"@types/node": "^22.15.32",
|
|
51
|
+
"eslint": "^10.5.0",
|
|
52
|
+
"globals": "^17.6.0",
|
|
49
53
|
"typescript": "^5.8.3",
|
|
54
|
+
"typescript-eslint": "^8.61.1",
|
|
50
55
|
"vitest": "^3.2.3"
|
|
51
56
|
}
|
|
52
57
|
}
|