@tablation/crew 0.153.3 → 0.154.1
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 +529 -223
- 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
|
@@ -7126,6 +7126,17 @@ function attentionProblems(items, already) {
|
|
|
7126
7126
|
if (already.some((p) => p.kind === "docker_daemon_down")) seen.add(DOCKER_DAEMON_KEY);
|
|
7127
7127
|
return items.filter((i) => !seen.has(i.key)).map((i) => ({ severity: "attention", kind: i.kind, message: i.message }));
|
|
7128
7128
|
}
|
|
7129
|
+
var NO_PROJECTS_REMEDY = "run `crew projects add NAME --prefix PREFIX` (or add a row to the Projects table)";
|
|
7130
|
+
function noProjectsFinding(route2, projectCount) {
|
|
7131
|
+
if (projectCount > 0) return null;
|
|
7132
|
+
return {
|
|
7133
|
+
severity: "attention",
|
|
7134
|
+
kind: "no_projects",
|
|
7135
|
+
route: route2,
|
|
7136
|
+
message: `route ${route2}: the tracker has no Projects row, so no ticket can be worked and a new Repos row has no project to belong to`,
|
|
7137
|
+
remedy: NO_PROJECTS_REMEDY
|
|
7138
|
+
};
|
|
7139
|
+
}
|
|
7129
7140
|
|
|
7130
7141
|
// src/passenger-containers.ts
|
|
7131
7142
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
@@ -7203,14 +7214,14 @@ function envForRepository(entries, repo) {
|
|
|
7203
7214
|
|
|
7204
7215
|
// src/interrupted.ts
|
|
7205
7216
|
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
|
|
7206
|
-
import { join as
|
|
7217
|
+
import { join as join35 } from "path";
|
|
7207
7218
|
|
|
7208
7219
|
// src/agent.ts
|
|
7209
7220
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
7210
7221
|
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";
|
|
7211
7222
|
import { StringDecoder } from "string_decoder";
|
|
7212
7223
|
import { finished } from "stream/promises";
|
|
7213
|
-
import { join as
|
|
7224
|
+
import { join as join34, dirname as dirname17, basename as basename9 } from "path";
|
|
7214
7225
|
import { createHash as createHash6, randomUUID as randomUUID2 } from "crypto";
|
|
7215
7226
|
|
|
7216
7227
|
// src/state.ts
|
|
@@ -9169,13 +9180,14 @@ var runInputFor = (run4) => live.get(run4);
|
|
|
9169
9180
|
|
|
9170
9181
|
// src/agent-log.ts
|
|
9171
9182
|
import { existsSync as existsSync25, mkdirSync as mkdirSync18, readdirSync as readdirSync8, readFileSync as readFileSync25, rmSync as rmSync14, writeFileSync as writeFileSync19 } from "fs";
|
|
9172
|
-
import { join as
|
|
9183
|
+
import { join as join28 } from "path";
|
|
9173
9184
|
|
|
9174
9185
|
// src/pending-backoff.ts
|
|
9175
9186
|
var sleepBackoff = (attempts) => Math.min(6e4 * 2 ** Math.max(0, attempts - 1), 30 * 6e4);
|
|
9176
9187
|
|
|
9177
9188
|
// src/handoff-guard.ts
|
|
9178
|
-
import { existsSync as existsSync24 } from "fs";
|
|
9189
|
+
import { existsSync as existsSync24, realpathSync as realpathSync2 } from "fs";
|
|
9190
|
+
import { dirname as dirname14, join as join27 } from "path";
|
|
9179
9191
|
|
|
9180
9192
|
// src/ticket-branch.ts
|
|
9181
9193
|
import { basename as basename7 } from "path";
|
|
@@ -9534,6 +9546,19 @@ var Tracker = class {
|
|
|
9534
9546
|
if (!model) return [];
|
|
9535
9547
|
return this.client.records.list(model, { limit: 200 });
|
|
9536
9548
|
}
|
|
9549
|
+
/** Create a `Projects` (area) row (CREW-3359). Throws when the workspace has no Projects table. */
|
|
9550
|
+
async createProjectRow(fields) {
|
|
9551
|
+
const model = this.route.resolved?.areaModelId;
|
|
9552
|
+
if (!model) throw new Error("this workspace has no Projects table");
|
|
9553
|
+
return this.client.records.create(model, fields);
|
|
9554
|
+
}
|
|
9555
|
+
/** Whether the Projects table has the contract's work mode column; true when its columns cannot be read. */
|
|
9556
|
+
async projectHasWorkMode() {
|
|
9557
|
+
const model = this.route.resolved?.areaModelId;
|
|
9558
|
+
if (!model) return false;
|
|
9559
|
+
const cols = await this.columnNames(model);
|
|
9560
|
+
return cols.size === 0 || cols.has(this.contract.columns.workMode);
|
|
9561
|
+
}
|
|
9537
9562
|
/** Every Projects row with its raw `work_mode`, for `crew status`. */
|
|
9538
9563
|
async projectRowsWithModes() {
|
|
9539
9564
|
const rows = await this.projectRows();
|
|
@@ -10799,6 +10824,67 @@ function inspectHandoff(dir, cfg, ticket, role) {
|
|
|
10799
10824
|
}
|
|
10800
10825
|
return { kind: "pushed", branch, sha: origin, remote };
|
|
10801
10826
|
}
|
|
10827
|
+
var sameDir = (a, b) => {
|
|
10828
|
+
try {
|
|
10829
|
+
return realpathSync2(a) === realpathSync2(b);
|
|
10830
|
+
} catch {
|
|
10831
|
+
return a === b;
|
|
10832
|
+
}
|
|
10833
|
+
};
|
|
10834
|
+
function repairMisnamedBranch(dir, cfg, ticket, role) {
|
|
10835
|
+
const expected = branchCandidatesForTicket(cfg, ticket, role).find((c) => !c.endsWith("*"));
|
|
10836
|
+
if (!expected) return { kind: "none" };
|
|
10837
|
+
const wtPath = join27(dirname14(dir), worktreeForTicket(dir, cfg, ticket, role));
|
|
10838
|
+
const wt = worktrees(dir).find((w) => !w.prunable && sameDir(w.path, wtPath));
|
|
10839
|
+
const from = wt?.branch;
|
|
10840
|
+
if (!wt || !from || from === cfg.branch.base) return { kind: "none" };
|
|
10841
|
+
const existing = existingBranchForTicket(dir, cfg, ticket, role);
|
|
10842
|
+
if (existing === from) return { kind: "none" };
|
|
10843
|
+
const base = [`${cfg.branch.remote}/${cfg.branch.base}`, cfg.branch.base].find((b) => gitOk(dir, ["rev-parse", "--verify", "-q", b]) !== null);
|
|
10844
|
+
const ahead = base ? Number(gitOk(dir, ["rev-list", "--count", `${base}..${from}`]) ?? "1") : 1;
|
|
10845
|
+
if (ahead === 0) return { kind: "none" };
|
|
10846
|
+
if (existing) {
|
|
10847
|
+
return {
|
|
10848
|
+
kind: "refused",
|
|
10849
|
+
from,
|
|
10850
|
+
to: existing,
|
|
10851
|
+
local: headSha(wt.path),
|
|
10852
|
+
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}\`)`
|
|
10853
|
+
};
|
|
10854
|
+
}
|
|
10855
|
+
try {
|
|
10856
|
+
git(dir, ["branch", "-m", from, expected]);
|
|
10857
|
+
} catch (e) {
|
|
10858
|
+
return {
|
|
10859
|
+
kind: "refused",
|
|
10860
|
+
from,
|
|
10861
|
+
to: expected,
|
|
10862
|
+
local: headSha(wt.path),
|
|
10863
|
+
reason: `the ticket's worktree is on \`${from}\`, not the expected \`${expected}\`, and renaming it failed: ${e.message}`
|
|
10864
|
+
};
|
|
10865
|
+
}
|
|
10866
|
+
return { kind: "renamed", from, to: expected };
|
|
10867
|
+
}
|
|
10868
|
+
async function announceRename(i, ticketId, r, sha, remote, log) {
|
|
10869
|
+
let remoteNote;
|
|
10870
|
+
const tip = remoteTip(i.dir, remote, r.from);
|
|
10871
|
+
if (tip === null) remoteNote = `Could not ask \`${remote}\` about \`${r.from}\`, so any copy of it there was left in place.`;
|
|
10872
|
+
else if (!tip) remoteNote = `\`${r.from}\` was never on \`${remote}\`.`;
|
|
10873
|
+
else if (tip === sha) {
|
|
10874
|
+
try {
|
|
10875
|
+
git(i.dir, ["push", remote, "--delete", r.from]);
|
|
10876
|
+
remoteNote = `The misnamed \`${remote}/${r.from}\` was at the same tip and has been deleted.`;
|
|
10877
|
+
} catch (e) {
|
|
10878
|
+
remoteNote = `\`${remote}/${r.from}\` is at the same tip but could not be deleted: ${e.message}`;
|
|
10879
|
+
}
|
|
10880
|
+
} else remoteNote = `\`${remote}/${r.from}\` is at \`${tip}\`, a different tip than the renamed branch, and was left in place.`;
|
|
10881
|
+
await i.writer.postEvent(
|
|
10882
|
+
ticketId,
|
|
10883
|
+
`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}`,
|
|
10884
|
+
i.seatId,
|
|
10885
|
+
"renamed_by_runner"
|
|
10886
|
+
).catch((e) => i.log.warn(`renamed, but the note failed to post: ${e.message}`, log));
|
|
10887
|
+
}
|
|
10802
10888
|
function pushableBounce(dir, v) {
|
|
10803
10889
|
if (!v.branch || !v.local) return false;
|
|
10804
10890
|
return !v.origin || isAncestor(dir, v.origin, v.local);
|
|
@@ -10920,6 +11006,17 @@ ${acceptanceChecklistBlock(shown(all))}
|
|
|
10920
11006
|
}
|
|
10921
11007
|
return boundNote(build(most));
|
|
10922
11008
|
}
|
|
11009
|
+
function pushForSeat(i, t, v) {
|
|
11010
|
+
const wt = worktrees(i.dir).find((w) => w.branch === v.branch);
|
|
11011
|
+
try {
|
|
11012
|
+
pushBranchUpstream(wt?.path ?? i.dir, v.remote, v.branch);
|
|
11013
|
+
const again = inspectHandoff(i.dir, i.cfg, t, i.role);
|
|
11014
|
+
if (again.kind === "pushed") return { again };
|
|
11015
|
+
return { error: `the push succeeded but ${again.kind === "bounce" ? again.reason : again.why}` };
|
|
11016
|
+
} catch (e) {
|
|
11017
|
+
return { error: e.message };
|
|
11018
|
+
}
|
|
11019
|
+
}
|
|
10923
11020
|
async function enforceHandoff(i) {
|
|
10924
11021
|
try {
|
|
10925
11022
|
const t = await i.writer.ticket(i.ticketId);
|
|
@@ -10930,7 +11027,10 @@ async function enforceHandoff(i) {
|
|
|
10930
11027
|
i.log.emit(`${displayKey(t)} is at ${t.status}, not handed off \u2014 nothing to check`, log);
|
|
10931
11028
|
return { kind: "not-handed-off" };
|
|
10932
11029
|
}
|
|
10933
|
-
const
|
|
11030
|
+
const repair = i.origin ? { kind: "none" } : repairMisnamedBranch(i.dir, i.cfg, t, i.role);
|
|
11031
|
+
const renamed = repair.kind === "renamed" ? repair : null;
|
|
11032
|
+
if (renamed) i.log.warn(`${displayKey(t)}: renamed the misnamed branch ${renamed.from} to ${renamed.to}`, log);
|
|
11033
|
+
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);
|
|
10934
11034
|
if (v.kind === "unverified") {
|
|
10935
11035
|
i.log.warn(`${displayKey(t)} is at ${t.status} but the push was not checked: ${v.why}`, log);
|
|
10936
11036
|
return { kind: "unverified", why: v.why };
|
|
@@ -10959,10 +11059,21 @@ async function enforceHandoff(i) {
|
|
|
10959
11059
|
}
|
|
10960
11060
|
if (v.kind === "pushed") {
|
|
10961
11061
|
await postPushed(i, t.id, v.sha, v.remote, v.branch, log);
|
|
11062
|
+
if (renamed) await announceRename(i, t.id, renamed, v.sha, v.remote, log);
|
|
10962
11063
|
i.log.emit(`${displayKey(t)} pushed at ${v.sha.slice(0, 7)} \u2014 handed on to QA`, log);
|
|
10963
11064
|
return { kind: "pushed", sha: v.sha };
|
|
10964
11065
|
}
|
|
10965
11066
|
if (claimed) {
|
|
11067
|
+
if (renamed && pushableBounce(i.dir, v)) {
|
|
11068
|
+
const done = pushForSeat(i, t, v);
|
|
11069
|
+
if (done.again) {
|
|
11070
|
+
await postPushed(i, t.id, done.again.sha, done.again.remote, done.again.branch, log);
|
|
11071
|
+
await announceRename(i, t.id, renamed, done.again.sha, done.again.remote, log);
|
|
11072
|
+
return { kind: "pushed", sha: done.again.sha };
|
|
11073
|
+
}
|
|
11074
|
+
i.log.warn(`${displayKey(t)} is at ${t.status} and its renamed branch could not be pushed: ${done.error}`, log);
|
|
11075
|
+
return { kind: "failed", why: done.error ?? v.reason };
|
|
11076
|
+
}
|
|
10966
11077
|
i.log.warn(`${displayKey(t)} is at ${t.status} but its branch is not on the remote at HEAD: ${v.reason}`, log);
|
|
10967
11078
|
return { kind: "failed", why: v.reason };
|
|
10968
11079
|
}
|
|
@@ -10981,26 +11092,24 @@ async function enforceHandoff(i) {
|
|
|
10981
11092
|
}
|
|
10982
11093
|
let pushError;
|
|
10983
11094
|
if (pushableBounce(i.dir, v)) {
|
|
10984
|
-
const
|
|
10985
|
-
|
|
10986
|
-
|
|
10987
|
-
const
|
|
10988
|
-
if (
|
|
10989
|
-
|
|
11095
|
+
const done = pushForSeat(i, t, v);
|
|
11096
|
+
if (done.again) {
|
|
11097
|
+
const again = done.again;
|
|
11098
|
+
const posted = await postPushed(i, t.id, again.sha, again.remote, again.branch, log).then(() => null, (e) => e.message);
|
|
11099
|
+
if (posted !== null) pushError = posted;
|
|
11100
|
+
else {
|
|
10990
11101
|
await i.writer.postEvent(
|
|
10991
11102
|
t.id,
|
|
10992
11103
|
`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." : ""}`,
|
|
10993
11104
|
i.seatId,
|
|
10994
11105
|
"pushed_by_runner"
|
|
10995
11106
|
).catch((e) => i.log.warn(`pushed, but the note failed to post: ${e.message}`, log));
|
|
11107
|
+
if (renamed) await announceRename(i, t.id, renamed, again.sha, again.remote, log);
|
|
10996
11108
|
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);
|
|
10997
11109
|
return { kind: "pushed", sha: again.sha };
|
|
10998
11110
|
}
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
pushError = e.message;
|
|
11002
|
-
}
|
|
11003
|
-
i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
|
|
11111
|
+
} else pushError = done.error;
|
|
11112
|
+
if (pushError) i.log.warn(`${displayKey(t)}: the runner's own push failed: ${pushError}`, log);
|
|
11004
11113
|
}
|
|
11005
11114
|
if (!await deliverNote(i, t.id, bounceComment(v, i.shipName, pushError), "bounced", log)) {
|
|
11006
11115
|
i.log.warn(`${displayKey(t)}: ${v.reason}, but the bounce note could not be delivered \u2014 left at ${t.status}, guard outcome unverified`, log);
|
|
@@ -11734,17 +11843,17 @@ async function addRunToTicket(target, t, recordId, run4) {
|
|
|
11734
11843
|
};
|
|
11735
11844
|
}
|
|
11736
11845
|
}
|
|
11737
|
-
var queueDir = (stateDir) =>
|
|
11846
|
+
var queueDir = (stateDir) => join28(stateDir, "pending-agent-logs");
|
|
11738
11847
|
function queueAgentRun(stateDir, name, q2) {
|
|
11739
11848
|
mkdirSync18(queueDir(stateDir), { recursive: true });
|
|
11740
|
-
writeFileSync19(
|
|
11849
|
+
writeFileSync19(join28(queueDir(stateDir), `${name}.json`), JSON.stringify(q2));
|
|
11741
11850
|
}
|
|
11742
11851
|
async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
|
|
11743
11852
|
const dir = queueDir(stateDir);
|
|
11744
11853
|
if (!existsSync25(dir)) return 0;
|
|
11745
11854
|
let sent = 0;
|
|
11746
11855
|
for (const f of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
|
|
11747
|
-
const path =
|
|
11856
|
+
const path = join28(dir, f);
|
|
11748
11857
|
let q2;
|
|
11749
11858
|
try {
|
|
11750
11859
|
q2 = JSON.parse(readFileSync25(path, "utf8"));
|
|
@@ -11787,17 +11896,17 @@ async function replayQueuedAgentRuns(stateDir, route2, keyFor, log, now = /* @__
|
|
|
11787
11896
|
}
|
|
11788
11897
|
return sent;
|
|
11789
11898
|
}
|
|
11790
|
-
var countersDir = (stateDir) =>
|
|
11899
|
+
var countersDir = (stateDir) => join28(stateDir, "pending-ticket-counters");
|
|
11791
11900
|
function queueTicketCounters(stateDir, name, q2) {
|
|
11792
11901
|
mkdirSync18(countersDir(stateDir), { recursive: true });
|
|
11793
|
-
writeFileSync19(
|
|
11902
|
+
writeFileSync19(join28(countersDir(stateDir), `${name}.json`), JSON.stringify(q2));
|
|
11794
11903
|
}
|
|
11795
11904
|
async function replayQueuedTicketCounters(stateDir, route2, keyFor, log, now = /* @__PURE__ */ new Date()) {
|
|
11796
11905
|
const dir = countersDir(stateDir);
|
|
11797
11906
|
if (!existsSync25(dir)) return 0;
|
|
11798
11907
|
let sent = 0;
|
|
11799
11908
|
for (const f of readdirSync8(dir).filter((n) => n.endsWith(".json")).sort()) {
|
|
11800
|
-
const path =
|
|
11909
|
+
const path = join28(dir, f);
|
|
11801
11910
|
let q2;
|
|
11802
11911
|
try {
|
|
11803
11912
|
q2 = JSON.parse(readFileSync25(path, "utf8"));
|
|
@@ -12061,8 +12170,8 @@ var HandoffTranscriptTracker = class {
|
|
|
12061
12170
|
// src/seat-notes.ts
|
|
12062
12171
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync20 } from "fs";
|
|
12063
12172
|
import { randomUUID } from "crypto";
|
|
12064
|
-
import { join as
|
|
12065
|
-
var fileFor2 = (stateDir, role) =>
|
|
12173
|
+
import { join as join29 } from "path";
|
|
12174
|
+
var fileFor2 = (stateDir, role) => join29(stateDir, "seat-notes", `${role}.jsonl`);
|
|
12066
12175
|
var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
12067
12176
|
function readAll(stateDir, role) {
|
|
12068
12177
|
let raw;
|
|
@@ -12083,7 +12192,7 @@ function readAll(stateDir, role) {
|
|
|
12083
12192
|
}
|
|
12084
12193
|
function addSeatNote(stateDir, note, now = /* @__PURE__ */ new Date()) {
|
|
12085
12194
|
const full = { id: randomUUID(), createdAt: now.toISOString(), ...note };
|
|
12086
|
-
mkdirSync19(
|
|
12195
|
+
mkdirSync19(join29(stateDir, "seat-notes"), { recursive: true });
|
|
12087
12196
|
appendFileSync3(fileFor2(stateDir, note.role), `${JSON.stringify(full)}
|
|
12088
12197
|
`);
|
|
12089
12198
|
return full;
|
|
@@ -12122,7 +12231,7 @@ import { createHash as createHash4 } from "crypto";
|
|
|
12122
12231
|
import { spawn as spawn4 } from "child_process";
|
|
12123
12232
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
12124
12233
|
import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
|
|
12125
|
-
import { dirname as
|
|
12234
|
+
import { dirname as dirname15, join as join30 } from "path";
|
|
12126
12235
|
import { fileURLToPath } from "url";
|
|
12127
12236
|
import { tmpdir as tmpdir3 } from "os";
|
|
12128
12237
|
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
@@ -12137,8 +12246,8 @@ var SANDBOX_UID = 1e3;
|
|
|
12137
12246
|
var CREW_PREFIX = "/opt/crew";
|
|
12138
12247
|
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
12139
12248
|
function readBridgeBundle() {
|
|
12140
|
-
const here =
|
|
12141
|
-
for (const p of [
|
|
12249
|
+
const here = dirname15(fileURLToPath(import.meta.url));
|
|
12250
|
+
for (const p of [join30(here, "sandbox-intel-bridge.cjs"), join30(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
12142
12251
|
if (existsSync26(p)) return readFileSync27(p, "utf8");
|
|
12143
12252
|
}
|
|
12144
12253
|
return void 0;
|
|
@@ -12314,7 +12423,7 @@ function planSandbox(repo, decl, warm = {}, bridge) {
|
|
|
12314
12423
|
}
|
|
12315
12424
|
var SHIP_SANDBOX_KEY = "@ship";
|
|
12316
12425
|
var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
|
|
12317
|
-
var sandboxStatePath = (stateDir) =>
|
|
12426
|
+
var sandboxStatePath = (stateDir) => join30(stateDir, "sandbox-images.json");
|
|
12318
12427
|
function readSandboxState(stateDir) {
|
|
12319
12428
|
try {
|
|
12320
12429
|
const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
|
|
@@ -12386,7 +12495,7 @@ var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
|
12386
12495
|
} catch {
|
|
12387
12496
|
}
|
|
12388
12497
|
};
|
|
12389
|
-
var sandboxLogDir = (stateDir) =>
|
|
12498
|
+
var sandboxLogDir = (stateDir) => join30(stateDir, "sandbox-logs");
|
|
12390
12499
|
async function buildSandboxImage(plan, deps) {
|
|
12391
12500
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
12392
12501
|
const state = readSandboxState(deps.stateDir);
|
|
@@ -12396,20 +12505,20 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12396
12505
|
}
|
|
12397
12506
|
const logDir = sandboxLogDir(deps.stateDir);
|
|
12398
12507
|
mkdirSync20(logDir, { recursive: true });
|
|
12399
|
-
const logPath =
|
|
12508
|
+
const logPath = join30(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
12400
12509
|
const builtLayers = [];
|
|
12401
12510
|
for (const layer of plan.layers) {
|
|
12402
12511
|
if (deps.hasImage(layer.tag)) continue;
|
|
12403
|
-
const ctx =
|
|
12512
|
+
const ctx = join30(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
12404
12513
|
mkdirSync20(ctx, { recursive: true });
|
|
12405
12514
|
try {
|
|
12406
|
-
writeFileSync21(
|
|
12515
|
+
writeFileSync21(join30(ctx, "Dockerfile"), layer.dockerfile);
|
|
12407
12516
|
for (const [name, content] of Object.entries(layer.files)) {
|
|
12408
|
-
mkdirSync20(
|
|
12409
|
-
writeFileSync21(
|
|
12517
|
+
mkdirSync20(dirname15(join30(ctx, name)), { recursive: true });
|
|
12518
|
+
writeFileSync21(join30(ctx, name), content);
|
|
12410
12519
|
}
|
|
12411
|
-
if (layer.caBundleFile) writeFileSync21(
|
|
12412
|
-
const code = await deps.run(["build", "--tag", layer.tag, "--file",
|
|
12520
|
+
if (layer.caBundleFile) writeFileSync21(join30(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
12521
|
+
const code = await deps.run(["build", "--tag", layer.tag, "--file", join30(ctx, "Dockerfile"), ctx], logPath);
|
|
12413
12522
|
if (code === BUILD_INTERRUPTED) return { kind: "interrupted", tag: plan.tag };
|
|
12414
12523
|
if (code !== 0) {
|
|
12415
12524
|
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
@@ -12528,7 +12637,7 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
|
12528
12637
|
|
|
12529
12638
|
// src/skills.ts
|
|
12530
12639
|
import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
|
|
12531
|
-
import { join as
|
|
12640
|
+
import { join as join32 } from "path";
|
|
12532
12641
|
import { parse as parseYaml2 } from "yaml";
|
|
12533
12642
|
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
12534
12643
|
|
|
@@ -12561,7 +12670,7 @@ function readPersonaFile(path) {
|
|
|
12561
12670
|
|
|
12562
12671
|
// src/agents.ts
|
|
12563
12672
|
import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
|
|
12564
|
-
import { join as
|
|
12673
|
+
import { join as join31 } from "path";
|
|
12565
12674
|
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
12566
12675
|
var PERSONA_NAME = {
|
|
12567
12676
|
dev: "Developer",
|
|
@@ -12575,16 +12684,16 @@ var CREW_AGENT_COLUMN = "agent_id";
|
|
|
12575
12684
|
var AgentsSyncError = class extends Error {
|
|
12576
12685
|
};
|
|
12577
12686
|
function personaDefaultPrompt(promptsDir, role) {
|
|
12578
|
-
const briefPath =
|
|
12687
|
+
const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
|
|
12579
12688
|
if (!existsSync27(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
|
|
12580
12689
|
const brief = readPersonaFile(briefPath).body;
|
|
12581
12690
|
if (SELF_CONTAINED_ROLES.has(role)) return brief;
|
|
12582
|
-
const commonPath =
|
|
12691
|
+
const commonPath = join31(promptsDir, "personas", "common.md");
|
|
12583
12692
|
if (!existsSync27(commonPath)) return brief;
|
|
12584
12693
|
return `${readFileSync29(commonPath, "utf8")}${brief}`;
|
|
12585
12694
|
}
|
|
12586
12695
|
function personaChatEnabled(promptsDir, role) {
|
|
12587
|
-
const briefPath =
|
|
12696
|
+
const briefPath = join31(promptsDir, "personas", `lane-${role}.md`);
|
|
12588
12697
|
return existsSync27(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
|
|
12589
12698
|
}
|
|
12590
12699
|
async function resolveAgentId(route2, role, opts) {
|
|
@@ -13082,9 +13191,9 @@ function parseSkillFile(path) {
|
|
|
13082
13191
|
};
|
|
13083
13192
|
}
|
|
13084
13193
|
function listLocalSkills(promptsDir) {
|
|
13085
|
-
const dir =
|
|
13194
|
+
const dir = join32(promptsDir, "skills");
|
|
13086
13195
|
if (!existsSync28(dir)) return [];
|
|
13087
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(
|
|
13196
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join32(dir, f)));
|
|
13088
13197
|
}
|
|
13089
13198
|
function personaColumn(model) {
|
|
13090
13199
|
for (const c of ["persona_id", "persona"]) if (model.fields?.some((f) => f.columnName === c)) return c;
|
|
@@ -13321,7 +13430,7 @@ import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_
|
|
|
13321
13430
|
import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
|
|
13322
13431
|
import { createHash as createHash5 } from "crypto";
|
|
13323
13432
|
import { tmpdir as tmpdir4 } from "os";
|
|
13324
|
-
import { basename as basename8, dirname as
|
|
13433
|
+
import { basename as basename8, dirname as dirname16, join as join33 } from "path";
|
|
13325
13434
|
import { promisify } from "util";
|
|
13326
13435
|
|
|
13327
13436
|
// src/run-limit.ts
|
|
@@ -13472,7 +13581,7 @@ var SandboxRunner = class {
|
|
|
13472
13581
|
throw new Error(`cannot generate the sandbox policy: ${e.message}`);
|
|
13473
13582
|
}
|
|
13474
13583
|
policyFile = policyPathFor(plan.streamPath);
|
|
13475
|
-
mkdirSync21(
|
|
13584
|
+
mkdirSync21(dirname16(policyFile), { recursive: true });
|
|
13476
13585
|
writeFileSync22(policyFile, generated.yaml, { mode: 384 });
|
|
13477
13586
|
}
|
|
13478
13587
|
const create2 = ["sandbox", "create", "--name", name, "--detach"];
|
|
@@ -13522,9 +13631,9 @@ var SandboxRunner = class {
|
|
|
13522
13631
|
const harness = cfg.agentBin ?? basename8(plan.bin);
|
|
13523
13632
|
const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
|
|
13524
13633
|
if (viaUpload) {
|
|
13525
|
-
const tmp = mkdtempSync(
|
|
13634
|
+
const tmp = mkdtempSync(join33(tmpdir4(), "crew-prompt-"));
|
|
13526
13635
|
try {
|
|
13527
|
-
const file =
|
|
13636
|
+
const file = join33(tmp, "prompt.txt");
|
|
13528
13637
|
writeFileSync22(file, plan.prompt, { mode: 384 });
|
|
13529
13638
|
await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
|
|
13530
13639
|
} finally {
|
|
@@ -13746,7 +13855,7 @@ function streamShowsAllowanceRefusal(streamPath) {
|
|
|
13746
13855
|
}
|
|
13747
13856
|
return false;
|
|
13748
13857
|
}
|
|
13749
|
-
var digestPathFor = (stateDir, routeLabel, role, runId) =>
|
|
13858
|
+
var digestPathFor = (stateDir, routeLabel, role, runId) => join34(stateDir, `digest-${routeLabel}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
13750
13859
|
function codeBridgeFor(o, harness) {
|
|
13751
13860
|
if (!o.ticket) return void 0;
|
|
13752
13861
|
const number = /(\d+)$/.exec(o.ticket)?.[1];
|
|
@@ -13774,7 +13883,7 @@ function codeBridgeFor(o, harness) {
|
|
|
13774
13883
|
"--clone",
|
|
13775
13884
|
o.ship.sandbox?.workDir ?? DEFAULT_SANDBOX_WORKDIR,
|
|
13776
13885
|
"--state-dir",
|
|
13777
|
-
|
|
13886
|
+
dirname17(SANDBOX_INTEL_DIR),
|
|
13778
13887
|
"--ticket",
|
|
13779
13888
|
number,
|
|
13780
13889
|
...seed ? ["--seed-cache", seed] : []
|
|
@@ -13787,8 +13896,8 @@ function codeBridgeFor(o, harness) {
|
|
|
13787
13896
|
bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
|
|
13788
13897
|
bridge.files = [{ path: bridge.settingsFile, content: text2 }];
|
|
13789
13898
|
} else {
|
|
13790
|
-
const file =
|
|
13791
|
-
mkdirSync22(
|
|
13899
|
+
const file = join34(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
|
|
13900
|
+
mkdirSync22(dirname17(file), { recursive: true });
|
|
13792
13901
|
writeFileSync23(file, text2);
|
|
13793
13902
|
bridge.settingsFile = file;
|
|
13794
13903
|
}
|
|
@@ -13796,11 +13905,11 @@ function codeBridgeFor(o, harness) {
|
|
|
13796
13905
|
return bridge;
|
|
13797
13906
|
}
|
|
13798
13907
|
function planAgentRun(o) {
|
|
13799
|
-
const briefPath =
|
|
13908
|
+
const briefPath = join34(o.route.promptsDir, "personas", `lane-${o.role}.md`);
|
|
13800
13909
|
if (!existsSync29(briefPath)) {
|
|
13801
13910
|
throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
|
|
13802
13911
|
}
|
|
13803
|
-
const commonPath =
|
|
13912
|
+
const commonPath = join34(o.route.promptsDir, "personas", "common.md");
|
|
13804
13913
|
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync29(commonPath);
|
|
13805
13914
|
const now = o.now ?? (() => Date.now());
|
|
13806
13915
|
const routeLabel = routeSlug(o.route.route);
|
|
@@ -13836,7 +13945,7 @@ function planAgentRun(o) {
|
|
|
13836
13945
|
digest
|
|
13837
13946
|
});
|
|
13838
13947
|
const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
|
|
13839
|
-
const streamsDir =
|
|
13948
|
+
const streamsDir = join34(o.stateDir, "streams");
|
|
13840
13949
|
const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
|
|
13841
13950
|
const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
|
|
13842
13951
|
const { model } = seat;
|
|
@@ -13947,8 +14056,8 @@ function planAgentRun(o) {
|
|
|
13947
14056
|
digestAttached: digest !== void 0,
|
|
13948
14057
|
digestAgeSeconds: ageSeconds,
|
|
13949
14058
|
model,
|
|
13950
|
-
streamPath:
|
|
13951
|
-
eventsPath:
|
|
14059
|
+
streamPath: join34(streamsDir, `${base}.jsonl`),
|
|
14060
|
+
eventsPath: join34(streamsDir, `${base}.events.jsonl`),
|
|
13952
14061
|
ticket: o.ticket,
|
|
13953
14062
|
ticketRecordId: o.ticketRecordId ?? null,
|
|
13954
14063
|
repo: o.repo ?? null,
|
|
@@ -14036,7 +14145,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
|
|
|
14036
14145
|
var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
|
|
14037
14146
|
function openSink(path) {
|
|
14038
14147
|
try {
|
|
14039
|
-
mkdirSync22(
|
|
14148
|
+
mkdirSync22(dirname17(path), { recursive: true });
|
|
14040
14149
|
return createWriteStream(path, { flags: "a" });
|
|
14041
14150
|
} catch {
|
|
14042
14151
|
return void 0;
|
|
@@ -14475,7 +14584,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14475
14584
|
const id = identityOf(plan, adapter.harness);
|
|
14476
14585
|
let streamFd;
|
|
14477
14586
|
try {
|
|
14478
|
-
mkdirSync22(
|
|
14587
|
+
mkdirSync22(dirname17(plan.streamPath), { recursive: true });
|
|
14479
14588
|
streamFd = openSync4(plan.streamPath, "a");
|
|
14480
14589
|
} catch (e) {
|
|
14481
14590
|
void endSink(eventsSink);
|
|
@@ -14740,13 +14849,13 @@ function runFinished(streamPath) {
|
|
|
14740
14849
|
}
|
|
14741
14850
|
}
|
|
14742
14851
|
function orphanedStreams(o) {
|
|
14743
|
-
const dir =
|
|
14852
|
+
const dir = join35(o.stateDir, "streams");
|
|
14744
14853
|
if (!existsSync30(dir)) return [];
|
|
14745
14854
|
const ownerAlive = o.isOwnerAlive ?? pidAlive;
|
|
14746
14855
|
const out = [];
|
|
14747
14856
|
for (const name of readdirSync10(dir)) {
|
|
14748
14857
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14749
|
-
const streamPath =
|
|
14858
|
+
const streamPath = join35(dir, name);
|
|
14750
14859
|
if (runFinished(streamPath)) continue;
|
|
14751
14860
|
const sidecar = readRunSidecar(streamPath);
|
|
14752
14861
|
if (!sidecar || sidecar.route !== o.routeLabel) continue;
|
|
@@ -14800,11 +14909,11 @@ async function reconcileRuns(o) {
|
|
|
14800
14909
|
|
|
14801
14910
|
// src/live-runs.ts
|
|
14802
14911
|
import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
|
|
14803
|
-
import { join as
|
|
14912
|
+
import { join as join37 } from "path";
|
|
14804
14913
|
|
|
14805
14914
|
// src/run-snapshot.ts
|
|
14806
14915
|
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";
|
|
14807
|
-
import { join as
|
|
14916
|
+
import { join as join36 } from "path";
|
|
14808
14917
|
var TAIL_BYTES = 256 * 1024;
|
|
14809
14918
|
var EXCERPT_CHARS = 280;
|
|
14810
14919
|
function endsWithQuestion(text2) {
|
|
@@ -14858,12 +14967,12 @@ function outcomeOf(m) {
|
|
|
14858
14967
|
return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
|
|
14859
14968
|
}
|
|
14860
14969
|
function lastRunsBySeat(stateDir) {
|
|
14861
|
-
const dir =
|
|
14970
|
+
const dir = join36(stateDir, "streams");
|
|
14862
14971
|
const out = /* @__PURE__ */ new Map();
|
|
14863
14972
|
if (!existsSync31(dir)) return out;
|
|
14864
14973
|
for (const name of readdirSync11(dir)) {
|
|
14865
14974
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14866
|
-
const streamPath =
|
|
14975
|
+
const streamPath = join36(dir, name);
|
|
14867
14976
|
if (!runFinished(streamPath)) continue;
|
|
14868
14977
|
const metaPath = `${streamPath}.meta.json`;
|
|
14869
14978
|
let meta;
|
|
@@ -14912,12 +15021,12 @@ function appendRunNote(streamPath, note) {
|
|
|
14912
15021
|
|
|
14913
15022
|
// src/live-runs.ts
|
|
14914
15023
|
function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
14915
|
-
const dir =
|
|
15024
|
+
const dir = join37(stateDir, "streams");
|
|
14916
15025
|
if (!existsSync32(dir)) return [];
|
|
14917
15026
|
const out = [];
|
|
14918
15027
|
for (const name of readdirSync12(dir)) {
|
|
14919
15028
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14920
|
-
const streamPath =
|
|
15029
|
+
const streamPath = join37(dir, name);
|
|
14921
15030
|
if (runFinished(streamPath)) continue;
|
|
14922
15031
|
const sidecar = readRunSidecar(streamPath);
|
|
14923
15032
|
if (!sidecar || !isAlive(sidecar)) continue;
|
|
@@ -14927,12 +15036,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
|
14927
15036
|
}
|
|
14928
15037
|
function runActivity(stateDir, isAlive = runIsAlive) {
|
|
14929
15038
|
const activeRuns = liveRuns(stateDir, isAlive).length;
|
|
14930
|
-
const dir =
|
|
15039
|
+
const dir = join37(stateDir, "streams");
|
|
14931
15040
|
let newest = 0;
|
|
14932
15041
|
if (existsSync32(dir)) {
|
|
14933
15042
|
for (const name of readdirSync12(dir)) {
|
|
14934
15043
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14935
|
-
const streamPath =
|
|
15044
|
+
const streamPath = join37(dir, name);
|
|
14936
15045
|
if (!runFinished(streamPath)) continue;
|
|
14937
15046
|
try {
|
|
14938
15047
|
newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
|
|
@@ -15945,7 +16054,7 @@ function managedGitIdentityWarnings(kind, identity) {
|
|
|
15945
16054
|
import { spawn as spawn7 } from "child_process";
|
|
15946
16055
|
import { existsSync as existsSync34, mkdirSync as mkdirSync23, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
|
|
15947
16056
|
import { tmpdir as tmpdir5 } from "os";
|
|
15948
|
-
import { join as
|
|
16057
|
+
import { join as join38 } from "path";
|
|
15949
16058
|
var SELFTEST_TIMEOUT_MS = 12e4;
|
|
15950
16059
|
var KEY_VAR = "CREW_API_KEY";
|
|
15951
16060
|
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: ";
|
|
@@ -16111,7 +16220,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
16111
16220
|
...adapter.runEnv(spec),
|
|
16112
16221
|
[KEY_VAR]: i.apiKey
|
|
16113
16222
|
};
|
|
16114
|
-
const cwd = mkdtempSync2(
|
|
16223
|
+
const cwd = mkdtempSync2(join38(tmpdir5(), "crew-selftest-"));
|
|
16115
16224
|
try {
|
|
16116
16225
|
const run4 = await deps.run({
|
|
16117
16226
|
bin: invocation.bin,
|
|
@@ -16144,7 +16253,7 @@ function formatResult(r) {
|
|
|
16144
16253
|
const secs = `${(r.ms / 1e3).toFixed(1)}s`;
|
|
16145
16254
|
return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
|
|
16146
16255
|
}
|
|
16147
|
-
var fileFor3 = (stateDir) =>
|
|
16256
|
+
var fileFor3 = (stateDir) => join38(stateDir, "selftest.json");
|
|
16148
16257
|
function readSelftest(stateDir) {
|
|
16149
16258
|
try {
|
|
16150
16259
|
const p = fileFor3(stateDir);
|
|
@@ -16219,7 +16328,7 @@ async function runSelfLaunchCheck(own, spawnFn = spawnChild, launch = selfLaunch
|
|
|
16219
16328
|
}
|
|
16220
16329
|
|
|
16221
16330
|
// src/cli.ts
|
|
16222
|
-
import { resolve as resolve7, dirname as
|
|
16331
|
+
import { resolve as resolve7, dirname as dirname38, join as join66, basename as basename17 } from "path";
|
|
16223
16332
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
16224
16333
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
16225
16334
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
@@ -16269,6 +16378,8 @@ var VALUE_FLAGS = /* @__PURE__ */ new Set([
|
|
|
16269
16378
|
"source",
|
|
16270
16379
|
"var",
|
|
16271
16380
|
"path",
|
|
16381
|
+
"prefix",
|
|
16382
|
+
"work-mode",
|
|
16272
16383
|
"service",
|
|
16273
16384
|
"topic",
|
|
16274
16385
|
"assignee",
|
|
@@ -16429,9 +16540,9 @@ function rosterMarkdown(roster, meId) {
|
|
|
16429
16540
|
|
|
16430
16541
|
// src/connect-resume.ts
|
|
16431
16542
|
import { mkdirSync as mkdirSync24, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "fs";
|
|
16432
|
-
import { dirname as
|
|
16543
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
16433
16544
|
function lastSessionFile(stateDir) {
|
|
16434
|
-
return
|
|
16545
|
+
return join39(stateDir, "connect-session.json");
|
|
16435
16546
|
}
|
|
16436
16547
|
function readPointers(stateDir) {
|
|
16437
16548
|
try {
|
|
@@ -16449,7 +16560,7 @@ function readPointers(stateDir) {
|
|
|
16449
16560
|
}
|
|
16450
16561
|
function writePointers(stateDir, pointers) {
|
|
16451
16562
|
const file = lastSessionFile(stateDir);
|
|
16452
|
-
mkdirSync24(
|
|
16563
|
+
mkdirSync24(dirname18(file), { recursive: true });
|
|
16453
16564
|
writeFileSync26(file, `${JSON.stringify(pointers, null, 2)}
|
|
16454
16565
|
`, { mode: 384 });
|
|
16455
16566
|
}
|
|
@@ -16536,10 +16647,10 @@ async function signOutSessions(o) {
|
|
|
16536
16647
|
|
|
16537
16648
|
// src/reset.ts
|
|
16538
16649
|
import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync27 } from "fs";
|
|
16539
|
-
import { dirname as
|
|
16650
|
+
import { dirname as dirname19, join as join40 } from "path";
|
|
16540
16651
|
import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
|
|
16541
16652
|
function clonedCheckoutsFile(stateDir) {
|
|
16542
|
-
return
|
|
16653
|
+
return join40(stateDir, "cloned-checkouts.json");
|
|
16543
16654
|
}
|
|
16544
16655
|
function readClonedCheckouts(stateDir) {
|
|
16545
16656
|
try {
|
|
@@ -16553,7 +16664,7 @@ function recordClonedCheckout(stateDir, dir) {
|
|
|
16553
16664
|
const known = readClonedCheckouts(stateDir);
|
|
16554
16665
|
if (known.includes(dir)) return;
|
|
16555
16666
|
const file = clonedCheckoutsFile(stateDir);
|
|
16556
|
-
mkdirSync25(
|
|
16667
|
+
mkdirSync25(dirname19(file), { recursive: true });
|
|
16557
16668
|
writeFileSync27(file, `${JSON.stringify([...known, dir], null, 2)}
|
|
16558
16669
|
`);
|
|
16559
16670
|
}
|
|
@@ -16630,10 +16741,10 @@ function removeCheckout(dir, dryRun, fx) {
|
|
|
16630
16741
|
}
|
|
16631
16742
|
function removeState(stateDir, dryRun) {
|
|
16632
16743
|
const out = [];
|
|
16633
|
-
const targets = [
|
|
16744
|
+
const targets = [join40(stateDir, "resolved"), join40(stateDir, "keys"), clonedCheckoutsFile(stateDir), join40(stateDir, "connect-session.json"), join40(stateDir, "reload-requested"), join40(stateDir, "daemon.started")];
|
|
16634
16745
|
try {
|
|
16635
16746
|
for (const name of readdirSync14(stateDir)) {
|
|
16636
|
-
if (name.startsWith(".") && statSync12(
|
|
16747
|
+
if (name.startsWith(".") && statSync12(join40(stateDir, name)).isFile()) targets.push(join40(stateDir, name));
|
|
16637
16748
|
}
|
|
16638
16749
|
} catch {
|
|
16639
16750
|
}
|
|
@@ -16653,7 +16764,7 @@ function wipeStateDir(stateDir, dryRun) {
|
|
|
16653
16764
|
return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
|
|
16654
16765
|
}
|
|
16655
16766
|
if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
|
|
16656
|
-
if (!dryRun) for (const n of names) rmSync20(
|
|
16767
|
+
if (!dryRun) for (const n of names) rmSync20(join40(stateDir, n), { recursive: true, force: true });
|
|
16657
16768
|
return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
|
|
16658
16769
|
}
|
|
16659
16770
|
function describeResetStep(s) {
|
|
@@ -16737,7 +16848,7 @@ async function runDeprovision(o, fx, deps) {
|
|
|
16737
16848
|
// src/pool-member.ts
|
|
16738
16849
|
import { mkdirSync as mkdirSync26, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync28 } from "fs";
|
|
16739
16850
|
import { homedir as homedir8 } from "os";
|
|
16740
|
-
import { dirname as
|
|
16851
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
16741
16852
|
var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
|
|
16742
16853
|
function backoffMs(attempt) {
|
|
16743
16854
|
return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
|
|
@@ -16979,10 +17090,10 @@ async function runPoolMember(deps) {
|
|
|
16979
17090
|
}
|
|
16980
17091
|
}
|
|
16981
17092
|
function defaultMemberDir(env = process.env) {
|
|
16982
|
-
return env.CREW_POOL_DIR ??
|
|
17093
|
+
return env.CREW_POOL_DIR ?? join41(env.XDG_STATE_HOME ?? join41(homedir8(), ".local", "state"), "crew-pool-member");
|
|
16983
17094
|
}
|
|
16984
17095
|
function fileMemberStore(dir) {
|
|
16985
|
-
const file =
|
|
17096
|
+
const file = join41(dir, "member.json");
|
|
16986
17097
|
return {
|
|
16987
17098
|
read() {
|
|
16988
17099
|
try {
|
|
@@ -16992,7 +17103,7 @@ function fileMemberStore(dir) {
|
|
|
16992
17103
|
}
|
|
16993
17104
|
},
|
|
16994
17105
|
write(f) {
|
|
16995
|
-
mkdirSync26(
|
|
17106
|
+
mkdirSync26(dirname20(file), { recursive: true, mode: 448 });
|
|
16996
17107
|
const tmp = `${file}.tmp`;
|
|
16997
17108
|
writeFileSync28(tmp, `${JSON.stringify(f)}
|
|
16998
17109
|
`, { mode: 384 });
|
|
@@ -17053,9 +17164,9 @@ import { hostname as hostname3 } from "os";
|
|
|
17053
17164
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
17054
17165
|
import { createHash as createHash8 } from "crypto";
|
|
17055
17166
|
import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
|
|
17056
|
-
import { dirname as
|
|
17167
|
+
import { dirname as dirname21, join as join42 } from "path";
|
|
17057
17168
|
function machineIdPathFor(stateDir) {
|
|
17058
|
-
return
|
|
17169
|
+
return join42(stateDir, "machine-id");
|
|
17059
17170
|
}
|
|
17060
17171
|
var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
|
|
17061
17172
|
function readRawMachineId(platform2 = process.platform) {
|
|
@@ -17087,7 +17198,7 @@ function ensureMachineId(stateDir, opts = {}) {
|
|
|
17087
17198
|
const raw = (opts.read ?? readRawMachineId)();
|
|
17088
17199
|
if (!raw) return void 0;
|
|
17089
17200
|
const hashed = sha256(raw);
|
|
17090
|
-
mkdirSync27(
|
|
17201
|
+
mkdirSync27(dirname21(path), { recursive: true });
|
|
17091
17202
|
writeFileSync29(path, `${hashed}
|
|
17092
17203
|
`, { mode: 384 });
|
|
17093
17204
|
return hashed;
|
|
@@ -17110,10 +17221,23 @@ import { parseDocument as parseDocument2 } from "yaml";
|
|
|
17110
17221
|
|
|
17111
17222
|
// src/repos-cmd.ts
|
|
17112
17223
|
import { homedir as homedir9 } from "os";
|
|
17113
|
-
import { basename as basename10, join as
|
|
17224
|
+
import { basename as basename10, join as join43, resolve as resolve4 } from "path";
|
|
17114
17225
|
import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
|
|
17115
17226
|
var ReposError = class extends Error {
|
|
17227
|
+
/** A stable reason for a `--json` reader, when the failure has one (CREW-3359). */
|
|
17228
|
+
code;
|
|
17229
|
+
constructor(message, code) {
|
|
17230
|
+
super(message);
|
|
17231
|
+
this.code = code;
|
|
17232
|
+
}
|
|
17116
17233
|
};
|
|
17234
|
+
var NO_PROJECTS_CODE = "no_projects";
|
|
17235
|
+
function noProjectsError() {
|
|
17236
|
+
return new ReposError(
|
|
17237
|
+
"the tracker has no Projects row, so the new Repos row has no project to belong to \u2014 create one with `crew projects add NAME --prefix PREFIX`, then re-run (or pass --no-create to skip the Repos row)",
|
|
17238
|
+
NO_PROJECTS_CODE
|
|
17239
|
+
);
|
|
17240
|
+
}
|
|
17117
17241
|
function normalizeRemote2(url) {
|
|
17118
17242
|
if (!url) return void 0;
|
|
17119
17243
|
let s = url.trim();
|
|
@@ -17388,7 +17512,7 @@ function planRepoClone(i) {
|
|
|
17388
17512
|
}
|
|
17389
17513
|
const ship = doc.get("ship", true);
|
|
17390
17514
|
const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
|
|
17391
|
-
const target = i.dir ? expandDir(i.dir, i.base) :
|
|
17515
|
+
const target = i.dir ? expandDir(i.dir, i.base) : join43(expandDir(basePath, i.base), i.route.split("/")[0], name);
|
|
17392
17516
|
const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
|
|
17393
17517
|
const forgeHost = i.resolved?.repoForgeHosts?.[id];
|
|
17394
17518
|
return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
|
|
@@ -18954,7 +19078,7 @@ function diskFullStop(state) {
|
|
|
18954
19078
|
|
|
18955
19079
|
// src/poll.ts
|
|
18956
19080
|
import { writeFileSync as writeFileSync31 } from "fs";
|
|
18957
|
-
import { join as
|
|
19081
|
+
import { join as join44 } from "path";
|
|
18958
19082
|
|
|
18959
19083
|
// src/stalled.ts
|
|
18960
19084
|
var STALLED_AFTER_CYCLES = 30;
|
|
@@ -19271,7 +19395,7 @@ async function decideCycle(o) {
|
|
|
19271
19395
|
}
|
|
19272
19396
|
return decision;
|
|
19273
19397
|
}
|
|
19274
|
-
var digestPath = (stateDir, route2, role, runId) =>
|
|
19398
|
+
var digestPath = (stateDir, route2, role, runId) => join44(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
19275
19399
|
function otherRunsRemoved(tickets, own) {
|
|
19276
19400
|
if (!own) return tickets;
|
|
19277
19401
|
return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
|
|
@@ -19502,7 +19626,7 @@ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket,
|
|
|
19502
19626
|
|
|
19503
19627
|
// src/repo-refresh.ts
|
|
19504
19628
|
import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
19505
|
-
import { dirname as
|
|
19629
|
+
import { dirname as dirname23 } from "path";
|
|
19506
19630
|
var REFRESH_COOLDOWN_MS = 2 * 6e4;
|
|
19507
19631
|
var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
|
|
19508
19632
|
var lastAsked = /* @__PURE__ */ new Map();
|
|
@@ -19534,7 +19658,7 @@ function persistRepoRows(stateDir, routeName, rows) {
|
|
|
19534
19658
|
if (!existsSync40(path)) return;
|
|
19535
19659
|
const raw = JSON.parse(readFileSync40(path, "utf8"));
|
|
19536
19660
|
applyRepoRows(raw, rows);
|
|
19537
|
-
mkdirSync28(
|
|
19661
|
+
mkdirSync28(dirname23(path), { recursive: true });
|
|
19538
19662
|
writeFileSync32(path, `${JSON.stringify(raw, null, 2)}
|
|
19539
19663
|
`);
|
|
19540
19664
|
}
|
|
@@ -19925,14 +20049,39 @@ async function applyBuildFailureBounce(writer, b, contract, memberId, log, dryRu
|
|
|
19925
20049
|
|
|
19926
20050
|
// src/stranded-verified.ts
|
|
19927
20051
|
var STRANDED_MARKER = calloutHeader("WARNING", "Stranded Verified");
|
|
20052
|
+
function findNearMissBranches(dir, cfg, ticket) {
|
|
20053
|
+
const number = ticket.issue_id.replace(/^\D+/, "");
|
|
20054
|
+
if (!number) return [];
|
|
20055
|
+
const remote = cfg.branch.remote;
|
|
20056
|
+
const prefix = `refs/remotes/${remote}/`;
|
|
20057
|
+
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));
|
|
20058
|
+
const keys = [...new Set([ticket.issue_id, ticket.issue_tag].filter((k) => !!k))];
|
|
20059
|
+
const keyRe = keys.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
20060
|
+
const out = [];
|
|
20061
|
+
for (const b of refs) {
|
|
20062
|
+
const log = gitOk(dir, ["log", "--format=%H", "-E", "-i", `--grep=(^|[^0-9A-Za-z])(${keyRe})([^0-9]|$)`, `${remote}/${cfg.branch.base}..${prefix}${b}`]);
|
|
20063
|
+
const commits = log ? log.split("\n").filter(Boolean).length : 0;
|
|
20064
|
+
if (commits > 0) out.push({ branch: b, commits });
|
|
20065
|
+
}
|
|
20066
|
+
return out;
|
|
20067
|
+
}
|
|
20068
|
+
function nearMissText(s) {
|
|
20069
|
+
if (!s.nearMisses?.length) return "";
|
|
20070
|
+
const list = s.nearMisses.map((n) => `\`${s.remote}/${n.branch}\` (${n.commits} commit${n.commits === 1 ? "" : "s"} naming the key)`).join(", ");
|
|
20071
|
+
return `
|
|
20072
|
+
|
|
20073
|
+
**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.`;
|
|
20074
|
+
}
|
|
19928
20075
|
var STRANDED_ESCALATE_AFTER_MS = 30 * 60 * 1e3;
|
|
19929
20076
|
var priorStrandedFlags = (ticket, events) => events.filter((e) => e.record_id === ticket.id && e.event_type === "stranded_flagged").length;
|
|
19930
|
-
function planStrandedVerified(candidate, base, remote, events) {
|
|
20077
|
+
function planStrandedVerified(candidate, base, remote, events, look) {
|
|
19931
20078
|
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));
|
|
20079
|
+
const nearMisses = look ? findNearMissBranches(look.dir, look.cfg, candidate.ticket) : [];
|
|
19932
20080
|
return {
|
|
19933
20081
|
candidate,
|
|
19934
20082
|
base,
|
|
19935
20083
|
remote,
|
|
20084
|
+
...nearMisses.length && look ? { nearMisses, expectedBranch: branchCandidatesForTicket(look.cfg, candidate.ticket).find((c) => !c.endsWith("*")) } : {},
|
|
19936
20085
|
priorFlags: priorStrandedFlags(candidate.ticket, events),
|
|
19937
20086
|
lastFlaggedAt: stamps.length ? Math.max(...stamps) : void 0
|
|
19938
20087
|
};
|
|
@@ -19945,7 +20094,7 @@ function flagComment(s) {
|
|
|
19945
20094
|
|
|
19946
20095
|
\`${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.
|
|
19947
20096
|
|
|
19948
|
-
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
|
|
20097
|
+
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)}`;
|
|
19949
20098
|
}
|
|
19950
20099
|
function escalateComment2(s) {
|
|
19951
20100
|
const key = s.candidate.ticket.issue_id;
|
|
@@ -19955,7 +20104,7 @@ function escalateComment2(s) {
|
|
|
19955
20104
|
|
|
19956
20105
|
\`${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.
|
|
19957
20106
|
|
|
19958
|
-
The crew will not close this on its own
|
|
20107
|
+
The crew will not close this on its own.${nearMissText(s)}`;
|
|
19959
20108
|
}
|
|
19960
20109
|
async function applyStrandedVerified(writer, s, contract, operatorId, memberId, log, dryRun, now = Date.now()) {
|
|
19961
20110
|
const t = { ticket: s.candidate.ticket.issue_id, step: "merge" };
|
|
@@ -20011,7 +20160,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
|
|
|
20011
20160
|
var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
|
|
20012
20161
|
|
|
20013
20162
|
// src/platform-gate.ts
|
|
20014
|
-
import { join as
|
|
20163
|
+
import { join as join45 } from "path";
|
|
20015
20164
|
function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
20016
20165
|
const out = [];
|
|
20017
20166
|
for (const t of tickets) {
|
|
@@ -20023,7 +20172,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
|
20023
20172
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
20024
20173
|
if (text2 === null) continue;
|
|
20025
20174
|
try {
|
|
20026
|
-
const { platform: platform2 } = parseRepoConfig(text2,
|
|
20175
|
+
const { platform: platform2 } = parseRepoConfig(text2, join45(dir, file));
|
|
20027
20176
|
if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
|
|
20028
20177
|
} catch (e) {
|
|
20029
20178
|
if (e instanceof RepoConfigError) continue;
|
|
@@ -20039,7 +20188,7 @@ function platformStuckNote(repo, required, ship, issueIds) {
|
|
|
20039
20188
|
}
|
|
20040
20189
|
|
|
20041
20190
|
// src/connect-wizard.ts
|
|
20042
|
-
import { delimiter, dirname as
|
|
20191
|
+
import { delimiter, dirname as dirname24, join as join46 } from "path";
|
|
20043
20192
|
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync29, writeFileSync as writeFileSync33 } from "fs";
|
|
20044
20193
|
import { stringify as stringify3 } from "yaml";
|
|
20045
20194
|
var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
|
|
@@ -20062,7 +20211,7 @@ function defaultIsExecutable(p) {
|
|
|
20062
20211
|
function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
|
|
20063
20212
|
for (const dir of pathEnv.split(delimiter)) {
|
|
20064
20213
|
if (!dir) continue;
|
|
20065
|
-
const candidate =
|
|
20214
|
+
const candidate = join46(dir, name);
|
|
20066
20215
|
if (isExecutable(candidate)) return candidate;
|
|
20067
20216
|
}
|
|
20068
20217
|
return void 0;
|
|
@@ -20088,9 +20237,9 @@ async function runWizard(p, env) {
|
|
|
20088
20237
|
if (entered && isExec(entered)) agentBin = entered;
|
|
20089
20238
|
else p.say(entered ? `${entered} is not an executable file.` : "A path is required.");
|
|
20090
20239
|
}
|
|
20091
|
-
const nodeDir =
|
|
20240
|
+
const nodeDir = dirname24(env.nodePath);
|
|
20092
20241
|
const pnpmPath = findOnPath2("pnpm", env.pathEnv, isExec);
|
|
20093
|
-
const baseDirs = [nodeDir, pnpmPath ?
|
|
20242
|
+
const baseDirs = [nodeDir, pnpmPath ? dirname24(pnpmPath) : void 0];
|
|
20094
20243
|
p.say(
|
|
20095
20244
|
`
|
|
20096
20245
|
Host Passengers lets this machine run the agent sessions that other people's
|
|
@@ -20101,7 +20250,7 @@ Tablation workspaces ask for, in a container. More: ${HOST_PASSENGERS_DOCS_URL}`
|
|
|
20101
20250
|
p.say("Docker is not available here, so nothing will be hosted until it is. Your answer is recorded anyway.");
|
|
20102
20251
|
}
|
|
20103
20252
|
const dockerPath = hostPassengers ? findOnPath2("docker", env.pathEnv, isExec) : void 0;
|
|
20104
|
-
const extraPath = deriveExtraPath([...baseDirs, dockerPath ?
|
|
20253
|
+
const extraPath = deriveExtraPath([...baseDirs, dockerPath ? dirname24(dockerPath) : void 0]);
|
|
20105
20254
|
if (extraPath) {
|
|
20106
20255
|
p.say(`Hooks will get ${extraPath} on their PATH (where node, pnpm${dockerPath ? " and docker" : ""} live).`);
|
|
20107
20256
|
}
|
|
@@ -20123,7 +20272,7 @@ routes:
|
|
|
20123
20272
|
${routeBlock}`;
|
|
20124
20273
|
}
|
|
20125
20274
|
function writeNewConfig(path, text2) {
|
|
20126
|
-
mkdirSync29(
|
|
20275
|
+
mkdirSync29(dirname24(path), { recursive: true });
|
|
20127
20276
|
try {
|
|
20128
20277
|
writeFileSync33(path, text2, { mode: 384, flag: "wx" });
|
|
20129
20278
|
return true;
|
|
@@ -20159,7 +20308,7 @@ Wrote ${o.configPath}.
|
|
|
20159
20308
|
// src/connect-json.ts
|
|
20160
20309
|
import { accessSync as accessSync4, constants as constants4 } from "fs";
|
|
20161
20310
|
import { homedir as homedir10 } from "os";
|
|
20162
|
-
import { dirname as
|
|
20311
|
+
import { dirname as dirname25, join as join47 } from "path";
|
|
20163
20312
|
import { delimiter as delimiter2 } from "path";
|
|
20164
20313
|
var CHOICE_EXIT_CODE = 3;
|
|
20165
20314
|
function createEmitter(json2, write) {
|
|
@@ -20198,12 +20347,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
|
|
|
20198
20347
|
const dirs = [
|
|
20199
20348
|
...pathEnv.split(delimiter2),
|
|
20200
20349
|
...(extraPath ?? "").split(delimiter2),
|
|
20201
|
-
|
|
20202
|
-
|
|
20350
|
+
join47(home, ".local/bin"),
|
|
20351
|
+
join47(home, ".claude/local"),
|
|
20203
20352
|
"/opt/homebrew/bin",
|
|
20204
20353
|
"/usr/local/bin",
|
|
20205
|
-
|
|
20206
|
-
|
|
20354
|
+
join47(home, ".npm-global/bin"),
|
|
20355
|
+
join47(home, ".volta/bin")
|
|
20207
20356
|
];
|
|
20208
20357
|
return [...new Set(dirs.filter(Boolean))];
|
|
20209
20358
|
}
|
|
@@ -20225,7 +20374,7 @@ function flagWizardAnswers(f, env) {
|
|
|
20225
20374
|
const agentBin = f.agentBin ?? found?.bin;
|
|
20226
20375
|
const pnpmPath = findOnPath2("pnpm", env.pathEnv, isExec);
|
|
20227
20376
|
const dockerPath = f.hostPassengers ? findOnPath2("docker", env.pathEnv, isExec) : void 0;
|
|
20228
|
-
const extraPath = f.extraPath ?? deriveExtraPath([
|
|
20377
|
+
const extraPath = f.extraPath ?? deriveExtraPath([dirname25(env.nodePath), pnpmPath ? dirname25(pnpmPath) : void 0, dockerPath ? dirname25(dockerPath) : void 0]);
|
|
20229
20378
|
return {
|
|
20230
20379
|
answers: {
|
|
20231
20380
|
name: f.shipName?.trim() || env.hostname,
|
|
@@ -20325,7 +20474,7 @@ async function collectDiagnostics(d) {
|
|
|
20325
20474
|
|
|
20326
20475
|
// src/release-run.ts
|
|
20327
20476
|
import { readFileSync as readFileSync41, writeFileSync as writeFileSync34, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
|
|
20328
|
-
import { dirname as
|
|
20477
|
+
import { dirname as dirname26, join as join48 } from "path";
|
|
20329
20478
|
import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
|
|
20330
20479
|
|
|
20331
20480
|
// src/release.ts
|
|
@@ -21300,7 +21449,7 @@ async function bump(o, size) {
|
|
|
21300
21449
|
}
|
|
21301
21450
|
return printed;
|
|
21302
21451
|
}
|
|
21303
|
-
const files = o.repo.release.versionFiles.map((f) =>
|
|
21452
|
+
const files = o.repo.release.versionFiles.map((f) => join48(o.cwd, f));
|
|
21304
21453
|
const first = files[0];
|
|
21305
21454
|
if (!existsAt(first, existsSync42)) {
|
|
21306
21455
|
o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
|
|
@@ -21338,7 +21487,7 @@ async function bump(o, size) {
|
|
|
21338
21487
|
function writeChangelog(o, version, entries) {
|
|
21339
21488
|
const file = o.repo.release.changelog;
|
|
21340
21489
|
if (!file || entries.length === 0) return;
|
|
21341
|
-
const path =
|
|
21490
|
+
const path = join48(o.cwd, file);
|
|
21342
21491
|
const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
|
|
21343
21492
|
if (o.dryRun) {
|
|
21344
21493
|
o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
|
|
@@ -21438,8 +21587,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
21438
21587
|
function openReleaseCheckout(o) {
|
|
21439
21588
|
const { remote, base } = o.repo.branch;
|
|
21440
21589
|
const branch = `crew/release-${Date.now()}`;
|
|
21441
|
-
const root = mkdtempSync3(
|
|
21442
|
-
const dir =
|
|
21590
|
+
const root = mkdtempSync3(join48(tmpdir6(), "crew-release-"));
|
|
21591
|
+
const dir = join48(root, "checkout");
|
|
21443
21592
|
o.emit.note(`release checkout: ${dir}`, { step: "release" });
|
|
21444
21593
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
21445
21594
|
try {
|
|
@@ -21449,10 +21598,10 @@ function openReleaseCheckout(o) {
|
|
|
21449
21598
|
throw e;
|
|
21450
21599
|
}
|
|
21451
21600
|
for (const f of o.repo.worktrees.copy) {
|
|
21452
|
-
const src =
|
|
21601
|
+
const src = join48(o.cwd, f);
|
|
21453
21602
|
if (!existsSync42(src)) continue;
|
|
21454
|
-
mkdirSync30(
|
|
21455
|
-
copyFileSync(src,
|
|
21603
|
+
mkdirSync30(dirname26(join48(dir, f)), { recursive: true });
|
|
21604
|
+
copyFileSync(src, join48(dir, f));
|
|
21456
21605
|
}
|
|
21457
21606
|
return { dir, branch, close };
|
|
21458
21607
|
}
|
|
@@ -22279,7 +22428,7 @@ import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
|
|
|
22279
22428
|
|
|
22280
22429
|
// src/daemon.ts
|
|
22281
22430
|
import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
|
|
22282
|
-
import { join as
|
|
22431
|
+
import { join as join53 } from "path";
|
|
22283
22432
|
import { randomBytes } from "crypto";
|
|
22284
22433
|
|
|
22285
22434
|
// src/outage.ts
|
|
@@ -22403,11 +22552,11 @@ function nextRoles(decision, ran) {
|
|
|
22403
22552
|
|
|
22404
22553
|
// src/noop-runs.ts
|
|
22405
22554
|
import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
|
|
22406
|
-
import { join as
|
|
22555
|
+
import { join as join49 } from "path";
|
|
22407
22556
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
22408
22557
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
22409
22558
|
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
22410
|
-
var noopRunsPath = (stateDir) =>
|
|
22559
|
+
var noopRunsPath = (stateDir) => join49(stateDir, "noop-runs.json");
|
|
22411
22560
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
22412
22561
|
function readNoopRuns(stateDir) {
|
|
22413
22562
|
try {
|
|
@@ -22498,7 +22647,7 @@ async function settleNoopRun(o) {
|
|
|
22498
22647
|
|
|
22499
22648
|
// src/ship-name.ts
|
|
22500
22649
|
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
|
|
22501
|
-
import { dirname as
|
|
22650
|
+
import { dirname as dirname27 } from "path";
|
|
22502
22651
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
22503
22652
|
var ShipNameError = class extends Error {
|
|
22504
22653
|
};
|
|
@@ -22577,7 +22726,7 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
22577
22726
|
}
|
|
22578
22727
|
if (raw.shipName === name) return;
|
|
22579
22728
|
raw.shipName = name;
|
|
22580
|
-
mkdirSync32(
|
|
22729
|
+
mkdirSync32(dirname27(resolvedFile), { recursive: true });
|
|
22581
22730
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
22582
22731
|
writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
|
|
22583
22732
|
`);
|
|
@@ -22660,7 +22809,7 @@ import { existsSync as existsSync45 } from "fs";
|
|
|
22660
22809
|
|
|
22661
22810
|
// src/passenger-mirror.ts
|
|
22662
22811
|
import { mkdirSync as mkdirSync33 } from "fs";
|
|
22663
|
-
import { dirname as
|
|
22812
|
+
import { dirname as dirname28 } from "path";
|
|
22664
22813
|
function mirrorRepoOf(spec) {
|
|
22665
22814
|
const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
|
|
22666
22815
|
if (fromOrigin) return fromOrigin;
|
|
@@ -22678,7 +22827,7 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
|
|
|
22678
22827
|
continue;
|
|
22679
22828
|
}
|
|
22680
22829
|
try {
|
|
22681
|
-
const parent =
|
|
22830
|
+
const parent = dirname28(spec.dir);
|
|
22682
22831
|
mkdirSync33(parent, { recursive: true });
|
|
22683
22832
|
mkdirSync33(spec.dir, { recursive: true });
|
|
22684
22833
|
const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
|
|
@@ -22779,17 +22928,17 @@ function explainRefusal(readable, unreadable) {
|
|
|
22779
22928
|
// src/ssh-keys.ts
|
|
22780
22929
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
22781
22930
|
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
22782
|
-
import { dirname as
|
|
22931
|
+
import { dirname as dirname29, join as join50 } from "path";
|
|
22783
22932
|
var SshKeyError = class extends Error {
|
|
22784
22933
|
};
|
|
22785
22934
|
function shipSshKeyPathFor(stateDir) {
|
|
22786
|
-
return
|
|
22935
|
+
return join50(stateDir, "ssh", "id_ed25519");
|
|
22787
22936
|
}
|
|
22788
22937
|
function ensureShipSshKeypair(stateDir) {
|
|
22789
22938
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
22790
22939
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
22791
22940
|
if (!existsSync46(privateKeyPath)) {
|
|
22792
|
-
mkdirSync34(
|
|
22941
|
+
mkdirSync34(dirname29(privateKeyPath), { recursive: true });
|
|
22793
22942
|
try {
|
|
22794
22943
|
execFileSync13("ssh-keygen", [
|
|
22795
22944
|
"-t",
|
|
@@ -22827,7 +22976,7 @@ function sshKeygenAvailable() {
|
|
|
22827
22976
|
// src/periscope-idle.ts
|
|
22828
22977
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
22829
22978
|
import { statSync as statSync13 } from "fs";
|
|
22830
|
-
import { join as
|
|
22979
|
+
import { join as join51 } from "path";
|
|
22831
22980
|
var MAX_SCANNED_FILES = 2e4;
|
|
22832
22981
|
function newestWorktreeMtime(root) {
|
|
22833
22982
|
const a = newestTrackedMtime(root);
|
|
@@ -22852,7 +23001,7 @@ function newestTrackedMtime(root) {
|
|
|
22852
23001
|
if (!rel) continue;
|
|
22853
23002
|
if (++scanned > MAX_SCANNED_FILES) break;
|
|
22854
23003
|
try {
|
|
22855
|
-
const m = statSync13(
|
|
23004
|
+
const m = statSync13(join51(root, rel)).mtimeMs;
|
|
22856
23005
|
if (newest === null || m > newest) newest = m;
|
|
22857
23006
|
} catch {
|
|
22858
23007
|
}
|
|
@@ -22927,7 +23076,7 @@ async function runPeriscopeIdlePass(d) {
|
|
|
22927
23076
|
|
|
22928
23077
|
// src/periscope-cmd.ts
|
|
22929
23078
|
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
|
|
22930
|
-
import { join as
|
|
23079
|
+
import { join as join52 } from "path";
|
|
22931
23080
|
var PeriscopeError = class extends Error {
|
|
22932
23081
|
};
|
|
22933
23082
|
var LivePeriscopeError = class extends PeriscopeError {
|
|
@@ -22937,8 +23086,8 @@ var LivePeriscopeError = class extends PeriscopeError {
|
|
|
22937
23086
|
this.data = { refused: "live_periscope_exists", ...live2 };
|
|
22938
23087
|
}
|
|
22939
23088
|
};
|
|
22940
|
-
var priorDir = (stateDir) =>
|
|
22941
|
-
var priorPath = (stateDir, ticketRecordId) =>
|
|
23089
|
+
var priorDir = (stateDir) => join52(stateDir, "periscope-priors");
|
|
23090
|
+
var priorPath = (stateDir, ticketRecordId) => join52(priorDir(stateDir), `${ticketRecordId}.json`);
|
|
22942
23091
|
function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
22943
23092
|
rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
|
|
22944
23093
|
}
|
|
@@ -23491,7 +23640,7 @@ function latestMtime(path) {
|
|
|
23491
23640
|
if (!stat2.isDirectory()) return 0;
|
|
23492
23641
|
let latest = stat2.mtimeMs;
|
|
23493
23642
|
for (const entry of readdirSync15(path, { withFileTypes: true })) {
|
|
23494
|
-
latest = Math.max(latest, latestMtime(
|
|
23643
|
+
latest = Math.max(latest, latestMtime(join53(path, entry.name)));
|
|
23495
23644
|
}
|
|
23496
23645
|
return latest;
|
|
23497
23646
|
}
|
|
@@ -23503,7 +23652,7 @@ function makeStaleChecker(paths, opts = {}) {
|
|
|
23503
23652
|
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
|
|
23504
23653
|
}
|
|
23505
23654
|
function reloadSentinelFor(stateDir) {
|
|
23506
|
-
return
|
|
23655
|
+
return join53(stateDir, "reload-requested");
|
|
23507
23656
|
}
|
|
23508
23657
|
function readReloadRequestedAt(stateDir) {
|
|
23509
23658
|
try {
|
|
@@ -23513,7 +23662,7 @@ function readReloadRequestedAt(stateDir) {
|
|
|
23513
23662
|
}
|
|
23514
23663
|
}
|
|
23515
23664
|
function daemonStampFor(stateDir) {
|
|
23516
|
-
return
|
|
23665
|
+
return join53(stateDir, "daemon.started");
|
|
23517
23666
|
}
|
|
23518
23667
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
23519
23668
|
mkdirSync36(stateDir, { recursive: true });
|
|
@@ -24556,11 +24705,11 @@ function startLaunchdDaemon(o) {
|
|
|
24556
24705
|
|
|
24557
24706
|
// src/daemon-start-failure.ts
|
|
24558
24707
|
import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
|
|
24559
|
-
import { dirname as
|
|
24708
|
+
import { dirname as dirname30, join as join54 } from "path";
|
|
24560
24709
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
24561
24710
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
24562
24711
|
var BACKOFF_AFTER_FAILURES = 2;
|
|
24563
|
-
var fileFor4 = (stateDir) =>
|
|
24712
|
+
var fileFor4 = (stateDir) => join54(stateDir, ".daemon-start-failure.json");
|
|
24564
24713
|
function readStartFailure(stateDir) {
|
|
24565
24714
|
try {
|
|
24566
24715
|
const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
|
|
@@ -24621,7 +24770,7 @@ async function reportStartFailure(o) {
|
|
|
24621
24770
|
return delay;
|
|
24622
24771
|
}
|
|
24623
24772
|
function fallbackStateDir(configFile) {
|
|
24624
|
-
return
|
|
24773
|
+
return join54(dirname30(configFile), "state");
|
|
24625
24774
|
}
|
|
24626
24775
|
|
|
24627
24776
|
// src/projects-cmd.ts
|
|
@@ -24662,6 +24811,85 @@ function formatProjectsReport(report) {
|
|
|
24662
24811
|
return `${lines2.join("\n")}
|
|
24663
24812
|
`;
|
|
24664
24813
|
}
|
|
24814
|
+
var ProjectsError = class extends Error {
|
|
24815
|
+
code;
|
|
24816
|
+
constructor(message, code = "invalid") {
|
|
24817
|
+
super(message);
|
|
24818
|
+
this.code = code;
|
|
24819
|
+
}
|
|
24820
|
+
};
|
|
24821
|
+
var WORK_MODES = ["automatic", "hybrid", "manual"];
|
|
24822
|
+
var PROJECT_FORBIDDEN_MESSAGE = "this route's key is not allowed to create a Projects row \u2014 a workspace admin has to add the project (the Projects table, or `crew projects add` with an admin's key)";
|
|
24823
|
+
function validateProjectInput(i) {
|
|
24824
|
+
const name = (i.name ?? "").trim();
|
|
24825
|
+
if (!name) throw new ProjectsError("a project needs a name: crew projects add [route] NAME --prefix PREFIX");
|
|
24826
|
+
const prefix = (i.prefix ?? "").trim();
|
|
24827
|
+
if (!prefix) throw new ProjectsError("a project needs an issue prefix: pass --prefix PREFIX (letters and digits, e.g. CREW)");
|
|
24828
|
+
if (!/^[A-Za-z0-9]+$/.test(prefix)) {
|
|
24829
|
+
throw new ProjectsError(`the issue prefix "${prefix}" may only contain letters and digits`);
|
|
24830
|
+
}
|
|
24831
|
+
const mode = i.workMode?.trim().toLowerCase();
|
|
24832
|
+
if (mode !== void 0 && !WORK_MODES.includes(mode)) {
|
|
24833
|
+
throw new ProjectsError(`unknown work mode "${i.workMode}" (use ${WORK_MODES.join(", ")})`);
|
|
24834
|
+
}
|
|
24835
|
+
return { name, prefix: prefix.toUpperCase(), workMode: mode ?? "automatic", explicitMode: mode !== void 0 };
|
|
24836
|
+
}
|
|
24837
|
+
function planProjectAdd(i, ctx) {
|
|
24838
|
+
const v = validateProjectInput(i);
|
|
24839
|
+
for (const row of ctx.existing) {
|
|
24840
|
+
if (row.name?.toLowerCase() === v.name.toLowerCase()) {
|
|
24841
|
+
throw new ProjectsError(`a project named "${row.name}" already exists (${row.id}); nothing was created`, "duplicate");
|
|
24842
|
+
}
|
|
24843
|
+
if (row.issue_prefix && row.issue_prefix.toLowerCase() === v.prefix.toLowerCase()) {
|
|
24844
|
+
throw new ProjectsError(`the prefix ${row.issue_prefix} is already used by project "${row.name ?? row.id}" (${row.id}); nothing was created`, "duplicate");
|
|
24845
|
+
}
|
|
24846
|
+
}
|
|
24847
|
+
const fields = { name: v.name, issue_prefix: v.prefix };
|
|
24848
|
+
if (ctx.hasWorkModeColumn) {
|
|
24849
|
+
fields[ctx.workModeColumn] = v.workMode === "manual" ? ctx.manualWorkMode : v.workMode === "hybrid" ? ctx.hybridWorkMode : "automatic";
|
|
24850
|
+
} else if (v.explicitMode) {
|
|
24851
|
+
throw new ProjectsError(`this workspace's Projects table has no ${ctx.workModeColumn} column, so --work-mode cannot be set; omit it to create the project without one`, "no_work_mode_column");
|
|
24852
|
+
}
|
|
24853
|
+
return { fields, name: v.name, prefix: v.prefix, workMode: ctx.hasWorkModeColumn ? v.workMode : "automatic" };
|
|
24854
|
+
}
|
|
24855
|
+
function isForbidden2(e) {
|
|
24856
|
+
const status2 = e?.status;
|
|
24857
|
+
return status2 === 403 || /\b403\b/.test(e instanceof Error ? e.message : String(e));
|
|
24858
|
+
}
|
|
24859
|
+
async function createProject(tracker, input, opts = {}) {
|
|
24860
|
+
validateProjectInput(input);
|
|
24861
|
+
let plan;
|
|
24862
|
+
try {
|
|
24863
|
+
plan = planProjectAdd(input, {
|
|
24864
|
+
workModeColumn: tracker.contract.columns.workMode,
|
|
24865
|
+
manualWorkMode: tracker.contract.manualWorkMode,
|
|
24866
|
+
hybridWorkMode: tracker.contract.hybridWorkMode,
|
|
24867
|
+
existing: await tracker.projectRows(),
|
|
24868
|
+
hasWorkModeColumn: await tracker.projectHasWorkMode()
|
|
24869
|
+
});
|
|
24870
|
+
} catch (e) {
|
|
24871
|
+
if (e instanceof ProjectsError) throw e;
|
|
24872
|
+
throw new ProjectsError(isForbidden2(e) ? PROJECT_FORBIDDEN_MESSAGE : `could not read the Projects table: ${firstLine2(e)}`, isForbidden2(e) ? "forbidden" : "tracker");
|
|
24873
|
+
}
|
|
24874
|
+
const entry = (id) => ({ id, name: plan.name, issuePrefix: plan.prefix, workMode: plan.workMode, current: false });
|
|
24875
|
+
if (opts.dryRun) return { entry: entry(""), created: false };
|
|
24876
|
+
try {
|
|
24877
|
+
const row = await tracker.createProjectRow(plan.fields);
|
|
24878
|
+
return { entry: entry(row.id), created: true };
|
|
24879
|
+
} catch (e) {
|
|
24880
|
+
throw new ProjectsError(isForbidden2(e) ? PROJECT_FORBIDDEN_MESSAGE : `could not create the project: ${firstLine2(e)}`, isForbidden2(e) ? "forbidden" : "tracker");
|
|
24881
|
+
}
|
|
24882
|
+
}
|
|
24883
|
+
function firstLine2(e) {
|
|
24884
|
+
return (e instanceof Error ? e.message : String(e)).split("\n")[0].slice(0, 200);
|
|
24885
|
+
}
|
|
24886
|
+
async function offerFirstProject(prompter, create2) {
|
|
24887
|
+
prompter.say("The tracker has no Projects row, and the new Repos row has to belong to one.");
|
|
24888
|
+
if (!await prompter.confirm("Create a project now?", true)) return null;
|
|
24889
|
+
const name = await prompter.ask("Project name");
|
|
24890
|
+
const prefix = await prompter.ask("Issue prefix (letters and digits, e.g. CREW)");
|
|
24891
|
+
return (await create2({ name, prefix })).entry;
|
|
24892
|
+
}
|
|
24665
24893
|
|
|
24666
24894
|
// src/forge-cmd.ts
|
|
24667
24895
|
import { parseDocument as parseDocument5 } from "yaml";
|
|
@@ -24736,7 +24964,7 @@ function runForge(a, io) {
|
|
|
24736
24964
|
// src/release-sandbox.ts
|
|
24737
24965
|
import { execFile as execFile5 } from "child_process";
|
|
24738
24966
|
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
|
|
24739
|
-
import { dirname as
|
|
24967
|
+
import { dirname as dirname31 } from "path";
|
|
24740
24968
|
import { promisify as promisify4 } from "util";
|
|
24741
24969
|
var execFileP4 = promisify4(execFile5);
|
|
24742
24970
|
var RELEASE_CLONE_DEPTH = 50;
|
|
@@ -24782,7 +25010,7 @@ async function openReleaseSandbox(o) {
|
|
|
24782
25010
|
if (!policyFile) {
|
|
24783
25011
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
24784
25012
|
policyFile = o.policyFile;
|
|
24785
|
-
mkdirSync38(
|
|
25013
|
+
mkdirSync38(dirname31(policyFile), { recursive: true });
|
|
24786
25014
|
writeFileSync40(policyFile, generated.yaml, { mode: 384 });
|
|
24787
25015
|
}
|
|
24788
25016
|
const secrets = { ...process.env };
|
|
@@ -25955,12 +26183,12 @@ function describeCapability(i) {
|
|
|
25955
26183
|
|
|
25956
26184
|
// src/persona-avatars.ts
|
|
25957
26185
|
import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
|
|
25958
|
-
import { join as
|
|
26186
|
+
import { join as join55 } from "path";
|
|
25959
26187
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
25960
26188
|
function personaAvatarFile(promptsDir, role) {
|
|
25961
26189
|
for (const ext of ["png", "svg"]) {
|
|
25962
26190
|
const name = `lane-${role}.${ext}`;
|
|
25963
|
-
const path =
|
|
26191
|
+
const path = join55(promptsDir, "personas", name);
|
|
25964
26192
|
if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
25965
26193
|
}
|
|
25966
26194
|
return void 0;
|
|
@@ -26024,7 +26252,7 @@ function routeAvatarFailures(stateDir, route2) {
|
|
|
26024
26252
|
|
|
26025
26253
|
// src/agents-sync-run.ts
|
|
26026
26254
|
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
26027
|
-
import { dirname as
|
|
26255
|
+
import { dirname as dirname32 } from "path";
|
|
26028
26256
|
async function runAgentsSync(target, o) {
|
|
26029
26257
|
const dryRun = o.dryRun ?? false;
|
|
26030
26258
|
const force = o.force ?? false;
|
|
@@ -26074,7 +26302,7 @@ async function runAgentsSync(target, o) {
|
|
|
26074
26302
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
26075
26303
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
26076
26304
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
26077
|
-
mkdirSync39(
|
|
26305
|
+
mkdirSync39(dirname32(resolvedPath), { recursive: true });
|
|
26078
26306
|
writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
26079
26307
|
`);
|
|
26080
26308
|
if (target.resolved) {
|
|
@@ -26212,10 +26440,10 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
26212
26440
|
|
|
26213
26441
|
// src/repo-setup-prompt.ts
|
|
26214
26442
|
import { readFileSync as readFileSync52 } from "fs";
|
|
26215
|
-
import { join as
|
|
26216
|
-
var REPO_SETUP_PROMPT_PATH =
|
|
26443
|
+
import { join as join56 } from "path";
|
|
26444
|
+
var REPO_SETUP_PROMPT_PATH = join56("docs", "repo-setup-prompt.md");
|
|
26217
26445
|
function readRepoSetupPrompt(crewHome) {
|
|
26218
|
-
return readFileSync52(
|
|
26446
|
+
return readFileSync52(join56(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
|
|
26219
26447
|
}
|
|
26220
26448
|
|
|
26221
26449
|
// src/repos-check.ts
|
|
@@ -26554,7 +26782,7 @@ function existingRepoConfig(f) {
|
|
|
26554
26782
|
|
|
26555
26783
|
// src/repos-hooks-agent.ts
|
|
26556
26784
|
import { spawn as spawn9, execFileSync as execFileSync15 } from "child_process";
|
|
26557
|
-
import { realpathSync as
|
|
26785
|
+
import { realpathSync as realpathSync3 } from "fs";
|
|
26558
26786
|
import { isAbsolute as isAbsolute3, relative } from "path";
|
|
26559
26787
|
var AgentSuggestError = class extends Error {
|
|
26560
26788
|
reason;
|
|
@@ -26610,7 +26838,7 @@ function parseAgentStream(out, dir) {
|
|
|
26610
26838
|
const files = /* @__PURE__ */ new Set();
|
|
26611
26839
|
let base = dir;
|
|
26612
26840
|
try {
|
|
26613
|
-
base =
|
|
26841
|
+
base = realpathSync3(dir);
|
|
26614
26842
|
} catch {
|
|
26615
26843
|
}
|
|
26616
26844
|
for (const line of out.split("\n")) {
|
|
@@ -26725,7 +26953,7 @@ ${run4.err}` });
|
|
|
26725
26953
|
}
|
|
26726
26954
|
|
|
26727
26955
|
// src/sample-ticket.ts
|
|
26728
|
-
import { basename as basename13, dirname as
|
|
26956
|
+
import { basename as basename13, dirname as dirname33, join as join57 } from "path";
|
|
26729
26957
|
var SAMPLE_REPO = "crew-sample";
|
|
26730
26958
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
26731
26959
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -26748,8 +26976,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
26748
26976
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
26749
26977
|
`;
|
|
26750
26978
|
function sampleDir(existing, reposBase, workspace) {
|
|
26751
|
-
if (existing.length > 0) return
|
|
26752
|
-
return
|
|
26979
|
+
if (existing.length > 0) return join57(dirname33(existing[0]), SAMPLE_REPO);
|
|
26980
|
+
return join57(reposBase, workspace, SAMPLE_REPO);
|
|
26753
26981
|
}
|
|
26754
26982
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
26755
26983
|
function sampleDescription() {
|
|
@@ -27017,7 +27245,7 @@ function fixPhaseNothingToOffer(o) {
|
|
|
27017
27245
|
|
|
27018
27246
|
// src/worktree-sweep.ts
|
|
27019
27247
|
import { existsSync as existsSync54, readFileSync as readFileSync54, readdirSync as readdirSync16 } from "fs";
|
|
27020
|
-
import { basename as basename14, dirname as
|
|
27248
|
+
import { basename as basename14, dirname as dirname34, join as join58, resolve as resolve5 } from "path";
|
|
27021
27249
|
function planWorktreeSweep(target, tickets, contract) {
|
|
27022
27250
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
27023
27251
|
const verified = contract.statuses.verified;
|
|
@@ -27081,7 +27309,7 @@ function worktreeTicketNumbers(target) {
|
|
|
27081
27309
|
return [...nums];
|
|
27082
27310
|
}
|
|
27083
27311
|
function siblingWorktreeDirs(target) {
|
|
27084
|
-
const parent =
|
|
27312
|
+
const parent = dirname34(target.dir.replace(/[/\\]+$/, ""));
|
|
27085
27313
|
const stem = `${basename14(target.dir.replace(/[/\\]+$/, ""))}-`;
|
|
27086
27314
|
const registered = new Set(worktrees(target.dir).map((w) => resolve5(w.path)));
|
|
27087
27315
|
let names;
|
|
@@ -27094,7 +27322,7 @@ function siblingWorktreeDirs(target) {
|
|
|
27094
27322
|
for (const name of names) {
|
|
27095
27323
|
if (!name.startsWith(stem)) continue;
|
|
27096
27324
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
27097
|
-
const path =
|
|
27325
|
+
const path = join58(parent, name);
|
|
27098
27326
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
27099
27327
|
}
|
|
27100
27328
|
return out;
|
|
@@ -27327,13 +27555,13 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
27327
27555
|
|
|
27328
27556
|
// src/stream-sweep.ts
|
|
27329
27557
|
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
|
|
27330
|
-
import { join as
|
|
27558
|
+
import { join as join59 } from "path";
|
|
27331
27559
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
27332
27560
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
27333
|
-
const dir =
|
|
27561
|
+
const dir = join59(stateDir, "streams");
|
|
27334
27562
|
if (!existsSync55(dir)) return [];
|
|
27335
27563
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
27336
|
-
return readdirSync17(dir).map((name) =>
|
|
27564
|
+
return readdirSync17(dir).map((name) => join59(dir, name)).filter((path) => {
|
|
27337
27565
|
try {
|
|
27338
27566
|
return statSync16(path).mtimeMs < cutoff;
|
|
27339
27567
|
} catch {
|
|
@@ -27361,7 +27589,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
27361
27589
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
27362
27590
|
if (!existsSync55(stateDir)) return [];
|
|
27363
27591
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
27364
|
-
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
27592
|
+
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join59(stateDir, name)).filter((path) => {
|
|
27365
27593
|
try {
|
|
27366
27594
|
return statSync16(path).mtimeMs < cutoff;
|
|
27367
27595
|
} catch {
|
|
@@ -27375,7 +27603,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
|
27375
27603
|
if (!existsSync55(dir)) return;
|
|
27376
27604
|
for (const name of readdirSync17(dir)) {
|
|
27377
27605
|
if (!keep(name)) continue;
|
|
27378
|
-
const path =
|
|
27606
|
+
const path = join59(dir, name);
|
|
27379
27607
|
try {
|
|
27380
27608
|
const st = statSync16(path);
|
|
27381
27609
|
if (st.isFile()) files.push({ path, mtime: st.mtimeMs, size: st.size });
|
|
@@ -27383,7 +27611,7 @@ function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
|
27383
27611
|
}
|
|
27384
27612
|
}
|
|
27385
27613
|
};
|
|
27386
|
-
add(
|
|
27614
|
+
add(join59(stateDir, "streams"), () => true);
|
|
27387
27615
|
add(stateDir, (name) => ROTATED_EVENTS_RE.test(name));
|
|
27388
27616
|
let total = files.reduce((n, f) => n + f.size, 0);
|
|
27389
27617
|
const out = [];
|
|
@@ -27403,7 +27631,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
|
|
|
27403
27631
|
}
|
|
27404
27632
|
|
|
27405
27633
|
// src/cli.ts
|
|
27406
|
-
import { realpathSync as
|
|
27634
|
+
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";
|
|
27407
27635
|
import { createInterface } from "readline/promises";
|
|
27408
27636
|
|
|
27409
27637
|
// src/periscope-resume.ts
|
|
@@ -27480,9 +27708,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
27480
27708
|
|
|
27481
27709
|
// src/bundle-staleness.ts
|
|
27482
27710
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
27483
|
-
import { join as
|
|
27711
|
+
import { join as join60 } from "path";
|
|
27484
27712
|
function builtVersion() {
|
|
27485
|
-
return true ? "0.
|
|
27713
|
+
return true ? "0.154.1" : null;
|
|
27486
27714
|
}
|
|
27487
27715
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
27488
27716
|
function newestMtime(path) {
|
|
@@ -27495,17 +27723,17 @@ function newestMtime(path) {
|
|
|
27495
27723
|
if (stat2.isFile()) return stat2.mtimeMs;
|
|
27496
27724
|
if (!stat2.isDirectory()) return 0;
|
|
27497
27725
|
let latest = stat2.mtimeMs;
|
|
27498
|
-
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(
|
|
27726
|
+
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join60(path, e.name)));
|
|
27499
27727
|
return latest;
|
|
27500
27728
|
}
|
|
27501
27729
|
function bundleStaleness(i) {
|
|
27502
27730
|
if (i.built === null || i.compiled) return null;
|
|
27503
|
-
const src =
|
|
27731
|
+
const src = join60(i.home, "src");
|
|
27504
27732
|
if (!existsSync56(src)) return null;
|
|
27505
27733
|
if (i.built !== i.current) {
|
|
27506
27734
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
27507
27735
|
}
|
|
27508
|
-
const bundle = statSafe(
|
|
27736
|
+
const bundle = statSafe(join60(i.home, "dist", "cli.js"));
|
|
27509
27737
|
if (bundle === null) return null;
|
|
27510
27738
|
if (newestMtime(src) > bundle) {
|
|
27511
27739
|
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
@@ -27724,7 +27952,7 @@ import { createServer as createHttpServer } from "http";
|
|
|
27724
27952
|
import { spawn as spawn10 } from "child_process";
|
|
27725
27953
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
27726
27954
|
import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync55, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
|
|
27727
|
-
import { join as
|
|
27955
|
+
import { join as join61 } from "path";
|
|
27728
27956
|
|
|
27729
27957
|
// src/secret-compare.ts
|
|
27730
27958
|
import { timingSafeEqual } from "crypto";
|
|
@@ -27817,7 +28045,7 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
27817
28045
|
return child;
|
|
27818
28046
|
};
|
|
27819
28047
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
27820
|
-
return
|
|
28048
|
+
return join61(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
27821
28049
|
}
|
|
27822
28050
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
27823
28051
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
@@ -27830,7 +28058,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
|
27830
28058
|
}
|
|
27831
28059
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
27832
28060
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
27833
|
-
mkdirSync40(
|
|
28061
|
+
mkdirSync40(join61(stateDir, "passengers"), { recursive: true });
|
|
27834
28062
|
writeFileSync42(path, `${JSON.stringify(state, null, 2)}
|
|
27835
28063
|
`);
|
|
27836
28064
|
}
|
|
@@ -27851,7 +28079,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
27851
28079
|
}
|
|
27852
28080
|
}
|
|
27853
28081
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
27854
|
-
const dir =
|
|
28082
|
+
const dir = join61(stateDir, "passengers");
|
|
27855
28083
|
if (!existsSync57(dir)) return [];
|
|
27856
28084
|
const suffix = "-sync.json";
|
|
27857
28085
|
return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
@@ -27916,7 +28144,7 @@ import { createServer, request as httpRequest } from "http";
|
|
|
27916
28144
|
import { request as httpsRequest } from "https";
|
|
27917
28145
|
import { connect as netConnect } from "net";
|
|
27918
28146
|
import { connect as tlsConnect } from "tls";
|
|
27919
|
-
import { dirname as
|
|
28147
|
+
import { dirname as dirname35, isAbsolute as isAbsolute4 } from "path";
|
|
27920
28148
|
import { brotliDecompressSync, gunzipSync, inflateSync } from "zlib";
|
|
27921
28149
|
|
|
27922
28150
|
// src/periscope-inspector.ts
|
|
@@ -28030,7 +28258,7 @@ function parsePointedBody(raw) {
|
|
|
28030
28258
|
return entry;
|
|
28031
28259
|
}
|
|
28032
28260
|
function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
|
|
28033
|
-
mkdirSync41(
|
|
28261
|
+
mkdirSync41(dirname35(file), { recursive: true });
|
|
28034
28262
|
appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
|
|
28035
28263
|
`);
|
|
28036
28264
|
}
|
|
@@ -28319,7 +28547,7 @@ async function startWorktreeIntel(d) {
|
|
|
28319
28547
|
}
|
|
28320
28548
|
|
|
28321
28549
|
// src/contract-refusal.ts
|
|
28322
|
-
import { join as
|
|
28550
|
+
import { join as join62 } from "path";
|
|
28323
28551
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
28324
28552
|
const out = [];
|
|
28325
28553
|
for (const t of tickets) {
|
|
@@ -28331,7 +28559,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
28331
28559
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
28332
28560
|
if (text2 === null) continue;
|
|
28333
28561
|
try {
|
|
28334
|
-
parseRepoConfig(text2,
|
|
28562
|
+
parseRepoConfig(text2, join62(dir, file));
|
|
28335
28563
|
} catch (e) {
|
|
28336
28564
|
if (e instanceof RepoConfigError) continue;
|
|
28337
28565
|
throw e;
|
|
@@ -28357,7 +28585,7 @@ import {
|
|
|
28357
28585
|
} from "fs";
|
|
28358
28586
|
import { createConnection } from "net";
|
|
28359
28587
|
import { createServer as createServer2 } from "http";
|
|
28360
|
-
import { basename as basename15, dirname as
|
|
28588
|
+
import { basename as basename15, dirname as dirname36, join as join63 } from "path";
|
|
28361
28589
|
import { execFile as execFile6, spawn as spawn13 } from "child_process";
|
|
28362
28590
|
|
|
28363
28591
|
// src/periscope-control.ts
|
|
@@ -28595,7 +28823,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
28595
28823
|
// src/control-api.ts
|
|
28596
28824
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
28597
28825
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
28598
|
-
var controlSocketFor = (stateDir) =>
|
|
28826
|
+
var controlSocketFor = (stateDir) => join63(stateDir, CONTROL_SOCKET_NAME);
|
|
28599
28827
|
var MAX_SOCKET_PATH = 100;
|
|
28600
28828
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
28601
28829
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -28682,7 +28910,7 @@ function candidates(live2, rotated) {
|
|
|
28682
28910
|
const out = [live2];
|
|
28683
28911
|
if (!rotated) return out;
|
|
28684
28912
|
try {
|
|
28685
|
-
for (const n of readdirSync20(
|
|
28913
|
+
for (const n of readdirSync20(dirname36(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join63(dirname36(live2), n));
|
|
28686
28914
|
} catch {
|
|
28687
28915
|
}
|
|
28688
28916
|
return out;
|
|
@@ -28850,7 +29078,7 @@ async function tailReply(path, q2, rotated, abort) {
|
|
|
28850
29078
|
const deadline = Date.now() + Math.min(wait, MAX_WAIT_SECONDS) * 1e3;
|
|
28851
29079
|
let r = readTail(path, { after, tail: tail3, rotated });
|
|
28852
29080
|
while (after && !r.lines.length && !r.reset && Date.now() < deadline && !abort.aborted) {
|
|
28853
|
-
await waitForChange(
|
|
29081
|
+
await waitForChange(dirname36(path), deadline - Date.now(), abort);
|
|
28854
29082
|
r = readTail(path, { after: r.cursor, rotated });
|
|
28855
29083
|
}
|
|
28856
29084
|
return reply2(200, r);
|
|
@@ -28941,7 +29169,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
28941
29169
|
if (p.startsWith("/streams/") && get2) {
|
|
28942
29170
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
28943
29171
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
28944
|
-
const file =
|
|
29172
|
+
const file = join63(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
28945
29173
|
if (!existsSync58(file)) return err2(404, "no such run");
|
|
28946
29174
|
return tailReply(file, url.searchParams, false, abort);
|
|
28947
29175
|
}
|
|
@@ -29109,7 +29337,7 @@ function crewJson(args, timeoutMs = CREW_JSON_TIMEOUT_MS) {
|
|
|
29109
29337
|
|
|
29110
29338
|
// src/periscope-mcp.ts
|
|
29111
29339
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
29112
|
-
import { basename as basename16, dirname as
|
|
29340
|
+
import { basename as basename16, dirname as dirname37, isAbsolute as isAbsolute5, join as join65, relative as relative2, resolve as resolve6, sep } from "path";
|
|
29113
29341
|
import { z } from "zod";
|
|
29114
29342
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
29115
29343
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
@@ -29117,11 +29345,11 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
29117
29345
|
// src/periscope-endpoints.ts
|
|
29118
29346
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
29119
29347
|
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync56, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
29120
|
-
import { join as
|
|
29121
|
-
var secretDir = (stateDir) =>
|
|
29122
|
-
var secretFile = (stateDir, id) =>
|
|
29123
|
-
var endpointDir = (stateDir) =>
|
|
29124
|
-
var endpointFile = (stateDir, id) =>
|
|
29348
|
+
import { join as join64 } from "path";
|
|
29349
|
+
var secretDir = (stateDir) => join64(stateDir, "periscope-mcp");
|
|
29350
|
+
var secretFile = (stateDir, id) => join64(secretDir(stateDir), `${id}.json`);
|
|
29351
|
+
var endpointDir = (stateDir) => join64(stateDir, "periscope-endpoints");
|
|
29352
|
+
var endpointFile = (stateDir, id) => join64(endpointDir(stateDir), `${id}.json`);
|
|
29125
29353
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
29126
29354
|
mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
29127
29355
|
const secret = randomBytes3(32).toString("base64url");
|
|
@@ -29247,10 +29475,10 @@ async function realAncestor(p) {
|
|
|
29247
29475
|
}
|
|
29248
29476
|
if (isLink) {
|
|
29249
29477
|
if (++hops > 40) throw new PathRefusal(`too many symbolic links resolving ${p}`);
|
|
29250
|
-
cur = resolve6(
|
|
29478
|
+
cur = resolve6(dirname37(cur), await readlink(cur));
|
|
29251
29479
|
continue;
|
|
29252
29480
|
}
|
|
29253
|
-
const parent =
|
|
29481
|
+
const parent = dirname37(cur);
|
|
29254
29482
|
if (parent === cur) throw new PathRefusal(`cannot resolve ${p}`);
|
|
29255
29483
|
tail3.push(basename16(cur));
|
|
29256
29484
|
cur = parent;
|
|
@@ -29262,13 +29490,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
29262
29490
|
let abs;
|
|
29263
29491
|
if (isAbsolute5(requested)) {
|
|
29264
29492
|
abs = resolve6(requested);
|
|
29265
|
-
if (isInside(root, abs)) abs =
|
|
29493
|
+
if (isInside(root, abs)) abs = join65(realRoot, relative2(root, abs));
|
|
29266
29494
|
} else {
|
|
29267
29495
|
abs = resolve6(realRoot, requested);
|
|
29268
29496
|
}
|
|
29269
29497
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
29270
29498
|
const { real, rest } = await realAncestor(abs);
|
|
29271
|
-
const final = rest ?
|
|
29499
|
+
const final = rest ? join65(real, rest) : real;
|
|
29272
29500
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
29273
29501
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
29274
29502
|
return final;
|
|
@@ -29336,7 +29564,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29336
29564
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
29337
29565
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
29338
29566
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
29339
|
-
const size = (await lstat(
|
|
29567
|
+
const size = (await lstat(join65(abs, e.name))).size;
|
|
29340
29568
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
29341
29569
|
}));
|
|
29342
29570
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -29361,7 +29589,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29361
29589
|
if (Buffer.byteLength(content) > MAX_WRITE_BYTES) return text(`content exceeds ${MAX_WRITE_BYTES} bytes`, true);
|
|
29362
29590
|
const abs = await inTree(path);
|
|
29363
29591
|
if (abs === await realpath(root)) return text("path must name a file", true);
|
|
29364
|
-
await mkdir(
|
|
29592
|
+
await mkdir(dirname37(abs), { recursive: true });
|
|
29365
29593
|
await inTree(path);
|
|
29366
29594
|
await writeFile(abs, content);
|
|
29367
29595
|
return text(`Wrote ${Buffer.byteLength(content)} bytes to ${await rel(abs)}`);
|
|
@@ -29401,8 +29629,8 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
29401
29629
|
inputSchema: { path: z.string() },
|
|
29402
29630
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
29403
29631
|
}, async ({ path }) => {
|
|
29404
|
-
const parent = await inTree(
|
|
29405
|
-
const abs =
|
|
29632
|
+
const parent = await inTree(dirname37(path) === "" ? "." : dirname37(path));
|
|
29633
|
+
const abs = join65(parent, basename16(path));
|
|
29406
29634
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
29407
29635
|
const st = await lstat(abs).catch(() => void 0);
|
|
29408
29636
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -29523,7 +29751,7 @@ function findPeriscope(sidecars, segment) {
|
|
|
29523
29751
|
}
|
|
29524
29752
|
|
|
29525
29753
|
// src/cli.ts
|
|
29526
|
-
var CREW_HOME = isCompiledBinary(import.meta.url) ?
|
|
29754
|
+
var CREW_HOME = isCompiledBinary(import.meta.url) ? dirname38(process.execPath) : resolve7(dirname38(fileURLToPath2(import.meta.url)), "..");
|
|
29527
29755
|
var RELEASE_LOCK_TTL_MS = 20 * 60 * 1e3;
|
|
29528
29756
|
var CYCLE_SECONDS2 = 120;
|
|
29529
29757
|
var STALE_CYCLES = 3;
|
|
@@ -29682,6 +29910,7 @@ function usage(problem, requested = false) {
|
|
|
29682
29910
|
crew --version [--json] print the crew version on one line (also: crew version); --json adds home and compiled
|
|
29683
29911
|
crew status [route] [--json] [--verbose] what is running and what needs a person; --verbose adds configuration and full lists; --json for a machine reader
|
|
29684
29912
|
crew projects [--route R] [--json] the Projects rows each route can read (id, name, prefix, work mode)
|
|
29913
|
+
crew projects add [route] NAME --prefix P [--work-mode automatic|hybrid|manual] [--json] [--dry-run] create a Projects row
|
|
29685
29914
|
crew provision --key K --route WS[/PROJECT] [--forge-host H] [--ship-name N] [--json] one non-interactive run: connect, forge tokens,
|
|
29686
29915
|
enable routes, install units with lingering, start the daemon; safe to re-run (CREW_CONNECT_KEY,
|
|
29687
29916
|
CREW_PROVISION_ROUTES, CREW_SHIP_NAME, CREW_FORGE_TOKEN[_<HOST>] also read)
|
|
@@ -30629,7 +30858,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
30629
30858
|
for (const l of summarizeJobs(results, { dryRun, verbose: flag("verbose"), host })) emit.emit(l);
|
|
30630
30859
|
if (host === "linux" && hasSystemd) {
|
|
30631
30860
|
const label = labelFor(CREW_HOME, "run");
|
|
30632
|
-
const staleTimer =
|
|
30861
|
+
const staleTimer = join66(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
30633
30862
|
if (existsSync60(staleTimer)) {
|
|
30634
30863
|
emit.emit(
|
|
30635
30864
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
|
|
@@ -30991,7 +31220,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
30991
31220
|
harnessBin: "claude",
|
|
30992
31221
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
30993
31222
|
},
|
|
30994
|
-
policyFile:
|
|
31223
|
+
policyFile: join66(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
30995
31224
|
repo: mirror,
|
|
30996
31225
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
30997
31226
|
base: effective.branch.base,
|
|
@@ -31517,7 +31746,7 @@ ${f.tail.trimEnd()}
|
|
|
31517
31746
|
}
|
|
31518
31747
|
for (const cand of outcome.unbuildable ?? []) {
|
|
31519
31748
|
try {
|
|
31520
|
-
const stranded = planStrandedVerified(cand, repo.branch.base, repo.branch.remote, flagged);
|
|
31749
|
+
const stranded = planStrandedVerified(cand, repo.branch.base, repo.branch.remote, flagged, { dir: target.dir, cfg: repo });
|
|
31521
31750
|
const r = await applyStrandedVerified(
|
|
31522
31751
|
tracker,
|
|
31523
31752
|
stranded,
|
|
@@ -32260,7 +32489,7 @@ ${f.tail.trimEnd()}
|
|
|
32260
32489
|
logFile: cfg.ship.logFile
|
|
32261
32490
|
});
|
|
32262
32491
|
}
|
|
32263
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
32492
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join66(CREW_HOME, "src"), join66(CREW_HOME, "dist"), join66(CREW_HOME, "bin")];
|
|
32264
32493
|
const configPaths = daemonConfigPaths(cfg);
|
|
32265
32494
|
watchPaths.push(...configPaths);
|
|
32266
32495
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -32636,7 +32865,7 @@ ${f.tail.trimEnd()}
|
|
|
32636
32865
|
case "repos": {
|
|
32637
32866
|
const sub = positional[1];
|
|
32638
32867
|
const usage2 = () => {
|
|
32639
|
-
process.stderr.write("crew repos add [workspace/project] [name] [path] [--name N] [--project P] [--dry-run] [--no-create]\ncrew repos clone [workspace/project] <name> [--dir PATH] [--dry-run] [--json]\ncrew repos list <workspace/project> [--json]\ncrew repos check [PATH | --route ROUTE [PATH] | ROUTE NAME] [--strict] [--json]\ncrew repos prompt [--json]\ncrew repos hooks [workspace/project] <name> [--suggest] [--agent] [--write route|repo [--replace]] [--clear route] [--recipes ID,ID] [--hook KEY=CMD ...] [--json]\n");
|
|
32868
|
+
process.stderr.write("crew repos add [workspace/project] [name] [path] [--name N] [--project P] [--dry-run] [--no-create] [--json]\ncrew repos clone [workspace/project] <name> [--dir PATH] [--dry-run] [--json]\ncrew repos list <workspace/project> [--json]\ncrew repos check [PATH | --route ROUTE [PATH] | ROUTE NAME] [--strict] [--json]\ncrew repos prompt [--json]\ncrew repos hooks [workspace/project] <name> [--suggest] [--agent] [--write route|repo [--replace]] [--clear route] [--recipes ID,ID] [--hook KEY=CMD ...] [--json]\n");
|
|
32640
32869
|
process.exit(2);
|
|
32641
32870
|
};
|
|
32642
32871
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
@@ -32647,7 +32876,7 @@ ${f.tail.trimEnd()}
|
|
|
32647
32876
|
const found = cfg.routes.find((r) => r.route === routeArg);
|
|
32648
32877
|
if (!found) throw new ReposError(`no route "${routeArg}" in the config (have: ${cfg.routes.map((r) => r.route).join(", ") || "none"})`);
|
|
32649
32878
|
const named2 = value("route") ? void 0 : positional[3];
|
|
32650
|
-
const dir = named2 ? repoDirOf(configText,
|
|
32879
|
+
const dir = named2 ? repoDirOf(configText, dirname38(cfg.configFile), found.route, named2) : resolvePath(positional[value("route") ? 2 : 3] ?? ".");
|
|
32651
32880
|
const target = reposOf(found).find((t) => resolvePath(t.dir) === dir || t.name === named2);
|
|
32652
32881
|
const o = target ? found.repoOverrides[target.name] : void 0;
|
|
32653
32882
|
runReposCheck(dir, {
|
|
@@ -32669,7 +32898,7 @@ ${f.tail.trimEnd()}
|
|
|
32669
32898
|
if (sub === "hooks") {
|
|
32670
32899
|
try {
|
|
32671
32900
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
32672
|
-
const dir = repoDirOf(configText,
|
|
32901
|
+
const dir = repoDirOf(configText, dirname38(cfg.configFile), a.route, a.name);
|
|
32673
32902
|
if (!existsSync60(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
32674
32903
|
const files = { exists: (r) => existsSync60(resolvePath(dir, r)), list: (r) => {
|
|
32675
32904
|
try {
|
|
@@ -32829,7 +33058,7 @@ ${f.tail.trimEnd()}
|
|
|
32829
33058
|
}
|
|
32830
33059
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
32831
33060
|
const text2 = configText;
|
|
32832
|
-
const base =
|
|
33061
|
+
const base = dirname38(cfg.configFile);
|
|
32833
33062
|
const isCheckout = (d) => existsSync60(`${d}/.git`);
|
|
32834
33063
|
try {
|
|
32835
33064
|
if (sub === "list") {
|
|
@@ -32937,7 +33166,32 @@ ${f.tail.trimEnd()}
|
|
|
32937
33166
|
if (e instanceof ConfigError) throw new ReposError(`${e.message}; or pass --no-create`);
|
|
32938
33167
|
throw e;
|
|
32939
33168
|
}
|
|
32940
|
-
const
|
|
33169
|
+
const knownProjects = await rowTracker.projectRows();
|
|
33170
|
+
let projectId;
|
|
33171
|
+
if (knownProjects.length === 0 && !value("project") && !planRoute.resolved?.areaId) {
|
|
33172
|
+
if (dryRun) {
|
|
33173
|
+
process.stdout.write(`${plan.block}
|
|
33174
|
+
would need a project first: the tracker has none (\`crew projects add NAME --prefix PREFIX\`)
|
|
33175
|
+
`);
|
|
33176
|
+
break;
|
|
33177
|
+
}
|
|
33178
|
+
if (flag("json") || !(process.stdin.isTTY && process.stdout.isTTY)) throw noProjectsError();
|
|
33179
|
+
const prompter = terminalPrompter();
|
|
33180
|
+
try {
|
|
33181
|
+
const made = await offerFirstProject(prompter, (input) => createProject(rowTracker, input));
|
|
33182
|
+
if (!made) throw noProjectsError();
|
|
33183
|
+
process.stdout.write(`created project ${made.name} (${made.issuePrefix}, ${made.workMode}) ${made.id}
|
|
33184
|
+
`);
|
|
33185
|
+
projectId = made.id;
|
|
33186
|
+
} catch (e) {
|
|
33187
|
+
if (e instanceof ProjectsError) throw new ReposError(e.message, e.code);
|
|
33188
|
+
throw e;
|
|
33189
|
+
} finally {
|
|
33190
|
+
prompter.close();
|
|
33191
|
+
}
|
|
33192
|
+
} else {
|
|
33193
|
+
projectId = resolveRepoProject(knownProjects, value("project"), planRoute.resolved?.areaId);
|
|
33194
|
+
}
|
|
32941
33195
|
let spec;
|
|
32942
33196
|
try {
|
|
32943
33197
|
const rc = loadRepoConfig(top);
|
|
@@ -32972,6 +33226,11 @@ ${f.tail.trimEnd()}
|
|
|
32972
33226
|
`);
|
|
32973
33227
|
} catch (e) {
|
|
32974
33228
|
if (e instanceof ReposError) {
|
|
33229
|
+
if (flag("json") && e.code) {
|
|
33230
|
+
process.stdout.write(`${JSON.stringify({ ok: false, reason: e.code, message: e.message })}
|
|
33231
|
+
`);
|
|
33232
|
+
process.exit(2);
|
|
33233
|
+
}
|
|
32975
33234
|
die("crew repos", e.message, "`crew doctor`", 2);
|
|
32976
33235
|
}
|
|
32977
33236
|
throw e;
|
|
@@ -33486,7 +33745,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
33486
33745
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
33487
33746
|
`);
|
|
33488
33747
|
} else {
|
|
33489
|
-
mkdirSync43(
|
|
33748
|
+
mkdirSync43(dirname38(resolvedPath), { recursive: true });
|
|
33490
33749
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
33491
33750
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
33492
33751
|
writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
@@ -33530,7 +33789,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
33530
33789
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
33531
33790
|
`);
|
|
33532
33791
|
} else {
|
|
33533
|
-
mkdirSync43(
|
|
33792
|
+
mkdirSync43(dirname38(apiKeyFile), { recursive: true });
|
|
33534
33793
|
writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
33535
33794
|
`, { mode: 384 });
|
|
33536
33795
|
routineLine(`API key written to ${apiKeyFile}`);
|
|
@@ -34168,10 +34427,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34168
34427
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
34169
34428
|
prepare: async (path) => {
|
|
34170
34429
|
for (const f of repoWt.config.worktrees.copy) {
|
|
34171
|
-
const src =
|
|
34172
|
-
if (!existsSync60(src) || existsSync60(
|
|
34173
|
-
mkdirSync43(dirOf2(
|
|
34174
|
-
copyFileSync2(src,
|
|
34430
|
+
const src = join66(repoWt.dir, f);
|
|
34431
|
+
if (!existsSync60(src) || existsSync60(join66(path, f))) continue;
|
|
34432
|
+
mkdirSync43(dirOf2(join66(path, f)), { recursive: true });
|
|
34433
|
+
copyFileSync2(src, join66(path, f));
|
|
34175
34434
|
}
|
|
34176
34435
|
const setup = repoWt.config.hooks.setup;
|
|
34177
34436
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -34250,7 +34509,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
34250
34509
|
}
|
|
34251
34510
|
const real = (p) => {
|
|
34252
34511
|
try {
|
|
34253
|
-
return
|
|
34512
|
+
return realpathSync4(p);
|
|
34254
34513
|
} catch {
|
|
34255
34514
|
return p;
|
|
34256
34515
|
}
|
|
@@ -34498,10 +34757,10 @@ ${where.join("\n")}`);
|
|
|
34498
34757
|
},
|
|
34499
34758
|
prepare: async (path) => {
|
|
34500
34759
|
for (const f of repoP.config.worktrees.copy) {
|
|
34501
|
-
const src =
|
|
34760
|
+
const src = join66(repoP.dir, f);
|
|
34502
34761
|
if (!existsSync60(src)) continue;
|
|
34503
|
-
mkdirSync43(dirOf2(
|
|
34504
|
-
copyFileSync2(src,
|
|
34762
|
+
mkdirSync43(dirOf2(join66(path, f)), { recursive: true });
|
|
34763
|
+
copyFileSync2(src, join66(path, f));
|
|
34505
34764
|
}
|
|
34506
34765
|
const setup = repoP.config.hooks.setup;
|
|
34507
34766
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -34810,7 +35069,7 @@ ${where.join("\n")}`);
|
|
|
34810
35069
|
},
|
|
34811
35070
|
inspectCheckout(dir) {
|
|
34812
35071
|
const dirty = status(dir).map((c) => c.path);
|
|
34813
|
-
const linkedWorktrees = worktrees(dir).map((w) => w.path).filter((p) =>
|
|
35072
|
+
const linkedWorktrees = worktrees(dir).map((w) => w.path).filter((p) => realpathSync4(p) !== realpathSync4(dir));
|
|
34814
35073
|
return { dirty, linkedWorktrees };
|
|
34815
35074
|
}
|
|
34816
35075
|
};
|
|
@@ -34967,7 +35226,7 @@ ${where.join("\n")}`);
|
|
|
34967
35226
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
34968
35227
|
const tracker = new Tracker(route2, cfg.ship);
|
|
34969
35228
|
const configText = readFileSync57(cfg.configFile, "utf8");
|
|
34970
|
-
const cfgBase =
|
|
35229
|
+
const cfgBase = dirname38(cfg.configFile);
|
|
34971
35230
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
34972
35231
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
34973
35232
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, route2.route);
|
|
@@ -35011,12 +35270,12 @@ ${where.join("\n")}`);
|
|
|
35011
35270
|
`);
|
|
35012
35271
|
}
|
|
35013
35272
|
}
|
|
35014
|
-
if (existsSync60(
|
|
35273
|
+
if (existsSync60(join66(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
35015
35274
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
35016
35275
|
break;
|
|
35017
35276
|
}
|
|
35018
35277
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
35019
|
-
const fresh = !existsSync60(
|
|
35278
|
+
const fresh = !existsSync60(join66(dir, ".git"));
|
|
35020
35279
|
if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
35021
35280
|
if (dryRun) {
|
|
35022
35281
|
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`);
|
|
@@ -35024,8 +35283,8 @@ ${where.join("\n")}`);
|
|
|
35024
35283
|
}
|
|
35025
35284
|
if (fresh) {
|
|
35026
35285
|
mkdirSync43(dir, { recursive: true });
|
|
35027
|
-
writeFileSync44(
|
|
35028
|
-
writeFileSync44(
|
|
35286
|
+
writeFileSync44(join66(dir, "README.md"), SAMPLE_README);
|
|
35287
|
+
writeFileSync44(join66(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
35029
35288
|
const g = (...a) => {
|
|
35030
35289
|
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
35031
35290
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -35141,6 +35400,42 @@ ${where.join("\n")}`);
|
|
|
35141
35400
|
break;
|
|
35142
35401
|
}
|
|
35143
35402
|
case "projects": {
|
|
35403
|
+
if (positional[1] === "add") {
|
|
35404
|
+
const rest = positional.slice(2);
|
|
35405
|
+
const names = cfg.routes.map((r) => r.route);
|
|
35406
|
+
let routeName = value("route");
|
|
35407
|
+
if (!routeName && rest.length > 1 && names.includes(rest[0])) routeName = rest.shift();
|
|
35408
|
+
if (!routeName && names.length === 1) routeName = names[0];
|
|
35409
|
+
const target = cfg.routes.find((r) => r.route === routeName);
|
|
35410
|
+
const failProject = (e) => {
|
|
35411
|
+
if (flag("json")) {
|
|
35412
|
+
process.stdout.write(`${JSON.stringify({ ok: false, reason: e.code, message: e.message })}
|
|
35413
|
+
`);
|
|
35414
|
+
return process.exit(2);
|
|
35415
|
+
}
|
|
35416
|
+
return die("crew projects add", e.message, "`crew projects`", 2);
|
|
35417
|
+
};
|
|
35418
|
+
if (!target) {
|
|
35419
|
+
die("crew projects add", routeName ? `no route "${routeName}" (have: ${names.join(", ")})` : `several routes are configured; name one: ${names.join(", ") || "none"}`, "`crew status`");
|
|
35420
|
+
}
|
|
35421
|
+
try {
|
|
35422
|
+
const { entry, created } = await createProject(
|
|
35423
|
+
new Tracker(target, cfg.ship),
|
|
35424
|
+
{ name: rest.join(" "), prefix: value("prefix"), workMode: value("work-mode") },
|
|
35425
|
+
{ dryRun }
|
|
35426
|
+
);
|
|
35427
|
+
if (flag("json")) process.stdout.write(`${JSON.stringify(created ? entry : { ...entry, id: null }, null, 2)}
|
|
35428
|
+
`);
|
|
35429
|
+
else if (!created) process.stdout.write(`would create project ${entry.name} (${entry.issuePrefix}, ${entry.workMode}) on route ${target.route}
|
|
35430
|
+
`);
|
|
35431
|
+
else process.stdout.write(`created project ${entry.name} (${entry.issuePrefix}, ${entry.workMode}) ${entry.id}
|
|
35432
|
+
`);
|
|
35433
|
+
} catch (e) {
|
|
35434
|
+
if (e instanceof ProjectsError) failProject(e);
|
|
35435
|
+
throw e;
|
|
35436
|
+
}
|
|
35437
|
+
break;
|
|
35438
|
+
}
|
|
35144
35439
|
const only = value("route") ?? positional[1];
|
|
35145
35440
|
const wanted = only ? cfg.routes.filter((r) => r.route === only) : cfg.routes;
|
|
35146
35441
|
if (only && wanted.length === 0) {
|
|
@@ -35502,6 +35797,11 @@ ${where.join("\n")}`);
|
|
|
35502
35797
|
} else if (w.state === "ok") passed++;
|
|
35503
35798
|
}
|
|
35504
35799
|
}
|
|
35800
|
+
if (!flag("offline")) {
|
|
35801
|
+
const np = noProjectsFinding(route2.route, (await new Tracker(route2, cfg.ship).projectRows().catch(() => [null])).length);
|
|
35802
|
+
if (np) problems.push(np);
|
|
35803
|
+
else passed++;
|
|
35804
|
+
}
|
|
35505
35805
|
for (const message of roleCapWarnings(cfg.ship)) problems.push({ severity: "note", kind: "role_cap_above_ship_cap", message });
|
|
35506
35806
|
for (const f of routeAvatarFailures(cfg.ship.stateDir, route2.route)) problems.push({ severity: "note", kind: "persona_avatar_upload_failed", route: route2.route, message: `${f.role} persona avatar failed to upload: ${f.detail}`, remedy: "run `crew agents sync` again" });
|
|
35507
35807
|
if (daemonLiveness) {
|
|
@@ -35845,6 +36145,12 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
35845
36145
|
`);
|
|
35846
36146
|
}
|
|
35847
36147
|
}
|
|
36148
|
+
if (!flag("offline")) {
|
|
36149
|
+
const projectRows = await tracker.projectRows().catch(() => void 0);
|
|
36150
|
+
const np = projectRows ? noProjectsFinding(route2.route, projectRows.length) : null;
|
|
36151
|
+
if (np) R.line(`projects: WARN ${np.message} \u2014 ${np.remedy}
|
|
36152
|
+
`);
|
|
36153
|
+
}
|
|
35848
36154
|
const [ships, crewRows] = await Promise.all([tracker.shipRows(), tracker.crewRows()]);
|
|
35849
36155
|
if (ships.length === 0) {
|
|
35850
36156
|
R.line("ship record: this workspace has no Ships table (fine)\n");
|