@tablation/crew 0.134.0 → 0.135.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -6520,12 +6520,12 @@ import { spawnSync as spawnSync7 } from "child_process";
6520
6520
  import { existsSync as existsSync30, readdirSync as readdirSync11 } from "fs";
6521
6521
 
6522
6522
  // src/interrupted.ts
6523
- import { existsSync as existsSync28, readdirSync as readdirSync9, readFileSync as readFileSync28 } from "fs";
6523
+ import { existsSync as existsSync28, readdirSync as readdirSync9, readFileSync as readFileSync29 } from "fs";
6524
6524
  import { join as join31 } from "path";
6525
6525
 
6526
6526
  // src/agent.ts
6527
6527
  import { spawnSync as spawnSync6 } from "child_process";
6528
- import { readFileSync as readFileSync27, existsSync as existsSync27, statSync as statSync9, mkdirSync as mkdirSync19, writeFileSync as writeFileSync20, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
6528
+ import { readFileSync as readFileSync28, existsSync as existsSync27, statSync as statSync9, mkdirSync as mkdirSync19, writeFileSync as writeFileSync20, createWriteStream, openSync as openSync4, closeSync as closeSync4, readSync } from "fs";
6529
6529
  import { StringDecoder } from "string_decoder";
6530
6530
  import { finished } from "stream/promises";
6531
6531
  import { join as join30, dirname as dirname15, basename as basename9 } from "path";
@@ -8996,6 +8996,26 @@ var Tracker = class {
8996
8996
  await this.client.records.update(this.route.resolved.shipsModelId, row.id, patch2);
8997
8997
  return true;
8998
8998
  }
8999
+ /**
9000
+ * `crew deprovision` on a retired `managed_instance` ship (CREW-3041): a replacement
9001
+ * gets a new member id and name, so the ship's Crew seats and then its Ships row are
9002
+ * trashed (recoverable; the event log and Agent Log keep the history) instead of
9003
+ * lingering in every list and assignment picker. Any other kind, and a Ships table
9004
+ * with no `kind` column, only clears the live fields as `clearForRelease` does, because an
9005
+ * operator may re-connect under the same name. Returns what was done, for the summary.
9006
+ */
9007
+ async retireShip(shipName2) {
9008
+ const row = await this.myShipRow(shipName2);
9009
+ if (!row) return { found: false, removed: false, seats: 0 };
9010
+ if (row.kind !== "managed_instance") {
9011
+ await this.clearForRelease(shipName2);
9012
+ return { found: true, removed: false, seats: 0 };
9013
+ }
9014
+ const seats2 = (await this.crewRows()).filter((c) => c.ship_id === row.id);
9015
+ for (const seat of seats2) await this.client.records.remove(this.models.crew, seat.id);
9016
+ await this.client.records.remove(this.route.resolved.shipsModelId, row.id);
9017
+ return { found: true, removed: true, seats: seats2.length };
9018
+ }
8999
9019
  /** The other half of `beatEngaged` — clears engagement back to idle. */
9000
9020
  async beatIdle(shipName2) {
9001
9021
  const row = await this.myShipRow(shipName2);
@@ -9369,12 +9389,12 @@ var Tracker = class {
9369
9389
  const conds = [{ columnName: "ship_id", operator: "EQ", value: shipId }];
9370
9390
  if (states?.length) conds.push({ columnName: "state", operator: "IN", value: states });
9371
9391
  const rows = await this.client.records.list(modelId, { filters: encodeFilters(conds), limit: 200 });
9372
- const refId2 = (v) => typeof v === "string" ? v : v && typeof v === "object" && typeof v.id === "string" ? v.id : void 0;
9373
- const ids = [...new Set(rows.map((r) => refId2(r.issue_id)).filter((x) => !!x))];
9392
+ const refId3 = (v) => typeof v === "string" ? v : v && typeof v === "object" && typeof v.id === "string" ? v.id : void 0;
9393
+ const ids = [...new Set(rows.map((r) => refId3(r.issue_id)).filter((x) => !!x))];
9374
9394
  const tickets = new Map((await this.ticketsByIds(ids)).map((t) => [t.id, t]));
9375
9395
  const out = [];
9376
9396
  for (const row of rows) {
9377
- const t = tickets.get(refId2(row.issue_id) ?? "");
9397
+ const t = tickets.get(refId3(row.issue_id) ?? "");
9378
9398
  if (t) out.push({ row, ticket: t });
9379
9399
  }
9380
9400
  return out.sort((a, b) => String(b.row.started_at ?? "").localeCompare(String(a.row.started_at ?? "")));
@@ -11379,9 +11399,9 @@ function expandSkillMarkers(text2, lookup2, opts = {}) {
11379
11399
  }
11380
11400
 
11381
11401
  // src/skills.ts
11382
- import { readFileSync as readFileSync26, readdirSync as readdirSync8, existsSync as existsSync26 } from "fs";
11402
+ import { readFileSync as readFileSync27, readdirSync as readdirSync8, existsSync as existsSync26 } from "fs";
11383
11403
  import { join as join28 } from "path";
11384
- import { parse as parseYaml } from "yaml";
11404
+ import { parse as parseYaml2 } from "yaml";
11385
11405
  import { TablationClient as TablationClient3, StaleWriteError as StaleWriteError3, TablationApiError as TablationApiError2 } from "@tablation/client";
11386
11406
 
11387
11407
  // src/prompt-additions.ts
@@ -11395,8 +11415,24 @@ ${PROMPT_ADDITIONS_SEPARATOR}
11395
11415
  ${additions}`;
11396
11416
  }
11397
11417
 
11418
+ // src/persona-file.ts
11419
+ import { readFileSync as readFileSync25 } from "fs";
11420
+ import { parse as parseYaml } from "yaml";
11421
+ function parsePersonaText(text2, path) {
11422
+ const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
11423
+ if (!match) return { body: text2 };
11424
+ const meta = parseYaml(match[1]) ?? {};
11425
+ if (meta.chat_enabled !== void 0 && meta.chat_enabled !== null && typeof meta.chat_enabled !== "boolean") {
11426
+ throw new Error(`${path}: front matter "chat_enabled" must be true or false`);
11427
+ }
11428
+ return { body: match[2], ...typeof meta.chat_enabled === "boolean" ? { chatEnabled: meta.chat_enabled } : {} };
11429
+ }
11430
+ function readPersonaFile(path) {
11431
+ return parsePersonaText(readFileSync25(path, "utf8"), path);
11432
+ }
11433
+
11398
11434
  // src/agents.ts
11399
- import { readFileSync as readFileSync25, existsSync as existsSync25 } from "fs";
11435
+ import { readFileSync as readFileSync26, existsSync as existsSync25 } from "fs";
11400
11436
  import { join as join27 } from "path";
11401
11437
  import { TablationClient as TablationClient2, StaleWriteError as StaleWriteError2, TablationApiError } from "@tablation/client";
11402
11438
  var PERSONA_NAME = {
@@ -11413,10 +11449,15 @@ var AgentsSyncError = class extends Error {
11413
11449
  function personaDefaultPrompt(promptsDir, role) {
11414
11450
  const briefPath = join27(promptsDir, "personas", `lane-${role}.md`);
11415
11451
  if (!existsSync25(briefPath)) throw new AgentsSyncError(`no brief at ${briefPath}`);
11416
- if (SELF_CONTAINED_ROLES.has(role)) return readFileSync25(briefPath, "utf8");
11452
+ const brief = readPersonaFile(briefPath).body;
11453
+ if (SELF_CONTAINED_ROLES.has(role)) return brief;
11417
11454
  const commonPath = join27(promptsDir, "personas", "common.md");
11418
- if (!existsSync25(commonPath)) return readFileSync25(briefPath, "utf8");
11419
- return `${readFileSync25(commonPath, "utf8")}${readFileSync25(briefPath, "utf8")}`;
11455
+ if (!existsSync25(commonPath)) return brief;
11456
+ return `${readFileSync26(commonPath, "utf8")}${brief}`;
11457
+ }
11458
+ function personaChatEnabled(promptsDir, role) {
11459
+ const briefPath = join27(promptsDir, "personas", `lane-${role}.md`);
11460
+ return existsSync25(briefPath) ? readPersonaFile(briefPath).chatEnabled : void 0;
11420
11461
  }
11421
11462
  async function resolveAgentId(route2, role, opts) {
11422
11463
  const cached = route2.resolved?.agentPersonas?.[role]?.agentId;
@@ -11586,6 +11627,13 @@ async function syncPersonas(route2, opts) {
11586
11627
  const cache = route2.resolved.agentPersonas ?? {};
11587
11628
  const outcomes = [];
11588
11629
  const agentPersonas = { ...cache };
11630
+ const hasChatColumn = agentsModel.fields?.some((f) => f.columnName === "chat_enabled") === true;
11631
+ const chatDeclared = {};
11632
+ for (const role of ROLE_NAMES) {
11633
+ const v = personaChatEnabled(route2.promptsDir, role);
11634
+ if (v !== void 0) chatDeclared[role] = v;
11635
+ }
11636
+ const chatNote = !hasChatColumn && Object.keys(chatDeclared).length > 0 && !opts.readOnly ? "chat_enabled not synced \u2014 the Agents table has no chat_enabled column yet (update the Issues template)" : void 0;
11589
11637
  for (const role of ROLE_NAMES) {
11590
11638
  const name = PERSONA_NAME[role];
11591
11639
  const defaultPrompt = personaDefaultPrompt(route2.promptsDir, role);
@@ -11605,7 +11653,12 @@ async function syncPersonas(route2, opts) {
11605
11653
  outcomes.push({ role, action: "created", agentId: "(dry run)" });
11606
11654
  continue;
11607
11655
  }
11608
- const created = await client2.records.create(agentsModel.id, { name, prompt: defaultPrompt, ...promptSourceFields(agentsModel, defaultPrompt) });
11656
+ const created = await client2.records.create(agentsModel.id, {
11657
+ name,
11658
+ prompt: defaultPrompt,
11659
+ ...promptSourceFields(agentsModel, defaultPrompt),
11660
+ ...hasChatColumn && chatDeclared[role] !== void 0 ? { chat_enabled: chatDeclared[role] } : {}
11661
+ });
11609
11662
  const historyId = await fetchLatestHistoryId(route2, agentsModel.id, created.id, opts.userAgent);
11610
11663
  agentPersonas[role] = { agentId: created.id, lastSyncedUpdatedAt: created.updated_at, ...historyId ? { historyId } : {} };
11611
11664
  outcomes.push({ role, action: "created", agentId: created.id });
@@ -11701,6 +11754,16 @@ async function syncPersonas(route2, opts) {
11701
11754
  throw e;
11702
11755
  }
11703
11756
  }
11757
+ if (hasChatColumn && !opts.dryRun && !opts.readOnly) {
11758
+ for (const role of ROLE_NAMES) {
11759
+ const want = chatDeclared[role];
11760
+ const row = rows.find((r) => r.name === PERSONA_NAME[role]);
11761
+ const entry = agentPersonas[role];
11762
+ if (want === void 0 || !row || !entry || entry.agentId !== row.id || (row.chat_enabled ?? null) !== null) continue;
11763
+ const updated = await client2.records.update(agentsModel.id, row.id, { chat_enabled: want });
11764
+ agentPersonas[role] = { ...entry, lastSyncedUpdatedAt: updated.updated_at };
11765
+ }
11766
+ }
11704
11767
  const crewLinks = opts.dryRun ? [] : await linkCrewSeats(route2, client2, agentsModel.id, agentPersonas, opts.userAgent, opts.readOnly === true);
11705
11768
  const release = opts.dryRun ? { agentId: route2.resolved.releaseAgentId } : await linkReleaseSeat(route2, client2, agentsModel, opts.userAgent, opts.readOnly === true);
11706
11769
  return {
@@ -11709,6 +11772,7 @@ async function syncPersonas(route2, opts) {
11709
11772
  crewLinks,
11710
11773
  ...release.agentId ? { releaseAgentId: release.agentId } : {},
11711
11774
  ...release.note ? { releaseNote: release.note } : {},
11775
+ ...chatNote ? { chatNote } : {},
11712
11776
  ...opts.readOnly ? { readOnly: true } : {}
11713
11777
  };
11714
11778
  }
@@ -11863,23 +11927,42 @@ function describeCrewLink(o) {
11863
11927
  var SkillSyncError = class extends Error {
11864
11928
  };
11865
11929
  function parseSkillFile(path) {
11866
- const text2 = readFileSync26(path, "utf8");
11930
+ const text2 = readFileSync27(path, "utf8");
11867
11931
  const match = /^---\n([\s\S]*?)\n---\n([\s\S]*)$/.exec(text2);
11868
11932
  if (!match) throw new SkillSyncError(`${path}: missing YAML frontmatter (expected a leading --- block)`);
11869
11933
  const frontmatter = match[1];
11870
11934
  const body = match[2];
11871
- const meta = parseYaml(frontmatter);
11935
+ const meta = parseYaml2(frontmatter);
11872
11936
  if (typeof meta.name !== "string" || !meta.name) throw new SkillSyncError(`${path}: frontmatter is missing "name"`);
11873
11937
  if (typeof meta.description !== "string" || !meta.description) {
11874
11938
  throw new SkillSyncError(`${path}: frontmatter is missing "description"`);
11875
11939
  }
11876
- return { name: meta.name, description: meta.description, prompt: body, file: path };
11940
+ for (const key of ["trigger", "persona"]) {
11941
+ if (meta[key] !== void 0 && meta[key] !== null && typeof meta[key] !== "string") {
11942
+ throw new SkillSyncError(`${path}: frontmatter "${key}" must be a string`);
11943
+ }
11944
+ }
11945
+ const trigger = typeof meta.trigger === "string" && meta.trigger ? meta.trigger : void 0;
11946
+ const persona = typeof meta.persona === "string" && meta.persona ? meta.persona : void 0;
11947
+ return {
11948
+ name: meta.name,
11949
+ description: meta.description,
11950
+ prompt: body,
11951
+ file: path,
11952
+ ...trigger ? { trigger } : {},
11953
+ ...persona ? { persona } : {}
11954
+ };
11877
11955
  }
11878
11956
  function listLocalSkills(promptsDir) {
11879
11957
  const dir = join28(promptsDir, "skills");
11880
11958
  if (!existsSync26(dir)) return [];
11881
11959
  return readdirSync8(dir).filter((f) => f.endsWith(".md")).map((f) => parseSkillFile(join28(dir, f)));
11882
11960
  }
11961
+ function personaColumn(model) {
11962
+ for (const c of ["persona_id", "persona"]) if (model.fields?.some((f) => f.columnName === c)) return c;
11963
+ return void 0;
11964
+ }
11965
+ var refId2 = (v) => typeof v === "string" ? v : v && typeof v === "object" && typeof v.id === "string" ? v.id : "";
11883
11966
  async function syncSkills(route2, opts) {
11884
11967
  if (!route2.resolved) {
11885
11968
  throw new SkillSyncError(`route "${route2.route}" has no resolved ids \u2014 run \`crew connect\` first`);
@@ -11906,8 +11989,51 @@ async function syncSkills(route2, opts) {
11906
11989
  const cache = route2.resolved.agentSkills ?? {};
11907
11990
  const outcomes = [];
11908
11991
  const agentSkills = { ...cache };
11992
+ const warnings = [];
11993
+ const hasTrigger = skillsModel.fields?.some((f) => f.columnName === "trigger") === true;
11994
+ const personaCol = personaColumn(skillsModel);
11995
+ let agentRows;
11996
+ const classified = /* @__PURE__ */ new Set();
11997
+ const declared = (skill) => {
11998
+ const out = {};
11999
+ if (skill.trigger) {
12000
+ if (hasTrigger) out.trigger = skill.trigger;
12001
+ else if (!classified.has("trigger")) {
12002
+ classified.add("trigger");
12003
+ warnings.push("skill trigger not synced \u2014 the Agent Skills table has no trigger column yet (update the Issues template)");
12004
+ }
12005
+ }
12006
+ return out;
12007
+ };
12008
+ const declaredPersona = async (skill) => {
12009
+ if (!skill.persona) return {};
12010
+ if (!personaCol) {
12011
+ if (!classified.has("persona")) {
12012
+ classified.add("persona");
12013
+ warnings.push("skill persona not synced \u2014 the Agent Skills table has no persona column yet (update the Issues template)");
12014
+ }
12015
+ return {};
12016
+ }
12017
+ if (!agentRows) {
12018
+ try {
12019
+ const agentsModel = await client2.dataModels.get("agents", workspaceId);
12020
+ agentRows = await client2.records.list(agentsModel.id, { limit: 200 });
12021
+ } catch (e) {
12022
+ if (!(e instanceof TablationApiError2)) throw e;
12023
+ agentRows = [];
12024
+ }
12025
+ }
12026
+ const match = agentRows.find((a) => a.name === skill.persona);
12027
+ if (!match) {
12028
+ warnings.push(`skill "${skill.name}": persona "${skill.persona}" matches no Agents row \u2014 Persona left empty`);
12029
+ return {};
12030
+ }
12031
+ return { [personaCol]: match.id };
12032
+ };
11909
12033
  for (const skill of local) {
11910
12034
  const row = rows.find((r) => r.name === skill.name);
12035
+ const extra = { ...declared(skill), ...await declaredPersona(skill) };
12036
+ const rowDiffers = (r) => Object.entries(extra).some(([col, v]) => (col === "trigger" ? r.trigger ?? "" : refId2(r[col])) !== v);
11911
12037
  if (!row) {
11912
12038
  if (opts.dryRun) {
11913
12039
  outcomes.push({ name: skill.name, action: "created", skillId: "(dry run)" });
@@ -11917,13 +12043,14 @@ async function syncSkills(route2, opts) {
11917
12043
  name: skill.name,
11918
12044
  description: skill.description,
11919
12045
  prompt: skill.prompt,
12046
+ ...extra,
11920
12047
  ...promptSourceFields(skillsModel, skill.prompt)
11921
12048
  });
11922
12049
  agentSkills[skill.name] = { skillId: created.id, lastSyncedUpdatedAt: created.updated_at };
11923
12050
  outcomes.push({ name: skill.name, action: "created", skillId: created.id });
11924
12051
  continue;
11925
12052
  }
11926
- if (row.description === skill.description && row.prompt === skill.prompt) {
12053
+ if (row.description === skill.description && row.prompt === skill.prompt && !rowDiffers(row)) {
11927
12054
  let anchoredAt = row.updated_at;
11928
12055
  if (!opts.dryRun && needsBaselineBackfill(skillsModel, row)) {
11929
12056
  try {
@@ -11946,7 +12073,7 @@ async function syncSkills(route2, opts) {
11946
12073
  outcomes.push({ name: skill.name, action: "overridden", skillId: row.id });
11947
12074
  continue;
11948
12075
  }
11949
- const body = { description: skill.description, prompt: skill.prompt, ...promptSourceFields(skillsModel, skill.prompt) };
12076
+ const body = { description: skill.description, prompt: skill.prompt, ...extra, ...promptSourceFields(skillsModel, skill.prompt) };
11950
12077
  if (opts.force) {
11951
12078
  if (opts.dryRun) {
11952
12079
  outcomes.push({ name: skill.name, action: "forced", skillId: row.id });
@@ -12001,7 +12128,7 @@ async function syncSkills(route2, opts) {
12001
12128
  throw e;
12002
12129
  }
12003
12130
  }
12004
- return { outcomes, agentSkills };
12131
+ return { outcomes, agentSkills, warnings };
12005
12132
  }
12006
12133
  function describeSkillSyncOutcome(o) {
12007
12134
  switch (o.action) {
@@ -12462,7 +12589,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
12462
12589
  function streamShowsAllowanceRefusal(streamPath) {
12463
12590
  let raw;
12464
12591
  try {
12465
- raw = readFileSync27(streamPath, "utf8");
12592
+ raw = readFileSync28(streamPath, "utf8");
12466
12593
  } catch {
12467
12594
  return false;
12468
12595
  }
@@ -12548,10 +12675,10 @@ function planAgentRun(o) {
12548
12675
  let ageSeconds;
12549
12676
  if (existsSync27(digestPath2)) {
12550
12677
  ageSeconds = Math.floor((now() - statSync9(digestPath2).mtimeMs) / 1e3);
12551
- if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync27(digestPath2, "utf8");
12678
+ if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync28(digestPath2, "utf8");
12552
12679
  }
12553
- const common = usesCommon ? readFileSync27(commonPath, "utf8") : "";
12554
- const brief = readFileSync27(briefPath, "utf8");
12680
+ const common = usesCommon ? readFileSync28(commonPath, "utf8") : "";
12681
+ const brief = readPersonaFile(briefPath).body;
12555
12682
  const effectiveCommon = o.divergedPrompt ? "" : common;
12556
12683
  const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
12557
12684
  const localSkills = new Map(listLocalSkills(o.route.promptsDir).map((s) => [s.name, s.prompt]));
@@ -12712,7 +12839,7 @@ function describePlan(p) {
12712
12839
  var pidPathFor = (streamPath) => `${streamPath}.pid`;
12713
12840
  function readRunSidecar(streamPath) {
12714
12841
  try {
12715
- const sc = JSON.parse(readFileSync27(pidPathFor(streamPath), "utf8"));
12842
+ const sc = JSON.parse(readFileSync28(pidPathFor(streamPath), "utf8"));
12716
12843
  return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
12717
12844
  } catch {
12718
12845
  return null;
@@ -13334,7 +13461,7 @@ function runFinished(streamPath) {
13334
13461
  const path = `${streamPath}.meta.json`;
13335
13462
  if (!existsSync28(path)) return false;
13336
13463
  try {
13337
- return JSON.parse(readFileSync28(path, "utf8")).running !== true;
13464
+ return JSON.parse(readFileSync29(path, "utf8")).running !== true;
13338
13465
  } catch {
13339
13466
  return true;
13340
13467
  }
@@ -13559,8 +13686,12 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
13559
13686
  const out = [];
13560
13687
  for (const r of cfg.routes.filter((x) => x.resolved?.shipsModelId)) {
13561
13688
  try {
13562
- const found = await new Tracker(r, cfg.ship).clearForRelease(cfg.ship.name);
13563
- out.push({ route: r.route, ok: true, detail: found ? "cleared engaged, tunnel_status, relay_url" : "no Ships row for this ship" });
13689
+ const res = await new Tracker(r, cfg.ship).retireShip(cfg.ship.name);
13690
+ out.push({
13691
+ route: r.route,
13692
+ ok: true,
13693
+ detail: !res.found ? "no Ships row for this ship" : res.removed ? `trashed ${res.seats} Crew seat${res.seats === 1 ? "" : "s"} and the Ships row` : "cleared engaged, tunnel_status, relay_url"
13694
+ });
13564
13695
  } catch (e) {
13565
13696
  out.push({ route: r.route, ok: false, detail: e.message });
13566
13697
  }
@@ -14398,7 +14529,7 @@ function managedGitIdentityWarnings(kind, identity) {
14398
14529
 
14399
14530
  // src/selftest.ts
14400
14531
  import { spawn as spawn6 } from "child_process";
14401
- import { existsSync as existsSync31, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync2, readFileSync as readFileSync29, rmSync as rmSync16, writeFileSync as writeFileSync21 } from "fs";
14532
+ import { existsSync as existsSync31, mkdirSync as mkdirSync20, mkdtempSync as mkdtempSync2, readFileSync as readFileSync30, rmSync as rmSync16, writeFileSync as writeFileSync21 } from "fs";
14402
14533
  import { tmpdir as tmpdir5 } from "os";
14403
14534
  import { join as join33 } from "path";
14404
14535
  var SELFTEST_TIMEOUT_MS = 12e4;
@@ -14603,7 +14734,7 @@ var fileFor2 = (stateDir) => join33(stateDir, "selftest.json");
14603
14734
  function readSelftest(stateDir) {
14604
14735
  try {
14605
14736
  const p = fileFor2(stateDir);
14606
- return existsSync31(p) ? JSON.parse(readFileSync29(p, "utf8")) : {};
14737
+ return existsSync31(p) ? JSON.parse(readFileSync30(p, "utf8")) : {};
14607
14738
  } catch {
14608
14739
  return {};
14609
14740
  }
@@ -14628,7 +14759,7 @@ import { resolve as resolve7, dirname as dirname35, join as join57, basename as
14628
14759
  import { fileURLToPath as fileURLToPath2 } from "url";
14629
14760
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
14630
14761
  import { spawnSync as spawnSync12 } from "child_process";
14631
- import { parse as parseYaml2 } from "yaml";
14762
+ import { parse as parseYaml3 } from "yaml";
14632
14763
 
14633
14764
  // src/argv.ts
14634
14765
  var VALUE_FLAGS = /* @__PURE__ */ new Set([
@@ -14823,14 +14954,14 @@ function rosterMarkdown(roster, meId) {
14823
14954
  }
14824
14955
 
14825
14956
  // src/connect-resume.ts
14826
- import { mkdirSync as mkdirSync21, readFileSync as readFileSync30, rmSync as rmSync17, writeFileSync as writeFileSync22 } from "fs";
14957
+ import { mkdirSync as mkdirSync21, readFileSync as readFileSync31, rmSync as rmSync17, writeFileSync as writeFileSync22 } from "fs";
14827
14958
  import { dirname as dirname16, join as join34 } from "path";
14828
14959
  function lastSessionFile(stateDir) {
14829
14960
  return join34(stateDir, "connect-session.json");
14830
14961
  }
14831
14962
  function readPointers(stateDir) {
14832
14963
  try {
14833
- const parsed = JSON.parse(readFileSync30(lastSessionFile(stateDir), "utf8"));
14964
+ const parsed = JSON.parse(readFileSync31(lastSessionFile(stateDir), "utf8"));
14834
14965
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
14835
14966
  const out = {};
14836
14967
  for (const [host, v] of Object.entries(parsed)) {
@@ -14930,7 +15061,7 @@ async function signOutSessions(o) {
14930
15061
  }
14931
15062
 
14932
15063
  // src/reset.ts
14933
- import { existsSync as existsSync32, mkdirSync as mkdirSync22, readFileSync as readFileSync31, readdirSync as readdirSync12, rmSync as rmSync18, statSync as statSync11, writeFileSync as writeFileSync23 } from "fs";
15064
+ import { existsSync as existsSync32, mkdirSync as mkdirSync22, readFileSync as readFileSync32, readdirSync as readdirSync12, rmSync as rmSync18, statSync as statSync11, writeFileSync as writeFileSync23 } from "fs";
14934
15065
  import { dirname as dirname17, join as join35 } from "path";
14935
15066
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
14936
15067
  function clonedCheckoutsFile(stateDir) {
@@ -14938,7 +15069,7 @@ function clonedCheckoutsFile(stateDir) {
14938
15069
  }
14939
15070
  function readClonedCheckouts(stateDir) {
14940
15071
  try {
14941
- const parsed = JSON.parse(readFileSync31(clonedCheckoutsFile(stateDir), "utf8"));
15072
+ const parsed = JSON.parse(readFileSync32(clonedCheckoutsFile(stateDir), "utf8"));
14942
15073
  return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
14943
15074
  } catch {
14944
15075
  return [];
@@ -15129,7 +15260,7 @@ async function runDeprovision(o, fx, deps) {
15129
15260
  }
15130
15261
 
15131
15262
  // src/pool-member.ts
15132
- import { mkdirSync as mkdirSync23, readFileSync as readFileSync32, renameSync as renameSync4, writeFileSync as writeFileSync24 } from "fs";
15263
+ import { mkdirSync as mkdirSync23, readFileSync as readFileSync33, renameSync as renameSync4, writeFileSync as writeFileSync24 } from "fs";
15133
15264
  import { homedir as homedir8 } from "os";
15134
15265
  import { dirname as dirname18, join as join36 } from "path";
15135
15266
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
@@ -15369,7 +15500,7 @@ function fileMemberStore(dir) {
15369
15500
  return {
15370
15501
  read() {
15371
15502
  try {
15372
- return JSON.parse(readFileSync32(file, "utf8"));
15503
+ return JSON.parse(readFileSync33(file, "utf8"));
15373
15504
  } catch {
15374
15505
  return {};
15375
15506
  }
@@ -15435,7 +15566,7 @@ import { hostname as hostname3 } from "os";
15435
15566
  // src/machine-id.ts
15436
15567
  import { execFileSync as execFileSync11 } from "child_process";
15437
15568
  import { createHash as createHash8 } from "crypto";
15438
- import { existsSync as existsSync33, mkdirSync as mkdirSync24, readFileSync as readFileSync33, writeFileSync as writeFileSync25 } from "fs";
15569
+ import { existsSync as existsSync33, mkdirSync as mkdirSync24, readFileSync as readFileSync34, writeFileSync as writeFileSync25 } from "fs";
15439
15570
  import { dirname as dirname19, join as join37 } from "path";
15440
15571
  function machineIdPathFor(stateDir) {
15441
15572
  return join37(stateDir, "machine-id");
@@ -15452,7 +15583,7 @@ function readRawMachineId(platform2 = process.platform) {
15452
15583
  }
15453
15584
  for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
15454
15585
  if (existsSync33(p)) {
15455
- const id = readFileSync33(p, "utf8").trim();
15586
+ const id = readFileSync34(p, "utf8").trim();
15456
15587
  if (id) return id;
15457
15588
  }
15458
15589
  }
@@ -15464,7 +15595,7 @@ function ensureMachineId(stateDir, opts = {}) {
15464
15595
  if (opts.override?.trim()) return sha256(opts.override.trim());
15465
15596
  const path = machineIdPathFor(stateDir);
15466
15597
  if (existsSync33(path)) {
15467
- const cached = readFileSync33(path, "utf8").trim();
15598
+ const cached = readFileSync34(path, "utf8").trim();
15468
15599
  if (/^[0-9a-f]{64}$/.test(cached)) return cached;
15469
15600
  }
15470
15601
  const raw = (opts.read ?? readRawMachineId)();
@@ -15484,7 +15615,7 @@ function matchShipRows(ships, shipName2, machineId) {
15484
15615
 
15485
15616
  // src/provision.ts
15486
15617
  import { spawnSync as spawnSync9 } from "child_process";
15487
- import { existsSync as existsSync34, readFileSync as readFileSync34, writeFileSync as writeFileSync26 } from "fs";
15618
+ import { existsSync as existsSync34, readFileSync as readFileSync35, writeFileSync as writeFileSync26 } from "fs";
15488
15619
  import { hostname as hostname2 } from "os";
15489
15620
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
15490
15621
 
@@ -16110,7 +16241,7 @@ function realProvisionDeps(crewHome) {
16110
16241
  enableRoute(route2) {
16111
16242
  const file = configFile();
16112
16243
  if (!file) return false;
16113
- const text2 = readFileSync34(file, "utf8");
16244
+ const text2 = readFileSync35(file, "utf8");
16114
16245
  const doc = parseDocument3(text2);
16115
16246
  const routes = doc.get("routes");
16116
16247
  const entry = routes?.items?.find((r) => r.get("route") === route2);
@@ -16136,7 +16267,7 @@ function realProvisionDeps(crewHome) {
16136
16267
  continue;
16137
16268
  }
16138
16269
  for (const p of plan.unitPaths) {
16139
- if (!existsSync34(p) || readFileSync34(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
16270
+ if (!existsSync34(p) || readFileSync35(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
16140
16271
  }
16141
16272
  }
16142
16273
  const label = labelFor(crewHome, "run");
@@ -16160,7 +16291,7 @@ function realProvisionDeps(crewHome) {
16160
16291
  setShipSetting(key, value2) {
16161
16292
  const file = configFile();
16162
16293
  if (!file) return false;
16163
- const doc = parseDocument3(readFileSync34(file, "utf8"));
16294
+ const doc = parseDocument3(readFileSync35(file, "utf8"));
16164
16295
  if (doc.getIn(["ship", key]) === value2) return false;
16165
16296
  doc.setIn(["ship", key], value2);
16166
16297
  writeFileSync26(file, doc.toString());
@@ -16169,7 +16300,7 @@ function realProvisionDeps(crewHome) {
16169
16300
  applyManagedDefaults() {
16170
16301
  const file = configFile();
16171
16302
  if (!file) return [];
16172
- const doc = parseDocument3(readFileSync34(file, "utf8"));
16303
+ const doc = parseDocument3(readFileSync35(file, "utf8"));
16173
16304
  const wrote = applyManagedDefaultsToDoc(doc);
16174
16305
  if (wrote.length) writeFileSync26(file, doc.toString());
16175
16306
  return wrote;
@@ -16199,7 +16330,7 @@ host=${host}
16199
16330
 
16200
16331
  // src/tunnel.ts
16201
16332
  import { spawn as spawn7 } from "child_process";
16202
- import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync35, writeFileSync as writeFileSync27, unlinkSync as unlinkSync3, readdirSync as readdirSync13 } from "fs";
16333
+ import { existsSync as existsSync35, mkdirSync as mkdirSync25, readFileSync as readFileSync36, writeFileSync as writeFileSync27, unlinkSync as unlinkSync3, readdirSync as readdirSync13 } from "fs";
16203
16334
  import { randomInt } from "crypto";
16204
16335
  import { join as join39 } from "path";
16205
16336
  var DEFAULT_SPAWN_OPTIONS = { stdio: "ignore", detached: true };
@@ -16285,7 +16416,7 @@ function readPersistedTunnel(stateDir, workspaceId) {
16285
16416
  const path = tunnelStatePath(stateDir, workspaceId);
16286
16417
  if (!existsSync35(path)) return void 0;
16287
16418
  try {
16288
- return JSON.parse(readFileSync35(path, "utf8"));
16419
+ return JSON.parse(readFileSync36(path, "utf8"));
16289
16420
  } catch {
16290
16421
  return void 0;
16291
16422
  }
@@ -18041,7 +18172,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
18041
18172
  }
18042
18173
 
18043
18174
  // src/repo-refresh.ts
18044
- import { existsSync as existsSync38, mkdirSync as mkdirSync26, readFileSync as readFileSync36, writeFileSync as writeFileSync29 } from "fs";
18175
+ import { existsSync as existsSync38, mkdirSync as mkdirSync26, readFileSync as readFileSync37, writeFileSync as writeFileSync29 } from "fs";
18045
18176
  import { dirname as dirname21 } from "path";
18046
18177
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
18047
18178
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -18072,7 +18203,7 @@ function applyRepoRows(resolved, rows) {
18072
18203
  function persistRepoRows(stateDir, routeName, rows) {
18073
18204
  const path = resolvedPathFor(stateDir, routeName);
18074
18205
  if (!existsSync38(path)) return;
18075
- const raw = JSON.parse(readFileSync36(path, "utf8"));
18206
+ const raw = JSON.parse(readFileSync37(path, "utf8"));
18076
18207
  applyRepoRows(raw, rows);
18077
18208
  mkdirSync26(dirname21(path), { recursive: true });
18078
18209
  writeFileSync29(path, `${JSON.stringify(raw, null, 2)}
@@ -18810,7 +18941,7 @@ async function collectDiagnostics(d) {
18810
18941
  }
18811
18942
 
18812
18943
  // src/release-run.ts
18813
- import { readFileSync as readFileSync37, writeFileSync as writeFileSync31, existsSync as existsSync40, copyFileSync, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync3, rmSync as rmSync19 } from "fs";
18944
+ import { readFileSync as readFileSync38, writeFileSync as writeFileSync31, existsSync as existsSync40, copyFileSync, mkdirSync as mkdirSync28, mkdtempSync as mkdtempSync3, rmSync as rmSync19 } from "fs";
18814
18945
  import { dirname as dirname24, join as join43 } from "path";
18815
18946
  import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
18816
18947
 
@@ -19599,7 +19730,7 @@ async function bump(o, size) {
19599
19730
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
19600
19731
  return null;
19601
19732
  }
19602
- const firstText = readTextAt(first, (p) => readFileSync37(p, "utf8"));
19733
+ const firstText = readTextAt(first, (p) => readFileSync38(p, "utf8"));
19603
19734
  const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
19604
19735
  if (problem) {
19605
19736
  o.emit.error(problem);
@@ -19618,7 +19749,7 @@ async function bump(o, size) {
19618
19749
  return version;
19619
19750
  }
19620
19751
  for (const f of files) {
19621
- const src = readTextAt(f, (p) => readFileSync37(p, "utf8"));
19752
+ const src = readTextAt(f, (p) => readFileSync38(p, "utf8"));
19622
19753
  const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
19623
19754
  if (out === src) {
19624
19755
  o.emit.error(`no version field in ${f}`);
@@ -19637,7 +19768,7 @@ function writeChangelog(o, version, entries) {
19637
19768
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
19638
19769
  return;
19639
19770
  }
19640
- const existing = existsAt(path, existsSync40) ? readTextAt(path, (p) => readFileSync37(p, "utf8")) : "# Changelog\n";
19771
+ const existing = existsAt(path, existsSync40) ? readTextAt(path, (p) => readFileSync38(p, "utf8")) : "# Changelog\n";
19641
19772
  writeTextAt(path, insertChangelogSection(existing, section), writeFileSync31);
19642
19773
  }
19643
19774
  async function confirm(o, expected) {
@@ -21260,7 +21391,7 @@ function nextRoles(decision, ran) {
21260
21391
  }
21261
21392
 
21262
21393
  // src/ship-name.ts
21263
- import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync38, renameSync as renameSync5, writeFileSync as writeFileSync33 } from "fs";
21394
+ import { existsSync as existsSync43, mkdirSync as mkdirSync31, readFileSync as readFileSync39, renameSync as renameSync5, writeFileSync as writeFileSync33 } from "fs";
21264
21395
  import { dirname as dirname27 } from "path";
21265
21396
  import { parseDocument as parseDocument5 } from "yaml";
21266
21397
  var ShipNameError = class extends Error {
@@ -21324,7 +21455,7 @@ async function syncRouteName(i) {
21324
21455
  function readSyncedName(resolvedFile) {
21325
21456
  if (!existsSync43(resolvedFile)) return void 0;
21326
21457
  try {
21327
- const v = JSON.parse(readFileSync38(resolvedFile, "utf8")).shipName;
21458
+ const v = JSON.parse(readFileSync39(resolvedFile, "utf8")).shipName;
21328
21459
  return typeof v === "string" ? v : void 0;
21329
21460
  } catch {
21330
21461
  return void 0;
@@ -21334,7 +21465,7 @@ function writeSyncedName(resolvedFile, name) {
21334
21465
  if (!existsSync43(resolvedFile)) return;
21335
21466
  let raw;
21336
21467
  try {
21337
- raw = JSON.parse(readFileSync38(resolvedFile, "utf8"));
21468
+ raw = JSON.parse(readFileSync39(resolvedFile, "utf8"));
21338
21469
  } catch {
21339
21470
  return;
21340
21471
  }
@@ -21349,7 +21480,7 @@ function writeSyncedName(resolvedFile, name) {
21349
21480
  async function reconcileShipName(i) {
21350
21481
  let local = i.ship.name;
21351
21482
  try {
21352
- local = shipNameOfYaml(readFileSync38(i.configFile, "utf8")) ?? local;
21483
+ local = shipNameOfYaml(readFileSync39(i.configFile, "utf8")) ?? local;
21353
21484
  } catch {
21354
21485
  }
21355
21486
  const resolvedFile = resolvedPathFor(i.stateDir, i.route);
@@ -21373,7 +21504,7 @@ async function reconcileShipName(i) {
21373
21504
  }
21374
21505
  if (result.status !== "ok") return result;
21375
21506
  if (result.action === "adopt" || result.action === "row-wins") {
21376
- const text2 = readFileSync38(i.configFile, "utf8");
21507
+ const text2 = readFileSync39(i.configFile, "utf8");
21377
21508
  writeFileSync33(i.configFile, setShipNameInYaml(text2, result.name));
21378
21509
  i.ship.name = result.name;
21379
21510
  if (result.action === "row-wins") {
@@ -22033,7 +22164,7 @@ function describeCapability(i) {
22033
22164
  }
22034
22165
 
22035
22166
  // src/agents-sync-run.ts
22036
- import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync39, writeFileSync as writeFileSync34 } from "fs";
22167
+ import { existsSync as existsSync44, mkdirSync as mkdirSync32, readFileSync as readFileSync40, writeFileSync as writeFileSync34 } from "fs";
22037
22168
  import { dirname as dirname28 } from "path";
22038
22169
  async function runAgentsSync(target, o) {
22039
22170
  const dryRun = o.dryRun ?? false;
@@ -22053,6 +22184,7 @@ async function runAgentsSync(target, o) {
22053
22184
  for (const p of personaResult.outcomes) o.say(describeSyncOutcome(p));
22054
22185
  for (const l of personaResult.crewLinks) o.say(describeCrewLink(l));
22055
22186
  if (personaResult.releaseNote) o.say(personaResult.releaseNote);
22187
+ if (personaResult.chatNote) o.say(personaResult.chatNote);
22056
22188
  const briefs = Object.fromEntries(ROLE_NAMES.map((r) => [r, personaDefaultPrompt(target.promptsDir, r)]));
22057
22189
  for (const w of skillMarkerWarnings(target.promptsDir, briefs)) o.warn(`warning: ${w}`);
22058
22190
  let skillResult;
@@ -22065,9 +22197,10 @@ async function runAgentsSync(target, o) {
22065
22197
  }
22066
22198
  }
22067
22199
  for (const s of skillResult?.outcomes ?? []) o.say(describeSkillSyncOutcome(s));
22200
+ for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
22068
22201
  if (!dryRun) {
22069
22202
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
22070
- const raw = existsSync44(resolvedPath) ? JSON.parse(readFileSync39(resolvedPath, "utf8")) : {};
22203
+ const raw = existsSync44(resolvedPath) ? JSON.parse(readFileSync40(resolvedPath, "utf8")) : {};
22071
22204
  raw.agentPersonas = personaResult.agentPersonas;
22072
22205
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
22073
22206
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
@@ -22209,7 +22342,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
22209
22342
 
22210
22343
  // src/repos-check.ts
22211
22344
  import { spawnSync as spawnSync11 } from "child_process";
22212
- import { readFileSync as readFileSync40 } from "fs";
22345
+ import { readFileSync as readFileSync41 } from "fs";
22213
22346
  import { basename as basename11 } from "path";
22214
22347
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
22215
22348
  function checkHookSyntax(script, shell) {
@@ -22250,7 +22383,7 @@ function checkRepoSpec(dir, opts = {}) {
22250
22383
  }
22251
22384
  let parsed;
22252
22385
  try {
22253
- parsed = parseRepoConfig(readFileSync40(file, "utf8"), file);
22386
+ parsed = parseRepoConfig(readFileSync41(file, "utf8"), file);
22254
22387
  } catch (e) {
22255
22388
  if (!(e instanceof RepoConfigError)) throw e;
22256
22389
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -22782,7 +22915,7 @@ function planSampleTicket(i) {
22782
22915
  }
22783
22916
 
22784
22917
  // src/worktree-sweep.ts
22785
- import { existsSync as existsSync45, readFileSync as readFileSync41, readdirSync as readdirSync14 } from "fs";
22918
+ import { existsSync as existsSync45, readFileSync as readFileSync42, readdirSync as readdirSync14 } from "fs";
22786
22919
  import { basename as basename13, dirname as dirname30, join as join45, resolve as resolve5 } from "path";
22787
22920
  function planWorktreeSweep(target, tickets, contract) {
22788
22921
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
@@ -22963,7 +23096,7 @@ function isHandBackMerge(path, base) {
22963
23096
  if (!msgPath) return false;
22964
23097
  let first;
22965
23098
  try {
22966
- first = readFileSync41(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
23099
+ first = readFileSync42(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
22967
23100
  } catch {
22968
23101
  return false;
22969
23102
  }
@@ -23113,11 +23246,11 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
23113
23246
  }
23114
23247
 
23115
23248
  // src/cli.ts
23116
- import { realpathSync as realpathSync3, readFileSync as readFileSync48, existsSync as existsSync54, mkdirSync as mkdirSync40, writeFileSync as writeFileSync40, rmSync as rmSync25, unlinkSync as unlinkSync5, copyFileSync as copyFileSync2, renameSync as renameSync7, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
23249
+ import { realpathSync as realpathSync3, readFileSync as readFileSync49, existsSync as existsSync54, mkdirSync as mkdirSync40, writeFileSync as writeFileSync40, rmSync as rmSync25, unlinkSync as unlinkSync5, copyFileSync as copyFileSync2, renameSync as renameSync7, statSync as statSync17, readdirSync as readdirSync20 } from "fs";
23117
23250
  import { createInterface } from "readline/promises";
23118
23251
 
23119
23252
  // src/periscope-cmd.ts
23120
- import { existsSync as existsSync47, mkdirSync as mkdirSync33, readFileSync as readFileSync42, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
23253
+ import { existsSync as existsSync47, mkdirSync as mkdirSync33, readFileSync as readFileSync43, rmSync as rmSync21, writeFileSync as writeFileSync35 } from "fs";
23121
23254
  import { join as join47 } from "path";
23122
23255
  var PeriscopeError = class extends Error {
23123
23256
  };
@@ -23143,7 +23276,7 @@ function writePeriscopePrior(stateDir, ticketRecordId, prior) {
23143
23276
  function readPeriscopePrior(stateDir, ticketRecordId) {
23144
23277
  try {
23145
23278
  const p = priorPath(stateDir, ticketRecordId);
23146
- return existsSync47(p) ? JSON.parse(readFileSync42(p, "utf8")) : void 0;
23279
+ return existsSync47(p) ? JSON.parse(readFileSync43(p, "utf8")) : void 0;
23147
23280
  } catch {
23148
23281
  return void 0;
23149
23282
  }
@@ -23699,7 +23832,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
23699
23832
 
23700
23833
  // src/ssh-keys.ts
23701
23834
  import { execFileSync as execFileSync14 } from "child_process";
23702
- import { existsSync as existsSync48, mkdirSync as mkdirSync34, readFileSync as readFileSync43, chmodSync as chmodSync3 } from "fs";
23835
+ import { existsSync as existsSync48, mkdirSync as mkdirSync34, readFileSync as readFileSync44, chmodSync as chmodSync3 } from "fs";
23703
23836
  import { dirname as dirname31, join as join49 } from "path";
23704
23837
  var SshKeyError = class extends Error {
23705
23838
  };
@@ -23733,7 +23866,7 @@ function ensureShipSshKeypair(stateDir) {
23733
23866
  if (!existsSync48(publicKeyPath)) {
23734
23867
  throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
23735
23868
  }
23736
- const publicKey = readFileSync43(publicKeyPath, "utf8").trim();
23869
+ const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
23737
23870
  return { privateKeyPath, publicKeyPath, publicKey };
23738
23871
  }
23739
23872
  function sshKeygenAvailable() {
@@ -23897,7 +24030,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
23897
24030
  import { createServer as createHttpServer } from "http";
23898
24031
  import { spawn as spawn9 } from "child_process";
23899
24032
  import { randomBytes } from "crypto";
23900
- import { existsSync as existsSync49, mkdirSync as mkdirSync35, readFileSync as readFileSync44, writeFileSync as writeFileSync36, unlinkSync as unlinkSync4, readdirSync as readdirSync16 } from "fs";
24033
+ import { existsSync as existsSync49, mkdirSync as mkdirSync35, readFileSync as readFileSync45, writeFileSync as writeFileSync36, unlinkSync as unlinkSync4, readdirSync as readdirSync16 } from "fs";
23901
24034
  import { join as join50 } from "path";
23902
24035
 
23903
24036
  // src/secret-compare.ts
@@ -23997,7 +24130,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
23997
24130
  const path = syncDaemonStatePath(stateDir, workspaceId);
23998
24131
  if (!existsSync49(path)) return void 0;
23999
24132
  try {
24000
- return JSON.parse(readFileSync44(path, "utf8"));
24133
+ return JSON.parse(readFileSync45(path, "utf8"));
24001
24134
  } catch {
24002
24135
  return void 0;
24003
24136
  }
@@ -24546,12 +24679,12 @@ function contractFixers(dir, baseRef, tickets, locate) {
24546
24679
  }
24547
24680
 
24548
24681
  // src/daemon.ts
24549
- import { existsSync as existsSync51, mkdirSync as mkdirSync38, readFileSync as readFileSync46, readdirSync as readdirSync17, rmSync as rmSync22, statSync as statSync15, writeFileSync as writeFileSync38 } from "fs";
24682
+ import { existsSync as existsSync51, mkdirSync as mkdirSync38, readFileSync as readFileSync47, readdirSync as readdirSync17, rmSync as rmSync22, statSync as statSync15, writeFileSync as writeFileSync38 } from "fs";
24550
24683
  import { join as join53 } from "path";
24551
24684
  import { randomBytes as randomBytes2 } from "crypto";
24552
24685
 
24553
24686
  // src/noop-runs.ts
24554
- import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync45, renameSync as renameSync6, writeFileSync as writeFileSync37 } from "fs";
24687
+ import { existsSync as existsSync50, mkdirSync as mkdirSync37, readFileSync as readFileSync46, renameSync as renameSync6, writeFileSync as writeFileSync37 } from "fs";
24555
24688
  import { join as join52 } from "path";
24556
24689
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
24557
24690
  var DEFAULT_NOOP_REPEATS = 3;
@@ -24560,7 +24693,7 @@ var noopRunsPath = (stateDir) => join52(stateDir, "noop-runs.json");
24560
24693
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
24561
24694
  function readNoopRuns(stateDir) {
24562
24695
  try {
24563
- const v = JSON.parse(readFileSync45(noopRunsPath(stateDir), "utf8"));
24696
+ const v = JSON.parse(readFileSync46(noopRunsPath(stateDir), "utf8"));
24564
24697
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
24565
24698
  } catch {
24566
24699
  return {};
@@ -24761,7 +24894,7 @@ function noteDaemonStarted(stateDir, now = Date.now()) {
24761
24894
  }
24762
24895
  function readDaemonStarted(stateDir) {
24763
24896
  try {
24764
- const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
24897
+ const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8")).startedAt;
24765
24898
  return typeof v === "number" ? v : null;
24766
24899
  } catch {
24767
24900
  return null;
@@ -25527,7 +25660,9 @@ function cliMessage(r) {
25527
25660
  function failureStatus(r) {
25528
25661
  const m = cliMessage(r);
25529
25662
  if (/^no periscope for ticket /.test(m)) return 404;
25663
+ if (/^no ticket numbered /.test(m)) return 404;
25530
25664
  if (/already hosts \d+ live periscope/.test(m)) return 409;
25665
+ if (/ is held by | has a live periscope on | has a run in flight on /.test(m)) return 409;
25531
25666
  return r.code === 1 ? 422 : 500;
25532
25667
  }
25533
25668
  function lastJsonLine(stdout) {
@@ -25653,7 +25788,15 @@ async function handlePeriscopes(h, q2) {
25653
25788
  } : void 0);
25654
25789
  }
25655
25790
  const repo = plainText(b.repo, "repo", true);
25656
- const topic = plainText(b.topic, "topic", true);
25791
+ const hasIssue = b.issue !== void 0 && b.issue !== null && b.issue !== "";
25792
+ const topic = plainText(b.topic, "topic", !hasIssue);
25793
+ let issue;
25794
+ if (hasIssue) {
25795
+ const raw = typeof b.issue === "number" ? String(b.issue) : typeof b.issue === "string" ? b.issue.trim() : "";
25796
+ if (!TICKET_RE.test(raw)) return err(400, "issue must be a ticket number such as 123 or CREW-123");
25797
+ if (topic !== void 0 && !isErr(topic)) return err(400, "issue and topic cannot be combined: issue periscopes a ticket that already exists");
25798
+ issue = String(Number.parseInt(/(\d+)$/.exec(raw)[1], 10));
25799
+ }
25657
25800
  const requestedBy = plainText(b.requestedBy, "requestedBy", false);
25658
25801
  for (const v of [repo, topic, requestedBy]) if (isErr(v)) return err(400, v.error);
25659
25802
  if (b.isolate !== void 0 && typeof b.isolate !== "boolean") return err(400, "isolate must be a boolean");
@@ -25672,11 +25815,10 @@ async function handlePeriscopes(h, q2) {
25672
25815
  "up",
25673
25816
  picked.route,
25674
25817
  repo,
25675
- "--topic",
25676
- topic,
25818
+ ...issue ? ["--issue", issue] : ["--topic", topic],
25677
25819
  "--host",
25678
25820
  h.previewHost,
25679
- ...requestedBy ? ["--requested-by", requestedBy] : [],
25821
+ ...requestedBy && !issue ? ["--requested-by", requestedBy] : [],
25680
25822
  ...b.isolate === true ? ["--isolate"] : [],
25681
25823
  ...h.mcp ? ["--serve-mcp"] : [],
25682
25824
  "--no-open",
@@ -26164,7 +26306,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
26164
26306
 
26165
26307
  // src/periscope-endpoints.ts
26166
26308
  import { randomBytes as randomBytes3 } from "crypto";
26167
- import { chmodSync as chmodSync5, existsSync as existsSync53, mkdirSync as mkdirSync39, readdirSync as readdirSync19, readFileSync as readFileSync47, rmSync as rmSync24, writeFileSync as writeFileSync39 } from "fs";
26309
+ import { chmodSync as chmodSync5, existsSync as existsSync53, mkdirSync as mkdirSync39, readdirSync as readdirSync19, readFileSync as readFileSync48, rmSync as rmSync24, writeFileSync as writeFileSync39 } from "fs";
26168
26310
  import { join as join55 } from "path";
26169
26311
  var secretDir = (stateDir) => join55(stateDir, "periscope-mcp");
26170
26312
  var secretFile = (stateDir, id) => join55(secretDir(stateDir), `${id}.json`);
@@ -26181,7 +26323,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
26181
26323
  }
26182
26324
  function readPeriscopeSecret(stateDir, ticketRecordId) {
26183
26325
  try {
26184
- const v = JSON.parse(readFileSync47(secretFile(stateDir, ticketRecordId), "utf8"));
26326
+ const v = JSON.parse(readFileSync48(secretFile(stateDir, ticketRecordId), "utf8"));
26185
26327
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
26186
26328
  } catch {
26187
26329
  return void 0;
@@ -26192,7 +26334,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
26192
26334
  }
26193
26335
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
26194
26336
  try {
26195
- return JSON.parse(readFileSync47(endpointFile(stateDir, ticketRecordId), "utf8"));
26337
+ return JSON.parse(readFileSync48(endpointFile(stateDir, ticketRecordId), "utf8"));
26196
26338
  } catch {
26197
26339
  return void 0;
26198
26340
  }
@@ -26941,7 +27083,7 @@ if (command === "provision") {
26941
27083
  process.exit(outcome.code);
26942
27084
  }
26943
27085
  if (command === "pool-member") {
26944
- const pool = poolConfigFrom(argv, process.env, () => readFileSync48(0, "utf8"));
27086
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync49(0, "utf8"));
26945
27087
  if (typeof pool === "string") {
26946
27088
  process.stderr.write(`crew pool-member: ${pool}
26947
27089
  `);
@@ -27205,7 +27347,7 @@ if (command === "passenger-sync-daemon") {
27205
27347
  throw e;
27206
27348
  }
27207
27349
  if (command === "credential") {
27208
- const r = runCredential(positional[1], readFileSync48(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
27350
+ const r = runCredential(positional[1], readFileSync49(0, "utf8"), cfg.ship.forges, cfg.ship.stateDir, process.env, !flag("no-miss"));
27209
27351
  process.stdout.write(r.out);
27210
27352
  process.stderr.write(r.err);
27211
27353
  process.exit(r.code);
@@ -27217,9 +27359,9 @@ if (command === "passenger-sync-daemon") {
27217
27359
  forges: cfg.ship.forges,
27218
27360
  stateDir: cfg.ship.stateDir,
27219
27361
  configFile: cfg.configFile,
27220
- readFile: (p) => readFileSync48(p, "utf8"),
27362
+ readFile: (p) => readFileSync49(p, "utf8"),
27221
27363
  writeFile: (p, t) => writeFileSync40(p, t),
27222
- stdin: () => readFileSync48(0, "utf8"),
27364
+ stdin: () => readFileSync49(0, "utf8"),
27223
27365
  env: process.env
27224
27366
  }
27225
27367
  );
@@ -27616,7 +27758,7 @@ if (command === "passenger-sync-daemon") {
27616
27758
  for (const a of plan.actions) {
27617
27759
  if (a.kind === "enable") {
27618
27760
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
27619
- writeFileSync40(cfg.configFile, planEnable(readFileSync48(cfg.configFile, "utf8"), a.route));
27761
+ writeFileSync40(cfg.configFile, planEnable(readFileSync49(cfg.configFile, "utf8"), a.route));
27620
27762
  enabledSound.add(a.route);
27621
27763
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
27622
27764
  } else {
@@ -29256,10 +29398,12 @@ ${cu.tail.trimEnd()}
29256
29398
  process.stdout.write(`route: ${target.route}
29257
29399
  `);
29258
29400
  for (const o of result.outcomes) process.stdout.write(`${describeSkillSyncOutcome(o)}
29401
+ `);
29402
+ for (const w of result.warnings) process.stderr.write(`warning: ${w}
29259
29403
  `);
29260
29404
  if (!dryRun) {
29261
29405
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
29262
- const raw = existsSync54(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
29406
+ const raw = existsSync54(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
29263
29407
  raw.agentSkills = result.agentSkills;
29264
29408
  mkdirSync40(dirOf2(resolvedPath), { recursive: true });
29265
29409
  writeFileSync40(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -29285,7 +29429,7 @@ ${cu.tail.trimEnd()}
29285
29429
  throw e;
29286
29430
  }
29287
29431
  const oldName = cfg.ship.name;
29288
- writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), newName));
29432
+ writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync49(cfg.configFile, "utf8"), newName));
29289
29433
  cfg.ship.name = newName;
29290
29434
  let renameMachineId;
29291
29435
  try {
@@ -29332,7 +29476,7 @@ ${cu.tail.trimEnd()}
29332
29476
  process.exit(2);
29333
29477
  };
29334
29478
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
29335
- const configText = readFileSync48(cfg.configFile, "utf8");
29479
+ const configText = readFileSync49(cfg.configFile, "utf8");
29336
29480
  if (sub === "check") {
29337
29481
  try {
29338
29482
  const routeArg = value("route") ?? positional[2];
@@ -29373,7 +29517,7 @@ ${cu.tail.trimEnd()}
29373
29517
  }
29374
29518
  }, read: (r) => {
29375
29519
  try {
29376
- return readFileSync48(resolvePath(dir, r), "utf8");
29520
+ return readFileSync49(resolvePath(dir, r), "utf8");
29377
29521
  } catch {
29378
29522
  return void 0;
29379
29523
  }
@@ -29524,7 +29668,7 @@ ${cu.tail.trimEnd()}
29524
29668
  let resolvedRemotes;
29525
29669
  if (existsSync54(resolvedFile)) {
29526
29670
  try {
29527
- resolvedRemotes = JSON.parse(readFileSync48(resolvedFile, "utf8"));
29671
+ resolvedRemotes = JSON.parse(readFileSync49(resolvedFile, "utf8"));
29528
29672
  } catch {
29529
29673
  }
29530
29674
  }
@@ -29546,7 +29690,7 @@ ${cu.tail.trimEnd()}
29546
29690
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
29547
29691
  try {
29548
29692
  const path = resolvePath(d, f);
29549
- return Object.keys(parseRepoConfig(readFileSync48(path, "utf8"), path).hooks).length > 0;
29693
+ return Object.keys(parseRepoConfig(readFileSync49(path, "utf8"), path).hooks).length > 0;
29550
29694
  } catch {
29551
29695
  return false;
29552
29696
  }
@@ -29655,7 +29799,7 @@ ${cu.tail.trimEnd()}
29655
29799
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
29656
29800
  `);
29657
29801
  if (existsSync54(resolvedFile)) {
29658
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
29802
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
29659
29803
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
29660
29804
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
29661
29805
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -30037,7 +30181,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
30037
30181
  process.exit(2);
30038
30182
  }
30039
30183
  if (found.shipNameAdopted && !dryRun) {
30040
- writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), found.shipNameAdopted));
30184
+ writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync49(cfg.configFile, "utf8"), found.shipNameAdopted));
30041
30185
  cfg.ship.name = found.shipNameAdopted;
30042
30186
  }
30043
30187
  if (found.shipRow) {
@@ -30083,7 +30227,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
30083
30227
  const hadPreviousFile = existsSync54(resolvedPath);
30084
30228
  if (hadPreviousFile) {
30085
30229
  try {
30086
- previous = JSON.parse(readFileSync48(resolvedPath, "utf8"));
30230
+ previous = JSON.parse(readFileSync49(resolvedPath, "utf8"));
30087
30231
  } catch {
30088
30232
  }
30089
30233
  }
@@ -31612,7 +31756,7 @@ ${where.join("\n")}`);
31612
31756
  };
31613
31757
  const droppedRoutes = [];
31614
31758
  try {
31615
- const rawCfg = parseYaml2(readFileSync48(cfg.configFile, "utf8"));
31759
+ const rawCfg = parseYaml3(readFileSync49(cfg.configFile, "utf8"));
31616
31760
  for (const r of rawCfg?.routes ?? []) {
31617
31761
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
31618
31762
  try {
@@ -31742,7 +31886,7 @@ ${where.join("\n")}`);
31742
31886
  }
31743
31887
  case "log": {
31744
31888
  try {
31745
- const text2 = readFileSync48(cfg.ship.logFile, "utf8").split("\n");
31889
+ const text2 = readFileSync49(cfg.ship.logFile, "utf8").split("\n");
31746
31890
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
31747
31891
  `);
31748
31892
  } catch {
@@ -31765,7 +31909,7 @@ ${where.join("\n")}`);
31765
31909
  };
31766
31910
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
31767
31911
  const tracker = new Tracker(route2, cfg.ship);
31768
- const configText = readFileSync48(cfg.configFile, "utf8");
31912
+ const configText = readFileSync49(cfg.configFile, "utf8");
31769
31913
  const cfgBase = dirname35(cfg.configFile);
31770
31914
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
31771
31915
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -31803,7 +31947,7 @@ ${where.join("\n")}`);
31803
31947
  if (row) {
31804
31948
  await tracker.deleteRepoRow(row.id);
31805
31949
  if (existsSync54(resolvedFile)) {
31806
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
31950
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
31807
31951
  if (raw.repoNames) delete raw.repoNames[row.id];
31808
31952
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
31809
31953
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -31843,7 +31987,7 @@ ${where.join("\n")}`);
31843
31987
  });
31844
31988
  repoId = (await tracker.createRepoRow(payload)).id;
31845
31989
  if (existsSync54(resolvedFile)) {
31846
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
31990
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
31847
31991
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
31848
31992
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
31849
31993
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -32351,7 +32495,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
32351
32495
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
32352
32496
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
32353
32497
  try {
32354
- return readFileSync48(p, "utf8");
32498
+ return readFileSync49(p, "utf8");
32355
32499
  } catch {
32356
32500
  return null;
32357
32501
  }
@@ -32366,7 +32510,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
32366
32510
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
32367
32511
  const keeps = unitAbandonsAgents(pPlan, (p) => {
32368
32512
  try {
32369
- return readFileSync48(p, "utf8");
32513
+ return readFileSync49(p, "utf8");
32370
32514
  } catch {
32371
32515
  return null;
32372
32516
  }