@tablation/crew 0.145.0 → 0.146.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +492 -393
- 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,17 +21685,48 @@ 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
|
|
|
21699
|
+
// src/outage.ts
|
|
21700
|
+
var TRANSIENT_BACKOFF_MS = [15e3, 3e4, 6e4];
|
|
21701
|
+
var OUTAGE_ESCALATE_AFTER = 5;
|
|
21702
|
+
var TRACKER_OUTAGE_KEY = "tracker_unreachable";
|
|
21703
|
+
var NETWORK_CODES = ["ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "EAI_AGAIN"];
|
|
21704
|
+
function transientBackoffMs(n) {
|
|
21705
|
+
return TRANSIENT_BACKOFF_MS[Math.min(Math.max(n, 1), TRANSIENT_BACKOFF_MS.length) - 1];
|
|
21706
|
+
}
|
|
21707
|
+
function codeOf(e) {
|
|
21708
|
+
const code = e?.code;
|
|
21709
|
+
return typeof code === "string" ? code : void 0;
|
|
21710
|
+
}
|
|
21711
|
+
function isTransientError(err3) {
|
|
21712
|
+
if (!(err3 instanceof Error)) return false;
|
|
21713
|
+
const msg = err3.message;
|
|
21714
|
+
if (msg === "fetch failed" || msg.startsWith("fetch failed")) return true;
|
|
21715
|
+
for (let e = err3, depth = 0; e && depth < 4; e = e.cause, depth++) {
|
|
21716
|
+
const code = codeOf(e);
|
|
21717
|
+
if (code && NETWORK_CODES.includes(code)) return true;
|
|
21718
|
+
}
|
|
21719
|
+
if (NETWORK_CODES.some((c) => msg.includes(c))) return true;
|
|
21720
|
+
if (/\b(?:HTTP|status)\s*:?\s*(502|503|504)\b/i.test(msg) || /^(502|503|504)\b/.test(msg)) return true;
|
|
21721
|
+
if (err3 instanceof SyntaxError && /Unexpected token '?<|is not valid JSON|Unexpected end of JSON/.test(msg)) return true;
|
|
21722
|
+
return false;
|
|
21723
|
+
}
|
|
21724
|
+
function describeCause(err3) {
|
|
21725
|
+
const first = (err3 instanceof Error ? err3.message : String(err3)).split("\n")[0];
|
|
21726
|
+
const code = codeOf(err3?.cause);
|
|
21727
|
+
return code && !first.includes(code) ? `${first} (${code})` : first;
|
|
21728
|
+
}
|
|
21729
|
+
|
|
21624
21730
|
// src/fleet.ts
|
|
21625
21731
|
function agedConnectionRank(rawRank, role, route2, decision, state, now) {
|
|
21626
21732
|
if (role !== "dev" && role !== "design") return rawRank;
|
|
@@ -21644,11 +21750,13 @@ async function decideFleet(o) {
|
|
|
21644
21750
|
rank: agedConnectionRank(rawRank, sel.selected, route2, decision, o.state, now)
|
|
21645
21751
|
};
|
|
21646
21752
|
} catch (e) {
|
|
21647
|
-
return { route: route2, rank: NOTHING_ACTIONABLE, error: e.message };
|
|
21753
|
+
return { route: route2, rank: NOTHING_ACTIONABLE, error: e.message, transient: isTransientError(e) };
|
|
21648
21754
|
}
|
|
21649
21755
|
}));
|
|
21650
21756
|
for (const e of entries) {
|
|
21651
|
-
if (e.error)
|
|
21757
|
+
if (!e.error) continue;
|
|
21758
|
+
const em = o.emit.forRoute(e.route.route);
|
|
21759
|
+
(e.transient ? em.warn : em.error).call(em, `${e.route.route}: ${e.error}`, { step: "poll" });
|
|
21652
21760
|
}
|
|
21653
21761
|
const contenders = entries.filter((e) => e.role && e.rank < NOTHING_ACTIONABLE);
|
|
21654
21762
|
const best = contenders.reduce(
|
|
@@ -21708,27 +21816,27 @@ function nextRoles(decision, ran) {
|
|
|
21708
21816
|
}
|
|
21709
21817
|
|
|
21710
21818
|
// src/noop-runs.ts
|
|
21711
|
-
import { existsSync as existsSync43, mkdirSync as
|
|
21712
|
-
import { join as
|
|
21819
|
+
import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync42, renameSync as renameSync8, writeFileSync as writeFileSync35 } from "fs";
|
|
21820
|
+
import { join as join48 } from "path";
|
|
21713
21821
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
21714
21822
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
21715
21823
|
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
21716
|
-
var noopRunsPath = (stateDir) =>
|
|
21824
|
+
var noopRunsPath = (stateDir) => join48(stateDir, "noop-runs.json");
|
|
21717
21825
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
21718
21826
|
function readNoopRuns(stateDir) {
|
|
21719
21827
|
try {
|
|
21720
|
-
const v = JSON.parse(
|
|
21828
|
+
const v = JSON.parse(readFileSync42(noopRunsPath(stateDir), "utf8"));
|
|
21721
21829
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
21722
21830
|
} catch {
|
|
21723
21831
|
return {};
|
|
21724
21832
|
}
|
|
21725
21833
|
}
|
|
21726
21834
|
function writeNoopRuns(stateDir, state) {
|
|
21727
|
-
|
|
21835
|
+
mkdirSync31(stateDir, { recursive: true });
|
|
21728
21836
|
const file = noopRunsPath(stateDir);
|
|
21729
|
-
|
|
21837
|
+
writeFileSync35(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
21730
21838
|
`);
|
|
21731
|
-
|
|
21839
|
+
renameSync8(`${file}.tmp`, file);
|
|
21732
21840
|
}
|
|
21733
21841
|
function noopBackedOff(stateDir, recordId, now = Date.now()) {
|
|
21734
21842
|
const e = readNoopRuns(stateDir)[recordId];
|
|
@@ -21803,7 +21911,7 @@ async function settleNoopRun(o) {
|
|
|
21803
21911
|
}
|
|
21804
21912
|
|
|
21805
21913
|
// src/ship-name.ts
|
|
21806
|
-
import { existsSync as existsSync44, mkdirSync as
|
|
21914
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync43, renameSync as renameSync9, writeFileSync as writeFileSync36 } from "fs";
|
|
21807
21915
|
import { dirname as dirname26 } from "path";
|
|
21808
21916
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
21809
21917
|
var ShipNameError = class extends Error {
|
|
@@ -21867,7 +21975,7 @@ async function syncRouteName(i) {
|
|
|
21867
21975
|
function readSyncedName(resolvedFile) {
|
|
21868
21976
|
if (!existsSync44(resolvedFile)) return void 0;
|
|
21869
21977
|
try {
|
|
21870
|
-
const v = JSON.parse(
|
|
21978
|
+
const v = JSON.parse(readFileSync43(resolvedFile, "utf8")).shipName;
|
|
21871
21979
|
return typeof v === "string" ? v : void 0;
|
|
21872
21980
|
} catch {
|
|
21873
21981
|
return void 0;
|
|
@@ -21877,22 +21985,22 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
21877
21985
|
if (!existsSync44(resolvedFile)) return;
|
|
21878
21986
|
let raw;
|
|
21879
21987
|
try {
|
|
21880
|
-
raw = JSON.parse(
|
|
21988
|
+
raw = JSON.parse(readFileSync43(resolvedFile, "utf8"));
|
|
21881
21989
|
} catch {
|
|
21882
21990
|
return;
|
|
21883
21991
|
}
|
|
21884
21992
|
if (raw.shipName === name) return;
|
|
21885
21993
|
raw.shipName = name;
|
|
21886
|
-
|
|
21994
|
+
mkdirSync32(dirname26(resolvedFile), { recursive: true });
|
|
21887
21995
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
21888
|
-
|
|
21996
|
+
writeFileSync36(tmp, `${JSON.stringify(raw, null, 2)}
|
|
21889
21997
|
`);
|
|
21890
|
-
|
|
21998
|
+
renameSync9(tmp, resolvedFile);
|
|
21891
21999
|
}
|
|
21892
22000
|
async function reconcileShipName(i) {
|
|
21893
22001
|
let local = i.ship.name;
|
|
21894
22002
|
try {
|
|
21895
|
-
local = shipNameOfYaml(
|
|
22003
|
+
local = shipNameOfYaml(readFileSync43(i.configFile, "utf8")) ?? local;
|
|
21896
22004
|
} catch {
|
|
21897
22005
|
}
|
|
21898
22006
|
const resolvedFile = resolvedPathFor(i.stateDir, i.route);
|
|
@@ -21916,8 +22024,8 @@ async function reconcileShipName(i) {
|
|
|
21916
22024
|
}
|
|
21917
22025
|
if (result.status !== "ok") return result;
|
|
21918
22026
|
if (result.action === "adopt" || result.action === "row-wins") {
|
|
21919
|
-
const text2 =
|
|
21920
|
-
|
|
22027
|
+
const text2 = readFileSync43(i.configFile, "utf8");
|
|
22028
|
+
writeFileSync36(i.configFile, setShipNameInYaml(text2, result.name));
|
|
21921
22029
|
i.ship.name = result.name;
|
|
21922
22030
|
if (result.action === "row-wins") {
|
|
21923
22031
|
i.emit?.warn(
|
|
@@ -21965,7 +22073,7 @@ async function reconcileRouteShipName(o) {
|
|
|
21965
22073
|
import { existsSync as existsSync45 } from "fs";
|
|
21966
22074
|
|
|
21967
22075
|
// src/passenger-mirror.ts
|
|
21968
|
-
import { mkdirSync as
|
|
22076
|
+
import { mkdirSync as mkdirSync33 } from "fs";
|
|
21969
22077
|
import { dirname as dirname27 } from "path";
|
|
21970
22078
|
function mirrorRepoOf(spec) {
|
|
21971
22079
|
const fromOrigin = spec.originUrl ? parseRemote(spec.originUrl) : null;
|
|
@@ -21985,8 +22093,8 @@ async function materializeMirrorCheckouts(specs, cacheFor = (s) => new SandboxCa
|
|
|
21985
22093
|
}
|
|
21986
22094
|
try {
|
|
21987
22095
|
const parent = dirname27(spec.dir);
|
|
21988
|
-
|
|
21989
|
-
|
|
22096
|
+
mkdirSync33(parent, { recursive: true });
|
|
22097
|
+
mkdirSync33(spec.dir, { recursive: true });
|
|
21990
22098
|
const r = await cacheFor(spec).materialize(repo, spec.base, parent, spec.name);
|
|
21991
22099
|
out.push({ ...base, action: r.changed ? "updated" : "unchanged", detail: r.tip });
|
|
21992
22100
|
} catch (e) {
|
|
@@ -22084,18 +22192,18 @@ function explainRefusal(readable, unreadable) {
|
|
|
22084
22192
|
|
|
22085
22193
|
// src/ssh-keys.ts
|
|
22086
22194
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
22087
|
-
import { existsSync as existsSync46, mkdirSync as
|
|
22088
|
-
import { dirname as dirname28, join as
|
|
22195
|
+
import { existsSync as existsSync46, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
|
|
22196
|
+
import { dirname as dirname28, join as join49 } from "path";
|
|
22089
22197
|
var SshKeyError = class extends Error {
|
|
22090
22198
|
};
|
|
22091
22199
|
function shipSshKeyPathFor(stateDir) {
|
|
22092
|
-
return
|
|
22200
|
+
return join49(stateDir, "ssh", "id_ed25519");
|
|
22093
22201
|
}
|
|
22094
22202
|
function ensureShipSshKeypair(stateDir) {
|
|
22095
22203
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
22096
22204
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
22097
22205
|
if (!existsSync46(privateKeyPath)) {
|
|
22098
|
-
|
|
22206
|
+
mkdirSync34(dirname28(privateKeyPath), { recursive: true });
|
|
22099
22207
|
try {
|
|
22100
22208
|
execFileSync13("ssh-keygen", [
|
|
22101
22209
|
"-t",
|
|
@@ -22118,7 +22226,7 @@ function ensureShipSshKeypair(stateDir) {
|
|
|
22118
22226
|
if (!existsSync46(publicKeyPath)) {
|
|
22119
22227
|
throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
|
|
22120
22228
|
}
|
|
22121
|
-
const publicKey =
|
|
22229
|
+
const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
|
|
22122
22230
|
return { privateKeyPath, publicKeyPath, publicKey };
|
|
22123
22231
|
}
|
|
22124
22232
|
function sshKeygenAvailable() {
|
|
@@ -22133,7 +22241,7 @@ function sshKeygenAvailable() {
|
|
|
22133
22241
|
// src/periscope-idle.ts
|
|
22134
22242
|
import { execFileSync as execFileSync14 } from "child_process";
|
|
22135
22243
|
import { statSync as statSync13 } from "fs";
|
|
22136
|
-
import { join as
|
|
22244
|
+
import { join as join50 } from "path";
|
|
22137
22245
|
var MAX_SCANNED_FILES = 2e4;
|
|
22138
22246
|
function newestWorktreeMtime(root) {
|
|
22139
22247
|
const a = newestTrackedMtime(root);
|
|
@@ -22158,7 +22266,7 @@ function newestTrackedMtime(root) {
|
|
|
22158
22266
|
if (!rel) continue;
|
|
22159
22267
|
if (++scanned > MAX_SCANNED_FILES) break;
|
|
22160
22268
|
try {
|
|
22161
|
-
const m = statSync13(
|
|
22269
|
+
const m = statSync13(join50(root, rel)).mtimeMs;
|
|
22162
22270
|
if (newest === null || m > newest) newest = m;
|
|
22163
22271
|
} catch {
|
|
22164
22272
|
}
|
|
@@ -22232,8 +22340,8 @@ async function runPeriscopeIdlePass(d) {
|
|
|
22232
22340
|
}
|
|
22233
22341
|
|
|
22234
22342
|
// src/periscope-cmd.ts
|
|
22235
|
-
import { existsSync as existsSync47, mkdirSync as
|
|
22236
|
-
import { join as
|
|
22343
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync45, rmSync as rmSync22, writeFileSync as writeFileSync37 } from "fs";
|
|
22344
|
+
import { join as join51 } from "path";
|
|
22237
22345
|
var PeriscopeError = class extends Error {
|
|
22238
22346
|
};
|
|
22239
22347
|
var LivePeriscopeError = class extends PeriscopeError {
|
|
@@ -22243,22 +22351,22 @@ var LivePeriscopeError = class extends PeriscopeError {
|
|
|
22243
22351
|
this.data = { refused: "live_periscope_exists", ...live2 };
|
|
22244
22352
|
}
|
|
22245
22353
|
};
|
|
22246
|
-
var priorDir = (stateDir) =>
|
|
22247
|
-
var priorPath = (stateDir, ticketRecordId) =>
|
|
22354
|
+
var priorDir = (stateDir) => join51(stateDir, "periscope-priors");
|
|
22355
|
+
var priorPath = (stateDir, ticketRecordId) => join51(priorDir(stateDir), `${ticketRecordId}.json`);
|
|
22248
22356
|
function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
22249
|
-
|
|
22357
|
+
rmSync22(priorPath(stateDir, ticketRecordId), { force: true });
|
|
22250
22358
|
}
|
|
22251
22359
|
function writePeriscopePrior(stateDir, ticketRecordId, prior) {
|
|
22252
22360
|
try {
|
|
22253
|
-
|
|
22254
|
-
|
|
22361
|
+
mkdirSync35(priorDir(stateDir), { recursive: true });
|
|
22362
|
+
writeFileSync37(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
|
|
22255
22363
|
} catch {
|
|
22256
22364
|
}
|
|
22257
22365
|
}
|
|
22258
22366
|
function readPeriscopePrior(stateDir, ticketRecordId) {
|
|
22259
22367
|
try {
|
|
22260
22368
|
const p = priorPath(stateDir, ticketRecordId);
|
|
22261
|
-
return existsSync47(p) ? JSON.parse(
|
|
22369
|
+
return existsSync47(p) ? JSON.parse(readFileSync45(p, "utf8")) : void 0;
|
|
22262
22370
|
} catch {
|
|
22263
22371
|
return void 0;
|
|
22264
22372
|
}
|
|
@@ -22709,37 +22817,6 @@ function formatPeriscopeList(entries) {
|
|
|
22709
22817
|
].join(" ")).join("\n");
|
|
22710
22818
|
}
|
|
22711
22819
|
|
|
22712
|
-
// src/outage.ts
|
|
22713
|
-
var TRANSIENT_BACKOFF_MS = [15e3, 3e4, 6e4];
|
|
22714
|
-
var OUTAGE_ESCALATE_AFTER = 5;
|
|
22715
|
-
var TRACKER_OUTAGE_KEY = "tracker_unreachable";
|
|
22716
|
-
var NETWORK_CODES = ["ECONNRESET", "ECONNREFUSED", "ETIMEDOUT", "EAI_AGAIN"];
|
|
22717
|
-
function transientBackoffMs(n) {
|
|
22718
|
-
return TRANSIENT_BACKOFF_MS[Math.min(Math.max(n, 1), TRANSIENT_BACKOFF_MS.length) - 1];
|
|
22719
|
-
}
|
|
22720
|
-
function codeOf(e) {
|
|
22721
|
-
const code = e?.code;
|
|
22722
|
-
return typeof code === "string" ? code : void 0;
|
|
22723
|
-
}
|
|
22724
|
-
function isTransientError(err3) {
|
|
22725
|
-
if (!(err3 instanceof Error)) return false;
|
|
22726
|
-
const msg = err3.message;
|
|
22727
|
-
if (msg === "fetch failed" || msg.startsWith("fetch failed")) return true;
|
|
22728
|
-
for (let e = err3, depth = 0; e && depth < 4; e = e.cause, depth++) {
|
|
22729
|
-
const code = codeOf(e);
|
|
22730
|
-
if (code && NETWORK_CODES.includes(code)) return true;
|
|
22731
|
-
}
|
|
22732
|
-
if (NETWORK_CODES.some((c) => msg.includes(c))) return true;
|
|
22733
|
-
if (/\b(?:HTTP|status)\s*:?\s*(502|503|504)\b/i.test(msg) || /^(502|503|504)\b/.test(msg)) return true;
|
|
22734
|
-
if (err3 instanceof SyntaxError && /Unexpected token '?<|is not valid JSON|Unexpected end of JSON/.test(msg)) return true;
|
|
22735
|
-
return false;
|
|
22736
|
-
}
|
|
22737
|
-
function describeCause(err3) {
|
|
22738
|
-
const first = (err3 instanceof Error ? err3.message : String(err3)).split("\n")[0];
|
|
22739
|
-
const code = codeOf(err3?.cause);
|
|
22740
|
-
return code && !first.includes(code) ? `${first} (${code})` : first;
|
|
22741
|
-
}
|
|
22742
|
-
|
|
22743
22820
|
// src/daemon.ts
|
|
22744
22821
|
var DEFAULT_FLOOR_MS = 5e3;
|
|
22745
22822
|
var DEFAULT_CEILING_MS = INTERVAL_SECONDS * 1e3;
|
|
@@ -22828,7 +22905,7 @@ function latestMtime(path) {
|
|
|
22828
22905
|
if (!stat2.isDirectory()) return 0;
|
|
22829
22906
|
let latest = stat2.mtimeMs;
|
|
22830
22907
|
for (const entry of readdirSync15(path, { withFileTypes: true })) {
|
|
22831
|
-
latest = Math.max(latest, latestMtime(
|
|
22908
|
+
latest = Math.max(latest, latestMtime(join52(path, entry.name)));
|
|
22832
22909
|
}
|
|
22833
22910
|
return latest;
|
|
22834
22911
|
}
|
|
@@ -22840,7 +22917,7 @@ function makeStaleChecker(paths, opts = {}) {
|
|
|
22840
22917
|
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync48(opts.reloadSentinel);
|
|
22841
22918
|
}
|
|
22842
22919
|
function reloadSentinelFor(stateDir) {
|
|
22843
|
-
return
|
|
22920
|
+
return join52(stateDir, "reload-requested");
|
|
22844
22921
|
}
|
|
22845
22922
|
function readReloadRequestedAt(stateDir) {
|
|
22846
22923
|
try {
|
|
@@ -22850,17 +22927,17 @@ function readReloadRequestedAt(stateDir) {
|
|
|
22850
22927
|
}
|
|
22851
22928
|
}
|
|
22852
22929
|
function daemonStampFor(stateDir) {
|
|
22853
|
-
return
|
|
22930
|
+
return join52(stateDir, "daemon.started");
|
|
22854
22931
|
}
|
|
22855
22932
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
22856
|
-
|
|
22857
|
-
|
|
22858
|
-
|
|
22933
|
+
mkdirSync36(stateDir, { recursive: true });
|
|
22934
|
+
rmSync23(reloadSentinelFor(stateDir), { force: true });
|
|
22935
|
+
writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
22859
22936
|
`);
|
|
22860
22937
|
}
|
|
22861
22938
|
function readDaemonStarted(stateDir) {
|
|
22862
22939
|
try {
|
|
22863
|
-
const v = JSON.parse(
|
|
22940
|
+
const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
22864
22941
|
return typeof v === "number" ? v : null;
|
|
22865
22942
|
} catch {
|
|
22866
22943
|
return null;
|
|
@@ -23717,7 +23794,7 @@ function parseSystemctlShow(text2) {
|
|
|
23717
23794
|
}
|
|
23718
23795
|
function lastLogLine(path, read = (p) => {
|
|
23719
23796
|
try {
|
|
23720
|
-
return
|
|
23797
|
+
return readFileSync47(p, "utf8");
|
|
23721
23798
|
} catch {
|
|
23722
23799
|
return null;
|
|
23723
23800
|
}
|
|
@@ -23794,7 +23871,7 @@ function daemonProblem(d, route2) {
|
|
|
23794
23871
|
}
|
|
23795
23872
|
function readDaemonStamp(stateDir) {
|
|
23796
23873
|
try {
|
|
23797
|
-
const v = JSON.parse(
|
|
23874
|
+
const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8"));
|
|
23798
23875
|
if (typeof v.startedAt !== "number") return null;
|
|
23799
23876
|
return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
|
|
23800
23877
|
} catch {
|
|
@@ -23823,7 +23900,7 @@ function defaultSleep2(ms3) {
|
|
|
23823
23900
|
}
|
|
23824
23901
|
function defaultReadLog(path) {
|
|
23825
23902
|
try {
|
|
23826
|
-
return
|
|
23903
|
+
return readFileSync48(path, "utf8");
|
|
23827
23904
|
} catch {
|
|
23828
23905
|
return null;
|
|
23829
23906
|
}
|
|
@@ -23890,15 +23967,15 @@ function startLaunchdDaemon(o) {
|
|
|
23890
23967
|
}
|
|
23891
23968
|
|
|
23892
23969
|
// src/daemon-start-failure.ts
|
|
23893
|
-
import { existsSync as existsSync50, mkdirSync as
|
|
23894
|
-
import { dirname as dirname29, join as
|
|
23970
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync49, unlinkSync as unlinkSync4, writeFileSync as writeFileSync39 } from "fs";
|
|
23971
|
+
import { dirname as dirname29, join as join53 } from "path";
|
|
23895
23972
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
23896
23973
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
23897
23974
|
var BACKOFF_AFTER_FAILURES = 2;
|
|
23898
|
-
var
|
|
23975
|
+
var fileFor4 = (stateDir) => join53(stateDir, ".daemon-start-failure.json");
|
|
23899
23976
|
function readStartFailure(stateDir) {
|
|
23900
23977
|
try {
|
|
23901
|
-
const parsed = JSON.parse(
|
|
23978
|
+
const parsed = JSON.parse(readFileSync49(fileFor4(stateDir), "utf8"));
|
|
23902
23979
|
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
23980
|
} catch {
|
|
23904
23981
|
return null;
|
|
@@ -23914,8 +23991,8 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
|
23914
23991
|
firstAt: same ? previous.firstAt : nowIso,
|
|
23915
23992
|
lastAt: nowIso
|
|
23916
23993
|
};
|
|
23917
|
-
|
|
23918
|
-
|
|
23994
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
23995
|
+
writeFileSync39(fileFor4(stateDir), JSON.stringify(record));
|
|
23919
23996
|
return record;
|
|
23920
23997
|
}
|
|
23921
23998
|
function startFailureDelayMs(count) {
|
|
@@ -23929,9 +24006,9 @@ function startFailureItem(record, o = {}) {
|
|
|
23929
24006
|
return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
|
|
23930
24007
|
}
|
|
23931
24008
|
function clearStartFailure(state, stateDir) {
|
|
23932
|
-
if (existsSync50(
|
|
24009
|
+
if (existsSync50(fileFor4(stateDir))) {
|
|
23933
24010
|
try {
|
|
23934
|
-
unlinkSync4(
|
|
24011
|
+
unlinkSync4(fileFor4(stateDir));
|
|
23935
24012
|
} catch {
|
|
23936
24013
|
}
|
|
23937
24014
|
}
|
|
@@ -23956,7 +24033,7 @@ async function reportStartFailure(o) {
|
|
|
23956
24033
|
return delay;
|
|
23957
24034
|
}
|
|
23958
24035
|
function fallbackStateDir(configFile) {
|
|
23959
|
-
return
|
|
24036
|
+
return join53(dirname29(configFile), "state");
|
|
23960
24037
|
}
|
|
23961
24038
|
|
|
23962
24039
|
// src/projects-cmd.ts
|
|
@@ -24070,7 +24147,7 @@ function runForge(a, io) {
|
|
|
24070
24147
|
|
|
24071
24148
|
// src/release-sandbox.ts
|
|
24072
24149
|
import { execFile as execFile5 } from "child_process";
|
|
24073
|
-
import { mkdirSync as
|
|
24150
|
+
import { mkdirSync as mkdirSync38, writeFileSync as writeFileSync40 } from "fs";
|
|
24074
24151
|
import { dirname as dirname30 } from "path";
|
|
24075
24152
|
import { promisify as promisify4 } from "util";
|
|
24076
24153
|
var execFileP4 = promisify4(execFile5);
|
|
@@ -24117,8 +24194,8 @@ async function openReleaseSandbox(o) {
|
|
|
24117
24194
|
if (!policyFile) {
|
|
24118
24195
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
24119
24196
|
policyFile = o.policyFile;
|
|
24120
|
-
|
|
24121
|
-
|
|
24197
|
+
mkdirSync38(dirname30(policyFile), { recursive: true });
|
|
24198
|
+
writeFileSync40(policyFile, generated.yaml, { mode: 384 });
|
|
24122
24199
|
}
|
|
24123
24200
|
const secrets = { ...process.env };
|
|
24124
24201
|
const secretKeys = [];
|
|
@@ -25202,13 +25279,13 @@ function describeCapability(i) {
|
|
|
25202
25279
|
}
|
|
25203
25280
|
|
|
25204
25281
|
// src/persona-avatars.ts
|
|
25205
|
-
import { existsSync as existsSync52, readFileSync as
|
|
25206
|
-
import { join as
|
|
25282
|
+
import { existsSync as existsSync52, readFileSync as readFileSync50 } from "fs";
|
|
25283
|
+
import { join as join54 } from "path";
|
|
25207
25284
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
25208
25285
|
function personaAvatarFile(promptsDir, role) {
|
|
25209
25286
|
for (const ext of ["png", "svg"]) {
|
|
25210
25287
|
const name = `lane-${role}.${ext}`;
|
|
25211
|
-
const path =
|
|
25288
|
+
const path = join54(promptsDir, "personas", name);
|
|
25212
25289
|
if (existsSync52(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
25213
25290
|
}
|
|
25214
25291
|
return void 0;
|
|
@@ -25223,7 +25300,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
|
25223
25300
|
if (!file || !agentId) continue;
|
|
25224
25301
|
try {
|
|
25225
25302
|
const form = new FormData();
|
|
25226
|
-
form.append("file", new Blob([
|
|
25303
|
+
form.append("file", new Blob([readFileSync50(file.path)], { type: file.mimeType }), file.name);
|
|
25227
25304
|
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
25228
25305
|
method: "PUT",
|
|
25229
25306
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
@@ -25264,14 +25341,14 @@ function avatarFailures(raw) {
|
|
|
25264
25341
|
}
|
|
25265
25342
|
function routeAvatarFailures(stateDir, route2) {
|
|
25266
25343
|
try {
|
|
25267
|
-
return avatarFailures(JSON.parse(
|
|
25344
|
+
return avatarFailures(JSON.parse(readFileSync50(resolvedPathFor(stateDir, route2), "utf8")));
|
|
25268
25345
|
} catch {
|
|
25269
25346
|
return [];
|
|
25270
25347
|
}
|
|
25271
25348
|
}
|
|
25272
25349
|
|
|
25273
25350
|
// src/agents-sync-run.ts
|
|
25274
|
-
import { existsSync as existsSync53, mkdirSync as
|
|
25351
|
+
import { existsSync as existsSync53, mkdirSync as mkdirSync39, readFileSync as readFileSync51, writeFileSync as writeFileSync41 } from "fs";
|
|
25275
25352
|
import { dirname as dirname31 } from "path";
|
|
25276
25353
|
async function runAgentsSync(target, o) {
|
|
25277
25354
|
const dryRun = o.dryRun ?? false;
|
|
@@ -25317,13 +25394,13 @@ async function runAgentsSync(target, o) {
|
|
|
25317
25394
|
}
|
|
25318
25395
|
if (!dryRun) {
|
|
25319
25396
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
25320
|
-
const raw = existsSync53(resolvedPath) ? JSON.parse(
|
|
25397
|
+
const raw = existsSync53(resolvedPath) ? JSON.parse(readFileSync51(resolvedPath, "utf8")) : {};
|
|
25321
25398
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
25322
25399
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
25323
25400
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
25324
25401
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
25325
|
-
|
|
25326
|
-
|
|
25402
|
+
mkdirSync39(dirname31(resolvedPath), { recursive: true });
|
|
25403
|
+
writeFileSync41(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
25327
25404
|
`);
|
|
25328
25405
|
if (target.resolved) {
|
|
25329
25406
|
target.resolved.agentPersonas = personaResult.agentPersonas;
|
|
@@ -25460,7 +25537,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
25460
25537
|
|
|
25461
25538
|
// src/repos-check.ts
|
|
25462
25539
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
25463
|
-
import { readFileSync as
|
|
25540
|
+
import { readFileSync as readFileSync52 } from "fs";
|
|
25464
25541
|
import { basename as basename12 } from "path";
|
|
25465
25542
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
25466
25543
|
function checkHookSyntax(script, shell) {
|
|
@@ -25501,7 +25578,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
25501
25578
|
}
|
|
25502
25579
|
let parsed;
|
|
25503
25580
|
try {
|
|
25504
|
-
parsed = parseRepoConfig(
|
|
25581
|
+
parsed = parseRepoConfig(readFileSync52(file, "utf8"), file);
|
|
25505
25582
|
} catch (e) {
|
|
25506
25583
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
25507
25584
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -25965,7 +26042,7 @@ ${run4.err}` });
|
|
|
25965
26042
|
}
|
|
25966
26043
|
|
|
25967
26044
|
// src/sample-ticket.ts
|
|
25968
|
-
import { basename as basename13, dirname as dirname32, join as
|
|
26045
|
+
import { basename as basename13, dirname as dirname32, join as join55 } from "path";
|
|
25969
26046
|
var SAMPLE_REPO = "crew-sample";
|
|
25970
26047
|
var SAMPLE_REMOTE = `local/${SAMPLE_REPO}`;
|
|
25971
26048
|
var SAMPLE_MARKER = "sample: true";
|
|
@@ -25988,8 +26065,8 @@ has something safe to work on: its test and build hooks always pass, it has no
|
|
|
25988
26065
|
remote, and \`crew sample-ticket --remove\` deletes it.
|
|
25989
26066
|
`;
|
|
25990
26067
|
function sampleDir(existing, reposBase, workspace) {
|
|
25991
|
-
if (existing.length > 0) return
|
|
25992
|
-
return
|
|
26068
|
+
if (existing.length > 0) return join55(dirname32(existing[0]), SAMPLE_REPO);
|
|
26069
|
+
return join55(reposBase, workspace, SAMPLE_REPO);
|
|
25993
26070
|
}
|
|
25994
26071
|
var SAMPLE_TITLE = "Sample: add a documented `greet` function with a test";
|
|
25995
26072
|
function sampleDescription() {
|
|
@@ -26033,8 +26110,8 @@ function planSampleTicket(i) {
|
|
|
26033
26110
|
}
|
|
26034
26111
|
|
|
26035
26112
|
// src/worktree-sweep.ts
|
|
26036
|
-
import { existsSync as existsSync54, readFileSync as
|
|
26037
|
-
import { basename as basename14, dirname as dirname33, join as
|
|
26113
|
+
import { existsSync as existsSync54, readFileSync as readFileSync53, readdirSync as readdirSync16 } from "fs";
|
|
26114
|
+
import { basename as basename14, dirname as dirname33, join as join56, resolve as resolve5 } from "path";
|
|
26038
26115
|
function planWorktreeSweep(target, tickets, contract) {
|
|
26039
26116
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
26040
26117
|
const verified = contract.statuses.verified;
|
|
@@ -26111,7 +26188,7 @@ function siblingWorktreeDirs(target) {
|
|
|
26111
26188
|
for (const name of names) {
|
|
26112
26189
|
if (!name.startsWith(stem)) continue;
|
|
26113
26190
|
const m = DIR_NUMBER_SUFFIXED.exec(name);
|
|
26114
|
-
const path =
|
|
26191
|
+
const path = join56(parent, name);
|
|
26115
26192
|
if (m && !registered.has(resolve5(path))) out.push({ path, number: m[1] });
|
|
26116
26193
|
}
|
|
26117
26194
|
return out;
|
|
@@ -26233,7 +26310,7 @@ function isHandBackMerge(path, base) {
|
|
|
26233
26310
|
if (!msgPath) return false;
|
|
26234
26311
|
let first;
|
|
26235
26312
|
try {
|
|
26236
|
-
first =
|
|
26313
|
+
first = readFileSync53(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
26237
26314
|
} catch {
|
|
26238
26315
|
return false;
|
|
26239
26316
|
}
|
|
@@ -26338,14 +26415,14 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
26338
26415
|
}
|
|
26339
26416
|
|
|
26340
26417
|
// src/stream-sweep.ts
|
|
26341
|
-
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as
|
|
26342
|
-
import { join as
|
|
26418
|
+
import { existsSync as existsSync55, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync16 } from "fs";
|
|
26419
|
+
import { join as join57 } from "path";
|
|
26343
26420
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
26344
26421
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26345
|
-
const dir =
|
|
26422
|
+
const dir = join57(stateDir, "streams");
|
|
26346
26423
|
if (!existsSync55(dir)) return [];
|
|
26347
26424
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26348
|
-
return readdirSync17(dir).map((name) =>
|
|
26425
|
+
return readdirSync17(dir).map((name) => join57(dir, name)).filter((path) => {
|
|
26349
26426
|
try {
|
|
26350
26427
|
return statSync16(path).mtimeMs < cutoff;
|
|
26351
26428
|
} catch {
|
|
@@ -26361,7 +26438,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26361
26438
|
continue;
|
|
26362
26439
|
}
|
|
26363
26440
|
try {
|
|
26364
|
-
|
|
26441
|
+
rmSync24(path, { force: true });
|
|
26365
26442
|
removed++;
|
|
26366
26443
|
log.emit(`removed stream artifact ${path}`, { step: "worktree" });
|
|
26367
26444
|
} catch (e) {
|
|
@@ -26373,7 +26450,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
26373
26450
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
26374
26451
|
if (!existsSync55(stateDir)) return [];
|
|
26375
26452
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
26376
|
-
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) =>
|
|
26453
|
+
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join57(stateDir, name)).filter((path) => {
|
|
26377
26454
|
try {
|
|
26378
26455
|
return statSync16(path).mtimeMs < cutoff;
|
|
26379
26456
|
} catch {
|
|
@@ -26383,7 +26460,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
26383
26460
|
}
|
|
26384
26461
|
|
|
26385
26462
|
// src/cli.ts
|
|
26386
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
26463
|
+
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
26464
|
import { createInterface } from "readline/promises";
|
|
26388
26465
|
|
|
26389
26466
|
// src/periscope-resume.ts
|
|
@@ -26460,9 +26537,9 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
|
26460
26537
|
|
|
26461
26538
|
// src/bundle-staleness.ts
|
|
26462
26539
|
import { existsSync as existsSync56, readdirSync as readdirSync18, statSync as statSync17 } from "fs";
|
|
26463
|
-
import { join as
|
|
26540
|
+
import { join as join58 } from "path";
|
|
26464
26541
|
function builtVersion() {
|
|
26465
|
-
return true ? "0.
|
|
26542
|
+
return true ? "0.146.1" : null;
|
|
26466
26543
|
}
|
|
26467
26544
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
26468
26545
|
function newestMtime(path) {
|
|
@@ -26475,17 +26552,17 @@ function newestMtime(path) {
|
|
|
26475
26552
|
if (stat2.isFile()) return stat2.mtimeMs;
|
|
26476
26553
|
if (!stat2.isDirectory()) return 0;
|
|
26477
26554
|
let latest = stat2.mtimeMs;
|
|
26478
|
-
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(
|
|
26555
|
+
for (const e of readdirSync18(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join58(path, e.name)));
|
|
26479
26556
|
return latest;
|
|
26480
26557
|
}
|
|
26481
26558
|
function bundleStaleness(i) {
|
|
26482
26559
|
if (i.built === null || i.compiled) return null;
|
|
26483
|
-
const src =
|
|
26560
|
+
const src = join58(i.home, "src");
|
|
26484
26561
|
if (!existsSync56(src)) return null;
|
|
26485
26562
|
if (i.built !== i.current) {
|
|
26486
26563
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
26487
26564
|
}
|
|
26488
|
-
const bundle = statSafe(
|
|
26565
|
+
const bundle = statSafe(join58(i.home, "dist", "cli.js"));
|
|
26489
26566
|
if (bundle === null) return null;
|
|
26490
26567
|
if (newestMtime(src) > bundle) {
|
|
26491
26568
|
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
@@ -26652,8 +26729,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
26652
26729
|
import { createServer as createHttpServer } from "http";
|
|
26653
26730
|
import { spawn as spawn9 } from "child_process";
|
|
26654
26731
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
26655
|
-
import { existsSync as existsSync57, mkdirSync as
|
|
26656
|
-
import { join as
|
|
26732
|
+
import { existsSync as existsSync57, mkdirSync as mkdirSync40, readFileSync as readFileSync54, writeFileSync as writeFileSync42, unlinkSync as unlinkSync5, readdirSync as readdirSync19 } from "fs";
|
|
26733
|
+
import { join as join59 } from "path";
|
|
26657
26734
|
|
|
26658
26735
|
// src/secret-compare.ts
|
|
26659
26736
|
import { timingSafeEqual } from "crypto";
|
|
@@ -26746,21 +26823,21 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
26746
26823
|
return child;
|
|
26747
26824
|
};
|
|
26748
26825
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
26749
|
-
return
|
|
26826
|
+
return join59(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
26750
26827
|
}
|
|
26751
26828
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
26752
26829
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
26753
26830
|
if (!existsSync57(path)) return void 0;
|
|
26754
26831
|
try {
|
|
26755
|
-
return JSON.parse(
|
|
26832
|
+
return JSON.parse(readFileSync54(path, "utf8"));
|
|
26756
26833
|
} catch {
|
|
26757
26834
|
return void 0;
|
|
26758
26835
|
}
|
|
26759
26836
|
}
|
|
26760
26837
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
26761
26838
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
26762
|
-
|
|
26763
|
-
|
|
26839
|
+
mkdirSync40(join59(stateDir, "passengers"), { recursive: true });
|
|
26840
|
+
writeFileSync42(path, `${JSON.stringify(state, null, 2)}
|
|
26764
26841
|
`);
|
|
26765
26842
|
}
|
|
26766
26843
|
function removePersistedSyncDaemon(stateDir, workspaceId) {
|
|
@@ -26780,7 +26857,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
26780
26857
|
}
|
|
26781
26858
|
}
|
|
26782
26859
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
26783
|
-
const dir =
|
|
26860
|
+
const dir = join59(stateDir, "passengers");
|
|
26784
26861
|
if (!existsSync57(dir)) return [];
|
|
26785
26862
|
const suffix = "-sync.json";
|
|
26786
26863
|
return readdirSync19(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
@@ -26839,7 +26916,7 @@ function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
|
|
|
26839
26916
|
|
|
26840
26917
|
// src/periscope-proxy.ts
|
|
26841
26918
|
import { spawn as spawn10 } from "child_process";
|
|
26842
|
-
import { appendFileSync as
|
|
26919
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync41 } from "fs";
|
|
26843
26920
|
import { createServer, request as httpRequest } from "http";
|
|
26844
26921
|
import { request as httpsRequest } from "https";
|
|
26845
26922
|
import { connect as netConnect } from "net";
|
|
@@ -26958,8 +27035,8 @@ function parsePointedBody(raw) {
|
|
|
26958
27035
|
return entry;
|
|
26959
27036
|
}
|
|
26960
27037
|
function appendPointed(file, entry, now = /* @__PURE__ */ new Date()) {
|
|
26961
|
-
|
|
26962
|
-
|
|
27038
|
+
mkdirSync41(dirname34(file), { recursive: true });
|
|
27039
|
+
appendFileSync4(file, `${JSON.stringify({ ...entry, at: now.toISOString() })}
|
|
26963
27040
|
`);
|
|
26964
27041
|
}
|
|
26965
27042
|
var CSP_DIRECTIVES = /* @__PURE__ */ new Set(["default-src", "script-src", "script-src-elem", "connect-src"]);
|
|
@@ -27247,7 +27324,7 @@ async function startWorktreeIntel(d) {
|
|
|
27247
27324
|
}
|
|
27248
27325
|
|
|
27249
27326
|
// src/contract-refusal.ts
|
|
27250
|
-
import { join as
|
|
27327
|
+
import { join as join60 } from "path";
|
|
27251
27328
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
27252
27329
|
const out = [];
|
|
27253
27330
|
for (const t of tickets) {
|
|
@@ -27259,7 +27336,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
27259
27336
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
27260
27337
|
if (text2 === null) continue;
|
|
27261
27338
|
try {
|
|
27262
|
-
parseRepoConfig(text2,
|
|
27339
|
+
parseRepoConfig(text2, join60(dir, file));
|
|
27263
27340
|
} catch (e) {
|
|
27264
27341
|
if (e instanceof RepoConfigError) continue;
|
|
27265
27342
|
throw e;
|
|
@@ -27279,13 +27356,13 @@ import {
|
|
|
27279
27356
|
openSync as openSync7,
|
|
27280
27357
|
readSync as readSync4,
|
|
27281
27358
|
readdirSync as readdirSync20,
|
|
27282
|
-
rmSync as
|
|
27359
|
+
rmSync as rmSync25,
|
|
27283
27360
|
statSync as statSync18,
|
|
27284
27361
|
watch
|
|
27285
27362
|
} from "fs";
|
|
27286
27363
|
import { createConnection } from "net";
|
|
27287
27364
|
import { createServer as createServer2 } from "http";
|
|
27288
|
-
import { basename as basename15, dirname as dirname35, join as
|
|
27365
|
+
import { basename as basename15, dirname as dirname35, join as join61 } from "path";
|
|
27289
27366
|
import { execFile as execFile6, spawn as spawn12 } from "child_process";
|
|
27290
27367
|
|
|
27291
27368
|
// src/periscope-control.ts
|
|
@@ -27522,7 +27599,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
27522
27599
|
// src/control-api.ts
|
|
27523
27600
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
27524
27601
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
27525
|
-
var controlSocketFor = (stateDir) =>
|
|
27602
|
+
var controlSocketFor = (stateDir) => join61(stateDir, CONTROL_SOCKET_NAME);
|
|
27526
27603
|
var MAX_SOCKET_PATH = 100;
|
|
27527
27604
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
27528
27605
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -27609,7 +27686,7 @@ function candidates(live2, rotated) {
|
|
|
27609
27686
|
const out = [live2];
|
|
27610
27687
|
if (!rotated) return out;
|
|
27611
27688
|
try {
|
|
27612
|
-
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(
|
|
27689
|
+
for (const n of readdirSync20(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join61(dirname35(live2), n));
|
|
27613
27690
|
} catch {
|
|
27614
27691
|
}
|
|
27615
27692
|
return out;
|
|
@@ -27775,6 +27852,7 @@ async function tailReply(path, q2, rotated, abort) {
|
|
|
27775
27852
|
return reply2(200, r);
|
|
27776
27853
|
}
|
|
27777
27854
|
var NOTE_MAX_CHARS = 4e3;
|
|
27855
|
+
var SEAT_ROLES = ["dev", "design", "qa", "triage", "pair"];
|
|
27778
27856
|
async function postRunMessage(deps, run4, body) {
|
|
27779
27857
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..")) return err2(400, "not a run name");
|
|
27780
27858
|
const live2 = liveRuns(deps.stateDir).find((r) => basename15(r.streamPath, ".jsonl") === run4.replace(/\.jsonl$/, ""));
|
|
@@ -27804,6 +27882,25 @@ async function postRunMessage(deps, run4, body) {
|
|
|
27804
27882
|
return err2(409, `the platform did not take the note: ${e.message}. ${carry}`);
|
|
27805
27883
|
}
|
|
27806
27884
|
}
|
|
27885
|
+
function postSeatNote(deps, role, body) {
|
|
27886
|
+
if (!SEAT_ROLES.includes(role)) return err2(400, `role must be one of ${SEAT_ROLES.join(", ")}`);
|
|
27887
|
+
if (!body) return err2(400, "body must be a small JSON object");
|
|
27888
|
+
const text2 = typeof body.text === "string" ? body.text.trim() : "";
|
|
27889
|
+
if (!text2 || text2.length > NOTE_MAX_CHARS) return err2(400, `text must be a string of 1 to ${NOTE_MAX_CHARS} characters`);
|
|
27890
|
+
if (body.author !== void 0 && typeof body.author !== "string") return err2(400, "author must be a string");
|
|
27891
|
+
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");
|
|
27892
|
+
try {
|
|
27893
|
+
const note = addSeatNote(deps.stateDir, {
|
|
27894
|
+
role,
|
|
27895
|
+
text: text2,
|
|
27896
|
+
...body.ticket ? { ticket: body.ticket.trim() } : {},
|
|
27897
|
+
...body.author ? { author: body.author.trim() } : {}
|
|
27898
|
+
});
|
|
27899
|
+
return reply2(200, { id: note.id, state: "carried_forward", carriedForward: true });
|
|
27900
|
+
} catch (e) {
|
|
27901
|
+
return err2(500, `could not store the note: ${e.message}`);
|
|
27902
|
+
}
|
|
27903
|
+
}
|
|
27807
27904
|
async function route(deps, method, url, req, abort) {
|
|
27808
27905
|
const p = url.pathname.replace(/\/+$/, "") || "/";
|
|
27809
27906
|
const get2 = method === "GET";
|
|
@@ -27839,12 +27936,14 @@ async function route(deps, method, url, req, abort) {
|
|
|
27839
27936
|
if (p.startsWith("/streams/") && get2) {
|
|
27840
27937
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
27841
27938
|
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 =
|
|
27939
|
+
const file = join61(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
27843
27940
|
if (!existsSync58(file)) return err2(404, "no such run");
|
|
27844
27941
|
return tailReply(file, url.searchParams, false, abort);
|
|
27845
27942
|
}
|
|
27846
27943
|
const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
|
|
27847
27944
|
if (note && post3) return postRunMessage(deps, decodeURIComponent(note[1]), await readJsonBody(req));
|
|
27945
|
+
const seatNote = /^\/seats\/([^/]+)\/notes$/.exec(p);
|
|
27946
|
+
if (seatNote && post3) return postSeatNote(deps, decodeURIComponent(seatNote[1]), await readJsonBody(req));
|
|
27848
27947
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
27849
27948
|
const body = await readJsonBody(req);
|
|
27850
27949
|
if (!body) return err2(400, "body must be a small JSON object");
|
|
@@ -27869,7 +27968,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
27869
27968
|
}
|
|
27870
27969
|
if (p === "/diagnostics" && get2 && deps.diagnostics) return reply2(200, await deps.diagnostics());
|
|
27871
27970
|
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");
|
|
27971
|
+
if (known.includes(p) || p.startsWith("/streams/") || seatNote || sched) return err2(405, "method not allowed");
|
|
27873
27972
|
return err2(404, "not found");
|
|
27874
27973
|
}
|
|
27875
27974
|
function send2(res, r) {
|
|
@@ -27905,7 +28004,7 @@ async function startControlServer(deps) {
|
|
|
27905
28004
|
log(`control API not started: socket path is too long for a unix socket (${path})`);
|
|
27906
28005
|
return null;
|
|
27907
28006
|
}
|
|
27908
|
-
if (await socketIsStale(path))
|
|
28007
|
+
if (await socketIsStale(path)) rmSync25(path, { force: true });
|
|
27909
28008
|
else if (existsSync58(path)) {
|
|
27910
28009
|
log(`control API not started: ${path} is in use by another process`);
|
|
27911
28010
|
return null;
|
|
@@ -27952,7 +28051,7 @@ async function startControlServer(deps) {
|
|
|
27952
28051
|
path,
|
|
27953
28052
|
close: () => new Promise((done) => {
|
|
27954
28053
|
server.close(() => {
|
|
27955
|
-
|
|
28054
|
+
rmSync25(path, { force: true });
|
|
27956
28055
|
done();
|
|
27957
28056
|
});
|
|
27958
28057
|
})
|
|
@@ -27992,53 +28091,53 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
27992
28091
|
|
|
27993
28092
|
// src/periscope-mcp.ts
|
|
27994
28093
|
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
|
|
28094
|
+
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join63, relative as relative2, resolve as resolve6, sep } from "path";
|
|
27996
28095
|
import { z } from "zod";
|
|
27997
28096
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
27998
28097
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
27999
28098
|
|
|
28000
28099
|
// src/periscope-endpoints.ts
|
|
28001
28100
|
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) =>
|
|
28101
|
+
import { chmodSync as chmodSync5, existsSync as existsSync59, mkdirSync as mkdirSync42, readdirSync as readdirSync21, readFileSync as readFileSync55, rmSync as rmSync26, writeFileSync as writeFileSync43 } from "fs";
|
|
28102
|
+
import { join as join62 } from "path";
|
|
28103
|
+
var secretDir = (stateDir) => join62(stateDir, "periscope-mcp");
|
|
28104
|
+
var secretFile = (stateDir, id) => join62(secretDir(stateDir), `${id}.json`);
|
|
28105
|
+
var endpointDir = (stateDir) => join62(stateDir, "periscope-endpoints");
|
|
28106
|
+
var endpointFile = (stateDir, id) => join62(endpointDir(stateDir), `${id}.json`);
|
|
28008
28107
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
28009
|
-
|
|
28108
|
+
mkdirSync42(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
28010
28109
|
const secret = randomBytes3(32).toString("base64url");
|
|
28011
28110
|
const file = secretFile(stateDir, ticketRecordId);
|
|
28012
|
-
|
|
28111
|
+
writeFileSync43(file, `${JSON.stringify({ secret })}
|
|
28013
28112
|
`, { mode: 384 });
|
|
28014
28113
|
chmodSync5(file, 384);
|
|
28015
28114
|
return secret;
|
|
28016
28115
|
}
|
|
28017
28116
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
28018
28117
|
try {
|
|
28019
|
-
const v = JSON.parse(
|
|
28118
|
+
const v = JSON.parse(readFileSync55(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
28020
28119
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
28021
28120
|
} catch {
|
|
28022
28121
|
return void 0;
|
|
28023
28122
|
}
|
|
28024
28123
|
}
|
|
28025
28124
|
function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
28026
|
-
|
|
28125
|
+
rmSync26(secretFile(stateDir, ticketRecordId), { force: true });
|
|
28027
28126
|
}
|
|
28028
28127
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
28029
28128
|
try {
|
|
28030
|
-
return JSON.parse(
|
|
28129
|
+
return JSON.parse(readFileSync55(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
28031
28130
|
} catch {
|
|
28032
28131
|
return void 0;
|
|
28033
28132
|
}
|
|
28034
28133
|
}
|
|
28035
28134
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
28036
|
-
|
|
28037
|
-
|
|
28135
|
+
mkdirSync42(endpointDir(stateDir), { recursive: true });
|
|
28136
|
+
writeFileSync43(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
28038
28137
|
`);
|
|
28039
28138
|
}
|
|
28040
28139
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
28041
|
-
|
|
28140
|
+
rmSync26(endpointFile(stateDir, ticketRecordId), { force: true });
|
|
28042
28141
|
}
|
|
28043
28142
|
function listPeriscopeEndpoints(stateDir) {
|
|
28044
28143
|
const dir = endpointDir(stateDir);
|
|
@@ -28145,13 +28244,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
28145
28244
|
let abs;
|
|
28146
28245
|
if (isAbsolute5(requested)) {
|
|
28147
28246
|
abs = resolve6(requested);
|
|
28148
|
-
if (isInside(root, abs)) abs =
|
|
28247
|
+
if (isInside(root, abs)) abs = join63(realRoot, relative2(root, abs));
|
|
28149
28248
|
} else {
|
|
28150
28249
|
abs = resolve6(realRoot, requested);
|
|
28151
28250
|
}
|
|
28152
28251
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28153
28252
|
const { real, rest } = await realAncestor(abs);
|
|
28154
|
-
const final = rest ?
|
|
28253
|
+
const final = rest ? join63(real, rest) : real;
|
|
28155
28254
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
28156
28255
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
28157
28256
|
return final;
|
|
@@ -28219,7 +28318,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28219
28318
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
28220
28319
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
28221
28320
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
28222
|
-
const size = (await lstat(
|
|
28321
|
+
const size = (await lstat(join63(abs, e.name))).size;
|
|
28223
28322
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
28224
28323
|
}));
|
|
28225
28324
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -28285,7 +28384,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
28285
28384
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
28286
28385
|
}, async ({ path }) => {
|
|
28287
28386
|
const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
|
|
28288
|
-
const abs =
|
|
28387
|
+
const abs = join63(parent, basename16(path));
|
|
28289
28388
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
28290
28389
|
const st = await lstat(abs).catch(() => void 0);
|
|
28291
28390
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -28780,7 +28879,7 @@ if (command === "provision") {
|
|
|
28780
28879
|
process.exit(outcome.code);
|
|
28781
28880
|
}
|
|
28782
28881
|
if (command === "pool-member") {
|
|
28783
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
28882
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync56(0, "utf8"));
|
|
28784
28883
|
if (typeof pool === "string") {
|
|
28785
28884
|
process.stderr.write(`crew pool-member: ${pool}
|
|
28786
28885
|
`);
|
|
@@ -29124,7 +29223,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29124
29223
|
throw e;
|
|
29125
29224
|
}
|
|
29126
29225
|
if (command === "credential") {
|
|
29127
|
-
const r = runCredential(positional[1],
|
|
29226
|
+
const r = runCredential(positional[1], readFileSync56(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
29128
29227
|
process.stdout.write(r.out);
|
|
29129
29228
|
process.stderr.write(r.err);
|
|
29130
29229
|
process.exit(r.code);
|
|
@@ -29136,9 +29235,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
29136
29235
|
forges: cfg.ship.forges,
|
|
29137
29236
|
stateDir: cfg.ship.stateDir,
|
|
29138
29237
|
configFile: cfg.configFile,
|
|
29139
|
-
readFile: (p) =>
|
|
29140
|
-
writeFile: (p, t) =>
|
|
29141
|
-
stdin: () =>
|
|
29238
|
+
readFile: (p) => readFileSync56(p, "utf8"),
|
|
29239
|
+
writeFile: (p, t) => writeFileSync44(p, t),
|
|
29240
|
+
stdin: () => readFileSync56(0, "utf8"),
|
|
29142
29241
|
env: process.env
|
|
29143
29242
|
}
|
|
29144
29243
|
);
|
|
@@ -29477,7 +29576,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29477
29576
|
}
|
|
29478
29577
|
if (host === "linux" && hasSystemd) {
|
|
29479
29578
|
const label = labelFor(CREW_HOME, "run");
|
|
29480
|
-
const staleTimer =
|
|
29579
|
+
const staleTimer = join64(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
29481
29580
|
if (existsSync60(staleTimer)) {
|
|
29482
29581
|
process.stdout.write(
|
|
29483
29582
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
@@ -29560,7 +29659,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29560
29659
|
for (const a of plan.actions) {
|
|
29561
29660
|
if (a.kind === "enable") {
|
|
29562
29661
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
29563
|
-
|
|
29662
|
+
writeFileSync44(cfg.configFile, planEnable(readFileSync56(cfg.configFile, "utf8"), a.route));
|
|
29564
29663
|
enabledSound.add(a.route);
|
|
29565
29664
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
29566
29665
|
} else {
|
|
@@ -29789,7 +29888,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
29789
29888
|
harnessBin: "claude",
|
|
29790
29889
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
29791
29890
|
},
|
|
29792
|
-
policyFile:
|
|
29891
|
+
policyFile: join64(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
29793
29892
|
repo: mirror,
|
|
29794
29893
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
29795
29894
|
base: effective.branch.base,
|
|
@@ -31056,7 +31155,7 @@ ${f.tail.trimEnd()}
|
|
|
31056
31155
|
logFile: cfg.ship.logFile
|
|
31057
31156
|
});
|
|
31058
31157
|
}
|
|
31059
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
31158
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join64(CREW_HOME, "src"), join64(CREW_HOME, "dist"), join64(CREW_HOME, "bin")];
|
|
31060
31159
|
const configPaths = daemonConfigPaths(cfg);
|
|
31061
31160
|
watchPaths.push(...configPaths);
|
|
31062
31161
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -31394,10 +31493,10 @@ ${f.tail.trimEnd()}
|
|
|
31394
31493
|
`);
|
|
31395
31494
|
if (!dryRun) {
|
|
31396
31495
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
31397
|
-
const raw = existsSync60(resolvedPath) ? JSON.parse(
|
|
31496
|
+
const raw = existsSync60(resolvedPath) ? JSON.parse(readFileSync56(resolvedPath, "utf8")) : {};
|
|
31398
31497
|
raw.agentSkills = result.agentSkills;
|
|
31399
|
-
|
|
31400
|
-
|
|
31498
|
+
mkdirSync43(dirOf2(resolvedPath), { recursive: true });
|
|
31499
|
+
writeFileSync44(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
31401
31500
|
`);
|
|
31402
31501
|
}
|
|
31403
31502
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -31420,7 +31519,7 @@ ${f.tail.trimEnd()}
|
|
|
31420
31519
|
throw e;
|
|
31421
31520
|
}
|
|
31422
31521
|
const oldName = cfg.ship.name;
|
|
31423
|
-
|
|
31522
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), newName));
|
|
31424
31523
|
cfg.ship.name = newName;
|
|
31425
31524
|
let renameMachineId;
|
|
31426
31525
|
try {
|
|
@@ -31467,7 +31566,7 @@ ${f.tail.trimEnd()}
|
|
|
31467
31566
|
process.exit(2);
|
|
31468
31567
|
};
|
|
31469
31568
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
31470
|
-
const configText =
|
|
31569
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
31471
31570
|
if (sub === "check") {
|
|
31472
31571
|
try {
|
|
31473
31572
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -31508,7 +31607,7 @@ ${f.tail.trimEnd()}
|
|
|
31508
31607
|
}
|
|
31509
31608
|
}, read: (r) => {
|
|
31510
31609
|
try {
|
|
31511
|
-
return
|
|
31610
|
+
return readFileSync56(resolvePath(dir, r), "utf8");
|
|
31512
31611
|
} catch {
|
|
31513
31612
|
return void 0;
|
|
31514
31613
|
}
|
|
@@ -31550,19 +31649,19 @@ ${f.tail.trimEnd()}
|
|
|
31550
31649
|
let cleared;
|
|
31551
31650
|
if (clear2) {
|
|
31552
31651
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
31553
|
-
if (plan.removed.length > 0)
|
|
31652
|
+
if (plan.removed.length > 0) writeFileSync44(cfg.configFile, plan.text);
|
|
31554
31653
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
31555
31654
|
}
|
|
31556
31655
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
31557
31656
|
if (write === "route") {
|
|
31558
31657
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
31559
|
-
|
|
31658
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31560
31659
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
31561
31660
|
} else if (write === "repo") {
|
|
31562
31661
|
const have = existingRepoConfig(files);
|
|
31563
31662
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
31564
31663
|
const file = resolvePath(dir, ".crew.yaml");
|
|
31565
|
-
|
|
31664
|
+
writeFileSync44(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
31566
31665
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
31567
31666
|
}
|
|
31568
31667
|
if (flag("json")) {
|
|
@@ -31659,7 +31758,7 @@ ${f.tail.trimEnd()}
|
|
|
31659
31758
|
let resolvedRemotes;
|
|
31660
31759
|
if (existsSync60(resolvedFile)) {
|
|
31661
31760
|
try {
|
|
31662
|
-
resolvedRemotes = JSON.parse(
|
|
31761
|
+
resolvedRemotes = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31663
31762
|
} catch {
|
|
31664
31763
|
}
|
|
31665
31764
|
}
|
|
@@ -31681,7 +31780,7 @@ ${f.tail.trimEnd()}
|
|
|
31681
31780
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
31682
31781
|
try {
|
|
31683
31782
|
const path = resolvePath(d, f);
|
|
31684
|
-
return Object.keys(parseRepoConfig(
|
|
31783
|
+
return Object.keys(parseRepoConfig(readFileSync56(path, "utf8"), path).hooks).length > 0;
|
|
31685
31784
|
} catch {
|
|
31686
31785
|
return false;
|
|
31687
31786
|
}
|
|
@@ -31730,7 +31829,7 @@ ${f.tail.trimEnd()}
|
|
|
31730
31829
|
throw new ReposError(`${e.message}${authHint}
|
|
31731
31830
|
crew.yaml was not changed`);
|
|
31732
31831
|
}
|
|
31733
|
-
|
|
31832
|
+
writeFileSync44(cfg.configFile, plan2.text);
|
|
31734
31833
|
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
31834
|
`);
|
|
31736
31835
|
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 +31889,14 @@ ${f.tail.trimEnd()}
|
|
|
31790
31889
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
31791
31890
|
`);
|
|
31792
31891
|
if (existsSync60(resolvedFile)) {
|
|
31793
|
-
const raw = JSON.parse(
|
|
31892
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
31794
31893
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
31795
31894
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
31796
|
-
|
|
31895
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31797
31896
|
`);
|
|
31798
31897
|
}
|
|
31799
31898
|
}
|
|
31800
|
-
|
|
31899
|
+
writeFileSync44(cfg.configFile, plan.text);
|
|
31801
31900
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
31802
31901
|
`);
|
|
31803
31902
|
} catch (e) {
|
|
@@ -32172,7 +32271,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32172
32271
|
process.exit(2);
|
|
32173
32272
|
}
|
|
32174
32273
|
if (found.shipNameAdopted && !dryRun) {
|
|
32175
|
-
|
|
32274
|
+
writeFileSync44(cfg.configFile, setShipNameInYaml(readFileSync56(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
32176
32275
|
cfg.ship.name = found.shipNameAdopted;
|
|
32177
32276
|
}
|
|
32178
32277
|
if (found.shipRow) {
|
|
@@ -32218,7 +32317,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32218
32317
|
const hadPreviousFile = existsSync60(resolvedPath);
|
|
32219
32318
|
if (hadPreviousFile) {
|
|
32220
32319
|
try {
|
|
32221
|
-
previous = JSON.parse(
|
|
32320
|
+
previous = JSON.parse(readFileSync56(resolvedPath, "utf8"));
|
|
32222
32321
|
} catch {
|
|
32223
32322
|
}
|
|
32224
32323
|
}
|
|
@@ -32348,12 +32447,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32348
32447
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
32349
32448
|
`);
|
|
32350
32449
|
} else {
|
|
32351
|
-
|
|
32450
|
+
mkdirSync43(dirname37(resolvedPath), { recursive: true });
|
|
32352
32451
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
32353
32452
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
32354
|
-
|
|
32453
|
+
writeFileSync44(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
32355
32454
|
`);
|
|
32356
|
-
|
|
32455
|
+
renameSync10(tmpPath, resolvedPath);
|
|
32357
32456
|
process.stderr.write(`Resolved ids written to ${resolvedPath}
|
|
32358
32457
|
`);
|
|
32359
32458
|
}
|
|
@@ -32397,8 +32496,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32397
32496
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
32398
32497
|
`);
|
|
32399
32498
|
} else {
|
|
32400
|
-
|
|
32401
|
-
|
|
32499
|
+
mkdirSync43(dirname37(apiKeyFile), { recursive: true });
|
|
32500
|
+
writeFileSync44(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
32402
32501
|
`, { mode: 384 });
|
|
32403
32502
|
process.stderr.write(`API key written to ${apiKeyFile}
|
|
32404
32503
|
`);
|
|
@@ -33113,10 +33212,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
33113
33212
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
33114
33213
|
prepare: async (path) => {
|
|
33115
33214
|
for (const f of repoWt.config.worktrees.copy) {
|
|
33116
|
-
const src =
|
|
33117
|
-
if (!existsSync60(src) || existsSync60(
|
|
33118
|
-
|
|
33119
|
-
copyFileSync2(src,
|
|
33215
|
+
const src = join64(repoWt.dir, f);
|
|
33216
|
+
if (!existsSync60(src) || existsSync60(join64(path, f))) continue;
|
|
33217
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33218
|
+
copyFileSync2(src, join64(path, f));
|
|
33120
33219
|
}
|
|
33121
33220
|
const setup = repoWt.config.hooks.setup;
|
|
33122
33221
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -33445,10 +33544,10 @@ ${where.join("\n")}`);
|
|
|
33445
33544
|
},
|
|
33446
33545
|
prepare: async (path) => {
|
|
33447
33546
|
for (const f of repoP.config.worktrees.copy) {
|
|
33448
|
-
const src =
|
|
33547
|
+
const src = join64(repoP.dir, f);
|
|
33449
33548
|
if (!existsSync60(src)) continue;
|
|
33450
|
-
|
|
33451
|
-
copyFileSync2(src,
|
|
33549
|
+
mkdirSync43(dirOf2(join64(path, f)), { recursive: true });
|
|
33550
|
+
copyFileSync2(src, join64(path, f));
|
|
33452
33551
|
}
|
|
33453
33552
|
const setup = repoP.config.hooks.setup;
|
|
33454
33553
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -33760,7 +33859,7 @@ ${where.join("\n")}`);
|
|
|
33760
33859
|
};
|
|
33761
33860
|
const droppedRoutes = [];
|
|
33762
33861
|
try {
|
|
33763
|
-
const rawCfg = parseYaml3(
|
|
33862
|
+
const rawCfg = parseYaml3(readFileSync56(cfg.configFile, "utf8"));
|
|
33764
33863
|
for (const r of rawCfg?.routes ?? []) {
|
|
33765
33864
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
33766
33865
|
try {
|
|
@@ -33824,8 +33923,8 @@ ${where.join("\n")}`);
|
|
|
33824
33923
|
process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
|
|
33825
33924
|
break;
|
|
33826
33925
|
}
|
|
33827
|
-
|
|
33828
|
-
|
|
33926
|
+
mkdirSync43(cfg.ship.stateDir, { recursive: true });
|
|
33927
|
+
writeFileSync44(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
33829
33928
|
`);
|
|
33830
33929
|
process.stdout.write(
|
|
33831
33930
|
"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 +33989,7 @@ ${where.join("\n")}`);
|
|
|
33890
33989
|
}
|
|
33891
33990
|
case "log": {
|
|
33892
33991
|
try {
|
|
33893
|
-
const text2 =
|
|
33992
|
+
const text2 = readFileSync56(cfg.ship.logFile, "utf8").split("\n");
|
|
33894
33993
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
33895
33994
|
`);
|
|
33896
33995
|
} catch {
|
|
@@ -33913,7 +34012,7 @@ ${where.join("\n")}`);
|
|
|
33913
34012
|
};
|
|
33914
34013
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
33915
34014
|
const tracker = new Tracker(route2, cfg.ship);
|
|
33916
|
-
const configText =
|
|
34015
|
+
const configText = readFileSync56(cfg.configFile, "utf8");
|
|
33917
34016
|
const cfgBase = dirname37(cfg.configFile);
|
|
33918
34017
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
33919
34018
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -33942,7 +34041,7 @@ ${where.join("\n")}`);
|
|
|
33942
34041
|
}
|
|
33943
34042
|
if (configured2.some((r) => r.dir === dir)) {
|
|
33944
34043
|
try {
|
|
33945
|
-
|
|
34044
|
+
writeFileSync44(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
33946
34045
|
} catch (e) {
|
|
33947
34046
|
if (e instanceof ReposError) fail2(e.message);
|
|
33948
34047
|
throw e;
|
|
@@ -33951,28 +34050,28 @@ ${where.join("\n")}`);
|
|
|
33951
34050
|
if (row) {
|
|
33952
34051
|
await tracker.deleteRepoRow(row.id);
|
|
33953
34052
|
if (existsSync60(resolvedFile)) {
|
|
33954
|
-
const raw = JSON.parse(
|
|
34053
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33955
34054
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
33956
34055
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
33957
|
-
|
|
34056
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33958
34057
|
`);
|
|
33959
34058
|
}
|
|
33960
34059
|
}
|
|
33961
|
-
if (existsSync60(
|
|
34060
|
+
if (existsSync60(join64(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
33962
34061
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
33963
34062
|
break;
|
|
33964
34063
|
}
|
|
33965
34064
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
33966
|
-
const fresh = !existsSync60(
|
|
34065
|
+
const fresh = !existsSync60(join64(dir, ".git"));
|
|
33967
34066
|
if (existsSync60(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
33968
34067
|
if (dryRun) {
|
|
33969
34068
|
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
34069
|
break;
|
|
33971
34070
|
}
|
|
33972
34071
|
if (fresh) {
|
|
33973
|
-
|
|
33974
|
-
|
|
33975
|
-
|
|
34072
|
+
mkdirSync43(dir, { recursive: true });
|
|
34073
|
+
writeFileSync44(join64(dir, "README.md"), SAMPLE_README);
|
|
34074
|
+
writeFileSync44(join64(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
33976
34075
|
const g = (...a) => {
|
|
33977
34076
|
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
33978
34077
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -33991,16 +34090,16 @@ ${where.join("\n")}`);
|
|
|
33991
34090
|
});
|
|
33992
34091
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
33993
34092
|
if (existsSync60(resolvedFile)) {
|
|
33994
|
-
const raw = JSON.parse(
|
|
34093
|
+
const raw = JSON.parse(readFileSync56(resolvedFile, "utf8"));
|
|
33995
34094
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
33996
34095
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
33997
|
-
|
|
34096
|
+
writeFileSync44(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33998
34097
|
`);
|
|
33999
34098
|
}
|
|
34000
34099
|
}
|
|
34001
34100
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
34002
34101
|
try {
|
|
34003
|
-
|
|
34102
|
+
writeFileSync44(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
34004
34103
|
} catch (e) {
|
|
34005
34104
|
if (e instanceof ReposError) fail2(e.message);
|
|
34006
34105
|
throw e;
|
|
@@ -34559,7 +34658,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34559
34658
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
34560
34659
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
34561
34660
|
try {
|
|
34562
|
-
return
|
|
34661
|
+
return readFileSync56(p, "utf8");
|
|
34563
34662
|
} catch {
|
|
34564
34663
|
return null;
|
|
34565
34664
|
}
|
|
@@ -34574,7 +34673,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34574
34673
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
34575
34674
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
34576
34675
|
try {
|
|
34577
|
-
return
|
|
34676
|
+
return readFileSync56(p, "utf8");
|
|
34578
34677
|
} catch {
|
|
34579
34678
|
return null;
|
|
34580
34679
|
}
|