@tablation/crew 0.154.0 → 0.155.0
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/cli.js +500 -226
- package/dist/sandbox-intel-bridge.cjs +9 -0
- package/package.json +1 -1
- package/prompts/default/personas/lane-qa.md +6 -1
- package/prompts/default/skills/crew-lane-agent.md +5 -1
- package/prompts/default/skills/worktree-setup.md +4 -0
- package/prompts/dev-qa/personas/lane-qa.md +6 -1
- package/prompts/dev-qa/skills/crew-lane-agent.md +5 -1
- package/prompts/dev-qa/skills/worktree-setup.md +4 -0
package/dist/cli.js
CHANGED
|
@@ -3500,6 +3500,7 @@ var RELEASE_KEYS = /* @__PURE__ */ new Set([
|
|
|
3500
3500
|
"ci",
|
|
3501
3501
|
"verify",
|
|
3502
3502
|
"isolateFailures",
|
|
3503
|
+
"rightOfWayMinutes",
|
|
3503
3504
|
"versioning",
|
|
3504
3505
|
"versionFiles",
|
|
3505
3506
|
"changelog",
|
|
@@ -3511,6 +3512,13 @@ var CI_KEYS = /* @__PURE__ */ new Set(["provider", "ref"]);
|
|
|
3511
3512
|
var VERIFY_KEYS = /* @__PURE__ */ new Set(["match", "timeoutSeconds", "intervalSeconds"]);
|
|
3512
3513
|
var ISOLATE_KEYS = /* @__PURE__ */ new Set(["maxCandidates"]);
|
|
3513
3514
|
var DEFAULT_ISOLATE_MAX_CANDIDATES = 4;
|
|
3515
|
+
var DEFAULT_RIGHT_OF_WAY_MINUTES = 60;
|
|
3516
|
+
function parseRightOfWayMinutes(raw, fail2) {
|
|
3517
|
+
if (raw === void 0 || raw === null) return void 0;
|
|
3518
|
+
const n = Number(raw);
|
|
3519
|
+
if (!Number.isInteger(n) || n < 0) throw fail2(`release.rightOfWayMinutes must be a non-negative integer (got "${raw}")`);
|
|
3520
|
+
return n;
|
|
3521
|
+
}
|
|
3514
3522
|
function parseIsolateMax(raw, where, fail2) {
|
|
3515
3523
|
if (raw === void 0 || raw === null) return void 0;
|
|
3516
3524
|
const n = Number(raw);
|
|
@@ -3735,6 +3743,7 @@ function parseRepoConfig(text2, file) {
|
|
|
3735
3743
|
"release.isolateFailures",
|
|
3736
3744
|
(m) => new RepoConfigError(`${file}: ${m}`)
|
|
3737
3745
|
);
|
|
3746
|
+
const rightOfWay = parseRightOfWayMinutes(raw.release?.rightOfWayMinutes, (m) => new RepoConfigError(`${file}: ${m}`));
|
|
3738
3747
|
const versioning = String(raw.release?.versioning ?? "auto");
|
|
3739
3748
|
if (!VERSIONINGS.includes(versioning)) {
|
|
3740
3749
|
throw new RepoConfigError(`${file}: release.versioning must be auto|none (got "${versioning}")`);
|
|
@@ -3812,6 +3821,7 @@ function parseRepoConfig(text2, file) {
|
|
|
3812
3821
|
ci: { provider, ref: raw.release?.ci?.ref ? String(raw.release.ci.ref) : void 0 },
|
|
3813
3822
|
verify,
|
|
3814
3823
|
isolateFailures: isolateMax === void 0 ? void 0 : { maxCandidates: isolateMax },
|
|
3824
|
+
rightOfWayMinutes: rightOfWay,
|
|
3815
3825
|
versioning,
|
|
3816
3826
|
versionFiles,
|
|
3817
3827
|
tag,
|
|
@@ -4022,6 +4032,7 @@ function resolveRepoConfig(repo, ship, dir) {
|
|
|
4022
4032
|
DEFAULT_ISOLATE_MAX_CANDIDATES
|
|
4023
4033
|
)
|
|
4024
4034
|
},
|
|
4035
|
+
rightOfWayMinutes: repo?.release.rightOfWayMinutes ?? ship?.release?.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES,
|
|
4025
4036
|
versioning: pick(
|
|
4026
4037
|
"release.versioning",
|
|
4027
4038
|
repo?.release.versioning === "auto" ? void 0 : repo?.release.versioning,
|
|
@@ -7214,14 +7225,14 @@ function envForRepository(entries, repo) {
|
|
|
7214
7225
|
|
|
7215
7226
|
// src/interrupted.ts
|
|
7216
7227
|
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
|
|
7217
|
-
import { join as
|
|
7228
|
+
import { join as join35 } from "path";
|
|
7218
7229
|
|
|
7219
7230
|
// src/agent.ts
|
|
7220
7231
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
7221
7232
|
import { readFileSync as readFileSync31, existsSync as existsSync29, statSync as statSync9, mkdirSync as mkdirSync22, writeFileSync as writeFileSync23, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
|
|
7222
7233
|
import { StringDecoder } from "string_decoder";
|
|
7223
7234
|
import { finished } from "stream/promises";
|
|
7224
|
-
import { join as
|
|
7235
|
+
import { join as join34, dirname as dirname17, basename as basename9 } from "path";
|
|
7225
7236
|
import { createHash as createHash6, randomUUID as randomUUID2 } from "crypto";
|
|
7226
7237
|
|
|
7227
7238
|
// src/state.ts
|
|
@@ -9180,13 +9191,14 @@ var runInputFor = (run4) => live.get(run4);
|
|
|
9180
9191
|
|
|
9181
9192
|
// src/agent-log.ts
|
|
9182
9193
|
import { existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync19 } from "fs";
|
|
9183
|
-
import { join as
|
|
9194
|
+
import { join as join28 } from "path";
|
|
9184
9195
|
|
|
9185
9196
|
// src/pending-backoff.ts
|
|
9186
9197
|
var sleepBackoff = (attempts) => Math.min(6e4 * 2 ** Math.max(0, attempts - 1), 30 * 6e4);
|
|
9187
9198
|
|
|
9188
9199
|
// src/handoff-guard.ts
|
|
9189
|
-
import { existsSync as existsSync24 } from "fs";
|
|
9200
|
+
import { existsSync as existsSync24, realpathSync as realpathSync2 } from "fs";
|
|
9201
|
+
import { dirname as dirname14, join as join27 } from "path";
|
|
9190
9202
|
|
|
9191
9203
|
// src/ticket-branch.ts
|
|
9192
9204
|
import { basename as basename7 } from "path";
|
|
@@ -10823,6 +10835,67 @@ function inspectHandoff(dir, cfg, ticket, role) {
|
|
|
10823
10835
|
}
|
|
10824
10836
|
return { kind: "pushed", branch, sha: origin, remote };
|
|
10825
10837
|
}
|
|
10838
|
+
var sameDir = (a, b) => {
|
|
10839
|
+
try {
|
|
10840
|
+
return realpathSync2(a) === realpathSync2(b);
|
|
10841
|
+
} catch {
|
|
10842
|
+
return a === b;
|
|
10843
|
+
}
|
|
10844
|
+
};
|
|
10845
|
+
function repairMisnamedBranch(dir, cfg, ticket, role) {
|
|
10846
|
+
const expected = branchCandidatesForTicket(cfg, ticket, role).find((c) => !c.endsWith("*"));
|
|
10847
|
+
if (!expected) return { kind: "none" };
|
|
10848
|
+
const wtPath = join27(dirname14(dir), worktreeForTicket(dir, cfg, ticket, role));
|
|
10849
|
+
const wt = worktrees(dir).find((w) => !w.prunable && sameDir(w.path, wtPath));
|
|
10850
|
+
const from = wt?.branch;
|
|
10851
|
+
if (!wt || !from || from === cfg.branch.base) return { kind: "none" };
|
|
10852
|
+
const existing = existingBranchForTicket(dir, cfg, ticket, role);
|
|
10853
|
+
if (existing === from) return { kind: "none" };
|
|
10854
|
+
const base = [`${cfg.branch.remote}/${cfg.branch.base}`, cfg.branch.base].find((b) => gitOk(dir, ["rev-parse", "--verify", "-q", b]) !== null);
|
|
10855
|
+
const ahead = base ? Number(gitOk(dir, ["rev-list", "--count", `${base}..${from}`]) ?? "1") : 1;
|
|
10856
|
+
if (ahead === 0) return { kind: "none" };
|
|
10857
|
+
if (existing) {
|
|
10858
|
+
return {
|
|
10859
|
+
kind: "refused",
|
|
10860
|
+
from,
|
|
10861
|
+
to: existing,
|
|
10862
|
+
local: headSha(wt.path),
|
|
10863
|
+
reason: `the ticket's worktree is on \`${from}\`, but the contract branch \`${existing}\` already exists and the runner will not overwrite it, so \`${from}\` was left as it is (expected name: \`${expected}\`)`
|
|
10864
|
+
};
|
|
10865
|
+
}
|
|
10866
|
+
try {
|
|
10867
|
+
git(dir, ["branch", "-m", from, expected]);
|
|
10868
|
+
} catch (e) {
|
|
10869
|
+
return {
|
|
10870
|
+
kind: "refused",
|
|
10871
|
+
from,
|
|
10872
|
+
to: expected,
|
|
10873
|
+
local: headSha(wt.path),
|
|
10874
|
+
reason: `the ticket's worktree is on \`${from}\`, not the expected \`${expected}\`, and renaming it failed: ${e.message}`
|
|
10875
|
+
};
|
|
10876
|
+
}
|
|
10877
|
+
return { kind: "renamed", from, to: expected };
|
|
10878
|
+
}
|
|
10879
|
+
async function announceRename(i, ticketId, r, sha, remote, log) {
|
|
10880
|
+
let remoteNote;
|
|
10881
|
+
const tip = remoteTip(i.dir, remote, r.from);
|
|
10882
|
+
if (tip === null) remoteNote = `Could not ask \`${remote}\` about \`${r.from}\`, so any copy of it there was left in place.`;
|
|
10883
|
+
else if (!tip) remoteNote = `\`${r.from}\` was never on \`${remote}\`.`;
|
|
10884
|
+
else if (tip === sha) {
|
|
10885
|
+
try {
|
|
10886
|
+
git(i.dir, ["push", remote, "--delete", r.from]);
|
|
10887
|
+
remoteNote = `The misnamed \`${remote}/${r.from}\` was at the same tip and has been deleted.`;
|
|
10888
|
+
} catch (e) {
|
|
10889
|
+
remoteNote = `\`${remote}/${r.from}\` is at the same tip but could not be deleted: ${e.message}`;
|
|
10890
|
+
}
|
|
10891
|
+
} else remoteNote = `\`${remote}/${r.from}\` is at \`${tip}\`, a different tip than the renamed branch, and was left in place.`;
|
|
10892
|
+
await i.writer.postEvent(
|
|
10893
|
+
ticketId,
|
|
10894
|
+
`The runner renamed the local branch \`${r.from}\` to \`${r.to}\` (the contract name) and pushed it to \`${remote}\` at ${sha}: the ${i.role} run built this ticket on a branch with another name, which QA and the release phase cannot find. ${remoteNote}`,
|
|
10895
|
+
i.seatId,
|
|
10896
|
+
"renamed_by_runner"
|
|
10897
|
+
).catch((e) => i.log.warn(`renamed, but the note failed to post: ${e.message}`, log));
|
|
10898
|
+
}
|
|
10826
10899
|
function pushableBounce(dir, v) {
|
|
10827
10900
|
if (!v.branch || !v.local) return false;
|
|
10828
10901
|
return !v.origin || isAncestor(dir, v.origin, v.local);
|
|
@@ -10944,6 +11017,17 @@ ${acceptanceChecklistBlock(shown(all))}
|
|
|
10944
11017
|
}
|
|
10945
11018
|
return boundNote(build(most));
|
|
10946
11019
|
}
|
|
11020
|
+
function pushForSeat(i, t, v) {
|
|
11021
|
+
const wt = worktrees(i.dir).find((w) => w.branch === v.branch);
|
|
11022
|
+
try {
|
|
11023
|
+
pushBranchUpstream(wt?.path ?? i.dir, v.remote, v.branch);
|
|
11024
|
+
const again = inspectHandoff(i.dir, i.cfg, t, i.role);
|
|
11025
|
+
if (again.kind === "pushed") return { again };
|
|
11026
|
+
return { error: `the push succeeded but ${again.kind === "bounce" ? again.reason : again.why}` };
|
|
11027
|
+
} catch (e) {
|
|
11028
|
+
return { error: e.message };
|
|
11029
|
+
}
|
|
11030
|
+
}
|
|
10947
11031
|
async function enforceHandoff(i) {
|
|
10948
11032
|
try {
|
|
10949
11033
|
const t = await i.writer.ticket(i.ticketId);
|
|
@@ -10954,7 +11038,10 @@ async function enforceHandoff(i) {
|
|
|
10954
11038
|
i.log.emit(`${displayKey(t)} is at ${t.status}, not handed off \u2014 nothing to check`, log);
|
|
10955
11039
|
return { kind: "not-handed-off" };
|
|
10956
11040
|
}
|
|
10957
|
-
const
|
|
11041
|
+
const repair = i.origin ? { kind: "none" } : repairMisnamedBranch(i.dir, i.cfg, t, i.role);
|
|
11042
|
+
const renamed = repair.kind === "renamed" ? repair : null;
|
|
11043
|
+
if (renamed) i.log.warn(`${displayKey(t)}: renamed the misnamed branch ${renamed.from} to ${renamed.to}`, log);
|
|
11044
|
+
const v = repair.kind === "refused" ? { kind: "bounce", branch: null, remote: i.cfg.branch.remote, local: repair.local, origin: null, reason: repair.reason } : i.origin ? inspectRemoteHandoff(i.origin, i.cfg, t, i.role) : inspectHandoff(i.dir, i.cfg, t, i.role);
|
|
10958
11045
|
if (v.kind === "unverified") {
|
|
10959
11046
|
i.log.warn(`${displayKey(t)} is at ${t.status} but the push was not checked: ${v.why}`, log);
|
|
10960
11047
|
return { kind: "unverified", why: v.why };
|
|
@@ -10983,10 +11070,21 @@ async function enforceHandoff(i) {
|
|
|
10983
11070
|
}
|
|
10984
11071
|
if (v.kind === "pushed") {
|
|
10985
11072
|
await postPushed(i, t.id, v.sha, v.remote, v.branch, log);
|
|
11073
|
+
if (renamed) await announceRename(i, t.id, renamed, v.sha, v.remote, log);
|
|
10986
11074
|
i.log.emit(`${displayKey(t)} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
|
|
10987
11075
|
return { kind: "pushed", sha: v.sha };
|
|
10988
11076
|
}
|
|
10989
11077
|
if (claimed) {
|
|
11078
|
+
if (renamed && pushableBounce(i.dir, v)) {
|
|
11079
|
+
const done = pushForSeat(i, t, v);
|
|
11080
|
+
if (done.again) {
|
|
11081
|
+
await postPushed(i, t.id, done.again.sha, done.again.remote, done.again.branch, log);
|
|
11082
|
+
await announceRename(i, t.id, renamed, done.again.sha, done.again.remote, log);
|
|
11083
|
+
return { kind: "pushed", sha: done.again.sha };
|
|
11084
|
+
}
|
|
11085
|
+
i.log.warn(`${displayKey(t)} is at ${t.status} and its renamed branch could not be pushed: ${done.error}`, log);
|
|
11086
|
+
return { kind: "failed", why: done.error ?? v.reason };
|
|
11087
|
+
}
|
|
10990
11088
|
i.log.warn(`${displayKey(t)} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
|
|
10991
11089
|
return { kind: "failed", why: v.reason };
|
|
10992
11090
|
}
|
|
@@ -11005,26 +11103,24 @@ async function enforceHandoff(i) {
|
|
|
11005
11103
|
}
|
|
11006
11104
|
let pushError;
|
|
11007
11105
|
if (pushableBounce(i.dir, v)) {
|
|
11008
|
-
const
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
const
|
|
11012
|
-
if (
|
|
11013
|
-
|
|
11106
|
+
const done = pushForSeat(i, t, v);
|
|
11107
|
+
if (done.again) {
|
|
11108
|
+
const again = done.again;
|
|
11109
|
+
const posted = await postPushed(i, t.id, again.sha, again.remote, again.branch, log).then(() => null, (e) => e.message);
|
|
11110
|
+
if (posted !== null) pushError = posted;
|
|
11111
|
+
else {
|
|
11014
11112
|
await i.writer.postEvent(
|
|
11015
11113
|
t.id,
|
|
11016
11114
|
`The runner pushed \`${again.branch}\` to \`${again.remote}\` on ${i.shipName ? `${i.shipName}'s` : "this ship's"} behalf: the ${i.role} seat set \`${i.contract.statuses.handoff}\` without pushing. Plain fast-forward push.${i.cfg.hooks.ci_status ? " The repo's `ci_status` hook was NOT run by the hand-off guard, so CI was not checked by the builder." : ""}`,
|
|
11017
11115
|
i.seatId,
|
|
11018
11116
|
"pushed_by_runner"
|
|
11019
11117
|
).catch((e) => i.log.warn(`pushed, but the note failed to post: ${e.message}`, log));
|
|
11118
|
+
if (renamed) await announceRename(i, t.id, renamed, again.sha, again.remote, log);
|
|
11020
11119
|
i.log.emit(`${displayKey(t)}: pushed ${again.branch} to ${again.remote} on the seat's behalf at ${again.sha.slice(0, 7)} \u2014 handed on to QA`, log);
|
|
11021
11120
|
return { kind: "pushed", sha: again.sha };
|
|
11022
11121
|
}
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
pushError = e.message;
|
|
11026
|
-
}
|
|
11027
|
-
i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
|
|
11122
|
+
} else pushError = done.error;
|
|
11123
|
+
if (pushError) i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
|
|
11028
11124
|
}
|
|
11029
11125
|
if (!await deliverNote(i, t.id, bounceComment(v, i.shipName, pushError), "bounced", log)) {
|
|
11030
11126
|
i.log.warn(`${displayKey(t)}: ${v.reason}, but the bounce note could not be delivered \u2014 left at ${t.status}, guard outcome unverified`, log);
|
|
@@ -11758,17 +11854,17 @@ async function addRunToTicket(target, t, recordId, run4) {
|
|
|
11758
11854
|
};
|
|
11759
11855
|
}
|
|
11760
11856
|
}
|
|
11761
|
-
var queueDir = (stateDir) =>
|
|
11857
|
+
var queueDir = (stateDir) => join28(stateDir, "pending-agent-logs");
|
|
11762
11858
|
function queueAgentRun(stateDir, name, q2) {
|
|
11763
11859
|
mkdirSync18(queueDir(stateDir), { recursive: true });
|
|
11764
|
-
writeFileSync19(
|
|
11860
|
+
writeFileSync19(join28(queueDir(stateDir), `${name}.json`), JSON.stringify(q2));
|
|
11765
11861
|
}
|
|
11766
11862
|
async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
|
|
11767
11863
|
const dir = queueDir(stateDir);
|
|
11768
11864
|
if (!existsSync25(dir)) return 0;
|
|
11769
11865
|
let sent = 0;
|
|
11770
11866
|
for (const f of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
|
|
11771
|
-
const path =
|
|
11867
|
+
const path = join28(dir, f);
|
|
11772
11868
|
let q2;
|
|
11773
11869
|
try {
|
|
11774
11870
|
q2 = JSON.parse(readFileSync25(path, "utf8"));
|
|
@@ -11811,17 +11907,17 @@ async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__
|
|
|
11811
11907
|
}
|
|
11812
11908
|
return sent;
|
|
11813
11909
|
}
|
|
11814
|
-
var countersDir = (stateDir) =>
|
|
11910
|
+
var countersDir = (stateDir) => join28(stateDir, "pending-ticket-counters");
|
|
11815
11911
|
function queueTicketCounters(stateDir, name, q2) {
|
|
11816
11912
|
mkdirSync18(countersDir(stateDir), { recursive: true });
|
|
11817
|
-
writeFileSync19(
|
|
11913
|
+
writeFileSync19(join28(countersDir(stateDir), `${name}.json`), JSON.stringify(q2));
|
|
11818
11914
|
}
|
|
11819
11915
|
async function replayQueuedTicketCounters(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
|
|
11820
11916
|
const dir = countersDir(stateDir);
|
|
11821
11917
|
if (!existsSync25(dir)) return 0;
|
|
11822
11918
|
let sent = 0;
|
|
11823
11919
|
for (const f of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
|
|
11824
|
-
const path =
|
|
11920
|
+
const path = join28(dir, f);
|
|
11825
11921
|
let q2;
|
|
11826
11922
|
try {
|
|
11827
11923
|
q2 = JSON.parse(readFileSync25(path, "utf8"));
|
|
@@ -12085,8 +12181,8 @@ var HandoffTranscriptTracker = class {
|
|
|
12085
12181
|
// src/seat-notes.ts
|
|
12086
12182
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync20 } from "fs";
|
|
12087
12183
|
import { randomUUID } from "crypto";
|
|
12088
|
-
import { join as
|
|
12089
|
-
var fileFor2 = (stateDir, role) =>
|
|
12184
|
+
import { join as join29 } from "path";
|
|
12185
|
+
var fileFor2 = (stateDir, role) => join29(stateDir, "seat-notes", `${role}.jsonl`);
|
|
12090
12186
|
var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
12091
12187
|
function readAll(stateDir, role) {
|
|
12092
12188
|
let raw;
|
|
@@ -12107,7 +12203,7 @@ function readAll(stateDir, role) {
|
|
|
12107
12203
|
}
|
|
12108
12204
|
function addSeatNote(stateDir, note, now = /* @__PURE__ */ new Date()) {
|
|
12109
12205
|
const full = { id: randomUUID(), createdAt: now.toISOString(), ...note };
|
|
12110
|
-
mkdirSync19(
|
|
12206
|
+
mkdirSync19(join29(stateDir, "seat-notes"), { recursive: true });
|
|
12111
12207
|
appendFileSync3(fileFor2(stateDir, note.role), `${JSON.stringify(full)}
|
|
12112
12208
|
`);
|
|
12113
12209
|
return full;
|
|
@@ -12146,7 +12242,7 @@ import { createHash as createHash4 } from "crypto";
|
|
|
12146
12242
|
import { spawn as spawn4 } from "child_process";
|
|
12147
12243
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
12148
12244
|
import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
|
|
12149
|
-
import { dirname as
|
|
12245
|
+
import { dirname as dirname15, join as join30 } from "path";
|
|
12150
12246
|
import { fileURLToPath } from "url";
|
|
12151
12247
|
import { tmpdir as tmpdir3 } from "os";
|
|
12152
12248
|
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
@@ -12161,8 +12257,8 @@ var SANDBOX_UID = 1e3;
|
|
|
12161
12257
|
var CREW_PREFIX = "/opt/crew";
|
|
12162
12258
|
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
12163
12259
|
function readBridgeBundle() {
|
|
12164
|
-
const here =
|
|
12165
|
-
for (const p of [
|
|
12260
|
+
const here = dirname15(fileURLToPath(import.meta.url));
|
|
12261
|
+
for (const p of [join30(here, "sandbox-intel-bridge.cjs"), join30(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
12166
12262
|
if (existsSync26(p)) return readFileSync27(p, "utf8");
|
|
12167
12263
|
}
|
|
12168
12264
|
return void 0;
|
|
@@ -12338,7 +12434,7 @@ function planSandbox(repo, decl, warm = {}, bridge) {
|
|
|
12338
12434
|
}
|
|
12339
12435
|
var SHIP_SANDBOX_KEY = "@ship";
|
|
12340
12436
|
var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
|
|
12341
|
-
var sandboxStatePath = (stateDir) =>
|
|
12437
|
+
var sandboxStatePath = (stateDir) => join30(stateDir, "sandbox-images.json");
|
|
12342
12438
|
function readSandboxState(stateDir) {
|
|
12343
12439
|
try {
|
|
12344
12440
|
const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
|
|
@@ -12410,7 +12506,7 @@ var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
|
12410
12506
|
} catch {
|
|
12411
12507
|
}
|
|
12412
12508
|
};
|
|
12413
|
-
var sandboxLogDir = (stateDir) =>
|
|
12509
|
+
var sandboxLogDir = (stateDir) => join30(stateDir, "sandbox-logs");
|
|
12414
12510
|
async function buildSandboxImage(plan, deps) {
|
|
12415
12511
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
12416
12512
|
const state = readSandboxState(deps.stateDir);
|
|
@@ -12420,20 +12516,20 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12420
12516
|
}
|
|
12421
12517
|
const logDir = sandboxLogDir(deps.stateDir);
|
|
12422
12518
|
mkdirSync20(logDir, { recursive: true });
|
|
12423
|
-
const logPath =
|
|
12519
|
+
const logPath = join30(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
12424
12520
|
const builtLayers = [];
|
|
12425
12521
|
for (const layer of plan.layers) {
|
|
12426
12522
|
if (deps.hasImage(layer.tag)) continue;
|
|
12427
|
-
const ctx =
|
|
12523
|
+
const ctx = join30(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
12428
12524
|
mkdirSync20(ctx, { recursive: true });
|
|
12429
12525
|
try {
|
|
12430
|
-
writeFileSync21(
|
|
12526
|
+
writeFileSync21(join30(ctx, "Dockerfile"), layer.dockerfile);
|
|
12431
12527
|
for (const [name, content] of Object.entries(layer.files)) {
|
|
12432
|
-
mkdirSync20(
|
|
12433
|
-
writeFileSync21(
|
|
12528
|
+
mkdirSync20(dirname15(join30(ctx, name)), { recursive: true });
|
|
12529
|
+
writeFileSync21(join30(ctx, name), content);
|
|
12434
12530
|
}
|
|
12435
|
-
if (layer.caBundleFile) writeFileSync21(
|
|
12436
|
-
const code = await deps.run(["build", "--tag", layer.tag, "--file",
|
|
12531
|
+
if (layer.caBundleFile) writeFileSync21(join30(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
12532
|
+
const code = await deps.run(["build", "--tag", layer.tag, "--file", join30(ctx, "Dockerfile"), ctx], logPath);
|
|
12437
12533
|
if (code === BUILD_INTERRUPTED) return { kind: "interrupted", tag: plan.tag };
|
|
12438
12534
|
if (code !== 0) {
|
|
12439
12535
|
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
@@ -12552,7 +12648,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
|
12552
12648
|
|
|
12553
12649
|
// src/skills.ts
|
|
12554
12650
|
import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
|
|
12555
|
-
import { join as
|
|
12651
|
+
import { join as join32 } from "path";
|
|
12556
12652
|
import { parse as parseYaml2 } from "yaml";
|
|
12557
12653
|
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
12558
12654
|
|
|
@@ -12585,7 +12681,7 @@ function readPersonaFile(path) {
|
|
|
12585
12681
|
|
|
12586
12682
|
// src/agents.ts
|
|
12587
12683
|
import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
|
|
12588
|
-
import { join as
|
|
12684
|
+
import { join as join31 } from "path";
|
|
12589
12685
|
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
12590
12686
|
var PERSONA_NAME = {
|
|
12591
12687
|
dev: "Developer",
|
|
@@ -12599,16 +12695,16 @@ var CREW_AGENT_COLUMN = "agent_id";
|
|
|
12599
12695
|
var AgentsSyncError = class extends Error {
|
|
12600
12696
|
};
|
|
12601
12697
|
function personaDefaultPrompt(promptsDir, role) {
|
|
12602
|
-
const briefPath =
|
|
12698
|
+
const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
|
|
12603
12699
|
if (!existsSync27(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
|
|
12604
12700
|
const brief = readPersonaFile(briefPath).body;
|
|
12605
12701
|
if (SELF_CONTAINED_ROLES.has(role)) return brief;
|
|
12606
|
-
const commonPath =
|
|
12702
|
+
const commonPath = join31(promptsDir, "personas", "common.md");
|
|
12607
12703
|
if (!existsSync27(commonPath)) return brief;
|
|
12608
12704
|
return `${readFileSync29(commonPath, "utf8")}${brief}`;
|
|
12609
12705
|
}
|
|
12610
12706
|
function personaChatEnabled(promptsDir, role) {
|
|
12611
|
-
const briefPath =
|
|
12707
|
+
const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
|
|
12612
12708
|
return existsSync27(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
|
|
12613
12709
|
}
|
|
12614
12710
|
async function resolveAgentId(route2, role, opts) {
|
|
@@ -13106,9 +13202,9 @@ function parseSkillFile(path) {
|
|
|
13106
13202
|
};
|
|
13107
13203
|
}
|
|
13108
13204
|
function listLocalSkills(promptsDir) {
|
|
13109
|
-
const dir =
|
|
13205
|
+
const dir = join32(promptsDir, "skills");
|
|
13110
13206
|
if (!existsSync28(dir)) return [];
|
|
13111
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(
|
|
13207
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join32(dir, f)));
|
|
13112
13208
|
}
|
|
13113
13209
|
function personaColumn(model) {
|
|
13114
13210
|
for (const c of ["persona_id", "persona"]) if (model.fields?.some((f) => f.columnName === c)) return c;
|
|
@@ -13345,7 +13441,7 @@ import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_
|
|
|
13345
13441
|
import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
|
|
13346
13442
|
import { createHash as createHash5 } from "crypto";
|
|
13347
13443
|
import { tmpdir as tmpdir4 } from "os";
|
|
13348
|
-
import { basename as basename8, dirname as
|
|
13444
|
+
import { basename as basename8, dirname as dirname16, join as join33 } from "path";
|
|
13349
13445
|
import { promisify } from "util";
|
|
13350
13446
|
|
|
13351
13447
|
// src/run-limit.ts
|
|
@@ -13496,7 +13592,7 @@ var SandboxRunner = class {
|
|
|
13496
13592
|
throw new Error(`cannot generate the sandbox policy: ${e.message}`);
|
|
13497
13593
|
}
|
|
13498
13594
|
policyFile = policyPathFor(plan.streamPath);
|
|
13499
|
-
mkdirSync21(
|
|
13595
|
+
mkdirSync21(dirname16(policyFile), { recursive: true });
|
|
13500
13596
|
writeFileSync22(policyFile, generated.yaml, { mode: 384 });
|
|
13501
13597
|
}
|
|
13502
13598
|
const create2 = ["sandbox", "create", "--name", name, "--detach"];
|
|
@@ -13546,9 +13642,9 @@ var SandboxRunner = class {
|
|
|
13546
13642
|
const harness = cfg.agentBin ?? basename8(plan.bin);
|
|
13547
13643
|
const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
|
|
13548
13644
|
if (viaUpload) {
|
|
13549
|
-
const tmp = mkdtempSync(
|
|
13645
|
+
const tmp = mkdtempSync(join33(tmpdir4(), "crew-prompt-"));
|
|
13550
13646
|
try {
|
|
13551
|
-
const file =
|
|
13647
|
+
const file = join33(tmp, "prompt.txt");
|
|
13552
13648
|
writeFileSync22(file, plan.prompt, { mode: 384 });
|
|
13553
13649
|
await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
|
|
13554
13650
|
} finally {
|
|
@@ -13770,7 +13866,7 @@ function streamShowsAllowanceRefusal(streamPath) {
|
|
|
13770
13866
|
}
|
|
13771
13867
|
return false;
|
|
13772
13868
|
}
|
|
13773
|
-
var digestPathFor = (stateDir, routeLabel, role, runId) =>
|
|
13869
|
+
var digestPathFor = (stateDir, routeLabel, role, runId) => join34(stateDir, `digest-${routeLabel}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
13774
13870
|
function codeBridgeFor(o, harness) {
|
|
13775
13871
|
if (!o.ticket) return void 0;
|
|
13776
13872
|
const number = /(\d+)$/.exec(o.ticket)?.[1];
|
|
@@ -13798,7 +13894,7 @@ function codeBridgeFor(o, harness) {
|
|
|
13798
13894
|
"--clone",
|
|
13799
13895
|
o.ship.sandbox?.workDir ?? DEFAULT_SANDBOX_WORKDIR,
|
|
13800
13896
|
"--state-dir",
|
|
13801
|
-
|
|
13897
|
+
dirname17(SANDBOX_INTEL_DIR),
|
|
13802
13898
|
"--ticket",
|
|
13803
13899
|
number,
|
|
13804
13900
|
...seed ? ["--seed-cache", seed] : []
|
|
@@ -13811,8 +13907,8 @@ function codeBridgeFor(o, harness) {
|
|
|
13811
13907
|
bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
|
|
13812
13908
|
bridge.files = [{ path: bridge.settingsFile, content: text2 }];
|
|
13813
13909
|
} else {
|
|
13814
|
-
const file =
|
|
13815
|
-
mkdirSync22(
|
|
13910
|
+
const file = join34(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
|
|
13911
|
+
mkdirSync22(dirname17(file), { recursive: true });
|
|
13816
13912
|
writeFileSync23(file, text2);
|
|
13817
13913
|
bridge.settingsFile = file;
|
|
13818
13914
|
}
|
|
@@ -13820,11 +13916,11 @@ function codeBridgeFor(o, harness) {
|
|
|
13820
13916
|
return bridge;
|
|
13821
13917
|
}
|
|
13822
13918
|
function planAgentRun(o) {
|
|
13823
|
-
const briefPath =
|
|
13919
|
+
const briefPath = join34(o.route.promptsDir, "personas", `lane-${o.role}.md`);
|
|
13824
13920
|
if (!existsSync29(briefPath)) {
|
|
13825
13921
|
throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
|
|
13826
13922
|
}
|
|
13827
|
-
const commonPath =
|
|
13923
|
+
const commonPath = join34(o.route.promptsDir, "personas", "common.md");
|
|
13828
13924
|
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync29(commonPath);
|
|
13829
13925
|
const now = o.now ?? (() => Date.now());
|
|
13830
13926
|
const routeLabel = routeSlug(o.route.route);
|
|
@@ -13860,7 +13956,7 @@ function planAgentRun(o) {
|
|
|
13860
13956
|
digest
|
|
13861
13957
|
});
|
|
13862
13958
|
const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
|
|
13863
|
-
const streamsDir =
|
|
13959
|
+
const streamsDir = join34(o.stateDir, "streams");
|
|
13864
13960
|
const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
|
|
13865
13961
|
const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
|
|
13866
13962
|
const { model } = seat;
|
|
@@ -13971,8 +14067,8 @@ function planAgentRun(o) {
|
|
|
13971
14067
|
digestAttached: digest !== void 0,
|
|
13972
14068
|
digestAgeSeconds: ageSeconds,
|
|
13973
14069
|
model,
|
|
13974
|
-
streamPath:
|
|
13975
|
-
eventsPath:
|
|
14070
|
+
streamPath: join34(streamsDir, `${base}.jsonl`),
|
|
14071
|
+
eventsPath: join34(streamsDir, `${base}.events.jsonl`),
|
|
13976
14072
|
ticket: o.ticket,
|
|
13977
14073
|
ticketRecordId: o.ticketRecordId ?? null,
|
|
13978
14074
|
repo: o.repo ?? null,
|
|
@@ -14060,7 +14156,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
|
|
|
14060
14156
|
var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
|
|
14061
14157
|
function openSink(path) {
|
|
14062
14158
|
try {
|
|
14063
|
-
mkdirSync22(
|
|
14159
|
+
mkdirSync22(dirname17(path), { recursive: true });
|
|
14064
14160
|
return createWriteStream(path, { flags: "a" });
|
|
14065
14161
|
} catch {
|
|
14066
14162
|
return void 0;
|
|
@@ -14499,7 +14595,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14499
14595
|
const id = identityOf(plan, adapter.harness);
|
|
14500
14596
|
let streamFd;
|
|
14501
14597
|
try {
|
|
14502
|
-
mkdirSync22(
|
|
14598
|
+
mkdirSync22(dirname17(plan.streamPath), { recursive: true });
|
|
14503
14599
|
streamFd = openSync4(plan.streamPath, "a");
|
|
14504
14600
|
} catch (e) {
|
|
14505
14601
|
void endSink(eventsSink);
|
|
@@ -14764,13 +14860,13 @@ function runFinished(streamPath) {
|
|
|
14764
14860
|
}
|
|
14765
14861
|
}
|
|
14766
14862
|
function orphanedStreams(o) {
|
|
14767
|
-
const dir =
|
|
14863
|
+
const dir = join35(o.stateDir, "streams");
|
|
14768
14864
|
if (!existsSync30(dir)) return [];
|
|
14769
14865
|
const ownerAlive = o.isOwnerAlive ?? pidAlive;
|
|
14770
14866
|
const out = [];
|
|
14771
14867
|
for (const name of readdirSync10(dir)) {
|
|
14772
14868
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14773
|
-
const streamPath =
|
|
14869
|
+
const streamPath = join35(dir, name);
|
|
14774
14870
|
if (runFinished(streamPath)) continue;
|
|
14775
14871
|
const sidecar = readRunSidecar(streamPath);
|
|
14776
14872
|
if (!sidecar || sidecar.route !== o.routeLabel) continue;
|
|
@@ -14824,11 +14920,11 @@ async function reconcileRuns(o) {
|
|
|
14824
14920
|
|
|
14825
14921
|
// src/live-runs.ts
|
|
14826
14922
|
import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
|
|
14827
|
-
import { join as
|
|
14923
|
+
import { join as join37 } from "path";
|
|
14828
14924
|
|
|
14829
14925
|
// src/run-snapshot.ts
|
|
14830
14926
|
import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as readFileSync33, writeFileSync as writeFileSync24, renameSync as renameSync6 } from "fs";
|
|
14831
|
-
import { join as
|
|
14927
|
+
import { join as join36 } from "path";
|
|
14832
14928
|
var TAIL_BYTES = 256 * 1024;
|
|
14833
14929
|
var EXCERPT_CHARS = 280;
|
|
14834
14930
|
function endsWithQuestion(text2) {
|
|
@@ -14882,12 +14978,12 @@ function outcomeOf(m) {
|
|
|
14882
14978
|
return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
|
|
14883
14979
|
}
|
|
14884
14980
|
function lastRunsBySeat(stateDir) {
|
|
14885
|
-
const dir =
|
|
14981
|
+
const dir = join36(stateDir, "streams");
|
|
14886
14982
|
const out = /* @__PURE__ */ new Map();
|
|
14887
14983
|
if (!existsSync31(dir)) return out;
|
|
14888
14984
|
for (const name of readdirSync11(dir)) {
|
|
14889
14985
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14890
|
-
const streamPath =
|
|
14986
|
+
const streamPath = join36(dir, name);
|
|
14891
14987
|
if (!runFinished(streamPath)) continue;
|
|
14892
14988
|
const metaPath = `${streamPath}.meta.json`;
|
|
14893
14989
|
let meta;
|
|
@@ -14936,12 +15032,12 @@ function appendRunNote(streamPath, note) {
|
|
|
14936
15032
|
|
|
14937
15033
|
// src/live-runs.ts
|
|
14938
15034
|
function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
14939
|
-
const dir =
|
|
15035
|
+
const dir = join37(stateDir, "streams");
|
|
14940
15036
|
if (!existsSync32(dir)) return [];
|
|
14941
15037
|
const out = [];
|
|
14942
15038
|
for (const name of readdirSync12(dir)) {
|
|
14943
15039
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14944
|
-
const streamPath =
|
|
15040
|
+
const streamPath = join37(dir, name);
|
|
14945
15041
|
if (runFinished(streamPath)) continue;
|
|
14946
15042
|
const sidecar = readRunSidecar(streamPath);
|
|
14947
15043
|
if (!sidecar || !isAlive(sidecar)) continue;
|
|
@@ -14951,12 +15047,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
|
14951
15047
|
}
|
|
14952
15048
|
function runActivity(stateDir, isAlive = runIsAlive) {
|
|
14953
15049
|
const activeRuns = liveRuns(stateDir, isAlive).length;
|
|
14954
|
-
const dir =
|
|
15050
|
+
const dir = join37(stateDir, "streams");
|
|
14955
15051
|
let newest = 0;
|
|
14956
15052
|
if (existsSync32(dir)) {
|
|
14957
15053
|
for (const name of readdirSync12(dir)) {
|
|
14958
15054
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14959
|
-
const streamPath =
|
|
15055
|
+
const streamPath = join37(dir, name);
|
|
14960
15056
|
if (!runFinished(streamPath)) continue;
|
|
14961
15057
|
try {
|
|
14962
15058
|
newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
|
|
@@ -15969,7 +16065,7 @@ function managedGitIdentityWarnings(kind, identity) {
|
|
|
15969
16065
|
import { spawn as spawn7 } from "child_process";
|
|
15970
16066
|
import { existsSync as existsSync34, mkdirSync as mkdirSync23, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
|
|
15971
16067
|
import { tmpdir as tmpdir5 } from "os";
|
|
15972
|
-
import { join as
|
|
16068
|
+
import { join as join38 } from "path";
|
|
15973
16069
|
var SELFTEST_TIMEOUT_MS = 12e4;
|
|
15974
16070
|
var KEY_VAR = "CREW_API_KEY";
|
|
15975
16071
|
var SELFTEST_PROMPT = "This is a read-only connectivity check. Use the tracker MCP tool to read this workspace (the workspaces find-one tool, using the workspace id below) and reply with the workspace's name alone, on one line. Do not write anything, do not create files, and do not use any other tool.\n\nWorkspace id: ";
|
|
@@ -16135,7 +16231,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
16135
16231
|
...adapter.runEnv(spec),
|
|
16136
16232
|
[KEY_VAR]: i.apiKey
|
|
16137
16233
|
};
|
|
16138
|
-
const cwd = mkdtempSync2(
|
|
16234
|
+
const cwd = mkdtempSync2(join38(tmpdir5(), "crew-selftest-"));
|
|
16139
16235
|
try {
|
|
16140
16236
|
const run4 = await deps.run({
|
|
16141
16237
|
bin: invocation.bin,
|
|
@@ -16168,7 +16264,7 @@ function formatResult(r) {
|
|
|
16168
16264
|
const secs = `${(r.ms / 1e3).toFixed(1)}s`;
|
|
16169
16265
|
return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
|
|
16170
16266
|
}
|
|
16171
|
-
var fileFor3 = (stateDir) =>
|
|
16267
|
+
var fileFor3 = (stateDir) => join38(stateDir, "selftest.json");
|
|
16172
16268
|
function readSelftest(stateDir) {
|
|
16173
16269
|
try {
|
|
16174
16270
|
const p = fileFor3(stateDir);
|
|
@@ -16243,7 +16339,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
|
|
|
16243
16339
|
}
|
|
16244
16340
|
|
|
16245
16341
|
// src/cli.ts
|
|
16246
|
-
import { resolve as resolve7, dirname as
|
|
16342
|
+
import { resolve as resolve7, dirname as dirname38, join as join66, basename as basename17 } from "path";
|
|
16247
16343
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16248
16344
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
16249
16345
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
@@ -16455,9 +16551,9 @@ function rosterMarkdown(roster, meId) {
|
|
|
16455
16551
|
|
|
16456
16552
|
// src/connect-resume.ts
|
|
16457
16553
|
import { mkdirSync as mkdirSync24, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "fs";
|
|
16458
|
-
import { dirname as
|
|
16554
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
16459
16555
|
function lastSessionFile(stateDir) {
|
|
16460
|
-
return
|
|
16556
|
+
return join39(stateDir, "connect-session.json");
|
|
16461
16557
|
}
|
|
16462
16558
|
function readPointers(stateDir) {
|
|
16463
16559
|
try {
|
|
@@ -16475,7 +16571,7 @@ function readPointers(stateDir) {
|
|
|
16475
16571
|
}
|
|
16476
16572
|
function writePointers(stateDir, pointers) {
|
|
16477
16573
|
const file = lastSessionFile(stateDir);
|
|
16478
|
-
mkdirSync24(
|
|
16574
|
+
mkdirSync24(dirname18(file), { recursive: true });
|
|
16479
16575
|
writeFileSync26(file, `${JSON.stringify(pointers, null, 2)}
|
|
16480
16576
|
`, { mode: 384 });
|
|
16481
16577
|
}
|
|
@@ -16562,10 +16658,10 @@ async function signOutSessions(o) {
|
|
|
16562
16658
|
|
|
16563
16659
|
// src/reset.ts
|
|
16564
16660
|
import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync27 } from "fs";
|
|
16565
|
-
import { dirname as
|
|
16661
|
+
import { dirname as dirname19, join as join40 } from "path";
|
|
16566
16662
|
import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
|
|
16567
16663
|
function clonedCheckoutsFile(stateDir) {
|
|
16568
|
-
return
|
|
16664
|
+
return join40(stateDir, "cloned-checkouts.json");
|
|
16569
16665
|
}
|
|
16570
16666
|
function readClonedCheckouts(stateDir) {
|
|
16571
16667
|
try {
|
|
@@ -16579,7 +16675,7 @@ function recordClonedCheckout(stateDir, dir) {
|
|
|
16579
16675
|
const known = readClonedCheckouts(stateDir);
|
|
16580
16676
|
if (known.includes(dir)) return;
|
|
16581
16677
|
const file = clonedCheckoutsFile(stateDir);
|
|
16582
|
-
mkdirSync25(
|
|
16678
|
+
mkdirSync25(dirname19(file), { recursive: true });
|
|
16583
16679
|
writeFileSync27(file, `${JSON.stringify([...known, dir], null, 2)}
|
|
16584
16680
|
`);
|
|
16585
16681
|
}
|
|
@@ -16656,10 +16752,10 @@ function removeCheckout(dir, dryRun, fx) {
|
|
|
16656
16752
|
}
|
|
16657
16753
|
function removeState(stateDir, dryRun) {
|
|
16658
16754
|
const out = [];
|
|
16659
|
-
const targets = [
|
|
16755
|
+
const targets = [join40(stateDir, "resolved"), join40(stateDir, "keys"), clonedCheckoutsFile(stateDir), join40(stateDir, "connect-session.json"), join40(stateDir, "reload-requested"), join40(stateDir, "daemon.started")];
|
|
16660
16756
|
try {
|
|
16661
16757
|
for (const name of readdirSync14(stateDir)) {
|
|
16662
|
-
if (name.startsWith(".") && statSync12(
|
|
16758
|
+
if (name.startsWith(".") && statSync12(join40(stateDir, name)).isFile()) targets.push(join40(stateDir, name));
|
|
16663
16759
|
}
|
|
16664
16760
|
} catch {
|
|
16665
16761
|
}
|
|
@@ -16679,7 +16775,7 @@ function wipeStateDir(stateDir, dryRun) {
|
|
|
16679
16775
|
return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
|
|
16680
16776
|
}
|
|
16681
16777
|
if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
|
|
16682
|
-
if (!dryRun) for (const n of names) rmSync20(
|
|
16778
|
+
if (!dryRun) for (const n of names) rmSync20(join40(stateDir, n), { recursive: true, force: true });
|
|
16683
16779
|
return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
|
|
16684
16780
|
}
|
|
16685
16781
|
function describeResetStep(s) {
|
|
@@ -16763,7 +16859,7 @@ async function runDeprovision(o, fx, deps) {
|
|
|
16763
16859
|
// src/pool-member.ts
|
|
16764
16860
|
import { mkdirSync as mkdirSync26, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync28 } from "fs";
|
|
16765
16861
|
import { homedir as homedir8 } from "os";
|
|
16766
|
-
import { dirname as
|
|
16862
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
16767
16863
|
var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
|
|
16768
16864
|
function backoffMs(attempt) {
|
|
16769
16865
|
return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
|
|
@@ -17005,10 +17101,10 @@ async function runPoolMember(deps) {
|
|
|
17005
17101
|
}
|
|
17006
17102
|
}
|
|
17007
17103
|
function defaultMemberDir(env = process.env) {
|
|
17008
|
-
return env.CREW_POOL_DIR ??
|
|
17104
|
+
return env.CREW_POOL_DIR ?? join41(env.XDG_STATE_HOME ?? join41(homedir8(), ".local", "state"), "crew-pool-member");
|
|
17009
17105
|
}
|
|
17010
17106
|
function fileMemberStore(dir) {
|
|
17011
|
-
const file =
|
|
17107
|
+
const file = join41(dir, "member.json");
|
|
17012
17108
|
return {
|
|
17013
17109
|
read() {
|
|
17014
17110
|
try {
|
|
@@ -17018,7 +17114,7 @@ function fileMemberStore(dir) {
|
|
|
17018
17114
|
}
|
|
17019
17115
|
},
|
|
17020
17116
|
write(f) {
|
|
17021
|
-
mkdirSync26(
|
|
17117
|
+
mkdirSync26(dirname20(file), { recursive: true, mode: 448 });
|
|
17022
17118
|
const tmp = `${file}.tmp`;
|
|
17023
17119
|
writeFileSync28(tmp, `${JSON.stringify(f)}
|
|
17024
17120
|
`, { mode: 384 });
|
|
@@ -17079,9 +17175,9 @@ import { hostname as hostname3 } from "os";
|
|
|
17079
17175
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
17080
17176
|
import { createHash as createHash8 } from "crypto";
|
|
17081
17177
|
import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
|
|
17082
|
-
import { dirname as
|
|
17178
|
+
import { dirname as dirname21, join as join42 } from "path";
|
|
17083
17179
|
function machineIdPathFor(stateDir) {
|
|
17084
|
-
return
|
|
17180
|
+
return join42(stateDir, "machine-id");
|
|
17085
17181
|
}
|
|
17086
17182
|
var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
|
|
17087
17183
|
function readRawMachineId(platform2 = process.platform) {
|
|
@@ -17113,7 +17209,7 @@ function ensureMachineId(stateDir, opts = {}) {
|
|
|
17113
17209
|
const raw = (opts.read ?? readRawMachineId)();
|
|
17114
17210
|
if (!raw) return void 0;
|
|
17115
17211
|
const hashed = sha256(raw);
|
|
17116
|
-
mkdirSync27(
|
|
17212
|
+
mkdirSync27(dirname21(path), { recursive: true });
|
|
17117
17213
|
writeFileSync29(path, `${hashed}
|
|
17118
17214
|
`, { mode: 384 });
|
|
17119
17215
|
return hashed;
|
|
@@ -17136,7 +17232,7 @@ import { parseDocument as parseDocument2 } from "yaml";
|
|
|
17136
17232
|
|
|
17137
17233
|
// src/repos-cmd.ts
|
|
17138
17234
|
import { homedir as homedir9 } from "os";
|
|
17139
|
-
import { basename as basename10, join as
|
|
17235
|
+
import { basename as basename10, join as join43, resolve as resolve4 } from "path";
|
|
17140
17236
|
import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
|
|
17141
17237
|
var ReposError = class extends Error {
|
|
17142
17238
|
/** A stable reason for a `--json` reader, when the failure has one (CREW-3359). */
|
|
@@ -17427,7 +17523,7 @@ function planRepoClone(i) {
|
|
|
17427
17523
|
}
|
|
17428
17524
|
const ship = doc.get("ship", true);
|
|
17429
17525
|
const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
|
|
17430
|
-
const target = i.dir ? expandDir(i.dir, i.base) :
|
|
17526
|
+
const target = i.dir ? expandDir(i.dir, i.base) : join43(expandDir(basePath, i.base), i.route.split("/")[0], name);
|
|
17431
17527
|
const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
|
|
17432
17528
|
const forgeHost = i.resolved?.repoForgeHosts?.[id];
|
|
17433
17529
|
return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
|
|
@@ -18993,7 +19089,7 @@ function diskFullStop(state) {
|
|
|
18993
19089
|
|
|
18994
19090
|
// src/poll.ts
|
|
18995
19091
|
import { writeFileSync as writeFileSync31 } from "fs";
|
|
18996
|
-
import { join as
|
|
19092
|
+
import { join as join44 } from "path";
|
|
18997
19093
|
|
|
18998
19094
|
// src/stalled.ts
|
|
18999
19095
|
var STALLED_AFTER_CYCLES = 30;
|
|
@@ -19310,7 +19406,7 @@ async function decideCycle(o) {
|
|
|
19310
19406
|
}
|
|
19311
19407
|
return decision;
|
|
19312
19408
|
}
|
|
19313
|
-
var digestPath = (stateDir, route2, role, runId) =>
|
|
19409
|
+
var digestPath = (stateDir, route2, role, runId) => join44(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
19314
19410
|
function otherRunsRemoved(tickets, own) {
|
|
19315
19411
|
if (!own) return tickets;
|
|
19316
19412
|
return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
|
|
@@ -19541,7 +19637,7 @@ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket,
|
|
|
19541
19637
|
|
|
19542
19638
|
// src/repo-refresh.ts
|
|
19543
19639
|
import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
19544
|
-
import { dirname as
|
|
19640
|
+
import { dirname as dirname23 } from "path";
|
|
19545
19641
|
var REFRESH_COOLDOWN_MS = 2 * 6e4;
|
|
19546
19642
|
var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
|
|
19547
19643
|
var lastAsked = /* @__PURE__ */ new Map();
|
|
@@ -19573,7 +19669,7 @@ function persistRepoRows(stateDir, routeName, rows) {
|
|
|
19573
19669
|
if (!existsSync40(path)) return;
|
|
19574
19670
|
const raw = JSON.parse(readFileSync40(path, "utf8"));
|
|
19575
19671
|
applyRepoRows(raw, rows);
|
|
19576
|
-
mkdirSync28(
|
|
19672
|
+
mkdirSync28(dirname23(path), { recursive: true });
|
|
19577
19673
|
writeFileSync32(path, `${JSON.stringify(raw, null, 2)}
|
|
19578
19674
|
`);
|
|
19579
19675
|
}
|
|
@@ -19796,7 +19892,7 @@ async function applyConflictBounce(writer, b, contract, memberId, log, dryRun) {
|
|
|
19796
19892
|
handBackComment(b, merged),
|
|
19797
19893
|
memberId,
|
|
19798
19894
|
"conflict_handed_back",
|
|
19799
|
-
b.baseSha ? { base_sha: b.baseSha } :
|
|
19895
|
+
{ ...b.baseSha ? { base_sha: b.baseSha } : {}, ...b.paths.length ? { paths: b.paths } : {} }
|
|
19800
19896
|
).catch((e) => {
|
|
19801
19897
|
log.warn(`handed back, but the note failed to post: ${e.message}`, t);
|
|
19802
19898
|
});
|
|
@@ -19964,14 +20060,39 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
|
|
|
19964
20060
|
|
|
19965
20061
|
// src/stranded-verified.ts
|
|
19966
20062
|
var STRANDED_MARKER = calloutHeader("WARNING", "Stranded Verified");
|
|
20063
|
+
function findNearMissBranches(dir, cfg, ticket) {
|
|
20064
|
+
const number = ticket.issue_id.replace(/^\D+/, "");
|
|
20065
|
+
if (!number) return [];
|
|
20066
|
+
const remote = cfg.branch.remote;
|
|
20067
|
+
const prefix = `refs/remotes/${remote}/`;
|
|
20068
|
+
const refs = (gitOk(dir, ["for-each-ref", "--format=%(refname)", prefix]) ?? "").split("\n").filter((r) => r.startsWith(prefix) && r !== `${prefix}HEAD`).map((r) => r.slice(prefix.length)).filter((b) => b !== cfg.branch.base && new RegExp(`(^|\\D)${number}(\\D|$)`).test(b));
|
|
20069
|
+
const keys = [...new Set([ticket.issue_id, ticket.issue_tag].filter((k) => !!k))];
|
|
20070
|
+
const keyRe = keys.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
20071
|
+
const out = [];
|
|
20072
|
+
for (const b of refs) {
|
|
20073
|
+
const log = gitOk(dir, ["log", "--format=%H", "-E", "-i", `--grep=(^|[^0-9A-Za-z])(${keyRe})([^0-9]|$)`, `${remote}/${cfg.branch.base}..${prefix}${b}`]);
|
|
20074
|
+
const commits = log ? log.split("\n").filter(Boolean).length : 0;
|
|
20075
|
+
if (commits > 0) out.push({ branch: b, commits });
|
|
20076
|
+
}
|
|
20077
|
+
return out;
|
|
20078
|
+
}
|
|
20079
|
+
function nearMissText(s) {
|
|
20080
|
+
if (!s.nearMisses?.length) return "";
|
|
20081
|
+
const list = s.nearMisses.map((n) => `\`${s.remote}/${n.branch}\` (${n.commits} commit${n.commits === 1 ? "" : "s"} naming the key)`).join(", ");
|
|
20082
|
+
return `
|
|
20083
|
+
|
|
20084
|
+
**A branch under another name looks like this ticket's work:** ${list}. The crew expected \`${s.expectedBranch ?? "the contract branch name"}\`. It was most likely built on a misnamed branch; pushing it under the expected name, or renaming it, lets the release merge it.`;
|
|
20085
|
+
}
|
|
19967
20086
|
var STRANDED_ESCALATE_AFTER_MS = 30 * 60 * 1e3;
|
|
19968
20087
|
var priorStrandedFlags = (ticket, events) => events.filter((e) => e.record_id === ticket.id && e.event_type === "stranded_flagged").length;
|
|
19969
|
-
function planStrandedVerified(candidate, base, remote, events) {
|
|
20088
|
+
function planStrandedVerified(candidate, base, remote, events, look) {
|
|
19970
20089
|
const stamps = events.filter((e) => e.record_id === candidate.ticket.id && e.event_type === "stranded_flagged").map((e) => Date.parse(e.occurred_at ?? e.created_at ?? "")).filter((n) => !Number.isNaN(n));
|
|
20090
|
+
const nearMisses = look ? findNearMissBranches(look.dir, look.cfg, candidate.ticket) : [];
|
|
19971
20091
|
return {
|
|
19972
20092
|
candidate,
|
|
19973
20093
|
base,
|
|
19974
20094
|
remote,
|
|
20095
|
+
...nearMisses.length && look ? { nearMisses, expectedBranch: branchCandidatesForTicket(look.cfg, candidate.ticket).find((c) => !c.endsWith("*")) } : {},
|
|
19975
20096
|
priorFlags: priorStrandedFlags(candidate.ticket, events),
|
|
19976
20097
|
lastFlaggedAt: stamps.length ? Math.max(...stamps) : void 0
|
|
19977
20098
|
};
|
|
@@ -19984,7 +20105,7 @@ function flagComment(s) {
|
|
|
19984
20105
|
|
|
19985
20106
|
\`${key}\` is \`verified\` with no branch on this ship, and its key names no commit anywhere in this ship's \`${s.base}\` history (searched all of it, local commits included, for a bounded \`${key}\` in a commit subject or body). One of three things is true: it landed under a commit that never named the key, the branch was deleted before it merged, or it was verified in error \u2014 the crew cannot tell these apart and will not guess.
|
|
19986
20107
|
|
|
19987
|
-
If it is still unplaceable next cycle, this ticket is escalated to a person. If the work already landed, closing this ticket by hand now avoids that
|
|
20108
|
+
If it is still unplaceable next cycle, this ticket is escalated to a person. If the work already landed, closing this ticket by hand now avoids that.${nearMissText(s)}`;
|
|
19988
20109
|
}
|
|
19989
20110
|
function escalateComment2(s) {
|
|
19990
20111
|
const key = s.candidate.ticket.issue_id;
|
|
@@ -19994,7 +20115,7 @@ function escalateComment2(s) {
|
|
|
19994
20115
|
|
|
19995
20116
|
\`${key}\` was flagged as stranded at \`verified\` on an earlier cycle and still has no branch on this ship or on \`${s.remote}\` and no commit in this ship's \`${s.base}\` history naming its key (searched all of it, local commits included). This needs a person: either the work landed under a commit that doesn't name the key and this ticket can simply close, or the branch is gone and the work needs redoing.
|
|
19996
20117
|
|
|
19997
|
-
The crew will not close this on its own
|
|
20118
|
+
The crew will not close this on its own.${nearMissText(s)}`;
|
|
19998
20119
|
}
|
|
19999
20120
|
async function applyStrandedVerified(writer, s, contract, operatorId, memberId, log, dryRun, now = Date.now()) {
|
|
20000
20121
|
const t = { ticket: s.candidate.ticket.issue_id, step: "merge" };
|
|
@@ -20036,6 +20157,80 @@ async function applyStrandedVerified(writer, s, contract, operatorId, memberId,
|
|
|
20036
20157
|
}
|
|
20037
20158
|
}
|
|
20038
20159
|
|
|
20160
|
+
// src/right-of-way.ts
|
|
20161
|
+
var RIGHT_OF_WAY_MARKER = calloutHeader("NOTE", "Waiting For A Conflict Fix");
|
|
20162
|
+
var DEFERRED_EVENT = "right_of_way_deferred";
|
|
20163
|
+
var stampMs = (e) => Date.parse(e.occurred_at ?? e.created_at ?? "") || 0;
|
|
20164
|
+
var pathsOf = (e) => {
|
|
20165
|
+
const p = e.metadata?.paths;
|
|
20166
|
+
return Array.isArray(p) ? p.filter((x) => typeof x === "string" && x !== "") : [];
|
|
20167
|
+
};
|
|
20168
|
+
function handBacks(tickets, events, contract, now, ttlMinutes) {
|
|
20169
|
+
const none = { open: [], lapsed: [] };
|
|
20170
|
+
if (ttlMinutes <= 0) return none;
|
|
20171
|
+
const s = contract.statuses;
|
|
20172
|
+
const live2 = /* @__PURE__ */ new Set([s.building, s.handoff, s.verifying, s.verified]);
|
|
20173
|
+
const byId = new Map(tickets.map((t) => [t.id, t]));
|
|
20174
|
+
const newest = /* @__PURE__ */ new Map();
|
|
20175
|
+
for (const e of events) {
|
|
20176
|
+
if (e.event_type !== "conflict_handed_back" || !pathsOf(e).length) continue;
|
|
20177
|
+
const prev = newest.get(e.record_id);
|
|
20178
|
+
if (!prev || stampMs(e) > stampMs(prev)) newest.set(e.record_id, e);
|
|
20179
|
+
}
|
|
20180
|
+
const out = { open: [], lapsed: [] };
|
|
20181
|
+
for (const [id, e] of newest) {
|
|
20182
|
+
const ticket = byId.get(id);
|
|
20183
|
+
if (!ticket || !live2.has(ticket.status)) continue;
|
|
20184
|
+
const at = stampMs(e);
|
|
20185
|
+
if (events.some((x) => x.record_id === id && x.event_type === "conflict_escalated" && stampMs(x) > at)) continue;
|
|
20186
|
+
const hb = { ticket, at, paths: pathsOf(e), expiresAt: at + ttlMinutes * 6e4 };
|
|
20187
|
+
(now >= hb.expiresAt ? out.lapsed : out.open).push(hb);
|
|
20188
|
+
}
|
|
20189
|
+
const order = (a, b) => a.at - b.at || a.ticket.issue_id.localeCompare(b.ticket.issue_id);
|
|
20190
|
+
out.open.sort(order);
|
|
20191
|
+
out.lapsed.sort(order);
|
|
20192
|
+
return out;
|
|
20193
|
+
}
|
|
20194
|
+
var overlap = (a, b) => {
|
|
20195
|
+
const set = new Set(b);
|
|
20196
|
+
return a.filter((p) => set.has(p));
|
|
20197
|
+
};
|
|
20198
|
+
function planRightOfWay(candidates2, tickets, events, contract, now, ttlMinutes) {
|
|
20199
|
+
const { open, lapsed } = handBacks(tickets, events, contract, now, ttlMinutes);
|
|
20200
|
+
const own = new Map(open.map((h) => [h.ticket.id, h]));
|
|
20201
|
+
const deferrals = [];
|
|
20202
|
+
for (const c of candidates2) {
|
|
20203
|
+
const mine = own.get(c.ticket.id);
|
|
20204
|
+
const first = open.find((h) => h.ticket.id !== c.ticket.id && (!mine || mine.at > h.at || mine.at === h.at && mine.ticket.issue_id > h.ticket.issue_id) && overlap(c.paths, h.paths).length > 0);
|
|
20205
|
+
if (first) deferrals.push({ ticket: c.ticket, waitingFor: first.ticket, paths: overlap(c.paths, first.paths), since: first.at });
|
|
20206
|
+
}
|
|
20207
|
+
const lapsedUsed = lapsed.filter((h) => candidates2.some((c) => c.ticket.id !== h.ticket.id && overlap(c.paths, h.paths).length > 0));
|
|
20208
|
+
return { deferrals, lapsed: lapsedUsed };
|
|
20209
|
+
}
|
|
20210
|
+
function branchPaths(cwd, base, branch) {
|
|
20211
|
+
return (gitOk(cwd, ["diff", "--name-only", `${base}...${branch}`]) ?? "").split("\n").filter(Boolean);
|
|
20212
|
+
}
|
|
20213
|
+
var deferralReported = (d, events) => events.some((e) => e.record_id === d.ticket.id && e.event_type === DEFERRED_EVENT && e.metadata?.waiting_for === d.waitingFor.id && stampMs(e) >= d.since);
|
|
20214
|
+
function deferralComment(d, base, ttlMinutes) {
|
|
20215
|
+
const list = d.paths.map((p) => `\`${p}\``).join(", ");
|
|
20216
|
+
return `${RIGHT_OF_WAY_MARKER}
|
|
20217
|
+
|
|
20218
|
+
**Verified, and waiting its turn \u2014 not handed back.**
|
|
20219
|
+
|
|
20220
|
+
${displayKey(d.waitingFor)} was handed back for a merge conflict in ${list}, which this branch also changes. Releasing this branch first would move \`${base}\` under it again, so the release leaves this ticket at \`verified\` and retries it each cycle until ${displayKey(d.waitingFor)} is verified and released, or until its right of way lapses (${ttlMinutes} minutes after the hand-back). Nothing is needed from anyone.`;
|
|
20221
|
+
}
|
|
20222
|
+
function deferredFromLog(tickets, events, contract, now, ttlMinutes) {
|
|
20223
|
+
const { open } = handBacks(tickets, events, contract, now, ttlMinutes);
|
|
20224
|
+
const out = [];
|
|
20225
|
+
for (const t of tickets) {
|
|
20226
|
+
if (t.status !== contract.statuses.verified) continue;
|
|
20227
|
+
const last = events.filter((e) => e.record_id === t.id && e.event_type === DEFERRED_EVENT).sort((a, b) => stampMs(b) - stampMs(a))[0];
|
|
20228
|
+
const hb = last && open.find((h) => h.ticket.id === last.metadata?.waiting_for && h.at <= stampMs(last));
|
|
20229
|
+
if (hb) out.push({ ticket: t, waitingFor: hb.ticket });
|
|
20230
|
+
}
|
|
20231
|
+
return out;
|
|
20232
|
+
}
|
|
20233
|
+
|
|
20039
20234
|
// src/local-ref-skip.ts
|
|
20040
20235
|
var LOCAL_REF_SKIP_MARKER = calloutHeader("WARNING", "Release Skipped");
|
|
20041
20236
|
function localRefSkipComment(shipName2, problem) {
|
|
@@ -20050,7 +20245,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
|
|
|
20050
20245
|
var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
|
|
20051
20246
|
|
|
20052
20247
|
// src/platform-gate.ts
|
|
20053
|
-
import { join as
|
|
20248
|
+
import { join as join45 } from "path";
|
|
20054
20249
|
function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
20055
20250
|
const out = [];
|
|
20056
20251
|
for (const t of tickets) {
|
|
@@ -20062,7 +20257,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
|
20062
20257
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
20063
20258
|
if (text2 === null) continue;
|
|
20064
20259
|
try {
|
|
20065
|
-
const { platform: platform2 } = parseRepoConfig(text2,
|
|
20260
|
+
const { platform: platform2 } = parseRepoConfig(text2, join45(dir, file));
|
|
20066
20261
|
if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
|
|
20067
20262
|
} catch (e) {
|
|
20068
20263
|
if (e instanceof RepoConfigError) continue;
|
|
@@ -20078,7 +20273,7 @@ function platformStuckNote(repo, required, ship, issueIds) {
|
|
|
20078
20273
|
}
|
|
20079
20274
|
|
|
20080
20275
|
// src/connect-wizard.ts
|
|
20081
|
-
import { delimiter, dirname as
|
|
20276
|
+
import { delimiter, dirname as dirname24, join as join46 } from "path";
|
|
20082
20277
|
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync29, writeFileSync as writeFileSync33 } from "fs";
|
|
20083
20278
|
import { stringify as stringify3 } from "yaml";
|
|
20084
20279
|
var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
|
|
@@ -20101,7 +20296,7 @@ function defaultIsExecutable(p) {
|
|
|
20101
20296
|
function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
|
|
20102
20297
|
for (const dir of pathEnv.split(delimiter)) {
|
|
20103
20298
|
if (!dir) continue;
|
|
20104
|
-
const candidate =
|
|
20299
|
+
const candidate = join46(dir, name);
|
|
20105
20300
|
if (isExecutable(candidate)) return candidate;
|
|
20106
20301
|
}
|
|
20107
20302
|
return void 0;
|
|
@@ -20127,9 +20322,9 @@ async function runWizard(p, env) {
|
|
|
20127
20322
|
if (entered && isExec(entered)) agentBin = entered;
|
|
20128
20323
|
else p.say(entered ? `${entered} is not an executable file.` : "A path is required.");
|
|
20129
20324
|
}
|
|
20130
|
-
const nodeDir =
|
|
20325
|
+
const nodeDir = dirname24(env.nodePath);
|
|
20131
20326
|
const pnpmPath = findOnPath2("pnpm", env.pathEnv, isExec);
|
|
20132
|
-
const baseDirs = [nodeDir, pnpmPath ?
|
|
20327
|
+
const baseDirs = [nodeDir, pnpmPath ? dirname24(pnpmPath) : void 0];
|
|
20133
20328
|
p.say(
|
|
20134
20329
|
`
|
|
20135
20330
|
Host Passengers lets this machine run the agent sessions that other people's
|
|
@@ -20140,7 +20335,7 @@ Tablation workspaces ask for, in a container. More: ${HOST_PASSENGERS_DOCS_URL}`
|
|
|
20140
20335
|
p.say("Docker is not available here, so nothing will be hosted until it is. Your answer is recorded anyway.");
|
|
20141
20336
|
}
|
|
20142
20337
|
const dockerPath = hostPassengers ? findOnPath2("docker", env.pathEnv, isExec) : void 0;
|
|
20143
|
-
const extraPath = deriveExtraPath([...baseDirs, dockerPath ?
|
|
20338
|
+
const extraPath = deriveExtraPath([...baseDirs, dockerPath ? dirname24(dockerPath) : void 0]);
|
|
20144
20339
|
if (extraPath) {
|
|
20145
20340
|
p.say(`Hooks will get ${extraPath} on their PATH (where node, pnpm${dockerPath ? " and docker" : ""} live).`);
|
|
20146
20341
|
}
|
|
@@ -20162,7 +20357,7 @@ routes:
|
|
|
20162
20357
|
${routeBlock}`;
|
|
20163
20358
|
}
|
|
20164
20359
|
function writeNewConfig(path, text2) {
|
|
20165
|
-
mkdirSync29(
|
|
20360
|
+
mkdirSync29(dirname24(path), { recursive: true });
|
|
20166
20361
|
try {
|
|
20167
20362
|
writeFileSync33(path, text2, { mode: 384, flag: "wx" });
|
|
20168
20363
|
return true;
|
|
@@ -20198,7 +20393,7 @@ Wrote ${o.configPath}.
|
|
|
20198
20393
|
// src/connect-json.ts
|
|
20199
20394
|
import { accessSync as accessSync4, constants as constants4 } from "fs";
|
|
20200
20395
|
import { homedir as homedir10 } from "os";
|
|
20201
|
-
import { dirname as
|
|
20396
|
+
import { dirname as dirname25, join as join47 } from "path";
|
|
20202
20397
|
import { delimiter as delimiter2 } from "path";
|
|
20203
20398
|
var CHOICE_EXIT_CODE = 3;
|
|
20204
20399
|
function createEmitter(json2, write) {
|
|
@@ -20237,12 +20432,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
|
|
|
20237
20432
|
const dirs = [
|
|
20238
20433
|
...pathEnv.split(delimiter2),
|
|
20239
20434
|
...(extraPath ?? "").split(delimiter2),
|
|
20240
|
-
|
|
20241
|
-
|
|
20435
|
+
join47(home, ".local/bin"),
|
|
20436
|
+
join47(home, ".claude/local"),
|
|
20242
20437
|
"/opt/homebrew/bin",
|
|
20243
20438
|
"/usr/local/bin",
|
|
20244
|
-
|
|
20245
|
-
|
|
20439
|
+
join47(home, ".npm-global/bin"),
|
|
20440
|
+
join47(home, ".volta/bin")
|
|
20246
20441
|
];
|
|
20247
20442
|
return [...new Set(dirs.filter(Boolean))];
|
|
20248
20443
|
}
|
|
@@ -20264,7 +20459,7 @@ function flagWizardAnswers(f, env) {
|
|
|
20264
20459
|
const agentBin = f.agentBin ?? found?.bin;
|
|
20265
20460
|
const pnpmPath = findOnPath2("pnpm", env.pathEnv, isExec);
|
|
20266
20461
|
const dockerPath = f.hostPassengers ? findOnPath2("docker", env.pathEnv, isExec) : void 0;
|
|
20267
|
-
const extraPath = f.extraPath ?? deriveExtraPath([
|
|
20462
|
+
const extraPath = f.extraPath ?? deriveExtraPath([dirname25(env.nodePath), pnpmPath ? dirname25(pnpmPath) : void 0, dockerPath ? dirname25(dockerPath) : void 0]);
|
|
20268
20463
|
return {
|
|
20269
20464
|
answers: {
|
|
20270
20465
|
name: f.shipName?.trim() || env.hostname,
|
|
@@ -20364,7 +20559,7 @@ async function collectDiagnostics(d) {
|
|
|
20364
20559
|
|
|
20365
20560
|
// src/release-run.ts
|
|
20366
20561
|
import { readFileSync as readFileSync41, writeFileSync as writeFileSync34, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
|
|
20367
|
-
import { dirname as
|
|
20562
|
+
import { dirname as dirname26, join as join48 } from "path";
|
|
20368
20563
|
import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
|
|
20369
20564
|
|
|
20370
20565
|
// src/release.ts
|
|
@@ -21339,7 +21534,7 @@ async function bump(o, size) {
|
|
|
21339
21534
|
}
|
|
21340
21535
|
return printed;
|
|
21341
21536
|
}
|
|
21342
|
-
const files = o.repo.release.versionFiles.map((f) =>
|
|
21537
|
+
const files = o.repo.release.versionFiles.map((f) => join48(o.cwd, f));
|
|
21343
21538
|
const first = files[0];
|
|
21344
21539
|
if (!existsAt(first, existsSync42)) {
|
|
21345
21540
|
o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
|
|
@@ -21377,7 +21572,7 @@ async function bump(o, size) {
|
|
|
21377
21572
|
function writeChangelog(o, version, entries) {
|
|
21378
21573
|
const file = o.repo.release.changelog;
|
|
21379
21574
|
if (!file || entries.length === 0) return;
|
|
21380
|
-
const path =
|
|
21575
|
+
const path = join48(o.cwd, file);
|
|
21381
21576
|
const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
|
|
21382
21577
|
if (o.dryRun) {
|
|
21383
21578
|
o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
|
|
@@ -21477,8 +21672,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
21477
21672
|
function openReleaseCheckout(o) {
|
|
21478
21673
|
const { remote, base } = o.repo.branch;
|
|
21479
21674
|
const branch = `crew/release-${Date.now()}`;
|
|
21480
|
-
const root = mkdtempSync3(
|
|
21481
|
-
const dir =
|
|
21675
|
+
const root = mkdtempSync3(join48(tmpdir6(), "crew-release-"));
|
|
21676
|
+
const dir = join48(root, "checkout");
|
|
21482
21677
|
o.emit.note(`release checkout: ${dir}`, { step: "release" });
|
|
21483
21678
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
21484
21679
|
try {
|
|
@@ -21488,10 +21683,10 @@ function openReleaseCheckout(o) {
|
|
|
21488
21683
|
throw e;
|
|
21489
21684
|
}
|
|
21490
21685
|
for (const f of o.repo.worktrees.copy) {
|
|
21491
|
-
const src =
|
|
21686
|
+
const src = join48(o.cwd, f);
|
|
21492
21687
|
if (!existsSync42(src)) continue;
|
|
21493
|
-
mkdirSync30(
|
|
21494
|
-
copyFileSync(src,
|
|
21688
|
+
mkdirSync30(dirname26(join48(dir, f)), { recursive: true });
|
|
21689
|
+
copyFileSync(src, join48(dir, f));
|
|
21495
21690
|
}
|
|
21496
21691
|
return { dir, branch, close };
|
|
21497
21692
|
}
|
|
@@ -21509,14 +21704,16 @@ function reportHeld(o, held) {
|
|
|
21509
21704
|
async function runRelease(o) {
|
|
21510
21705
|
const movedPast2 = [];
|
|
21511
21706
|
const localRefSkips = [];
|
|
21512
|
-
const
|
|
21707
|
+
const rightOfWay = { deferrals: [], lapsed: [] };
|
|
21708
|
+
const out = await runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay);
|
|
21513
21709
|
return {
|
|
21514
21710
|
...out,
|
|
21515
21711
|
...movedPast2.length ? { movedPast: movedPast2 } : {},
|
|
21516
|
-
...localRefSkips.length ? { localRefSkips } : {}
|
|
21712
|
+
...localRefSkips.length ? { localRefSkips } : {},
|
|
21713
|
+
...rightOfWay.deferrals.length || rightOfWay.lapsed.length ? { rightOfWay } : {}
|
|
21517
21714
|
};
|
|
21518
21715
|
}
|
|
21519
|
-
async function runReleaseCycle(o, movedPast2, localRefSkips) {
|
|
21716
|
+
async function runReleaseCycle(o, movedPast2, localRefSkips, rightOfWay) {
|
|
21520
21717
|
const scoped = (msg) => o.scope ? `${o.scope}: ${msg}` : msg;
|
|
21521
21718
|
const tagPattern = o.repo.release.tagPattern ?? "v*";
|
|
21522
21719
|
o.emit.enter("release");
|
|
@@ -21563,6 +21760,41 @@ async function runReleaseCycle(o, movedPast2, localRefSkips) {
|
|
|
21563
21760
|
}
|
|
21564
21761
|
if (drop.size) releasable = releasable.filter((t) => !drop.has(t.id));
|
|
21565
21762
|
}
|
|
21763
|
+
if (o.rightOfWayEvents?.length && (o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES) > 0) {
|
|
21764
|
+
const baseRef = remoteBranchExists(o.cwd, o.repo.branch.remote, o.repo.branch.base) ? `${o.repo.branch.remote}/${o.repo.branch.base}` : o.repo.branch.base;
|
|
21765
|
+
const candidates2 = [];
|
|
21766
|
+
for (const t of releasable) {
|
|
21767
|
+
if (t.status !== o.contract.statuses.verified) continue;
|
|
21768
|
+
const branch = locateBranchForTicket(o.cwd, o.repo, t)?.branch;
|
|
21769
|
+
if (branch) candidates2.push({ ticket: t, paths: branchPaths(o.cwd, baseRef, branch) });
|
|
21770
|
+
}
|
|
21771
|
+
const plan = planRightOfWay(
|
|
21772
|
+
candidates2,
|
|
21773
|
+
o.tickets,
|
|
21774
|
+
o.rightOfWayEvents,
|
|
21775
|
+
o.contract,
|
|
21776
|
+
(o.now ?? Date.now)(),
|
|
21777
|
+
o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES
|
|
21778
|
+
);
|
|
21779
|
+
rightOfWay.deferrals.push(...plan.deferrals);
|
|
21780
|
+
rightOfWay.lapsed.push(...plan.lapsed);
|
|
21781
|
+
for (const h of plan.lapsed) {
|
|
21782
|
+
o.emit.warn(
|
|
21783
|
+
`${displayKey(h.ticket)}'s right of way over ${h.paths.join(", ")} lapsed after ${o.repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES} minutes without it coming back verified \u2014 not deferring other branches for it`,
|
|
21784
|
+
{ ticket: h.ticket.issue_id, step: "release" }
|
|
21785
|
+
);
|
|
21786
|
+
}
|
|
21787
|
+
for (const d of plan.deferrals) {
|
|
21788
|
+
o.emit.emit(
|
|
21789
|
+
`not releasing ${displayKey(d.ticket)} this cycle: waiting for ${displayKey(d.waitingFor)}, handed back for a conflict in ${d.paths.join(", ")}`,
|
|
21790
|
+
{ ticket: d.ticket.issue_id, step: "release" }
|
|
21791
|
+
);
|
|
21792
|
+
}
|
|
21793
|
+
if (plan.deferrals.length) {
|
|
21794
|
+
const waiting = new Set(plan.deferrals.map((d) => d.ticket.id));
|
|
21795
|
+
releasable = releasable.filter((t) => !waiting.has(t.id));
|
|
21796
|
+
}
|
|
21797
|
+
}
|
|
21566
21798
|
const { remote, base } = o.repo.branch;
|
|
21567
21799
|
const inPlace = o.dryRun || !!o.mergeOnly || !remoteBranchExists(o.cwd, remote, base);
|
|
21568
21800
|
const remoteRef = `${remote}/${base}`;
|
|
@@ -22318,7 +22550,7 @@ import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
|
|
|
22318
22550
|
|
|
22319
22551
|
// src/daemon.ts
|
|
22320
22552
|
import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
|
|
22321
|
-
import { join as
|
|
22553
|
+
import { join as join53 } from "path";
|
|
22322
22554
|
import { randomBytes } from "crypto";
|
|
22323
22555
|
|
|
22324
22556
|
// src/outage.ts
|
|
@@ -22442,11 +22674,11 @@ function nextRoles(decision, ran) {
|
|
|
22442
22674
|
|
|
22443
22675
|
// src/noop-runs.ts
|
|
22444
22676
|
import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
|
|
22445
|
-
import { join as
|
|
22677
|
+
import { join as join49 } from "path";
|
|
22446
22678
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
22447
22679
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
22448
22680
|
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
22449
|
-
var noopRunsPath = (stateDir) =>
|
|
22681
|
+
var noopRunsPath = (stateDir) => join49(stateDir, "noop-runs.json");
|
|
22450
22682
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
22451
22683
|
function readNoopRuns(stateDir) {
|
|
22452
22684
|
try {
|
|
@@ -22537,7 +22769,7 @@ async function settleNoopRun(o) {
|
|
|
22537
22769
|
|
|
22538
22770
|
// src/ship-name.ts
|
|
22539
22771
|
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
|
|
22540
|
-
import { dirname as
|
|
22772
|
+
import { dirname as dirname27 } from "path";
|
|
22541
22773
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
22542
22774
|
var ShipNameError = class extends Error {
|
|
22543
22775
|
};
|
|
@@ -22616,7 +22848,7 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
22616
22848
|
}
|
|
22617
22849
|
if (raw.shipName === name) return;
|
|
22618
22850
|
raw.shipName = name;
|
|
22619
|
-
mkdirSync32(
|
|
22851
|
+
mkdirSync32(dirname27(resolvedFile), { recursive: true });
|
|
22620
22852
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
22621
22853
|
writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
|
|
22622
22854
|
`);
|
|
@@ -22699,7 +22931,7 @@ import { existsSync as existsSync45 } from "fs";
|
|
|
22699
22931
|
|
|
22700
22932
|
// src/passenger-mirror.ts
|
|
22701
22933
|
import { mkdirSync as mkdirSync33 } from "fs";
|
|
22702
|
-
import { dirname as
|
|
22934
|
+
import { dirname as dirname28 } from "path";
|
|
22703
22935
|
function mirrorRepoOf(spec) {
|
|
22704
22936
|
const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
|
|
22705
22937
|
if (fromOrigin) return fromOrigin;
|
|
@@ -22717,7 +22949,7 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
|
|
|
22717
22949
|
continue;
|
|
22718
22950
|
}
|
|
22719
22951
|
try {
|
|
22720
|
-
const parent =
|
|
22952
|
+
const parent = dirname28(spec.dir);
|
|
22721
22953
|
mkdirSync33(parent, { recursive: true });
|
|
22722
22954
|
mkdirSync33(spec.dir, { recursive: true });
|
|
22723
22955
|
const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
|
|
@@ -22818,17 +23050,17 @@ function explainRefusal(readable, unreadable) {
|
|
|
22818
23050
|
// src/ssh-keys.ts
|
|
22819
23051
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
22820
23052
|
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
22821
|
-
import { dirname as
|
|
23053
|
+
import { dirname as dirname29, join as join50 } from "path";
|
|
22822
23054
|
var SshKeyError = class extends Error {
|
|
22823
23055
|
};
|
|
22824
23056
|
function shipSshKeyPathFor(stateDir) {
|
|
22825
|
-
return
|
|
23057
|
+
return join50(stateDir, "ssh", "id_ed25519");
|
|
22826
23058
|
}
|
|
22827
23059
|
function ensureShipSshKeypair(stateDir) {
|
|
22828
23060
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
22829
23061
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
22830
23062
|
if (!existsSync46(privateKeyPath)) {
|
|
22831
|
-
mkdirSync34(
|
|
23063
|
+
mkdirSync34(dirname29(privateKeyPath), { recursive: true });
|
|
22832
23064
|
try {
|
|
22833
23065
|
execFileSync13("ssh-keygen", [
|
|
22834
23066
|
"-t",
|
|
@@ -22866,7 +23098,7 @@ function sshKeygenAvailable() {
|
|
|
22866
23098
|
// src/periscope-idle.ts
|
|
22867
23099
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
22868
23100
|
import { statSync as statSync13 } from "fs";
|
|
22869
|
-
import { join as
|
|
23101
|
+
import { join as join51 } from "path";
|
|
22870
23102
|
var MAX_SCANNED_FILES = 2e4;
|
|
22871
23103
|
function newestWorktreeMtime(root) {
|
|
22872
23104
|
const a = newestTrackedMtime(root);
|
|
@@ -22891,7 +23123,7 @@ function newestTrackedMtime(root) {
|
|
|
22891
23123
|
if (!rel) continue;
|
|
22892
23124
|
if (++scanned > MAX_SCANNED_FILES) break;
|
|
22893
23125
|
try {
|
|
22894
|
-
const m = statSync13(
|
|
23126
|
+
const m = statSync13(join51(root, rel)).mtimeMs;
|
|
22895
23127
|
if (newest === null || m > newest) newest = m;
|
|
22896
23128
|
} catch {
|
|
22897
23129
|
}
|
|
@@ -22966,7 +23198,7 @@ async function runPeriscopeIdlePass(d) {
|
|
|
22966
23198
|
|
|
22967
23199
|
// src/periscope-cmd.ts
|
|
22968
23200
|
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
|
|
22969
|
-
import { join as
|
|
23201
|
+
import { join as join52 } from "path";
|
|
22970
23202
|
var PeriscopeError = class extends Error {
|
|
22971
23203
|
};
|
|
22972
23204
|
var LivePeriscopeError = class extends PeriscopeError {
|
|
@@ -22976,8 +23208,8 @@ var LivePeriscopeError = class extends PeriscopeError {
|
|
|
22976
23208
|
this.data = { refused: "live_periscope_exists", ...live2 };
|
|
22977
23209
|
}
|
|
22978
23210
|
};
|
|
22979
|
-
var priorDir = (stateDir) =>
|
|
22980
|
-
var priorPath = (stateDir, ticketRecordId) =>
|
|
23211
|
+
var priorDir = (stateDir) => join52(stateDir, "periscope-priors");
|
|
23212
|
+
var priorPath = (stateDir, ticketRecordId) => join52(priorDir(stateDir), `${ticketRecordId}.json`);
|
|
22981
23213
|
function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
22982
23214
|
rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
|
|
22983
23215
|
}
|
|
@@ -23530,7 +23762,7 @@ function latestMtime(path) {
|
|
|
23530
23762
|
if (!stat2.isDirectory()) return 0;
|
|
23531
23763
|
let latest = stat2.mtimeMs;
|
|
23532
23764
|
for (const entry of readdirSync15(path, { withFileTypes: true })) {
|
|
23533
|
-
latest = Math.max(latest, latestMtime(
|
|
23765
|
+
latest = Math.max(latest, latestMtime(join53(path, entry.name)));
|
|
23534
23766
|
}
|
|
23535
23767
|
return latest;
|
|
23536
23768
|
}
|
|
@@ -23542,7 +23774,7 @@ function makeStaleChecker(paths, opts = {}) {
|
|
|
23542
23774
|
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
|
|
23543
23775
|
}
|
|
23544
23776
|
function reloadSentinelFor(stateDir) {
|
|
23545
|
-
return
|
|
23777
|
+
return join53(stateDir, "reload-requested");
|
|
23546
23778
|
}
|
|
23547
23779
|
function readReloadRequestedAt(stateDir) {
|
|
23548
23780
|
try {
|
|
@@ -23552,7 +23784,7 @@ function readReloadRequestedAt(stateDir) {
|
|
|
23552
23784
|
}
|
|
23553
23785
|
}
|
|
23554
23786
|
function daemonStampFor(stateDir) {
|
|
23555
|
-
return
|
|
23787
|
+
return join53(stateDir, "daemon.started");
|
|
23556
23788
|
}
|
|
23557
23789
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
23558
23790
|
mkdirSync36(stateDir, { recursive: true });
|
|
@@ -24595,11 +24827,11 @@ function startLaunchdDaemon(o) {
|
|
|
24595
24827
|
|
|
24596
24828
|
// src/daemon-start-failure.ts
|
|
24597
24829
|
import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
|
|
24598
|
-
import { dirname as
|
|
24830
|
+
import { dirname as dirname30, join as join54 } from "path";
|
|
24599
24831
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
24600
24832
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
24601
24833
|
var BACKOFF_AFTER_FAILURES = 2;
|
|
24602
|
-
var fileFor4 = (stateDir) =>
|
|
24834
|
+
var fileFor4 = (stateDir) => join54(stateDir, ".daemon-start-failure.json");
|
|
24603
24835
|
function readStartFailure(stateDir) {
|
|
24604
24836
|
try {
|
|
24605
24837
|
const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
|
|
@@ -24660,7 +24892,7 @@ async function reportStartFailure(o) {
|
|
|
24660
24892
|
return delay;
|
|
24661
24893
|
}
|
|
24662
24894
|
function fallbackStateDir(configFile) {
|
|
24663
|
-
return
|
|
24895
|
+
return join54(dirname30(configFile), "state");
|
|
24664
24896
|
}
|
|
24665
24897
|
|
|
24666
24898
|
// src/projects-cmd.ts
|
|
@@ -24854,7 +25086,7 @@ function runForge(a, io) {
|
|
|
24854
25086
|
// src/release-sandbox.ts
|
|
24855
25087
|
import { execFile as execFile5 } from "child_process";
|
|
24856
25088
|
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
|
|
24857
|
-
import { dirname as
|
|
25089
|
+
import { dirname as dirname31 } from "path";
|
|
24858
25090
|
import { promisify as promisify4 } from "util";
|
|
24859
25091
|
var execFileP4 = promisify4(execFile5);
|
|
24860
25092
|
var RELEASE_CLONE_DEPTH = 50;
|
|
@@ -24900,7 +25132,7 @@ async function openReleaseSandbox(o) {
|
|
|
24900
25132
|
if (!policyFile) {
|
|
24901
25133
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
24902
25134
|
policyFile = o.policyFile;
|
|
24903
|
-
mkdirSync38(
|
|
25135
|
+
mkdirSync38(dirname31(policyFile), { recursive: true });
|
|
24904
25136
|
writeFileSync40(policyFile, generated.yaml, { mode: 384 });
|
|
24905
25137
|
}
|
|
24906
25138
|
const secrets = { ...process.env };
|
|
@@ -25361,11 +25593,13 @@ function renderStatus(v, opts) {
|
|
|
25361
25593
|
const own = byRecent(v.attention, (a) => a.since);
|
|
25362
25594
|
const others = v.ships.filter((s) => s.name !== v.ship.name && s.attention.length);
|
|
25363
25595
|
const unsafe = v.repos.filter((r) => r.unsafeDetail);
|
|
25364
|
-
|
|
25596
|
+
const deferred = v.deferredReleases ?? [];
|
|
25597
|
+
if (own.length || others.length || unsafe.length || v.heldReleases.length || deferred.length || v.starved) {
|
|
25365
25598
|
out.push("needs attention:");
|
|
25366
25599
|
for (const i of own) out.push(` ${i.kind} \u2014 ${i.message}`);
|
|
25367
25600
|
for (const r of unsafe) out.push(` base ${r.name} \u2014 UNSAFE, no worktree cuts or releases: ${r.unsafeDetail}`);
|
|
25368
25601
|
for (const l of v.heldReleases) out.push(` release: ${l}`);
|
|
25602
|
+
for (const l of deferred) out.push(` deferred: ${l}`);
|
|
25369
25603
|
if (v.starved) {
|
|
25370
25604
|
out.push(` waiting: ${v.starved.ticket} for ${since(v.starved.since, now)} (passed over ${plural(v.starved.streak, "cycle")} running)`);
|
|
25371
25605
|
}
|
|
@@ -26073,12 +26307,12 @@ function describeCapability(i) {
|
|
|
26073
26307
|
|
|
26074
26308
|
// src/persona-avatars.ts
|
|
26075
26309
|
import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
|
|
26076
|
-
import { join as
|
|
26310
|
+
import { join as join55 } from "path";
|
|
26077
26311
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
26078
26312
|
function personaAvatarFile(promptsDir, role) {
|
|
26079
26313
|
for (const ext of ["png", "svg"]) {
|
|
26080
26314
|
const name = `lane-${role}.${ext}`;
|
|
26081
|
-
const path =
|
|
26315
|
+
const path = join55(promptsDir, "personas", name);
|
|
26082
26316
|
if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
26083
26317
|
}
|
|
26084
26318
|
return void 0;
|
|
@@ -26142,7 +26376,7 @@ function routeAvatarFailures(stateDir, route2) {
|
|
|
26142
26376
|
|
|
26143
26377
|
// src/agents-sync-run.ts
|
|
26144
26378
|
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
26145
|
-
import { dirname as
|
|
26379
|
+
import { dirname as dirname32 } from "path";
|
|
26146
26380
|
async function runAgentsSync(target, o) {
|
|
26147
26381
|
const dryRun = o.dryRun ?? false;
|
|
26148
26382
|
const force = o.force ?? false;
|
|
@@ -26192,7 +26426,7 @@ async function runAgentsSync(target, o) {
|
|
|
26192
26426
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
26193
26427
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
26194
26428
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
26195
|
-
mkdirSync39(
|
|
26429
|
+
mkdirSync39(dirname32(resolvedPath), { recursive: true });
|
|
26196
26430
|
writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
26197
26431
|
`);
|
|
26198
26432
|
if (target.resolved) {
|
|
@@ -26330,10 +26564,10 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
26330
26564
|
|
|
26331
26565
|
// src/repo-setup-prompt.ts
|
|
26332
26566
|
import { readFileSync as readFileSync52 } from "fs";
|
|
26333
|
-
import { join as
|
|
26334
|
-
var REPO_SETUP_PROMPT_PATH =
|
|
26567
|
+
import { join as join56 } from "path";
|
|
26568
|
+
var REPO_SETUP_PROMPT_PATH = join56("docs", "repo-setup-prompt.md");
|
|
26335
26569
|
function readRepoSetupPrompt(crewHome) {
|
|
26336
|
-
return readFileSync52(
|
|
26570
|
+
return readFileSync52(join56(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
|
|
26337
26571
|
}
|
|
26338
26572
|
|
|
26339
26573
|
// src/repos-check.ts
|
|
@@ -26672,7 +26906,7 @@ function existingRepoConfig(f) {
|
|
|
26672
26906
|
|
|
26673
26907
|
// src/repos-hooks-agent.ts
|
|
26674
26908
|
import { spawn as spawn9, execFileSync as execFileSync15 } from "child_process";
|
|
26675
|
-
import { realpathSync as
|
|
26909
|
+
import { realpathSync as realpathSync3 } from "fs";
|
|
26676
26910
|
import { isAbsolute as isAbsolute3, relative } from "path";
|
|
26677
26911
|
var AgentSuggestError = class extends Error {
|
|
26678
26912
|
reason;
|
|
@@ -26728,7 +26962,7 @@ function parseAgentStream(out, dir) {
|
|
|
26728
26962
|
const files = /* @__PURE__ */ new Set();
|
|
26729
26963
|
let base = dir;
|
|
26730
26964
|
try {
|
|
26731
|
-
base =
|
|
26965
|
+
base = realpathSync3(dir);
|
|
26732
26966
|
} catch {
|
|
26733
26967
|
}
|
|
26734
26968
|
for (const line of out.split("\n")) {
|
|
@@ -26843,7 +27077,7 @@ ${run4.err}` });
|
|
|
26843
27077
|
}
|
|
26844
27078
|
|
|
26845
27079
|
// src/sample-ticket.ts
|
|
26846
|
-
import { basename as basename13, dirname as
|
|
27080
|
+
import { basename as basename13, dirname as dirname33, join as join57 } from "path";
|
|
26847
27081
|
var SAMPLE_REPO = "crew-sample";
|
|
26848
27082
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
26849
27083
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -26866,8 +27100,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
26866
27100
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
26867
27101
|
`;
|
|
26868
27102
|
function sampleDir(existing, reposBase, workspace) {
|
|
26869
|
-
if (existing.length > 0) return
|
|
26870
|
-
return
|
|
27103
|
+
if (existing.length > 0) return join57(dirname33(existing[0]), SAMPLE_REPO);
|
|
27104
|
+
return join57(reposBase, workspace, SAMPLE_REPO);
|
|
26871
27105
|
}
|
|
26872
27106
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
26873
27107
|
function sampleDescription() {
|
|
@@ -27135,7 +27369,7 @@ function fixPhaseNothingToOffer(o) {
|
|
|
27135
27369
|
|
|
27136
27370
|
// src/worktree-sweep.ts
|
|
27137
27371
|
import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
|
|
27138
|
-
import { basename as basename14, dirname as
|
|
27372
|
+
import { basename as basename14, dirname as dirname34, join as join58, resolve as resolve5 } from "path";
|
|
27139
27373
|
function planWorktreeSweep(target, tickets, contract) {
|
|
27140
27374
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
27141
27375
|
const verified = contract.statuses.verified;
|
|
@@ -27199,7 +27433,7 @@ function worktreeTicketNumbers(target) {
|
|
|
27199
27433
|
return [...nums];
|
|
27200
27434
|
}
|
|
27201
27435
|
function siblingWorktreeDirs(target) {
|
|
27202
|
-
const parent =
|
|
27436
|
+
const parent = dirname34(target.dir.replace(/[/\\]+$/, ""));
|
|
27203
27437
|
const stem = `${basename14(target.dir.replace(/[/\\]+$/, ""))}-`;
|
|
27204
27438
|
const registered = new Set(worktrees(target.dir).map((w) => resolve5(w.path)));
|
|
27205
27439
|
let names;
|
|
@@ -27212,7 +27446,7 @@ function siblingWorktreeDirs(target) {
|
|
|
27212
27446
|
for (const name of names) {
|
|
27213
27447
|
if (!name.startsWith(stem)) continue;
|
|
27214
27448
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
27215
|
-
const path =
|
|
27449
|
+
const path = join58(parent, name);
|
|
27216
27450
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
27217
27451
|
}
|
|
27218
27452
|
return out;
|
|
@@ -27445,13 +27679,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
27445
27679
|
|
|
27446
27680
|
// src/stream-sweep.ts
|
|
27447
27681
|
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
|
|
27448
|
-
import { join as
|
|
27682
|
+
import { join as join59 } from "path";
|
|
27449
27683
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
27450
27684
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
27451
|
-
const dir =
|
|
27685
|
+
const dir = join59(stateDir, "streams");
|
|
27452
27686
|
if (!existsSync55(dir)) return [];
|
|
27453
27687
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
27454
|
-
return readdirSync17(dir).map((name) =>
|
|
27688
|
+
return readdirSync17(dir).map((name) => join59(dir, name)).filter((path) => {
|
|
27455
27689
|
try {
|
|
27456
27690
|
return statSync16(path).mtimeMs < cutoff;
|
|
27457
27691
|
} catch {
|
|
@@ -27479,7 +27713,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
27479
27713
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
27480
27714
|
if (!existsSync55(stateDir)) return [];
|
|
27481
27715
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
27482
|
-
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
27716
|
+
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join59(stateDir, name)).filter((path) => {
|
|
27483
27717
|
try {
|
|
27484
27718
|
return statSync16(path).mtimeMs < cutoff;
|
|
27485
27719
|
} catch {
|
|
@@ -27493,7 +27727,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
|
27493
27727
|
if (!existsSync55(dir)) return;
|
|
27494
27728
|
for (const name of readdirSync17(dir)) {
|
|
27495
27729
|
if (!keep(name)) continue;
|
|
27496
|
-
const path =
|
|
27730
|
+
const path = join59(dir, name);
|
|
27497
27731
|
try {
|
|
27498
27732
|
const st = statSync16(path);
|
|
27499
27733
|
if (st.isFile()) files.push({ path, mtime: st.mtimeMs, size: st.size });
|
|
@@ -27501,7 +27735,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
|
27501
27735
|
}
|
|
27502
27736
|
}
|
|
27503
27737
|
};
|
|
27504
|
-
add(
|
|
27738
|
+
add(join59(stateDir, "streams"), () => true);
|
|
27505
27739
|
add(stateDir, (name) => ROTATED_EVENTS_RE.test(name));
|
|
27506
27740
|
let total = files.reduce((n, f) => n + f.size, 0);
|
|
27507
27741
|
const out = [];
|
|
@@ -27521,7 +27755,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
|
|
|
27521
27755
|
}
|
|
27522
27756
|
|
|
27523
27757
|
// src/cli.ts
|
|
27524
|
-
import { realpathSync as
|
|
27758
|
+
import { realpathSync as realpathSync4, readFileSync as readFileSync57, existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync44, rmSync as rmSync27, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync10, statSync as statSync19, readdirSync as readdirSync22 } from "fs";
|
|
27525
27759
|
import { createInterface } from "readline/promises";
|
|
27526
27760
|
|
|
27527
27761
|
// src/periscope-resume.ts
|
|
@@ -27598,9 +27832,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27598
27832
|
|
|
27599
27833
|
// src/bundle-staleness.ts
|
|
27600
27834
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27601
|
-
import { join as
|
|
27835
|
+
import { join as join60 } from "path";
|
|
27602
27836
|
function builtVersion() {
|
|
27603
|
-
return true ? "0.
|
|
27837
|
+
return true ? "0.155.0" : null;
|
|
27604
27838
|
}
|
|
27605
27839
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27606
27840
|
function newestMtime(path) {
|
|
@@ -27613,17 +27847,17 @@ function newestMtime(path) {
|
|
|
27613
27847
|
if (stat2.isFile()) return stat2.mtimeMs;
|
|
27614
27848
|
if (!stat2.isDirectory()) return 0;
|
|
27615
27849
|
let latest = stat2.mtimeMs;
|
|
27616
|
-
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(
|
|
27850
|
+
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join60(path, e.name)));
|
|
27617
27851
|
return latest;
|
|
27618
27852
|
}
|
|
27619
27853
|
function bundleStaleness(i) {
|
|
27620
27854
|
if (i.built === null || i.compiled) return null;
|
|
27621
|
-
const src =
|
|
27855
|
+
const src = join60(i.home, "src");
|
|
27622
27856
|
if (!existsSync56(src)) return null;
|
|
27623
27857
|
if (i.built !== i.current) {
|
|
27624
27858
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
27625
27859
|
}
|
|
27626
|
-
const bundle = statSafe(
|
|
27860
|
+
const bundle = statSafe(join60(i.home, "dist", "cli.js"));
|
|
27627
27861
|
if (bundle === null) return null;
|
|
27628
27862
|
if (newestMtime(src) > bundle) {
|
|
27629
27863
|
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
@@ -27842,7 +28076,7 @@ import { createServer as createHttpServer } from "http";
|
|
|
27842
28076
|
import { spawn as spawn10 } from "child_process";
|
|
27843
28077
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
27844
28078
|
import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync55, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
|
|
27845
|
-
import { join as
|
|
28079
|
+
import { join as join61 } from "path";
|
|
27846
28080
|
|
|
27847
28081
|
// src/secret-compare.ts
|
|
27848
28082
|
import { timingSafeEqual } from "crypto";
|
|
@@ -27935,7 +28169,7 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
27935
28169
|
return child;
|
|
27936
28170
|
};
|
|
27937
28171
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
27938
|
-
return
|
|
28172
|
+
return join61(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
27939
28173
|
}
|
|
27940
28174
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
27941
28175
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
@@ -27948,7 +28182,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
|
27948
28182
|
}
|
|
27949
28183
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
27950
28184
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
27951
|
-
mkdirSync40(
|
|
28185
|
+
mkdirSync40(join61(stateDir, "passengers"), { recursive: true });
|
|
27952
28186
|
writeFileSync42(path, `${JSON.stringify(state, null, 2)}
|
|
27953
28187
|
`);
|
|
27954
28188
|
}
|
|
@@ -27969,7 +28203,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
27969
28203
|
}
|
|
27970
28204
|
}
|
|
27971
28205
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
27972
|
-
const dir =
|
|
28206
|
+
const dir = join61(stateDir, "passengers");
|
|
27973
28207
|
if (!existsSync57(dir)) return [];
|
|
27974
28208
|
const suffix = "-sync.json";
|
|
27975
28209
|
return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
@@ -28034,7 +28268,7 @@ import { createServer, request as httpRequest } from "http";
|
|
|
28034
28268
|
import { request as httpsRequest } from "https";
|
|
28035
28269
|
import { connect as netConnect } from "net";
|
|
28036
28270
|
import { connect as tlsConnect } from "tls";
|
|
28037
|
-
import { dirname as
|
|
28271
|
+
import { dirname as dirname35, isAbsolute as isAbsolute4 } from "path";
|
|
28038
28272
|
import { brotliDecompressSync, gunzipSync, inflateSync } from "zlib";
|
|
28039
28273
|
|
|
28040
28274
|
// src/periscope-inspector.ts
|
|
@@ -28148,7 +28382,7 @@ function parsePointedBody(raw) {
|
|
|
28148
28382
|
return entry;
|
|
28149
28383
|
}
|
|
28150
28384
|
function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
|
|
28151
|
-
mkdirSync41(
|
|
28385
|
+
mkdirSync41(dirname35(file), { recursive: true });
|
|
28152
28386
|
appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
|
|
28153
28387
|
`);
|
|
28154
28388
|
}
|
|
@@ -28437,7 +28671,7 @@ async function startWorktreeIntel(d) {
|
|
|
28437
28671
|
}
|
|
28438
28672
|
|
|
28439
28673
|
// src/contract-refusal.ts
|
|
28440
|
-
import { join as
|
|
28674
|
+
import { join as join62 } from "path";
|
|
28441
28675
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
28442
28676
|
const out = [];
|
|
28443
28677
|
for (const t of tickets) {
|
|
@@ -28449,7 +28683,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
28449
28683
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
28450
28684
|
if (text2 === null) continue;
|
|
28451
28685
|
try {
|
|
28452
|
-
parseRepoConfig(text2,
|
|
28686
|
+
parseRepoConfig(text2, join62(dir, file));
|
|
28453
28687
|
} catch (e) {
|
|
28454
28688
|
if (e instanceof RepoConfigError) continue;
|
|
28455
28689
|
throw e;
|
|
@@ -28475,7 +28709,7 @@ import {
|
|
|
28475
28709
|
} from "fs";
|
|
28476
28710
|
import { createConnection } from "net";
|
|
28477
28711
|
import { createServer as createServer2 } from "http";
|
|
28478
|
-
import { basename as basename15, dirname as
|
|
28712
|
+
import { basename as basename15, dirname as dirname36, join as join63 } from "path";
|
|
28479
28713
|
import { execFile as execFile6, spawn as spawn13 } from "child_process";
|
|
28480
28714
|
|
|
28481
28715
|
// src/periscope-control.ts
|
|
@@ -28713,7 +28947,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
28713
28947
|
// src/control-api.ts
|
|
28714
28948
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
28715
28949
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
28716
|
-
var controlSocketFor = (stateDir) =>
|
|
28950
|
+
var controlSocketFor = (stateDir) => join63(stateDir, CONTROL_SOCKET_NAME);
|
|
28717
28951
|
var MAX_SOCKET_PATH = 100;
|
|
28718
28952
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
28719
28953
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -28800,7 +29034,7 @@ function candidates(live2, rotated) {
|
|
|
28800
29034
|
const out = [live2];
|
|
28801
29035
|
if (!rotated) return out;
|
|
28802
29036
|
try {
|
|
28803
|
-
for (const n of readdirSync20(
|
|
29037
|
+
for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join63(dirname36(live2), n));
|
|
28804
29038
|
} catch {
|
|
28805
29039
|
}
|
|
28806
29040
|
return out;
|
|
@@ -28968,7 +29202,7 @@ async function tailReply(path, q2, rotated, abort) {
|
|
|
28968
29202
|
const deadline = Date.now() + Math.min(wait, MAX_WAIT_SECONDS) * 1e3;
|
|
28969
29203
|
let r = readTail(path, { after, tail: tail3, rotated });
|
|
28970
29204
|
while (after && !r.lines.length && !r.reset && Date.now() < deadline && !abort.aborted) {
|
|
28971
|
-
await waitForChange(
|
|
29205
|
+
await waitForChange(dirname36(path), deadline - Date.now(), abort);
|
|
28972
29206
|
r = readTail(path, { after: r.cursor, rotated });
|
|
28973
29207
|
}
|
|
28974
29208
|
return reply2(200, r);
|
|
@@ -29059,7 +29293,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
29059
29293
|
if (p.startsWith("/streams/") && get2) {
|
|
29060
29294
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
29061
29295
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
29062
|
-
const file =
|
|
29296
|
+
const file = join63(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
29063
29297
|
if (!existsSync58(file)) return err2(404, "no such run");
|
|
29064
29298
|
return tailReply(file, url.searchParams, false, abort);
|
|
29065
29299
|
}
|
|
@@ -29227,7 +29461,7 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
|
|
|
29227
29461
|
|
|
29228
29462
|
// src/periscope-mcp.ts
|
|
29229
29463
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
29230
|
-
import { basename as basename16, dirname as
|
|
29464
|
+
import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join65, relative as relative2, resolve as resolve6, sep } from "path";
|
|
29231
29465
|
import { z } from "zod";
|
|
29232
29466
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
29233
29467
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
@@ -29235,11 +29469,11 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
29235
29469
|
// src/periscope-endpoints.ts
|
|
29236
29470
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
29237
29471
|
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
29238
|
-
import { join as
|
|
29239
|
-
var secretDir = (stateDir) =>
|
|
29240
|
-
var secretFile = (stateDir, id) =>
|
|
29241
|
-
var endpointDir = (stateDir) =>
|
|
29242
|
-
var endpointFile = (stateDir, id) =>
|
|
29472
|
+
import { join as join64 } from "path";
|
|
29473
|
+
var secretDir = (stateDir) => join64(stateDir, "periscope-mcp");
|
|
29474
|
+
var secretFile = (stateDir, id) => join64(secretDir(stateDir), `${id}.json`);
|
|
29475
|
+
var endpointDir = (stateDir) => join64(stateDir, "periscope-endpoints");
|
|
29476
|
+
var endpointFile = (stateDir, id) => join64(endpointDir(stateDir), `${id}.json`);
|
|
29243
29477
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
29244
29478
|
mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
29245
29479
|
const secret = randomBytes3(32).toString("base64url");
|
|
@@ -29365,10 +29599,10 @@ async function realAncestor(p) {
|
|
|
29365
29599
|
}
|
|
29366
29600
|
if (isLink) {
|
|
29367
29601
|
if (++hops > 40) throw new PathRefusal(`too many symbolic links resolving ${p}`);
|
|
29368
|
-
cur = resolve6(
|
|
29602
|
+
cur = resolve6(dirname37(cur), await readlink(cur));
|
|
29369
29603
|
continue;
|
|
29370
29604
|
}
|
|
29371
|
-
const parent =
|
|
29605
|
+
const parent = dirname37(cur);
|
|
29372
29606
|
if (parent === cur) throw new PathRefusal(`cannot resolve ${p}`);
|
|
29373
29607
|
tail3.push(basename16(cur));
|
|
29374
29608
|
cur = parent;
|
|
@@ -29380,13 +29614,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
29380
29614
|
let abs;
|
|
29381
29615
|
if (isAbsolute5(requested)) {
|
|
29382
29616
|
abs = resolve6(requested);
|
|
29383
|
-
if (isInside(root, abs)) abs =
|
|
29617
|
+
if (isInside(root, abs)) abs = join65(realRoot, relative2(root, abs));
|
|
29384
29618
|
} else {
|
|
29385
29619
|
abs = resolve6(realRoot, requested);
|
|
29386
29620
|
}
|
|
29387
29621
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
29388
29622
|
const { real, rest } = await realAncestor(abs);
|
|
29389
|
-
const final = rest ?
|
|
29623
|
+
const final = rest ? join65(real, rest) : real;
|
|
29390
29624
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
29391
29625
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
29392
29626
|
return final;
|
|
@@ -29454,7 +29688,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29454
29688
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
29455
29689
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
29456
29690
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
29457
|
-
const size = (await lstat(
|
|
29691
|
+
const size = (await lstat(join65(abs, e.name))).size;
|
|
29458
29692
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
29459
29693
|
}));
|
|
29460
29694
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -29479,7 +29713,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29479
29713
|
if (Buffer.byteLength(content) > MAX_WRITE_BYTES) return text(`content exceeds ${MAX_WRITE_BYTES} bytes`, true);
|
|
29480
29714
|
const abs = await inTree(path);
|
|
29481
29715
|
if (abs === await realpath(root)) return text("path must name a file", true);
|
|
29482
|
-
await mkdir(
|
|
29716
|
+
await mkdir(dirname37(abs), { recursive: true });
|
|
29483
29717
|
await inTree(path);
|
|
29484
29718
|
await writeFile(abs, content);
|
|
29485
29719
|
return text(`Wrote ${Buffer.byteLength(content)} bytes to ${await rel(abs)}`);
|
|
@@ -29519,8 +29753,8 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29519
29753
|
inputSchema: { path: z.string() },
|
|
29520
29754
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
29521
29755
|
}, async ({ path }) => {
|
|
29522
|
-
const parent = await inTree(
|
|
29523
|
-
const abs =
|
|
29756
|
+
const parent = await inTree(dirname37(path) === "" ? "." : dirname37(path));
|
|
29757
|
+
const abs = join65(parent, basename16(path));
|
|
29524
29758
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
29525
29759
|
const st = await lstat(abs).catch(() => void 0);
|
|
29526
29760
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -29641,7 +29875,7 @@ function findPeriscope(sidecars, segment) {
|
|
|
29641
29875
|
}
|
|
29642
29876
|
|
|
29643
29877
|
// src/cli.ts
|
|
29644
|
-
var CREW_HOME = isCompiledBinary(import.meta.url) ?
|
|
29878
|
+
var CREW_HOME = isCompiledBinary(import.meta.url) ? dirname38(process.execPath) : resolve7(dirname38(fileURLToPath2(import.meta.url)), "..");
|
|
29645
29879
|
var RELEASE_LOCK_TTL_MS = 20 * 60 * 1e3;
|
|
29646
29880
|
var CYCLE_SECONDS2 = 120;
|
|
29647
29881
|
var STALE_CYCLES = 3;
|
|
@@ -30748,7 +30982,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
30748
30982
|
for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
|
|
30749
30983
|
if (host === "linux" && hasSystemd) {
|
|
30750
30984
|
const label = labelFor(CREW_HOME, "run");
|
|
30751
|
-
const staleTimer =
|
|
30985
|
+
const staleTimer = join66(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
30752
30986
|
if (existsSync60(staleTimer)) {
|
|
30753
30987
|
emit.emit(
|
|
30754
30988
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
|
|
@@ -31110,7 +31344,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
31110
31344
|
harnessBin: "claude",
|
|
31111
31345
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
31112
31346
|
},
|
|
31113
|
-
policyFile:
|
|
31347
|
+
policyFile: join66(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
31114
31348
|
repo: mirror,
|
|
31115
31349
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
31116
31350
|
base: effective.branch.base,
|
|
@@ -31359,9 +31593,18 @@ ${changed2.map((c) => ` - ${c}
|
|
|
31359
31593
|
if (sha) verifiedShas.set(t.id, sha);
|
|
31360
31594
|
}
|
|
31361
31595
|
}
|
|
31596
|
+
let rightOfWayEvents;
|
|
31597
|
+
if (verifiedTickets.length >= 1 && repo.release.mode !== "external") {
|
|
31598
|
+
try {
|
|
31599
|
+
rightOfWayEvents = [...await tracker.events("conflict_handed_back"), ...await tracker.events("conflict_escalated")];
|
|
31600
|
+
} catch (e) {
|
|
31601
|
+
remit.warn(`could not read hand-back events; not deferring any branch: ${e.message}`);
|
|
31602
|
+
}
|
|
31603
|
+
}
|
|
31362
31604
|
const outcome = await runRelease({
|
|
31363
31605
|
cwd: target.dir,
|
|
31364
31606
|
repo,
|
|
31607
|
+
rightOfWayEvents,
|
|
31365
31608
|
reloadRepo: (dir) => resolveRepoConfig(loadRepoConfig(dir), {
|
|
31366
31609
|
hooks: { ...c.hooks, ...o?.hooks },
|
|
31367
31610
|
labels: { ...c.labels, ...o?.labels },
|
|
@@ -31487,6 +31730,25 @@ ${changed2.map((c) => ` - ${c}
|
|
|
31487
31730
|
remit.warn(`could not note the skipped release on the board: ${e.message}`, { step: "merge" });
|
|
31488
31731
|
}
|
|
31489
31732
|
}
|
|
31733
|
+
if (outcome.rightOfWay?.deferrals.length && !dryRun) {
|
|
31734
|
+
try {
|
|
31735
|
+
const reported2 = await tracker.events(DEFERRED_EVENT);
|
|
31736
|
+
const seat = releaseSeat(c);
|
|
31737
|
+
const minutes = repo.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES;
|
|
31738
|
+
for (const d of outcome.rightOfWay.deferrals) {
|
|
31739
|
+
if (deferralReported(d, reported2)) continue;
|
|
31740
|
+
await tracker.postEvent(
|
|
31741
|
+
d.ticket.id,
|
|
31742
|
+
deferralComment(d, repo.branch.base, minutes),
|
|
31743
|
+
seat,
|
|
31744
|
+
DEFERRED_EVENT,
|
|
31745
|
+
{ waiting_for: d.waitingFor.id, paths: d.paths }
|
|
31746
|
+
);
|
|
31747
|
+
}
|
|
31748
|
+
} catch (e) {
|
|
31749
|
+
remit.warn(`could not note the deferred release on the board: ${e.message}`, { step: "release" });
|
|
31750
|
+
}
|
|
31751
|
+
}
|
|
31490
31752
|
if (outcome.externalClosures?.length) {
|
|
31491
31753
|
await applyExternalClosures(tracker, outcome.externalClosures, tracker.contract, remit, dryRun, target.dir);
|
|
31492
31754
|
}
|
|
@@ -31636,7 +31898,7 @@ ${f.tail.trimEnd()}
|
|
|
31636
31898
|
}
|
|
31637
31899
|
for (const cand of outcome.unbuildable ?? []) {
|
|
31638
31900
|
try {
|
|
31639
|
-
const stranded = planStrandedVerified(cand, repo.branch.base, repo.branch.remote, flagged);
|
|
31901
|
+
const stranded = planStrandedVerified(cand, repo.branch.base, repo.branch.remote, flagged, { dir: target.dir, cfg: repo });
|
|
31640
31902
|
const r = await applyStrandedVerified(
|
|
31641
31903
|
tracker,
|
|
31642
31904
|
stranded,
|
|
@@ -32379,7 +32641,7 @@ ${f.tail.trimEnd()}
|
|
|
32379
32641
|
logFile: cfg.ship.logFile
|
|
32380
32642
|
});
|
|
32381
32643
|
}
|
|
32382
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
32644
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join66(CREW_HOME, "src"), join66(CREW_HOME, "dist"), join66(CREW_HOME, "bin")];
|
|
32383
32645
|
const configPaths = daemonConfigPaths(cfg);
|
|
32384
32646
|
watchPaths.push(...configPaths);
|
|
32385
32647
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -32766,7 +33028,7 @@ ${f.tail.trimEnd()}
|
|
|
32766
33028
|
const found = cfg.routes.find((r) => r.route === routeArg);
|
|
32767
33029
|
if (!found) throw new ReposError(`no route "${routeArg}" in the config (have: ${cfg.routes.map((r) => r.route).join(", ") || "none"})`);
|
|
32768
33030
|
const named2 = value("route") ? void 0 : positional[3];
|
|
32769
|
-
const dir = named2 ? repoDirOf(configText,
|
|
33031
|
+
const dir = named2 ? repoDirOf(configText, dirname38(cfg.configFile), found.route, named2) : resolvePath(positional[value("route") ? 2 : 3] ?? ".");
|
|
32770
33032
|
const target = reposOf(found).find((t) => resolvePath(t.dir) === dir || t.name === named2);
|
|
32771
33033
|
const o = target ? found.repoOverrides[target.name] : void 0;
|
|
32772
33034
|
runReposCheck(dir, {
|
|
@@ -32788,7 +33050,7 @@ ${f.tail.trimEnd()}
|
|
|
32788
33050
|
if (sub === "hooks") {
|
|
32789
33051
|
try {
|
|
32790
33052
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
32791
|
-
const dir = repoDirOf(configText,
|
|
33053
|
+
const dir = repoDirOf(configText, dirname38(cfg.configFile), a.route, a.name);
|
|
32792
33054
|
if (!existsSync60(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
32793
33055
|
const files = { exists: (r) => existsSync60(resolvePath(dir, r)), list: (r) => {
|
|
32794
33056
|
try {
|
|
@@ -32948,7 +33210,7 @@ ${f.tail.trimEnd()}
|
|
|
32948
33210
|
}
|
|
32949
33211
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
32950
33212
|
const text2 = configText;
|
|
32951
|
-
const base =
|
|
33213
|
+
const base = dirname38(cfg.configFile);
|
|
32952
33214
|
const isCheckout = (d) => existsSync60(`${d}/.git`);
|
|
32953
33215
|
try {
|
|
32954
33216
|
if (sub === "list") {
|
|
@@ -33635,7 +33897,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
33635
33897
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
33636
33898
|
`);
|
|
33637
33899
|
} else {
|
|
33638
|
-
mkdirSync43(
|
|
33900
|
+
mkdirSync43(dirname38(resolvedPath), { recursive: true });
|
|
33639
33901
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
33640
33902
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
33641
33903
|
writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
@@ -33679,7 +33941,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
33679
33941
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
33680
33942
|
`);
|
|
33681
33943
|
} else {
|
|
33682
|
-
mkdirSync43(
|
|
33944
|
+
mkdirSync43(dirname38(apiKeyFile), { recursive: true });
|
|
33683
33945
|
writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
33684
33946
|
`, { mode: 384 });
|
|
33685
33947
|
routineLine(`API key written to ${apiKeyFile}`);
|
|
@@ -34317,10 +34579,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34317
34579
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
34318
34580
|
prepare: async (path) => {
|
|
34319
34581
|
for (const f of repoWt.config.worktrees.copy) {
|
|
34320
|
-
const src =
|
|
34321
|
-
if (!existsSync60(src) || existsSync60(
|
|
34322
|
-
mkdirSync43(dirOf2(
|
|
34323
|
-
copyFileSync2(src,
|
|
34582
|
+
const src = join66(repoWt.dir, f);
|
|
34583
|
+
if (!existsSync60(src) || existsSync60(join66(path, f))) continue;
|
|
34584
|
+
mkdirSync43(dirOf2(join66(path, f)), { recursive: true });
|
|
34585
|
+
copyFileSync2(src, join66(path, f));
|
|
34324
34586
|
}
|
|
34325
34587
|
const setup = repoWt.config.hooks.setup;
|
|
34326
34588
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -34399,7 +34661,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34399
34661
|
}
|
|
34400
34662
|
const real = (p) => {
|
|
34401
34663
|
try {
|
|
34402
|
-
return
|
|
34664
|
+
return realpathSync4(p);
|
|
34403
34665
|
} catch {
|
|
34404
34666
|
return p;
|
|
34405
34667
|
}
|
|
@@ -34647,10 +34909,10 @@ ${where.join("\n")}`);
|
|
|
34647
34909
|
},
|
|
34648
34910
|
prepare: async (path) => {
|
|
34649
34911
|
for (const f of repoP.config.worktrees.copy) {
|
|
34650
|
-
const src =
|
|
34912
|
+
const src = join66(repoP.dir, f);
|
|
34651
34913
|
if (!existsSync60(src)) continue;
|
|
34652
|
-
mkdirSync43(dirOf2(
|
|
34653
|
-
copyFileSync2(src,
|
|
34914
|
+
mkdirSync43(dirOf2(join66(path, f)), { recursive: true });
|
|
34915
|
+
copyFileSync2(src, join66(path, f));
|
|
34654
34916
|
}
|
|
34655
34917
|
const setup = repoP.config.hooks.setup;
|
|
34656
34918
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -34959,7 +35221,7 @@ ${where.join("\n")}`);
|
|
|
34959
35221
|
},
|
|
34960
35222
|
inspectCheckout(dir) {
|
|
34961
35223
|
const dirty = status(dir).map((c) => c.path);
|
|
34962
|
-
const linkedWorktrees = worktrees(dir).map((w) => w.path).filter((p) =>
|
|
35224
|
+
const linkedWorktrees = worktrees(dir).map((w) => w.path).filter((p) => realpathSync4(p) !== realpathSync4(dir));
|
|
34963
35225
|
return { dirty, linkedWorktrees };
|
|
34964
35226
|
}
|
|
34965
35227
|
};
|
|
@@ -35116,7 +35378,7 @@ ${where.join("\n")}`);
|
|
|
35116
35378
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
35117
35379
|
const tracker = new Tracker(route2, cfg.ship);
|
|
35118
35380
|
const configText = readFileSync57(cfg.configFile, "utf8");
|
|
35119
|
-
const cfgBase =
|
|
35381
|
+
const cfgBase = dirname38(cfg.configFile);
|
|
35120
35382
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
35121
35383
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
35122
35384
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, route2.route);
|
|
@@ -35160,12 +35422,12 @@ ${where.join("\n")}`);
|
|
|
35160
35422
|
`);
|
|
35161
35423
|
}
|
|
35162
35424
|
}
|
|
35163
|
-
if (existsSync60(
|
|
35425
|
+
if (existsSync60(join66(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
35164
35426
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
35165
35427
|
break;
|
|
35166
35428
|
}
|
|
35167
35429
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
35168
|
-
const fresh = !existsSync60(
|
|
35430
|
+
const fresh = !existsSync60(join66(dir, ".git"));
|
|
35169
35431
|
if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
35170
35432
|
if (dryRun) {
|
|
35171
35433
|
say("dry-run", { dir, newCheckout: fresh, repoRow: row?.id ?? null }, `would ${fresh ? "create" : "reuse"} ${dir}${row ? "" : ", create the Repos row"}, and file one ${tracker.contract.statuses.approved} ticket`);
|
|
@@ -35173,8 +35435,8 @@ ${where.join("\n")}`);
|
|
|
35173
35435
|
}
|
|
35174
35436
|
if (fresh) {
|
|
35175
35437
|
mkdirSync43(dir, { recursive: true });
|
|
35176
|
-
writeFileSync44(
|
|
35177
|
-
writeFileSync44(
|
|
35438
|
+
writeFileSync44(join66(dir, "README.md"), SAMPLE_README);
|
|
35439
|
+
writeFileSync44(join66(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
35178
35440
|
const g = (...a) => {
|
|
35179
35441
|
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
35180
35442
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -35525,6 +35787,7 @@ ${where.join("\n")}`);
|
|
|
35525
35787
|
}
|
|
35526
35788
|
const shipAttention = openShipAttention(state);
|
|
35527
35789
|
let heldReleases = [];
|
|
35790
|
+
let deferredReleases = [];
|
|
35528
35791
|
try {
|
|
35529
35792
|
const open = await statusTracker.openTickets();
|
|
35530
35793
|
heldReleases = describeHeld(heldByBlockers(
|
|
@@ -35532,6 +35795,16 @@ ${where.join("\n")}`);
|
|
|
35532
35795
|
statusTracker.contract.statuses.verified,
|
|
35533
35796
|
blockerInfoMap(open, await statusTracker.ticketsByIds(missingBlockerIds(open)))
|
|
35534
35797
|
));
|
|
35798
|
+
const minutes = Math.min(...(await resolvedRepos(route2)).map((r) => r.config.release.rightOfWayMinutes ?? DEFAULT_RIGHT_OF_WAY_MINUTES), DEFAULT_RIGHT_OF_WAY_MINUTES);
|
|
35799
|
+
if (open.some((t) => t.status === statusTracker.contract.statuses.verified)) {
|
|
35800
|
+
deferredReleases = deferredFromLog(
|
|
35801
|
+
open,
|
|
35802
|
+
[...await statusTracker.events(DEFERRED_EVENT), ...await statusTracker.events("conflict_handed_back"), ...await statusTracker.events("conflict_escalated")],
|
|
35803
|
+
statusTracker.contract,
|
|
35804
|
+
Date.now(),
|
|
35805
|
+
minutes
|
|
35806
|
+
).map((d) => `${displayKey(d.ticket)} waits for ${displayKey(d.waitingFor)}, handed back for a merge conflict`);
|
|
35807
|
+
}
|
|
35535
35808
|
} catch {
|
|
35536
35809
|
}
|
|
35537
35810
|
const repoViews = [];
|
|
@@ -35572,6 +35845,7 @@ ${where.join("\n")}`);
|
|
|
35572
35845
|
})),
|
|
35573
35846
|
repos: repoViews,
|
|
35574
35847
|
heldReleases,
|
|
35848
|
+
deferredReleases,
|
|
35575
35849
|
starved: waiting ? { ticket: waiting.ticket, since: waiting.since, streak: fairness.streak() } : void 0,
|
|
35576
35850
|
ships: shipRows.map((s) => ({
|
|
35577
35851
|
name: s.name ?? "(unnamed)",
|