@tablation/crew 0.145.0 → 0.146.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 +457 -360
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7001,16 +7001,16 @@ function envForRepository(entries, repo) {
|
|
|
7001
7001
|
}
|
|
7002
7002
|
|
|
7003
7003
|
// src/interrupted.ts
|
|
7004
|
-
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as
|
|
7005
|
-
import { join as
|
|
7004
|
+
import { existsSync as existsSync30, readdirSync as readdirSync10, readFileSync as readFileSync32 } from "fs";
|
|
7005
|
+
import { join as join34 } from "path";
|
|
7006
7006
|
|
|
7007
7007
|
// src/agent.ts
|
|
7008
7008
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
7009
|
-
import { readFileSync as
|
|
7009
|
+
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";
|
|
7010
7010
|
import { StringDecoder } from "string_decoder";
|
|
7011
7011
|
import { finished } from "stream/promises";
|
|
7012
|
-
import { join as
|
|
7013
|
-
import { createHash as createHash6, randomUUID } from "crypto";
|
|
7012
|
+
import { join as join33, dirname as dirname16, basename as basename9 } from "path";
|
|
7013
|
+
import { createHash as createHash6, randomUUID as randomUUID2 } from "crypto";
|
|
7014
7014
|
|
|
7015
7015
|
// src/state.ts
|
|
7016
7016
|
import { readFileSync as readFileSync21, writeFileSync as writeFileSync16, existsSync as existsSync20, mkdirSync as mkdirSync15, rmSync as rmSync11, statSync as statSync7, readdirSync as readdirSync6 } from "fs";
|
|
@@ -11744,12 +11744,71 @@ var HandoffTranscriptTracker = class {
|
|
|
11744
11744
|
}
|
|
11745
11745
|
};
|
|
11746
11746
|
|
|
11747
|
+
// src/seat-notes.ts
|
|
11748
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync19, readFileSync as readFileSync26, renameSync as renameSync4, rmSync as rmSync15, writeFileSync as writeFileSync20 } from "fs";
|
|
11749
|
+
import { randomUUID } from "crypto";
|
|
11750
|
+
import { join as join28 } from "path";
|
|
11751
|
+
var fileFor2 = (stateDir, role) => join28(stateDir, "seat-notes", `${role}.jsonl`);
|
|
11752
|
+
var sameTicket = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
11753
|
+
function readAll(stateDir, role) {
|
|
11754
|
+
let raw;
|
|
11755
|
+
try {
|
|
11756
|
+
raw = readFileSync26(fileFor2(stateDir, role), "utf8");
|
|
11757
|
+
} catch {
|
|
11758
|
+
return [];
|
|
11759
|
+
}
|
|
11760
|
+
const notes = [];
|
|
11761
|
+
for (const line of raw.split("\n")) {
|
|
11762
|
+
if (!line.trim()) continue;
|
|
11763
|
+
try {
|
|
11764
|
+
notes.push(JSON.parse(line));
|
|
11765
|
+
} catch {
|
|
11766
|
+
}
|
|
11767
|
+
}
|
|
11768
|
+
return notes;
|
|
11769
|
+
}
|
|
11770
|
+
function addSeatNote(stateDir, note, now = /* @__PURE__ */ new Date()) {
|
|
11771
|
+
const full = { id: randomUUID(), createdAt: now.toISOString(), ...note };
|
|
11772
|
+
mkdirSync19(join28(stateDir, "seat-notes"), { recursive: true });
|
|
11773
|
+
appendFileSync3(fileFor2(stateDir, note.role), `${JSON.stringify(full)}
|
|
11774
|
+
`);
|
|
11775
|
+
return full;
|
|
11776
|
+
}
|
|
11777
|
+
function waitingSeatNotes(stateDir, role, ticket) {
|
|
11778
|
+
return readAll(stateDir, role).filter((n) => !n.ticket || ticket !== void 0 && sameTicket(n.ticket, ticket));
|
|
11779
|
+
}
|
|
11780
|
+
function consumeSeatNotes(stateDir, role, taken) {
|
|
11781
|
+
if (taken.length === 0) return;
|
|
11782
|
+
const ids = new Set(taken.map((n) => n.id));
|
|
11783
|
+
const keep = readAll(stateDir, role).filter((n) => !ids.has(n.id));
|
|
11784
|
+
const file = fileFor2(stateDir, role);
|
|
11785
|
+
if (keep.length === 0) {
|
|
11786
|
+
rmSync15(file, { force: true });
|
|
11787
|
+
return;
|
|
11788
|
+
}
|
|
11789
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
11790
|
+
writeFileSync20(tmp, keep.map((n) => `${JSON.stringify(n)}
|
|
11791
|
+
`).join(""));
|
|
11792
|
+
renameSync4(tmp, file);
|
|
11793
|
+
}
|
|
11794
|
+
function seatNotesSection(notes) {
|
|
11795
|
+
if (notes.length === 0) return "";
|
|
11796
|
+
const lines2 = notes.map((n) => `- ${n.createdAt} \u2014 ${n.author ?? "the operator"}: ${n.text.replace(/\n/g, "\n ")}`);
|
|
11797
|
+
return [
|
|
11798
|
+
"## Notes left for this seat",
|
|
11799
|
+
"",
|
|
11800
|
+
"These were left while no run was live. They come from the operator and carry the operator's authority; acknowledge each in your first progress comment.",
|
|
11801
|
+
"",
|
|
11802
|
+
...lines2
|
|
11803
|
+
].join("\n");
|
|
11804
|
+
}
|
|
11805
|
+
|
|
11747
11806
|
// src/sandbox-image.ts
|
|
11748
11807
|
import { createHash as createHash4 } from "crypto";
|
|
11749
11808
|
import { spawn as spawn4 } from "child_process";
|
|
11750
11809
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
11751
|
-
import { existsSync as existsSync26, mkdirSync as
|
|
11752
|
-
import { dirname as dirname14, join as
|
|
11810
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync20, readFileSync as readFileSync27, renameSync as renameSync5, writeFileSync as writeFileSync21, rmSync as rmSync16, statSync as statSync8 } from "fs";
|
|
11811
|
+
import { dirname as dirname14, join as join29 } from "path";
|
|
11753
11812
|
import { fileURLToPath } from "url";
|
|
11754
11813
|
import { tmpdir as tmpdir3 } from "os";
|
|
11755
11814
|
var SANDBOX_BASE_IMAGE = "nvcr.io/nvidia/base/ubuntu:24.04";
|
|
@@ -11765,8 +11824,8 @@ var CREW_PREFIX = "/opt/crew";
|
|
|
11765
11824
|
var SANDBOX_BRIDGE_PATH = `${CREW_PREFIX}/bin/intel-bridge`;
|
|
11766
11825
|
function readBridgeBundle() {
|
|
11767
11826
|
const here = dirname14(fileURLToPath(import.meta.url));
|
|
11768
|
-
for (const p of [
|
|
11769
|
-
if (existsSync26(p)) return
|
|
11827
|
+
for (const p of [join29(here, "sandbox-intel-bridge.cjs"), join29(here, "..", "dist", "sandbox-intel-bridge.cjs")]) {
|
|
11828
|
+
if (existsSync26(p)) return readFileSync27(p, "utf8");
|
|
11770
11829
|
}
|
|
11771
11830
|
return void 0;
|
|
11772
11831
|
}
|
|
@@ -11850,7 +11909,7 @@ var HOST_CA_BUNDLES = ["/etc/ssl/certs/ca-certificates.crt", "/etc/pki/tls/certs
|
|
|
11850
11909
|
function readHostCaBundle(paths = HOST_CA_BUNDLES) {
|
|
11851
11910
|
for (const path of paths) {
|
|
11852
11911
|
try {
|
|
11853
|
-
return
|
|
11912
|
+
return readFileSync27(path, "utf8");
|
|
11854
11913
|
} catch {
|
|
11855
11914
|
}
|
|
11856
11915
|
}
|
|
@@ -11941,21 +12000,21 @@ function planSandbox(repo, decl, warm = {}, bridge) {
|
|
|
11941
12000
|
}
|
|
11942
12001
|
var SHIP_SANDBOX_KEY = "@ship";
|
|
11943
12002
|
var shipSandboxRef = () => ({ name: SHIP_SANDBOX_KEY, decl: { packages: [], setup: [] } });
|
|
11944
|
-
var sandboxStatePath = (stateDir) =>
|
|
12003
|
+
var sandboxStatePath = (stateDir) => join29(stateDir, "sandbox-images.json");
|
|
11945
12004
|
function readSandboxState(stateDir) {
|
|
11946
12005
|
try {
|
|
11947
|
-
const v = JSON.parse(
|
|
12006
|
+
const v = JSON.parse(readFileSync27(sandboxStatePath(stateDir), "utf8"));
|
|
11948
12007
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
11949
12008
|
} catch {
|
|
11950
12009
|
return {};
|
|
11951
12010
|
}
|
|
11952
12011
|
}
|
|
11953
12012
|
function writeSandboxState(stateDir, state) {
|
|
11954
|
-
|
|
12013
|
+
mkdirSync20(stateDir, { recursive: true });
|
|
11955
12014
|
const file = sandboxStatePath(stateDir);
|
|
11956
|
-
|
|
12015
|
+
writeFileSync21(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
11957
12016
|
`);
|
|
11958
|
-
|
|
12017
|
+
renameSync5(`${file}.tmp`, file);
|
|
11959
12018
|
}
|
|
11960
12019
|
function sandboxImageFor(state, repo) {
|
|
11961
12020
|
return state[repo]?.tags[0]?.tag ?? null;
|
|
@@ -11991,7 +12050,7 @@ var spawnBuildRunner = (engine = "docker") => (args, logPath) => new Promise((re
|
|
|
11991
12050
|
child.stdout.on("data", (d) => chunks.push(d));
|
|
11992
12051
|
child.stderr.on("data", (d) => chunks.push(d));
|
|
11993
12052
|
const done = (code, extra = "") => {
|
|
11994
|
-
|
|
12053
|
+
writeFileSync21(logPath, `$ ${engine} ${args.join(" ")}
|
|
11995
12054
|
${Buffer.concat(chunks).toString("utf8")}${extra}`, { flag: "a" });
|
|
11996
12055
|
resolve8(code);
|
|
11997
12056
|
};
|
|
@@ -12013,7 +12072,7 @@ var engineRemoveImage = (engine = "docker", exec = realExec) => (tag) => {
|
|
|
12013
12072
|
} catch {
|
|
12014
12073
|
}
|
|
12015
12074
|
};
|
|
12016
|
-
var sandboxLogDir = (stateDir) =>
|
|
12075
|
+
var sandboxLogDir = (stateDir) => join29(stateDir, "sandbox-logs");
|
|
12017
12076
|
async function buildSandboxImage(plan, deps) {
|
|
12018
12077
|
const now = deps.now ?? (() => /* @__PURE__ */ new Date());
|
|
12019
12078
|
const state = readSandboxState(deps.stateDir);
|
|
@@ -12022,21 +12081,21 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12022
12081
|
return { kind: "reused", tag: plan.tag };
|
|
12023
12082
|
}
|
|
12024
12083
|
const logDir = sandboxLogDir(deps.stateDir);
|
|
12025
|
-
|
|
12026
|
-
const logPath =
|
|
12084
|
+
mkdirSync20(logDir, { recursive: true });
|
|
12085
|
+
const logPath = join29(logDir, `${slug(plan.repo)}-${now().toISOString().replace(/[:.]/g, "-")}.log`);
|
|
12027
12086
|
const builtLayers = [];
|
|
12028
12087
|
for (const layer of plan.layers) {
|
|
12029
12088
|
if (deps.hasImage(layer.tag)) continue;
|
|
12030
|
-
const ctx =
|
|
12031
|
-
|
|
12089
|
+
const ctx = join29(tmpdir3(), `crew-sandbox-${hash([layer.tag, process.pid, Date.now()])}`);
|
|
12090
|
+
mkdirSync20(ctx, { recursive: true });
|
|
12032
12091
|
try {
|
|
12033
|
-
|
|
12092
|
+
writeFileSync21(join29(ctx, "Dockerfile"), layer.dockerfile);
|
|
12034
12093
|
for (const [name, content] of Object.entries(layer.files)) {
|
|
12035
|
-
|
|
12036
|
-
|
|
12094
|
+
mkdirSync20(dirname14(join29(ctx, name)), { recursive: true });
|
|
12095
|
+
writeFileSync21(join29(ctx, name), content);
|
|
12037
12096
|
}
|
|
12038
|
-
if (layer.caBundleFile)
|
|
12039
|
-
const code = await deps.run(["build", "--tag", layer.tag, "--file",
|
|
12097
|
+
if (layer.caBundleFile) writeFileSync21(join29(ctx, layer.caBundleFile), (deps.caBundle ?? readHostCaBundle)());
|
|
12098
|
+
const code = await deps.run(["build", "--tag", layer.tag, "--file", join29(ctx, "Dockerfile"), ctx], logPath);
|
|
12040
12099
|
if (code === BUILD_INTERRUPTED) return { kind: "interrupted", tag: plan.tag };
|
|
12041
12100
|
if (code !== 0) {
|
|
12042
12101
|
state[plan.repo] = { ...entry, failure: { tag: plan.tag, at: now().toISOString(), logPath } };
|
|
@@ -12045,7 +12104,7 @@ async function buildSandboxImage(plan, deps) {
|
|
|
12045
12104
|
}
|
|
12046
12105
|
builtLayers.push(layer.name);
|
|
12047
12106
|
} finally {
|
|
12048
|
-
|
|
12107
|
+
rmSync16(ctx, { recursive: true, force: true });
|
|
12049
12108
|
}
|
|
12050
12109
|
}
|
|
12051
12110
|
const tags = [{ tag: plan.tag, builtAt: now().toISOString(), claude: plan.claude }, ...entry.tags.filter((t) => t.tag !== plan.tag)];
|
|
@@ -12148,8 +12207,8 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
|
|
|
12148
12207
|
}
|
|
12149
12208
|
|
|
12150
12209
|
// src/skills.ts
|
|
12151
|
-
import { readFileSync as
|
|
12152
|
-
import { join as
|
|
12210
|
+
import { readFileSync as readFileSync30, readdirSync as readdirSync9, existsSync as existsSync28 } from "fs";
|
|
12211
|
+
import { join as join31 } from "path";
|
|
12153
12212
|
import { parse as parseYaml2 } from "yaml";
|
|
12154
12213
|
import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
|
|
12155
12214
|
|
|
@@ -12165,7 +12224,7 @@ ${additions}`;
|
|
|
12165
12224
|
}
|
|
12166
12225
|
|
|
12167
12226
|
// src/persona-file.ts
|
|
12168
|
-
import { readFileSync as
|
|
12227
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
12169
12228
|
import { parse as parseYaml } from "yaml";
|
|
12170
12229
|
function parsePersonaText(text2, path) {
|
|
12171
12230
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
|
|
@@ -12177,12 +12236,12 @@ function parsePersonaText(text2, path) {
|
|
|
12177
12236
|
return { body: match[2], ...typeof meta.chat_enabled === "boolean" ? { chatEnabled: meta.chat_enabled } : {} };
|
|
12178
12237
|
}
|
|
12179
12238
|
function readPersonaFile(path) {
|
|
12180
|
-
return parsePersonaText(
|
|
12239
|
+
return parsePersonaText(readFileSync28(path, "utf8"), path);
|
|
12181
12240
|
}
|
|
12182
12241
|
|
|
12183
12242
|
// src/agents.ts
|
|
12184
|
-
import { readFileSync as
|
|
12185
|
-
import { join as
|
|
12243
|
+
import { readFileSync as readFileSync29, existsSync as existsSync27 } from "fs";
|
|
12244
|
+
import { join as join30 } from "path";
|
|
12186
12245
|
import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
|
|
12187
12246
|
var PERSONA_NAME = {
|
|
12188
12247
|
dev: "Developer",
|
|
@@ -12196,16 +12255,16 @@ var CREW_AGENT_COLUMN = "agent_id";
|
|
|
12196
12255
|
var AgentsSyncError = class extends Error {
|
|
12197
12256
|
};
|
|
12198
12257
|
function personaDefaultPrompt(promptsDir, role) {
|
|
12199
|
-
const briefPath =
|
|
12258
|
+
const briefPath = join30(promptsDir, "personas", `lane-${role}.md`);
|
|
12200
12259
|
if (!existsSync27(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
|
|
12201
12260
|
const brief = readPersonaFile(briefPath).body;
|
|
12202
12261
|
if (SELF_CONTAINED_ROLES.has(role)) return brief;
|
|
12203
|
-
const commonPath =
|
|
12262
|
+
const commonPath = join30(promptsDir, "personas", "common.md");
|
|
12204
12263
|
if (!existsSync27(commonPath)) return brief;
|
|
12205
|
-
return `${
|
|
12264
|
+
return `${readFileSync29(commonPath, "utf8")}${brief}`;
|
|
12206
12265
|
}
|
|
12207
12266
|
function personaChatEnabled(promptsDir, role) {
|
|
12208
|
-
const briefPath =
|
|
12267
|
+
const briefPath = join30(promptsDir, "personas", `lane-${role}.md`);
|
|
12209
12268
|
return existsSync27(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
|
|
12210
12269
|
}
|
|
12211
12270
|
async function resolveAgentId(route2, role, opts) {
|
|
@@ -12676,7 +12735,7 @@ function describeCrewLink(o) {
|
|
|
12676
12735
|
var SkillSyncError = class extends Error {
|
|
12677
12736
|
};
|
|
12678
12737
|
function parseSkillFile(path) {
|
|
12679
|
-
const text2 =
|
|
12738
|
+
const text2 = readFileSync30(path, "utf8");
|
|
12680
12739
|
const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
|
|
12681
12740
|
if (!match) throw new SkillSyncError(`${path}: missing YAML frontmatter (expected a leading --- block)`);
|
|
12682
12741
|
const frontmatter = match[1];
|
|
@@ -12703,9 +12762,9 @@ function parseSkillFile(path) {
|
|
|
12703
12762
|
};
|
|
12704
12763
|
}
|
|
12705
12764
|
function listLocalSkills(promptsDir) {
|
|
12706
|
-
const dir =
|
|
12765
|
+
const dir = join31(promptsDir, "skills");
|
|
12707
12766
|
if (!existsSync28(dir)) return [];
|
|
12708
|
-
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(
|
|
12767
|
+
return readdirSync9(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join31(dir, f)));
|
|
12709
12768
|
}
|
|
12710
12769
|
function personaColumn(model) {
|
|
12711
12770
|
for (const c of ["persona_id", "persona"]) if (model.fields?.some((f) => f.columnName === c)) return c;
|
|
@@ -12939,10 +12998,10 @@ function skillMarkerWarnings(promptsDir, personaPrompts) {
|
|
|
12939
12998
|
|
|
12940
12999
|
// src/runner.ts
|
|
12941
13000
|
import { spawn as spawn5, execFile, execFileSync as execFileSync9 } from "child_process";
|
|
12942
|
-
import { mkdtempSync, mkdirSync as
|
|
13001
|
+
import { mkdtempSync, mkdirSync as mkdirSync21, writeFileSync as writeFileSync22, rmSync as rmSync17 } from "fs";
|
|
12943
13002
|
import { createHash as createHash5 } from "crypto";
|
|
12944
13003
|
import { tmpdir as tmpdir4 } from "os";
|
|
12945
|
-
import { basename as basename8, dirname as dirname15, join as
|
|
13004
|
+
import { basename as basename8, dirname as dirname15, join as join32 } from "path";
|
|
12946
13005
|
import { promisify } from "util";
|
|
12947
13006
|
|
|
12948
13007
|
// src/run-limit.ts
|
|
@@ -13093,8 +13152,8 @@ var SandboxRunner = class {
|
|
|
13093
13152
|
throw new Error(`cannot generate the sandbox policy: ${e.message}`);
|
|
13094
13153
|
}
|
|
13095
13154
|
policyFile = policyPathFor(plan.streamPath);
|
|
13096
|
-
|
|
13097
|
-
|
|
13155
|
+
mkdirSync21(dirname15(policyFile), { recursive: true });
|
|
13156
|
+
writeFileSync22(policyFile, generated.yaml, { mode: 384 });
|
|
13098
13157
|
}
|
|
13099
13158
|
const create2 = ["sandbox", "create", "--name", name, "--detach"];
|
|
13100
13159
|
if (policyFile) create2.push("--policy", policyFile);
|
|
@@ -13143,13 +13202,13 @@ var SandboxRunner = class {
|
|
|
13143
13202
|
const harness = cfg.agentBin ?? basename8(plan.bin);
|
|
13144
13203
|
const viaUpload = Buffer.byteLength(plan.prompt) > SANDBOX_STDIN_LIMIT;
|
|
13145
13204
|
if (viaUpload) {
|
|
13146
|
-
const tmp = mkdtempSync(
|
|
13205
|
+
const tmp = mkdtempSync(join32(tmpdir4(), "crew-prompt-"));
|
|
13147
13206
|
try {
|
|
13148
|
-
const file =
|
|
13149
|
-
|
|
13207
|
+
const file = join32(tmp, "prompt.txt");
|
|
13208
|
+
writeFileSync22(file, plan.prompt, { mode: 384 });
|
|
13150
13209
|
await this.os(["sandbox", "upload", name, file, SANDBOX_PROMPT_PATH]);
|
|
13151
13210
|
} finally {
|
|
13152
|
-
|
|
13211
|
+
rmSync17(tmp, { recursive: true, force: true });
|
|
13153
13212
|
}
|
|
13154
13213
|
}
|
|
13155
13214
|
const withStubs = `${sandboxEnvExports()}PATH=${shQuote2(SANDBOX_STUB_DIR)}:"$PATH"; export PATH; `;
|
|
@@ -13344,7 +13403,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
|
|
|
13344
13403
|
function streamShowsAllowanceRefusal(streamPath) {
|
|
13345
13404
|
let raw;
|
|
13346
13405
|
try {
|
|
13347
|
-
raw =
|
|
13406
|
+
raw = readFileSync31(streamPath, "utf8");
|
|
13348
13407
|
} catch {
|
|
13349
13408
|
return false;
|
|
13350
13409
|
}
|
|
@@ -13367,7 +13426,7 @@ function streamShowsAllowanceRefusal(streamPath) {
|
|
|
13367
13426
|
}
|
|
13368
13427
|
return false;
|
|
13369
13428
|
}
|
|
13370
|
-
var digestPathFor = (stateDir, routeLabel, role, runId) =>
|
|
13429
|
+
var digestPathFor = (stateDir, routeLabel, role, runId) => join33(stateDir, `digest-${routeLabel}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
13371
13430
|
function codeBridgeFor(o, harness) {
|
|
13372
13431
|
if (!o.ticket) return void 0;
|
|
13373
13432
|
const number = /(\d+)$/.exec(o.ticket)?.[1];
|
|
@@ -13407,20 +13466,20 @@ function codeBridgeFor(o, harness) {
|
|
|
13407
13466
|
bridge.settingsFile = `${SANDBOX_INTEL_DIR}/gemini-settings.json`;
|
|
13408
13467
|
bridge.files = [{ path: bridge.settingsFile, content: text2 }];
|
|
13409
13468
|
} else {
|
|
13410
|
-
const file =
|
|
13411
|
-
|
|
13412
|
-
|
|
13469
|
+
const file = join33(intelDir(o.stateDir, o.route.route, number), "gemini-settings.json");
|
|
13470
|
+
mkdirSync22(dirname16(file), { recursive: true });
|
|
13471
|
+
writeFileSync23(file, text2);
|
|
13413
13472
|
bridge.settingsFile = file;
|
|
13414
13473
|
}
|
|
13415
13474
|
}
|
|
13416
13475
|
return bridge;
|
|
13417
13476
|
}
|
|
13418
13477
|
function planAgentRun(o) {
|
|
13419
|
-
const briefPath =
|
|
13478
|
+
const briefPath = join33(o.route.promptsDir, "personas", `lane-${o.role}.md`);
|
|
13420
13479
|
if (!existsSync29(briefPath)) {
|
|
13421
13480
|
throw new AgentError(`no brief at ${briefPath} \u2014 refusing to run an unscoped session`);
|
|
13422
13481
|
}
|
|
13423
|
-
const commonPath =
|
|
13482
|
+
const commonPath = join33(o.route.promptsDir, "personas", "common.md");
|
|
13424
13483
|
const usesCommon = !SELF_CONTAINED_ROLES.has(o.role) && existsSync29(commonPath);
|
|
13425
13484
|
const now = o.now ?? (() => Date.now());
|
|
13426
13485
|
const routeLabel = routeSlug(o.route.route);
|
|
@@ -13430,9 +13489,9 @@ function planAgentRun(o) {
|
|
|
13430
13489
|
let ageSeconds;
|
|
13431
13490
|
if (existsSync29(digestPath2)) {
|
|
13432
13491
|
ageSeconds = Math.floor((now() - statSync9(digestPath2).mtimeMs) / 1e3);
|
|
13433
|
-
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest =
|
|
13492
|
+
if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync31(digestPath2, "utf8");
|
|
13434
13493
|
}
|
|
13435
|
-
const common = usesCommon ?
|
|
13494
|
+
const common = usesCommon ? readFileSync31(commonPath, "utf8") : "";
|
|
13436
13495
|
const brief = readPersonaFile(briefPath).body;
|
|
13437
13496
|
const effectiveCommon = o.divergedPrompt ? "" : common;
|
|
13438
13497
|
const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
|
|
@@ -13456,7 +13515,7 @@ function planAgentRun(o) {
|
|
|
13456
13515
|
digest
|
|
13457
13516
|
});
|
|
13458
13517
|
const promptSha = createHash6("sha256").update(expanded.text).digest("hex");
|
|
13459
|
-
const streamsDir =
|
|
13518
|
+
const streamsDir = join33(o.stateDir, "streams");
|
|
13460
13519
|
const base = `${routeLabel}-${o.role}-${o.cycle}${o.runId ? `-${o.runId}` : ""}`;
|
|
13461
13520
|
const seat = resolveSeat(o.ship, o.route, o.role, o.agentPersona ?? (o.agentModel ? { model: o.agentModel } : {}), o.repo);
|
|
13462
13521
|
const { model } = seat;
|
|
@@ -13469,7 +13528,7 @@ function planAgentRun(o) {
|
|
|
13469
13528
|
if (!o.route.resolved) {
|
|
13470
13529
|
throw new WorkspaceAuthRefused(`${o.role}: toolchain ${toolchain.name} has auth: workspace, but route ${o.route.route} is not connected (run \`crew connect\`)`);
|
|
13471
13530
|
}
|
|
13472
|
-
workspaceRunId = o.runId ??
|
|
13531
|
+
workspaceRunId = o.runId ?? randomUUID2();
|
|
13473
13532
|
toolchain = { ...toolchain, inference: { baseUrl: inferenceBaseUrl(o.route.baseUrl, o.route.resolved.workspaceId), token: o.apiKey, ticket: o.ticket, runId: workspaceRunId } };
|
|
13474
13533
|
}
|
|
13475
13534
|
const adapter = adapterFor(toolchain.harness);
|
|
@@ -13567,8 +13626,8 @@ function planAgentRun(o) {
|
|
|
13567
13626
|
digestAttached: digest !== void 0,
|
|
13568
13627
|
digestAgeSeconds: ageSeconds,
|
|
13569
13628
|
model,
|
|
13570
|
-
streamPath:
|
|
13571
|
-
eventsPath:
|
|
13629
|
+
streamPath: join33(streamsDir, `${base}.jsonl`),
|
|
13630
|
+
eventsPath: join33(streamsDir, `${base}.events.jsonl`),
|
|
13572
13631
|
ticket: o.ticket,
|
|
13573
13632
|
ticketRecordId: o.ticketRecordId ?? null,
|
|
13574
13633
|
repo: o.repo ?? null,
|
|
@@ -13601,14 +13660,14 @@ function updateSidecar(streamPath, patch2) {
|
|
|
13601
13660
|
const sc = readRunSidecar(streamPath);
|
|
13602
13661
|
if (!sc) return;
|
|
13603
13662
|
try {
|
|
13604
|
-
|
|
13663
|
+
writeFileSync23(pidPathFor(streamPath), JSON.stringify({ ...sc, ...patch2 }));
|
|
13605
13664
|
} catch {
|
|
13606
13665
|
}
|
|
13607
13666
|
}
|
|
13608
13667
|
var pidPathFor = (streamPath) => `${streamPath}.pid`;
|
|
13609
13668
|
function readRunSidecar(streamPath) {
|
|
13610
13669
|
try {
|
|
13611
|
-
const sc = JSON.parse(
|
|
13670
|
+
const sc = JSON.parse(readFileSync31(pidPathFor(streamPath), "utf8"));
|
|
13612
13671
|
return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
|
|
13613
13672
|
} catch {
|
|
13614
13673
|
return null;
|
|
@@ -13656,7 +13715,7 @@ async function killForDeadline(kill, pid, emit, role, ticket, spawnedAt, limitMi
|
|
|
13656
13715
|
var withoutKey = ({ apiKey: _apiKey, ...rest }) => rest;
|
|
13657
13716
|
function openSink(path) {
|
|
13658
13717
|
try {
|
|
13659
|
-
|
|
13718
|
+
mkdirSync22(dirname16(path), { recursive: true });
|
|
13660
13719
|
return createWriteStream(path, { flags: "a" });
|
|
13661
13720
|
} catch {
|
|
13662
13721
|
return void 0;
|
|
@@ -13857,7 +13916,7 @@ var RunObserver = class {
|
|
|
13857
13916
|
};
|
|
13858
13917
|
function writeRunMeta(id, startedAt, liveTicket, extra) {
|
|
13859
13918
|
try {
|
|
13860
|
-
|
|
13919
|
+
writeFileSync23(`${id.streamPath}.meta.json`, JSON.stringify({
|
|
13861
13920
|
route: id.route,
|
|
13862
13921
|
role: id.role,
|
|
13863
13922
|
hint: id.ticket,
|
|
@@ -14066,8 +14125,24 @@ function streamsInput(plan) {
|
|
|
14066
14125
|
return !!plan.acceptsInput && i >= 0 && plan.args[i + 1] === "stream-json";
|
|
14067
14126
|
}
|
|
14068
14127
|
function spawnAgent(plan, emit, hintMoved) {
|
|
14069
|
-
|
|
14070
|
-
|
|
14128
|
+
const seated = withSeatNotes(plan);
|
|
14129
|
+
if (!seated.agentLog?.tickets || !seated.ticketRecordId) return spawnPlanned(seated, emit, hintMoved);
|
|
14130
|
+
return withOperatorNotes(seated).catch(() => seated).then((p) => spawnPlanned(p, emit, hintMoved));
|
|
14131
|
+
}
|
|
14132
|
+
function withSeatNotes(plan) {
|
|
14133
|
+
try {
|
|
14134
|
+
const stateDir = stateDirOfStream(plan.streamPath);
|
|
14135
|
+
const notes = waitingSeatNotes(stateDir, plan.role, plan.ticket);
|
|
14136
|
+
if (notes.length === 0) return plan;
|
|
14137
|
+
const prompt = `${plan.prompt}
|
|
14138
|
+
|
|
14139
|
+
${seatNotesSection(notes)}
|
|
14140
|
+
`;
|
|
14141
|
+
consumeSeatNotes(stateDir, plan.role, notes);
|
|
14142
|
+
return { ...plan, prompt, promptBytes: Buffer.byteLength(prompt, "utf8") };
|
|
14143
|
+
} catch {
|
|
14144
|
+
return plan;
|
|
14145
|
+
}
|
|
14071
14146
|
}
|
|
14072
14147
|
function spawnPlanned(plan, emit, hintMoved) {
|
|
14073
14148
|
const adapter = adapterFor(plan.harness ?? LEGACY_TOOLCHAIN_HARNESS);
|
|
@@ -14079,7 +14154,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14079
14154
|
const id = identityOf(plan, adapter.harness);
|
|
14080
14155
|
let streamFd;
|
|
14081
14156
|
try {
|
|
14082
|
-
|
|
14157
|
+
mkdirSync22(dirname16(plan.streamPath), { recursive: true });
|
|
14083
14158
|
streamFd = openSync4(plan.streamPath, "a");
|
|
14084
14159
|
} catch (e) {
|
|
14085
14160
|
void endSink(eventsSink);
|
|
@@ -14139,7 +14214,7 @@ function spawnPlanned(plan, emit, hintMoved) {
|
|
|
14139
14214
|
...streamsInput(plan) && !promptDelivered && adapter.userMessageLine ? { acceptsInput: true } : {}
|
|
14140
14215
|
};
|
|
14141
14216
|
try {
|
|
14142
|
-
|
|
14217
|
+
writeFileSync23(pidPathFor(plan.streamPath), JSON.stringify(sidecar));
|
|
14143
14218
|
} catch {
|
|
14144
14219
|
}
|
|
14145
14220
|
}
|
|
@@ -14338,19 +14413,19 @@ function runFinished(streamPath) {
|
|
|
14338
14413
|
const path = `${streamPath}.meta.json`;
|
|
14339
14414
|
if (!existsSync30(path)) return false;
|
|
14340
14415
|
try {
|
|
14341
|
-
return JSON.parse(
|
|
14416
|
+
return JSON.parse(readFileSync32(path, "utf8")).running !== true;
|
|
14342
14417
|
} catch {
|
|
14343
14418
|
return true;
|
|
14344
14419
|
}
|
|
14345
14420
|
}
|
|
14346
14421
|
function orphanedStreams(o) {
|
|
14347
|
-
const dir =
|
|
14422
|
+
const dir = join34(o.stateDir, "streams");
|
|
14348
14423
|
if (!existsSync30(dir)) return [];
|
|
14349
14424
|
const ownerAlive = o.isOwnerAlive ?? pidAlive;
|
|
14350
14425
|
const out = [];
|
|
14351
14426
|
for (const name of readdirSync10(dir)) {
|
|
14352
14427
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14353
|
-
const streamPath =
|
|
14428
|
+
const streamPath = join34(dir, name);
|
|
14354
14429
|
if (runFinished(streamPath)) continue;
|
|
14355
14430
|
const sidecar = readRunSidecar(streamPath);
|
|
14356
14431
|
if (!sidecar || sidecar.route !== o.routeLabel) continue;
|
|
@@ -14404,11 +14479,11 @@ async function reconcileRuns(o) {
|
|
|
14404
14479
|
|
|
14405
14480
|
// src/live-runs.ts
|
|
14406
14481
|
import { existsSync as existsSync32, readdirSync as readdirSync12, statSync as statSync11 } from "fs";
|
|
14407
|
-
import { join as
|
|
14482
|
+
import { join as join36 } from "path";
|
|
14408
14483
|
|
|
14409
14484
|
// src/run-snapshot.ts
|
|
14410
|
-
import { closeSync as closeSync5, existsSync as existsSync31, fstatSync, openSync as openSync5, readSync as readSync2, readdirSync as readdirSync11, statSync as statSync10, readFileSync as
|
|
14411
|
-
import { join as
|
|
14485
|
+
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";
|
|
14486
|
+
import { join as join35 } from "path";
|
|
14412
14487
|
var TAIL_BYTES = 256 * 1024;
|
|
14413
14488
|
var EXCERPT_CHARS = 280;
|
|
14414
14489
|
function endsWithQuestion(text2) {
|
|
@@ -14462,18 +14537,18 @@ function outcomeOf(m) {
|
|
|
14462
14537
|
return m.exitCode === void 0 || m.exitCode === null || m.exitCode === 0 ? "ok" : "failed";
|
|
14463
14538
|
}
|
|
14464
14539
|
function lastRunsBySeat(stateDir) {
|
|
14465
|
-
const dir =
|
|
14540
|
+
const dir = join35(stateDir, "streams");
|
|
14466
14541
|
const out = /* @__PURE__ */ new Map();
|
|
14467
14542
|
if (!existsSync31(dir)) return out;
|
|
14468
14543
|
for (const name of readdirSync11(dir)) {
|
|
14469
14544
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14470
|
-
const streamPath =
|
|
14545
|
+
const streamPath = join35(dir, name);
|
|
14471
14546
|
if (!runFinished(streamPath)) continue;
|
|
14472
14547
|
const metaPath = `${streamPath}.meta.json`;
|
|
14473
14548
|
let meta;
|
|
14474
14549
|
let mtimeMs;
|
|
14475
14550
|
try {
|
|
14476
|
-
meta = JSON.parse(
|
|
14551
|
+
meta = JSON.parse(readFileSync33(metaPath, "utf8"));
|
|
14477
14552
|
mtimeMs = statSync10(metaPath).mtimeMs;
|
|
14478
14553
|
} catch {
|
|
14479
14554
|
continue;
|
|
@@ -14498,7 +14573,7 @@ function lastRunsBySeat(stateDir) {
|
|
|
14498
14573
|
var notesPathFor = (streamPath) => `${streamPath}.notes.json`;
|
|
14499
14574
|
function readRunNotes(streamPath) {
|
|
14500
14575
|
try {
|
|
14501
|
-
const parsed = JSON.parse(
|
|
14576
|
+
const parsed = JSON.parse(readFileSync33(notesPathFor(streamPath), "utf8"));
|
|
14502
14577
|
return Array.isArray(parsed) ? parsed : [];
|
|
14503
14578
|
} catch {
|
|
14504
14579
|
return [];
|
|
@@ -14508,20 +14583,20 @@ function appendRunNote(streamPath, note) {
|
|
|
14508
14583
|
try {
|
|
14509
14584
|
const path = notesPathFor(streamPath);
|
|
14510
14585
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
14511
|
-
|
|
14512
|
-
|
|
14586
|
+
writeFileSync24(tmp, JSON.stringify([...readRunNotes(streamPath), note]));
|
|
14587
|
+
renameSync6(tmp, path);
|
|
14513
14588
|
} catch {
|
|
14514
14589
|
}
|
|
14515
14590
|
}
|
|
14516
14591
|
|
|
14517
14592
|
// src/live-runs.ts
|
|
14518
14593
|
function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
14519
|
-
const dir =
|
|
14594
|
+
const dir = join36(stateDir, "streams");
|
|
14520
14595
|
if (!existsSync32(dir)) return [];
|
|
14521
14596
|
const out = [];
|
|
14522
14597
|
for (const name of readdirSync12(dir)) {
|
|
14523
14598
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14524
|
-
const streamPath =
|
|
14599
|
+
const streamPath = join36(dir, name);
|
|
14525
14600
|
if (runFinished(streamPath)) continue;
|
|
14526
14601
|
const sidecar = readRunSidecar(streamPath);
|
|
14527
14602
|
if (!sidecar || !isAlive(sidecar)) continue;
|
|
@@ -14531,12 +14606,12 @@ function liveRuns(stateDir, isAlive = runIsAlive) {
|
|
|
14531
14606
|
}
|
|
14532
14607
|
function runActivity(stateDir, isAlive = runIsAlive) {
|
|
14533
14608
|
const activeRuns = liveRuns(stateDir, isAlive).length;
|
|
14534
|
-
const dir =
|
|
14609
|
+
const dir = join36(stateDir, "streams");
|
|
14535
14610
|
let newest = 0;
|
|
14536
14611
|
if (existsSync32(dir)) {
|
|
14537
14612
|
for (const name of readdirSync12(dir)) {
|
|
14538
14613
|
if (!name.endsWith(".jsonl") || name.endsWith(".events.jsonl")) continue;
|
|
14539
|
-
const streamPath =
|
|
14614
|
+
const streamPath = join36(dir, name);
|
|
14540
14615
|
if (!runFinished(streamPath)) continue;
|
|
14541
14616
|
try {
|
|
14542
14617
|
newest = Math.max(newest, statSync11(`${streamPath}.meta.json`).mtimeMs);
|
|
@@ -15546,9 +15621,9 @@ function managedGitIdentityWarnings(kind, identity) {
|
|
|
15546
15621
|
|
|
15547
15622
|
// src/selftest.ts
|
|
15548
15623
|
import { spawn as spawn7 } from "child_process";
|
|
15549
|
-
import { existsSync as existsSync34, mkdirSync as
|
|
15624
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync23, mkdtempSync as mkdtempSync2, readFileSync as readFileSync34, rmSync as rmSync18, writeFileSync as writeFileSync25 } from "fs";
|
|
15550
15625
|
import { tmpdir as tmpdir5 } from "os";
|
|
15551
|
-
import { join as
|
|
15626
|
+
import { join as join37 } from "path";
|
|
15552
15627
|
var SELFTEST_TIMEOUT_MS = 12e4;
|
|
15553
15628
|
var KEY_VAR = "CREW_API_KEY";
|
|
15554
15629
|
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: ";
|
|
@@ -15714,7 +15789,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
15714
15789
|
...adapter.runEnv(spec),
|
|
15715
15790
|
[KEY_VAR]: i.apiKey
|
|
15716
15791
|
};
|
|
15717
|
-
const cwd = mkdtempSync2(
|
|
15792
|
+
const cwd = mkdtempSync2(join37(tmpdir5(), "crew-selftest-"));
|
|
15718
15793
|
try {
|
|
15719
15794
|
const run4 = await deps.run({
|
|
15720
15795
|
bin: invocation.bin,
|
|
@@ -15736,7 +15811,7 @@ async function runSelftest(i, deps = realDeps) {
|
|
|
15736
15811
|
return finish({ ok: false, failure, detail, ...usage2 });
|
|
15737
15812
|
} finally {
|
|
15738
15813
|
try {
|
|
15739
|
-
|
|
15814
|
+
rmSync18(cwd, { recursive: true, force: true });
|
|
15740
15815
|
} catch {
|
|
15741
15816
|
}
|
|
15742
15817
|
}
|
|
@@ -15747,11 +15822,11 @@ function formatResult(r) {
|
|
|
15747
15822
|
const secs = `${(r.ms / 1e3).toFixed(1)}s`;
|
|
15748
15823
|
return r.ok ? `${r.toolchain}: PASS ${r.detail} (${secs}${tok})` : `${r.toolchain}: FAIL ${r.failure} \u2014 ${r.detail} (${secs})`;
|
|
15749
15824
|
}
|
|
15750
|
-
var
|
|
15825
|
+
var fileFor3 = (stateDir) => join37(stateDir, "selftest.json");
|
|
15751
15826
|
function readSelftest(stateDir) {
|
|
15752
15827
|
try {
|
|
15753
|
-
const p =
|
|
15754
|
-
return existsSync34(p) ? JSON.parse(
|
|
15828
|
+
const p = fileFor3(stateDir);
|
|
15829
|
+
return existsSync34(p) ? JSON.parse(readFileSync34(p, "utf8")) : {};
|
|
15755
15830
|
} catch {
|
|
15756
15831
|
return {};
|
|
15757
15832
|
}
|
|
@@ -15759,8 +15834,8 @@ function readSelftest(stateDir) {
|
|
|
15759
15834
|
function recordSelftest(stateDir, results) {
|
|
15760
15835
|
const all = readSelftest(stateDir);
|
|
15761
15836
|
for (const r of results) all[r.toolchain] = r;
|
|
15762
|
-
|
|
15763
|
-
|
|
15837
|
+
mkdirSync23(stateDir, { recursive: true });
|
|
15838
|
+
writeFileSync25(fileFor3(stateDir), `${JSON.stringify(all, null, 2)}
|
|
15764
15839
|
`);
|
|
15765
15840
|
}
|
|
15766
15841
|
function doctorSelftestLines(stored, toolchains) {
|
|
@@ -15772,7 +15847,7 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
15772
15847
|
}
|
|
15773
15848
|
|
|
15774
15849
|
// src/cli.ts
|
|
15775
|
-
import { resolve as resolve7, dirname as dirname37, join as
|
|
15850
|
+
import { resolve as resolve7, dirname as dirname37, join as join64, basename as basename17 } from "path";
|
|
15776
15851
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
15777
15852
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
15778
15853
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
@@ -15981,14 +16056,14 @@ function rosterMarkdown(roster, meId) {
|
|
|
15981
16056
|
}
|
|
15982
16057
|
|
|
15983
16058
|
// src/connect-resume.ts
|
|
15984
|
-
import { mkdirSync as
|
|
15985
|
-
import { dirname as dirname17, join as
|
|
16059
|
+
import { mkdirSync as mkdirSync24, readFileSync as readFileSync35, rmSync as rmSync19, writeFileSync as writeFileSync26 } from "fs";
|
|
16060
|
+
import { dirname as dirname17, join as join38 } from "path";
|
|
15986
16061
|
function lastSessionFile(stateDir) {
|
|
15987
|
-
return
|
|
16062
|
+
return join38(stateDir, "connect-session.json");
|
|
15988
16063
|
}
|
|
15989
16064
|
function readPointers(stateDir) {
|
|
15990
16065
|
try {
|
|
15991
|
-
const parsed = JSON.parse(
|
|
16066
|
+
const parsed = JSON.parse(readFileSync35(lastSessionFile(stateDir), "utf8"));
|
|
15992
16067
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
|
|
15993
16068
|
const out = {};
|
|
15994
16069
|
for (const [host, v] of Object.entries(parsed)) {
|
|
@@ -16002,8 +16077,8 @@ function readPointers(stateDir) {
|
|
|
16002
16077
|
}
|
|
16003
16078
|
function writePointers(stateDir, pointers) {
|
|
16004
16079
|
const file = lastSessionFile(stateDir);
|
|
16005
|
-
|
|
16006
|
-
|
|
16080
|
+
mkdirSync24(dirname17(file), { recursive: true });
|
|
16081
|
+
writeFileSync26(file, `${JSON.stringify(pointers, null, 2)}
|
|
16007
16082
|
`, { mode: 384 });
|
|
16008
16083
|
}
|
|
16009
16084
|
function rememberSession(stateDir, host, workspaceSlug) {
|
|
@@ -16020,7 +16095,7 @@ function forgetWorkspace(stateDir, host, workspaceSlug) {
|
|
|
16020
16095
|
const { [host]: _old, ...rest } = all;
|
|
16021
16096
|
const next = left.length ? { ...rest, [host]: left } : rest;
|
|
16022
16097
|
if (Object.keys(next).length) writePointers(stateDir, next);
|
|
16023
|
-
else
|
|
16098
|
+
else rmSync19(lastSessionFile(stateDir), { force: true });
|
|
16024
16099
|
} catch {
|
|
16025
16100
|
}
|
|
16026
16101
|
}
|
|
@@ -16060,7 +16135,7 @@ function forgetSession(stateDir, host) {
|
|
|
16060
16135
|
try {
|
|
16061
16136
|
const { [host]: _gone, ...rest } = readPointers(stateDir);
|
|
16062
16137
|
if (Object.keys(rest).length) writePointers(stateDir, rest);
|
|
16063
|
-
else
|
|
16138
|
+
else rmSync19(lastSessionFile(stateDir), { force: true });
|
|
16064
16139
|
} catch {
|
|
16065
16140
|
}
|
|
16066
16141
|
}
|
|
@@ -16088,15 +16163,15 @@ async function signOutSessions(o) {
|
|
|
16088
16163
|
}
|
|
16089
16164
|
|
|
16090
16165
|
// src/reset.ts
|
|
16091
|
-
import { existsSync as existsSync35, mkdirSync as
|
|
16092
|
-
import { dirname as dirname18, join as
|
|
16166
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, readdirSync as readdirSync14, rmSync as rmSync20, statSync as statSync12, writeFileSync as writeFileSync27 } from "fs";
|
|
16167
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
16093
16168
|
import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
|
|
16094
16169
|
function clonedCheckoutsFile(stateDir) {
|
|
16095
|
-
return
|
|
16170
|
+
return join39(stateDir, "cloned-checkouts.json");
|
|
16096
16171
|
}
|
|
16097
16172
|
function readClonedCheckouts(stateDir) {
|
|
16098
16173
|
try {
|
|
16099
|
-
const parsed = JSON.parse(
|
|
16174
|
+
const parsed = JSON.parse(readFileSync36(clonedCheckoutsFile(stateDir), "utf8"));
|
|
16100
16175
|
return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
|
|
16101
16176
|
} catch {
|
|
16102
16177
|
return [];
|
|
@@ -16106,8 +16181,8 @@ function recordClonedCheckout(stateDir, dir) {
|
|
|
16106
16181
|
const known = readClonedCheckouts(stateDir);
|
|
16107
16182
|
if (known.includes(dir)) return;
|
|
16108
16183
|
const file = clonedCheckoutsFile(stateDir);
|
|
16109
|
-
|
|
16110
|
-
|
|
16184
|
+
mkdirSync25(dirname18(file), { recursive: true });
|
|
16185
|
+
writeFileSync27(file, `${JSON.stringify([...known, dir], null, 2)}
|
|
16111
16186
|
`);
|
|
16112
16187
|
}
|
|
16113
16188
|
var mark = (dryRun) => dryRun ? "would-remove" : "removed";
|
|
@@ -16162,7 +16237,7 @@ async function runReset(o, fx) {
|
|
|
16162
16237
|
if (o.beforeState) steps.push(...await o.beforeState());
|
|
16163
16238
|
steps.push(...o.wipeState ? wipeStateDir(o.stateDir, o.dryRun) : removeState(o.stateDir, o.dryRun));
|
|
16164
16239
|
if (existsSync35(o.configFile)) {
|
|
16165
|
-
if (!o.dryRun)
|
|
16240
|
+
if (!o.dryRun) rmSync20(o.configFile, { force: true });
|
|
16166
16241
|
steps.push({ step: "config", target: o.configFile, action: mark(o.dryRun) });
|
|
16167
16242
|
} else {
|
|
16168
16243
|
steps.push({ step: "config", target: o.configFile, action: "absent" });
|
|
@@ -16178,21 +16253,21 @@ function removeCheckout(dir, dryRun, fx) {
|
|
|
16178
16253
|
if (linkedWorktrees.length) {
|
|
16179
16254
|
return { step: "checkout", target: dir, action: "kept", detail: `has linked worktrees (${linkedWorktrees.join(", ")}); remove them first` };
|
|
16180
16255
|
}
|
|
16181
|
-
if (!dryRun)
|
|
16256
|
+
if (!dryRun) rmSync20(dir, { recursive: true, force: true });
|
|
16182
16257
|
return { step: "checkout", target: dir, action: mark(dryRun) };
|
|
16183
16258
|
}
|
|
16184
16259
|
function removeState(stateDir, dryRun) {
|
|
16185
16260
|
const out = [];
|
|
16186
|
-
const targets = [
|
|
16261
|
+
const targets = [join39(stateDir, "resolved"), join39(stateDir, "keys"), clonedCheckoutsFile(stateDir), join39(stateDir, "connect-session.json"), join39(stateDir, "reload-requested"), join39(stateDir, "daemon.started")];
|
|
16187
16262
|
try {
|
|
16188
16263
|
for (const name of readdirSync14(stateDir)) {
|
|
16189
|
-
if (name.startsWith(".") && statSync12(
|
|
16264
|
+
if (name.startsWith(".") && statSync12(join39(stateDir, name)).isFile()) targets.push(join39(stateDir, name));
|
|
16190
16265
|
}
|
|
16191
16266
|
} catch {
|
|
16192
16267
|
}
|
|
16193
16268
|
for (const t of targets) {
|
|
16194
16269
|
if (!existsSync35(t)) continue;
|
|
16195
|
-
if (!dryRun)
|
|
16270
|
+
if (!dryRun) rmSync20(t, { recursive: true, force: true });
|
|
16196
16271
|
out.push({ step: "state", target: t, action: mark(dryRun) });
|
|
16197
16272
|
}
|
|
16198
16273
|
if (!out.length) out.push({ step: "state", target: stateDir, action: "absent", detail: "nothing to remove" });
|
|
@@ -16206,7 +16281,7 @@ function wipeStateDir(stateDir, dryRun) {
|
|
|
16206
16281
|
return [{ step: "state", target: stateDir, action: "absent", detail: "no state directory" }];
|
|
16207
16282
|
}
|
|
16208
16283
|
if (!names.length) return [{ step: "state", target: stateDir, action: "absent", detail: "already empty" }];
|
|
16209
|
-
if (!dryRun) for (const n of names)
|
|
16284
|
+
if (!dryRun) for (const n of names) rmSync20(join39(stateDir, n), { recursive: true, force: true });
|
|
16210
16285
|
return [{ step: "state", target: stateDir, action: mark(dryRun), detail: `${names.length} entr${names.length === 1 ? "y" : "ies"}` }];
|
|
16211
16286
|
}
|
|
16212
16287
|
function describeResetStep(s) {
|
|
@@ -16288,9 +16363,9 @@ async function runDeprovision(o, fx, deps) {
|
|
|
16288
16363
|
}
|
|
16289
16364
|
|
|
16290
16365
|
// src/pool-member.ts
|
|
16291
|
-
import { mkdirSync as
|
|
16366
|
+
import { mkdirSync as mkdirSync26, readFileSync as readFileSync37, renameSync as renameSync7, writeFileSync as writeFileSync28 } from "fs";
|
|
16292
16367
|
import { homedir as homedir8 } from "os";
|
|
16293
|
-
import { dirname as dirname19, join as
|
|
16368
|
+
import { dirname as dirname19, join as join40 } from "path";
|
|
16294
16369
|
var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
|
|
16295
16370
|
function backoffMs(attempt) {
|
|
16296
16371
|
return Math.min(6e4, 5e3 * 2 ** Math.max(0, attempt));
|
|
@@ -16532,24 +16607,24 @@ async function runPoolMember(deps) {
|
|
|
16532
16607
|
}
|
|
16533
16608
|
}
|
|
16534
16609
|
function defaultMemberDir(env = process.env) {
|
|
16535
|
-
return env.CREW_POOL_DIR ??
|
|
16610
|
+
return env.CREW_POOL_DIR ?? join40(env.XDG_STATE_HOME ?? join40(homedir8(), ".local", "state"), "crew-pool-member");
|
|
16536
16611
|
}
|
|
16537
16612
|
function fileMemberStore(dir) {
|
|
16538
|
-
const file =
|
|
16613
|
+
const file = join40(dir, "member.json");
|
|
16539
16614
|
return {
|
|
16540
16615
|
read() {
|
|
16541
16616
|
try {
|
|
16542
|
-
return JSON.parse(
|
|
16617
|
+
return JSON.parse(readFileSync37(file, "utf8"));
|
|
16543
16618
|
} catch {
|
|
16544
16619
|
return {};
|
|
16545
16620
|
}
|
|
16546
16621
|
},
|
|
16547
16622
|
write(f) {
|
|
16548
|
-
|
|
16623
|
+
mkdirSync26(dirname19(file), { recursive: true, mode: 448 });
|
|
16549
16624
|
const tmp = `${file}.tmp`;
|
|
16550
|
-
|
|
16625
|
+
writeFileSync28(tmp, `${JSON.stringify(f)}
|
|
16551
16626
|
`, { mode: 384 });
|
|
16552
|
-
|
|
16627
|
+
renameSync7(tmp, file);
|
|
16553
16628
|
}
|
|
16554
16629
|
};
|
|
16555
16630
|
}
|
|
@@ -16605,10 +16680,10 @@ import { hostname as hostname3 } from "os";
|
|
|
16605
16680
|
// src/machine-id.ts
|
|
16606
16681
|
import { execFileSync as execFileSync12 } from "child_process";
|
|
16607
16682
|
import { createHash as createHash8 } from "crypto";
|
|
16608
|
-
import { existsSync as existsSync36, mkdirSync as
|
|
16609
|
-
import { dirname as dirname20, join as
|
|
16683
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync27, readFileSync as readFileSync38, writeFileSync as writeFileSync29 } from "fs";
|
|
16684
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
16610
16685
|
function machineIdPathFor(stateDir) {
|
|
16611
|
-
return
|
|
16686
|
+
return join41(stateDir, "machine-id");
|
|
16612
16687
|
}
|
|
16613
16688
|
var sha256 = (s) => createHash8("sha256").update(s).digest("hex");
|
|
16614
16689
|
function readRawMachineId(platform2 = process.platform) {
|
|
@@ -16622,7 +16697,7 @@ function readRawMachineId(platform2 = process.platform) {
|
|
|
16622
16697
|
}
|
|
16623
16698
|
for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
|
|
16624
16699
|
if (existsSync36(p)) {
|
|
16625
|
-
const id =
|
|
16700
|
+
const id = readFileSync38(p, "utf8").trim();
|
|
16626
16701
|
if (id) return id;
|
|
16627
16702
|
}
|
|
16628
16703
|
}
|
|
@@ -16634,14 +16709,14 @@ function ensureMachineId(stateDir, opts = {}) {
|
|
|
16634
16709
|
if (opts.override?.trim()) return sha256(opts.override.trim());
|
|
16635
16710
|
const path = machineIdPathFor(stateDir);
|
|
16636
16711
|
if (existsSync36(path)) {
|
|
16637
|
-
const cached =
|
|
16712
|
+
const cached = readFileSync38(path, "utf8").trim();
|
|
16638
16713
|
if (/^[0-9a-f]{64}$/.test(cached)) return cached;
|
|
16639
16714
|
}
|
|
16640
16715
|
const raw = (opts.read ?? readRawMachineId)();
|
|
16641
16716
|
if (!raw) return void 0;
|
|
16642
16717
|
const hashed = sha256(raw);
|
|
16643
|
-
|
|
16644
|
-
|
|
16718
|
+
mkdirSync27(dirname20(path), { recursive: true });
|
|
16719
|
+
writeFileSync29(path, `${hashed}
|
|
16645
16720
|
`, { mode: 384 });
|
|
16646
16721
|
return hashed;
|
|
16647
16722
|
}
|
|
@@ -16654,7 +16729,7 @@ function matchShipRows(ships, shipName2, machineId) {
|
|
|
16654
16729
|
|
|
16655
16730
|
// src/provision.ts
|
|
16656
16731
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
16657
|
-
import { existsSync as existsSync37, readFileSync as
|
|
16732
|
+
import { existsSync as existsSync37, readFileSync as readFileSync39, writeFileSync as writeFileSync30 } from "fs";
|
|
16658
16733
|
import { hostname as hostname2 } from "os";
|
|
16659
16734
|
import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
|
|
16660
16735
|
|
|
@@ -16663,7 +16738,7 @@ import { parseDocument as parseDocument2 } from "yaml";
|
|
|
16663
16738
|
|
|
16664
16739
|
// src/repos-cmd.ts
|
|
16665
16740
|
import { homedir as homedir9 } from "os";
|
|
16666
|
-
import { basename as basename10, join as
|
|
16741
|
+
import { basename as basename10, join as join42, resolve as resolve4 } from "path";
|
|
16667
16742
|
import { isMap, isSeq, parseDocument, stringify as stringify2 } from "yaml";
|
|
16668
16743
|
var ReposError = class extends Error {
|
|
16669
16744
|
};
|
|
@@ -16941,7 +17016,7 @@ function planRepoClone(i) {
|
|
|
16941
17016
|
}
|
|
16942
17017
|
const ship = doc.get("ship", true);
|
|
16943
17018
|
const basePath = String(m.get("reposBasePath") ?? (isMap(ship) ? ship.get("reposBasePath") : void 0) ?? "~/Crew");
|
|
16944
|
-
const target = i.dir ? expandDir(i.dir, i.base) :
|
|
17019
|
+
const target = i.dir ? expandDir(i.dir, i.base) : join42(expandDir(basePath, i.base), i.route.split("/")[0], name);
|
|
16945
17020
|
const add = planRepoAdd({ text: i.text, base: i.base, route: i.route, path: target, origin: remote, resolved: i.resolved, name, isCheckout: i.isCheckout });
|
|
16946
17021
|
const forgeHost = i.resolved?.repoForgeHosts?.[id];
|
|
16947
17022
|
return { ...add, remote, target, ...forgeHost ? { forgeHost } : {} };
|
|
@@ -17280,13 +17355,13 @@ function realProvisionDeps(crewHome) {
|
|
|
17280
17355
|
enableRoute(route2) {
|
|
17281
17356
|
const file = configFile();
|
|
17282
17357
|
if (!file) return false;
|
|
17283
|
-
const text2 =
|
|
17358
|
+
const text2 = readFileSync39(file, "utf8");
|
|
17284
17359
|
const doc = parseDocument3(text2);
|
|
17285
17360
|
const routes = doc.get("routes");
|
|
17286
17361
|
const entry = routes?.items?.find((r) => r.get("route") === route2);
|
|
17287
17362
|
if (!entry) throw new Error(`route ${route2} is not in ${file}`);
|
|
17288
17363
|
if (entry.get("enabled") === true) return false;
|
|
17289
|
-
|
|
17364
|
+
writeFileSync30(file, planEnable(text2, route2));
|
|
17290
17365
|
return true;
|
|
17291
17366
|
},
|
|
17292
17367
|
installState() {
|
|
@@ -17306,7 +17381,7 @@ function realProvisionDeps(crewHome) {
|
|
|
17306
17381
|
continue;
|
|
17307
17382
|
}
|
|
17308
17383
|
for (const p of plan.unitPaths) {
|
|
17309
|
-
if (!existsSync37(p) ||
|
|
17384
|
+
if (!existsSync37(p) || readFileSync39(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
|
|
17310
17385
|
}
|
|
17311
17386
|
}
|
|
17312
17387
|
const label = labelFor(crewHome, "run");
|
|
@@ -17330,18 +17405,18 @@ function realProvisionDeps(crewHome) {
|
|
|
17330
17405
|
setShipSetting(key, value2) {
|
|
17331
17406
|
const file = configFile();
|
|
17332
17407
|
if (!file) return false;
|
|
17333
|
-
const doc = parseDocument3(
|
|
17408
|
+
const doc = parseDocument3(readFileSync39(file, "utf8"));
|
|
17334
17409
|
if (doc.getIn(["ship", key]) === value2) return false;
|
|
17335
17410
|
doc.setIn(["ship", key], value2);
|
|
17336
|
-
|
|
17411
|
+
writeFileSync30(file, doc.toString());
|
|
17337
17412
|
return true;
|
|
17338
17413
|
},
|
|
17339
17414
|
applyManagedDefaults() {
|
|
17340
17415
|
const file = configFile();
|
|
17341
17416
|
if (!file) return [];
|
|
17342
|
-
const doc = parseDocument3(
|
|
17417
|
+
const doc = parseDocument3(readFileSync39(file, "utf8"));
|
|
17343
17418
|
const wrote = applyManagedDefaultsToDoc(doc);
|
|
17344
|
-
if (wrote.length)
|
|
17419
|
+
if (wrote.length) writeFileSync30(file, doc.toString());
|
|
17345
17420
|
return wrote;
|
|
17346
17421
|
},
|
|
17347
17422
|
ensureGitIdentity(name, email) {
|
|
@@ -18499,8 +18574,8 @@ function diskFullStop(state) {
|
|
|
18499
18574
|
}
|
|
18500
18575
|
|
|
18501
18576
|
// src/poll.ts
|
|
18502
|
-
import { writeFileSync as
|
|
18503
|
-
import { join as
|
|
18577
|
+
import { writeFileSync as writeFileSync31 } from "fs";
|
|
18578
|
+
import { join as join43 } from "path";
|
|
18504
18579
|
|
|
18505
18580
|
// src/stalled.ts
|
|
18506
18581
|
var STALLED_AFTER_CYCLES = 30;
|
|
@@ -18816,7 +18891,7 @@ async function decideCycle(o) {
|
|
|
18816
18891
|
}
|
|
18817
18892
|
return decision;
|
|
18818
18893
|
}
|
|
18819
|
-
var digestPath = (stateDir, route2, role, runId) =>
|
|
18894
|
+
var digestPath = (stateDir, route2, role, runId) => join43(stateDir, `digest-${route2}-${role}${runId ? `-${runId}` : ""}.md`);
|
|
18820
18895
|
function otherRunsRemoved(tickets, own) {
|
|
18821
18896
|
if (!own) return tickets;
|
|
18822
18897
|
return tickets.filter((t) => t.id === own.ticket.id || !own.inFlight(t.id));
|
|
@@ -18902,7 +18977,7 @@ function writeDigest(o, d, role, stateDir, runId, own) {
|
|
|
18902
18977
|
|
|
18903
18978
|
${body}` : body;
|
|
18904
18979
|
const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
|
|
18905
|
-
|
|
18980
|
+
writeFileSync31(path, text2);
|
|
18906
18981
|
o.emit.emit(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
|
|
18907
18982
|
data: { role, bytes: Buffer.byteLength(text2) }
|
|
18908
18983
|
});
|
|
@@ -19025,7 +19100,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
|
|
|
19025
19100
|
}
|
|
19026
19101
|
|
|
19027
19102
|
// src/repo-refresh.ts
|
|
19028
|
-
import { existsSync as existsSync40, mkdirSync as
|
|
19103
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync28, readFileSync as readFileSync40, writeFileSync as writeFileSync32 } from "fs";
|
|
19029
19104
|
import { dirname as dirname22 } from "path";
|
|
19030
19105
|
var REFRESH_COOLDOWN_MS = 2 * 6e4;
|
|
19031
19106
|
var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
|
|
@@ -19056,10 +19131,10 @@ function applyRepoRows(resolved, rows) {
|
|
|
19056
19131
|
function persistRepoRows(stateDir, routeName, rows) {
|
|
19057
19132
|
const path = resolvedPathFor(stateDir, routeName);
|
|
19058
19133
|
if (!existsSync40(path)) return;
|
|
19059
|
-
const raw = JSON.parse(
|
|
19134
|
+
const raw = JSON.parse(readFileSync40(path, "utf8"));
|
|
19060
19135
|
applyRepoRows(raw, rows);
|
|
19061
|
-
|
|
19062
|
-
|
|
19136
|
+
mkdirSync28(dirname22(path), { recursive: true });
|
|
19137
|
+
writeFileSync32(path, `${JSON.stringify(raw, null, 2)}
|
|
19063
19138
|
`);
|
|
19064
19139
|
}
|
|
19065
19140
|
async function refreshUnknownRepos(o) {
|
|
@@ -19535,7 +19610,7 @@ Ship ${shipName2} found: ${problem}. The release refuses to squash a ref nobody
|
|
|
19535
19610
|
var localRefSkipReported = (ticket, problem, events) => events.some((e) => e.record_id === ticket.id && e.event_type === "local_ref_skip" && (e.message ?? "").includes(problem));
|
|
19536
19611
|
|
|
19537
19612
|
// src/platform-gate.ts
|
|
19538
|
-
import { join as
|
|
19613
|
+
import { join as join44 } from "path";
|
|
19539
19614
|
function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
19540
19615
|
const out = [];
|
|
19541
19616
|
for (const t of tickets) {
|
|
@@ -19547,7 +19622,7 @@ function platformAdmitters(dir, baseRef, ship, tickets, locate) {
|
|
|
19547
19622
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
19548
19623
|
if (text2 === null) continue;
|
|
19549
19624
|
try {
|
|
19550
|
-
const { platform: platform2 } = parseRepoConfig(text2,
|
|
19625
|
+
const { platform: platform2 } = parseRepoConfig(text2, join44(dir, file));
|
|
19551
19626
|
if (satisfies(ship, platform2)) out.push({ issueId: t.issue_id, branch, platform: platform2 });
|
|
19552
19627
|
} catch (e) {
|
|
19553
19628
|
if (e instanceof RepoConfigError) continue;
|
|
@@ -19563,8 +19638,8 @@ function platformStuckNote(repo, required, ship, issueIds) {
|
|
|
19563
19638
|
}
|
|
19564
19639
|
|
|
19565
19640
|
// src/connect-wizard.ts
|
|
19566
|
-
import { delimiter, dirname as dirname23, join as
|
|
19567
|
-
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as
|
|
19641
|
+
import { delimiter, dirname as dirname23, join as join45 } from "path";
|
|
19642
|
+
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync41, mkdirSync as mkdirSync29, writeFileSync as writeFileSync33 } from "fs";
|
|
19568
19643
|
import { stringify as stringify3 } from "yaml";
|
|
19569
19644
|
var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
|
|
19570
19645
|
function shouldRunWizard(opts) {
|
|
@@ -19586,7 +19661,7 @@ function defaultIsExecutable(p) {
|
|
|
19586
19661
|
function findOnPath2(name, pathEnv, isExecutable = defaultIsExecutable) {
|
|
19587
19662
|
for (const dir of pathEnv.split(delimiter)) {
|
|
19588
19663
|
if (!dir) continue;
|
|
19589
|
-
const candidate =
|
|
19664
|
+
const candidate = join45(dir, name);
|
|
19590
19665
|
if (isExecutable(candidate)) return candidate;
|
|
19591
19666
|
}
|
|
19592
19667
|
return void 0;
|
|
@@ -19647,9 +19722,9 @@ routes:
|
|
|
19647
19722
|
${routeBlock}`;
|
|
19648
19723
|
}
|
|
19649
19724
|
function writeNewConfig(path, text2) {
|
|
19650
|
-
|
|
19725
|
+
mkdirSync29(dirname23(path), { recursive: true });
|
|
19651
19726
|
try {
|
|
19652
|
-
|
|
19727
|
+
writeFileSync33(path, text2, { mode: 384, flag: "wx" });
|
|
19653
19728
|
return true;
|
|
19654
19729
|
} catch (e) {
|
|
19655
19730
|
if (e.code === "EEXIST") return false;
|
|
@@ -19683,7 +19758,7 @@ Wrote ${o.configPath}.
|
|
|
19683
19758
|
// src/connect-json.ts
|
|
19684
19759
|
import { accessSync as accessSync4, constants as constants4 } from "fs";
|
|
19685
19760
|
import { homedir as homedir10 } from "os";
|
|
19686
|
-
import { dirname as dirname24, join as
|
|
19761
|
+
import { dirname as dirname24, join as join46 } from "path";
|
|
19687
19762
|
import { delimiter as delimiter2 } from "path";
|
|
19688
19763
|
var CHOICE_EXIT_CODE = 3;
|
|
19689
19764
|
function createEmitter(json2, write) {
|
|
@@ -19722,12 +19797,12 @@ function agentBinSearchDirs(home, pathEnv, extraPath) {
|
|
|
19722
19797
|
const dirs = [
|
|
19723
19798
|
...pathEnv.split(delimiter2),
|
|
19724
19799
|
...(extraPath ?? "").split(delimiter2),
|
|
19725
|
-
|
|
19726
|
-
|
|
19800
|
+
join46(home, ".local/bin"),
|
|
19801
|
+
join46(home, ".claude/local"),
|
|
19727
19802
|
"/opt/homebrew/bin",
|
|
19728
19803
|
"/usr/local/bin",
|
|
19729
|
-
|
|
19730
|
-
|
|
19804
|
+
join46(home, ".npm-global/bin"),
|
|
19805
|
+
join46(home, ".volta/bin")
|
|
19731
19806
|
];
|
|
19732
19807
|
return [...new Set(dirs.filter(Boolean))];
|
|
19733
19808
|
}
|
|
@@ -19848,8 +19923,8 @@ async function collectDiagnostics(d) {
|
|
|
19848
19923
|
}
|
|
19849
19924
|
|
|
19850
19925
|
// src/release-run.ts
|
|
19851
|
-
import { readFileSync as
|
|
19852
|
-
import { dirname as dirname25, join as
|
|
19926
|
+
import { readFileSync as readFileSync41, writeFileSync as writeFileSync34, existsSync as existsSync42, copyFileSync, mkdirSync as mkdirSync30, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
|
|
19927
|
+
import { dirname as dirname25, join as join47 } from "path";
|
|
19853
19928
|
import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
|
|
19854
19929
|
|
|
19855
19930
|
// src/release.ts
|
|
@@ -20639,13 +20714,13 @@ async function bump(o, size) {
|
|
|
20639
20714
|
}
|
|
20640
20715
|
return printed;
|
|
20641
20716
|
}
|
|
20642
|
-
const files = o.repo.release.versionFiles.map((f) =>
|
|
20717
|
+
const files = o.repo.release.versionFiles.map((f) => join47(o.cwd, f));
|
|
20643
20718
|
const first = files[0];
|
|
20644
20719
|
if (!existsAt(first, existsSync42)) {
|
|
20645
20720
|
o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
|
|
20646
20721
|
return null;
|
|
20647
20722
|
}
|
|
20648
|
-
const firstText = readTextAt(first, (p) =>
|
|
20723
|
+
const firstText = readTextAt(first, (p) => readFileSync41(p, "utf8"));
|
|
20649
20724
|
const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
|
|
20650
20725
|
if (problem) {
|
|
20651
20726
|
o.emit.error(problem);
|
|
@@ -20664,27 +20739,27 @@ async function bump(o, size) {
|
|
|
20664
20739
|
return version;
|
|
20665
20740
|
}
|
|
20666
20741
|
for (const f of files) {
|
|
20667
|
-
const src = readTextAt(f, (p) =>
|
|
20742
|
+
const src = readTextAt(f, (p) => readFileSync41(p, "utf8"));
|
|
20668
20743
|
const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
|
|
20669
20744
|
if (out === src) {
|
|
20670
20745
|
o.emit.error(`no version field in ${f}`);
|
|
20671
20746
|
return null;
|
|
20672
20747
|
}
|
|
20673
|
-
writeTextAt(f, out,
|
|
20748
|
+
writeTextAt(f, out, writeFileSync34);
|
|
20674
20749
|
}
|
|
20675
20750
|
return version;
|
|
20676
20751
|
}
|
|
20677
20752
|
function writeChangelog(o, version, entries) {
|
|
20678
20753
|
const file = o.repo.release.changelog;
|
|
20679
20754
|
if (!file || entries.length === 0) return;
|
|
20680
|
-
const path =
|
|
20755
|
+
const path = join47(o.cwd, file);
|
|
20681
20756
|
const section = renderChangelogSection(version, (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), entries);
|
|
20682
20757
|
if (o.dryRun) {
|
|
20683
20758
|
o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
|
|
20684
20759
|
return;
|
|
20685
20760
|
}
|
|
20686
|
-
const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) =>
|
|
20687
|
-
writeTextAt(path, insertChangelogSection(existing, section),
|
|
20761
|
+
const existing = existsAt(path, existsSync42) ? readTextAt(path, (p) => readFileSync41(p, "utf8")) : "# Changelog\n";
|
|
20762
|
+
writeTextAt(path, insertChangelogSection(existing, section), writeFileSync34);
|
|
20688
20763
|
}
|
|
20689
20764
|
async function confirm(o, expected) {
|
|
20690
20765
|
if (!o.repo.hooks.released) return void 0;
|
|
@@ -20767,7 +20842,7 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
20767
20842
|
run4(cwd, ["worktree", "remove", "--force", dir]);
|
|
20768
20843
|
} finally {
|
|
20769
20844
|
try {
|
|
20770
|
-
|
|
20845
|
+
rmSync21(root, { recursive: true, force: true });
|
|
20771
20846
|
} finally {
|
|
20772
20847
|
run4(cwd, ["worktree", "prune"]);
|
|
20773
20848
|
run4(cwd, ["branch", "-D", branch]);
|
|
@@ -20777,8 +20852,8 @@ function closeReleaseCheckout(cwd, root, dir, branch, run4 = gitOk) {
|
|
|
20777
20852
|
function openReleaseCheckout(o) {
|
|
20778
20853
|
const { remote, base } = o.repo.branch;
|
|
20779
20854
|
const branch = `crew/release-${Date.now()}`;
|
|
20780
|
-
const root = mkdtempSync3(
|
|
20781
|
-
const dir =
|
|
20855
|
+
const root = mkdtempSync3(join47(tmpdir6(), "crew-release-"));
|
|
20856
|
+
const dir = join47(root, "checkout");
|
|
20782
20857
|
o.emit.emit(`release checkout: ${dir}`, { step: "release" });
|
|
20783
20858
|
const close = () => closeReleaseCheckout(o.cwd, root, dir, branch);
|
|
20784
20859
|
try {
|
|
@@ -20788,10 +20863,10 @@ function openReleaseCheckout(o) {
|
|
|
20788
20863
|
throw e;
|
|
20789
20864
|
}
|
|
20790
20865
|
for (const f of o.repo.worktrees.copy) {
|
|
20791
|
-
const src =
|
|
20866
|
+
const src = join47(o.cwd, f);
|
|
20792
20867
|
if (!existsSync42(src)) continue;
|
|
20793
|
-
|
|
20794
|
-
copyFileSync(src,
|
|
20868
|
+
mkdirSync30(dirname25(join47(dir, f)), { recursive: true });
|
|
20869
|
+
copyFileSync(src, join47(dir, f));
|
|
20795
20870
|
}
|
|
20796
20871
|
return { dir, branch, close };
|
|
20797
20872
|
}
|
|
@@ -21610,15 +21685,15 @@ async function runCommentDeliveryPass(deps) {
|
|
|
21610
21685
|
}
|
|
21611
21686
|
|
|
21612
21687
|
// src/launchd-start.ts
|
|
21613
|
-
import { readFileSync as
|
|
21688
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
21614
21689
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
21615
21690
|
|
|
21616
21691
|
// src/daemon-liveness.ts
|
|
21617
|
-
import { existsSync as existsSync49, readFileSync as
|
|
21692
|
+
import { existsSync as existsSync49, readFileSync as readFileSync47 } from "fs";
|
|
21618
21693
|
|
|
21619
21694
|
// src/daemon.ts
|
|
21620
|
-
import { existsSync as existsSync48, mkdirSync as
|
|
21621
|
-
import { join as
|
|
21695
|
+
import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync46, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
|
|
21696
|
+
import { join as join52 } from "path";
|
|
21622
21697
|
import { randomBytes } from "crypto";
|
|
21623
21698
|
|
|
21624
21699
|
// src/fleet.ts
|
|
@@ -21708,27 +21783,27 @@ function nextRoles(decision, ran) {
|
|
|
21708
21783
|
}
|
|
21709
21784
|
|
|
21710
21785
|
// src/noop-runs.ts
|
|
21711
|
-
import { existsSync as existsSync43, mkdirSync as
|
|
21712
|
-
import { join as
|
|
21786
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
|
|
21787
|
+
import { join as join48 } from "path";
|
|
21713
21788
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
21714
21789
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
21715
21790
|
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
21716
|
-
var noopRunsPath = (stateDir) =>
|
|
21791
|
+
var noopRunsPath = (stateDir) => join48(stateDir, "noop-runs.json");
|
|
21717
21792
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
21718
21793
|
function readNoopRuns(stateDir) {
|
|
21719
21794
|
try {
|
|
21720
|
-
const v = JSON.parse(
|
|
21795
|
+
const v = JSON.parse(readFileSync42(noopRunsPath(stateDir), "utf8"));
|
|
21721
21796
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
21722
21797
|
} catch {
|
|
21723
21798
|
return {};
|
|
21724
21799
|
}
|
|
21725
21800
|
}
|
|
21726
21801
|
function writeNoopRuns(stateDir, state) {
|
|
21727
|
-
|
|
21802
|
+
mkdirSync31(stateDir, { recursive: true });
|
|
21728
21803
|
const file = noopRunsPath(stateDir);
|
|
21729
|
-
|
|
21804
|
+
writeFileSync35(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
21730
21805
|
`);
|
|
21731
|
-
|
|
21806
|
+
renameSync8(`${file}.tmp`, file);
|
|
21732
21807
|
}
|
|
21733
21808
|
function noopBackedOff(stateDir, recordId, now = Date.now()) {
|
|
21734
21809
|
const e = readNoopRuns(stateDir)[recordId];
|
|
@@ -21803,7 +21878,7 @@ async function settleNoopRun(o) {
|
|
|
21803
21878
|
}
|
|
21804
21879
|
|
|
21805
21880
|
// src/ship-name.ts
|
|
21806
|
-
import { existsSync as existsSync44, mkdirSync as
|
|
21881
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
|
|
21807
21882
|
import { dirname as dirname26 } from "path";
|
|
21808
21883
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
21809
21884
|
var ShipNameError = class extends Error {
|
|
@@ -21867,7 +21942,7 @@ async function syncRouteName(i) {
|
|
|
21867
21942
|
function readSyncedName(resolvedFile) {
|
|
21868
21943
|
if (!existsSync44(resolvedFile)) return void 0;
|
|
21869
21944
|
try {
|
|
21870
|
-
const v = JSON.parse(
|
|
21945
|
+
const v = JSON.parse(readFileSync43(resolvedFile, "utf8")).shipName;
|
|
21871
21946
|
return typeof v === "string" ? v : void 0;
|
|
21872
21947
|
} catch {
|
|
21873
21948
|
return void 0;
|
|
@@ -21877,22 +21952,22 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
21877
21952
|
if (!existsSync44(resolvedFile)) return;
|
|
21878
21953
|
let raw;
|
|
21879
21954
|
try {
|
|
21880
|
-
raw = JSON.parse(
|
|
21955
|
+
raw = JSON.parse(readFileSync43(resolvedFile, "utf8"));
|
|
21881
21956
|
} catch {
|
|
21882
21957
|
return;
|
|
21883
21958
|
}
|
|
21884
21959
|
if (raw.shipName === name) return;
|
|
21885
21960
|
raw.shipName = name;
|
|
21886
|
-
|
|
21961
|
+
mkdirSync32(dirname26(resolvedFile), { recursive: true });
|
|
21887
21962
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
21888
|
-
|
|
21963
|
+
writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
|
|
21889
21964
|
`);
|
|
21890
|
-
|
|
21965
|
+
renameSync9(tmp, resolvedFile);
|
|
21891
21966
|
}
|
|
21892
21967
|
async function reconcileShipName(i) {
|
|
21893
21968
|
let local = i.ship.name;
|
|
21894
21969
|
try {
|
|
21895
|
-
local = shipNameOfYaml(
|
|
21970
|
+
local = shipNameOfYaml(readFileSync43(i.configFile, "utf8")) ?? local;
|
|
21896
21971
|
} catch {
|
|
21897
21972
|
}
|
|
21898
21973
|
const resolvedFile = resolvedPathFor(i.stateDir, i.route);
|
|
@@ -21916,8 +21991,8 @@ async function reconcileShipName(i) {
|
|
|
21916
21991
|
}
|
|
21917
21992
|
if (result.status !== "ok") return result;
|
|
21918
21993
|
if (result.action === "adopt" || result.action === "row-wins") {
|
|
21919
|
-
const text2 =
|
|
21920
|
-
|
|
21994
|
+
const text2 = readFileSync43(i.configFile, "utf8");
|
|
21995
|
+
writeFileSync36(i.configFile, setShipNameInYaml(text2, result.name));
|
|
21921
21996
|
i.ship.name = result.name;
|
|
21922
21997
|
if (result.action === "row-wins") {
|
|
21923
21998
|
i.emit?.warn(
|
|
@@ -21965,7 +22040,7 @@ async function reconcileRouteShipName(o) {
|
|
|
21965
22040
|
import { existsSync as existsSync45 } from "fs";
|
|
21966
22041
|
|
|
21967
22042
|
// src/passenger-mirror.ts
|
|
21968
|
-
import { mkdirSync as
|
|
22043
|
+
import { mkdirSync as mkdirSync33 } from "fs";
|
|
21969
22044
|
import { dirname as dirname27 } from "path";
|
|
21970
22045
|
function mirrorRepoOf(spec) {
|
|
21971
22046
|
const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
|
|
@@ -21985,8 +22060,8 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
|
|
|
21985
22060
|
}
|
|
21986
22061
|
try {
|
|
21987
22062
|
const parent = dirname27(spec.dir);
|
|
21988
|
-
|
|
21989
|
-
|
|
22063
|
+
mkdirSync33(parent, { recursive: true });
|
|
22064
|
+
mkdirSync33(spec.dir, { recursive: true });
|
|
21990
22065
|
const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
|
|
21991
22066
|
out.push({ ...base, action: r.changed ? "updated" : "unchanged", detail: r.tip });
|
|
21992
22067
|
} catch (e) {
|
|
@@ -22084,18 +22159,18 @@ function explainRefusal(readable, unreadable) {
|
|
|
22084
22159
|
|
|
22085
22160
|
// src/ssh-keys.ts
|
|
22086
22161
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
22087
|
-
import { existsSync as existsSync46, mkdirSync as
|
|
22088
|
-
import { dirname as dirname28, join as
|
|
22162
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
22163
|
+
import { dirname as dirname28, join as join49 } from "path";
|
|
22089
22164
|
var SshKeyError = class extends Error {
|
|
22090
22165
|
};
|
|
22091
22166
|
function shipSshKeyPathFor(stateDir) {
|
|
22092
|
-
return
|
|
22167
|
+
return join49(stateDir, "ssh", "id_ed25519");
|
|
22093
22168
|
}
|
|
22094
22169
|
function ensureShipSshKeypair(stateDir) {
|
|
22095
22170
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
22096
22171
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
22097
22172
|
if (!existsSync46(privateKeyPath)) {
|
|
22098
|
-
|
|
22173
|
+
mkdirSync34(dirname28(privateKeyPath), { recursive: true });
|
|
22099
22174
|
try {
|
|
22100
22175
|
execFileSync13("ssh-keygen", [
|
|
22101
22176
|
"-t",
|
|
@@ -22118,7 +22193,7 @@ function ensureShipSshKeypair(stateDir) {
|
|
|
22118
22193
|
if (!existsSync46(publicKeyPath)) {
|
|
22119
22194
|
throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
|
|
22120
22195
|
}
|
|
22121
|
-
const publicKey =
|
|
22196
|
+
const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
|
|
22122
22197
|
return { privateKeyPath, publicKeyPath, publicKey };
|
|
22123
22198
|
}
|
|
22124
22199
|
function sshKeygenAvailable() {
|
|
@@ -22133,7 +22208,7 @@ function sshKeygenAvailable() {
|
|
|
22133
22208
|
// src/periscope-idle.ts
|
|
22134
22209
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
22135
22210
|
import { statSync as statSync13 } from "fs";
|
|
22136
|
-
import { join as
|
|
22211
|
+
import { join as join50 } from "path";
|
|
22137
22212
|
var MAX_SCANNED_FILES = 2e4;
|
|
22138
22213
|
function newestWorktreeMtime(root) {
|
|
22139
22214
|
const a = newestTrackedMtime(root);
|
|
@@ -22158,7 +22233,7 @@ function newestTrackedMtime(root) {
|
|
|
22158
22233
|
if (!rel) continue;
|
|
22159
22234
|
if (++scanned > MAX_SCANNED_FILES) break;
|
|
22160
22235
|
try {
|
|
22161
|
-
const m = statSync13(
|
|
22236
|
+
const m = statSync13(join50(root, rel)).mtimeMs;
|
|
22162
22237
|
if (newest === null || m > newest) newest = m;
|
|
22163
22238
|
} catch {
|
|
22164
22239
|
}
|
|
@@ -22232,8 +22307,8 @@ async function runPeriscopeIdlePass(d) {
|
|
|
22232
22307
|
}
|
|
22233
22308
|
|
|
22234
22309
|
// src/periscope-cmd.ts
|
|
22235
|
-
import { existsSync as existsSync47, mkdirSync as
|
|
22236
|
-
import { join as
|
|
22310
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
|
|
22311
|
+
import { join as join51 } from "path";
|
|
22237
22312
|
var PeriscopeError = class extends Error {
|
|
22238
22313
|
};
|
|
22239
22314
|
var LivePeriscopeError = class extends PeriscopeError {
|
|
@@ -22243,22 +22318,22 @@ var LivePeriscopeError = class extends PeriscopeError {
|
|
|
22243
22318
|
this.data = { refused: "live_periscope_exists", ...live2 };
|
|
22244
22319
|
}
|
|
22245
22320
|
};
|
|
22246
|
-
var priorDir = (stateDir) =>
|
|
22247
|
-
var priorPath = (stateDir, ticketRecordId) =>
|
|
22321
|
+
var priorDir = (stateDir) => join51(stateDir, "periscope-priors");
|
|
22322
|
+
var priorPath = (stateDir, ticketRecordId) => join51(priorDir(stateDir), `${ticketRecordId}.json`);
|
|
22248
22323
|
function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
22249
|
-
|
|
22324
|
+
rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
|
|
22250
22325
|
}
|
|
22251
22326
|
function writePeriscopePrior(stateDir, ticketRecordId, prior) {
|
|
22252
22327
|
try {
|
|
22253
|
-
|
|
22254
|
-
|
|
22328
|
+
mkdirSync35(priorDir(stateDir), { recursive: true });
|
|
22329
|
+
writeFileSync37(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
|
|
22255
22330
|
} catch {
|
|
22256
22331
|
}
|
|
22257
22332
|
}
|
|
22258
22333
|
function readPeriscopePrior(stateDir, ticketRecordId) {
|
|
22259
22334
|
try {
|
|
22260
22335
|
const p = priorPath(stateDir, ticketRecordId);
|
|
22261
|
-
return existsSync47(p) ? JSON.parse(
|
|
22336
|
+
return existsSync47(p) ? JSON.parse(readFileSync45(p, "utf8")) : void 0;
|
|
22262
22337
|
} catch {
|
|
22263
22338
|
return void 0;
|
|
22264
22339
|
}
|
|
@@ -22828,7 +22903,7 @@ function latestMtime(path) {
|
|
|
22828
22903
|
if (!stat2.isDirectory()) return 0;
|
|
22829
22904
|
let latest = stat2.mtimeMs;
|
|
22830
22905
|
for (const entry of readdirSync15(path, { withFileTypes: true })) {
|
|
22831
|
-
latest = Math.max(latest, latestMtime(
|
|
22906
|
+
latest = Math.max(latest, latestMtime(join52(path, entry.name)));
|
|
22832
22907
|
}
|
|
22833
22908
|
return latest;
|
|
22834
22909
|
}
|
|
@@ -22840,7 +22915,7 @@ function makeStaleChecker(paths, opts = {}) {
|
|
|
22840
22915
|
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
|
|
22841
22916
|
}
|
|
22842
22917
|
function reloadSentinelFor(stateDir) {
|
|
22843
|
-
return
|
|
22918
|
+
return join52(stateDir, "reload-requested");
|
|
22844
22919
|
}
|
|
22845
22920
|
function readReloadRequestedAt(stateDir) {
|
|
22846
22921
|
try {
|
|
@@ -22850,17 +22925,17 @@ function readReloadRequestedAt(stateDir) {
|
|
|
22850
22925
|
}
|
|
22851
22926
|
}
|
|
22852
22927
|
function daemonStampFor(stateDir) {
|
|
22853
|
-
return
|
|
22928
|
+
return join52(stateDir, "daemon.started");
|
|
22854
22929
|
}
|
|
22855
22930
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
|
|
22931
|
+
mkdirSync36(stateDir, { recursive: true });
|
|
22932
|
+
rmSync23(reloadSentinelFor(stateDir), { force: true });
|
|
22933
|
+
writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
22859
22934
|
`);
|
|
22860
22935
|
}
|
|
22861
22936
|
function readDaemonStarted(stateDir) {
|
|
22862
22937
|
try {
|
|
22863
|
-
const v = JSON.parse(
|
|
22938
|
+
const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
22864
22939
|
return typeof v === "number" ? v : null;
|
|
22865
22940
|
} catch {
|
|
22866
22941
|
return null;
|
|
@@ -23717,7 +23792,7 @@ function parseSystemctlShow(text2) {
|
|
|
23717
23792
|
}
|
|
23718
23793
|
function lastLogLine(path, read = (p) => {
|
|
23719
23794
|
try {
|
|
23720
|
-
return
|
|
23795
|
+
return readFileSync47(p, "utf8");
|
|
23721
23796
|
} catch {
|
|
23722
23797
|
return null;
|
|
23723
23798
|
}
|
|
@@ -23794,7 +23869,7 @@ function daemonProblem(d, route2) {
|
|
|
23794
23869
|
}
|
|
23795
23870
|
function readDaemonStamp(stateDir) {
|
|
23796
23871
|
try {
|
|
23797
|
-
const v = JSON.parse(
|
|
23872
|
+
const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8"));
|
|
23798
23873
|
if (typeof v.startedAt !== "number") return null;
|
|
23799
23874
|
return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
|
|
23800
23875
|
} catch {
|
|
@@ -23823,7 +23898,7 @@ function defaultSleep2(ms3) {
|
|
|
23823
23898
|
}
|
|
23824
23899
|
function defaultReadLog(path) {
|
|
23825
23900
|
try {
|
|
23826
|
-
return
|
|
23901
|
+
return readFileSync48(path, "utf8");
|
|
23827
23902
|
} catch {
|
|
23828
23903
|
return null;
|
|
23829
23904
|
}
|
|
@@ -23890,15 +23965,15 @@ function startLaunchdDaemon(o) {
|
|
|
23890
23965
|
}
|
|
23891
23966
|
|
|
23892
23967
|
// src/daemon-start-failure.ts
|
|
23893
|
-
import { existsSync as existsSync50, mkdirSync as
|
|
23894
|
-
import { dirname as dirname29, join as
|
|
23968
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
|
|
23969
|
+
import { dirname as dirname29, join as join53 } from "path";
|
|
23895
23970
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
23896
23971
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
23897
23972
|
var BACKOFF_AFTER_FAILURES = 2;
|
|
23898
|
-
var
|
|
23973
|
+
var fileFor4 = (stateDir) => join53(stateDir, ".daemon-start-failure.json");
|
|
23899
23974
|
function readStartFailure(stateDir) {
|
|
23900
23975
|
try {
|
|
23901
|
-
const parsed = JSON.parse(
|
|
23976
|
+
const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
|
|
23902
23977
|
return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
|
|
23903
23978
|
} catch {
|
|
23904
23979
|
return null;
|
|
@@ -23914,8 +23989,8 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
|
23914
23989
|
firstAt: same ? previous.firstAt : nowIso,
|
|
23915
23990
|
lastAt: nowIso
|
|
23916
23991
|
};
|
|
23917
|
-
|
|
23918
|
-
|
|
23992
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
23993
|
+
writeFileSync39(fileFor4(stateDir), JSON.stringify(record));
|
|
23919
23994
|
return record;
|
|
23920
23995
|
}
|
|
23921
23996
|
function startFailureDelayMs(count) {
|
|
@@ -23929,9 +24004,9 @@ function startFailureItem(record, o = {}) {
|
|
|
23929
24004
|
return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
|
|
23930
24005
|
}
|
|
23931
24006
|
function clearStartFailure(state, stateDir) {
|
|
23932
|
-
if (existsSync50(
|
|
24007
|
+
if (existsSync50(fileFor4(stateDir))) {
|
|
23933
24008
|
try {
|
|
23934
|
-
unlinkSync4(
|
|
24009
|
+
unlinkSync4(fileFor4(stateDir));
|
|
23935
24010
|
} catch {
|
|
23936
24011
|
}
|
|
23937
24012
|
}
|
|
@@ -23956,7 +24031,7 @@ async function reportStartFailure(o) {
|
|
|
23956
24031
|
return delay;
|
|
23957
24032
|
}
|
|
23958
24033
|
function fallbackStateDir(configFile) {
|
|
23959
|
-
return
|
|
24034
|
+
return join53(dirname29(configFile), "state");
|
|
23960
24035
|
}
|
|
23961
24036
|
|
|
23962
24037
|
// src/projects-cmd.ts
|
|
@@ -24070,7 +24145,7 @@ function runForge(a, io) {
|
|
|
24070
24145
|
|
|
24071
24146
|
// src/release-sandbox.ts
|
|
24072
24147
|
import { execFile as execFile5 } from "child_process";
|
|
24073
|
-
import { mkdirSync as
|
|
24148
|
+
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
|
|
24074
24149
|
import { dirname as dirname30 } from "path";
|
|
24075
24150
|
import { promisify as promisify4 } from "util";
|
|
24076
24151
|
var execFileP4 = promisify4(execFile5);
|
|
@@ -24117,8 +24192,8 @@ async function openReleaseSandbox(o) {
|
|
|
24117
24192
|
if (!policyFile) {
|
|
24118
24193
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
24119
24194
|
policyFile = o.policyFile;
|
|
24120
|
-
|
|
24121
|
-
|
|
24195
|
+
mkdirSync38(dirname30(policyFile), { recursive: true });
|
|
24196
|
+
writeFileSync40(policyFile, generated.yaml, { mode: 384 });
|
|
24122
24197
|
}
|
|
24123
24198
|
const secrets = { ...process.env };
|
|
24124
24199
|
const secretKeys = [];
|
|
@@ -25202,13 +25277,13 @@ function describeCapability(i) {
|
|
|
25202
25277
|
}
|
|
25203
25278
|
|
|
25204
25279
|
// src/persona-avatars.ts
|
|
25205
|
-
import { existsSync as existsSync52, readFileSync as
|
|
25206
|
-
import { join as
|
|
25280
|
+
import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
|
|
25281
|
+
import { join as join54 } from "path";
|
|
25207
25282
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
25208
25283
|
function personaAvatarFile(promptsDir, role) {
|
|
25209
25284
|
for (const ext of ["png", "svg"]) {
|
|
25210
25285
|
const name = `lane-${role}.${ext}`;
|
|
25211
|
-
const path =
|
|
25286
|
+
const path = join54(promptsDir, "personas", name);
|
|
25212
25287
|
if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
25213
25288
|
}
|
|
25214
25289
|
return void 0;
|
|
@@ -25223,7 +25298,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
|
25223
25298
|
if (!file || !agentId) continue;
|
|
25224
25299
|
try {
|
|
25225
25300
|
const form = new FormData();
|
|
25226
|
-
form.append("file", new Blob([
|
|
25301
|
+
form.append("file", new Blob([readFileSync50(file.path)], { type: file.mimeType }), file.name);
|
|
25227
25302
|
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
25228
25303
|
method: "PUT",
|
|
25229
25304
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
@@ -25264,14 +25339,14 @@ function avatarFailures(raw) {
|
|
|
25264
25339
|
}
|
|
25265
25340
|
function routeAvatarFailures(stateDir, route2) {
|
|
25266
25341
|
try {
|
|
25267
|
-
return avatarFailures(JSON.parse(
|
|
25342
|
+
return avatarFailures(JSON.parse(readFileSync50(resolvedPathFor(stateDir, route2), "utf8")));
|
|
25268
25343
|
} catch {
|
|
25269
25344
|
return [];
|
|
25270
25345
|
}
|
|
25271
25346
|
}
|
|
25272
25347
|
|
|
25273
25348
|
// src/agents-sync-run.ts
|
|
25274
|
-
import { existsSync as existsSync53, mkdirSync as
|
|
25349
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
25275
25350
|
import { dirname as dirname31 } from "path";
|
|
25276
25351
|
async function runAgentsSync(target, o) {
|
|
25277
25352
|
const dryRun = o.dryRun ?? false;
|
|
@@ -25317,13 +25392,13 @@ async function runAgentsSync(target, o) {
|
|
|
25317
25392
|
}
|
|
25318
25393
|
if (!dryRun) {
|
|
25319
25394
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
25320
|
-
const raw = existsSync53(resolvedPath) ? JSON.parse(
|
|
25395
|
+
const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync51(resolvedPath, "utf8")) : {};
|
|
25321
25396
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
25322
25397
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
25323
25398
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
25324
25399
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
25325
|
-
|
|
25326
|
-
|
|
25400
|
+
mkdirSync39(dirname31(resolvedPath), { recursive: true });
|
|
25401
|
+
writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
25327
25402
|
`);
|
|
25328
25403
|
if (target.resolved) {
|
|
25329
25404
|
target.resolved.agentPersonas = personaResult.agentPersonas;
|
|
@@ -25460,7 +25535,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
25460
25535
|
|
|
25461
25536
|
// src/repos-check.ts
|
|
25462
25537
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
25463
|
-
import { readFileSync as
|
|
25538
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
25464
25539
|
import { basename as basename12 } from "path";
|
|
25465
25540
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
25466
25541
|
function checkHookSyntax(script, shell) {
|
|
@@ -25501,7 +25576,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
25501
25576
|
}
|
|
25502
25577
|
let parsed;
|
|
25503
25578
|
try {
|
|
25504
|
-
parsed = parseRepoConfig(
|
|
25579
|
+
parsed = parseRepoConfig(readFileSync52(file, "utf8"), file);
|
|
25505
25580
|
} catch (e) {
|
|
25506
25581
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
25507
25582
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -25965,7 +26040,7 @@ ${run4.err}` });
|
|
|
25965
26040
|
}
|
|
25966
26041
|
|
|
25967
26042
|
// src/sample-ticket.ts
|
|
25968
|
-
import { basename as basename13, dirname as dirname32, join as
|
|
26043
|
+
import { basename as basename13, dirname as dirname32, join as join55 } from "path";
|
|
25969
26044
|
var SAMPLE_REPO = "crew-sample";
|
|
25970
26045
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
25971
26046
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -25988,8 +26063,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
25988
26063
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
25989
26064
|
`;
|
|
25990
26065
|
function sampleDir(existing, reposBase, workspace) {
|
|
25991
|
-
if (existing.length > 0) return
|
|
25992
|
-
return
|
|
26066
|
+
if (existing.length > 0) return join55(dirname32(existing[0]), SAMPLE_REPO);
|
|
26067
|
+
return join55(reposBase, workspace, SAMPLE_REPO);
|
|
25993
26068
|
}
|
|
25994
26069
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
25995
26070
|
function sampleDescription() {
|
|
@@ -26033,8 +26108,8 @@ function planSampleTicket(i) {
|
|
|
26033
26108
|
}
|
|
26034
26109
|
|
|
26035
26110
|
// src/worktree-sweep.ts
|
|
26036
|
-
import { existsSync as existsSync54, readFileSync as
|
|
26037
|
-
import { basename as basename14, dirname as dirname33, join as
|
|
26111
|
+
import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync16 } from "fs";
|
|
26112
|
+
import { basename as basename14, dirname as dirname33, join as join56, resolve as resolve5 } from "path";
|
|
26038
26113
|
function planWorktreeSweep(target, tickets, contract) {
|
|
26039
26114
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
26040
26115
|
const verified = contract.statuses.verified;
|
|
@@ -26111,7 +26186,7 @@ function siblingWorktreeDirs(target) {
|
|
|
26111
26186
|
for (const name of names) {
|
|
26112
26187
|
if (!name.startsWith(stem)) continue;
|
|
26113
26188
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
26114
|
-
const path =
|
|
26189
|
+
const path = join56(parent, name);
|
|
26115
26190
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
26116
26191
|
}
|
|
26117
26192
|
return out;
|
|
@@ -26233,7 +26308,7 @@ function isHandBackMerge(path, base) {
|
|
|
26233
26308
|
if (!msgPath) return false;
|
|
26234
26309
|
let first;
|
|
26235
26310
|
try {
|
|
26236
|
-
first =
|
|
26311
|
+
first = readFileSync53(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
26237
26312
|
} catch {
|
|
26238
26313
|
return false;
|
|
26239
26314
|
}
|
|
@@ -26338,14 +26413,14 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
26338
26413
|
}
|
|
26339
26414
|
|
|
26340
26415
|
// src/stream-sweep.ts
|
|
26341
|
-
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as
|
|
26342
|
-
import { join as
|
|
26416
|
+
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
|
|
26417
|
+
import { join as join57 } from "path";
|
|
26343
26418
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
26344
26419
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26345
|
-
const dir =
|
|
26420
|
+
const dir = join57(stateDir, "streams");
|
|
26346
26421
|
if (!existsSync55(dir)) return [];
|
|
26347
26422
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26348
|
-
return readdirSync17(dir).map((name) =>
|
|
26423
|
+
return readdirSync17(dir).map((name) => join57(dir, name)).filter((path) => {
|
|
26349
26424
|
try {
|
|
26350
26425
|
return statSync16(path).mtimeMs < cutoff;
|
|
26351
26426
|
} catch {
|
|
@@ -26361,7 +26436,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26361
26436
|
continue;
|
|
26362
26437
|
}
|
|
26363
26438
|
try {
|
|
26364
|
-
|
|
26439
|
+
rmSync24(path, { force: true });
|
|
26365
26440
|
removed++;
|
|
26366
26441
|
log.emit(`removed stream artifact ${path}`, { step: "worktree" });
|
|
26367
26442
|
} catch (e) {
|
|
@@ -26373,7 +26448,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26373
26448
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26374
26449
|
if (!existsSync55(stateDir)) return [];
|
|
26375
26450
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26376
|
-
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
26451
|
+
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join57(stateDir, name)).filter((path) => {
|
|
26377
26452
|
try {
|
|
26378
26453
|
return statSync16(path).mtimeMs < cutoff;
|
|
26379
26454
|
} catch {
|
|
@@ -26383,7 +26458,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
26383
26458
|
}
|
|
26384
26459
|
|
|
26385
26460
|
// src/cli.ts
|
|
26386
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
26461
|
+
import { realpathSync as realpathSync3, readFileSync as readFileSync56, 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";
|
|
26387
26462
|
import { createInterface } from "readline/promises";
|
|
26388
26463
|
|
|
26389
26464
|
// src/periscope-resume.ts
|
|
@@ -26460,9 +26535,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
26460
26535
|
|
|
26461
26536
|
// src/bundle-staleness.ts
|
|
26462
26537
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
26463
|
-
import { join as
|
|
26538
|
+
import { join as join58 } from "path";
|
|
26464
26539
|
function builtVersion() {
|
|
26465
|
-
return true ? "0.
|
|
26540
|
+
return true ? "0.146.0" : null;
|
|
26466
26541
|
}
|
|
26467
26542
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
26468
26543
|
function newestMtime(path) {
|
|
@@ -26475,17 +26550,17 @@ function newestMtime(path) {
|
|
|
26475
26550
|
if (stat2.isFile()) return stat2.mtimeMs;
|
|
26476
26551
|
if (!stat2.isDirectory()) return 0;
|
|
26477
26552
|
let latest = stat2.mtimeMs;
|
|
26478
|
-
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(
|
|
26553
|
+
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join58(path, e.name)));
|
|
26479
26554
|
return latest;
|
|
26480
26555
|
}
|
|
26481
26556
|
function bundleStaleness(i) {
|
|
26482
26557
|
if (i.built === null || i.compiled) return null;
|
|
26483
|
-
const src =
|
|
26558
|
+
const src = join58(i.home, "src");
|
|
26484
26559
|
if (!existsSync56(src)) return null;
|
|
26485
26560
|
if (i.built !== i.current) {
|
|
26486
26561
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
26487
26562
|
}
|
|
26488
|
-
const bundle = statSafe(
|
|
26563
|
+
const bundle = statSafe(join58(i.home, "dist", "cli.js"));
|
|
26489
26564
|
if (bundle === null) return null;
|
|
26490
26565
|
if (newestMtime(src) > bundle) {
|
|
26491
26566
|
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
@@ -26652,8 +26727,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
26652
26727
|
import { createServer as createHttpServer } from "http";
|
|
26653
26728
|
import { spawn as spawn9 } from "child_process";
|
|
26654
26729
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
26655
|
-
import { existsSync as existsSync57, mkdirSync as
|
|
26656
|
-
import { join as
|
|
26730
|
+
import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync54, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
|
|
26731
|
+
import { join as join59 } from "path";
|
|
26657
26732
|
|
|
26658
26733
|
// src/secret-compare.ts
|
|
26659
26734
|
import { timingSafeEqual } from "crypto";
|
|
@@ -26746,21 +26821,21 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
26746
26821
|
return child;
|
|
26747
26822
|
};
|
|
26748
26823
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
26749
|
-
return
|
|
26824
|
+
return join59(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
26750
26825
|
}
|
|
26751
26826
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
26752
26827
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
26753
26828
|
if (!existsSync57(path)) return void 0;
|
|
26754
26829
|
try {
|
|
26755
|
-
return JSON.parse(
|
|
26830
|
+
return JSON.parse(readFileSync54(path, "utf8"));
|
|
26756
26831
|
} catch {
|
|
26757
26832
|
return void 0;
|
|
26758
26833
|
}
|
|
26759
26834
|
}
|
|
26760
26835
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
26761
26836
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
26762
|
-
|
|
26763
|
-
|
|
26837
|
+
mkdirSync40(join59(stateDir, "passengers"), { recursive: true });
|
|
26838
|
+
writeFileSync42(path, `${JSON.stringify(state, null, 2)}
|
|
26764
26839
|
`);
|
|
26765
26840
|
}
|
|
26766
26841
|
function removePersistedSyncDaemon(stateDir, workspaceId) {
|
|
@@ -26780,7 +26855,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
26780
26855
|
}
|
|
26781
26856
|
}
|
|
26782
26857
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
26783
|
-
const dir =
|
|
26858
|
+
const dir = join59(stateDir, "passengers");
|
|
26784
26859
|
if (!existsSync57(dir)) return [];
|
|
26785
26860
|
const suffix = "-sync.json";
|
|
26786
26861
|
return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
@@ -26839,7 +26914,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
|
|
|
26839
26914
|
|
|
26840
26915
|
// src/periscope-proxy.ts
|
|
26841
26916
|
import { spawn as spawn10 } from "child_process";
|
|
26842
|
-
import { appendFileSync as
|
|
26917
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
|
|
26843
26918
|
import { createServer, request as httpRequest } from "http";
|
|
26844
26919
|
import { request as httpsRequest } from "https";
|
|
26845
26920
|
import { connect as netConnect } from "net";
|
|
@@ -26958,8 +27033,8 @@ function parsePointedBody(raw) {
|
|
|
26958
27033
|
return entry;
|
|
26959
27034
|
}
|
|
26960
27035
|
function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
|
|
26961
|
-
|
|
26962
|
-
|
|
27036
|
+
mkdirSync41(dirname34(file), { recursive: true });
|
|
27037
|
+
appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
|
|
26963
27038
|
`);
|
|
26964
27039
|
}
|
|
26965
27040
|
var CSP_DIRECTIVES = /* @__PURE__ */ new Set(["default-src", "script-src", "script-src-elem", "connect-src"]);
|
|
@@ -27247,7 +27322,7 @@ async function startWorktreeIntel(d) {
|
|
|
27247
27322
|
}
|
|
27248
27323
|
|
|
27249
27324
|
// src/contract-refusal.ts
|
|
27250
|
-
import { join as
|
|
27325
|
+
import { join as join60 } from "path";
|
|
27251
27326
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
27252
27327
|
const out = [];
|
|
27253
27328
|
for (const t of tickets) {
|
|
@@ -27259,7 +27334,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
27259
27334
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
27260
27335
|
if (text2 === null) continue;
|
|
27261
27336
|
try {
|
|
27262
|
-
parseRepoConfig(text2,
|
|
27337
|
+
parseRepoConfig(text2, join60(dir, file));
|
|
27263
27338
|
} catch (e) {
|
|
27264
27339
|
if (e instanceof RepoConfigError) continue;
|
|
27265
27340
|
throw e;
|
|
@@ -27279,13 +27354,13 @@ import {
|
|
|
27279
27354
|
openSync as openSync7,
|
|
27280
27355
|
readSync as readSync4,
|
|
27281
27356
|
readdirSync as readdirSync20,
|
|
27282
|
-
rmSync as
|
|
27357
|
+
rmSync as rmSync25,
|
|
27283
27358
|
statSync as statSync18,
|
|
27284
27359
|
watch
|
|
27285
27360
|
} from "fs";
|
|
27286
27361
|
import { createConnection } from "net";
|
|
27287
27362
|
import { createServer as createServer2 } from "http";
|
|
27288
|
-
import { basename as basename15, dirname as dirname35, join as
|
|
27363
|
+
import { basename as basename15, dirname as dirname35, join as join61 } from "path";
|
|
27289
27364
|
import { execFile as execFile6, spawn as spawn12 } from "child_process";
|
|
27290
27365
|
|
|
27291
27366
|
// src/periscope-control.ts
|
|
@@ -27522,7 +27597,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
27522
27597
|
// src/control-api.ts
|
|
27523
27598
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
27524
27599
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
27525
|
-
var controlSocketFor = (stateDir) =>
|
|
27600
|
+
var controlSocketFor = (stateDir) => join61(stateDir, CONTROL_SOCKET_NAME);
|
|
27526
27601
|
var MAX_SOCKET_PATH = 100;
|
|
27527
27602
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
27528
27603
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -27609,7 +27684,7 @@ function candidates(live2, rotated) {
|
|
|
27609
27684
|
const out = [live2];
|
|
27610
27685
|
if (!rotated) return out;
|
|
27611
27686
|
try {
|
|
27612
|
-
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(
|
|
27687
|
+
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join61(dirname35(live2), n));
|
|
27613
27688
|
} catch {
|
|
27614
27689
|
}
|
|
27615
27690
|
return out;
|
|
@@ -27775,6 +27850,7 @@ async function tailReply(path, q2, rotated, abort) {
|
|
|
27775
27850
|
return reply2(200, r);
|
|
27776
27851
|
}
|
|
27777
27852
|
var NOTE_MAX_CHARS = 4e3;
|
|
27853
|
+
var SEAT_ROLES = ["dev", "design", "qa", "triage", "pair"];
|
|
27778
27854
|
async function postRunMessage(deps, run4, body) {
|
|
27779
27855
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..")) return err2(400, "not a run name");
|
|
27780
27856
|
const live2 = liveRuns(deps.stateDir).find((r) => basename15(r.streamPath, ".jsonl") === run4.replace(/\.jsonl$/, ""));
|
|
@@ -27804,6 +27880,25 @@ async function postRunMessage(deps, run4, body) {
|
|
|
27804
27880
|
return err2(409, `the platform did not take the note: ${e.message}. ${carry}`);
|
|
27805
27881
|
}
|
|
27806
27882
|
}
|
|
27883
|
+
function postSeatNote(deps, role, body) {
|
|
27884
|
+
if (!SEAT_ROLES.includes(role)) return err2(400, `role must be one of ${SEAT_ROLES.join(", ")}`);
|
|
27885
|
+
if (!body) return err2(400, "body must be a small JSON object");
|
|
27886
|
+
const text2 = typeof body.text === "string" ? body.text.trim() : "";
|
|
27887
|
+
if (!text2 || text2.length > NOTE_MAX_CHARS) return err2(400, `text must be a string of 1 to ${NOTE_MAX_CHARS} characters`);
|
|
27888
|
+
if (body.author !== void 0 && typeof body.author !== "string") return err2(400, "author must be a string");
|
|
27889
|
+
if (body.ticket !== void 0 && (typeof body.ticket !== "string" || !body.ticket.trim() || body.ticket.length > 64)) return err2(400, "ticket must be a ticket tag");
|
|
27890
|
+
try {
|
|
27891
|
+
const note = addSeatNote(deps.stateDir, {
|
|
27892
|
+
role,
|
|
27893
|
+
text: text2,
|
|
27894
|
+
...body.ticket ? { ticket: body.ticket.trim() } : {},
|
|
27895
|
+
...body.author ? { author: body.author.trim() } : {}
|
|
27896
|
+
});
|
|
27897
|
+
return reply2(200, { id: note.id, state: "carried_forward", carriedForward: true });
|
|
27898
|
+
} catch (e) {
|
|
27899
|
+
return err2(500, `could not store the note: ${e.message}`);
|
|
27900
|
+
}
|
|
27901
|
+
}
|
|
27807
27902
|
async function route(deps, method, url, req, abort) {
|
|
27808
27903
|
const p = url.pathname.replace(/\/+$/, "") || "/";
|
|
27809
27904
|
const get2 = method === "GET";
|
|
@@ -27839,12 +27934,14 @@ async function route(deps, method, url, req, abort) {
|
|
|
27839
27934
|
if (p.startsWith("/streams/") && get2) {
|
|
27840
27935
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
27841
27936
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
27842
|
-
const file =
|
|
27937
|
+
const file = join61(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
27843
27938
|
if (!existsSync58(file)) return err2(404, "no such run");
|
|
27844
27939
|
return tailReply(file, url.searchParams, false, abort);
|
|
27845
27940
|
}
|
|
27846
27941
|
const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
|
|
27847
27942
|
if (note && post3) return postRunMessage(deps, decodeURIComponent(note[1]), await readJsonBody(req));
|
|
27943
|
+
const seatNote = /^\/seats\/([^/]+)\/notes$/.exec(p);
|
|
27944
|
+
if (seatNote && post3) return postSeatNote(deps, decodeURIComponent(seatNote[1]), await readJsonBody(req));
|
|
27848
27945
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
27849
27946
|
const body = await readJsonBody(req);
|
|
27850
27947
|
if (!body) return err2(400, "body must be a small JSON object");
|
|
@@ -27869,7 +27966,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
27869
27966
|
}
|
|
27870
27967
|
if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
|
|
27871
27968
|
const known = ["/status", "/events", "/streams", "/pause", "/resume", "/release/pause", "/release/resume", "/doctor", ...deps.diagnostics ? ["/diagnostics"] : []];
|
|
27872
|
-
if (known.includes(p) || p.startsWith("/streams/") || sched) return err2(405, "method not allowed");
|
|
27969
|
+
if (known.includes(p) || p.startsWith("/streams/") || seatNote || sched) return err2(405, "method not allowed");
|
|
27873
27970
|
return err2(404, "not found");
|
|
27874
27971
|
}
|
|
27875
27972
|
function send2(res, r) {
|
|
@@ -27905,7 +28002,7 @@ async function startControlServer(deps) {
|
|
|
27905
28002
|
log(`control API not started: socket path is too long for a unix socket (${path})`);
|
|
27906
28003
|
return null;
|
|
27907
28004
|
}
|
|
27908
|
-
if (await socketIsStale(path))
|
|
28005
|
+
if (await socketIsStale(path)) rmSync25(path, { force: true });
|
|
27909
28006
|
else if (existsSync58(path)) {
|
|
27910
28007
|
log(`control API not started: ${path} is in use by another process`);
|
|
27911
28008
|
return null;
|
|
@@ -27952,7 +28049,7 @@ async function startControlServer(deps) {
|
|
|
27952
28049
|
path,
|
|
27953
28050
|
close: () => new Promise((done) => {
|
|
27954
28051
|
server.close(() => {
|
|
27955
|
-
|
|
28052
|
+
rmSync25(path, { force: true });
|
|
27956
28053
|
done();
|
|
27957
28054
|
});
|
|
27958
28055
|
})
|
|
@@ -27992,53 +28089,53 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
27992
28089
|
|
|
27993
28090
|
// src/periscope-mcp.ts
|
|
27994
28091
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
27995
|
-
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as
|
|
28092
|
+
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join63, relative as relative2, resolve as resolve6, sep } from "path";
|
|
27996
28093
|
import { z } from "zod";
|
|
27997
28094
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
27998
28095
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
27999
28096
|
|
|
28000
28097
|
// src/periscope-endpoints.ts
|
|
28001
28098
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
28002
|
-
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as
|
|
28003
|
-
import { join as
|
|
28004
|
-
var secretDir = (stateDir) =>
|
|
28005
|
-
var secretFile = (stateDir, id) =>
|
|
28006
|
-
var endpointDir = (stateDir) =>
|
|
28007
|
-
var endpointFile = (stateDir, id) =>
|
|
28099
|
+
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync55, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
28100
|
+
import { join as join62 } from "path";
|
|
28101
|
+
var secretDir = (stateDir) => join62(stateDir, "periscope-mcp");
|
|
28102
|
+
var secretFile = (stateDir, id) => join62(secretDir(stateDir), `${id}.json`);
|
|
28103
|
+
var endpointDir = (stateDir) => join62(stateDir, "periscope-endpoints");
|
|
28104
|
+
var endpointFile = (stateDir, id) => join62(endpointDir(stateDir), `${id}.json`);
|
|
28008
28105
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
28009
|
-
|
|
28106
|
+
mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
28010
28107
|
const secret = randomBytes3(32).toString("base64url");
|
|
28011
28108
|
const file = secretFile(stateDir, ticketRecordId);
|
|
28012
|
-
|
|
28109
|
+
writeFileSync43(file, `${JSON.stringify({ secret })}
|
|
28013
28110
|
`, { mode: 384 });
|
|
28014
28111
|
chmodSync5(file, 384);
|
|
28015
28112
|
return secret;
|
|
28016
28113
|
}
|
|
28017
28114
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
28018
28115
|
try {
|
|
28019
|
-
const v = JSON.parse(
|
|
28116
|
+
const v = JSON.parse(readFileSync55(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
28020
28117
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
28021
28118
|
} catch {
|
|
28022
28119
|
return void 0;
|
|
28023
28120
|
}
|
|
28024
28121
|
}
|
|
28025
28122
|
function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
28026
|
-
|
|
28123
|
+
rmSync26(secretFile(stateDir, ticketRecordId), { force: true });
|
|
28027
28124
|
}
|
|
28028
28125
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
28029
28126
|
try {
|
|
28030
|
-
return JSON.parse(
|
|
28127
|
+
return JSON.parse(readFileSync55(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
28031
28128
|
} catch {
|
|
28032
28129
|
return void 0;
|
|
28033
28130
|
}
|
|
28034
28131
|
}
|
|
28035
28132
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
28036
|
-
|
|
28037
|
-
|
|
28133
|
+
mkdirSync42(endpointDir(stateDir), { recursive: true });
|
|
28134
|
+
writeFileSync43(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
28038
28135
|
`);
|
|
28039
28136
|
}
|
|
28040
28137
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
28041
|
-
|
|
28138
|
+
rmSync26(endpointFile(stateDir, ticketRecordId), { force: true });
|
|
28042
28139
|
}
|
|
28043
28140
|
function listPeriscopeEndpoints(stateDir) {
|
|
28044
28141
|
const dir = endpointDir(stateDir);
|
|
@@ -28145,13 +28242,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
28145
28242
|
let abs;
|
|
28146
28243
|
if (isAbsolute5(requested)) {
|
|
28147
28244
|
abs = resolve6(requested);
|
|
28148
|
-
if (isInside(root, abs)) abs =
|
|
28245
|
+
if (isInside(root, abs)) abs = join63(realRoot, relative2(root, abs));
|
|
28149
28246
|
} else {
|
|
28150
28247
|
abs = resolve6(realRoot, requested);
|
|
28151
28248
|
}
|
|
28152
28249
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28153
28250
|
const { real, rest } = await realAncestor(abs);
|
|
28154
|
-
const final = rest ?
|
|
28251
|
+
const final = rest ? join63(real, rest) : real;
|
|
28155
28252
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28156
28253
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
28157
28254
|
return final;
|
|
@@ -28219,7 +28316,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28219
28316
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
28220
28317
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
28221
28318
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
28222
|
-
const size = (await lstat(
|
|
28319
|
+
const size = (await lstat(join63(abs, e.name))).size;
|
|
28223
28320
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
28224
28321
|
}));
|
|
28225
28322
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -28285,7 +28382,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28285
28382
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
28286
28383
|
}, async ({ path }) => {
|
|
28287
28384
|
const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
|
|
28288
|
-
const abs =
|
|
28385
|
+
const abs = join63(parent, basename16(path));
|
|
28289
28386
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
28290
28387
|
const st = await lstat(abs).catch(() => void 0);
|
|
28291
28388
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -28780,7 +28877,7 @@ if (command === "provision") {
|
|
|
28780
28877
|
process.exit(outcome.code);
|
|
28781
28878
|
}
|
|
28782
28879
|
if (command === "pool-member") {
|
|
28783
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
28880
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync56(0, "utf8"));
|
|
28784
28881
|
if (typeof pool === "string") {
|
|
28785
28882
|
process.stderr.write(`crew pool-member: ${pool}
|
|
28786
28883
|
`);
|
|
@@ -29124,7 +29221,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29124
29221
|
throw e;
|
|
29125
29222
|
}
|
|
29126
29223
|
if (command === "credential") {
|
|
29127
|
-
const r = runCredential(positional[1],
|
|
29224
|
+
const r = runCredential(positional[1], readFileSync56(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
29128
29225
|
process.stdout.write(r.out);
|
|
29129
29226
|
process.stderr.write(r.err);
|
|
29130
29227
|
process.exit(r.code);
|
|
@@ -29136,9 +29233,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
29136
29233
|
forges: cfg.ship.forges,
|
|
29137
29234
|
stateDir: cfg.ship.stateDir,
|
|
29138
29235
|
configFile: cfg.configFile,
|
|
29139
|
-
readFile: (p) =>
|
|
29140
|
-
writeFile: (p, t) =>
|
|
29141
|
-
stdin: () =>
|
|
29236
|
+
readFile: (p) => readFileSync56(p, "utf8"),
|
|
29237
|
+
writeFile: (p, t) => writeFileSync44(p, t),
|
|
29238
|
+
stdin: () => readFileSync56(0, "utf8"),
|
|
29142
29239
|
env: process.env
|
|
29143
29240
|
}
|
|
29144
29241
|
);
|
|
@@ -29477,7 +29574,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29477
29574
|
}
|
|
29478
29575
|
if (host === "linux" && hasSystemd) {
|
|
29479
29576
|
const label = labelFor(CREW_HOME, "run");
|
|
29480
|
-
const staleTimer =
|
|
29577
|
+
const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
29481
29578
|
if (existsSync60(staleTimer)) {
|
|
29482
29579
|
process.stdout.write(
|
|
29483
29580
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
@@ -29560,7 +29657,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29560
29657
|
for (const a of plan.actions) {
|
|
29561
29658
|
if (a.kind === "enable") {
|
|
29562
29659
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
29563
|
-
|
|
29660
|
+
writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
|
|
29564
29661
|
enabledSound.add(a.route);
|
|
29565
29662
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
29566
29663
|
} else {
|
|
@@ -29789,7 +29886,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
29789
29886
|
harnessBin: "claude",
|
|
29790
29887
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
29791
29888
|
},
|
|
29792
|
-
policyFile:
|
|
29889
|
+
policyFile: join64(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
29793
29890
|
repo: mirror,
|
|
29794
29891
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
29795
29892
|
base: effective.branch.base,
|
|
@@ -31056,7 +31153,7 @@ ${f.tail.trimEnd()}
|
|
|
31056
31153
|
logFile: cfg.ship.logFile
|
|
31057
31154
|
});
|
|
31058
31155
|
}
|
|
31059
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
31156
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join64(CREW_HOME, "src"), join64(CREW_HOME, "dist"), join64(CREW_HOME, "bin")];
|
|
31060
31157
|
const configPaths = daemonConfigPaths(cfg);
|
|
31061
31158
|
watchPaths.push(...configPaths);
|
|
31062
31159
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -31394,10 +31491,10 @@ ${f.tail.trimEnd()}
|
|
|
31394
31491
|
`);
|
|
31395
31492
|
if (!dryRun) {
|
|
31396
31493
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
31397
|
-
const raw = existsSync60(resolvedPath) ? JSON.parse(
|
|
31494
|
+
const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync56(resolvedPath, "utf8")) : {};
|
|
31398
31495
|
raw.agentSkills = result.agentSkills;
|
|
31399
|
-
|
|
31400
|
-
|
|
31496
|
+
mkdirSync43(dirOf2(resolvedPath), { recursive: true });
|
|
31497
|
+
writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
31401
31498
|
`);
|
|
31402
31499
|
}
|
|
31403
31500
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -31420,7 +31517,7 @@ ${f.tail.trimEnd()}
|
|
|
31420
31517
|
throw e;
|
|
31421
31518
|
}
|
|
31422
31519
|
const oldName = cfg.ship.name;
|
|
31423
|
-
|
|
31520
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), newName));
|
|
31424
31521
|
cfg.ship.name = newName;
|
|
31425
31522
|
let renameMachineId;
|
|
31426
31523
|
try {
|
|
@@ -31467,7 +31564,7 @@ ${f.tail.trimEnd()}
|
|
|
31467
31564
|
process.exit(2);
|
|
31468
31565
|
};
|
|
31469
31566
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
31470
|
-
const configText =
|
|
31567
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
31471
31568
|
if (sub === "check") {
|
|
31472
31569
|
try {
|
|
31473
31570
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -31508,7 +31605,7 @@ ${f.tail.trimEnd()}
|
|
|
31508
31605
|
}
|
|
31509
31606
|
}, read: (r) => {
|
|
31510
31607
|
try {
|
|
31511
|
-
return
|
|
31608
|
+
return readFileSync56(resolvePath(dir, r), "utf8");
|
|
31512
31609
|
} catch {
|
|
31513
31610
|
return void 0;
|
|
31514
31611
|
}
|
|
@@ -31550,19 +31647,19 @@ ${f.tail.trimEnd()}
|
|
|
31550
31647
|
let cleared;
|
|
31551
31648
|
if (clear2) {
|
|
31552
31649
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
31553
|
-
if (plan.removed.length > 0)
|
|
31650
|
+
if (plan.removed.length > 0) writeFileSync44(cfg.configFile, plan.text);
|
|
31554
31651
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
31555
31652
|
}
|
|
31556
31653
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
31557
31654
|
if (write === "route") {
|
|
31558
31655
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
31559
|
-
|
|
31656
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31560
31657
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
31561
31658
|
} else if (write === "repo") {
|
|
31562
31659
|
const have = existingRepoConfig(files);
|
|
31563
31660
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
31564
31661
|
const file = resolvePath(dir, ".crew.yaml");
|
|
31565
|
-
|
|
31662
|
+
writeFileSync44(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
31566
31663
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
31567
31664
|
}
|
|
31568
31665
|
if (flag("json")) {
|
|
@@ -31659,7 +31756,7 @@ ${f.tail.trimEnd()}
|
|
|
31659
31756
|
let resolvedRemotes;
|
|
31660
31757
|
if (existsSync60(resolvedFile)) {
|
|
31661
31758
|
try {
|
|
31662
|
-
resolvedRemotes = JSON.parse(
|
|
31759
|
+
resolvedRemotes = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31663
31760
|
} catch {
|
|
31664
31761
|
}
|
|
31665
31762
|
}
|
|
@@ -31681,7 +31778,7 @@ ${f.tail.trimEnd()}
|
|
|
31681
31778
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
31682
31779
|
try {
|
|
31683
31780
|
const path = resolvePath(d, f);
|
|
31684
|
-
return Object.keys(parseRepoConfig(
|
|
31781
|
+
return Object.keys(parseRepoConfig(readFileSync56(path, "utf8"), path).hooks).length > 0;
|
|
31685
31782
|
} catch {
|
|
31686
31783
|
return false;
|
|
31687
31784
|
}
|
|
@@ -31730,7 +31827,7 @@ ${f.tail.trimEnd()}
|
|
|
31730
31827
|
throw new ReposError(`${e.message}${authHint}
|
|
31731
31828
|
crew.yaml was not changed`);
|
|
31732
31829
|
}
|
|
31733
|
-
|
|
31830
|
+
writeFileSync44(cfg.configFile, plan2.text);
|
|
31734
31831
|
if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
|
|
31735
31832
|
`);
|
|
31736
31833
|
say("attached", { route: routeName, name: plan2.name, dir: plan2.target, mode: plan2.mode }, `cloned and attached ${plan2.target} to ${routeName} as ${plan2.mode === "dir" ? "dir" : `repos.${plan2.name}`} in ${cfg.configFile}`);
|
|
@@ -31790,14 +31887,14 @@ ${f.tail.trimEnd()}
|
|
|
31790
31887
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
31791
31888
|
`);
|
|
31792
31889
|
if (existsSync60(resolvedFile)) {
|
|
31793
|
-
const raw = JSON.parse(
|
|
31890
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31794
31891
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
31795
31892
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
31796
|
-
|
|
31893
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31797
31894
|
`);
|
|
31798
31895
|
}
|
|
31799
31896
|
}
|
|
31800
|
-
|
|
31897
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31801
31898
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
31802
31899
|
`);
|
|
31803
31900
|
} catch (e) {
|
|
@@ -32172,7 +32269,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32172
32269
|
process.exit(2);
|
|
32173
32270
|
}
|
|
32174
32271
|
if (found.shipNameAdopted && !dryRun) {
|
|
32175
|
-
|
|
32272
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
32176
32273
|
cfg.ship.name = found.shipNameAdopted;
|
|
32177
32274
|
}
|
|
32178
32275
|
if (found.shipRow) {
|
|
@@ -32218,7 +32315,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32218
32315
|
const hadPreviousFile = existsSync60(resolvedPath);
|
|
32219
32316
|
if (hadPreviousFile) {
|
|
32220
32317
|
try {
|
|
32221
|
-
previous = JSON.parse(
|
|
32318
|
+
previous = JSON.parse(readFileSync56(resolvedPath, "utf8"));
|
|
32222
32319
|
} catch {
|
|
32223
32320
|
}
|
|
32224
32321
|
}
|
|
@@ -32348,12 +32445,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32348
32445
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
32349
32446
|
`);
|
|
32350
32447
|
} else {
|
|
32351
|
-
|
|
32448
|
+
mkdirSync43(dirname37(resolvedPath), { recursive: true });
|
|
32352
32449
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
32353
32450
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
32354
|
-
|
|
32451
|
+
writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
32355
32452
|
`);
|
|
32356
|
-
|
|
32453
|
+
renameSync10(tmpPath, resolvedPath);
|
|
32357
32454
|
process.stderr.write(`Resolved ids written to ${resolvedPath}
|
|
32358
32455
|
`);
|
|
32359
32456
|
}
|
|
@@ -32397,8 +32494,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32397
32494
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
32398
32495
|
`);
|
|
32399
32496
|
} else {
|
|
32400
|
-
|
|
32401
|
-
|
|
32497
|
+
mkdirSync43(dirname37(apiKeyFile), { recursive: true });
|
|
32498
|
+
writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
32402
32499
|
`, { mode: 384 });
|
|
32403
32500
|
process.stderr.write(`API key written to ${apiKeyFile}
|
|
32404
32501
|
`);
|
|
@@ -33113,10 +33210,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
33113
33210
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
33114
33211
|
prepare: async (path) => {
|
|
33115
33212
|
for (const f of repoWt.config.worktrees.copy) {
|
|
33116
|
-
const src =
|
|
33117
|
-
if (!existsSync60(src) || existsSync60(
|
|
33118
|
-
|
|
33119
|
-
copyFileSync2(src,
|
|
33213
|
+
const src = join64(repoWt.dir, f);
|
|
33214
|
+
if (!existsSync60(src) || existsSync60(join64(path, f))) continue;
|
|
33215
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33216
|
+
copyFileSync2(src, join64(path, f));
|
|
33120
33217
|
}
|
|
33121
33218
|
const setup = repoWt.config.hooks.setup;
|
|
33122
33219
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -33445,10 +33542,10 @@ ${where.join("\n")}`);
|
|
|
33445
33542
|
},
|
|
33446
33543
|
prepare: async (path) => {
|
|
33447
33544
|
for (const f of repoP.config.worktrees.copy) {
|
|
33448
|
-
const src =
|
|
33545
|
+
const src = join64(repoP.dir, f);
|
|
33449
33546
|
if (!existsSync60(src)) continue;
|
|
33450
|
-
|
|
33451
|
-
copyFileSync2(src,
|
|
33547
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33548
|
+
copyFileSync2(src, join64(path, f));
|
|
33452
33549
|
}
|
|
33453
33550
|
const setup = repoP.config.hooks.setup;
|
|
33454
33551
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -33760,7 +33857,7 @@ ${where.join("\n")}`);
|
|
|
33760
33857
|
};
|
|
33761
33858
|
const droppedRoutes = [];
|
|
33762
33859
|
try {
|
|
33763
|
-
const rawCfg = parseYaml3(
|
|
33860
|
+
const rawCfg = parseYaml3(readFileSync56(cfg.configFile, "utf8"));
|
|
33764
33861
|
for (const r of rawCfg?.routes ?? []) {
|
|
33765
33862
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
33766
33863
|
try {
|
|
@@ -33824,8 +33921,8 @@ ${where.join("\n")}`);
|
|
|
33824
33921
|
process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
|
|
33825
33922
|
break;
|
|
33826
33923
|
}
|
|
33827
|
-
|
|
33828
|
-
|
|
33924
|
+
mkdirSync43(cfg.ship.stateDir, { recursive: true });
|
|
33925
|
+
writeFileSync44(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
33829
33926
|
`);
|
|
33830
33927
|
process.stdout.write(
|
|
33831
33928
|
"crew reload: requested \u2014 the daemon relaunches with the new config once its running agents end (it starts no new work meanwhile); if it is busy, `crew reload --now` forces the relaunch and interrupts them\n"
|
|
@@ -33890,7 +33987,7 @@ ${where.join("\n")}`);
|
|
|
33890
33987
|
}
|
|
33891
33988
|
case "log": {
|
|
33892
33989
|
try {
|
|
33893
|
-
const text2 =
|
|
33990
|
+
const text2 = readFileSync56(cfg.ship.logFile, "utf8").split("\n");
|
|
33894
33991
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
33895
33992
|
`);
|
|
33896
33993
|
} catch {
|
|
@@ -33913,7 +34010,7 @@ ${where.join("\n")}`);
|
|
|
33913
34010
|
};
|
|
33914
34011
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
33915
34012
|
const tracker = new Tracker(route2, cfg.ship);
|
|
33916
|
-
const configText =
|
|
34013
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
33917
34014
|
const cfgBase = dirname37(cfg.configFile);
|
|
33918
34015
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
33919
34016
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -33942,7 +34039,7 @@ ${where.join("\n")}`);
|
|
|
33942
34039
|
}
|
|
33943
34040
|
if (configured2.some((r) => r.dir === dir)) {
|
|
33944
34041
|
try {
|
|
33945
|
-
|
|
34042
|
+
writeFileSync44(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
33946
34043
|
} catch (e) {
|
|
33947
34044
|
if (e instanceof ReposError) fail2(e.message);
|
|
33948
34045
|
throw e;
|
|
@@ -33951,28 +34048,28 @@ ${where.join("\n")}`);
|
|
|
33951
34048
|
if (row) {
|
|
33952
34049
|
await tracker.deleteRepoRow(row.id);
|
|
33953
34050
|
if (existsSync60(resolvedFile)) {
|
|
33954
|
-
const raw = JSON.parse(
|
|
34051
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33955
34052
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
33956
34053
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
33957
|
-
|
|
34054
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33958
34055
|
`);
|
|
33959
34056
|
}
|
|
33960
34057
|
}
|
|
33961
|
-
if (existsSync60(
|
|
34058
|
+
if (existsSync60(join64(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
33962
34059
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
33963
34060
|
break;
|
|
33964
34061
|
}
|
|
33965
34062
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
33966
|
-
const fresh = !existsSync60(
|
|
34063
|
+
const fresh = !existsSync60(join64(dir, ".git"));
|
|
33967
34064
|
if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
33968
34065
|
if (dryRun) {
|
|
33969
34066
|
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`);
|
|
33970
34067
|
break;
|
|
33971
34068
|
}
|
|
33972
34069
|
if (fresh) {
|
|
33973
|
-
|
|
33974
|
-
|
|
33975
|
-
|
|
34070
|
+
mkdirSync43(dir, { recursive: true });
|
|
34071
|
+
writeFileSync44(join64(dir, "README.md"), SAMPLE_README);
|
|
34072
|
+
writeFileSync44(join64(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
33976
34073
|
const g = (...a) => {
|
|
33977
34074
|
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
33978
34075
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -33991,16 +34088,16 @@ ${where.join("\n")}`);
|
|
|
33991
34088
|
});
|
|
33992
34089
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
33993
34090
|
if (existsSync60(resolvedFile)) {
|
|
33994
|
-
const raw = JSON.parse(
|
|
34091
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33995
34092
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
33996
34093
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
33997
|
-
|
|
34094
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33998
34095
|
`);
|
|
33999
34096
|
}
|
|
34000
34097
|
}
|
|
34001
34098
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
34002
34099
|
try {
|
|
34003
|
-
|
|
34100
|
+
writeFileSync44(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
34004
34101
|
} catch (e) {
|
|
34005
34102
|
if (e instanceof ReposError) fail2(e.message);
|
|
34006
34103
|
throw e;
|
|
@@ -34559,7 +34656,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34559
34656
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
34560
34657
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
34561
34658
|
try {
|
|
34562
|
-
return
|
|
34659
|
+
return readFileSync56(p, "utf8");
|
|
34563
34660
|
} catch {
|
|
34564
34661
|
return null;
|
|
34565
34662
|
}
|
|
@@ -34574,7 +34671,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34574
34671
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
34575
34672
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
34576
34673
|
try {
|
|
34577
|
-
return
|
|
34674
|
+
return readFileSync56(p, "utf8");
|
|
34578
34675
|
} catch {
|
|
34579
34676
|
return null;
|
|
34580
34677
|
}
|