@tablation/crew 0.143.1 → 0.143.2
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 +328 -137
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -15637,10 +15637,10 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
15637
15637
|
}
|
|
15638
15638
|
|
|
15639
15639
|
// src/cli.ts
|
|
15640
|
-
import { resolve as resolve7, dirname as dirname37, join as
|
|
15640
|
+
import { resolve as resolve7, dirname as dirname37, join as join62, basename as basename17 } from "path";
|
|
15641
15641
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
15642
15642
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
15643
|
-
import { spawnSync as
|
|
15643
|
+
import { spawnSync as spawnSync14 } from "child_process";
|
|
15644
15644
|
import { parse as parseYaml3 } from "yaml";
|
|
15645
15645
|
|
|
15646
15646
|
// src/argv.ts
|
|
@@ -21471,6 +21471,10 @@ async function runCommentDeliveryPass(deps) {
|
|
|
21471
21471
|
return n;
|
|
21472
21472
|
}
|
|
21473
21473
|
|
|
21474
|
+
// src/launchd-start.ts
|
|
21475
|
+
import { readFileSync as readFileSync46 } from "fs";
|
|
21476
|
+
import { spawnSync as spawnSync12 } from "child_process";
|
|
21477
|
+
|
|
21474
21478
|
// src/daemon-liveness.ts
|
|
21475
21479
|
import { existsSync as existsSync48, readFileSync as readFileSync45 } from "fs";
|
|
21476
21480
|
|
|
@@ -23659,8 +23663,95 @@ function readDaemonStamp(stateDir) {
|
|
|
23659
23663
|
}
|
|
23660
23664
|
}
|
|
23661
23665
|
|
|
23666
|
+
// src/launchd-start.ts
|
|
23667
|
+
function launchdStartState(r) {
|
|
23668
|
+
if (!r.loaded) return "unloaded";
|
|
23669
|
+
return r.pid !== null ? "running" : "loaded";
|
|
23670
|
+
}
|
|
23671
|
+
function planLaunchdStart(r, unit) {
|
|
23672
|
+
const state = launchdStartState(r);
|
|
23673
|
+
if (state === "running") return { state, commands: [] };
|
|
23674
|
+
if (state === "loaded") return { state, commands: [["launchctl", "kickstart", `gui/${unit.uid}/${unit.label}`]] };
|
|
23675
|
+
return { state, commands: [["launchctl", "load", unit.unitPath]] };
|
|
23676
|
+
}
|
|
23677
|
+
var LOG_TAIL_LINES = 10;
|
|
23678
|
+
function defaultRun(cmd) {
|
|
23679
|
+
const r = spawnSync12(cmd[0], cmd.slice(1), { encoding: "utf8" });
|
|
23680
|
+
return r.error ? null : { status: r.status, stdout: r.stdout ?? "", stderr: r.stderr ?? "" };
|
|
23681
|
+
}
|
|
23682
|
+
function defaultSleep2(ms3) {
|
|
23683
|
+
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms3);
|
|
23684
|
+
}
|
|
23685
|
+
function defaultReadLog(path) {
|
|
23686
|
+
try {
|
|
23687
|
+
return readFileSync46(path, "utf8");
|
|
23688
|
+
} catch {
|
|
23689
|
+
return null;
|
|
23690
|
+
}
|
|
23691
|
+
}
|
|
23692
|
+
function logTail(text2, n = LOG_TAIL_LINES) {
|
|
23693
|
+
if (text2 === null) return [];
|
|
23694
|
+
return text2.split("\n").map((l) => l.trimEnd()).filter((l) => l.trim() !== "").slice(-n);
|
|
23695
|
+
}
|
|
23696
|
+
function startLaunchdDaemon(o) {
|
|
23697
|
+
const run4 = o.run ?? defaultRun;
|
|
23698
|
+
const sleep = o.sleep ?? defaultSleep2;
|
|
23699
|
+
const readLog = o.readLog ?? defaultReadLog;
|
|
23700
|
+
let out = "";
|
|
23701
|
+
let err3 = "";
|
|
23702
|
+
const read = () => {
|
|
23703
|
+
const r = run4(["launchctl", "print", `gui/${o.uid}/${o.label}`]);
|
|
23704
|
+
if (!r || r.status !== 0) return { loaded: false, pid: null, lastExitCode: null };
|
|
23705
|
+
return { loaded: true, ...parseLaunchctlPrint(r.stdout) };
|
|
23706
|
+
};
|
|
23707
|
+
const reading = o.assumeUnloaded ? { loaded: false, pid: null, lastExitCode: null } : read();
|
|
23708
|
+
const plan = planLaunchdStart(reading, o);
|
|
23709
|
+
if (plan.state === "running") {
|
|
23710
|
+
out += `crew daemon start: already running (pid ${reading.pid})
|
|
23711
|
+
`;
|
|
23712
|
+
return { exitCode: 0, stdout: out, stderr: err3 };
|
|
23713
|
+
}
|
|
23714
|
+
if (o.dryRun) {
|
|
23715
|
+
for (const c of plan.commands) out += `would run: ${c.join(" ")}
|
|
23716
|
+
`;
|
|
23717
|
+
return { exitCode: 0, stdout: out, stderr: err3 };
|
|
23718
|
+
}
|
|
23719
|
+
for (const cmd of plan.commands) {
|
|
23720
|
+
const res = run4(cmd);
|
|
23721
|
+
if (res?.stdout) out += res.stdout;
|
|
23722
|
+
if (res?.stderr) err3 += res.stderr;
|
|
23723
|
+
if (!res || res.status !== 0) {
|
|
23724
|
+
err3 += `crew daemon start: ${cmd.join(" ")} exited ${res?.status ?? "error"}
|
|
23725
|
+
`;
|
|
23726
|
+
return { exitCode: 1, stdout: out, stderr: err3 };
|
|
23727
|
+
}
|
|
23728
|
+
}
|
|
23729
|
+
if (plan.state === "unloaded" && !o.verifyAfterLoad) return { exitCode: 0, stdout: out, stderr: err3 };
|
|
23730
|
+
sleep(o.settleMs ?? 3e3);
|
|
23731
|
+
const after = read();
|
|
23732
|
+
if (after.loaded && after.pid !== null) {
|
|
23733
|
+
out += `crew daemon start: running (pid ${after.pid})
|
|
23734
|
+
`;
|
|
23735
|
+
return { exitCode: 0, stdout: out, stderr: err3 };
|
|
23736
|
+
}
|
|
23737
|
+
err3 += "crew daemon start: the daemon did not stay up.\n";
|
|
23738
|
+
err3 += ` last exit status: ${after.lastExitCode ?? "none recorded"}
|
|
23739
|
+
`;
|
|
23740
|
+
const tail3 = logTail(readLog(o.schedulerLog));
|
|
23741
|
+
if (tail3.length) {
|
|
23742
|
+
err3 += ` last lines of ${o.schedulerLog}:
|
|
23743
|
+
`;
|
|
23744
|
+
for (const l of tail3) err3 += ` ${l}
|
|
23745
|
+
`;
|
|
23746
|
+
} else {
|
|
23747
|
+
err3 += ` ${o.schedulerLog} has no output
|
|
23748
|
+
`;
|
|
23749
|
+
}
|
|
23750
|
+
return { exitCode: 1, stdout: out, stderr: err3 };
|
|
23751
|
+
}
|
|
23752
|
+
|
|
23662
23753
|
// src/daemon-start-failure.ts
|
|
23663
|
-
import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as
|
|
23754
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync36, readFileSync as readFileSync47, unlinkSync as unlinkSync4, writeFileSync as writeFileSync37 } from "fs";
|
|
23664
23755
|
import { dirname as dirname29, join as join51 } from "path";
|
|
23665
23756
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
23666
23757
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
@@ -23668,7 +23759,7 @@ var BACKOFF_AFTER_FAILURES = 2;
|
|
|
23668
23759
|
var fileFor3 = (stateDir) => join51(stateDir, ".daemon-start-failure.json");
|
|
23669
23760
|
function readStartFailure(stateDir) {
|
|
23670
23761
|
try {
|
|
23671
|
-
const parsed = JSON.parse(
|
|
23762
|
+
const parsed = JSON.parse(readFileSync47(fileFor3(stateDir), "utf8"));
|
|
23672
23763
|
return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
|
|
23673
23764
|
} catch {
|
|
23674
23765
|
return null;
|
|
@@ -24934,7 +25025,7 @@ function describeCapability(i) {
|
|
|
24934
25025
|
}
|
|
24935
25026
|
|
|
24936
25027
|
// src/persona-avatars.ts
|
|
24937
|
-
import { existsSync as existsSync51, readFileSync as
|
|
25028
|
+
import { existsSync as existsSync51, readFileSync as readFileSync48 } from "fs";
|
|
24938
25029
|
import { join as join52 } from "path";
|
|
24939
25030
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
24940
25031
|
function personaAvatarFile(promptsDir, role) {
|
|
@@ -24955,7 +25046,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
|
24955
25046
|
if (!file || !agentId) continue;
|
|
24956
25047
|
try {
|
|
24957
25048
|
const form = new FormData();
|
|
24958
|
-
form.append("file", new Blob([
|
|
25049
|
+
form.append("file", new Blob([readFileSync48(file.path)], { type: file.mimeType }), file.name);
|
|
24959
25050
|
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
24960
25051
|
method: "PUT",
|
|
24961
25052
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
@@ -24996,14 +25087,14 @@ function avatarFailures(raw) {
|
|
|
24996
25087
|
}
|
|
24997
25088
|
function routeAvatarFailures(stateDir, route2) {
|
|
24998
25089
|
try {
|
|
24999
|
-
return avatarFailures(JSON.parse(
|
|
25090
|
+
return avatarFailures(JSON.parse(readFileSync48(resolvedPathFor(stateDir, route2), "utf8")));
|
|
25000
25091
|
} catch {
|
|
25001
25092
|
return [];
|
|
25002
25093
|
}
|
|
25003
25094
|
}
|
|
25004
25095
|
|
|
25005
25096
|
// src/agents-sync-run.ts
|
|
25006
|
-
import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as
|
|
25097
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync38, readFileSync as readFileSync49, writeFileSync as writeFileSync39 } from "fs";
|
|
25007
25098
|
import { dirname as dirname31 } from "path";
|
|
25008
25099
|
async function runAgentsSync(target, o) {
|
|
25009
25100
|
const dryRun = o.dryRun ?? false;
|
|
@@ -25049,7 +25140,7 @@ async function runAgentsSync(target, o) {
|
|
|
25049
25140
|
}
|
|
25050
25141
|
if (!dryRun) {
|
|
25051
25142
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
25052
|
-
const raw = existsSync52(resolvedPath) ? JSON.parse(
|
|
25143
|
+
const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
|
|
25053
25144
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
25054
25145
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
25055
25146
|
if (!readOnly) raw.avatarSyncFailures = avatarFailures2;
|
|
@@ -25191,8 +25282,8 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
25191
25282
|
}
|
|
25192
25283
|
|
|
25193
25284
|
// src/repos-check.ts
|
|
25194
|
-
import { spawnSync as
|
|
25195
|
-
import { readFileSync as
|
|
25285
|
+
import { spawnSync as spawnSync13 } from "child_process";
|
|
25286
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
25196
25287
|
import { basename as basename12 } from "path";
|
|
25197
25288
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
25198
25289
|
function checkHookSyntax(script, shell) {
|
|
@@ -25200,10 +25291,10 @@ function checkHookSyntax(script, shell) {
|
|
|
25200
25291
|
const name = basename12(spec.bin).replace(/\.exe$/i, "").toLowerCase();
|
|
25201
25292
|
let run4;
|
|
25202
25293
|
if (POSIX_SHELL.test(name)) {
|
|
25203
|
-
run4 =
|
|
25294
|
+
run4 = spawnSync13(spec.bin, ["-n"], { input: script, encoding: "utf8" });
|
|
25204
25295
|
} else if (/^(pwsh|powershell)$/.test(name)) {
|
|
25205
25296
|
const parse3 = "$e=$null;[void][System.Management.Automation.Language.Parser]::ParseInput($env:CREW_CHECK_SCRIPT,[ref]$null,[ref]$e);if($e){$e|ForEach-Object{[Console]::Error.WriteLine($_.Message)};exit 1}";
|
|
25206
|
-
run4 =
|
|
25297
|
+
run4 = spawnSync13(spec.bin, ["-NoProfile", "-NonInteractive", "-Command", parse3], {
|
|
25207
25298
|
encoding: "utf8",
|
|
25208
25299
|
env: { ...process.env, CREW_CHECK_SCRIPT: script }
|
|
25209
25300
|
});
|
|
@@ -25233,7 +25324,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
25233
25324
|
}
|
|
25234
25325
|
let parsed;
|
|
25235
25326
|
try {
|
|
25236
|
-
parsed = parseRepoConfig(
|
|
25327
|
+
parsed = parseRepoConfig(readFileSync50(file, "utf8"), file);
|
|
25237
25328
|
} catch (e) {
|
|
25238
25329
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
25239
25330
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -25765,7 +25856,7 @@ function planSampleTicket(i) {
|
|
|
25765
25856
|
}
|
|
25766
25857
|
|
|
25767
25858
|
// src/worktree-sweep.ts
|
|
25768
|
-
import { existsSync as existsSync53, readFileSync as
|
|
25859
|
+
import { existsSync as existsSync53, readFileSync as readFileSync51, readdirSync as readdirSync15 } from "fs";
|
|
25769
25860
|
import { basename as basename14, dirname as dirname33, join as join54, resolve as resolve5 } from "path";
|
|
25770
25861
|
function planWorktreeSweep(target, tickets, contract) {
|
|
25771
25862
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
@@ -25965,7 +26056,7 @@ function isHandBackMerge(path, base) {
|
|
|
25965
26056
|
if (!msgPath) return false;
|
|
25966
26057
|
let first;
|
|
25967
26058
|
try {
|
|
25968
|
-
first =
|
|
26059
|
+
first = readFileSync51(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
25969
26060
|
} catch {
|
|
25970
26061
|
return false;
|
|
25971
26062
|
}
|
|
@@ -26115,7 +26206,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
26115
26206
|
}
|
|
26116
26207
|
|
|
26117
26208
|
// src/cli.ts
|
|
26118
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
26209
|
+
import { realpathSync as realpathSync3, readFileSync as readFileSync54, existsSync as existsSync59, mkdirSync as mkdirSync42, writeFileSync as writeFileSync42, rmSync as rmSync26, unlinkSync as unlinkSync6, copyFileSync as copyFileSync2, renameSync as renameSync8, statSync as statSync18, readdirSync as readdirSync21 } from "fs";
|
|
26119
26210
|
import { createInterface } from "readline/promises";
|
|
26120
26211
|
|
|
26121
26212
|
// src/periscope-resume.ts
|
|
@@ -26190,6 +26281,48 @@ ${tail2(preview.output)}`);
|
|
|
26190
26281
|
// src/cli.ts
|
|
26191
26282
|
import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
26192
26283
|
|
|
26284
|
+
// src/bundle-staleness.ts
|
|
26285
|
+
import { existsSync as existsSync55, readdirSync as readdirSync17, statSync as statSync16 } from "fs";
|
|
26286
|
+
import { join as join56 } from "path";
|
|
26287
|
+
function builtVersion() {
|
|
26288
|
+
return true ? "0.143.2" : null;
|
|
26289
|
+
}
|
|
26290
|
+
var REBUILD_HINT = "rebuild with npm run build";
|
|
26291
|
+
function newestMtime(path) {
|
|
26292
|
+
let stat2;
|
|
26293
|
+
try {
|
|
26294
|
+
stat2 = statSync16(path);
|
|
26295
|
+
} catch {
|
|
26296
|
+
return 0;
|
|
26297
|
+
}
|
|
26298
|
+
if (stat2.isFile()) return stat2.mtimeMs;
|
|
26299
|
+
if (!stat2.isDirectory()) return 0;
|
|
26300
|
+
let latest = stat2.mtimeMs;
|
|
26301
|
+
for (const e of readdirSync17(path, { withFileTypes: true })) latest = Math.max(latest, newestMtime(join56(path, e.name)));
|
|
26302
|
+
return latest;
|
|
26303
|
+
}
|
|
26304
|
+
function bundleStaleness(i) {
|
|
26305
|
+
if (i.built === null || i.compiled) return null;
|
|
26306
|
+
const src = join56(i.home, "src");
|
|
26307
|
+
if (!existsSync55(src)) return null;
|
|
26308
|
+
if (i.built !== i.current) {
|
|
26309
|
+
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
26310
|
+
}
|
|
26311
|
+
const bundle = statSafe(join56(i.home, "dist", "cli.js"));
|
|
26312
|
+
if (bundle === null) return null;
|
|
26313
|
+
if (newestMtime(src) > bundle) {
|
|
26314
|
+
return { kind: "source", builtVersion: i.built, message: `running a bundle older than the source in src/ (both ${i.current}); ${REBUILD_HINT}` };
|
|
26315
|
+
}
|
|
26316
|
+
return null;
|
|
26317
|
+
}
|
|
26318
|
+
function statSafe(p) {
|
|
26319
|
+
try {
|
|
26320
|
+
return statSync16(p).mtimeMs;
|
|
26321
|
+
} catch {
|
|
26322
|
+
return null;
|
|
26323
|
+
}
|
|
26324
|
+
}
|
|
26325
|
+
|
|
26193
26326
|
// src/relay-probe.ts
|
|
26194
26327
|
async function probeRelayControl(relayUrl, apiKey, userAgent, fetchFn = fetch, timeoutMs = 1e4) {
|
|
26195
26328
|
const started = Date.now();
|
|
@@ -26342,8 +26475,8 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
26342
26475
|
import { createServer as createHttpServer } from "http";
|
|
26343
26476
|
import { spawn as spawn9 } from "child_process";
|
|
26344
26477
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
26345
|
-
import { existsSync as
|
|
26346
|
-
import { join as
|
|
26478
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync39, readFileSync as readFileSync52, writeFileSync as writeFileSync40, unlinkSync as unlinkSync5, readdirSync as readdirSync18 } from "fs";
|
|
26479
|
+
import { join as join57 } from "path";
|
|
26347
26480
|
|
|
26348
26481
|
// src/secret-compare.ts
|
|
26349
26482
|
import { timingSafeEqual } from "crypto";
|
|
@@ -26436,20 +26569,20 @@ var defaultSpawn2 = (cmd, args, env) => {
|
|
|
26436
26569
|
return child;
|
|
26437
26570
|
};
|
|
26438
26571
|
function syncDaemonStatePath(stateDir, workspaceId) {
|
|
26439
|
-
return
|
|
26572
|
+
return join57(stateDir, "passengers", `${workspaceId}-sync.json`);
|
|
26440
26573
|
}
|
|
26441
26574
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
26442
26575
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
26443
|
-
if (!
|
|
26576
|
+
if (!existsSync56(path)) return void 0;
|
|
26444
26577
|
try {
|
|
26445
|
-
return JSON.parse(
|
|
26578
|
+
return JSON.parse(readFileSync52(path, "utf8"));
|
|
26446
26579
|
} catch {
|
|
26447
26580
|
return void 0;
|
|
26448
26581
|
}
|
|
26449
26582
|
}
|
|
26450
26583
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
26451
26584
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
26452
|
-
mkdirSync39(
|
|
26585
|
+
mkdirSync39(join57(stateDir, "passengers"), { recursive: true });
|
|
26453
26586
|
writeFileSync40(path, `${JSON.stringify(state, null, 2)}
|
|
26454
26587
|
`);
|
|
26455
26588
|
}
|
|
@@ -26470,10 +26603,10 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
26470
26603
|
}
|
|
26471
26604
|
}
|
|
26472
26605
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
26473
|
-
const dir =
|
|
26474
|
-
if (!
|
|
26606
|
+
const dir = join57(stateDir, "passengers");
|
|
26607
|
+
if (!existsSync56(dir)) return [];
|
|
26475
26608
|
const suffix = "-sync.json";
|
|
26476
|
-
return
|
|
26609
|
+
return readdirSync18(dir).filter((f) => f.endsWith(suffix)).map((f) => f.slice(0, -suffix.length));
|
|
26477
26610
|
}
|
|
26478
26611
|
function syncPassengerSyncDaemons(plans, cfg, stateDir, deps = {}) {
|
|
26479
26612
|
const alive = deps.isPidAlive ?? isPidAlive;
|
|
@@ -26937,7 +27070,7 @@ async function startWorktreeIntel(d) {
|
|
|
26937
27070
|
}
|
|
26938
27071
|
|
|
26939
27072
|
// src/contract-refusal.ts
|
|
26940
|
-
import { join as
|
|
27073
|
+
import { join as join58 } from "path";
|
|
26941
27074
|
function contractFixers(dir, baseRef, tickets, locate) {
|
|
26942
27075
|
const out = [];
|
|
26943
27076
|
for (const t of tickets) {
|
|
@@ -26949,7 +27082,7 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
26949
27082
|
const text2 = gitOk(dir, ["show", `${branch}:${file}`]);
|
|
26950
27083
|
if (text2 === null) continue;
|
|
26951
27084
|
try {
|
|
26952
|
-
parseRepoConfig(text2,
|
|
27085
|
+
parseRepoConfig(text2, join58(dir, file));
|
|
26953
27086
|
} catch (e) {
|
|
26954
27087
|
if (e instanceof RepoConfigError) continue;
|
|
26955
27088
|
throw e;
|
|
@@ -26964,18 +27097,18 @@ import { createHash as createHash11 } from "crypto";
|
|
|
26964
27097
|
import {
|
|
26965
27098
|
chmodSync as chmodSync4,
|
|
26966
27099
|
closeSync as closeSync6,
|
|
26967
|
-
existsSync as
|
|
27100
|
+
existsSync as existsSync57,
|
|
26968
27101
|
fstatSync,
|
|
26969
27102
|
openSync as openSync6,
|
|
26970
27103
|
readSync as readSync3,
|
|
26971
|
-
readdirSync as
|
|
27104
|
+
readdirSync as readdirSync19,
|
|
26972
27105
|
rmSync as rmSync24,
|
|
26973
|
-
statSync as
|
|
27106
|
+
statSync as statSync17,
|
|
26974
27107
|
watch
|
|
26975
27108
|
} from "fs";
|
|
26976
27109
|
import { createConnection } from "net";
|
|
26977
27110
|
import { createServer as createServer2 } from "http";
|
|
26978
|
-
import { basename as basename15, dirname as dirname35, join as
|
|
27111
|
+
import { basename as basename15, dirname as dirname35, join as join59 } from "path";
|
|
26979
27112
|
import { execFile as execFile6, spawn as spawn12 } from "child_process";
|
|
26980
27113
|
|
|
26981
27114
|
// src/periscope-control.ts
|
|
@@ -27212,7 +27345,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
27212
27345
|
// src/control-api.ts
|
|
27213
27346
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
27214
27347
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
27215
|
-
var controlSocketFor = (stateDir) =>
|
|
27348
|
+
var controlSocketFor = (stateDir) => join59(stateDir, CONTROL_SOCKET_NAME);
|
|
27216
27349
|
var MAX_SOCKET_PATH = 100;
|
|
27217
27350
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
27218
27351
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -27299,7 +27432,7 @@ function candidates(live2, rotated) {
|
|
|
27299
27432
|
const out = [live2];
|
|
27300
27433
|
if (!rotated) return out;
|
|
27301
27434
|
try {
|
|
27302
|
-
for (const n of
|
|
27435
|
+
for (const n of readdirSync19(dirname35(live2))) if (ROTATED_EVENTS_RE.test(n)) out.push(join59(dirname35(live2), n));
|
|
27303
27436
|
} catch {
|
|
27304
27437
|
}
|
|
27305
27438
|
return out;
|
|
@@ -27322,7 +27455,7 @@ function readRange(path, from, max) {
|
|
|
27322
27455
|
}
|
|
27323
27456
|
}
|
|
27324
27457
|
function lastLines2(path, n) {
|
|
27325
|
-
const st =
|
|
27458
|
+
const st = statSync17(path);
|
|
27326
27459
|
const cursorAt = (off) => encodeCursor({ dev: st.dev, ino: st.ino, off });
|
|
27327
27460
|
if (n <= 0 || st.size === 0) return { lines: [], cursor: cursorAt(st.size), reset: false };
|
|
27328
27461
|
let start = st.size;
|
|
@@ -27343,7 +27476,7 @@ function lastLines2(path, n) {
|
|
|
27343
27476
|
}
|
|
27344
27477
|
function readTail(live2, opts) {
|
|
27345
27478
|
const max = opts.maxBytes ?? MAX_TAIL_BYTES;
|
|
27346
|
-
if (!
|
|
27479
|
+
if (!existsSync57(live2)) {
|
|
27347
27480
|
return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
|
|
27348
27481
|
}
|
|
27349
27482
|
const cur = opts.after ? decodeCursor(opts.after) : null;
|
|
@@ -27356,7 +27489,7 @@ function readTail(live2, opts) {
|
|
|
27356
27489
|
} else {
|
|
27357
27490
|
const found = candidates(live2, opts.rotated ?? false).find((p) => {
|
|
27358
27491
|
try {
|
|
27359
|
-
const s =
|
|
27492
|
+
const s = statSync17(p);
|
|
27360
27493
|
return s.ino === cur.ino && s.dev === cur.dev;
|
|
27361
27494
|
} catch {
|
|
27362
27495
|
return false;
|
|
@@ -27367,7 +27500,7 @@ function readTail(live2, opts) {
|
|
|
27367
27500
|
off = cur.off;
|
|
27368
27501
|
} else reset = true;
|
|
27369
27502
|
}
|
|
27370
|
-
let size =
|
|
27503
|
+
let size = statSync17(path).size;
|
|
27371
27504
|
if (off > size) {
|
|
27372
27505
|
off = 0;
|
|
27373
27506
|
reset = true;
|
|
@@ -27375,12 +27508,12 @@ function readTail(live2, opts) {
|
|
|
27375
27508
|
if (off >= size && path !== live2) {
|
|
27376
27509
|
path = live2;
|
|
27377
27510
|
off = 0;
|
|
27378
|
-
size =
|
|
27511
|
+
size = statSync17(path).size;
|
|
27379
27512
|
}
|
|
27380
27513
|
const { text: text2 } = readRange(path, off, max);
|
|
27381
27514
|
const cut = text2.lastIndexOf("\n");
|
|
27382
27515
|
const whole = cut < 0 ? "" : text2.slice(0, cut + 1);
|
|
27383
|
-
const st =
|
|
27516
|
+
const st = statSync17(path);
|
|
27384
27517
|
return {
|
|
27385
27518
|
lines: whole.split("\n").filter((l) => l.length),
|
|
27386
27519
|
cursor: encodeCursor({ dev: st.dev, ino: st.ino, off: off + Buffer.byteLength(whole) }),
|
|
@@ -27522,8 +27655,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
27522
27655
|
if (p.startsWith("/streams/") && get2) {
|
|
27523
27656
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
27524
27657
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
27525
|
-
const file =
|
|
27526
|
-
if (!
|
|
27658
|
+
const file = join59(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
27659
|
+
if (!existsSync57(file)) return err2(404, "no such run");
|
|
27527
27660
|
return tailReply(file, url.searchParams, false, abort);
|
|
27528
27661
|
}
|
|
27529
27662
|
const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
|
|
@@ -27570,7 +27703,7 @@ function send2(res, r) {
|
|
|
27570
27703
|
res.end(body);
|
|
27571
27704
|
}
|
|
27572
27705
|
async function socketIsStale(path) {
|
|
27573
|
-
if (!
|
|
27706
|
+
if (!existsSync57(path)) return false;
|
|
27574
27707
|
return new Promise((resolve8) => {
|
|
27575
27708
|
const c = createConnection(path);
|
|
27576
27709
|
c.once("connect", () => {
|
|
@@ -27589,7 +27722,7 @@ async function startControlServer(deps) {
|
|
|
27589
27722
|
return null;
|
|
27590
27723
|
}
|
|
27591
27724
|
if (await socketIsStale(path)) rmSync24(path, { force: true });
|
|
27592
|
-
else if (
|
|
27725
|
+
else if (existsSync57(path)) {
|
|
27593
27726
|
log(`control API not started: ${path} is in use by another process`);
|
|
27594
27727
|
return null;
|
|
27595
27728
|
}
|
|
@@ -27675,19 +27808,19 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
27675
27808
|
|
|
27676
27809
|
// src/periscope-mcp.ts
|
|
27677
27810
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
27678
|
-
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as
|
|
27811
|
+
import { basename as basename16, dirname as dirname36, isAbsolute as isAbsolute5, join as join61, relative as relative2, resolve as resolve6, sep } from "path";
|
|
27679
27812
|
import { z } from "zod";
|
|
27680
27813
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
27681
27814
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
27682
27815
|
|
|
27683
27816
|
// src/periscope-endpoints.ts
|
|
27684
27817
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
27685
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
27686
|
-
import { join as
|
|
27687
|
-
var secretDir = (stateDir) =>
|
|
27688
|
-
var secretFile = (stateDir, id) =>
|
|
27689
|
-
var endpointDir = (stateDir) =>
|
|
27690
|
-
var endpointFile = (stateDir, id) =>
|
|
27818
|
+
import { chmodSync as chmodSync5, existsSync as existsSync58, mkdirSync as mkdirSync41, readdirSync as readdirSync20, readFileSync as readFileSync53, rmSync as rmSync25, writeFileSync as writeFileSync41 } from "fs";
|
|
27819
|
+
import { join as join60 } from "path";
|
|
27820
|
+
var secretDir = (stateDir) => join60(stateDir, "periscope-mcp");
|
|
27821
|
+
var secretFile = (stateDir, id) => join60(secretDir(stateDir), `${id}.json`);
|
|
27822
|
+
var endpointDir = (stateDir) => join60(stateDir, "periscope-endpoints");
|
|
27823
|
+
var endpointFile = (stateDir, id) => join60(endpointDir(stateDir), `${id}.json`);
|
|
27691
27824
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27692
27825
|
mkdirSync41(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
27693
27826
|
const secret = randomBytes3(32).toString("base64url");
|
|
@@ -27699,7 +27832,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
27699
27832
|
}
|
|
27700
27833
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
27701
27834
|
try {
|
|
27702
|
-
const v = JSON.parse(
|
|
27835
|
+
const v = JSON.parse(readFileSync53(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
27703
27836
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
27704
27837
|
} catch {
|
|
27705
27838
|
return void 0;
|
|
@@ -27710,7 +27843,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
27710
27843
|
}
|
|
27711
27844
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
27712
27845
|
try {
|
|
27713
|
-
return JSON.parse(
|
|
27846
|
+
return JSON.parse(readFileSync53(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
27714
27847
|
} catch {
|
|
27715
27848
|
return void 0;
|
|
27716
27849
|
}
|
|
@@ -27725,9 +27858,9 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
|
27725
27858
|
}
|
|
27726
27859
|
function listPeriscopeEndpoints(stateDir) {
|
|
27727
27860
|
const dir = endpointDir(stateDir);
|
|
27728
|
-
if (!
|
|
27861
|
+
if (!existsSync58(dir)) return [];
|
|
27729
27862
|
const out = [];
|
|
27730
|
-
for (const name of
|
|
27863
|
+
for (const name of readdirSync20(dir)) {
|
|
27731
27864
|
if (!name.endsWith(".json")) continue;
|
|
27732
27865
|
const rec = readPeriscopeEndpoint(stateDir, name.slice(0, -".json".length));
|
|
27733
27866
|
if (rec && typeof rec.endpointId === "string") out.push(rec);
|
|
@@ -27828,13 +27961,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
27828
27961
|
let abs;
|
|
27829
27962
|
if (isAbsolute5(requested)) {
|
|
27830
27963
|
abs = resolve6(requested);
|
|
27831
|
-
if (isInside(root, abs)) abs =
|
|
27964
|
+
if (isInside(root, abs)) abs = join61(realRoot, relative2(root, abs));
|
|
27832
27965
|
} else {
|
|
27833
27966
|
abs = resolve6(realRoot, requested);
|
|
27834
27967
|
}
|
|
27835
27968
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
27836
27969
|
const { real, rest } = await realAncestor(abs);
|
|
27837
|
-
const final = rest ?
|
|
27970
|
+
const final = rest ? join61(real, rest) : real;
|
|
27838
27971
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
27839
27972
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
27840
27973
|
return final;
|
|
@@ -27902,7 +28035,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
27902
28035
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
27903
28036
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
27904
28037
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
27905
|
-
const size = (await lstat(
|
|
28038
|
+
const size = (await lstat(join61(abs, e.name))).size;
|
|
27906
28039
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
27907
28040
|
}));
|
|
27908
28041
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -27968,7 +28101,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
27968
28101
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
27969
28102
|
}, async ({ path }) => {
|
|
27970
28103
|
const parent = await inTree(dirname36(path) === "" ? "." : dirname36(path));
|
|
27971
|
-
const abs =
|
|
28104
|
+
const abs = join61(parent, basename16(path));
|
|
27972
28105
|
if (basename16(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
27973
28106
|
const st = await lstat(abs).catch(() => void 0);
|
|
27974
28107
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -28327,11 +28460,15 @@ if (helpRequest(argv)) usage(void 0, true);
|
|
|
28327
28460
|
var versionReq = versionRequest(argv);
|
|
28328
28461
|
if (versionReq) {
|
|
28329
28462
|
const version = crewVersion(CREW_HOME);
|
|
28330
|
-
|
|
28331
|
-
|
|
28463
|
+
const stale = bundleStaleness({ built: builtVersion(), current: version, home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) });
|
|
28464
|
+
process.stdout.write(versionReq.json ? `${JSON.stringify({ version, home: CREW_HOME, compiled: isCompiledBinary(import.meta.url), builtVersion: builtVersion(), stale: stale !== null })}
|
|
28465
|
+
` : `${stale ? `${version} (${stale.kind === "version" ? `running a bundle built from ${stale.builtVersion}` : "running a bundle older than the source in src/"}; ${REBUILD_HINT})` : version}
|
|
28332
28466
|
`);
|
|
28333
28467
|
process.exit(0);
|
|
28334
28468
|
}
|
|
28469
|
+
var staleBundle = bundleStaleness({ built: builtVersion(), current: crewVersion(CREW_HOME), home: CREW_HOME, compiled: isCompiledBinary(import.meta.url) });
|
|
28470
|
+
if (staleBundle) process.stderr.write(`crew: warning: ${staleBundle.message}
|
|
28471
|
+
`);
|
|
28335
28472
|
var flag = (name) => argv.includes(`--${name}`);
|
|
28336
28473
|
var value = (name) => {
|
|
28337
28474
|
const i = argv.indexOf(`--${name}`);
|
|
@@ -28459,7 +28596,7 @@ if (command === "provision") {
|
|
|
28459
28596
|
process.exit(outcome.code);
|
|
28460
28597
|
}
|
|
28461
28598
|
if (command === "pool-member") {
|
|
28462
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
28599
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync54(0, "utf8"));
|
|
28463
28600
|
if (typeof pool === "string") {
|
|
28464
28601
|
process.stderr.write(`crew pool-member: ${pool}
|
|
28465
28602
|
`);
|
|
@@ -28780,7 +28917,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28780
28917
|
} else {
|
|
28781
28918
|
const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
|
|
28782
28919
|
const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
|
|
28783
|
-
if (configless && !
|
|
28920
|
+
if (configless && !existsSync59(findConfigFile(CREW_HOME))) {
|
|
28784
28921
|
cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
|
|
28785
28922
|
} else {
|
|
28786
28923
|
cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
|
|
@@ -28803,7 +28940,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
28803
28940
|
throw e;
|
|
28804
28941
|
}
|
|
28805
28942
|
if (command === "credential") {
|
|
28806
|
-
const r = runCredential(positional[1],
|
|
28943
|
+
const r = runCredential(positional[1], readFileSync54(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
28807
28944
|
process.stdout.write(r.out);
|
|
28808
28945
|
process.stderr.write(r.err);
|
|
28809
28946
|
process.exit(r.code);
|
|
@@ -28815,9 +28952,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
28815
28952
|
forges: cfg.ship.forges,
|
|
28816
28953
|
stateDir: cfg.ship.stateDir,
|
|
28817
28954
|
configFile: cfg.configFile,
|
|
28818
|
-
readFile: (p) =>
|
|
28955
|
+
readFile: (p) => readFileSync54(p, "utf8"),
|
|
28819
28956
|
writeFile: (p, t) => writeFileSync42(p, t),
|
|
28820
|
-
stdin: () =>
|
|
28957
|
+
stdin: () => readFileSync54(0, "utf8"),
|
|
28821
28958
|
env: process.env
|
|
28822
28959
|
}
|
|
28823
28960
|
);
|
|
@@ -29151,14 +29288,14 @@ if (command === "passenger-sync-daemon") {
|
|
|
29151
29288
|
}
|
|
29152
29289
|
if (host === "linux" && hasSystemd) {
|
|
29153
29290
|
const label = labelFor(CREW_HOME, "run");
|
|
29154
|
-
const staleTimer =
|
|
29155
|
-
if (
|
|
29291
|
+
const staleTimer = join62(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
29292
|
+
if (existsSync59(staleTimer)) {
|
|
29156
29293
|
process.stdout.write(
|
|
29157
29294
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
29158
29295
|
`
|
|
29159
29296
|
);
|
|
29160
29297
|
if (!dryRun) {
|
|
29161
|
-
|
|
29298
|
+
spawnSync14("systemctl", ["--user", "disable", "--now", `${label}.timer`], { cwd: CREW_HOME, env: withUserBusEnv() });
|
|
29162
29299
|
try {
|
|
29163
29300
|
unlinkSync6(staleTimer);
|
|
29164
29301
|
} catch {
|
|
@@ -29181,7 +29318,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29181
29318
|
const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
29182
29319
|
for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
|
|
29183
29320
|
for (const r of doctorRepos) {
|
|
29184
|
-
if (!
|
|
29321
|
+
if (!existsSync59(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
|
|
29185
29322
|
if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
|
|
29186
29323
|
readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
|
|
29187
29324
|
}
|
|
@@ -29217,8 +29354,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
29217
29354
|
}
|
|
29218
29355
|
async function doctorFix(o) {
|
|
29219
29356
|
const routes = await Promise.all(routesInScope(cfg.routes, named).map((c) => gatherHealth({ route: c.route, enabled: c.enabled, hasRepos: reposOf(c).length > 0 }, () => routeProblems(c))));
|
|
29220
|
-
const unitExists = (p) =>
|
|
29221
|
-
const crontab = o.host === "linux" ?
|
|
29357
|
+
const unitExists = (p) => existsSync59(p);
|
|
29358
|
+
const crontab = o.host === "linux" ? spawnSync14("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
|
|
29222
29359
|
const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
|
|
29223
29360
|
const plan = planFix({ routes, schedulerAbsent, host: o.host });
|
|
29224
29361
|
for (const n of plan.notes) process.stdout.write(`fix: ${n}
|
|
@@ -29234,7 +29371,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
29234
29371
|
for (const a of plan.actions) {
|
|
29235
29372
|
if (a.kind === "enable") {
|
|
29236
29373
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
29237
|
-
writeFileSync42(cfg.configFile, planEnable(
|
|
29374
|
+
writeFileSync42(cfg.configFile, planEnable(readFileSync54(cfg.configFile, "utf8"), a.route));
|
|
29238
29375
|
enabledSound.add(a.route);
|
|
29239
29376
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
29240
29377
|
} else {
|
|
@@ -29463,7 +29600,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
29463
29600
|
harnessBin: "claude",
|
|
29464
29601
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
29465
29602
|
},
|
|
29466
|
-
policyFile:
|
|
29603
|
+
policyFile: join62(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
29467
29604
|
repo: mirror,
|
|
29468
29605
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
29469
29606
|
base: effective.branch.base,
|
|
@@ -30567,6 +30704,41 @@ ${f.tail.trimEnd()}
|
|
|
30567
30704
|
);
|
|
30568
30705
|
break;
|
|
30569
30706
|
}
|
|
30707
|
+
const launchdStart = (o) => {
|
|
30708
|
+
const runPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
30709
|
+
const label = labelFor(CREW_HOME, "run");
|
|
30710
|
+
const r = startLaunchdDaemon({
|
|
30711
|
+
unitPath: runPlan.unitPaths[0],
|
|
30712
|
+
label,
|
|
30713
|
+
uid: process.getuid?.() ?? 0,
|
|
30714
|
+
schedulerLog: runPlan.schedulerLog,
|
|
30715
|
+
dryRun,
|
|
30716
|
+
...o,
|
|
30717
|
+
run: (c) => {
|
|
30718
|
+
const res2 = spawnSync14(c[0], c.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
|
|
30719
|
+
return res2.error ? null : { status: res2.status, stdout: res2.stdout ?? "", stderr: res2.stderr ?? "" };
|
|
30720
|
+
}
|
|
30721
|
+
});
|
|
30722
|
+
if (r.stdout) process.stdout.write(r.stdout);
|
|
30723
|
+
if (r.stderr) process.stderr.write(r.stderr);
|
|
30724
|
+
process.exitCode = r.exitCode;
|
|
30725
|
+
return true;
|
|
30726
|
+
};
|
|
30727
|
+
if (control.mechanism === "launchd" && daemonSub === "start") {
|
|
30728
|
+
launchdStart({});
|
|
30729
|
+
break;
|
|
30730
|
+
}
|
|
30731
|
+
if (control.mechanism === "launchd" && daemonSub === "restart") {
|
|
30732
|
+
if (dryRun) process.stdout.write(`would run: ${control.stopCommand.join(" ")}
|
|
30733
|
+
`);
|
|
30734
|
+
else {
|
|
30735
|
+
const res2 = spawnSync14(control.stopCommand[0], control.stopCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
|
|
30736
|
+
if (res2.stdout) process.stdout.write(res2.stdout);
|
|
30737
|
+
if (res2.stderr) process.stderr.write(res2.stderr);
|
|
30738
|
+
}
|
|
30739
|
+
launchdStart({ verifyAfterLoad: true, assumeUnloaded: true });
|
|
30740
|
+
break;
|
|
30741
|
+
}
|
|
30570
30742
|
if (daemonSub === "restart") {
|
|
30571
30743
|
const commands = [control.stopCommand, control.startCommand];
|
|
30572
30744
|
if (dryRun) {
|
|
@@ -30576,7 +30748,7 @@ ${f.tail.trimEnd()}
|
|
|
30576
30748
|
}
|
|
30577
30749
|
let failed = false;
|
|
30578
30750
|
for (const cmd2 of commands) {
|
|
30579
|
-
const res2 =
|
|
30751
|
+
const res2 = spawnSync14(cmd2[0], cmd2.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
|
|
30580
30752
|
if (res2.stdout) process.stdout.write(res2.stdout);
|
|
30581
30753
|
if (res2.stderr) process.stderr.write(res2.stderr);
|
|
30582
30754
|
if (cmd2 === control.startCommand && (res2.error || res2.status !== 0)) {
|
|
@@ -30594,7 +30766,7 @@ ${f.tail.trimEnd()}
|
|
|
30594
30766
|
`);
|
|
30595
30767
|
break;
|
|
30596
30768
|
}
|
|
30597
|
-
const res =
|
|
30769
|
+
const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
|
|
30598
30770
|
if (res.stdout) process.stdout.write(res.stdout);
|
|
30599
30771
|
if (res.stderr) process.stderr.write(res.stderr);
|
|
30600
30772
|
if (daemonSub !== "status" && (res.error || res.status !== 0)) {
|
|
@@ -30610,7 +30782,20 @@ ${f.tail.trimEnd()}
|
|
|
30610
30782
|
process.stderr.write("crew: daemon does not support --dry-run \u2014 it only ever performs real cycles.\n");
|
|
30611
30783
|
process.exit(2);
|
|
30612
30784
|
}
|
|
30613
|
-
|
|
30785
|
+
if (!fleetWide && !route2.enabled) {
|
|
30786
|
+
const reason = `route "${route2.route}" is not enabled in ${cfg.configFile} \u2014 refusing to run the daemon loop`;
|
|
30787
|
+
process.stderr.write(`crew: ${reason}.
|
|
30788
|
+
`);
|
|
30789
|
+
await failDaemonStart({
|
|
30790
|
+
stateDir: cfg.ship.stateDir,
|
|
30791
|
+
reason,
|
|
30792
|
+
fix: `Set \`enabled: true\` on route "${route2.route}" in crew.yaml, or name an enabled route in the unit`,
|
|
30793
|
+
code: 1,
|
|
30794
|
+
routes: cfg.routes,
|
|
30795
|
+
ship: cfg.ship,
|
|
30796
|
+
logFile: cfg.ship.logFile
|
|
30797
|
+
});
|
|
30798
|
+
}
|
|
30614
30799
|
const daemonRoutes = fleetWide ? cfg.routes.filter((r) => r.enabled) : [route2];
|
|
30615
30800
|
if (!daemonRoutes.length) {
|
|
30616
30801
|
emit.error("no enabled routes \u2014 nothing for the daemon to serve");
|
|
@@ -30682,7 +30867,7 @@ ${f.tail.trimEnd()}
|
|
|
30682
30867
|
logFile: cfg.ship.logFile
|
|
30683
30868
|
});
|
|
30684
30869
|
}
|
|
30685
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
30870
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join62(CREW_HOME, "src"), join62(CREW_HOME, "dist"), join62(CREW_HOME, "bin")];
|
|
30686
30871
|
const configPaths = daemonConfigPaths(cfg);
|
|
30687
30872
|
watchPaths.push(...configPaths);
|
|
30688
30873
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -31020,7 +31205,7 @@ ${f.tail.trimEnd()}
|
|
|
31020
31205
|
`);
|
|
31021
31206
|
if (!dryRun) {
|
|
31022
31207
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
31023
|
-
const raw =
|
|
31208
|
+
const raw = existsSync59(resolvedPath) ? JSON.parse(readFileSync54(resolvedPath, "utf8")) : {};
|
|
31024
31209
|
raw.agentSkills = result.agentSkills;
|
|
31025
31210
|
mkdirSync42(dirOf2(resolvedPath), { recursive: true });
|
|
31026
31211
|
writeFileSync42(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
@@ -31046,7 +31231,7 @@ ${f.tail.trimEnd()}
|
|
|
31046
31231
|
throw e;
|
|
31047
31232
|
}
|
|
31048
31233
|
const oldName = cfg.ship.name;
|
|
31049
|
-
writeFileSync42(cfg.configFile, setShipNameInYaml(
|
|
31234
|
+
writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), newName));
|
|
31050
31235
|
cfg.ship.name = newName;
|
|
31051
31236
|
let renameMachineId;
|
|
31052
31237
|
try {
|
|
@@ -31093,7 +31278,7 @@ ${f.tail.trimEnd()}
|
|
|
31093
31278
|
process.exit(2);
|
|
31094
31279
|
};
|
|
31095
31280
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
31096
|
-
const configText =
|
|
31281
|
+
const configText = readFileSync54(cfg.configFile, "utf8");
|
|
31097
31282
|
if (sub === "check") {
|
|
31098
31283
|
try {
|
|
31099
31284
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -31125,16 +31310,16 @@ ${f.tail.trimEnd()}
|
|
|
31125
31310
|
try {
|
|
31126
31311
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
31127
31312
|
const dir = repoDirOf(configText, dirname37(cfg.configFile), a.route, a.name);
|
|
31128
|
-
if (!
|
|
31129
|
-
const files = { exists: (r) =>
|
|
31313
|
+
if (!existsSync59(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
31314
|
+
const files = { exists: (r) => existsSync59(resolvePath(dir, r)), list: (r) => {
|
|
31130
31315
|
try {
|
|
31131
|
-
return
|
|
31316
|
+
return readdirSync21(resolvePath(dir, r));
|
|
31132
31317
|
} catch {
|
|
31133
31318
|
return [];
|
|
31134
31319
|
}
|
|
31135
31320
|
}, read: (r) => {
|
|
31136
31321
|
try {
|
|
31137
|
-
return
|
|
31322
|
+
return readFileSync54(resolvePath(dir, r), "utf8");
|
|
31138
31323
|
} catch {
|
|
31139
31324
|
return void 0;
|
|
31140
31325
|
}
|
|
@@ -31244,7 +31429,7 @@ ${f.tail.trimEnd()}
|
|
|
31244
31429
|
if (sub === "list" && !routeName) usage2();
|
|
31245
31430
|
if (sub === "add") {
|
|
31246
31431
|
try {
|
|
31247
|
-
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) =>
|
|
31432
|
+
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync59(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
|
|
31248
31433
|
routeName = a.route;
|
|
31249
31434
|
addPath = a.path;
|
|
31250
31435
|
addName = a.name;
|
|
@@ -31274,7 +31459,7 @@ ${f.tail.trimEnd()}
|
|
|
31274
31459
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
|
|
31275
31460
|
if (sub === "list" || sub === "add") {
|
|
31276
31461
|
const liveRoute = cfg.routes.find((r) => r.route === routeName);
|
|
31277
|
-
if (liveRoute?.resolved?.reposModelId &&
|
|
31462
|
+
if (liveRoute?.resolved?.reposModelId && existsSync59(resolvedFile) && !dryRun) {
|
|
31278
31463
|
try {
|
|
31279
31464
|
await hydrateApiKeys([liveRoute]);
|
|
31280
31465
|
persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
|
|
@@ -31283,16 +31468,16 @@ ${f.tail.trimEnd()}
|
|
|
31283
31468
|
}
|
|
31284
31469
|
}
|
|
31285
31470
|
let resolvedRemotes;
|
|
31286
|
-
if (
|
|
31471
|
+
if (existsSync59(resolvedFile)) {
|
|
31287
31472
|
try {
|
|
31288
|
-
resolvedRemotes = JSON.parse(
|
|
31473
|
+
resolvedRemotes = JSON.parse(readFileSync54(resolvedFile, "utf8"));
|
|
31289
31474
|
} catch {
|
|
31290
31475
|
}
|
|
31291
31476
|
}
|
|
31292
31477
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
31293
31478
|
const text2 = configText;
|
|
31294
31479
|
const base = dirname37(cfg.configFile);
|
|
31295
|
-
const isCheckout = (d) =>
|
|
31480
|
+
const isCheckout = (d) => existsSync59(`${d}/.git`);
|
|
31296
31481
|
try {
|
|
31297
31482
|
if (sub === "list") {
|
|
31298
31483
|
if (flag("json")) {
|
|
@@ -31302,12 +31487,12 @@ ${f.tail.trimEnd()}
|
|
|
31302
31487
|
base,
|
|
31303
31488
|
resolved: resolvedRemotes,
|
|
31304
31489
|
originOf,
|
|
31305
|
-
exists: (d) =>
|
|
31490
|
+
exists: (d) => existsSync59(d),
|
|
31306
31491
|
isCheckout,
|
|
31307
31492
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
31308
31493
|
try {
|
|
31309
31494
|
const path = resolvePath(d, f);
|
|
31310
|
-
return Object.keys(parseRepoConfig(
|
|
31495
|
+
return Object.keys(parseRepoConfig(readFileSync54(path, "utf8"), path).hooks).length > 0;
|
|
31311
31496
|
} catch {
|
|
31312
31497
|
return false;
|
|
31313
31498
|
}
|
|
@@ -31324,7 +31509,7 @@ ${f.tail.trimEnd()}
|
|
|
31324
31509
|
for (const r of repos) {
|
|
31325
31510
|
const origin2 = originOf(r.dir);
|
|
31326
31511
|
const row = matchRepoName(origin2, resolvedRemotes);
|
|
31327
|
-
const note = !
|
|
31512
|
+
const note = !existsSync59(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
|
|
31328
31513
|
process.stdout.write(`${r.name} ${r.dir} ${note}
|
|
31329
31514
|
`);
|
|
31330
31515
|
}
|
|
@@ -31336,9 +31521,9 @@ ${f.tail.trimEnd()}
|
|
|
31336
31521
|
` : `${human}
|
|
31337
31522
|
`);
|
|
31338
31523
|
const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
|
|
31339
|
-
if (
|
|
31524
|
+
if (existsSync59(plan2.target) && (existsSync59(`${plan2.target}/.git`) || readdirSync21(plan2.target).length > 0)) {
|
|
31340
31525
|
throw new ReposError(
|
|
31341
|
-
|
|
31526
|
+
existsSync59(`${plan2.target}/.git`) ? `${plan2.target} is already a checkout \u2014 attach it with \`crew repos add ${routeName} ${plan2.name} ${plan2.target}\`` : `${plan2.target} exists and is not empty \u2014 pass --dir to clone somewhere else`
|
|
31342
31527
|
);
|
|
31343
31528
|
}
|
|
31344
31529
|
if (dryRun) {
|
|
@@ -31363,7 +31548,7 @@ ${f.tail.trimEnd()}
|
|
|
31363
31548
|
break;
|
|
31364
31549
|
}
|
|
31365
31550
|
const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
|
|
31366
|
-
const top =
|
|
31551
|
+
const top = existsSync59(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
|
|
31367
31552
|
if (!top) throw new ReposError(`${target} is not a git checkout`);
|
|
31368
31553
|
const origin = originOf(top);
|
|
31369
31554
|
const plan = planRepoAdd({
|
|
@@ -31415,8 +31600,8 @@ ${f.tail.trimEnd()}
|
|
|
31415
31600
|
const created = await rowTracker.createRepoRow(rowPayload);
|
|
31416
31601
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
31417
31602
|
`);
|
|
31418
|
-
if (
|
|
31419
|
-
const raw = JSON.parse(
|
|
31603
|
+
if (existsSync59(resolvedFile)) {
|
|
31604
|
+
const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
|
|
31420
31605
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
31421
31606
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
31422
31607
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
@@ -31798,7 +31983,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
31798
31983
|
process.exit(2);
|
|
31799
31984
|
}
|
|
31800
31985
|
if (found.shipNameAdopted && !dryRun) {
|
|
31801
|
-
writeFileSync42(cfg.configFile, setShipNameInYaml(
|
|
31986
|
+
writeFileSync42(cfg.configFile, setShipNameInYaml(readFileSync54(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
31802
31987
|
cfg.ship.name = found.shipNameAdopted;
|
|
31803
31988
|
}
|
|
31804
31989
|
if (found.shipRow) {
|
|
@@ -31841,10 +32026,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
31841
32026
|
}
|
|
31842
32027
|
}
|
|
31843
32028
|
let previous;
|
|
31844
|
-
const hadPreviousFile =
|
|
32029
|
+
const hadPreviousFile = existsSync59(resolvedPath);
|
|
31845
32030
|
if (hadPreviousFile) {
|
|
31846
32031
|
try {
|
|
31847
|
-
previous = JSON.parse(
|
|
32032
|
+
previous = JSON.parse(readFileSync54(resolvedPath, "utf8"));
|
|
31848
32033
|
} catch {
|
|
31849
32034
|
}
|
|
31850
32035
|
}
|
|
@@ -32739,10 +32924,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32739
32924
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
32740
32925
|
prepare: async (path) => {
|
|
32741
32926
|
for (const f of repoWt.config.worktrees.copy) {
|
|
32742
|
-
const src =
|
|
32743
|
-
if (!
|
|
32744
|
-
mkdirSync42(dirOf2(
|
|
32745
|
-
copyFileSync2(src,
|
|
32927
|
+
const src = join62(repoWt.dir, f);
|
|
32928
|
+
if (!existsSync59(src) || existsSync59(join62(path, f))) continue;
|
|
32929
|
+
mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
|
|
32930
|
+
copyFileSync2(src, join62(path, f));
|
|
32746
32931
|
}
|
|
32747
32932
|
const setup = repoWt.config.hooks.setup;
|
|
32748
32933
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -32968,7 +33153,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
32968
33153
|
const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
|
|
32969
33154
|
const resumed = await runPeriscopeResume({
|
|
32970
33155
|
find: async () => hit && { row: hit.row, tag: hit.tag },
|
|
32971
|
-
worktreeExists: (p) =>
|
|
33156
|
+
worktreeExists: (p) => existsSync59(p),
|
|
32972
33157
|
prepareDropFile,
|
|
32973
33158
|
startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
|
|
32974
33159
|
relay: hit && previewRelayFor(hit.route) && {
|
|
@@ -33071,10 +33256,10 @@ ${where.join("\n")}`);
|
|
|
33071
33256
|
},
|
|
33072
33257
|
prepare: async (path) => {
|
|
33073
33258
|
for (const f of repoP.config.worktrees.copy) {
|
|
33074
|
-
const src =
|
|
33075
|
-
if (!
|
|
33076
|
-
mkdirSync42(dirOf2(
|
|
33077
|
-
copyFileSync2(src,
|
|
33259
|
+
const src = join62(repoP.dir, f);
|
|
33260
|
+
if (!existsSync59(src)) continue;
|
|
33261
|
+
mkdirSync42(dirOf2(join62(path, f)), { recursive: true });
|
|
33262
|
+
copyFileSync2(src, join62(path, f));
|
|
33078
33263
|
}
|
|
33079
33264
|
const setup = repoP.config.hooks.setup;
|
|
33080
33265
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -33185,7 +33370,7 @@ ${where.join("\n")}`);
|
|
|
33185
33370
|
process.stdout.write(upOutput(res, terminal));
|
|
33186
33371
|
const opener = openerFor(process.platform);
|
|
33187
33372
|
if (opener && shouldOpen({ open: flag("open"), noOpen: flag("no-open"), json: jsonP, terminal })) {
|
|
33188
|
-
const r =
|
|
33373
|
+
const r = spawnSync14(opener, [res.url], { stdio: "ignore" });
|
|
33189
33374
|
if (r.error || r.status !== 0) process.stderr.write(`crew periscope: could not open ${res.url} with ${opener}
|
|
33190
33375
|
`);
|
|
33191
33376
|
}
|
|
@@ -33386,7 +33571,7 @@ ${where.join("\n")}`);
|
|
|
33386
33571
|
};
|
|
33387
33572
|
const droppedRoutes = [];
|
|
33388
33573
|
try {
|
|
33389
|
-
const rawCfg = parseYaml3(
|
|
33574
|
+
const rawCfg = parseYaml3(readFileSync54(cfg.configFile, "utf8"));
|
|
33390
33575
|
for (const r of rawCfg?.routes ?? []) {
|
|
33391
33576
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
33392
33577
|
try {
|
|
@@ -33433,10 +33618,10 @@ ${where.join("\n")}`);
|
|
|
33433
33618
|
}
|
|
33434
33619
|
const host = hostPlatform();
|
|
33435
33620
|
const control = host === "windows" ? null : planDaemonControl(CREW_HOME, host, detectSystemd());
|
|
33436
|
-
const unitStatus = control?.statusCommand ?
|
|
33621
|
+
const unitStatus = control?.statusCommand ? spawnSync14(control.statusCommand[0], control.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() }) : null;
|
|
33437
33622
|
const unitRunning = unitStatus !== null && !unitStatus.error && unitStatus.status === 0;
|
|
33438
33623
|
if (!unitRunning && control?.mechanism === "systemd" && control.startCommand) {
|
|
33439
|
-
const res =
|
|
33624
|
+
const res = spawnSync14(control.startCommand[0], control.startCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
33440
33625
|
if (res.error || res.status !== 0) {
|
|
33441
33626
|
process.stderr.write(`crew reload: ${control.startCommand.join(" ")} exited ${res.status ?? "error"}
|
|
33442
33627
|
`);
|
|
@@ -33458,7 +33643,7 @@ ${where.join("\n")}`);
|
|
|
33458
33643
|
);
|
|
33459
33644
|
if (flag("now") && control?.stopCommand && control.startCommand) {
|
|
33460
33645
|
for (const cmd of [control.stopCommand, control.startCommand]) {
|
|
33461
|
-
const res =
|
|
33646
|
+
const res = spawnSync14(cmd[0], cmd.slice(1), { cwd: CREW_HOME, encoding: "utf8", env: withUserBusEnv() });
|
|
33462
33647
|
if (cmd === control.startCommand && (res.error || res.status !== 0)) {
|
|
33463
33648
|
process.stderr.write(`crew reload: ${cmd.join(" ")} exited ${res.status ?? "error"}
|
|
33464
33649
|
`);
|
|
@@ -33516,7 +33701,7 @@ ${where.join("\n")}`);
|
|
|
33516
33701
|
}
|
|
33517
33702
|
case "log": {
|
|
33518
33703
|
try {
|
|
33519
|
-
const text2 =
|
|
33704
|
+
const text2 = readFileSync54(cfg.ship.logFile, "utf8").split("\n");
|
|
33520
33705
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
33521
33706
|
`);
|
|
33522
33707
|
} catch {
|
|
@@ -33539,7 +33724,7 @@ ${where.join("\n")}`);
|
|
|
33539
33724
|
};
|
|
33540
33725
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
33541
33726
|
const tracker = new Tracker(route2, cfg.ship);
|
|
33542
|
-
const configText =
|
|
33727
|
+
const configText = readFileSync54(cfg.configFile, "utf8");
|
|
33543
33728
|
const cfgBase = dirname37(cfg.configFile);
|
|
33544
33729
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
33545
33730
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -33576,31 +33761,31 @@ ${where.join("\n")}`);
|
|
|
33576
33761
|
}
|
|
33577
33762
|
if (row) {
|
|
33578
33763
|
await tracker.deleteRepoRow(row.id);
|
|
33579
|
-
if (
|
|
33580
|
-
const raw = JSON.parse(
|
|
33764
|
+
if (existsSync59(resolvedFile)) {
|
|
33765
|
+
const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
|
|
33581
33766
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
33582
33767
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
33583
33768
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
33584
33769
|
`);
|
|
33585
33770
|
}
|
|
33586
33771
|
}
|
|
33587
|
-
if (
|
|
33772
|
+
if (existsSync59(join62(dir, ".git")) && basename17(dir) === SAMPLE_REPO) rmSync26(dir, { recursive: true, force: true });
|
|
33588
33773
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
33589
33774
|
break;
|
|
33590
33775
|
}
|
|
33591
33776
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
33592
|
-
const fresh = !
|
|
33593
|
-
if (
|
|
33777
|
+
const fresh = !existsSync59(join62(dir, ".git"));
|
|
33778
|
+
if (existsSync59(dir) && fresh && readdirSync21(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
33594
33779
|
if (dryRun) {
|
|
33595
33780
|
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`);
|
|
33596
33781
|
break;
|
|
33597
33782
|
}
|
|
33598
33783
|
if (fresh) {
|
|
33599
33784
|
mkdirSync42(dir, { recursive: true });
|
|
33600
|
-
writeFileSync42(
|
|
33601
|
-
writeFileSync42(
|
|
33785
|
+
writeFileSync42(join62(dir, "README.md"), SAMPLE_README);
|
|
33786
|
+
writeFileSync42(join62(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
33602
33787
|
const g = (...a) => {
|
|
33603
|
-
const r =
|
|
33788
|
+
const r = spawnSync14("git", a, { cwd: dir, encoding: "utf8" });
|
|
33604
33789
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
33605
33790
|
};
|
|
33606
33791
|
g("init", "-b", "main");
|
|
@@ -33616,8 +33801,8 @@ ${where.join("\n")}`);
|
|
|
33616
33801
|
spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
|
|
33617
33802
|
});
|
|
33618
33803
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
33619
|
-
if (
|
|
33620
|
-
const raw = JSON.parse(
|
|
33804
|
+
if (existsSync59(resolvedFile)) {
|
|
33805
|
+
const raw = JSON.parse(readFileSync54(resolvedFile, "utf8"));
|
|
33621
33806
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
33622
33807
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
33623
33808
|
writeFileSync42(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
@@ -33995,7 +34180,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
33995
34180
|
plan,
|
|
33996
34181
|
label,
|
|
33997
34182
|
uid: process.getuid?.() ?? 0,
|
|
33998
|
-
system: plan.mechanism === "systemd" &&
|
|
34183
|
+
system: plan.mechanism === "systemd" && existsSync59(systemUnitPathFor(label)),
|
|
33999
34184
|
stamp: readDaemonStamp(cfg.ship.stateDir)
|
|
34000
34185
|
});
|
|
34001
34186
|
})();
|
|
@@ -34011,7 +34196,7 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
34011
34196
|
}
|
|
34012
34197
|
for (const r of repos) {
|
|
34013
34198
|
const remote = r.config.branch.remote;
|
|
34014
|
-
if (
|
|
34199
|
+
if (existsSync59(r.dir)) {
|
|
34015
34200
|
pushAuth.push({
|
|
34016
34201
|
route: c.route,
|
|
34017
34202
|
repo: r.name,
|
|
@@ -34094,7 +34279,8 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
34094
34279
|
if (dp) problems.push(dp);
|
|
34095
34280
|
else passed++;
|
|
34096
34281
|
}
|
|
34097
|
-
|
|
34282
|
+
if (staleBundle) problems.push({ severity: "blocker", kind: "stale_bundle", message: staleBundle.message, remedy: "npm run build" });
|
|
34283
|
+
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync59, userInfo2().username);
|
|
34098
34284
|
if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
|
|
34099
34285
|
if (!flag("offline")) {
|
|
34100
34286
|
const shipKind = await doctorShipKind(route2, cfg.ship);
|
|
@@ -34140,6 +34326,11 @@ watermark: ${state.watermark(routeSlug(route2.route))}
|
|
|
34140
34326
|
routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
34141
34327
|
`
|
|
34142
34328
|
);
|
|
34329
|
+
if (staleBundle) {
|
|
34330
|
+
process.stdout.write(`bundle: BLOCKER ${staleBundle.message}
|
|
34331
|
+
`);
|
|
34332
|
+
process.exitCode = 1;
|
|
34333
|
+
}
|
|
34143
34334
|
for (const w of roleCapWarnings(cfg.ship)) process.stdout.write(`role concurrency: WARN ${w}
|
|
34144
34335
|
`);
|
|
34145
34336
|
for (const r of cfg.routes) for (const f of routeAvatarFailures(cfg.ship.stateDir, r.route)) process.stdout.write(`persona avatar: WARN ${r.route}: ${f.role} avatar failed to upload (${f.detail}); run \`crew agents sync\` again
|
|
@@ -34161,7 +34352,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34161
34352
|
}
|
|
34162
34353
|
try {
|
|
34163
34354
|
const evFile = eventFileFor(cfg.ship.stateDir);
|
|
34164
|
-
const evSize =
|
|
34355
|
+
const evSize = existsSync59(evFile) ? statSync18(evFile).size : 0;
|
|
34165
34356
|
process.stdout.write(
|
|
34166
34357
|
evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
|
|
34167
34358
|
` : "events log: ok\n"
|
|
@@ -34172,7 +34363,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34172
34363
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
34173
34364
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
34174
34365
|
try {
|
|
34175
|
-
return
|
|
34366
|
+
return readFileSync54(p, "utf8");
|
|
34176
34367
|
} catch {
|
|
34177
34368
|
return null;
|
|
34178
34369
|
}
|
|
@@ -34187,7 +34378,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34187
34378
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
34188
34379
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
34189
34380
|
try {
|
|
34190
|
-
return
|
|
34381
|
+
return readFileSync54(p, "utf8");
|
|
34191
34382
|
} catch {
|
|
34192
34383
|
return null;
|
|
34193
34384
|
}
|
|
@@ -34201,8 +34392,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34201
34392
|
if (host === "linux" && detectSystemd()) {
|
|
34202
34393
|
const ctl = planDaemonControl(CREW_HOME, host, true);
|
|
34203
34394
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
|
|
34204
|
-
if (ctl.statusCommand && unitPlan.unitPaths.some((p) =>
|
|
34205
|
-
const st =
|
|
34395
|
+
if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync59(p))) {
|
|
34396
|
+
const st = spawnSync14(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
34206
34397
|
if (!st.error && st.status !== 0) {
|
|
34207
34398
|
process.stdout.write("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
|
|
34208
34399
|
}
|
|
@@ -34226,8 +34417,8 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
34226
34417
|
const changed2 = configChangedAfter(daemonConfigPaths(cfg), daemonStartedAt);
|
|
34227
34418
|
if (changed2) {
|
|
34228
34419
|
process.stdout.write(
|
|
34229
|
-
daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(
|
|
34230
|
-
` : `daemon config: WARN ${changed2} changed at ${new Date(
|
|
34420
|
+
daemonDead ? `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} \u2014 no daemon is running; the new config applies when it starts
|
|
34421
|
+
` : `daemon config: WARN ${changed2} changed at ${new Date(statSync18(changed2).mtimeMs).toISOString()} but the daemon started at ${new Date(daemonStartedAt).toISOString()} \u2014 run \`crew reload\`
|
|
34231
34422
|
`
|
|
34232
34423
|
);
|
|
34233
34424
|
}
|
package/package.json
CHANGED