teamtrail 0.61.0 → 0.64.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
@@ -2320,20 +2320,20 @@ var require_resolve = __commonJS({
2320
2320
  return false;
2321
2321
  }
2322
2322
  function countKeys(schema) {
2323
- let count2 = 0;
2323
+ let count3 = 0;
2324
2324
  for (const key in schema) {
2325
2325
  if (key === "$ref")
2326
2326
  return Infinity;
2327
- count2++;
2327
+ count3++;
2328
2328
  if (SIMPLE_INLINED.has(key))
2329
2329
  continue;
2330
2330
  if (typeof schema[key] == "object") {
2331
- (0, util_1.eachItem)(schema[key], (sch) => count2 += countKeys(sch));
2331
+ (0, util_1.eachItem)(schema[key], (sch) => count3 += countKeys(sch));
2332
2332
  }
2333
- if (count2 === Infinity)
2333
+ if (count3 === Infinity)
2334
2334
  return Infinity;
2335
2335
  }
2336
- return count2;
2336
+ return count3;
2337
2337
  }
2338
2338
  function getFullPath(resolver, id = "", normalize) {
2339
2339
  if (normalize !== false)
@@ -5871,8 +5871,8 @@ var require_contains = __commonJS({
5871
5871
  cxt.result(valid2, () => cxt.reset());
5872
5872
  function validateItemsWithCount() {
5873
5873
  const schValid = gen.name("_valid");
5874
- const count2 = gen.let("count", 0);
5875
- validateItems(schValid, () => gen.if(schValid, () => checkLimits(count2)));
5874
+ const count3 = gen.let("count", 0);
5875
+ validateItems(schValid, () => gen.if(schValid, () => checkLimits(count3)));
5876
5876
  }
5877
5877
  function validateItems(_valid, block3) {
5878
5878
  gen.forRange("i", 0, len, (i) => {
@@ -5885,16 +5885,16 @@ var require_contains = __commonJS({
5885
5885
  block3();
5886
5886
  });
5887
5887
  }
5888
- function checkLimits(count2) {
5889
- gen.code((0, codegen_1._)`${count2}++`);
5888
+ function checkLimits(count3) {
5889
+ gen.code((0, codegen_1._)`${count3}++`);
5890
5890
  if (max === void 0) {
5891
- gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid2, true).break());
5891
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid2, true).break());
5892
5892
  } else {
5893
- gen.if((0, codegen_1._)`${count2} > ${max}`, () => gen.assign(valid2, false).break());
5893
+ gen.if((0, codegen_1._)`${count3} > ${max}`, () => gen.assign(valid2, false).break());
5894
5894
  if (min === 1)
5895
5895
  gen.assign(valid2, true);
5896
5896
  else
5897
- gen.if((0, codegen_1._)`${count2} >= ${min}`, () => gen.assign(valid2, true));
5897
+ gen.if((0, codegen_1._)`${count3} >= ${min}`, () => gen.assign(valid2, true));
5898
5898
  }
5899
5899
  }
5900
5900
  }
@@ -7869,6 +7869,35 @@ function parseMapBody(md4) {
7869
7869
  return out;
7870
7870
  }
7871
7871
 
7872
+ // ../core/src/model/trailTextLimits.ts
7873
+ var TRAIL_TEXT_LIMITS = {
7874
+ /** Characters of the destination. */
7875
+ destination: 1e4,
7876
+ /** Characters of the notes. */
7877
+ notes: 5e4,
7878
+ /** Assumptions a trail starts with. */
7879
+ assumptions: 100,
7880
+ /** Characters of one assumption. */
7881
+ assumption: 500
7882
+ };
7883
+
7884
+ // ../core/src/model/trailTextProblem.ts
7885
+ var count = (n) => n.toLocaleString("en-US");
7886
+ function trailTextProblem(t) {
7887
+ const L = TRAIL_TEXT_LIMITS;
7888
+ const destination = t.destination?.trim().length ?? 0;
7889
+ if (destination > L.destination)
7890
+ return `The destination is too long: ${count(destination)} characters, at most ${count(L.destination)}.`;
7891
+ const notes = t.notes?.trim().length ?? 0;
7892
+ if (notes > L.notes) return `The notes are too long: ${count(notes)} characters, at most ${count(L.notes)}.`;
7893
+ const assumptions = t.assumptions ?? [];
7894
+ if (assumptions.length > L.assumptions)
7895
+ return `Too many assumptions: ${count(assumptions.length)}, at most ${L.assumptions}. Each line is one assumption.`;
7896
+ const long = assumptions.findIndex((a) => a.trim().length > L.assumption);
7897
+ if (long >= 0) return `Assumption ${long + 1} is too long: at most ${L.assumption} characters on one line.`;
7898
+ return void 0;
7899
+ }
7900
+
7872
7901
  // ../core/src/model/steps.ts
7873
7902
  var STEPS = {
7874
7903
  chart: ["Name destination", "Find frontier", "Create trail", "Create tickets + wire blocking", "Fire research"],
@@ -7877,8 +7906,15 @@ var STEPS = {
7877
7906
  };
7878
7907
  var stepTag = (mode, n) => `${mode[0].toUpperCase()}${mode.slice(1)} ${n}/${STEPS[mode].length}`;
7879
7908
 
7909
+ // ../core/src/planning/operations/operationError.ts
7910
+ var OperationError = class extends Error {
7911
+ };
7912
+
7880
7913
  // ../core/src/planning/operations/chart.ts
7881
7914
  async function chartMap(adapter, input2, hooks = {}) {
7915
+ const { destination, notes, assumptions } = input2.sections;
7916
+ const tooLong = trailTextProblem({ destination, notes, assumptions: assumptions?.map((a) => a.text) });
7917
+ if (tooLong) throw new OperationError(tooLong);
7882
7918
  const plan2 = withMode(input2, input2.mode ?? DEFAULT_MAP_MODE);
7883
7919
  const map2 = await adapter.createMap({
7884
7920
  title: plan2.title,
@@ -7922,10 +7958,6 @@ function withMode(plan2, mode) {
7922
7958
  };
7923
7959
  }
7924
7960
 
7925
- // ../core/src/planning/operations/operationError.ts
7926
- var OperationError = class extends Error {
7927
- };
7928
-
7929
7961
  // ../core/src/planning/operations/assertNotArchived.ts
7930
7962
  function assertNotArchived(map2) {
7931
7963
  if (map2.archived)
@@ -11044,11 +11076,11 @@ function byScore(a, b) {
11044
11076
  return b.score - a.score || a.since - b.since || a.id.localeCompare(b.id);
11045
11077
  }
11046
11078
  function fewerQuestions(items, waitedOn) {
11047
- const count2 = /* @__PURE__ */ new Map();
11079
+ const count3 = /* @__PURE__ */ new Map();
11048
11080
  const key = (i) => `${i.mapId}\0${i.agent}`;
11049
- for (const i of items) if (i.kind === "question") count2.set(key(i), (count2.get(key(i)) ?? 0) + 1);
11081
+ for (const i of items) if (i.kind === "question") count3.set(key(i), (count3.get(key(i)) ?? 0) + 1);
11050
11082
  return items.map((i) => {
11051
- const n = i.kind === "question" ? count2.get(key(i)) ?? 1 : 1;
11083
+ const n = i.kind === "question" ? count3.get(key(i)) ?? 1 : 1;
11052
11084
  if (n < 2 || waitedOn.has(i.id)) return i;
11053
11085
  return {
11054
11086
  ...i,
@@ -11223,9 +11255,9 @@ var deliverySource = {
11223
11255
  // ../core/src/attention/escapeRule.ts
11224
11256
  var MAX_GLOBS = 5;
11225
11257
  var PLAIN_PATH = /^[\w./@+-]+$/;
11226
- function globOf(file10) {
11227
- const at2 = file10.lastIndexOf("/");
11228
- return at2 > 0 ? `${file10.slice(0, at2)}/**` : file10;
11258
+ function globOf(file9) {
11259
+ const at2 = file9.lastIndexOf("/");
11260
+ return at2 > 0 ? `${file9.slice(0, at2)}/**` : file9;
11229
11261
  }
11230
11262
  function escapeRule(e) {
11231
11263
  const plain2 = e.files.filter((f) => PLAIN_PATH.test(f) && !f.split("/").includes(".."));
@@ -12900,8 +12932,8 @@ function serializeMapFile(m) {
12900
12932
  }
12901
12933
 
12902
12934
  // ../core/src/adapters/markdown/unreadDecision.ts
12903
- function unreadDecision(file10, e) {
12904
- if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${file10} can't be read: ${e.message}`);
12935
+ function unreadDecision(file9, e) {
12936
+ if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${file9} can't be read: ${e.message}`);
12905
12937
  return void 0;
12906
12938
  }
12907
12939
 
@@ -13056,9 +13088,9 @@ var MarkdownAdapter = class {
13056
13088
  }
13057
13089
  async createDecision(mapId, input2) {
13058
13090
  const d = await this.putNew(async () => {
13059
- const file10 = await newDecisionFile(this.fs, mapId, input2);
13060
- this.external.remember(file10.path, file10.text);
13061
- return file10;
13091
+ const file9 = await newDecisionFile(this.fs, mapId, input2);
13092
+ this.external.remember(file9.path, file9.text);
13093
+ return file9;
13062
13094
  });
13063
13095
  this.events.emit({ kind: "decision.recorded", mapId, decisionId: d.id, ticketId: d.ticketId, at: Date.now() });
13064
13096
  return d;
@@ -13619,6 +13651,17 @@ var SettingsLedger = class {
13619
13651
  }
13620
13652
  };
13621
13653
 
13654
+ // ../core/src/adapters/remote/mapBodyFits.ts
13655
+ function assertMapBodyFits(map2, o) {
13656
+ if (o.limit === void 0) return;
13657
+ const length = mapBody(map2).length;
13658
+ if (length <= o.limit) return;
13659
+ const n = (x) => x.toLocaleString("en-US");
13660
+ throw new OperationError(
13661
+ `This trail is too long for ${o.tracker}: ${n(length)} characters with its destination, notes and assumptions, at most ${n(o.limit)}. Shorten the notes.`
13662
+ );
13663
+ }
13664
+
13622
13665
  // ../core/src/adapters/remote/sync/fingerprint.ts
13623
13666
  var roundtrip = (s) => parseMapBody(serializeMapBody(s));
13624
13667
  function fingerprint(e) {
@@ -14191,8 +14234,11 @@ var SyncedEdits = class extends SyncedWriter {
14191
14234
  // ../core/src/adapters/remote/sync/syncedAdapter.ts
14192
14235
  var MAX_DECISION = 999999999;
14193
14236
  var SyncedAdapter = class extends SyncedEdits {
14237
+ /** The most characters the tracker takes in an issue body; undefined: no limit Teamtrail knows of. */
14238
+ mapBodyLimit = void 0;
14194
14239
  lastDecision = 0;
14195
14240
  async createMap(input2) {
14241
+ assertMapBodyFits(input2, { limit: this.mapBodyLimit, tracker: this.label });
14196
14242
  let map2;
14197
14243
  try {
14198
14244
  map2 = await this.remoteCreateMap({
@@ -14229,7 +14275,11 @@ var SyncedAdapter = class extends SyncedEdits {
14229
14275
  await this.change(
14230
14276
  mapId,
14231
14277
  "trail sections",
14232
- (e) => ({ kind: "sections", sections: roundtrip({ ...e.snap.map.sections, ...patch }) }),
14278
+ (e) => {
14279
+ const sections = roundtrip({ ...e.snap.map.sections, ...patch });
14280
+ assertMapBodyFits({ ...e.snap.map, sections }, { limit: this.mapBodyLimit, tracker: this.label });
14281
+ return { kind: "sections", sections };
14282
+ },
14233
14283
  {
14234
14284
  kind: "map.updated",
14235
14285
  mapId,
@@ -14680,6 +14730,8 @@ async function setIssueLabel(gh, issue3, name2, on) {
14680
14730
  var GitHubAdapter = class extends SyncedAdapter {
14681
14731
  kind = "github";
14682
14732
  label = "GitHub Issues";
14733
+ /** GitHub refuses an issue body over 65,536 characters. */
14734
+ mapBodyLimit = 65536;
14683
14735
  location;
14684
14736
  gh;
14685
14737
  /** Issue number → REST id (sub-issue and dependency endpoints take ids, not numbers). */
@@ -16631,26 +16683,26 @@ function costShares(tickets2, sessions) {
16631
16683
  return share;
16632
16684
  }
16633
16685
  function row2(key, items, minSample, extra = {}) {
16634
- const verified = items.filter((i) => i.t.verified);
16686
+ const verified2 = items.filter((i) => i.t.verified);
16635
16687
  const firstTime = items.filter((i) => i.t.verified && i.t.attempts.length === 1 && i.t.attempts[0].result === "pass");
16636
16688
  const costUsd = items.reduce((n, i) => n + i.costUsd, 0);
16637
16689
  const findings = { info: 0, warn: 0, error: 0 };
16638
16690
  for (const { t } of items) for (const k of ["info", "warn", "error"]) findings[k] += t.findings[k];
16639
- const attempts = verified.reduce((n, i) => n + i.t.attempts.length, 0);
16691
+ const attempts = verified2.reduce((n, i) => n + i.t.attempts.length, 0);
16640
16692
  const everVerified = items.filter((i) => i.t.verified || i.t.escaped).length;
16641
16693
  const escaped3 = items.filter((i) => i.t.escaped).length;
16642
16694
  return {
16643
16695
  key,
16644
16696
  ...extra,
16645
16697
  tickets: items.length,
16646
- verified: verified.length,
16698
+ verified: verified2.length,
16647
16699
  verifiedFirstTime: firstTime.length,
16648
16700
  firstTimeRate: items.length ? round2(firstTime.length / items.length, 3) : 0,
16649
16701
  reworkRate: items.length ? round2(items.filter((i) => i.t.attempts.length > 1).length / items.length, 3) : 0,
16650
- attemptsPerVerified: verified.length ? round2(attempts / verified.length, 2) : void 0,
16702
+ attemptsPerVerified: verified2.length ? round2(attempts / verified2.length, 2) : void 0,
16651
16703
  costUsd: round2(costUsd, 4),
16652
- costPerVerifiedUsd: verified.length && costUsd ? round2(costUsd / verified.length, 4) : void 0,
16653
- medianLeadMs: median2(verified.flatMap((i) => i.t.leadMs === void 0 ? [] : [i.t.leadMs])),
16704
+ costPerVerifiedUsd: verified2.length && costUsd ? round2(costUsd / verified2.length, 4) : void 0,
16705
+ medianLeadMs: median2(verified2.flatMap((i) => i.t.leadMs === void 0 ? [] : [i.t.leadMs])),
16654
16706
  findings,
16655
16707
  escaped: escaped3,
16656
16708
  escapeRate: everVerified ? round2(escaped3 / everVerified, 3) : void 0,
@@ -17095,8 +17147,8 @@ var inode = (p) => {
17095
17147
  return void 0;
17096
17148
  }
17097
17149
  };
17098
- function withFileLock(file10, fn) {
17099
- const lock = `${file10}.lock`;
17150
+ function withFileLock(file9, fn) {
17151
+ const lock = `${file9}.lock`;
17100
17152
  const token = `${process.pid}.${randomBytes(8).toString("hex")}`;
17101
17153
  const until = Date.now() + WAIT_MS;
17102
17154
  for (; ; ) {
@@ -17109,7 +17161,7 @@ function withFileLock(file10, fn) {
17109
17161
  if (e.code !== "EEXIST") throw e;
17110
17162
  const seen2 = inode(lock);
17111
17163
  if (seen2?.old) removeIf(lock, (moved) => statSync2(moved).ino === seen2.ino);
17112
- else if (Date.now() > until) throw new Error(`${file10} is locked by another process`);
17164
+ else if (Date.now() > until) throw new Error(`${file9} is locked by another process`);
17113
17165
  else Atomics.wait(pause, 0, 0, 5);
17114
17166
  }
17115
17167
  }
@@ -17129,10 +17181,10 @@ function ensurePrivateDir(dir4) {
17129
17181
  if ((statSync3(dir4).mode & 63) !== 0) chmodSync(dir4, 448);
17130
17182
  for (const name2 of readdirSync(dir4)) tighten(`${dir4}/${name2}`);
17131
17183
  }
17132
- function tighten(file10) {
17184
+ function tighten(file9) {
17133
17185
  try {
17134
- const st = statSync3(file10);
17135
- if (st.isFile() && (st.mode & 63) !== 0) chmodSync(file10, 384);
17186
+ const st = statSync3(file9);
17187
+ if (st.isFile() && (st.mode & 63) !== 0) chmodSync(file9, 384);
17136
17188
  } catch {
17137
17189
  }
17138
17190
  }
@@ -17152,36 +17204,36 @@ function configDir(env = process.env) {
17152
17204
  const base2 = env.XDG_CONFIG_HOME || process.platform === "win32" && env.APPDATA || path2.join(os.homedir(), ".config");
17153
17205
  return path2.join(base2, BRAND.slug);
17154
17206
  }
17155
- function readJson(file10, fallback) {
17207
+ function readJson(file9, fallback) {
17156
17208
  try {
17157
- return { ...fallback, ...parseJsonSafe(readFileSync2(file10, "utf8")) };
17209
+ return { ...fallback, ...parseJsonSafe(readFileSync2(file9, "utf8")) };
17158
17210
  } catch {
17159
17211
  return fallback;
17160
17212
  }
17161
17213
  }
17162
- function writeJson(file10, value, secret = false) {
17163
- if (secret) ensurePrivateDir(path2.dirname(file10));
17164
- else mkdirSync2(path2.dirname(file10), { recursive: true });
17165
- const tmp = `${file10}.${process.pid}.tmp`;
17214
+ function writeJson(file9, value, secret = false) {
17215
+ if (secret) ensurePrivateDir(path2.dirname(file9));
17216
+ else mkdirSync2(path2.dirname(file9), { recursive: true });
17217
+ const tmp = `${file9}.${process.pid}.tmp`;
17166
17218
  writeFileSync(tmp, JSON.stringify(value, null, 2) + "\n", secret ? { mode: 384 } : {});
17167
- renameSync2(tmp, file10);
17219
+ renameSync2(tmp, file9);
17168
17220
  }
17169
17221
  function projectConfig(trackerRoot) {
17170
- const file10 = path2.join(trackerRoot, "trackers.json");
17222
+ const file9 = path2.join(trackerRoot, "trackers.json");
17171
17223
  return {
17172
- file: file10,
17173
- read: () => readJson(file10, { active: "markdown" }),
17174
- write: (c) => writeJson(file10, c)
17224
+ file: file9,
17225
+ read: () => readJson(file9, { active: "markdown" }),
17226
+ write: (c) => writeJson(file9, c)
17175
17227
  };
17176
17228
  }
17177
17229
  function credentialStore(dir4 = configDir()) {
17178
- const file10 = path2.join(dir4, "credentials.json");
17230
+ const file9 = path2.join(dir4, "credentials.json");
17179
17231
  return {
17180
- file: file10,
17181
- read: () => readJson(file10, {}),
17232
+ file: file9,
17233
+ read: () => readJson(file9, {}),
17182
17234
  write(c) {
17183
17235
  ensurePrivateDir(dir4);
17184
- withFileLock(file10, () => writeJson(file10, c, true));
17236
+ withFileLock(file9, () => writeJson(file9, c, true));
17185
17237
  },
17186
17238
  /**
17187
17239
  * Read, change and write under one lock: what every change should use, so a Lookout and an `mcp` process
@@ -17189,9 +17241,9 @@ function credentialStore(dir4 = configDir()) {
17189
17241
  */
17190
17242
  update(change3) {
17191
17243
  ensurePrivateDir(dir4);
17192
- return withFileLock(file10, () => {
17193
- const next = change3(readJson(file10, {}));
17194
- writeJson(file10, next, true);
17244
+ return withFileLock(file9, () => {
17245
+ const next = change3(readJson(file9, {}));
17246
+ writeJson(file9, next, true);
17195
17247
  return next;
17196
17248
  });
17197
17249
  }
@@ -17235,19 +17287,19 @@ async function detectGitHubRepo(cwd, exec) {
17235
17287
  function privateTarget(dir4) {
17236
17288
  return path3.resolve(dir4) === path3.resolve(configDir()) || isPrivateDir(dir4);
17237
17289
  }
17238
- function writeJsonAtomic(file10, value, opts = {}) {
17239
- const dir4 = path3.dirname(file10);
17290
+ function writeJsonAtomic(file9, value, opts = {}) {
17291
+ const dir4 = path3.dirname(file9);
17240
17292
  const secret = opts.private || privateTarget(dir4);
17241
17293
  if (secret) ensurePrivateDir(dir4);
17242
17294
  else mkdirSync3(dir4, { recursive: true });
17243
- const tmp = `${file10}.${process.pid}.tmp`;
17295
+ const tmp = `${file9}.${process.pid}.tmp`;
17244
17296
  writeFileSync2(tmp, JSON.stringify(value, null, 2), secret ? { mode: 384 } : {});
17245
- renameSync3(tmp, file10);
17246
- if (secret && process.platform !== "win32") chmodSync2(file10, 384);
17297
+ renameSync3(tmp, file9);
17298
+ if (secret && process.platform !== "win32") chmodSync2(file9, 384);
17247
17299
  }
17248
- function readJsonFile(file10) {
17300
+ function readJsonFile(file9) {
17249
17301
  try {
17250
- return parseJsonSafe(readFileSync3(file10, "utf8"));
17302
+ return parseJsonSafe(readFileSync3(file9, "utf8"));
17251
17303
  } catch {
17252
17304
  return void 0;
17253
17305
  }
@@ -17269,17 +17321,17 @@ var machineId = (root) => createHash("sha256").update(canonical(root)).digest("h
17269
17321
  // ../core/src/machine/writePrivateFile.ts
17270
17322
  import { chmodSync as chmodSync3, mkdirSync as mkdirSync4, renameSync as renameSync4, writeFileSync as writeFileSync3 } from "node:fs";
17271
17323
  import path5 from "node:path";
17272
- function writePrivateFile(file10, text11) {
17273
- const dir4 = path5.dirname(file10);
17324
+ function writePrivateFile(file9, text11) {
17325
+ const dir4 = path5.dirname(file9);
17274
17326
  mkdirSync4(dir4, { recursive: true, mode: 448 });
17275
17327
  try {
17276
17328
  chmodSync3(dir4, 448);
17277
17329
  } catch {
17278
17330
  }
17279
- const tmp = `${file10}.${process.pid}.tmp`;
17331
+ const tmp = `${file9}.${process.pid}.tmp`;
17280
17332
  writeFileSync3(tmp, text11, { mode: 384 });
17281
- renameSync4(tmp, file10);
17282
- chmodSync3(file10, 384);
17333
+ renameSync4(tmp, file9);
17334
+ chmodSync3(file9, 384);
17283
17335
  }
17284
17336
 
17285
17337
  // ../core/src/machine/machineStore.ts
@@ -17287,15 +17339,15 @@ var MACHINE_PROJECTS_DIR = "projects";
17287
17339
  function machineStore(root, dir4 = configDir()) {
17288
17340
  const id = machineId(root);
17289
17341
  const base2 = path6.join(dir4, MACHINE_PROJECTS_DIR, id);
17290
- const file10 = (name2) => path6.join(base2, name2);
17342
+ const file9 = (name2) => path6.join(base2, name2);
17291
17343
  return {
17292
17344
  id,
17293
17345
  dir: base2,
17294
- file: file10,
17295
- read: (name2) => readJsonFile(file10(name2)),
17296
- write: (name2, value) => writePrivateFile(file10(name2), `${JSON.stringify(value, null, 2)}
17346
+ file: file9,
17347
+ read: (name2) => readJsonFile(file9(name2)),
17348
+ write: (name2, value) => writePrivateFile(file9(name2), `${JSON.stringify(value, null, 2)}
17297
17349
  `),
17298
- remove: (name2) => rmSync2(file10(name2), { force: true })
17350
+ remove: (name2) => rmSync2(file9(name2), { force: true })
17299
17351
  };
17300
17352
  }
17301
17353
 
@@ -17626,19 +17678,19 @@ function cachedFields(item2, text11) {
17626
17678
  }
17627
17679
  var texts = lru(MAX_ENTRIES);
17628
17680
  var isOversized = (t) => typeof t === "object";
17629
- function oversizedFile(file10) {
17630
- const s = statSync5(file10, { throwIfNoEntry: false });
17681
+ function oversizedFile(file9) {
17682
+ const s = statSync5(file9, { throwIfNoEntry: false });
17631
17683
  return s?.isFile() && s.size > MAX_ITEM_BYTES ? s.size : void 0;
17632
17684
  }
17633
- function cachedText(file10) {
17634
- const s = statSync5(file10, { throwIfNoEntry: false });
17685
+ function cachedText(file9) {
17686
+ const s = statSync5(file9, { throwIfNoEntry: false });
17635
17687
  if (!s?.isFile()) return void 0;
17636
17688
  if (s.size > MAX_ITEM_BYTES) return { oversized: s.size };
17637
17689
  const stamp2 = `${s.ino}:${s.mtimeMs}:${s.size}`;
17638
- const hit = texts.get(file10);
17690
+ const hit = texts.get(file9);
17639
17691
  if (hit?.stamp === stamp2) return hit.text;
17640
- const text11 = readFileSync5(file10, "utf8");
17641
- texts.set(file10, { stamp: stamp2, text: text11 });
17692
+ const text11 = readFileSync5(file9, "utf8");
17693
+ texts.set(file9, { stamp: stamp2, text: text11 });
17642
17694
  return text11;
17643
17695
  }
17644
17696
 
@@ -17716,10 +17768,10 @@ import { linkSync as linkSync2, readFileSync as readFileSync6, rmSync as rmSync4
17716
17768
  import path8 from "node:path";
17717
17769
  var MACHINE_KEY_FILE = "machine.key";
17718
17770
  var KEY2 = /^[0-9a-f]{64}$/;
17719
- function readKey(file10) {
17771
+ function readKey(file9) {
17720
17772
  let text11;
17721
17773
  try {
17722
- text11 = readFileSync6(file10, "utf8").trim();
17774
+ text11 = readFileSync6(file9, "utf8").trim();
17723
17775
  } catch (e) {
17724
17776
  if (e.code === "ENOENT") return void 0;
17725
17777
  throw e;
@@ -17727,24 +17779,24 @@ function readKey(file10) {
17727
17779
  return KEY2.test(text11) ? text11 : void 0;
17728
17780
  }
17729
17781
  function machineKey(dir4 = configDir()) {
17730
- const file10 = path8.join(dir4, MACHINE_KEY_FILE);
17731
- const known4 = readKey(file10);
17782
+ const file9 = path8.join(dir4, MACHINE_KEY_FILE);
17783
+ const known4 = readKey(file9);
17732
17784
  if (known4) return known4;
17733
- const draft = `${file10}.${process.pid}.${randomBytes2(4).toString("hex")}`;
17785
+ const draft = `${file9}.${process.pid}.${randomBytes2(4).toString("hex")}`;
17734
17786
  writePrivateFile(draft, `${randomBytes2(32).toString("hex")}
17735
17787
  `);
17736
17788
  try {
17737
- linkSync2(draft, file10);
17789
+ linkSync2(draft, file9);
17738
17790
  } catch (e) {
17739
17791
  if (e.code !== "EEXIST") throw e;
17740
17792
  } finally {
17741
17793
  rmSync4(draft, { force: true });
17742
17794
  }
17743
- const made = readKey(file10);
17795
+ const made = readKey(file9);
17744
17796
  if (made) return made;
17745
- writePrivateFile(file10, `${randomBytes2(32).toString("hex")}
17797
+ writePrivateFile(file9, `${randomBytes2(32).toString("hex")}
17746
17798
  `);
17747
- return readKey(file10);
17799
+ return readKey(file9);
17748
17800
  }
17749
17801
  function machineSign(parts2, dir4) {
17750
17802
  const mac4 = createHmac("sha256", machineKey(dir4));
@@ -17771,8 +17823,8 @@ var signed = (root, mapId, entries2) => [
17771
17823
  JSON.stringify(entries2)
17772
17824
  ];
17773
17825
  var cache = /* @__PURE__ */ new Map();
17774
- function stampOf(file10) {
17775
- const s = statSync6(file10, { throwIfNoEntry: false });
17826
+ function stampOf(file9) {
17827
+ const s = statSync6(file9, { throwIfNoEntry: false });
17776
17828
  return s ? `${s.ino}:${s.mtimeMs}:${s.size}` : void 0;
17777
17829
  }
17778
17830
  function unreadable(mapId, why2) {
@@ -17799,18 +17851,18 @@ function parseRecord(root, mapId, text11) {
17799
17851
  return { entries: entries2 };
17800
17852
  }
17801
17853
  function readStateRecord(root, mapId) {
17802
- const file10 = stateRecordFile(root, mapId);
17803
- const stamp2 = stampOf(file10);
17854
+ const file9 = stateRecordFile(root, mapId);
17855
+ const stamp2 = stampOf(file9);
17804
17856
  if (!stamp2) return { entries: {} };
17805
- const hit = cache.get(file10);
17857
+ const hit = cache.get(file9);
17806
17858
  if (hit?.stamp === stamp2) return hit.record;
17807
17859
  let record3;
17808
17860
  try {
17809
- record3 = parseRecord(root, mapId, readFileSync7(file10, "utf8"));
17861
+ record3 = parseRecord(root, mapId, readFileSync7(file9, "utf8"));
17810
17862
  } catch {
17811
17863
  record3 = { entries: {}, problem: machineAccess() ?? unreadable(mapId, "no access").problem, blocked: true };
17812
17864
  }
17813
- if (!record3.blocked) cache.set(file10, { stamp: stamp2, record: record3 });
17865
+ if (!record3.blocked) cache.set(file9, { stamp: stamp2, record: record3 });
17814
17866
  return record3;
17815
17867
  }
17816
17868
  function writeStateRecord(root, mapId, entries2) {
@@ -17828,8 +17880,8 @@ function entriesToChange(root, mapId) {
17828
17880
  const record3 = readStateRecord(root, mapId);
17829
17881
  if (record3.blocked) throw new Error(record3.problem);
17830
17882
  if (!record3.problem) return { ...record3.entries };
17831
- const file10 = stateRecordFile(root, mapId);
17832
- renameSync5(file10, `${file10}.unreadable-${Date.now()}`);
17883
+ const file9 = stateRecordFile(root, mapId);
17884
+ renameSync5(file9, `${file9}.unreadable-${Date.now()}`);
17833
17885
  return {};
17834
17886
  }
17835
17887
  function changeStateRecord(root, mapId, fn) {
@@ -18035,14 +18087,14 @@ function writeTrackerFile(input2) {
18035
18087
  refuseLinks(root, rel);
18036
18088
  const dir4 = realFolder(root, rel);
18037
18089
  trackerWriteHooks.afterCheck?.(dir4);
18038
- const file10 = path10.join(dir4, path10.basename(rel));
18090
+ const file9 = path10.join(dir4, path10.basename(rel));
18039
18091
  const tmp = path10.join(dir4, `.${path10.basename(rel)}.${randomBytes3(6).toString("hex")}.tmp`);
18040
18092
  writeFileSync5(tmp, text11, { flag: "wx" });
18041
18093
  try {
18042
18094
  confirmLanded(tmp, rel);
18043
- if (input2.create) linkSync3(tmp, file10);
18044
- else renameSync6(tmp, file10);
18045
- confirmLanded(file10, rel);
18095
+ if (input2.create) linkSync3(tmp, file9);
18096
+ else renameSync6(tmp, file9);
18097
+ confirmLanded(file9, rel);
18046
18098
  return true;
18047
18099
  } catch (e) {
18048
18100
  if (input2.create && e.code === "EEXIST") return false;
@@ -18062,10 +18114,10 @@ function removeTrackerFile(root, rel) {
18062
18114
  // ../core/src/signedState/signedWrite.ts
18063
18115
  function readIfThere(root, rel) {
18064
18116
  refuseLinks(root, rel);
18065
- const file10 = path11.join(root, rel);
18066
- if (oversizedFile(file10)) return void 0;
18117
+ const file9 = path11.join(root, rel);
18118
+ if (oversizedFile(file9)) return void 0;
18067
18119
  try {
18068
- return readFileSync8(file10, "utf8");
18120
+ return readFileSync8(file9, "utf8");
18069
18121
  } catch (e) {
18070
18122
  if (e.code === "ENOENT") return void 0;
18071
18123
  throw e;
@@ -18231,10 +18283,10 @@ function watchFolders(root, onChange) {
18231
18283
  for (const e of entries2(dir4)) {
18232
18284
  const full = path13.join(dir4, e.name);
18233
18285
  if (announce) onChange(relOf(full));
18234
- if (e.isDirectory()) folder(full, announce);
18286
+ if (e.isDirectory()) folder2(full, announce);
18235
18287
  }
18236
18288
  }
18237
- function folder(full, announce) {
18289
+ function folder2(full, announce) {
18238
18290
  const s = lstatSync3(full, { throwIfNoEntry: false });
18239
18291
  if (!s?.isDirectory()) return unwatchUnder(full);
18240
18292
  if (watched.get(full)?.ino === s.ino) return;
@@ -18244,7 +18296,7 @@ function watchFolders(root, onChange) {
18244
18296
  function changed(full) {
18245
18297
  if (closed) return;
18246
18298
  onChange(relOf(full));
18247
- folder(full, true);
18299
+ folder2(full, true);
18248
18300
  }
18249
18301
  const top = lstatSync3(root, { throwIfNoEntry: false });
18250
18302
  if (top?.isDirectory()) add3(root, top.ino, false);
@@ -18268,7 +18320,7 @@ function watchTree(root, onChange, opts = {}) {
18268
18320
  function rawMarkdownFs(root) {
18269
18321
  const abs = path15.resolve(root);
18270
18322
  mkdirSync8(abs, { recursive: true });
18271
- const safe17 = (p) => {
18323
+ const safe18 = (p) => {
18272
18324
  const full = path15.resolve(abs, p);
18273
18325
  if (full !== abs && !full.startsWith(abs + path15.sep)) throw new Error("path escapes root");
18274
18326
  return full;
@@ -18285,15 +18337,15 @@ function rawMarkdownFs(root) {
18285
18337
  }
18286
18338
  return {
18287
18339
  list: () => walk(abs),
18288
- read: (p) => fs.readFile(safe17(p), "utf8"),
18340
+ read: (p) => fs.readFile(safe18(p), "utf8"),
18289
18341
  async write(p, text11) {
18290
- await fs.mkdir(path15.dirname(safe17(p)), { recursive: true });
18291
- await fs.writeFile(safe17(p), text11);
18342
+ await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18343
+ await fs.writeFile(safe18(p), text11);
18292
18344
  },
18293
18345
  async create(p, text11) {
18294
- await fs.mkdir(path15.dirname(safe17(p)), { recursive: true });
18346
+ await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18295
18347
  try {
18296
- await fs.writeFile(safe17(p), text11, { flag: "wx" });
18348
+ await fs.writeFile(safe18(p), text11, { flag: "wx" });
18297
18349
  return true;
18298
18350
  } catch (e) {
18299
18351
  if (e.code === "EEXIST") return false;
@@ -18350,14 +18402,14 @@ function localRepoFiles(repoRoot) {
18350
18402
  if (!existsSync6(path17.join(real7, ".git"))) return void 0;
18351
18403
  return {
18352
18404
  async read(rel) {
18353
- const file10 = await inside(real7, rel);
18354
- const s = file10 ? await stat(file10).catch(() => void 0) : void 0;
18355
- if (!file10 || !s?.isFile() || s.size > MAX_SCREEN_BYTES) return void 0;
18356
- return readFile(file10, "utf8").catch(() => void 0);
18405
+ const file9 = await inside(real7, rel);
18406
+ const s = file9 ? await stat(file9).catch(() => void 0) : void 0;
18407
+ if (!file9 || !s?.isFile() || s.size > MAX_SCREEN_BYTES) return void 0;
18408
+ return readFile(file9, "utf8").catch(() => void 0);
18357
18409
  },
18358
18410
  async kind(rel) {
18359
- const file10 = await inside(real7, rel);
18360
- const s = file10 ? await stat(file10).catch(() => void 0) : void 0;
18411
+ const file9 = await inside(real7, rel);
18412
+ const s = file9 ? await stat(file9).catch(() => void 0) : void 0;
18361
18413
  if (s?.isDirectory()) return "dir";
18362
18414
  return s?.isFile() ? "file" : void 0;
18363
18415
  }
@@ -18463,24 +18515,24 @@ import path20 from "node:path";
18463
18515
 
18464
18516
  // ../core/src/policy/stricterPolicy.ts
18465
18517
  var rank3 = (l) => RISK_LEVELS.indexOf(l);
18466
- function keptRule(approved, file10) {
18467
- const now2 = file10.filter((r) => r.glob === approved.glob);
18518
+ function keptRule(approved, file9) {
18519
+ const now2 = file9.filter((r) => r.glob === approved.glob);
18468
18520
  if (!now2.length) return { rule: approved, line: `path rule ${approved.glob} (${approved.level}) was removed` };
18469
18521
  const highest = now2.reduce((a, b) => rank3(b.level) > rank3(a.level) ? b : a);
18470
18522
  if (rank3(highest.level) >= rank3(approved.level)) return void 0;
18471
18523
  return { rule: approved, line: `path rule ${approved.glob}: ${approved.level} \u2192 ${highest.level}` };
18472
18524
  }
18473
- function stricterPolicy(file10, approved) {
18525
+ function stricterPolicy(file9, approved) {
18474
18526
  const lowered = [];
18475
- const categories = { ...file10.categories };
18527
+ const categories = { ...file9.categories };
18476
18528
  for (const c of RISK_CATEGORIES) {
18477
- if (rank3(file10.categories[c]) >= rank3(approved.categories[c])) continue;
18478
- lowered.push(`${c}: ${approved.categories[c]} \u2192 ${file10.categories[c]}`);
18529
+ if (rank3(file9.categories[c]) >= rank3(approved.categories[c])) continue;
18530
+ lowered.push(`${c}: ${approved.categories[c]} \u2192 ${file9.categories[c]}`);
18479
18531
  categories[c] = approved.categories[c];
18480
18532
  }
18481
- const kept = approved.paths.map((r) => keptRule(r, file10.paths)).filter((k) => k !== void 0);
18533
+ const kept = approved.paths.map((r) => keptRule(r, file9.paths)).filter((k) => k !== void 0);
18482
18534
  lowered.push(...kept.map((k) => k.line));
18483
- return { policy: { v: 1, categories, paths: [...file10.paths, ...kept.map((k) => k.rule)] }, lowered };
18535
+ return { policy: { v: 1, categories, paths: [...file9.paths, ...kept.map((k) => k.rule)] }, lowered };
18484
18536
  }
18485
18537
 
18486
18538
  // ../core/src/policy/policyStore.ts
@@ -18758,33 +18810,33 @@ var checkSha = (spec) => sha(JSON.stringify({ run: spec.run, cwd: spec.cwd ?? nu
18758
18810
  var LOCK_CHANGED = "guides.lock.json changed outside Teamtrail (by an agent, or pulled with git); waiting for your approval";
18759
18811
  var NOT_APPROVED_HERE = "approved elsewhere, not on this machine yet; approvals are kept per machine, outside the repo, and a repo that moved is asked again";
18760
18812
  var pendingChecks = (guide, lock) => Object.entries(guide.proposedChecks).filter(([name2, spec]) => lock?.approvedChecks[name2] !== checkSha(spec)).map(([name2]) => name2);
18761
- function guideStatus(file10) {
18762
- const lint = lintGuide(file10.text);
18763
- const sha256 = guideSha(file10.text);
18813
+ function guideStatus(file9) {
18814
+ const lint = lintGuide(file9.text);
18815
+ const sha256 = guideSha(file9.text);
18764
18816
  const base2 = {
18765
- id: file10.id,
18766
- origin: file10.origin,
18817
+ id: file9.id,
18818
+ origin: file9.origin,
18767
18819
  sha256,
18768
18820
  ...lint.guide ? { guide: lint.guide } : {},
18769
- ...file10.lock ? { lock: file10.lock } : {},
18821
+ ...file9.lock ? { lock: file9.lock } : {},
18770
18822
  findings: lint.findings,
18771
- pendingChecks: lint.guide && file10.origin === "local" ? pendingChecks(lint.guide, file10.lock) : [],
18772
- overridesBuiltin: !!file10.overridesBuiltin
18823
+ pendingChecks: lint.guide && file9.origin === "local" ? pendingChecks(lint.guide, file9.lock) : [],
18824
+ overridesBuiltin: !!file9.overridesBuiltin
18773
18825
  };
18774
18826
  const firstError = lint.findings.find((f) => f.level === "error");
18775
18827
  if (firstError) return { ...base2, status: "invalid", reason: `line ${firstError.line}: ${firstError.message}` };
18776
- if (lint.guide?.id !== file10.id)
18828
+ if (lint.guide?.id !== file9.id)
18777
18829
  return {
18778
18830
  ...base2,
18779
18831
  status: "invalid",
18780
- reason: `its id "${lint.guide?.id}" doesn't match the file name ${file10.id}.md`
18832
+ reason: `its id "${lint.guide?.id}" doesn't match the file name ${file9.id}.md`
18781
18833
  };
18782
- if (file10.origin === "builtin") return { ...base2, status: "active" };
18783
- if (file10.lockChanged && !file10.lock) return { ...base2, status: "unapproved", reason: NOT_APPROVED_HERE };
18784
- if (file10.lockChanged) return { ...base2, status: "tampered", reason: LOCK_CHANGED };
18785
- if (!file10.lock) return { ...base2, status: "unapproved", reason: "not approved by the trail lead yet" };
18786
- if (file10.lock.sha256 !== sha256)
18787
- return { ...base2, status: "tampered", reason: `changed since version ${file10.lock.version} was approved` };
18834
+ if (file9.origin === "builtin") return { ...base2, status: "active" };
18835
+ if (file9.lockChanged && !file9.lock) return { ...base2, status: "unapproved", reason: NOT_APPROVED_HERE };
18836
+ if (file9.lockChanged) return { ...base2, status: "tampered", reason: LOCK_CHANGED };
18837
+ if (!file9.lock) return { ...base2, status: "unapproved", reason: "not approved by the trail lead yet" };
18838
+ if (file9.lock.sha256 !== sha256)
18839
+ return { ...base2, status: "tampered", reason: `changed since version ${file9.lock.version} was approved` };
18788
18840
  return { ...base2, status: "active" };
18789
18841
  }
18790
18842
  var missingGuide = (id, lock) => ({
@@ -19022,11 +19074,11 @@ import path26 from "node:path";
19022
19074
  var STATE_DIR2 = ".attention";
19023
19075
  var STATE_FILE = "state.json";
19024
19076
  function readAttentionPolicy(root) {
19025
- const file10 = path26.join(root, ATTENTION_FILE);
19026
- if (!existsSync9(file10)) return { file: ATTENTION_FILE, exists: false, ...parseAttentionPolicy({ v: 1 }) };
19077
+ const file9 = path26.join(root, ATTENTION_FILE);
19078
+ if (!existsSync9(file9)) return { file: ATTENTION_FILE, exists: false, ...parseAttentionPolicy({ v: 1 }) };
19027
19079
  let raw;
19028
19080
  try {
19029
- raw = parseJsonSafe(readFileSync14(file10, "utf8"));
19081
+ raw = parseJsonSafe(readFileSync14(file9, "utf8"));
19030
19082
  } catch (err) {
19031
19083
  const parsed3 = parseAttentionPolicy({ v: 1 });
19032
19084
  return { file: ATTENTION_FILE, exists: true, value: parsed3.value, errors: [`not valid JSON: ${String(err)}`] };
@@ -19140,9 +19192,9 @@ function orphans(dir4, key) {
19140
19192
  }
19141
19193
  return names.filter((n) => n.startsWith(`${key}.`) && n.endsWith(".json") && !owned(n.slice(key.length + 1, -".json".length))).sort();
19142
19194
  }
19143
- function readWrites(file10) {
19195
+ function readWrites(file9) {
19144
19196
  try {
19145
- const doc = JSON.parse(readFileSync15(file10, "utf8"));
19197
+ const doc = JSON.parse(readFileSync15(file9, "utf8"));
19146
19198
  return doc.v === 1 && Array.isArray(doc.writes) ? doc.writes.filter(isQueuedWrite) : [];
19147
19199
  } catch {
19148
19200
  return [];
@@ -19153,15 +19205,15 @@ function orphanedWrites(dir4, key) {
19153
19205
  }
19154
19206
  function outboxFile(dir4, key) {
19155
19207
  const owner = `${process.pid}-${++instances}`;
19156
- const file10 = path27.join(dir4, `${key}.${owner}.json`);
19208
+ const file9 = path27.join(dir4, `${key}.${owner}.json`);
19157
19209
  let released = false;
19158
19210
  const save2 = (writes) => {
19159
19211
  if (released) return;
19160
- if (!writes.length) return void rmSync6(file10, { force: true });
19161
- writePrivateFile(file10, JSON.stringify({ v: 1, writes }, null, 2) + "\n");
19212
+ if (!writes.length) return void rmSync6(file9, { force: true });
19213
+ writePrivateFile(file9, JSON.stringify({ v: 1, writes }, null, 2) + "\n");
19162
19214
  };
19163
19215
  return {
19164
- file: file10,
19216
+ file: file9,
19165
19217
  load() {
19166
19218
  live.add(owner);
19167
19219
  const claimed = [];
@@ -19189,9 +19241,9 @@ function outboxFile(dir4, key) {
19189
19241
 
19190
19242
  // ../core/src/adapters/remote/legacyOutbox.ts
19191
19243
  var targetOf = (name2) => name2.replace(/\.[^.]*\.json$/, "");
19192
- function readQueue(file10) {
19244
+ function readQueue(file9) {
19193
19245
  try {
19194
- const doc = JSON.parse(readFileSync16(file10, "utf8"));
19246
+ const doc = JSON.parse(readFileSync16(file9, "utf8"));
19195
19247
  return doc.v === 1 && Array.isArray(doc.writes) ? doc.writes.filter(isQueuedWrite) : [];
19196
19248
  } catch {
19197
19249
  return [];
@@ -19330,10 +19382,10 @@ import path31 from "node:path";
19330
19382
  var safe5 = (s) => s.replace(/[^\w.-]/g, "_");
19331
19383
  var briefPath = (root, mapId) => path31.join(root, BRIEF_DIR, `${safe5(mapId)}.md`);
19332
19384
  function readBriefFile(root, mapId) {
19333
- const file10 = briefPath(root, mapId);
19334
- if (!existsSync10(file10)) return void 0;
19385
+ const file9 = briefPath(root, mapId);
19386
+ if (!existsSync10(file9)) return void 0;
19335
19387
  try {
19336
- const text11 = readFileSync18(file10, "utf8");
19388
+ const text11 = readFileSync18(file9, "utf8");
19337
19389
  return { brief: parseBrief(mapId, text11), text: text11 };
19338
19390
  } catch {
19339
19391
  return void 0;
@@ -19484,9 +19536,9 @@ function nextKnowledgeId(root) {
19484
19536
  const n = Math.max(0, ...listKnowledge(root).map((e) => Number(e.id.slice(2)) || 0));
19485
19537
  return `K-${n + 1}`;
19486
19538
  }
19487
- function blobHash(repo, file10) {
19539
+ function blobHash(repo, file9) {
19488
19540
  const top = path33.resolve(repo);
19489
- const abs = path33.resolve(top, file10);
19541
+ const abs = path33.resolve(top, file9);
19490
19542
  if (!abs.startsWith(top + path33.sep) || !existsSync11(abs)) return void 0;
19491
19543
  const content = readFileSync19(abs);
19492
19544
  return createHash5("sha1").update(`blob ${content.length}\0`).update(content).digest("hex");
@@ -19554,14 +19606,14 @@ import path34 from "node:path";
19554
19606
  var VERIFICATION_FILE = "verification.json";
19555
19607
  var configHash = (text11) => `sha256:${createHash6("sha256").update(text11).digest("hex")}`;
19556
19608
  function readVerificationConfig(root) {
19557
- const file10 = path34.join(root, VERIFICATION_FILE);
19609
+ const file9 = path34.join(root, VERIFICATION_FILE);
19558
19610
  let text11;
19559
19611
  try {
19560
- text11 = readFileSync20(file10, "utf8");
19612
+ text11 = readFileSync20(file9, "utf8");
19561
19613
  } catch {
19562
- return { path: file10, exists: false, errors: [] };
19614
+ return { path: file9, exists: false, errors: [] };
19563
19615
  }
19564
- return { path: file10, exists: true, ...parseVerificationConfig(text11), hash: configHash(text11) };
19616
+ return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: configHash(text11) };
19565
19617
  }
19566
19618
 
19567
19619
  // ../core/src/verification/checksApproval.ts
@@ -19586,9 +19638,9 @@ function checksApproval(root) {
19586
19638
  return { state, waiting: state !== "approved" && state !== "none", text: text11, hash: hash2, approved };
19587
19639
  }
19588
19640
  function parsed2(root, text11) {
19589
- const file10 = path35.join(root, VERIFICATION_FILE);
19590
- if (!text11) return { path: file10, exists: false, errors: [] };
19591
- return { path: file10, exists: true, ...parseVerificationConfig(text11), hash: contentHash(text11) };
19641
+ const file9 = path35.join(root, VERIFICATION_FILE);
19642
+ if (!text11) return { path: file9, exists: false, errors: [] };
19643
+ return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: contentHash(text11) };
19592
19644
  }
19593
19645
  function trustedChecks(root) {
19594
19646
  const approval = checksApproval(root);
@@ -19687,18 +19739,18 @@ function latestMainRun(root, budgetMs = 0) {
19687
19739
  function lockMainRun(root, id, budgetMs) {
19688
19740
  ensureLocalDir(path36.join(root, EVIDENCE_DIR));
19689
19741
  ensureLocalDir(path36.join(root, MAIN_DIR));
19690
- const file10 = path36.join(root, RUNNING2);
19742
+ const file9 = path36.join(root, RUNNING2);
19691
19743
  for (let tries = 0; tries < 2; tries++) {
19692
19744
  try {
19693
- const fd = openSync2(file10, "wx");
19745
+ const fd = openSync2(file9, "wx");
19694
19746
  writeSync2(fd, JSON.stringify({ id, pid: process.pid, at: Date.now() }));
19695
19747
  closeSync2(fd);
19696
- return { ok: true, release: () => rmSync11(file10, { force: true }) };
19748
+ return { ok: true, release: () => rmSync11(file9, { force: true }) };
19697
19749
  } catch {
19698
- const held = readJsonFile(file10);
19750
+ const held = readJsonFile(file9);
19699
19751
  const live2 = !!held?.pid && processAlive(held.pid) && Date.now() - (held.at ?? 0) < budgetMs + STUCK_MARGIN_MS;
19700
19752
  if (live2) return { ok: false };
19701
- rmSync11(file10, { force: true });
19753
+ rmSync11(file9, { force: true });
19702
19754
  }
19703
19755
  }
19704
19756
  return { ok: false };
@@ -19937,9 +19989,9 @@ var safe9 = (s) => s.replace(/[^\w.-]/g, "_");
19937
19989
  var recordsDir = (root) => path39.join(root, AGENTS_DIR, "workspaces");
19938
19990
  var recordFile = (root, mapId, ticketId) => path39.join(recordsDir(root), `${safe9(mapId)}--${safe9(ticketId)}.json`);
19939
19991
  function readWorkspaceSettings(root) {
19940
- const file10 = path39.join(root, WORKSPACES_FILE);
19941
- if (!existsSync12(file10)) return { settings: DEFAULT_WORKSPACE_SETTINGS, errors: [], exists: false };
19942
- const parsed3 = parseWorkspaceSettings(readFileSync23(file10, "utf8"));
19992
+ const file9 = path39.join(root, WORKSPACES_FILE);
19993
+ if (!existsSync12(file9)) return { settings: DEFAULT_WORKSPACE_SETTINGS, errors: [], exists: false };
19994
+ const parsed3 = parseWorkspaceSettings(readFileSync23(file9, "utf8"));
19943
19995
  return { settings: parsed3.settings ?? DEFAULT_WORKSPACE_SETTINGS, errors: parsed3.errors, exists: true };
19944
19996
  }
19945
19997
  function writeWorkspaceSettings(root, s) {
@@ -20033,11 +20085,11 @@ function commonGitDir(repo) {
20033
20085
  const at2 = abs.lastIndexOf(`${path40.sep}worktrees${path40.sep}`);
20034
20086
  return at2 === -1 ? abs : abs.slice(0, at2);
20035
20087
  }
20036
- function ownWorktree(folder, gitDir) {
20037
- const dotGit = path40.join(folder, ".git");
20088
+ function ownWorktree(folder2, gitDir) {
20089
+ const dotGit = path40.join(folder2, ".git");
20038
20090
  if (!existsSync14(dotGit) || statSync8(dotGit).isDirectory()) return false;
20039
20091
  const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
20040
- return real2(path40.resolve(folder, pointed)).startsWith(`${gitDir}${path40.sep}worktrees${path40.sep}`);
20092
+ return real2(path40.resolve(folder2, pointed)).startsWith(`${gitDir}${path40.sep}worktrees${path40.sep}`);
20041
20093
  }
20042
20094
  function siblingProblem(o) {
20043
20095
  if (o.target === o.parent) return "is the folder your projects live in";
@@ -20232,10 +20284,10 @@ function noChangesFlag(i) {
20232
20284
 
20233
20285
  // ../core/src/evidence/pathCovered.ts
20234
20286
  var WILD2 = /[*?[{]/;
20235
- function pathCovered(glob, file10) {
20287
+ function pathCovered(glob, file9) {
20236
20288
  const g = glob.replace(/^\.\//, "").replace(/\/+$/, "");
20237
- if (WILD2.test(g)) return globMatch(g, file10);
20238
- return file10 === g || file10.startsWith(`${g}/`);
20289
+ if (WILD2.test(g)) return globMatch(g, file9);
20290
+ return file9 === g || file9.startsWith(`${g}/`);
20239
20291
  }
20240
20292
 
20241
20293
  // ../core/src/evidence/scopeFlag.ts
@@ -20310,9 +20362,9 @@ function readRunnerReport(o) {
20310
20362
  function resultOf(asked, got, log) {
20311
20363
  const raw = typeof got.output === "string" ? got.output : "";
20312
20364
  const output2 = redact(raw.slice(-MAX_OUTPUT));
20313
- const file10 = `${safe10(asked.name)}.log`;
20365
+ const file9 = `${safe10(asked.name)}.log`;
20314
20366
  mkdirSync19(log.dir, { recursive: true });
20315
- writeFileSync13(path45.join(log.dir, file10), output2);
20367
+ writeFileSync13(path45.join(log.dir, file9), output2);
20316
20368
  const error63 = text(got.error, 300);
20317
20369
  return {
20318
20370
  name: asked.name,
@@ -20323,7 +20375,7 @@ function resultOf(asked, got, log) {
20323
20375
  timedOut: got.timedOut === true,
20324
20376
  durationMs: Number.isFinite(got.durationMs) ? Math.max(0, Math.round(got.durationMs)) : 0,
20325
20377
  ...error63 ? { error: error63 } : {},
20326
- log: `${log.rel}/${file10}`,
20378
+ log: `${log.rel}/${file9}`,
20327
20379
  tail: tailOf(output2),
20328
20380
  truncated: raw.length > MAX_OUTPUT
20329
20381
  };
@@ -20348,6 +20400,10 @@ async function ask(runner, job, ms) {
20348
20400
  clearTimeout(timer);
20349
20401
  }
20350
20402
  }
20403
+ function otherCommit(o) {
20404
+ if (!o.asked || o.ran === o.asked) return void 0;
20405
+ return `${o.runner} ran on ${o.ran?.slice(0, 7) ?? "no commit it named"}, not ${o.asked.slice(0, 7)} as asked`;
20406
+ }
20351
20407
  async function runMainOnRunner(o) {
20352
20408
  const runner = o.runner.name;
20353
20409
  if (!o.runner.runMain)
@@ -20359,8 +20415,8 @@ async function runMainOnRunner(o) {
20359
20415
  runner,
20360
20416
  note: `${runner} doesn't run checks on main`
20361
20417
  };
20362
- const head = o.head ?? await defaultHead(o.repoRoot);
20363
- const known4 = "note" in head ? {} : { branch: head.branch, commit: head.commit };
20418
+ const head = o.head === void 0 ? await defaultHead(o.repoRoot) : o.head;
20419
+ const known4 = !head || "note" in head ? {} : { branch: head.branch, commit: head.commit };
20364
20420
  const asked = o.names.map((name2) => ({ name: name2, spec: o.config.checks[name2] }));
20365
20421
  const job = {
20366
20422
  runId: o.id,
@@ -20384,8 +20440,11 @@ async function runMainOnRunner(o) {
20384
20440
  ticketType: "research"
20385
20441
  });
20386
20442
  if ("error" in read4) return { ...at2, result: "unavailable", checks: [], note: read4.error };
20443
+ const ran = read4.git.tree?.head ?? null;
20444
+ const moved = otherCommit({ runner, asked: known4.commit, ran });
20445
+ if (moved) return { ...at2, result: "unavailable", checks: [], note: moved };
20387
20446
  const checks = read4.checks.map((c) => mainCheckResult(o.root, c, []));
20388
- const commit = read4.git.tree?.head ?? at2.commit;
20447
+ const commit = ran ?? at2.commit;
20389
20448
  const said = Array.isArray(report3.contains) ? report3.contains : [];
20390
20449
  const contains2 = o.contains ? { contains: o.contains.filter((c) => said.includes(c)) } : {};
20391
20450
  if (checks.length < asked.length && checks.every((c) => c.passed))
@@ -20660,10 +20719,10 @@ function trackerPin(root, configDir2) {
20660
20719
  return {
20661
20720
  /** The tracker to use now, and the one waiting for approval when `trackers.json` names another. */
20662
20721
  read() {
20663
- const file10 = project.read();
20722
+ const file9 = project.read();
20664
20723
  const pin = pinned();
20665
- if (trackerTargetKey(file10) === trackerTargetKey(pin)) return { config: file10 };
20666
- return { config: pin, pending: file10 };
20724
+ if (trackerTargetKey(file9) === trackerTargetKey(pin)) return { config: file9 };
20725
+ return { config: pin, pending: file9 };
20667
20726
  },
20668
20727
  /** The human chose this target on this machine (Settings, or approving a change to `trackers.json`). */
20669
20728
  approve(config4) {
@@ -20767,9 +20826,14 @@ async function here(env, o) {
20767
20826
  const found = await runMainHere({ ...job, head, logRel: trailPaths.logs(o.mapId, o.id) });
20768
20827
  return { ...found, merges: marked(o.merges, (c) => head.contained.has(c)) };
20769
20828
  }
20829
+ async function namedHead(repoRoot, commits) {
20830
+ const head = await trailHead(repoRoot, commits);
20831
+ if ("note" in head || head.contained.size < commits.length) return { note: "not every merge is here" };
20832
+ return head;
20833
+ }
20770
20834
  async function onRunner(env, o) {
20771
20835
  const repoRoot = env.repoRoot ?? path50.dirname(env.root);
20772
- const known4 = await defaultHead(repoRoot);
20836
+ const known4 = await namedHead(repoRoot, commitsOf(o.merges));
20773
20837
  const found = await runMainOnRunner({
20774
20838
  root: env.root,
20775
20839
  repoRoot,
@@ -20778,7 +20842,7 @@ async function onRunner(env, o) {
20778
20842
  config: o.plan.config,
20779
20843
  names: o.plan.names,
20780
20844
  signal: env.signal,
20781
- ..."note" in known4 ? {} : { head: { branch: known4.branch, commit: known4.commit } },
20845
+ head: "note" in known4 ? null : { branch: known4.branch, commit: known4.commit },
20782
20846
  contains: commitsOf(o.merges),
20783
20847
  logRel: trailPaths.logs(o.mapId, o.id)
20784
20848
  });
@@ -20926,9 +20990,9 @@ function judgeFile(root, item2, strict, out) {
20926
20990
  out.changes.push({ ...item2, fields: ["oversized"], counts: entry?.f, signed: !!entry, ...unreadable2 });
20927
20991
  return;
20928
20992
  }
20929
- const file10 = text11 === void 0 ? void 0 : cachedFields(item2, text11);
20930
- if (text11 !== void 0 && !file10) return;
20931
- const judged2 = judgeItem({ kind: item2.kind, entry, raw: file10, text: text11, strict });
20993
+ const file9 = text11 === void 0 ? void 0 : cachedFields(item2, text11);
20994
+ if (text11 !== void 0 && !file9) return;
20995
+ const judged2 = judgeItem({ kind: item2.kind, entry, raw: file9, text: text11, strict });
20932
20996
  if (judged2.textEdited) out.textEdits.push(item2);
20933
20997
  if (!judged2.outside.length) return;
20934
20998
  const signedText2 = entry?.text ? { signedText: entry.text } : {};
@@ -20939,7 +21003,7 @@ function judgeFile(root, item2, strict, out) {
20939
21003
  ...item2,
20940
21004
  fields: judged2.outside,
20941
21005
  counts: judged2.base,
20942
- file: file10,
21006
+ file: file9,
20943
21007
  signed: signed3,
20944
21008
  ...keep3,
20945
21009
  ...unreadable2,
@@ -20948,9 +21012,9 @@ function judgeFile(root, item2, strict, out) {
20948
21012
  }
20949
21013
  function removedTrail(root, mapId) {
20950
21014
  const entries2 = readStateRecord(root, mapId).entries;
20951
- const count2 = (kind2) => Object.keys(entries2).filter((k) => k.startsWith(`${kind2}:`)).length;
21015
+ const count3 = (kind2) => Object.keys(entries2).filter((k) => k.startsWith(`${kind2}:`)).length;
20952
21016
  const item2 = stateItemOf(`${mapId}/map.md`);
20953
- const trail2 = { tickets: count2("ticket"), decisions: count2("decision") };
21017
+ const trail2 = { tickets: count3("ticket"), decisions: count3("decision") };
20954
21018
  return { ...item2, fields: ["removed"], counts: entries2.map?.f, signed: true, trail: trail2 };
20955
21019
  }
20956
21020
  function outsideChanges(root) {
@@ -21449,8 +21513,8 @@ function briefItems(root, ledger) {
21449
21513
  const j = judged(ledger, trustKey.brief(mapId), read4.text);
21450
21514
  if (!j) return [];
21451
21515
  const lines = j.standing === "changed" ? j.lines : firstLines(read4.brief.sections.summary || read4.text);
21452
- const file10 = `${BRIEF_DIR}/${mapId}.md`;
21453
- return [{ ...j, lines, kind: "brief", title: "Accepted discovery brief", mapId, file: file10 }];
21516
+ const file9 = `${BRIEF_DIR}/${mapId}.md`;
21517
+ return [{ ...j, lines, kind: "brief", title: "Accepted discovery brief", mapId, file: file9 }];
21454
21518
  });
21455
21519
  }
21456
21520
  function criteriaItems(root, ledger) {
@@ -21459,8 +21523,8 @@ function criteriaItems(root, ledger) {
21459
21523
  const j = judged(ledger, trustKey.criteria(mapId, t.ticketId), criteriaContent(t));
21460
21524
  if (!j) return [];
21461
21525
  const title = `Confirmed criteria of ${t.ticketKey}`;
21462
- const file10 = `${CRITERIA_DIR}/${mapId}.md`;
21463
- return [{ ...j, kind: "criteria", title, mapId, ticketId: t.ticketId, file: file10 }];
21526
+ const file9 = `${CRITERIA_DIR}/${mapId}.md`;
21527
+ return [{ ...j, kind: "criteria", title, mapId, ticketId: t.ticketId, file: file9 }];
21464
21528
  })
21465
21529
  );
21466
21530
  }
@@ -21552,7 +21616,7 @@ function applyGuard(graded, o) {
21552
21616
  kind: "check-guard",
21553
21617
  level: held ? "alert" : "warn",
21554
21618
  message: `the work changed what its checks run: ${reason}`,
21555
- files: [...new Set(guard2.findings.map((f) => f.file))]
21619
+ files: [...new Set(guard2.findings.map((f) => f.file).filter(Boolean))]
21556
21620
  };
21557
21621
  if (graded.git) graded.git.flags.push(flag);
21558
21622
  if (graded.result === "pass")
@@ -21743,70 +21807,70 @@ var RUNNER_CONFIGS = {
21743
21807
  var base = (f) => f.split("/").pop() ?? f;
21744
21808
  var dirOf = (f) => f.split("/").slice(0, -1).join("/");
21745
21809
  var near = (a, b) => !a || !b || a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
21746
- var unread2 = (file10) => ({
21810
+ var unread2 = (file9) => ({
21747
21811
  kind: "unread",
21748
- file: file10,
21749
- text: `${file10} changed; Teamtrail couldn't read it to compare`
21812
+ file: file9,
21813
+ text: `${file9} changed; Teamtrail couldn't read it to compare`
21750
21814
  });
21751
- function packageFindings(file10, texts2, reach, tools) {
21815
+ function packageFindings(file9, texts2, reach, tools) {
21752
21816
  const [b, a] = texts2.map(packageJson);
21753
- if (b === "invalid" || a === "invalid") return [{ kind: "script", file: file10, text: `${file10} isn't valid JSON` }];
21817
+ if (b === "invalid" || a === "invalid") return [{ kind: "script", file: file9, text: `${file9} isn't valid JSON` }];
21754
21818
  const empty = { scripts: {}, keys: {} };
21755
21819
  const before = b ?? empty;
21756
21820
  const after = a ?? empty;
21757
- const names = [...reach.scripts.get(file10) ?? []].sort();
21758
- const scripts = names.filter((n) => before.scripts[n] !== after.scripts[n]).map((n) => ({ kind: "script", file: file10, text: `${file10} scripts.${n} changed` }));
21821
+ const names = [...reach.scripts.get(file9) ?? []].sort();
21822
+ const scripts = names.filter((n) => before.scripts[n] !== after.scripts[n]).map((n) => ({ kind: "script", file: file9, text: `${file9} scripts.${n} changed` }));
21759
21823
  const keys2 = tools.flatMap(
21760
- (tool) => (RUNNER_CONFIGS[tool]?.pkgKeys ?? []).filter((k) => before.keys[k] !== after.keys[k]).map((k) => ({ kind: "runner-config", file: file10, text: `${file10} "${k}" changed (${tool}'s config)` }))
21824
+ (tool) => (RUNNER_CONFIGS[tool]?.pkgKeys ?? []).filter((k) => before.keys[k] !== after.keys[k]).map((k) => ({ kind: "runner-config", file: file9, text: `${file9} "${k}" changed (${tool}'s config)` }))
21761
21825
  );
21762
21826
  return [...scripts, ...keys2];
21763
21827
  }
21764
- function configFindings(file10, texts2, tools) {
21765
- const name2 = base(file10);
21828
+ function configFindings(file9, texts2, tools) {
21829
+ const name2 = base(file9);
21766
21830
  const out = [];
21767
21831
  for (const tool of tools) {
21768
21832
  const c = RUNNER_CONFIGS[tool];
21769
21833
  if (!c) continue;
21770
21834
  if (c.files.some((r) => r.test(name2)))
21771
- out.push({ kind: "runner-config", file: file10, text: `${file10} changed (${tool}'s config)` });
21835
+ out.push({ kind: "runner-config", file: file9, text: `${file9} changed (${tool}'s config)` });
21772
21836
  for (const s of c.sections ?? []) {
21773
21837
  if (!s.file.test(name2)) continue;
21774
21838
  const [b, a] = texts2.map((t) => configSection(t, s.header));
21775
- if (b !== a) out.push({ kind: "runner-config", file: file10, text: `${file10} changed in ${tool}'s section` });
21839
+ if (b !== a) out.push({ kind: "runner-config", file: file9, text: `${file9} changed in ${tool}'s section` });
21776
21840
  }
21777
21841
  }
21778
21842
  return out;
21779
21843
  }
21780
- function makeFindings(file10, texts2, targets) {
21844
+ function makeFindings(file9, texts2, targets) {
21781
21845
  return [...targets].filter((t) => {
21782
21846
  const [b, a] = texts2.map((x) => x == null ? void 0 : makeReach(x, t || void 0).relevant);
21783
21847
  return b !== a;
21784
- }).map((t) => ({ kind: "makefile", file: file10, text: `${file10} changed for \`make${t ? ` ${t}` : ""}\`` }));
21848
+ }).map((t) => ({ kind: "makefile", file: file9, text: `${file9} changed for \`make${t ? ` ${t}` : ""}\`` }));
21785
21849
  }
21786
- var toolsNear = (file10, reach) => [...reach.tools].filter(([, dirs2]) => [...dirs2].some((d) => near(dirOf(file10), d))).map(([tool]) => tool).sort();
21787
- function needsText(file10, reach, tools) {
21788
- if (reach.scripts.has(file10) || reach.makefiles.has(file10)) return true;
21789
- if (base(file10) === "package.json") return tools.some((t) => RUNNER_CONFIGS[t]?.pkgKeys?.length);
21790
- return tools.some((t) => RUNNER_CONFIGS[t]?.sections?.some((s) => s.file.test(base(file10))));
21850
+ var toolsNear = (file9, reach) => [...reach.tools].filter(([, dirs2]) => [...dirs2].some((d) => near(dirOf(file9), d))).map(([tool]) => tool).sort();
21851
+ function needsText(file9, reach, tools) {
21852
+ if (reach.scripts.has(file9) || reach.makefiles.has(file9)) return true;
21853
+ if (base(file9) === "package.json") return tools.some((t) => RUNNER_CONFIGS[t]?.pkgKeys?.length);
21854
+ return tools.some((t) => RUNNER_CONFIGS[t]?.sections?.some((s) => s.file.test(base(file9))));
21791
21855
  }
21792
- async function fileFindings(file10, reach, read4) {
21793
- const tools = toolsNear(file10, reach);
21856
+ async function fileFindings(file9, reach, read4) {
21857
+ const tools = toolsNear(file9, reach);
21794
21858
  const out = [];
21795
- if (reach.files.has(file10)) out.push({ kind: "named-file", file: file10, text: `${file10} changed (the check runs it)` });
21796
- const guard2 = reach.guards.find((g) => globMatch(g.replace(/^\.\//, ""), file10));
21797
- if (guard2) out.push({ kind: "guarded", file: file10, text: `${file10} changed (guarded by ${guard2})` });
21798
- if (!needsText(file10, reach, tools)) return [...out, ...configFindings(file10, [null, null], tools)];
21799
- const texts2 = [await read4.before(file10), await read4.after(file10)];
21800
- if (texts2[0] === void 0 || texts2[1] === void 0) return [...out, unread2(file10)];
21801
- if (base(file10) === "package.json") out.push(...packageFindings(file10, texts2, reach, tools));
21802
- const targets = reach.makefiles.get(file10);
21803
- if (targets) out.push(...makeFindings(file10, texts2, targets));
21804
- return [...out, ...configFindings(file10, texts2, tools)];
21859
+ if (reach.files.has(file9)) out.push({ kind: "named-file", file: file9, text: `${file9} changed (the check runs it)` });
21860
+ const guard2 = reach.guards.find((g) => globMatch(g.replace(/^\.\//, ""), file9));
21861
+ if (guard2) out.push({ kind: "guarded", file: file9, text: `${file9} changed (guarded by ${guard2})` });
21862
+ if (!needsText(file9, reach, tools)) return [...out, ...configFindings(file9, [null, null], tools)];
21863
+ const texts2 = [await read4.before(file9), await read4.after(file9)];
21864
+ if (texts2[0] === void 0 || texts2[1] === void 0) return [...out, unread2(file9)];
21865
+ if (base(file9) === "package.json") out.push(...packageFindings(file9, texts2, reach, tools));
21866
+ const targets = reach.makefiles.get(file9);
21867
+ if (targets) out.push(...makeFindings(file9, texts2, targets));
21868
+ return [...out, ...configFindings(file9, texts2, tools)];
21805
21869
  }
21806
21870
  async function checkInputFindings(o) {
21807
21871
  const out = [];
21808
- for (const file10 of o.changed)
21809
- for (const f of await fileFindings(file10, o.reach, o.read)) out.push({ ...f, check: o.reach.check });
21872
+ for (const file9 of o.changed)
21873
+ for (const f of await fileFindings(file9, o.reach, o.read)) out.push({ ...f, check: o.reach.check });
21810
21874
  return out;
21811
21875
  }
21812
21876
 
@@ -21962,15 +22026,15 @@ function pkgArgs(args, dir4) {
21962
22026
  }
21963
22027
  function makeArgs(args, dir4) {
21964
22028
  let at2 = dir4;
21965
- let file10;
22029
+ let file9;
21966
22030
  let target2 = "";
21967
22031
  for (let n = 0; n < args.length; n++) {
21968
22032
  const a = args[n];
21969
22033
  if (a === "-C" || a === "--directory") at2 = repoPath2(at2, args[++n]) ?? at2;
21970
- else if (a === "-f" || a === "--file" || a === "--makefile") file10 = args[++n];
22034
+ else if (a === "-f" || a === "--file" || a === "--makefile") file9 = args[++n];
21971
22035
  else if (!a.startsWith("-") && !a.includes("=") && !target2) target2 = a;
21972
22036
  }
21973
- return { at: at2, file: file10, target: target2 };
22037
+ return { at: at2, file: file9, target: target2 };
21974
22038
  }
21975
22039
  var Walk = class {
21976
22040
  constructor(name2, guards, read4, changed) {
@@ -22037,7 +22101,7 @@ var Walk = class {
22037
22101
  }
22038
22102
  if (plan2.kind !== "script") return;
22039
22103
  await this.script(at2, plan2.name);
22040
- if (across) for (const folder of await this.packagesUnder(at2)) await this.script(folder, plan2.name);
22104
+ if (across) for (const folder2 of await this.packagesUnder(at2)) await this.script(folder2, plan2.name);
22041
22105
  }
22042
22106
  /** A package.json script, its pre and post scripts, and the commands they run, read before and after. */
22043
22107
  async script(dir4, name2) {
@@ -22062,21 +22126,21 @@ var Walk = class {
22062
22126
  for (let n = parts2.length; n > (dir4 ? dir4.split("/").length : 0); n--) folders.add(parts2.slice(0, n).join("/"));
22063
22127
  }
22064
22128
  const out = [];
22065
- for (const folder of folders) {
22066
- const [b, a] = await this.both(`${folder}/package.json`);
22067
- if (b != null || a != null) out.push(folder);
22129
+ for (const folder2 of folders) {
22130
+ const [b, a] = await this.both(`${folder2}/package.json`);
22131
+ if (b != null || a != null) out.push(folder2);
22068
22132
  }
22069
22133
  return out;
22070
22134
  }
22071
22135
  /** `make -C dir -f file target`: the makefile, its target, and the recipes the target reaches. */
22072
22136
  async make(args, dir4) {
22073
- const { at: at2, file: file10, target: target2 } = makeArgs(args, dir4);
22074
- const names = file10 ? [file10] : MAKEFILES;
22137
+ const { at: at2, file: file9, target: target2 } = makeArgs(args, dir4);
22138
+ const names = file9 ? [file9] : MAKEFILES;
22075
22139
  for (const name2 of names) {
22076
22140
  const rel = repoPath2(at2, name2);
22077
22141
  if (!rel) continue;
22078
22142
  const texts2 = await this.both(rel);
22079
- if (texts2.every((t) => t == null) && !file10) continue;
22143
+ if (texts2.every((t) => t == null) && !file9) continue;
22080
22144
  const targets = this.reach.makefiles.get(rel) ?? /* @__PURE__ */ new Set();
22081
22145
  this.reach.makefiles.set(rel, targets.add(target2));
22082
22146
  const recipes = texts2.flatMap((text11) => text11 == null ? [] : makeReach(text11, target2 || void 0).recipes);
@@ -22125,30 +22189,30 @@ var TEST_PATTERNS = [
22125
22189
 
22126
22190
  // ../core/src/checkGuard/testFindings.ts
22127
22191
  var TEST_PATH = /(^|\/)(tests?|__tests__|specs?|e2e)\/|[._-](test|spec)s?\.[^/]+$|(^|\/)test_[^/]*\.py$|Tests?\.(java|kt)$|\.rs$/;
22128
- var count = (text11, r) => text11 && r ? (text11.match(r) ?? []).length : 0;
22192
+ var count2 = (text11, r) => text11 && r ? (text11.match(r) ?? []).length : 0;
22129
22193
  var tests = (n) => `${n} test${n === 1 ? "" : "s"}`;
22130
- function weakened(file10, p, before, after) {
22131
- const had = count(before, p.test);
22194
+ function weakened(file9, p, before, after) {
22195
+ const had = count2(before, p.test);
22132
22196
  if (after === null)
22133
- return had ? [{ kind: "deleted-tests", file: file10, text: `${file10} deleted (${tests(had)})` }] : [];
22197
+ return had ? [{ kind: "deleted-tests", file: file9, text: `${file9} deleted (${tests(had)})` }] : [];
22134
22198
  if (after === void 0) return [];
22135
22199
  const out = [];
22136
- const removed = had - count(after, p.test);
22137
- if (removed > 0) out.push({ kind: "removed-tests", file: file10, text: `${tests(removed)} removed from ${file10}` });
22138
- const skipped = count(after, p.skip) - count(before, p.skip);
22139
- if (skipped > 0) out.push({ kind: "skipped", file: file10, text: `${tests(skipped)} skipped in ${file10}` });
22140
- const focused = count(after, p.focus) - count(before, p.focus);
22141
- if (focused > 0) out.push({ kind: "focused", file: file10, text: `${tests(focused)} focused with .only in ${file10}` });
22200
+ const removed = had - count2(after, p.test);
22201
+ if (removed > 0) out.push({ kind: "removed-tests", file: file9, text: `${tests(removed)} removed from ${file9}` });
22202
+ const skipped = count2(after, p.skip) - count2(before, p.skip);
22203
+ if (skipped > 0) out.push({ kind: "skipped", file: file9, text: `${tests(skipped)} skipped in ${file9}` });
22204
+ const focused = count2(after, p.focus) - count2(before, p.focus);
22205
+ if (focused > 0) out.push({ kind: "focused", file: file9, text: `${tests(focused)} focused with .only in ${file9}` });
22142
22206
  return out;
22143
22207
  }
22144
22208
  async function testFindings(o) {
22145
22209
  const out = [];
22146
- for (const file10 of o.changed) {
22147
- const p = TEST_PATTERNS.find((x) => x.file.test(file10));
22148
- if (!p || !TEST_PATH.test(file10) || file10.split("/").includes("node_modules")) continue;
22149
- const before = await o.read.before(file10);
22210
+ for (const file9 of o.changed) {
22211
+ const p = TEST_PATTERNS.find((x) => x.file.test(file9));
22212
+ if (!p || !TEST_PATH.test(file9) || file9.split("/").includes("node_modules")) continue;
22213
+ const before = await o.read.before(file9);
22150
22214
  if (typeof before !== "string") continue;
22151
- out.push(...weakened(file10, p, before, await o.read.after(file10)));
22215
+ out.push(...weakened(file9, p, before, await o.read.after(file9)));
22152
22216
  }
22153
22217
  return out;
22154
22218
  }
@@ -22212,9 +22276,17 @@ function prefixOf(toplevel, checkout) {
22212
22276
  const rel = path57.relative(real3(toplevel), real3(checkout)).split(path57.sep).join("/");
22213
22277
  return rel.startsWith("..") || path57.isAbsolute(rel) ? "" : rel;
22214
22278
  }
22279
+ function noBaseline(config4) {
22280
+ const mode = gateModeFor(config4, "check-guard");
22281
+ if (mode === "off") return void 0;
22282
+ const text11 = "no baseline this machine recorded at the claim: the check guard couldn't tell what the work changed";
22283
+ return { mode, findings: [{ kind: "unread", file: "", text: text11 }] };
22284
+ }
22215
22285
  async function localGuard(o) {
22216
22286
  const { tree, base: base2 } = o.git;
22217
- if (!tree || !base2?.head || !o.git.changed.length) return void 0;
22287
+ if (!tree) return void 0;
22288
+ if (!o.git.baseline) return noBaseline(o.config);
22289
+ if (!base2?.head || !o.git.changed.length) return void 0;
22218
22290
  return guardAttempt({
22219
22291
  config: o.config,
22220
22292
  checks: o.checks,
@@ -22235,15 +22307,77 @@ async function withLocalGuard(graded, o) {
22235
22307
  // ../core/src/evidence/collectEvidence.ts
22236
22308
  import { existsSync as existsSync21 } from "node:fs";
22237
22309
 
22238
- // ../core/src/evidence/baseline.ts
22239
- import { readdirSync as readdirSync17 } from "node:fs";
22240
- import path59 from "node:path";
22310
+ // ../core/src/evidence/baselineStore.ts
22311
+ import { linkSync as linkSync4, mkdirSync as mkdirSync21, readdirSync as readdirSync17, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
22312
+ import path58 from "node:path";
22313
+ var DIR = "baselines";
22314
+ var RE = /^baseline-(\d+)\.json$/;
22315
+ var safe13 = (s) => s.replace(/[^\w-]/g, "_");
22316
+ var folder = (root, mapId, ticketId) => path58.join(machineStore(root).dir, DIR, `${safe13(mapId)}--${safe13(ticketId)}`);
22317
+ var macParts = (root, b) => [
22318
+ "baseline",
22319
+ machineId(root),
22320
+ b.mapId,
22321
+ b.ticketId,
22322
+ JSON.stringify(b)
22323
+ ];
22324
+ function numbers(dir4) {
22325
+ try {
22326
+ return readdirSync17(dir4).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
22327
+ } catch {
22328
+ return [];
22329
+ }
22330
+ }
22331
+ function verified(root, o) {
22332
+ const raw = readJsonFile(o.file);
22333
+ const b = raw?.baseline;
22334
+ if (raw?.v !== 1 || b?.v !== 1 || b.mapId !== o.mapId || b.ticketId !== o.ticketId) return void 0;
22335
+ try {
22336
+ return machineSigned(macParts(root, b), raw.mac) ? b : void 0;
22337
+ } catch {
22338
+ return void 0;
22339
+ }
22340
+ }
22341
+ function createWhole(file9, text11) {
22342
+ const tmp = `${file9}.${process.pid}.${Date.now()}.tmp`;
22343
+ writeFileSync15(tmp, text11, { mode: 384, flag: "wx" });
22344
+ try {
22345
+ linkSync4(tmp, file9);
22346
+ } finally {
22347
+ rmSync13(tmp, { force: true });
22348
+ }
22349
+ }
22350
+ var baselineStore = {
22351
+ /** The ticket's most recent baseline as this machine recorded it; undefined when there is none it signed. */
22352
+ latest(root, mapId, ticketId) {
22353
+ const dir4 = folder(root, mapId, ticketId);
22354
+ const n = numbers(dir4).at(-1);
22355
+ return n ? verified(root, { mapId, ticketId, file: path58.join(dir4, `baseline-${n}.json`) }) : void 0;
22356
+ },
22357
+ /** Records a new baseline under the next number, signed; returns it with its id. Throws when it can't be kept. */
22358
+ add(root, rec) {
22359
+ const dir4 = folder(root, rec.mapId, rec.ticketId);
22360
+ mkdirSync21(dir4, { recursive: true, mode: 448 });
22361
+ for (; ; ) {
22362
+ const id = `baseline-${(numbers(dir4).at(-1) ?? 0) + 1}`;
22363
+ const baseline = { ...rec, id };
22364
+ const signed3 = { v: 1, baseline, mac: machineSign(macParts(root, baseline)) };
22365
+ try {
22366
+ createWhole(path58.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
22367
+ `);
22368
+ return baseline;
22369
+ } catch (e) {
22370
+ if (e.code !== "EEXIST") throw e;
22371
+ }
22372
+ }
22373
+ }
22374
+ };
22241
22375
 
22242
22376
  // ../core/src/evidence/treeState.ts
22243
22377
  import { createHash as createHash7 } from "node:crypto";
22244
22378
  import { existsSync as existsSync20, realpathSync as realpathSync10 } from "node:fs";
22245
- import path58 from "node:path";
22246
- var posix = (p) => p.split(path58.sep).join("/");
22379
+ import path59 from "node:path";
22380
+ var posix = (p) => p.split(path59.sep).join("/");
22247
22381
  async function findWorktree(cwd, trackerRoot) {
22248
22382
  if (!existsSync20(cwd)) return { error: `${cwd} does not exist` };
22249
22383
  const r = await git(cwd, ["rev-parse", "--show-toplevel"]);
@@ -22252,15 +22386,15 @@ async function findWorktree(cwd, trackerRoot) {
22252
22386
  const toplevel = realpathSync10(r.stdout.toString("utf8").trim());
22253
22387
  const pathspec = ["--", "."];
22254
22388
  if (trackerRoot && existsSync20(trackerRoot)) {
22255
- const rel = path58.relative(toplevel, realpathSync10(trackerRoot));
22256
- if (rel && !rel.startsWith("..") && !path58.isAbsolute(rel)) pathspec.push(`:(exclude)${posix(rel)}`);
22389
+ const rel = path59.relative(toplevel, realpathSync10(trackerRoot));
22390
+ if (rel && !rel.startsWith("..") && !path59.isAbsolute(rel)) pathspec.push(`:(exclude)${posix(rel)}`);
22257
22391
  }
22258
22392
  return { toplevel, pathspec };
22259
22393
  }
22260
22394
  var emptyTree = (wt) => gitText(wt.toplevel, ["hash-object", "-t", "tree", "--stdin"], "").then((s) => s ?? "");
22261
22395
  async function hashFiles(wt, files) {
22262
22396
  const out = {};
22263
- const present = files.filter((f) => existsSync20(path58.join(wt.toplevel, f)));
22397
+ const present = files.filter((f) => existsSync20(path59.join(wt.toplevel, f)));
22264
22398
  for (const f of files) out[f] = null;
22265
22399
  if (!present.length) return out;
22266
22400
  const r = await git(wt.toplevel, ["hash-object", "--stdin-paths"], present.join("\n") + "\n");
@@ -22285,22 +22419,8 @@ async function readTreeState(wt) {
22285
22419
  }
22286
22420
 
22287
22421
  // ../core/src/evidence/baseline.ts
22288
- var RE = /^baseline-(\d+)\.json$/;
22289
- function numbers(root, mapId, ticketId) {
22290
- try {
22291
- return readdirSync17(path59.join(root, evidencePaths.ticket(mapId, ticketId))).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
22292
- } catch {
22293
- return [];
22294
- }
22295
- }
22296
- var file3 = (mapId, ticketId, id) => `${evidencePaths.ticket(mapId, ticketId)}/${id}.json`;
22297
- var readBaseline = (root, mapId, ticketId, id) => {
22298
- const b = readJsonFile(path59.join(root, file3(mapId, ticketId, id)));
22299
- return b?.v === 1 ? b : void 0;
22300
- };
22301
22422
  function latestBaseline(root, mapId, ticketId) {
22302
- const n = numbers(root, mapId, ticketId).at(-1);
22303
- return n ? readBaseline(root, mapId, ticketId, `baseline-${n}`) : void 0;
22423
+ return baselineStore.latest(root, mapId, ticketId);
22304
22424
  }
22305
22425
  async function captureBaseline(c) {
22306
22426
  const wt = await findWorktree(c.cwd, c.root);
@@ -22316,16 +22436,10 @@ async function captureBaseline(c) {
22316
22436
  ..."error" in wt ? { git: null, note: wt.error } : { git: await readTreeState(wt) },
22317
22437
  ...config4.hash ? { configHash: config4.hash } : {}
22318
22438
  };
22319
- for (; ; ) {
22320
- const id = `baseline-${(numbers(c.root, c.mapId, c.ticket.id).at(-1) ?? 0) + 1}`;
22321
- try {
22322
- writeOnce(c.root, file3(c.mapId, c.ticket.id, id), { ...rec, id });
22323
- return { ...rec, id };
22324
- } catch (e) {
22325
- const code2 = e.code;
22326
- if (code2 === "EEXIST") continue;
22327
- return { ...rec, id, note: `baseline not saved: ${e.message}` };
22328
- }
22439
+ try {
22440
+ return baselineStore.add(c.root, rec);
22441
+ } catch (e) {
22442
+ return { ...rec, id: "baseline-unsaved", note: `baseline not saved: ${e.message}` };
22329
22443
  }
22330
22444
  }
22331
22445
  async function baselineForClaim(c) {
@@ -22449,7 +22563,7 @@ function evidenceFlags(i) {
22449
22563
  out.push({
22450
22564
  kind: "no-baseline",
22451
22565
  level: "warn",
22452
- message: "no git baseline from the claim: changes cannot be told apart from earlier work"
22566
+ message: "no baseline this machine recorded at the claim: changes cannot be told apart from earlier work"
22453
22567
  });
22454
22568
  return out;
22455
22569
  }
@@ -22929,11 +23043,11 @@ ${note}` : reviewBody(t, a)
22929
23043
  }
22930
23044
 
22931
23045
  // ../core/src/verification/runLock.ts
22932
- import { mkdirSync as mkdirSync21, readdirSync as readdirSync18, renameSync as renameSync9, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
23046
+ import { mkdirSync as mkdirSync22, readdirSync as readdirSync18, renameSync as renameSync9, rmSync as rmSync14, writeFileSync as writeFileSync16 } from "node:fs";
22933
23047
  import path64 from "node:path";
22934
23048
  var RUNS_DIR = `${AGENTS_DIR}/runs`;
22935
- var safe13 = (s) => s.replace(/[^\w.-]/g, "_");
22936
- var lockFile = (root, mapId, ticketId) => path64.join(root, RUNS_DIR, `${safe13(mapId)}--${safe13(ticketId)}.json`);
23049
+ var safe14 = (s) => s.replace(/[^\w.-]/g, "_");
23050
+ var lockFile = (root, mapId, ticketId) => path64.join(root, RUNS_DIR, `${safe14(mapId)}--${safe14(ticketId)}.json`);
22937
23051
  var readRunLock = (root, mapId, ticketId) => readJsonFile(lockFile(root, mapId, ticketId));
22938
23052
  function readRunLocks(root) {
22939
23053
  let names = [];
@@ -22945,18 +23059,18 @@ function readRunLocks(root) {
22945
23059
  return names.map((n) => readJsonFile(path64.join(root, RUNS_DIR, n))).filter((l) => l?.v === 1 && !!l.ticketId);
22946
23060
  }
22947
23061
  function recover(root, lock, now2) {
22948
- const file10 = lockFile(root, lock.mapId, lock.ticketId);
22949
- const claimed = `${file10}.${process.pid}.recover`;
23062
+ const file9 = lockFile(root, lock.mapId, lock.ticketId);
23063
+ const claimed = `${file9}.${process.pid}.recover`;
22950
23064
  try {
22951
- renameSync9(file10, claimed);
23065
+ renameSync9(file9, claimed);
22952
23066
  } catch {
22953
23067
  return void 0;
22954
23068
  }
22955
23069
  const held = readJsonFile(claimed);
22956
- rmSync13(claimed, { force: true });
23070
+ rmSync14(claimed, { force: true });
22957
23071
  if (held && held.pid !== lock.pid) {
22958
23072
  try {
22959
- writeFileSync15(file10, JSON.stringify(held, null, 2), { flag: "wx" });
23073
+ writeFileSync16(file9, JSON.stringify(held, null, 2), { flag: "wx" });
22960
23074
  } catch {
22961
23075
  }
22962
23076
  return void 0;
@@ -22979,14 +23093,14 @@ function recover(root, lock, now2) {
22979
23093
  return a;
22980
23094
  }
22981
23095
  function acquireRunLock(root, lock, now2 = Date.now()) {
22982
- const file10 = lockFile(root, lock.mapId, lock.ticketId);
23096
+ const file9 = lockFile(root, lock.mapId, lock.ticketId);
22983
23097
  const mine2 = { ...lock, pid: process.pid, startedAt: now2 };
22984
23098
  let recovered;
22985
23099
  ensureLocalDir(path64.join(root, AGENTS_DIR));
22986
- mkdirSync21(path64.dirname(file10), { recursive: true });
23100
+ mkdirSync22(path64.dirname(file9), { recursive: true });
22987
23101
  for (let i = 0; i < 3; i++) {
22988
23102
  try {
22989
- writeFileSync15(file10, JSON.stringify(mine2, null, 2), { flag: "wx" });
23103
+ writeFileSync16(file9, JSON.stringify(mine2, null, 2), { flag: "wx" });
22990
23104
  return { ok: true, lock: mine2, ...recovered ? { recovered } : {} };
22991
23105
  } catch (e) {
22992
23106
  if (e.code !== "EEXIST") throw e;
@@ -22994,7 +23108,7 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
22994
23108
  const holder2 = readRunLock(root, lock.mapId, lock.ticketId);
22995
23109
  if (holder2 && processAlive(holder2.pid)) return { ok: false, holder: holder2 };
22996
23110
  if (holder2) recovered = recover(root, holder2, now2) ?? recovered;
22997
- else rmSync13(file10, { force: true });
23111
+ else rmSync14(file9, { force: true });
22998
23112
  }
22999
23113
  const holder = readRunLock(root, lock.mapId, lock.ticketId);
23000
23114
  if (holder) return { ok: false, holder };
@@ -23002,7 +23116,7 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
23002
23116
  }
23003
23117
  function releaseRunLock(root, mapId, ticketId, pid = process.pid) {
23004
23118
  const held = readRunLock(root, mapId, ticketId);
23005
- if (held?.pid === pid) rmSync13(lockFile(root, mapId, ticketId), { force: true });
23119
+ if (held?.pid === pid) rmSync14(lockFile(root, mapId, ticketId), { force: true });
23006
23120
  }
23007
23121
  var recoverInterrupted = (root, now2 = Date.now()) => readRunLocks(root).filter((l) => !processAlive(l.pid)).map((l) => recover(root, l, now2)).filter((a) => !!a);
23008
23122
 
@@ -23144,13 +23258,13 @@ function outcomeOf3(checks, asked) {
23144
23258
  }
23145
23259
 
23146
23260
  // ../core/src/verification/checkWaivers.ts
23147
- import { mkdirSync as mkdirSync22 } from "node:fs";
23261
+ import { mkdirSync as mkdirSync23 } from "node:fs";
23148
23262
  var FILE8 = "waivers.json";
23149
23263
  var keyOf5 = (mapId, ticketId) => `${mapId}/${ticketId}`;
23150
23264
  function change(root, fn) {
23151
23265
  try {
23152
23266
  const store = machineStore(root);
23153
- mkdirSync22(store.dir, { recursive: true, mode: 448 });
23267
+ mkdirSync23(store.dir, { recursive: true, mode: 448 });
23154
23268
  withFileLock2(store.file(`${FILE8}.lock`), () => {
23155
23269
  const all = store.read(FILE8) ?? {};
23156
23270
  fn(all);
@@ -23230,7 +23344,7 @@ function matchRules(rules2, files) {
23230
23344
  }
23231
23345
 
23232
23346
  // ../core/src/verification/ruleWaivers.ts
23233
- import { mkdirSync as mkdirSync23 } from "node:fs";
23347
+ import { mkdirSync as mkdirSync24 } from "node:fs";
23234
23348
  var FILE9 = "rule-waivers.json";
23235
23349
  var keyOf6 = (mapId, ticketId) => `${mapId}/${ticketId}`;
23236
23350
  var ruleWaivers = {
@@ -23246,7 +23360,7 @@ var ruleWaivers = {
23246
23360
  add(root, w) {
23247
23361
  try {
23248
23362
  const store = machineStore(root);
23249
- mkdirSync23(store.dir, { recursive: true, mode: 448 });
23363
+ mkdirSync24(store.dir, { recursive: true, mode: 448 });
23250
23364
  withFileLock2(store.file(`${FILE9}.lock`), () => {
23251
23365
  const all = store.read(FILE9) ?? {};
23252
23366
  const key = keyOf6(w.mapId, w.ticketId);
@@ -23258,6 +23372,26 @@ var ruleWaivers = {
23258
23372
  `Couldn't keep it in Teamtrail's config folder on this machine: ${e.message}`
23259
23373
  );
23260
23374
  }
23375
+ },
23376
+ /** Removes the ticket's waiver of `rule` under the file's lock; returns it, or undefined when there was none. */
23377
+ remove(root, at2) {
23378
+ try {
23379
+ const store = machineStore(root);
23380
+ mkdirSync24(store.dir, { recursive: true, mode: 448 });
23381
+ return withFileLock2(store.file(`${FILE9}.lock`), () => {
23382
+ const all = store.read(FILE9) ?? {};
23383
+ const key = keyOf6(at2.mapId, at2.ticketId);
23384
+ const gone = all[key]?.find((x) => x.rule === at2.rule);
23385
+ if (!gone) return void 0;
23386
+ const left = all[key].filter((x) => x !== gone);
23387
+ if (left.length) all[key] = left;
23388
+ else delete all[key];
23389
+ store.write(FILE9, all);
23390
+ return gone;
23391
+ });
23392
+ } catch (e) {
23393
+ throw new OperationError(`Couldn't change Teamtrail's config folder on this machine: ${e.message}`);
23394
+ }
23261
23395
  }
23262
23396
  };
23263
23397
 
@@ -23508,14 +23642,14 @@ function reviewItem({ base: base2, last, verdict: verdict2 }, level) {
23508
23642
 
23509
23643
  // ../core/src/workspaces/integrationStore.ts
23510
23644
  import path67 from "node:path";
23511
- var file4 = (root) => path67.join(root, AGENTS_DIR, "integration.json");
23645
+ var file3 = (root) => path67.join(root, AGENTS_DIR, "integration.json");
23512
23646
  function readIntegrationScan(root) {
23513
- const s = readJsonFile(file4(root));
23647
+ const s = readJsonFile(file3(root));
23514
23648
  return s?.v === 1 ? s : { v: 1, at: 0, overlaps: [] };
23515
23649
  }
23516
23650
  function writeIntegrationScan(root, s) {
23517
23651
  ensureLocalDir(path67.join(root, AGENTS_DIR));
23518
- writeJsonAtomic(file4(root), s);
23652
+ writeJsonAtomic(file3(root), s);
23519
23653
  }
23520
23654
 
23521
23655
  // ../core/src/precedent/precedentAreas.ts
@@ -23603,12 +23737,12 @@ async function readViolations(input2) {
23603
23737
  }
23604
23738
 
23605
23739
  // ../core/src/planning/reroute/rerouteStore.ts
23606
- import { mkdirSync as mkdirSync24, readdirSync as readdirSync19, writeFileSync as writeFileSync16 } from "node:fs";
23740
+ import { mkdirSync as mkdirSync25, readdirSync as readdirSync19, writeFileSync as writeFileSync17 } from "node:fs";
23607
23741
  import path68 from "node:path";
23608
23742
  var REROUTES_DIR = ".reroutes";
23609
- var safe14 = (s) => s.replace(/[^\w.-]/g, "_");
23610
- var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR, safe14(mapId));
23611
- var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${safe14(id)}.json`);
23743
+ var safe15 = (s) => s.replace(/[^\w.-]/g, "_");
23744
+ var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR, safe15(mapId));
23745
+ var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${safe15(id)}.json`);
23612
23746
  var idNumber2 = (id) => Number(id.match(/^R-(\d+)$/)?.[1] ?? 0);
23613
23747
  function listReroutes(root, mapId) {
23614
23748
  let names = [];
@@ -23632,12 +23766,12 @@ var readReroute = (root, mapId, id) => readJsonFile(fileOf(root, mapId, id));
23632
23766
  function createReroute(root, draft) {
23633
23767
  const dir4 = mapDir(root, draft.mapId);
23634
23768
  ensureLocalDir(path68.join(root, REROUTES_DIR));
23635
- mkdirSync24(dir4, { recursive: true });
23769
+ mkdirSync25(dir4, { recursive: true });
23636
23770
  let n = Math.max(0, ...listReroutes(root, draft.mapId).map((p) => idNumber2(p.id))) + 1;
23637
23771
  for (; ; ) {
23638
23772
  const p = { ...draft, id: `R-${n}` };
23639
23773
  try {
23640
- writeFileSync16(fileOf(root, draft.mapId, p.id), JSON.stringify(p, null, 2), { flag: "wx" });
23774
+ writeFileSync17(fileOf(root, draft.mapId, p.id), JSON.stringify(p, null, 2), { flag: "wx" });
23641
23775
  return p;
23642
23776
  } catch (e) {
23643
23777
  if (e.code !== "EEXIST") throw e;
@@ -23773,11 +23907,11 @@ async function attentionView(input2) {
23773
23907
  import { existsSync as existsSync24, readFileSync as readFileSync27 } from "node:fs";
23774
23908
  import path69 from "node:path";
23775
23909
  function writeReviewLimit(root, limit) {
23776
- const file10 = path69.join(root, ATTENTION_FILE);
23910
+ const file9 = path69.join(root, ATTENTION_FILE);
23777
23911
  let raw = { v: 1 };
23778
- if (existsSync24(file10)) {
23912
+ if (existsSync24(file9)) {
23779
23913
  try {
23780
- const read4 = parseJsonSafe(readFileSync27(file10, "utf8"));
23914
+ const read4 = parseJsonSafe(readFileSync27(file9, "utf8"));
23781
23915
  if (!read4 || typeof read4 !== "object" || Array.isArray(read4)) throw new Error("not a JSON object");
23782
23916
  raw = read4;
23783
23917
  } catch (err) {
@@ -23792,7 +23926,7 @@ function writeReviewLimit(root, limit) {
23792
23926
  const parsed3 = parseAttentionPolicy(next);
23793
23927
  const own3 = parsed3.errors.filter((e) => e.includes('"reviewLimit"'));
23794
23928
  if (own3.length) return { value: parsed3.value, errors: own3 };
23795
- writeJsonAtomic(file10, next);
23929
+ writeJsonAtomic(file9, next);
23796
23930
  return { value: parsed3.value, errors: [] };
23797
23931
  }
23798
23932
 
@@ -23927,8 +24061,8 @@ async function handleBriefs({ root, active }, req, res, url2) {
23927
24061
  if (url2.pathname === "/briefs" && req.method === "GET") {
23928
24062
  const mapId2 = url2.searchParams.get("mapId");
23929
24063
  if (!trailId(mapId2)) throw new BadRequest('"mapId" is required');
23930
- const file10 = readBriefFile(root, mapId2);
23931
- const hash2 = file10 ? { hash: contentHash(file10.text) } : {};
24064
+ const file9 = readBriefFile(root, mapId2);
24065
+ const hash2 = file9 ? { hash: contentHash(file9.text) } : {};
23932
24066
  sendJson(res, 200, { brief: readBrief(root, mapId2) ?? null, gated: requiresDiscovery(root, mapId2), ...hash2 });
23933
24067
  return true;
23934
24068
  }
@@ -23988,30 +24122,30 @@ async function seedAssumptions(adapter, brief) {
23988
24122
  }
23989
24123
 
23990
24124
  // ../core/src/criteria/criteriaProposals.ts
23991
- import { rmSync as rmSync14 } from "node:fs";
24125
+ import { rmSync as rmSync15 } from "node:fs";
23992
24126
  import path71 from "node:path";
23993
24127
 
23994
24128
  // ../core/src/agents/ignoreAgentsDir.ts
23995
- import { existsSync as existsSync25, mkdirSync as mkdirSync25, writeFileSync as writeFileSync17 } from "node:fs";
24129
+ import { existsSync as existsSync25, mkdirSync as mkdirSync26, writeFileSync as writeFileSync18 } from "node:fs";
23996
24130
  import path70 from "node:path";
23997
24131
  function ignoreAgentsDir(root) {
23998
24132
  const ignore = path70.join(root, AGENTS_DIR, ".gitignore");
23999
- mkdirSync25(path70.dirname(ignore), { recursive: true });
24000
- if (!existsSync25(ignore)) writeFileSync17(ignore, "*\n");
24133
+ mkdirSync26(path70.dirname(ignore), { recursive: true });
24134
+ if (!existsSync25(ignore)) writeFileSync18(ignore, "*\n");
24001
24135
  }
24002
24136
 
24003
24137
  // ../core/src/criteria/criteriaProposals.ts
24004
- var safe15 = (s) => s.replace(/[^\w.-]/g, "_");
24005
- var file5 = (root, mapId) => path71.join(root, AGENTS_DIR, "criteria-proposals", `${safe15(mapId)}.json`);
24138
+ var safe16 = (s) => s.replace(/[^\w.-]/g, "_");
24139
+ var file4 = (root, mapId) => path71.join(root, AGENTS_DIR, "criteria-proposals", `${safe16(mapId)}.json`);
24006
24140
  var isProposal = (p) => !!p && typeof p.ticketId === "string" && typeof p.by === "string" && Array.isArray(p.criteria);
24007
24141
  function readCriteriaProposals(root, mapId) {
24008
- const f = readJsonFile(file5(root, mapId));
24142
+ const f = readJsonFile(file4(root, mapId));
24009
24143
  return f?.v === 1 && Array.isArray(f.proposals) ? f.proposals.filter(isProposal) : [];
24010
24144
  }
24011
24145
  function save(root, mapId, proposals) {
24012
24146
  ignoreAgentsDir(root);
24013
- if (proposals.length) writeJsonAtomic(file5(root, mapId), { v: 1, proposals });
24014
- else rmSync14(file5(root, mapId), { force: true });
24147
+ if (proposals.length) writeJsonAtomic(file4(root, mapId), { v: 1, proposals });
24148
+ else rmSync15(file4(root, mapId), { force: true });
24015
24149
  }
24016
24150
  function writeCriteriaProposal(root, mapId, p) {
24017
24151
  save(root, mapId, [...readCriteriaProposals(root, mapId).filter((x) => x.ticketId !== p.ticketId), p]);
@@ -24112,7 +24246,7 @@ async function handleDecisionMemory(ctx, req, res, url2) {
24112
24246
  }
24113
24247
 
24114
24248
  // ../core/src/policy/lookoutOnlyTickets.ts
24115
- import { mkdirSync as mkdirSync26 } from "node:fs";
24249
+ import { mkdirSync as mkdirSync27 } from "node:fs";
24116
24250
  var FILE10 = "lookout-only.json";
24117
24251
  var keyOf7 = (mapId, ticketId) => `${mapId}/${ticketId}`;
24118
24252
  var lookoutOnlyTickets = {
@@ -24120,7 +24254,7 @@ var lookoutOnlyTickets = {
24120
24254
  mark(root, o) {
24121
24255
  try {
24122
24256
  const store = machineStore(root);
24123
- mkdirSync26(store.dir, { recursive: true, mode: 448 });
24257
+ mkdirSync27(store.dir, { recursive: true, mode: 448 });
24124
24258
  withFileLock2(store.file(`${FILE10}.lock`), () => {
24125
24259
  const marks = store.read(FILE10) ?? {};
24126
24260
  const was = marks[keyOf7(o.mapId, o.ticketId)];
@@ -24375,15 +24509,15 @@ async function handleFlakyChecks(ctx, req, res, url2) {
24375
24509
  }
24376
24510
 
24377
24511
  // ../core/src/guides/approveCheck.ts
24378
- import { writeFileSync as writeFileSync18 } from "node:fs";
24512
+ import { writeFileSync as writeFileSync19 } from "node:fs";
24379
24513
  import path73 from "node:path";
24380
24514
 
24381
24515
  // ../core/src/verification/rawConfig.ts
24382
24516
  import { readFileSync as readFileSync28 } from "node:fs";
24383
- function readRawConfig(file10, fresh2) {
24517
+ function readRawConfig(file9, fresh2) {
24384
24518
  let text11;
24385
24519
  try {
24386
- text11 = readFileSync28(file10, "utf8");
24520
+ text11 = readFileSync28(file9, "utf8");
24387
24521
  } catch {
24388
24522
  return fresh2;
24389
24523
  }
@@ -24395,7 +24529,7 @@ function readRawConfig(file10, fresh2) {
24395
24529
  }
24396
24530
 
24397
24531
  // ../core/src/guides/approveCheck.ts
24398
- var readRaw2 = (file10) => readRawConfig(file10, { v: 1, default: "off", checks: {} });
24532
+ var readRaw2 = (file9) => readRawConfig(file9, { v: 1, default: "off", checks: {} });
24399
24533
  var specOf = (p) => ({
24400
24534
  run: p.run,
24401
24535
  ...p.timeoutSec ? { timeoutSec: p.timeoutSec } : {},
@@ -24412,8 +24546,8 @@ function approveCheck(input2) {
24412
24546
  const notice = checkNotice(proposed2);
24413
24547
  if (notice && !input2.acknowledged)
24414
24548
  throw new OperationError(`check ${input2.name}: ${notice}; approve it again, acknowledging that`);
24415
- const file10 = path73.join(input2.root, VERIFICATION_FILE);
24416
- const raw = readRaw2(file10);
24549
+ const file9 = path73.join(input2.root, VERIFICATION_FILE);
24550
+ const raw = readRaw2(file9);
24417
24551
  const checks = { ...raw.checks ?? {} };
24418
24552
  const spec = specOf(proposed2);
24419
24553
  const existing = checks[input2.name];
@@ -24429,7 +24563,7 @@ function approveCheck(input2) {
24429
24563
  const { errors } = parseVerificationConfig(text11);
24430
24564
  if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
24431
24565
  const wasApproved = !checksApproval(input2.root).waiting;
24432
- writeFileSync18(file10, text11);
24566
+ writeFileSync19(file9, text11);
24433
24567
  if (wasApproved) approveChecksHere(input2.root, "trail lead", text11);
24434
24568
  lock.guides[input2.id].approvedChecks[input2.name] = checkSha(proposed2);
24435
24569
  writeGuideLock(input2.root, lock, input2.id);
@@ -24452,7 +24586,7 @@ function readChecklist(root, mapId, ticketId) {
24452
24586
  }
24453
24587
 
24454
24588
  // ../core/src/guides/installGuide.ts
24455
- import { mkdirSync as mkdirSync27, readFileSync as readFileSync29, writeFileSync as writeFileSync19 } from "node:fs";
24589
+ import { mkdirSync as mkdirSync28, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
24456
24590
  function lintRefusal(text11) {
24457
24591
  const lint = lintGuide(text11);
24458
24592
  if (lint.ok) return void 0;
@@ -24466,8 +24600,8 @@ function installGuide(input2) {
24466
24600
  const guide = lintGuide(input2.text).guide;
24467
24601
  if (input2.expectId && guide.id !== input2.expectId)
24468
24602
  throw new OperationError(`the file is guide "${guide.id}", not "${input2.expectId}"`);
24469
- mkdirSync27(guidesDir(input2.root), { recursive: true });
24470
- writeFileSync19(guideFilePath(input2.root, guide.id), input2.text);
24603
+ mkdirSync28(guidesDir(input2.root), { recursive: true });
24604
+ writeFileSync20(guideFilePath(input2.root, guide.id), input2.text);
24471
24605
  const lock = readGuideLock(input2.root);
24472
24606
  const prev = lock.guides[guide.id];
24473
24607
  const approvedHere = readApprovedLock(input2.root).guides[guide.id]?.approvedChecks ?? {};
@@ -24512,14 +24646,14 @@ function approveGuide(input2) {
24512
24646
  }
24513
24647
 
24514
24648
  // ../core/src/guides/removeGuide.ts
24515
- import { rmSync as rmSync15 } from "node:fs";
24649
+ import { rmSync as rmSync16 } from "node:fs";
24516
24650
  function removeGuide(input2) {
24517
24651
  const lock = readGuideLock(input2.root);
24518
- const file10 = guideFilePath(input2.root, input2.id);
24652
+ const file9 = guideFilePath(input2.root, input2.id);
24519
24653
  const pinned = input2.id in lock.guides;
24520
24654
  let had = false;
24521
24655
  try {
24522
- rmSync15(file10);
24656
+ rmSync16(file9);
24523
24657
  had = true;
24524
24658
  } catch {
24525
24659
  }
@@ -25094,7 +25228,7 @@ function canonicalJson(value) {
25094
25228
  var gapsHash = (o) => contentHash(canonicalJson({ head: o.head, gaps: o.gaps }));
25095
25229
 
25096
25230
  // ../core/src/proof/mergeAcceptances.ts
25097
- import { mkdirSync as mkdirSync28 } from "node:fs";
25231
+ import { mkdirSync as mkdirSync29 } from "node:fs";
25098
25232
  var FILE11 = "merge-anyway.json";
25099
25233
  var KEPT = 20;
25100
25234
  var keyOf8 = (mapId, ticketId) => `${mapId}/${ticketId}`;
@@ -25111,7 +25245,7 @@ var mergeAcceptances = {
25111
25245
  add(root, a) {
25112
25246
  try {
25113
25247
  const store = machineStore(root);
25114
- mkdirSync28(store.dir, { recursive: true, mode: 448 });
25248
+ mkdirSync29(store.dir, { recursive: true, mode: 448 });
25115
25249
  withFileLock2(store.file(`${FILE11}.lock`), () => {
25116
25250
  const all = store.read(FILE11) ?? {};
25117
25251
  const key = keyOf8(a.mapId, a.ticketId);
@@ -25469,9 +25603,9 @@ async function handleMergeAnyway(ctx, req, res, url2) {
25469
25603
  import { existsSync as existsSync26, readFileSync as readFileSync30 } from "node:fs";
25470
25604
  import path76 from "node:path";
25471
25605
  function readModelsConfig(root) {
25472
- const file10 = path76.join(root, MODELS_FILE);
25473
- if (!existsSync26(file10)) return { models: {}, errors: [], exists: false };
25474
- const parsed3 = parseModelsConfig(readFileSync30(file10, "utf8"));
25606
+ const file9 = path76.join(root, MODELS_FILE);
25607
+ if (!existsSync26(file9)) return { models: {}, errors: [], exists: false };
25608
+ const parsed3 = parseModelsConfig(readFileSync30(file9, "utf8"));
25475
25609
  return { models: parsed3.models ?? {}, errors: parsed3.errors, exists: true };
25476
25610
  }
25477
25611
 
@@ -25539,14 +25673,14 @@ function proofPostSetting(root, dir4) {
25539
25673
 
25540
25674
  // ../core/src/proof/proofPostStore.ts
25541
25675
  import path77 from "node:path";
25542
- var file6 = (root, mapId, ticketId) => path77.join(root, evidencePaths.ticket(mapId, ticketId), "proof-post.json");
25676
+ var file5 = (root, mapId, ticketId) => path77.join(root, evidencePaths.ticket(mapId, ticketId), "proof-post.json");
25543
25677
  function readProofPost(root, mapId, ticketId) {
25544
- const r = readJsonFile(file6(root, mapId, ticketId));
25678
+ const r = readJsonFile(file5(root, mapId, ticketId));
25545
25679
  return r?.v === 1 ? r : void 0;
25546
25680
  }
25547
25681
  function writeProofPost(root, r) {
25548
25682
  ensureLocalDir(path77.join(root, EVIDENCE_DIR));
25549
- writeJsonAtomic(file6(root, r.mapId, r.ticketId), r);
25683
+ writeJsonAtomic(file5(root, r.mapId, r.ticketId), r);
25550
25684
  }
25551
25685
 
25552
25686
  // ../core/src/proof/proofStatus.ts
@@ -25762,18 +25896,18 @@ function proofMarkdown(p, signature4) {
25762
25896
  }
25763
25897
 
25764
25898
  // ../core/src/proof/repoProofKey.ts
25765
- import { existsSync as existsSync27, mkdirSync as mkdirSync29, writeFileSync as writeFileSync20 } from "node:fs";
25899
+ import { existsSync as existsSync27, mkdirSync as mkdirSync30, writeFileSync as writeFileSync21 } from "node:fs";
25766
25900
  import path80 from "node:path";
25767
25901
 
25768
25902
  // ../core/src/machine/proofKey.ts
25769
25903
  import { createHash as createHash9, createPrivateKey, generateKeyPairSync, randomBytes as randomBytes6 } from "node:crypto";
25770
- import { linkSync as linkSync4, readFileSync as readFileSync31, rmSync as rmSync16 } from "node:fs";
25904
+ import { linkSync as linkSync5, readFileSync as readFileSync31, rmSync as rmSync17 } from "node:fs";
25771
25905
  import path79 from "node:path";
25772
25906
  var PROOF_KEY_FILE = "proof-key.json";
25773
25907
  var proofKeyId = (publicKeyB64) => createHash9("sha256").update(Buffer.from(publicKeyB64, "base64")).digest("hex").slice(0, 16);
25774
- function read(file10) {
25908
+ function read(file9) {
25775
25909
  try {
25776
- const s = JSON.parse(readFileSync31(file10, "utf8"));
25910
+ const s = JSON.parse(readFileSync31(file9, "utf8"));
25777
25911
  return s?.v === 1 && s.id === proofKeyId(s.publicKey) ? s : void 0;
25778
25912
  } catch (e) {
25779
25913
  if (e.code === "ENOENT" || e instanceof SyntaxError) return void 0;
@@ -25791,21 +25925,21 @@ function fresh() {
25791
25925
  };
25792
25926
  }
25793
25927
  function machineProofKey(dir4 = configDir()) {
25794
- const file10 = path79.join(dir4, PROOF_KEY_FILE);
25795
- let s = read(file10);
25928
+ const file9 = path79.join(dir4, PROOF_KEY_FILE);
25929
+ let s = read(file9);
25796
25930
  if (!s) {
25797
- const draft = `${file10}.${process.pid}.${randomBytes6(4).toString("hex")}`;
25931
+ const draft = `${file9}.${process.pid}.${randomBytes6(4).toString("hex")}`;
25798
25932
  writePrivateFile(draft, `${JSON.stringify(fresh())}
25799
25933
  `);
25800
25934
  try {
25801
- linkSync4(draft, file10);
25935
+ linkSync5(draft, file9);
25802
25936
  } catch (e) {
25803
25937
  if (e.code !== "EEXIST") throw e;
25804
25938
  } finally {
25805
- rmSync16(draft, { force: true });
25939
+ rmSync17(draft, { force: true });
25806
25940
  }
25807
- s = read(file10);
25808
- if (!s) throw new Error(`${file10} is not a proof key: move it away and Teamtrail makes a new one`);
25941
+ s = read(file9);
25942
+ if (!s) throw new Error(`${file9} is not a proof key: move it away and Teamtrail makes a new one`);
25809
25943
  }
25810
25944
  return { id: s.id, publicKey: s.publicKey, privateKey: createPrivateKey(s.privateKey) };
25811
25945
  }
@@ -25822,11 +25956,11 @@ function ensureRepoProofKey(root, dir4) {
25822
25956
  return void 0;
25823
25957
  }
25824
25958
  const rel = path80.join(PROOF_KEYS_DIR, `${key.id}.pub`);
25825
- const file10 = path80.join(root, rel);
25826
- if (!existsSync27(file10)) {
25827
- mkdirSync29(path80.dirname(file10), { recursive: true });
25959
+ const file9 = path80.join(root, rel);
25960
+ if (!existsSync27(file9)) {
25961
+ mkdirSync30(path80.dirname(file9), { recursive: true });
25828
25962
  try {
25829
- writeFileSync20(file10, proofKeyLine(key.publicKey), { flag: "wx" });
25963
+ writeFileSync21(file9, proofKeyLine(key.publicKey), { flag: "wx" });
25830
25964
  } catch (e) {
25831
25965
  if (e.code !== "EEXIST") throw e;
25832
25966
  }
@@ -26050,7 +26184,7 @@ function redactResponse(res, places = []) {
26050
26184
  }
26051
26185
 
26052
26186
  // ../core/src/remoteAgents/mcpEndpoints.ts
26053
- import { readdirSync as readdirSync20, rmSync as rmSync17 } from "node:fs";
26187
+ import { readdirSync as readdirSync20, rmSync as rmSync18 } from "node:fs";
26054
26188
  import os3 from "node:os";
26055
26189
  import path81 from "node:path";
26056
26190
 
@@ -26090,17 +26224,17 @@ function ownEndpointUrl(raw, addresses) {
26090
26224
  }
26091
26225
 
26092
26226
  // ../core/src/remoteAgents/mcpEndpoints.ts
26093
- var DIR = `${AGENTS_DIR}/mcp-endpoints`;
26227
+ var DIR2 = `${AGENTS_DIR}/mcp-endpoints`;
26094
26228
  var ENDPOINT_SIG = "mcp-endpoint";
26095
26229
  var fieldsOf = (e) => [e.url, e.pid, e.kind, e.network === true, e.startedAt];
26096
26230
  function writeMcpEndpoint(root, e) {
26097
- const file10 = path81.join(root, DIR, `${process.pid}.json`);
26231
+ const file9 = path81.join(root, DIR2, `${process.pid}.json`);
26098
26232
  ensureLocalDir(path81.join(root, AGENTS_DIR));
26099
26233
  const base2 = { url: e.url, kind: e.kind, network: e.network, pid: process.pid, startedAt: Date.now() };
26100
26234
  const sig = announcementSig(root, ENDPOINT_SIG, fieldsOf(base2));
26101
26235
  const endpoint = { ...base2, ...sig ? { sig } : {} };
26102
- writeJsonAtomic(file10, endpoint);
26103
- return () => rmSync17(file10, { force: true });
26236
+ writeJsonAtomic(file9, endpoint);
26237
+ return () => rmSync18(file9, { force: true });
26104
26238
  }
26105
26239
  var ownAddresses = () => Object.values(os3.networkInterfaces()).flatMap((list8) => list8 ?? []).map((a) => a.address.toLowerCase());
26106
26240
  function believed(root, at2, e) {
@@ -26115,12 +26249,12 @@ function believed(root, at2, e) {
26115
26249
  function readMcpEndpoints(root) {
26116
26250
  let names = [];
26117
26251
  try {
26118
- names = readdirSync20(path81.join(root, DIR)).filter((n) => n.endsWith(".json"));
26252
+ names = readdirSync20(path81.join(root, DIR2)).filter((n) => n.endsWith(".json"));
26119
26253
  } catch {
26120
26254
  return [];
26121
26255
  }
26122
26256
  const addresses = ownAddresses();
26123
- return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path81.join(root, DIR, n)))).filter((e) => !!e).sort((a, b) => Number(b.kind === "standalone") - Number(a.kind === "standalone") || a.startedAt - b.startedAt);
26257
+ return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path81.join(root, DIR2, n)))).filter((e) => !!e).sort((a, b) => Number(b.kind === "standalone") - Number(a.kind === "standalone") || a.startedAt - b.startedAt);
26124
26258
  }
26125
26259
 
26126
26260
  // ../core/src/remoteAgents/remoteTokens.ts
@@ -26388,11 +26522,11 @@ function write(root, p, by) {
26388
26522
  }
26389
26523
  var keepApprovedReroute = write;
26390
26524
  var keepRerouteProgress = write;
26391
- function approvedReroute(root, file10) {
26392
- const kept = read2(root, file10);
26525
+ function approvedReroute(root, file9) {
26526
+ const kept = read2(root, file9);
26393
26527
  if (!kept) return void 0;
26394
26528
  const changes2 = kept.core.changes;
26395
- return { ...file10, ...kept.core, changes: changes2, applied: kept.applied, created: kept.created ?? {} };
26529
+ return { ...file9, ...kept.core, changes: changes2, applied: kept.applied, created: kept.created ?? {} };
26396
26530
  }
26397
26531
 
26398
26532
  // ../core/src/discovery/skipDiscoveryHere.ts
@@ -26734,10 +26868,10 @@ var ALL = { recentMs: Number.MAX_SAFE_INTEGER, limit: Number.MAX_SAFE_INTEGER };
26734
26868
  var guidesOf2 = (guides) => guides ? { guides: guides.map((g) => g.id) } : {};
26735
26869
  var passed6 = (c) => c.exitCode === 0 && !c.timedOut && !c.error;
26736
26870
  function escapeFields(attempts, escape3) {
26737
- const verified = attempts.find((a) => a.id === escape3?.attemptId) ?? [...attempts].reverse().find((a) => a.result === "pass");
26871
+ const verified2 = attempts.find((a) => a.id === escape3?.attemptId) ?? [...attempts].reverse().find((a) => a.result === "pass");
26738
26872
  return {
26739
26873
  ...escape3 ? { escaped: true } : {},
26740
- ...verified ? { passedChecks: verified.checks.filter(passed6).map((c) => c.name) } : {}
26874
+ ...verified2 ? { passedChecks: verified2.checks.filter(passed6).map((c) => c.name) } : {}
26741
26875
  };
26742
26876
  }
26743
26877
  function ticketOf2(input2) {
@@ -27433,14 +27567,14 @@ async function handleLinearTeams(req, res, o) {
27433
27567
  }
27434
27568
 
27435
27569
  // ../core/src/adapters/remote/acceptedSettingsFile.ts
27436
- import { existsSync as existsSync28, mkdirSync as mkdirSync30, rmSync as rmSync18 } from "node:fs";
27570
+ import { existsSync as existsSync28, mkdirSync as mkdirSync31, rmSync as rmSync19 } from "node:fs";
27437
27571
  import { open, rename, rm, stat as stat2 } from "node:fs/promises";
27438
27572
  import path83 from "node:path";
27439
27573
  var ACCEPTED_DIR = "tracker-settings";
27440
27574
  var acceptedSettingsPath = (root, target2) => path83.join(machineStore(root).dir, ACCEPTED_DIR, `${target2}.json`);
27441
27575
  var LOCK_STALE_MS = 5e3;
27442
27576
  var BACKOFF_MS = [0, 5, 10, 20, 40, 80, 160, 320, 400];
27443
- var macParts = (root, target2, issues) => [
27577
+ var macParts2 = (root, target2, issues) => [
27444
27578
  "tracker-settings",
27445
27579
  machineId(root),
27446
27580
  target2,
@@ -27448,14 +27582,14 @@ var macParts = (root, target2, issues) => [
27448
27582
  ];
27449
27583
  function signed2(root, target2, issues, mac4) {
27450
27584
  try {
27451
- return machineSigned(macParts(root, target2, issues), mac4);
27585
+ return machineSigned(macParts2(root, target2, issues), mac4);
27452
27586
  } catch {
27453
27587
  return false;
27454
27588
  }
27455
27589
  }
27456
27590
  var isEntry2 = (e) => !!e && typeof e === "object" && !Array.isArray(e);
27457
- function readDoc(root, file10, target2) {
27458
- const raw = readJsonFile(file10);
27591
+ function readDoc(root, file9, target2) {
27592
+ const raw = readJsonFile(file9);
27459
27593
  if (raw?.v !== 1 || raw.target !== target2 || !raw.issues || typeof raw.issues !== "object") return {};
27460
27594
  if (!signed2(root, target2, raw.issues, raw.mac)) return {};
27461
27595
  return Object.fromEntries(Object.entries(raw.issues).filter(([, e]) => isEntry2(e)));
@@ -27474,8 +27608,8 @@ async function clearStale2(lock) {
27474
27608
  );
27475
27609
  if (moved) await rm(aside2, { force: true });
27476
27610
  }
27477
- async function withLock(file10, fn) {
27478
- const lock = `${file10}.lock`;
27611
+ async function withLock(file9, fn) {
27612
+ const lock = `${file9}.lock`;
27479
27613
  for (const wait of BACKOFF_MS) {
27480
27614
  if (wait) await sleep(wait);
27481
27615
  if (await tryLock(lock)) {
@@ -27497,35 +27631,35 @@ function migrate(root, target2) {
27497
27631
  if (legacy === target2 || !existsSync28(from) || existsSync28(to)) return;
27498
27632
  const issues = readDoc(root, from, legacy);
27499
27633
  try {
27500
- const mac4 = machineSign(macParts(root, target2, issues));
27634
+ const mac4 = machineSign(macParts2(root, target2, issues));
27501
27635
  writePrivateFile(to, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
27502
27636
  `);
27503
- rmSync18(from, { force: true });
27637
+ rmSync19(from, { force: true });
27504
27638
  } catch {
27505
27639
  }
27506
27640
  }
27507
27641
  function acceptedSettingsFile(root, target2) {
27508
27642
  migrate(root, target2);
27509
- const file10 = acceptedSettingsPath(root, target2);
27643
+ const file9 = acceptedSettingsPath(root, target2);
27510
27644
  return {
27511
- read: () => readDoc(root, file10, target2),
27645
+ read: () => readDoc(root, file9, target2),
27512
27646
  async update(change3) {
27513
27647
  try {
27514
- mkdirSync30(path83.dirname(file10), { recursive: true, mode: 448 });
27648
+ mkdirSync31(path83.dirname(file9), { recursive: true, mode: 448 });
27515
27649
  } catch {
27516
27650
  return false;
27517
27651
  }
27518
- const done2 = await withLock(file10, () => {
27519
- const issues = readDoc(root, file10, target2);
27652
+ const done2 = await withLock(file9, () => {
27653
+ const issues = readDoc(root, file9, target2);
27520
27654
  for (const [id, e] of Object.entries(change3(issues))) {
27521
27655
  if (e) issues[id] = e;
27522
27656
  else delete issues[id];
27523
27657
  }
27524
- const mac4 = machineSign(macParts(root, target2, issues));
27525
- writePrivateFile(file10, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
27658
+ const mac4 = machineSign(macParts2(root, target2, issues));
27659
+ writePrivateFile(file9, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
27526
27660
  `);
27527
27661
  });
27528
- if (!done2) console.warn(`teamtrail: ${path83.basename(file10)} is locked; settings not recorded this time`);
27662
+ if (!done2) console.warn(`teamtrail: ${path83.basename(file9)} is locked; settings not recorded this time`);
27529
27663
  return done2;
27530
27664
  }
27531
27665
  };
@@ -28577,10 +28711,10 @@ async function nearest(i, names) {
28577
28711
  }
28578
28712
  return void 0;
28579
28713
  }
28580
- async function screenModule(i, file10) {
28581
- if (await nearest(i, [file10])) return [];
28714
+ async function screenModule(i, file9) {
28715
+ if (await nearest(i, [file9])) return [];
28582
28716
  const where2 = i.cwd ? ` in \`${i.cwd}\` or above it` : "";
28583
- return [{ severity: "wont-run", text: `No ${file10}${where2}` }];
28717
+ return [{ severity: "wont-run", text: `No ${file9}${where2}` }];
28584
28718
  }
28585
28719
  async function screenPytest(i) {
28586
28720
  if (await nearest(i, PYTEST_FILES)) return [];
@@ -28596,15 +28730,15 @@ function scriptOf(args) {
28596
28730
  }
28597
28731
  return {};
28598
28732
  }
28599
- async function screenFile(i, file10) {
28600
- const rel = repoPath2(i.cwd, file10);
28733
+ async function screenFile(i, file9) {
28734
+ const rel = repoPath2(i.cwd, file9);
28601
28735
  if (rel === void 0 || await i.files.kind(rel)) return [];
28602
28736
  return [{ severity: "wont-run", text: `No \`${rel}\`` }];
28603
28737
  }
28604
28738
  async function screenInterpreter(i) {
28605
- const { module, file: file10 } = scriptOf(i.args);
28739
+ const { module, file: file9 } = scriptOf(i.args);
28606
28740
  if (module === "pytest") return screenPytest(i);
28607
- if (file10) return screenFile(i, file10);
28741
+ if (file9) return screenFile(i, file9);
28608
28742
  return [];
28609
28743
  }
28610
28744
  var INTERPRETERS2 = /* @__PURE__ */ new Set(["node", "bash", "sh", "zsh", "python", "python3", "ruby", "tsx"]);
@@ -28998,19 +29132,19 @@ function ticketEvidence(root, mapId, ticketId) {
28998
29132
  }
28999
29133
  function readEvidenceLog(root, rel) {
29000
29134
  if (!rel.endsWith(".log")) return void 0;
29001
- let file10;
29135
+ let file9;
29002
29136
  let base2;
29003
29137
  try {
29004
29138
  base2 = realpathSync14(path86.join(root, EVIDENCE_DIR));
29005
- file10 = realpathSync14(path86.join(root, rel));
29139
+ file9 = realpathSync14(path86.join(root, rel));
29006
29140
  } catch {
29007
29141
  return void 0;
29008
29142
  }
29009
- if (!file10.startsWith(base2 + path86.sep)) return void 0;
29010
- const size3 = statSync9(file10).size;
29143
+ if (!file9.startsWith(base2 + path86.sep)) return void 0;
29144
+ const size3 = statSync9(file9).size;
29011
29145
  const len = Math.min(size3, LOG_VIEW_BYTES);
29012
29146
  const buf = Buffer.alloc(len);
29013
- const fd = openSync3(file10, "r");
29147
+ const fd = openSync3(file9, "r");
29014
29148
  try {
29015
29149
  readSync(fd, buf, 0, len, size3 - len);
29016
29150
  } finally {
@@ -29023,17 +29157,17 @@ function readEvidenceLog(root, rel) {
29023
29157
  import path88 from "node:path";
29024
29158
 
29025
29159
  // ../core/src/verification/writeApprovedConfig.ts
29026
- import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as writeFileSync21 } from "node:fs";
29160
+ import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as writeFileSync22 } from "node:fs";
29027
29161
  import path87 from "node:path";
29028
29162
  function writeApprovedConfig(o) {
29029
29163
  const { errors } = parseVerificationConfig(o.text);
29030
29164
  if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
29031
- const file10 = path87.join(o.root, VERIFICATION_FILE);
29032
- if (lstatSync6(file10, { throwIfNoEntry: false })?.isSymbolicLink())
29165
+ const file9 = path87.join(o.root, VERIFICATION_FILE);
29166
+ if (lstatSync6(file9, { throwIfNoEntry: false })?.isSymbolicLink())
29033
29167
  throw new OperationError(`${VERIFICATION_FILE} is a link; replace it by hand`);
29034
- const tmp = `${file10}.${process.pid}.tmp`;
29035
- writeFileSync21(tmp, o.text, { flag: "wx" });
29036
- renameSync10(tmp, file10);
29168
+ const tmp = `${file9}.${process.pid}.tmp`;
29169
+ writeFileSync22(tmp, o.text, { flag: "wx" });
29170
+ renameSync10(tmp, file9);
29037
29171
  const approval = approveChecksHere(o.root, o.by, o.text);
29038
29172
  journalFile(o.root).append({
29039
29173
  v: 1,
@@ -29076,8 +29210,8 @@ function setChecks(o) {
29076
29210
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29077
29211
  const problem = problemOf(o.checks, o.acknowledged === true);
29078
29212
  if (problem) throw new OperationError(problem);
29079
- const file10 = path88.join(o.root, VERIFICATION_FILE);
29080
- const raw = readRawConfig(file10, { v: 1, default: "checks" });
29213
+ const file9 = path88.join(o.root, VERIFICATION_FILE);
29214
+ const raw = readRawConfig(file9, { v: 1, default: "checks" });
29081
29215
  const kept = raw.checks ?? {};
29082
29216
  const checks = Object.fromEntries(o.checks.map((c) => [c.name, { ...kept[c.name] ?? {}, run: c.run }]));
29083
29217
  const text11 = `${JSON.stringify({ ...raw, v: 1, checks, run: o.checks.map((c) => c.name) }, null, 2)}
@@ -29153,11 +29287,11 @@ function setGateMode(o) {
29153
29287
  const mode = o.mode;
29154
29288
  const now2 = checksApproval(o.root);
29155
29289
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29156
- const file10 = path89.join(o.root, VERIFICATION_FILE);
29157
- if (!existsSync29(file10)) throw new OperationError("Set the checks first: without them nothing is verified");
29290
+ const file9 = path89.join(o.root, VERIFICATION_FILE);
29291
+ if (!existsSync29(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29158
29292
  if (now2.waiting)
29159
29293
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29160
- const raw = readRawConfig(file10, { v: 1 });
29294
+ const raw = readRawConfig(file9, { v: 1 });
29161
29295
  const gates = { ...isObject3(raw.gates) ? raw.gates : {}, [gate]: mode };
29162
29296
  const text11 = `${JSON.stringify({ ...raw, gates }, null, 2)}
29163
29297
  `;
@@ -29201,11 +29335,11 @@ function setScope(o) {
29201
29335
  const scope = o.scope;
29202
29336
  const now2 = checksApproval(o.root);
29203
29337
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29204
- const file10 = path90.join(o.root, VERIFICATION_FILE);
29205
- if (!existsSync30(file10)) throw new OperationError("Set the checks first: without them nothing is verified");
29338
+ const file9 = path90.join(o.root, VERIFICATION_FILE);
29339
+ if (!existsSync30(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29206
29340
  if (now2.waiting)
29207
29341
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29208
- const raw = readRawConfig(file10, { v: 1 });
29342
+ const raw = readRawConfig(file9, { v: 1 });
29209
29343
  const text11 = `${JSON.stringify({ ...raw, scope }, null, 2)}
29210
29344
  `;
29211
29345
  return writeApprovedConfig({
@@ -29301,20 +29435,20 @@ async function handleVerification({ root, active, local, repoFiles }, req, res,
29301
29435
  }
29302
29436
 
29303
29437
  // ../core/src/verification/heldRulesStore.ts
29304
- import { rmSync as rmSync19 } from "node:fs";
29438
+ import { rmSync as rmSync20 } from "node:fs";
29305
29439
  import path91 from "node:path";
29306
- var file7 = (root, mapId, ticketId) => path91.join(root, evidencePaths.ticket(mapId, ticketId), "rules-held.json");
29440
+ var file6 = (root, mapId, ticketId) => path91.join(root, evidencePaths.ticket(mapId, ticketId), "rules-held.json");
29307
29441
  var heldRulesStore = {
29308
29442
  read(root, mapId, ticketId) {
29309
- const r = readJsonFile(file7(root, mapId, ticketId));
29443
+ const r = readJsonFile(file6(root, mapId, ticketId));
29310
29444
  return r?.v === 1 && Array.isArray(r.rules) ? r : void 0;
29311
29445
  },
29312
29446
  write(root, mapId, ticketId, held) {
29313
29447
  ensureLocalDir(path91.join(root, EVIDENCE_DIR));
29314
- writeJsonAtomic(file7(root, mapId, ticketId), held);
29448
+ writeJsonAtomic(file6(root, mapId, ticketId), held);
29315
29449
  },
29316
29450
  clear(root, mapId, ticketId) {
29317
- rmSync19(file7(root, mapId, ticketId), { force: true });
29451
+ rmSync20(file6(root, mapId, ticketId), { force: true });
29318
29452
  }
29319
29453
  };
29320
29454
 
@@ -29366,11 +29500,11 @@ function setRules(o) {
29366
29500
  const rules2 = shapeRules(o.rules);
29367
29501
  const now2 = checksApproval(o.root);
29368
29502
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29369
- const file10 = path93.join(o.root, VERIFICATION_FILE);
29370
- if (!existsSync31(file10)) throw new OperationError("Set the checks first: without them nothing is verified");
29503
+ const file9 = path93.join(o.root, VERIFICATION_FILE);
29504
+ if (!existsSync31(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29371
29505
  if (now2.waiting)
29372
29506
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29373
- const { rules: _old, ...raw } = readRawConfig(file10, { v: 1 });
29507
+ const { rules: _old, ...raw } = readRawConfig(file9, { v: 1 });
29374
29508
  const written = `${JSON.stringify(rules2.length ? { ...raw, rules: rules2 } : raw, null, 2)}
29375
29509
  `;
29376
29510
  return writeApprovedConfig({
@@ -29381,15 +29515,46 @@ function setRules(o) {
29381
29515
  });
29382
29516
  }
29383
29517
 
29384
- // ../core/src/verification/waiveRule.ts
29385
- var TRAIL_LEAD4 = "trail lead";
29386
- var MAX_REASON2 = 500;
29387
- async function assertMay(root, r, key) {
29388
- if (r.via === "slack" || r.via === "chat") throw new OperationError(`Waiving a rule for ${key} is for the Lookout.`);
29518
+ // ../core/src/verification/assertMayWaiveRule.ts
29519
+ async function assertMayWaiveRule(root, r) {
29520
+ if (r.via === "slack" || r.via === "chat") throw new OperationError(`${r.doing} for ${r.key} is for the Lookout.`);
29389
29521
  if (!await ticketNeedsLookout(root, r.mapId, r.ticketId)) return;
29390
- if (r.via !== "lookout") throw new OperationError(highRiskRefusal(key, r.via));
29391
- if (!r.local) throw new OperationError(`${key} is high risk: waive its rules in the Lookout on its machine.`);
29522
+ if (r.via !== "lookout") throw new OperationError(highRiskRefusal(r.key, r.via));
29523
+ if (!r.local) throw new OperationError(`${r.key} is high risk: change its rules in the Lookout on its machine.`);
29392
29524
  }
29525
+
29526
+ // ../core/src/verification/undoRuleWaiver.ts
29527
+ var TRAIL_LEAD4 = "trail lead";
29528
+ async function undoRuleWaiver(env, r) {
29529
+ const snap = await env.adapter.loadMap(r.mapId);
29530
+ const t = snap.tickets.find((x) => x.id === r.ticketId);
29531
+ if (!t) throw new OperationError(`ticket ${r.ticketId} not found`);
29532
+ await assertMayWaiveRule(env.root, { ...r, key: t.key, doing: `Undoing Go without ${r.rule}` });
29533
+ const gone = ruleWaivers.remove(env.root, { mapId: r.mapId, ticketId: t.id, rule: r.rule });
29534
+ if (!gone) throw new OperationError(`${t.key} isn't going without ${r.rule}.`);
29535
+ const by = r.person ?? TRAIL_LEAD4;
29536
+ journalFile(env.root).append({
29537
+ v: 1,
29538
+ kind: "rule-waiver",
29539
+ at: Date.now(),
29540
+ mapId: r.mapId,
29541
+ ticketId: t.id,
29542
+ ticketKey: t.key,
29543
+ rule: gone.rule,
29544
+ action: "undone",
29545
+ reason: gone.reason,
29546
+ actor: by,
29547
+ actorKind: "trail lead"
29548
+ });
29549
+ await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD4, `**${gone.rule} asks again**
29550
+
29551
+ ${by} undid going without it.`);
29552
+ return { rule: gone.rule, waived: false };
29553
+ }
29554
+
29555
+ // ../core/src/verification/waiveRule.ts
29556
+ var TRAIL_LEAD5 = "trail lead";
29557
+ var MAX_REASON2 = 500;
29393
29558
  async function waiveRule(env, r) {
29394
29559
  const reason = oneLine(r.reason).slice(0, MAX_REASON2);
29395
29560
  if (!reason) throw new OperationError("Say why it can go without the answer.");
@@ -29398,7 +29563,7 @@ async function waiveRule(env, r) {
29398
29563
  if (!t) throw new OperationError(`ticket ${r.ticketId} not found`);
29399
29564
  const rule = trustedChecks(env.root).config.config?.rules.find((x) => x.id === r.rule);
29400
29565
  if (!rule?.ask) throw new OperationError(`${r.rule} is not an approved rule that asks a question.`);
29401
- await assertMay(env.root, r, t.key);
29566
+ await assertMayWaiveRule(env.root, { ...r, key: t.key, doing: "Waiving a rule" });
29402
29567
  const w = {
29403
29568
  v: 1,
29404
29569
  mapId: r.mapId,
@@ -29406,7 +29571,7 @@ async function waiveRule(env, r) {
29406
29571
  ticketKey: t.key,
29407
29572
  rule: rule.id,
29408
29573
  reason,
29409
- by: r.person ?? TRAIL_LEAD4,
29574
+ by: r.person ?? TRAIL_LEAD5,
29410
29575
  via: r.via,
29411
29576
  at: Date.now()
29412
29577
  };
@@ -29419,6 +29584,7 @@ async function waiveRule(env, r) {
29419
29584
  ticketId: w.ticketId,
29420
29585
  ticketKey: w.ticketKey,
29421
29586
  rule: w.rule,
29587
+ action: "waived",
29422
29588
  reason,
29423
29589
  actor: w.by,
29424
29590
  actorKind: "trail lead"
@@ -29427,7 +29593,7 @@ async function waiveRule(env, r) {
29427
29593
  const left = held?.rules.filter((x) => x.id !== rule.id) ?? [];
29428
29594
  if (held && left.length) heldRulesStore.write(env.root, r.mapId, t.id, { ...held, rules: left });
29429
29595
  else heldRulesStore.clear(env.root, r.mapId, t.id);
29430
- await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD4, `**Went without ${rule.id}**
29596
+ await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD5, `**Went without ${rule.id}**
29431
29597
 
29432
29598
  ${reason}
29433
29599
 
@@ -29450,7 +29616,7 @@ async function putRules(o, req, res) {
29450
29616
  sendJson(res, e instanceof StaleChecks ? 409 : 400, { error: e.message });
29451
29617
  }
29452
29618
  }
29453
- async function waive(o, req, res) {
29619
+ async function waive(o, req, res, undo) {
29454
29620
  const b = await readJson2(req, "{}");
29455
29621
  const [mapId, ticketId, rule] = [str12(b.mapId), str12(b.ticketId), str12(b.rule, 20)];
29456
29622
  const reason = typeof b.reason === "string" ? b.reason : "";
@@ -29458,7 +29624,8 @@ async function waive(o, req, res) {
29458
29624
  const who = { person: personOfRequest(req)?.name, via: lookoutVia(req), local: o.local !== false };
29459
29625
  try {
29460
29626
  const env = { adapter: await o.active(), root: o.root };
29461
- sendJson(res, 200, await waiveRule(env, { mapId, ticketId, rule, reason, ...who }));
29627
+ const ids2 = { mapId, ticketId, rule, ...who };
29628
+ sendJson(res, 200, undo ? await undoRuleWaiver(env, ids2) : await waiveRule(env, { ...ids2, reason }));
29462
29629
  } catch (e) {
29463
29630
  if (!(e instanceof OperationError)) throw e;
29464
29631
  sendJson(res, 409, { error: e.message });
@@ -29472,13 +29639,14 @@ async function handleRules(o, req, res, url2) {
29472
29639
  if (p === "/verification/rules/held" && req.method === "GET") {
29473
29640
  if (!q("mapId") || !q("ticketId")) throw new BadRequest('"mapId" and "ticketId" are required');
29474
29641
  const held = heldRulesStore.read(o.root, q("mapId"), q("ticketId"));
29475
- const waived = ruleWaivers.list(o.root, q("mapId"), q("ticketId")).map((w) => ({ rule: w.rule, by: w.by, at: w.at }));
29642
+ const waived = ruleWaivers.list(o.root, q("mapId"), q("ticketId")).map((w) => ({ rule: w.rule, by: w.by, at: w.at, reason: w.reason }));
29476
29643
  return sendJson(res, 200, { ...held ? { held } : {}, waived }), true;
29477
29644
  }
29478
- const write2 = p === "/verification/rules" && req.method === "PUT" || p === "/verification/rules/waive" && req.method === "POST";
29645
+ const waiving = req.method === "POST" && (p === "/verification/rules/waive" || p === "/verification/rules/waive/undo");
29646
+ const write2 = p === "/verification/rules" && req.method === "PUT" || waiving;
29479
29647
  if (!write2) return false;
29480
29648
  if (crossSite(req)) return sendJson(res, 403, { error: "cross-site request refused" }), true;
29481
- await (req.method === "PUT" ? putRules(o, req, res) : waive(o, req, res));
29649
+ await (waiving ? waive(o, req, res, p.endsWith("/undo")) : putRules(o, req, res));
29482
29650
  return true;
29483
29651
  }
29484
29652
 
@@ -29709,7 +29877,7 @@ function linked(i) {
29709
29877
  }
29710
29878
 
29711
29879
  // ../core/src/verification/undoWaiver.ts
29712
- var TRAIL_LEAD5 = "trail lead";
29880
+ var TRAIL_LEAD6 = "trail lead";
29713
29881
  async function undoWaiver(env, r) {
29714
29882
  if (r.via === "slack" || r.via === "chat") throw new OperationError("Undo it in the Lookout.");
29715
29883
  const snap = await env.adapter.loadMap(r.mapId);
@@ -29718,14 +29886,14 @@ async function undoWaiver(env, r) {
29718
29886
  if (!activeWaivers(env.root, r.mapId, t.id).length) throw new OperationError(`${t.key} has no waived check to undo.`);
29719
29887
  if (r.via !== "lookout" && await ticketNeedsLookout(env.root, r.mapId, t.id))
29720
29888
  throw new OperationError(highRiskRefusal(t.key, r.via));
29721
- const by = r.person ?? TRAIL_LEAD5;
29889
+ const by = r.person ?? TRAIL_LEAD6;
29722
29890
  const undone = checkWaivers.undo(env.root, { mapId: r.mapId, ticketId: t.id, by });
29723
29891
  const names = [...new Set(undone.flatMap((w) => w.checks.map((c) => c.name)))].join(", ");
29724
29892
  for (const w of undone) {
29725
29893
  journal5(env.root, { w, t, by });
29726
29894
  await supersede2(env, { w, t, r, names });
29727
29895
  }
29728
- await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD5, `**${names} runs again**
29896
+ await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD6, `**${names} runs again**
29729
29897
 
29730
29898
  ${by} undid accepting it without.`);
29731
29899
  if (t.state === "closed" && t.closeReason === "completed")
@@ -29763,7 +29931,7 @@ async function supersede2(env, o) {
29763
29931
  ticketKey: t.key,
29764
29932
  answer: `Run ${o.names} again.`,
29765
29933
  summary: `${t.key} runs ${o.names} again`,
29766
- decidedBy: TRAIL_LEAD5,
29934
+ decidedBy: TRAIL_LEAD6,
29767
29935
  ...r.person ? { decidedByName: r.person } : {},
29768
29936
  source: { kind: "lookout", label: "Undid accepting without a check" },
29769
29937
  transcript: [],
@@ -29787,7 +29955,7 @@ async function assertMayWaive(root, o) {
29787
29955
 
29788
29956
  // ../core/src/verification/waiveChecks.ts
29789
29957
  var HELD = ["rework", "blocked", "working"];
29790
- var TRAIL_LEAD6 = "trail lead";
29958
+ var TRAIL_LEAD7 = "trail lead";
29791
29959
  async function waiveChecks(env, r) {
29792
29960
  const reason = r.reason.trim();
29793
29961
  if (!reason) throw new OperationError("Say why it can go without them.");
@@ -29828,7 +29996,7 @@ async function keep2(env, o) {
29828
29996
  attemptId: r.attemptId,
29829
29997
  checks,
29830
29998
  reason: r.reason,
29831
- by: r.person ?? TRAIL_LEAD6,
29999
+ by: r.person ?? TRAIL_LEAD7,
29832
30000
  via: r.via,
29833
30001
  at: Date.now()
29834
30002
  };
@@ -29844,7 +30012,7 @@ async function keep2(env, o) {
29844
30012
  answer: r.reason,
29845
30013
  summary: `Accepted ${t.key} without ${list8}: ${firstSentence(r.reason)}`,
29846
30014
  rationale: r.reason,
29847
- decidedBy: TRAIL_LEAD6,
30015
+ decidedBy: TRAIL_LEAD7,
29848
30016
  ...r.person ? { decidedByName: r.person } : {},
29849
30017
  source: { kind: "lookout", ref: `waiver:${w.id}`, label: "Accepted without a check" },
29850
30018
  transcript: []
@@ -29866,7 +30034,7 @@ async function keep2(env, o) {
29866
30034
  actorKind: "trail lead",
29867
30035
  reason: r.reason
29868
30036
  });
29869
- await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD6, `**Accepted without ${list8}**
30037
+ await env.adapter.comment(r.mapId, t.id, TRAIL_LEAD7, `**Accepted without ${list8}**
29870
30038
 
29871
30039
  ${r.reason}
29872
30040
 
@@ -30380,13 +30548,13 @@ var real5 = (p) => {
30380
30548
  }
30381
30549
  };
30382
30550
  var inside3 = (dir4, p) => p.startsWith(dir4 + path97.sep);
30383
- async function ownWorktree2(root, folder) {
30551
+ async function ownWorktree2(root, folder2) {
30384
30552
  const top = await gitText(path97.dirname(root), ["rev-parse", "--show-toplevel"]);
30385
30553
  if (!top) return void 0;
30386
30554
  const listed3 = await git(top, ["worktree", "list", "--porcelain", "-z"]);
30387
30555
  if (listed3.code !== 0) return void 0;
30388
30556
  const linked2 = listed3.stdout.toString("utf8").split("\0").filter((l) => l.startsWith("worktree ")).map((l) => real5(l.slice("worktree ".length))).filter((p) => p !== real5(top));
30389
- const target2 = real5(folder);
30557
+ const target2 = real5(folder2);
30390
30558
  if (!linked2.includes(target2)) return void 0;
30391
30559
  const dirs2 = [worktreeDir(top, readWorkspaceSettings(root).settings.dir), worktreeDir(top)];
30392
30560
  const allowed2 = dirs2.flatMap((d) => "dir" in d ? [real5(d.dir)] : []);
@@ -30681,7 +30849,7 @@ function activeTracker(o) {
30681
30849
  }
30682
30850
 
30683
30851
  // ../core/src/agents/lookoutLock.ts
30684
- import { rmSync as rmSync20 } from "node:fs";
30852
+ import { rmSync as rmSync21 } from "node:fs";
30685
30853
  import path100 from "node:path";
30686
30854
  var LOCK_SIG = "lookout-lock";
30687
30855
  function writeLookoutLock(root, url2) {
@@ -30698,7 +30866,7 @@ function writeLookoutLock(root, url2) {
30698
30866
  writeLocalJson(root, agentPaths.lock, lock);
30699
30867
  return () => {
30700
30868
  const cur = readJsonFile(path100.join(root, agentPaths.lock));
30701
- if (cur?.pid === process.pid) rmSync20(path100.join(root, agentPaths.lock), { force: true });
30869
+ if (cur?.pid === process.pid) rmSync21(path100.join(root, agentPaths.lock), { force: true });
30702
30870
  };
30703
30871
  }
30704
30872
  function readLookoutLock(root) {
@@ -30874,8 +31042,8 @@ function readProjects(configDir2) {
30874
31042
  const projects = list8.filter((p) => !seen2.has(p.id) && seen2.add(p.id));
30875
31043
  return { v: 1, projects, autoRegister: raw.autoRegister !== false };
30876
31044
  }
30877
- function writeProjects(configDir2, file10) {
30878
- writeJsonAtomic(projectsPath(configDir2), file10, { private: true });
31045
+ function writeProjects(configDir2, file9) {
31046
+ writeJsonAtomic(projectsPath(configDir2), file9, { private: true });
30879
31047
  }
30880
31048
  function updateProjects(configDir2, change3) {
30881
31049
  const next = change3(readProjects(configDir2));
@@ -30889,11 +31057,11 @@ function homeEntry(root) {
30889
31057
  return { id: projectId(root), name: projectName(real7), path: repoOfRoot(real7), root: real7, addedAt: 0 };
30890
31058
  }
30891
31059
  function projectEntries(configDir2, homeRoot) {
30892
- const file10 = readProjects(configDir2);
31060
+ const file9 = readProjects(configDir2);
30893
31061
  const home = homeEntry(homeRoot);
30894
- const registeredHome = file10.projects.find((p) => p.id === home.id);
30895
- const others = file10.projects.filter((p) => p.id !== home.id);
30896
- return { entries: [registeredHome ?? home, ...others], autoRegister: file10.autoRegister };
31062
+ const registeredHome = file9.projects.find((p) => p.id === home.id);
31063
+ const others = file9.projects.filter((p) => p.id !== home.id);
31064
+ return { entries: [registeredHome ?? home, ...others], autoRegister: file9.autoRegister };
30897
31065
  }
30898
31066
 
30899
31067
  // ../core/src/projects/projectState.ts
@@ -31054,7 +31222,7 @@ async function projectBriefing(input2) {
31054
31222
  }
31055
31223
 
31056
31224
  // ../core/src/projects/registerProject.ts
31057
- import { existsSync as existsSync36, mkdirSync as mkdirSync31, statSync as statSync13 } from "node:fs";
31225
+ import { existsSync as existsSync36, mkdirSync as mkdirSync32, statSync as statSync13 } from "node:fs";
31058
31226
  import path105 from "node:path";
31059
31227
  var ProjectPathError = class extends Error {
31060
31228
  };
@@ -31063,7 +31231,7 @@ function trackerRootFor(input2, opts = {}) {
31063
31231
  if (!existsSync36(abs) || !statSync13(abs).isDirectory()) throw new ProjectPathError(`no folder at ${abs}`);
31064
31232
  if (path105.basename(abs) === BRAND.dataDir || existsSync36(path105.join(abs, "trackers.json"))) return realRoot(abs);
31065
31233
  const root = path105.join(abs, BRAND.dataDir);
31066
- if (!existsSync36(root) && opts.create) mkdirSync31(root, { recursive: true });
31234
+ if (!existsSync36(root) && opts.create) mkdirSync32(root, { recursive: true });
31067
31235
  return realRoot(root);
31068
31236
  }
31069
31237
  function registerProject(input2) {
@@ -31226,7 +31394,7 @@ function findByHash(entries2, secret) {
31226
31394
  }
31227
31395
 
31228
31396
  // ../core/src/signIn/signInStore.ts
31229
- import { mkdirSync as mkdirSync32, statSync as statSync14 } from "node:fs";
31397
+ import { mkdirSync as mkdirSync33, statSync as statSync14 } from "node:fs";
31230
31398
  var SIGN_IN_FILE = "sign-in.json";
31231
31399
  var EMPTY3 = { v: 1, sessions: [], codes: [] };
31232
31400
  var isSession = (s) => {
@@ -31248,10 +31416,10 @@ function readSignIns(at2) {
31248
31416
  }
31249
31417
  function updateSignIns(at2, change3) {
31250
31418
  const store = machineStore(at2.root, at2.configDir);
31251
- mkdirSync32(store.dir, { recursive: true, mode: 448 });
31419
+ mkdirSync33(store.dir, { recursive: true, mode: 448 });
31252
31420
  return withFileLock2(store.file(`${SIGN_IN_FILE}.lock`), () => {
31253
- const { file: file10, result: result2 } = change3(readSignIns(at2));
31254
- store.write(SIGN_IN_FILE, file10);
31421
+ const { file: file9, result: result2 } = change3(readSignIns(at2));
31422
+ store.write(SIGN_IN_FILE, file9);
31255
31423
  return result2;
31256
31424
  });
31257
31425
  }
@@ -31301,9 +31469,9 @@ function mintPairCode(at2) {
31301
31469
  expiresAt,
31302
31470
  ...at2.via ? { via: at2.via } : {}
31303
31471
  };
31304
- updateSignIns(at2, (file10) => {
31305
- const live2 = file10.codes.filter((c) => c.expiresAt > now2);
31306
- return { file: { ...file10, codes: [...live2, entry].slice(-MAX_CODES) }, result: void 0 };
31472
+ updateSignIns(at2, (file9) => {
31473
+ const live2 = file9.codes.filter((c) => c.expiresAt > now2);
31474
+ return { file: { ...file9, codes: [...live2, entry].slice(-MAX_CODES) }, result: void 0 };
31307
31475
  });
31308
31476
  return { code: at2.kind === "machine" ? code2 : showTypedCode(code2), expiresAt };
31309
31477
  }
@@ -31706,12 +31874,12 @@ var MAX_SESSIONS = 50;
31706
31874
  function pairWithCode(at2) {
31707
31875
  const now2 = at2.now ?? Date.now();
31708
31876
  const code2 = normalizePairCode(at2.code)?.code;
31709
- return updateSignIns(at2, (file10) => {
31710
- const codes = file10.codes.filter((c) => c.expiresAt > now2);
31877
+ return updateSignIns(at2, (file9) => {
31878
+ const codes = file9.codes.filter((c) => c.expiresAt > now2);
31711
31879
  const mine2 = codes.filter((c) => c.instance === at2.instance);
31712
31880
  const used = code2 ? findByHash(mine2, code2) : void 0;
31713
31881
  const rest = codes.filter((c) => c !== used);
31714
- if (!used) return { file: { ...file10, codes: rest }, result: { kind: "refused" } };
31882
+ if (!used) return { file: { ...file9, codes: rest }, result: { kind: "refused" } };
31715
31883
  const kind2 = used.kind === "machine" && at2.local ? "machine" : "device";
31716
31884
  const secret = newSessionSecret();
31717
31885
  const session2 = {
@@ -31726,7 +31894,7 @@ function pairWithCode(at2) {
31726
31894
  expiresAt: now2 + SESSION_MS,
31727
31895
  ...used.via ? { via: used.via } : {}
31728
31896
  };
31729
- const live2 = file10.sessions.filter((s) => s.expiresAt > now2 && (s.start === at2.start || processAlive(s.instance))).sort((a, b) => a.lastUsedAt - b.lastUsedAt);
31897
+ const live2 = file9.sessions.filter((s) => s.expiresAt > now2 && (s.start === at2.start || processAlive(s.instance))).sort((a, b) => a.lastUsedAt - b.lastUsedAt);
31730
31898
  const sessions = [...live2, session2].slice(-MAX_SESSIONS);
31731
31899
  return { file: { v: 1, sessions, codes: rest }, result: { kind: "paired", secret, session: session2 } };
31732
31900
  });
@@ -31734,25 +31902,25 @@ function pairWithCode(at2) {
31734
31902
  function burnPairCode(at2) {
31735
31903
  const code2 = normalizePairCode(at2.code)?.code;
31736
31904
  if (!code2) return;
31737
- updateSignIns(at2, (file10) => {
31738
- const used = findByHash(file10.codes, code2);
31739
- return { file: { ...file10, codes: file10.codes.filter((c) => c !== used) }, result: void 0 };
31905
+ updateSignIns(at2, (file9) => {
31906
+ const used = findByHash(file9.codes, code2);
31907
+ return { file: { ...file9, codes: file9.codes.filter((c) => c !== used) }, result: void 0 };
31740
31908
  });
31741
31909
  }
31742
31910
  function removeSession(at2) {
31743
- return updateSignIns(at2, (file10) => {
31744
- const gone = file10.sessions.find((s) => s.id === at2.id);
31745
- return { file: { ...file10, sessions: file10.sessions.filter((s) => s !== gone) }, result: gone };
31911
+ return updateSignIns(at2, (file9) => {
31912
+ const gone = file9.sessions.find((s) => s.id === at2.id);
31913
+ return { file: { ...file9, sessions: file9.sessions.filter((s) => s !== gone) }, result: gone };
31746
31914
  });
31747
31915
  }
31748
31916
  function touchSessions(at2) {
31749
31917
  if (!at2.used.size) return;
31750
- updateSignIns(at2, (file10) => {
31751
- const sessions = file10.sessions.map((s) => {
31918
+ updateSignIns(at2, (file9) => {
31919
+ const sessions = file9.sessions.map((s) => {
31752
31920
  const when = at2.used.get(s.id);
31753
31921
  return when && when > s.lastUsedAt ? { ...s, lastUsedAt: when, expiresAt: when + SESSION_MS } : s;
31754
31922
  });
31755
- return { file: { ...file10, sessions }, result: void 0 };
31923
+ return { file: { ...file9, sessions }, result: void 0 };
31756
31924
  });
31757
31925
  }
31758
31926
 
@@ -31780,7 +31948,7 @@ function streamTickets(now2) {
31780
31948
  }
31781
31949
 
31782
31950
  // ../core/src/signIn/sweepSignInRedirects.ts
31783
- import { readdirSync as readdirSync25, readFileSync as readFileSync33, rmSync as rmSync21, statSync as statSync15 } from "node:fs";
31951
+ import { readdirSync as readdirSync25, readFileSync as readFileSync33, rmSync as rmSync22, statSync as statSync15 } from "node:fs";
31784
31952
 
31785
31953
  // ../core/src/signIn/signInRedirectFile.ts
31786
31954
  import { randomBytes as randomBytes12 } from "node:crypto";
@@ -31809,10 +31977,10 @@ function sweepSignInRedirects(at2) {
31809
31977
  const now2 = at2.now ?? Date.now();
31810
31978
  const pending = at2.keep === "pending" ? readSignIns(at2).codes.filter((c) => c.expiresAt > now2) : void 0;
31811
31979
  for (const name2 of names) {
31812
- const file10 = store.file(name2);
31980
+ const file9 = store.file(name2);
31813
31981
  try {
31814
- const keep3 = pending ? stillPending({ file: file10, name: name2, pending }) : false;
31815
- if (!keep3) rmSync21(file10, { force: true });
31982
+ const keep3 = pending ? stillPending({ file: file9, name: name2, pending }) : false;
31983
+ if (!keep3) rmSync22(file9, { force: true });
31816
31984
  } catch {
31817
31985
  }
31818
31986
  }
@@ -31950,7 +32118,7 @@ async function runningLookout(root, fetcher = fetch) {
31950
32118
  }
31951
32119
 
31952
32120
  // ../core/src/signIn/writeSignInRedirect.ts
31953
- import { chmodSync as chmodSync4, linkSync as linkSync5, mkdirSync as mkdirSync33, rmSync as rmSync22, writeFileSync as writeFileSync22 } from "node:fs";
32121
+ import { chmodSync as chmodSync4, linkSync as linkSync6, mkdirSync as mkdirSync34, rmSync as rmSync23, writeFileSync as writeFileSync23 } from "node:fs";
31954
32122
 
31955
32123
  // ../core/src/signIn/signInRedirectPage.ts
31956
32124
  import { createHash as createHash14 } from "node:crypto";
@@ -31975,20 +32143,20 @@ function signInRedirectPage(link) {
31975
32143
  // ../core/src/signIn/writeSignInRedirect.ts
31976
32144
  function writeSignInRedirect(at2) {
31977
32145
  const store = machineStore(at2.root, at2.configDir);
31978
- const file10 = store.file(SIGN_IN_REDIRECT.newName());
31979
- const tmp = `${file10}.${process.pid}.tmp`;
32146
+ const file9 = store.file(SIGN_IN_REDIRECT.newName());
32147
+ const tmp = `${file9}.${process.pid}.tmp`;
31980
32148
  try {
31981
- mkdirSync33(store.dir, { recursive: true, mode: 448 });
32149
+ mkdirSync34(store.dir, { recursive: true, mode: 448 });
31982
32150
  chmodSync4(store.dir, 448);
31983
- writeFileSync22(tmp, signInRedirectPage(at2.link), { mode: 384, flag: "wx" });
32151
+ writeFileSync23(tmp, signInRedirectPage(at2.link), { mode: 384, flag: "wx" });
31984
32152
  chmodSync4(tmp, 384);
31985
- linkSync5(tmp, file10);
32153
+ linkSync6(tmp, file9);
31986
32154
  } catch (e) {
31987
32155
  throw new Error(machineAccess(at2.configDir) ?? e.message);
31988
32156
  } finally {
31989
- rmSync22(tmp, { force: true });
32157
+ rmSync23(tmp, { force: true });
31990
32158
  }
31991
- return file10;
32159
+ return file9;
31992
32160
  }
31993
32161
 
31994
32162
  // ../core/src/projects/autoRegister.ts
@@ -32305,7 +32473,7 @@ function ttyIo() {
32305
32473
  import path112 from "node:path";
32306
32474
 
32307
32475
  // ../core/src/agents/agentDocWriter.ts
32308
- import { rmSync as rmSync23 } from "node:fs";
32476
+ import { rmSync as rmSync24 } from "node:fs";
32309
32477
  import path108 from "node:path";
32310
32478
  var teamtrailVersion = () => {
32311
32479
  const v = runningVersion();
@@ -32373,12 +32541,12 @@ var AgentDocWriter = class {
32373
32541
  */
32374
32542
  pullAnswers() {
32375
32543
  for (const q of this.activity.snapshot.pending) {
32376
- const file10 = path108.join(this.root, agentPaths.answer(q.sessionId, q.id));
32377
- const ans = readJsonFile(file10);
32378
- if (ans) this.take(file10, ans, q);
32544
+ const file9 = path108.join(this.root, agentPaths.answer(q.sessionId, q.id));
32545
+ const ans = readJsonFile(file9);
32546
+ if (ans) this.take(file9, ans, q);
32379
32547
  }
32380
32548
  }
32381
- take(file10, ans, q) {
32549
+ take(file9, ans, q) {
32382
32550
  let check2;
32383
32551
  try {
32384
32552
  check2 = checkAgentAnswer(this.root, ans, { sessionId: q.sessionId, questionId: q.id });
@@ -32386,7 +32554,7 @@ var AgentDocWriter = class {
32386
32554
  return this.cannotVerify(q.sessionId);
32387
32555
  }
32388
32556
  if (check2.kind === "forged" && this.newerWriter(ans.writer)) return this.skewed(q.sessionId, ans.writer);
32389
- rmSync23(file10, { force: true });
32557
+ rmSync24(file9, { force: true });
32390
32558
  if (check2.kind === "signed") return this.activity.answer(q.id, ans.text, ans.author || "trail lead", check2.how);
32391
32559
  this.activity.push({
32392
32560
  source: "system",
@@ -32445,35 +32613,35 @@ function claimTrailName(root, family, taken = /* @__PURE__ */ new Set(), holder)
32445
32613
  for (let n = 1; ; n++) {
32446
32614
  const trailName = name(family, n);
32447
32615
  if (taken.has(trailName)) continue;
32448
- const file10 = path109.join(dir4, `${trailName}.json`);
32616
+ const file9 = path109.join(dir4, `${trailName}.json`);
32449
32617
  try {
32450
- fs3.writeFileSync(file10, JSON.stringify({ pid: process.pid, holder, at: Date.now() }), { flag: "wx" });
32618
+ fs3.writeFileSync(file9, JSON.stringify({ pid: process.pid, holder, at: Date.now() }), { flag: "wx" });
32451
32619
  } catch (e) {
32452
32620
  if (e.code !== "EEXIST") throw e;
32453
- const lock = readLock(file10);
32621
+ const lock = readLock(file9);
32454
32622
  if (!lock) continue;
32455
32623
  const owner = lock.pid ?? 0;
32456
32624
  if (owner === process.pid && lock.holder === holder) return trailName;
32457
32625
  if (processAlive(owner)) continue;
32458
- fs3.rmSync(file10, { force: true });
32626
+ fs3.rmSync(file9, { force: true });
32459
32627
  n--;
32460
32628
  continue;
32461
32629
  }
32462
- if (holder === void 0) process.once("exit", () => fs3.rmSync(file10, { force: true }));
32630
+ if (holder === void 0) process.once("exit", () => fs3.rmSync(file9, { force: true }));
32463
32631
  return trailName;
32464
32632
  }
32465
32633
  }
32466
- function readLock(file10) {
32634
+ function readLock(file9) {
32467
32635
  try {
32468
- return JSON.parse(fs3.readFileSync(file10, "utf8"));
32636
+ return JSON.parse(fs3.readFileSync(file9, "utf8"));
32469
32637
  } catch {
32470
32638
  return void 0;
32471
32639
  }
32472
32640
  }
32473
32641
  function releaseTrailName(root, trailName, holder) {
32474
- const file10 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR, `${trailName}.json`);
32475
- const lock = readLock(file10);
32476
- if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(file10, { force: true });
32642
+ const file9 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR, `${trailName}.json`);
32643
+ const lock = readLock(file9);
32644
+ if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(file9, { force: true });
32477
32645
  }
32478
32646
 
32479
32647
  // ../core/src/policy/repoRootSpellings.ts
@@ -32488,16 +32656,16 @@ function repoRootSpellings(repoRoot) {
32488
32656
 
32489
32657
  // ../core/src/agents/chartedStore.ts
32490
32658
  import path110 from "node:path";
32491
- var safe16 = (s) => s.replace(/[^\w.-]/g, "_");
32492
- var file8 = (root, mapId) => path110.join(root, AGENTS_DIR, "charted", `${safe16(mapId)}.json`);
32659
+ var safe17 = (s) => s.replace(/[^\w.-]/g, "_");
32660
+ var file7 = (root, mapId) => path110.join(root, AGENTS_DIR, "charted", `${safe17(mapId)}.json`);
32493
32661
  var read3 = (root, mapId) => {
32494
- const f = readJsonFile(file8(root, mapId));
32662
+ const f = readJsonFile(file7(root, mapId));
32495
32663
  return f?.v === 1 && f.tickets && typeof f.tickets === "object" ? f.tickets : {};
32496
32664
  };
32497
32665
  function recordCharted(root, mapId, ticketIds, by) {
32498
32666
  ignoreAgentsDir(root);
32499
32667
  const tickets2 = { ...read3(root, mapId), ...Object.fromEntries(ticketIds.map((id) => [id, by])) };
32500
- writeJsonAtomic(file8(root, mapId), { v: 1, tickets: tickets2 });
32668
+ writeJsonAtomic(file7(root, mapId), { v: 1, tickets: tickets2 });
32501
32669
  }
32502
32670
  var chartedBy = (root, mapId, ticketId) => read3(root, mapId)[ticketId];
32503
32671
 
@@ -32793,7 +32961,7 @@ async function findCatalogGuide(input2) {
32793
32961
  }
32794
32962
 
32795
32963
  // ../core/src/guides/newGuide.ts
32796
- import { existsSync as existsSync38, mkdirSync as mkdirSync34, writeFileSync as writeFileSync23 } from "node:fs";
32964
+ import { existsSync as existsSync38, mkdirSync as mkdirSync35, writeFileSync as writeFileSync24 } from "node:fs";
32797
32965
  var ID_RE2 = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
32798
32966
  var nameOf3 = (id) => {
32799
32967
  const words7 = id.split("-").join(" ");
@@ -32830,12 +32998,12 @@ function newGuide(input2) {
32830
32998
  throw new OperationError(
32831
32999
  `${input2.id} is a built-in guide; pick another id (a file named ${input2.id}.md replaces it)`
32832
33000
  );
32833
- const file10 = guideFilePath(input2.root, input2.id);
32834
- if (existsSync38(file10)) throw new OperationError(`${file10} already exists`);
33001
+ const file9 = guideFilePath(input2.root, input2.id);
33002
+ if (existsSync38(file9)) throw new OperationError(`${file9} already exists`);
32835
33003
  const text11 = guideTemplate(input2);
32836
- mkdirSync34(guidesDir(input2.root), { recursive: true });
32837
- writeFileSync23(file10, text11);
32838
- return { file: file10, lint: lintGuide(text11) };
33004
+ mkdirSync35(guidesDir(input2.root), { recursive: true });
33005
+ writeFileSync24(file9, text11);
33006
+ return { file: file9, lint: lintGuide(text11) };
32839
33007
  }
32840
33008
 
32841
33009
  // src/approve/showItem.ts
@@ -32959,7 +33127,7 @@ function parseArgs(argv2) {
32959
33127
  process.exit(0);
32960
33128
  case "-v":
32961
33129
  case "--version":
32962
- process.stdout.write(`${"0.61.0"}
33130
+ process.stdout.write(`${"0.64.1"}
32963
33131
  `);
32964
33132
  process.exit(0);
32965
33133
  case "--no-open":
@@ -33032,11 +33200,11 @@ var scout_default = "---\ndescription: Teamtrail trails: new, resume, status, in
33032
33200
  // src/files.ts
33033
33201
  import fs4 from "node:fs";
33034
33202
  import path114 from "node:path";
33035
- function writeIfChanged(file10, text11) {
33036
- const prev = fs4.existsSync(file10) ? fs4.readFileSync(file10, "utf8") : void 0;
33203
+ function writeIfChanged(file9, text11) {
33204
+ const prev = fs4.existsSync(file9) ? fs4.readFileSync(file9, "utf8") : void 0;
33037
33205
  if (prev === text11) return "unchanged";
33038
- fs4.mkdirSync(path114.dirname(file10), { recursive: true });
33039
- fs4.writeFileSync(file10, text11);
33206
+ fs4.mkdirSync(path114.dirname(file9), { recursive: true });
33207
+ fs4.writeFileSync(file9, text11);
33040
33208
  return prev === void 0 ? "added" : "updated";
33041
33209
  }
33042
33210
 
@@ -33054,10 +33222,10 @@ var claudeSettingsFile = (env = process.env) => path116.join(env.CLAUDE_CONFIG_D
33054
33222
 
33055
33223
  // src/protect/readSettings.ts
33056
33224
  import fs5 from "node:fs";
33057
- function readSettings(file10) {
33058
- if (!fs5.existsSync(file10)) return {};
33225
+ function readSettings(file9) {
33226
+ if (!fs5.existsSync(file9)) return {};
33059
33227
  try {
33060
- const parsed3 = JSON.parse(fs5.readFileSync(file10, "utf8"));
33228
+ const parsed3 = JSON.parse(fs5.readFileSync(file9, "utf8"));
33061
33229
  const plain2 = typeof parsed3 === "object" && parsed3 !== null && !Array.isArray(parsed3);
33062
33230
  return plain2 ? parsed3 : void 0;
33063
33231
  } catch {
@@ -33066,18 +33234,18 @@ function readSettings(file10) {
33066
33234
  }
33067
33235
 
33068
33236
  // src/protect/claudeSandboxState.ts
33069
- function enabledIn(file10) {
33070
- const sandbox = readSettings(file10)?.sandbox;
33237
+ function enabledIn(file9) {
33238
+ const sandbox = readSettings(file9)?.sandbox;
33071
33239
  if (typeof sandbox !== "object" || sandbox === null) return void 0;
33072
33240
  const enabled = sandbox.enabled;
33073
33241
  return typeof enabled === "boolean" ? enabled : void 0;
33074
33242
  }
33075
33243
  function claudeSandboxState(cwd, env = process.env) {
33076
33244
  const files = [claudeLocalSettings(cwd), path117.join(cwd, ".claude", "settings.json"), claudeSettingsFile(env)];
33077
- for (const file10 of files) {
33078
- const enabled = enabledIn(file10);
33245
+ for (const file9 of files) {
33246
+ const enabled = enabledIn(file9);
33079
33247
  if (enabled === void 0) continue;
33080
- return enabled ? { kind: "on", file: file10 } : { kind: "off", file: file10 };
33248
+ return enabled ? { kind: "on", file: file9 } : { kind: "off", file: file9 };
33081
33249
  }
33082
33250
  return { kind: "unset" };
33083
33251
  }
@@ -33089,8 +33257,8 @@ function indentOf(text11) {
33089
33257
  const m = text11?.match(/^[{[][^\n]*\n([ \t]+)\S/);
33090
33258
  return m ? m[1] : 2;
33091
33259
  }
33092
- function writeSettings(file10, settings2) {
33093
- const target2 = fs6.existsSync(file10) ? fs6.realpathSync(file10) : file10;
33260
+ function writeSettings(file9, settings2) {
33261
+ const target2 = fs6.existsSync(file9) ? fs6.realpathSync(file9) : file9;
33094
33262
  const before = fs6.existsSync(target2) ? fs6.readFileSync(target2, "utf8") : void 0;
33095
33263
  const mode = before === void 0 ? void 0 : fs6.statSync(target2).mode & 511;
33096
33264
  fs6.mkdirSync(path118.dirname(target2), { recursive: true });
@@ -33106,27 +33274,27 @@ function writeSettings(file10, settings2) {
33106
33274
  }
33107
33275
 
33108
33276
  // src/protect/enableClaudeSandbox.ts
33109
- function enableClaudeSandbox(file10) {
33110
- const settings2 = readSettings(file10);
33277
+ function enableClaudeSandbox(file9) {
33278
+ const settings2 = readSettings(file9);
33111
33279
  if (!settings2) return "unreadable";
33112
33280
  const sandbox = settings2.sandbox ?? {};
33113
33281
  if (typeof sandbox !== "object" || sandbox === null || Array.isArray(sandbox)) return "unreadable";
33114
33282
  const current = sandbox;
33115
33283
  if (current.enabled === true) return "unchanged";
33116
33284
  const prompts = typeof current.autoAllowBashIfSandboxed === "boolean" ? {} : { autoAllowBashIfSandboxed: false };
33117
- writeSettings(file10, { ...settings2, sandbox: { ...current, enabled: true, ...prompts } });
33285
+ writeSettings(file9, { ...settings2, sandbox: { ...current, enabled: true, ...prompts } });
33118
33286
  return "enabled";
33119
33287
  }
33120
33288
 
33121
33289
  // src/protect/applySandbox.ts
33122
33290
  function applySandbox(o) {
33123
- const file10 = claudeLocalSettings(o.cwd);
33291
+ const file9 = claudeLocalSettings(o.cwd);
33124
33292
  const state = claudeSandboxState(o.cwd);
33125
33293
  if (state.kind === "on") return { kind: "already-on", file: state.file };
33126
- if (o.choice !== "on") return { kind: "left", why: o.choice, file: file10 };
33127
- const done2 = enableClaudeSandbox(file10);
33128
- if (done2 === "unreadable") return { kind: "unreadable", file: file10 };
33129
- return { kind: "turned-on", file: file10 };
33294
+ if (o.choice !== "on") return { kind: "left", why: o.choice, file: file9 };
33295
+ const done2 = enableClaudeSandbox(file9);
33296
+ if (done2 === "unreadable") return { kind: "unreadable", file: file9 };
33297
+ return { kind: "turned-on", file: file9 };
33130
33298
  }
33131
33299
 
33132
33300
  // src/protect/protectConfig.ts
@@ -33137,18 +33305,18 @@ import path121 from "node:path";
33137
33305
  var PAD = " ";
33138
33306
  var WHY3 = "Claude Code's own file tools can't read or change it. That is best effort unless Claude Code's sandbox is on: without it, a shell command (cat) can still read the folder; with it, sandboxed commands can't either. Teamtrail's own MCP server is not affected";
33139
33307
  function claudeProtectionLines(p, dirs2) {
33140
- const folder = dirs2.join(" and ");
33308
+ const folder2 = dirs2.join(" and ");
33141
33309
  switch (p.kind) {
33142
33310
  case "added":
33143
33311
  return [
33144
- ` Config folder protected \xB7 ${folder} \xB7 added to ${p.file}:`,
33312
+ ` Config folder protected \xB7 ${folder2} \xB7 added to ${p.file}:`,
33145
33313
  ...p.added.map((a) => `${PAD}+ ${a}`),
33146
33314
  `${PAD}${WHY3}.`,
33147
33315
  `${PAD}To remove: delete those entries from ${p.file}; connect with --no-protect-config to skip this.`
33148
33316
  ];
33149
33317
  case "unchanged":
33150
33318
  return [
33151
- ` Config folder already protected \xB7 ${folder} \xB7 deny rules in ${p.file}`,
33319
+ ` Config folder already protected \xB7 ${folder2} \xB7 deny rules in ${p.file}`,
33152
33320
  `${PAD}To remove: delete the entries naming it from ${p.file}; connect with --no-protect-config to skip this.`
33153
33321
  ];
33154
33322
  case "pattern-path":
@@ -33227,20 +33395,20 @@ function merge(s, dirs2) {
33227
33395
  ];
33228
33396
  return parts2.some((p) => !p) ? void 0 : parts2.flatMap((p) => p);
33229
33397
  }
33230
- function protectClaude(file10, dirs2) {
33398
+ function protectClaude(file9, dirs2) {
33231
33399
  const all = claudeRules(dirs2);
33232
33400
  const byHand = [
33233
33401
  ...all.deny.map((r) => `permissions.deny: ${r}`),
33234
33402
  ...all.denyRead.map((d) => `sandbox.filesystem.denyRead: ${d}`),
33235
33403
  ...all.denyWrite.map((d) => `sandbox.filesystem.denyWrite: ${d}`)
33236
33404
  ];
33237
- if (dirs2.some((d) => PATTERN.test(d))) return { kind: "pattern-path", file: file10, rules: byHand };
33238
- const settings2 = readSettings(file10);
33405
+ if (dirs2.some((d) => PATTERN.test(d))) return { kind: "pattern-path", file: file9, rules: byHand };
33406
+ const settings2 = readSettings(file9);
33239
33407
  const added = settings2 && merge(settings2, dirs2);
33240
- if (!settings2 || !added) return { kind: "unreadable", file: file10, rules: byHand };
33241
- if (!added.length) return { kind: "unchanged", file: file10 };
33242
- writeSettings(file10, settings2);
33243
- return { kind: "added", file: file10, added };
33408
+ if (!settings2 || !added) return { kind: "unreadable", file: file9, rules: byHand };
33409
+ if (!added.length) return { kind: "unchanged", file: file9 };
33410
+ writeSettings(file9, settings2);
33411
+ return { kind: "added", file: file9, added };
33244
33412
  }
33245
33413
 
33246
33414
  // src/protect/protectedDirs.ts
@@ -33369,11 +33537,11 @@ function hookCommand(dir4, self) {
33369
33537
  const where2 = dir4 && dir4 !== BRAND.dataDir ? ["--dir", dir4] : [];
33370
33538
  return shellLine([self.command, ...self.args, "hook", "claude", ...where2]);
33371
33539
  }
33372
- function installClaudeHook(file10, dir4, self) {
33540
+ function installClaudeHook(file9, dir4, self) {
33373
33541
  let settings2 = {};
33374
- if (fs8.existsSync(file10)) {
33542
+ if (fs8.existsSync(file9)) {
33375
33543
  try {
33376
- settings2 = JSON.parse(fs8.readFileSync(file10, "utf8"));
33544
+ settings2 = JSON.parse(fs8.readFileSync(file9, "utf8"));
33377
33545
  } catch {
33378
33546
  return "skipped (settings file is not valid JSON)";
33379
33547
  }
@@ -33386,7 +33554,7 @@ function installClaudeHook(file10, dir4, self) {
33386
33554
  ...settings2,
33387
33555
  hooks: { ...settings2.hooks, SessionStart: [...kept, { hooks: [{ type: "command", command, timeout: 30 }] }] }
33388
33556
  };
33389
- return writeIfChanged(file10, `${JSON.stringify(next, null, 2)}
33557
+ return writeIfChanged(file9, `${JSON.stringify(next, null, 2)}
33390
33558
  `);
33391
33559
  }
33392
33560
 
@@ -33443,8 +33611,8 @@ function registerClaude(o, server) {
33443
33611
  return `not updated (${again.out || `exit ${again.status}`}). Run: claude mcp remove ${BRAND.slug}, then ${shown3}`;
33444
33612
  }
33445
33613
  function connectClaude(o) {
33446
- const file10 = path124.join(o.cwd, ".claude", "commands", "scout.md");
33447
- o.print(` /scout command ${writeIfChanged(file10, scout_default)} \xB7 ${path124.relative(o.cwd, file10)}`);
33614
+ const file9 = path124.join(o.cwd, ".claude", "commands", "scout.md");
33615
+ o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path124.relative(o.cwd, file9)}`);
33448
33616
  o.print(` MCP server ${registerClaude(o, serverCommand(o.self, o.dir))}`);
33449
33617
  const settings2 = claudeLocalSettings(o.cwd);
33450
33618
  o.print(
@@ -33453,8 +33621,8 @@ function connectClaude(o) {
33453
33621
  }
33454
33622
  function connectCodex(o) {
33455
33623
  const home = process.env.CODEX_HOME || path124.join(os8.homedir(), ".codex");
33456
- const file10 = path124.join(home, "prompts", "scout.md");
33457
- o.print(` /scout prompt ${writeIfChanged(file10, scout_default)} \xB7 ${file10}`);
33624
+ const file9 = path124.join(home, "prompts", "scout.md");
33625
+ o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33458
33626
  const [command, ...args] = serverCommand(o.self, o.dir);
33459
33627
  const env = process.env.CODEX_HOME ? ["--env", `CODEX_HOME=${process.env.CODEX_HOME}`] : [];
33460
33628
  const r = o.run("codex", ["mcp", "add", BRAND.slug, ...env, "--", command, ...args]);
@@ -33564,8 +33732,8 @@ function connectClaude2(o) {
33564
33732
  fail(
33565
33733
  `Claude Code keeps the token in its config, so connect needs it: --token-stdin, $${BRAND.tokenEnv} or --token`
33566
33734
  );
33567
- const file10 = path125.join(o.cwd, ".claude", "commands", "scout.md");
33568
- o.print(` /scout command ${writeIfChanged(file10, scout_default)} \xB7 ${path125.relative(o.cwd, file10)}`);
33735
+ const file9 = path125.join(o.cwd, ".claude", "commands", "scout.md");
33736
+ o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path125.relative(o.cwd, file9)}`);
33569
33737
  const shown3 = `claude mcp add --transport http ${BRAND.slug} ${o.url} --header "Authorization: Bearer $${BRAND.tokenEnv}"`;
33570
33738
  const add3 = ["mcp", "add", "--transport", "http", BRAND.slug, o.url, "--header", `Authorization: Bearer ${o.token}`];
33571
33739
  const r = (o.run ?? runCli2)("claude", add3);
@@ -33585,8 +33753,8 @@ function connectClaude2(o) {
33585
33753
  }
33586
33754
  function connectCodex2(o) {
33587
33755
  const home = process.env.CODEX_HOME || path125.join(os9.homedir(), ".codex");
33588
- const file10 = path125.join(home, "prompts", "scout.md");
33589
- o.print(` /scout prompt ${writeIfChanged(file10, scout_default)} \xB7 ${file10}`);
33756
+ const file9 = path125.join(home, "prompts", "scout.md");
33757
+ o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33590
33758
  const args = ["mcp", "add", BRAND.slug, "--url", o.url, "--bearer-token-env-var", BRAND.tokenEnv];
33591
33759
  const r = (o.run ?? runCli2)("codex", args);
33592
33760
  const config4 = path125.join(home, "config.toml");
@@ -33921,8 +34089,8 @@ function guidesNew(a, io) {
33921
34089
  }
33922
34090
  const root = path129.resolve(a.dir);
33923
34091
  const author = a.author ?? gitName(path129.dirname(root));
33924
- const { file: file10, lint } = newGuide({ root, id, author });
33925
- const shown3 = path129.relative(process.cwd(), file10) || file10;
34092
+ const { file: file9, lint } = newGuide({ root, id, author });
34093
+ const shown3 = path129.relative(process.cwd(), file9) || file9;
33926
34094
  printFindings(io, shown3, lint.findings);
33927
34095
  io.out(
33928
34096
  [
@@ -34149,8 +34317,8 @@ async function guidesCli(argv2) {
34149
34317
  // src/knowledgeImport.ts
34150
34318
  import { readFileSync as readFileSync37 } from "node:fs";
34151
34319
  import path133 from "node:path";
34152
- function importKnowledge(root, file10) {
34153
- const parts2 = splitForImport(readFileSync37(file10, "utf8"), path133.basename(file10));
34320
+ function importKnowledge(root, file9) {
34321
+ const parts2 = splitForImport(readFileSync37(file9, "utf8"), path133.basename(file9));
34154
34322
  const now2 = Date.now();
34155
34323
  const ids2 = [];
34156
34324
  for (const p of parts2) {
@@ -34186,7 +34354,7 @@ function mcpHttpOptions(o, root) {
34186
34354
  allowHosts: o.allowHosts,
34187
34355
  leaseMinutes: o.leaseMinutes,
34188
34356
  noRegister: o.noRegister,
34189
- version: "0.61.0"
34357
+ version: "0.64.1"
34190
34358
  };
34191
34359
  }
34192
34360
 
@@ -36246,14 +36414,14 @@ function codePointLength(str14) {
36246
36414
  const units = str14.length;
36247
36415
  if (!highSurrogate.test(str14))
36248
36416
  return units;
36249
- let count2 = units;
36417
+ let count3 = units;
36250
36418
  for (let i = 0; i < units - 1; i++) {
36251
36419
  if ((str14.charCodeAt(i) & 64512) === 55296 && (str14.charCodeAt(i + 1) & 64512) === 56320) {
36252
- count2--;
36420
+ count3--;
36253
36421
  i++;
36254
36422
  }
36255
36423
  }
36256
- return count2;
36424
+ return count3;
36257
36425
  }
36258
36426
  function getLengthableOrigin(input2) {
36259
36427
  if (Array.isArray(input2))
@@ -44760,7 +44928,7 @@ import { randomUUID as randomUUID4 } from "node:crypto";
44760
44928
  import path134 from "node:path";
44761
44929
 
44762
44930
  // src/ownVersion.ts
44763
- var OWN_VERSION = true ? "0.61.0" : void 0;
44931
+ var OWN_VERSION = true ? "0.64.1" : void 0;
44764
44932
 
44765
44933
  // src/mcp/trail/agentLeases.ts
44766
44934
  var AgentLeases = class {
@@ -46546,7 +46714,7 @@ function ticketView(snap, t, records = []) {
46546
46714
  }
46547
46715
  function trailView(snap, docs, records, keyOf11) {
46548
46716
  const states = deriveStates(snap.tickets, snap.map.mode);
46549
- const count2 = (st) => snap.tickets.filter((t) => states.get(t.id) === st).length;
46717
+ const count3 = (st) => snap.tickets.filter((t) => states.get(t.id) === st).length;
46550
46718
  const mine2 = docs.filter((d) => d.session.mapId === snap.map.id);
46551
46719
  const usage = mine2.map((d) => d.session.usage).filter((u) => !!u);
46552
46720
  return {
@@ -46555,20 +46723,20 @@ function trailView(snap, docs, records, keyOf11) {
46555
46723
  title: snap.map.title,
46556
46724
  mode: snap.map.mode,
46557
46725
  destination: snap.map.sections.destination,
46558
- progress: `${count2("decided")}/${snap.tickets.filter((t) => states.get(t.id) !== "out-of-scope").length} decided`,
46726
+ progress: `${count3("decided")}/${snap.tickets.filter((t) => states.get(t.id) !== "out-of-scope").length} decided`,
46559
46727
  counts: {
46560
- decided: count2("decided"),
46561
- claimed: count2("claimed"),
46562
- ready: count2("frontier"),
46563
- blocked: count2("blocked"),
46564
- parked: count2("parked"),
46565
- outOfScope: count2("out-of-scope"),
46566
- ...snap.map.verification || count2("verifying") || count2("rework") || count2("held") ? { verifying: count2("verifying"), rework: count2("rework"), waitingOnHuman: count2("held") } : {}
46728
+ decided: count3("decided"),
46729
+ claimed: count3("claimed"),
46730
+ ready: count3("frontier"),
46731
+ blocked: count3("blocked"),
46732
+ parked: count3("parked"),
46733
+ outOfScope: count3("out-of-scope"),
46734
+ ...snap.map.verification || count3("verifying") || count3("rework") || count3("held") ? { verifying: count3("verifying"), rework: count3("rework"), waitingOnHuman: count3("held") } : {}
46567
46735
  },
46568
46736
  ready: snap.tickets.filter((t) => states.get(t.id) === "frontier").map((t) => ({ key: t.key, title: t.title, type: t.type, attention: attention(t) })),
46569
46737
  claimed: snap.tickets.filter((t) => states.get(t.id) === "claimed").map((t) => ({ key: t.key, title: t.title, assignee: t.assignee })),
46570
46738
  blocked: snap.tickets.filter((t) => states.get(t.id) === "blocked").map((t) => ({ key: t.key, title: t.title })),
46571
- ...snap.map.verification || count2("verifying") || count2("rework") || count2("held") ? {
46739
+ ...snap.map.verification || count3("verifying") || count3("rework") || count3("held") ? {
46572
46740
  verification: {
46573
46741
  level: snap.map.verification ?? "off",
46574
46742
  verifying: snap.tickets.filter((t) => states.get(t.id) === "verifying").map((t) => t.key),
@@ -46615,12 +46783,12 @@ function noTicketReason(snap, discovery) {
46615
46783
  if (discovery.gate)
46616
46784
  return `No ready ${discovery.gate.join(", ")} ticket, and implementation tickets wait for the discovery brief: ${discovery.next}`;
46617
46785
  const states = deriveStates(snap.tickets, snap.map.mode);
46618
- const count2 = (state) => open4.filter((x) => states.get(x.id) === state).length;
46786
+ const count3 = (state) => open4.filter((x) => states.get(x.id) === state).length;
46619
46787
  const waiting2 = [
46620
- { label: "verifying", n: count2("verifying") },
46621
- { label: "waiting on the human", n: count2("held") }
46788
+ { label: "verifying", n: count3("verifying") },
46789
+ { label: "waiting on the human", n: count3("held") }
46622
46790
  ].filter((w) => w.n > 0).map((w) => `, ${w.n} ${w.label}`).join("");
46623
- return `No ready ticket: ${count2("claimed")} claimed, ${count2("blocked")} blocked, ${count2("parked")} parked${waiting2}.`;
46791
+ return `No ready ticket: ${count3("claimed")} claimed, ${count3("blocked")} blocked, ${count3("parked")} parked${waiting2}.`;
46624
46792
  }
46625
46793
 
46626
46794
  // src/mcp/trail/ticketOps.ts
@@ -47075,22 +47243,22 @@ async function complete(c, wait) {
47075
47243
  const transcript = wantsTranscript ? log.map((e) => `**${e.author}:** ${e.text}`).join("\n\n") : void 0;
47076
47244
  const { info } = levelFor(ctx.root, snap, t);
47077
47245
  assertConfirmed(t, info);
47078
- const verified = info.level !== "off";
47246
+ const verified2 = info.level !== "off";
47079
47247
  const declared = declaredPaths({
47080
47248
  remote: ctx.remote,
47081
- verified,
47249
+ verified: verified2,
47082
47250
  paths: input2.paths,
47083
47251
  noCodeReason: input2.noCodeReason,
47084
47252
  repoRoot: pathRoots(ctx)
47085
47253
  });
47086
47254
  assertCriteria(ctx.root, snap, t, info.level);
47087
- if (verified)
47255
+ if (verified2)
47088
47256
  await assertRulesAnswered(ctx, { snap, ticket: t, declared, answers: input2.ruleAnswers, agent: c.agent });
47089
47257
  const checked = checkedAnswers(ctx, { snap, ticket: t, given: input2.checklist });
47090
47258
  await keepAnswers(ctx, { snap, ticket: t, checked });
47091
47259
  spend(c.human, `the close of ${t.key}`);
47092
47260
  let unverified = {};
47093
- if (!verified) {
47261
+ if (!verified2) {
47094
47262
  unverified = { warning: await flagUnverified(ctx, { snap, ticket: t, seen: c.seen }) };
47095
47263
  await resolveDirectly(c, { meta: meta4, transcript });
47096
47264
  } else {
@@ -47233,7 +47401,7 @@ async function findPrecedentTool(ctx, input2) {
47233
47401
  }
47234
47402
 
47235
47403
  // src/mcp/trail/types.ts
47236
- var TRAIL_LEAD7 = "trail lead";
47404
+ var TRAIL_LEAD8 = "trail lead";
47237
47405
 
47238
47406
  // src/mcp/trail/hitl.ts
47239
47407
  async function ask3(ctx, input2, ctl = {}) {
@@ -47262,7 +47430,7 @@ async function ask3(ctx, input2, ctl = {}) {
47262
47430
  ctx.waits.set(
47263
47431
  q.id,
47264
47432
  answer3.then((text11) => {
47265
- const author = [...ctx.activity.snapshot.chats].reverse().find((c) => c.sessionId === sid && c.from === "human")?.author ?? TRAIL_LEAD7;
47433
+ const author = [...ctx.activity.snapshot.chats].reverse().find((c) => c.sessionId === sid && c.from === "human")?.author ?? TRAIL_LEAD8;
47266
47434
  const { via, chatOf, by } = ctx.activity.snapshot.answered.find((a) => a.id === q.id) ?? {};
47267
47435
  const at2 = Date.now();
47268
47436
  const where2 = chatNote({ via, chatOf });
@@ -47379,7 +47547,7 @@ async function answerQuestion(ctx, input2) {
47379
47547
  const given = { via: "chat", note: CHAT_GUIDES };
47380
47548
  const own3 = ctx.activity.snapshot.pending.find((p) => p.id === input2.questionId);
47381
47549
  if (own3) {
47382
- ctx.activity.answer(own3.id, input2.answer.trim(), TRAIL_LEAD7, { via: "chat", chatOf });
47550
+ ctx.activity.answer(own3.id, input2.answer.trim(), TRAIL_LEAD8, { via: "chat", chatOf });
47383
47551
  return { delivered: true, to: own3.agent, ...given };
47384
47552
  }
47385
47553
  const doc = (await readAgentDocs(ctx.root)).find((d) => d.pending.some((q) => q.id === input2.questionId));
@@ -47388,7 +47556,7 @@ async function answerQuestion(ctx, input2) {
47388
47556
  sessionId: doc.session.id,
47389
47557
  questionId: input2.questionId,
47390
47558
  text: input2.answer,
47391
- author: TRAIL_LEAD7,
47559
+ author: TRAIL_LEAD8,
47392
47560
  via: "chat",
47393
47561
  chatOf
47394
47562
  });
@@ -47665,6 +47833,8 @@ async function resumeTrail(ctx, trailRef) {
47665
47833
  };
47666
47834
  }
47667
47835
  async function updateTrail(ctx, input2) {
47836
+ const tooLong = trailTextProblem({ destination: input2.destination, notes: input2.notes });
47837
+ if (tooLong) throw new OperationError(tooLong);
47668
47838
  const snap = await ctx.resolveTrail(input2.trail);
47669
47839
  const requests = await settingRequests(ctx, snap, input2);
47670
47840
  const trail2 = await applyUpdate(ctx, { snap, input: { ...input2, mode: void 0, destination: void 0 } });
@@ -55048,7 +55218,7 @@ var ExperimentalMcpServerTasks = class {
55048
55218
 
55049
55219
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
55050
55220
  function toolInputElementCount(value, max) {
55051
- let count2 = 0;
55221
+ let count3 = 0;
55052
55222
  const stack = [value];
55053
55223
  while (stack.length > 0) {
55054
55224
  const node3 = stack.pop();
@@ -55056,8 +55226,8 @@ function toolInputElementCount(value, max) {
55056
55226
  continue;
55057
55227
  if (Array.isArray(node3)) {
55058
55228
  for (const child2 of node3) {
55059
- if (++count2 > max)
55060
- return count2;
55229
+ if (++count3 > max)
55230
+ return count3;
55061
55231
  if (child2 !== null && typeof child2 === "object")
55062
55232
  stack.push(child2);
55063
55233
  }
@@ -55065,15 +55235,15 @@ function toolInputElementCount(value, max) {
55065
55235
  for (const key in node3) {
55066
55236
  if (!Object.prototype.hasOwnProperty.call(node3, key))
55067
55237
  continue;
55068
- if (++count2 > max)
55069
- return count2;
55238
+ if (++count3 > max)
55239
+ return count3;
55070
55240
  const child2 = node3[key];
55071
55241
  if (child2 !== null && typeof child2 === "object")
55072
55242
  stack.push(child2);
55073
55243
  }
55074
55244
  }
55075
55245
  }
55076
- return count2;
55246
+ return count3;
55077
55247
  }
55078
55248
  function resolveMaxToolInputElements(value) {
55079
55249
  if (value === void 0 || value === Infinity)
@@ -56004,10 +56174,10 @@ import path135 from "node:path";
56004
56174
 
56005
56175
  // src/usage/quietFs.ts
56006
56176
  import fs9 from "node:fs";
56007
- function tail(file10, bytes2 = 256 << 10) {
56177
+ function tail(file9, bytes2 = 256 << 10) {
56008
56178
  try {
56009
- const size3 = fs9.statSync(file10).size;
56010
- const fd = fs9.openSync(file10, "r");
56179
+ const size3 = fs9.statSync(file9).size;
56180
+ const fd = fs9.openSync(file9, "r");
56011
56181
  try {
56012
56182
  const buf = Buffer.alloc(Math.min(size3, bytes2));
56013
56183
  fs9.readSync(fd, buf, 0, buf.length, size3 - buf.length);
@@ -56019,16 +56189,16 @@ function tail(file10, bytes2 = 256 << 10) {
56019
56189
  return "";
56020
56190
  }
56021
56191
  }
56022
- var size2 = (file10) => {
56192
+ var size2 = (file9) => {
56023
56193
  try {
56024
- return fs9.statSync(file10).size;
56194
+ return fs9.statSync(file9).size;
56025
56195
  } catch {
56026
56196
  return -1;
56027
56197
  }
56028
56198
  };
56029
- var recent = (file10, since2) => {
56199
+ var recent = (file9, since2) => {
56030
56200
  try {
56031
- return fs9.statSync(file10).mtimeMs >= since2;
56201
+ return fs9.statSync(file9).mtimeMs >= since2;
56032
56202
  } catch {
56033
56203
  return false;
56034
56204
  }
@@ -56184,8 +56354,8 @@ function codexRolloutParser() {
56184
56354
  };
56185
56355
  }
56186
56356
  var LogFile = class {
56187
- constructor(file10, parser) {
56188
- this.file = file10;
56357
+ constructor(file9, parser) {
56358
+ this.file = file9;
56189
56359
  this.parser = parser;
56190
56360
  }
56191
56361
  offset = 0;
@@ -56275,10 +56445,10 @@ var UsageMeter = class {
56275
56445
  const codexMeta = meta4?.["x-codex-turn-metadata"];
56276
56446
  const thread = meta4?.threadId ?? codexMeta?.thread_id ?? codexMeta?.session_id;
56277
56447
  if (typeof thread === "string" && thread !== this.threadId) {
56278
- const file10 = findCodexRollout(thread, this.env, this.home);
56279
- if (file10) {
56448
+ const file9 = findCodexRollout(thread, this.env, this.home);
56449
+ if (file9) {
56280
56450
  this.threadId = thread;
56281
- this.attach(file10, "codex");
56451
+ this.attach(file9, "codex");
56282
56452
  }
56283
56453
  }
56284
56454
  const toolUse = meta4?.["claudecode/toolUseId"];
@@ -56303,14 +56473,14 @@ var UsageMeter = class {
56303
56473
  }
56304
56474
  return void 0;
56305
56475
  }
56306
- attach(file10, source) {
56307
- if (this.files.has(file10)) return;
56476
+ attach(file9, source) {
56477
+ if (this.files.has(file9)) return;
56308
56478
  this.source = source;
56309
- this.files.set(file10, new LogFile(file10, source === "codex" ? codexRolloutParser() : claudeTranscriptParser()));
56479
+ this.files.set(file9, new LogFile(file9, source === "codex" ? codexRolloutParser() : claudeTranscriptParser()));
56310
56480
  }
56311
56481
  poll() {
56312
- for (const [file10, f] of this.files) {
56313
- const own3 = path136.basename(path136.dirname(file10)) !== "subagents";
56482
+ for (const [file9, f] of this.files) {
56483
+ const own3 = path136.basename(path136.dirname(file9)) !== "subagents";
56314
56484
  for (const e of f.read()) {
56315
56485
  if (own3 && e.model && (!this.latest || e.at >= this.latest.at)) this.latest = { at: e.at, model: e.model };
56316
56486
  const prev = this.events.get(e.key);
@@ -56330,9 +56500,9 @@ var UsageMeter = class {
56330
56500
  }
56331
56501
  /** Subagent (Task) transcripts sit next to the main one, under `<session>/subagents/`. */
56332
56502
  attachSubagents() {
56333
- for (const file10 of [...this.files.keys()]) {
56334
- if (path136.basename(path136.dirname(file10)) === "subagents") continue;
56335
- const dir4 = path136.join(file10.replace(/\.jsonl$/, ""), "subagents");
56503
+ for (const file9 of [...this.files.keys()]) {
56504
+ if (path136.basename(path136.dirname(file9)) === "subagents") continue;
56505
+ const dir4 = path136.join(file9.replace(/\.jsonl$/, ""), "subagents");
56336
56506
  for (const n of ls(dir4)) if (n.endsWith(".jsonl")) this.attach(path136.join(dir4, n), "claude-code");
56337
56507
  }
56338
56508
  }
@@ -56544,7 +56714,7 @@ __export(external_exports, {
56544
56714
  endsWith: () => _endsWith2,
56545
56715
  enum: () => _enum3,
56546
56716
  exactOptional: () => exactOptional2,
56547
- file: () => file9,
56717
+ file: () => file8,
56548
56718
  flattenError: () => flattenError2,
56549
56719
  float32: () => float32,
56550
56720
  float64: () => float64,
@@ -57642,14 +57812,14 @@ function codePointLength2(str14) {
57642
57812
  const units = str14.length;
57643
57813
  if (!highSurrogate2.test(str14))
57644
57814
  return units;
57645
- let count2 = units;
57815
+ let count3 = units;
57646
57816
  for (let i = 0; i < units - 1; i++) {
57647
57817
  if ((str14.charCodeAt(i) & 64512) === 55296 && (str14.charCodeAt(i + 1) & 64512) === 56320) {
57648
- count2--;
57818
+ count3--;
57649
57819
  i++;
57650
57820
  }
57651
57821
  }
57652
- return count2;
57822
+ return count3;
57653
57823
  }
57654
57824
  function getLengthableOrigin2(input2) {
57655
57825
  if (Array.isArray(input2))
@@ -62029,8 +62199,8 @@ function az_default() {
62029
62199
  }
62030
62200
 
62031
62201
  // node_modules/zod/v4/locales/be.js
62032
- function getBelarusianPlural(count2, one, few, many) {
62033
- const absCount = Math.abs(count2);
62202
+ function getBelarusianPlural(count3, one, few, many) {
62203
+ const absCount = Math.abs(count3);
62034
62204
  const lastDigit = absCount % 10;
62035
62205
  const lastTwoDigits = absCount % 100;
62036
62206
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -64676,8 +64846,8 @@ function hu_default() {
64676
64846
  }
64677
64847
 
64678
64848
  // node_modules/zod/v4/locales/hy.js
64679
- function getArmenianPlural(count2, one, many) {
64680
- return Math.abs(count2) === 1 ? one : many;
64849
+ function getArmenianPlural(count3, one, many) {
64850
+ return Math.abs(count3) === 1 ? one : many;
64681
64851
  }
64682
64852
  function withDefiniteArticle(word) {
64683
64853
  if (!word)
@@ -67415,8 +67585,8 @@ function ro_default() {
67415
67585
  }
67416
67586
 
67417
67587
  // node_modules/zod/v4/locales/ru.js
67418
- function getRussianPlural(count2, one, few, many) {
67419
- const absCount = Math.abs(count2);
67588
+ function getRussianPlural(count3, one, few, many) {
67589
+ const absCount = Math.abs(count3);
67420
67590
  const lastDigit = absCount % 10;
67421
67591
  const lastTwoDigits = absCount % 100;
67422
67592
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -73482,7 +73652,7 @@ __export(schemas_exports2, {
73482
73652
  emoji: () => emoji3,
73483
73653
  enum: () => _enum3,
73484
73654
  exactOptional: () => exactOptional2,
73485
- file: () => file9,
73655
+ file: () => file8,
73486
73656
  float32: () => float32,
73487
73657
  float64: () => float64,
73488
73658
  function: () => _function,
@@ -74783,7 +74953,7 @@ var ZodFile = /* @__PURE__ */ $constructor2("ZodFile", (inst, def) => {
74783
74953
  inst.max = (size3, params) => inst.check(_maxSize2(size3, params));
74784
74954
  inst.mime = (types2, params) => inst.check(_mime2(Array.isArray(types2) ? types2 : [types2], params));
74785
74955
  });
74786
- function file9(params) {
74956
+ function file8(params) {
74787
74957
  return _file2(ZodFile, params);
74788
74958
  }
74789
74959
  var ZodTransform2 = /* @__PURE__ */ $constructor2("ZodTransform", (inst, def) => {
@@ -77172,7 +77342,7 @@ import path138 from "node:path";
77172
77342
 
77173
77343
  // src/serve/openSignedIn.ts
77174
77344
  import { spawn as spawn4 } from "node:child_process";
77175
- import { rmSync as rmSync24 } from "node:fs";
77345
+ import { rmSync as rmSync25 } from "node:fs";
77176
77346
 
77177
77347
  // src/serve/browser/httpHandler.ts
77178
77348
  import { execFileSync } from "node:child_process";
@@ -77202,7 +77372,7 @@ function linuxHttpHandler(deps) {
77202
77372
  if (/snap|flatpak/i.test(`${entry}
77203
77373
  ${text11}`))
77204
77374
  return { kind: "none", why: `the default browser (${id}) is a snap or Flatpak, which can't read the page` };
77205
- return { kind: "app", name: id, command: (file10) => ["gio", ["launch", entry, file10]] };
77375
+ return { kind: "app", name: id, command: (file9) => ["gio", ["launch", entry, file9]] };
77206
77376
  }
77207
77377
  return { kind: "none", why: `the default browser's desktop entry (${id}) wasn't found` };
77208
77378
  }
@@ -77222,7 +77392,7 @@ function macHttpHandler(deps) {
77222
77392
  return { kind: "none", why: `couldn't ask macOS for the default browser (${e.message.split("\n")[0]})` };
77223
77393
  }
77224
77394
  if (!BUNDLE_ID.test(id)) return { kind: "none", why: "macOS named no default browser" };
77225
- return { kind: "app", name: id, command: (file10) => ["open", ["-b", id, file10]] };
77395
+ return { kind: "app", name: id, command: (file9) => ["open", ["-b", id, file9]] };
77226
77396
  }
77227
77397
 
77228
77398
  // src/serve/browser/windowsHttpHandler.ts
@@ -77234,10 +77404,10 @@ function parseCommand(line5) {
77234
77404
  if (!m) return void 0;
77235
77405
  return { exe: m[1], args: m[2].split(/\s+/).filter(Boolean) };
77236
77406
  }
77237
- function withFile(args, file10) {
77407
+ function withFile(args, file9) {
77238
77408
  const hasSlot = args.some((a) => a.includes("%1"));
77239
- const filled = args.map((a) => a.includes("%1") ? file10 : a);
77240
- return hasSlot ? filled : [...filled, file10];
77409
+ const filled = args.map((a) => a.includes("%1") ? file9 : a);
77410
+ return hasSlot ? filled : [...filled, file9];
77241
77411
  }
77242
77412
  function openCommand(run3) {
77243
77413
  const progId = regValue(run3("reg", ["query", USER_CHOICE, "/v", "ProgId"]));
@@ -77255,16 +77425,16 @@ function windowsHttpHandler(deps) {
77255
77425
  }
77256
77426
  if (!found) return { kind: "none", why: "no default browser is set for http" };
77257
77427
  const { progId, exe, args } = found;
77258
- return { kind: "app", name: progId, command: (file10) => [exe, withFile(args, file10)] };
77428
+ return { kind: "app", name: progId, command: (file9) => [exe, withFile(args, file9)] };
77259
77429
  }
77260
77430
 
77261
77431
  // src/serve/browser/httpHandler.ts
77262
77432
  var DEFAULT_DEPS = {
77263
77433
  run: (cmd, args) => execFileSync(cmd, args, { encoding: "utf8", timeout: 5e3, stdio: ["ignore", "pipe", "ignore"] }),
77264
77434
  env: process.env,
77265
- readFile: (file10) => {
77435
+ readFile: (file9) => {
77266
77436
  try {
77267
- return readFileSync38(file10, "utf8");
77437
+ return readFileSync38(file9, "utf8");
77268
77438
  } catch {
77269
77439
  return void 0;
77270
77440
  }
@@ -77309,15 +77479,15 @@ function bare(o, why2) {
77309
77479
  function openSignedIn(o) {
77310
77480
  const browser = (o.handler ?? httpHandler)();
77311
77481
  if (browser.kind === "none") return bare(o, browser.why);
77312
- let file10;
77482
+ let file9;
77313
77483
  try {
77314
- file10 = writeSignInRedirect({ root: o.root, configDir: o.configDir, link: o.mint() });
77484
+ file9 = writeSignInRedirect({ root: o.root, configDir: o.configDir, link: o.mint() });
77315
77485
  } catch (e) {
77316
77486
  return bare(o, e.message);
77317
77487
  }
77318
- const [cmd, args] = browser.command(file10);
77488
+ const [cmd, args] = browser.command(file9);
77319
77489
  const failed = (e) => {
77320
- rmSync24(file10, { force: true });
77490
+ rmSync25(file9, { force: true });
77321
77491
  bare(o, `${browser.name} didn't start: ${e.message}`);
77322
77492
  };
77323
77493
  try {
@@ -77327,7 +77497,7 @@ function openSignedIn(o) {
77327
77497
  } catch (e) {
77328
77498
  failed(e);
77329
77499
  }
77330
- return { kind: "sign-in-page", file: file10, browser: browser.name };
77500
+ return { kind: "sign-in-page", file: file9, browser: browser.name };
77331
77501
  }
77332
77502
 
77333
77503
  // src/serve/pairLink.ts
@@ -77423,7 +77593,7 @@ ${footer}
77423
77593
  function printGreeting() {
77424
77594
  process.stdout.write(
77425
77595
  greeting({
77426
- version: "0.61.0",
77596
+ version: "0.64.1",
77427
77597
  tagline: BRAND.tagline,
77428
77598
  isTTY: !!process.stdout.isTTY,
77429
77599
  columns: process.stdout.columns ?? 80,
@@ -77755,7 +77925,7 @@ function statusOf2(ctx) {
77755
77925
  }
77756
77926
 
77757
77927
  // ../connector-slack/src/service/slackJournal.ts
77758
- var TRAIL_LEAD8 = "trail lead";
77928
+ var TRAIL_LEAD9 = "trail lead";
77759
77929
  function journalSlack(ctx, e) {
77760
77930
  const { who, by } = e;
77761
77931
  try {
@@ -77768,7 +77938,7 @@ function journalSlack(ctx, e) {
77768
77938
  ...who ? { user: who.id } : {},
77769
77939
  ...who?.name ? { name: who.name } : {},
77770
77940
  ...who?.via ? { via: who.via } : {},
77771
- actor: by === "lead" ? TRAIL_LEAD8 : BRAND.slug,
77941
+ actor: by === "lead" ? TRAIL_LEAD9 : BRAND.slug,
77772
77942
  actorKind: by === "lead" ? "trail lead" : "engine"
77773
77943
  });
77774
77944
  } catch {
@@ -78773,9 +78943,9 @@ async function decisionForm(ctx, adapter, target2, o) {
78773
78943
  const candidates = snap.tickets.filter((t) => t.state === "open");
78774
78944
  const risky = /* @__PURE__ */ new Set();
78775
78945
  for (const t of candidates) if (await ticketNeedsLookout(ctx.o.root, mapId, t.id)) risky.add(t.id);
78776
- const safe17 = { ...snap, tickets: snap.tickets.filter((t) => !risky.has(t.id)) };
78777
- const related = relatedTicket(safe17, docs, o.related);
78778
- const tickets2 = safe17.tickets.filter((t) => isDecisionTicket(t) || t.id === related?.id);
78946
+ const safe18 = { ...snap, tickets: snap.tickets.filter((t) => !risky.has(t.id)) };
78947
+ const related = relatedTicket(safe18, docs, o.related);
78948
+ const tickets2 = safe18.tickets.filter((t) => isDecisionTicket(t) || t.id === related?.id);
78779
78949
  return {
78780
78950
  trails: maps.map((m) => ({ id: m.id, label: `${m.key} ${m.title}` })),
78781
78951
  mapId,
@@ -79953,11 +80123,11 @@ import { readFileSync as readFileSync40 } from "node:fs";
79953
80123
  import path143 from "node:path";
79954
80124
  var FILE13 = ".agents/slack-settings.json";
79955
80125
  function settingStore(root) {
79956
- const file10 = path143.join(root, FILE13);
80126
+ const file9 = path143.join(root, FILE13);
79957
80127
  return {
79958
80128
  read: () => {
79959
80129
  try {
79960
- return JSON.parse(readFileSync40(file10, "utf8")).posted ?? {};
80130
+ return JSON.parse(readFileSync40(file9, "utf8")).posted ?? {};
79961
80131
  } catch {
79962
80132
  return {};
79963
80133
  }
@@ -79967,7 +80137,7 @@ function settingStore(root) {
79967
80137
  }
79968
80138
 
79969
80139
  // ../connector-slack/src/store.ts
79970
- import { readFileSync as readFileSync41, rmSync as rmSync25 } from "node:fs";
80140
+ import { readFileSync as readFileSync41, rmSync as rmSync26 } from "node:fs";
79971
80141
  import path144 from "node:path";
79972
80142
  var DEFAULTS = {
79973
80143
  enabled: false,
@@ -79977,19 +80147,19 @@ var DEFAULTS = {
79977
80147
  command: DEFAULT_COMMAND,
79978
80148
  channelTrail: {}
79979
80149
  };
79980
- function readJson3(file10) {
80150
+ function readJson3(file9) {
79981
80151
  try {
79982
- return JSON.parse(readFileSync41(file10, "utf8"));
80152
+ return JSON.parse(readFileSync41(file9, "utf8"));
79983
80153
  } catch {
79984
80154
  return {};
79985
80155
  }
79986
80156
  }
79987
80157
  var KEPT2 = ["enabled", "workspace", "bot", "appId", "owners", "allow", "notify", "command", "channelTrail"];
79988
80158
  function slackStore(dir4) {
79989
- const file10 = path144.join(dir4, "slack.json");
80159
+ const file9 = path144.join(dir4, "slack.json");
79990
80160
  const creds = credentialStore(dir4);
79991
80161
  const read4 = () => {
79992
- const c = readJson3(file10);
80162
+ const c = readJson3(file9);
79993
80163
  const kept = Object.fromEntries(KEPT2.filter((k) => c[k] !== void 0).map((k) => [k, c[k]]));
79994
80164
  return {
79995
80165
  ...DEFAULTS,
@@ -80002,14 +80172,14 @@ function slackStore(dir4) {
80002
80172
  };
80003
80173
  };
80004
80174
  return {
80005
- file: file10,
80175
+ file: file9,
80006
80176
  read: read4,
80007
80177
  write(c) {
80008
- writeJsonAtomic(file10, c);
80178
+ writeJsonAtomic(file9, c);
80009
80179
  },
80010
80180
  update(patch) {
80011
80181
  const next = { ...read4(), ...patch };
80012
- writeJsonAtomic(file10, next);
80182
+ writeJsonAtomic(file9, next);
80013
80183
  return next;
80014
80184
  },
80015
80185
  link() {
@@ -80031,7 +80201,7 @@ function slackStore(dir4) {
80031
80201
  const { slack: _gone, ...rest } = c;
80032
80202
  return rest;
80033
80203
  });
80034
- rmSync25(file10, { force: true });
80204
+ rmSync26(file9, { force: true });
80035
80205
  }
80036
80206
  };
80037
80207
  }
@@ -80045,9 +80215,9 @@ function alive3(pid) {
80045
80215
  }
80046
80216
  }
80047
80217
  function slackLock(dir4, owner) {
80048
- const file10 = path144.join(dir4, "slack.lock");
80218
+ const file9 = path144.join(dir4, "slack.lock");
80049
80219
  const current = () => {
80050
- const l = readJson3(file10);
80220
+ const l = readJson3(file9);
80051
80221
  return l.pid && alive3(l.pid) ? l : void 0;
80052
80222
  };
80053
80223
  return {
@@ -80055,7 +80225,7 @@ function slackLock(dir4, owner) {
80055
80225
  acquire(root) {
80056
80226
  const l = current();
80057
80227
  if (l && l.owner !== owner) return { ok: false, heldBy: l.root };
80058
- writeJsonAtomic(file10, { pid: process.pid, owner, root, at: Date.now() });
80228
+ writeJsonAtomic(file9, { pid: process.pid, owner, root, at: Date.now() });
80059
80229
  return { ok: true };
80060
80230
  },
80061
80231
  /** The tracker folder of another live process that holds the connection, if one does. */
@@ -80064,23 +80234,23 @@ function slackLock(dir4, owner) {
80064
80234
  return l && l.owner !== owner ? l.root : void 0;
80065
80235
  },
80066
80236
  release() {
80067
- if (current()?.owner === owner) rmSync25(file10, { force: true });
80237
+ if (current()?.owner === owner) rmSync26(file9, { force: true });
80068
80238
  }
80069
80239
  };
80070
80240
  }
80071
80241
  var ASKS_FILE = ".agents/slack.json";
80072
80242
  var APPROVALS_FILE = ".agents/slack-approvals.json";
80073
80243
  function askStore(root) {
80074
- const file10 = path144.join(root, ASKS_FILE);
80244
+ const file9 = path144.join(root, ASKS_FILE);
80075
80245
  return {
80076
- read: () => readJson3(file10).asks ?? {},
80246
+ read: () => readJson3(file9).asks ?? {},
80077
80247
  write: (asks) => writeLocalJson(root, ASKS_FILE, { asks })
80078
80248
  };
80079
80249
  }
80080
80250
  function approvalStore(root) {
80081
- const file10 = path144.join(root, APPROVALS_FILE);
80251
+ const file9 = path144.join(root, APPROVALS_FILE);
80082
80252
  return {
80083
- read: () => readJson3(file10).approvals ?? {},
80253
+ read: () => readJson3(file9).approvals ?? {},
80084
80254
  write: (approvals) => writeLocalJson(root, APPROVALS_FILE, { approvals })
80085
80255
  };
80086
80256
  }
@@ -80499,14 +80669,14 @@ function decoded(pathname) {
80499
80669
  }
80500
80670
  async function serveStatic(appDir, pathname, res) {
80501
80671
  let rel = decoded(pathname);
80502
- let file10 = path145.join(appDir, path145.normalize(rel));
80503
- if (!file10.startsWith(appDir + path145.sep) || !existsSync41(file10) || statSync17(file10).isDirectory()) {
80672
+ let file9 = path145.join(appDir, path145.normalize(rel));
80673
+ if (!file9.startsWith(appDir + path145.sep) || !existsSync41(file9) || statSync17(file9).isDirectory()) {
80504
80674
  rel = "/index.html";
80505
- file10 = path145.join(appDir, "index.html");
80675
+ file9 = path145.join(appDir, "index.html");
80506
80676
  }
80507
- res.setHeader("Content-Type", TYPES[path145.extname(file10)] ?? "application/octet-stream");
80677
+ res.setHeader("Content-Type", TYPES[path145.extname(file9)] ?? "application/octet-stream");
80508
80678
  res.setHeader("Cache-Control", rel.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache");
80509
- res.end(await fs12.readFile(file10));
80679
+ res.end(await fs12.readFile(file9));
80510
80680
  }
80511
80681
 
80512
80682
  // src/serve/lookoutHandler.ts
@@ -80553,7 +80723,7 @@ async function serveLookout(opts, slackSetup) {
80553
80723
  const root = path146.resolve(process.cwd(), opts.dir);
80554
80724
  const mcp = createMcpHttp({
80555
80725
  auth: tokenFileAuth(root),
80556
- open: remoteAgentOpener({ root, version: "0.61.0" }),
80726
+ open: remoteAgentOpener({ root, version: "0.64.1" }),
80557
80727
  thisMachineOnly: true
80558
80728
  });
80559
80729
  let hub;
@@ -80590,7 +80760,7 @@ async function serveLookout(opts, slackSetup) {
80590
80760
  const howToSignIn = opts.open ? "Your browser opens ready to sign in: one click, within a minute. For another browser, open this link" : "Open it to sign in the browser";
80591
80761
  process.stdout.write(
80592
80762
  `
80593
- ${BRAND.name} ${"0.61.0"} \xB7 ${BRAND.assistant.name} online
80763
+ ${BRAND.name} ${"0.64.1"} \xB7 ${BRAND.assistant.name} online
80594
80764
 
80595
80765
  Lookout ${url2}
80596
80766
  Sign in ${signInLink}
@@ -80609,7 +80779,7 @@ async function serveLookout(opts, slackSetup) {
80609
80779
  openSignedIn({ root: bridge.root, mint, fallback: `${url2}${next}` });
80610
80780
  }
80611
80781
  const unlock = writeLookoutLock(bridge.root, url2);
80612
- for (const w of await agentVersionWarnings(bridge.root, "0.61.0"))
80782
+ for (const w of await agentVersionWarnings(bridge.root, "0.64.1"))
80613
80783
  process.stdout.write(` Heads up ${w}
80614
80784
  `);
80615
80785
  const unlist = writeMcpEndpoint(bridge.root, {
@@ -80656,7 +80826,7 @@ async function mcpCommand(argv2) {
80656
80826
  agent: o.agent,
80657
80827
  leaseMinutes: o.leaseMinutes,
80658
80828
  noRegister: o.noRegister,
80659
- version: "0.61.0"
80829
+ version: "0.64.1"
80660
80830
  });
80661
80831
  }
80662
80832
  function sandboxFlagFits(o, target2) {
@@ -80701,7 +80871,7 @@ async function connectCommand(argv2) {
80701
80871
  protectConfig: !o.noProtectConfig
80702
80872
  });
80703
80873
  else {
80704
- const self = selfCommand({ version: "0.61.0", file: fileURLToPath2(import.meta.url) });
80874
+ const self = selfCommand({ version: "0.64.1", file: fileURLToPath2(import.meta.url) });
80705
80875
  const protect = !o.noProtectConfig;
80706
80876
  const sandbox = target2 === "claude" ? await askSandbox({ cwd: process.cwd(), flag: o.sandbox, protect }) : void 0;
80707
80877
  runConnect(target2, {
@@ -80716,7 +80886,7 @@ async function connectCommand(argv2) {
80716
80886
  process.stdout.write("\n");
80717
80887
  }
80718
80888
  async function main() {
80719
- setRunningVersion("0.61.0");
80889
+ setRunningVersion("0.64.1");
80720
80890
  const argv2 = process.argv.slice(2);
80721
80891
  if (argv2[0] === "mcp") return mcpCommand(argv2.slice(1));
80722
80892
  if (argv2[0] === "hook") {