@bridge_gpt/mcp-server 0.2.73 → 0.2.75
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 +14 -7
- package/build/agent-launchers/claude-executor-adapter.js +12 -0
- package/build/agent-launchers/prompt.js +9 -21
- package/build/agents.generated.js +4 -4
- package/build/authored-plan.js +542 -0
- package/build/bridge-config.js +7 -1
- package/build/bridge-permissions.js +11 -0
- package/build/command-provisioning.js +4 -3
- package/build/commands.generated.js +6 -6
- package/build/conductor/bridge-api-client.js +692 -47
- package/build/conductor/command-drift.js +1 -1
- package/build/conductor/declared-extras.js +335 -0
- package/build/conductor/doctor.js +2 -0
- package/build/conductor/driver-pass-output.js +104 -0
- package/build/conductor/driver-pass.js +571 -0
- package/build/conductor/epic-branch-ci-inspection.js +61 -16
- package/build/conductor/epic-implementer-cli.js +370 -93
- package/build/conductor/epic-server-sfcc-upload.js +1567 -0
- package/build/conductor/epic-server-sfcc.js +58 -80
- package/build/conductor/epic-server.js +57 -4
- package/build/conductor/gate-discovery.js +253 -13
- package/build/conductor/gate-settings-review.js +58 -25
- package/build/conductor/launch-plan.js +58 -12
- package/build/conductor/open-decision-phrases.js +50 -0
- package/build/conductor/prerequisite-inputs.js +181 -14
- package/build/connect-github-api.js +18 -0
- package/build/connect-github.js +35 -18
- package/build/credential-delivery.js +280 -0
- package/build/credential-launch-safety.js +142 -0
- package/build/credential-materialization.js +91 -16
- package/build/credential-references-node-deps.js +29 -0
- package/build/credential-references.js +1394 -0
- package/build/credential-references.test-fixtures.js +211 -0
- package/build/credential-scan-conventions.js +145 -0
- package/build/credential-scan.js +517 -0
- package/build/credential-store.js +50 -0
- package/build/credentials-cli.js +252 -3
- package/build/dependency-install-declarations.js +47 -1
- package/build/docs.generated.js +8 -1
- package/build/doctor.js +41 -0
- package/build/drive-epic.js +684 -49
- package/build/epic-branch-ci-summary.js +18 -1
- package/build/epic-capability-statement.js +71 -3
- package/build/epic-ci-workflow-drift.js +52 -13
- package/build/epic-ci-workflow-install.js +31 -6
- package/build/epic-ci-workflow-v3.js +273 -0
- package/build/epic-ci-workflow.js +129 -7
- package/build/epic-implementer-bin.js +288 -83
- package/build/epic-implementer-bundle-cli.js +61 -0
- package/build/epic-implementer-claude-hook-bin.js +1 -1
- package/build/epic-implementer-env.js +3 -4
- package/build/epic-integration-pr.js +5 -2
- package/build/epic-launch-context.js +102 -7
- package/build/epic-server-record.js +30 -15
- package/build/executor/completion-contract.js +24 -1
- package/build/executor/credential-delivery-step.js +168 -0
- package/build/executor/deps.js +3 -1
- package/build/executor/env.js +39 -1
- package/build/executor/epic-server-context.js +23 -7
- package/build/executor/gate-qualification-job.js +193 -23
- package/build/executor/gate-qualification-tests-ran.js +232 -0
- package/build/executor/guarded-fast-forward-push.js +13 -8
- package/build/executor/job-runner.js +167 -738
- package/build/executor/job-type-wrappers.js +734 -0
- package/build/executor/permissions.js +85 -3
- package/build/executor/preflight.js +6 -2
- package/build/executor/process-containment.js +8 -1
- package/build/executor/prompt-spec.js +37 -3
- package/build/executor/required-verification.js +28 -2
- package/build/executor/runner.js +4 -1
- package/build/executor/types.js +9 -0
- package/build/executor/worker-database.js +6 -1
- package/build/executor/worker-guard-hook.js +24 -2
- package/build/executor-launch.js +4 -2
- package/build/generated/ticket-status.js +20 -0
- package/build/git-exclude-lock.js +187 -0
- package/build/index.js +589 -326
- package/build/install-bridge-conductor-answers.js +112 -22
- package/build/install-bridge-conductor-apply.js +38 -1
- package/build/install-bridge-conductor-assessment.js +482 -53
- package/build/install-bridge-conductor-compact.js +29 -2
- package/build/install-bridge-conductor-contracts.js +10 -1
- package/build/install-bridge-conductor-gate.js +379 -89
- package/build/install-bridge-conductor-setup.js +46 -8
- package/build/install-bridge-conductor-trial-report.js +170 -0
- package/build/install-bridge-conductor.js +925 -141
- package/build/install-bridge.js +88 -11
- package/build/install-doctor.js +38 -8
- package/build/install-sfcc-detection.js +120 -0
- package/build/install-sfcc-setup.js +185 -0
- package/build/mcp-grant-candidates.js +108 -96
- package/build/mcp-invoke.js +168 -4
- package/build/mcp-provisioning.js +21 -4
- package/build/mcp-server-invocation.js +13 -0
- package/build/merge-workflow-install.js +9 -1
- package/build/pipelines.generated.js +8 -7
- package/build/plan-generation.js +17 -0
- package/build/plane/status.js +8 -2
- package/build/printed-remedy-commands.js +59 -0
- package/build/project-root.js +40 -0
- package/build/readme.generated.js +1 -1
- package/build/repository-state-paths.js +5 -2
- package/build/repository-toolchains.js +16 -7
- package/build/scripts/saved-commands-config-field-driver.js +65 -0
- package/build/setup-epic.js +126 -16
- package/build/sfcc/credentials.js +3 -2
- package/build/sfcc/hostname.js +98 -2
- package/build/sfcc/tool-wrapper.js +6 -95
- package/build/start-tickets.js +193 -29
- package/build/test-support/executor-source-files.js +200 -0
- package/build/testing-config-client.js +25 -2
- package/build/third-party-mcp-targets.js +35 -4
- package/build/v2-readiness-requirements.js +5 -1
- package/build/version.generated.js +3 -3
- package/build/with-credentials.js +208 -0
- package/build/worker-guard-hook-bin.js +2 -2
- package/build/worktree-credential-delivery.js +340 -0
- package/docs/EPIC-IMPLEMENTER.md +4 -4
- package/docs/install/github-app.md +79 -92
- package/package.json +1 -1
- package/build/conductor/epic-reconcile.js +0 -603
- package/build/conductor/epic-runtime.js +0 -2020
- package/build/conductor/epic-state.js +0 -774
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BAPI-1647: the one file-delivery lifecycle shared by the EI executor and
|
|
3
|
+
* `start-tickets` worktrees.
|
|
4
|
+
*
|
|
5
|
+
* For each approved sandbox `worktree_file` destination, at every worker start:
|
|
6
|
+
*
|
|
7
|
+
* 1. RECONCILE. Bridge keeps a small, names-and-paths-only state file under
|
|
8
|
+
* the worktree's OWN git directory (`git rev-parse --git-dir`, so each
|
|
9
|
+
* linked worktree has its own). A link Bridge recorded that is no longer
|
|
10
|
+
* approved, or whose approved source changed, is removed — but only after
|
|
11
|
+
* `lstat` + `readlink` show it is still exactly the link Bridge made. A
|
|
12
|
+
* regular file, a foreign link, or a target Bridge cannot identify is left
|
|
13
|
+
* in place. An absent or unusable record approves nothing, so it removes
|
|
14
|
+
* every identifiable Bridge link.
|
|
15
|
+
* 2. EXCLUDE FIRST. Every approved destination — retained, new, or one whose
|
|
16
|
+
* source is missing right now — is added to the checkout's local
|
|
17
|
+
* `info/exclude` under the cross-process exclude lock. A link is created
|
|
18
|
+
* (or kept) only after its exclusion succeeded, so a reused worktree never
|
|
19
|
+
* fails the pre-spawn clean check because of an unexcluded link.
|
|
20
|
+
* 3. LINK. Ownership is recorded BEFORE the link is exposed, and rolled back
|
|
21
|
+
* when the hardened materializer refuses. An unrecorded symlink that
|
|
22
|
+
* already points at the approved source is used but never adopted.
|
|
23
|
+
*
|
|
24
|
+
* WHY A SYMLINK IS SAFE TO LEAVE IN A CHECKOUT: git stores a symlink as the
|
|
25
|
+
* link's TARGET PATHNAME, never the bytes of the file it points to. Even a
|
|
26
|
+
* link that was somehow committed would carry only a path such as
|
|
27
|
+
* `/Users/owner/.config/tool/dw.json`, not the secret. The local exclusion is
|
|
28
|
+
* still required so the link (and its path) stays out of commits and out of
|
|
29
|
+
* `git status`.
|
|
30
|
+
*
|
|
31
|
+
* Every failure omits only the affected credential with a named notice. Nothing
|
|
32
|
+
* here fails a job or a `start-tickets` row, and nothing reads or copies a
|
|
33
|
+
* credential file's contents.
|
|
34
|
+
*/
|
|
35
|
+
import { lstat, mkdir, readFile, readlink, realpath, rename, symlink, unlink, writeFile } from "fs/promises";
|
|
36
|
+
import path from "path";
|
|
37
|
+
import { materializeFileCredentialForWorktree, } from "./credential-materialization.js";
|
|
38
|
+
import { defaultExcludeLockDeps, ensureGitInfoExcludedLocked, } from "./git-exclude-lock.js";
|
|
39
|
+
export const CREDENTIAL_LINK_STATE_VERSION = 1;
|
|
40
|
+
/** Relative to the worktree's own git directory. */
|
|
41
|
+
export const CREDENTIAL_LINK_STATE_RELPATH = path.join("bridge", "credential-links.json");
|
|
42
|
+
function errnoCode(err) {
|
|
43
|
+
return err && typeof err === "object" ? err.code : undefined;
|
|
44
|
+
}
|
|
45
|
+
function isWithin(child, root) {
|
|
46
|
+
const rel = path.relative(root, child);
|
|
47
|
+
return rel === "" || (!rel.startsWith("..") && !path.isAbsolute(rel));
|
|
48
|
+
}
|
|
49
|
+
function outcomeFor(reason) {
|
|
50
|
+
switch (reason) {
|
|
51
|
+
case "dest_occupied":
|
|
52
|
+
return "dest_occupied";
|
|
53
|
+
case "dest_unsafe":
|
|
54
|
+
case "invalid_dest":
|
|
55
|
+
return "dest_unsafe";
|
|
56
|
+
default:
|
|
57
|
+
return "dest_unavailable";
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function parseState(raw) {
|
|
61
|
+
let parsed;
|
|
62
|
+
try {
|
|
63
|
+
parsed = JSON.parse(raw);
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
if (!parsed || typeof parsed !== "object")
|
|
69
|
+
return null;
|
|
70
|
+
const obj = parsed;
|
|
71
|
+
if (obj.version !== CREDENTIAL_LINK_STATE_VERSION || !Array.isArray(obj.links))
|
|
72
|
+
return null;
|
|
73
|
+
const links = [];
|
|
74
|
+
for (const item of obj.links) {
|
|
75
|
+
if (!item || typeof item !== "object")
|
|
76
|
+
return null;
|
|
77
|
+
const { name, dest, source } = item;
|
|
78
|
+
if (typeof name !== "string" || typeof dest !== "string" || typeof source !== "string")
|
|
79
|
+
return null;
|
|
80
|
+
if (path.isAbsolute(dest) || dest.split(/[\\/]+/).includes("..") || !path.isAbsolute(source))
|
|
81
|
+
return null;
|
|
82
|
+
links.push({ name, dest, source });
|
|
83
|
+
}
|
|
84
|
+
return { version: CREDENTIAL_LINK_STATE_VERSION, links };
|
|
85
|
+
}
|
|
86
|
+
async function resolveGitDir(worktreeRoot, deps) {
|
|
87
|
+
try {
|
|
88
|
+
const result = await deps.runCommand("git", ["rev-parse", "--git-dir"], { cwd: worktreeRoot });
|
|
89
|
+
const raw = result.stdout.trim();
|
|
90
|
+
if (result.exitCode !== 0 || raw.length === 0)
|
|
91
|
+
return null;
|
|
92
|
+
return path.isAbsolute(raw) ? path.normalize(raw) : path.resolve(worktreeRoot, raw);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Remove one Bridge-recorded link, only when it is still provably Bridge's:
|
|
100
|
+
* its parent canonicalizes inside the worktree, it is a symlink, and it points
|
|
101
|
+
* at the recorded source. Returns "removed", "left" (not identifiable — left in
|
|
102
|
+
* place), or "failed" (identifiable but could not be removed).
|
|
103
|
+
*/
|
|
104
|
+
async function removeOwnedLink(worktreeRoot, realRoot, entry, deps) {
|
|
105
|
+
const linkPath = path.join(worktreeRoot, entry.dest);
|
|
106
|
+
try {
|
|
107
|
+
const parent = await deps.realpath(path.dirname(linkPath));
|
|
108
|
+
if (!isWithin(parent, realRoot))
|
|
109
|
+
return "unsafe";
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
return errnoCode(err) === "ENOENT" ? "removed" : "left";
|
|
113
|
+
}
|
|
114
|
+
let stat;
|
|
115
|
+
try {
|
|
116
|
+
stat = await deps.lstat(linkPath);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
return errnoCode(err) === "ENOENT" ? "removed" : "left";
|
|
120
|
+
}
|
|
121
|
+
if (!stat.isSymbolicLink())
|
|
122
|
+
return "left";
|
|
123
|
+
try {
|
|
124
|
+
if ((await deps.readlink(linkPath)) !== entry.source)
|
|
125
|
+
return "left";
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return "left";
|
|
129
|
+
}
|
|
130
|
+
try {
|
|
131
|
+
await deps.unlink(linkPath);
|
|
132
|
+
return "removed";
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
return errnoCode(err) === "ENOENT" ? "removed" : "failed";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/** Deliver approved file credentials into one worktree. Never throws. */
|
|
139
|
+
export async function deliverWorktreeFileCredentials(input, deps) {
|
|
140
|
+
const result = { delivered: [], notices: [], removed: [] };
|
|
141
|
+
try {
|
|
142
|
+
return await deliver(input, deps, result);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
// Contain anything unexpected: omit every credential not yet delivered.
|
|
146
|
+
const delivered = new Set(result.delivered.map((d) => d.name));
|
|
147
|
+
for (const spec of input.files) {
|
|
148
|
+
if (!delivered.has(spec.name))
|
|
149
|
+
result.notices.push({ name: spec.name, reason: "dest_unavailable" });
|
|
150
|
+
}
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async function deliver(input, deps, result) {
|
|
155
|
+
const { worktreeRoot } = input;
|
|
156
|
+
if (deps.platform === "win32") {
|
|
157
|
+
// The file channel stays gated on Windows; variables and MCP overlays still apply.
|
|
158
|
+
for (const spec of input.files)
|
|
159
|
+
result.notices.push({ name: spec.name, reason: "windows_gated" });
|
|
160
|
+
return result;
|
|
161
|
+
}
|
|
162
|
+
const approved = input.recordState === "ok" ? input.approved : [];
|
|
163
|
+
const gitDir = await resolveGitDir(worktreeRoot, deps);
|
|
164
|
+
if (gitDir === null) {
|
|
165
|
+
for (const spec of input.files)
|
|
166
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
const statePath = path.join(gitDir, CREDENTIAL_LINK_STATE_RELPATH);
|
|
170
|
+
let state;
|
|
171
|
+
try {
|
|
172
|
+
state = parseState(await deps.readFile(statePath));
|
|
173
|
+
}
|
|
174
|
+
catch (err) {
|
|
175
|
+
state = errnoCode(err) === "ENOENT" ? { version: CREDENTIAL_LINK_STATE_VERSION, links: [] } : null;
|
|
176
|
+
}
|
|
177
|
+
if (state === null) {
|
|
178
|
+
// Ownership bookkeeping is unreadable: never guess what Bridge owns.
|
|
179
|
+
for (const spec of input.files)
|
|
180
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
// Nothing recorded, approved, or offered (for example an absent record in a
|
|
184
|
+
// worktree Bridge never linked into): no further filesystem work.
|
|
185
|
+
if (state.links.length === 0 && approved.length === 0 && input.files.length === 0)
|
|
186
|
+
return result;
|
|
187
|
+
let realRoot;
|
|
188
|
+
try {
|
|
189
|
+
realRoot = await deps.realpath(worktreeRoot);
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
for (const spec of input.files)
|
|
193
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
const publish = async (links) => {
|
|
197
|
+
try {
|
|
198
|
+
await deps.mkdir(path.dirname(statePath), { recursive: true });
|
|
199
|
+
const temp = `${statePath}.${deps.tempSuffix ? deps.tempSuffix() : `${process.pid}.${Date.now()}`}.tmp`;
|
|
200
|
+
const body = { version: CREDENTIAL_LINK_STATE_VERSION, links };
|
|
201
|
+
await deps.writeFile(temp, `${JSON.stringify(body, null, 2)}\n`);
|
|
202
|
+
await deps.rename(temp, statePath);
|
|
203
|
+
return true;
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const specByDest = new Map(input.files.map((spec) => [spec.dest, spec]));
|
|
210
|
+
const approvedByDest = new Map(approved.map((a) => [a.dest, a.entry]));
|
|
211
|
+
// 1. Reconcile recorded links.
|
|
212
|
+
const kept = [];
|
|
213
|
+
let stateChanged = false;
|
|
214
|
+
for (const entry of state.links) {
|
|
215
|
+
const stillApproved = approvedByDest.get(entry.dest) === entry.name;
|
|
216
|
+
const spec = specByDest.get(entry.dest);
|
|
217
|
+
const sameSource = spec === undefined || spec.source === entry.source;
|
|
218
|
+
if (stillApproved && sameSource) {
|
|
219
|
+
kept.push(entry);
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
const outcome = await removeOwnedLink(worktreeRoot, realRoot, entry, deps);
|
|
223
|
+
if (outcome === "failed") {
|
|
224
|
+
kept.push(entry);
|
|
225
|
+
result.notices.push({ name: entry.name, reason: "reconcile_failed" });
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
// A parent that now resolves outside the worktree: never delete through
|
|
229
|
+
// it; name the omission and stop tracking a link Bridge cannot reach.
|
|
230
|
+
if (outcome === "unsafe")
|
|
231
|
+
result.notices.push({ name: entry.name, reason: "reconcile_failed" });
|
|
232
|
+
if (outcome === "removed")
|
|
233
|
+
result.removed.push(entry.dest);
|
|
234
|
+
stateChanged = true;
|
|
235
|
+
}
|
|
236
|
+
let links = kept;
|
|
237
|
+
if (stateChanged && !(await publish(links))) {
|
|
238
|
+
for (const spec of input.files)
|
|
239
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
240
|
+
return result;
|
|
241
|
+
}
|
|
242
|
+
// 2. Exclude every approved destination first.
|
|
243
|
+
const gitDeps = {
|
|
244
|
+
readFile: deps.readFile,
|
|
245
|
+
writeFile: deps.writeFile,
|
|
246
|
+
mkdir: deps.mkdir,
|
|
247
|
+
runCommand: deps.runCommand,
|
|
248
|
+
platform: deps.platform,
|
|
249
|
+
};
|
|
250
|
+
const ensureExcluded = deps.ensureExcluded ??
|
|
251
|
+
((root, rel, d) => ensureGitInfoExcludedLocked(root, rel, d, deps.excludeLock ?? defaultExcludeLockDeps()));
|
|
252
|
+
const excluded = new Set();
|
|
253
|
+
for (const { dest } of approved) {
|
|
254
|
+
if (excluded.has(dest))
|
|
255
|
+
continue;
|
|
256
|
+
const outcome = await ensureExcluded(worktreeRoot, dest, gitDeps);
|
|
257
|
+
if (outcome.ok)
|
|
258
|
+
excluded.add(dest);
|
|
259
|
+
}
|
|
260
|
+
// A retained Bridge link whose exclusion failed is withdrawn.
|
|
261
|
+
const retained = [];
|
|
262
|
+
for (const entry of links) {
|
|
263
|
+
if (excluded.has(entry.dest)) {
|
|
264
|
+
retained.push(entry);
|
|
265
|
+
continue;
|
|
266
|
+
}
|
|
267
|
+
const outcome = await removeOwnedLink(worktreeRoot, realRoot, entry, deps);
|
|
268
|
+
if (outcome === "failed") {
|
|
269
|
+
retained.push(entry);
|
|
270
|
+
result.notices.push({ name: entry.name, reason: "reconcile_failed" });
|
|
271
|
+
}
|
|
272
|
+
else if (outcome === "unsafe") {
|
|
273
|
+
result.notices.push({ name: entry.name, reason: "reconcile_failed" });
|
|
274
|
+
}
|
|
275
|
+
else if (outcome === "removed") {
|
|
276
|
+
result.removed.push(entry.dest);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
if (retained.length !== links.length) {
|
|
280
|
+
links = retained;
|
|
281
|
+
if (!(await publish(links))) {
|
|
282
|
+
for (const spec of input.files)
|
|
283
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
284
|
+
return result;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
// 3. Link each resolvable credential whose exclusion succeeded.
|
|
288
|
+
for (const spec of input.files) {
|
|
289
|
+
if (!excluded.has(spec.dest)) {
|
|
290
|
+
result.notices.push({ name: spec.name, reason: "exclude_failed" });
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
const recorded = links.some((l) => l.dest === spec.dest && l.source === spec.source);
|
|
294
|
+
let willCreate = false;
|
|
295
|
+
if (!recorded) {
|
|
296
|
+
try {
|
|
297
|
+
await deps.lstat(path.join(worktreeRoot, spec.dest));
|
|
298
|
+
}
|
|
299
|
+
catch (err) {
|
|
300
|
+
willCreate = errnoCode(err) === "ENOENT";
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (willCreate) {
|
|
304
|
+
const next = [...links.filter((l) => l.dest !== spec.dest), { name: spec.name, dest: spec.dest, source: spec.source }];
|
|
305
|
+
if (!(await publish(next))) {
|
|
306
|
+
result.notices.push({ name: spec.name, reason: "state_write_failed" });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
links = next;
|
|
310
|
+
}
|
|
311
|
+
const materialized = await materializeFileCredentialForWorktree({ canonicalSourcePath: spec.source, worktreeRelativeDestPath: spec.dest }, worktreeRoot, deps);
|
|
312
|
+
if (materialized.ok) {
|
|
313
|
+
result.delivered.push({ name: spec.name, dest: spec.dest });
|
|
314
|
+
continue;
|
|
315
|
+
}
|
|
316
|
+
result.notices.push({ name: spec.name, reason: outcomeFor(materialized.reason) });
|
|
317
|
+
if (willCreate) {
|
|
318
|
+
const rolledBack = links.filter((l) => l.dest !== spec.dest);
|
|
319
|
+
if (await publish(rolledBack))
|
|
320
|
+
links = rolledBack;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return result;
|
|
324
|
+
}
|
|
325
|
+
/** Node-backed deps for the production executor and `start-tickets` callers. */
|
|
326
|
+
export function createNodeWorktreeCredentialDeliveryDeps(runCommand, platform) {
|
|
327
|
+
return {
|
|
328
|
+
platform,
|
|
329
|
+
runCommand,
|
|
330
|
+
readFile: (p) => readFile(p, "utf-8"),
|
|
331
|
+
writeFile: (p, data) => writeFile(p, data, { encoding: "utf-8", mode: 0o600 }),
|
|
332
|
+
mkdir: (p, o) => mkdir(p, o),
|
|
333
|
+
rename: (a, b) => rename(a, b),
|
|
334
|
+
unlink: (p) => unlink(p),
|
|
335
|
+
symlink: (target, linkPath) => symlink(target, linkPath),
|
|
336
|
+
lstat: (p) => lstat(p),
|
|
337
|
+
readlink: (p) => readlink(p),
|
|
338
|
+
realpath: (p) => realpath(p),
|
|
339
|
+
};
|
|
340
|
+
}
|
package/docs/EPIC-IMPLEMENTER.md
CHANGED
|
@@ -34,10 +34,10 @@ typed run-control record that says why and what clears it.
|
|
|
34
34
|
`abandoned`. A ticket that needs a person **parks** as `needs_human`. See
|
|
35
35
|
[Recovering a parked run](#recovering-a-stuck-or-parked-run).
|
|
36
36
|
|
|
37
|
-
**The v1 `epic-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
**The v1 `epic-tick` command is retired.** It is no longer a command, and the
|
|
38
|
+
CLI refuses it as an unknown command. There is nothing to schedule locally. If
|
|
39
|
+
you registered a schedule for it with an older release, remove it; it is a dead
|
|
40
|
+
timer.
|
|
41
41
|
|
|
42
42
|
## Drive an epic: `drive-epic`
|
|
43
43
|
|
|
@@ -49,17 +49,26 @@ to confirm.
|
|
|
49
49
|
|
|
50
50
|
What happens:
|
|
51
51
|
|
|
52
|
-
1. The command opens
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
52
|
+
1. The command opens a Bridge **connect page** in your browser, which sends you to GitHub
|
|
53
|
+
to sign in. Choose the GitHub account you use for this repository.
|
|
54
|
+
2. Bridge lists the installations of the app where you can **change** at least one
|
|
55
|
+
repository (push, maintain, or admin). Pick one, or choose **Install on a new GitHub
|
|
56
|
+
account** to install the app — on GitHub, pick the repositories under **Repository
|
|
57
|
+
access** (see [Choosing repositories](#choosing-repositories)) and click **Install**.
|
|
58
|
+
GitHub then asks you to sign in once more so Bridge can check your access.
|
|
59
|
+
3. Bridge shows a **Confirm GitHub access for this Bridge project** page naming your GitHub
|
|
60
|
+
login, the GitHub account, the Bridge project, and the repositories Bridge may use.
|
|
61
|
+
Click **Confirm connection** only if you started this connection yourself.
|
|
62
|
+
4. The browser lands on *"GitHub connection received — return to your terminal."*
|
|
63
|
+
5. Back in the terminal, the command shows who confirmed GitHub access and the
|
|
64
|
+
repositories you can change, and asks which one to connect. **Every connection is
|
|
65
|
+
confirmed by hand** — even when there is exactly one repository. There is no `--yes`
|
|
66
|
+
flag.
|
|
67
|
+
6. Choose one, and it prints the connected `owner/repo`.
|
|
68
|
+
|
|
69
|
+
**Bridge connects only repositories you can change on GitHub.** A read-only collaborator
|
|
70
|
+
cannot connect an installation, and nobody can connect more repositories than they could
|
|
71
|
+
already push to.
|
|
63
72
|
|
|
64
73
|
**You are never asked for a GitHub token, password, or installation ID.** You
|
|
65
74
|
authenticate to GitHub in your own browser; the terminal only ever carries a short-lived
|
|
@@ -78,11 +87,12 @@ If an organization owns the repository and you are not an owner, GitHub sends an
|
|
|
78
87
|
entirely on GitHub's side and **does not return to your terminal**, so `connect-github`
|
|
79
88
|
cannot wait for it — the command exits, and the 15-minute request expires.
|
|
80
89
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
Once an owner approves, run `connect-github` again. The connect page signs you in to
|
|
91
|
+
GitHub and lists the approved installation, provided you can push to at least one of its
|
|
92
|
+
repositories. If you cannot, the approving owner can connect it instead — or use
|
|
93
|
+
[Option A-2 — delegated handoff](#option-a-2--delegated-handoff-someone-else-installs-it):
|
|
94
|
+
its link stays valid for 72 hours and `--resume` reports `awaiting organization approval`
|
|
95
|
+
while you wait.
|
|
86
96
|
|
|
87
97
|
---
|
|
88
98
|
|
|
@@ -111,12 +121,19 @@ The link is valid for **72 hours** and is **single-use**.
|
|
|
111
121
|
|
|
112
122
|
### 2. Send it to your GitHub org admin
|
|
113
123
|
|
|
114
|
-
They open it
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
They open it and sign in to GitHub. Bridge lists the installations where they can change
|
|
125
|
+
at least one repository, or lets them install the app on a new account. After that,
|
|
126
|
+
Bridge shows a **confirmation page** naming their GitHub login, the GitHub account, the
|
|
127
|
+
requesting Bridge project and account, and the repositories Bridge may use. Nothing is
|
|
128
|
+
staged until they click **Confirm connection**. They then land on a page that tells them
|
|
129
|
+
whether their part succeeded.
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
and the
|
|
131
|
+
Before they prove access on GitHub, the pages show nothing about your project. Bridge
|
|
132
|
+
records the GitHub user ID and login of the person who proved access, with the proof, so
|
|
133
|
+
`--resume` can show you who confirmed. Bridge does not keep their GitHub token.
|
|
134
|
+
|
|
135
|
+
If the person has no write access to any repository in the installation, they see the
|
|
136
|
+
failure page and are asked to contact you. Ask someone who can push to the repository.
|
|
120
137
|
|
|
121
138
|
### 3. Finish the connection
|
|
122
139
|
|
|
@@ -139,14 +156,14 @@ Possible states `--resume` will report:
|
|
|
139
156
|
|---|---|
|
|
140
157
|
| `pending` | Nobody has opened the link yet. |
|
|
141
158
|
| `awaiting organization approval` | They requested the install; a GitHub org owner must approve it. The link stays usable until it expires. |
|
|
142
|
-
| `staged` | Ready — pick a repository
|
|
159
|
+
| `staged` | Ready — `--resume` shows who confirmed GitHub access, then you pick a repository they can change. |
|
|
160
|
+
| `verification-failed` | Access could not be confirmed, or the confirmation is more than 72 hours old. Mint a new link. |
|
|
143
161
|
| `expired` / `revoked` | Mint a new link with `--handoff`. |
|
|
144
162
|
| `connected` | Already finished. |
|
|
145
163
|
|
|
146
|
-
**A staged handoff stays confirmable after the
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
safe. Only the click window expires.
|
|
164
|
+
**A staged handoff stays confirmable for 72 hours after the delegate proved access**,
|
|
165
|
+
even past the link's own deadline. Confirmation re-checks the repositories with GitHub
|
|
166
|
+
at that moment. After 72 hours the proof is too old and you mint a new link.
|
|
150
167
|
|
|
151
168
|
### Revoking a link
|
|
152
169
|
|
|
@@ -161,11 +178,9 @@ even if it had already staged.
|
|
|
161
178
|
|
|
162
179
|
### If the app is already installed on that organization
|
|
163
180
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
not claim to have detected an installation it cannot safely see. In that case use
|
|
168
|
-
[Option C](#option-c--manual-install--installation-id-fallback).
|
|
181
|
+
The same link works. After signing in to GitHub, the recipient sees the existing
|
|
182
|
+
installation in the list and can choose it — as long as they can push to at least one of
|
|
183
|
+
its repositories.
|
|
169
184
|
|
|
170
185
|
---
|
|
171
186
|
|
|
@@ -173,27 +188,23 @@ not claim to have detected an installation it cannot safely see. In that case us
|
|
|
173
188
|
|
|
174
189
|
Bridge captures the installation automatically — you never copy an ID by hand.
|
|
175
190
|
|
|
176
|
-
1. Open your project's **Get Started** page in the Bridge web UI
|
|
177
|
-
on the GitHub connection task
|
|
178
|
-
2. In the **1. Connect GitHub** panel, click **Connect GitHub**. Bridge
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
GitHub, links it to your project, and stores the installation automatically. If the
|
|
189
|
-
installation covers exactly one repo — or one repo clearly matches your project —
|
|
190
|
-
Bridge binds it for you; otherwise it shows a short **repository picker** so you can
|
|
191
|
-
confirm which repo maps to this project.
|
|
192
|
-
7. The outcome appears in the **1. Connect GitHub** panel itself — you should see
|
|
191
|
+
1. Open your project's **Get Started** page in the Bridge web UI, signed in to Bridge. The
|
|
192
|
+
page opens directly on the GitHub connection task.
|
|
193
|
+
2. In the **1. Connect GitHub** panel, click **Connect GitHub**. Bridge sends you to GitHub
|
|
194
|
+
to sign in (choose the GitHub account you use for this repository).
|
|
195
|
+
3. Bridge lists the installations where you can change at least one repository. Choose
|
|
196
|
+
one, or choose **Install on a new GitHub account**: on GitHub, pick the repositories
|
|
197
|
+
under **Repository access** (see [Choosing repositories](#choosing-repositories)) and
|
|
198
|
+
click **Install** (or **Install & request** / **Request** if an org owner must approve).
|
|
199
|
+
4. Bridge confirms your access with GitHub and links the installation to your project. If
|
|
200
|
+
exactly one repository you can change — or one that clearly matches your project — is
|
|
201
|
+
available, Bridge binds it for you; otherwise it shows a short **repository picker**.
|
|
202
|
+
5. The outcome appears in the **1. Connect GitHub** panel — you should see
|
|
193
203
|
**GitHub connected** naming the repository Bridge linked.
|
|
194
204
|
|
|
195
|
-
|
|
196
|
-
|
|
205
|
+
The connection link works only in a browser signed in to the Bridge account that owns the
|
|
206
|
+
project. If an app installation is waiting for organization approval, click **Connect
|
|
207
|
+
GitHub** again after the owner approves.
|
|
197
208
|
|
|
198
209
|
Connecting an editor over MCP is **optional** and is not a prerequisite for any of the
|
|
199
210
|
above. If you need it, the Get Started page keeps that setup in a collapsed
|
|
@@ -202,45 +213,14 @@ if you want it.
|
|
|
202
213
|
|
|
203
214
|
---
|
|
204
215
|
|
|
205
|
-
## Option C —
|
|
206
|
-
|
|
207
|
-
This is the **advanced fallback**, not the normal path — use it only if none of the
|
|
208
|
-
`connect-github` command (Option A), the
|
|
209
|
-
[delegated handoff](#option-a-2--delegated-handoff-someone-else-installs-it) (Option A-2),
|
|
210
|
-
or the one-click **Connect GitHub** button (Option B) is available to you, or if automatic
|
|
211
|
-
linking failed. The main case that still lands here is a GitHub App **already installed**
|
|
212
|
-
on the owning organization, where GitHub may send no callback for Bridge to act on. Get
|
|
213
|
-
Started links to it from the manual-fallback note under the GitHub panel.
|
|
214
|
-
|
|
215
|
-
### 1. Install the app
|
|
216
|
-
|
|
217
|
-
Go to the public install page and install it on the owning account/organization,
|
|
218
|
-
selecting the repository/repositories you want Bridge to access:
|
|
219
|
-
|
|
220
|
-
<https://github.com/apps/bridge-gpt-ai-tools-for-sfcc/installations/new>
|
|
221
|
-
|
|
222
|
-
(Same repository-selection and permissions-review screen as Option B, steps 3–5.)
|
|
223
|
-
|
|
224
|
-
### 2. Find the Installation ID
|
|
225
|
-
|
|
226
|
-
The Installation ID is the trailing number in the app's **Configure** URL:
|
|
227
|
-
|
|
228
|
-
- **Personal account:** open **Settings → Applications → Installed GitHub Apps**, click
|
|
229
|
-
**Configure** next to *Bridge GPT - AI Tools for SFCC*. The URL is
|
|
230
|
-
`https://github.com/settings/installations/<INSTALLATION_ID>`.
|
|
231
|
-
- **Organization:** open **Organization Settings → Third-party Access → GitHub Apps**,
|
|
232
|
-
click **Configure** next to the app. The URL is
|
|
233
|
-
`https://github.com/organizations/<ORG>/settings/installations/<INSTALLATION_ID>`.
|
|
234
|
-
|
|
235
|
-
For example, `https://github.com/organizations/Bridge-GPT/settings/installations/61661616`
|
|
236
|
-
has Installation ID **`61661616`**.
|
|
237
|
-
|
|
238
|
-
### 3. Enter it in Bridge
|
|
216
|
+
## Option C — retired
|
|
239
217
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
218
|
+
Earlier versions let you paste an Installation ID on the project's **Setup** page. That
|
|
219
|
+
path is retired: a GitHub App connection is made only through Option A, A-2, or B, where
|
|
220
|
+
you prove access to the installation on GitHub. The Setup page still shows the stored
|
|
221
|
+
values, accepts saving them unchanged, and lets you disconnect GitHub by clearing both the
|
|
222
|
+
installation ID and the repository together. It refuses a new installation ID or a
|
|
223
|
+
different repository for a GitHub App connection. Bitbucket settings are unaffected.
|
|
244
224
|
|
|
245
225
|
---
|
|
246
226
|
|
|
@@ -286,7 +266,7 @@ After linking, confirm Bridge can act on the repo:
|
|
|
286
266
|
a VCS connection.)
|
|
287
267
|
|
|
288
268
|
If a GitHub-dependent tool refuses, the installation isn't linked to that project yet —
|
|
289
|
-
re-run Option A
|
|
269
|
+
re-run Option A or B.
|
|
290
270
|
|
|
291
271
|
## Managing or removing the app
|
|
292
272
|
|
|
@@ -311,13 +291,20 @@ persists no long-lived GitHub token.
|
|
|
311
291
|
|---|---|
|
|
312
292
|
| `GIT_APP_ID` | The app's numeric App ID — `954077` for *Bridge GPT - AI Tools for SFCC*. |
|
|
313
293
|
| `GIT_PRIVATE_KEY` | **base64-encoded PEM** private key generated for the app (GitHub → app settings → *Generate a private key*). This is the one true secret. |
|
|
314
|
-
| `GITHUB_APP_INSTALL_URL` | The public install URL
|
|
294
|
+
| `GITHUB_APP_INSTALL_URL` | The public install URL, used when someone chooses to install on a new account from the connect page: `https://github.com/apps/bridge-gpt-ai-tools-for-sfcc/installations/new`. |
|
|
295
|
+
| `GITHUB_APP_CLIENT_ID` / `GITHUB_APP_CLIENT_SECRET` | The app's OAuth client, used to prove a person's access to an installation. Without both, Bridge refuses to start a GitHub connection. Removing the secret stops new connections; existing ones keep working. |
|
|
296
|
+
| `BAPI_PUBLIC_BASE_URL` | This deployment's public origin. The connect link and the OAuth callback URL are built from it. |
|
|
315
297
|
| `GITHUB_WEBHOOK_SECRET` | App-level shared secret validating signed `installation` / merge webhooks. If unset, those webhooks are disabled (the redirect-callback path still works). |
|
|
316
298
|
| `BGPT_ENCRYPTION_KEY` | Fernet key used to encrypt per-repo credentials at rest. |
|
|
317
299
|
|
|
318
300
|
The app's **Setup URL** (in GitHub app settings) must point at the deployment's
|
|
319
|
-
`GET /setup/github/callback` endpoint
|
|
320
|
-
|
|
301
|
+
`GET /setup/github/callback` endpoint, which sends the person into the access-proof flow
|
|
302
|
+
after an install. The app's **Callback URL** must be exactly
|
|
303
|
+
`<BAPI_PUBLIC_BASE_URL>/setup/github/authorized` (no trailing slash), with wildcard
|
|
304
|
+
callback matching turned off. Leave **Request user authorization (OAuth) during
|
|
305
|
+
installation** off; Bridge runs GitHub's web application flow itself. See the
|
|
306
|
+
[GitHub installation claims runbook](../../../docs/claude/runbooks/github-installation-claims.md)
|
|
307
|
+
for the rollout checklist. Webhook endpoints used by the integration include the code-review hook
|
|
321
308
|
(e.g. `https://<deployment-host>/github/code-review`); configure these on the app to match
|
|
322
309
|
your deployment host.
|
|
323
310
|
|