@tablation/crew 0.138.0 → 0.139.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +337 -125
- package/package.json +1 -1
- package/prompts/default/personas/lane-design.svg +1 -0
- package/prompts/default/personas/lane-dev.svg +1 -0
- package/prompts/default/personas/lane-pair.svg +1 -0
- package/prompts/default/personas/lane-qa.svg +1 -0
- package/prompts/default/personas/lane-triage.svg +1 -0
- package/prompts/dev-qa/personas/lane-design.svg +1 -0
- package/prompts/dev-qa/personas/lane-dev.svg +1 -0
- package/prompts/dev-qa/personas/lane-pair.svg +1 -0
- package/prompts/dev-qa/personas/lane-qa.svg +1 -0
- package/prompts/dev-qa/personas/lane-triage.svg +1 -0
package/dist/cli.js
CHANGED
|
@@ -1673,9 +1673,12 @@ var claudeAdapter = {
|
|
|
1673
1673
|
"the write profile (QA) withholds the Edit tool, not file writes \u2014 Bash can still write files",
|
|
1674
1674
|
"git push is not blocked, only forced pushes"
|
|
1675
1675
|
],
|
|
1676
|
+
// CREW-3118: with `--input-format stream-json` stdin is NDJSON user messages, so a note can follow the prompt.
|
|
1677
|
+
userMessageLine: (text2) => JSON.stringify({ type: "user", message: { role: "user", content: [{ type: "text", text: text2 }] } }) + "\n",
|
|
1676
1678
|
invocation(spec, o) {
|
|
1677
1679
|
const args = [
|
|
1678
1680
|
"-p",
|
|
1681
|
+
...o.streamInput ? ["--input-format", "stream-json"] : [],
|
|
1679
1682
|
"--allowedTools",
|
|
1680
1683
|
...allowedTools(o.role),
|
|
1681
1684
|
"--disallowedTools",
|
|
@@ -11018,6 +11021,55 @@ async function updateStartedRow(target, rowId, body) {
|
|
|
11018
11021
|
throw e;
|
|
11019
11022
|
}
|
|
11020
11023
|
}
|
|
11024
|
+
async function markMessage(target, rowId, messageId, state) {
|
|
11025
|
+
try {
|
|
11026
|
+
await send(target, "PATCH", `/agents/log/${rowId}/messages/${messageId}`, { deliveryState: state });
|
|
11027
|
+
return true;
|
|
11028
|
+
} catch {
|
|
11029
|
+
return false;
|
|
11030
|
+
}
|
|
11031
|
+
}
|
|
11032
|
+
async function fetchPendingMessages(target, workItem) {
|
|
11033
|
+
try {
|
|
11034
|
+
const res = await request(
|
|
11035
|
+
target,
|
|
11036
|
+
"GET",
|
|
11037
|
+
`/workspaces/${target.workspaceId}/agents/log/pending-messages?workItem=${encodeURIComponent(`${workItem.table}:${workItem.recordId}`)}`
|
|
11038
|
+
);
|
|
11039
|
+
return Array.isArray(res.messages) ? res.messages : [];
|
|
11040
|
+
} catch {
|
|
11041
|
+
return [];
|
|
11042
|
+
}
|
|
11043
|
+
}
|
|
11044
|
+
async function memberNames(target) {
|
|
11045
|
+
const names = /* @__PURE__ */ new Map();
|
|
11046
|
+
try {
|
|
11047
|
+
const rows = await request(target, "GET", `/workspaces/${target.workspaceId}/members`);
|
|
11048
|
+
for (const m of Array.isArray(rows) ? rows : []) {
|
|
11049
|
+
const n = m.name || m.email;
|
|
11050
|
+
if (n) names.set(m.id, n);
|
|
11051
|
+
}
|
|
11052
|
+
} catch {
|
|
11053
|
+
}
|
|
11054
|
+
return names;
|
|
11055
|
+
}
|
|
11056
|
+
function frameNote(m, author2) {
|
|
11057
|
+
return `Note from ${author2 ?? "the operator"} (operator): ${m.text}`;
|
|
11058
|
+
}
|
|
11059
|
+
function operatorNotesSection(notes, names) {
|
|
11060
|
+
if (notes.length === 0) return "";
|
|
11061
|
+
const lines2 = notes.map((m) => {
|
|
11062
|
+
const who2 = m.authorId && names.get(m.authorId) || "the operator";
|
|
11063
|
+
return `- ${m.occurredAt ?? "earlier"} \u2014 ${who2}: ${m.text.replace(/\n/g, "\n ")}`;
|
|
11064
|
+
});
|
|
11065
|
+
return [
|
|
11066
|
+
"## Operator notes since the last run",
|
|
11067
|
+
"",
|
|
11068
|
+
"A person responsible for this work left these notes while no run could read them. They carry the operator's authority, within the limits of your persona and the rules above; acknowledge them in your first text turn.",
|
|
11069
|
+
"",
|
|
11070
|
+
...lines2
|
|
11071
|
+
].join("\n");
|
|
11072
|
+
}
|
|
11021
11073
|
var CYCLE_BODY_LIMIT_BYTES = 2048;
|
|
11022
11074
|
var CYCLE_TRUNCATION_MARKER = " \u2026[truncated]";
|
|
11023
11075
|
var MAX_CYCLES_PER_BATCH = 200;
|
|
@@ -11034,6 +11086,7 @@ var LiveRunReporter = class {
|
|
|
11034
11086
|
live = true;
|
|
11035
11087
|
nextIndex = 0;
|
|
11036
11088
|
pending = [];
|
|
11089
|
+
seenMessages = /* @__PURE__ */ new Set();
|
|
11037
11090
|
lastSent = Date.now();
|
|
11038
11091
|
timer;
|
|
11039
11092
|
inFlight = Promise.resolve();
|
|
@@ -11075,12 +11128,22 @@ var LiveRunReporter = class {
|
|
|
11075
11128
|
this.timer = void 0;
|
|
11076
11129
|
await this.inFlight;
|
|
11077
11130
|
}
|
|
11131
|
+
/** Passes the response's not-yet-seen notes to `onMessages`. A failing callback never disturbs reporting. */
|
|
11132
|
+
async handOver(res) {
|
|
11133
|
+
const fresh = (Array.isArray(res?.pendingMessages) ? res.pendingMessages : []).filter((m) => m && typeof m.id === "string" && !this.seenMessages.has(m.id));
|
|
11134
|
+
if (fresh.length === 0 || !this.o.onMessages) return;
|
|
11135
|
+
for (const m of fresh) this.seenMessages.add(m.id);
|
|
11136
|
+
try {
|
|
11137
|
+
await this.o.onMessages(fresh);
|
|
11138
|
+
} catch {
|
|
11139
|
+
}
|
|
11140
|
+
}
|
|
11078
11141
|
async step() {
|
|
11079
11142
|
if (!this.live) return;
|
|
11080
11143
|
try {
|
|
11081
11144
|
if (this.pending.length > 0) {
|
|
11082
11145
|
const batch = this.pending.slice(0, MAX_CYCLES_PER_BATCH);
|
|
11083
|
-
await post(this.target, `/agents/log/${this.rowId}/cycles`, batch.map((c) => ({
|
|
11146
|
+
const res = await post(this.target, `/agents/log/${this.rowId}/cycles`, batch.map((c) => ({
|
|
11084
11147
|
cycleIndex: c.cycleIndex,
|
|
11085
11148
|
occurredAt: c.occurredAt,
|
|
11086
11149
|
thinking: c.thinking,
|
|
@@ -11090,9 +11153,11 @@ var LiveRunReporter = class {
|
|
|
11090
11153
|
this.posted = batch[batch.length - 1].cycleIndex + 1;
|
|
11091
11154
|
this.lastSent = Date.now();
|
|
11092
11155
|
this.o.onPosted?.(this.posted);
|
|
11156
|
+
await this.handOver(res);
|
|
11093
11157
|
} else if (Date.now() - this.lastSent >= this.heartbeatMs) {
|
|
11094
|
-
await send(this.target, "PATCH", `/agents/log/${this.rowId}`, {});
|
|
11158
|
+
const res = await send(this.target, "PATCH", `/agents/log/${this.rowId}`, {});
|
|
11095
11159
|
this.lastSent = Date.now();
|
|
11160
|
+
await this.handOver(res);
|
|
11096
11161
|
}
|
|
11097
11162
|
} catch (e) {
|
|
11098
11163
|
if (e instanceof AgentLogHttpError && e.status < 500) {
|
|
@@ -13269,8 +13334,10 @@ function planAgentRun(o) {
|
|
|
13269
13334
|
const sandboxChoice = o.ship.runner === "sandbox" ? sandboxImageOf(o.route, o.repo, o.stateDir, o.repoContract) : void 0;
|
|
13270
13335
|
const sandboxImage = sandboxChoice?.image;
|
|
13271
13336
|
const sandboxFiles = [...code?.files ?? [], ...sandboxLsp?.files ?? []];
|
|
13337
|
+
const streamInput = adapter.userMessageLine !== void 0 && o.ship.runner !== "sandbox";
|
|
13272
13338
|
const invocation = adapter.invocation(toolchain, {
|
|
13273
13339
|
code,
|
|
13340
|
+
streamInput,
|
|
13274
13341
|
role: o.role,
|
|
13275
13342
|
model,
|
|
13276
13343
|
pluginDirs: adapter.harness !== "claude" ? void 0 : sandboxLsp ? [sandboxLsp.dir] : lspPluginDirsFor(o.route, o.repo, o.stateDir),
|
|
@@ -13331,6 +13398,7 @@ function planAgentRun(o) {
|
|
|
13331
13398
|
} : {},
|
|
13332
13399
|
resolution: { toolchain: seat.toolchainWhy, model: seat.modelWhy },
|
|
13333
13400
|
warnings: [...seat.warnings ?? [], ...expanded.warnings],
|
|
13401
|
+
...streamInput ? { acceptsInput: true } : {},
|
|
13334
13402
|
prompt,
|
|
13335
13403
|
promptBytes: Buffer.byteLength(prompt, "utf8"),
|
|
13336
13404
|
unsetEnv: adapter.unsetEnv,
|
|
@@ -13503,6 +13571,8 @@ var RunObserver = class {
|
|
|
13503
13571
|
* ticket the run actually claims (CREW-1776); `id.ticket` stays the hint.
|
|
13504
13572
|
*/
|
|
13505
13573
|
liveTicket;
|
|
13574
|
+
/** CREW-3118: called when the stream first carries the harness's final result, e.g. to close a streaming stdin. */
|
|
13575
|
+
onResult;
|
|
13506
13576
|
/** Called after `liveTicket` changes, so the sidecar can be rewritten. */
|
|
13507
13577
|
onClaim;
|
|
13508
13578
|
buf = "";
|
|
@@ -13551,7 +13621,11 @@ var RunObserver = class {
|
|
|
13551
13621
|
const got = this.adapter.extractResult(parsed);
|
|
13552
13622
|
if (got) {
|
|
13553
13623
|
this.result = { ...this.result, ...Object.fromEntries(Object.entries(got).filter(([, v]) => v !== void 0)) };
|
|
13554
|
-
if (got.numTurns !== void 0 || got.costUsd !== void 0)
|
|
13624
|
+
if (got.numTurns !== void 0 || got.costUsd !== void 0) {
|
|
13625
|
+
const first = !this.sawResult;
|
|
13626
|
+
this.sawResult = true;
|
|
13627
|
+
if (first && !this.muted) this.onResult?.();
|
|
13628
|
+
}
|
|
13555
13629
|
}
|
|
13556
13630
|
this.handoff.feed(parsed);
|
|
13557
13631
|
this.consume(parsed, this.mapper.map(parsed));
|
|
@@ -13820,7 +13894,36 @@ async function finishRun(id, obs, emit, startedAt, end, agentLogKey, hintMoved)
|
|
|
13820
13894
|
}
|
|
13821
13895
|
return { ms: ms3, ticket: attributedTicket, handoffPending: !!pending };
|
|
13822
13896
|
}
|
|
13897
|
+
async function deliverNotes(target, rowId, msgs, write) {
|
|
13898
|
+
const names = await memberNames(target);
|
|
13899
|
+
for (const m of msgs) {
|
|
13900
|
+
const landed = await write(frameNote(m, m.authorId && names.get(m.authorId) || void 0));
|
|
13901
|
+
await markMessage(target, rowId, m.id, landed ? "delivered" : "carried_forward");
|
|
13902
|
+
}
|
|
13903
|
+
}
|
|
13904
|
+
async function withOperatorNotes(plan) {
|
|
13905
|
+
const log = plan.agentLog;
|
|
13906
|
+
const issues = log?.tickets?.issuesModelId;
|
|
13907
|
+
if (!log || !issues || !plan.ticketRecordId) return plan;
|
|
13908
|
+
const notes = await fetchPendingMessages(log, { table: issues, recordId: plan.ticketRecordId });
|
|
13909
|
+
if (notes.length === 0) return plan;
|
|
13910
|
+
const section = operatorNotesSection(notes, await memberNames(log));
|
|
13911
|
+
const prompt = `${plan.prompt}
|
|
13912
|
+
|
|
13913
|
+
${section}
|
|
13914
|
+
`;
|
|
13915
|
+
await Promise.all(notes.map((m) => m.agentLogId ? markMessage(log, m.agentLogId, m.id, "delivered") : Promise.resolve(false)));
|
|
13916
|
+
return { ...plan, prompt, promptBytes: Buffer.byteLength(prompt, "utf8") };
|
|
13917
|
+
}
|
|
13918
|
+
function streamsInput(plan) {
|
|
13919
|
+
const i = plan.args.indexOf("--input-format");
|
|
13920
|
+
return !!plan.acceptsInput && i >= 0 && plan.args[i + 1] === "stream-json";
|
|
13921
|
+
}
|
|
13823
13922
|
function spawnAgent(plan, emit, hintMoved) {
|
|
13923
|
+
if (!plan.agentLog?.tickets || !plan.ticketRecordId) return spawnPlanned(plan, emit, hintMoved);
|
|
13924
|
+
return withOperatorNotes(plan).catch(() => plan).then((p) => spawnPlanned(p, emit, hintMoved));
|
|
13925
|
+
}
|
|
13926
|
+
function spawnPlanned(plan, emit, hintMoved) {
|
|
13824
13927
|
const adapter = adapterFor(plan.harness ?? LEGACY_TOOLCHAIN_HARNESS);
|
|
13825
13928
|
const runner = runnerFor(plan.runner, plan.sandboxConfig);
|
|
13826
13929
|
const started = Date.now();
|
|
@@ -13894,6 +13997,25 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
13894
13997
|
}
|
|
13895
13998
|
}
|
|
13896
13999
|
const obs = new RunObserver(id, adapter, eventsSink, emit.cycle);
|
|
14000
|
+
let inputOpen = streamsInput(plan) && !promptDelivered && !!adapter.userMessageLine;
|
|
14001
|
+
const closeInput = () => {
|
|
14002
|
+
if (!inputOpen) return;
|
|
14003
|
+
inputOpen = false;
|
|
14004
|
+
child.stdin?.end();
|
|
14005
|
+
};
|
|
14006
|
+
if (inputOpen) obs.onResult = closeInput;
|
|
14007
|
+
const writeNote = (text2) => new Promise((done) => {
|
|
14008
|
+
const stdin = child.stdin;
|
|
14009
|
+
if (!inputOpen || !stdin || !stdin.writable) {
|
|
14010
|
+
done(false);
|
|
14011
|
+
return;
|
|
14012
|
+
}
|
|
14013
|
+
try {
|
|
14014
|
+
stdin.write(adapter.userMessageLine(text2), (err3) => done(!err3));
|
|
14015
|
+
} catch {
|
|
14016
|
+
done(false);
|
|
14017
|
+
}
|
|
14018
|
+
});
|
|
13897
14019
|
const startedRow = plan.agentLog ? startAgentRunRow(plan.agentLog, {
|
|
13898
14020
|
runId: plan.workspaceRunId,
|
|
13899
14021
|
ticketReference: plan.ticket ?? void 0,
|
|
@@ -13910,7 +14032,8 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
13910
14032
|
updateSidecar(plan.streamPath, { agentLogRowId: row.id });
|
|
13911
14033
|
if (row.live && plan.agentLog) {
|
|
13912
14034
|
const reporter = new LiveRunReporter(plan.agentLog, row.id, {
|
|
13913
|
-
onPosted: (n) => updateSidecar(plan.streamPath, { cyclesPosted: n })
|
|
14035
|
+
onPosted: (n) => updateSidecar(plan.streamPath, { cyclesPosted: n }),
|
|
14036
|
+
onMessages: (msgs) => deliverNotes(plan.agentLog, row.id, msgs, writeNote)
|
|
13914
14037
|
});
|
|
13915
14038
|
obs.attachReporter(reporter);
|
|
13916
14039
|
reporter.start();
|
|
@@ -13936,6 +14059,7 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
13936
14059
|
reject(new AgentSpawnError(`cannot run ${plan.bin}: ${err3.message}`));
|
|
13937
14060
|
});
|
|
13938
14061
|
child.on("close", async (code) => {
|
|
14062
|
+
inputOpen = false;
|
|
13939
14063
|
clearInterval(timer);
|
|
13940
14064
|
clearTimeout(limitTimer);
|
|
13941
14065
|
obs.feed(tail3.poll());
|
|
@@ -13963,7 +14087,9 @@ function spawnAgent(plan, emit, hintMoved) {
|
|
|
13963
14087
|
emit.warn(`agent closed stdin before the prompt was delivered: ${err3.message}`, { step: "agent" });
|
|
13964
14088
|
});
|
|
13965
14089
|
if (promptDelivered) child.stdin?.end();
|
|
13966
|
-
else
|
|
14090
|
+
else if (inputOpen) {
|
|
14091
|
+
child.stdin?.write(adapter.userMessageLine(plan.prompt));
|
|
14092
|
+
} else child.stdin?.end(plan.prompt);
|
|
13967
14093
|
});
|
|
13968
14094
|
}
|
|
13969
14095
|
}
|
|
@@ -13978,8 +14104,11 @@ async function reattachRun(streamPath, sc, emit, o = {}) {
|
|
|
13978
14104
|
obs.feed(tail3.poll());
|
|
13979
14105
|
obs.muted = false;
|
|
13980
14106
|
if (sc.agentLogRowId && sc.agentLog && o.agentLogKey) {
|
|
13981
|
-
const
|
|
13982
|
-
|
|
14107
|
+
const logTarget = { ...sc.agentLog, apiKey: o.agentLogKey };
|
|
14108
|
+
const reporter = new LiveRunReporter(logTarget, sc.agentLogRowId, {
|
|
14109
|
+
onPosted: (n) => updateSidecar(streamPath, { cyclesPosted: n }),
|
|
14110
|
+
// CREW-3118: the adopted run's stdin belongs to the process that died, so a note can only be carried forward.
|
|
14111
|
+
onMessages: (msgs) => deliverNotes(logTarget, sc.agentLogRowId, msgs, async () => false)
|
|
13983
14112
|
}, sc.cyclesPosted ?? 0);
|
|
13984
14113
|
obs.attachReporter(reporter);
|
|
13985
14114
|
reporter.start();
|
|
@@ -15339,7 +15468,7 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
15339
15468
|
}
|
|
15340
15469
|
|
|
15341
15470
|
// src/cli.ts
|
|
15342
|
-
import { resolve as resolve7, dirname as dirname37, join as
|
|
15471
|
+
import { resolve as resolve7, dirname as dirname37, join as join61, basename as basename16 } from "path";
|
|
15343
15472
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
15344
15473
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
15345
15474
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
@@ -24452,8 +24581,77 @@ function describeCapability(i) {
|
|
|
24452
24581
|
return `missing ${missLine(i)}`;
|
|
24453
24582
|
}
|
|
24454
24583
|
|
|
24584
|
+
// src/persona-avatars.ts
|
|
24585
|
+
import { existsSync as existsSync51, readFileSync as readFileSync47 } from "fs";
|
|
24586
|
+
import { join as join52 } from "path";
|
|
24587
|
+
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
24588
|
+
function personaAvatarFile(promptsDir, role) {
|
|
24589
|
+
for (const ext of ["png", "svg"]) {
|
|
24590
|
+
const name = `lane-${role}.${ext}`;
|
|
24591
|
+
const path = join52(promptsDir, "personas", name);
|
|
24592
|
+
if (existsSync51(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
24593
|
+
}
|
|
24594
|
+
return void 0;
|
|
24595
|
+
}
|
|
24596
|
+
async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
24597
|
+
if (!route2.resolved) return [];
|
|
24598
|
+
const base = `${route2.baseUrl.replace(/\/+$/, "")}/api/workspaces/${route2.resolved.workspaceId}/agents/personas`;
|
|
24599
|
+
const outcomes = [];
|
|
24600
|
+
for (const role of ROLE_NAMES) {
|
|
24601
|
+
const file = personaAvatarFile(route2.promptsDir, role);
|
|
24602
|
+
const agentId = agentPersonas[role]?.agentId;
|
|
24603
|
+
if (!file || !agentId) continue;
|
|
24604
|
+
try {
|
|
24605
|
+
const form = new FormData();
|
|
24606
|
+
form.append("file", new Blob([readFileSync47(file.path)], { type: file.mimeType }), file.name);
|
|
24607
|
+
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
24608
|
+
method: "PUT",
|
|
24609
|
+
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
24610
|
+
body: form
|
|
24611
|
+
});
|
|
24612
|
+
if (!res.ok) {
|
|
24613
|
+
outcomes.push({ role, status: "failed", detail: `${res.status} ${(await res.text()).slice(0, 200)}`.trim() });
|
|
24614
|
+
continue;
|
|
24615
|
+
}
|
|
24616
|
+
const body = await res.json();
|
|
24617
|
+
if (body.status === "updated" || body.status === "unchanged" || body.status === "skipped") {
|
|
24618
|
+
outcomes.push({ role, status: body.status, ...body.reason ? { detail: body.reason } : {} });
|
|
24619
|
+
} else {
|
|
24620
|
+
outcomes.push({ role, status: "failed", detail: "unrecognised response" });
|
|
24621
|
+
}
|
|
24622
|
+
} catch (e) {
|
|
24623
|
+
outcomes.push({ role, status: "failed", detail: e instanceof Error ? e.message : String(e) });
|
|
24624
|
+
}
|
|
24625
|
+
}
|
|
24626
|
+
return outcomes;
|
|
24627
|
+
}
|
|
24628
|
+
function describeAvatarOutcome(o, label) {
|
|
24629
|
+
switch (o.status) {
|
|
24630
|
+
case "updated":
|
|
24631
|
+
return `${label}: avatar uploaded`;
|
|
24632
|
+
case "unchanged":
|
|
24633
|
+
return `${label}: avatar already current`;
|
|
24634
|
+
case "skipped":
|
|
24635
|
+
return `${label}: avatar left alone${o.detail ? ` (${o.detail})` : ""}`;
|
|
24636
|
+
case "failed":
|
|
24637
|
+
return `${label}: avatar upload failed \u2014 ${o.detail ?? "unknown error"}`;
|
|
24638
|
+
}
|
|
24639
|
+
}
|
|
24640
|
+
function avatarFailures(raw) {
|
|
24641
|
+
const map = raw?.avatarSyncFailures;
|
|
24642
|
+
if (!map || typeof map !== "object") return [];
|
|
24643
|
+
return Object.entries(map).map(([role, detail]) => ({ role, detail: String(detail) }));
|
|
24644
|
+
}
|
|
24645
|
+
function routeAvatarFailures(stateDir, route2) {
|
|
24646
|
+
try {
|
|
24647
|
+
return avatarFailures(JSON.parse(readFileSync47(resolvedPathFor(stateDir, route2), "utf8")));
|
|
24648
|
+
} catch {
|
|
24649
|
+
return [];
|
|
24650
|
+
}
|
|
24651
|
+
}
|
|
24652
|
+
|
|
24455
24653
|
// src/agents-sync-run.ts
|
|
24456
|
-
import { existsSync as
|
|
24654
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync48, writeFileSync as writeFileSync39 } from "fs";
|
|
24457
24655
|
import { dirname as dirname31 } from "path";
|
|
24458
24656
|
async function runAgentsSync(target, o) {
|
|
24459
24657
|
const dryRun = o.dryRun ?? false;
|
|
@@ -24487,11 +24685,22 @@ async function runAgentsSync(target, o) {
|
|
|
24487
24685
|
}
|
|
24488
24686
|
for (const s of skillResult?.outcomes ?? []) o.say(describeSkillSyncOutcome(s));
|
|
24489
24687
|
for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
|
|
24688
|
+
const avatarFailures2 = {};
|
|
24689
|
+
if (!readOnly && !dryRun) {
|
|
24690
|
+
for (const a of await syncPersonaAvatars(target, personaResult.agentPersonas, { userAgent: o.userAgent })) {
|
|
24691
|
+
const line = describeAvatarOutcome(a, PERSONA_NAME[a.role]);
|
|
24692
|
+
if (a.status === "failed") {
|
|
24693
|
+
o.warn(`warning: ${line}`);
|
|
24694
|
+
avatarFailures2[a.role] = a.detail ?? "unknown error";
|
|
24695
|
+
} else o.say(line);
|
|
24696
|
+
}
|
|
24697
|
+
}
|
|
24490
24698
|
if (!dryRun) {
|
|
24491
24699
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
24492
|
-
const raw =
|
|
24700
|
+
const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
|
|
24493
24701
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
24494
24702
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
24703
|
+
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
24495
24704
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
24496
24705
|
mkdirSync38(dirname31(resolvedPath), { recursive: true });
|
|
24497
24706
|
writeFileSync39(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
@@ -24631,7 +24840,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
24631
24840
|
|
|
24632
24841
|
// src/repos-check.ts
|
|
24633
24842
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
24634
|
-
import { readFileSync as
|
|
24843
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
24635
24844
|
import { basename as basename11 } from "path";
|
|
24636
24845
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
24637
24846
|
function checkHookSyntax(script, shell) {
|
|
@@ -24672,7 +24881,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
24672
24881
|
}
|
|
24673
24882
|
let parsed;
|
|
24674
24883
|
try {
|
|
24675
|
-
parsed = parseRepoConfig(
|
|
24884
|
+
parsed = parseRepoConfig(readFileSync49(file, "utf8"), file);
|
|
24676
24885
|
} catch (e) {
|
|
24677
24886
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
24678
24887
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -25136,7 +25345,7 @@ ${run4.err}` });
|
|
|
25136
25345
|
}
|
|
25137
25346
|
|
|
25138
25347
|
// src/sample-ticket.ts
|
|
25139
|
-
import { basename as basename12, dirname as dirname32, join as
|
|
25348
|
+
import { basename as basename12, dirname as dirname32, join as join53 } from "path";
|
|
25140
25349
|
var SAMPLE_REPO = "crew-sample";
|
|
25141
25350
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
25142
25351
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -25159,8 +25368,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
25159
25368
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
25160
25369
|
`;
|
|
25161
25370
|
function sampleDir(existing, reposBase, workspace) {
|
|
25162
|
-
if (existing.length > 0) return
|
|
25163
|
-
return
|
|
25371
|
+
if (existing.length > 0) return join53(dirname32(existing[0]), SAMPLE_REPO);
|
|
25372
|
+
return join53(reposBase, workspace, SAMPLE_REPO);
|
|
25164
25373
|
}
|
|
25165
25374
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
25166
25375
|
function sampleDescription() {
|
|
@@ -25204,8 +25413,8 @@ function planSampleTicket(i) {
|
|
|
25204
25413
|
}
|
|
25205
25414
|
|
|
25206
25415
|
// src/worktree-sweep.ts
|
|
25207
|
-
import { existsSync as
|
|
25208
|
-
import { basename as basename13, dirname as dirname33, join as
|
|
25416
|
+
import { existsSync as existsSync53, readFileSync as readFileSync50, readdirSync as readdirSync15 } from "fs";
|
|
25417
|
+
import { basename as basename13, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
|
|
25209
25418
|
function planWorktreeSweep(target, tickets, contract) {
|
|
25210
25419
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
25211
25420
|
const verified = contract.statuses.verified;
|
|
@@ -25282,7 +25491,7 @@ function siblingWorktreeDirs(target) {
|
|
|
25282
25491
|
for (const name of names) {
|
|
25283
25492
|
if (!name.startsWith(stem)) continue;
|
|
25284
25493
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
25285
|
-
const path =
|
|
25494
|
+
const path = join54(parent, name);
|
|
25286
25495
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
25287
25496
|
}
|
|
25288
25497
|
return out;
|
|
@@ -25317,7 +25526,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
25317
25526
|
let removed = 0;
|
|
25318
25527
|
let keptBranches = 0;
|
|
25319
25528
|
for (const a of actions) {
|
|
25320
|
-
if (!dryRun && base && !a.keepBranch &&
|
|
25529
|
+
if (!dryRun && base && !a.keepBranch && existsSync53(a.path) && isHandBackMerge(a.path, base)) {
|
|
25321
25530
|
if (gitOk(a.path, ["merge", "--abort"]) !== null) {
|
|
25322
25531
|
log.emit(
|
|
25323
25532
|
`abandoned the hand-back merge of ${base} in ${a.path}: ${a.ticket.issue_id} deployed without it`,
|
|
@@ -25325,7 +25534,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
25325
25534
|
);
|
|
25326
25535
|
}
|
|
25327
25536
|
}
|
|
25328
|
-
if (!dryRun &&
|
|
25537
|
+
if (!dryRun && existsSync53(a.path)) {
|
|
25329
25538
|
let dirty = false;
|
|
25330
25539
|
try {
|
|
25331
25540
|
dirty = status(a.path).length > 0;
|
|
@@ -25336,7 +25545,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
25336
25545
|
continue;
|
|
25337
25546
|
}
|
|
25338
25547
|
}
|
|
25339
|
-
if (!dryRun && a.requirePushed && a.branch &&
|
|
25548
|
+
if (!dryRun && a.requirePushed && a.branch && existsSync53(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
|
|
25340
25549
|
refuse2(a, "unpushed commits", `${a.branch} has commits that are not on ${remote}`);
|
|
25341
25550
|
continue;
|
|
25342
25551
|
}
|
|
@@ -25385,7 +25594,7 @@ function isHandBackMerge(path, base) {
|
|
|
25385
25594
|
if (!msgPath) return false;
|
|
25386
25595
|
let first;
|
|
25387
25596
|
try {
|
|
25388
|
-
first =
|
|
25597
|
+
first = readFileSync50(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
25389
25598
|
} catch {
|
|
25390
25599
|
return false;
|
|
25391
25600
|
}
|
|
@@ -25490,14 +25699,14 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
25490
25699
|
}
|
|
25491
25700
|
|
|
25492
25701
|
// src/stream-sweep.ts
|
|
25493
|
-
import { existsSync as
|
|
25494
|
-
import { join as
|
|
25702
|
+
import { existsSync as existsSync54, readdirSync as readdirSync16, rmSync as rmSync23, statSync as statSync15 } from "fs";
|
|
25703
|
+
import { join as join55 } from "path";
|
|
25495
25704
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
25496
25705
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
25497
|
-
const dir =
|
|
25498
|
-
if (!
|
|
25706
|
+
const dir = join55(stateDir, "streams");
|
|
25707
|
+
if (!existsSync54(dir)) return [];
|
|
25499
25708
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
25500
|
-
return readdirSync16(dir).map((name) =>
|
|
25709
|
+
return readdirSync16(dir).map((name) => join55(dir, name)).filter((path) => {
|
|
25501
25710
|
try {
|
|
25502
25711
|
return statSync15(path).mtimeMs < cutoff;
|
|
25503
25712
|
} catch {
|
|
@@ -25523,9 +25732,9 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
25523
25732
|
return removed;
|
|
25524
25733
|
}
|
|
25525
25734
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
25526
|
-
if (!
|
|
25735
|
+
if (!existsSync54(stateDir)) return [];
|
|
25527
25736
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
25528
|
-
return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
25737
|
+
return readdirSync16(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join55(stateDir, name)).filter((path) => {
|
|
25529
25738
|
try {
|
|
25530
25739
|
return statSync15(path).mtimeMs < cutoff;
|
|
25531
25740
|
} catch {
|
|
@@ -25535,7 +25744,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
25535
25744
|
}
|
|
25536
25745
|
|
|
25537
25746
|
// src/cli.ts
|
|
25538
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
25747
|
+
import { realpathSync as realpathSync3, readFileSync as readFileSync53, existsSync as existsSync58, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
|
|
25539
25748
|
import { createInterface } from "readline/promises";
|
|
25540
25749
|
|
|
25541
25750
|
// src/periscope-resume.ts
|
|
@@ -25762,8 +25971,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
25762
25971
|
import { createServer as createHttpServer } from "http";
|
|
25763
25972
|
import { spawn as spawn9 } from "child_process";
|
|
25764
25973
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
25765
|
-
import { existsSync as
|
|
25766
|
-
import { join as
|
|
25974
|
+
import { existsSync as existsSync55, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync17 } from "fs";
|
|
25975
|
+
import { join as join56 } from "path";
|
|
25767
25976
|
|
|
25768
25977
|
// src/secret-compare.ts
|
|
25769
25978
|
import { timingSafeEqual } from "crypto";
|
|
@@ -25856,20 +26065,20 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
25856
26065
|
return child;
|
|
25857
26066
|
};
|
|
25858
26067
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
25859
|
-
return
|
|
26068
|
+
return join56(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
25860
26069
|
}
|
|
25861
26070
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
25862
26071
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
25863
|
-
if (!
|
|
26072
|
+
if (!existsSync55(path)) return void 0;
|
|
25864
26073
|
try {
|
|
25865
|
-
return JSON.parse(
|
|
26074
|
+
return JSON.parse(readFileSync51(path, "utf8"));
|
|
25866
26075
|
} catch {
|
|
25867
26076
|
return void 0;
|
|
25868
26077
|
}
|
|
25869
26078
|
}
|
|
25870
26079
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
25871
26080
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
25872
|
-
mkdirSync39(
|
|
26081
|
+
mkdirSync39(join56(stateDir, "passengers"), { recursive: true });
|
|
25873
26082
|
writeFileSync40(path, `${JSON.stringify(state, null, 2)}
|
|
25874
26083
|
`);
|
|
25875
26084
|
}
|
|
@@ -25890,8 +26099,8 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
25890
26099
|
}
|
|
25891
26100
|
}
|
|
25892
26101
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
25893
|
-
const dir =
|
|
25894
|
-
if (!
|
|
26102
|
+
const dir = join56(stateDir, "passengers");
|
|
26103
|
+
if (!existsSync55(dir)) return [];
|
|
25895
26104
|
const suffix = "-sync.json";
|
|
25896
26105
|
return readdirSync17(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
25897
26106
|
}
|
|
@@ -26357,7 +26566,7 @@ async function startWorktreeIntel(d) {
|
|
|
26357
26566
|
}
|
|
26358
26567
|
|
|
26359
26568
|
// src/contract-refusal.ts
|
|
26360
|
-
import { join as
|
|
26569
|
+
import { join as join57 } from "path";
|
|
26361
26570
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
26362
26571
|
const out = [];
|
|
26363
26572
|
for (const t of tickets) {
|
|
@@ -26369,7 +26578,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
26369
26578
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
26370
26579
|
if (text2 === null) continue;
|
|
26371
26580
|
try {
|
|
26372
|
-
parseRepoConfig(text2,
|
|
26581
|
+
parseRepoConfig(text2, join57(dir, file));
|
|
26373
26582
|
} catch (e) {
|
|
26374
26583
|
if (e instanceof RepoConfigError) continue;
|
|
26375
26584
|
throw e;
|
|
@@ -26384,7 +26593,7 @@ import { createHash as createHash11 } from "crypto";
|
|
|
26384
26593
|
import {
|
|
26385
26594
|
chmodSync as chmodSync4,
|
|
26386
26595
|
closeSync as closeSync6,
|
|
26387
|
-
existsSync as
|
|
26596
|
+
existsSync as existsSync56,
|
|
26388
26597
|
fstatSync,
|
|
26389
26598
|
openSync as openSync6,
|
|
26390
26599
|
readSync as readSync3,
|
|
@@ -26395,7 +26604,7 @@ import {
|
|
|
26395
26604
|
} from "fs";
|
|
26396
26605
|
import { createConnection } from "net";
|
|
26397
26606
|
import { createServer as createServer2 } from "http";
|
|
26398
|
-
import { basename as basename14, dirname as dirname35, join as
|
|
26607
|
+
import { basename as basename14, dirname as dirname35, join as join58 } from "path";
|
|
26399
26608
|
import { execFile as execFile6, spawn as spawn12 } from "child_process";
|
|
26400
26609
|
|
|
26401
26610
|
// src/periscope-control.ts
|
|
@@ -26632,7 +26841,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
26632
26841
|
// src/control-api.ts
|
|
26633
26842
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
26634
26843
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
26635
|
-
var controlSocketFor = (stateDir) =>
|
|
26844
|
+
var controlSocketFor = (stateDir) => join58(stateDir, CONTROL_SOCKET_NAME);
|
|
26636
26845
|
var MAX_SOCKET_PATH = 100;
|
|
26637
26846
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
26638
26847
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -26719,7 +26928,7 @@ function candidates(live, rotated) {
|
|
|
26719
26928
|
const out = [live];
|
|
26720
26929
|
if (!rotated) return out;
|
|
26721
26930
|
try {
|
|
26722
|
-
for (const n of readdirSync18(dirname35(live))) if (ROTATED_EVENTS_RE.test(n)) out.push(
|
|
26931
|
+
for (const n of readdirSync18(dirname35(live))) if (ROTATED_EVENTS_RE.test(n)) out.push(join58(dirname35(live), n));
|
|
26723
26932
|
} catch {
|
|
26724
26933
|
}
|
|
26725
26934
|
return out;
|
|
@@ -26763,7 +26972,7 @@ function lastLines2(path, n) {
|
|
|
26763
26972
|
}
|
|
26764
26973
|
function readTail(live, opts) {
|
|
26765
26974
|
const max = opts.maxBytes ?? MAX_TAIL_BYTES;
|
|
26766
|
-
if (!
|
|
26975
|
+
if (!existsSync56(live)) {
|
|
26767
26976
|
return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
|
|
26768
26977
|
}
|
|
26769
26978
|
const cur = opts.after ? decodeCursor(opts.after) : null;
|
|
@@ -26919,8 +27128,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
26919
27128
|
if (p.startsWith("/streams/") && get2) {
|
|
26920
27129
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
26921
27130
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
26922
|
-
const file =
|
|
26923
|
-
if (!
|
|
27131
|
+
const file = join58(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
27132
|
+
if (!existsSync56(file)) return err2(404, "no such run");
|
|
26924
27133
|
return tailReply(file, url.searchParams, false, abort);
|
|
26925
27134
|
}
|
|
26926
27135
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
@@ -26965,7 +27174,7 @@ function send2(res, r) {
|
|
|
26965
27174
|
res.end(body);
|
|
26966
27175
|
}
|
|
26967
27176
|
async function socketIsStale(path) {
|
|
26968
|
-
if (!
|
|
27177
|
+
if (!existsSync56(path)) return false;
|
|
26969
27178
|
return new Promise((resolve8) => {
|
|
26970
27179
|
const c = createConnection(path);
|
|
26971
27180
|
c.once("connect", () => {
|
|
@@ -26984,7 +27193,7 @@ async function startControlServer(deps) {
|
|
|
26984
27193
|
return null;
|
|
26985
27194
|
}
|
|
26986
27195
|
if (await socketIsStale(path)) rmSync24(path, { force: true });
|
|
26987
|
-
else if (
|
|
27196
|
+
else if (existsSync56(path)) {
|
|
26988
27197
|
log(`control API not started: ${path} is in use by another process`);
|
|
26989
27198
|
return null;
|
|
26990
27199
|
}
|
|
@@ -27070,19 +27279,19 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
27070
27279
|
|
|
27071
27280
|
// src/periscope-mcp.ts
|
|
27072
27281
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
27073
|
-
import { basename as basename15, dirname as dirname36, isAbsolute as isAbsolute5, join as
|
|
27282
|
+
import { basename as basename15, dirname as dirname36, isAbsolute as isAbsolute5, join as join60, relative as relative2, resolve as resolve6, sep } from "path";
|
|
27074
27283
|
import { z } from "zod";
|
|
27075
27284
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
27076
27285
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
27077
27286
|
|
|
27078
27287
|
// src/periscope-endpoints.ts
|
|
27079
27288
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
27080
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
27081
|
-
import { join as
|
|
27082
|
-
var secretDir = (stateDir) =>
|
|
27083
|
-
var secretFile = (stateDir, id) =>
|
|
27084
|
-
var endpointDir = (stateDir) =>
|
|
27085
|
-
var endpointFile = (stateDir, id) =>
|
|
27289
|
+
import { chmodSync as chmodSync5, existsSync as existsSync57, mkdirSync as mkdirSync41, readdirSync as readdirSync19, readFileSync as readFileSync52, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
|
|
27290
|
+
import { join as join59 } from "path";
|
|
27291
|
+
var secretDir = (stateDir) => join59(stateDir, "periscope-mcp");
|
|
27292
|
+
var secretFile = (stateDir, id) => join59(secretDir(stateDir), `${id}.json`);
|
|
27293
|
+
var endpointDir = (stateDir) => join59(stateDir, "periscope-endpoints");
|
|
27294
|
+
var endpointFile = (stateDir, id) => join59(endpointDir(stateDir), `${id}.json`);
|
|
27086
27295
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27087
27296
|
mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
27088
27297
|
const secret = randomBytes3(32).toString("base64url");
|
|
@@ -27094,7 +27303,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
27094
27303
|
}
|
|
27095
27304
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27096
27305
|
try {
|
|
27097
|
-
const v = JSON.parse(
|
|
27306
|
+
const v = JSON.parse(readFileSync52(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
27098
27307
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
27099
27308
|
} catch {
|
|
27100
27309
|
return void 0;
|
|
@@ -27105,7 +27314,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
27105
27314
|
}
|
|
27106
27315
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
27107
27316
|
try {
|
|
27108
|
-
return JSON.parse(
|
|
27317
|
+
return JSON.parse(readFileSync52(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
27109
27318
|
} catch {
|
|
27110
27319
|
return void 0;
|
|
27111
27320
|
}
|
|
@@ -27120,7 +27329,7 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
|
27120
27329
|
}
|
|
27121
27330
|
function listPeriscopeEndpoints(stateDir) {
|
|
27122
27331
|
const dir = endpointDir(stateDir);
|
|
27123
|
-
if (!
|
|
27332
|
+
if (!existsSync57(dir)) return [];
|
|
27124
27333
|
const out = [];
|
|
27125
27334
|
for (const name of readdirSync19(dir)) {
|
|
27126
27335
|
if (!name.endsWith(".json")) continue;
|
|
@@ -27223,13 +27432,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
27223
27432
|
let abs;
|
|
27224
27433
|
if (isAbsolute5(requested)) {
|
|
27225
27434
|
abs = resolve6(requested);
|
|
27226
|
-
if (isInside(root, abs)) abs =
|
|
27435
|
+
if (isInside(root, abs)) abs = join60(realRoot, relative2(root, abs));
|
|
27227
27436
|
} else {
|
|
27228
27437
|
abs = resolve6(realRoot, requested);
|
|
27229
27438
|
}
|
|
27230
27439
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
27231
27440
|
const { real, rest } = await realAncestor(abs);
|
|
27232
|
-
const final = rest ?
|
|
27441
|
+
const final = rest ? join60(real, rest) : real;
|
|
27233
27442
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
27234
27443
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
27235
27444
|
return final;
|
|
@@ -27297,7 +27506,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
27297
27506
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
27298
27507
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
27299
27508
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
27300
|
-
const size = (await lstat(
|
|
27509
|
+
const size = (await lstat(join60(abs, e.name))).size;
|
|
27301
27510
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
27302
27511
|
}));
|
|
27303
27512
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -27363,7 +27572,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
27363
27572
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
27364
27573
|
}, async ({ path }) => {
|
|
27365
27574
|
const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
|
|
27366
|
-
const abs =
|
|
27575
|
+
const abs = join60(parent, basename15(path));
|
|
27367
27576
|
if (basename15(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
27368
27577
|
const st = await lstat(abs).catch(() => void 0);
|
|
27369
27578
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -27854,7 +28063,7 @@ if (command === "provision") {
|
|
|
27854
28063
|
process.exit(outcome.code);
|
|
27855
28064
|
}
|
|
27856
28065
|
if (command === "pool-member") {
|
|
27857
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
28066
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync53(0, "utf8"));
|
|
27858
28067
|
if (typeof pool === "string") {
|
|
27859
28068
|
process.stderr.write(`crew pool-member: ${pool}
|
|
27860
28069
|
`);
|
|
@@ -28175,7 +28384,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28175
28384
|
} else {
|
|
28176
28385
|
const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
|
|
28177
28386
|
const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
|
|
28178
|
-
if (configless && !
|
|
28387
|
+
if (configless && !existsSync58(findConfigFile(CREW_HOME))) {
|
|
28179
28388
|
cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
|
|
28180
28389
|
} else {
|
|
28181
28390
|
cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
|
|
@@ -28198,7 +28407,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28198
28407
|
throw e;
|
|
28199
28408
|
}
|
|
28200
28409
|
if (command === "credential") {
|
|
28201
|
-
const r = runCredential(positional[1],
|
|
28410
|
+
const r = runCredential(positional[1], readFileSync53(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
28202
28411
|
process.stdout.write(r.out);
|
|
28203
28412
|
process.stderr.write(r.err);
|
|
28204
28413
|
process.exit(r.code);
|
|
@@ -28210,9 +28419,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
28210
28419
|
forges: cfg.ship.forges,
|
|
28211
28420
|
stateDir: cfg.ship.stateDir,
|
|
28212
28421
|
configFile: cfg.configFile,
|
|
28213
|
-
readFile: (p) =>
|
|
28422
|
+
readFile: (p) => readFileSync53(p, "utf8"),
|
|
28214
28423
|
writeFile: (p, t) => writeFileSync42(p, t),
|
|
28215
|
-
stdin: () =>
|
|
28424
|
+
stdin: () => readFileSync53(0, "utf8"),
|
|
28216
28425
|
env: process.env
|
|
28217
28426
|
}
|
|
28218
28427
|
);
|
|
@@ -28546,8 +28755,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
28546
28755
|
}
|
|
28547
28756
|
if (host === "linux" && hasSystemd) {
|
|
28548
28757
|
const label = labelFor(CREW_HOME, "run");
|
|
28549
|
-
const staleTimer =
|
|
28550
|
-
if (
|
|
28758
|
+
const staleTimer = join61(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
28759
|
+
if (existsSync58(staleTimer)) {
|
|
28551
28760
|
process.stdout.write(
|
|
28552
28761
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
28553
28762
|
`
|
|
@@ -28576,7 +28785,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28576
28785
|
const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
28577
28786
|
for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
|
|
28578
28787
|
for (const r of doctorRepos) {
|
|
28579
|
-
if (!
|
|
28788
|
+
if (!existsSync58(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
|
|
28580
28789
|
if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
|
|
28581
28790
|
readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
|
|
28582
28791
|
}
|
|
@@ -28611,7 +28820,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28611
28820
|
}
|
|
28612
28821
|
async function doctorFix(o) {
|
|
28613
28822
|
const routes = await Promise.all(routesInScope(cfg.routes, named).map((c) => gatherHealth({ route: c.route, enabled: c.enabled, hasRepos: reposOf(c).length > 0 }, () => routeProblems(c))));
|
|
28614
|
-
const unitExists = (p) =>
|
|
28823
|
+
const unitExists = (p) => existsSync58(p);
|
|
28615
28824
|
const crontab = o.host === "linux" ? spawnSync13("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
|
|
28616
28825
|
const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
|
|
28617
28826
|
const plan = planFix({ routes, schedulerAbsent, host: o.host });
|
|
@@ -28628,7 +28837,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28628
28837
|
for (const a of plan.actions) {
|
|
28629
28838
|
if (a.kind === "enable") {
|
|
28630
28839
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
28631
|
-
writeFileSync42(cfg.configFile, planEnable(
|
|
28840
|
+
writeFileSync42(cfg.configFile, planEnable(readFileSync53(cfg.configFile, "utf8"), a.route));
|
|
28632
28841
|
enabledSound.add(a.route);
|
|
28633
28842
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
28634
28843
|
} else {
|
|
@@ -28857,7 +29066,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
28857
29066
|
harnessBin: "claude",
|
|
28858
29067
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
28859
29068
|
},
|
|
28860
|
-
policyFile:
|
|
29069
|
+
policyFile: join61(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
28861
29070
|
repo: mirror,
|
|
28862
29071
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
28863
29072
|
base: effective.branch.base,
|
|
@@ -30059,7 +30268,7 @@ ${cu.tail.trimEnd()}
|
|
|
30059
30268
|
logFile: cfg.ship.logFile
|
|
30060
30269
|
});
|
|
30061
30270
|
}
|
|
30062
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
30271
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join61(CREW_HOME, "src"), join61(CREW_HOME, "dist"), join61(CREW_HOME, "bin")];
|
|
30063
30272
|
const configPaths = daemonConfigPaths(cfg);
|
|
30064
30273
|
watchPaths.push(...configPaths);
|
|
30065
30274
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -30377,7 +30586,7 @@ ${cu.tail.trimEnd()}
|
|
|
30377
30586
|
`);
|
|
30378
30587
|
if (!dryRun) {
|
|
30379
30588
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
30380
|
-
const raw =
|
|
30589
|
+
const raw = existsSync58(resolvedPath) ? JSON.parse(readFileSync53(resolvedPath, "utf8")) : {};
|
|
30381
30590
|
raw.agentSkills = result.agentSkills;
|
|
30382
30591
|
mkdirSync42(dirOf2(resolvedPath), { recursive: true });
|
|
30383
30592
|
writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
@@ -30403,7 +30612,7 @@ ${cu.tail.trimEnd()}
|
|
|
30403
30612
|
throw e;
|
|
30404
30613
|
}
|
|
30405
30614
|
const oldName = cfg.ship.name;
|
|
30406
|
-
writeFileSync42(cfg.configFile, setShipNameInYaml(
|
|
30615
|
+
writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), newName));
|
|
30407
30616
|
cfg.ship.name = newName;
|
|
30408
30617
|
let renameMachineId;
|
|
30409
30618
|
try {
|
|
@@ -30450,7 +30659,7 @@ ${cu.tail.trimEnd()}
|
|
|
30450
30659
|
process.exit(2);
|
|
30451
30660
|
};
|
|
30452
30661
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
30453
|
-
const configText =
|
|
30662
|
+
const configText = readFileSync53(cfg.configFile, "utf8");
|
|
30454
30663
|
if (sub === "check") {
|
|
30455
30664
|
try {
|
|
30456
30665
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -30482,8 +30691,8 @@ ${cu.tail.trimEnd()}
|
|
|
30482
30691
|
try {
|
|
30483
30692
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
30484
30693
|
const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
|
|
30485
|
-
if (!
|
|
30486
|
-
const files = { exists: (r) =>
|
|
30694
|
+
if (!existsSync58(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
30695
|
+
const files = { exists: (r) => existsSync58(resolvePath(dir, r)), list: (r) => {
|
|
30487
30696
|
try {
|
|
30488
30697
|
return readdirSync20(resolvePath(dir, r));
|
|
30489
30698
|
} catch {
|
|
@@ -30491,7 +30700,7 @@ ${cu.tail.trimEnd()}
|
|
|
30491
30700
|
}
|
|
30492
30701
|
}, read: (r) => {
|
|
30493
30702
|
try {
|
|
30494
|
-
return
|
|
30703
|
+
return readFileSync53(resolvePath(dir, r), "utf8");
|
|
30495
30704
|
} catch {
|
|
30496
30705
|
return void 0;
|
|
30497
30706
|
}
|
|
@@ -30601,7 +30810,7 @@ ${cu.tail.trimEnd()}
|
|
|
30601
30810
|
if (sub === "list" && !routeName) usage2();
|
|
30602
30811
|
if (sub === "add") {
|
|
30603
30812
|
try {
|
|
30604
|
-
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) =>
|
|
30813
|
+
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync58(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
|
|
30605
30814
|
routeName = a.route;
|
|
30606
30815
|
addPath = a.path;
|
|
30607
30816
|
addName = a.name;
|
|
@@ -30631,7 +30840,7 @@ ${cu.tail.trimEnd()}
|
|
|
30631
30840
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
|
|
30632
30841
|
if (sub === "list" || sub === "add") {
|
|
30633
30842
|
const liveRoute = cfg.routes.find((r) => r.route === routeName);
|
|
30634
|
-
if (liveRoute?.resolved?.reposModelId &&
|
|
30843
|
+
if (liveRoute?.resolved?.reposModelId && existsSync58(resolvedFile) && !dryRun) {
|
|
30635
30844
|
try {
|
|
30636
30845
|
await hydrateApiKeys([liveRoute]);
|
|
30637
30846
|
persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
|
|
@@ -30640,16 +30849,16 @@ ${cu.tail.trimEnd()}
|
|
|
30640
30849
|
}
|
|
30641
30850
|
}
|
|
30642
30851
|
let resolvedRemotes;
|
|
30643
|
-
if (
|
|
30852
|
+
if (existsSync58(resolvedFile)) {
|
|
30644
30853
|
try {
|
|
30645
|
-
resolvedRemotes = JSON.parse(
|
|
30854
|
+
resolvedRemotes = JSON.parse(readFileSync53(resolvedFile, "utf8"));
|
|
30646
30855
|
} catch {
|
|
30647
30856
|
}
|
|
30648
30857
|
}
|
|
30649
30858
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
30650
30859
|
const text2 = configText;
|
|
30651
30860
|
const base = dirname37(cfg.configFile);
|
|
30652
|
-
const isCheckout = (d) =>
|
|
30861
|
+
const isCheckout = (d) => existsSync58(`${d}/.git`);
|
|
30653
30862
|
try {
|
|
30654
30863
|
if (sub === "list") {
|
|
30655
30864
|
if (flag("json")) {
|
|
@@ -30659,12 +30868,12 @@ ${cu.tail.trimEnd()}
|
|
|
30659
30868
|
base,
|
|
30660
30869
|
resolved: resolvedRemotes,
|
|
30661
30870
|
originOf,
|
|
30662
|
-
exists: (d) =>
|
|
30871
|
+
exists: (d) => existsSync58(d),
|
|
30663
30872
|
isCheckout,
|
|
30664
30873
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
30665
30874
|
try {
|
|
30666
30875
|
const path = resolvePath(d, f);
|
|
30667
|
-
return Object.keys(parseRepoConfig(
|
|
30876
|
+
return Object.keys(parseRepoConfig(readFileSync53(path, "utf8"), path).hooks).length > 0;
|
|
30668
30877
|
} catch {
|
|
30669
30878
|
return false;
|
|
30670
30879
|
}
|
|
@@ -30681,7 +30890,7 @@ ${cu.tail.trimEnd()}
|
|
|
30681
30890
|
for (const r of repos) {
|
|
30682
30891
|
const origin2 = originOf(r.dir);
|
|
30683
30892
|
const row = matchRepoName(origin2, resolvedRemotes);
|
|
30684
|
-
const note = !
|
|
30893
|
+
const note = !existsSync58(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
|
|
30685
30894
|
process.stdout.write(`${r.name} ${r.dir} ${note}
|
|
30686
30895
|
`);
|
|
30687
30896
|
}
|
|
@@ -30693,9 +30902,9 @@ ${cu.tail.trimEnd()}
|
|
|
30693
30902
|
` : `${human}
|
|
30694
30903
|
`);
|
|
30695
30904
|
const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
|
|
30696
|
-
if (
|
|
30905
|
+
if (existsSync58(plan2.target) && (existsSync58(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
|
|
30697
30906
|
throw new ReposError(
|
|
30698
|
-
|
|
30907
|
+
existsSync58(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
|
|
30699
30908
|
);
|
|
30700
30909
|
}
|
|
30701
30910
|
if (dryRun) {
|
|
@@ -30720,7 +30929,7 @@ ${cu.tail.trimEnd()}
|
|
|
30720
30929
|
break;
|
|
30721
30930
|
}
|
|
30722
30931
|
const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
|
|
30723
|
-
const top =
|
|
30932
|
+
const top = existsSync58(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
|
|
30724
30933
|
if (!top) throw new ReposError(`${target} is not a git checkout`);
|
|
30725
30934
|
const origin = originOf(top);
|
|
30726
30935
|
const plan = planRepoAdd({
|
|
@@ -30772,8 +30981,8 @@ ${cu.tail.trimEnd()}
|
|
|
30772
30981
|
const created = await rowTracker.createRepoRow(rowPayload);
|
|
30773
30982
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
30774
30983
|
`);
|
|
30775
|
-
if (
|
|
30776
|
-
const raw = JSON.parse(
|
|
30984
|
+
if (existsSync58(resolvedFile)) {
|
|
30985
|
+
const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
|
|
30777
30986
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
30778
30987
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
30779
30988
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
@@ -31155,7 +31364,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
31155
31364
|
process.exit(2);
|
|
31156
31365
|
}
|
|
31157
31366
|
if (found.shipNameAdopted && !dryRun) {
|
|
31158
|
-
writeFileSync42(cfg.configFile, setShipNameInYaml(
|
|
31367
|
+
writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync53(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
31159
31368
|
cfg.ship.name = found.shipNameAdopted;
|
|
31160
31369
|
}
|
|
31161
31370
|
if (found.shipRow) {
|
|
@@ -31198,10 +31407,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
31198
31407
|
}
|
|
31199
31408
|
}
|
|
31200
31409
|
let previous;
|
|
31201
|
-
const hadPreviousFile =
|
|
31410
|
+
const hadPreviousFile = existsSync58(resolvedPath);
|
|
31202
31411
|
if (hadPreviousFile) {
|
|
31203
31412
|
try {
|
|
31204
|
-
previous = JSON.parse(
|
|
31413
|
+
previous = JSON.parse(readFileSync53(resolvedPath, "utf8"));
|
|
31205
31414
|
} catch {
|
|
31206
31415
|
}
|
|
31207
31416
|
}
|
|
@@ -32096,10 +32305,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32096
32305
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
32097
32306
|
prepare: async (path) => {
|
|
32098
32307
|
for (const f of repoWt.config.worktrees.copy) {
|
|
32099
|
-
const src =
|
|
32100
|
-
if (!
|
|
32101
|
-
mkdirSync42(dirOf2(
|
|
32102
|
-
copyFileSync2(src,
|
|
32308
|
+
const src = join61(repoWt.dir, f);
|
|
32309
|
+
if (!existsSync58(src) || existsSync58(join61(path, f))) continue;
|
|
32310
|
+
mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
|
|
32311
|
+
copyFileSync2(src, join61(path, f));
|
|
32103
32312
|
}
|
|
32104
32313
|
const setup = repoWt.config.hooks.setup;
|
|
32105
32314
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -32325,7 +32534,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32325
32534
|
const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
|
|
32326
32535
|
const resumed = await runPeriscopeResume({
|
|
32327
32536
|
find: async () => hit && { row: hit.row, tag: hit.tag },
|
|
32328
|
-
worktreeExists: (p) =>
|
|
32537
|
+
worktreeExists: (p) => existsSync58(p),
|
|
32329
32538
|
prepareDropFile,
|
|
32330
32539
|
startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
|
|
32331
32540
|
relay: hit && previewRelayFor(hit.route) && {
|
|
@@ -32428,10 +32637,10 @@ ${where.join("\n")}`);
|
|
|
32428
32637
|
},
|
|
32429
32638
|
prepare: async (path) => {
|
|
32430
32639
|
for (const f of repoP.config.worktrees.copy) {
|
|
32431
|
-
const src =
|
|
32432
|
-
if (!
|
|
32433
|
-
mkdirSync42(dirOf2(
|
|
32434
|
-
copyFileSync2(src,
|
|
32640
|
+
const src = join61(repoP.dir, f);
|
|
32641
|
+
if (!existsSync58(src)) continue;
|
|
32642
|
+
mkdirSync42(dirOf2(join61(path, f)), { recursive: true });
|
|
32643
|
+
copyFileSync2(src, join61(path, f));
|
|
32435
32644
|
}
|
|
32436
32645
|
const setup = repoP.config.hooks.setup;
|
|
32437
32646
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -32743,7 +32952,7 @@ ${where.join("\n")}`);
|
|
|
32743
32952
|
};
|
|
32744
32953
|
const droppedRoutes = [];
|
|
32745
32954
|
try {
|
|
32746
|
-
const rawCfg = parseYaml3(
|
|
32955
|
+
const rawCfg = parseYaml3(readFileSync53(cfg.configFile, "utf8"));
|
|
32747
32956
|
for (const r of rawCfg?.routes ?? []) {
|
|
32748
32957
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
32749
32958
|
try {
|
|
@@ -32873,7 +33082,7 @@ ${where.join("\n")}`);
|
|
|
32873
33082
|
}
|
|
32874
33083
|
case "log": {
|
|
32875
33084
|
try {
|
|
32876
|
-
const text2 =
|
|
33085
|
+
const text2 = readFileSync53(cfg.ship.logFile, "utf8").split("\n");
|
|
32877
33086
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
32878
33087
|
`);
|
|
32879
33088
|
} catch {
|
|
@@ -32896,7 +33105,7 @@ ${where.join("\n")}`);
|
|
|
32896
33105
|
};
|
|
32897
33106
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
32898
33107
|
const tracker = new Tracker(route2, cfg.ship);
|
|
32899
|
-
const configText =
|
|
33108
|
+
const configText = readFileSync53(cfg.configFile, "utf8");
|
|
32900
33109
|
const cfgBase = dirname37(cfg.configFile);
|
|
32901
33110
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
32902
33111
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -32933,29 +33142,29 @@ ${where.join("\n")}`);
|
|
|
32933
33142
|
}
|
|
32934
33143
|
if (row) {
|
|
32935
33144
|
await tracker.deleteRepoRow(row.id);
|
|
32936
|
-
if (
|
|
32937
|
-
const raw = JSON.parse(
|
|
33145
|
+
if (existsSync58(resolvedFile)) {
|
|
33146
|
+
const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
|
|
32938
33147
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
32939
33148
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
32940
33149
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
32941
33150
|
`);
|
|
32942
33151
|
}
|
|
32943
33152
|
}
|
|
32944
|
-
if (
|
|
33153
|
+
if (existsSync58(join61(dir, ".git")) && basename16(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
|
|
32945
33154
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
32946
33155
|
break;
|
|
32947
33156
|
}
|
|
32948
33157
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
32949
|
-
const fresh = !
|
|
32950
|
-
if (
|
|
33158
|
+
const fresh = !existsSync58(join61(dir, ".git"));
|
|
33159
|
+
if (existsSync58(dir) && fresh && readdirSync20(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
32951
33160
|
if (dryRun) {
|
|
32952
33161
|
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`);
|
|
32953
33162
|
break;
|
|
32954
33163
|
}
|
|
32955
33164
|
if (fresh) {
|
|
32956
33165
|
mkdirSync42(dir, { recursive: true });
|
|
32957
|
-
writeFileSync42(
|
|
32958
|
-
writeFileSync42(
|
|
33166
|
+
writeFileSync42(join61(dir, "README.md"), SAMPLE_README);
|
|
33167
|
+
writeFileSync42(join61(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
32959
33168
|
const g = (...a) => {
|
|
32960
33169
|
const r = spawnSync13("git", a, { cwd: dir, encoding: "utf8" });
|
|
32961
33170
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -32973,8 +33182,8 @@ ${where.join("\n")}`);
|
|
|
32973
33182
|
spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
|
|
32974
33183
|
});
|
|
32975
33184
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
32976
|
-
if (
|
|
32977
|
-
const raw = JSON.parse(
|
|
33185
|
+
if (existsSync58(resolvedFile)) {
|
|
33186
|
+
const raw = JSON.parse(readFileSync53(resolvedFile, "utf8"));
|
|
32978
33187
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
32979
33188
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
32980
33189
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
@@ -33352,7 +33561,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
33352
33561
|
plan,
|
|
33353
33562
|
label,
|
|
33354
33563
|
uid: process.getuid?.() ?? 0,
|
|
33355
|
-
system: plan.mechanism === "systemd" &&
|
|
33564
|
+
system: plan.mechanism === "systemd" && existsSync58(systemUnitPathFor(label)),
|
|
33356
33565
|
stamp: readDaemonStamp(cfg.ship.stateDir)
|
|
33357
33566
|
});
|
|
33358
33567
|
})();
|
|
@@ -33368,7 +33577,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
33368
33577
|
}
|
|
33369
33578
|
for (const r of repos) {
|
|
33370
33579
|
const remote = r.config.branch.remote;
|
|
33371
|
-
if (
|
|
33580
|
+
if (existsSync58(r.dir)) {
|
|
33372
33581
|
pushAuth.push({
|
|
33373
33582
|
route: c.route,
|
|
33374
33583
|
repo: r.name,
|
|
@@ -33445,12 +33654,13 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
33445
33654
|
}
|
|
33446
33655
|
}
|
|
33447
33656
|
for (const message of roleCapWarnings(cfg.ship)) problems.push({ severity: "note", kind: "role_cap_above_ship_cap", message });
|
|
33657
|
+
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" });
|
|
33448
33658
|
if (daemonLiveness) {
|
|
33449
33659
|
const dp = daemonProblem(daemonLiveness, route2.route);
|
|
33450
33660
|
if (dp) problems.push(dp);
|
|
33451
33661
|
else passed++;
|
|
33452
33662
|
}
|
|
33453
|
-
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null,
|
|
33663
|
+
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync58, userInfo2().username);
|
|
33454
33664
|
if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
|
|
33455
33665
|
if (!flag("offline")) {
|
|
33456
33666
|
const shipKind = await doctorShipKind(route2, cfg.ship);
|
|
@@ -33497,6 +33707,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
33497
33707
|
`
|
|
33498
33708
|
);
|
|
33499
33709
|
for (const w of roleCapWarnings(cfg.ship)) process.stdout.write(`role concurrency: WARN ${w}
|
|
33710
|
+
`);
|
|
33711
|
+
for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) process.stdout.write(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
|
|
33500
33712
|
`);
|
|
33501
33713
|
for (const t of rejectedTunnels(cfg.ship.stateDir)) process.stdout.write(`relay tunnel: ATTENTION ${tunnelRejectedMessage(t.workspaceId, t.quickExits)}
|
|
33502
33714
|
`);
|
|
@@ -33515,7 +33727,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
33515
33727
|
}
|
|
33516
33728
|
try {
|
|
33517
33729
|
const evFile = eventFileFor(cfg.ship.stateDir);
|
|
33518
|
-
const evSize =
|
|
33730
|
+
const evSize = existsSync58(evFile) ? statSync17(evFile).size : 0;
|
|
33519
33731
|
process.stdout.write(
|
|
33520
33732
|
evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
|
|
33521
33733
|
` : "events log: ok\n"
|
|
@@ -33526,7 +33738,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
33526
33738
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
33527
33739
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
33528
33740
|
try {
|
|
33529
|
-
return
|
|
33741
|
+
return readFileSync53(p, "utf8");
|
|
33530
33742
|
} catch {
|
|
33531
33743
|
return null;
|
|
33532
33744
|
}
|
|
@@ -33541,7 +33753,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
33541
33753
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
33542
33754
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
33543
33755
|
try {
|
|
33544
|
-
return
|
|
33756
|
+
return readFileSync53(p, "utf8");
|
|
33545
33757
|
} catch {
|
|
33546
33758
|
return null;
|
|
33547
33759
|
}
|
|
@@ -33555,7 +33767,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
33555
33767
|
if (host === "linux" && detectSystemd()) {
|
|
33556
33768
|
const ctl = planDaemonControl(CREW_HOME, host, true);
|
|
33557
33769
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
|
|
33558
|
-
if (ctl.statusCommand && unitPlan.unitPaths.some((p) =>
|
|
33770
|
+
if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync58(p))) {
|
|
33559
33771
|
const st = spawnSync13(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
33560
33772
|
if (!st.error && st.status !== 0) {
|
|
33561
33773
|
process.stdout.write("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#c026d3"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">Ds</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#2563eb"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">D</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#7c3aed"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">P</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#059669"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">Q</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#d97706"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">T</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#c026d3"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">Ds</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#2563eb"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">D</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#7c3aed"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">P</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#059669"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">Q</text></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128"><circle cx="64" cy="64" r="64" fill="#d97706"/><text x="64" y="64" text-anchor="middle" dominant-baseline="central" font-family="Helvetica, Arial, sans-serif" font-size="56" font-weight="600" fill="#ffffff">T</text></svg>
|