@tablation/crew 0.131.1 → 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 +323 -125
- 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
|
}
|
|
@@ -14355,7 +14373,7 @@ function doctorSelftestLines(stored, toolchains) {
|
|
|
14355
14373
|
}
|
|
14356
14374
|
|
|
14357
14375
|
// src/cli.ts
|
|
14358
|
-
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";
|
|
14359
14377
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
14360
14378
|
import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
|
|
14361
14379
|
import { spawnSync as spawnSync12 } from "child_process";
|
|
@@ -22624,7 +22642,7 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
|
|
|
22624
22642
|
}
|
|
22625
22643
|
|
|
22626
22644
|
// src/cli.ts
|
|
22627
|
-
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";
|
|
22628
22646
|
import { createInterface } from "readline/promises";
|
|
22629
22647
|
|
|
22630
22648
|
// src/periscope-cmd.ts
|
|
@@ -24057,9 +24075,103 @@ function contractFixers(dir, baseRef, tickets, locate) {
|
|
|
24057
24075
|
}
|
|
24058
24076
|
|
|
24059
24077
|
// src/daemon.ts
|
|
24060
|
-
import { existsSync as
|
|
24061
|
-
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";
|
|
24062
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
|
|
24063
24175
|
var DEFAULT_FLOOR_MS = 5e3;
|
|
24064
24176
|
var DEFAULT_CEILING_MS = INTERVAL_SECONDS * 1e3;
|
|
24065
24177
|
var ALLOWANCE_PAUSE_MS = 5 * 60 * 1e3;
|
|
@@ -24146,7 +24258,7 @@ function latestMtime(path) {
|
|
|
24146
24258
|
if (!stat2.isDirectory()) return 0;
|
|
24147
24259
|
let latest = stat2.mtimeMs;
|
|
24148
24260
|
for (const entry of readdirSync17(path, { withFileTypes: true })) {
|
|
24149
|
-
latest = Math.max(latest, latestMtime(
|
|
24261
|
+
latest = Math.max(latest, latestMtime(join53(path, entry.name)));
|
|
24150
24262
|
}
|
|
24151
24263
|
return latest;
|
|
24152
24264
|
}
|
|
@@ -24155,10 +24267,10 @@ function computeTreeSignature(paths) {
|
|
|
24155
24267
|
}
|
|
24156
24268
|
function makeStaleChecker(paths, opts = {}) {
|
|
24157
24269
|
const initial = computeTreeSignature(paths);
|
|
24158
|
-
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 &&
|
|
24270
|
+
return () => computeTreeSignature(paths) !== initial || opts.reloadSentinel !== void 0 && existsSync49(opts.reloadSentinel);
|
|
24159
24271
|
}
|
|
24160
24272
|
function reloadSentinelFor(stateDir) {
|
|
24161
|
-
return
|
|
24273
|
+
return join53(stateDir, "reload-requested");
|
|
24162
24274
|
}
|
|
24163
24275
|
function readReloadRequestedAt(stateDir) {
|
|
24164
24276
|
try {
|
|
@@ -24168,17 +24280,17 @@ function readReloadRequestedAt(stateDir) {
|
|
|
24168
24280
|
}
|
|
24169
24281
|
}
|
|
24170
24282
|
function daemonStampFor(stateDir) {
|
|
24171
|
-
return
|
|
24283
|
+
return join53(stateDir, "daemon.started");
|
|
24172
24284
|
}
|
|
24173
24285
|
function noteDaemonStarted(stateDir, now = Date.now()) {
|
|
24174
|
-
|
|
24286
|
+
mkdirSync38(stateDir, { recursive: true });
|
|
24175
24287
|
rmSync22(reloadSentinelFor(stateDir), { force: true });
|
|
24176
|
-
|
|
24288
|
+
writeFileSync38(daemonStampFor(stateDir), `${JSON.stringify({ pid: process.pid, startedAt: now })}
|
|
24177
24289
|
`);
|
|
24178
24290
|
}
|
|
24179
24291
|
function readDaemonStarted(stateDir) {
|
|
24180
24292
|
try {
|
|
24181
|
-
const v = JSON.parse(
|
|
24293
|
+
const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
|
|
24182
24294
|
return typeof v === "number" ? v : null;
|
|
24183
24295
|
} catch {
|
|
24184
24296
|
return null;
|
|
@@ -24541,6 +24653,61 @@ async function postRunKilled(route2, tracker, ticketId, memberId, limitMinutes,
|
|
|
24541
24653
|
emit.warn(`could not post the wall-clock limit comment: ${e.message}`, { step: "agent" });
|
|
24542
24654
|
}
|
|
24543
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
|
+
}
|
|
24544
24711
|
async function runRoleAgent(role, decision, ctx, hooks) {
|
|
24545
24712
|
const held = {};
|
|
24546
24713
|
try {
|
|
@@ -24586,9 +24753,10 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24586
24753
|
const candidates2 = rankedCandidates(role, decision.selectionInput);
|
|
24587
24754
|
const contract = decision.selectionInput.contract ?? DEFAULT_CONTRACT;
|
|
24588
24755
|
await refreshUnknownRepos({ route: route2, stateDir: ship.stateDir, fetchRows: () => tracker.repoRowsForMap(), tickets: candidates2 });
|
|
24756
|
+
const runnable = await skipUnrunnable(candidates2, ctx);
|
|
24589
24757
|
const result = await resolveTopCandidate(
|
|
24590
24758
|
tracker,
|
|
24591
|
-
|
|
24759
|
+
runnable,
|
|
24592
24760
|
seat,
|
|
24593
24761
|
claimStatuses(role, contract).approved,
|
|
24594
24762
|
claimStatuses(role, contract).building,
|
|
@@ -24714,10 +24882,33 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24714
24882
|
try {
|
|
24715
24883
|
const runStart = (/* @__PURE__ */ new Date()).toISOString();
|
|
24716
24884
|
let hintMoved;
|
|
24885
|
+
let settleNoop;
|
|
24717
24886
|
if (workingId) {
|
|
24718
24887
|
try {
|
|
24719
24888
|
const before = await tracker.ticket(workingId);
|
|
24720
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
|
+
}
|
|
24721
24912
|
hintMoved = async () => {
|
|
24722
24913
|
const after = await tracker.ticket(workingId);
|
|
24723
24914
|
return after[col.status] !== before[col.status] || after[col.assignee] !== before[col.assignee];
|
|
@@ -24734,6 +24925,13 @@ async function runRoleAgentLocked(role, decision, ctx, hooks, held) {
|
|
|
24734
24925
|
throw new WorkspaceAllowanceExhausted("the inference endpoint refused the run: the workspace is past its AI allowance");
|
|
24735
24926
|
}
|
|
24736
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
|
+
}
|
|
24737
24935
|
}
|
|
24738
24936
|
} finally {
|
|
24739
24937
|
await settleRunEnd({
|
|
@@ -24796,7 +24994,7 @@ import { createHash as createHash11 } from "crypto";
|
|
|
24796
24994
|
import {
|
|
24797
24995
|
chmodSync as chmodSync4,
|
|
24798
24996
|
closeSync as closeSync6,
|
|
24799
|
-
existsSync as
|
|
24997
|
+
existsSync as existsSync50,
|
|
24800
24998
|
fstatSync,
|
|
24801
24999
|
openSync as openSync6,
|
|
24802
25000
|
readSync as readSync3,
|
|
@@ -24807,7 +25005,7 @@ import {
|
|
|
24807
25005
|
} from "fs";
|
|
24808
25006
|
import { createConnection } from "net";
|
|
24809
25007
|
import { createServer as createServer2 } from "http";
|
|
24810
|
-
import { basename as basename14, dirname as dirname33, join as
|
|
25008
|
+
import { basename as basename14, dirname as dirname33, join as join54 } from "path";
|
|
24811
25009
|
import { execFile as execFile5, spawn as spawn12 } from "child_process";
|
|
24812
25010
|
|
|
24813
25011
|
// src/periscope-control.ts
|
|
@@ -25036,7 +25234,7 @@ function runCrew(args, onLine, timeoutMs = 20 * 6e4) {
|
|
|
25036
25234
|
// src/control-api.ts
|
|
25037
25235
|
var PAUSABLE = ["dev", "design", "qa"];
|
|
25038
25236
|
var CONTROL_SOCKET_NAME = "control.sock";
|
|
25039
|
-
var controlSocketFor = (stateDir) =>
|
|
25237
|
+
var controlSocketFor = (stateDir) => join54(stateDir, CONTROL_SOCKET_NAME);
|
|
25040
25238
|
var MAX_SOCKET_PATH = 100;
|
|
25041
25239
|
var MAX_TAIL_BYTES = 1024 * 1024;
|
|
25042
25240
|
var MAX_WAIT_SECONDS = 30;
|
|
@@ -25123,7 +25321,7 @@ function candidates(live, rotated) {
|
|
|
25123
25321
|
const out = [live];
|
|
25124
25322
|
if (!rotated) return out;
|
|
25125
25323
|
try {
|
|
25126
|
-
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));
|
|
25127
25325
|
} catch {
|
|
25128
25326
|
}
|
|
25129
25327
|
return out;
|
|
@@ -25167,7 +25365,7 @@ function lastLines2(path, n) {
|
|
|
25167
25365
|
}
|
|
25168
25366
|
function readTail(live, opts) {
|
|
25169
25367
|
const max = opts.maxBytes ?? MAX_TAIL_BYTES;
|
|
25170
|
-
if (!
|
|
25368
|
+
if (!existsSync50(live)) {
|
|
25171
25369
|
return { lines: [], cursor: opts.after ?? encodeCursor({ dev: 0, ino: 0, off: 0 }), reset: false };
|
|
25172
25370
|
}
|
|
25173
25371
|
const cur = opts.after ? decodeCursor(opts.after) : null;
|
|
@@ -25323,8 +25521,8 @@ async function route(deps, method, url, req, abort) {
|
|
|
25323
25521
|
if (p.startsWith("/streams/") && get2) {
|
|
25324
25522
|
const run3 = decodeURIComponent(p.slice("/streams/".length));
|
|
25325
25523
|
if (!RUN_NAME_RE.test(run3) || run3.includes("..") || /\.(pid|meta\.json|events\.jsonl)$/.test(run3)) return err2(400, "not a run name");
|
|
25326
|
-
const file =
|
|
25327
|
-
if (!
|
|
25524
|
+
const file = join54(deps.stateDir, "streams", run3.endsWith(".jsonl") ? run3 : `${run3}.jsonl`);
|
|
25525
|
+
if (!existsSync50(file)) return err2(404, "no such run");
|
|
25328
25526
|
return tailReply(file, url.searchParams, false, abort);
|
|
25329
25527
|
}
|
|
25330
25528
|
if ((p === "/pause" || p === "/resume") && post3) {
|
|
@@ -25369,7 +25567,7 @@ function send(res, r) {
|
|
|
25369
25567
|
res.end(body);
|
|
25370
25568
|
}
|
|
25371
25569
|
async function socketIsStale(path) {
|
|
25372
|
-
if (!
|
|
25570
|
+
if (!existsSync50(path)) return false;
|
|
25373
25571
|
return new Promise((resolve8) => {
|
|
25374
25572
|
const c = createConnection(path);
|
|
25375
25573
|
c.once("connect", () => {
|
|
@@ -25388,7 +25586,7 @@ async function startControlServer(deps) {
|
|
|
25388
25586
|
return null;
|
|
25389
25587
|
}
|
|
25390
25588
|
if (await socketIsStale(path)) rmSync23(path, { force: true });
|
|
25391
|
-
else if (
|
|
25589
|
+
else if (existsSync50(path)) {
|
|
25392
25590
|
log(`control API not started: ${path} is in use by another process`);
|
|
25393
25591
|
return null;
|
|
25394
25592
|
}
|
|
@@ -25474,31 +25672,31 @@ function crewJson(args, timeoutMs = 6e4) {
|
|
|
25474
25672
|
|
|
25475
25673
|
// src/periscope-mcp.ts
|
|
25476
25674
|
import { lstat, mkdir, readdir, readFile, readlink, realpath, rm, stat, writeFile } from "fs/promises";
|
|
25477
|
-
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";
|
|
25478
25676
|
import { z } from "zod";
|
|
25479
25677
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
25480
25678
|
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
25481
25679
|
|
|
25482
25680
|
// src/periscope-endpoints.ts
|
|
25483
25681
|
import { randomBytes as randomBytes3 } from "crypto";
|
|
25484
|
-
import { chmodSync as chmodSync5, existsSync as
|
|
25485
|
-
import { join as
|
|
25486
|
-
var secretDir = (stateDir) =>
|
|
25487
|
-
var secretFile = (stateDir, id) =>
|
|
25488
|
-
var endpointDir = (stateDir) =>
|
|
25489
|
-
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`);
|
|
25490
25688
|
function mintPeriscopeSecret(stateDir, ticketRecordId) {
|
|
25491
|
-
|
|
25689
|
+
mkdirSync39(secretDir(stateDir), { recursive: true, mode: 448 });
|
|
25492
25690
|
const secret = randomBytes3(32).toString("base64url");
|
|
25493
25691
|
const file = secretFile(stateDir, ticketRecordId);
|
|
25494
|
-
|
|
25692
|
+
writeFileSync39(file, `${JSON.stringify({ secret })}
|
|
25495
25693
|
`, { mode: 384 });
|
|
25496
25694
|
chmodSync5(file, 384);
|
|
25497
25695
|
return secret;
|
|
25498
25696
|
}
|
|
25499
25697
|
function readPeriscopeSecret(stateDir, ticketRecordId) {
|
|
25500
25698
|
try {
|
|
25501
|
-
const v = JSON.parse(
|
|
25699
|
+
const v = JSON.parse(readFileSync47(secretFile(stateDir, ticketRecordId), "utf8"));
|
|
25502
25700
|
return typeof v.secret === "string" && v.secret ? v.secret : void 0;
|
|
25503
25701
|
} catch {
|
|
25504
25702
|
return void 0;
|
|
@@ -25509,14 +25707,14 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
|
|
|
25509
25707
|
}
|
|
25510
25708
|
function readPeriscopeEndpoint(stateDir, ticketRecordId) {
|
|
25511
25709
|
try {
|
|
25512
|
-
return JSON.parse(
|
|
25710
|
+
return JSON.parse(readFileSync47(endpointFile(stateDir, ticketRecordId), "utf8"));
|
|
25513
25711
|
} catch {
|
|
25514
25712
|
return void 0;
|
|
25515
25713
|
}
|
|
25516
25714
|
}
|
|
25517
25715
|
function writePeriscopeEndpoint(stateDir, rec) {
|
|
25518
|
-
|
|
25519
|
-
|
|
25716
|
+
mkdirSync39(endpointDir(stateDir), { recursive: true });
|
|
25717
|
+
writeFileSync39(endpointFile(stateDir, rec.ticketRecordId), `${JSON.stringify(rec, null, 2)}
|
|
25520
25718
|
`);
|
|
25521
25719
|
}
|
|
25522
25720
|
function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
@@ -25524,7 +25722,7 @@ function removePeriscopeEndpointRecord(stateDir, ticketRecordId) {
|
|
|
25524
25722
|
}
|
|
25525
25723
|
function listPeriscopeEndpoints(stateDir) {
|
|
25526
25724
|
const dir = endpointDir(stateDir);
|
|
25527
|
-
if (!
|
|
25725
|
+
if (!existsSync51(dir)) return [];
|
|
25528
25726
|
const out = [];
|
|
25529
25727
|
for (const name of readdirSync19(dir)) {
|
|
25530
25728
|
if (!name.endsWith(".json")) continue;
|
|
@@ -25627,13 +25825,13 @@ async function resolveInWorktree(root, requested) {
|
|
|
25627
25825
|
let abs;
|
|
25628
25826
|
if (isAbsolute5(requested)) {
|
|
25629
25827
|
abs = resolve6(requested);
|
|
25630
|
-
if (isInside(root, abs)) abs =
|
|
25828
|
+
if (isInside(root, abs)) abs = join56(realRoot, relative2(root, abs));
|
|
25631
25829
|
} else {
|
|
25632
25830
|
abs = resolve6(realRoot, requested);
|
|
25633
25831
|
}
|
|
25634
25832
|
if (!isInside(realRoot, abs)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
25635
25833
|
const { real, rest } = await realAncestor(abs);
|
|
25636
|
-
const final = rest ?
|
|
25834
|
+
const final = rest ? join56(real, rest) : real;
|
|
25637
25835
|
if (!isInside(realRoot, final)) throw new PathRefusal(`${requested} is outside this periscope's worktree`);
|
|
25638
25836
|
if (relative2(realRoot, final).split(sep).includes(".git")) throw new PathRefusal(".git is not reachable from a periscope");
|
|
25639
25837
|
return final;
|
|
@@ -25701,7 +25899,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
25701
25899
|
const entries = (await readdir(abs, { withFileTypes: true })).filter((e) => e.name !== ".git");
|
|
25702
25900
|
const lines2 = await Promise.all(entries.map(async (e) => {
|
|
25703
25901
|
if (e.isDirectory()) return `[DIR] ${e.name}`;
|
|
25704
|
-
const size = (await lstat(
|
|
25902
|
+
const size = (await lstat(join56(abs, e.name))).size;
|
|
25705
25903
|
return `[FILE] ${e.name} (${size} bytes)`;
|
|
25706
25904
|
}));
|
|
25707
25905
|
return text(lines2.join("\n") || "(empty)");
|
|
@@ -25767,7 +25965,7 @@ function createPeriscopeMcpServer(d, sc) {
|
|
|
25767
25965
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
25768
25966
|
}, async ({ path }) => {
|
|
25769
25967
|
const parent = await inTree(dirname34(path) === "" ? "." : dirname34(path));
|
|
25770
|
-
const abs =
|
|
25968
|
+
const abs = join56(parent, basename15(path));
|
|
25771
25969
|
if (basename15(path) === ".git" || abs === parent) return text("path must name a file", true);
|
|
25772
25970
|
const st = await lstat(abs).catch(() => void 0);
|
|
25773
25971
|
if (!st) return text(`${path} does not exist`, true);
|
|
@@ -26258,7 +26456,7 @@ if (command === "provision") {
|
|
|
26258
26456
|
process.exit(outcome.code);
|
|
26259
26457
|
}
|
|
26260
26458
|
if (command === "pool-member") {
|
|
26261
|
-
const pool = poolConfigFrom(argv, process.env, () =>
|
|
26459
|
+
const pool = poolConfigFrom(argv, process.env, () => readFileSync48(0, "utf8"));
|
|
26262
26460
|
if (typeof pool === "string") {
|
|
26263
26461
|
process.stderr.write(`crew pool-member: ${pool}
|
|
26264
26462
|
`);
|
|
@@ -26507,7 +26705,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26507
26705
|
} else {
|
|
26508
26706
|
const toleratesNoRoutes = command === "credential" || command === "forge" || command === "repos" || command === "ship" || command === "disconnect" && flag("reset") || command === "deprovision" || command === "connect" && flag("sign-out");
|
|
26509
26707
|
const configless = command === "connect" && flag("sign-out") || command === "disconnect" && flag("reset") || command === "deprovision";
|
|
26510
|
-
if (configless && !
|
|
26708
|
+
if (configless && !existsSync52(findConfigFile(CREW_HOME))) {
|
|
26511
26709
|
cfg = loadConfig(CREW_HOME, firstRunConfigPath(), { text: "ship: {}\n", allowNoRoutes: true });
|
|
26512
26710
|
} else {
|
|
26513
26711
|
cfg = loadConfig(CREW_HOME, void 0, toleratesNoRoutes ? { allowNoRoutes: true } : {});
|
|
@@ -26522,7 +26720,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26522
26720
|
throw e;
|
|
26523
26721
|
}
|
|
26524
26722
|
if (command === "credential") {
|
|
26525
|
-
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"));
|
|
26526
26724
|
process.stdout.write(r.out);
|
|
26527
26725
|
process.stderr.write(r.err);
|
|
26528
26726
|
process.exit(r.code);
|
|
@@ -26534,9 +26732,9 @@ if (command === "passenger-sync-daemon") {
|
|
|
26534
26732
|
forges: cfg.ship.forges,
|
|
26535
26733
|
stateDir: cfg.ship.stateDir,
|
|
26536
26734
|
configFile: cfg.configFile,
|
|
26537
|
-
readFile: (p) =>
|
|
26538
|
-
writeFile: (p, t) =>
|
|
26539
|
-
stdin: () =>
|
|
26735
|
+
readFile: (p) => readFileSync48(p, "utf8"),
|
|
26736
|
+
writeFile: (p, t) => writeFileSync40(p, t),
|
|
26737
|
+
stdin: () => readFileSync48(0, "utf8"),
|
|
26540
26738
|
env: process.env
|
|
26541
26739
|
}
|
|
26542
26740
|
);
|
|
@@ -26859,8 +27057,8 @@ if (command === "passenger-sync-daemon") {
|
|
|
26859
27057
|
}
|
|
26860
27058
|
if (host === "linux" && hasSystemd) {
|
|
26861
27059
|
const label = labelFor(CREW_HOME, "run");
|
|
26862
|
-
const staleTimer =
|
|
26863
|
-
if (
|
|
27060
|
+
const staleTimer = join57(homedir11(), ".config", "systemd", "user", `${label}.timer`);
|
|
27061
|
+
if (existsSync52(staleTimer)) {
|
|
26864
27062
|
process.stdout.write(
|
|
26865
27063
|
`removing stale run timer from before the persistent-service cutover: ${staleTimer}${dryRun ? " (dry run)" : ""}
|
|
26866
27064
|
`
|
|
@@ -26889,7 +27087,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26889
27087
|
const { settled: doctorRepos, errors: refusedRepos } = await settleRepos(reposOf(c), (t) => t.name, (t) => resolveOneRepo(c, t));
|
|
26890
27088
|
for (const e of refusedRepos) problems.push(`repo ${e.repo}: ${e.detail}`);
|
|
26891
27089
|
for (const r of doctorRepos) {
|
|
26892
|
-
if (!
|
|
27090
|
+
if (!existsSync52(r.dir)) problems.push(`repo ${r.name}: ${r.dir} is missing on disk`);
|
|
26893
27091
|
if (!satisfies(host, r.config.platform)) problems.push(`repo ${r.name}: requires ${r.config.platform}, this host is ${host}`);
|
|
26894
27092
|
readiness.push(...validateEffective(r.config).map((p) => `repo ${r.name}: ${p}`));
|
|
26895
27093
|
}
|
|
@@ -26916,7 +27114,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26916
27114
|
}
|
|
26917
27115
|
async function doctorFix(o) {
|
|
26918
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))));
|
|
26919
|
-
const unitExists = (p) =>
|
|
27117
|
+
const unitExists = (p) => existsSync52(p);
|
|
26920
27118
|
const crontab = o.host === "linux" ? spawnSync12("crontab", ["-l"], { encoding: "utf8" }).stdout ?? "" : "";
|
|
26921
27119
|
const schedulerAbsent = o.host !== "windows" ? !schedulerInstalled(planInstall(cfg.ship, CREW_HOME, o.host, detectSystemd(), "run", installContext()), unitExists, crontab) : true;
|
|
26922
27120
|
const plan = planFix({ routes, schedulerAbsent, host: o.host });
|
|
@@ -26933,7 +27131,7 @@ if (command === "passenger-sync-daemon") {
|
|
|
26933
27131
|
for (const a of plan.actions) {
|
|
26934
27132
|
if (a.kind === "enable") {
|
|
26935
27133
|
if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
|
|
26936
|
-
|
|
27134
|
+
writeFileSync40(cfg.configFile, planEnable(readFileSync48(cfg.configFile, "utf8"), a.route));
|
|
26937
27135
|
enabledSound.add(a.route);
|
|
26938
27136
|
changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
|
|
26939
27137
|
} else {
|
|
@@ -27158,7 +27356,7 @@ ${changed2.map((c) => ` - ${c}
|
|
|
27158
27356
|
harnessBin: "claude",
|
|
27159
27357
|
...contract.sandboxNetwork ? { extraHosts: contract.sandboxNetwork.hosts, toolchains: contract.sandboxNetwork.toolchains } : {}
|
|
27160
27358
|
},
|
|
27161
|
-
policyFile:
|
|
27359
|
+
policyFile: join57(cfg.ship.stateDir, "release", `${target.name}.policy.yaml`),
|
|
27162
27360
|
repo: mirror,
|
|
27163
27361
|
origin: forgeDescriptorFor(forgeHost).httpsUrl(mirror.host, mirror.path),
|
|
27164
27362
|
base: effective.branch.base,
|
|
@@ -28255,7 +28453,7 @@ ${cu.tail.trimEnd()}
|
|
|
28255
28453
|
);
|
|
28256
28454
|
process.exit(1);
|
|
28257
28455
|
}
|
|
28258
|
-
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")];
|
|
28259
28457
|
const configPaths = daemonConfigPaths(cfg);
|
|
28260
28458
|
watchPaths.push(...configPaths);
|
|
28261
28459
|
noteDaemonStarted(cfg.ship.stateDir);
|
|
@@ -28567,10 +28765,10 @@ ${cu.tail.trimEnd()}
|
|
|
28567
28765
|
`);
|
|
28568
28766
|
if (!dryRun) {
|
|
28569
28767
|
const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
|
|
28570
|
-
const raw =
|
|
28768
|
+
const raw = existsSync52(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
|
|
28571
28769
|
raw.agentSkills = result.agentSkills;
|
|
28572
|
-
|
|
28573
|
-
|
|
28770
|
+
mkdirSync40(dirOf2(resolvedPath), { recursive: true });
|
|
28771
|
+
writeFileSync40(resolvedPath, `${JSON.stringify(raw, null, 2)}
|
|
28574
28772
|
`);
|
|
28575
28773
|
}
|
|
28576
28774
|
if (result.outcomes.some((o) => o.action === "diverged")) process.exitCode = 1;
|
|
@@ -28593,7 +28791,7 @@ ${cu.tail.trimEnd()}
|
|
|
28593
28791
|
throw e;
|
|
28594
28792
|
}
|
|
28595
28793
|
const oldName = cfg.ship.name;
|
|
28596
|
-
|
|
28794
|
+
writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), newName));
|
|
28597
28795
|
cfg.ship.name = newName;
|
|
28598
28796
|
let renameMachineId;
|
|
28599
28797
|
try {
|
|
@@ -28640,7 +28838,7 @@ ${cu.tail.trimEnd()}
|
|
|
28640
28838
|
process.exit(2);
|
|
28641
28839
|
};
|
|
28642
28840
|
if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
|
|
28643
|
-
const configText =
|
|
28841
|
+
const configText = readFileSync48(cfg.configFile, "utf8");
|
|
28644
28842
|
if (sub === "check") {
|
|
28645
28843
|
try {
|
|
28646
28844
|
const routeArg = value("route") ?? positional[2];
|
|
@@ -28672,8 +28870,8 @@ ${cu.tail.trimEnd()}
|
|
|
28672
28870
|
try {
|
|
28673
28871
|
const a = parseHooksArgs(positional.slice(2), routeNamesOf(configText));
|
|
28674
28872
|
const dir = repoDirOf(configText, dirname35(cfg.configFile), a.route, a.name);
|
|
28675
|
-
if (!
|
|
28676
|
-
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) => {
|
|
28677
28875
|
try {
|
|
28678
28876
|
return readdirSync20(resolvePath(dir, r));
|
|
28679
28877
|
} catch {
|
|
@@ -28681,7 +28879,7 @@ ${cu.tail.trimEnd()}
|
|
|
28681
28879
|
}
|
|
28682
28880
|
}, read: (r) => {
|
|
28683
28881
|
try {
|
|
28684
|
-
return
|
|
28882
|
+
return readFileSync48(resolvePath(dir, r), "utf8");
|
|
28685
28883
|
} catch {
|
|
28686
28884
|
return void 0;
|
|
28687
28885
|
}
|
|
@@ -28723,19 +28921,19 @@ ${cu.tail.trimEnd()}
|
|
|
28723
28921
|
let cleared;
|
|
28724
28922
|
if (clear2) {
|
|
28725
28923
|
const plan = clearRouteHooks(configText, a.route, a.name);
|
|
28726
|
-
if (plan.removed.length > 0)
|
|
28924
|
+
if (plan.removed.length > 0) writeFileSync40(cfg.configFile, plan.text);
|
|
28727
28925
|
cleared = { file: cfg.configFile, removed: plan.removed };
|
|
28728
28926
|
}
|
|
28729
28927
|
if (write && suggestion.source === null && recipeIds.length === 0 && hookSpecs.length === 0) throw new ReposError(`nothing to write: ${suggestion.notes[0]}`);
|
|
28730
28928
|
if (write === "route") {
|
|
28731
28929
|
const plan = planRouteHooks(configText, a.route, a.name, picked.hooks, { replace: flag("replace") });
|
|
28732
|
-
|
|
28930
|
+
writeFileSync40(cfg.configFile, plan.text);
|
|
28733
28931
|
written = { target: "route", file: cfg.configFile, hooks: plan.written, kept: plan.kept, replaced: plan.replaced };
|
|
28734
28932
|
} else if (write === "repo") {
|
|
28735
28933
|
const have = existingRepoConfig(files);
|
|
28736
28934
|
if (have) throw new ReposError(`${resolvePath(dir, have)} already exists; not overwriting it`);
|
|
28737
28935
|
const file = resolvePath(dir, ".crew.yaml");
|
|
28738
|
-
|
|
28936
|
+
writeFileSync40(file, starterRepoConfig(picked.hooks, picked.release), { flag: "wx" });
|
|
28739
28937
|
written = { target: "repo", file, hooks: Object.keys(picked.hooks), kept: [], replaced: [] };
|
|
28740
28938
|
}
|
|
28741
28939
|
if (flag("json")) {
|
|
@@ -28791,7 +28989,7 @@ ${cu.tail.trimEnd()}
|
|
|
28791
28989
|
if (sub === "list" && !routeName) usage2();
|
|
28792
28990
|
if (sub === "add") {
|
|
28793
28991
|
try {
|
|
28794
|
-
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) =>
|
|
28992
|
+
const a = parseAddArgs(positional.slice(2), routeNamesOf(configText), (p) => existsSync52(resolvePath(p.replace(/^~(?=\/|$)/, homedir11()))));
|
|
28795
28993
|
routeName = a.route;
|
|
28796
28994
|
addPath = a.path;
|
|
28797
28995
|
addName = a.name;
|
|
@@ -28821,7 +29019,7 @@ ${cu.tail.trimEnd()}
|
|
|
28821
29019
|
const resolvedFile = resolvedPathFor(cfg.ship.stateDir, routeName);
|
|
28822
29020
|
if (sub === "list" || sub === "add") {
|
|
28823
29021
|
const liveRoute = cfg.routes.find((r) => r.route === routeName);
|
|
28824
|
-
if (liveRoute?.resolved?.reposModelId &&
|
|
29022
|
+
if (liveRoute?.resolved?.reposModelId && existsSync52(resolvedFile) && !dryRun) {
|
|
28825
29023
|
try {
|
|
28826
29024
|
await hydrateApiKeys([liveRoute]);
|
|
28827
29025
|
persistRepoRows(cfg.ship.stateDir, liveRoute.route, await new Tracker(liveRoute, cfg.ship).repoRowsForMap());
|
|
@@ -28830,16 +29028,16 @@ ${cu.tail.trimEnd()}
|
|
|
28830
29028
|
}
|
|
28831
29029
|
}
|
|
28832
29030
|
let resolvedRemotes;
|
|
28833
|
-
if (
|
|
29031
|
+
if (existsSync52(resolvedFile)) {
|
|
28834
29032
|
try {
|
|
28835
|
-
resolvedRemotes = JSON.parse(
|
|
29033
|
+
resolvedRemotes = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
28836
29034
|
} catch {
|
|
28837
29035
|
}
|
|
28838
29036
|
}
|
|
28839
29037
|
const originOf = (dir) => gitOk(dir, ["remote", "get-url", "origin"]) ?? void 0;
|
|
28840
29038
|
const text2 = configText;
|
|
28841
29039
|
const base = dirname35(cfg.configFile);
|
|
28842
|
-
const isCheckout = (d) =>
|
|
29040
|
+
const isCheckout = (d) => existsSync52(`${d}/.git`);
|
|
28843
29041
|
try {
|
|
28844
29042
|
if (sub === "list") {
|
|
28845
29043
|
if (flag("json")) {
|
|
@@ -28849,12 +29047,12 @@ ${cu.tail.trimEnd()}
|
|
|
28849
29047
|
base,
|
|
28850
29048
|
resolved: resolvedRemotes,
|
|
28851
29049
|
originOf,
|
|
28852
|
-
exists: (d) =>
|
|
29050
|
+
exists: (d) => existsSync52(d),
|
|
28853
29051
|
isCheckout,
|
|
28854
29052
|
repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
|
|
28855
29053
|
try {
|
|
28856
29054
|
const path = resolvePath(d, f);
|
|
28857
|
-
return Object.keys(parseRepoConfig(
|
|
29055
|
+
return Object.keys(parseRepoConfig(readFileSync48(path, "utf8"), path).hooks).length > 0;
|
|
28858
29056
|
} catch {
|
|
28859
29057
|
return false;
|
|
28860
29058
|
}
|
|
@@ -28871,7 +29069,7 @@ ${cu.tail.trimEnd()}
|
|
|
28871
29069
|
for (const r of repos) {
|
|
28872
29070
|
const origin2 = originOf(r.dir);
|
|
28873
29071
|
const row = matchRepoName(origin2, resolvedRemotes);
|
|
28874
|
-
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)"}`;
|
|
28875
29073
|
process.stdout.write(`${r.name} ${r.dir} ${note}
|
|
28876
29074
|
`);
|
|
28877
29075
|
}
|
|
@@ -28883,9 +29081,9 @@ ${cu.tail.trimEnd()}
|
|
|
28883
29081
|
` : `${human}
|
|
28884
29082
|
`);
|
|
28885
29083
|
const plan2 = planRepoClone({ text: text2, base, route: routeName, name: addName, resolved: resolvedRemotes, dir: value("dir"), isCheckout });
|
|
28886
|
-
if (
|
|
29084
|
+
if (existsSync52(plan2.target) && (existsSync52(`${plan2.target}/.git`) || readdirSync20(plan2.target).length > 0)) {
|
|
28887
29085
|
throw new ReposError(
|
|
28888
|
-
|
|
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`
|
|
28889
29087
|
);
|
|
28890
29088
|
}
|
|
28891
29089
|
if (dryRun) {
|
|
@@ -28903,14 +29101,14 @@ ${cu.tail.trimEnd()}
|
|
|
28903
29101
|
throw new ReposError(`${e.message}${authHint}
|
|
28904
29102
|
crew.yaml was not changed`);
|
|
28905
29103
|
}
|
|
28906
|
-
|
|
29104
|
+
writeFileSync40(cfg.configFile, plan2.text);
|
|
28907
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:
|
|
28908
29106
|
`);
|
|
28909
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}`);
|
|
28910
29108
|
break;
|
|
28911
29109
|
}
|
|
28912
29110
|
const target = resolvePath(addPath.replace(/^~(?=\/|$)/, homedir11()));
|
|
28913
|
-
const top =
|
|
29111
|
+
const top = existsSync52(target) ? gitOk(target, ["rev-parse", "--show-toplevel"]) : null;
|
|
28914
29112
|
if (!top) throw new ReposError(`${target} is not a git checkout`);
|
|
28915
29113
|
const origin = originOf(top);
|
|
28916
29114
|
const plan = planRepoAdd({
|
|
@@ -28962,15 +29160,15 @@ ${cu.tail.trimEnd()}
|
|
|
28962
29160
|
const created = await rowTracker.createRepoRow(rowPayload);
|
|
28963
29161
|
process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
|
|
28964
29162
|
`);
|
|
28965
|
-
if (
|
|
28966
|
-
const raw = JSON.parse(
|
|
29163
|
+
if (existsSync52(resolvedFile)) {
|
|
29164
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
28967
29165
|
raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
|
|
28968
29166
|
raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
|
|
28969
|
-
|
|
29167
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
28970
29168
|
`);
|
|
28971
29169
|
}
|
|
28972
29170
|
}
|
|
28973
|
-
|
|
29171
|
+
writeFileSync40(cfg.configFile, plan.text);
|
|
28974
29172
|
process.stdout.write(`added ${top} to ${routeName} as ${plan.mode === "dir" ? "dir" : `repos.${plan.name}`} in ${cfg.configFile}
|
|
28975
29173
|
`);
|
|
28976
29174
|
} catch (e) {
|
|
@@ -29345,7 +29543,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29345
29543
|
process.exit(2);
|
|
29346
29544
|
}
|
|
29347
29545
|
if (found.shipNameAdopted && !dryRun) {
|
|
29348
|
-
|
|
29546
|
+
writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), found.shipNameAdopted));
|
|
29349
29547
|
cfg.ship.name = found.shipNameAdopted;
|
|
29350
29548
|
}
|
|
29351
29549
|
if (found.shipRow) {
|
|
@@ -29388,10 +29586,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29388
29586
|
}
|
|
29389
29587
|
}
|
|
29390
29588
|
let previous;
|
|
29391
|
-
const hadPreviousFile =
|
|
29589
|
+
const hadPreviousFile = existsSync52(resolvedPath);
|
|
29392
29590
|
if (hadPreviousFile) {
|
|
29393
29591
|
try {
|
|
29394
|
-
previous = JSON.parse(
|
|
29592
|
+
previous = JSON.parse(readFileSync48(resolvedPath, "utf8"));
|
|
29395
29593
|
} catch {
|
|
29396
29594
|
}
|
|
29397
29595
|
}
|
|
@@ -29521,12 +29719,12 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29521
29719
|
process.stderr.write(`(dry run) would write resolved ids to ${resolvedPath}
|
|
29522
29720
|
`);
|
|
29523
29721
|
} else {
|
|
29524
|
-
|
|
29722
|
+
mkdirSync40(dirname35(resolvedPath), { recursive: true });
|
|
29525
29723
|
if (hadPreviousFile) copyFileSync2(resolvedPath, `${resolvedPath}.bak`);
|
|
29526
29724
|
const tmpPath = `${resolvedPath}.tmp${process.pid}`;
|
|
29527
|
-
|
|
29725
|
+
writeFileSync40(tmpPath, `${JSON.stringify(resolved, null, 2)}
|
|
29528
29726
|
`);
|
|
29529
|
-
|
|
29727
|
+
renameSync7(tmpPath, resolvedPath);
|
|
29530
29728
|
process.stderr.write(`Resolved ids written to ${resolvedPath}
|
|
29531
29729
|
`);
|
|
29532
29730
|
}
|
|
@@ -29570,8 +29768,8 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
29570
29768
|
process.stderr.write(`(dry run) would write the minted API key to ${apiKeyFile}
|
|
29571
29769
|
`);
|
|
29572
29770
|
} else {
|
|
29573
|
-
|
|
29574
|
-
|
|
29771
|
+
mkdirSync40(dirname35(apiKeyFile), { recursive: true });
|
|
29772
|
+
writeFileSync40(apiKeyFile, `${apiKeyVar}=${apiKey}
|
|
29575
29773
|
`, { mode: 384 });
|
|
29576
29774
|
process.stderr.write(`API key written to ${apiKeyFile}
|
|
29577
29775
|
`);
|
|
@@ -30286,10 +30484,10 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
30286
30484
|
startupSeconds: cfg.ship.intelStartupSeconds,
|
|
30287
30485
|
prepare: async (path) => {
|
|
30288
30486
|
for (const f of repoWt.config.worktrees.copy) {
|
|
30289
|
-
const src =
|
|
30290
|
-
if (!
|
|
30291
|
-
|
|
30292
|
-
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));
|
|
30293
30491
|
}
|
|
30294
30492
|
const setup = repoWt.config.hooks.setup;
|
|
30295
30493
|
return setup ? runScript(setup, { cwd: path, shell: shellWt }) : null;
|
|
@@ -30510,7 +30708,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
|
|
|
30510
30708
|
const shellR = hit && resolveShell(hit.repo.config.shell ?? cfg.ship.shell);
|
|
30511
30709
|
const resumed = await runPeriscopeResume({
|
|
30512
30710
|
find: async () => hit && { row: hit.row, tag: hit.tag },
|
|
30513
|
-
worktreeExists: (p) =>
|
|
30711
|
+
worktreeExists: (p) => existsSync52(p),
|
|
30514
30712
|
prepareDropFile,
|
|
30515
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" }),
|
|
30516
30714
|
caps: periscopeCaps(cfg.ship),
|
|
@@ -30606,10 +30804,10 @@ ${where.join("\n")}`);
|
|
|
30606
30804
|
},
|
|
30607
30805
|
prepare: async (path) => {
|
|
30608
30806
|
for (const f of repoP.config.worktrees.copy) {
|
|
30609
|
-
const src =
|
|
30610
|
-
if (!
|
|
30611
|
-
|
|
30612
|
-
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));
|
|
30613
30811
|
}
|
|
30614
30812
|
const setup = repoP.config.hooks.setup;
|
|
30615
30813
|
return setup ? runScript(setup, { cwd: path, shell: shellP, onLine: (l) => {
|
|
@@ -30920,7 +31118,7 @@ ${where.join("\n")}`);
|
|
|
30920
31118
|
};
|
|
30921
31119
|
const droppedRoutes = [];
|
|
30922
31120
|
try {
|
|
30923
|
-
const rawCfg = parseYaml2(
|
|
31121
|
+
const rawCfg = parseYaml2(readFileSync48(cfg.configFile, "utf8"));
|
|
30924
31122
|
for (const r of rawCfg?.routes ?? []) {
|
|
30925
31123
|
if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
|
|
30926
31124
|
try {
|
|
@@ -30984,8 +31182,8 @@ ${where.join("\n")}`);
|
|
|
30984
31182
|
process.stdout.write("crew reload: no daemon unit is running \u2014 nothing to reload (the next run reads crew.yaml fresh)\n");
|
|
30985
31183
|
break;
|
|
30986
31184
|
}
|
|
30987
|
-
|
|
30988
|
-
|
|
31185
|
+
mkdirSync40(cfg.ship.stateDir, { recursive: true });
|
|
31186
|
+
writeFileSync40(sentinel, `${(/* @__PURE__ */ new Date()).toISOString()}
|
|
30989
31187
|
`);
|
|
30990
31188
|
process.stdout.write(
|
|
30991
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"
|
|
@@ -31050,7 +31248,7 @@ ${where.join("\n")}`);
|
|
|
31050
31248
|
}
|
|
31051
31249
|
case "log": {
|
|
31052
31250
|
try {
|
|
31053
|
-
const text2 =
|
|
31251
|
+
const text2 = readFileSync48(cfg.ship.logFile, "utf8").split("\n");
|
|
31054
31252
|
process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
|
|
31055
31253
|
`);
|
|
31056
31254
|
} catch {
|
|
@@ -31073,7 +31271,7 @@ ${where.join("\n")}`);
|
|
|
31073
31271
|
};
|
|
31074
31272
|
if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
|
|
31075
31273
|
const tracker = new Tracker(route2, cfg.ship);
|
|
31076
|
-
const configText =
|
|
31274
|
+
const configText = readFileSync48(cfg.configFile, "utf8");
|
|
31077
31275
|
const cfgBase = dirname35(cfg.configFile);
|
|
31078
31276
|
const configured2 = configuredRepos(configText, route2.route, cfgBase);
|
|
31079
31277
|
const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
|
|
@@ -31102,7 +31300,7 @@ ${where.join("\n")}`);
|
|
|
31102
31300
|
}
|
|
31103
31301
|
if (configured2.some((r) => r.dir === dir)) {
|
|
31104
31302
|
try {
|
|
31105
|
-
|
|
31303
|
+
writeFileSync40(cfg.configFile, planRepoRemove(configText, cfgBase, route2.route, dir).text);
|
|
31106
31304
|
} catch (e) {
|
|
31107
31305
|
if (e instanceof ReposError) fail2(e.message);
|
|
31108
31306
|
throw e;
|
|
@@ -31110,29 +31308,29 @@ ${where.join("\n")}`);
|
|
|
31110
31308
|
}
|
|
31111
31309
|
if (row) {
|
|
31112
31310
|
await tracker.deleteRepoRow(row.id);
|
|
31113
|
-
if (
|
|
31114
|
-
const raw = JSON.parse(
|
|
31311
|
+
if (existsSync52(resolvedFile)) {
|
|
31312
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
31115
31313
|
if (raw.repoNames) delete raw.repoNames[row.id];
|
|
31116
31314
|
if (raw.repoRemotes) delete raw.repoRemotes[row.id];
|
|
31117
|
-
|
|
31315
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31118
31316
|
`);
|
|
31119
31317
|
}
|
|
31120
31318
|
}
|
|
31121
|
-
if (
|
|
31319
|
+
if (existsSync52(join57(dir, ".git")) && basename16(dir) === SAMPLE_REPO) rmSync25(dir, { recursive: true, force: true });
|
|
31122
31320
|
say("removed", { dir, closed }, `removed the sample repo${closed.length ? `, closed ${closed.join(", ")}` : ""}`);
|
|
31123
31321
|
break;
|
|
31124
31322
|
}
|
|
31125
31323
|
const projectId = route2.resolved.areaId ?? resolveRepoProject(await tracker.projectRows(), value("project"));
|
|
31126
|
-
const fresh = !
|
|
31127
|
-
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`);
|
|
31128
31326
|
if (dryRun) {
|
|
31129
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`);
|
|
31130
31328
|
break;
|
|
31131
31329
|
}
|
|
31132
31330
|
if (fresh) {
|
|
31133
|
-
|
|
31134
|
-
|
|
31135
|
-
|
|
31331
|
+
mkdirSync40(dir, { recursive: true });
|
|
31332
|
+
writeFileSync40(join57(dir, "README.md"), SAMPLE_README);
|
|
31333
|
+
writeFileSync40(join57(dir, ".crew.yaml"), SAMPLE_CREW_YAML);
|
|
31136
31334
|
const g = (...a) => {
|
|
31137
31335
|
const r = spawnSync12("git", a, { cwd: dir, encoding: "utf8" });
|
|
31138
31336
|
if (r.status !== 0) fail2(`git ${a[0]} failed in ${dir}: ${(r.stderr || r.stdout).trim()}`);
|
|
@@ -31150,17 +31348,17 @@ ${where.join("\n")}`);
|
|
|
31150
31348
|
spec: { platform: "unix", releaseMode: "integrate", ciProvider: "none" }
|
|
31151
31349
|
});
|
|
31152
31350
|
repoId = (await tracker.createRepoRow(payload)).id;
|
|
31153
|
-
if (
|
|
31154
|
-
const raw = JSON.parse(
|
|
31351
|
+
if (existsSync52(resolvedFile)) {
|
|
31352
|
+
const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
|
|
31155
31353
|
raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
|
|
31156
31354
|
raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
|
|
31157
|
-
|
|
31355
|
+
writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
|
|
31158
31356
|
`);
|
|
31159
31357
|
}
|
|
31160
31358
|
}
|
|
31161
31359
|
if (!configured2.some((r) => r.dir === dir)) {
|
|
31162
31360
|
try {
|
|
31163
|
-
|
|
31361
|
+
writeFileSync40(cfg.configFile, planRepoAdd({ text: configText, base: cfgBase, route: route2.route, path: dir, name: SAMPLE_REPO }).text);
|
|
31164
31362
|
} catch (e) {
|
|
31165
31363
|
if (e instanceof ReposError) fail2(e.message);
|
|
31166
31364
|
throw e;
|
|
@@ -31506,7 +31704,7 @@ watermark: ${state.watermark()}
|
|
|
31506
31704
|
}
|
|
31507
31705
|
for (const r of repos) {
|
|
31508
31706
|
const remote = r.config.branch.remote;
|
|
31509
|
-
if (
|
|
31707
|
+
if (existsSync52(r.dir)) {
|
|
31510
31708
|
pushAuth.push({
|
|
31511
31709
|
route: c.route,
|
|
31512
31710
|
repo: r.name,
|
|
@@ -31579,7 +31777,7 @@ watermark: ${state.watermark()}
|
|
|
31579
31777
|
}
|
|
31580
31778
|
}
|
|
31581
31779
|
for (const message of roleCapWarnings(cfg.ship)) problems.push({ severity: "note", kind: "role_cap_above_ship_cap", message });
|
|
31582
|
-
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null,
|
|
31780
|
+
const runtimeDir = runtimeDirWarning(process.platform, process.getuid?.() ?? null, existsSync52, userInfo2().username);
|
|
31583
31781
|
if (runtimeDir) problems.push({ severity: "attention", kind: "runtime_dir_missing", message: runtimeDir });
|
|
31584
31782
|
if (!flag("offline")) {
|
|
31585
31783
|
const shipKind = await doctorShipKind(route2, cfg.ship);
|
|
@@ -31640,7 +31838,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31640
31838
|
}
|
|
31641
31839
|
try {
|
|
31642
31840
|
const evFile = eventFileFor(cfg.ship.stateDir);
|
|
31643
|
-
const evSize =
|
|
31841
|
+
const evSize = existsSync52(evFile) ? statSync16(evFile).size : 0;
|
|
31644
31842
|
process.stdout.write(
|
|
31645
31843
|
evSize > cfg.ship.eventsRotateBytes * 4 ? `events log: WARN ${evFile} is ${Math.round(evSize / 1048576)} MB (> 4x eventsRotateBytes); run \`crew reap\` to rotate it
|
|
31646
31844
|
` : "events log: ok\n"
|
|
@@ -31651,7 +31849,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31651
31849
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
|
|
31652
31850
|
const abandons = unitAbandonsAgents(unitPlan, (p) => {
|
|
31653
31851
|
try {
|
|
31654
|
-
return
|
|
31852
|
+
return readFileSync48(p, "utf8");
|
|
31655
31853
|
} catch {
|
|
31656
31854
|
return null;
|
|
31657
31855
|
}
|
|
@@ -31666,7 +31864,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31666
31864
|
const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
|
|
31667
31865
|
const keeps = unitAbandonsAgents(pPlan, (p) => {
|
|
31668
31866
|
try {
|
|
31669
|
-
return
|
|
31867
|
+
return readFileSync48(p, "utf8");
|
|
31670
31868
|
} catch {
|
|
31671
31869
|
return null;
|
|
31672
31870
|
}
|
|
@@ -31680,7 +31878,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
|
|
|
31680
31878
|
if (host === "linux" && detectSystemd()) {
|
|
31681
31879
|
const ctl = planDaemonControl(CREW_HOME, host, true);
|
|
31682
31880
|
const unitPlan = planInstall(cfg.ship, CREW_HOME, host, true, "run", installContext());
|
|
31683
|
-
if (ctl.statusCommand && unitPlan.unitPaths.some((p) =>
|
|
31881
|
+
if (ctl.statusCommand && unitPlan.unitPaths.some((p) => existsSync52(p))) {
|
|
31684
31882
|
const st = spawnSync12(ctl.statusCommand[0], ctl.statusCommand.slice(1), { cwd: CREW_HOME, encoding: "utf8" });
|
|
31685
31883
|
if (!st.error && st.status !== 0) {
|
|
31686
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