@tablation/crew 0.135.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);
@@ -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,12 +11927,12 @@ 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"`);
@@ -12525,7 +12589,7 @@ var ALLOWANCE_REFUSAL_MARKER = "AI_ALLOWANCE_EXCEEDED";
12525
12589
  function streamShowsAllowanceRefusal(streamPath) {
12526
12590
  let raw;
12527
12591
  try {
12528
- raw = readFileSync27(streamPath, "utf8");
12592
+ raw = readFileSync28(streamPath, "utf8");
12529
12593
  } catch {
12530
12594
  return false;
12531
12595
  }
@@ -12611,10 +12675,10 @@ function planAgentRun(o) {
12611
12675
  let ageSeconds;
12612
12676
  if (existsSync27(digestPath2)) {
12613
12677
  ageSeconds = Math.floor((now() - statSync9(digestPath2).mtimeMs) / 1e3);
12614
- if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync27(digestPath2, "utf8");
12678
+ if (ageSeconds <= DIGEST_MAX_AGE_SECONDS) digest = readFileSync28(digestPath2, "utf8");
12615
12679
  }
12616
- const common = usesCommon ? readFileSync27(commonPath, "utf8") : "";
12617
- const brief = readFileSync27(briefPath, "utf8");
12680
+ const common = usesCommon ? readFileSync28(commonPath, "utf8") : "";
12681
+ const brief = readPersonaFile(briefPath).body;
12618
12682
  const effectiveCommon = o.divergedPrompt ? "" : common;
12619
12683
  const effectiveBrief = appendAdditions(o.divergedPrompt ?? brief, o.personaAdditions);
12620
12684
  const localSkills = new Map(listLocalSkills(o.route.promptsDir).map((s) => [s.name, s.prompt]));
@@ -12775,7 +12839,7 @@ function describePlan(p) {
12775
12839
  var pidPathFor = (streamPath) => `${streamPath}.pid`;
12776
12840
  function readRunSidecar(streamPath) {
12777
12841
  try {
12778
- const sc = JSON.parse(readFileSync27(pidPathFor(streamPath), "utf8"));
12842
+ const sc = JSON.parse(readFileSync28(pidPathFor(streamPath), "utf8"));
12779
12843
  return typeof sc.pid === "number" && typeof sc.spawnedAt === "string" && typeof sc.role === "string" ? sc : null;
12780
12844
  } catch {
12781
12845
  return null;
@@ -13397,7 +13461,7 @@ function runFinished(streamPath) {
13397
13461
  const path = `${streamPath}.meta.json`;
13398
13462
  if (!existsSync28(path)) return false;
13399
13463
  try {
13400
- return JSON.parse(readFileSync28(path, "utf8")).running !== true;
13464
+ return JSON.parse(readFileSync29(path, "utf8")).running !== true;
13401
13465
  } catch {
13402
13466
  return true;
13403
13467
  }
@@ -13622,8 +13686,12 @@ function realDeprovisionDeps(cfg, emit, crewHome, getStore) {
13622
13686
  const out = [];
13623
13687
  for (const r of cfg.routes.filter((x) => x.resolved?.shipsModelId)) {
13624
13688
  try {
13625
- const found = await new Tracker(r, cfg.ship).clearForRelease(cfg.ship.name);
13626
- 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
+ });
13627
13695
  } catch (e) {
13628
13696
  out.push({ route: r.route, ok: false, detail: e.message });
13629
13697
  }
@@ -14461,7 +14529,7 @@ function managedGitIdentityWarnings(kind, identity) {
14461
14529
 
14462
14530
  // src/selftest.ts
14463
14531
  import { spawn as spawn6 } from "child_process";
14464
- 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";
14465
14533
  import { tmpdir as tmpdir5 } from "os";
14466
14534
  import { join as join33 } from "path";
14467
14535
  var SELFTEST_TIMEOUT_MS = 12e4;
@@ -14666,7 +14734,7 @@ var fileFor2 = (stateDir) => join33(stateDir, "selftest.json");
14666
14734
  function readSelftest(stateDir) {
14667
14735
  try {
14668
14736
  const p = fileFor2(stateDir);
14669
- return existsSync31(p) ? JSON.parse(readFileSync29(p, "utf8")) : {};
14737
+ return existsSync31(p) ? JSON.parse(readFileSync30(p, "utf8")) : {};
14670
14738
  } catch {
14671
14739
  return {};
14672
14740
  }
@@ -14691,7 +14759,7 @@ import { resolve as resolve7, dirname as dirname35, join as join57, basename as
14691
14759
  import { fileURLToPath as fileURLToPath2 } from "url";
14692
14760
  import { hostname as hostname5, homedir as homedir11, userInfo as userInfo2 } from "os";
14693
14761
  import { spawnSync as spawnSync12 } from "child_process";
14694
- import { parse as parseYaml2 } from "yaml";
14762
+ import { parse as parseYaml3 } from "yaml";
14695
14763
 
14696
14764
  // src/argv.ts
14697
14765
  var VALUE_FLAGS = /* @__PURE__ */ new Set([
@@ -14886,14 +14954,14 @@ function rosterMarkdown(roster, meId) {
14886
14954
  }
14887
14955
 
14888
14956
  // src/connect-resume.ts
14889
- 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";
14890
14958
  import { dirname as dirname16, join as join34 } from "path";
14891
14959
  function lastSessionFile(stateDir) {
14892
14960
  return join34(stateDir, "connect-session.json");
14893
14961
  }
14894
14962
  function readPointers(stateDir) {
14895
14963
  try {
14896
- const parsed = JSON.parse(readFileSync30(lastSessionFile(stateDir), "utf8"));
14964
+ const parsed = JSON.parse(readFileSync31(lastSessionFile(stateDir), "utf8"));
14897
14965
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
14898
14966
  const out = {};
14899
14967
  for (const [host, v] of Object.entries(parsed)) {
@@ -14993,7 +15061,7 @@ async function signOutSessions(o) {
14993
15061
  }
14994
15062
 
14995
15063
  // src/reset.ts
14996
- 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";
14997
15065
  import { dirname as dirname17, join as join35 } from "path";
14998
15066
  import { hostFromUrl as hostFromUrl3 } from "@tablation/client";
14999
15067
  function clonedCheckoutsFile(stateDir) {
@@ -15001,7 +15069,7 @@ function clonedCheckoutsFile(stateDir) {
15001
15069
  }
15002
15070
  function readClonedCheckouts(stateDir) {
15003
15071
  try {
15004
- const parsed = JSON.parse(readFileSync31(clonedCheckoutsFile(stateDir), "utf8"));
15072
+ const parsed = JSON.parse(readFileSync32(clonedCheckoutsFile(stateDir), "utf8"));
15005
15073
  return Array.isArray(parsed) ? parsed.filter((d) => typeof d === "string") : [];
15006
15074
  } catch {
15007
15075
  return [];
@@ -15192,7 +15260,7 @@ async function runDeprovision(o, fx, deps) {
15192
15260
  }
15193
15261
 
15194
15262
  // src/pool-member.ts
15195
- 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";
15196
15264
  import { homedir as homedir8 } from "os";
15197
15265
  import { dirname as dirname18, join as join36 } from "path";
15198
15266
  var POOL_EXIT = { ok: 0, failed: 1, credential: 2 };
@@ -15432,7 +15500,7 @@ function fileMemberStore(dir) {
15432
15500
  return {
15433
15501
  read() {
15434
15502
  try {
15435
- return JSON.parse(readFileSync32(file, "utf8"));
15503
+ return JSON.parse(readFileSync33(file, "utf8"));
15436
15504
  } catch {
15437
15505
  return {};
15438
15506
  }
@@ -15498,7 +15566,7 @@ import { hostname as hostname3 } from "os";
15498
15566
  // src/machine-id.ts
15499
15567
  import { execFileSync as execFileSync11 } from "child_process";
15500
15568
  import { createHash as createHash8 } from "crypto";
15501
- 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";
15502
15570
  import { dirname as dirname19, join as join37 } from "path";
15503
15571
  function machineIdPathFor(stateDir) {
15504
15572
  return join37(stateDir, "machine-id");
@@ -15515,7 +15583,7 @@ function readRawMachineId(platform2 = process.platform) {
15515
15583
  }
15516
15584
  for (const p of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) {
15517
15585
  if (existsSync33(p)) {
15518
- const id = readFileSync33(p, "utf8").trim();
15586
+ const id = readFileSync34(p, "utf8").trim();
15519
15587
  if (id) return id;
15520
15588
  }
15521
15589
  }
@@ -15527,7 +15595,7 @@ function ensureMachineId(stateDir, opts = {}) {
15527
15595
  if (opts.override?.trim()) return sha256(opts.override.trim());
15528
15596
  const path = machineIdPathFor(stateDir);
15529
15597
  if (existsSync33(path)) {
15530
- const cached = readFileSync33(path, "utf8").trim();
15598
+ const cached = readFileSync34(path, "utf8").trim();
15531
15599
  if (/^[0-9a-f]{64}$/.test(cached)) return cached;
15532
15600
  }
15533
15601
  const raw = (opts.read ?? readRawMachineId)();
@@ -15547,7 +15615,7 @@ function matchShipRows(ships, shipName2, machineId) {
15547
15615
 
15548
15616
  // src/provision.ts
15549
15617
  import { spawnSync as spawnSync9 } from "child_process";
15550
- 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";
15551
15619
  import { hostname as hostname2 } from "os";
15552
15620
  import { parseDocument as parseDocument3, isMap as isMap2, isScalar } from "yaml";
15553
15621
 
@@ -16173,7 +16241,7 @@ function realProvisionDeps(crewHome) {
16173
16241
  enableRoute(route2) {
16174
16242
  const file = configFile();
16175
16243
  if (!file) return false;
16176
- const text2 = readFileSync34(file, "utf8");
16244
+ const text2 = readFileSync35(file, "utf8");
16177
16245
  const doc = parseDocument3(text2);
16178
16246
  const routes = doc.get("routes");
16179
16247
  const entry = routes?.items?.find((r) => r.get("route") === route2);
@@ -16199,7 +16267,7 @@ function realProvisionDeps(crewHome) {
16199
16267
  continue;
16200
16268
  }
16201
16269
  for (const p of plan.unitPaths) {
16202
- if (!existsSync34(p) || readFileSync34(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
16270
+ if (!existsSync34(p) || readFileSync35(p, "utf8") !== plan.unitContent[p]) unitsStale = true;
16203
16271
  }
16204
16272
  }
16205
16273
  const label = labelFor(crewHome, "run");
@@ -16223,7 +16291,7 @@ function realProvisionDeps(crewHome) {
16223
16291
  setShipSetting(key, value2) {
16224
16292
  const file = configFile();
16225
16293
  if (!file) return false;
16226
- const doc = parseDocument3(readFileSync34(file, "utf8"));
16294
+ const doc = parseDocument3(readFileSync35(file, "utf8"));
16227
16295
  if (doc.getIn(["ship", key]) === value2) return false;
16228
16296
  doc.setIn(["ship", key], value2);
16229
16297
  writeFileSync26(file, doc.toString());
@@ -16232,7 +16300,7 @@ function realProvisionDeps(crewHome) {
16232
16300
  applyManagedDefaults() {
16233
16301
  const file = configFile();
16234
16302
  if (!file) return [];
16235
- const doc = parseDocument3(readFileSync34(file, "utf8"));
16303
+ const doc = parseDocument3(readFileSync35(file, "utf8"));
16236
16304
  const wrote = applyManagedDefaultsToDoc(doc);
16237
16305
  if (wrote.length) writeFileSync26(file, doc.toString());
16238
16306
  return wrote;
@@ -16262,7 +16330,7 @@ host=${host}
16262
16330
 
16263
16331
  // src/tunnel.ts
16264
16332
  import { spawn as spawn7 } from "child_process";
16265
- 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";
16266
16334
  import { randomInt } from "crypto";
16267
16335
  import { join as join39 } from "path";
16268
16336
  var DEFAULT_SPAWN_OPTIONS = { stdio: "ignore", detached: true };
@@ -16348,7 +16416,7 @@ function readPersistedTunnel(stateDir, workspaceId) {
16348
16416
  const path = tunnelStatePath(stateDir, workspaceId);
16349
16417
  if (!existsSync35(path)) return void 0;
16350
16418
  try {
16351
- return JSON.parse(readFileSync35(path, "utf8"));
16419
+ return JSON.parse(readFileSync36(path, "utf8"));
16352
16420
  } catch {
16353
16421
  return void 0;
16354
16422
  }
@@ -18104,7 +18172,7 @@ async function claimStillHeld(tracker, t, buildingStatus, affinity) {
18104
18172
  }
18105
18173
 
18106
18174
  // src/repo-refresh.ts
18107
- 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";
18108
18176
  import { dirname as dirname21 } from "path";
18109
18177
  var REFRESH_COOLDOWN_MS = 2 * 6e4;
18110
18178
  var UNSERVABLE_PASSES_BEFORE_ATTENTION = 3;
@@ -18135,7 +18203,7 @@ function applyRepoRows(resolved, rows) {
18135
18203
  function persistRepoRows(stateDir, routeName, rows) {
18136
18204
  const path = resolvedPathFor(stateDir, routeName);
18137
18205
  if (!existsSync38(path)) return;
18138
- const raw = JSON.parse(readFileSync36(path, "utf8"));
18206
+ const raw = JSON.parse(readFileSync37(path, "utf8"));
18139
18207
  applyRepoRows(raw, rows);
18140
18208
  mkdirSync26(dirname21(path), { recursive: true });
18141
18209
  writeFileSync29(path, `${JSON.stringify(raw, null, 2)}
@@ -18873,7 +18941,7 @@ async function collectDiagnostics(d) {
18873
18941
  }
18874
18942
 
18875
18943
  // src/release-run.ts
18876
- 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";
18877
18945
  import { dirname as dirname24, join as join43 } from "path";
18878
18946
  import { tmpdir as tmpdir6, hostname as hostname4 } from "os";
18879
18947
 
@@ -19662,7 +19730,7 @@ async function bump(o, size) {
19662
19730
  o.emit.error(`no ${o.repo.release.versionFiles[0]} to read a version from`);
19663
19731
  return null;
19664
19732
  }
19665
- const firstText = readTextAt(first, (p) => readFileSync37(p, "utf8"));
19733
+ const firstText = readTextAt(first, (p) => readFileSync38(p, "utf8"));
19666
19734
  const problem = versionFileProblem(o.repo.release.versionFiles[0], firstText);
19667
19735
  if (problem) {
19668
19736
  o.emit.error(problem);
@@ -19681,7 +19749,7 @@ async function bump(o, size) {
19681
19749
  return version;
19682
19750
  }
19683
19751
  for (const f of files) {
19684
- const src = readTextAt(f, (p) => readFileSync37(p, "utf8"));
19752
+ const src = readTextAt(f, (p) => readFileSync38(p, "utf8"));
19685
19753
  const out = src.replace(/("version"\s*:\s*")[^"]*(")/, `$1${version}$2`);
19686
19754
  if (out === src) {
19687
19755
  o.emit.error(`no version field in ${f}`);
@@ -19700,7 +19768,7 @@ function writeChangelog(o, version, entries) {
19700
19768
  o.emit.emit(`would prepend ${entries.length} entr(ies) to ${file}`);
19701
19769
  return;
19702
19770
  }
19703
- 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";
19704
19772
  writeTextAt(path, insertChangelogSection(existing, section), writeFileSync31);
19705
19773
  }
19706
19774
  async function confirm(o, expected) {
@@ -21323,7 +21391,7 @@ function nextRoles(decision, ran) {
21323
21391
  }
21324
21392
 
21325
21393
  // src/ship-name.ts
21326
- 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";
21327
21395
  import { dirname as dirname27 } from "path";
21328
21396
  import { parseDocument as parseDocument5 } from "yaml";
21329
21397
  var ShipNameError = class extends Error {
@@ -21387,7 +21455,7 @@ async function syncRouteName(i) {
21387
21455
  function readSyncedName(resolvedFile) {
21388
21456
  if (!existsSync43(resolvedFile)) return void 0;
21389
21457
  try {
21390
- const v = JSON.parse(readFileSync38(resolvedFile, "utf8")).shipName;
21458
+ const v = JSON.parse(readFileSync39(resolvedFile, "utf8")).shipName;
21391
21459
  return typeof v === "string" ? v : void 0;
21392
21460
  } catch {
21393
21461
  return void 0;
@@ -21397,7 +21465,7 @@ function writeSyncedName(resolvedFile, name) {
21397
21465
  if (!existsSync43(resolvedFile)) return;
21398
21466
  let raw;
21399
21467
  try {
21400
- raw = JSON.parse(readFileSync38(resolvedFile, "utf8"));
21468
+ raw = JSON.parse(readFileSync39(resolvedFile, "utf8"));
21401
21469
  } catch {
21402
21470
  return;
21403
21471
  }
@@ -21412,7 +21480,7 @@ function writeSyncedName(resolvedFile, name) {
21412
21480
  async function reconcileShipName(i) {
21413
21481
  let local = i.ship.name;
21414
21482
  try {
21415
- local = shipNameOfYaml(readFileSync38(i.configFile, "utf8")) ?? local;
21483
+ local = shipNameOfYaml(readFileSync39(i.configFile, "utf8")) ?? local;
21416
21484
  } catch {
21417
21485
  }
21418
21486
  const resolvedFile = resolvedPathFor(i.stateDir, i.route);
@@ -21436,7 +21504,7 @@ async function reconcileShipName(i) {
21436
21504
  }
21437
21505
  if (result.status !== "ok") return result;
21438
21506
  if (result.action === "adopt" || result.action === "row-wins") {
21439
- const text2 = readFileSync38(i.configFile, "utf8");
21507
+ const text2 = readFileSync39(i.configFile, "utf8");
21440
21508
  writeFileSync33(i.configFile, setShipNameInYaml(text2, result.name));
21441
21509
  i.ship.name = result.name;
21442
21510
  if (result.action === "row-wins") {
@@ -22096,7 +22164,7 @@ function describeCapability(i) {
22096
22164
  }
22097
22165
 
22098
22166
  // src/agents-sync-run.ts
22099
- 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";
22100
22168
  import { dirname as dirname28 } from "path";
22101
22169
  async function runAgentsSync(target, o) {
22102
22170
  const dryRun = o.dryRun ?? false;
@@ -22116,6 +22184,7 @@ async function runAgentsSync(target, o) {
22116
22184
  for (const p of personaResult.outcomes) o.say(describeSyncOutcome(p));
22117
22185
  for (const l of personaResult.crewLinks) o.say(describeCrewLink(l));
22118
22186
  if (personaResult.releaseNote) o.say(personaResult.releaseNote);
22187
+ if (personaResult.chatNote) o.say(personaResult.chatNote);
22119
22188
  const briefs = Object.fromEntries(ROLE_NAMES.map((r) => [r, personaDefaultPrompt(target.promptsDir, r)]));
22120
22189
  for (const w of skillMarkerWarnings(target.promptsDir, briefs)) o.warn(`warning: ${w}`);
22121
22190
  let skillResult;
@@ -22131,7 +22200,7 @@ async function runAgentsSync(target, o) {
22131
22200
  for (const w of skillResult?.warnings ?? []) o.warn(`warning: ${w}`);
22132
22201
  if (!dryRun) {
22133
22202
  const resolvedPath = resolvedPathFor(o.stateDir, target.route);
22134
- const raw = existsSync44(resolvedPath) ? JSON.parse(readFileSync39(resolvedPath, "utf8")) : {};
22203
+ const raw = existsSync44(resolvedPath) ? JSON.parse(readFileSync40(resolvedPath, "utf8")) : {};
22135
22204
  raw.agentPersonas = personaResult.agentPersonas;
22136
22205
  if (skillResult) raw.agentSkills = skillResult.agentSkills;
22137
22206
  if (personaResult.releaseAgentId) raw.releaseAgentId = personaResult.releaseAgentId;
@@ -22273,7 +22342,7 @@ async function showLogEntry(route2, entryId, opts = {}) {
22273
22342
 
22274
22343
  // src/repos-check.ts
22275
22344
  import { spawnSync as spawnSync11 } from "child_process";
22276
- import { readFileSync as readFileSync40 } from "fs";
22345
+ import { readFileSync as readFileSync41 } from "fs";
22277
22346
  import { basename as basename11 } from "path";
22278
22347
  var POSIX_SHELL = /^(?:ba|z|da|k|a|mk)?sh$|^fish$/;
22279
22348
  function checkHookSyntax(script, shell) {
@@ -22314,7 +22383,7 @@ function checkRepoSpec(dir, opts = {}) {
22314
22383
  }
22315
22384
  let parsed;
22316
22385
  try {
22317
- parsed = parseRepoConfig(readFileSync40(file, "utf8"), file);
22386
+ parsed = parseRepoConfig(readFileSync41(file, "utf8"), file);
22318
22387
  } catch (e) {
22319
22388
  if (!(e instanceof RepoConfigError)) throw e;
22320
22389
  return { ...empty, file, error: e.message, exitCode: 1 };
@@ -22846,7 +22915,7 @@ function planSampleTicket(i) {
22846
22915
  }
22847
22916
 
22848
22917
  // src/worktree-sweep.ts
22849
- 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";
22850
22919
  import { basename as basename13, dirname as dirname30, join as join45, resolve as resolve5 } from "path";
22851
22920
  function planWorktreeSweep(target, tickets, contract) {
22852
22921
  const terminal = new Set(contract.statuses.resolved.filter((s) => s !== contract.statuses.verified));
@@ -23027,7 +23096,7 @@ function isHandBackMerge(path, base) {
23027
23096
  if (!msgPath) return false;
23028
23097
  let first;
23029
23098
  try {
23030
- first = readFileSync41(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
23099
+ first = readFileSync42(resolve5(path, msgPath), "utf8").split("\n")[0] ?? "";
23031
23100
  } catch {
23032
23101
  return false;
23033
23102
  }
@@ -23177,11 +23246,11 @@ function planEventsSweep(stateDir, retentionDays, now = Date.now()) {
23177
23246
  }
23178
23247
 
23179
23248
  // src/cli.ts
23180
- 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";
23181
23250
  import { createInterface } from "readline/promises";
23182
23251
 
23183
23252
  // src/periscope-cmd.ts
23184
- 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";
23185
23254
  import { join as join47 } from "path";
23186
23255
  var PeriscopeError = class extends Error {
23187
23256
  };
@@ -23207,7 +23276,7 @@ function writePeriscopePrior(stateDir, ticketRecordId, prior) {
23207
23276
  function readPeriscopePrior(stateDir, ticketRecordId) {
23208
23277
  try {
23209
23278
  const p = priorPath(stateDir, ticketRecordId);
23210
- return existsSync47(p) ? JSON.parse(readFileSync42(p, "utf8")) : void 0;
23279
+ return existsSync47(p) ? JSON.parse(readFileSync43(p, "utf8")) : void 0;
23211
23280
  } catch {
23212
23281
  return void 0;
23213
23282
  }
@@ -23763,7 +23832,7 @@ import { dirname as dirOf2, resolve as resolvePath } from "path";
23763
23832
 
23764
23833
  // src/ssh-keys.ts
23765
23834
  import { execFileSync as execFileSync14 } from "child_process";
23766
- 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";
23767
23836
  import { dirname as dirname31, join as join49 } from "path";
23768
23837
  var SshKeyError = class extends Error {
23769
23838
  };
@@ -23797,7 +23866,7 @@ function ensureShipSshKeypair(stateDir) {
23797
23866
  if (!existsSync48(publicKeyPath)) {
23798
23867
  throw new SshKeyError(`${privateKeyPath} exists but ${publicKeyPath} does not \u2014 regenerate or restore it`);
23799
23868
  }
23800
- const publicKey = readFileSync43(publicKeyPath, "utf8").trim();
23869
+ const publicKey = readFileSync44(publicKeyPath, "utf8").trim();
23801
23870
  return { privateKeyPath, publicKeyPath, publicKey };
23802
23871
  }
23803
23872
  function sshKeygenAvailable() {
@@ -23961,7 +24030,7 @@ async function unregisterEndpoint(workspaceId, info, d) {
23961
24030
  import { createServer as createHttpServer } from "http";
23962
24031
  import { spawn as spawn9 } from "child_process";
23963
24032
  import { randomBytes } from "crypto";
23964
- 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";
23965
24034
  import { join as join50 } from "path";
23966
24035
 
23967
24036
  // src/secret-compare.ts
@@ -24061,7 +24130,7 @@ function readPersistedSyncDaemon(stateDir, workspaceId) {
24061
24130
  const path = syncDaemonStatePath(stateDir, workspaceId);
24062
24131
  if (!existsSync49(path)) return void 0;
24063
24132
  try {
24064
- return JSON.parse(readFileSync44(path, "utf8"));
24133
+ return JSON.parse(readFileSync45(path, "utf8"));
24065
24134
  } catch {
24066
24135
  return void 0;
24067
24136
  }
@@ -24610,12 +24679,12 @@ function contractFixers(dir, baseRef, tickets, locate) {
24610
24679
  }
24611
24680
 
24612
24681
  // src/daemon.ts
24613
- 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";
24614
24683
  import { join as join53 } from "path";
24615
24684
  import { randomBytes as randomBytes2 } from "crypto";
24616
24685
 
24617
24686
  // src/noop-runs.ts
24618
- 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";
24619
24688
  import { join as join52 } from "path";
24620
24689
  var NOOP_DELAYS_MS = [5, 15, 60].map((m) => m * 6e4);
24621
24690
  var DEFAULT_NOOP_REPEATS = 3;
@@ -24624,7 +24693,7 @@ var noopRunsPath = (stateDir) => join52(stateDir, "noop-runs.json");
24624
24693
  var noopRunsKey = (issueId) => `noop_runs:${issueId}`;
24625
24694
  function readNoopRuns(stateDir) {
24626
24695
  try {
24627
- const v = JSON.parse(readFileSync45(noopRunsPath(stateDir), "utf8"));
24696
+ const v = JSON.parse(readFileSync46(noopRunsPath(stateDir), "utf8"));
24628
24697
  return v && typeof v === "object" && !Array.isArray(v) ? v : {};
24629
24698
  } catch {
24630
24699
  return {};
@@ -24825,7 +24894,7 @@ function noteDaemonStarted(stateDir, now = Date.now()) {
24825
24894
  }
24826
24895
  function readDaemonStarted(stateDir) {
24827
24896
  try {
24828
- const v = JSON.parse(readFileSync46(daemonStampFor(stateDir), "utf8")).startedAt;
24897
+ const v = JSON.parse(readFileSync47(daemonStampFor(stateDir), "utf8")).startedAt;
24829
24898
  return typeof v === "number" ? v : null;
24830
24899
  } catch {
24831
24900
  return null;
@@ -25591,7 +25660,9 @@ function cliMessage(r) {
25591
25660
  function failureStatus(r) {
25592
25661
  const m = cliMessage(r);
25593
25662
  if (/^no periscope for ticket /.test(m)) return 404;
25663
+ if (/^no ticket numbered /.test(m)) return 404;
25594
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;
25595
25666
  return r.code === 1 ? 422 : 500;
25596
25667
  }
25597
25668
  function lastJsonLine(stdout) {
@@ -25717,7 +25788,15 @@ async function handlePeriscopes(h, q2) {
25717
25788
  } : void 0);
25718
25789
  }
25719
25790
  const repo = plainText(b.repo, "repo", true);
25720
- 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
+ }
25721
25800
  const requestedBy = plainText(b.requestedBy, "requestedBy", false);
25722
25801
  for (const v of [repo, topic, requestedBy]) if (isErr(v)) return err(400, v.error);
25723
25802
  if (b.isolate !== void 0 && typeof b.isolate !== "boolean") return err(400, "isolate must be a boolean");
@@ -25736,11 +25815,10 @@ async function handlePeriscopes(h, q2) {
25736
25815
  "up",
25737
25816
  picked.route,
25738
25817
  repo,
25739
- "--topic",
25740
- topic,
25818
+ ...issue ? ["--issue", issue] : ["--topic", topic],
25741
25819
  "--host",
25742
25820
  h.previewHost,
25743
- ...requestedBy ? ["--requested-by", requestedBy] : [],
25821
+ ...requestedBy && !issue ? ["--requested-by", requestedBy] : [],
25744
25822
  ...b.isolate === true ? ["--isolate"] : [],
25745
25823
  ...h.mcp ? ["--serve-mcp"] : [],
25746
25824
  "--no-open",
@@ -26228,7 +26306,7 @@ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/
26228
26306
 
26229
26307
  // src/periscope-endpoints.ts
26230
26308
  import { randomBytes as randomBytes3 } from "crypto";
26231
- 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";
26232
26310
  import { join as join55 } from "path";
26233
26311
  var secretDir = (stateDir) => join55(stateDir, "periscope-mcp");
26234
26312
  var secretFile = (stateDir, id) => join55(secretDir(stateDir), `${id}.json`);
@@ -26245,7 +26323,7 @@ function mintPeriscopeSecret(stateDir, ticketRecordId) {
26245
26323
  }
26246
26324
  function readPeriscopeSecret(stateDir, ticketRecordId) {
26247
26325
  try {
26248
- const v = JSON.parse(readFileSync47(secretFile(stateDir, ticketRecordId), "utf8"));
26326
+ const v = JSON.parse(readFileSync48(secretFile(stateDir, ticketRecordId), "utf8"));
26249
26327
  return typeof v.secret === "string" && v.secret ? v.secret : void 0;
26250
26328
  } catch {
26251
26329
  return void 0;
@@ -26256,7 +26334,7 @@ function removePeriscopeSecret(stateDir, ticketRecordId) {
26256
26334
  }
26257
26335
  function readPeriscopeEndpoint(stateDir, ticketRecordId) {
26258
26336
  try {
26259
- return JSON.parse(readFileSync47(endpointFile(stateDir, ticketRecordId), "utf8"));
26337
+ return JSON.parse(readFileSync48(endpointFile(stateDir, ticketRecordId), "utf8"));
26260
26338
  } catch {
26261
26339
  return void 0;
26262
26340
  }
@@ -27005,7 +27083,7 @@ if (command === "provision") {
27005
27083
  process.exit(outcome.code);
27006
27084
  }
27007
27085
  if (command === "pool-member") {
27008
- const pool = poolConfigFrom(argv, process.env, () => readFileSync48(0, "utf8"));
27086
+ const pool = poolConfigFrom(argv, process.env, () => readFileSync49(0, "utf8"));
27009
27087
  if (typeof pool === "string") {
27010
27088
  process.stderr.write(`crew pool-member: ${pool}
27011
27089
  `);
@@ -27269,7 +27347,7 @@ if (command === "passenger-sync-daemon") {
27269
27347
  throw e;
27270
27348
  }
27271
27349
  if (command === "credential") {
27272
- 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"));
27273
27351
  process.stdout.write(r.out);
27274
27352
  process.stderr.write(r.err);
27275
27353
  process.exit(r.code);
@@ -27281,9 +27359,9 @@ if (command === "passenger-sync-daemon") {
27281
27359
  forges: cfg.ship.forges,
27282
27360
  stateDir: cfg.ship.stateDir,
27283
27361
  configFile: cfg.configFile,
27284
- readFile: (p) => readFileSync48(p, "utf8"),
27362
+ readFile: (p) => readFileSync49(p, "utf8"),
27285
27363
  writeFile: (p, t) => writeFileSync40(p, t),
27286
- stdin: () => readFileSync48(0, "utf8"),
27364
+ stdin: () => readFileSync49(0, "utf8"),
27287
27365
  env: process.env
27288
27366
  }
27289
27367
  );
@@ -27680,7 +27758,7 @@ if (command === "passenger-sync-daemon") {
27680
27758
  for (const a of plan.actions) {
27681
27759
  if (a.kind === "enable") {
27682
27760
  if (prompter && !await prompter.confirm(`Route ${a.route} passes every check \u2014 set enabled: true in ${cfg.configFile}?`, false)) continue;
27683
- writeFileSync40(cfg.configFile, planEnable(readFileSync48(cfg.configFile, "utf8"), a.route));
27761
+ writeFileSync40(cfg.configFile, planEnable(readFileSync49(cfg.configFile, "utf8"), a.route));
27684
27762
  enabledSound.add(a.route);
27685
27763
  changed2.push(`enabled route ${a.route} in ${cfg.configFile}`);
27686
27764
  } else {
@@ -29325,7 +29403,7 @@ ${cu.tail.trimEnd()}
29325
29403
  `);
29326
29404
  if (!dryRun) {
29327
29405
  const resolvedPath = resolvedPathFor(cfg.ship.stateDir, target.route);
29328
- const raw = existsSync54(resolvedPath) ? JSON.parse(readFileSync48(resolvedPath, "utf8")) : {};
29406
+ const raw = existsSync54(resolvedPath) ? JSON.parse(readFileSync49(resolvedPath, "utf8")) : {};
29329
29407
  raw.agentSkills = result.agentSkills;
29330
29408
  mkdirSync40(dirOf2(resolvedPath), { recursive: true });
29331
29409
  writeFileSync40(resolvedPath, `${JSON.stringify(raw, null, 2)}
@@ -29351,7 +29429,7 @@ ${cu.tail.trimEnd()}
29351
29429
  throw e;
29352
29430
  }
29353
29431
  const oldName = cfg.ship.name;
29354
- writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), newName));
29432
+ writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync49(cfg.configFile, "utf8"), newName));
29355
29433
  cfg.ship.name = newName;
29356
29434
  let renameMachineId;
29357
29435
  try {
@@ -29398,7 +29476,7 @@ ${cu.tail.trimEnd()}
29398
29476
  process.exit(2);
29399
29477
  };
29400
29478
  if (sub !== "add" && sub !== "list" && sub !== "clone" && sub !== "hooks" && sub !== "check") usage2();
29401
- const configText = readFileSync48(cfg.configFile, "utf8");
29479
+ const configText = readFileSync49(cfg.configFile, "utf8");
29402
29480
  if (sub === "check") {
29403
29481
  try {
29404
29482
  const routeArg = value("route") ?? positional[2];
@@ -29439,7 +29517,7 @@ ${cu.tail.trimEnd()}
29439
29517
  }
29440
29518
  }, read: (r) => {
29441
29519
  try {
29442
- return readFileSync48(resolvePath(dir, r), "utf8");
29520
+ return readFileSync49(resolvePath(dir, r), "utf8");
29443
29521
  } catch {
29444
29522
  return void 0;
29445
29523
  }
@@ -29590,7 +29668,7 @@ ${cu.tail.trimEnd()}
29590
29668
  let resolvedRemotes;
29591
29669
  if (existsSync54(resolvedFile)) {
29592
29670
  try {
29593
- resolvedRemotes = JSON.parse(readFileSync48(resolvedFile, "utf8"));
29671
+ resolvedRemotes = JSON.parse(readFileSync49(resolvedFile, "utf8"));
29594
29672
  } catch {
29595
29673
  }
29596
29674
  }
@@ -29612,7 +29690,7 @@ ${cu.tail.trimEnd()}
29612
29690
  repoHasHooks: (d) => REPO_CONFIG_FILENAMES.some((f) => {
29613
29691
  try {
29614
29692
  const path = resolvePath(d, f);
29615
- return Object.keys(parseRepoConfig(readFileSync48(path, "utf8"), path).hooks).length > 0;
29693
+ return Object.keys(parseRepoConfig(readFileSync49(path, "utf8"), path).hooks).length > 0;
29616
29694
  } catch {
29617
29695
  return false;
29618
29696
  }
@@ -29721,7 +29799,7 @@ ${cu.tail.trimEnd()}
29721
29799
  process.stdout.write(`created Repos row ${String(rowPayload.name)} (${String(rowPayload.remote)}) ${created.id}
29722
29800
  `);
29723
29801
  if (existsSync54(resolvedFile)) {
29724
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
29802
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
29725
29803
  raw.repoNames = { ...raw.repoNames, [created.id]: String(rowPayload.name) };
29726
29804
  raw.repoRemotes = { ...raw.repoRemotes, [created.id]: String(rowPayload.remote) };
29727
29805
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -30103,7 +30181,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
30103
30181
  process.exit(2);
30104
30182
  }
30105
30183
  if (found.shipNameAdopted && !dryRun) {
30106
- writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync48(cfg.configFile, "utf8"), found.shipNameAdopted));
30184
+ writeFileSync40(cfg.configFile, setShipNameInYaml(readFileSync49(cfg.configFile, "utf8"), found.shipNameAdopted));
30107
30185
  cfg.ship.name = found.shipNameAdopted;
30108
30186
  }
30109
30187
  if (found.shipRow) {
@@ -30149,7 +30227,7 @@ Signed in as ${result.identity.email} \u2014 minted an API key in workspace "${r
30149
30227
  const hadPreviousFile = existsSync54(resolvedPath);
30150
30228
  if (hadPreviousFile) {
30151
30229
  try {
30152
- previous = JSON.parse(readFileSync48(resolvedPath, "utf8"));
30230
+ previous = JSON.parse(readFileSync49(resolvedPath, "utf8"));
30153
30231
  } catch {
30154
30232
  }
30155
30233
  }
@@ -31678,7 +31756,7 @@ ${where.join("\n")}`);
31678
31756
  };
31679
31757
  const droppedRoutes = [];
31680
31758
  try {
31681
- const rawCfg = parseYaml2(readFileSync48(cfg.configFile, "utf8"));
31759
+ const rawCfg = parseYaml3(readFileSync49(cfg.configFile, "utf8"));
31682
31760
  for (const r of rawCfg?.routes ?? []) {
31683
31761
  if (typeof r?.route !== "string" || cfg.routes.some((x) => x.route === r.route)) continue;
31684
31762
  try {
@@ -31808,7 +31886,7 @@ ${where.join("\n")}`);
31808
31886
  }
31809
31887
  case "log": {
31810
31888
  try {
31811
- const text2 = readFileSync48(cfg.ship.logFile, "utf8").split("\n");
31889
+ const text2 = readFileSync49(cfg.ship.logFile, "utf8").split("\n");
31812
31890
  process.stdout.write(`${text2.slice(-(Number(value("tail")) || 40)).join("\n")}
31813
31891
  `);
31814
31892
  } catch {
@@ -31831,7 +31909,7 @@ ${where.join("\n")}`);
31831
31909
  };
31832
31910
  if (!route2.resolved) fail2(`route ${route2.route} is not connected \u2014 run \`crew connect\` first`);
31833
31911
  const tracker = new Tracker(route2, cfg.ship);
31834
- const configText = readFileSync48(cfg.configFile, "utf8");
31912
+ const configText = readFileSync49(cfg.configFile, "utf8");
31835
31913
  const cfgBase = dirname35(cfg.configFile);
31836
31914
  const configured2 = configuredRepos(configText, route2.route, cfgBase);
31837
31915
  const dir = configured2.find((r) => r.name === SAMPLE_REPO)?.dir ?? sampleDir(configured2.map((r) => r.dir), route2.reposBasePath, route2.route.split("/")[0]);
@@ -31869,7 +31947,7 @@ ${where.join("\n")}`);
31869
31947
  if (row) {
31870
31948
  await tracker.deleteRepoRow(row.id);
31871
31949
  if (existsSync54(resolvedFile)) {
31872
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
31950
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
31873
31951
  if (raw.repoNames) delete raw.repoNames[row.id];
31874
31952
  if (raw.repoRemotes) delete raw.repoRemotes[row.id];
31875
31953
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -31909,7 +31987,7 @@ ${where.join("\n")}`);
31909
31987
  });
31910
31988
  repoId = (await tracker.createRepoRow(payload)).id;
31911
31989
  if (existsSync54(resolvedFile)) {
31912
- const raw = JSON.parse(readFileSync48(resolvedFile, "utf8"));
31990
+ const raw = JSON.parse(readFileSync49(resolvedFile, "utf8"));
31913
31991
  raw.repoNames = { ...raw.repoNames, [repoId]: SAMPLE_REPO };
31914
31992
  raw.repoRemotes = { ...raw.repoRemotes, [repoId]: SAMPLE_REMOTE };
31915
31993
  writeFileSync40(resolvedFile, `${JSON.stringify(raw, null, 2)}
@@ -32417,7 +32495,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
32417
32495
  const unitPlan = planInstall(cfg.ship, CREW_HOME, host, detectSystemd(), "run", installContext());
32418
32496
  const abandons = unitAbandonsAgents(unitPlan, (p) => {
32419
32497
  try {
32420
- return readFileSync48(p, "utf8");
32498
+ return readFileSync49(p, "utf8");
32421
32499
  } catch {
32422
32500
  return null;
32423
32501
  }
@@ -32432,7 +32510,7 @@ routes: ${cfg.routes.map((c) => c.route).join(", ")}
32432
32510
  const pPlan = planInstall(cfg.ship, CREW_HOME, host, true, "passengers", installContext());
32433
32511
  const keeps = unitAbandonsAgents(pPlan, (p) => {
32434
32512
  try {
32435
- return readFileSync48(p, "utf8");
32513
+ return readFileSync49(p, "utf8");
32436
32514
  } catch {
32437
32515
  return null;
32438
32516
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tablation/crew",
3
- "version": "0.135.0",
3
+ "version": "0.135.1",
4
4
  "description": "A standing team of headless agents that picks work off a Tablation board, does it on a machine you control, and reports back.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,3 +1,6 @@
1
+ ---
2
+ chat_enabled: true
3
+ ---
1
4
  You are **Pair** — the identity a live, interactive coding session uses when
2
5
  it touches this project's tracker while working directly alongside a person
3
6
  (in an IDE, a terminal, wherever they start you). You are not one of the
@@ -1,3 +1,6 @@
1
+ ---
2
+ chat_enabled: true
3
+ ---
1
4
  You are **Pair** — the identity a live, interactive coding session uses when
2
5
  it touches this project's tracker while working directly alongside a person
3
6
  (in an IDE, a terminal, wherever they start you). You are not one of the