@tablation/crew 0.171.0 → 0.171.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 +314 -188
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -20576,18 +20576,20 @@ async function checkTrackerInterface(o, deps = {}) {
|
|
|
20576
20576
|
clearShipAttention(o.state, mismatchKey);
|
|
20577
20577
|
return null;
|
|
20578
20578
|
}
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
if (!r?.projectId) return { kind: "unreadable" };
|
|
20582
|
-
const get2 = async (path) => {
|
|
20579
|
+
function getterFor(route2, ship) {
|
|
20580
|
+
return async (path) => {
|
|
20583
20581
|
const res = await fetch(`${route2.baseUrl.replace(/\/+$/, "")}/api${path}`, {
|
|
20584
20582
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": ship.userAgent }
|
|
20585
20583
|
});
|
|
20586
20584
|
if (!res.ok) throw Object.assign(new Error(`HTTP ${res.status}`), { status: res.status });
|
|
20587
20585
|
return await res.json();
|
|
20588
20586
|
};
|
|
20587
|
+
}
|
|
20588
|
+
async function readForRoute(route2, ship) {
|
|
20589
|
+
const r = route2.resolved;
|
|
20590
|
+
if (!r?.projectId) return { kind: "unreadable" };
|
|
20589
20591
|
try {
|
|
20590
|
-
return await readInterfaceState(
|
|
20592
|
+
return await readInterfaceState(getterFor(route2, ship), r.workspaceId, r.projectId);
|
|
20591
20593
|
} catch {
|
|
20592
20594
|
return { kind: "unreadable" };
|
|
20593
20595
|
}
|
|
@@ -20602,19 +20604,137 @@ function interfaceReport(state, o) {
|
|
|
20602
20604
|
}
|
|
20603
20605
|
const lines2 = [];
|
|
20604
20606
|
const blocking = blockingMessage(state, o.storedMappingKey);
|
|
20607
|
+
const unresolved = state.accepted && state.conforms !== false && !blocking && o.stored && !o.stored.trackerInterface ? "this route was connected before the app declared the interface, so it is still read by default names" : state.accepted && state.conforms !== false && !blocking && o.stored && questionsPartMapped(state.mapping) && !(o.stored.questionsModelId && o.stored.answersModelId) ? "the questions part is declared by the app but not resolved on this ship, so `crew ask` would write nothing" : null;
|
|
20608
|
+
const refreshed = o.stored?.trackerInterface?.mappingKey === mappingKey(state.mapping);
|
|
20605
20609
|
if (!state.accepted) lines2.push({ line: `work tracker interface: ${versionMismatchMessage(state.version)}`, problem: true });
|
|
20606
20610
|
else if (state.conforms === false) {
|
|
20607
20611
|
lines2.push({ line: `work tracker interface ${versionLabel(state.version)}: does not conform`, problem: true });
|
|
20608
20612
|
for (const d of describeDifferences(state.unmet)) lines2.push({ line: ` - ${d}`, problem: true });
|
|
20609
20613
|
} else if (blocking) lines2.push({ line: `work tracker interface: ${blocking}`, problem: true });
|
|
20614
|
+
else if (unresolved) lines2.push({
|
|
20615
|
+
line: refreshed ? `work tracker interface: ${unresolved} \u2014 the Questions and Answers tables the app maps were not found in this project, so a refresh cannot resolve them; fix the app's mapping` : `work tracker interface: ${unresolved} \u2014 the daemon refreshes it on its next poll, or run \`crew connect\``,
|
|
20616
|
+
problem: true
|
|
20617
|
+
});
|
|
20610
20618
|
else lines2.push({ line: `work tracker interface ${versionLabel(state.version)}: ${state.conforms ? "conforms" : "declared (conformance not visible to this key)"}`, problem: false });
|
|
20611
20619
|
if (o.contractAuthored) lines2.push({ line: `work tracker interface: ${OVERRIDE_IGNORED_MESSAGE}`, problem: false });
|
|
20612
20620
|
return lines2;
|
|
20613
20621
|
}
|
|
20614
20622
|
|
|
20623
|
+
// src/interface-refresh.ts
|
|
20624
|
+
import { copyFileSync, existsSync as existsSync39, readFileSync as readFileSync41, renameSync as renameSync8, writeFileSync as writeFileSync32 } from "fs";
|
|
20625
|
+
var OPTIONAL_TABLES = [
|
|
20626
|
+
["ships", "shipsModelId"],
|
|
20627
|
+
["epics", "epicsModelId"],
|
|
20628
|
+
["maps", "mapsModelId"],
|
|
20629
|
+
["periscopes", "periscopesModelId"],
|
|
20630
|
+
["locks", "locksModelId"]
|
|
20631
|
+
];
|
|
20632
|
+
function refreshable(state) {
|
|
20633
|
+
return state.kind === "declared" && state.accepted && state.conforms !== false;
|
|
20634
|
+
}
|
|
20635
|
+
function snapshotCurrent(resolved, state) {
|
|
20636
|
+
if (!resolved?.trackerInterface || resolved.trackerInterface.mappingKey !== mappingKey(state.mapping)) return false;
|
|
20637
|
+
return !questionsPartMapped(state.mapping) || !!resolved.questionsModelId && !!resolved.answersModelId;
|
|
20638
|
+
}
|
|
20639
|
+
function planRefresh(resolved, state, models) {
|
|
20640
|
+
const eq2 = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
20641
|
+
const idOf = (role) => {
|
|
20642
|
+
const name = mappedTableName(state.mapping, role);
|
|
20643
|
+
return name ? models.find((m) => eq2(m.name, name))?.id : void 0;
|
|
20644
|
+
};
|
|
20645
|
+
const declaredContract = contractFromMapping(DEFAULT_CONTRACT, state.mapping);
|
|
20646
|
+
const resolvedStatuses = [.../* @__PURE__ */ new Set([...declaredContract.statuses.resolved, ...resolved.contract?.statuses?.resolved ?? []])];
|
|
20647
|
+
const patch2 = {
|
|
20648
|
+
trackerInterface: { declared: true, version: versionLabel(state.version), mappingKey: mappingKey(state.mapping) },
|
|
20649
|
+
contract: { ...declaredContract, statuses: { ...declaredContract.statuses, resolved: resolvedStatuses } }
|
|
20650
|
+
};
|
|
20651
|
+
const required = {};
|
|
20652
|
+
for (const role of ["issues", "comments", "crew"]) {
|
|
20653
|
+
const id = idOf(role);
|
|
20654
|
+
if (id) required[role] = id;
|
|
20655
|
+
}
|
|
20656
|
+
if (Object.keys(required).length > 0) patch2.models = required;
|
|
20657
|
+
for (const [role, key] of OPTIONAL_TABLES) {
|
|
20658
|
+
const id = idOf(role);
|
|
20659
|
+
if (id) patch2[key] = id;
|
|
20660
|
+
}
|
|
20661
|
+
if (questionsPartMapped(state.mapping)) {
|
|
20662
|
+
const q2 = idOf("questions");
|
|
20663
|
+
const a = idOf("answers");
|
|
20664
|
+
if (q2 && a) {
|
|
20665
|
+
patch2.questionsModelId = q2;
|
|
20666
|
+
patch2.answersModelId = a;
|
|
20667
|
+
}
|
|
20668
|
+
}
|
|
20669
|
+
return patch2;
|
|
20670
|
+
}
|
|
20671
|
+
function mergePatch(raw, patch2) {
|
|
20672
|
+
const { models, ...rest } = patch2;
|
|
20673
|
+
const out = { ...raw, ...rest };
|
|
20674
|
+
if (models) out["models"] = { ...raw["models"], ...models };
|
|
20675
|
+
return out;
|
|
20676
|
+
}
|
|
20677
|
+
function applyToRoute(route2, patch2) {
|
|
20678
|
+
const { models, contract, trackerInterface, ...ids } = patch2;
|
|
20679
|
+
route2.resolved = {
|
|
20680
|
+
...route2.resolved,
|
|
20681
|
+
...ids,
|
|
20682
|
+
trackerInterface,
|
|
20683
|
+
contract,
|
|
20684
|
+
...models ? { models: { ...route2.resolved.models, ...models } } : {}
|
|
20685
|
+
};
|
|
20686
|
+
route2.contract = contract;
|
|
20687
|
+
}
|
|
20688
|
+
var attempted = /* @__PURE__ */ new Set();
|
|
20689
|
+
async function refreshInterfaceSnapshot(o, state, listModels) {
|
|
20690
|
+
const r = o.route.resolved;
|
|
20691
|
+
if (!r || !refreshable(state) || snapshotCurrent(r, state)) return null;
|
|
20692
|
+
const attemptKey = `${o.stateDir}|${o.route.route}|${mappingKey(state.mapping)}`;
|
|
20693
|
+
if (attempted.has(attemptKey)) return null;
|
|
20694
|
+
let models;
|
|
20695
|
+
try {
|
|
20696
|
+
models = await listModels();
|
|
20697
|
+
} catch {
|
|
20698
|
+
return null;
|
|
20699
|
+
}
|
|
20700
|
+
attempted.add(attemptKey);
|
|
20701
|
+
const patch2 = planRefresh(r, state, models);
|
|
20702
|
+
if (o.write !== false) {
|
|
20703
|
+
const path = resolvedPathFor(o.stateDir, o.route.route);
|
|
20704
|
+
if (!existsSync39(path)) return null;
|
|
20705
|
+
let raw;
|
|
20706
|
+
try {
|
|
20707
|
+
raw = JSON.parse(readFileSync41(path, "utf8"));
|
|
20708
|
+
} catch {
|
|
20709
|
+
return null;
|
|
20710
|
+
}
|
|
20711
|
+
const next = `${JSON.stringify(mergePatch(raw, patch2), null, 2)}
|
|
20712
|
+
`;
|
|
20713
|
+
if (next === readFileSync41(path, "utf8")) return null;
|
|
20714
|
+
copyFileSync(path, `${path}.bak`);
|
|
20715
|
+
const tmp = `${path}.tmp${process.pid}`;
|
|
20716
|
+
writeFileSync32(tmp, next);
|
|
20717
|
+
renameSync8(tmp, path);
|
|
20718
|
+
}
|
|
20719
|
+
applyToRoute(o.route, patch2);
|
|
20720
|
+
return patch2;
|
|
20721
|
+
}
|
|
20722
|
+
async function refreshForRoute(route2, ship, write, state) {
|
|
20723
|
+
const live2 = state ?? await readForRoute(route2, ship);
|
|
20724
|
+
const projectId = route2.resolved?.projectId;
|
|
20725
|
+
if (!projectId) return false;
|
|
20726
|
+
const get2 = getterFor(route2, ship);
|
|
20727
|
+
const patch2 = await refreshInterfaceSnapshot(
|
|
20728
|
+
{ route: route2, stateDir: ship.stateDir, write },
|
|
20729
|
+
live2,
|
|
20730
|
+
() => get2(`/data-models?projectId=${projectId}`)
|
|
20731
|
+
);
|
|
20732
|
+
return patch2 !== null;
|
|
20733
|
+
}
|
|
20734
|
+
|
|
20615
20735
|
// src/sandbox-hygiene.ts
|
|
20616
20736
|
import { execFile as execFile3 } from "child_process";
|
|
20617
|
-
import { existsSync as
|
|
20737
|
+
import { existsSync as existsSync40, statfsSync as statfsSync2 } from "fs";
|
|
20618
20738
|
import { promisify as promisify3 } from "util";
|
|
20619
20739
|
var execFileP3 = promisify3(execFile3);
|
|
20620
20740
|
var REAP_MIN_AGE_MS = 5 * 6e4;
|
|
@@ -20757,7 +20877,7 @@ async function realDiskReadings(ship) {
|
|
|
20757
20877
|
const paths = ["/"];
|
|
20758
20878
|
try {
|
|
20759
20879
|
const root = (await run3(ship.sandbox?.engine ?? DEFAULT_CACHE_SETTINGS.engine, ["info", "--format", "{{.DockerRootDir}}"])).trim();
|
|
20760
|
-
if (root &&
|
|
20880
|
+
if (root && existsSync40(root)) paths.push(root);
|
|
20761
20881
|
} catch {
|
|
20762
20882
|
}
|
|
20763
20883
|
return paths.flatMap((path) => {
|
|
@@ -20798,7 +20918,7 @@ function diskFullStop(state) {
|
|
|
20798
20918
|
}
|
|
20799
20919
|
|
|
20800
20920
|
// src/poll.ts
|
|
20801
|
-
import { writeFileSync as
|
|
20921
|
+
import { writeFileSync as writeFileSync33 } from "fs";
|
|
20802
20922
|
import { join as join45 } from "path";
|
|
20803
20923
|
|
|
20804
20924
|
// src/stalled.ts
|
|
@@ -20903,6 +21023,11 @@ async function runStalledSweep(o, stalled) {
|
|
|
20903
21023
|
}
|
|
20904
21024
|
|
|
20905
21025
|
// src/poll.ts
|
|
21026
|
+
async function readAndRefresh(route2, ship) {
|
|
21027
|
+
const s = await readForRoute(route2, ship);
|
|
21028
|
+
await refreshForRoute(route2, ship, true, s);
|
|
21029
|
+
return s;
|
|
21030
|
+
}
|
|
20906
21031
|
async function decideCycle(o) {
|
|
20907
21032
|
const { route: route2, ship, state, emit } = o;
|
|
20908
21033
|
const tracker = new Tracker(route2, ship);
|
|
@@ -21072,7 +21197,7 @@ async function decideCycle(o) {
|
|
|
21072
21197
|
emit.emit(`${what}: no longer missing from the scheduler PATH \u2014 stop cleared`, { step: "select" });
|
|
21073
21198
|
}
|
|
21074
21199
|
await checkRepoDisks({ state, emit, route: route2, ship });
|
|
21075
|
-
const floorStop = await checkCrewFloor({ state, emit, route: route2, ship }) ?? await checkTrackerInterface({ state, emit, route: route2, ship });
|
|
21200
|
+
const floorStop = await checkCrewFloor({ state, emit, route: route2, ship }) ?? await checkTrackerInterface({ state, emit, route: route2, ship }, { read: (r) => readAndRefresh(r, ship) });
|
|
21076
21201
|
const itemStop = repoStopFor(openShipAttention(state), route2);
|
|
21077
21202
|
const diskStop = diskFullStop(state);
|
|
21078
21203
|
const selectionInput = {
|
|
@@ -21225,7 +21350,7 @@ ${footprintDigestSection(recorded)}`;
|
|
|
21225
21350
|
|
|
21226
21351
|
${body}` : body;
|
|
21227
21352
|
const path = digestPath(stateDir, routeSlug(o.route.route), role, runId);
|
|
21228
|
-
|
|
21353
|
+
writeFileSync33(path, text2);
|
|
21229
21354
|
o.emit.note(`queue digest written for ${role} (${Buffer.byteLength(text2)} bytes)`, {
|
|
21230
21355
|
data: { role, bytes: Buffer.byteLength(text2) }
|
|
21231
21356
|
});
|
|
@@ -21400,7 +21525,7 @@ async function markCrewAssistedAtLaunch(tracker, route2, role, ticketId, ticket,
|
|
|
21400
21525
|
}
|
|
21401
21526
|
|
|
21402
21527
|
// src/repo-refresh.ts
|
|
21403
|
-
import { existsSync as
|
|
21528
|
+
import { existsSync as existsSync41, mkdirSync as mkdirSync29, readFileSync as readFileSync42, writeFileSync as writeFileSync34 } from "fs";
|
|
21404
21529
|
import { dirname as dirname23 } from "path";
|
|
21405
21530
|
var REFRESH_COOLDOWN_MS = 2 * 6e4;
|
|
21406
21531
|
var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
|
|
@@ -21430,11 +21555,11 @@ function applyRepoRows(resolved, rows) {
|
|
|
21430
21555
|
}
|
|
21431
21556
|
function persistRepoRows(stateDir, routeName, rows) {
|
|
21432
21557
|
const path = resolvedPathFor(stateDir, routeName);
|
|
21433
|
-
if (!
|
|
21434
|
-
const raw = JSON.parse(
|
|
21558
|
+
if (!existsSync41(path)) return;
|
|
21559
|
+
const raw = JSON.parse(readFileSync42(path, "utf8"));
|
|
21435
21560
|
applyRepoRows(raw, rows);
|
|
21436
21561
|
mkdirSync29(dirname23(path), { recursive: true });
|
|
21437
|
-
|
|
21562
|
+
writeFileSync34(path, `${JSON.stringify(raw, null, 2)}
|
|
21438
21563
|
`);
|
|
21439
21564
|
}
|
|
21440
21565
|
async function refreshUnknownRepos(o) {
|
|
@@ -21725,12 +21850,12 @@ function platformStuckNote(repo, required, ship, issueIds) {
|
|
|
21725
21850
|
|
|
21726
21851
|
// src/connect-wizard.ts
|
|
21727
21852
|
import { delimiter, dirname as dirname24, join as join47 } from "path";
|
|
21728
|
-
import { accessSync as accessSync3, constants as constants3, existsSync as
|
|
21853
|
+
import { accessSync as accessSync3, constants as constants3, existsSync as existsSync42, mkdirSync as mkdirSync30, writeFileSync as writeFileSync35 } from "fs";
|
|
21729
21854
|
import { stringify as stringify3 } from "yaml";
|
|
21730
21855
|
var HOST_PASSENGERS_DOCS_URL = "https://crew.tablation.dev/host-passengers";
|
|
21731
21856
|
function shouldRunWizard(opts) {
|
|
21732
21857
|
if (!opts.isTTY) return false;
|
|
21733
|
-
const exists = opts.configExists ??
|
|
21858
|
+
const exists = opts.configExists ?? existsSync42;
|
|
21734
21859
|
return !configSearchPath(opts.crewHome).some((p) => exists(p));
|
|
21735
21860
|
}
|
|
21736
21861
|
function firstRunConfigPath() {
|
|
@@ -21810,7 +21935,7 @@ ${routeBlock}`;
|
|
|
21810
21935
|
function writeNewConfig(path, text2) {
|
|
21811
21936
|
mkdirSync30(dirname24(path), { recursive: true });
|
|
21812
21937
|
try {
|
|
21813
|
-
|
|
21938
|
+
writeFileSync35(path, text2, { mode: 384, flag: "wx" });
|
|
21814
21939
|
return true;
|
|
21815
21940
|
} catch (e) {
|
|
21816
21941
|
if (e.code === "EEXIST") return false;
|
|
@@ -22009,7 +22134,7 @@ async function collectDiagnostics(d) {
|
|
|
22009
22134
|
}
|
|
22010
22135
|
|
|
22011
22136
|
// src/release-run.ts
|
|
22012
|
-
import { readFileSync as
|
|
22137
|
+
import { readFileSync as readFileSync43, writeFileSync as writeFileSync36, existsSync as existsSync43, copyFileSync as copyFileSync2, mkdirSync as mkdirSync31, mkdtempSync as mkdtempSync3, rmSync as rmSync21 } from "fs";
|
|
22013
22138
|
import { dirname as dirname26, join as join49 } from "path";
|
|
22014
22139
|
import { tmpdir as tmpdir7, hostname as hostname4 } from "os";
|
|
22015
22140
|
|
|
@@ -22990,11 +23115,11 @@ async function bump(o, size) {
|
|
|
22990
23115
|
}
|
|
22991
23116
|
const files = o.repo.release.versionFiles.map((f2) => join49(o.cwd, f2));
|
|
22992
23117
|
const first = files[0];
|
|
22993
|
-
if (!existsAt(first,
|
|
23118
|
+
if (!existsAt(first, existsSync43)) {
|
|
22994
23119
|
o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
|
|
22995
23120
|
return null;
|
|
22996
23121
|
}
|
|
22997
|
-
const firstText = readTextAt(first, (p) =>
|
|
23122
|
+
const firstText = readTextAt(first, (p) => readFileSync43(p, "utf8"));
|
|
22998
23123
|
const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
|
|
22999
23124
|
if (problem) {
|
|
23000
23125
|
o.emit.error(problem);
|
|
@@ -23013,13 +23138,13 @@ async function bump(o, size) {
|
|
|
23013
23138
|
return version;
|
|
23014
23139
|
}
|
|
23015
23140
|
for (const f2 of files) {
|
|
23016
|
-
const src = readTextAt(f2, (p) =>
|
|
23141
|
+
const src = readTextAt(f2, (p) => readFileSync43(p, "utf8"));
|
|
23017
23142
|
const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
|
|
23018
23143
|
if (out === src) {
|
|
23019
23144
|
o.emit.error(`no version field in ${f2}`);
|
|
23020
23145
|
return null;
|
|
23021
23146
|
}
|
|
23022
|
-
writeTextAt(f2, out,
|
|
23147
|
+
writeTextAt(f2, out, writeFileSync36);
|
|
23023
23148
|
}
|
|
23024
23149
|
return version;
|
|
23025
23150
|
}
|
|
@@ -23032,8 +23157,8 @@ function writeChangelog(o, version, entries) {
|
|
|
23032
23157
|
o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
|
|
23033
23158
|
return;
|
|
23034
23159
|
}
|
|
23035
|
-
const existing = existsAt(path,
|
|
23036
|
-
writeTextAt(path, insertChangelogSection(existing, section),
|
|
23160
|
+
const existing = existsAt(path, existsSync43) ? readTextAt(path, (p) => readFileSync43(p, "utf8")) : "# Changelog\n";
|
|
23161
|
+
writeTextAt(path, insertChangelogSection(existing, section), writeFileSync36);
|
|
23037
23162
|
}
|
|
23038
23163
|
async function confirm(o, expected, ci) {
|
|
23039
23164
|
if (!o.repo.hooks.released) return void 0;
|
|
@@ -23198,9 +23323,9 @@ function openReleaseCheckout(o) {
|
|
|
23198
23323
|
}
|
|
23199
23324
|
for (const f2 of o.repo.worktrees.copy) {
|
|
23200
23325
|
const src = join49(o.cwd, f2);
|
|
23201
|
-
if (!
|
|
23326
|
+
if (!existsSync43(src)) continue;
|
|
23202
23327
|
mkdirSync31(dirname26(join49(dir, f2)), { recursive: true });
|
|
23203
|
-
|
|
23328
|
+
copyFileSync2(src, join49(dir, f2));
|
|
23204
23329
|
}
|
|
23205
23330
|
return { dir, branch, close };
|
|
23206
23331
|
}
|
|
@@ -24259,14 +24384,14 @@ async function runCommentDeliveryPass(deps) {
|
|
|
24259
24384
|
}
|
|
24260
24385
|
|
|
24261
24386
|
// src/launchd-start.ts
|
|
24262
|
-
import { readFileSync as
|
|
24387
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
24263
24388
|
import { spawnSync as spawnSync13 } from "child_process";
|
|
24264
24389
|
|
|
24265
24390
|
// src/daemon-liveness.ts
|
|
24266
|
-
import { existsSync as
|
|
24391
|
+
import { existsSync as existsSync50, readFileSync as readFileSync49 } from "fs";
|
|
24267
24392
|
|
|
24268
24393
|
// src/daemon.ts
|
|
24269
|
-
import { existsSync as
|
|
24394
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync37, readFileSync as readFileSync48, readdirSync as readdirSync15, rmSync as rmSync23, statSync as statSync14, writeFileSync as writeFileSync40 } from "fs";
|
|
24270
24395
|
import { join as join54 } from "path";
|
|
24271
24396
|
import { randomBytes } from "crypto";
|
|
24272
24397
|
|
|
@@ -24553,7 +24678,7 @@ function nextRoles(decision, ran) {
|
|
|
24553
24678
|
}
|
|
24554
24679
|
|
|
24555
24680
|
// src/noop-runs.ts
|
|
24556
|
-
import { existsSync as
|
|
24681
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync44, renameSync as renameSync9, writeFileSync as writeFileSync37 } from "fs";
|
|
24557
24682
|
import { join as join50 } from "path";
|
|
24558
24683
|
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
24559
24684
|
var DEFAULT_NOOP_REPEATS = 3;
|
|
@@ -24562,7 +24687,7 @@ var noopRunsPath = (stateDir) => join50(stateDir, "noop-runs.json");
|
|
|
24562
24687
|
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
24563
24688
|
function readNoopRuns(stateDir) {
|
|
24564
24689
|
try {
|
|
24565
|
-
const v = JSON.parse(
|
|
24690
|
+
const v = JSON.parse(readFileSync44(noopRunsPath(stateDir), "utf8"));
|
|
24566
24691
|
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
24567
24692
|
} catch {
|
|
24568
24693
|
return {};
|
|
@@ -24571,9 +24696,9 @@ function readNoopRuns(stateDir) {
|
|
|
24571
24696
|
function writeNoopRuns(stateDir, state) {
|
|
24572
24697
|
mkdirSync32(stateDir, { recursive: true });
|
|
24573
24698
|
const file = noopRunsPath(stateDir);
|
|
24574
|
-
|
|
24699
|
+
writeFileSync37(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
24575
24700
|
`);
|
|
24576
|
-
|
|
24701
|
+
renameSync9(`${file}.tmp`, file);
|
|
24577
24702
|
}
|
|
24578
24703
|
function noopBackedOff(stateDir, recordId, now = Date.now()) {
|
|
24579
24704
|
const e = readNoopRuns(stateDir)[recordId];
|
|
@@ -24588,7 +24713,7 @@ function recordNoopRun(stateDir, recordId, repeats, now = Date.now()) {
|
|
|
24588
24713
|
return { count, nextAt, bounce: count >= repeats };
|
|
24589
24714
|
}
|
|
24590
24715
|
function clearNoopRuns(stateDir, recordId) {
|
|
24591
|
-
if (!
|
|
24716
|
+
if (!existsSync44(noopRunsPath(stateDir))) return;
|
|
24592
24717
|
const state = readNoopRuns(stateDir);
|
|
24593
24718
|
if (!(recordId in state)) return;
|
|
24594
24719
|
delete state[recordId];
|
|
@@ -24653,7 +24778,7 @@ async function settleNoopRun(o) {
|
|
|
24653
24778
|
}
|
|
24654
24779
|
|
|
24655
24780
|
// src/ship-name.ts
|
|
24656
|
-
import { existsSync as
|
|
24781
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync33, readFileSync as readFileSync45, renameSync as renameSync10, writeFileSync as writeFileSync38 } from "fs";
|
|
24657
24782
|
import { dirname as dirname27 } from "path";
|
|
24658
24783
|
import { parseDocument as parseDocument4 } from "yaml";
|
|
24659
24784
|
var ShipNameError = class extends Error {
|
|
@@ -24715,19 +24840,19 @@ async function syncRouteName(i) {
|
|
|
24715
24840
|
return { status: "ok", ...base, action, name: i.local };
|
|
24716
24841
|
}
|
|
24717
24842
|
function readSyncedName(resolvedFile) {
|
|
24718
|
-
if (!
|
|
24843
|
+
if (!existsSync45(resolvedFile)) return void 0;
|
|
24719
24844
|
try {
|
|
24720
|
-
const v = JSON.parse(
|
|
24845
|
+
const v = JSON.parse(readFileSync45(resolvedFile, "utf8")).shipName;
|
|
24721
24846
|
return typeof v === "string" ? v : void 0;
|
|
24722
24847
|
} catch {
|
|
24723
24848
|
return void 0;
|
|
24724
24849
|
}
|
|
24725
24850
|
}
|
|
24726
24851
|
function writeSyncedName(resolvedFile, name) {
|
|
24727
|
-
if (!
|
|
24852
|
+
if (!existsSync45(resolvedFile)) return;
|
|
24728
24853
|
let raw;
|
|
24729
24854
|
try {
|
|
24730
|
-
raw = JSON.parse(
|
|
24855
|
+
raw = JSON.parse(readFileSync45(resolvedFile, "utf8"));
|
|
24731
24856
|
} catch {
|
|
24732
24857
|
return;
|
|
24733
24858
|
}
|
|
@@ -24735,14 +24860,14 @@ function writeSyncedName(resolvedFile, name) {
|
|
|
24735
24860
|
raw.shipName = name;
|
|
24736
24861
|
mkdirSync33(dirname27(resolvedFile), { recursive: true });
|
|
24737
24862
|
const tmp = `${resolvedFile}.tmp${process.pid}`;
|
|
24738
|
-
|
|
24863
|
+
writeFileSync38(tmp, `${JSON.stringify(raw, null, 2)}
|
|
24739
24864
|
`);
|
|
24740
|
-
|
|
24865
|
+
renameSync10(tmp, resolvedFile);
|
|
24741
24866
|
}
|
|
24742
24867
|
async function reconcileShipName(i) {
|
|
24743
24868
|
let local = i.ship.name;
|
|
24744
24869
|
try {
|
|
24745
|
-
local = shipNameOfYaml(
|
|
24870
|
+
local = shipNameOfYaml(readFileSync45(i.configFile, "utf8")) ?? local;
|
|
24746
24871
|
} catch {
|
|
24747
24872
|
}
|
|
24748
24873
|
const resolvedFile = resolvedPathFor(i.stateDir, i.route);
|
|
@@ -24766,8 +24891,8 @@ async function reconcileShipName(i) {
|
|
|
24766
24891
|
}
|
|
24767
24892
|
if (result.status !== "ok") return result;
|
|
24768
24893
|
if (result.action === "adopt" || result.action === "row-wins") {
|
|
24769
|
-
const text2 =
|
|
24770
|
-
|
|
24894
|
+
const text2 = readFileSync45(i.configFile, "utf8");
|
|
24895
|
+
writeFileSync38(i.configFile, setShipNameInYaml(text2, result.name));
|
|
24771
24896
|
i.ship.name = result.name;
|
|
24772
24897
|
if (result.action === "row-wins") {
|
|
24773
24898
|
i.emit?.warn(
|
|
@@ -24812,7 +24937,7 @@ async function reconcileRouteShipName(o) {
|
|
|
24812
24937
|
}
|
|
24813
24938
|
|
|
24814
24939
|
// src/mirror-contract.ts
|
|
24815
|
-
import { existsSync as
|
|
24940
|
+
import { existsSync as existsSync46 } from "fs";
|
|
24816
24941
|
|
|
24817
24942
|
// src/passenger-mirror.ts
|
|
24818
24943
|
import { mkdirSync as mkdirSync34 } from "fs";
|
|
@@ -24853,7 +24978,7 @@ function mirrorOutcome(m) {
|
|
|
24853
24978
|
|
|
24854
24979
|
// src/mirror-contract.ts
|
|
24855
24980
|
function lacksCheckout(ship, dir) {
|
|
24856
|
-
return ship.runner === "sandbox" && !
|
|
24981
|
+
return ship.runner === "sandbox" && !existsSync46(dir) && !remoteOf(dir);
|
|
24857
24982
|
}
|
|
24858
24983
|
function skipsHostCheckout(ship) {
|
|
24859
24984
|
return ship.runner === "sandbox";
|
|
@@ -24988,7 +25113,7 @@ function seatMissingProblems(route2, probes) {
|
|
|
24988
25113
|
|
|
24989
25114
|
// src/ssh-keys.ts
|
|
24990
25115
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
24991
|
-
import { existsSync as
|
|
25116
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync35, readFileSync as readFileSync46, chmodSync as chmodSync3 } from "fs";
|
|
24992
25117
|
import { dirname as dirname29, join as join51 } from "path";
|
|
24993
25118
|
var SshKeyError = class extends Error {
|
|
24994
25119
|
};
|
|
@@ -24998,7 +25123,7 @@ function shipSshKeyPathFor(stateDir) {
|
|
|
24998
25123
|
function ensureShipSshKeypair(stateDir) {
|
|
24999
25124
|
const privateKeyPath = shipSshKeyPathFor(stateDir);
|
|
25000
25125
|
const publicKeyPath = `${privateKeyPath}.pub`;
|
|
25001
|
-
if (!
|
|
25126
|
+
if (!existsSync47(privateKeyPath)) {
|
|
25002
25127
|
mkdirSync35(dirname29(privateKeyPath), { recursive: true });
|
|
25003
25128
|
try {
|
|
25004
25129
|
execFileSync13("ssh-keygen", [
|
|
@@ -25019,10 +25144,10 @@ function ensureShipSshKeypair(stateDir) {
|
|
|
25019
25144
|
}
|
|
25020
25145
|
chmodSync3(privateKeyPath, 384);
|
|
25021
25146
|
}
|
|
25022
|
-
if (!
|
|
25147
|
+
if (!existsSync47(publicKeyPath)) {
|
|
25023
25148
|
throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
|
|
25024
25149
|
}
|
|
25025
|
-
const publicKey =
|
|
25150
|
+
const publicKey = readFileSync46(publicKeyPath, "utf8").trim();
|
|
25026
25151
|
return { privateKeyPath, publicKeyPath, publicKey };
|
|
25027
25152
|
}
|
|
25028
25153
|
function sshKeygenAvailable() {
|
|
@@ -25136,7 +25261,7 @@ async function runPeriscopeIdlePass(d) {
|
|
|
25136
25261
|
}
|
|
25137
25262
|
|
|
25138
25263
|
// src/periscope-cmd.ts
|
|
25139
|
-
import { existsSync as
|
|
25264
|
+
import { existsSync as existsSync48, mkdirSync as mkdirSync36, readFileSync as readFileSync47, rmSync as rmSync22, writeFileSync as writeFileSync39 } from "fs";
|
|
25140
25265
|
import { join as join53 } from "path";
|
|
25141
25266
|
var PeriscopeError = class extends Error {
|
|
25142
25267
|
};
|
|
@@ -25155,14 +25280,14 @@ function removePeriscopePrior(stateDir, ticketRecordId) {
|
|
|
25155
25280
|
function writePeriscopePrior(stateDir, ticketRecordId, prior) {
|
|
25156
25281
|
try {
|
|
25157
25282
|
mkdirSync36(priorDir(stateDir), { recursive: true });
|
|
25158
|
-
|
|
25283
|
+
writeFileSync39(priorPath(stateDir, ticketRecordId), JSON.stringify(prior));
|
|
25159
25284
|
} catch {
|
|
25160
25285
|
}
|
|
25161
25286
|
}
|
|
25162
25287
|
function readPeriscopePrior(stateDir, ticketRecordId) {
|
|
25163
25288
|
try {
|
|
25164
25289
|
const p = priorPath(stateDir, ticketRecordId);
|
|
25165
|
-
return
|
|
25290
|
+
return existsSync48(p) ? JSON.parse(readFileSync47(p, "utf8")) : void 0;
|
|
25166
25291
|
} catch {
|
|
25167
25292
|
return void 0;
|
|
25168
25293
|
}
|
|
@@ -25710,7 +25835,7 @@ function computeTreeSignature(paths) {
|
|
|
25710
25835
|
}
|
|
25711
25836
|
function makeStaleChecker(paths, opts = {}) {
|
|
25712
25837
|
const initial = computeTreeSignature(paths);
|
|
25713
|
-
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 &&
|
|
25838
|
+
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync49(opts.reloadSentinel);
|
|
25714
25839
|
}
|
|
25715
25840
|
function reloadSentinelFor(stateDir) {
|
|
25716
25841
|
return join54(stateDir, "reload-requested");
|
|
@@ -25728,12 +25853,12 @@ function daemonStampFor(stateDir) {
|
|
|
25728
25853
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
25729
25854
|
mkdirSync37(stateDir, { recursive: true });
|
|
25730
25855
|
rmSync23(reloadSentinelFor(stateDir), { force: true });
|
|
25731
|
-
|
|
25856
|
+
writeFileSync40(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
25732
25857
|
`);
|
|
25733
25858
|
}
|
|
25734
25859
|
function readDaemonStarted(stateDir) {
|
|
25735
25860
|
try {
|
|
25736
|
-
const v = JSON.parse(
|
|
25861
|
+
const v = JSON.parse(readFileSync48(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
25737
25862
|
return typeof v === "number" ? v : null;
|
|
25738
25863
|
} catch {
|
|
25739
25864
|
return null;
|
|
@@ -26622,7 +26747,7 @@ function parseSystemctlShow(text2) {
|
|
|
26622
26747
|
}
|
|
26623
26748
|
function lastLogLine(path, read = (p) => {
|
|
26624
26749
|
try {
|
|
26625
|
-
return
|
|
26750
|
+
return readFileSync49(p, "utf8");
|
|
26626
26751
|
} catch {
|
|
26627
26752
|
return null;
|
|
26628
26753
|
}
|
|
@@ -26649,7 +26774,7 @@ function probeDaemonUnit(o) {
|
|
|
26649
26774
|
const r = spawnSync12(cmd[0], cmd.slice(1), { encoding: "utf8" });
|
|
26650
26775
|
return r.error ? null : { status: r.status, stdout: r.stdout ?? "" };
|
|
26651
26776
|
});
|
|
26652
|
-
const installed = o.plan.unitPaths.some((p) =>
|
|
26777
|
+
const installed = o.plan.unitPaths.some((p) => existsSync50(p));
|
|
26653
26778
|
let reading = null;
|
|
26654
26779
|
if (installed && o.plan.mechanism === "launchd") {
|
|
26655
26780
|
const r = run4(["launchctl", "print", `gui/${o.uid}/${o.label}`]);
|
|
@@ -26699,7 +26824,7 @@ function daemonProblem(d, route2) {
|
|
|
26699
26824
|
}
|
|
26700
26825
|
function readDaemonStamp(stateDir) {
|
|
26701
26826
|
try {
|
|
26702
|
-
const v = JSON.parse(
|
|
26827
|
+
const v = JSON.parse(readFileSync49(daemonStampFor(stateDir), "utf8"));
|
|
26703
26828
|
if (typeof v.startedAt !== "number") return null;
|
|
26704
26829
|
return typeof v.pid === "number" ? { pid: v.pid, startedAt: v.startedAt } : { startedAt: v.startedAt };
|
|
26705
26830
|
} catch {
|
|
@@ -26725,7 +26850,7 @@ function defaultRun(cmd) {
|
|
|
26725
26850
|
}
|
|
26726
26851
|
function defaultReadLog(path) {
|
|
26727
26852
|
try {
|
|
26728
|
-
return
|
|
26853
|
+
return readFileSync50(path, "utf8");
|
|
26729
26854
|
} catch {
|
|
26730
26855
|
return null;
|
|
26731
26856
|
}
|
|
@@ -26792,7 +26917,7 @@ function startLaunchdDaemon(o) {
|
|
|
26792
26917
|
}
|
|
26793
26918
|
|
|
26794
26919
|
// src/daemon-start-failure.ts
|
|
26795
|
-
import { existsSync as
|
|
26920
|
+
import { existsSync as existsSync51, mkdirSync as mkdirSync38, readFileSync as readFileSync51, unlinkSync as unlinkSync4, writeFileSync as writeFileSync41 } from "fs";
|
|
26796
26921
|
import { dirname as dirname30, join as join55 } from "path";
|
|
26797
26922
|
var DAEMON_START_FAILED_KEY = "daemon_start_failed";
|
|
26798
26923
|
var START_FAILURE_BACKOFF_MS = 6e4;
|
|
@@ -26800,7 +26925,7 @@ var BACKOFF_AFTER_FAILURES = 2;
|
|
|
26800
26925
|
var fileFor4 = (stateDir) => join55(stateDir, ".daemon-start-failure.json");
|
|
26801
26926
|
function readStartFailure(stateDir) {
|
|
26802
26927
|
try {
|
|
26803
|
-
const parsed = JSON.parse(
|
|
26928
|
+
const parsed = JSON.parse(readFileSync51(fileFor4(stateDir), "utf8"));
|
|
26804
26929
|
return typeof parsed.reason === "string" && typeof parsed.count === "number" ? { reason: parsed.reason, count: parsed.count, firstAt: String(parsed.firstAt), lastAt: String(parsed.lastAt) } : null;
|
|
26805
26930
|
} catch {
|
|
26806
26931
|
return null;
|
|
@@ -26817,7 +26942,7 @@ function noteStartFailure(stateDir, reason, nowMs = Date.now()) {
|
|
|
26817
26942
|
lastAt: nowIso
|
|
26818
26943
|
};
|
|
26819
26944
|
mkdirSync38(stateDir, { recursive: true });
|
|
26820
|
-
|
|
26945
|
+
writeFileSync41(fileFor4(stateDir), JSON.stringify(record));
|
|
26821
26946
|
return record;
|
|
26822
26947
|
}
|
|
26823
26948
|
function startFailureDelayMs(count) {
|
|
@@ -26831,7 +26956,7 @@ function startFailureItem(record, o = {}) {
|
|
|
26831
26956
|
return { kind: "daemon_start_failed", key: DAEMON_START_FAILED_KEY, message: parts.join(". ").replace(/\.\./g, "."), since: record.firstAt };
|
|
26832
26957
|
}
|
|
26833
26958
|
function clearStartFailure(state, stateDir) {
|
|
26834
|
-
if (
|
|
26959
|
+
if (existsSync51(fileFor4(stateDir))) {
|
|
26835
26960
|
try {
|
|
26836
26961
|
unlinkSync4(fileFor4(stateDir));
|
|
26837
26962
|
} catch {
|
|
@@ -27143,7 +27268,7 @@ function runForge(a, io) {
|
|
|
27143
27268
|
|
|
27144
27269
|
// src/release-sandbox.ts
|
|
27145
27270
|
import { execFile as execFile5 } from "child_process";
|
|
27146
|
-
import { mkdirSync as mkdirSync39, writeFileSync as
|
|
27271
|
+
import { mkdirSync as mkdirSync39, writeFileSync as writeFileSync42 } from "fs";
|
|
27147
27272
|
import { dirname as dirname31 } from "path";
|
|
27148
27273
|
import { promisify as promisify4 } from "util";
|
|
27149
27274
|
var execFileP4 = promisify4(execFile5);
|
|
@@ -27191,7 +27316,7 @@ async function openReleaseSandbox(o) {
|
|
|
27191
27316
|
generated = generateSandboxPolicy({ mirrorDir: cfg.mirrorDir, workDir: cfg.workDir, ...o.policy });
|
|
27192
27317
|
policyFile = o.policyFile;
|
|
27193
27318
|
mkdirSync39(dirname31(policyFile), { recursive: true });
|
|
27194
|
-
|
|
27319
|
+
writeFileSync42(policyFile, generated.yaml, { mode: 384 });
|
|
27195
27320
|
}
|
|
27196
27321
|
const secrets = { ...process.env };
|
|
27197
27322
|
const secretKeys = [];
|
|
@@ -27357,7 +27482,7 @@ function missingReleaserWarning(repo, release, ships, now = Date.now()) {
|
|
|
27357
27482
|
}
|
|
27358
27483
|
|
|
27359
27484
|
// src/watch.ts
|
|
27360
|
-
import { watch as watchFile, existsSync as
|
|
27485
|
+
import { watch as watchFile, existsSync as existsSync52, statSync as statSync15, openSync as openSync6, readSync as readSync3, closeSync as closeSync6 } from "fs";
|
|
27361
27486
|
var E = "\x1B[";
|
|
27362
27487
|
var dim = (s) => `${E}2m${s}${E}0m`;
|
|
27363
27488
|
var bold = (s) => `${E}1m${s}${E}0m`;
|
|
@@ -27458,7 +27583,7 @@ function renderHeaders(states, now = Date.now()) {
|
|
|
27458
27583
|
return states.map((s) => renderHeader(s, now)).join("");
|
|
27459
27584
|
}
|
|
27460
27585
|
function readFrom(file, from) {
|
|
27461
|
-
if (!
|
|
27586
|
+
if (!existsSync52(file)) return { events: [], offset: from };
|
|
27462
27587
|
const size = statSync15(file).size;
|
|
27463
27588
|
if (size < from) return readFrom(file, 0);
|
|
27464
27589
|
if (size === from) return { events: [], offset: from };
|
|
@@ -28525,7 +28650,7 @@ function describeCapability(i) {
|
|
|
28525
28650
|
}
|
|
28526
28651
|
|
|
28527
28652
|
// src/persona-avatars.ts
|
|
28528
|
-
import { existsSync as
|
|
28653
|
+
import { existsSync as existsSync53, readFileSync as readFileSync52 } from "fs";
|
|
28529
28654
|
import { join as join56 } from "path";
|
|
28530
28655
|
var IMAGE_TYPES = { png: "image/png", svg: "image/svg+xml" };
|
|
28531
28656
|
function personaAvatarFile(promptsDir, role) {
|
|
@@ -28533,7 +28658,7 @@ function personaAvatarFile(promptsDir, role) {
|
|
|
28533
28658
|
for (const ext of ["png", "svg"]) {
|
|
28534
28659
|
const name = `${stem}.${ext}`;
|
|
28535
28660
|
const path = join56(promptsDir, "personas", name);
|
|
28536
|
-
if (
|
|
28661
|
+
if (existsSync53(path)) return { path, mimeType: IMAGE_TYPES[ext], name };
|
|
28537
28662
|
}
|
|
28538
28663
|
return void 0;
|
|
28539
28664
|
}
|
|
@@ -28550,7 +28675,7 @@ async function syncPersonaAvatars(route2, agentPersonas, opts) {
|
|
|
28550
28675
|
if (!file || !agentId) continue;
|
|
28551
28676
|
try {
|
|
28552
28677
|
const form = new FormData();
|
|
28553
|
-
form.append("file", new Blob([
|
|
28678
|
+
form.append("file", new Blob([readFileSync52(file.path)], { type: file.mimeType }), file.name);
|
|
28554
28679
|
const res = await fetch(`${base}/${agentId}/avatar`, {
|
|
28555
28680
|
method: "PUT",
|
|
28556
28681
|
headers: { Authorization: `Bearer ${resolveApiKey(route2)}`, "User-Agent": opts.userAgent ?? "Mozilla/5.0 TablationCrewAgent/1.0" },
|
|
@@ -28591,14 +28716,14 @@ function avatarFailures(raw) {
|
|
|
28591
28716
|
}
|
|
28592
28717
|
function routeAvatarFailures(stateDir, route2) {
|
|
28593
28718
|
try {
|
|
28594
|
-
return avatarFailures(JSON.parse(
|
|
28719
|
+
return avatarFailures(JSON.parse(readFileSync52(resolvedPathFor(stateDir, route2), "utf8")));
|
|
28595
28720
|
} catch {
|
|
28596
28721
|
return [];
|
|
28597
28722
|
}
|
|
28598
28723
|
}
|
|
28599
28724
|
|
|
28600
28725
|
// src/agents-sync-run.ts
|
|
28601
|
-
import { existsSync as
|
|
28726
|
+
import { existsSync as existsSync54, mkdirSync as mkdirSync40, readFileSync as readFileSync53, writeFileSync as writeFileSync43 } from "fs";
|
|
28602
28727
|
import { dirname as dirname32 } from "path";
|
|
28603
28728
|
async function runAgentsSync(target, o) {
|
|
28604
28729
|
const dryRun = o.dryRun ?? false;
|
|
@@ -28644,13 +28769,13 @@ async function runAgentsSync(target, o) {
|
|
|
28644
28769
|
}
|
|
28645
28770
|
if (!dryRun) {
|
|
28646
28771
|
const resolvedPath = resolvedPathFor(o.stateDir, target.route);
|
|
28647
|
-
const raw =
|
|
28772
|
+
const raw = existsSync54(resolvedPath) ? JSON.parse(readFileSync53(resolvedPath, "utf8")) : {};
|
|
28648
28773
|
raw.agentPersonas = personaResult.agentPersonas;
|
|
28649
28774
|
if (skillResult) raw.agentSkills = skillResult.agentSkills;
|
|
28650
28775
|
if (!readOnly2) raw.avatarSyncFailures = avatarFailures2;
|
|
28651
28776
|
if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
|
|
28652
28777
|
mkdirSync40(dirname32(resolvedPath), { recursive: true });
|
|
28653
|
-
|
|
28778
|
+
writeFileSync43(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
28654
28779
|
`);
|
|
28655
28780
|
if (target.resolved) {
|
|
28656
28781
|
target.resolved.agentPersonas = personaResult.agentPersonas;
|
|
@@ -28786,16 +28911,16 @@ async function showLogEntry(route2, entryId, opts = {}) {
|
|
|
28786
28911
|
}
|
|
28787
28912
|
|
|
28788
28913
|
// src/repo-setup-prompt.ts
|
|
28789
|
-
import { readFileSync as
|
|
28914
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
28790
28915
|
import { join as join57 } from "path";
|
|
28791
28916
|
var REPO_SETUP_PROMPT_PATH = join57("docs", "repo-setup-prompt.md");
|
|
28792
28917
|
function readRepoSetupPrompt(crewHome) {
|
|
28793
|
-
return
|
|
28918
|
+
return readFileSync54(join57(crewHome, REPO_SETUP_PROMPT_PATH), "utf8");
|
|
28794
28919
|
}
|
|
28795
28920
|
|
|
28796
28921
|
// src/repos-check.ts
|
|
28797
28922
|
import { spawnSync as spawnSync14 } from "child_process";
|
|
28798
|
-
import { readFileSync as
|
|
28923
|
+
import { readFileSync as readFileSync55 } from "fs";
|
|
28799
28924
|
import { basename as basename12 } from "path";
|
|
28800
28925
|
var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
|
|
28801
28926
|
function checkHookSyntax(script, shell) {
|
|
@@ -28836,7 +28961,7 @@ function checkRepoSpec(dir, opts = {}) {
|
|
|
28836
28961
|
}
|
|
28837
28962
|
let parsed;
|
|
28838
28963
|
try {
|
|
28839
|
-
parsed = parseRepoConfig(
|
|
28964
|
+
parsed = parseRepoConfig(readFileSync55(file, "utf8"), file);
|
|
28840
28965
|
} catch (e) {
|
|
28841
28966
|
if (!(e instanceof RepoConfigError)) throw e;
|
|
28842
28967
|
return { ...empty, file, error: e.message, exitCode: 1 };
|
|
@@ -29369,7 +29494,7 @@ function planSampleTicket(i) {
|
|
|
29369
29494
|
}
|
|
29370
29495
|
|
|
29371
29496
|
// src/connect-append.ts
|
|
29372
|
-
import { chmodSync as chmodSync4, existsSync as
|
|
29497
|
+
import { chmodSync as chmodSync4, existsSync as existsSync55, readFileSync as readFileSync56, renameSync as renameSync11, statSync as statSync16, unlinkSync as unlinkSync5, writeFileSync as writeFileSync44 } from "fs";
|
|
29373
29498
|
import { basename as basename14, dirname as dirname34, join as join59 } from "path";
|
|
29374
29499
|
import { isMap as isMap4, isSeq as isSeq2, parseDocument as parseDocument7 } from "yaml";
|
|
29375
29500
|
function appendRouteBlock(config, block) {
|
|
@@ -29408,11 +29533,11 @@ function replaceFileKeepingMode(path, text2) {
|
|
|
29408
29533
|
const mode = statSync16(path).mode & 4095;
|
|
29409
29534
|
const tmp = join59(dirname34(path), `.${basename14(path)}.${process.pid}.tmp`);
|
|
29410
29535
|
try {
|
|
29411
|
-
|
|
29536
|
+
writeFileSync44(tmp, text2, { mode });
|
|
29412
29537
|
chmodSync4(tmp, mode);
|
|
29413
|
-
|
|
29538
|
+
renameSync11(tmp, path);
|
|
29414
29539
|
} catch (e) {
|
|
29415
|
-
if (
|
|
29540
|
+
if (existsSync55(tmp)) unlinkSync5(tmp);
|
|
29416
29541
|
throw e;
|
|
29417
29542
|
}
|
|
29418
29543
|
}
|
|
@@ -29420,7 +29545,7 @@ function planAppendToConfig(crewHome, configFile, route2, block, keyPersisted) {
|
|
|
29420
29545
|
if (!keyPersisted) return { ok: false, reason: "no stored key to name" };
|
|
29421
29546
|
let current;
|
|
29422
29547
|
try {
|
|
29423
|
-
current =
|
|
29548
|
+
current = readFileSync56(configFile, "utf8");
|
|
29424
29549
|
} catch (e) {
|
|
29425
29550
|
return { ok: false, reason: `could not read the file: ${e.message}` };
|
|
29426
29551
|
}
|
|
@@ -29660,7 +29785,7 @@ function fixPhaseNothingToOffer(o) {
|
|
|
29660
29785
|
}
|
|
29661
29786
|
|
|
29662
29787
|
// src/worktree-sweep.ts
|
|
29663
|
-
import { existsSync as
|
|
29788
|
+
import { existsSync as existsSync56, readFileSync as readFileSync57, readdirSync as readdirSync16 } from "fs";
|
|
29664
29789
|
import { basename as basename15, dirname as dirname35, join as join60, resolve as resolve6 } from "path";
|
|
29665
29790
|
function planWorktreeSweep(target, tickets, contract) {
|
|
29666
29791
|
const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
|
|
@@ -29773,7 +29898,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
29773
29898
|
let removed = 0;
|
|
29774
29899
|
let keptBranches = 0;
|
|
29775
29900
|
for (const a of actions) {
|
|
29776
|
-
if (!dryRun && base && !a.keepBranch &&
|
|
29901
|
+
if (!dryRun && base && !a.keepBranch && existsSync56(a.path) && isHandBackMerge(a.path, base)) {
|
|
29777
29902
|
if (gitOk(a.path, ["merge", "--abort"]) !== null) {
|
|
29778
29903
|
log.emit(
|
|
29779
29904
|
`abandoned the hand-back merge of ${base} in ${a.path}: ${displayKey(a.ticket)} deployed without it`,
|
|
@@ -29790,11 +29915,11 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
29790
29915
|
{ ticket: a.ticket.issue_id, step: "worktree" }
|
|
29791
29916
|
);
|
|
29792
29917
|
};
|
|
29793
|
-
if (!dryRun && liveRun &&
|
|
29918
|
+
if (!dryRun && liveRun && existsSync56(a.path)) {
|
|
29794
29919
|
defer();
|
|
29795
29920
|
continue;
|
|
29796
29921
|
}
|
|
29797
|
-
if (!dryRun &&
|
|
29922
|
+
if (!dryRun && existsSync56(a.path)) {
|
|
29798
29923
|
let dirty = false;
|
|
29799
29924
|
try {
|
|
29800
29925
|
dirty = status(a.path).length > 0;
|
|
@@ -29809,7 +29934,7 @@ async function applyWorktreeSweep(cwd, actions, dryRun, log, remote = "origin",
|
|
|
29809
29934
|
continue;
|
|
29810
29935
|
}
|
|
29811
29936
|
}
|
|
29812
|
-
if (!dryRun && a.requirePushed && a.branch &&
|
|
29937
|
+
if (!dryRun && a.requirePushed && a.branch && existsSync56(a.path) && remoteConfigured(cwd, remote) && worktreeHoldsUnpushed(a.path, remote)) {
|
|
29813
29938
|
if (pids.length) {
|
|
29814
29939
|
defer();
|
|
29815
29940
|
continue;
|
|
@@ -29865,7 +29990,7 @@ function isHandBackMerge(path, base) {
|
|
|
29865
29990
|
if (!msgPath) return false;
|
|
29866
29991
|
let first;
|
|
29867
29992
|
try {
|
|
29868
|
-
first =
|
|
29993
|
+
first = readFileSync57(resolve6(path, msgPath), "utf8").split("\n")[0] ?? "";
|
|
29869
29994
|
} catch {
|
|
29870
29995
|
return false;
|
|
29871
29996
|
}
|
|
@@ -29970,12 +30095,12 @@ function applyRemoteBranchCleanup(cwd, remote, branches2, dryRun, log) {
|
|
|
29970
30095
|
}
|
|
29971
30096
|
|
|
29972
30097
|
// src/stream-sweep.ts
|
|
29973
|
-
import { existsSync as
|
|
30098
|
+
import { existsSync as existsSync57, readdirSync as readdirSync17, rmSync as rmSync24, statSync as statSync17 } from "fs";
|
|
29974
30099
|
import { join as join61 } from "path";
|
|
29975
30100
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
29976
30101
|
function planStreamSweep(stateDir, retentionDays, now = Date.now()) {
|
|
29977
30102
|
const dir = join61(stateDir, "streams");
|
|
29978
|
-
if (!
|
|
30103
|
+
if (!existsSync57(dir)) return [];
|
|
29979
30104
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
29980
30105
|
return readdirSync17(dir).map((name) => join61(dir, name)).filter((path) => {
|
|
29981
30106
|
try {
|
|
@@ -30003,7 +30128,7 @@ function applyStreamSweep(paths, dryRun, log) {
|
|
|
30003
30128
|
return removed;
|
|
30004
30129
|
}
|
|
30005
30130
|
function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
30006
|
-
if (!
|
|
30131
|
+
if (!existsSync57(stateDir)) return [];
|
|
30007
30132
|
const cutoff = now - retentionDays * DAY_MS2;
|
|
30008
30133
|
return readdirSync17(stateDir).filter((name) => ROTATED_EVENTS_RE.test(name)).map((name) => join61(stateDir, name)).filter((path) => {
|
|
30009
30134
|
try {
|
|
@@ -30016,7 +30141,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
30016
30141
|
function planSizeCapSweep(stateDir, maxBytes, now = Date.now()) {
|
|
30017
30142
|
const files = [];
|
|
30018
30143
|
const add = (dir, keep) => {
|
|
30019
|
-
if (!
|
|
30144
|
+
if (!existsSync57(dir)) return;
|
|
30020
30145
|
for (const name of readdirSync17(dir)) {
|
|
30021
30146
|
if (!keep(name)) continue;
|
|
30022
30147
|
const path = join61(dir, name);
|
|
@@ -30047,7 +30172,7 @@ function planStateSweep(stateDir, retentionDays, maxBytes, now = Date.now()) {
|
|
|
30047
30172
|
}
|
|
30048
30173
|
|
|
30049
30174
|
// src/cli.ts
|
|
30050
|
-
import { realpathSync as realpathSync4, readFileSync as
|
|
30175
|
+
import { realpathSync as realpathSync4, readFileSync as readFileSync60, existsSync as existsSync62, mkdirSync as mkdirSync44, writeFileSync as writeFileSync47, rmSync as rmSync27, unlinkSync as unlinkSync7, copyFileSync as copyFileSync3, renameSync as renameSync12, statSync as statSync20, readdirSync as readdirSync22 } from "fs";
|
|
30051
30176
|
import { createInterface } from "readline/promises";
|
|
30052
30177
|
|
|
30053
30178
|
// src/periscope-resume.ts
|
|
@@ -30123,10 +30248,10 @@ ${tail2(preview.output)}`);
|
|
|
30123
30248
|
import { dirname as dirOf2, resolve as resolvePath } from "path";
|
|
30124
30249
|
|
|
30125
30250
|
// src/bundle-staleness.ts
|
|
30126
|
-
import { existsSync as
|
|
30251
|
+
import { existsSync as existsSync58, readdirSync as readdirSync18, statSync as statSync18 } from "fs";
|
|
30127
30252
|
import { join as join62 } from "path";
|
|
30128
30253
|
function builtVersion() {
|
|
30129
|
-
return true ? "0.171.
|
|
30254
|
+
return true ? "0.171.1" : null;
|
|
30130
30255
|
}
|
|
30131
30256
|
var REBUILD_HINT = "rebuild with npm run build";
|
|
30132
30257
|
function newestMtime(path) {
|
|
@@ -30145,7 +30270,7 @@ function newestMtime(path) {
|
|
|
30145
30270
|
function bundleStaleness(i) {
|
|
30146
30271
|
if (i.built === null || i.compiled) return null;
|
|
30147
30272
|
const src = join62(i.home, "src");
|
|
30148
|
-
if (!
|
|
30273
|
+
if (!existsSync58(src)) return null;
|
|
30149
30274
|
if (i.built !== i.current) {
|
|
30150
30275
|
return { kind: "version", builtVersion: i.built, message: `running a bundle built from ${i.built} (package.json names ${i.current}); ${REBUILD_HINT}` };
|
|
30151
30276
|
}
|
|
@@ -30367,7 +30492,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
|
|
|
30367
30492
|
import { createServer as createHttpServer } from "http";
|
|
30368
30493
|
import { spawn as spawn10 } from "child_process";
|
|
30369
30494
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
30370
|
-
import { existsSync as
|
|
30495
|
+
import { existsSync as existsSync59, mkdirSync as mkdirSync41, readFileSync as readFileSync58, writeFileSync as writeFileSync45, unlinkSync as unlinkSync6, readdirSync as readdirSync19 } from "fs";
|
|
30371
30496
|
import { join as join63 } from "path";
|
|
30372
30497
|
|
|
30373
30498
|
// src/secret-compare.ts
|
|
@@ -30465,9 +30590,9 @@ function syncDaemonStatePath(stateDir, workspaceId) {
|
|
|
30465
30590
|
}
|
|
30466
30591
|
function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
30467
30592
|
const path = syncDaemonStatePath(stateDir, workspaceId);
|
|
30468
|
-
if (!
|
|
30593
|
+
if (!existsSync59(path)) return void 0;
|
|
30469
30594
|
try {
|
|
30470
|
-
return JSON.parse(
|
|
30595
|
+
return JSON.parse(readFileSync58(path, "utf8"));
|
|
30471
30596
|
} catch {
|
|
30472
30597
|
return void 0;
|
|
30473
30598
|
}
|
|
@@ -30475,7 +30600,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
|
|
|
30475
30600
|
function writePersistedSyncDaemon(stateDir, state) {
|
|
30476
30601
|
const path = syncDaemonStatePath(stateDir, state.workspaceId);
|
|
30477
30602
|
mkdirSync41(join63(stateDir, "passengers"), { recursive: true });
|
|
30478
|
-
|
|
30603
|
+
writeFileSync45(path, `${JSON.stringify(state, null, 2)}
|
|
30479
30604
|
`);
|
|
30480
30605
|
}
|
|
30481
30606
|
function removePersistedSyncDaemon(stateDir, workspaceId) {
|
|
@@ -30493,7 +30618,7 @@ function waitForExit(pid, alive, timeoutMs = 5e3) {
|
|
|
30493
30618
|
}
|
|
30494
30619
|
function readAllPersistedSyncWorkspaceIds(stateDir) {
|
|
30495
30620
|
const dir = join63(stateDir, "passengers");
|
|
30496
|
-
if (!
|
|
30621
|
+
if (!existsSync59(dir)) return [];
|
|
30497
30622
|
const suffix = "-sync.json";
|
|
30498
30623
|
return readdirSync19(dir).filter((f2) => f2.endsWith(suffix)).map((f2) => f2.slice(0, -suffix.length));
|
|
30499
30624
|
}
|
|
@@ -30987,7 +31112,7 @@ import { createHash as createHash12 } from "crypto";
|
|
|
30987
31112
|
import {
|
|
30988
31113
|
chmodSync as chmodSync5,
|
|
30989
31114
|
closeSync as closeSync7,
|
|
30990
|
-
existsSync as
|
|
31115
|
+
existsSync as existsSync60,
|
|
30991
31116
|
fstatSync as fstatSync2,
|
|
30992
31117
|
openSync as openSync7,
|
|
30993
31118
|
readSync as readSync4,
|
|
@@ -31367,7 +31492,7 @@ function lastLines2(path, n) {
|
|
|
31367
31492
|
}
|
|
31368
31493
|
function readTail(live2, opts) {
|
|
31369
31494
|
const max = opts.maxBytes ?? MAX_TAIL_BYTES;
|
|
31370
|
-
if (!
|
|
31495
|
+
if (!existsSync60(live2)) {
|
|
31371
31496
|
return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
|
|
31372
31497
|
}
|
|
31373
31498
|
const cur = opts.after ? decodeCursor(opts.after) : null;
|
|
@@ -31583,7 +31708,7 @@ async function route(deps, method, url, req, abort) {
|
|
|
31583
31708
|
const run4 = decodeURIComponent(p.slice("/streams/".length));
|
|
31584
31709
|
if (!RUN_NAME_RE.test(run4) || run4.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run4)) return err2(400, "not a run name");
|
|
31585
31710
|
const file = join65(deps.stateDir, "streams", run4.endsWith(".jsonl") ? run4 : `${run4}.jsonl`);
|
|
31586
|
-
if (!
|
|
31711
|
+
if (!existsSync60(file)) return err2(404, "no such run");
|
|
31587
31712
|
return tailReply(file, url.searchParams, false, abort);
|
|
31588
31713
|
}
|
|
31589
31714
|
const note = /^\/streams\/([^/]+)\/messages$/.exec(p);
|
|
@@ -31632,7 +31757,7 @@ function send2(res, r) {
|
|
|
31632
31757
|
res.end(body);
|
|
31633
31758
|
}
|
|
31634
31759
|
async function socketIsStale(path) {
|
|
31635
|
-
if (!
|
|
31760
|
+
if (!existsSync60(path)) return false;
|
|
31636
31761
|
return new Promise((resolve9) => {
|
|
31637
31762
|
const c = createConnection(path);
|
|
31638
31763
|
c.once("connect", () => {
|
|
@@ -31651,7 +31776,7 @@ async function startControlServer(deps) {
|
|
|
31651
31776
|
return null;
|
|
31652
31777
|
}
|
|
31653
31778
|
if (await socketIsStale(path)) rmSync25(path, { force: true });
|
|
31654
|
-
else if (
|
|
31779
|
+
else if (existsSync60(path)) {
|
|
31655
31780
|
log(`control API not started: ${path} is in use by another process`);
|
|
31656
31781
|
return null;
|
|
31657
31782
|
}
|
|
@@ -31757,7 +31882,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
|
|
|
31757
31882
|
|
|
31758
31883
|
// src/periscope-endpoints.ts
|
|
31759
31884
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
31760
|
-
import { chmodSync as chmodSync6, existsSync as
|
|
31885
|
+
import { chmodSync as chmodSync6, existsSync as existsSync61, mkdirSync as mkdirSync43, readdirSync as readdirSync21, readFileSync as readFileSync59, rmSync as rmSync26, writeFileSync as writeFileSync46 } from "fs";
|
|
31761
31886
|
import { join as join66 } from "path";
|
|
31762
31887
|
var secretDir = (stateDir) => join66(stateDir, "periscope-mcp");
|
|
31763
31888
|
var secretFile = (stateDir, id) => join66(secretDir(stateDir), `${id}.json`);
|
|
@@ -31767,14 +31892,14 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
31767
31892
|
mkdirSync43(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
31768
31893
|
const secret = randomBytes3(32).toString("base64url");
|
|
31769
31894
|
const file = secretFile(stateDir, ticketRecordId);
|
|
31770
|
-
|
|
31895
|
+
writeFileSync46(file, `${JSON.stringify({ secret })}
|
|
31771
31896
|
`, { mode: 384 });
|
|
31772
31897
|
chmodSync6(file, 384);
|
|
31773
31898
|
return secret;
|
|
31774
31899
|
}
|
|
31775
31900
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
31776
31901
|
try {
|
|
31777
|
-
const v = JSON.parse(
|
|
31902
|
+
const v = JSON.parse(readFileSync59(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
31778
31903
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
31779
31904
|
} catch {
|
|
31780
31905
|
return void 0;
|
|
@@ -31785,14 +31910,14 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
31785
31910
|
}
|
|
31786
31911
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
31787
31912
|
try {
|
|
31788
|
-
return JSON.parse(
|
|
31913
|
+
return JSON.parse(readFileSync59(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
31789
31914
|
} catch {
|
|
31790
31915
|
return void 0;
|
|
31791
31916
|
}
|
|
31792
31917
|
}
|
|
31793
31918
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
31794
31919
|
mkdirSync43(endpointDir(stateDir), { recursive: true });
|
|
31795
|
-
|
|
31920
|
+
writeFileSync46(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
31796
31921
|
`);
|
|
31797
31922
|
}
|
|
31798
31923
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
@@ -31800,7 +31925,7 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
|
31800
31925
|
}
|
|
31801
31926
|
function listPeriscopeEndpoints(stateDir) {
|
|
31802
31927
|
const dir = endpointDir(stateDir);
|
|
31803
|
-
if (!
|
|
31928
|
+
if (!existsSync61(dir)) return [];
|
|
31804
31929
|
const out = [];
|
|
31805
31930
|
for (const name of readdirSync21(dir)) {
|
|
31806
31931
|
if (!name.endsWith(".json")) continue;
|
|
@@ -32578,7 +32703,7 @@ if (command === "provision") {
|
|
|
32578
32703
|
process.exit(outcome.code);
|
|
32579
32704
|
}
|
|
32580
32705
|
if (command === "pool-member") {
|
|
32581
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
32706
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync60(0, "utf8"));
|
|
32582
32707
|
if (typeof pool === "string") {
|
|
32583
32708
|
process.stderr.write(`crew pool-member: ${pool}
|
|
32584
32709
|
`);
|
|
@@ -32923,7 +33048,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
32923
33048
|
} else {
|
|
32924
33049
|
const toleratesNoRoutes = command === "routes" || command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
|
|
32925
33050
|
const configless = command === "routes" || command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
|
|
32926
|
-
if (configless && !
|
|
33051
|
+
if (configless && !existsSync62(findConfigFile(CREW_HOME))) {
|
|
32927
33052
|
cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
|
|
32928
33053
|
} else {
|
|
32929
33054
|
cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
|
|
@@ -32946,7 +33071,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
32946
33071
|
throw e;
|
|
32947
33072
|
}
|
|
32948
33073
|
if (command === "credential") {
|
|
32949
|
-
const r = runCredential(positional[1],
|
|
33074
|
+
const r = runCredential(positional[1], readFileSync60(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
32950
33075
|
process.stdout.write(r.out);
|
|
32951
33076
|
process.stderr.write(r.err);
|
|
32952
33077
|
process.exit(r.code);
|
|
@@ -32958,9 +33083,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
32958
33083
|
forges: cfg.ship.forges,
|
|
32959
33084
|
stateDir: cfg.ship.stateDir,
|
|
32960
33085
|
configFile: cfg.configFile,
|
|
32961
|
-
readFile: (p) =>
|
|
32962
|
-
writeFile: (p, t) =>
|
|
32963
|
-
stdin: () =>
|
|
33086
|
+
readFile: (p) => readFileSync60(p, "utf8"),
|
|
33087
|
+
writeFile: (p, t) => writeFileSync47(p, t),
|
|
33088
|
+
stdin: () => readFileSync60(0, "utf8"),
|
|
32964
33089
|
env: process.env
|
|
32965
33090
|
}
|
|
32966
33091
|
);
|
|
@@ -33321,7 +33446,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
33321
33446
|
if (host === "linux" && hasSystemd) {
|
|
33322
33447
|
const label = labelFor(CREW_HOME, "run");
|
|
33323
33448
|
const staleTimer = join68(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
33324
|
-
if (
|
|
33449
|
+
if (existsSync62(staleTimer)) {
|
|
33325
33450
|
emit.emit(
|
|
33326
33451
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run, not applied)" : ""}`
|
|
33327
33452
|
);
|
|
@@ -33370,7 +33495,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
33370
33495
|
const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
33371
33496
|
for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
|
|
33372
33497
|
for (const r of doctorRepos) {
|
|
33373
|
-
if (!
|
|
33498
|
+
if (!existsSync62(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
|
|
33374
33499
|
if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
|
|
33375
33500
|
readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
|
|
33376
33501
|
}
|
|
@@ -33393,7 +33518,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
33393
33518
|
problems.push(`tracker unreachable: ${e instanceof Error ? e.message : String(e)}`);
|
|
33394
33519
|
}
|
|
33395
33520
|
if (await tracker.eventLogTracksStatus() === false) problems.push(EVENT_LOG_STATUS_UNTRACKED(tracker.contract.columns.status));
|
|
33396
|
-
for (const l of interfaceReport(await readForRoute(c, cfg.ship), { storedMappingKey: c.resolved?.trackerInterface?.mappingKey, contractAuthored: c.contractAuthored })) {
|
|
33521
|
+
for (const l of interfaceReport(await readForRoute(c, cfg.ship), { storedMappingKey: c.resolved?.trackerInterface?.mappingKey, contractAuthored: c.contractAuthored, stored: c.resolved })) {
|
|
33397
33522
|
if (l.problem) problems.push(l.line);
|
|
33398
33523
|
}
|
|
33399
33524
|
const diff = await snapshotDiffFor(c);
|
|
@@ -33410,7 +33535,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
33410
33535
|
}
|
|
33411
33536
|
async function doctorFix(o) {
|
|
33412
33537
|
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))));
|
|
33413
|
-
const unitExists = (p) =>
|
|
33538
|
+
const unitExists = (p) => existsSync62(p);
|
|
33414
33539
|
const crontab = o.host === "linux" ? spawnSync15("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
|
|
33415
33540
|
const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
|
|
33416
33541
|
const plan = planFix({ routes, schedulerAbsent, host: o.host });
|
|
@@ -33440,7 +33565,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
33440
33565
|
changed2.push(`refreshed the connect snapshot for ${a.route} (\`crew connect\`)${rel.status === 0 ? " and reloaded the daemon" : "; `crew reload` failed \u2014 run it by hand"}`);
|
|
33441
33566
|
} else if (a.kind === "enable") {
|
|
33442
33567
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
33443
|
-
|
|
33568
|
+
writeFileSync47(cfg.configFile, planEnable(readFileSync60(cfg.configFile, "utf8"), a.route));
|
|
33444
33569
|
enabledSound.add(a.route);
|
|
33445
33570
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
33446
33571
|
} else {
|
|
@@ -35425,10 +35550,10 @@ ${f2.tail.trimEnd()}
|
|
|
35425
35550
|
for (const w of result.warnings) emit.warn(w);
|
|
35426
35551
|
if (!dryRun) {
|
|
35427
35552
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
35428
|
-
const raw =
|
|
35553
|
+
const raw = existsSync62(resolvedPath) ? JSON.parse(readFileSync60(resolvedPath, "utf8")) : {};
|
|
35429
35554
|
raw.agentSkills = result.agentSkills;
|
|
35430
35555
|
mkdirSync44(dirOf2(resolvedPath), { recursive: true });
|
|
35431
|
-
|
|
35556
|
+
writeFileSync47(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
35432
35557
|
`);
|
|
35433
35558
|
}
|
|
35434
35559
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -35449,7 +35574,7 @@ ${f2.tail.trimEnd()}
|
|
|
35449
35574
|
throw e;
|
|
35450
35575
|
}
|
|
35451
35576
|
const oldName = cfg.ship.name;
|
|
35452
|
-
|
|
35577
|
+
writeFileSync47(cfg.configFile, setShipNameInYaml(readFileSync60(cfg.configFile, "utf8"), newName));
|
|
35453
35578
|
cfg.ship.name = newName;
|
|
35454
35579
|
let renameMachineId;
|
|
35455
35580
|
try {
|
|
@@ -35496,7 +35621,7 @@ ${f2.tail.trimEnd()}
|
|
|
35496
35621
|
process.exit(2);
|
|
35497
35622
|
};
|
|
35498
35623
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
35499
|
-
const configText =
|
|
35624
|
+
const configText = readFileSync60(cfg.configFile, "utf8");
|
|
35500
35625
|
if (sub === "check") {
|
|
35501
35626
|
try {
|
|
35502
35627
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -35526,8 +35651,8 @@ ${f2.tail.trimEnd()}
|
|
|
35526
35651
|
try {
|
|
35527
35652
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
35528
35653
|
const dir = repoDirOf(configText, dirname39(cfg.configFile), a.route, a.name);
|
|
35529
|
-
if (!
|
|
35530
|
-
const files = { exists: (r) =>
|
|
35654
|
+
if (!existsSync62(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
35655
|
+
const files = { exists: (r) => existsSync62(resolvePath(dir, r)), list: (r) => {
|
|
35531
35656
|
try {
|
|
35532
35657
|
return readdirSync22(resolvePath(dir, r));
|
|
35533
35658
|
} catch {
|
|
@@ -35535,7 +35660,7 @@ ${f2.tail.trimEnd()}
|
|
|
35535
35660
|
}
|
|
35536
35661
|
}, read: (r) => {
|
|
35537
35662
|
try {
|
|
35538
|
-
return
|
|
35663
|
+
return readFileSync60(resolvePath(dir, r), "utf8");
|
|
35539
35664
|
} catch {
|
|
35540
35665
|
return void 0;
|
|
35541
35666
|
}
|
|
@@ -35577,19 +35702,19 @@ ${f2.tail.trimEnd()}
|
|
|
35577
35702
|
let cleared;
|
|
35578
35703
|
if (clear2) {
|
|
35579
35704
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
35580
|
-
if (plan.removed.length > 0)
|
|
35705
|
+
if (plan.removed.length > 0) writeFileSync47(cfg.configFile, plan.text);
|
|
35581
35706
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
35582
35707
|
}
|
|
35583
35708
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
35584
35709
|
if (write === "route") {
|
|
35585
35710
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
35586
|
-
|
|
35711
|
+
writeFileSync47(cfg.configFile, plan.text);
|
|
35587
35712
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
35588
35713
|
} else if (write === "repo") {
|
|
35589
35714
|
const have = existingRepoConfig(files);
|
|
35590
35715
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
35591
35716
|
const file = resolvePath(dir, ".crew.yaml");
|
|
35592
|
-
|
|
35717
|
+
writeFileSync47(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
35593
35718
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
35594
35719
|
}
|
|
35595
35720
|
if (flag("json")) {
|
|
@@ -35642,7 +35767,7 @@ ${f2.tail.trimEnd()}
|
|
|
35642
35767
|
if (sub === "list" && !routeName) usage2();
|
|
35643
35768
|
if (sub === "add") {
|
|
35644
35769
|
try {
|
|
35645
|
-
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) =>
|
|
35770
|
+
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync62(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
|
|
35646
35771
|
routeName = a.route;
|
|
35647
35772
|
addPath = a.path;
|
|
35648
35773
|
addName = a.name;
|
|
@@ -35668,7 +35793,7 @@ ${f2.tail.trimEnd()}
|
|
|
35668
35793
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
|
|
35669
35794
|
if (sub === "list" || sub === "add") {
|
|
35670
35795
|
const liveRoute = cfg.routes.find((r) => r.route === routeName);
|
|
35671
|
-
if (liveRoute?.resolved?.reposModelId &&
|
|
35796
|
+
if (liveRoute?.resolved?.reposModelId && existsSync62(resolvedFile) && !dryRun) {
|
|
35672
35797
|
try {
|
|
35673
35798
|
await hydrateApiKeys([liveRoute]);
|
|
35674
35799
|
persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
|
|
@@ -35677,16 +35802,16 @@ ${f2.tail.trimEnd()}
|
|
|
35677
35802
|
}
|
|
35678
35803
|
}
|
|
35679
35804
|
let resolvedRemotes;
|
|
35680
|
-
if (
|
|
35805
|
+
if (existsSync62(resolvedFile)) {
|
|
35681
35806
|
try {
|
|
35682
|
-
resolvedRemotes = JSON.parse(
|
|
35807
|
+
resolvedRemotes = JSON.parse(readFileSync60(resolvedFile, "utf8"));
|
|
35683
35808
|
} catch {
|
|
35684
35809
|
}
|
|
35685
35810
|
}
|
|
35686
35811
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
35687
35812
|
const text2 = configText;
|
|
35688
35813
|
const base = dirname39(cfg.configFile);
|
|
35689
|
-
const isCheckout = (d) =>
|
|
35814
|
+
const isCheckout = (d) => existsSync62(`${d}/.git`);
|
|
35690
35815
|
try {
|
|
35691
35816
|
if (sub === "list") {
|
|
35692
35817
|
if (flag("json")) {
|
|
@@ -35696,12 +35821,12 @@ ${f2.tail.trimEnd()}
|
|
|
35696
35821
|
base,
|
|
35697
35822
|
resolved: resolvedRemotes,
|
|
35698
35823
|
originOf,
|
|
35699
|
-
exists: (d) =>
|
|
35824
|
+
exists: (d) => existsSync62(d),
|
|
35700
35825
|
isCheckout,
|
|
35701
35826
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f2) => {
|
|
35702
35827
|
try {
|
|
35703
35828
|
const path = resolvePath(d, f2);
|
|
35704
|
-
return Object.keys(parseRepoConfig(
|
|
35829
|
+
return Object.keys(parseRepoConfig(readFileSync60(path, "utf8"), path).hooks).length > 0;
|
|
35705
35830
|
} catch {
|
|
35706
35831
|
return false;
|
|
35707
35832
|
}
|
|
@@ -35718,7 +35843,7 @@ ${f2.tail.trimEnd()}
|
|
|
35718
35843
|
for (const r of repos) {
|
|
35719
35844
|
const origin2 = originOf(r.dir);
|
|
35720
35845
|
const row = matchRepoName(origin2, resolvedRemotes);
|
|
35721
|
-
const note = !
|
|
35846
|
+
const note = !existsSync62(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote2(origin2) ?? "this checkout (no origin remote)"}`;
|
|
35722
35847
|
process.stdout.write(`${r.name} ${r.dir} ${note}
|
|
35723
35848
|
`);
|
|
35724
35849
|
}
|
|
@@ -35730,9 +35855,9 @@ ${f2.tail.trimEnd()}
|
|
|
35730
35855
|
` : `${human}
|
|
35731
35856
|
`);
|
|
35732
35857
|
const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
|
|
35733
|
-
if (
|
|
35858
|
+
if (existsSync62(plan2.target) && (existsSync62(`${plan2.target}/.git`) || readdirSync22(plan2.target).length > 0)) {
|
|
35734
35859
|
throw new ReposError(
|
|
35735
|
-
|
|
35860
|
+
existsSync62(`${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`
|
|
35736
35861
|
);
|
|
35737
35862
|
}
|
|
35738
35863
|
if (dryRun) {
|
|
@@ -35750,13 +35875,13 @@ ${f2.tail.trimEnd()}
|
|
|
35750
35875
|
throw new ReposError(`${e.message}${authHint}
|
|
35751
35876
|
crew.yaml was not changed`);
|
|
35752
35877
|
}
|
|
35753
|
-
|
|
35878
|
+
writeFileSync47(cfg.configFile, plan2.text);
|
|
35754
35879
|
if (plan2.droppedDir) emit.warn(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:`);
|
|
35755
35880
|
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}`);
|
|
35756
35881
|
break;
|
|
35757
35882
|
}
|
|
35758
35883
|
const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
|
|
35759
|
-
if (!
|
|
35884
|
+
if (!existsSync62(target)) throw new ReposError(`${target} does not exist`);
|
|
35760
35885
|
let top;
|
|
35761
35886
|
try {
|
|
35762
35887
|
top = git(target, ["rev-parse", "--show-toplevel"]);
|
|
@@ -35840,15 +35965,15 @@ would need a project first: the tracker has none (\`crew projects add NAME --pre
|
|
|
35840
35965
|
const created = await rowTracker.createRepoRow(rowPayload);
|
|
35841
35966
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
35842
35967
|
`);
|
|
35843
|
-
if (
|
|
35844
|
-
const raw = JSON.parse(
|
|
35968
|
+
if (existsSync62(resolvedFile)) {
|
|
35969
|
+
const raw = JSON.parse(readFileSync60(resolvedFile, "utf8"));
|
|
35845
35970
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
35846
35971
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
35847
|
-
|
|
35972
|
+
writeFileSync47(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
35848
35973
|
`);
|
|
35849
35974
|
}
|
|
35850
35975
|
}
|
|
35851
|
-
|
|
35976
|
+
writeFileSync47(cfg.configFile, plan.text);
|
|
35852
35977
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
35853
35978
|
`);
|
|
35854
35979
|
} catch (e) {
|
|
@@ -36214,7 +36339,7 @@ Waiting for approval`
|
|
|
36214
36339
|
${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, then run `crew connect` again");
|
|
36215
36340
|
}
|
|
36216
36341
|
if (found.shipNameAdopted && !dryRun) {
|
|
36217
|
-
|
|
36342
|
+
writeFileSync47(cfg.configFile, setShipNameInYaml(readFileSync60(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
36218
36343
|
cfg.ship.name = found.shipNameAdopted;
|
|
36219
36344
|
}
|
|
36220
36345
|
if (found.shipRow) {
|
|
@@ -36255,10 +36380,10 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
36255
36380
|
}
|
|
36256
36381
|
}
|
|
36257
36382
|
let previous;
|
|
36258
|
-
const hadPreviousFile =
|
|
36383
|
+
const hadPreviousFile = existsSync62(resolvedPath);
|
|
36259
36384
|
if (hadPreviousFile) {
|
|
36260
36385
|
try {
|
|
36261
|
-
previous = JSON.parse(
|
|
36386
|
+
previous = JSON.parse(readFileSync60(resolvedPath, "utf8"));
|
|
36262
36387
|
} catch {
|
|
36263
36388
|
}
|
|
36264
36389
|
}
|
|
@@ -36405,11 +36530,11 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
36405
36530
|
`);
|
|
36406
36531
|
} else {
|
|
36407
36532
|
mkdirSync44(dirname39(resolvedPath), { recursive: true });
|
|
36408
|
-
if (hadPreviousFile)
|
|
36533
|
+
if (hadPreviousFile) copyFileSync3(resolvedPath, `${resolvedPath}.bak`);
|
|
36409
36534
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
36410
|
-
|
|
36535
|
+
writeFileSync47(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
36411
36536
|
`);
|
|
36412
|
-
|
|
36537
|
+
renameSync12(tmpPath, resolvedPath);
|
|
36413
36538
|
emit.note(`Resolved ids written to ${resolvedPath}`);
|
|
36414
36539
|
}
|
|
36415
36540
|
let mintOutcomes = [];
|
|
@@ -36477,7 +36602,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`, "fix the problems above, t
|
|
|
36477
36602
|
`);
|
|
36478
36603
|
} else {
|
|
36479
36604
|
mkdirSync44(dirname39(apiKeyFile), { recursive: true });
|
|
36480
|
-
|
|
36605
|
+
writeFileSync47(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
36481
36606
|
`, { mode: 384 });
|
|
36482
36607
|
routineLine(`API key written to ${apiKeyFile}`);
|
|
36483
36608
|
}
|
|
@@ -37151,9 +37276,9 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
37151
37276
|
prepare: async (path) => {
|
|
37152
37277
|
for (const f2 of repoWt.config.worktrees.copy) {
|
|
37153
37278
|
const src = join68(repoWt.dir, f2);
|
|
37154
|
-
if (!
|
|
37279
|
+
if (!existsSync62(src) || existsSync62(join68(path, f2))) continue;
|
|
37155
37280
|
mkdirSync44(dirOf2(join68(path, f2)), { recursive: true });
|
|
37156
|
-
|
|
37281
|
+
copyFileSync3(src, join68(path, f2));
|
|
37157
37282
|
}
|
|
37158
37283
|
const setup = repoWt.config.hooks.setup;
|
|
37159
37284
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -37377,7 +37502,7 @@ ${found.problems.map((p) => ` - ${p}`).join("\n")}`);
|
|
|
37377
37502
|
const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
|
|
37378
37503
|
const resumed = await runPeriscopeResume({
|
|
37379
37504
|
find: async () => hit && { row: hit.row, tag: hit.tag },
|
|
37380
|
-
worktreeExists: (p) =>
|
|
37505
|
+
worktreeExists: (p) => existsSync62(p),
|
|
37381
37506
|
prepareDropFile,
|
|
37382
37507
|
startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
|
|
37383
37508
|
relay: hit && previewRelayFor(hit.route) && {
|
|
@@ -37481,9 +37606,9 @@ ${where.join("\n")}`);
|
|
|
37481
37606
|
prepare: async (path) => {
|
|
37482
37607
|
for (const f2 of repoP.config.worktrees.copy) {
|
|
37483
37608
|
const src = join68(repoP.dir, f2);
|
|
37484
|
-
if (!
|
|
37609
|
+
if (!existsSync62(src)) continue;
|
|
37485
37610
|
mkdirSync44(dirOf2(join68(path, f2)), { recursive: true });
|
|
37486
|
-
|
|
37611
|
+
copyFileSync3(src, join68(path, f2));
|
|
37487
37612
|
}
|
|
37488
37613
|
const setup = repoP.config.hooks.setup;
|
|
37489
37614
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -37666,6 +37791,7 @@ ${where.join("\n")}`);
|
|
|
37666
37791
|
}
|
|
37667
37792
|
answersA.push({ label: raw.slice(0, at).trim(), detail: raw.slice(at + 2).trim() });
|
|
37668
37793
|
});
|
|
37794
|
+
if (!new Tracker(route2, cfg.ship).questionsPart()) await refreshForRoute(route2, cfg.ship, !dryRun);
|
|
37669
37795
|
const trA = new Tracker(route2, cfg.ship);
|
|
37670
37796
|
const partA = trA.questionsPart();
|
|
37671
37797
|
if (!partA) {
|
|
@@ -37888,7 +38014,7 @@ ${where.join("\n")}`);
|
|
|
37888
38014
|
};
|
|
37889
38015
|
const droppedRoutes = [];
|
|
37890
38016
|
try {
|
|
37891
|
-
const rawCfg = parseYaml3(
|
|
38017
|
+
const rawCfg = parseYaml3(readFileSync60(cfg.configFile, "utf8"));
|
|
37892
38018
|
for (const r of rawCfg?.routes ?? []) {
|
|
37893
38019
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
37894
38020
|
try {
|
|
@@ -37952,7 +38078,7 @@ ${where.join("\n")}`);
|
|
|
37952
38078
|
break;
|
|
37953
38079
|
}
|
|
37954
38080
|
mkdirSync44(cfg.ship.stateDir, { recursive: true });
|
|
37955
|
-
|
|
38081
|
+
writeFileSync47(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
37956
38082
|
`);
|
|
37957
38083
|
process.stdout.write(
|
|
37958
38084
|
"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"
|
|
@@ -38014,7 +38140,7 @@ ${where.join("\n")}`);
|
|
|
38014
38140
|
}
|
|
38015
38141
|
case "log": {
|
|
38016
38142
|
try {
|
|
38017
|
-
const text2 =
|
|
38143
|
+
const text2 = readFileSync60(cfg.ship.logFile, "utf8").split("\n");
|
|
38018
38144
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
38019
38145
|
`);
|
|
38020
38146
|
} catch {
|
|
@@ -38038,7 +38164,7 @@ ${where.join("\n")}`);
|
|
|
38038
38164
|
};
|
|
38039
38165
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
38040
38166
|
const tracker = new Tracker(route2, cfg.ship);
|
|
38041
|
-
const configText =
|
|
38167
|
+
const configText = readFileSync60(cfg.configFile, "utf8");
|
|
38042
38168
|
const cfgBase = dirname39(cfg.configFile);
|
|
38043
38169
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
38044
38170
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -38067,7 +38193,7 @@ ${where.join("\n")}`);
|
|
|
38067
38193
|
}
|
|
38068
38194
|
if (configured2.some((r) => r.dir === dir)) {
|
|
38069
38195
|
try {
|
|
38070
|
-
|
|
38196
|
+
writeFileSync47(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
38071
38197
|
} catch (e) {
|
|
38072
38198
|
if (e instanceof ReposError) fail2(e.message);
|
|
38073
38199
|
throw e;
|
|
@@ -38075,29 +38201,29 @@ ${where.join("\n")}`);
|
|
|
38075
38201
|
}
|
|
38076
38202
|
if (row) {
|
|
38077
38203
|
await tracker.deleteRepoRow(row.id);
|
|
38078
|
-
if (
|
|
38079
|
-
const raw = JSON.parse(
|
|
38204
|
+
if (existsSync62(resolvedFile)) {
|
|
38205
|
+
const raw = JSON.parse(readFileSync60(resolvedFile, "utf8"));
|
|
38080
38206
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
38081
38207
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
38082
|
-
|
|
38208
|
+
writeFileSync47(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
38083
38209
|
`);
|
|
38084
38210
|
}
|
|
38085
38211
|
}
|
|
38086
|
-
if (
|
|
38212
|
+
if (existsSync62(join68(dir, ".git")) && basename18(dir) === SAMPLE_REPO) rmSync27(dir, { recursive: true, force: true });
|
|
38087
38213
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
38088
38214
|
break;
|
|
38089
38215
|
}
|
|
38090
38216
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
38091
|
-
const fresh = !
|
|
38092
|
-
if (
|
|
38217
|
+
const fresh = !existsSync62(join68(dir, ".git"));
|
|
38218
|
+
if (existsSync62(dir) && fresh && readdirSync22(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
38093
38219
|
if (dryRun) {
|
|
38094
38220
|
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`);
|
|
38095
38221
|
break;
|
|
38096
38222
|
}
|
|
38097
38223
|
if (fresh) {
|
|
38098
38224
|
mkdirSync44(dir, { recursive: true });
|
|
38099
|
-
|
|
38100
|
-
|
|
38225
|
+
writeFileSync47(join68(dir, "README.md"), SAMPLE_README);
|
|
38226
|
+
writeFileSync47(join68(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
38101
38227
|
const g = (...a) => {
|
|
38102
38228
|
const r = spawnSync15("git", a, { cwd: dir, encoding: "utf8" });
|
|
38103
38229
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -38115,17 +38241,17 @@ ${where.join("\n")}`);
|
|
|
38115
38241
|
spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
|
|
38116
38242
|
});
|
|
38117
38243
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
38118
|
-
if (
|
|
38119
|
-
const raw = JSON.parse(
|
|
38244
|
+
if (existsSync62(resolvedFile)) {
|
|
38245
|
+
const raw = JSON.parse(readFileSync60(resolvedFile, "utf8"));
|
|
38120
38246
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
38121
38247
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
38122
|
-
|
|
38248
|
+
writeFileSync47(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
38123
38249
|
`);
|
|
38124
38250
|
}
|
|
38125
38251
|
}
|
|
38126
38252
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
38127
38253
|
try {
|
|
38128
|
-
|
|
38254
|
+
writeFileSync47(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
38129
38255
|
} catch (e) {
|
|
38130
38256
|
if (e instanceof ReposError) fail2(e.message);
|
|
38131
38257
|
throw e;
|
|
@@ -38560,7 +38686,7 @@ ${where.join("\n")}`);
|
|
|
38560
38686
|
plan,
|
|
38561
38687
|
label,
|
|
38562
38688
|
uid: process.getuid?.() ?? 0,
|
|
38563
|
-
system: plan.mechanism === "systemd" &&
|
|
38689
|
+
system: plan.mechanism === "systemd" && existsSync62(systemUnitPathFor(label)),
|
|
38564
38690
|
stamp: readDaemonStamp(cfg.ship.stateDir)
|
|
38565
38691
|
});
|
|
38566
38692
|
})();
|
|
@@ -38576,7 +38702,7 @@ ${where.join("\n")}`);
|
|
|
38576
38702
|
}
|
|
38577
38703
|
for (const r of repos) {
|
|
38578
38704
|
const remote = r.config.branch.remote;
|
|
38579
|
-
if (
|
|
38705
|
+
if (existsSync62(r.dir)) {
|
|
38580
38706
|
pushAuth.push({
|
|
38581
38707
|
route: c.route,
|
|
38582
38708
|
repo: r.name,
|
|
@@ -38665,7 +38791,7 @@ ${where.join("\n")}`);
|
|
|
38665
38791
|
else passed++;
|
|
38666
38792
|
}
|
|
38667
38793
|
if (staleBundle) problems.push({ severity: "blocker", kind: "stale_bundle", message: staleBundle.message, remedy: "npm run build" });
|
|
38668
|
-
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null,
|
|
38794
|
+
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync62, userInfo2().username);
|
|
38669
38795
|
if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
|
|
38670
38796
|
if (!flag("offline")) {
|
|
38671
38797
|
const shipKind = await doctorShipKind(route2, cfg.ship);
|
|
@@ -38762,7 +38888,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
38762
38888
|
}
|
|
38763
38889
|
try {
|
|
38764
38890
|
const evFile = eventFileFor(cfg.ship.stateDir);
|
|
38765
|
-
const evSize =
|
|
38891
|
+
const evSize = existsSync62(evFile) ? statSync20(evFile).size : 0;
|
|
38766
38892
|
R.line(
|
|
38767
38893
|
evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
|
|
38768
38894
|
` : "events log: ok\n"
|
|
@@ -38773,7 +38899,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
38773
38899
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
38774
38900
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
38775
38901
|
try {
|
|
38776
|
-
return
|
|
38902
|
+
return readFileSync60(p, "utf8");
|
|
38777
38903
|
} catch {
|
|
38778
38904
|
return null;
|
|
38779
38905
|
}
|
|
@@ -38788,7 +38914,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
38788
38914
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
38789
38915
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
38790
38916
|
try {
|
|
38791
|
-
return
|
|
38917
|
+
return readFileSync60(p, "utf8");
|
|
38792
38918
|
} catch {
|
|
38793
38919
|
return null;
|
|
38794
38920
|
}
|
|
@@ -38802,7 +38928,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
38802
38928
|
if (host === "linux" && detectSystemd()) {
|
|
38803
38929
|
const ctl = planDaemonControl(CREW_HOME, host, true);
|
|
38804
38930
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
|
|
38805
|
-
if (ctl.statusCommand && unitPlan.unitPaths.some((p) =>
|
|
38931
|
+
if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync62(p))) {
|
|
38806
38932
|
const st = spawnSync15(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
38807
38933
|
if (!st.error && st.status !== 0) {
|
|
38808
38934
|
R.line("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");
|
|
@@ -38847,7 +38973,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
38847
38973
|
`);
|
|
38848
38974
|
}
|
|
38849
38975
|
}
|
|
38850
|
-
for (const l of interfaceReport(await readForRoute(route2, cfg.ship), { storedMappingKey: route2.resolved?.trackerInterface?.mappingKey, contractAuthored: route2.contractAuthored })) {
|
|
38976
|
+
for (const l of interfaceReport(await readForRoute(route2, cfg.ship), { storedMappingKey: route2.resolved?.trackerInterface?.mappingKey, contractAuthored: route2.contractAuthored, stored: route2.resolved })) {
|
|
38851
38977
|
R.line(`${l.line.startsWith(" ") ? "" : `${l.problem ? "WARN " : ""}`}${l.line}
|
|
38852
38978
|
`);
|
|
38853
38979
|
}
|