@tablation/crew 0.131.0 → 0.132.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +366 -127
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3731,6 +3731,7 @@ var SHIP_KEYS = /* @__PURE__ */ new Set([
|
|
|
3731
3731
|
"periscopeIdleMinutes",
|
|
3732
3732
|
"intelStartupSeconds",
|
|
3733
3733
|
"mapTokenBudget",
|
|
3734
|
+
"noopRunRepeats",
|
|
3734
3735
|
"secretStore",
|
|
3735
3736
|
"env",
|
|
3736
3737
|
"runner",
|
|
@@ -4087,6 +4088,10 @@ Create the first of those:
|
|
|
4087
4088
|
if (!Number.isInteger(mapTokenBudget) || mapTokenBudget < 1) {
|
|
4088
4089
|
missing.add(`ship.mapTokenBudget must be a positive integer (got "${shipRaw.mapTokenBudget}")`);
|
|
4089
4090
|
}
|
|
4091
|
+
const noopRunRepeats = shipRaw.noopRunRepeats === void 0 ? void 0 : Number(shipRaw.noopRunRepeats);
|
|
4092
|
+
if (noopRunRepeats !== void 0 && (!Number.isInteger(noopRunRepeats) || noopRunRepeats < 1)) {
|
|
4093
|
+
missing.add(`ship.noopRunRepeats must be a positive integer (got "${shipRaw.noopRunRepeats}")`);
|
|
4094
|
+
}
|
|
4090
4095
|
const secretStoreRaw = shipRaw.secretStore === void 0 ? "auto" : shipRaw.secretStore;
|
|
4091
4096
|
if (!isSecretStoreMode(secretStoreRaw)) {
|
|
4092
4097
|
missing.add(`ship.secretStore must be one of ${SECRET_STORE_MODES.join(" | ")} (got "${String(shipRaw.secretStore)}")`);
|
|
@@ -4172,6 +4177,7 @@ Create the first of those:
|
|
|
4172
4177
|
periscopeIdleMinutes,
|
|
4173
4178
|
intelStartupSeconds,
|
|
4174
4179
|
mapTokenBudget,
|
|
4180
|
+
...noopRunRepeats !== void 0 ? { noopRunRepeats } : {},
|
|
4175
4181
|
secretStore,
|
|
4176
4182
|
env: parseShipEnv(shipRaw.env)
|
|
4177
4183
|
},
|
|
@@ -11038,6 +11044,17 @@ function sandboxImageFor(state, repo) {
|
|
|
11038
11044
|
function sandboxImageForRun(state, repo, declares) {
|
|
11039
11045
|
return (declares && repo ? sandboxImageFor(state, repo) : null) ?? sandboxImageFor(state, SHIP_SANDBOX_KEY);
|
|
11040
11046
|
}
|
|
11047
|
+
function sandboxImageMissing(state, repo, declares) {
|
|
11048
|
+
return declares && Boolean(repo) && sandboxImageFor(state, repo) === null;
|
|
11049
|
+
}
|
|
11050
|
+
function sandboxMissingItem(repo, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
11051
|
+
return {
|
|
11052
|
+
kind: "sandbox_build_failed",
|
|
11053
|
+
key: sandboxFailedKey(repo),
|
|
11054
|
+
since: nowIso,
|
|
11055
|
+
message: `${repo}: its sandbox image has not been built on this ship, so its tickets are skipped until it is (the build runs between passes; \`crew sandbox build\` forces it)`
|
|
11056
|
+
};
|
|
11057
|
+
}
|
|
11041
11058
|
function sandboxImageStatus(state, plan) {
|
|
11042
11059
|
const s = state[plan.repo];
|
|
11043
11060
|
const current = s?.tags[0];
|
|
@@ -11115,7 +11132,7 @@ async function buildSandboxImage(plan, deps) {
|
|
|
11115
11132
|
state[plan.repo] = { tags: tags.slice(0, KEEP_TAGS) };
|
|
11116
11133
|
writeSandboxState(deps.stateDir, state);
|
|
11117
11134
|
for (const t of dropped) deps.removeImage(t.tag);
|
|
11118
|
-
return { kind: "built", tag: plan.tag, builtLayers };
|
|
11135
|
+
return builtLayers.length === 0 ? { kind: "adopted", tag: plan.tag } : { kind: "built", tag: plan.tag, builtLayers };
|
|
11119
11136
|
}
|
|
11120
11137
|
var sandboxFailedKey = (repo) => `sandbox_build_failed:${repo}`;
|
|
11121
11138
|
function sandboxFailedItem(repo, tag, layer, logPath, nowIso = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
@@ -11136,15 +11153,16 @@ async function sandboxBuildTick(repos, deps, force = false) {
|
|
|
11136
11153
|
deps.clear(sandboxFailedKey(r.name));
|
|
11137
11154
|
continue;
|
|
11138
11155
|
}
|
|
11139
|
-
|
|
11140
|
-
|
|
11156
|
+
const present = !upToDate && deps.hasImage(plan.tag);
|
|
11157
|
+
if (!force && !present && state?.failure?.tag === plan.tag && nowMs - Date.parse(state.failure.at) < SANDBOX_RETRY_AFTER_MS) continue;
|
|
11158
|
+
deps.log(`sandbox image for ${r.name}: ${present ? `found ${plan.tag} in the engine, recording it` : `building ${plan.tag}`}`);
|
|
11141
11159
|
const out = await buildSandboxImage(plan, deps);
|
|
11142
11160
|
if (out.kind === "failed") {
|
|
11143
11161
|
deps.raise(sandboxFailedItem(r.name, out.tag, out.layer, out.logPath));
|
|
11144
11162
|
deps.log(`sandbox image for ${r.name}: build failed at the ${out.layer} layer, log ${out.logPath}`);
|
|
11145
11163
|
} else {
|
|
11146
11164
|
deps.clear(sandboxFailedKey(r.name));
|
|
11147
|
-
deps.log(`sandbox image for ${r.name}: ${out.kind === "built" ? `built ${out.tag}` : `${out.tag} already built`}`);
|
|
11165
|
+
deps.log(`sandbox image for ${r.name}: ${out.kind === "built" ? `built ${out.tag}` : out.kind === "adopted" ? `recorded ${out.tag}` : `${out.tag} already built`}`);
|
|
11148
11166
|
}
|
|
11149
11167
|
return r.name;
|
|
11150
11168
|
}
|
|
@@ -13508,6 +13526,14 @@ git -C "$m" rev-parse --verify --quiet "refs/heads/$base^{commit}" >/dev/null ||
|
|
|
13508
13526
|
git -C "$m" cat-file -e "refs/heads/$base:$path" 2>/dev/null || exit 4
|
|
13509
13527
|
git -C "$m" show "refs/heads/$base:$path"
|
|
13510
13528
|
`;
|
|
13529
|
+
var LIST_SCRIPT = `
|
|
13530
|
+
set -e
|
|
13531
|
+
export GIT_TERMINAL_PROMPT=0
|
|
13532
|
+
m=${VOLUME_ROOT}/"$1"; base="$2"
|
|
13533
|
+
git config --global --add safe.directory '*'
|
|
13534
|
+
git -C "$m" rev-parse --verify --quiet "refs/heads/$base^{commit}" >/dev/null || { echo "the mirror has no branch $base" >&2; exit 3; }
|
|
13535
|
+
git -C "$m" ls-tree -r --name-only "refs/heads/$base"
|
|
13536
|
+
`;
|
|
13511
13537
|
var SandboxCache = class {
|
|
13512
13538
|
s;
|
|
13513
13539
|
exec;
|
|
@@ -13618,6 +13644,11 @@ var SandboxCache = class {
|
|
|
13618
13644
|
throw e;
|
|
13619
13645
|
}
|
|
13620
13646
|
}
|
|
13647
|
+
/** Every file path at the tip of `base` in the mirror (CREW-3010). Throws when the mirror or branch is absent. */
|
|
13648
|
+
async listFiles(repo, base) {
|
|
13649
|
+
const { stdout } = await this.helper(this.s.helperImage, LIST_SCRIPT, [mirrorRelPath(repo), base]);
|
|
13650
|
+
return stdout.split("\n").filter(Boolean);
|
|
13651
|
+
}
|
|
13621
13652
|
/** Mirrors in the volume with their last refresh; empty when the volume does not exist. */
|
|
13622
13653
|
async list() {
|
|
13623
13654
|
try {
|
|
@@ -14342,7 +14373,7 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
14342
14373
|
}
|
|
14343
14374
|
|
|
14344
14375
|
// src/cli.ts
|
|
14345
|
-
import { resolve as resolve7, dirname as dirname35, join as
|
|
14376
|
+
import { resolve as resolve7, dirname as dirname35, join as join57, basename as basename16 } from "path";
|
|
14346
14377
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
14347
14378
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
14348
14379
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
@@ -20157,6 +20188,20 @@ async function readMirrorContract(cache, repo, base) {
|
|
|
20157
20188
|
}
|
|
20158
20189
|
return null;
|
|
20159
20190
|
}
|
|
20191
|
+
async function readMirrorWarmFiles(cache, repo, base, patterns) {
|
|
20192
|
+
if (patterns.length === 0) return {};
|
|
20193
|
+
const res = patterns.map(globToRegExp);
|
|
20194
|
+
const out = {};
|
|
20195
|
+
let total = 0;
|
|
20196
|
+
for (const path of (await cache.listFiles(repo, base)).filter((f) => res.some((re) => re.test(f))).sort()) {
|
|
20197
|
+
const content = await cache.showFile(repo, base, path);
|
|
20198
|
+
if (content === null) continue;
|
|
20199
|
+
total += content.length;
|
|
20200
|
+
if (total > WARM_MAX_BYTES) throw new Error(`sandbox.warm files exceed ${WARM_MAX_BYTES} bytes`);
|
|
20201
|
+
out[path] = content;
|
|
20202
|
+
}
|
|
20203
|
+
return out;
|
|
20204
|
+
}
|
|
20160
20205
|
function noCheckoutReleaseNote(repo, mode) {
|
|
20161
20206
|
if (mode === "external") {
|
|
20162
20207
|
return `${repo}: no checkout on this ship; release.mode "external" repositories are handed off by a ship with a checkout`;
|
|
@@ -22597,7 +22642,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
22597
22642
|
}
|
|
22598
22643
|
|
|
22599
22644
|
// src/cli.ts
|
|
22600
|
-
import { realpathSync as realpathSync3, readFileSync as
|
|
22645
|
+
import { realpathSync as realpathSync3, readFileSync as readFileSync48, existsSync as existsSync52, mkdirSync as mkdirSync40, writeFileSync as writeFileSync40, rmSync as rmSync25, unlinkSync as unlinkSync5, copyFileSync as copyFileSync2, renameSync as renameSync7, statSync as statSync16, readdirSync as readdirSync20 } from "fs";
|
|
22601
22646
|
import { createInterface } from "readline/promises";
|
|
22602
22647
|
|
|
22603
22648
|
// src/periscope-cmd.ts
|
|
@@ -24030,9 +24075,103 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
24030
24075
|
}
|
|
24031
24076
|
|
|
24032
24077
|
// src/daemon.ts
|
|
24033
|
-
import { existsSync as
|
|
24034
|
-
import { join as
|
|
24078
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync38, readFileSync as readFileSync46, readdirSync as readdirSync17, rmSync as rmSync22, statSync as statSync14, writeFileSync as writeFileSync38 } from "fs";
|
|
24079
|
+
import { join as join53 } from "path";
|
|
24035
24080
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
24081
|
+
|
|
24082
|
+
// src/noop-runs.ts
|
|
24083
|
+
import { existsSync as existsSync48, mkdirSync as mkdirSync37, readFileSync as readFileSync45, renameSync as renameSync6, writeFileSync as writeFileSync37 } from "fs";
|
|
24084
|
+
import { join as join52 } from "path";
|
|
24085
|
+
var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
|
|
24086
|
+
var DEFAULT_NOOP_REPEATS = 3;
|
|
24087
|
+
var NOOP_BOUNCED_MARKER = calloutHeader("WARNING", "Runs Changed Nothing");
|
|
24088
|
+
var noopRunsPath = (stateDir) => join52(stateDir, "noop-runs.json");
|
|
24089
|
+
var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
|
|
24090
|
+
function readNoopRuns(stateDir) {
|
|
24091
|
+
try {
|
|
24092
|
+
const v = JSON.parse(readFileSync45(noopRunsPath(stateDir), "utf8"));
|
|
24093
|
+
return v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
24094
|
+
} catch {
|
|
24095
|
+
return {};
|
|
24096
|
+
}
|
|
24097
|
+
}
|
|
24098
|
+
function writeNoopRuns(stateDir, state) {
|
|
24099
|
+
mkdirSync37(stateDir, { recursive: true });
|
|
24100
|
+
const file = noopRunsPath(stateDir);
|
|
24101
|
+
writeFileSync37(`${file}.tmp`, `${JSON.stringify(state, null, 2)}
|
|
24102
|
+
`);
|
|
24103
|
+
renameSync6(`${file}.tmp`, file);
|
|
24104
|
+
}
|
|
24105
|
+
function noopBackedOff(stateDir, recordId, now = Date.now()) {
|
|
24106
|
+
const e = readNoopRuns(stateDir)[recordId];
|
|
24107
|
+
return e !== void 0 && now < e.nextAt;
|
|
24108
|
+
}
|
|
24109
|
+
function recordNoopRun(stateDir, recordId, repeats, now = Date.now()) {
|
|
24110
|
+
const state = readNoopRuns(stateDir);
|
|
24111
|
+
const count = (state[recordId]?.count ?? 0) + 1;
|
|
24112
|
+
const nextAt = now + NOOP_DELAYS_MS[Math.min(count, NOOP_DELAYS_MS.length) - 1];
|
|
24113
|
+
state[recordId] = { count, lastAt: now, nextAt };
|
|
24114
|
+
writeNoopRuns(stateDir, state);
|
|
24115
|
+
return { count, nextAt, bounce: count >= repeats };
|
|
24116
|
+
}
|
|
24117
|
+
function clearNoopRuns(stateDir, recordId) {
|
|
24118
|
+
if (!existsSync48(noopRunsPath(stateDir))) return;
|
|
24119
|
+
const state = readNoopRuns(stateDir);
|
|
24120
|
+
if (!(recordId in state)) return;
|
|
24121
|
+
delete state[recordId];
|
|
24122
|
+
writeNoopRuns(stateDir, state);
|
|
24123
|
+
}
|
|
24124
|
+
function noopAttentionMessage(tag, role, count, nextAt, lastComment2) {
|
|
24125
|
+
const mins = Math.max(1, Math.round((nextAt - Date.now()) / 6e4));
|
|
24126
|
+
return `${tag}: ${role} run ended ${count} time${count === 1 ? "" : "s"} in a row with nothing pushed and no hand-off; next attempt in about ${mins} minutes` + (lastComment2 ? `. Its last comment: ${lastComment2.slice(0, 300)}` : "");
|
|
24127
|
+
}
|
|
24128
|
+
function noopBounceComment(count, lastComment2) {
|
|
24129
|
+
return `${NOOP_BOUNCED_MARKER}
|
|
24130
|
+
|
|
24131
|
+
${count} consecutive runs of this ticket ended with nothing pushed and no hand-off, so the crew stopped retrying and released its hold. ` + (lastComment2 ? `The agent's last comment:
|
|
24132
|
+
|
|
24133
|
+
${lastComment2}
|
|
24134
|
+
|
|
24135
|
+
` : "") + "Needs a person to read this, fix what stopped the run, and set the status back to `accepted` or `in_progress`.";
|
|
24136
|
+
}
|
|
24137
|
+
async function settleNoopRun(o) {
|
|
24138
|
+
const tag = o.before.issue_tag ?? o.before.issue_id;
|
|
24139
|
+
const after = await o.tracker.ticket(o.ticketId);
|
|
24140
|
+
const noop = o.before[o.columns.status] === o.statuses.building && after[o.columns.status] === o.before[o.columns.status] && after[o.columns.assignee] === o.before[o.columns.assignee] && o.tipBefore === o.tipAfter;
|
|
24141
|
+
if (!noop) {
|
|
24142
|
+
clearNoopRuns(o.stateDir, o.ticketId);
|
|
24143
|
+
o.clear(noopRunsKey(o.before.issue_id));
|
|
24144
|
+
return "progress";
|
|
24145
|
+
}
|
|
24146
|
+
const verdict = recordNoopRun(o.stateDir, o.ticketId, o.repeats, o.now);
|
|
24147
|
+
let last = null;
|
|
24148
|
+
try {
|
|
24149
|
+
const mine = (await o.tracker.comments()).filter((c) => c.ticket_id === o.ticketId && c.team_member_id === o.memberId && c.created_at >= o.runStart && c.body).sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
24150
|
+
last = mine.at(-1)?.body ?? null;
|
|
24151
|
+
} catch {
|
|
24152
|
+
}
|
|
24153
|
+
if (!verdict.bounce) {
|
|
24154
|
+
await o.raise({
|
|
24155
|
+
kind: "noop_runs",
|
|
24156
|
+
key: noopRunsKey(o.before.issue_id),
|
|
24157
|
+
since: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24158
|
+
message: noopAttentionMessage(tag, o.role, verdict.count, verdict.nextAt, last)
|
|
24159
|
+
});
|
|
24160
|
+
return "backoff";
|
|
24161
|
+
}
|
|
24162
|
+
const affinity = await o.tracker.claimAffinity();
|
|
24163
|
+
await o.tracker.updateTicket(o.ticketId, {
|
|
24164
|
+
[o.columns.status]: o.statuses.needsHuman,
|
|
24165
|
+
...o.operatorId ? { [o.columns.assignee]: o.operatorId } : {},
|
|
24166
|
+
...affinity ? { [affinity.column]: null } : {}
|
|
24167
|
+
}, after.updated_at);
|
|
24168
|
+
if (o.memberId) await o.tracker.postEvent(o.ticketId, noopBounceComment(verdict.count, last), o.memberId, "noop_bounced").catch(() => void 0);
|
|
24169
|
+
clearNoopRuns(o.stateDir, o.ticketId);
|
|
24170
|
+
o.clear(noopRunsKey(o.before.issue_id));
|
|
24171
|
+
return "bounced";
|
|
24172
|
+
}
|
|
24173
|
+
|
|
24174
|
+
// src/daemon.ts
|
|
24036
24175
|
var DEFAULT_FLOOR_MS = 5e3;
|
|
24037
24176
|
var DEFAULT_CEILING_MS = INTERVAL_SECONDS * 1e3;
|
|
24038
24177
|
var ALLOWANCE_PAUSE_MS = 5 * 60 * 1e3;
|
|
@@ -24119,7 +24258,7 @@ function latestMtime(path) {
|
|
|
24119
24258
|
if (!stat2.isDirectory()) return 0;
|
|
24120
24259
|
let latest = stat2.mtimeMs;
|
|
24121
24260
|
for (const entry of readdirSync17(path, { withFileTypes: true })) {
|
|
24122
|
-
latest = Math.max(latest, latestMtime(
|
|
24261
|
+
latest = Math.max(latest, latestMtime(join53(path, entry.name)));
|
|
24123
24262
|
}
|
|
24124
24263
|
return latest;
|
|
24125
24264
|
}
|
|
@@ -24128,10 +24267,10 @@ function computeTreeSignature(paths) {
|
|
|
24128
24267
|
}
|
|
24129
24268
|
function makeStaleChecker(paths, opts = {}) {
|
|
24130
24269
|
const initial = computeTreeSignature(paths);
|
|
24131
|
-
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 &&
|
|
24270
|
+
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync49(opts.reloadSentinel);
|
|
24132
24271
|
}
|
|
24133
24272
|
function reloadSentinelFor(stateDir) {
|
|
24134
|
-
return
|
|
24273
|
+
return join53(stateDir, "reload-requested");
|
|
24135
24274
|
}
|
|
24136
24275
|
function readReloadRequestedAt(stateDir) {
|
|
24137
24276
|
try {
|
|
@@ -24141,17 +24280,17 @@ function readReloadRequestedAt(stateDir) {
|
|
|
24141
24280
|
}
|
|
24142
24281
|
}
|
|
24143
24282
|
function daemonStampFor(stateDir) {
|
|
24144
|
-
return
|
|
24283
|
+
return join53(stateDir, "daemon.started");
|
|
24145
24284
|
}
|
|
24146
24285
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
24147
|
-
|
|
24286
|
+
mkdirSync38(stateDir, { recursive: true });
|
|
24148
24287
|
rmSync22(reloadSentinelFor(stateDir), { force: true });
|
|
24149
|
-
|
|
24288
|
+
writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
24150
24289
|
`);
|
|
24151
24290
|
}
|
|
24152
24291
|
function readDaemonStarted(stateDir) {
|
|
24153
24292
|
try {
|
|
24154
|
-
const v = JSON.parse(
|
|
24293
|
+
const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
24155
24294
|
return typeof v === "number" ? v : null;
|
|
24156
24295
|
} catch {
|
|
24157
24296
|
return null;
|
|
@@ -24514,6 +24653,61 @@ async function postRunKilled(route2, tracker, ticketId, memberId, limitMinutes,
|
|
|
24514
24653
|
emit.warn(`could not post the wall-clock limit comment: ${e.message}`, { step: "agent" });
|
|
24515
24654
|
}
|
|
24516
24655
|
}
|
|
24656
|
+
function declaresSandbox(dir) {
|
|
24657
|
+
try {
|
|
24658
|
+
return Boolean(loadRepoConfigTolerant(dir)?.sandbox);
|
|
24659
|
+
} catch {
|
|
24660
|
+
return false;
|
|
24661
|
+
}
|
|
24662
|
+
}
|
|
24663
|
+
async function skipUnrunnable(candidates2, ctx) {
|
|
24664
|
+
const { route: route2, ship, emit } = ctx;
|
|
24665
|
+
const backedOff = [];
|
|
24666
|
+
const noImage = /* @__PURE__ */ new Set();
|
|
24667
|
+
const imageSkipped = [];
|
|
24668
|
+
const state = ship.runner === "sandbox" ? readSandboxState(ship.stateDir) : null;
|
|
24669
|
+
const out = candidates2.filter((t) => {
|
|
24670
|
+
if (noopBackedOff(ship.stateDir, t.id)) {
|
|
24671
|
+
backedOff.push(t.issue_id);
|
|
24672
|
+
return false;
|
|
24673
|
+
}
|
|
24674
|
+
const target = repoTargetFor(route2, t.repo_id);
|
|
24675
|
+
if (state && target && sandboxImageMissing(state, target.name, declaresSandbox(target.dir))) {
|
|
24676
|
+
noImage.add(target.name);
|
|
24677
|
+
imageSkipped.push(t.issue_id);
|
|
24678
|
+
return false;
|
|
24679
|
+
}
|
|
24680
|
+
return true;
|
|
24681
|
+
});
|
|
24682
|
+
if (backedOff.length) emit.emit(`skipped ${backedOff.join(", ")} \u2014 recent runs changed nothing, backing off`, { step: "select" });
|
|
24683
|
+
if (imageSkipped.length) emit.emit(`skipped ${imageSkipped.join(", ")} \u2014 the sandbox image for their repo is not built yet`, { step: "select" });
|
|
24684
|
+
for (const repo of noImage) {
|
|
24685
|
+
if (openShipAttention(ctx.state).some((i) => i.key === sandboxFailedKey(repo))) continue;
|
|
24686
|
+
try {
|
|
24687
|
+
await raiseShipAttention({ state: ctx.state, emit, route: route2, ship }, sandboxMissingItem(repo));
|
|
24688
|
+
} catch {
|
|
24689
|
+
}
|
|
24690
|
+
}
|
|
24691
|
+
return out;
|
|
24692
|
+
}
|
|
24693
|
+
function branchProgress(route2, t) {
|
|
24694
|
+
try {
|
|
24695
|
+
const target = repoTargetFor(route2, t.repo_id);
|
|
24696
|
+
if (!target) return "";
|
|
24697
|
+
const num2 = String(t.issue_id).replace(/^\D+/, "");
|
|
24698
|
+
const origin = originBranchSha(target.dir, t, resolve3) ?? "";
|
|
24699
|
+
const wt = worktreeForNumber(target.dir, num2);
|
|
24700
|
+
let local = "";
|
|
24701
|
+
if (wt) {
|
|
24702
|
+
const o = route2.repoOverrides[target.name];
|
|
24703
|
+
const base = resolveRepoConfig(loadRepoConfigTolerant(target.dir), { hooks: {}, labels: {}, branch: { ...route2.branch, ...o?.branch }, worktrees: {} }, target.dir).branch.base;
|
|
24704
|
+
if (countCommits(wt.path, `origin/${base}..HEAD`) > 0) local = (resolve3(wt.path, "HEAD") ?? "").slice(0, 7);
|
|
24705
|
+
}
|
|
24706
|
+
return `${origin}|${local}`;
|
|
24707
|
+
} catch {
|
|
24708
|
+
return "";
|
|
24709
|
+
}
|
|
24710
|
+
}
|
|
24517
24711
|
async function runRoleAgent(role, decision, ctx, hooks) {
|
|
24518
24712
|
const held = {};
|
|
24519
24713
|
try {
|
|
@@ -24559,9 +24753,10 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24559
24753
|
const candidates2 = rankedCandidates(role, decision.selectionInput);
|
|
24560
24754
|
const contract = decision.selectionInput.contract ?? DEFAULT_CONTRACT;
|
|
24561
24755
|
await refreshUnknownRepos({ route: route2, stateDir: ship.stateDir, fetchRows: () => tracker.repoRowsForMap(), tickets: candidates2 });
|
|
24756
|
+
const runnable = await skipUnrunnable(candidates2, ctx);
|
|
24562
24757
|
const result = await resolveTopCandidate(
|
|
24563
24758
|
tracker,
|
|
24564
|
-
|
|
24759
|
+
runnable,
|
|
24565
24760
|
seat,
|
|
24566
24761
|
claimStatuses(role, contract).approved,
|
|
24567
24762
|
claimStatuses(role, contract).building,
|
|
@@ -24687,10 +24882,33 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24687
24882
|
try {
|
|
24688
24883
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
24689
24884
|
let hintMoved;
|
|
24885
|
+
let settleNoop;
|
|
24690
24886
|
if (workingId) {
|
|
24691
24887
|
try {
|
|
24692
24888
|
const before = await tracker.ticket(workingId);
|
|
24693
24889
|
const col = tracker.contract.columns;
|
|
24890
|
+
const tipBefore = branchProgress(route2, before);
|
|
24891
|
+
if (role === "dev" || role === "design") {
|
|
24892
|
+
settleNoop = async () => {
|
|
24893
|
+
await settleNoopRun({
|
|
24894
|
+
tracker,
|
|
24895
|
+
stateDir: ship.stateDir,
|
|
24896
|
+
role,
|
|
24897
|
+
ticketId: workingId,
|
|
24898
|
+
before,
|
|
24899
|
+
tipBefore,
|
|
24900
|
+
tipAfter: branchProgress(route2, before),
|
|
24901
|
+
runStart,
|
|
24902
|
+
memberId,
|
|
24903
|
+
operatorId: route2.resolved?.operator,
|
|
24904
|
+
columns: { status: col.status, assignee: col.assignee },
|
|
24905
|
+
statuses: { building: tracker.contract.statuses.building, needsHuman: tracker.contract.statuses.needsHuman },
|
|
24906
|
+
repeats: ship.noopRunRepeats ?? DEFAULT_NOOP_REPEATS,
|
|
24907
|
+
raise: (item) => raiseShipAttention({ state: ctx.state, emit, route: route2, ship }, item),
|
|
24908
|
+
clear: (key) => clearShipAttention(ctx.state, key)
|
|
24909
|
+
});
|
|
24910
|
+
};
|
|
24911
|
+
}
|
|
24694
24912
|
hintMoved = async () => {
|
|
24695
24913
|
const after = await tracker.ticket(workingId);
|
|
24696
24914
|
return after[col.status] !== before[col.status] || after[col.assignee] !== before[col.assignee];
|
|
@@ -24707,6 +24925,13 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24707
24925
|
throw new WorkspaceAllowanceExhausted("the inference endpoint refused the run: the workspace is past its AI allowance");
|
|
24708
24926
|
}
|
|
24709
24927
|
await settleSignOut(plan, tracker, ctx.state, workingId, emit);
|
|
24928
|
+
if (settleNoop) {
|
|
24929
|
+
try {
|
|
24930
|
+
await settleNoop();
|
|
24931
|
+
} catch (e) {
|
|
24932
|
+
emit.warn(`could not settle a no-op run: ${e.message}`, { step: "agent" });
|
|
24933
|
+
}
|
|
24934
|
+
}
|
|
24710
24935
|
}
|
|
24711
24936
|
} finally {
|
|
24712
24937
|
await settleRunEnd({
|
|
@@ -24769,7 +24994,7 @@ import { createHash as createHash11 } from "crypto";
|
|
|
24769
24994
|
import {
|
|
24770
24995
|
chmodSync as chmodSync4,
|
|
24771
24996
|
closeSync as closeSync6,
|
|
24772
|
-
existsSync as
|
|
24997
|
+
existsSync as existsSync50,
|
|
24773
24998
|
fstatSync,
|
|
24774
24999
|
openSync as openSync6,
|
|
24775
25000
|
readSync as readSync3,
|
|
@@ -24780,7 +25005,7 @@ import {
|
|
|
24780
25005
|
} from "fs";
|
|
24781
25006
|
import { createConnection } from "net";
|
|
24782
25007
|
import { createServer as createServer2 } from "http";
|
|
24783
|
-
import { basename as basename14, dirname as dirname33, join as
|
|
25008
|
+
import { basename as basename14, dirname as dirname33, join as join54 } from "path";
|
|
24784
25009
|
import { execFile as execFile5, spawn as spawn12 } from "child_process";
|
|
24785
25010
|
|
|
24786
25011
|
// src/periscope-control.ts
|
|
@@ -25009,7 +25234,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
25009
25234
|
// src/control-api.ts
|
|
25010
25235
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
25011
25236
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
25012
|
-
var controlSocketFor = (stateDir) =>
|
|
25237
|
+
var controlSocketFor = (stateDir) => join54(stateDir, CONTROL_SOCKET_NAME);
|
|
25013
25238
|
var MAX_SOCKET_PATH = 100;
|
|
25014
25239
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
25015
25240
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -25096,7 +25321,7 @@ function candidates(live, rotated) {
|
|
|
25096
25321
|
const out = [live];
|
|
25097
25322
|
if (!rotated) return out;
|
|
25098
25323
|
try {
|
|
25099
|
-
for (const n of readdirSync18(dirname33(live))) if (ROTATED_EVENTS_RE.test(n)) out.push(
|
|
25324
|
+
for (const n of readdirSync18(dirname33(live))) if (ROTATED_EVENTS_RE.test(n)) out.push(join54(dirname33(live), n));
|
|
25100
25325
|
} catch {
|
|
25101
25326
|
}
|
|
25102
25327
|
return out;
|
|
@@ -25140,7 +25365,7 @@ function lastLines2(path, n) {
|
|
|
25140
25365
|
}
|
|
25141
25366
|
function readTail(live, opts) {
|
|
25142
25367
|
const max = opts.maxBytes ?? MAX_TAIL_BYTES;
|
|
25143
|
-
if (!
|
|
25368
|
+
if (!existsSync50(live)) {
|
|
25144
25369
|
return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
|
|
25145
25370
|
}
|
|
25146
25371
|
const cur = opts.after ? decodeCursor(opts.after) : null;
|
|
@@ -25296,8 +25521,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
25296
25521
|
if (p.startsWith("/streams/") && get2) {
|
|
25297
25522
|
const run3 = decodeURIComponent(p.slice("/streams/".length));
|
|
25298
25523
|
if (!RUN_NAME_RE.test(run3) || run3.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run3)) return err2(400, "not a run name");
|
|
25299
|
-
const file =
|
|
25300
|
-
if (!
|
|
25524
|
+
const file = join54(deps.stateDir, "streams", run3.endsWith(".jsonl") ? run3 : `${run3}.jsonl`);
|
|
25525
|
+
if (!existsSync50(file)) return err2(404, "no such run");
|
|
25301
25526
|
return tailReply(file, url.searchParams, false, abort);
|
|
25302
25527
|
}
|
|
25303
25528
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
@@ -25342,7 +25567,7 @@ function send(res, r) {
|
|
|
25342
25567
|
res.end(body);
|
|
25343
25568
|
}
|
|
25344
25569
|
async function socketIsStale(path) {
|
|
25345
|
-
if (!
|
|
25570
|
+
if (!existsSync50(path)) return false;
|
|
25346
25571
|
return new Promise((resolve8) => {
|
|
25347
25572
|
const c = createConnection(path);
|
|
25348
25573
|
c.once("connect", () => {
|
|
@@ -25361,7 +25586,7 @@ async function startControlServer(deps) {
|
|
|
25361
25586
|
return null;
|
|
25362
25587
|
}
|
|
25363
25588
|
if (await socketIsStale(path)) rmSync23(path, { force: true });
|
|
25364
|
-
else if (
|
|
25589
|
+
else if (existsSync50(path)) {
|
|
25365
25590
|
log(`control API not started: ${path} is in use by another process`);
|
|
25366
25591
|
return null;
|
|
25367
25592
|
}
|
|
@@ -25447,31 +25672,31 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
25447
25672
|
|
|
25448
25673
|
// src/periscope-mcp.ts
|
|
25449
25674
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
25450
|
-
import { basename as basename15, dirname as dirname34, isAbsolute as isAbsolute5, join as
|
|
25675
|
+
import { basename as basename15, dirname as dirname34, isAbsolute as isAbsolute5, join as join56, relative as relative2, resolve as resolve6, sep } from "path";
|
|
25451
25676
|
import { z } from "zod";
|
|
25452
25677
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
25453
25678
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
25454
25679
|
|
|
25455
25680
|
// src/periscope-endpoints.ts
|
|
25456
25681
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
25457
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
25458
|
-
import { join as
|
|
25459
|
-
var secretDir = (stateDir) =>
|
|
25460
|
-
var secretFile = (stateDir, id) =>
|
|
25461
|
-
var endpointDir = (stateDir) =>
|
|
25462
|
-
var endpointFile = (stateDir, id) =>
|
|
25682
|
+
import { chmodSync as chmodSync5, existsSync as existsSync51, mkdirSync as mkdirSync39, readdirSync as readdirSync19, readFileSync as readFileSync47, rmSync as rmSync24, writeFileSync as writeFileSync39 } from "fs";
|
|
25683
|
+
import { join as join55 } from "path";
|
|
25684
|
+
var secretDir = (stateDir) => join55(stateDir, "periscope-mcp");
|
|
25685
|
+
var secretFile = (stateDir, id) => join55(secretDir(stateDir), `${id}.json`);
|
|
25686
|
+
var endpointDir = (stateDir) => join55(stateDir, "periscope-endpoints");
|
|
25687
|
+
var endpointFile = (stateDir, id) => join55(endpointDir(stateDir), `${id}.json`);
|
|
25463
25688
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
25464
|
-
|
|
25689
|
+
mkdirSync39(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
25465
25690
|
const secret = randomBytes3(32).toString("base64url");
|
|
25466
25691
|
const file = secretFile(stateDir, ticketRecordId);
|
|
25467
|
-
|
|
25692
|
+
writeFileSync39(file, `${JSON.stringify({ secret })}
|
|
25468
25693
|
`, { mode: 384 });
|
|
25469
25694
|
chmodSync5(file, 384);
|
|
25470
25695
|
return secret;
|
|
25471
25696
|
}
|
|
25472
25697
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
25473
25698
|
try {
|
|
25474
|
-
const v = JSON.parse(
|
|
25699
|
+
const v = JSON.parse(readFileSync47(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
25475
25700
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
25476
25701
|
} catch {
|
|
25477
25702
|
return void 0;
|
|
@@ -25482,14 +25707,14 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
25482
25707
|
}
|
|
25483
25708
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
25484
25709
|
try {
|
|
25485
|
-
return JSON.parse(
|
|
25710
|
+
return JSON.parse(readFileSync47(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
25486
25711
|
} catch {
|
|
25487
25712
|
return void 0;
|
|
25488
25713
|
}
|
|
25489
25714
|
}
|
|
25490
25715
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
25491
|
-
|
|
25492
|
-
|
|
25716
|
+
mkdirSync39(endpointDir(stateDir), { recursive: true });
|
|
25717
|
+
writeFileSync39(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
25493
25718
|
`);
|
|
25494
25719
|
}
|
|
25495
25720
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
@@ -25497,7 +25722,7 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
|
25497
25722
|
}
|
|
25498
25723
|
function listPeriscopeEndpoints(stateDir) {
|
|
25499
25724
|
const dir = endpointDir(stateDir);
|
|
25500
|
-
if (!
|
|
25725
|
+
if (!existsSync51(dir)) return [];
|
|
25501
25726
|
const out = [];
|
|
25502
25727
|
for (const name of readdirSync19(dir)) {
|
|
25503
25728
|
if (!name.endsWith(".json")) continue;
|
|
@@ -25600,13 +25825,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
25600
25825
|
let abs;
|
|
25601
25826
|
if (isAbsolute5(requested)) {
|
|
25602
25827
|
abs = resolve6(requested);
|
|
25603
|
-
if (isInside(root, abs)) abs =
|
|
25828
|
+
if (isInside(root, abs)) abs = join56(realRoot, relative2(root, abs));
|
|
25604
25829
|
} else {
|
|
25605
25830
|
abs = resolve6(realRoot, requested);
|
|
25606
25831
|
}
|
|
25607
25832
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
25608
25833
|
const { real, rest } = await realAncestor(abs);
|
|
25609
|
-
const final = rest ?
|
|
25834
|
+
const final = rest ? join56(real, rest) : real;
|
|
25610
25835
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
25611
25836
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
25612
25837
|
return final;
|
|
@@ -25674,7 +25899,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
25674
25899
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
25675
25900
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
25676
25901
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
25677
|
-
const size = (await lstat(
|
|
25902
|
+
const size = (await lstat(join56(abs, e.name))).size;
|
|
25678
25903
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
25679
25904
|
}));
|
|
25680
25905
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -25740,7 +25965,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
25740
25965
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
25741
25966
|
}, async ({ path }) => {
|
|
25742
25967
|
const parent = await inTree(dirname34(path) === "" ? "." : dirname34(path));
|
|
25743
|
-
const abs =
|
|
25968
|
+
const abs = join56(parent, basename15(path));
|
|
25744
25969
|
if (basename15(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
25745
25970
|
const st = await lstat(abs).catch(() => void 0);
|
|
25746
25971
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -26231,7 +26456,7 @@ if (command === "provision") {
|
|
|
26231
26456
|
process.exit(outcome.code);
|
|
26232
26457
|
}
|
|
26233
26458
|
if (command === "pool-member") {
|
|
26234
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
26459
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync48(0, "utf8"));
|
|
26235
26460
|
if (typeof pool === "string") {
|
|
26236
26461
|
process.stderr.write(`crew pool-member: ${pool}
|
|
26237
26462
|
`);
|
|
@@ -26480,7 +26705,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26480
26705
|
} else {
|
|
26481
26706
|
const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
|
|
26482
26707
|
const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
|
|
26483
|
-
if (configless && !
|
|
26708
|
+
if (configless && !existsSync52(findConfigFile(CREW_HOME))) {
|
|
26484
26709
|
cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
|
|
26485
26710
|
} else {
|
|
26486
26711
|
cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
|
|
@@ -26495,7 +26720,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26495
26720
|
throw e;
|
|
26496
26721
|
}
|
|
26497
26722
|
if (command === "credential") {
|
|
26498
|
-
const r = runCredential(positional[1],
|
|
26723
|
+
const r = runCredential(positional[1], readFileSync48(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
|
|
26499
26724
|
process.stdout.write(r.out);
|
|
26500
26725
|
process.stderr.write(r.err);
|
|
26501
26726
|
process.exit(r.code);
|
|
@@ -26507,9 +26732,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
26507
26732
|
forges: cfg.ship.forges,
|
|
26508
26733
|
stateDir: cfg.ship.stateDir,
|
|
26509
26734
|
configFile: cfg.configFile,
|
|
26510
|
-
readFile: (p) =>
|
|
26511
|
-
writeFile: (p, t) =>
|
|
26512
|
-
stdin: () =>
|
|
26735
|
+
readFile: (p) => readFileSync48(p, "utf8"),
|
|
26736
|
+
writeFile: (p, t) => writeFileSync40(p, t),
|
|
26737
|
+
stdin: () => readFileSync48(0, "utf8"),
|
|
26513
26738
|
env: process.env
|
|
26514
26739
|
}
|
|
26515
26740
|
);
|
|
@@ -26832,8 +27057,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
26832
27057
|
}
|
|
26833
27058
|
if (host === "linux" && hasSystemd) {
|
|
26834
27059
|
const label = labelFor(CREW_HOME, "run");
|
|
26835
|
-
const staleTimer =
|
|
26836
|
-
if (
|
|
27060
|
+
const staleTimer = join57(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
27061
|
+
if (existsSync52(staleTimer)) {
|
|
26837
27062
|
process.stdout.write(
|
|
26838
27063
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
26839
27064
|
`
|
|
@@ -26862,7 +27087,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26862
27087
|
const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26863
27088
|
for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
|
|
26864
27089
|
for (const r of doctorRepos) {
|
|
26865
|
-
if (!
|
|
27090
|
+
if (!existsSync52(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
|
|
26866
27091
|
if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
|
|
26867
27092
|
readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
|
|
26868
27093
|
}
|
|
@@ -26889,7 +27114,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26889
27114
|
}
|
|
26890
27115
|
async function doctorFix(o) {
|
|
26891
27116
|
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))));
|
|
26892
|
-
const unitExists = (p) =>
|
|
27117
|
+
const unitExists = (p) => existsSync52(p);
|
|
26893
27118
|
const crontab = o.host === "linux" ? spawnSync12("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
|
|
26894
27119
|
const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
|
|
26895
27120
|
const plan = planFix({ routes, schedulerAbsent, host: o.host });
|
|
@@ -26906,7 +27131,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26906
27131
|
for (const a of plan.actions) {
|
|
26907
27132
|
if (a.kind === "enable") {
|
|
26908
27133
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
26909
|
-
|
|
27134
|
+
writeFileSync40(cfg.configFile, planEnable(readFileSync48(cfg.configFile, "utf8"), a.route));
|
|
26910
27135
|
enabledSound.add(a.route);
|
|
26911
27136
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
26912
27137
|
} else {
|
|
@@ -26942,10 +27167,24 @@ ${changed2.map((c) => ` - ${c}
|
|
|
26942
27167
|
for (const c of routes) {
|
|
26943
27168
|
const { settled } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26944
27169
|
for (const r of settled) if (r.config.sandbox && !out.has(r.name)) {
|
|
27170
|
+
const patterns = r.config.sandbox.warm ?? [];
|
|
27171
|
+
const base = r.config.branch.base;
|
|
26945
27172
|
let warm = {};
|
|
27173
|
+
const target = reposOf(c).find((t) => t.name === r.name);
|
|
27174
|
+
const noCheckout = lacksCheckout(cfg.ship, r.dir);
|
|
27175
|
+
const mirror = target && noCheckout ? mirrorRepoOfTarget(target) : null;
|
|
27176
|
+
const settings = cfg.ship.runner === "sandbox" ? cacheSettingsOf(cfg.ship.sandbox) : null;
|
|
27177
|
+
const source = mirror ? `the mirror of ${mirror.host}/${mirror.path} at ${base}` : `${r.dir} at ${r.config.branch.remote}/${base}`;
|
|
27178
|
+
let failure = "";
|
|
26946
27179
|
try {
|
|
26947
|
-
warm =
|
|
26948
|
-
|
|
27180
|
+
if (mirror && settings) warm = await readMirrorWarmFiles(new SandboxCache(settings), mirror, base, patterns);
|
|
27181
|
+
else if (!noCheckout) warm = readWarmFiles(r.dir, `${r.config.branch.remote}/${base}`, patterns);
|
|
27182
|
+
else failure = "no checkout and no mirror to read";
|
|
27183
|
+
} catch (e) {
|
|
27184
|
+
failure = e instanceof Error ? e.message.split("\n")[0] : String(e);
|
|
27185
|
+
}
|
|
27186
|
+
if (patterns.length > 0 && Object.keys(warm).length === 0 && firstReport(`warm-empty:${r.name}:${failure}`)) {
|
|
27187
|
+
emit.emit(`${r.name}: sandbox.warm declares ${patterns.join(", ")} but no file could be read from ${source}${failure ? ` (${failure})` : ""}; the image is built without warm files`);
|
|
26949
27188
|
}
|
|
26950
27189
|
out.set(r.name, { name: r.name, decl: intelFlavor(r.config.hooks.intel) === "serena" ? { ...r.config.sandbox, intel: "serena" } : r.config.sandbox, warm, ...wantsCodeBridge(r.config.hooks.intel) ? { bridge: readBridgeBundle() } : {} });
|
|
26951
27190
|
}
|
|
@@ -27117,7 +27356,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
27117
27356
|
harnessBin: "claude",
|
|
27118
27357
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
27119
27358
|
},
|
|
27120
|
-
policyFile:
|
|
27359
|
+
policyFile: join57(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
27121
27360
|
repo: mirror,
|
|
27122
27361
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
27123
27362
|
base: effective.branch.base,
|
|
@@ -28214,7 +28453,7 @@ ${cu.tail.trimEnd()}
|
|
|
28214
28453
|
);
|
|
28215
28454
|
process.exit(1);
|
|
28216
28455
|
}
|
|
28217
|
-
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [
|
|
28456
|
+
const watchPaths = isCompiledBinary(import.meta.url) ? [process.execPath] : [join57(CREW_HOME, "src"), join57(CREW_HOME, "dist"), join57(CREW_HOME, "bin")];
|
|
28218
28457
|
const configPaths = daemonConfigPaths(cfg);
|
|
28219
28458
|
watchPaths.push(...configPaths);
|
|
28220
28459
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -28526,10 +28765,10 @@ ${cu.tail.trimEnd()}
|
|
|
28526
28765
|
`);
|
|
28527
28766
|
if (!dryRun) {
|
|
28528
28767
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
28529
|
-
const raw =
|
|
28768
|
+
const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
|
|
28530
28769
|
raw.agentSkills = result.agentSkills;
|
|
28531
|
-
|
|
28532
|
-
|
|
28770
|
+
mkdirSync40(dirOf2(resolvedPath), { recursive: true });
|
|
28771
|
+
writeFileSync40(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
28533
28772
|
`);
|
|
28534
28773
|
}
|
|
28535
28774
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -28552,7 +28791,7 @@ ${cu.tail.trimEnd()}
|
|
|
28552
28791
|
throw e;
|
|
28553
28792
|
}
|
|
28554
28793
|
const oldName = cfg.ship.name;
|
|
28555
|
-
|
|
28794
|
+
writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), newName));
|
|
28556
28795
|
cfg.ship.name = newName;
|
|
28557
28796
|
let renameMachineId;
|
|
28558
28797
|
try {
|
|
@@ -28599,7 +28838,7 @@ ${cu.tail.trimEnd()}
|
|
|
28599
28838
|
process.exit(2);
|
|
28600
28839
|
};
|
|
28601
28840
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
28602
|
-
const configText =
|
|
28841
|
+
const configText = readFileSync48(cfg.configFile, "utf8");
|
|
28603
28842
|
if (sub === "check") {
|
|
28604
28843
|
try {
|
|
28605
28844
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -28631,8 +28870,8 @@ ${cu.tail.trimEnd()}
|
|
|
28631
28870
|
try {
|
|
28632
28871
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
28633
28872
|
const dir = repoDirOf(configText, dirname35(cfg.configFile), a.route, a.name);
|
|
28634
|
-
if (!
|
|
28635
|
-
const files = { exists: (r) =>
|
|
28873
|
+
if (!existsSync52(dir)) throw new ReposError(`${dir} does not exist on disk`);
|
|
28874
|
+
const files = { exists: (r) => existsSync52(resolvePath(dir, r)), list: (r) => {
|
|
28636
28875
|
try {
|
|
28637
28876
|
return readdirSync20(resolvePath(dir, r));
|
|
28638
28877
|
} catch {
|
|
@@ -28640,7 +28879,7 @@ ${cu.tail.trimEnd()}
|
|
|
28640
28879
|
}
|
|
28641
28880
|
}, read: (r) => {
|
|
28642
28881
|
try {
|
|
28643
|
-
return
|
|
28882
|
+
return readFileSync48(resolvePath(dir, r), "utf8");
|
|
28644
28883
|
} catch {
|
|
28645
28884
|
return void 0;
|
|
28646
28885
|
}
|
|
@@ -28682,19 +28921,19 @@ ${cu.tail.trimEnd()}
|
|
|
28682
28921
|
let cleared;
|
|
28683
28922
|
if (clear2) {
|
|
28684
28923
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
28685
|
-
if (plan.removed.length > 0)
|
|
28924
|
+
if (plan.removed.length > 0) writeFileSync40(cfg.configFile, plan.text);
|
|
28686
28925
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
28687
28926
|
}
|
|
28688
28927
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
28689
28928
|
if (write === "route") {
|
|
28690
28929
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
28691
|
-
|
|
28930
|
+
writeFileSync40(cfg.configFile, plan.text);
|
|
28692
28931
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
28693
28932
|
} else if (write === "repo") {
|
|
28694
28933
|
const have = existingRepoConfig(files);
|
|
28695
28934
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
28696
28935
|
const file = resolvePath(dir, ".crew.yaml");
|
|
28697
|
-
|
|
28936
|
+
writeFileSync40(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
28698
28937
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
28699
28938
|
}
|
|
28700
28939
|
if (flag("json")) {
|
|
@@ -28750,7 +28989,7 @@ ${cu.tail.trimEnd()}
|
|
|
28750
28989
|
if (sub === "list" && !routeName) usage2();
|
|
28751
28990
|
if (sub === "add") {
|
|
28752
28991
|
try {
|
|
28753
|
-
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) =>
|
|
28992
|
+
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync52(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
|
|
28754
28993
|
routeName = a.route;
|
|
28755
28994
|
addPath = a.path;
|
|
28756
28995
|
addName = a.name;
|
|
@@ -28780,7 +29019,7 @@ ${cu.tail.trimEnd()}
|
|
|
28780
29019
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
|
|
28781
29020
|
if (sub === "list" || sub === "add") {
|
|
28782
29021
|
const liveRoute = cfg.routes.find((r) => r.route === routeName);
|
|
28783
|
-
if (liveRoute?.resolved?.reposModelId &&
|
|
29022
|
+
if (liveRoute?.resolved?.reposModelId && existsSync52(resolvedFile) && !dryRun) {
|
|
28784
29023
|
try {
|
|
28785
29024
|
await hydrateApiKeys([liveRoute]);
|
|
28786
29025
|
persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
|
|
@@ -28789,16 +29028,16 @@ ${cu.tail.trimEnd()}
|
|
|
28789
29028
|
}
|
|
28790
29029
|
}
|
|
28791
29030
|
let resolvedRemotes;
|
|
28792
|
-
if (
|
|
29031
|
+
if (existsSync52(resolvedFile)) {
|
|
28793
29032
|
try {
|
|
28794
|
-
resolvedRemotes = JSON.parse(
|
|
29033
|
+
resolvedRemotes = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
28795
29034
|
} catch {
|
|
28796
29035
|
}
|
|
28797
29036
|
}
|
|
28798
29037
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
28799
29038
|
const text2 = configText;
|
|
28800
29039
|
const base = dirname35(cfg.configFile);
|
|
28801
|
-
const isCheckout = (d) =>
|
|
29040
|
+
const isCheckout = (d) => existsSync52(`${d}/.git`);
|
|
28802
29041
|
try {
|
|
28803
29042
|
if (sub === "list") {
|
|
28804
29043
|
if (flag("json")) {
|
|
@@ -28808,12 +29047,12 @@ ${cu.tail.trimEnd()}
|
|
|
28808
29047
|
base,
|
|
28809
29048
|
resolved: resolvedRemotes,
|
|
28810
29049
|
originOf,
|
|
28811
|
-
exists: (d) =>
|
|
29050
|
+
exists: (d) => existsSync52(d),
|
|
28812
29051
|
isCheckout,
|
|
28813
29052
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
28814
29053
|
try {
|
|
28815
29054
|
const path = resolvePath(d, f);
|
|
28816
|
-
return Object.keys(parseRepoConfig(
|
|
29055
|
+
return Object.keys(parseRepoConfig(readFileSync48(path, "utf8"), path).hooks).length > 0;
|
|
28817
29056
|
} catch {
|
|
28818
29057
|
return false;
|
|
28819
29058
|
}
|
|
@@ -28830,7 +29069,7 @@ ${cu.tail.trimEnd()}
|
|
|
28830
29069
|
for (const r of repos) {
|
|
28831
29070
|
const origin2 = originOf(r.dir);
|
|
28832
29071
|
const row = matchRepoName(origin2, resolvedRemotes);
|
|
28833
|
-
const note = !
|
|
29072
|
+
const note = !existsSync52(r.dir) ? "missing on disk" : row ? `Repos row: ${row}` : `no Repos row matches ${normalizeRemote(origin2) ?? "this checkout (no origin remote)"}`;
|
|
28834
29073
|
process.stdout.write(`${r.name} ${r.dir} ${note}
|
|
28835
29074
|
`);
|
|
28836
29075
|
}
|
|
@@ -28842,9 +29081,9 @@ ${cu.tail.trimEnd()}
|
|
|
28842
29081
|
` : `${human}
|
|
28843
29082
|
`);
|
|
28844
29083
|
const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
|
|
28845
|
-
if (
|
|
29084
|
+
if (existsSync52(plan2.target) && (existsSync52(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
|
|
28846
29085
|
throw new ReposError(
|
|
28847
|
-
|
|
29086
|
+
existsSync52(`${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`
|
|
28848
29087
|
);
|
|
28849
29088
|
}
|
|
28850
29089
|
if (dryRun) {
|
|
@@ -28862,14 +29101,14 @@ ${cu.tail.trimEnd()}
|
|
|
28862
29101
|
throw new ReposError(`${e.message}${authHint}
|
|
28863
29102
|
crew.yaml was not changed`);
|
|
28864
29103
|
}
|
|
28865
|
-
|
|
29104
|
+
writeFileSync40(cfg.configFile, plan2.text);
|
|
28866
29105
|
if (plan2.droppedDir) process.stderr.write(`crew repos: dropped dir: ${plan2.droppedDir} from route ${routeName} \u2014 it is not a checkout (the clone base); checkouts now live under repos:
|
|
28867
29106
|
`);
|
|
28868
29107
|
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}`);
|
|
28869
29108
|
break;
|
|
28870
29109
|
}
|
|
28871
29110
|
const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
|
|
28872
|
-
const top =
|
|
29111
|
+
const top = existsSync52(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
|
|
28873
29112
|
if (!top) throw new ReposError(`${target} is not a git checkout`);
|
|
28874
29113
|
const origin = originOf(top);
|
|
28875
29114
|
const plan = planRepoAdd({
|
|
@@ -28921,15 +29160,15 @@ ${cu.tail.trimEnd()}
|
|
|
28921
29160
|
const created = await rowTracker.createRepoRow(rowPayload);
|
|
28922
29161
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
28923
29162
|
`);
|
|
28924
|
-
if (
|
|
28925
|
-
const raw = JSON.parse(
|
|
29163
|
+
if (existsSync52(resolvedFile)) {
|
|
29164
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
28926
29165
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
28927
29166
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
28928
|
-
|
|
29167
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
28929
29168
|
`);
|
|
28930
29169
|
}
|
|
28931
29170
|
}
|
|
28932
|
-
|
|
29171
|
+
writeFileSync40(cfg.configFile, plan.text);
|
|
28933
29172
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
28934
29173
|
`);
|
|
28935
29174
|
} catch (e) {
|
|
@@ -29304,7 +29543,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29304
29543
|
process.exit(2);
|
|
29305
29544
|
}
|
|
29306
29545
|
if (found.shipNameAdopted && !dryRun) {
|
|
29307
|
-
|
|
29546
|
+
writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
29308
29547
|
cfg.ship.name = found.shipNameAdopted;
|
|
29309
29548
|
}
|
|
29310
29549
|
if (found.shipRow) {
|
|
@@ -29347,10 +29586,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29347
29586
|
}
|
|
29348
29587
|
}
|
|
29349
29588
|
let previous;
|
|
29350
|
-
const hadPreviousFile =
|
|
29589
|
+
const hadPreviousFile = existsSync52(resolvedPath);
|
|
29351
29590
|
if (hadPreviousFile) {
|
|
29352
29591
|
try {
|
|
29353
|
-
previous = JSON.parse(
|
|
29592
|
+
previous = JSON.parse(readFileSync48(resolvedPath, "utf8"));
|
|
29354
29593
|
} catch {
|
|
29355
29594
|
}
|
|
29356
29595
|
}
|
|
@@ -29480,12 +29719,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29480
29719
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
29481
29720
|
`);
|
|
29482
29721
|
} else {
|
|
29483
|
-
|
|
29722
|
+
mkdirSync40(dirname35(resolvedPath), { recursive: true });
|
|
29484
29723
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
29485
29724
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
29486
|
-
|
|
29725
|
+
writeFileSync40(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
29487
29726
|
`);
|
|
29488
|
-
|
|
29727
|
+
renameSync7(tmpPath, resolvedPath);
|
|
29489
29728
|
process.stderr.write(`Resolved ids written to ${resolvedPath}
|
|
29490
29729
|
`);
|
|
29491
29730
|
}
|
|
@@ -29529,8 +29768,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29529
29768
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
29530
29769
|
`);
|
|
29531
29770
|
} else {
|
|
29532
|
-
|
|
29533
|
-
|
|
29771
|
+
mkdirSync40(dirname35(apiKeyFile), { recursive: true });
|
|
29772
|
+
writeFileSync40(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
29534
29773
|
`, { mode: 384 });
|
|
29535
29774
|
process.stderr.write(`API key written to ${apiKeyFile}
|
|
29536
29775
|
`);
|
|
@@ -30245,10 +30484,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
30245
30484
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
30246
30485
|
prepare: async (path) => {
|
|
30247
30486
|
for (const f of repoWt.config.worktrees.copy) {
|
|
30248
|
-
const src =
|
|
30249
|
-
if (!
|
|
30250
|
-
|
|
30251
|
-
copyFileSync2(src,
|
|
30487
|
+
const src = join57(repoWt.dir, f);
|
|
30488
|
+
if (!existsSync52(src) || existsSync52(join57(path, f))) continue;
|
|
30489
|
+
mkdirSync40(dirOf2(join57(path, f)), { recursive: true });
|
|
30490
|
+
copyFileSync2(src, join57(path, f));
|
|
30252
30491
|
}
|
|
30253
30492
|
const setup = repoWt.config.hooks.setup;
|
|
30254
30493
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -30469,7 +30708,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
30469
30708
|
const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
|
|
30470
30709
|
const resumed = await runPeriscopeResume({
|
|
30471
30710
|
find: async () => hit && { row: hit.row, tag: hit.tag },
|
|
30472
|
-
worktreeExists: (p) =>
|
|
30711
|
+
worktreeExists: (p) => existsSync52(p),
|
|
30473
30712
|
prepareDropFile,
|
|
30474
30713
|
startProxy: (wt, url, n) => launchProxy(crewInvocation(CREW_HOME), wt, url, Number(n), { host: hit.row.host || "localhost", inject: hit.repo.config.periscope?.inspector !== "repo" }),
|
|
30475
30714
|
caps: periscopeCaps(cfg.ship),
|
|
@@ -30565,10 +30804,10 @@ ${where.join("\n")}`);
|
|
|
30565
30804
|
},
|
|
30566
30805
|
prepare: async (path) => {
|
|
30567
30806
|
for (const f of repoP.config.worktrees.copy) {
|
|
30568
|
-
const src =
|
|
30569
|
-
if (!
|
|
30570
|
-
|
|
30571
|
-
copyFileSync2(src,
|
|
30807
|
+
const src = join57(repoP.dir, f);
|
|
30808
|
+
if (!existsSync52(src)) continue;
|
|
30809
|
+
mkdirSync40(dirOf2(join57(path, f)), { recursive: true });
|
|
30810
|
+
copyFileSync2(src, join57(path, f));
|
|
30572
30811
|
}
|
|
30573
30812
|
const setup = repoP.config.hooks.setup;
|
|
30574
30813
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -30879,7 +31118,7 @@ ${where.join("\n")}`);
|
|
|
30879
31118
|
};
|
|
30880
31119
|
const droppedRoutes = [];
|
|
30881
31120
|
try {
|
|
30882
|
-
const rawCfg = parseYaml2(
|
|
31121
|
+
const rawCfg = parseYaml2(readFileSync48(cfg.configFile, "utf8"));
|
|
30883
31122
|
for (const r of rawCfg?.routes ?? []) {
|
|
30884
31123
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
30885
31124
|
try {
|
|
@@ -30943,8 +31182,8 @@ ${where.join("\n")}`);
|
|
|
30943
31182
|
process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
|
|
30944
31183
|
break;
|
|
30945
31184
|
}
|
|
30946
|
-
|
|
30947
|
-
|
|
31185
|
+
mkdirSync40(cfg.ship.stateDir, { recursive: true });
|
|
31186
|
+
writeFileSync40(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
30948
31187
|
`);
|
|
30949
31188
|
process.stdout.write(
|
|
30950
31189
|
"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"
|
|
@@ -31009,7 +31248,7 @@ ${where.join("\n")}`);
|
|
|
31009
31248
|
}
|
|
31010
31249
|
case "log": {
|
|
31011
31250
|
try {
|
|
31012
|
-
const text2 =
|
|
31251
|
+
const text2 = readFileSync48(cfg.ship.logFile, "utf8").split("\n");
|
|
31013
31252
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
31014
31253
|
`);
|
|
31015
31254
|
} catch {
|
|
@@ -31032,7 +31271,7 @@ ${where.join("\n")}`);
|
|
|
31032
31271
|
};
|
|
31033
31272
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
31034
31273
|
const tracker = new Tracker(route2, cfg.ship);
|
|
31035
|
-
const configText =
|
|
31274
|
+
const configText = readFileSync48(cfg.configFile, "utf8");
|
|
31036
31275
|
const cfgBase = dirname35(cfg.configFile);
|
|
31037
31276
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
31038
31277
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -31061,7 +31300,7 @@ ${where.join("\n")}`);
|
|
|
31061
31300
|
}
|
|
31062
31301
|
if (configured2.some((r) => r.dir === dir)) {
|
|
31063
31302
|
try {
|
|
31064
|
-
|
|
31303
|
+
writeFileSync40(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
31065
31304
|
} catch (e) {
|
|
31066
31305
|
if (e instanceof ReposError) fail2(e.message);
|
|
31067
31306
|
throw e;
|
|
@@ -31069,29 +31308,29 @@ ${where.join("\n")}`);
|
|
|
31069
31308
|
}
|
|
31070
31309
|
if (row) {
|
|
31071
31310
|
await tracker.deleteRepoRow(row.id);
|
|
31072
|
-
if (
|
|
31073
|
-
const raw = JSON.parse(
|
|
31311
|
+
if (existsSync52(resolvedFile)) {
|
|
31312
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
31074
31313
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
31075
31314
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
31076
|
-
|
|
31315
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31077
31316
|
`);
|
|
31078
31317
|
}
|
|
31079
31318
|
}
|
|
31080
|
-
if (
|
|
31319
|
+
if (existsSync52(join57(dir, ".git")) && basename16(dir) === SAMPLE_REPO) rmSync25(dir, { recursive: true, force: true });
|
|
31081
31320
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
31082
31321
|
break;
|
|
31083
31322
|
}
|
|
31084
31323
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
31085
|
-
const fresh = !
|
|
31086
|
-
if (
|
|
31324
|
+
const fresh = !existsSync52(join57(dir, ".git"));
|
|
31325
|
+
if (existsSync52(dir) && fresh && readdirSync20(dir).length > 0) fail2(`${dir} exists and is not a git checkout \u2014 move it aside`);
|
|
31087
31326
|
if (dryRun) {
|
|
31088
31327
|
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`);
|
|
31089
31328
|
break;
|
|
31090
31329
|
}
|
|
31091
31330
|
if (fresh) {
|
|
31092
|
-
|
|
31093
|
-
|
|
31094
|
-
|
|
31331
|
+
mkdirSync40(dir, { recursive: true });
|
|
31332
|
+
writeFileSync40(join57(dir, "README.md"), SAMPLE_README);
|
|
31333
|
+
writeFileSync40(join57(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
31095
31334
|
const g = (...a) => {
|
|
31096
31335
|
const r = spawnSync12("git", a, { cwd: dir, encoding: "utf8" });
|
|
31097
31336
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -31109,17 +31348,17 @@ ${where.join("\n")}`);
|
|
|
31109
31348
|
spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
|
|
31110
31349
|
});
|
|
31111
31350
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
31112
|
-
if (
|
|
31113
|
-
const raw = JSON.parse(
|
|
31351
|
+
if (existsSync52(resolvedFile)) {
|
|
31352
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
31114
31353
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
31115
31354
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
31116
|
-
|
|
31355
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31117
31356
|
`);
|
|
31118
31357
|
}
|
|
31119
31358
|
}
|
|
31120
31359
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
31121
31360
|
try {
|
|
31122
|
-
|
|
31361
|
+
writeFileSync40(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
31123
31362
|
} catch (e) {
|
|
31124
31363
|
if (e instanceof ReposError) fail2(e.message);
|
|
31125
31364
|
throw e;
|
|
@@ -31465,7 +31704,7 @@ watermark: ${state.watermark()}
|
|
|
31465
31704
|
}
|
|
31466
31705
|
for (const r of repos) {
|
|
31467
31706
|
const remote = r.config.branch.remote;
|
|
31468
|
-
if (
|
|
31707
|
+
if (existsSync52(r.dir)) {
|
|
31469
31708
|
pushAuth.push({
|
|
31470
31709
|
route: c.route,
|
|
31471
31710
|
repo: r.name,
|
|
@@ -31538,7 +31777,7 @@ watermark: ${state.watermark()}
|
|
|
31538
31777
|
}
|
|
31539
31778
|
}
|
|
31540
31779
|
for (const message of roleCapWarnings(cfg.ship)) problems.push({ severity: "note", kind: "role_cap_above_ship_cap", message });
|
|
31541
|
-
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null,
|
|
31780
|
+
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync52, userInfo2().username);
|
|
31542
31781
|
if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
|
|
31543
31782
|
if (!flag("offline")) {
|
|
31544
31783
|
const shipKind = await doctorShipKind(route2, cfg.ship);
|
|
@@ -31599,7 +31838,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31599
31838
|
}
|
|
31600
31839
|
try {
|
|
31601
31840
|
const evFile = eventFileFor(cfg.ship.stateDir);
|
|
31602
|
-
const evSize =
|
|
31841
|
+
const evSize = existsSync52(evFile) ? statSync16(evFile).size : 0;
|
|
31603
31842
|
process.stdout.write(
|
|
31604
31843
|
evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
|
|
31605
31844
|
` : "events log: ok\n"
|
|
@@ -31610,7 +31849,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31610
31849
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
31611
31850
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
31612
31851
|
try {
|
|
31613
|
-
return
|
|
31852
|
+
return readFileSync48(p, "utf8");
|
|
31614
31853
|
} catch {
|
|
31615
31854
|
return null;
|
|
31616
31855
|
}
|
|
@@ -31625,7 +31864,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31625
31864
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
31626
31865
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
31627
31866
|
try {
|
|
31628
|
-
return
|
|
31867
|
+
return readFileSync48(p, "utf8");
|
|
31629
31868
|
} catch {
|
|
31630
31869
|
return null;
|
|
31631
31870
|
}
|
|
@@ -31639,7 +31878,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31639
31878
|
if (host === "linux" && detectSystemd()) {
|
|
31640
31879
|
const ctl = planDaemonControl(CREW_HOME, host, true);
|
|
31641
31880
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
|
|
31642
|
-
if (ctl.statusCommand && unitPlan.unitPaths.some((p) =>
|
|
31881
|
+
if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync52(p))) {
|
|
31643
31882
|
const st = spawnSync12(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
31644
31883
|
if (!st.error && st.status !== 0) {
|
|
31645
31884
|
process.stdout.write("daemon unit: WARN installed but not running \u2014 no work is picked up; run `crew reload` (or `crew daemon start`), and `crew install` if the unit still says Restart=on-failure\n");
|
package/package.json
CHANGED