teamtrail 0.61.2 → 0.64.2

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)
@@ -3362,8 +3362,8 @@ var require_utils = __commonJS({
3362
3362
  }
3363
3363
  return ind;
3364
3364
  }
3365
- function removeDotSegments(path148) {
3366
- let input2 = path148;
3365
+ function removeDotSegments(path149) {
3366
+ let input2 = path149;
3367
3367
  const output2 = [];
3368
3368
  let nextSlash = -1;
3369
3369
  let len = 0;
@@ -3437,11 +3437,11 @@ var require_utils = __commonJS({
3437
3437
  }
3438
3438
  return output2.join("");
3439
3439
  }
3440
- function removeDotSegmentsRelative(path148) {
3441
- if (path148 === "" || path148[0] === "/") {
3442
- return removeDotSegments(path148);
3440
+ function removeDotSegmentsRelative(path149) {
3441
+ if (path149 === "" || path149[0] === "/") {
3442
+ return removeDotSegments(path149);
3443
3443
  }
3444
- const segments = path148.split("/");
3444
+ const segments = path149.split("/");
3445
3445
  const last = segments.length - 1;
3446
3446
  const output2 = [];
3447
3447
  let trailingDirectory = false;
@@ -3804,8 +3804,8 @@ var require_schemes = __commonJS({
3804
3804
  }
3805
3805
  if (wsComponent.resourceName) {
3806
3806
  const queryIndex = wsComponent.resourceName.indexOf("?");
3807
- const path148 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3808
- wsComponent.path = path148 && path148 !== "/" ? path148 : void 0;
3807
+ const path149 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3808
+ wsComponent.path = path149 && path149 !== "/" ? path149 : void 0;
3809
3809
  wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3810
3810
  wsComponent.resourceName = void 0;
3811
3811
  }
@@ -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
  }
@@ -7356,7 +7356,7 @@ var require_dist = __commonJS({
7356
7356
  });
7357
7357
 
7358
7358
  // src/cli.ts
7359
- import path147 from "node:path";
7359
+ import path148 from "node:path";
7360
7360
  import { fileURLToPath as fileURLToPath2 } from "node:url";
7361
7361
 
7362
7362
  // ../core/src/model/brand.ts
@@ -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)
@@ -9934,8 +9966,8 @@ function applyCall(e, call, now2 = Date.now()) {
9934
9966
  }
9935
9967
  }
9936
9968
  var words = (s) => s.toLowerCase().match(/[a-z0-9][a-z0-9_-]{1,}/g) ?? [];
9937
- function globMatch(glob, path148) {
9938
- return wildcardMatch(glob, path148.replace(/^\.\//, ""), { segments: true });
9969
+ function globMatch(glob, path149) {
9970
+ return wildcardMatch(glob, path149.replace(/^\.\//, ""), { segments: true });
9939
9971
  }
9940
9972
  function searchKnowledge(entries2, q) {
9941
9973
  const terms = new Set(words(q.query ?? ""));
@@ -10211,10 +10243,10 @@ function serializePolicy(p) {
10211
10243
 
10212
10244
  // ../core/src/policy/repoPath.ts
10213
10245
  var DRIVE = /^[A-Za-z]:\//;
10214
- function insideRepo(path148, declared, repoRoot) {
10246
+ function insideRepo(path149, declared, repoRoot) {
10215
10247
  const spellings = [repoRoot ?? []].flat().map((r) => r.replace(/\\/g, "/").replace(/\/+$/, ""));
10216
- const root = spellings.find((r) => path148.startsWith(`${r}/`));
10217
- if (root) return path148.slice(root.length + 1);
10248
+ const root = spellings.find((r) => path149.startsWith(`${r}/`));
10249
+ if (root) return path149.slice(root.length + 1);
10218
10250
  throw new OperationError(`"${declared}" is an absolute path outside the repo: give paths relative to the repo root`);
10219
10251
  }
10220
10252
  function repoPath(declared, repoRoot) {
@@ -10239,9 +10271,9 @@ function repoPaths(declared, repoRoot) {
10239
10271
  }
10240
10272
 
10241
10273
  // ../core/src/policy/ruleMatches.ts
10242
- function ruleMatches(glob, path148, fold2 = false) {
10274
+ function ruleMatches(glob, path149, fold2 = false) {
10243
10275
  const g = glob.normalize("NFC");
10244
- const p = path148.normalize("NFC");
10276
+ const p = path149.normalize("NFC");
10245
10277
  return fold2 ? globMatch(g.toLowerCase(), p.toLowerCase()) : globMatch(g, p);
10246
10278
  }
10247
10279
 
@@ -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,
@@ -12749,7 +12781,7 @@ async function newDecisionFile(fs13, mapId, input2) {
12749
12781
 
12750
12782
  // ../core/src/adapters/markdown/paths.ts
12751
12783
  var DECISION_PATH = /^([^/]+)\/decisions\/([^/]+)\.md$/;
12752
- var trailSlug = (title, n) => title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 40) || `map-${n}`;
12784
+ var trailSlug = (title, n) => title.toLowerCase().replace(/[^a-z0-9]+/g, "-").slice(0, 40).replace(/^-+|-+$/g, "") || `map-${n}`;
12753
12785
  var SEGMENT = /^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;
12754
12786
  function segment(id) {
12755
12787
  if (typeof id !== "string" || id.length > 128 || !SEGMENT.test(id))
@@ -12770,19 +12802,19 @@ var ExternalChanges = class {
12770
12802
  /** Last seen text and supersededBy per decision file, to tell new records from supersessions and drop duplicate watcher hits. */
12771
12803
  seen = /* @__PURE__ */ new Map();
12772
12804
  pending = /* @__PURE__ */ new Map();
12773
- knows(path148) {
12774
- return this.seen.has(path148);
12805
+ knows(path149) {
12806
+ return this.seen.has(path149);
12775
12807
  }
12776
- remember(path148, text11, supersededBy) {
12777
- this.seen.set(path148, { text: text11, supersededBy });
12808
+ remember(path149, text11, supersededBy) {
12809
+ this.seen.set(path149, { text: text11, supersededBy });
12778
12810
  }
12779
- queue(path148) {
12780
- const mapId = path148.split("/")[0];
12811
+ queue(path149) {
12812
+ const mapId = path149.split("/")[0];
12781
12813
  const batch = this.pending.get(mapId) ?? {
12782
12814
  paths: /* @__PURE__ */ new Set(),
12783
12815
  timer: setTimeout(() => void this.flush(mapId), 250)
12784
12816
  };
12785
- batch.paths.add(path148);
12817
+ batch.paths.add(path149);
12786
12818
  this.pending.set(mapId, batch);
12787
12819
  }
12788
12820
  async flush(mapId) {
@@ -12899,6 +12931,42 @@ function serializeMapFile(m) {
12899
12931
  );
12900
12932
  }
12901
12933
 
12934
+ // ../core/src/adapters/markdown/newTrailFile.ts
12935
+ var NOT_TRAILS = /* @__PURE__ */ new Set(["briefs", "criteria", "knowledge", "guides", "proof-keys"]);
12936
+ var MAX_TRIES = 200;
12937
+ function taken(id, files) {
12938
+ if (NOT_TRAILS.has(id)) return true;
12939
+ return files.some((f) => f.startsWith(`${id}/`) || f === `briefs/${id}.md` || f === `criteria/${id}.md`);
12940
+ }
12941
+ var mapDoc = (id, n, input2) => ({
12942
+ id,
12943
+ key: `#${n}`,
12944
+ title: input2.title,
12945
+ mode: input2.mode ?? DEFAULT_MAP_MODE,
12946
+ ...input2.verification ? { verification: input2.verification } : {},
12947
+ sections: input2.sections,
12948
+ createdAt: Date.now(),
12949
+ updatedAt: Date.now()
12950
+ });
12951
+ async function newTrailFile(fs13, input2, writing) {
12952
+ const n = await nextNumber(fs13);
12953
+ const slug2 = trailSlug(input2.title, n);
12954
+ const files = await fs13.list();
12955
+ for (let i = 1; i <= MAX_TRIES; i++) {
12956
+ const id = i === 1 ? slug2 : `${slug2}-${i}`;
12957
+ if (taken(id, files)) continue;
12958
+ const map2 = mapDoc(id, n, input2);
12959
+ const path149 = `${id}/map.md`;
12960
+ writing(path149);
12961
+ if (!fs13.create) {
12962
+ await fs13.write(path149, serializeMapFile(map2));
12963
+ return map2;
12964
+ }
12965
+ if (await fs13.create(path149, serializeMapFile(map2))) return map2;
12966
+ }
12967
+ throw new Error(`could not find a free folder for the trail ${JSON.stringify(slug2)}`);
12968
+ }
12969
+
12902
12970
  // ../core/src/adapters/markdown/unreadDecision.ts
12903
12971
  function unreadDecision(file9, e) {
12904
12972
  if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${file9} can't be read: ${e.message}`);
@@ -12910,10 +12978,10 @@ var MarkdownAdapter = class {
12910
12978
  constructor(fs13, location = `./${BRAND.dataDir}`) {
12911
12979
  this.fs = fs13;
12912
12980
  this.location = location;
12913
- fs13.watch?.((path148) => {
12914
- const t = this.selfWrites.get(path148);
12981
+ fs13.watch?.((path149) => {
12982
+ const t = this.selfWrites.get(path149);
12915
12983
  if (t && Date.now() - t < 1500) return;
12916
- this.external.queue(path148);
12984
+ this.external.queue(path149);
12917
12985
  });
12918
12986
  }
12919
12987
  kind = "markdown";
@@ -12921,17 +12989,17 @@ var MarkdownAdapter = class {
12921
12989
  events = new Emitter();
12922
12990
  selfWrites = /* @__PURE__ */ new Map();
12923
12991
  external = new ExternalChanges(
12924
- (path148) => this.fs.read(path148),
12992
+ (path149) => this.fs.read(path149),
12925
12993
  (e) => this.events.emit(e)
12926
12994
  );
12927
12995
  /** `base`: the file as read before this change, so a write never undoes one made in between (signedWrite.ts). */
12928
- async put(path148, text11, base2) {
12929
- this.selfWrites.set(path148, Date.now());
12930
- await this.fs.write(path148, text11, base2 === void 0 ? void 0 : { base: base2 });
12996
+ async put(path149, text11, base2) {
12997
+ this.selfWrites.set(path149, Date.now());
12998
+ await this.fs.write(path149, text11, base2 === void 0 ? void 0 : { base: base2 });
12931
12999
  }
12932
13000
  /** A new numbered file under a number nobody else has (createNumbered.ts). */
12933
13001
  putNew(make) {
12934
- return createNumbered(this.fs, make, (path148) => this.selfWrites.set(path148, Date.now()));
13002
+ return createNumbered(this.fs, make, (path149) => this.selfWrites.set(path149, Date.now()));
12935
13003
  }
12936
13004
  async readMap(mapId) {
12937
13005
  return parseMapFile(mapId, await this.fs.read(`${segment(mapId)}/map.md`));
@@ -12953,20 +13021,8 @@ var MarkdownAdapter = class {
12953
13021
  return { map: map2, tickets: tickets2.sort((a, b) => a.createdAt - b.createdAt) };
12954
13022
  }
12955
13023
  async createMap(input2) {
12956
- const n = await nextNumber(this.fs);
12957
- const slug2 = trailSlug(input2.title, n);
12958
- const map2 = {
12959
- id: slug2,
12960
- key: `#${n}`,
12961
- title: input2.title,
12962
- mode: input2.mode ?? DEFAULT_MAP_MODE,
12963
- ...input2.verification ? { verification: input2.verification } : {},
12964
- sections: input2.sections,
12965
- createdAt: Date.now(),
12966
- updatedAt: Date.now()
12967
- };
12968
- await this.writeMap(map2);
12969
- this.events.emit({ kind: "map.created", mapId: slug2, at: Date.now() });
13024
+ const map2 = await newTrailFile(this.fs, input2, (path149) => this.selfWrites.set(path149, Date.now()));
13025
+ this.events.emit({ kind: "map.created", mapId: map2.id, at: Date.now() });
12970
13026
  return map2;
12971
13027
  }
12972
13028
  async editMap(mapId, edit, event) {
@@ -13064,11 +13120,11 @@ var MarkdownAdapter = class {
13064
13120
  return d;
13065
13121
  }
13066
13122
  async markSuperseded(mapId, decisionId, supersededBy) {
13067
- const path148 = `${segment(mapId)}/decisions/${segment(decisionId)}.md`;
13068
- const base2 = await this.fs.read(path148);
13123
+ const path149 = `${segment(mapId)}/decisions/${segment(decisionId)}.md`;
13124
+ const base2 = await this.fs.read(path149);
13069
13125
  const text11 = serializeDecision({ ...parseDecision(base2), mapId, supersededBy });
13070
- this.external.remember(path148, text11, supersededBy);
13071
- await this.put(path148, text11, base2);
13126
+ this.external.remember(path149, text11, supersededBy);
13127
+ await this.put(path149, text11, base2);
13072
13128
  this.events.emit({ kind: "decision.superseded", mapId, decisionId, supersededBy, at: Date.now() });
13073
13129
  }
13074
13130
  subscribe(listener) {
@@ -13619,6 +13675,17 @@ var SettingsLedger = class {
13619
13675
  }
13620
13676
  };
13621
13677
 
13678
+ // ../core/src/adapters/remote/mapBodyFits.ts
13679
+ function assertMapBodyFits(map2, o) {
13680
+ if (o.limit === void 0) return;
13681
+ const length = mapBody(map2).length;
13682
+ if (length <= o.limit) return;
13683
+ const n = (x) => x.toLocaleString("en-US");
13684
+ throw new OperationError(
13685
+ `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.`
13686
+ );
13687
+ }
13688
+
13622
13689
  // ../core/src/adapters/remote/sync/fingerprint.ts
13623
13690
  var roundtrip = (s) => parseMapBody(serializeMapBody(s));
13624
13691
  function fingerprint(e) {
@@ -14191,8 +14258,11 @@ var SyncedEdits = class extends SyncedWriter {
14191
14258
  // ../core/src/adapters/remote/sync/syncedAdapter.ts
14192
14259
  var MAX_DECISION = 999999999;
14193
14260
  var SyncedAdapter = class extends SyncedEdits {
14261
+ /** The most characters the tracker takes in an issue body; undefined: no limit Teamtrail knows of. */
14262
+ mapBodyLimit = void 0;
14194
14263
  lastDecision = 0;
14195
14264
  async createMap(input2) {
14265
+ assertMapBodyFits(input2, { limit: this.mapBodyLimit, tracker: this.label });
14196
14266
  let map2;
14197
14267
  try {
14198
14268
  map2 = await this.remoteCreateMap({
@@ -14229,7 +14299,11 @@ var SyncedAdapter = class extends SyncedEdits {
14229
14299
  await this.change(
14230
14300
  mapId,
14231
14301
  "trail sections",
14232
- (e) => ({ kind: "sections", sections: roundtrip({ ...e.snap.map.sections, ...patch }) }),
14302
+ (e) => {
14303
+ const sections = roundtrip({ ...e.snap.map.sections, ...patch });
14304
+ assertMapBodyFits({ ...e.snap.map, sections }, { limit: this.mapBodyLimit, tracker: this.label });
14305
+ return { kind: "sections", sections };
14306
+ },
14233
14307
  {
14234
14308
  kind: "map.updated",
14235
14309
  mapId,
@@ -14423,9 +14497,9 @@ var GitHubClient = class {
14423
14497
  return this.http.rate;
14424
14498
  }
14425
14499
  /** A REST call under `/repos/<owner>/<name>`. */
14426
- async repo(method, path148, body2, headers = {}) {
14500
+ async repo(method, path149, body2, headers = {}) {
14427
14501
  return this.http.send(
14428
- `${this.api}/repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.name)}${path148}`,
14502
+ `${this.api}/repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.name)}${path149}`,
14429
14503
  {
14430
14504
  method,
14431
14505
  headers: { ...restHeaders(this.o.token), ...body2 ? { "Content-Type": "application/json" } : {}, ...headers },
@@ -14469,8 +14543,8 @@ var GitHubPermissions = class {
14469
14543
  async lookUp(login) {
14470
14544
  const key = login.toLowerCase();
14471
14545
  try {
14472
- const path148 = `/collaborators/${encodeURIComponent(login)}/permission`;
14473
- const { body: body2 } = await this.gh.repo("GET", path148);
14546
+ const path149 = `/collaborators/${encodeURIComponent(login)}/permission`;
14547
+ const { body: body2 } = await this.gh.repo("GET", path149);
14474
14548
  const write2 = WRITE_ROLES.has(body2.role_name ?? "") || WRITE_ROLES.has(body2.permission ?? "");
14475
14549
  this.known.set(key, { at: this.now(), ttl: OK_MS, write: write2 });
14476
14550
  } catch (err) {
@@ -14680,6 +14754,8 @@ async function setIssueLabel(gh, issue3, name2, on) {
14680
14754
  var GitHubAdapter = class extends SyncedAdapter {
14681
14755
  kind = "github";
14682
14756
  label = "GitHub Issues";
14757
+ /** GitHub refuses an issue body over 65,536 characters. */
14758
+ mapBodyLimit = 65536;
14683
14759
  location;
14684
14760
  gh;
14685
14761
  /** Issue number → REST id (sub-issue and dependency endpoints take ids, not numbers). */
@@ -14790,8 +14866,8 @@ var GitHubAdapter = class extends SyncedAdapter {
14790
14866
  });
14791
14867
  }
14792
14868
  async remoteRemoveBlocking(_map2, blocker, blocked) {
14793
- const path148 = `/issues/${blocked.id}/dependencies/blocked_by/${await this.issueId(blocker.id)}`;
14794
- await this.gh.repo("DELETE", path148).catch((e) => {
14869
+ const path149 = `/issues/${blocked.id}/dependencies/blocked_by/${await this.issueId(blocker.id)}`;
14870
+ await this.gh.repo("DELETE", path149).catch((e) => {
14795
14871
  if (!(e instanceof TrackerError && e.code === "not_found")) throw e;
14796
14872
  });
14797
14873
  }
@@ -15500,8 +15576,8 @@ var CHECK_NAME_RE = /^[\w.-]+$/;
15500
15576
  function guideFields(yaml) {
15501
15577
  const findings = [];
15502
15578
  const v = yaml.value;
15503
- const lineOf = (path148) => yaml.lines[path148] ?? yaml.lines[path148.split(".")[0]] ?? 1;
15504
- const fail2 = (path148, message) => findings.push({ line: lineOf(path148), rule: "schema", level: "error", message });
15579
+ const lineOf = (path149) => yaml.lines[path149] ?? yaml.lines[path149.split(".")[0]] ?? 1;
15580
+ const fail2 = (path149, message) => findings.push({ line: lineOf(path149), rule: "schema", level: "error", message });
15505
15581
  for (const k of Object.keys(v)) {
15506
15582
  if (KEYS7.includes(k)) continue;
15507
15583
  if (FORBIDDEN.test(k))
@@ -15621,10 +15697,10 @@ function readMap(s, scope) {
15621
15697
  s.errors.push({ line: l.n, message: `"${key}" is not a key a guide can have` });
15622
15698
  continue;
15623
15699
  }
15624
- const path148 = scope.path ? `${scope.path}.${key}` : key;
15700
+ const path149 = scope.path ? `${scope.path}.${key}` : key;
15625
15701
  if (key in out) s.errors.push({ line: l.n, message: `"${key}" appears twice` });
15626
- s.at[path148] = l.n;
15627
- out[key] = readValue(s, { line: l, rest: l.text.slice(colon + 1).trim(), path: path148 });
15702
+ s.at[path149] = l.n;
15703
+ out[key] = readValue(s, { line: l, rest: l.text.slice(colon + 1).trim(), path: path149 });
15628
15704
  }
15629
15705
  return out;
15630
15706
  }
@@ -16840,16 +16916,16 @@ function personOf(value) {
16840
16916
  }
16841
16917
 
16842
16918
  // src/approve/approveCli.ts
16843
- import path113 from "node:path";
16919
+ import path114 from "node:path";
16844
16920
 
16845
16921
  // ../core/src/server/trackerBridge.ts
16846
- import path99 from "node:path";
16922
+ import path100 from "node:path";
16847
16923
 
16848
16924
  // ../core/src/adapters/markdown/nodeMarkdownFs.ts
16849
- import path16 from "node:path";
16925
+ import path17 from "node:path";
16850
16926
 
16851
16927
  // ../core/src/signedState/signedFs.ts
16852
- import path12 from "node:path";
16928
+ import path13 from "node:path";
16853
16929
 
16854
16930
  // ../core/src/signedState/cachedFields.ts
16855
16931
  import { readFileSync as readFileSync5, statSync as statSync5 } from "node:fs";
@@ -17960,29 +18036,11 @@ function removedTrails(root, files) {
17960
18036
 
17961
18037
  // ../core/src/signedState/signedWrite.ts
17962
18038
  import { readFileSync as readFileSync8 } from "node:fs";
17963
- import path11 from "node:path";
17964
-
17965
- // ../core/src/signedState/outsideMapText.ts
17966
- function keepOutsideMapText(input2) {
17967
- const { mapId, changed } = input2;
17968
- const written = parseMapFile(mapId, input2.written);
17969
- const raw = parseMapFile(mapId, input2.raw);
17970
- const rewritten = !changed.includes("destination") && destinationHash(raw) !== destinationHash(written);
17971
- const inRaw = new Set((raw.sections.assumptions ?? []).map((a) => a.id));
17972
- const deleted = (id) => !inRaw.has(id) && !changed.includes(`${ASSUMPTION_PREFIX}${id}`);
17973
- const assumptions = written.sections.assumptions ?? [];
17974
- const kept = assumptions.filter((a) => !deleted(a.id));
17975
- if (!rewritten && kept.length === assumptions.length) return input2.written;
17976
- const sections = { ...written.sections, assumptions: kept };
17977
- if (rewritten) sections.destination = raw.sections.destination;
17978
- return serializeMapFile({ ...written, sections });
17979
- }
18039
+ import path12 from "node:path";
17980
18040
 
17981
- // ../core/src/signedState/staleWrite.ts
17982
- function staleWrite(rel, fields2) {
17983
- const msg = `${rel} changed while this was being done (${fields2.join(", ")}): nothing was written. Read it again and redo the change.`;
17984
- return Object.assign(new Error(msg), { stale: true, status: 409 });
17985
- }
18041
+ // ../core/src/signedState/freeTrailFolder.ts
18042
+ import { existsSync as existsSync5, readdirSync as readdirSync3 } from "node:fs";
18043
+ import path11 from "node:path";
17986
18044
 
17987
18045
  // ../core/src/signedState/trackerFileWrite.ts
17988
18046
  import { randomBytes as randomBytes3 } from "node:crypto";
@@ -18059,10 +18117,49 @@ function removeTrackerFile(root, rel) {
18059
18117
  rmSync5(path10.join(dir4, path10.basename(rel)), { force: true });
18060
18118
  }
18061
18119
 
18120
+ // ../core/src/signedState/freeTrailFolder.ts
18121
+ function holdsFiles(dir4) {
18122
+ let entries2;
18123
+ try {
18124
+ entries2 = readdirSync3(dir4, { withFileTypes: true });
18125
+ } catch (e) {
18126
+ if (e.code === "ENOENT") return false;
18127
+ throw e;
18128
+ }
18129
+ return entries2.some((e) => !e.isDirectory() || holdsFiles(path11.join(dir4, e.name)));
18130
+ }
18131
+ function freeTrailFolder(root, mapId) {
18132
+ if (existsSync5(stateRecordFile(root, mapId))) return false;
18133
+ refuseLinks(root, mapId);
18134
+ return !holdsFiles(path11.join(root, mapId));
18135
+ }
18136
+
18137
+ // ../core/src/signedState/outsideMapText.ts
18138
+ function keepOutsideMapText(input2) {
18139
+ const { mapId, changed } = input2;
18140
+ const written = parseMapFile(mapId, input2.written);
18141
+ const raw = parseMapFile(mapId, input2.raw);
18142
+ const rewritten = !changed.includes("destination") && destinationHash(raw) !== destinationHash(written);
18143
+ const inRaw = new Set((raw.sections.assumptions ?? []).map((a) => a.id));
18144
+ const deleted = (id) => !inRaw.has(id) && !changed.includes(`${ASSUMPTION_PREFIX}${id}`);
18145
+ const assumptions = written.sections.assumptions ?? [];
18146
+ const kept = assumptions.filter((a) => !deleted(a.id));
18147
+ if (!rewritten && kept.length === assumptions.length) return input2.written;
18148
+ const sections = { ...written.sections, assumptions: kept };
18149
+ if (rewritten) sections.destination = raw.sections.destination;
18150
+ return serializeMapFile({ ...written, sections });
18151
+ }
18152
+
18153
+ // ../core/src/signedState/staleWrite.ts
18154
+ function staleWrite(rel, fields2) {
18155
+ const msg = `${rel} changed while this was being done (${fields2.join(", ")}): nothing was written. Read it again and redo the change.`;
18156
+ return Object.assign(new Error(msg), { stale: true, status: 409 });
18157
+ }
18158
+
18062
18159
  // ../core/src/signedState/signedWrite.ts
18063
18160
  function readIfThere(root, rel) {
18064
18161
  refuseLinks(root, rel);
18065
- const file9 = path11.join(root, rel);
18162
+ const file9 = path12.join(root, rel);
18066
18163
  if (oversizedFile(file9)) return void 0;
18067
18164
  try {
18068
18165
  return readFileSync8(file9, "utf8");
@@ -18120,6 +18217,7 @@ function signedWrite(w, mode = {}) {
18120
18217
  return withStateLock(root, item2.mapId, () => {
18121
18218
  const raw = readIfThere(root, item2.rel);
18122
18219
  if (mode.create && raw !== void 0) return false;
18220
+ if (mode.create && item2.kind === "map" && !freeTrailFolder(root, item2.mapId)) return false;
18123
18221
  const entries2 = entriesToChange(root, item2.mapId);
18124
18222
  const was = entries2[item2.key];
18125
18223
  const { written, fields: fields2 } = plan(w, mode.create ? void 0 : raw, mode.create ? void 0 : was);
@@ -18131,7 +18229,7 @@ function signedWrite(w, mode = {}) {
18131
18229
  }
18132
18230
 
18133
18231
  // ../core/src/signedState/writerDone.ts
18134
- import { existsSync as existsSync5 } from "node:fs";
18232
+ import { existsSync as existsSync6 } from "node:fs";
18135
18233
  var WAIT_MS3 = 3e3;
18136
18234
  var POLL_MS = 10;
18137
18235
  async function writerDone(root, mapId) {
@@ -18142,13 +18240,13 @@ async function writerDone(root, mapId) {
18142
18240
  return;
18143
18241
  }
18144
18242
  const until = Date.now() + WAIT_MS3;
18145
- while (existsSync5(lock) && Date.now() < until) await new Promise((done2) => setTimeout(done2, POLL_MS));
18243
+ while (existsSync6(lock) && Date.now() < until) await new Promise((done2) => setTimeout(done2, POLL_MS));
18146
18244
  }
18147
18245
 
18148
18246
  // ../core/src/signedState/signedFs.ts
18149
18247
  var notFound = (p) => Object.assign(new Error(`not found: ${p}`), { code: "ENOENT" });
18150
18248
  async function readRaw(root, inner, p) {
18151
- if (oversizedFile(path12.join(root, p))) return void 0;
18249
+ if (oversizedFile(path13.join(root, p))) return void 0;
18152
18250
  try {
18153
18251
  return await inner.read(p);
18154
18252
  } catch (e) {
@@ -18191,29 +18289,29 @@ function signedFs(root, inner, by) {
18191
18289
  // ../core/src/adapters/markdown/rawMarkdownFs.ts
18192
18290
  import { mkdirSync as mkdirSync8 } from "node:fs";
18193
18291
  import fs from "node:fs/promises";
18194
- import path15 from "node:path";
18292
+ import path16 from "node:path";
18195
18293
 
18196
18294
  // ../core/src/lib/watchTree.ts
18197
18295
  import { watch as watch2 } from "node:fs";
18198
- import path14 from "node:path";
18296
+ import path15 from "node:path";
18199
18297
 
18200
18298
  // ../core/src/lib/watchFolders.ts
18201
- import { lstatSync as lstatSync3, readdirSync as readdirSync3, watch } from "node:fs";
18202
- import path13 from "node:path";
18299
+ import { lstatSync as lstatSync3, readdirSync as readdirSync4, watch } from "node:fs";
18300
+ import path14 from "node:path";
18203
18301
  function watchFolders(root, onChange) {
18204
18302
  const watched = /* @__PURE__ */ new Map();
18205
18303
  let closed = false;
18206
- const relOf = (full) => path13.relative(root, full).split(path13.sep).join("/");
18304
+ const relOf = (full) => path14.relative(root, full).split(path14.sep).join("/");
18207
18305
  function unwatchUnder(dir4) {
18208
18306
  for (const [d, w] of watched) {
18209
- if (d !== dir4 && !d.startsWith(dir4 + path13.sep)) continue;
18307
+ if (d !== dir4 && !d.startsWith(dir4 + path14.sep)) continue;
18210
18308
  w.watcher.close();
18211
18309
  watched.delete(d);
18212
18310
  }
18213
18311
  }
18214
18312
  function entries2(dir4) {
18215
18313
  try {
18216
- return readdirSync3(dir4, { withFileTypes: true });
18314
+ return readdirSync4(dir4, { withFileTypes: true });
18217
18315
  } catch {
18218
18316
  return [];
18219
18317
  }
@@ -18222,14 +18320,14 @@ function watchFolders(root, onChange) {
18222
18320
  if (closed) return;
18223
18321
  let watcher;
18224
18322
  try {
18225
- watcher = watch(dir4, (_event, name2) => name2 && changed(path13.join(dir4, String(name2))));
18323
+ watcher = watch(dir4, (_event, name2) => name2 && changed(path14.join(dir4, String(name2))));
18226
18324
  } catch {
18227
18325
  return;
18228
18326
  }
18229
18327
  watcher.on("error", () => unwatchUnder(dir4));
18230
18328
  watched.set(dir4, { watcher, ino });
18231
18329
  for (const e of entries2(dir4)) {
18232
- const full = path13.join(dir4, e.name);
18330
+ const full = path14.join(dir4, e.name);
18233
18331
  if (announce) onChange(relOf(full));
18234
18332
  if (e.isDirectory()) folder2(full, announce);
18235
18333
  }
@@ -18260,26 +18358,26 @@ var NATIVE_RECURSIVE = /* @__PURE__ */ new Set(["darwin", "win32"]);
18260
18358
  function watchTree(root, onChange, opts = {}) {
18261
18359
  const native = opts.native ?? NATIVE_RECURSIVE.has(process.platform);
18262
18360
  if (!native) return watchFolders(root, onChange);
18263
- const w = watch2(root, { recursive: true }, (_e, f) => f && onChange(String(f).split(path14.sep).join("/")));
18361
+ const w = watch2(root, { recursive: true }, (_e, f) => f && onChange(String(f).split(path15.sep).join("/")));
18264
18362
  return () => w.close();
18265
18363
  }
18266
18364
 
18267
18365
  // ../core/src/adapters/markdown/rawMarkdownFs.ts
18268
18366
  function rawMarkdownFs(root) {
18269
- const abs = path15.resolve(root);
18367
+ const abs = path16.resolve(root);
18270
18368
  mkdirSync8(abs, { recursive: true });
18271
18369
  const safe18 = (p) => {
18272
- const full = path15.resolve(abs, p);
18273
- if (full !== abs && !full.startsWith(abs + path15.sep)) throw new Error("path escapes root");
18370
+ const full = path16.resolve(abs, p);
18371
+ if (full !== abs && !full.startsWith(abs + path16.sep)) throw new Error("path escapes root");
18274
18372
  return full;
18275
18373
  };
18276
18374
  async function walk(dir4) {
18277
18375
  const entries2 = await fs.readdir(dir4, { withFileTypes: true }).catch(() => []);
18278
18376
  const out = [];
18279
18377
  for (const e of entries2) {
18280
- const full = path15.join(dir4, e.name);
18378
+ const full = path16.join(dir4, e.name);
18281
18379
  if (e.isDirectory()) out.push(...await walk(full));
18282
- else if (e.name.endsWith(".md")) out.push(path15.relative(abs, full).split(path15.sep).join("/"));
18380
+ else if (e.name.endsWith(".md")) out.push(path16.relative(abs, full).split(path16.sep).join("/"));
18283
18381
  }
18284
18382
  return out;
18285
18383
  }
@@ -18287,11 +18385,11 @@ function rawMarkdownFs(root) {
18287
18385
  list: () => walk(abs),
18288
18386
  read: (p) => fs.readFile(safe18(p), "utf8"),
18289
18387
  async write(p, text11) {
18290
- await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18388
+ await fs.mkdir(path16.dirname(safe18(p)), { recursive: true });
18291
18389
  await fs.writeFile(safe18(p), text11);
18292
18390
  },
18293
18391
  async create(p, text11) {
18294
- await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18392
+ await fs.mkdir(path16.dirname(safe18(p)), { recursive: true });
18295
18393
  try {
18296
18394
  await fs.writeFile(safe18(p), text11, { flag: "wx" });
18297
18395
  return true;
@@ -18306,15 +18404,15 @@ function rawMarkdownFs(root) {
18306
18404
 
18307
18405
  // ../core/src/adapters/markdown/nodeMarkdownFs.ts
18308
18406
  function nodeMarkdownFs(root, opts = {}) {
18309
- const abs = path16.resolve(root);
18407
+ const abs = path17.resolve(root);
18310
18408
  const { by = "teamtrail" } = opts;
18311
18409
  return signedFs(abs, rawMarkdownFs(abs), typeof by === "function" ? by : () => by);
18312
18410
  }
18313
18411
 
18314
18412
  // ../core/src/verification/localRepoFiles.ts
18315
- import { existsSync as existsSync6, realpathSync as realpathSync3 } from "node:fs";
18413
+ import { existsSync as existsSync7, realpathSync as realpathSync3 } from "node:fs";
18316
18414
  import { readFile, realpath, stat } from "node:fs/promises";
18317
- import path17 from "node:path";
18415
+ import path18 from "node:path";
18318
18416
 
18319
18417
  // ../core/src/verification/repoPath.ts
18320
18418
  function repoPath2(...parts2) {
@@ -18336,9 +18434,9 @@ var MAX_SCREEN_BYTES = 1024 * 1024;
18336
18434
  async function inside(real7, rel) {
18337
18435
  const clean2 = repoPath2(rel);
18338
18436
  if (clean2 === void 0) return void 0;
18339
- const target2 = await realpath(path17.join(real7, clean2)).catch(() => void 0);
18437
+ const target2 = await realpath(path18.join(real7, clean2)).catch(() => void 0);
18340
18438
  if (!target2) return void 0;
18341
- return target2 === real7 || target2.startsWith(real7 + path17.sep) ? target2 : void 0;
18439
+ return target2 === real7 || target2.startsWith(real7 + path18.sep) ? target2 : void 0;
18342
18440
  }
18343
18441
  function localRepoFiles(repoRoot) {
18344
18442
  let real7;
@@ -18347,7 +18445,7 @@ function localRepoFiles(repoRoot) {
18347
18445
  } catch {
18348
18446
  return void 0;
18349
18447
  }
18350
- if (!existsSync6(path17.join(real7, ".git"))) return void 0;
18448
+ if (!existsSync7(path18.join(real7, ".git"))) return void 0;
18351
18449
  return {
18352
18450
  async read(rel) {
18353
18451
  const file9 = await inside(real7, rel);
@@ -18366,15 +18464,15 @@ function localRepoFiles(repoRoot) {
18366
18464
 
18367
18465
  // ../core/src/agents/agentDocs.ts
18368
18466
  import fs2 from "node:fs/promises";
18369
- import path21 from "node:path";
18467
+ import path22 from "node:path";
18370
18468
 
18371
18469
  // ../core/src/lib/ensureLocalDir.ts
18372
18470
  import { mkdirSync as mkdirSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
18373
- import path18 from "node:path";
18471
+ import path19 from "node:path";
18374
18472
  var RULE = "*\n";
18375
18473
  function ensureLocalDir(dir4) {
18376
18474
  mkdirSync9(dir4, { recursive: true });
18377
- const ignore = path18.join(dir4, ".gitignore");
18475
+ const ignore = path19.join(dir4, ".gitignore");
18378
18476
  let text11 = "";
18379
18477
  try {
18380
18478
  text11 = readFileSync9(ignore, "utf8");
@@ -18383,13 +18481,13 @@ function ensureLocalDir(dir4) {
18383
18481
  if (text11 !== RULE) writeFileSync6(ignore, RULE);
18384
18482
  }
18385
18483
  function writeLocalJson(root, rel, value) {
18386
- ensureLocalDir(path18.join(root, rel.split(/[\\/]/)[0]));
18387
- writeJsonAtomic(path18.join(root, rel), value);
18484
+ ensureLocalDir(path19.join(root, rel.split(/[\\/]/)[0]));
18485
+ writeJsonAtomic(path19.join(root, rel), value);
18388
18486
  }
18389
18487
 
18390
18488
  // ../core/src/verification/evidenceStore.ts
18391
- import { mkdirSync as mkdirSync10, readdirSync as readdirSync4, writeFileSync as writeFileSync7 } from "node:fs";
18392
- import path19 from "node:path";
18489
+ import { mkdirSync as mkdirSync10, readdirSync as readdirSync5, writeFileSync as writeFileSync7 } from "node:fs";
18490
+ import path20 from "node:path";
18393
18491
  var EVIDENCE_DIR = ".evidence";
18394
18492
  var safe3 = (s) => s.replace(/[^\w.-]/g, "_");
18395
18493
  var evidencePaths = {
@@ -18402,7 +18500,7 @@ var seq = (prefix) => new RegExp(`^${prefix}-(\\d+)\\.json$`);
18402
18500
  function numbered2(root, mapId, ticketId, prefix) {
18403
18501
  let names = [];
18404
18502
  try {
18405
- names = readdirSync4(path19.join(root, evidencePaths.ticket(mapId, ticketId)));
18503
+ names = readdirSync5(path20.join(root, evidencePaths.ticket(mapId, ticketId)));
18406
18504
  } catch {
18407
18505
  return [];
18408
18506
  }
@@ -18410,16 +18508,16 @@ function numbered2(root, mapId, ticketId, prefix) {
18410
18508
  return names.map((n) => Number(n.match(re)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
18411
18509
  }
18412
18510
  function writeOnce(root, rel, value) {
18413
- ensureLocalDir(path19.join(root, EVIDENCE_DIR));
18414
- mkdirSync10(path19.dirname(path19.join(root, rel)), { recursive: true });
18415
- writeFileSync7(path19.join(root, rel), JSON.stringify(value, null, 2), { flag: "wx" });
18511
+ ensureLocalDir(path20.join(root, EVIDENCE_DIR));
18512
+ mkdirSync10(path20.dirname(path20.join(root, rel)), { recursive: true });
18513
+ writeFileSync7(path20.join(root, rel), JSON.stringify(value, null, 2), { flag: "wx" });
18416
18514
  }
18417
18515
  var nextAttemptId = (root, mapId, ticketId) => `A-${(numbered2(root, mapId, ticketId, "A").at(-1) ?? 0) + 1}`;
18418
18516
  function writeAttempt(root, a) {
18419
18517
  writeOnce(root, evidencePaths.attempt(a.mapId, a.ticketId, a.id), a);
18420
18518
  }
18421
18519
  function readAttempt(root, mapId, ticketId, id) {
18422
- const a = readJsonFile(path19.join(root, evidencePaths.attempt(mapId, ticketId, id)));
18520
+ const a = readJsonFile(path20.join(root, evidencePaths.attempt(mapId, ticketId, id)));
18423
18521
  return a?.v === 1 ? a : void 0;
18424
18522
  }
18425
18523
  var readAttempts = (root, mapId, ticketId) => numbered2(root, mapId, ticketId, "A").map((n) => readAttempt(root, mapId, ticketId, `A-${n}`)).filter((a) => !!a);
@@ -18435,7 +18533,7 @@ function writeVerdict(root, v) {
18435
18533
  }
18436
18534
  }
18437
18535
  }
18438
- var readVerdicts = (root, mapId, ticketId) => numbered2(root, mapId, ticketId, "V").map((n) => readJsonFile(path19.join(root, evidencePaths.verdict(mapId, ticketId, `V-${n}`)))).filter((v) => v?.v === 1);
18536
+ var readVerdicts = (root, mapId, ticketId) => numbered2(root, mapId, ticketId, "V").map((n) => readJsonFile(path20.join(root, evidencePaths.verdict(mapId, ticketId, `V-${n}`)))).filter((v) => v?.v === 1);
18439
18537
 
18440
18538
  // ../core/src/policy/caseInsensitiveFs.ts
18441
18539
  import { statSync as statSync7 } from "node:fs";
@@ -18458,8 +18556,8 @@ function caseInsensitiveFs(dir4) {
18458
18556
  }
18459
18557
 
18460
18558
  // ../core/src/policy/policyStore.ts
18461
- import { existsSync as existsSync7, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
18462
- import path20 from "node:path";
18559
+ import { existsSync as existsSync8, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
18560
+ import path21 from "node:path";
18463
18561
 
18464
18562
  // ../core/src/policy/stricterPolicy.ts
18465
18563
  var rank3 = (l) => RISK_LEVELS.indexOf(l);
@@ -18485,10 +18583,10 @@ function stricterPolicy(file9, approved) {
18485
18583
 
18486
18584
  // ../core/src/policy/policyStore.ts
18487
18585
  var POLICY_FILE = "policy.json";
18488
- var policyPath = (root) => path20.join(root, POLICY_FILE);
18586
+ var policyPath = (root) => path21.join(root, POLICY_FILE);
18489
18587
  function readPolicyFile(root) {
18490
18588
  const f = policyPath(root);
18491
- if (!existsSync7(f)) return { policy: DEFAULT_POLICY, errors: [], defaults: true };
18589
+ if (!existsSync8(f)) return { policy: DEFAULT_POLICY, errors: [], defaults: true };
18492
18590
  const { policy, errors } = parsePolicy(readFileSync10(f, "utf8"));
18493
18591
  if (policy) return { policy, errors, defaults: false };
18494
18592
  return { policy: DEFAULT_POLICY, errors, defaults: true };
@@ -18581,12 +18679,12 @@ function checkAgentAnswer(root, a, q) {
18581
18679
  // ../core/src/agents/agentDocs.ts
18582
18680
  function readAgentDoc(root, rel) {
18583
18681
  if (!SESSION_DOC_PATH.test(rel)) return void 0;
18584
- const doc = readJsonFile(path21.join(root, rel));
18682
+ const doc = readJsonFile(path22.join(root, rel));
18585
18683
  if (!doc || doc.v !== 1 || !doc.session) return void 0;
18586
18684
  return processAlive(doc.pid) ? doc : markDisconnected(doc);
18587
18685
  }
18588
18686
  async function readAgentDocs(root, opts = {}) {
18589
- const dir4 = path21.join(root, agentPaths.sessions);
18687
+ const dir4 = path22.join(root, agentPaths.sessions);
18590
18688
  const names = await fs2.readdir(dir4).catch(() => []);
18591
18689
  const since2 = Date.now() - (opts.recentMs ?? 24 * 36e5);
18592
18690
  const docs = names.filter((n) => n.endsWith(".json")).map((n) => readAgentDoc(root, `${agentPaths.sessions}/${n}`)).filter((d) => !!d && (d.session.status === "running" || d.updatedAt >= since2)).sort((a, b) => b.updatedAt - a.updatedAt);
@@ -18630,10 +18728,10 @@ function writeAgentAnswer(root, input2) {
18630
18728
 
18631
18729
  // ../core/src/guides/catalogsApproval.ts
18632
18730
  import { readFileSync as readFileSync11 } from "node:fs";
18633
- import path22 from "node:path";
18731
+ import path23 from "node:path";
18634
18732
  function fileText(root) {
18635
18733
  try {
18636
- return readFileSync11(path22.join(root, GUIDES_CONFIG_FILE), "utf8");
18734
+ return readFileSync11(path23.join(root, GUIDES_CONFIG_FILE), "utf8");
18637
18735
  } catch {
18638
18736
  return void 0;
18639
18737
  }
@@ -18696,8 +18794,8 @@ function readGuidesConfig(root) {
18696
18794
  }
18697
18795
 
18698
18796
  // ../core/src/guides/guideStore.ts
18699
- import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync12 } from "node:fs";
18700
- import path24 from "node:path";
18797
+ import { existsSync as existsSync9, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "node:fs";
18798
+ import path25 from "node:path";
18701
18799
 
18702
18800
  // ../core/src/guides/approvedLock.ts
18703
18801
  var FILE2 = "guides-approved.json";
@@ -18712,8 +18810,8 @@ var same3 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
18712
18810
  var lockChangedFor = (lock, approved, id) => !same3(lock.guides[id], approved.guides[id]);
18713
18811
 
18714
18812
  // ../core/src/guides/guideLock.ts
18715
- import path23 from "node:path";
18716
- var guideLockPath = (root) => path23.join(root, GUIDES_LOCK_FILE);
18813
+ import path24 from "node:path";
18814
+ var guideLockPath = (root) => path24.join(root, GUIDES_LOCK_FILE);
18717
18815
  var isEntry = (e) => !!e && typeof e === "object" && typeof e.sha256 === "string";
18718
18816
  function reviewOf(raw) {
18719
18817
  const r = raw;
@@ -18799,12 +18897,12 @@ var missingGuide = (id, lock) => ({
18799
18897
  });
18800
18898
 
18801
18899
  // ../core/src/guides/guideStore.ts
18802
- var guidesDir = (root) => path24.join(root, GUIDES_DIR);
18803
- var guideFilePath = (root, id) => path24.join(guidesDir(root), `${id}.md`);
18900
+ var guidesDir = (root) => path25.join(root, GUIDES_DIR);
18901
+ var guideFilePath = (root, id) => path25.join(guidesDir(root), `${id}.md`);
18804
18902
  function readGuideFiles(root) {
18805
18903
  const dir4 = guidesDir(root);
18806
- if (!existsSync8(dir4)) return [];
18807
- return readdirSync5(dir4).filter((n) => n.endsWith(".md")).map((n) => ({ id: n.slice(0, -3), text: readFileSync12(path24.join(dir4, n), "utf8") }));
18904
+ if (!existsSync9(dir4)) return [];
18905
+ return readdirSync6(dir4).filter((n) => n.endsWith(".md")).map((n) => ({ id: n.slice(0, -3), text: readFileSync12(path25.join(dir4, n), "utf8") }));
18808
18906
  }
18809
18907
  function listGuides(root) {
18810
18908
  const lock = readGuideLock(root);
@@ -18828,18 +18926,18 @@ function listGuides(root) {
18828
18926
 
18829
18927
  // ../core/src/history/journalFile.ts
18830
18928
  import { appendFileSync, readFileSync as readFileSync13 } from "node:fs";
18831
- import path25 from "node:path";
18929
+ import path26 from "node:path";
18832
18930
  var TRAIL_KINDS = /* @__PURE__ */ new Set(["transition", "reroute"]);
18833
18931
  var JOURNAL_DIR = ".events";
18834
18932
  var MAX_REASON = 500;
18835
18933
  var safe4 = (s) => s.replace(/[^\w.-]/g, "_");
18836
- var journalPath = (root, mapId) => path25.join(root, JOURNAL_DIR, `${safe4(mapId)}.jsonl`);
18934
+ var journalPath = (root, mapId) => path26.join(root, JOURNAL_DIR, `${safe4(mapId)}.jsonl`);
18837
18935
  function journalFile(root) {
18838
18936
  const raw = (mapId) => readEntries(root, mapId);
18839
18937
  const readAll2 = (mapId) => raw(mapId).filter((e) => TRAIL_KINDS.has(e.kind));
18840
18938
  return {
18841
18939
  append(entry) {
18842
- ensureLocalDir(path25.join(root, JOURNAL_DIR));
18940
+ ensureLocalDir(path26.join(root, JOURNAL_DIR));
18843
18941
  const line5 = { ...entry, ...entry.reason ? { reason: entry.reason.slice(0, MAX_REASON) } : {} };
18844
18942
  appendFileSync(journalPath(root, entry.mapId), JSON.stringify(line5) + "\n");
18845
18943
  },
@@ -19017,13 +19115,13 @@ async function handleAgents(root, req, res, url2) {
19017
19115
  }
19018
19116
 
19019
19117
  // ../core/src/attention/attentionStore.ts
19020
- import { existsSync as existsSync9, readFileSync as readFileSync14 } from "node:fs";
19021
- import path26 from "node:path";
19118
+ import { existsSync as existsSync10, readFileSync as readFileSync14 } from "node:fs";
19119
+ import path27 from "node:path";
19022
19120
  var STATE_DIR2 = ".attention";
19023
19121
  var STATE_FILE = "state.json";
19024
19122
  function readAttentionPolicy(root) {
19025
- const file9 = path26.join(root, ATTENTION_FILE);
19026
- if (!existsSync9(file9)) return { file: ATTENTION_FILE, exists: false, ...parseAttentionPolicy({ v: 1 }) };
19123
+ const file9 = path27.join(root, ATTENTION_FILE);
19124
+ if (!existsSync10(file9)) return { file: ATTENTION_FILE, exists: false, ...parseAttentionPolicy({ v: 1 }) };
19027
19125
  let raw;
19028
19126
  try {
19029
19127
  raw = parseJsonSafe(readFileSync14(file9, "utf8"));
@@ -19034,14 +19132,14 @@ function readAttentionPolicy(root) {
19034
19132
  return { file: ATTENTION_FILE, exists: true, ...parseAttentionPolicy(raw) };
19035
19133
  }
19036
19134
  function readAttentionPrefs(dir4 = configDir()) {
19037
- return parseAttentionPrefs(readJsonFile(path26.join(dir4, ATTENTION_FILE)) ?? {}).value;
19135
+ return parseAttentionPrefs(readJsonFile(path27.join(dir4, ATTENTION_FILE)) ?? {}).value;
19038
19136
  }
19039
19137
  function writeAttentionPrefs(raw, dir4 = configDir()) {
19040
19138
  const parsed3 = parseAttentionPrefs(raw);
19041
- if (!parsed3.errors.length) writeJsonAtomic(path26.join(dir4, ATTENTION_FILE), parsed3.value, { private: true });
19139
+ if (!parsed3.errors.length) writeJsonAtomic(path27.join(dir4, ATTENTION_FILE), parsed3.value, { private: true });
19042
19140
  return parsed3;
19043
19141
  }
19044
- var stateFile = (root) => path26.join(root, STATE_DIR2, STATE_FILE);
19142
+ var stateFile = (root) => path27.join(root, STATE_DIR2, STATE_FILE);
19045
19143
  function readAttentionState(root) {
19046
19144
  const s = readJsonFile(stateFile(root));
19047
19145
  if (s?.v !== 1) return EMPTY_ATTENTION_STATE;
@@ -19053,7 +19151,7 @@ function readAttentionState(root) {
19053
19151
  };
19054
19152
  }
19055
19153
  function writeAttentionState(root, s) {
19056
- ensureLocalDir(path26.join(root, STATE_DIR2));
19154
+ ensureLocalDir(path27.join(root, STATE_DIR2));
19057
19155
  writeJsonAtomic(stateFile(root), s);
19058
19156
  }
19059
19157
  function updateAttentionState(root, change3, now2 = Date.now()) {
@@ -19065,13 +19163,13 @@ function updateAttentionState(root, change3, now2 = Date.now()) {
19065
19163
  }
19066
19164
 
19067
19165
  // ../core/src/adapters/remote/legacyOutbox.ts
19068
- import { readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync7 } from "node:fs";
19069
- import path28 from "node:path";
19166
+ import { readdirSync as readdirSync8, readFileSync as readFileSync16, rmSync as rmSync7 } from "node:fs";
19167
+ import path29 from "node:path";
19070
19168
 
19071
19169
  // ../core/src/adapters/remote/outboxFile.ts
19072
19170
  import { createHash as createHash4 } from "node:crypto";
19073
- import { readFileSync as readFileSync15, readdirSync as readdirSync6, renameSync as renameSync7, rmSync as rmSync6 } from "node:fs";
19074
- import path27 from "node:path";
19171
+ import { readFileSync as readFileSync15, readdirSync as readdirSync7, renameSync as renameSync7, rmSync as rmSync6 } from "node:fs";
19172
+ import path28 from "node:path";
19075
19173
 
19076
19174
  // ../core/src/adapters/remote/legacyTargetKey.ts
19077
19175
  var legacyTargetKey = (key) => key.replace(/-[0-9a-f]{16}$/, "");
@@ -19103,7 +19201,7 @@ function isQueuedWrite(w) {
19103
19201
 
19104
19202
  // ../core/src/adapters/remote/outboxFile.ts
19105
19203
  var OUTBOX_DIR = ".outbox";
19106
- var outboxDir = (root, configDir2) => path27.join(machineStore(root, configDir2).dir, "outbox");
19204
+ var outboxDir = (root, configDir2) => path28.join(machineStore(root, configDir2).dir, "outbox");
19107
19205
  var isOutboxPath = (rel) => rel === OUTBOX_DIR || rel.startsWith(`${OUTBOX_DIR}/`) || rel.startsWith(`${OUTBOX_DIR}\\`);
19108
19206
  function outboxKey(kind2, ...target2) {
19109
19207
  const parts2 = [kind2, ...target2.filter(Boolean)];
@@ -19134,7 +19232,7 @@ function mine(dir4, key) {
19134
19232
  function orphans(dir4, key) {
19135
19233
  let names;
19136
19234
  try {
19137
- names = readdirSync6(dir4);
19235
+ names = readdirSync7(dir4);
19138
19236
  } catch {
19139
19237
  return [];
19140
19238
  }
@@ -19149,11 +19247,11 @@ function readWrites(file9) {
19149
19247
  }
19150
19248
  }
19151
19249
  function orphanedWrites(dir4, key) {
19152
- return mine(dir4, key).reduce((n, f) => n + readWrites(path27.join(dir4, f)).length, 0);
19250
+ return mine(dir4, key).reduce((n, f) => n + readWrites(path28.join(dir4, f)).length, 0);
19153
19251
  }
19154
19252
  function outboxFile(dir4, key) {
19155
19253
  const owner = `${process.pid}-${++instances}`;
19156
- const file9 = path27.join(dir4, `${key}.${owner}.json`);
19254
+ const file9 = path28.join(dir4, `${key}.${owner}.json`);
19157
19255
  let released = false;
19158
19256
  const save2 = (writes) => {
19159
19257
  if (released) return;
@@ -19166,9 +19264,9 @@ function outboxFile(dir4, key) {
19166
19264
  live.add(owner);
19167
19265
  const claimed = [];
19168
19266
  for (const [i, name2] of mine(dir4, key).entries()) {
19169
- const to = path27.join(dir4, `${key}.${owner}.claim-${i}.json`);
19267
+ const to = path28.join(dir4, `${key}.${owner}.claim-${i}.json`);
19170
19268
  try {
19171
- renameSync7(path27.join(dir4, name2), to);
19269
+ renameSync7(path28.join(dir4, name2), to);
19172
19270
  claimed.push(to);
19173
19271
  } catch {
19174
19272
  }
@@ -19198,10 +19296,10 @@ function readQueue(file9) {
19198
19296
  }
19199
19297
  }
19200
19298
  function legacyOutbox(root) {
19201
- const dir4 = path28.join(root, OUTBOX_DIR);
19299
+ const dir4 = path29.join(root, OUTBOX_DIR);
19202
19300
  const files = () => {
19203
19301
  try {
19204
- return readdirSync7(dir4).filter((n) => n.endsWith(".json"));
19302
+ return readdirSync8(dir4).filter((n) => n.endsWith(".json"));
19205
19303
  } catch {
19206
19304
  return [];
19207
19305
  }
@@ -19209,20 +19307,20 @@ function legacyOutbox(root) {
19209
19307
  return {
19210
19308
  list() {
19211
19309
  const names = files();
19212
- const writes = names.flatMap((n) => readQueue(path28.join(dir4, n)));
19310
+ const writes = names.flatMap((n) => readQueue(path29.join(dir4, n)));
19213
19311
  return { writes: writes.length, targets: [...new Set(names.map(targetOf))], labels: writes.map((w) => w.label) };
19214
19312
  },
19215
19313
  /** Moves every queue into `queueDir` (this machine's), where the tracker adapter for its target sends it. */
19216
19314
  send(queueDir) {
19217
19315
  files().forEach((n, i) => {
19218
- const writes = readQueue(path28.join(dir4, n));
19316
+ const writes = readQueue(path29.join(dir4, n));
19219
19317
  if (writes.length)
19220
- writePrivateFile(path28.join(queueDir, `${targetOf(n)}.legacy-${i}.json`), JSON.stringify({ v: 1, writes }));
19221
- rmSync7(path28.join(dir4, n), { force: true });
19318
+ writePrivateFile(path29.join(queueDir, `${targetOf(n)}.legacy-${i}.json`), JSON.stringify({ v: 1, writes }));
19319
+ rmSync7(path29.join(dir4, n), { force: true });
19222
19320
  });
19223
19321
  },
19224
19322
  discard() {
19225
- for (const n of files()) rmSync7(path28.join(dir4, n), { force: true });
19323
+ for (const n of files()) rmSync7(path29.join(dir4, n), { force: true });
19226
19324
  }
19227
19325
  };
19228
19326
  }
@@ -19243,19 +19341,19 @@ function connectedAgents(docs) {
19243
19341
  }
19244
19342
 
19245
19343
  // ../core/src/agents/leaseStore.ts
19246
- import { readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync8 } from "node:fs";
19247
- import path29 from "node:path";
19344
+ import { readdirSync as readdirSync9, renameSync as renameSync8, rmSync as rmSync8 } from "node:fs";
19345
+ import path30 from "node:path";
19248
19346
  var MAX_NOTES = 20;
19249
- var file = (root, mapId, ticketId) => path29.join(root, leasePaths.lease(mapId, ticketId));
19347
+ var file = (root, mapId, ticketId) => path30.join(root, leasePaths.lease(mapId, ticketId));
19250
19348
  function readLeases(root) {
19251
- const dir4 = path29.join(root, leasePaths.dir);
19349
+ const dir4 = path30.join(root, leasePaths.dir);
19252
19350
  let names = [];
19253
19351
  try {
19254
- names = readdirSync8(dir4).filter((n) => n.endsWith(".json"));
19352
+ names = readdirSync9(dir4).filter((n) => n.endsWith(".json"));
19255
19353
  } catch {
19256
19354
  return [];
19257
19355
  }
19258
- return names.map((n) => readJsonFile(path29.join(dir4, n))).filter((l) => l?.v === 1 && !!l.ticketId);
19356
+ return names.map((n) => readJsonFile(path30.join(dir4, n))).filter((l) => l?.v === 1 && !!l.ticketId);
19259
19357
  }
19260
19358
  function readLease(root, mapId, ticketId) {
19261
19359
  const l = readJsonFile(file(root, mapId, ticketId));
@@ -19292,9 +19390,9 @@ function takeLease(root, l) {
19292
19390
  } catch {
19293
19391
  return void 0;
19294
19392
  }
19295
- const taken = readJsonFile(to) ?? l;
19393
+ const taken2 = readJsonFile(to) ?? l;
19296
19394
  return {
19297
- lease: taken,
19395
+ lease: taken2,
19298
19396
  put(next) {
19299
19397
  writeLease(root, next);
19300
19398
  rmSync8(to, { force: true });
@@ -19307,11 +19405,11 @@ function takeLease(root, l) {
19307
19405
 
19308
19406
  // ../core/src/delivery/deliveryStore.ts
19309
19407
  import { readFileSync as readFileSync17 } from "node:fs";
19310
- import path30 from "node:path";
19311
- var FILE3 = path30.join(".agents", "delivery.json");
19408
+ import path31 from "node:path";
19409
+ var FILE3 = path31.join(".agents", "delivery.json");
19312
19410
  function readDeliveryProblems(root) {
19313
19411
  try {
19314
- const raw = JSON.parse(readFileSync17(path30.join(root, FILE3), "utf8"));
19412
+ const raw = JSON.parse(readFileSync17(path31.join(root, FILE3), "utf8"));
19315
19413
  return Object.values(raw.problems ?? {}).filter((p) => p && typeof p.channel === "string");
19316
19414
  } catch {
19317
19415
  return [];
@@ -19321,17 +19419,17 @@ function writeDeliveryProblem(root, channel, problem) {
19321
19419
  const problems = Object.fromEntries(readDeliveryProblems(root).map((p) => [p.channel, p]));
19322
19420
  if (problem) problems[channel] = problem;
19323
19421
  else delete problems[channel];
19324
- writeJsonAtomic(path30.join(root, FILE3), { v: 1, problems });
19422
+ writeJsonAtomic(path31.join(root, FILE3), { v: 1, problems });
19325
19423
  }
19326
19424
 
19327
19425
  // ../core/src/discovery/briefStore.ts
19328
- import { existsSync as existsSync10, mkdirSync as mkdirSync12, readdirSync as readdirSync9, readFileSync as readFileSync18, rmSync as rmSync9, writeFileSync as writeFileSync9 } from "node:fs";
19329
- import path31 from "node:path";
19426
+ import { existsSync as existsSync11, mkdirSync as mkdirSync12, readdirSync as readdirSync10, readFileSync as readFileSync18, rmSync as rmSync9, writeFileSync as writeFileSync9 } from "node:fs";
19427
+ import path32 from "node:path";
19330
19428
  var safe5 = (s) => s.replace(/[^\w.-]/g, "_");
19331
- var briefPath = (root, mapId) => path31.join(root, BRIEF_DIR, `${safe5(mapId)}.md`);
19429
+ var briefPath = (root, mapId) => path32.join(root, BRIEF_DIR, `${safe5(mapId)}.md`);
19332
19430
  function readBriefFile(root, mapId) {
19333
19431
  const file9 = briefPath(root, mapId);
19334
- if (!existsSync10(file9)) return void 0;
19432
+ if (!existsSync11(file9)) return void 0;
19335
19433
  try {
19336
19434
  const text11 = readFileSync18(file9, "utf8");
19337
19435
  return { brief: parseBrief(mapId, text11), text: text11 };
@@ -19348,13 +19446,13 @@ function readBrief(root, mapId) {
19348
19446
  }
19349
19447
  function briefIds(root) {
19350
19448
  try {
19351
- return readdirSync9(path31.join(root, BRIEF_DIR)).filter((n) => n.endsWith(".md")).map((n) => n.slice(0, -3));
19449
+ return readdirSync10(path32.join(root, BRIEF_DIR)).filter((n) => n.endsWith(".md")).map((n) => n.slice(0, -3));
19352
19450
  } catch {
19353
19451
  return [];
19354
19452
  }
19355
19453
  }
19356
19454
  function writeBrief(root, brief) {
19357
- mkdirSync12(path31.join(root, BRIEF_DIR), { recursive: true });
19455
+ mkdirSync12(path32.join(root, BRIEF_DIR), { recursive: true });
19358
19456
  writeFileSync9(briefPath(root, brief.mapId), serializeBrief(brief));
19359
19457
  }
19360
19458
  function approveBriefHere(root, mapId, by, text11) {
@@ -19363,7 +19461,7 @@ function approveBriefHere(root, mapId, by, text11) {
19363
19461
  }
19364
19462
  function writeBriefText(root, brief) {
19365
19463
  const text11 = serializeBrief(brief);
19366
- mkdirSync12(path31.join(root, BRIEF_DIR), { recursive: true });
19464
+ mkdirSync12(path32.join(root, BRIEF_DIR), { recursive: true });
19367
19465
  writeFileSync9(briefPath(root, brief.mapId), text11);
19368
19466
  return text11;
19369
19467
  }
@@ -19374,13 +19472,13 @@ function dropBrief(root, mapId) {
19374
19472
  }
19375
19473
 
19376
19474
  // ../core/src/evidence/syncStore.ts
19377
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync13, readdirSync as readdirSync10, rmSync as rmSync10 } from "node:fs";
19378
- import path32 from "node:path";
19475
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync13, readdirSync as readdirSync11, rmSync as rmSync10 } from "node:fs";
19476
+ import path33 from "node:path";
19379
19477
  var SYNC_FILE = "sync.json";
19380
19478
  var STATUS_FILE = "sync-status.json";
19381
19479
  var safe6 = (s) => s.replace(/[^\w.-]/g, "_");
19382
- var ticketFile = (root, mapId, ticketId) => path32.join(root, evidencePaths.ticket(mapId, ticketId), SYNC_FILE);
19383
- var ignored2 = (root, dir4) => ensureLocalDir(path32.join(root, dir4));
19480
+ var ticketFile = (root, mapId, ticketId) => path33.join(root, evidencePaths.ticket(mapId, ticketId), SYNC_FILE);
19481
+ var ignored2 = (root, dir4) => ensureLocalDir(path33.join(root, dir4));
19384
19482
  function readTicketSync(root, mapId, ticketId) {
19385
19483
  const s = readJsonFile(ticketFile(root, mapId, ticketId));
19386
19484
  return s?.v === 1 ? s : void 0;
@@ -19393,10 +19491,10 @@ function dropTicketSync(root, mapId, ticketId) {
19393
19491
  rmSync10(ticketFile(root, mapId, ticketId), { force: true });
19394
19492
  }
19395
19493
  function readTicketSyncs(root, mapId) {
19396
- const base2 = path32.join(root, EVIDENCE_DIR);
19494
+ const base2 = path33.join(root, EVIDENCE_DIR);
19397
19495
  const list8 = (dir4) => {
19398
19496
  try {
19399
- return readdirSync10(dir4, { withFileTypes: true }).filter((d) => d.isDirectory());
19497
+ return readdirSync11(dir4, { withFileTypes: true }).filter((d) => d.isDirectory());
19400
19498
  } catch {
19401
19499
  return [];
19402
19500
  }
@@ -19404,34 +19502,34 @@ function readTicketSyncs(root, mapId) {
19404
19502
  const maps = mapId === void 0 ? list8(base2).map((d) => d.name) : [safe6(mapId)];
19405
19503
  const out = [];
19406
19504
  for (const m of maps)
19407
- for (const t of list8(path32.join(base2, m))) {
19408
- const s = readJsonFile(path32.join(base2, m, t.name, SYNC_FILE));
19505
+ for (const t of list8(path33.join(base2, m))) {
19506
+ const s = readJsonFile(path33.join(base2, m, t.name, SYNC_FILE));
19409
19507
  if (s?.v === 1) out.push(s);
19410
19508
  }
19411
19509
  return out;
19412
19510
  }
19413
- var readSyncStatus = (root) => readJsonFile(path32.join(root, EVIDENCE_DIR, STATUS_FILE)) ?? { state: "off", reason: "not started" };
19511
+ var readSyncStatus = (root) => readJsonFile(path33.join(root, EVIDENCE_DIR, STATUS_FILE)) ?? { state: "off", reason: "not started" };
19414
19512
  function writeSyncStatus(root, s) {
19415
19513
  ignored2(root, EVIDENCE_DIR);
19416
- writeJsonAtomic(path32.join(root, EVIDENCE_DIR, STATUS_FILE), s);
19514
+ writeJsonAtomic(path33.join(root, EVIDENCE_DIR, STATUS_FILE), s);
19417
19515
  }
19418
19516
  function appendFlagEntry(root, e) {
19419
19517
  ignored2(root, JOURNAL_DIR);
19420
- const dir4 = path32.join(root, JOURNAL_DIR, "flags");
19518
+ const dir4 = path33.join(root, JOURNAL_DIR, "flags");
19421
19519
  mkdirSync13(dir4, { recursive: true });
19422
- appendFileSync2(path32.join(dir4, `${safe6(e.mapId)}.jsonl`), JSON.stringify({ ...e, text: e.text.slice(0, 300) }) + "\n");
19520
+ appendFileSync2(path33.join(dir4, `${safe6(e.mapId)}.jsonl`), JSON.stringify({ ...e, text: e.text.slice(0, 300) }) + "\n");
19423
19521
  }
19424
19522
 
19425
19523
  // ../core/src/knowledge/knowledgeStore.ts
19426
19524
  import { createHash as createHash5 } from "node:crypto";
19427
- import { existsSync as existsSync11, mkdirSync as mkdirSync14, readdirSync as readdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "node:fs";
19428
- import path33 from "node:path";
19429
- var dir2 = (root) => path33.join(root, KNOWLEDGE_DIR);
19525
+ import { existsSync as existsSync12, mkdirSync as mkdirSync14, readdirSync as readdirSync12, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "node:fs";
19526
+ import path34 from "node:path";
19527
+ var dir2 = (root) => path34.join(root, KNOWLEDGE_DIR);
19430
19528
  function listKnowledgeFiles(root) {
19431
- if (!existsSync11(dir2(root))) return [];
19432
- return readdirSync11(dir2(root)).filter((n) => /^K-\d+\.md$/.test(n)).map((n) => {
19529
+ if (!existsSync12(dir2(root))) return [];
19530
+ return readdirSync12(dir2(root)).filter((n) => /^K-\d+\.md$/.test(n)).map((n) => {
19433
19531
  try {
19434
- return parseKnowledge(n.slice(0, -3), readFileSync19(path33.join(dir2(root), n), "utf8"));
19532
+ return parseKnowledge(n.slice(0, -3), readFileSync19(path34.join(dir2(root), n), "utf8"));
19435
19533
  } catch {
19436
19534
  return void 0;
19437
19535
  }
@@ -19464,7 +19562,7 @@ function writeKnowledge(root, e) {
19464
19562
  mkdirSync14(dir2(root), { recursive: true });
19465
19563
  const { approval, ...entry } = e;
19466
19564
  const kept = approval ? { ...entry, status: approval.claimed } : entry;
19467
- writeFileSync10(path33.join(dir2(root), `${e.id}.md`), serializeKnowledge(kept));
19565
+ writeFileSync10(path34.join(dir2(root), `${e.id}.md`), serializeKnowledge(kept));
19468
19566
  }
19469
19567
  function createKnowledge(root, draft) {
19470
19568
  mkdirSync14(dir2(root), { recursive: true });
@@ -19472,7 +19570,7 @@ function createKnowledge(root, draft) {
19472
19570
  for (let n = first; n < first + 50; n++) {
19473
19571
  const entry = { ...draft, id: `K-${n}` };
19474
19572
  try {
19475
- writeFileSync10(path33.join(dir2(root), `${entry.id}.md`), serializeKnowledge(entry), { flag: "wx" });
19573
+ writeFileSync10(path34.join(dir2(root), `${entry.id}.md`), serializeKnowledge(entry), { flag: "wx" });
19476
19574
  return entry;
19477
19575
  } catch (e) {
19478
19576
  if (e.code !== "EEXIST") throw e;
@@ -19485,21 +19583,21 @@ function nextKnowledgeId(root) {
19485
19583
  return `K-${n + 1}`;
19486
19584
  }
19487
19585
  function blobHash(repo, file9) {
19488
- const top = path33.resolve(repo);
19489
- const abs = path33.resolve(top, file9);
19490
- if (!abs.startsWith(top + path33.sep) || !existsSync11(abs)) return void 0;
19586
+ const top = path34.resolve(repo);
19587
+ const abs = path34.resolve(top, file9);
19588
+ if (!abs.startsWith(top + path34.sep) || !existsSync12(abs)) return void 0;
19491
19589
  const content = readFileSync19(abs);
19492
19590
  return createHash5("sha1").update(`blob ${content.length}\0`).update(content).digest("hex");
19493
19591
  }
19494
19592
  function repoRootFor(root) {
19495
- for (let d = path33.resolve(root); ; d = path33.dirname(d)) {
19496
- if (existsSync11(path33.join(d, ".git"))) return d;
19497
- if (path33.dirname(d) === d) return path33.dirname(path33.resolve(root));
19593
+ for (let d = path34.resolve(root); ; d = path34.dirname(d)) {
19594
+ if (existsSync12(path34.join(d, ".git"))) return d;
19595
+ if (path34.dirname(d) === d) return path34.dirname(path34.resolve(root));
19498
19596
  }
19499
19597
  }
19500
19598
 
19501
19599
  // ../core/src/mainChecks/readMainChecks.ts
19502
- import path48 from "node:path";
19600
+ import path49 from "node:path";
19503
19601
 
19504
19602
  // ../core/src/discovery/discoveryGate.ts
19505
19603
  var discoverySkipped = (root, mapId) => !!trustLedger(root).get(trustKey.discoverySkipped(mapId));
@@ -19545,16 +19643,16 @@ async function defaultHead(repoRoot) {
19545
19643
 
19546
19644
  // ../core/src/verification/checksApproval.ts
19547
19645
  import { readFileSync as readFileSync21 } from "node:fs";
19548
- import path35 from "node:path";
19646
+ import path36 from "node:path";
19549
19647
 
19550
19648
  // ../core/src/verification/configFile.ts
19551
19649
  import { createHash as createHash6 } from "node:crypto";
19552
19650
  import { readFileSync as readFileSync20 } from "node:fs";
19553
- import path34 from "node:path";
19651
+ import path35 from "node:path";
19554
19652
  var VERIFICATION_FILE = "verification.json";
19555
19653
  var configHash = (text11) => `sha256:${createHash6("sha256").update(text11).digest("hex")}`;
19556
19654
  function readVerificationConfig(root) {
19557
- const file9 = path34.join(root, VERIFICATION_FILE);
19655
+ const file9 = path35.join(root, VERIFICATION_FILE);
19558
19656
  let text11;
19559
19657
  try {
19560
19658
  text11 = readFileSync20(file9, "utf8");
@@ -19568,7 +19666,7 @@ function readVerificationConfig(root) {
19568
19666
  var NO_FILE = "none";
19569
19667
  function fileText2(root) {
19570
19668
  try {
19571
- return readFileSync21(path35.join(root, VERIFICATION_FILE), "utf8");
19669
+ return readFileSync21(path36.join(root, VERIFICATION_FILE), "utf8");
19572
19670
  } catch {
19573
19671
  return void 0;
19574
19672
  }
@@ -19586,7 +19684,7 @@ function checksApproval(root) {
19586
19684
  return { state, waiting: state !== "approved" && state !== "none", text: text11, hash: hash2, approved };
19587
19685
  }
19588
19686
  function parsed2(root, text11) {
19589
- const file9 = path35.join(root, VERIFICATION_FILE);
19687
+ const file9 = path36.join(root, VERIFICATION_FILE);
19590
19688
  if (!text11) return { path: file9, exists: false, errors: [] };
19591
19689
  return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: contentHash(text11) };
19592
19690
  }
@@ -19659,7 +19757,7 @@ function updateMainChoices(root, mapId, change3) {
19659
19757
 
19660
19758
  // ../core/src/mainChecks/mainRunStore.ts
19661
19759
  import { closeSync as closeSync2, openSync as openSync2, rmSync as rmSync11, writeSync as writeSync2 } from "node:fs";
19662
- import path36 from "node:path";
19760
+ import path37 from "node:path";
19663
19761
  var MAIN_DIR = `${EVIDENCE_DIR}/_main`;
19664
19762
  var RUNNING2 = `${MAIN_DIR}/running.json`;
19665
19763
  var STUCK_MARGIN_MS = 5 * 6e4;
@@ -19669,7 +19767,7 @@ var mainPaths = {
19669
19767
  logs: (id) => `${MAIN_DIR}/runs/${safe7(id)}`
19670
19768
  };
19671
19769
  function readMainRun(root, id) {
19672
- const r = readJsonFile(path36.join(root, mainPaths.run(id)));
19770
+ const r = readJsonFile(path37.join(root, mainPaths.run(id)));
19673
19771
  return r?.v === 1 ? r : void 0;
19674
19772
  }
19675
19773
  function writeMainRun(root, run3) {
@@ -19677,7 +19775,7 @@ function writeMainRun(root, run3) {
19677
19775
  writeLocalJson(root, `${MAIN_DIR}/latest.json`, { id: run3.id });
19678
19776
  }
19679
19777
  function latestMainRun(root, budgetMs = 0) {
19680
- const id = readJsonFile(path36.join(root, MAIN_DIR, "latest.json"))?.id;
19778
+ const id = readJsonFile(path37.join(root, MAIN_DIR, "latest.json"))?.id;
19681
19779
  const run3 = typeof id === "string" ? readMainRun(root, id) : void 0;
19682
19780
  if (!run3 || run3.result !== "running") return run3;
19683
19781
  const alive4 = !!run3.pid && processAlive(run3.pid);
@@ -19685,9 +19783,9 @@ function latestMainRun(root, budgetMs = 0) {
19685
19783
  return alive4 && !stuck ? run3 : void 0;
19686
19784
  }
19687
19785
  function lockMainRun(root, id, budgetMs) {
19688
- ensureLocalDir(path36.join(root, EVIDENCE_DIR));
19689
- ensureLocalDir(path36.join(root, MAIN_DIR));
19690
- const file9 = path36.join(root, RUNNING2);
19786
+ ensureLocalDir(path37.join(root, EVIDENCE_DIR));
19787
+ ensureLocalDir(path37.join(root, MAIN_DIR));
19788
+ const file9 = path37.join(root, RUNNING2);
19691
19789
  for (let tries = 0; tries < 2; tries++) {
19692
19790
  try {
19693
19791
  const fd = openSync2(file9, "wx");
@@ -19706,7 +19804,7 @@ function lockMainRun(root, id, budgetMs) {
19706
19804
 
19707
19805
  // ../core/src/mainChecks/startMainRun.ts
19708
19806
  import { randomBytes as randomBytes4 } from "node:crypto";
19709
- import path47 from "node:path";
19807
+ import path48 from "node:path";
19710
19808
 
19711
19809
  // ../core/src/verification/redact.ts
19712
19810
  var SECRETS = [
@@ -19723,12 +19821,12 @@ function tailOf(text11, lines = 60, bytes2 = 4096) {
19723
19821
  }
19724
19822
 
19725
19823
  // ../core/src/mainChecks/runMainHere.ts
19726
- import path44 from "node:path";
19824
+ import path45 from "node:path";
19727
19825
 
19728
19826
  // ../core/src/verification/runCheck.ts
19729
19827
  import { spawn as spawn2 } from "node:child_process";
19730
19828
  import { mkdirSync as mkdirSync16, realpathSync as realpathSync4, writeFileSync as writeFileSync11 } from "node:fs";
19731
- import path37 from "node:path";
19829
+ import path38 from "node:path";
19732
19830
 
19733
19831
  // ../core/src/verification/checkEnv.ts
19734
19832
  var CHECK_ENV = `${BRAND.slug.toUpperCase()}_CHECK_ENV`;
@@ -19754,8 +19852,8 @@ var safe8 = (s) => s.replace(/[^\w.-]/g, "_");
19754
19852
  function confinedCwd(repoRoot, cwd = ".") {
19755
19853
  try {
19756
19854
  const root = realpathSync4(repoRoot);
19757
- const dir4 = realpathSync4(path37.resolve(root, cwd));
19758
- return dir4 === root || dir4.startsWith(root + path37.sep) ? dir4 : void 0;
19855
+ const dir4 = realpathSync4(path38.resolve(root, cwd));
19856
+ return dir4 === root || dir4.startsWith(root + path38.sep) ? dir4 : void 0;
19759
19857
  } catch {
19760
19858
  return void 0;
19761
19859
  }
@@ -19836,14 +19934,14 @@ function runCheck(name2, spec, run3) {
19836
19934
  if (exit?.code !== 0) text11 += withheldNote(withheld);
19837
19935
  try {
19838
19936
  mkdirSync16(run3.logDir, { recursive: true });
19839
- writeFileSync11(path37.join(run3.logDir, `${safe8(name2)}.log`), redact(text11));
19937
+ writeFileSync11(path38.join(run3.logDir, `${safe8(name2)}.log`), redact(text11));
19840
19938
  } catch {
19841
19939
  }
19842
19940
  const note = timedOut ? `
19843
19941
  [timed out after ${Math.round(timeoutMs / 1e3)} s]` : "";
19844
19942
  resolve2({
19845
19943
  ...base2,
19846
- cwd: path37.relative(realpathSync4(run3.repoRoot), cwd) || ".",
19944
+ cwd: path38.relative(realpathSync4(run3.repoRoot), cwd) || ".",
19847
19945
  exitCode: exit?.code ?? null,
19848
19946
  ...exit?.signal ? { signal: exit.signal } : {},
19849
19947
  timedOut,
@@ -19896,12 +19994,12 @@ async function runChecks(config4, names, run3) {
19896
19994
 
19897
19995
  // ../core/src/mainChecks/mainCheckResult.ts
19898
19996
  import { readFileSync as readFileSync22 } from "node:fs";
19899
- import path38 from "node:path";
19997
+ import path39 from "node:path";
19900
19998
  var MAX_LOG = 1048576;
19901
19999
  function outputOf(root, c) {
19902
20000
  if (!c.log) return c.tail;
19903
20001
  try {
19904
- const text11 = readFileSync22(path38.join(root, c.log), "utf8");
20002
+ const text11 = readFileSync22(path39.join(root, c.log), "utf8");
19905
20003
  return text11.length > MAX_LOG ? text11.slice(-MAX_LOG) : text11;
19906
20004
  } catch {
19907
20005
  return c.tail;
@@ -19924,34 +20022,34 @@ function mainCheckResult(root, c, folders) {
19924
20022
  }
19925
20023
 
19926
20024
  // ../core/src/mainChecks/mainWorktree.ts
19927
- import { existsSync as existsSync16, lstatSync as lstatSync5, symlinkSync, unlinkSync } from "node:fs";
19928
- import path43 from "node:path";
20025
+ import { existsSync as existsSync17, lstatSync as lstatSync5, symlinkSync, unlinkSync } from "node:fs";
20026
+ import path44 from "node:path";
19929
20027
 
19930
20028
  // ../core/src/workspaces/trustedWorkspace.ts
19931
- import { existsSync as existsSync13, mkdirSync as mkdirSync18, realpathSync as realpathSync5 } from "node:fs";
20029
+ import { existsSync as existsSync14, mkdirSync as mkdirSync18, realpathSync as realpathSync5 } from "node:fs";
19932
20030
 
19933
20031
  // ../core/src/workspaces/workspaceStore.ts
19934
- import { existsSync as existsSync12, mkdirSync as mkdirSync17, readdirSync as readdirSync12, readFileSync as readFileSync23, rmSync as rmSync12, writeFileSync as writeFileSync12 } from "node:fs";
19935
- import path39 from "node:path";
20032
+ import { existsSync as existsSync13, mkdirSync as mkdirSync17, readdirSync as readdirSync13, readFileSync as readFileSync23, rmSync as rmSync12, writeFileSync as writeFileSync12 } from "node:fs";
20033
+ import path40 from "node:path";
19936
20034
  var safe9 = (s) => s.replace(/[^\w.-]/g, "_");
19937
- var recordsDir = (root) => path39.join(root, AGENTS_DIR, "workspaces");
19938
- var recordFile = (root, mapId, ticketId) => path39.join(recordsDir(root), `${safe9(mapId)}--${safe9(ticketId)}.json`);
20035
+ var recordsDir = (root) => path40.join(root, AGENTS_DIR, "workspaces");
20036
+ var recordFile = (root, mapId, ticketId) => path40.join(recordsDir(root), `${safe9(mapId)}--${safe9(ticketId)}.json`);
19939
20037
  function readWorkspaceSettings(root) {
19940
- const file9 = path39.join(root, WORKSPACES_FILE);
19941
- if (!existsSync12(file9)) return { settings: DEFAULT_WORKSPACE_SETTINGS, errors: [], exists: false };
20038
+ const file9 = path40.join(root, WORKSPACES_FILE);
20039
+ if (!existsSync13(file9)) return { settings: DEFAULT_WORKSPACE_SETTINGS, errors: [], exists: false };
19942
20040
  const parsed3 = parseWorkspaceSettings(readFileSync23(file9, "utf8"));
19943
20041
  return { settings: parsed3.settings ?? DEFAULT_WORKSPACE_SETTINGS, errors: parsed3.errors, exists: true };
19944
20042
  }
19945
20043
  function writeWorkspaceSettings(root, s) {
19946
20044
  mkdirSync17(root, { recursive: true });
19947
- writeFileSync12(path39.join(root, WORKSPACES_FILE), serializeWorkspaceSettings(s));
20045
+ writeFileSync12(path40.join(root, WORKSPACES_FILE), serializeWorkspaceSettings(s));
19948
20046
  }
19949
20047
  function readWorkspace(root, mapId, ticketId) {
19950
20048
  const r = readJsonFile(recordFile(root, mapId, ticketId));
19951
20049
  return r?.v === 1 ? r : void 0;
19952
20050
  }
19953
20051
  function writeWorkspace(root, r) {
19954
- ensureLocalDir(path39.join(root, AGENTS_DIR));
20052
+ ensureLocalDir(path40.join(root, AGENTS_DIR));
19955
20053
  writeJsonAtomic(recordFile(root, r.mapId, r.ticketId), r);
19956
20054
  }
19957
20055
  function dropWorkspace(root, mapId, ticketId) {
@@ -19960,11 +20058,11 @@ function dropWorkspace(root, mapId, ticketId) {
19960
20058
  function listWorkspaces(root) {
19961
20059
  let names = [];
19962
20060
  try {
19963
- names = readdirSync12(recordsDir(root)).filter((n) => n.endsWith(".json"));
20061
+ names = readdirSync13(recordsDir(root)).filter((n) => n.endsWith(".json"));
19964
20062
  } catch {
19965
20063
  return [];
19966
20064
  }
19967
- return names.map((n) => readJsonFile(path39.join(recordsDir(root), n))).filter((r) => r?.v === 1 && existsSync12(r.path));
20065
+ return names.map((n) => readJsonFile(path40.join(recordsDir(root), n))).filter((r) => r?.v === 1 && existsSync13(r.path));
19968
20066
  }
19969
20067
 
19970
20068
  // ../core/src/workspaces/trustedWorkspace.ts
@@ -20001,7 +20099,7 @@ function preparedWorktree(root, mapId, ticketId) {
20001
20099
  }
20002
20100
  function trustedWorkspace(root, mapId, ticketId) {
20003
20101
  const ws = readWorkspace(root, mapId, ticketId);
20004
- if (!ws || !existsSync13(ws.path)) return void 0;
20102
+ if (!ws || !existsSync14(ws.path)) return void 0;
20005
20103
  let prepared;
20006
20104
  try {
20007
20105
  prepared = machineStore(root).read(FILE5)?.[keyOf4(mapId, ticketId)];
@@ -20012,12 +20110,12 @@ function trustedWorkspace(root, mapId, ticketId) {
20012
20110
  }
20013
20111
 
20014
20112
  // ../core/src/workspaces/worktreeDir.ts
20015
- import { existsSync as existsSync15, realpathSync as realpathSync7 } from "node:fs";
20016
- import path41 from "node:path";
20113
+ import { existsSync as existsSync16, realpathSync as realpathSync7 } from "node:fs";
20114
+ import path42 from "node:path";
20017
20115
 
20018
20116
  // ../core/src/workspaces/siblingProblem.ts
20019
- import { existsSync as existsSync14, readdirSync as readdirSync13, readFileSync as readFileSync24, realpathSync as realpathSync6, statSync as statSync8 } from "node:fs";
20020
- import path40 from "node:path";
20117
+ import { existsSync as existsSync15, readdirSync as readdirSync14, readFileSync as readFileSync24, realpathSync as realpathSync6, statSync as statSync8 } from "node:fs";
20118
+ import path41 from "node:path";
20021
20119
  var real2 = (p) => {
20022
20120
  try {
20023
20121
  return realpathSync6(p);
@@ -20026,62 +20124,62 @@ var real2 = (p) => {
20026
20124
  }
20027
20125
  };
20028
20126
  function commonGitDir(repo) {
20029
- const dotGit = path40.join(repo, ".git");
20030
- if (!existsSync14(dotGit) || statSync8(dotGit).isDirectory()) return real2(dotGit);
20127
+ const dotGit = path41.join(repo, ".git");
20128
+ if (!existsSync15(dotGit) || statSync8(dotGit).isDirectory()) return real2(dotGit);
20031
20129
  const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
20032
- const abs = real2(path40.resolve(repo, pointed));
20033
- const at2 = abs.lastIndexOf(`${path40.sep}worktrees${path40.sep}`);
20130
+ const abs = real2(path41.resolve(repo, pointed));
20131
+ const at2 = abs.lastIndexOf(`${path41.sep}worktrees${path41.sep}`);
20034
20132
  return at2 === -1 ? abs : abs.slice(0, at2);
20035
20133
  }
20036
20134
  function ownWorktree(folder2, gitDir) {
20037
- const dotGit = path40.join(folder2, ".git");
20038
- if (!existsSync14(dotGit) || statSync8(dotGit).isDirectory()) return false;
20135
+ const dotGit = path41.join(folder2, ".git");
20136
+ if (!existsSync15(dotGit) || statSync8(dotGit).isDirectory()) return false;
20039
20137
  const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
20040
- return real2(path40.resolve(folder2, pointed)).startsWith(`${gitDir}${path40.sep}worktrees${path40.sep}`);
20138
+ return real2(path41.resolve(folder2, pointed)).startsWith(`${gitDir}${path41.sep}worktrees${path41.sep}`);
20041
20139
  }
20042
20140
  function siblingProblem(o) {
20043
20141
  if (o.target === o.parent) return "is the folder your projects live in";
20044
- for (let at2 = o.target; at2 !== o.parent && at2.startsWith(o.parent); at2 = path40.dirname(at2))
20045
- if (existsSync14(path40.join(at2, ".git")) && at2 !== o.target) return "is inside another git repository";
20046
- if (!existsSync14(o.target)) return void 0;
20047
- if (existsSync14(path40.join(o.target, ".git"))) return "is another git repository";
20142
+ for (let at2 = o.target; at2 !== o.parent && at2.startsWith(o.parent); at2 = path41.dirname(at2))
20143
+ if (existsSync15(path41.join(at2, ".git")) && at2 !== o.target) return "is inside another git repository";
20144
+ if (!existsSync15(o.target)) return void 0;
20145
+ if (existsSync15(path41.join(o.target, ".git"))) return "is another git repository";
20048
20146
  const gitDir = commonGitDir(o.repo);
20049
- const strangers = readdirSync13(o.target).filter((n) => !ownWorktree(path40.join(o.target, n), gitDir));
20147
+ const strangers = readdirSync14(o.target).filter((n) => !ownWorktree(path41.join(o.target, n), gitDir));
20050
20148
  return strangers.length ? "already holds files that aren't this repo's worktrees" : void 0;
20051
20149
  }
20052
20150
 
20053
20151
  // ../core/src/workspaces/worktreeDir.ts
20054
20152
  function realish(p) {
20055
- if (existsSync15(p)) return realpathSync7(p);
20056
- const parent = path41.dirname(p);
20057
- return parent === p ? p : path41.join(realish(parent), path41.basename(p));
20153
+ if (existsSync16(p)) return realpathSync7(p);
20154
+ const parent = path42.dirname(p);
20155
+ return parent === p ? p : path42.join(realish(parent), path42.basename(p));
20058
20156
  }
20059
- var inside2 = (parent, p) => p === parent || p.startsWith(parent + path41.sep);
20157
+ var inside2 = (parent, p) => p === parent || p.startsWith(parent + path42.sep);
20060
20158
  function worktreeDir(top, dir4) {
20061
- if (dir4 === void 0) return { dir: path41.resolve(top, `../${path41.basename(top)}.teamtrail`) };
20159
+ if (dir4 === void 0) return { dir: path42.resolve(top, `../${path42.basename(top)}.teamtrail`) };
20062
20160
  const refused2 = (why2) => ({
20063
20161
  refused: `workspaces.json "dir" (${dir4}) ${why2}. Worktrees go next to the repo: use a folder like "../worktrees".`
20064
20162
  });
20065
20163
  const problem = dirProblem(dir4);
20066
20164
  if (problem) return refused2(problem);
20067
20165
  const repo = realish(top);
20068
- const parent = path41.dirname(repo);
20069
- const target2 = realish(path41.resolve(repo, dir4));
20166
+ const parent = path42.dirname(repo);
20167
+ const target2 = realish(path42.resolve(repo, dir4));
20070
20168
  if (!inside2(parent, target2) || parent === repo) return refused2("is outside the repo's parent folder");
20071
20169
  if (target2 === repo) return refused2("is the repo itself");
20072
20170
  if (inside2(repo, target2)) {
20073
- const first = path41.relative(repo, target2).split(path41.sep)[0];
20171
+ const first = path42.relative(repo, target2).split(path42.sep)[0];
20074
20172
  return first === ".git" ? refused2("is inside the repo's .git folder") : { dir: target2 };
20075
20173
  }
20076
- const hidden = path41.relative(parent, target2).split(path41.sep).some((part) => part.startsWith("."));
20174
+ const hidden = path42.relative(parent, target2).split(path42.sep).some((part) => part.startsWith("."));
20077
20175
  if (hidden) return refused2("is in a hidden folder");
20078
20176
  const sibling = siblingProblem({ repo, parent, target: target2 });
20079
20177
  return sibling ? refused2(sibling) : { dir: target2 };
20080
20178
  }
20081
20179
 
20082
20180
  // ../core/src/mainChecks/dependencyFolders.ts
20083
- import { lstatSync as lstatSync4, readdirSync as readdirSync14, realpathSync as realpathSync8 } from "node:fs";
20084
- import path42 from "node:path";
20181
+ import { lstatSync as lstatSync4, readdirSync as readdirSync15, realpathSync as realpathSync8 } from "node:fs";
20182
+ import path43 from "node:path";
20085
20183
  var DEPENDENCIES = /* @__PURE__ */ new Set(["node_modules", ".venv"]);
20086
20184
  var SKIP = /* @__PURE__ */ new Set([".git", ".teamtrail", "node_modules", ".venv", "dist", "build"]);
20087
20185
  var DEPTH = 4;
@@ -20089,15 +20187,15 @@ var MAX_FOLDERS = 20;
20089
20187
  var MAX_VISITS = 2e3;
20090
20188
  function entries(dir4) {
20091
20189
  try {
20092
- return readdirSync14(dir4).sort();
20190
+ return readdirSync15(dir4).sort();
20093
20191
  } catch {
20094
20192
  return [];
20095
20193
  }
20096
20194
  }
20097
20195
  function insideRepo2(top, realTop, rel) {
20098
20196
  try {
20099
- const real7 = realpathSync8(path42.join(top, rel));
20100
- return real7.startsWith(realTop + path42.sep);
20197
+ const real7 = realpathSync8(path43.join(top, rel));
20198
+ return real7.startsWith(realTop + path43.sep);
20101
20199
  } catch {
20102
20200
  return false;
20103
20201
  }
@@ -20116,12 +20214,12 @@ function dependencyFolders(top) {
20116
20214
  const queue = [{ rel: "", depth: 0 }];
20117
20215
  for (let visits = 0; queue.length && visits < MAX_VISITS && found.length < MAX_FOLDERS; visits++) {
20118
20216
  const { rel, depth } = queue.shift();
20119
- const names = entries(path42.join(top, rel));
20120
- const deps = names.filter((n) => DEPENDENCIES.has(n)).map((n) => path42.join(rel, n));
20217
+ const names = entries(path43.join(top, rel));
20218
+ const deps = names.filter((n) => DEPENDENCIES.has(n)).map((n) => path43.join(rel, n));
20121
20219
  found.push(...deps.filter((d) => insideRepo2(top, realTop, d)));
20122
20220
  if (depth >= DEPTH) continue;
20123
- const folders = names.filter((n) => !SKIP.has(n) && !n.startsWith(".") && isFolder(path42.join(top, rel, n)));
20124
- queue.push(...folders.map((n) => ({ rel: path42.join(rel, n), depth: depth + 1 })));
20221
+ const folders = names.filter((n) => !SKIP.has(n) && !n.startsWith(".") && isFolder(path43.join(top, rel, n)));
20222
+ queue.push(...folders.map((n) => ({ rel: path43.join(rel, n), depth: depth + 1 })));
20125
20223
  }
20126
20224
  return found.slice(0, MAX_FOLDERS);
20127
20225
  }
@@ -20131,10 +20229,10 @@ var MAIN_WORKTREE_KEY = "_main";
20131
20229
  function linkDependencies(top, wt) {
20132
20230
  const links = [];
20133
20231
  for (const rel of dependencyFolders(top)) {
20134
- const at2 = path43.join(wt, rel);
20135
- if (!existsSync16(path43.dirname(at2)) || lstatSync5(at2, { throwIfNoEntry: false })) continue;
20232
+ const at2 = path44.join(wt, rel);
20233
+ if (!existsSync17(path44.dirname(at2)) || lstatSync5(at2, { throwIfNoEntry: false })) continue;
20136
20234
  try {
20137
- symlinkSync(path43.join(top, rel), at2, "dir");
20235
+ symlinkSync(path44.join(top, rel), at2, "dir");
20138
20236
  links.push(at2);
20139
20237
  } catch {
20140
20238
  }
@@ -20144,8 +20242,8 @@ function linkDependencies(top, wt) {
20144
20242
  async function prepareMainWorktree(o) {
20145
20243
  const where2 = worktreeDir(o.top, readWorkspaceSettings(o.root).settings.dir);
20146
20244
  if ("refused" in where2) return { note: where2.refused };
20147
- const dir4 = path43.join(where2.dir, `_main-${o.commit.slice(0, 12)}-${o.id.slice(-6)}`);
20148
- if (existsSync16(dir4)) return { note: `${dir4} already exists` };
20245
+ const dir4 = path44.join(where2.dir, `_main-${o.commit.slice(0, 12)}-${o.id.slice(-6)}`);
20246
+ if (existsSync17(dir4)) return { note: `${dir4} already exists` };
20149
20247
  const r = await git(o.top, ["worktree", "add", "--detach", "--end-of-options", dir4, o.commit]);
20150
20248
  if (r.code !== 0) return { note: r.stderr.trim().split("\n")[0] || "git worktree add failed" };
20151
20249
  recordWorktree(o.root, { mapId: MAIN_WORKTREE_KEY, ticketId: o.id, path: dir4 });
@@ -20163,7 +20261,7 @@ async function sweepMainWorktrees(o) {
20163
20261
  const prefix = `${MAIN_WORKTREE_KEY}--`;
20164
20262
  for (const key of Object.keys(known4).filter((k) => k.startsWith(prefix))) {
20165
20263
  const dir4 = known4[key];
20166
- const links = dependencyFolders(o.top).map((rel) => path43.join(dir4, rel)).filter((p) => lstatSync5(p, { throwIfNoEntry: false })?.isSymbolicLink());
20264
+ const links = dependencyFolders(o.top).map((rel) => path44.join(dir4, rel)).filter((p) => lstatSync5(p, { throwIfNoEntry: false })?.isSymbolicLink());
20167
20265
  await removeMainWorktree({ ...o, id: key.slice(prefix.length), links });
20168
20266
  }
20169
20267
  }
@@ -20187,7 +20285,7 @@ async function runMainHere(o) {
20187
20285
  const rel = o.logRel ?? mainPaths.logs(o.id);
20188
20286
  const out = await runChecks(o.config, o.names, {
20189
20287
  repoRoot: wt.path,
20190
- logDir: path44.join(o.root, rel),
20288
+ logDir: path45.join(o.root, rel),
20191
20289
  logRel: rel,
20192
20290
  signal: o.signal
20193
20291
  });
@@ -20205,11 +20303,11 @@ async function runMainHere(o) {
20205
20303
  }
20206
20304
 
20207
20305
  // ../core/src/mainChecks/runMainOnRunner.ts
20208
- import path46 from "node:path";
20306
+ import path47 from "node:path";
20209
20307
 
20210
20308
  // ../core/src/verification/runnerReport.ts
20211
20309
  import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync13 } from "node:fs";
20212
- import path45 from "node:path";
20310
+ import path46 from "node:path";
20213
20311
 
20214
20312
  // ../core/src/evidence/noChangesFlag.ts
20215
20313
  var NO_CHANGES_EFFECT = { fail: "; completing needs a change", human: "; a human decides" };
@@ -20312,7 +20410,7 @@ function resultOf(asked, got, log) {
20312
20410
  const output2 = redact(raw.slice(-MAX_OUTPUT));
20313
20411
  const file9 = `${safe10(asked.name)}.log`;
20314
20412
  mkdirSync19(log.dir, { recursive: true });
20315
- writeFileSync13(path45.join(log.dir, file9), output2);
20413
+ writeFileSync13(path46.join(log.dir, file9), output2);
20316
20414
  const error63 = text(got.error, 300);
20317
20415
  return {
20318
20416
  name: asked.name,
@@ -20383,7 +20481,7 @@ async function runMainOnRunner(o) {
20383
20481
  runner,
20384
20482
  report: report3,
20385
20483
  asked,
20386
- log: { dir: path46.join(o.root, rel), rel },
20484
+ log: { dir: path47.join(o.root, rel), rel },
20387
20485
  config: o.config,
20388
20486
  ticketType: "research"
20389
20487
  });
@@ -20403,7 +20501,7 @@ async function runMainOnRunner(o) {
20403
20501
  // ../core/src/mainChecks/startMainRun.ts
20404
20502
  var newId = () => `M-${Date.now().toString(36)}-${randomBytes4(3).toString("hex")}`;
20405
20503
  function outcome(env, o) {
20406
- const repoRoot = env.repoRoot ?? path47.dirname(env.root);
20504
+ const repoRoot = env.repoRoot ?? path48.dirname(env.root);
20407
20505
  const job = { root: env.root, repoRoot, id: o.id, config: o.plan.config, names: o.plan.names, signal: env.signal };
20408
20506
  return env.checkRunner ? runMainOnRunner({ ...job, runner: env.checkRunner }) : runMainHere(job);
20409
20507
  }
@@ -20451,9 +20549,9 @@ function startMainRun(env, by) {
20451
20549
 
20452
20550
  // ../core/src/mainChecks/readMainChecks.ts
20453
20551
  var SEEN = `${MAIN_DIR}/trails.json`;
20454
- var seenRun = (root, mapId) => readJsonFile(path48.join(root, SEEN))?.[mapId];
20552
+ var seenRun = (root, mapId) => readJsonFile(path49.join(root, SEEN))?.[mapId];
20455
20553
  function markSeen(root, mapId, runId) {
20456
- const all = readJsonFile(path48.join(root, SEEN)) ?? {};
20554
+ const all = readJsonFile(path49.join(root, SEEN)) ?? {};
20457
20555
  if (all[mapId] !== runId) writeLocalJson(root, SEEN, { ...all, [mapId]: runId });
20458
20556
  }
20459
20557
  async function due(env, o) {
@@ -20461,7 +20559,7 @@ async function due(env, o) {
20461
20559
  if (!run3 || run3.configHash !== o.hash) return true;
20462
20560
  if (run3.result === "running" || seenRun(env.root, o.mapId)) return false;
20463
20561
  if (env.checkRunner) return false;
20464
- const head = await defaultHead(env.repoRoot ?? path48.dirname(env.root));
20562
+ const head = await defaultHead(env.repoRoot ?? path49.dirname(env.root));
20465
20563
  return "commit" in head && !!run3.commit && head.commit !== run3.commit;
20466
20564
  }
20467
20565
  async function triggered(env, o) {
@@ -20685,7 +20783,7 @@ function pendingTrackerMessage(t) {
20685
20783
  }
20686
20784
 
20687
20785
  // ../core/src/trailChecks/readTrailChecks.ts
20688
- import path51 from "node:path";
20786
+ import path52 from "node:path";
20689
20787
 
20690
20788
  // ../core/src/trailChecks/readTrailMerges.ts
20691
20789
  function readTrailMerges(root, snap) {
@@ -20700,7 +20798,7 @@ function readTrailMerges(root, snap) {
20700
20798
  import { randomBytes as randomBytes5 } from "node:crypto";
20701
20799
 
20702
20800
  // ../core/src/trailChecks/runTrailChecks.ts
20703
- import path50 from "node:path";
20801
+ import path51 from "node:path";
20704
20802
 
20705
20803
  // ../core/src/trailChecks/trailHead.ts
20706
20804
  async function contains(top, head, ancestor) {
@@ -20731,7 +20829,7 @@ async function trailHead(repoRoot, commits) {
20731
20829
  }
20732
20830
 
20733
20831
  // ../core/src/trailChecks/trailRunStore.ts
20734
- import path49 from "node:path";
20832
+ import path50 from "node:path";
20735
20833
  var TRAIL_DIR = "_trail";
20736
20834
  var safe11 = (s) => s.replace(/[^\w.-]/g, "_");
20737
20835
  var STUCK_MARGIN_MS2 = 5 * 6e4;
@@ -20742,7 +20840,7 @@ var trailPaths = {
20742
20840
  latest: (mapId) => `${dir3(mapId)}/latest.json`
20743
20841
  };
20744
20842
  function readTrailRun(root, mapId, id) {
20745
- const r = readJsonFile(path49.join(root, trailPaths.run(mapId, id)));
20843
+ const r = readJsonFile(path50.join(root, trailPaths.run(mapId, id)));
20746
20844
  return r?.v === 1 && r.mapId === mapId ? r : void 0;
20747
20845
  }
20748
20846
  function writeTrailRun(root, run3) {
@@ -20750,7 +20848,7 @@ function writeTrailRun(root, run3) {
20750
20848
  writeLocalJson(root, trailPaths.latest(run3.mapId), { id: run3.id });
20751
20849
  }
20752
20850
  function latestTrailRun(root, mapId, budgetMs = 0) {
20753
- const id = readJsonFile(path49.join(root, trailPaths.latest(mapId)))?.id;
20851
+ const id = readJsonFile(path50.join(root, trailPaths.latest(mapId)))?.id;
20754
20852
  const run3 = typeof id === "string" ? readTrailRun(root, mapId, id) : void 0;
20755
20853
  if (!run3 || run3.result !== "running") return run3;
20756
20854
  const alive4 = !!run3.pid && processAlive(run3.pid);
@@ -20764,7 +20862,7 @@ function latestTrailRun(root, mapId, budgetMs = 0) {
20764
20862
  var commitsOf = (merges) => merges.flatMap((m) => m.state === "merged" && m.commit ? [m.commit] : []);
20765
20863
  var marked = (merges, has2) => merges.map((m) => m.state === "merged" && m.commit ? { ...m, contained: has2(m.commit) } : m);
20766
20864
  async function here(env, o) {
20767
- const repoRoot = env.repoRoot ?? path50.dirname(env.root);
20865
+ const repoRoot = env.repoRoot ?? path51.dirname(env.root);
20768
20866
  const head = await trailHead(repoRoot, commitsOf(o.merges));
20769
20867
  if ("note" in head) {
20770
20868
  const none = { commit: null, branch: null, checks: [], result: "unavailable", note: head.note };
@@ -20780,7 +20878,7 @@ async function namedHead(repoRoot, commits) {
20780
20878
  return head;
20781
20879
  }
20782
20880
  async function onRunner(env, o) {
20783
- const repoRoot = env.repoRoot ?? path50.dirname(env.root);
20881
+ const repoRoot = env.repoRoot ?? path51.dirname(env.root);
20784
20882
  const known4 = await namedHead(repoRoot, commitsOf(o.merges));
20785
20883
  const found = await runMainOnRunner({
20786
20884
  root: env.root,
@@ -20887,7 +20985,7 @@ async function withReverts(root, snap, merges) {
20887
20985
  async function marked2(env, merges) {
20888
20986
  const commits = merges.flatMap((m) => m.state === "merged" && m.commit ? [m.commit] : []);
20889
20987
  if (env.checkRunner || !commits.length) return merges;
20890
- const head = await trailHead(env.repoRoot ?? path51.dirname(env.root), commits);
20988
+ const head = await trailHead(env.repoRoot ?? path52.dirname(env.root), commits);
20891
20989
  const has2 = (c) => !("note" in head) && head.contained.has(c);
20892
20990
  return merges.map((m) => m.state === "merged" && m.commit ? { ...m, contained: has2(m.commit) } : m);
20893
20991
  }
@@ -20912,28 +21010,28 @@ async function readTrailChecks(env, snap, o = {}) {
20912
21010
  }
20913
21011
 
20914
21012
  // ../core/src/signedState/outsideChanges.ts
20915
- import { readdirSync as readdirSync15 } from "node:fs";
20916
- import path52 from "node:path";
21013
+ import { readdirSync as readdirSync16 } from "node:fs";
21014
+ import path53 from "node:path";
20917
21015
  function listDir(dir4) {
20918
21016
  try {
20919
- return readdirSync15(dir4);
21017
+ return readdirSync16(dir4);
20920
21018
  } catch {
20921
21019
  return [];
20922
21020
  }
20923
21021
  }
20924
21022
  function trailFiles(root) {
20925
- const trails = listDir(root).filter((d) => !d.startsWith(".") && cachedText(path52.join(root, d, "map.md")));
21023
+ const trails = listDir(root).filter((d) => !d.startsWith(".") && cachedText(path53.join(root, d, "map.md")));
20926
21024
  return trails.flatMap((mapId) => [
20927
21025
  `${mapId}/map.md`,
20928
- ...listDir(path52.join(root, mapId, "tickets")).map((f) => `${mapId}/tickets/${f}`),
20929
- ...listDir(path52.join(root, mapId, "decisions")).map((f) => `${mapId}/decisions/${f}`)
21026
+ ...listDir(path53.join(root, mapId, "tickets")).map((f) => `${mapId}/tickets/${f}`),
21027
+ ...listDir(path53.join(root, mapId, "decisions")).map((f) => `${mapId}/decisions/${f}`)
20930
21028
  ]);
20931
21029
  }
20932
21030
  function judgeFile(root, item2, strict, out) {
20933
21031
  const record3 = readStateRecord(root, item2.mapId);
20934
21032
  const entry = record3.entries[item2.key];
20935
21033
  const unreadable2 = record3.problem ? { unreadable: true } : {};
20936
- const text11 = cachedText(path52.join(root, item2.rel));
21034
+ const text11 = cachedText(path53.join(root, item2.rel));
20937
21035
  if (isOversized(text11)) {
20938
21036
  out.changes.push({ ...item2, fields: ["oversized"], counts: entry?.f, signed: !!entry, ...unreadable2 });
20939
21037
  return;
@@ -20960,9 +21058,9 @@ function judgeFile(root, item2, strict, out) {
20960
21058
  }
20961
21059
  function removedTrail(root, mapId) {
20962
21060
  const entries2 = readStateRecord(root, mapId).entries;
20963
- const count2 = (kind2) => Object.keys(entries2).filter((k) => k.startsWith(`${kind2}:`)).length;
21061
+ const count3 = (kind2) => Object.keys(entries2).filter((k) => k.startsWith(`${kind2}:`)).length;
20964
21062
  const item2 = stateItemOf(`${mapId}/map.md`);
20965
- const trail2 = { tickets: count2("ticket"), decisions: count2("decision") };
21063
+ const trail2 = { tickets: count3("ticket"), decisions: count3("decision") };
20966
21064
  return { ...item2, fields: ["removed"], counts: entries2.map?.f, signed: true, trail: trail2 };
20967
21065
  }
20968
21066
  function outsideChanges(root) {
@@ -21230,8 +21328,8 @@ function checksDiff(approved, current) {
21230
21328
  }
21231
21329
 
21232
21330
  // ../core/src/verification/approvedLevel.ts
21233
- import { existsSync as existsSync17 } from "node:fs";
21234
- import path53 from "node:path";
21331
+ import { existsSync as existsSync18 } from "node:fs";
21332
+ import path54 from "node:path";
21235
21333
  var rank4 = (l) => VERIFICATION_LEVELS.indexOf(l);
21236
21334
  var recorded = (ledger, key) => levelOf(ledger[key]?.content);
21237
21335
  var recordedType = (ledger, mapId, t) => ledger[trustKey.type(mapId, t.id)]?.content ?? t.type;
@@ -21265,7 +21363,7 @@ function recordLevel(root, at2, level) {
21265
21363
  }
21266
21364
  function levelFile(root, mapId, ticketId) {
21267
21365
  const rel = ticketId ? `${mapId}/tickets/${ticketId}.md` : `${mapId}/map.md`;
21268
- return existsSync17(path53.join(root, rel)) ? rel : void 0;
21366
+ return existsSync18(path54.join(root, rel)) ? rel : void 0;
21269
21367
  }
21270
21368
 
21271
21369
  // ../core/src/verification/levelItems.ts
@@ -21356,8 +21454,8 @@ function catalogsItem(root) {
21356
21454
  }
21357
21455
 
21358
21456
  // ../core/src/trust/discoveryItems.ts
21359
- import { existsSync as existsSync18 } from "node:fs";
21360
- import path54 from "node:path";
21457
+ import { existsSync as existsSync19 } from "node:fs";
21458
+ import path55 from "node:path";
21361
21459
  function discoveryItems(root, ledger, snaps) {
21362
21460
  return snaps.flatMap((s) => {
21363
21461
  const mapId = s.map.id;
@@ -21377,7 +21475,7 @@ function discoveryItems(root, ledger, snaps) {
21377
21475
  lines: [line5],
21378
21476
  warnings: [],
21379
21477
  mapId,
21380
- ...existsSync18(path54.join(root, map2)) ? { file: map2 } : {},
21478
+ ...existsSync19(path55.join(root, map2)) ? { file: map2 } : {},
21381
21479
  // never adopted with others: an agent can commit a trail folder without a brief, or a brief's removal
21382
21480
  alone: true
21383
21481
  }
@@ -21386,13 +21484,13 @@ function discoveryItems(root, ledger, snaps) {
21386
21484
  }
21387
21485
 
21388
21486
  // ../core/src/criteria/criteriaStore.ts
21389
- import { existsSync as existsSync19, mkdirSync as mkdirSync20, readdirSync as readdirSync16, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "node:fs";
21390
- import path55 from "node:path";
21487
+ import { existsSync as existsSync20, mkdirSync as mkdirSync20, readdirSync as readdirSync17, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "node:fs";
21488
+ import path56 from "node:path";
21391
21489
  var safe12 = (s) => s.replace(/[^\w.-]/g, "_");
21392
- var file2 = (root, mapId) => path55.join(root, CRITERIA_DIR, `${safe12(mapId)}.md`);
21490
+ var file2 = (root, mapId) => path56.join(root, CRITERIA_DIR, `${safe12(mapId)}.md`);
21393
21491
  function readCriteriaFile(root, mapId) {
21394
21492
  const f = file2(root, mapId);
21395
- if (!existsSync19(f)) return [];
21493
+ if (!existsSync20(f)) return [];
21396
21494
  try {
21397
21495
  return parseCriteria(readFileSync25(f, "utf8"));
21398
21496
  } catch {
@@ -21417,7 +21515,7 @@ function readCriteria(root, mapId) {
21417
21515
  }
21418
21516
  function criteriaIds(root) {
21419
21517
  try {
21420
- return readdirSync16(path55.join(root, CRITERIA_DIR)).filter((n) => n.endsWith(".md")).map((n) => n.slice(0, -3));
21518
+ return readdirSync17(path56.join(root, CRITERIA_DIR)).filter((n) => n.endsWith(".md")).map((n) => n.slice(0, -3));
21421
21519
  } catch {
21422
21520
  return [];
21423
21521
  }
@@ -21438,7 +21536,7 @@ function writeTicketCriteria(root, map2, ticket2, patch) {
21438
21536
  criteria: prev?.criteria ?? [],
21439
21537
  confirmed: patch.confirmed || void 0
21440
21538
  };
21441
- mkdirSync20(path55.join(root, CRITERIA_DIR), { recursive: true });
21539
+ mkdirSync20(path56.join(root, CRITERIA_DIR), { recursive: true });
21442
21540
  writeFileSync14(file2(root, map2.id), serializeCriteria(map2.title, [...all, next]));
21443
21541
  return next;
21444
21542
  }
@@ -21534,7 +21632,7 @@ function pendingTrust(root, snaps = []) {
21534
21632
  }
21535
21633
 
21536
21634
  // ../core/src/verification/verifyCompletion.ts
21537
- import path66 from "node:path";
21635
+ import path67 from "node:path";
21538
21636
 
21539
21637
  // ../core/src/verification/recordGate.ts
21540
21638
  function recordGate(o) {
@@ -21576,11 +21674,11 @@ function applyGuard(graded, o) {
21576
21674
 
21577
21675
  // ../core/src/checkGuard/localGuard.ts
21578
21676
  import { realpathSync as realpathSync9 } from "node:fs";
21579
- import path57 from "node:path";
21677
+ import path58 from "node:path";
21580
21678
 
21581
21679
  // ../core/src/checkGuard/gitReaders.ts
21582
21680
  import { lstat } from "node:fs/promises";
21583
- import path56 from "node:path";
21681
+ import path57 from "node:path";
21584
21682
  var MAX_BYTES = 1024 * 1024;
21585
21683
  var unread = async () => void 0;
21586
21684
  async function commitReader(cwd, commit) {
@@ -21605,7 +21703,7 @@ function worktreeReader(toplevel) {
21605
21703
  if (text11 !== void 0) return text11;
21606
21704
  const clean2 = repoPath2(rel);
21607
21705
  if (!clean2) return void 0;
21608
- const there = await lstat(path56.join(toplevel, clean2)).catch(() => void 0);
21706
+ const there = await lstat(path57.join(toplevel, clean2)).catch(() => void 0);
21609
21707
  return there ? void 0 : null;
21610
21708
  };
21611
21709
  }
@@ -22137,19 +22235,19 @@ var TEST_PATTERNS = [
22137
22235
 
22138
22236
  // ../core/src/checkGuard/testFindings.ts
22139
22237
  var TEST_PATH = /(^|\/)(tests?|__tests__|specs?|e2e)\/|[._-](test|spec)s?\.[^/]+$|(^|\/)test_[^/]*\.py$|Tests?\.(java|kt)$|\.rs$/;
22140
- var count = (text11, r) => text11 && r ? (text11.match(r) ?? []).length : 0;
22238
+ var count2 = (text11, r) => text11 && r ? (text11.match(r) ?? []).length : 0;
22141
22239
  var tests = (n) => `${n} test${n === 1 ? "" : "s"}`;
22142
22240
  function weakened(file9, p, before, after) {
22143
- const had = count(before, p.test);
22241
+ const had = count2(before, p.test);
22144
22242
  if (after === null)
22145
22243
  return had ? [{ kind: "deleted-tests", file: file9, text: `${file9} deleted (${tests(had)})` }] : [];
22146
22244
  if (after === void 0) return [];
22147
22245
  const out = [];
22148
- const removed = had - count(after, p.test);
22246
+ const removed = had - count2(after, p.test);
22149
22247
  if (removed > 0) out.push({ kind: "removed-tests", file: file9, text: `${tests(removed)} removed from ${file9}` });
22150
- const skipped = count(after, p.skip) - count(before, p.skip);
22248
+ const skipped = count2(after, p.skip) - count2(before, p.skip);
22151
22249
  if (skipped > 0) out.push({ kind: "skipped", file: file9, text: `${tests(skipped)} skipped in ${file9}` });
22152
- const focused = count(after, p.focus) - count(before, p.focus);
22250
+ const focused = count2(after, p.focus) - count2(before, p.focus);
22153
22251
  if (focused > 0) out.push({ kind: "focused", file: file9, text: `${tests(focused)} focused with .only in ${file9}` });
22154
22252
  return out;
22155
22253
  }
@@ -22221,8 +22319,8 @@ var real3 = (p) => {
22221
22319
  }
22222
22320
  };
22223
22321
  function prefixOf(toplevel, checkout) {
22224
- const rel = path57.relative(real3(toplevel), real3(checkout)).split(path57.sep).join("/");
22225
- return rel.startsWith("..") || path57.isAbsolute(rel) ? "" : rel;
22322
+ const rel = path58.relative(real3(toplevel), real3(checkout)).split(path58.sep).join("/");
22323
+ return rel.startsWith("..") || path58.isAbsolute(rel) ? "" : rel;
22226
22324
  }
22227
22325
  function noBaseline(config4) {
22228
22326
  const mode = gateModeFor(config4, "check-guard");
@@ -22253,15 +22351,15 @@ async function withLocalGuard(graded, o) {
22253
22351
  }
22254
22352
 
22255
22353
  // ../core/src/evidence/collectEvidence.ts
22256
- import { existsSync as existsSync21 } from "node:fs";
22354
+ import { existsSync as existsSync22 } from "node:fs";
22257
22355
 
22258
22356
  // ../core/src/evidence/baselineStore.ts
22259
- import { linkSync as linkSync4, mkdirSync as mkdirSync21, readdirSync as readdirSync17, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
22260
- import path58 from "node:path";
22357
+ import { linkSync as linkSync4, mkdirSync as mkdirSync21, readdirSync as readdirSync18, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
22358
+ import path59 from "node:path";
22261
22359
  var DIR = "baselines";
22262
22360
  var RE = /^baseline-(\d+)\.json$/;
22263
22361
  var safe13 = (s) => s.replace(/[^\w-]/g, "_");
22264
- var folder = (root, mapId, ticketId) => path58.join(machineStore(root).dir, DIR, `${safe13(mapId)}--${safe13(ticketId)}`);
22362
+ var folder = (root, mapId, ticketId) => path59.join(machineStore(root).dir, DIR, `${safe13(mapId)}--${safe13(ticketId)}`);
22265
22363
  var macParts = (root, b) => [
22266
22364
  "baseline",
22267
22365
  machineId(root),
@@ -22271,7 +22369,7 @@ var macParts = (root, b) => [
22271
22369
  ];
22272
22370
  function numbers(dir4) {
22273
22371
  try {
22274
- return readdirSync17(dir4).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
22372
+ return readdirSync18(dir4).map((n) => Number(n.match(RE)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
22275
22373
  } catch {
22276
22374
  return [];
22277
22375
  }
@@ -22300,7 +22398,7 @@ var baselineStore = {
22300
22398
  latest(root, mapId, ticketId) {
22301
22399
  const dir4 = folder(root, mapId, ticketId);
22302
22400
  const n = numbers(dir4).at(-1);
22303
- return n ? verified(root, { mapId, ticketId, file: path58.join(dir4, `baseline-${n}.json`) }) : void 0;
22401
+ return n ? verified(root, { mapId, ticketId, file: path59.join(dir4, `baseline-${n}.json`) }) : void 0;
22304
22402
  },
22305
22403
  /** Records a new baseline under the next number, signed; returns it with its id. Throws when it can't be kept. */
22306
22404
  add(root, rec) {
@@ -22311,7 +22409,7 @@ var baselineStore = {
22311
22409
  const baseline = { ...rec, id };
22312
22410
  const signed3 = { v: 1, baseline, mac: machineSign(macParts(root, baseline)) };
22313
22411
  try {
22314
- createWhole(path58.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
22412
+ createWhole(path59.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
22315
22413
  `);
22316
22414
  return baseline;
22317
22415
  } catch (e) {
@@ -22323,26 +22421,26 @@ var baselineStore = {
22323
22421
 
22324
22422
  // ../core/src/evidence/treeState.ts
22325
22423
  import { createHash as createHash7 } from "node:crypto";
22326
- import { existsSync as existsSync20, realpathSync as realpathSync10 } from "node:fs";
22327
- import path59 from "node:path";
22328
- var posix = (p) => p.split(path59.sep).join("/");
22424
+ import { existsSync as existsSync21, realpathSync as realpathSync10 } from "node:fs";
22425
+ import path60 from "node:path";
22426
+ var posix = (p) => p.split(path60.sep).join("/");
22329
22427
  async function findWorktree(cwd, trackerRoot) {
22330
- if (!existsSync20(cwd)) return { error: `${cwd} does not exist` };
22428
+ if (!existsSync21(cwd)) return { error: `${cwd} does not exist` };
22331
22429
  const r = await git(cwd, ["rev-parse", "--show-toplevel"]);
22332
22430
  if (r.code === null) return { error: `git is not available (${r.stderr.trim()})` };
22333
22431
  if (r.code !== 0) return { error: `${cwd} is not inside a git repository` };
22334
22432
  const toplevel = realpathSync10(r.stdout.toString("utf8").trim());
22335
22433
  const pathspec = ["--", "."];
22336
- if (trackerRoot && existsSync20(trackerRoot)) {
22337
- const rel = path59.relative(toplevel, realpathSync10(trackerRoot));
22338
- if (rel && !rel.startsWith("..") && !path59.isAbsolute(rel)) pathspec.push(`:(exclude)${posix(rel)}`);
22434
+ if (trackerRoot && existsSync21(trackerRoot)) {
22435
+ const rel = path60.relative(toplevel, realpathSync10(trackerRoot));
22436
+ if (rel && !rel.startsWith("..") && !path60.isAbsolute(rel)) pathspec.push(`:(exclude)${posix(rel)}`);
22339
22437
  }
22340
22438
  return { toplevel, pathspec };
22341
22439
  }
22342
22440
  var emptyTree = (wt) => gitText(wt.toplevel, ["hash-object", "-t", "tree", "--stdin"], "").then((s) => s ?? "");
22343
22441
  async function hashFiles(wt, files) {
22344
22442
  const out = {};
22345
- const present = files.filter((f) => existsSync20(path59.join(wt.toplevel, f)));
22443
+ const present = files.filter((f) => existsSync21(path60.join(wt.toplevel, f)));
22346
22444
  for (const f of files) out[f] = null;
22347
22445
  if (!present.length) return out;
22348
22446
  const r = await git(wt.toplevel, ["hash-object", "--stdin-paths"], present.join("\n") + "\n");
@@ -22402,7 +22500,7 @@ async function baselineForClaim(c) {
22402
22500
 
22403
22501
  // ../core/src/evidence/changes.ts
22404
22502
  import { readFileSync as readFileSync26 } from "node:fs";
22405
- import path60 from "node:path";
22503
+ import path61 from "node:path";
22406
22504
  function numstat(out) {
22407
22505
  const rows = /* @__PURE__ */ new Map();
22408
22506
  for (const line5 of out.toString("utf8").split("\0")) {
@@ -22413,7 +22511,7 @@ function numstat(out) {
22413
22511
  }
22414
22512
  function lineCount(wt, f) {
22415
22513
  try {
22416
- const b = readFileSync26(path60.join(wt.toplevel, f));
22514
+ const b = readFileSync26(path61.join(wt.toplevel, f));
22417
22515
  if (b.includes(0)) return null;
22418
22516
  const text11 = b.toString("utf8");
22419
22517
  return text11 ? text11.split("\n").length - (text11.endsWith("\n") ? 1 : 0) : 0;
@@ -22553,7 +22651,7 @@ async function otherWork(root, snap, self) {
22553
22651
  async function collectEvidence(r) {
22554
22652
  const base2 = latestBaseline(r.root, r.snap.map.id, r.ticket.id);
22555
22653
  const b = base2?.git ?? void 0;
22556
- const dir4 = b && existsSync21(b.toplevel) ? b.toplevel : r.cwd;
22654
+ const dir4 = b && existsSync22(b.toplevel) ? b.toplevel : r.cwd;
22557
22655
  const found = await findWorktree(dir4, r.root);
22558
22656
  const wt = "error" in found ? void 0 : found;
22559
22657
  const now2 = wt && await readTreeState(wt);
@@ -22596,14 +22694,14 @@ var treeOf = (now2) => ({
22596
22694
  });
22597
22695
 
22598
22696
  // ../core/src/evidence/stale.ts
22599
- import { existsSync as existsSync22 } from "node:fs";
22600
- import path61 from "node:path";
22697
+ import { existsSync as existsSync23 } from "node:fs";
22698
+ import path62 from "node:path";
22601
22699
  var short3 = (sha2) => sha2?.slice(0, 8) ?? "none";
22602
22700
  async function staleness(root, ev) {
22603
22701
  const hash2 = trustedChecks(root).config.hash;
22604
22702
  if (ev && (ev.configHash ?? null) !== (hash2 ?? null))
22605
22703
  return { checked: true, stale: true, reason: "verification.json changed since the checks ran" };
22606
- if (!ev?.tree || !path61.isAbsolute(ev.tree.toplevel) || !existsSync22(ev.tree.toplevel))
22704
+ if (!ev?.tree || !path62.isAbsolute(ev.tree.toplevel) || !existsSync23(ev.tree.toplevel))
22607
22705
  return { checked: false, stale: false };
22608
22706
  const wt = await findWorktree(ev.tree.toplevel, root);
22609
22707
  if ("error" in wt) return { checked: false, stale: false, reason: wt.error };
@@ -22748,13 +22846,13 @@ function attemptBase(o) {
22748
22846
  }
22749
22847
 
22750
22848
  // ../core/src/verification/checkoutFor.ts
22751
- import { existsSync as existsSync23 } from "node:fs";
22752
- import path62 from "node:path";
22849
+ import { existsSync as existsSync24 } from "node:fs";
22850
+ import path63 from "node:path";
22753
22851
  function checkoutFor(env, mapId, ticketId) {
22754
- const repo = env.repoRoot ?? path62.dirname(env.root);
22852
+ const repo = env.repoRoot ?? path63.dirname(env.root);
22755
22853
  if (env.repoRoot) return { kind: "here", path: repo };
22756
22854
  const prepared = preparedWorktree(env.root, mapId, ticketId);
22757
- if (prepared && existsSync23(prepared)) return { kind: "here", path: prepared };
22855
+ if (prepared && existsSync24(prepared)) return { kind: "here", path: prepared };
22758
22856
  const record3 = readWorkspace(env.root, mapId, ticketId);
22759
22857
  if (!prepared && !record3) return { kind: "here", path: repo };
22760
22858
  const where2 = prepared ?? record3?.path;
@@ -22765,7 +22863,7 @@ function checkoutFor(env, mapId, ticketId) {
22765
22863
  }
22766
22864
 
22767
22865
  // ../core/src/verification/gradeAttempt.ts
22768
- import path63 from "node:path";
22866
+ import path64 from "node:path";
22769
22867
 
22770
22868
  // ../core/src/verification/gradeCriteria.ts
22771
22869
  function gradeCriteria(at2, checks, known4 = []) {
@@ -22800,11 +22898,11 @@ async function checksOrError(i) {
22800
22898
  return { checks: [], result: "error", note };
22801
22899
  }
22802
22900
  const rel = evidencePaths.logs(i.mapId, i.ticketId, i.attemptId);
22803
- ensureLocalDir(path63.join(i.root, EVIDENCE_DIR));
22901
+ ensureLocalDir(path64.join(i.root, EVIDENCE_DIR));
22804
22902
  const failFast = config4.config.failFast && !i.known?.length;
22805
22903
  return runChecks({ ...config4.config, failFast }, i.info.checks, {
22806
22904
  repoRoot: i.repoRoot,
22807
- logDir: path63.join(i.root, rel),
22905
+ logDir: path64.join(i.root, rel),
22808
22906
  logRel: rel,
22809
22907
  signal: i.signal
22810
22908
  });
@@ -22991,20 +23089,20 @@ ${note}` : reviewBody(t, a)
22991
23089
  }
22992
23090
 
22993
23091
  // ../core/src/verification/runLock.ts
22994
- import { mkdirSync as mkdirSync22, readdirSync as readdirSync18, renameSync as renameSync9, rmSync as rmSync14, writeFileSync as writeFileSync16 } from "node:fs";
22995
- import path64 from "node:path";
23092
+ import { mkdirSync as mkdirSync22, readdirSync as readdirSync19, renameSync as renameSync9, rmSync as rmSync14, writeFileSync as writeFileSync16 } from "node:fs";
23093
+ import path65 from "node:path";
22996
23094
  var RUNS_DIR = `${AGENTS_DIR}/runs`;
22997
23095
  var safe14 = (s) => s.replace(/[^\w.-]/g, "_");
22998
- var lockFile = (root, mapId, ticketId) => path64.join(root, RUNS_DIR, `${safe14(mapId)}--${safe14(ticketId)}.json`);
23096
+ var lockFile = (root, mapId, ticketId) => path65.join(root, RUNS_DIR, `${safe14(mapId)}--${safe14(ticketId)}.json`);
22999
23097
  var readRunLock = (root, mapId, ticketId) => readJsonFile(lockFile(root, mapId, ticketId));
23000
23098
  function readRunLocks(root) {
23001
23099
  let names = [];
23002
23100
  try {
23003
- names = readdirSync18(path64.join(root, RUNS_DIR)).filter((n) => n.endsWith(".json"));
23101
+ names = readdirSync19(path65.join(root, RUNS_DIR)).filter((n) => n.endsWith(".json"));
23004
23102
  } catch {
23005
23103
  return [];
23006
23104
  }
23007
- return names.map((n) => readJsonFile(path64.join(root, RUNS_DIR, n))).filter((l) => l?.v === 1 && !!l.ticketId);
23105
+ return names.map((n) => readJsonFile(path65.join(root, RUNS_DIR, n))).filter((l) => l?.v === 1 && !!l.ticketId);
23008
23106
  }
23009
23107
  function recover(root, lock, now2) {
23010
23108
  const file9 = lockFile(root, lock.mapId, lock.ticketId);
@@ -23044,8 +23142,8 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
23044
23142
  const file9 = lockFile(root, lock.mapId, lock.ticketId);
23045
23143
  const mine2 = { ...lock, pid: process.pid, startedAt: now2 };
23046
23144
  let recovered;
23047
- ensureLocalDir(path64.join(root, AGENTS_DIR));
23048
- mkdirSync22(path64.dirname(file9), { recursive: true });
23145
+ ensureLocalDir(path65.join(root, AGENTS_DIR));
23146
+ mkdirSync22(path65.dirname(file9), { recursive: true });
23049
23147
  for (let i = 0; i < 3; i++) {
23050
23148
  try {
23051
23149
  writeFileSync16(file9, JSON.stringify(mine2, null, 2), { flag: "wx" });
@@ -23069,7 +23167,7 @@ function releaseRunLock(root, mapId, ticketId, pid = process.pid) {
23069
23167
  var recoverInterrupted = (root, now2 = Date.now()) => readRunLocks(root).filter((l) => !processAlive(l.pid)).map((l) => recover(root, l, now2)).filter((a) => !!a);
23070
23168
 
23071
23169
  // ../core/src/verification/runnerGraded.ts
23072
- import path65 from "node:path";
23170
+ import path66 from "node:path";
23073
23171
 
23074
23172
  // ../core/src/checkGuard/runnerGuard.ts
23075
23173
  var MAX_CHARS = 1024 * 1024;
@@ -23154,12 +23252,12 @@ async function runnerGraded(env, job, run3) {
23154
23252
  const report3 = await ask2(env.checkRunner, runJob, config4.totalTimeoutSec * 1e3 + RUNNER_MARGIN_MS2);
23155
23253
  if (typeof report3 === "string") return { checks: [], result: "error", note: report3 };
23156
23254
  const rel = evidencePaths.logs(job.mapId, job.ticket.id, run3.id);
23157
- ensureLocalDir(path65.join(env.root, EVIDENCE_DIR));
23255
+ ensureLocalDir(path66.join(env.root, EVIDENCE_DIR));
23158
23256
  const read4 = readRunnerReport({
23159
23257
  runner: env.checkRunner.name,
23160
23258
  report: report3,
23161
23259
  asked,
23162
- log: { dir: path65.join(env.root, rel), rel },
23260
+ log: { dir: path66.join(env.root, rel), rel },
23163
23261
  config: config4,
23164
23262
  configHash: run3.config.hash,
23165
23263
  ticketType: job.ticket.type,
@@ -23183,7 +23281,7 @@ async function runnerGraded(env, job, run3) {
23183
23281
  );
23184
23282
  const unmet = criteria ? [...criteria.missing, ...criteria.failed] : [];
23185
23283
  const graded = { ...outcome3, git: read4.git, ...criteria ? { criteria } : {} };
23186
- const repoRoot = env.repoRoot ?? path65.dirname(env.root);
23284
+ const repoRoot = env.repoRoot ?? path66.dirname(env.root);
23187
23285
  const guard2 = await runnerGuard({
23188
23286
  config: config4,
23189
23287
  checks: job.info.checks,
@@ -23385,7 +23483,7 @@ function withRules(o) {
23385
23483
 
23386
23484
  // ../core/src/verification/verifyCompletion.ts
23387
23485
  var CHECK_RUNNER = BRAND.slug;
23388
- var repoRootOf = (env) => env.repoRoot ?? path66.dirname(env.root);
23486
+ var repoRootOf = (env) => env.repoRoot ?? path67.dirname(env.root);
23389
23487
  function levelFor(root, snap, t) {
23390
23488
  const { config: config4 } = trustedChecks(root);
23391
23489
  const asked = verificationFor(config4.config, snap.map, t);
@@ -23589,14 +23687,14 @@ function reviewItem({ base: base2, last, verdict: verdict2 }, level) {
23589
23687
  }
23590
23688
 
23591
23689
  // ../core/src/workspaces/integrationStore.ts
23592
- import path67 from "node:path";
23593
- var file3 = (root) => path67.join(root, AGENTS_DIR, "integration.json");
23690
+ import path68 from "node:path";
23691
+ var file3 = (root) => path68.join(root, AGENTS_DIR, "integration.json");
23594
23692
  function readIntegrationScan(root) {
23595
23693
  const s = readJsonFile(file3(root));
23596
23694
  return s?.v === 1 ? s : { v: 1, at: 0, overlaps: [] };
23597
23695
  }
23598
23696
  function writeIntegrationScan(root, s) {
23599
- ensureLocalDir(path67.join(root, AGENTS_DIR));
23697
+ ensureLocalDir(path68.join(root, AGENTS_DIR));
23600
23698
  writeJsonAtomic(file3(root), s);
23601
23699
  }
23602
23700
 
@@ -23685,26 +23783,26 @@ async function readViolations(input2) {
23685
23783
  }
23686
23784
 
23687
23785
  // ../core/src/planning/reroute/rerouteStore.ts
23688
- import { mkdirSync as mkdirSync25, readdirSync as readdirSync19, writeFileSync as writeFileSync17 } from "node:fs";
23689
- import path68 from "node:path";
23786
+ import { mkdirSync as mkdirSync25, readdirSync as readdirSync20, writeFileSync as writeFileSync17 } from "node:fs";
23787
+ import path69 from "node:path";
23690
23788
  var REROUTES_DIR = ".reroutes";
23691
23789
  var safe15 = (s) => s.replace(/[^\w.-]/g, "_");
23692
- var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR, safe15(mapId));
23693
- var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${safe15(id)}.json`);
23790
+ var mapDir = (root, mapId) => path69.join(root, REROUTES_DIR, safe15(mapId));
23791
+ var fileOf = (root, mapId, id) => path69.join(mapDir(root, mapId), `${safe15(id)}.json`);
23694
23792
  var idNumber2 = (id) => Number(id.match(/^R-(\d+)$/)?.[1] ?? 0);
23695
23793
  function listReroutes(root, mapId) {
23696
23794
  let names = [];
23697
23795
  try {
23698
- names = readdirSync19(mapDir(root, mapId)).filter((n) => /^R-\d+\.json$/.test(n));
23796
+ names = readdirSync20(mapDir(root, mapId)).filter((n) => /^R-\d+\.json$/.test(n));
23699
23797
  } catch {
23700
23798
  return [];
23701
23799
  }
23702
- return names.map((n) => readJsonFile(path68.join(mapDir(root, mapId), n))).filter((p) => !!p && p.v === 1).sort((a, b) => idNumber2(a.id) - idNumber2(b.id));
23800
+ return names.map((n) => readJsonFile(path69.join(mapDir(root, mapId), n))).filter((p) => !!p && p.v === 1).sort((a, b) => idNumber2(a.id) - idNumber2(b.id));
23703
23801
  }
23704
23802
  function listAllReroutes(root) {
23705
23803
  let maps = [];
23706
23804
  try {
23707
- maps = readdirSync19(path68.join(root, REROUTES_DIR)).filter((n) => !n.startsWith("."));
23805
+ maps = readdirSync20(path69.join(root, REROUTES_DIR)).filter((n) => !n.startsWith("."));
23708
23806
  } catch {
23709
23807
  return [];
23710
23808
  }
@@ -23713,7 +23811,7 @@ function listAllReroutes(root) {
23713
23811
  var readReroute = (root, mapId, id) => readJsonFile(fileOf(root, mapId, id));
23714
23812
  function createReroute(root, draft) {
23715
23813
  const dir4 = mapDir(root, draft.mapId);
23716
- ensureLocalDir(path68.join(root, REROUTES_DIR));
23814
+ ensureLocalDir(path69.join(root, REROUTES_DIR));
23717
23815
  mkdirSync25(dir4, { recursive: true });
23718
23816
  let n = Math.max(0, ...listReroutes(root, draft.mapId).map((p) => idNumber2(p.id))) + 1;
23719
23817
  for (; ; ) {
@@ -23728,7 +23826,7 @@ function createReroute(root, draft) {
23728
23826
  }
23729
23827
  }
23730
23828
  function writeReroute(root, p) {
23731
- ensureLocalDir(path68.join(root, REROUTES_DIR));
23829
+ ensureLocalDir(path69.join(root, REROUTES_DIR));
23732
23830
  writeJsonAtomic(fileOf(root, p.mapId, p.id), p);
23733
23831
  }
23734
23832
 
@@ -23852,12 +23950,12 @@ async function attentionView(input2) {
23852
23950
  }
23853
23951
 
23854
23952
  // ../core/src/attention/writeReviewLimit.ts
23855
- import { existsSync as existsSync24, readFileSync as readFileSync27 } from "node:fs";
23856
- import path69 from "node:path";
23953
+ import { existsSync as existsSync25, readFileSync as readFileSync27 } from "node:fs";
23954
+ import path70 from "node:path";
23857
23955
  function writeReviewLimit(root, limit) {
23858
- const file9 = path69.join(root, ATTENTION_FILE);
23956
+ const file9 = path70.join(root, ATTENTION_FILE);
23859
23957
  let raw = { v: 1 };
23860
- if (existsSync24(file9)) {
23958
+ if (existsSync25(file9)) {
23861
23959
  try {
23862
23960
  const read4 = parseJsonSafe(readFileSync27(file9, "utf8"));
23863
23961
  if (!read4 || typeof read4 !== "object" || Array.isArray(read4)) throw new Error("not a JSON object");
@@ -24071,20 +24169,20 @@ async function seedAssumptions(adapter, brief) {
24071
24169
 
24072
24170
  // ../core/src/criteria/criteriaProposals.ts
24073
24171
  import { rmSync as rmSync15 } from "node:fs";
24074
- import path71 from "node:path";
24172
+ import path72 from "node:path";
24075
24173
 
24076
24174
  // ../core/src/agents/ignoreAgentsDir.ts
24077
- import { existsSync as existsSync25, mkdirSync as mkdirSync26, writeFileSync as writeFileSync18 } from "node:fs";
24078
- import path70 from "node:path";
24175
+ import { existsSync as existsSync26, mkdirSync as mkdirSync26, writeFileSync as writeFileSync18 } from "node:fs";
24176
+ import path71 from "node:path";
24079
24177
  function ignoreAgentsDir(root) {
24080
- const ignore = path70.join(root, AGENTS_DIR, ".gitignore");
24081
- mkdirSync26(path70.dirname(ignore), { recursive: true });
24082
- if (!existsSync25(ignore)) writeFileSync18(ignore, "*\n");
24178
+ const ignore = path71.join(root, AGENTS_DIR, ".gitignore");
24179
+ mkdirSync26(path71.dirname(ignore), { recursive: true });
24180
+ if (!existsSync26(ignore)) writeFileSync18(ignore, "*\n");
24083
24181
  }
24084
24182
 
24085
24183
  // ../core/src/criteria/criteriaProposals.ts
24086
24184
  var safe16 = (s) => s.replace(/[^\w.-]/g, "_");
24087
- var file4 = (root, mapId) => path71.join(root, AGENTS_DIR, "criteria-proposals", `${safe16(mapId)}.json`);
24185
+ var file4 = (root, mapId) => path72.join(root, AGENTS_DIR, "criteria-proposals", `${safe16(mapId)}.json`);
24088
24186
  var isProposal = (p) => !!p && typeof p.ticketId === "string" && typeof p.by === "string" && Array.isArray(p.criteria);
24089
24187
  function readCriteriaProposals(root, mapId) {
24090
24188
  const f = readJsonFile(file4(root, mapId));
@@ -24131,13 +24229,13 @@ async function handleCriteriaProposals(root, req, res, url2) {
24131
24229
  if (!waiting2) return sendJson(res, 404, { error: "no proposed criteria for this ticket" }), true;
24132
24230
  const shown3 = action === "accept" ? checkShown(b.hash, contentOf2(waiting2), "The proposal") : { ok: true };
24133
24231
  if (!shown3.ok) return sendJson(res, shown3.status, { error: shown3.error }), true;
24134
- const taken = dropCriteriaProposal(root, b.mapId, b.ticketId);
24135
- if (action === "dismiss") return sendJson(res, 200, { dismissed: taken.ticketKey }), true;
24232
+ const taken2 = dropCriteriaProposal(root, b.mapId, b.ticketId);
24233
+ if (action === "dismiss") return sendJson(res, 200, { dismissed: taken2.ticketKey }), true;
24136
24234
  const map2 = { id: b.mapId, title: text3(b.title) ? b.title : b.mapId };
24137
- const ticket2 = { id: taken.ticketId, key: taken.ticketKey };
24138
- writeTicketCriteria(root, map2, ticket2, { criteria: taken.criteria });
24235
+ const ticket2 = { id: taken2.ticketId, key: taken2.ticketKey };
24236
+ writeTicketCriteria(root, map2, ticket2, { criteria: taken2.criteria });
24139
24237
  const confirmed = writeTicketCriteria(root, map2, ticket2, { confirmed: true });
24140
- confirmCriteriaHere(root, { mapId: b.mapId, ticketId: taken.ticketId, content: contentOf2(taken) }, "trail lead");
24238
+ confirmCriteriaHere(root, { mapId: b.mapId, ticketId: taken2.ticketId, content: contentOf2(taken2) }, "trail lead");
24141
24239
  sendJson(res, 200, { ticket: confirmed });
24142
24240
  return true;
24143
24241
  }
@@ -24291,21 +24389,21 @@ async function handleDecisions({ adapter, root }, req, res, url2) {
24291
24389
 
24292
24390
  // ../core/src/projects/confinePath.ts
24293
24391
  import { realpathSync as realpathSync11 } from "node:fs";
24294
- import path72 from "node:path";
24392
+ import path73 from "node:path";
24295
24393
  function realOrParent(p) {
24296
24394
  try {
24297
24395
  return realpathSync11(p);
24298
24396
  } catch {
24299
- const parent = path72.dirname(p);
24397
+ const parent = path73.dirname(p);
24300
24398
  if (parent === p) return p;
24301
- return path72.join(realOrParent(parent), path72.basename(p));
24399
+ return path73.join(realOrParent(parent), path73.basename(p));
24302
24400
  }
24303
24401
  }
24304
24402
  function insideRoot(root, rel) {
24305
- if (path72.isAbsolute(rel) || rel.includes("\0")) return false;
24306
- const base2 = realOrParent(path72.resolve(root));
24307
- const full = realOrParent(path72.resolve(root, rel));
24308
- return full === base2 || full.startsWith(base2 + path72.sep);
24403
+ if (path73.isAbsolute(rel) || rel.includes("\0")) return false;
24404
+ const base2 = realOrParent(path73.resolve(root));
24405
+ const full = realOrParent(path73.resolve(root, rel));
24406
+ return full === base2 || full.startsWith(base2 + path73.sep);
24309
24407
  }
24310
24408
 
24311
24409
  // ../core/src/server/trustFields.ts
@@ -24458,7 +24556,7 @@ async function handleFlakyChecks(ctx, req, res, url2) {
24458
24556
 
24459
24557
  // ../core/src/guides/approveCheck.ts
24460
24558
  import { writeFileSync as writeFileSync19 } from "node:fs";
24461
- import path73 from "node:path";
24559
+ import path74 from "node:path";
24462
24560
 
24463
24561
  // ../core/src/verification/rawConfig.ts
24464
24562
  import { readFileSync as readFileSync28 } from "node:fs";
@@ -24494,7 +24592,7 @@ function approveCheck(input2) {
24494
24592
  const notice = checkNotice(proposed2);
24495
24593
  if (notice && !input2.acknowledged)
24496
24594
  throw new OperationError(`check ${input2.name}: ${notice}; approve it again, acknowledging that`);
24497
- const file9 = path73.join(input2.root, VERIFICATION_FILE);
24595
+ const file9 = path74.join(input2.root, VERIFICATION_FILE);
24498
24596
  const raw = readRaw2(file9);
24499
24597
  const checks = { ...raw.checks ?? {} };
24500
24598
  const spec = specOf(proposed2);
@@ -24519,10 +24617,10 @@ function approveCheck(input2) {
24519
24617
  }
24520
24618
 
24521
24619
  // ../core/src/guides/checklistStore.ts
24522
- import path74 from "node:path";
24523
- var fileOf2 = (root, mapId, ticketId) => path74.join(root, evidencePaths.ticket(mapId, ticketId), "checklist.json");
24620
+ import path75 from "node:path";
24621
+ var fileOf2 = (root, mapId, ticketId) => path75.join(root, evidencePaths.ticket(mapId, ticketId), "checklist.json");
24524
24622
  function writeChecklist(root, rec) {
24525
- ensureLocalDir(path74.join(root, EVIDENCE_DIR));
24623
+ ensureLocalDir(path75.join(root, EVIDENCE_DIR));
24526
24624
  writeJsonAtomic(fileOf2(root, rec.mapId, rec.ticketId), rec);
24527
24625
  }
24528
24626
  function readChecklist(root, mapId, ticketId) {
@@ -24775,12 +24873,12 @@ function changeOf(b) {
24775
24873
  if (typeof b.remove === "string" && b.remove) return { kind: "remove", id: b.remove };
24776
24874
  throw new BadRequest('"add" or "remove" is required');
24777
24875
  }
24778
- async function guideTrailAction(ctx, req, path148) {
24876
+ async function guideTrailAction(ctx, req, path149) {
24779
24877
  const b = await readJson2(req, "{}");
24780
24878
  const mapId = str5(b.mapId, "mapId");
24781
24879
  const adapter = await ctx.active();
24782
24880
  const guides = listGuides(ctx.root);
24783
- if (path148 === "/guides/trail") {
24881
+ if (path149 === "/guides/trail") {
24784
24882
  const byType = byTypeOf(b.byType);
24785
24883
  const before = trailGuidesByType((await adapter.loadMap(mapId)).map).byType;
24786
24884
  const added = Object.entries(byType ?? {}).flatMap(
@@ -24804,13 +24902,13 @@ var str6 = (v, name2) => {
24804
24902
  if (typeof v !== "string" || !v) throw new BadRequest(`"${name2}" is required`);
24805
24903
  return v;
24806
24904
  };
24807
- async function projectAction(ctx, req, path148) {
24905
+ async function projectAction(ctx, req, path149) {
24808
24906
  const b = await readJson2(req, "{}");
24809
24907
  const id = str6(b.id, "id");
24810
- if (path148 === "/guides/approve") {
24908
+ if (path149 === "/guides/approve") {
24811
24909
  const r = approveGuide({ root: ctx.root, id, by: TRAIL_LEAD2, sha256: str6(b.sha256, "sha256") });
24812
24910
  journalGuide(ctx.root, { action: "approved", guide: id, version: r.guide.version });
24813
- } else if (path148 === "/guides/checks/approve") {
24911
+ } else if (path149 === "/guides/checks/approve") {
24814
24912
  const acknowledged = b.acknowledged === true;
24815
24913
  const r = approveCheck({ root: ctx.root, id, name: str6(b.name, "name"), acknowledged });
24816
24914
  journalGuide(ctx.root, { action: "check-approved", guide: id, version: r.version, check: r.check });
@@ -24941,7 +25039,7 @@ function trailLeadCall(root, b, hashOf) {
24941
25039
  // ../core/src/server/lanPlaces.ts
24942
25040
  import { realpathSync as realpathSync12 } from "node:fs";
24943
25041
  import os2 from "node:os";
24944
- import path75 from "node:path";
25042
+ import path76 from "node:path";
24945
25043
  function real4(p) {
24946
25044
  try {
24947
25045
  return realpathSync12(p);
@@ -24950,28 +25048,28 @@ function real4(p) {
24950
25048
  }
24951
25049
  }
24952
25050
  function lanPlaces(root, configDir2) {
24953
- const repo = path75.basename(root) === BRAND.dataDir ? path75.dirname(root) : root;
24954
- const named4 = [root, repo, path75.dirname(repo), os2.homedir(), os2.tmpdir(), configDir2].filter((p) => !!p);
25051
+ const repo = path76.basename(root) === BRAND.dataDir ? path76.dirname(root) : root;
25052
+ const named4 = [root, repo, path76.dirname(repo), os2.homedir(), os2.tmpdir(), configDir2].filter((p) => !!p);
24955
25053
  const temp = process.platform === "win32" ? [] : ["/tmp", "/private/tmp", "/var/folders", "/private/var/folders"];
24956
- return [.../* @__PURE__ */ new Set([...named4, ...named4.map(real4), ...temp])].filter((p) => path75.dirname(p) !== p);
25054
+ return [.../* @__PURE__ */ new Set([...named4, ...named4.map(real4), ...temp])].filter((p) => path76.dirname(p) !== p);
24957
25055
  }
24958
25056
 
24959
25057
  // ../core/src/agents/returnToQueue.ts
24960
25058
  var LEASE_REAPER = "teamtrail";
24961
25059
  async function returnToQueue(root, adapter, lease, why2) {
24962
25060
  const { reason, by, now: now2 = Date.now() } = why2;
24963
- const taken = takeLease(root, lease);
24964
- if (!taken) return { busy: true };
24965
- const l = taken.lease;
25061
+ const taken2 = takeLease(root, lease);
25062
+ if (!taken2) return { busy: true };
25063
+ const l = taken2.lease;
24966
25064
  if (l.returned || reason === "expired" && leaseHealth(l, now2) !== "expired") {
24967
- taken.put(l);
25065
+ taken2.put(l);
24968
25066
  return { busy: true };
24969
25067
  }
24970
25068
  try {
24971
25069
  const snap = await adapter.loadMap(l.mapId);
24972
25070
  const t = snap.tickets.find((x) => x.id === l.ticketId);
24973
25071
  if (!t || t.state === "closed" || t.assignee !== l.agent) {
24974
- taken.drop();
25072
+ taken2.drop();
24975
25073
  return { dropped: l };
24976
25074
  }
24977
25075
  await adapter.comment(l.mapId, l.ticketId, by, handoffComment(l, reason, by));
@@ -24984,11 +25082,11 @@ async function returnToQueue(root, adapter, lease, why2) {
24984
25082
  journal: journalFile(root)
24985
25083
  });
24986
25084
  } catch (e) {
24987
- taken.put(l);
25085
+ taken2.put(l);
24988
25086
  throw e;
24989
25087
  }
24990
25088
  const tomb = { ...l, returned: { at: now2, reason, by } };
24991
- taken.put(tomb);
25089
+ taken2.put(tomb);
24992
25090
  return { returned: tomb };
24993
25091
  }
24994
25092
  async function reclaimExpired(root, adapter, now2 = Date.now()) {
@@ -25548,11 +25646,11 @@ async function handleMergeAnyway(ctx, req, res, url2) {
25548
25646
  }
25549
25647
 
25550
25648
  // ../core/src/planning/matching/modelsStore.ts
25551
- import { existsSync as existsSync26, readFileSync as readFileSync30 } from "node:fs";
25552
- import path76 from "node:path";
25649
+ import { existsSync as existsSync27, readFileSync as readFileSync30 } from "node:fs";
25650
+ import path77 from "node:path";
25553
25651
  function readModelsConfig(root) {
25554
- const file9 = path76.join(root, MODELS_FILE);
25555
- if (!existsSync26(file9)) return { models: {}, errors: [], exists: false };
25652
+ const file9 = path77.join(root, MODELS_FILE);
25653
+ if (!existsSync27(file9)) return { models: {}, errors: [], exists: false };
25556
25654
  const parsed3 = parseModelsConfig(readFileSync30(file9, "utf8"));
25557
25655
  return { models: parsed3.models ?? {}, errors: parsed3.errors, exists: true };
25558
25656
  }
@@ -25620,14 +25718,14 @@ function proofPostSetting(root, dir4) {
25620
25718
  }
25621
25719
 
25622
25720
  // ../core/src/proof/proofPostStore.ts
25623
- import path77 from "node:path";
25624
- var file5 = (root, mapId, ticketId) => path77.join(root, evidencePaths.ticket(mapId, ticketId), "proof-post.json");
25721
+ import path78 from "node:path";
25722
+ var file5 = (root, mapId, ticketId) => path78.join(root, evidencePaths.ticket(mapId, ticketId), "proof-post.json");
25625
25723
  function readProofPost(root, mapId, ticketId) {
25626
25724
  const r = readJsonFile(file5(root, mapId, ticketId));
25627
25725
  return r?.v === 1 ? r : void 0;
25628
25726
  }
25629
25727
  function writeProofPost(root, r) {
25630
- ensureLocalDir(path77.join(root, EVIDENCE_DIR));
25728
+ ensureLocalDir(path78.join(root, EVIDENCE_DIR));
25631
25729
  writeJsonAtomic(file5(root, r.mapId, r.ticketId), r);
25632
25730
  }
25633
25731
 
@@ -25797,13 +25895,13 @@ function gitLines(p) {
25797
25895
  ];
25798
25896
  }
25799
25897
  var SCOPE_SHOWN = 10;
25800
- var path78 = (s) => md(s, 120);
25898
+ var path79 = (s) => md(s, 120);
25801
25899
  function scopeLines(s) {
25802
25900
  if (!s) return [];
25803
- const declared = s.declared.slice(0, SCOPE_SHOWN).map(path78).join(", ");
25901
+ const declared = s.declared.slice(0, SCOPE_SHOWN).map(path79).join(", ");
25804
25902
  if (!s.outside.length) return ["", `**Scope:** every changed file is inside the declared ${declared}.`];
25805
25903
  const more = s.outside.length > SCOPE_SHOWN ? `, and ${s.outside.length - SCOPE_SHOWN} more` : "";
25806
- const files = s.outside.slice(0, SCOPE_SHOWN).map(path78).join(", ");
25904
+ const files = s.outside.slice(0, SCOPE_SHOWN).map(path79).join(", ");
25807
25905
  return [
25808
25906
  "",
25809
25907
  `**Scope:** ${s.outside.length} changed file${s.outside.length === 1 ? "" : "s"} outside the declared ${declared}: ${files}${more}.`
@@ -25844,13 +25942,13 @@ function proofMarkdown(p, signature4) {
25844
25942
  }
25845
25943
 
25846
25944
  // ../core/src/proof/repoProofKey.ts
25847
- import { existsSync as existsSync27, mkdirSync as mkdirSync30, writeFileSync as writeFileSync21 } from "node:fs";
25848
- import path80 from "node:path";
25945
+ import { existsSync as existsSync28, mkdirSync as mkdirSync30, writeFileSync as writeFileSync21 } from "node:fs";
25946
+ import path81 from "node:path";
25849
25947
 
25850
25948
  // ../core/src/machine/proofKey.ts
25851
25949
  import { createHash as createHash9, createPrivateKey, generateKeyPairSync, randomBytes as randomBytes6 } from "node:crypto";
25852
25950
  import { linkSync as linkSync5, readFileSync as readFileSync31, rmSync as rmSync17 } from "node:fs";
25853
- import path79 from "node:path";
25951
+ import path80 from "node:path";
25854
25952
  var PROOF_KEY_FILE = "proof-key.json";
25855
25953
  var proofKeyId = (publicKeyB64) => createHash9("sha256").update(Buffer.from(publicKeyB64, "base64")).digest("hex").slice(0, 16);
25856
25954
  function read(file9) {
@@ -25873,7 +25971,7 @@ function fresh() {
25873
25971
  };
25874
25972
  }
25875
25973
  function machineProofKey(dir4 = configDir()) {
25876
- const file9 = path79.join(dir4, PROOF_KEY_FILE);
25974
+ const file9 = path80.join(dir4, PROOF_KEY_FILE);
25877
25975
  let s = read(file9);
25878
25976
  if (!s) {
25879
25977
  const draft = `${file9}.${process.pid}.${randomBytes6(4).toString("hex")}`;
@@ -25903,10 +26001,10 @@ function ensureRepoProofKey(root, dir4) {
25903
26001
  } catch {
25904
26002
  return void 0;
25905
26003
  }
25906
- const rel = path80.join(PROOF_KEYS_DIR, `${key.id}.pub`);
25907
- const file9 = path80.join(root, rel);
25908
- if (!existsSync27(file9)) {
25909
- mkdirSync30(path80.dirname(file9), { recursive: true });
26004
+ const rel = path81.join(PROOF_KEYS_DIR, `${key.id}.pub`);
26005
+ const file9 = path81.join(root, rel);
26006
+ if (!existsSync28(file9)) {
26007
+ mkdirSync30(path81.dirname(file9), { recursive: true });
25910
26008
  try {
25911
26009
  writeFileSync21(file9, proofKeyLine(key.publicKey), { flag: "wx" });
25912
26010
  } catch (e) {
@@ -26132,9 +26230,9 @@ function redactResponse(res, places = []) {
26132
26230
  }
26133
26231
 
26134
26232
  // ../core/src/remoteAgents/mcpEndpoints.ts
26135
- import { readdirSync as readdirSync20, rmSync as rmSync18 } from "node:fs";
26233
+ import { readdirSync as readdirSync21, rmSync as rmSync18 } from "node:fs";
26136
26234
  import os3 from "node:os";
26137
- import path81 from "node:path";
26235
+ import path82 from "node:path";
26138
26236
 
26139
26237
  // ../core/src/machine/announcementSig.ts
26140
26238
  function announcementSig(root, what2, fields2) {
@@ -26176,8 +26274,8 @@ var DIR2 = `${AGENTS_DIR}/mcp-endpoints`;
26176
26274
  var ENDPOINT_SIG = "mcp-endpoint";
26177
26275
  var fieldsOf = (e) => [e.url, e.pid, e.kind, e.network === true, e.startedAt];
26178
26276
  function writeMcpEndpoint(root, e) {
26179
- const file9 = path81.join(root, DIR2, `${process.pid}.json`);
26180
- ensureLocalDir(path81.join(root, AGENTS_DIR));
26277
+ const file9 = path82.join(root, DIR2, `${process.pid}.json`);
26278
+ ensureLocalDir(path82.join(root, AGENTS_DIR));
26181
26279
  const base2 = { url: e.url, kind: e.kind, network: e.network, pid: process.pid, startedAt: Date.now() };
26182
26280
  const sig = announcementSig(root, ENDPOINT_SIG, fieldsOf(base2));
26183
26281
  const endpoint = { ...base2, ...sig ? { sig } : {} };
@@ -26197,40 +26295,40 @@ function believed(root, at2, e) {
26197
26295
  function readMcpEndpoints(root) {
26198
26296
  let names = [];
26199
26297
  try {
26200
- names = readdirSync20(path81.join(root, DIR2)).filter((n) => n.endsWith(".json"));
26298
+ names = readdirSync21(path82.join(root, DIR2)).filter((n) => n.endsWith(".json"));
26201
26299
  } catch {
26202
26300
  return [];
26203
26301
  }
26204
26302
  const addresses = ownAddresses();
26205
- 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);
26303
+ return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path82.join(root, DIR2, n)))).filter((e) => !!e).sort((a, b) => Number(b.kind === "standalone") - Number(a.kind === "standalone") || a.startedAt - b.startedAt);
26206
26304
  }
26207
26305
 
26208
26306
  // ../core/src/remoteAgents/remoteTokens.ts
26209
26307
  import { createHash as createHash10, randomBytes as randomBytes7, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
26210
26308
 
26211
26309
  // ../core/src/remoteAgents/remoteTokenStore.ts
26212
- import path82 from "node:path";
26310
+ import path83 from "node:path";
26213
26311
  var REMOTE_TOKENS_FILE = `${AGENTS_DIR}/remote-tokens.json`;
26214
26312
  var REMOTE_TOKENS_USED_FILE = `${AGENTS_DIR}/remote-tokens-used.json`;
26215
26313
  var TOKEN_FIELDS = ["id", "name", "hash"];
26216
26314
  var isToken = (t) => !!t && TOKEN_FIELDS.every((k) => typeof t[k] === "string" && t[k]) && typeof t.createdAt === "number";
26217
- var ignoreAgentsDir2 = (root) => ensureLocalDir(path82.join(root, AGENTS_DIR));
26315
+ var ignoreAgentsDir2 = (root) => ensureLocalDir(path83.join(root, AGENTS_DIR));
26218
26316
  function readRemoteTokens(root) {
26219
- const raw = readJsonFile(path82.join(root, REMOTE_TOKENS_FILE));
26317
+ const raw = readJsonFile(path83.join(root, REMOTE_TOKENS_FILE));
26220
26318
  if (raw?.v !== 1 || !Array.isArray(raw.tokens)) return [];
26221
26319
  return raw.tokens.filter(isToken);
26222
26320
  }
26223
26321
  function writeRemoteTokens(root, tokens) {
26224
26322
  ignoreAgentsDir2(root);
26225
- writeJsonAtomic(path82.join(root, REMOTE_TOKENS_FILE), { v: 1, tokens });
26323
+ writeJsonAtomic(path83.join(root, REMOTE_TOKENS_FILE), { v: 1, tokens });
26226
26324
  }
26227
26325
  function readRemoteTokenUse(root) {
26228
- const raw = readJsonFile(path82.join(root, REMOTE_TOKENS_USED_FILE));
26326
+ const raw = readJsonFile(path83.join(root, REMOTE_TOKENS_USED_FILE));
26229
26327
  return raw?.v === 1 && raw.used && typeof raw.used === "object" ? raw.used : {};
26230
26328
  }
26231
26329
  function writeRemoteTokenUse(root, used) {
26232
26330
  ignoreAgentsDir2(root);
26233
- writeJsonAtomic(path82.join(root, REMOTE_TOKENS_USED_FILE), { v: 1, used });
26331
+ writeJsonAtomic(path83.join(root, REMOTE_TOKENS_USED_FILE), { v: 1, used });
26234
26332
  }
26235
26333
 
26236
26334
  // ../core/src/remoteAgents/remoteTokens.ts
@@ -26985,8 +27083,8 @@ var GitHubCiProvider = class {
26985
27083
  this.#base = `${apiBase(o.apiUrl)}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name2)}`;
26986
27084
  this.#limit = Math.min(100, o.recentLimit ?? 50);
26987
27085
  }
26988
- async #get(path148) {
26989
- return (await this.#http.send(`${this.#base}${path148}`, { headers: restHeaders(this.#token) })).body;
27086
+ async #get(path149) {
27087
+ return (await this.#http.send(`${this.#base}${path149}`, { headers: restHeaders(this.#token) })).body;
26990
27088
  }
26991
27089
  #snapshot(p, review2 = "none") {
26992
27090
  const sha2 = SHA2.test(p.head.sha) ? p.head.sha.toLowerCase() : "";
@@ -27515,11 +27613,11 @@ async function handleLinearTeams(req, res, o) {
27515
27613
  }
27516
27614
 
27517
27615
  // ../core/src/adapters/remote/acceptedSettingsFile.ts
27518
- import { existsSync as existsSync28, mkdirSync as mkdirSync31, rmSync as rmSync19 } from "node:fs";
27616
+ import { existsSync as existsSync29, mkdirSync as mkdirSync31, rmSync as rmSync19 } from "node:fs";
27519
27617
  import { open, rename, rm, stat as stat2 } from "node:fs/promises";
27520
- import path83 from "node:path";
27618
+ import path84 from "node:path";
27521
27619
  var ACCEPTED_DIR = "tracker-settings";
27522
- var acceptedSettingsPath = (root, target2) => path83.join(machineStore(root).dir, ACCEPTED_DIR, `${target2}.json`);
27620
+ var acceptedSettingsPath = (root, target2) => path84.join(machineStore(root).dir, ACCEPTED_DIR, `${target2}.json`);
27523
27621
  var LOCK_STALE_MS = 5e3;
27524
27622
  var BACKOFF_MS = [0, 5, 10, 20, 40, 80, 160, 320, 400];
27525
27623
  var macParts2 = (root, target2, issues) => [
@@ -27576,7 +27674,7 @@ function migrate(root, target2) {
27576
27674
  const legacy = legacyTargetKey(target2);
27577
27675
  const from = acceptedSettingsPath(root, legacy);
27578
27676
  const to = acceptedSettingsPath(root, target2);
27579
- if (legacy === target2 || !existsSync28(from) || existsSync28(to)) return;
27677
+ if (legacy === target2 || !existsSync29(from) || existsSync29(to)) return;
27580
27678
  const issues = readDoc(root, from, legacy);
27581
27679
  try {
27582
27680
  const mac4 = machineSign(macParts2(root, target2, issues));
@@ -27593,7 +27691,7 @@ function acceptedSettingsFile(root, target2) {
27593
27691
  read: () => readDoc(root, file9, target2),
27594
27692
  async update(change3) {
27595
27693
  try {
27596
- mkdirSync31(path83.dirname(file9), { recursive: true, mode: 448 });
27694
+ mkdirSync31(path84.dirname(file9), { recursive: true, mode: 448 });
27597
27695
  } catch {
27598
27696
  return false;
27599
27697
  }
@@ -27607,7 +27705,7 @@ function acceptedSettingsFile(root, target2) {
27607
27705
  writePrivateFile(file9, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
27608
27706
  `);
27609
27707
  });
27610
- if (!done2) console.warn(`teamtrail: ${path83.basename(file9)} is locked; settings not recorded this time`);
27708
+ if (!done2) console.warn(`teamtrail: ${path84.basename(file9)} is locked; settings not recorded this time`);
27611
27709
  return done2;
27612
27710
  }
27613
27711
  };
@@ -28383,7 +28481,7 @@ async function handleTrailChecks(ctx, req, res, url2) {
28383
28481
 
28384
28482
  // ../core/src/signedState/revertState.ts
28385
28483
  import { readFileSync as readFileSync32 } from "node:fs";
28386
- import path84 from "node:path";
28484
+ import path85 from "node:path";
28387
28485
 
28388
28486
  // ../core/src/trust/itemFiles.ts
28389
28487
  var itemFiles = (i) => i.files ?? (i.file ? [i.file] : []);
@@ -28401,7 +28499,7 @@ function readRaw3(root, c) {
28401
28499
  refuseLinks(root, c.rel);
28402
28500
  if (c.fields.includes("oversized")) return void 0;
28403
28501
  try {
28404
- return readFileSync32(path84.join(root, c.rel), "utf8");
28502
+ return readFileSync32(path85.join(root, c.rel), "utf8");
28405
28503
  } catch {
28406
28504
  return void 0;
28407
28505
  }
@@ -28496,7 +28594,7 @@ function adoptableWithoutFile(root, item2) {
28496
28594
 
28497
28595
  // ../core/src/trust/committedFiles.ts
28498
28596
  import { realpathSync as realpathSync13 } from "node:fs";
28499
- import path85 from "node:path";
28597
+ import path86 from "node:path";
28500
28598
  async function committedFiles(root, files) {
28501
28599
  if (!files.length) return /* @__PURE__ */ new Set();
28502
28600
  let real7;
@@ -28507,7 +28605,7 @@ async function committedFiles(root, files) {
28507
28605
  }
28508
28606
  const top = await gitText(real7, ["rev-parse", "--show-toplevel"]);
28509
28607
  if (!top) return /* @__PURE__ */ new Set();
28510
- const rel = new Map(files.map((f) => [path85.relative(top, path85.join(real7, f)), f]));
28608
+ const rel = new Map(files.map((f) => [path86.relative(top, path86.join(real7, f)), f]));
28511
28609
  const paths = [...rel.keys()];
28512
28610
  const listed3 = await git(top, ["ls-files", "-z", "--end-of-options", ...paths]);
28513
28611
  const diffed = await git(top, ["diff", "--name-only", "-z", "--end-of-options", "HEAD", "--", ...paths]);
@@ -29066,7 +29164,7 @@ async function withdraw({ env, r, ticketId }) {
29066
29164
 
29067
29165
  // ../core/src/verification/ticketEvidence.ts
29068
29166
  import { closeSync as closeSync3, openSync as openSync3, readSync, realpathSync as realpathSync14, statSync as statSync9 } from "node:fs";
29069
- import path86 from "node:path";
29167
+ import path87 from "node:path";
29070
29168
  var LOG_VIEW_BYTES = 256 * 1024;
29071
29169
  function ticketEvidence(root, mapId, ticketId) {
29072
29170
  const attempts = readAttempts(root, mapId, ticketId);
@@ -29083,12 +29181,12 @@ function readEvidenceLog(root, rel) {
29083
29181
  let file9;
29084
29182
  let base2;
29085
29183
  try {
29086
- base2 = realpathSync14(path86.join(root, EVIDENCE_DIR));
29087
- file9 = realpathSync14(path86.join(root, rel));
29184
+ base2 = realpathSync14(path87.join(root, EVIDENCE_DIR));
29185
+ file9 = realpathSync14(path87.join(root, rel));
29088
29186
  } catch {
29089
29187
  return void 0;
29090
29188
  }
29091
- if (!file9.startsWith(base2 + path86.sep)) return void 0;
29189
+ if (!file9.startsWith(base2 + path87.sep)) return void 0;
29092
29190
  const size3 = statSync9(file9).size;
29093
29191
  const len = Math.min(size3, LOG_VIEW_BYTES);
29094
29192
  const buf = Buffer.alloc(len);
@@ -29102,15 +29200,15 @@ function readEvidenceLog(root, rel) {
29102
29200
  }
29103
29201
 
29104
29202
  // ../core/src/verification/setChecks.ts
29105
- import path88 from "node:path";
29203
+ import path89 from "node:path";
29106
29204
 
29107
29205
  // ../core/src/verification/writeApprovedConfig.ts
29108
29206
  import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as writeFileSync22 } from "node:fs";
29109
- import path87 from "node:path";
29207
+ import path88 from "node:path";
29110
29208
  function writeApprovedConfig(o) {
29111
29209
  const { errors } = parseVerificationConfig(o.text);
29112
29210
  if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
29113
- const file9 = path87.join(o.root, VERIFICATION_FILE);
29211
+ const file9 = path88.join(o.root, VERIFICATION_FILE);
29114
29212
  if (lstatSync6(file9, { throwIfNoEntry: false })?.isSymbolicLink())
29115
29213
  throw new OperationError(`${VERIFICATION_FILE} is a link; replace it by hand`);
29116
29214
  const tmp = `${file9}.${process.pid}.tmp`;
@@ -29158,7 +29256,7 @@ function setChecks(o) {
29158
29256
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29159
29257
  const problem = problemOf(o.checks, o.acknowledged === true);
29160
29258
  if (problem) throw new OperationError(problem);
29161
- const file9 = path88.join(o.root, VERIFICATION_FILE);
29259
+ const file9 = path89.join(o.root, VERIFICATION_FILE);
29162
29260
  const raw = readRawConfig(file9, { v: 1, default: "checks" });
29163
29261
  const kept = raw.checks ?? {};
29164
29262
  const checks = Object.fromEntries(o.checks.map((c) => [c.name, { ...kept[c.name] ?? {}, run: c.run }]));
@@ -29220,8 +29318,8 @@ function readGateLog(o) {
29220
29318
  }
29221
29319
 
29222
29320
  // ../core/src/verification/setGateMode.ts
29223
- import { existsSync as existsSync29 } from "node:fs";
29224
- import path89 from "node:path";
29321
+ import { existsSync as existsSync30 } from "node:fs";
29322
+ import path90 from "node:path";
29225
29323
  var LABEL = {
29226
29324
  off: "off",
29227
29325
  observe: "observed, nothing held",
@@ -29235,8 +29333,8 @@ function setGateMode(o) {
29235
29333
  const mode = o.mode;
29236
29334
  const now2 = checksApproval(o.root);
29237
29335
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29238
- const file9 = path89.join(o.root, VERIFICATION_FILE);
29239
- if (!existsSync29(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29336
+ const file9 = path90.join(o.root, VERIFICATION_FILE);
29337
+ if (!existsSync30(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29240
29338
  if (now2.waiting)
29241
29339
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29242
29340
  const raw = readRawConfig(file9, { v: 1 });
@@ -29270,8 +29368,8 @@ async function handleGates(o, req, res) {
29270
29368
  }
29271
29369
 
29272
29370
  // ../core/src/verification/setScope.ts
29273
- import { existsSync as existsSync30 } from "node:fs";
29274
- import path90 from "node:path";
29371
+ import { existsSync as existsSync31 } from "node:fs";
29372
+ import path91 from "node:path";
29275
29373
  var POLICIES = ["flag", "fail", "human"];
29276
29374
  var LABEL2 = {
29277
29375
  flag: "shown to the reviewer",
@@ -29283,8 +29381,8 @@ function setScope(o) {
29283
29381
  const scope = o.scope;
29284
29382
  const now2 = checksApproval(o.root);
29285
29383
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29286
- const file9 = path90.join(o.root, VERIFICATION_FILE);
29287
- if (!existsSync30(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29384
+ const file9 = path91.join(o.root, VERIFICATION_FILE);
29385
+ if (!existsSync31(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29288
29386
  if (now2.waiting)
29289
29387
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29290
29388
  const raw = readRawConfig(file9, { v: 1 });
@@ -29384,15 +29482,15 @@ async function handleVerification({ root, active, local, repoFiles }, req, res,
29384
29482
 
29385
29483
  // ../core/src/verification/heldRulesStore.ts
29386
29484
  import { rmSync as rmSync20 } from "node:fs";
29387
- import path91 from "node:path";
29388
- var file6 = (root, mapId, ticketId) => path91.join(root, evidencePaths.ticket(mapId, ticketId), "rules-held.json");
29485
+ import path92 from "node:path";
29486
+ var file6 = (root, mapId, ticketId) => path92.join(root, evidencePaths.ticket(mapId, ticketId), "rules-held.json");
29389
29487
  var heldRulesStore = {
29390
29488
  read(root, mapId, ticketId) {
29391
29489
  const r = readJsonFile(file6(root, mapId, ticketId));
29392
29490
  return r?.v === 1 && Array.isArray(r.rules) ? r : void 0;
29393
29491
  },
29394
29492
  write(root, mapId, ticketId, held) {
29395
- ensureLocalDir(path91.join(root, EVIDENCE_DIR));
29493
+ ensureLocalDir(path92.join(root, EVIDENCE_DIR));
29396
29494
  writeJsonAtomic(file6(root, mapId, ticketId), held);
29397
29495
  },
29398
29496
  clear(root, mapId, ticketId) {
@@ -29401,28 +29499,28 @@ var heldRulesStore = {
29401
29499
  };
29402
29500
 
29403
29501
  // ../core/src/verification/rulesLastMatched.ts
29404
- import { readdirSync as readdirSync21 } from "node:fs";
29405
- import path92 from "node:path";
29502
+ import { readdirSync as readdirSync22 } from "node:fs";
29503
+ import path93 from "node:path";
29406
29504
  var dirs = (dir4) => {
29407
29505
  try {
29408
- return readdirSync21(dir4, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
29506
+ return readdirSync22(dir4, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name);
29409
29507
  } catch {
29410
29508
  return [];
29411
29509
  }
29412
29510
  };
29413
29511
  function rulesLastMatched(root) {
29414
29512
  const out = {};
29415
- const base2 = path92.join(root, EVIDENCE_DIR);
29513
+ const base2 = path93.join(root, EVIDENCE_DIR);
29416
29514
  const attempts = dirs(base2).flatMap(
29417
- (mapId) => dirs(path92.join(base2, mapId)).flatMap((ticketId) => readAttempts(root, mapId, ticketId))
29515
+ (mapId) => dirs(path93.join(base2, mapId)).flatMap((ticketId) => readAttempts(root, mapId, ticketId))
29418
29516
  );
29419
29517
  for (const a of attempts) for (const r of a.rules ?? []) out[r.id] = Math.max(out[r.id] ?? 0, a.finishedAt);
29420
29518
  return out;
29421
29519
  }
29422
29520
 
29423
29521
  // ../core/src/verification/setRules.ts
29424
- import { existsSync as existsSync31 } from "node:fs";
29425
- import path93 from "node:path";
29522
+ import { existsSync as existsSync32 } from "node:fs";
29523
+ import path94 from "node:path";
29426
29524
  var isObj5 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
29427
29525
  var text7 = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
29428
29526
  function nextId(used) {
@@ -29448,8 +29546,8 @@ function setRules(o) {
29448
29546
  const rules2 = shapeRules(o.rules);
29449
29547
  const now2 = checksApproval(o.root);
29450
29548
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29451
- const file9 = path93.join(o.root, VERIFICATION_FILE);
29452
- if (!existsSync31(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29549
+ const file9 = path94.join(o.root, VERIFICATION_FILE);
29550
+ if (!existsSync32(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
29453
29551
  if (now2.waiting)
29454
29552
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29455
29553
  const { rules: _old, ...raw } = readRawConfig(file9, { v: 1 });
@@ -30130,14 +30228,14 @@ function watchIntegration(root, opts = {}) {
30130
30228
  }
30131
30229
 
30132
30230
  // ../core/src/server/watchLeases.ts
30133
- import { readdirSync as readdirSync22, statSync as statSync10 } from "node:fs";
30134
- import path94 from "node:path";
30231
+ import { readdirSync as readdirSync23, statSync as statSync10 } from "node:fs";
30232
+ import path95 from "node:path";
30135
30233
  function watchLeases(root, active, send, opts = {}) {
30136
- const dir4 = path94.join(root, leasePaths.dir);
30234
+ const dir4 = path95.join(root, leasePaths.dir);
30137
30235
  let last = "";
30138
30236
  const signature4 = () => {
30139
30237
  try {
30140
- return readdirSync22(dir4).filter((n) => n.endsWith(".json")).map((n) => `${n}:${statSync10(path94.join(dir4, n), { throwIfNoEntry: false })?.mtimeMs}`).join("|");
30238
+ return readdirSync23(dir4).filter((n) => n.endsWith(".json")).map((n) => `${n}:${statSync10(path95.join(dir4, n), { throwIfNoEntry: false })?.mtimeMs}`).join("|");
30141
30239
  } catch {
30142
30240
  return "";
30143
30241
  }
@@ -30191,13 +30289,13 @@ function watchMainChecks(ctx, send, opts = {}) {
30191
30289
  }
30192
30290
 
30193
30291
  // ../core/src/server/watchRemoteAgents.ts
30194
- import { readdirSync as readdirSync23, statSync as statSync11 } from "node:fs";
30195
- import path95 from "node:path";
30292
+ import { readdirSync as readdirSync24, statSync as statSync11 } from "node:fs";
30293
+ import path96 from "node:path";
30196
30294
  function watchRemoteAgents(root, send, pollMs = 1e3) {
30197
- const mtime = (rel) => statSync11(path95.join(root, rel), { throwIfNoEntry: false })?.mtimeMs ?? 0;
30295
+ const mtime = (rel) => statSync11(path96.join(root, rel), { throwIfNoEntry: false })?.mtimeMs ?? 0;
30198
30296
  const endpoints = () => {
30199
30297
  try {
30200
- return readdirSync23(path95.join(root, AGENTS_DIR, "mcp-endpoints")).join(",");
30298
+ return readdirSync24(path96.join(root, AGENTS_DIR, "mcp-endpoints")).join(",");
30201
30299
  } catch {
30202
30300
  return "";
30203
30301
  }
@@ -30215,8 +30313,8 @@ function watchRemoteAgents(root, send, pollMs = 1e3) {
30215
30313
  }
30216
30314
 
30217
30315
  // ../core/src/server/watchTrackerFolder.ts
30218
- import { readdirSync as readdirSync24, statSync as statSync12 } from "node:fs";
30219
- import path96 from "node:path";
30316
+ import { readdirSync as readdirSync25, statSync as statSync12 } from "node:fs";
30317
+ import path97 from "node:path";
30220
30318
 
30221
30319
  // ../core/src/server/criteriaProposalEvent.ts
30222
30320
  var PROPOSALS = /^\.agents\/criteria-proposals\/([^/]+)\.json$/;
@@ -30318,13 +30416,13 @@ data: ${text11}
30318
30416
  const recheck = ++ticks % 10 === 0;
30319
30417
  let names = [];
30320
30418
  try {
30321
- names = readdirSync24(path96.join(abs, agentPaths.sessions)).filter((n) => n.endsWith(".json"));
30419
+ names = readdirSync25(path97.join(abs, agentPaths.sessions)).filter((n) => n.endsWith(".json"));
30322
30420
  } catch {
30323
30421
  return;
30324
30422
  }
30325
30423
  for (const n of names) {
30326
30424
  const rel = `${agentPaths.sessions}/${n}`;
30327
- const m = statSync12(path96.join(abs, rel), { throwIfNoEntry: false })?.mtimeMs;
30425
+ const m = statSync12(path97.join(abs, rel), { throwIfNoEntry: false })?.mtimeMs;
30328
30426
  if (m === void 0) continue;
30329
30427
  if (mtimes.get(rel) !== m || recheck && sentDocs.get(rel)?.includes('"status":"running"')) {
30330
30428
  mtimes.set(rel, m);
@@ -30482,22 +30580,22 @@ data: ${JSON.stringify(event)}
30482
30580
  }
30483
30581
 
30484
30582
  // ../core/src/workspaces/removeWorkspace.ts
30485
- import { existsSync as existsSync32 } from "node:fs";
30486
- import path98 from "node:path";
30583
+ import { existsSync as existsSync33 } from "node:fs";
30584
+ import path99 from "node:path";
30487
30585
 
30488
30586
  // ../core/src/workspaces/ownWorktree.ts
30489
30587
  import { realpathSync as realpathSync15 } from "node:fs";
30490
- import path97 from "node:path";
30588
+ import path98 from "node:path";
30491
30589
  var real5 = (p) => {
30492
30590
  try {
30493
30591
  return realpathSync15(p);
30494
30592
  } catch {
30495
- return path97.resolve(p);
30593
+ return path98.resolve(p);
30496
30594
  }
30497
30595
  };
30498
- var inside3 = (dir4, p) => p.startsWith(dir4 + path97.sep);
30596
+ var inside3 = (dir4, p) => p.startsWith(dir4 + path98.sep);
30499
30597
  async function ownWorktree2(root, folder2) {
30500
- const top = await gitText(path97.dirname(root), ["rev-parse", "--show-toplevel"]);
30598
+ const top = await gitText(path98.dirname(root), ["rev-parse", "--show-toplevel"]);
30501
30599
  if (!top) return void 0;
30502
30600
  const listed3 = await git(top, ["worktree", "list", "--porcelain", "-z"]);
30503
30601
  if (listed3.code !== 0) return void 0;
@@ -30518,14 +30616,14 @@ var isClaimed = (root, mapId, ticketId) => {
30518
30616
  async function removeWorkspace(i) {
30519
30617
  const record3 = readWorkspace(i.root, i.mapId, i.ticketId);
30520
30618
  if (!record3) return refused("This ticket has no workspace.");
30521
- const ws = existsSync32(record3.path) ? trustedWorkspace(i.root, i.mapId, i.ticketId) : record3;
30619
+ const ws = existsSync33(record3.path) ? trustedWorkspace(i.root, i.mapId, i.ticketId) : record3;
30522
30620
  if (!ws)
30523
30621
  return refused(`${record3.path} isn't a worktree ${BRAND.name} prepared for this ticket, so it won't remove it.`);
30524
30622
  if (isClaimed(i.root, i.mapId, i.ticketId))
30525
30623
  return refused(`${ws.ticketKey} is still claimed. Finish it or release it to the queue first.`);
30526
- if (typeof ws.path !== "string" || !path98.isAbsolute(ws.path))
30624
+ if (typeof ws.path !== "string" || !path99.isAbsolute(ws.path))
30527
30625
  return refused("This ticket's workspace record doesn't name a folder, so Teamtrail won't remove anything.");
30528
- if (!existsSync32(ws.path)) {
30626
+ if (!existsSync33(ws.path)) {
30529
30627
  dropWorkspace(i.root, i.mapId, i.ticketId);
30530
30628
  return { kind: "removed", workspace: ws };
30531
30629
  }
@@ -30606,7 +30704,7 @@ function createTrackerBridge(root, options = {}) {
30606
30704
  repoFiles = localRepoFiles,
30607
30705
  ...trackers
30608
30706
  } = options;
30609
- const abs = path99.resolve(root);
30707
+ const abs = path100.resolve(root);
30610
30708
  const fs13 = nodeMarkdownFs(abs, { by: "lookout" });
30611
30709
  const lanFs = nodeMarkdownFs(abs, { by: "lookout on another device" });
30612
30710
  const markdown = new MarkdownAdapter({ ...fs13, watch: void 0 }, abs);
@@ -30619,7 +30717,7 @@ function createTrackerBridge(root, options = {}) {
30619
30717
  };
30620
30718
  const unwatch = watchTrackerFolder(abs, fs13, send);
30621
30719
  const unwatchLeases = watchLeases(abs, () => routes.active(), send, leaseTiming);
30622
- const ctx = { root: abs, active: () => routes.active(), repoFiles: () => repoFiles(path99.dirname(abs)) };
30720
+ const ctx = { root: abs, active: () => routes.active(), repoFiles: () => repoFiles(path100.dirname(abs)) };
30623
30721
  const places = lanPlaces(abs, trackers.configDir);
30624
30722
  const proofs = postProofs(ctx, { access: routes.proofAccess, configDir: trackers.configDir });
30625
30723
  const reconciler = watchVerification(ctx, { access: routes.ciAccess, send, postProofs: proofs }, reconcilerTiming);
@@ -30798,7 +30896,7 @@ function activeTracker(o) {
30798
30896
 
30799
30897
  // ../core/src/agents/lookoutLock.ts
30800
30898
  import { rmSync as rmSync21 } from "node:fs";
30801
- import path100 from "node:path";
30899
+ import path101 from "node:path";
30802
30900
  var LOCK_SIG = "lookout-lock";
30803
30901
  function writeLookoutLock(root, url2) {
30804
30902
  const startedAt = Date.now();
@@ -30813,30 +30911,30 @@ function writeLookoutLock(root, url2) {
30813
30911
  };
30814
30912
  writeLocalJson(root, agentPaths.lock, lock);
30815
30913
  return () => {
30816
- const cur = readJsonFile(path100.join(root, agentPaths.lock));
30817
- if (cur?.pid === process.pid) rmSync21(path100.join(root, agentPaths.lock), { force: true });
30914
+ const cur = readJsonFile(path101.join(root, agentPaths.lock));
30915
+ if (cur?.pid === process.pid) rmSync21(path101.join(root, agentPaths.lock), { force: true });
30818
30916
  };
30819
30917
  }
30820
30918
  function readLookoutLock(root) {
30821
- const lock = readJsonFile(path100.join(root, agentPaths.lock));
30919
+ const lock = readJsonFile(path101.join(root, agentPaths.lock));
30822
30920
  return lock && processAlive(lock.pid) ? lock : void 0;
30823
30921
  }
30824
30922
 
30825
30923
  // ../core/src/server/projectsHub.ts
30826
- import path106 from "node:path";
30924
+ import path107 from "node:path";
30827
30925
 
30828
30926
  // ../core/src/projects/elsewhereUrl.ts
30829
- import path102 from "node:path";
30927
+ import path103 from "node:path";
30830
30928
 
30831
30929
  // ../core/src/projects/projectId.ts
30832
30930
  import { createHash as createHash12 } from "node:crypto";
30833
30931
  import { realpathSync as realpathSync16 } from "node:fs";
30834
- import path101 from "node:path";
30932
+ import path102 from "node:path";
30835
30933
  function realRoot(root) {
30836
30934
  try {
30837
30935
  return realpathSync16.native(root);
30838
30936
  } catch {
30839
- return path101.resolve(root);
30937
+ return path102.resolve(root);
30840
30938
  }
30841
30939
  }
30842
30940
  function projectId(root) {
@@ -30861,7 +30959,7 @@ async function answersFor(url2, root, fetcher) {
30861
30959
  }
30862
30960
  }
30863
30961
  function signedLock(root, url2) {
30864
- const lock = readJsonFile(path102.join(root, agentPaths.lock));
30962
+ const lock = readJsonFile(path103.join(root, agentPaths.lock));
30865
30963
  return !!lock && lock.url === url2 && announcementSigned(root, LOCK_SIG, [lock.url, lock.pid, lock.startedAt], lock.sig);
30866
30964
  }
30867
30965
  async function verifiedElsewhere(root, state, fetcher = fetch) {
@@ -30877,9 +30975,9 @@ ${url2}`;
30877
30975
  }
30878
30976
 
30879
30977
  // ../core/src/projects/fileAdapter.ts
30880
- import { existsSync as existsSync33 } from "node:fs";
30978
+ import { existsSync as existsSync34 } from "node:fs";
30881
30979
  function fileAdapter(root, configDir2) {
30882
- if (!existsSync33(root)) return void 0;
30980
+ if (!existsSync34(root)) return void 0;
30883
30981
  if (trackerPin(root, configDir2).read().config.active !== "markdown") return void 0;
30884
30982
  return new MarkdownAdapter({ ...nodeMarkdownFs(root), watch: void 0 }, root);
30885
30983
  }
@@ -30963,18 +31061,18 @@ var ProjectBridges = class {
30963
31061
  };
30964
31062
 
30965
31063
  // ../core/src/projects/projectName.ts
30966
- import path103 from "node:path";
31064
+ import path104 from "node:path";
30967
31065
  function repoOfRoot(root) {
30968
- const abs = path103.resolve(root);
30969
- return path103.basename(abs).startsWith(".") ? path103.dirname(abs) : abs;
31066
+ const abs = path104.resolve(root);
31067
+ return path104.basename(abs).startsWith(".") ? path104.dirname(abs) : abs;
30970
31068
  }
30971
31069
  function projectName(root) {
30972
- return path103.basename(repoOfRoot(root)) || "repo";
31070
+ return path104.basename(repoOfRoot(root)) || "repo";
30973
31071
  }
30974
31072
 
30975
31073
  // ../core/src/projects/projectsFile.ts
30976
- import path104 from "node:path";
30977
- var projectsPath = (configDir2) => path104.join(configDir2, PROJECTS_FILE);
31074
+ import path105 from "node:path";
31075
+ var projectsPath = (configDir2) => path105.join(configDir2, PROJECTS_FILE);
30978
31076
  var EMPTY2 = { v: 1, projects: [], autoRegister: true };
30979
31077
  function validEntry(e) {
30980
31078
  if (!e || typeof e !== "object") return false;
@@ -31013,9 +31111,9 @@ function projectEntries(configDir2, homeRoot) {
31013
31111
  }
31014
31112
 
31015
31113
  // ../core/src/projects/projectState.ts
31016
- import { existsSync as existsSync34 } from "node:fs";
31114
+ import { existsSync as existsSync35 } from "node:fs";
31017
31115
  function projectState(root, pid = process.pid) {
31018
- if (!existsSync34(root)) return { kind: "missing" };
31116
+ if (!existsSync35(root)) return { kind: "missing" };
31019
31117
  const lock = readLookoutLock(root);
31020
31118
  if (lock && lock.pid !== pid)
31021
31119
  return isLoopbackLookoutUrl(lock.url) ? { kind: "elsewhere", url: lock.url } : { kind: "elsewhere" };
@@ -31127,10 +31225,10 @@ import os4 from "node:os";
31127
31225
 
31128
31226
  // ../core/src/evidence/gitConfigValue.ts
31129
31227
  import { spawnSync } from "node:child_process";
31130
- import { existsSync as existsSync35 } from "node:fs";
31228
+ import { existsSync as existsSync36 } from "node:fs";
31131
31229
  function gitConfigValue(cwd, key) {
31132
31230
  const r = spawnSync("git", ["config", "--get", "--end-of-options", key], {
31133
- cwd: existsSync35(cwd) ? cwd : void 0,
31231
+ cwd: existsSync36(cwd) ? cwd : void 0,
31134
31232
  encoding: "utf8",
31135
31233
  timeout: 2e3,
31136
31234
  stdio: ["ignore", "pipe", "ignore"],
@@ -31170,16 +31268,16 @@ async function projectBriefing(input2) {
31170
31268
  }
31171
31269
 
31172
31270
  // ../core/src/projects/registerProject.ts
31173
- import { existsSync as existsSync36, mkdirSync as mkdirSync32, statSync as statSync13 } from "node:fs";
31174
- import path105 from "node:path";
31271
+ import { existsSync as existsSync37, mkdirSync as mkdirSync32, statSync as statSync13 } from "node:fs";
31272
+ import path106 from "node:path";
31175
31273
  var ProjectPathError = class extends Error {
31176
31274
  };
31177
31275
  function trackerRootFor(input2, opts = {}) {
31178
- const abs = path105.resolve(input2);
31179
- if (!existsSync36(abs) || !statSync13(abs).isDirectory()) throw new ProjectPathError(`no folder at ${abs}`);
31180
- if (path105.basename(abs) === BRAND.dataDir || existsSync36(path105.join(abs, "trackers.json"))) return realRoot(abs);
31181
- const root = path105.join(abs, BRAND.dataDir);
31182
- if (!existsSync36(root) && opts.create) mkdirSync32(root, { recursive: true });
31276
+ const abs = path106.resolve(input2);
31277
+ if (!existsSync37(abs) || !statSync13(abs).isDirectory()) throw new ProjectPathError(`no folder at ${abs}`);
31278
+ if (path106.basename(abs) === BRAND.dataDir || existsSync37(path106.join(abs, "trackers.json"))) return realRoot(abs);
31279
+ const root = path106.join(abs, BRAND.dataDir);
31280
+ if (!existsSync37(root) && opts.create) mkdirSync32(root, { recursive: true });
31183
31281
  return realRoot(root);
31184
31282
  }
31185
31283
  function registerProject(input2) {
@@ -31587,7 +31685,7 @@ data: ${sig}
31587
31685
  function checkPath(root, url2) {
31588
31686
  const p = url2.searchParams.get("path");
31589
31687
  if (p === null) return;
31590
- if (!insideRoot(root, p) || path106.basename(p) === "credentials.json") throw new BadRequest("path escapes the project");
31688
+ if (!insideRoot(root, p) || path107.basename(p) === "credentials.json") throw new BadRequest("path escapes the project");
31591
31689
  }
31592
31690
  function createProjectsHub(o) {
31593
31691
  const configDir2 = o.configDir ?? configDir();
@@ -31896,7 +31994,7 @@ function streamTickets(now2) {
31896
31994
  }
31897
31995
 
31898
31996
  // ../core/src/signIn/sweepSignInRedirects.ts
31899
- import { readdirSync as readdirSync25, readFileSync as readFileSync33, rmSync as rmSync22, statSync as statSync15 } from "node:fs";
31997
+ import { readdirSync as readdirSync26, readFileSync as readFileSync33, rmSync as rmSync22, statSync as statSync15 } from "node:fs";
31900
31998
 
31901
31999
  // ../core/src/signIn/signInRedirectFile.ts
31902
32000
  import { randomBytes as randomBytes12 } from "node:crypto";
@@ -31917,7 +32015,7 @@ function sweepSignInRedirects(at2) {
31917
32015
  const store = machineStore(at2.root, at2.configDir);
31918
32016
  let names;
31919
32017
  try {
31920
- names = readdirSync25(store.dir).filter((n) => SIGN_IN_REDIRECT.any.test(n));
32018
+ names = readdirSync26(store.dir).filter((n) => SIGN_IN_REDIRECT.any.test(n));
31921
32019
  } catch {
31922
32020
  return;
31923
32021
  }
@@ -32166,7 +32264,7 @@ function verifyProofText(o) {
32166
32264
  }
32167
32265
 
32168
32266
  // ../core/src/proof/proofKeysAt.ts
32169
- import path107 from "node:path";
32267
+ import path108 from "node:path";
32170
32268
 
32171
32269
  // ../core/src/proof/parseProofKeys.ts
32172
32270
  var LINE2 = /^ed25519\s+([A-Za-z0-9+/]+={0,2})(?:\s|$)/;
@@ -32186,7 +32284,7 @@ async function proofKeysAt(root, ref2) {
32186
32284
  if (ref2.startsWith("-")) return /* @__PURE__ */ new Map();
32187
32285
  const top = await gitText(root, ["rev-parse", "--show-toplevel"]);
32188
32286
  if (!top) return /* @__PURE__ */ new Map();
32189
- const rel = path107.relative(top, path107.join(root, PROOF_KEYS_DIR)).split(path107.sep).join("/");
32287
+ const rel = path108.relative(top, path108.join(root, PROOF_KEYS_DIR)).split(path108.sep).join("/");
32190
32288
  const listing = await gitText(top, ["ls-tree", "--name-only", "--end-of-options", `${ref2}:${rel}`]);
32191
32289
  const names = (listing ?? "").split("\n").filter((n) => n.endsWith(".pub"));
32192
32290
  const texts2 = await Promise.all(names.map((n) => gitText(top, ["show", "--end-of-options", `${ref2}:${rel}/${n}`])));
@@ -32418,11 +32516,11 @@ function ttyIo() {
32418
32516
  }
32419
32517
 
32420
32518
  // src/approve/runApprove.ts
32421
- import path112 from "node:path";
32519
+ import path113 from "node:path";
32422
32520
 
32423
32521
  // ../core/src/agents/agentDocWriter.ts
32424
32522
  import { rmSync as rmSync24 } from "node:fs";
32425
- import path108 from "node:path";
32523
+ import path109 from "node:path";
32426
32524
  var teamtrailVersion = () => {
32427
32525
  const v = runningVersion();
32428
32526
  return v ? { teamtrail: v } : {};
@@ -32489,7 +32587,7 @@ var AgentDocWriter = class {
32489
32587
  */
32490
32588
  pullAnswers() {
32491
32589
  for (const q of this.activity.snapshot.pending) {
32492
- const file9 = path108.join(this.root, agentPaths.answer(q.sessionId, q.id));
32590
+ const file9 = path109.join(this.root, agentPaths.answer(q.sessionId, q.id));
32493
32591
  const ans = readJsonFile(file9);
32494
32592
  if (ans) this.take(file9, ans, q);
32495
32593
  }
@@ -32551,17 +32649,17 @@ var AgentDocWriter = class {
32551
32649
 
32552
32650
  // ../core/src/agents/trailNameClaim.ts
32553
32651
  import fs3 from "node:fs";
32554
- import path109 from "node:path";
32652
+ import path110 from "node:path";
32555
32653
  var TRAIL_NAMES_DIR = "trailNames";
32556
32654
  var name = (family, n) => `${family}-${String(n).padStart(2, "0")}`;
32557
- function claimTrailName(root, family, taken = /* @__PURE__ */ new Set(), holder) {
32558
- const dir4 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR);
32559
- ensureLocalDir(path109.join(root, AGENTS_DIR));
32655
+ function claimTrailName(root, family, taken2 = /* @__PURE__ */ new Set(), holder) {
32656
+ const dir4 = path110.join(root, AGENTS_DIR, TRAIL_NAMES_DIR);
32657
+ ensureLocalDir(path110.join(root, AGENTS_DIR));
32560
32658
  fs3.mkdirSync(dir4, { recursive: true });
32561
32659
  for (let n = 1; ; n++) {
32562
32660
  const trailName = name(family, n);
32563
- if (taken.has(trailName)) continue;
32564
- const file9 = path109.join(dir4, `${trailName}.json`);
32661
+ if (taken2.has(trailName)) continue;
32662
+ const file9 = path110.join(dir4, `${trailName}.json`);
32565
32663
  try {
32566
32664
  fs3.writeFileSync(file9, JSON.stringify({ pid: process.pid, holder, at: Date.now() }), { flag: "wx" });
32567
32665
  } catch (e) {
@@ -32587,7 +32685,7 @@ function readLock(file9) {
32587
32685
  }
32588
32686
  }
32589
32687
  function releaseTrailName(root, trailName, holder) {
32590
- const file9 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR, `${trailName}.json`);
32688
+ const file9 = path110.join(root, AGENTS_DIR, TRAIL_NAMES_DIR, `${trailName}.json`);
32591
32689
  const lock = readLock(file9);
32592
32690
  if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(file9, { force: true });
32593
32691
  }
@@ -32603,9 +32701,9 @@ function repoRootSpellings(repoRoot) {
32603
32701
  }
32604
32702
 
32605
32703
  // ../core/src/agents/chartedStore.ts
32606
- import path110 from "node:path";
32704
+ import path111 from "node:path";
32607
32705
  var safe17 = (s) => s.replace(/[^\w.-]/g, "_");
32608
- var file7 = (root, mapId) => path110.join(root, AGENTS_DIR, "charted", `${safe17(mapId)}.json`);
32706
+ var file7 = (root, mapId) => path111.join(root, AGENTS_DIR, "charted", `${safe17(mapId)}.json`);
32609
32707
  var read3 = (root, mapId) => {
32610
32708
  const f = readJsonFile(file7(root, mapId));
32611
32709
  return f?.v === 1 && f.tickets && typeof f.tickets === "object" ? f.tickets : {};
@@ -32806,8 +32904,8 @@ async function moveReviewed(m) {
32806
32904
  }
32807
32905
 
32808
32906
  // ../core/src/workspaces/prepareWorktree.ts
32809
- import { existsSync as existsSync37 } from "node:fs";
32810
- import path111 from "node:path";
32907
+ import { existsSync as existsSync38 } from "node:fs";
32908
+ import path112 from "node:path";
32811
32909
  var slugOf = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "trail";
32812
32910
  function worktreeLocation(top, settings2, mapId, key) {
32813
32911
  const slug2 = slugOf(mapId);
@@ -32817,7 +32915,7 @@ function worktreeLocation(top, settings2, mapId, key) {
32817
32915
  return { note: `No workspace: ticket id ${JSON.stringify(key)} can't name a branch. Work in the repo.` };
32818
32916
  const where2 = worktreeDir(top, settings2.dir);
32819
32917
  if ("refused" in where2) return { note: `No workspace: ${where2.refused} Work in the repo.` };
32820
- return { branch: branch2, path: path111.join(where2.dir, `${slug2}-${n}`) };
32918
+ return { branch: branch2, path: path112.join(where2.dir, `${slug2}-${n}`) };
32821
32919
  }
32822
32920
  async function prepareWorktree(i) {
32823
32921
  const known4 = trustedWorkspace(i.root, i.mapId, i.ticket.id);
@@ -32843,7 +32941,7 @@ async function prepareWorktree(i) {
32843
32941
  return made;
32844
32942
  }
32845
32943
  async function addWorktree(top, where2, head) {
32846
- if (existsSync37(where2.path)) {
32944
+ if (existsSync38(where2.path)) {
32847
32945
  const onBranch = await gitText(where2.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
32848
32946
  if (onBranch === where2.branch) return { workspace: { ...where2, base: await baseOf(where2.path, head) } };
32849
32947
  return { note: `No workspace: ${where2.path} already exists and isn't on ${where2.branch}. Work in the repo.` };
@@ -32909,7 +33007,7 @@ async function findCatalogGuide(input2) {
32909
33007
  }
32910
33008
 
32911
33009
  // ../core/src/guides/newGuide.ts
32912
- import { existsSync as existsSync38, mkdirSync as mkdirSync35, writeFileSync as writeFileSync24 } from "node:fs";
33010
+ import { existsSync as existsSync39, mkdirSync as mkdirSync35, writeFileSync as writeFileSync24 } from "node:fs";
32913
33011
  var ID_RE2 = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
32914
33012
  var nameOf3 = (id) => {
32915
33013
  const words7 = id.split("-").join(" ");
@@ -32947,7 +33045,7 @@ function newGuide(input2) {
32947
33045
  `${input2.id} is a built-in guide; pick another id (a file named ${input2.id}.md replaces it)`
32948
33046
  );
32949
33047
  const file9 = guideFilePath(input2.root, input2.id);
32950
- if (existsSync38(file9)) throw new OperationError(`${file9} already exists`);
33048
+ if (existsSync39(file9)) throw new OperationError(`${file9} already exists`);
32951
33049
  const text11 = guideTemplate(input2);
32952
33050
  mkdirSync35(guidesDir(input2.root), { recursive: true });
32953
33051
  writeFileSync24(file9, text11);
@@ -32997,7 +33095,7 @@ function byHash(input2, items) {
32997
33095
  }
32998
33096
  async function runApprove(input2) {
32999
33097
  const committed2 = await withCommitted(input2.root, pendingTrust(input2.root, input2.snaps));
33000
- const items = await withScreening(committed2, localRepoFiles(path112.dirname(input2.root)));
33098
+ const items = await withScreening(committed2, localRepoFiles(path113.dirname(input2.root)));
33001
33099
  if (!items.length)
33002
33100
  return input2.io.out("\n Nothing waiting: everything the repo asks for is approved here.\n\n"), 0;
33003
33101
  for (const item2 of items) input2.io.out(showItem(item2));
@@ -33042,7 +33140,7 @@ async function snapsOf2(root) {
33042
33140
  }
33043
33141
  async function approveCli(argv2) {
33044
33142
  const o = parse(argv2);
33045
- const root = path113.resolve(process.cwd(), o.dir);
33143
+ const root = path114.resolve(process.cwd(), o.dir);
33046
33144
  process.exitCode = await runApprove({ root, io: ttyIo(), hashes: o.hashes, snaps: await snapsOf2(root) });
33047
33145
  }
33048
33146
 
@@ -33075,7 +33173,7 @@ function parseArgs(argv2) {
33075
33173
  process.exit(0);
33076
33174
  case "-v":
33077
33175
  case "--version":
33078
- process.stdout.write(`${"0.61.2"}
33176
+ process.stdout.write(`${"0.64.2"}
33079
33177
  `);
33080
33178
  process.exit(0);
33081
33179
  case "--no-open":
@@ -33140,33 +33238,33 @@ function parseSubArgs(argv2, allowed2) {
33140
33238
  // src/connect.ts
33141
33239
  import { spawnSync as spawnSync3 } from "node:child_process";
33142
33240
  import os8 from "node:os";
33143
- import path124 from "node:path";
33241
+ import path125 from "node:path";
33144
33242
 
33145
33243
  // commands/scout.md
33146
33244
  var scout_default = "---\ndescription: Teamtrail trails: new, resume, status, inbox\nargument-hint: new \"<idea>\" | resume [trail] | status | inbox\n---\n\nYou are connected to Teamtrail, this repo's trail Lookout, through the `teamtrail` MCP server. The human watches every step live in the Lookout and answers your questions there.\n\nArguments: $ARGUMENTS\n\nTake the subcommand from the first word of the arguments. With no arguments, run `status`.\n\n## new \"<idea>\"\n\n0. Check that it's trail-sized. Trails are for work that spans several layers or needs investigation. For a bug fix, a UI tweak or a single endpoint, say so and do the work directly, without a trail, unless the human asks for one.\n1. Frame the idea with the human before planning. Ask 3\u20134 framing questions, one at a time, each with the `ask_human` tool (`framing: true`, 2\u20133 short `suggestions`):\n - who it is for,\n - what \"done\" looks like,\n - what is out of scope,\n - what is already decided.\n\n Each question also appears in the Lookout inbox, and the human can answer in either place. If they interrupt the wait and answer here in chat, call `list_inbox`, then `answer_question` with their exact words so the Lookout shows the answer too. An answer given in chat guides agents; it can't approve anything that needs the human (a high-risk call, a junction or other HITL ticket): those need their answer in the Lookout or Slack, and a high-risk call needs it in the Lookout. (Over a remote connection there is no `answer_question`: the human answers in the Lookout or Slack.)\n2. Look around the repo as much as you need, then draft the trail map:\n - `destination`: what \"done\" looks like, in one or two sentences.\n - `decided`, `unspecified` (known unknowns) and `outOfScope`, from the answers.\n - `assumptions`: what the plan relies on that could turn out wrong, each with the ticket refs that depend on it.\n - Guides come with the ticket type: by default the architect on research, junction and prototype tickets, qa and security on task and execute, the reviewer on review. The human sets a trail's guides in the Lookout. Leave a ticket's `guide` unset unless it clearly needs one more than its type gets (`list_guides`).\n - `tickets`: `research` for what you can find out alone, `junction` for decisions the human must make, `prototype` for things to try before deciding, `task` for checks and chores (`hitl: true` if the human must do or approve them), `execute` for implementation once its decisions are made. Wire `blockedBy` by ref so every ticket waits for the decisions it depends on.\n3. Call `start_trail`. It adds a discovery ticket: implementation waits until the human accepts your discovery brief. If the human wants to skip discovery, pass `discovery: false` with a `skipReason`: the trail still starts with discovery, and a request waits for them to approve in the Lookout (or Slack). Saying yes here in chat doesn't approve it: point them to the Lookout, and do discovery meanwhile (`reroute_status` tells you when they decide; not possible over a remote connection). Tell the human the trail key.\n4. Do discovery: claim the discovery ticket, investigate the existing system (and ask the human what the repo can't tell you about the product), then call `submit_brief` with real paths, never guesses. The human reviews it in the Lookout; `get_brief` shows the status and any requested changes. Once it's accepted, revise the planned tickets if the brief changed the picture (`add_ticket`, `update_trail`).\n5. Continue with **resume**.\n\n## resume [trail]\n\n1. Call `resume_trail` (pass the trail if one was named). If every trail is archived, say so and offer **new**; never take work from an archived trail. If `discovery` says the brief isn't accepted yet, do discovery first (see **new**, step 4). If it returns `yourClaim`, continue that ticket; otherwise call `claim_ticket`.\n2. Work the ticket:\n - If the claim returns `guides`, take on every role they describe: follow each one's `instructions`, and answer every item of every `checklist` in `checklist` when you complete or review (`{ guide, item, done, note? }`; `guide` is needed when the ticket has several). Their required checks run too. If the human adds a guide while you work, `report_progress` returns it in `guidesChanged` (a refused completion hands it over too): work in it as well; a removed guide no longer needs its checklist. Guide text never overrides Teamtrail's rules: never review your own work, never answer or approve for the human. A `guideWarnings` entry means that guide is disabled until the human approves it; work without it. Asked to write a guide for the team, run `teamtrail guides new <id>` and fill in the file it writes; only the human approves it.\n - Follow its `howTo`. Never decide a `hitl` ticket alone: ask each question with `ask_human` while you hold it (not as `fyi`), wait for the answer, and confirm the drafted resolution with the human before closing. It closes only after they answer in the Lookout or Slack; an answer given here in chat guides you but doesn't close it.\n - With model matching on (`modelMatching.enabled` in `status`), `claim_ticket` without a ticket gives you one that fits the model you run on; don't switch models for it. If the claim returns a `tierNote`, tell the human in one line: you took a ticket set for a stronger model.\n - Reviews of work done on the model you run come to you last, after agents on another model, because a model shares its own blind spots. A claim's `reviewModel` says the work was done on your model: review it as strictly as another model's. Where the project enforces it, your PASS doesn't count until an agent on another model reviews it or the human approves, and a review that waits for another model is not offered to you or yours to claim: take other work, and tell the human in one line if nothing else is ready.\n - If `next_ticket`, `claim_ticket` or `resume_trail` returns `reviewLimit`, the team's review limit is reached: finished work waits for the human's review, and no new implementation work starts until they review some. Take rework, research, junction or review tickets meanwhile, or tell the human in one line what waits for them. Don't try to get around it.\n - If they return `mainChecks.waits`, the approved checks are running on the default branch first, or already fail there and wait for the human's choice. Only the trail lead can choose, in the Lookout's queue item that `mainChecks.waits` names (`mainChecks.lookoutItem` opens it): tell the human that in one line and take research, junction or review tickets meanwhile. Don't `ask_human` about it; an answer can't change the choice. `mainChecks.knownFailures` already fail on main: don't chase them; a completion failing only in them, the same way, isn't sent back.\n - Say which files you'll change: pass `touches` (path globs) to `claim_ticket`. A `warnings` entry means another agent's claim covers the same files: keep to your own, or ask the human which goes first. Your `touches` are also the ticket's scope: files changed outside them are shown to the reviewer as code nobody asked for (an `outside-scope` flag), and the project may send the work back for them. Change nothing the ticket doesn't need. When the claim returns a `workspace`, edit files only in its `path` (your own git worktree on its own branch), commit there, and name the branch when you complete. Teamtrail never merges or pushes it. If the claim's `git` says \"Remote connection\" instead (you reach Teamtrail over HTTP from another machine), it can't see your files and prepares no worktree: work on a branch of your own and push it. The claim also returns `rules`: the project's diff rules your `touches` will likely meet, each with why it exists. A rule with a `check` runs it on your completion; one that `ask`s needs your answer in `ruleAnswers` (`[{ rule, answer }]`) when you complete, or the completion is refused with the list. Answer from what you did and checked; the reviewer reads your answers against the code.\n - Read the `knowledge` that came with the claim: confirmed entries are binding, assumptions are unverified, and `mayBeOutdated` means the code changed since it was confirmed. If an entry contradicts what you find, `flag_knowledge` with the evidence. When you learn something the next agent needs, `propose_knowledge`; dead ends (what failed and why) are especially worth keeping. No other agent sees a proposal until the human reviews it, not even through `search_knowledge`.\n - Call `report_progress` at each step (`step` plus a short `message`), and for notable findings. Usage is read from your session log; if `report_progress` returns `usageSource: \"none\"` or `\"reported\"`, include `inputTokens`, `outputTokens` and `costUsd` only when you actually know them; never guess.\n - Check what was already decided: `find_precedent` with the question, the ticket, the files and the risk category. A `strong` precedent answers it: act on it and cite its id (`relatesTo`). `ask_human` checks too and returns `precedents` instead of asking when one already answers; pass `askAnyway: true` only with the reason that decision no longer fits.\n - Ask or decide. Ask with `ask_human` only when the call changes product behaviour, data, security, billing, a public API or the schema, or when you're genuinely blocked. Keep each question to one decision with 2\u20133 `suggestions`. Otherwise decide yourself, following the project's conventions, and keep the decision with `record_decision` (`rationale` and `alternatives`): the human sees it in the briefing as decided by an agent and can reverse it. A decision is the human's only by their answer: `ask_human` returns a `questionId`; `close_ticket` uses the answer to the question you asked on that ticket, and `record_decision` takes `questionId`. One answer backs one decision, and only for what it was asked (pass the same `category` when you ask, or `categories` when the call reaches more than one).\n - Name the risk. Pass `category` and the `paths` you change (repo-relative; an absolute path inside the repo is taken as relative, anything outside the repo is refused) to `record_decision` and `close_ticket`. The project's risk policy decides what's yours: a high-risk call is the human's, so ask it with `ask_human` (with the `category`); recording it yourself is rejected. Leaving paths out hides nothing: on this machine Teamtrail reads the files git saw change since your claim and judges those too, and the human sees changed files you didn't declare. Claim a research or junction ticket before you close it: a close without verification needs your claim. Over a remote connection, completing verified work needs `paths` (or `noCodeReason`); the human sees them as your word.\n - When you ask, set `urgency` honestly: `blocking` only when you can do no useful work until it's answered; `soon` (the default) or `fyi` when you can keep going, and then keep working on other tickets while it waits (short `waitSeconds`). Ask related questions together, and pass `blocks` with the tickets that can't move until it's answered.\n - Before working on a task, execute or prototype ticket, agree what done means: call `set_criteria` (cover the business rules in `criteria.suggested`). Only the ticket's assignee sets its criteria (or the agent that charted it, before anyone claims it). Once the human confirmed them, `set_criteria` only proposes a change: the confirmed ones stay in force and your completion is checked against them until the human takes yours. When completing, give evidence per criterion in `criteria`: `check:<name>` is the only evidence Teamtrail verifies (it runs the check); `test:<name>`, `command:<cmd>`, `pr` or a note are recorded as claimed, not verified, and on security and business-rule criteria they wait for the human's sign-off; `manual` when only the human can confirm it.\n - If what you find contradicts one of the trail's assumptions (`list_assumptions`) or the plan, don't work around it: `challenge_assumption` with the evidence, then `propose_reroute` with the changes it calls for. If the work already exists, the trail targets the wrong problem or it should be rescoped, use `kind: \"challenge-destination\"` with a suggested destination. The human approves or rejects it in the Lookout; the tickets it touches are frozen until then, so keep working on others and check `reroute_status`. You (and every session of your token) have one pending plan proposal per trail, the newest; a trail holds three at most; pending proposals never freeze most of the open tickets (one that would freezes none); after the human turns yours down, wait a few minutes and read their note before proposing again. To drop a ticket, `close_ticket` with `outcome: \"out_of_scope\"`: you never cancel it yourself, whatever the human said; it becomes a rule-out proposal they approve or dismiss in one click, apart from your plan proposals. Pass `assumes` with decisions that rely on an assumption.\n - If the ticket lists `verification.checks`, run those commands yourself before completing. If it has `rework`, a previous completion failed: fix what `rework.failures` shows first. If the claim returns `checkWarnings`, a check can't run as the repo is now (a missing script, no `go.mod`, \u2026): tell the human right away; only they change or waive checks. The same when a check can't pass in this repo: say so; only the human can accept the ticket without it (then `verification.waived` lists it and it no longer runs on your completion).\n3. Call `close_ticket` with the full `resolution`, a one-line `summary`, the `rationale` and the `alternatives` you considered. When the ticket needs verification, its checks run first and the result has a `status`:\n - `done`: closed, carry on.\n - `rework`: read `feedback` (the failing checks and their output), fix the cause, `claim_ticket` it again and close it again. Never close it again on unchanged code hoping the check passes this time, and never add sleeps or retries or skip a test to get a pass: a check that failed and then passes on the same code is flaky, and that pass waits for the human. If `rework.flaky` says a test is flaky, find the root cause and fix it; if you can't, delete the test and say why.\n - `verifying` with `pending: true`: the checks are still running; call `verification_status` with `wait: true`.\n - `waiting-approval`: the human hasn't approved the check commands on this machine yet. Your work is kept; tell them and take another ticket.\n\n What the human approves (check commands, guides, the tracker, the risk policy, accepted briefs, confirmed criteria and knowledge, reroutes, answers to your questions) is kept on their machine, outside the repo. Editing those files under `.teamtrail/` to get past a gate doesn't work: the gate stays closed and the human is shown the change.\n - `blocked`: the human decides in the Lookout; move on to another ticket. With `checkGuard.held`, your checks passed but your work changed what they run (a `package.json` script, a test runner's config, a file a check runs) or skipped, focused or removed tests: the pass doesn't count until the human accepts it. If it comes back for rework, undo those changes first; if one is needed, say why in the `resolution`. Over a remote connection every verified completion ends here, because the checks can't run on files Teamtrail doesn't have: name your pushed branch or pull request in the `resolution` (or pass `pr`) so the human can review it.\n\n When you open a pull request for the ticket, call `proof_report` and put its `markdown` in the PR description unchanged. It is what Teamtrail recorded (the checks it ran, criteria verified or only claimed, the review, the decisions it relies on), not what you say; `gaps` tells you why it isn't verified yet.\n\n A trail is verified only together: once every ticket is done and merged, Teamtrail runs the approved checks on the default branch with all of the merges, by itself. If that fails, the trail lead may add a fix ticket to the trail: work it like any other. `proof_report` with `wholeTrail: true` gives the trail's proof.\n4. Claim the next ready ticket and repeat until none is ready, the trail is done, or the human asks you to stop. Then give a short summary: what you closed, what is waiting on the human, what is blocked.\n\nIf `ask_human` returns `answered: false`, call `wait_for_answer` with its `questionId`. If you have other useful work in the meantime, tell the human the question is waiting in the Lookout.\n\n## status\n\nCall `status` and summarize it in a few lines: progress, running sessions, what is waiting on the human (`attention`: how many items, how many interrupt, the top ones), what is blocked, what is verifying or back for rework, and spend. Then call `projects_status`: if another project has questions waiting or items that need the human, add one line naming it (you can't act there).\n\n## inbox\n\nCall `list_inbox`. List its `attention` items in their ranked order, each with a number, what it is, its trail and ticket, and its `reasons`; keep items with the same `batch` together. For questions (`questionId`), let the human answer here, then pass their exact words to `answer_question` (over a remote connection, point them to the Lookout instead: you can't answer for them). Say plainly that an answer given here guides the agent that asked but can't approve a gate: a high-risk call, a junction or other HITL ticket, or a decision recorded as theirs needs their answer in the Lookout or Slack, so for those questions point them there. Other items (approvals, held tickets, flags, briefs, knowledge) are decided in the Lookout: say where. Never answer or approve on their behalf.\n";
33147
33245
 
33148
33246
  // src/files.ts
33149
33247
  import fs4 from "node:fs";
33150
- import path114 from "node:path";
33248
+ import path115 from "node:path";
33151
33249
  function writeIfChanged(file9, text11) {
33152
33250
  const prev = fs4.existsSync(file9) ? fs4.readFileSync(file9, "utf8") : void 0;
33153
33251
  if (prev === text11) return "unchanged";
33154
- fs4.mkdirSync(path114.dirname(file9), { recursive: true });
33252
+ fs4.mkdirSync(path115.dirname(file9), { recursive: true });
33155
33253
  fs4.writeFileSync(file9, text11);
33156
33254
  return prev === void 0 ? "added" : "updated";
33157
33255
  }
33158
33256
 
33159
33257
  // src/protect/claudeLocalSettings.ts
33160
- import path115 from "node:path";
33161
- var claudeLocalSettings = (cwd) => path115.join(cwd, ".claude", "settings.local.json");
33258
+ import path116 from "node:path";
33259
+ var claudeLocalSettings = (cwd) => path116.join(cwd, ".claude", "settings.local.json");
33162
33260
 
33163
33261
  // src/protect/claudeSandboxState.ts
33164
- import path117 from "node:path";
33262
+ import path118 from "node:path";
33165
33263
 
33166
33264
  // src/protect/claudeSettingsFile.ts
33167
33265
  import os5 from "node:os";
33168
- import path116 from "node:path";
33169
- var claudeSettingsFile = (env = process.env) => path116.join(env.CLAUDE_CONFIG_DIR || path116.join(os5.homedir(), ".claude"), "settings.json");
33266
+ import path117 from "node:path";
33267
+ var claudeSettingsFile = (env = process.env) => path117.join(env.CLAUDE_CONFIG_DIR || path117.join(os5.homedir(), ".claude"), "settings.json");
33170
33268
 
33171
33269
  // src/protect/readSettings.ts
33172
33270
  import fs5 from "node:fs";
@@ -33189,7 +33287,7 @@ function enabledIn(file9) {
33189
33287
  return typeof enabled === "boolean" ? enabled : void 0;
33190
33288
  }
33191
33289
  function claudeSandboxState(cwd, env = process.env) {
33192
- const files = [claudeLocalSettings(cwd), path117.join(cwd, ".claude", "settings.json"), claudeSettingsFile(env)];
33290
+ const files = [claudeLocalSettings(cwd), path118.join(cwd, ".claude", "settings.json"), claudeSettingsFile(env)];
33193
33291
  for (const file9 of files) {
33194
33292
  const enabled = enabledIn(file9);
33195
33293
  if (enabled === void 0) continue;
@@ -33200,7 +33298,7 @@ function claudeSandboxState(cwd, env = process.env) {
33200
33298
 
33201
33299
  // src/protect/writeSettings.ts
33202
33300
  import fs6 from "node:fs";
33203
- import path118 from "node:path";
33301
+ import path119 from "node:path";
33204
33302
  function indentOf(text11) {
33205
33303
  const m = text11?.match(/^[{[][^\n]*\n([ \t]+)\S/);
33206
33304
  return m ? m[1] : 2;
@@ -33209,8 +33307,8 @@ function writeSettings(file9, settings2) {
33209
33307
  const target2 = fs6.existsSync(file9) ? fs6.realpathSync(file9) : file9;
33210
33308
  const before = fs6.existsSync(target2) ? fs6.readFileSync(target2, "utf8") : void 0;
33211
33309
  const mode = before === void 0 ? void 0 : fs6.statSync(target2).mode & 511;
33212
- fs6.mkdirSync(path118.dirname(target2), { recursive: true });
33213
- const temp = path118.join(path118.dirname(target2), `.${path118.basename(target2)}.${process.pid}.tmp`);
33310
+ fs6.mkdirSync(path119.dirname(target2), { recursive: true });
33311
+ const temp = path119.join(path119.dirname(target2), `.${path119.basename(target2)}.${process.pid}.tmp`);
33214
33312
  try {
33215
33313
  fs6.writeFileSync(temp, `${JSON.stringify(settings2, null, indentOf(before))}
33216
33314
  `, { mode: mode ?? 420 });
@@ -33247,7 +33345,7 @@ function applySandbox(o) {
33247
33345
 
33248
33346
  // src/protect/protectConfig.ts
33249
33347
  import os7 from "node:os";
33250
- import path121 from "node:path";
33348
+ import path122 from "node:path";
33251
33349
 
33252
33350
  // src/protect/claudeProtectionLines.ts
33253
33351
  var PAD = " ";
@@ -33285,10 +33383,10 @@ function claudeProtectionLines(p, dirs2) {
33285
33383
  }
33286
33384
 
33287
33385
  // src/protect/codexProtectionLines.ts
33288
- import path119 from "node:path";
33386
+ import path120 from "node:path";
33289
33387
  var PAD2 = " ";
33290
33388
  function codexProtectionLines(dirs2, codexHome) {
33291
- const config4 = path119.join(codexHome, "config.toml");
33389
+ const config4 = path120.join(codexHome, "config.toml");
33292
33390
  return [
33293
33391
  ` Config folder readable by Codex's commands: ${dirs2.join(" and ")} (this machine's key, approvals, credentials).`,
33294
33392
  `${PAD2}Its default sandbox (workspace-write) keeps its commands' writes inside the repo, so not there: leave it on.`,
@@ -33362,21 +33460,21 @@ function protectClaude(file9, dirs2) {
33362
33460
  // src/protect/protectedDirs.ts
33363
33461
  import fs7 from "node:fs";
33364
33462
  import os6 from "node:os";
33365
- import path120 from "node:path";
33463
+ import path121 from "node:path";
33366
33464
  function realOf(p) {
33367
33465
  const rest = [];
33368
- for (let cur = p; ; cur = path120.dirname(cur)) {
33466
+ for (let cur = p; ; cur = path121.dirname(cur)) {
33369
33467
  try {
33370
- return path120.join(fs7.realpathSync(cur), ...rest.reverse());
33468
+ return path121.join(fs7.realpathSync(cur), ...rest.reverse());
33371
33469
  } catch {
33372
- if (path120.dirname(cur) === cur) return p;
33373
- rest.push(path120.basename(cur));
33470
+ if (path121.dirname(cur) === cur) return p;
33471
+ rest.push(path121.basename(cur));
33374
33472
  }
33375
33473
  }
33376
33474
  }
33377
33475
  function protectedDirs(dir4 = configDir()) {
33378
- const named4 = path120.resolve(dir4);
33379
- const fallback = path120.join(process.env.HOME || os6.homedir(), ".config", BRAND.slug);
33476
+ const named4 = path121.resolve(dir4);
33477
+ const fallback = path121.join(process.env.HOME || os6.homedir(), ".config", BRAND.slug);
33380
33478
  return [.../* @__PURE__ */ new Set([named4, realOf(named4), fallback, realOf(fallback)])];
33381
33479
  }
33382
33480
 
@@ -33394,7 +33492,7 @@ function protectConfig(target2, o) {
33394
33492
  return void 0;
33395
33493
  }
33396
33494
  if (target2 === "codex") {
33397
- for (const l of codexProtectionLines(dirs2, process.env.CODEX_HOME || path121.join(os7.homedir(), ".codex"))) o.print(l);
33495
+ for (const l of codexProtectionLines(dirs2, process.env.CODEX_HOME || path122.join(os7.homedir(), ".codex"))) o.print(l);
33398
33496
  return false;
33399
33497
  }
33400
33498
  const done2 = protectClaude(claudeSettingsFile(), dirs2);
@@ -33403,7 +33501,7 @@ function protectConfig(target2, o) {
33403
33501
  }
33404
33502
 
33405
33503
  // src/protect/sandboxLines.ts
33406
- import path122 from "node:path";
33504
+ import path123 from "node:path";
33407
33505
  var PAD3 = " ";
33408
33506
  var LINUX = `${PAD3}On Linux it needs bubblewrap and socat (e.g. apt install bubblewrap socat); without them commands run unsandboxed.`;
33409
33507
  var LEFT = {
@@ -33413,8 +33511,8 @@ var LEFT = {
33413
33511
  };
33414
33512
  function sandboxLines(o) {
33415
33513
  const r = o.result;
33416
- const relative = path122.relative(o.cwd, r.file);
33417
- const outside = relative.startsWith("..") || path122.isAbsolute(relative);
33514
+ const relative = path123.relative(o.cwd, r.file);
33515
+ const outside = relative.startsWith("..") || path123.isAbsolute(relative);
33418
33516
  const shown3 = outside ? r.file : relative;
33419
33517
  const reach = o.guarded ? "shell commands can't reach the config folder either" : "shell commands run in it, but the config folder is not denied (above)";
33420
33518
  const turnOn = `${PAD3}To turn it on: connect claude --sandbox, or set "sandbox": { "enabled": true } in ${shown3}.`;
@@ -33444,7 +33542,7 @@ function sandboxLines(o) {
33444
33542
 
33445
33543
  // src/usage/hook.ts
33446
33544
  import fs8 from "node:fs";
33447
- import path123 from "node:path";
33545
+ import path124 from "node:path";
33448
33546
  function recordClaudeSession(input2, opts) {
33449
33547
  let p;
33450
33548
  try {
@@ -33455,7 +33553,7 @@ function recordClaudeSession(input2, opts) {
33455
33553
  if (!p.session_id || !p.transcript_path) return void 0;
33456
33554
  const env = opts.env ?? process.env;
33457
33555
  const project = env.CLAUDE_PROJECT_DIR || p.cwd || opts.cwd || process.cwd();
33458
- const root = path123.resolve(project, opts.dir);
33556
+ const root = path124.resolve(project, opts.dir);
33459
33557
  const link = {
33460
33558
  agent: "claude-code",
33461
33559
  hostSessionId: p.session_id,
@@ -33466,7 +33564,7 @@ function recordClaudeSession(input2, opts) {
33466
33564
  };
33467
33565
  const rel = agentPaths.host("claude-code", p.session_id);
33468
33566
  writeLocalJson(root, rel, link);
33469
- return path123.join(root, rel);
33567
+ return path124.join(root, rel);
33470
33568
  }
33471
33569
  async function readStdin(timeoutMs = 5e3) {
33472
33570
  if (process.stdin.isTTY) return "";
@@ -33527,7 +33625,7 @@ function runConnect(target2, opts) {
33527
33625
  `));
33528
33626
  const project = autoRegister({
33529
33627
  configDir: configDir(),
33530
- root: path124.resolve(opts.cwd, opts.dir ?? BRAND.dataDir),
33628
+ root: path125.resolve(opts.cwd, opts.dir ?? BRAND.dataDir),
33531
33629
  optOut: opts.noRegister
33532
33630
  });
33533
33631
  if (project) print(` Project ${project.name} \xB7 listed in the Lookout's All projects (${project.id})`);
@@ -33559,27 +33657,27 @@ function registerClaude(o, server) {
33559
33657
  return `not updated (${again.out || `exit ${again.status}`}). Run: claude mcp remove ${BRAND.slug}, then ${shown3}`;
33560
33658
  }
33561
33659
  function connectClaude(o) {
33562
- const file9 = path124.join(o.cwd, ".claude", "commands", "scout.md");
33563
- o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path124.relative(o.cwd, file9)}`);
33660
+ const file9 = path125.join(o.cwd, ".claude", "commands", "scout.md");
33661
+ o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path125.relative(o.cwd, file9)}`);
33564
33662
  o.print(` MCP server ${registerClaude(o, serverCommand(o.self, o.dir))}`);
33565
33663
  const settings2 = claudeLocalSettings(o.cwd);
33566
33664
  o.print(
33567
- ` Usage hook ${installClaudeHook(settings2, o.dir, o.self)} \xB7 ${path124.relative(o.cwd, settings2)} (SessionStart: tokens and cost come from the session transcript)`
33665
+ ` Usage hook ${installClaudeHook(settings2, o.dir, o.self)} \xB7 ${path125.relative(o.cwd, settings2)} (SessionStart: tokens and cost come from the session transcript)`
33568
33666
  );
33569
33667
  }
33570
33668
  function connectCodex(o) {
33571
- const home = process.env.CODEX_HOME || path124.join(os8.homedir(), ".codex");
33572
- const file9 = path124.join(home, "prompts", "scout.md");
33669
+ const home = process.env.CODEX_HOME || path125.join(os8.homedir(), ".codex");
33670
+ const file9 = path125.join(home, "prompts", "scout.md");
33573
33671
  o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33574
33672
  const [command, ...args] = serverCommand(o.self, o.dir);
33575
33673
  const env = process.env.CODEX_HOME ? ["--env", `CODEX_HOME=${process.env.CODEX_HOME}`] : [];
33576
33674
  const r = o.run("codex", ["mcp", "add", BRAND.slug, ...env, "--", command, ...args]);
33577
- const config4 = path124.join(home, "config.toml");
33675
+ const config4 = path125.join(home, "config.toml");
33578
33676
  if (r.missing) o.print(` MCP server Codex not found on PATH. Add this to ${config4}:`);
33579
33677
  else if (r.status === 0)
33580
33678
  o.print(` MCP server registered \xB7 codex mcp add ${BRAND.slug} -- ${shellLine([command, ...args])}`);
33581
33679
  else o.print(` MCP server not registered. Add it to ${config4} (below).`);
33582
- o.print(` Usage read from Codex session logs in ${path124.join(home, "sessions")} (nothing to install)`);
33680
+ o.print(` Usage read from Codex session logs in ${path125.join(home, "sessions")} (nothing to install)`);
33583
33681
  o.print(
33584
33682
  `
33585
33683
  [mcp_servers.${BRAND.slug}]
@@ -33593,7 +33691,7 @@ function connectCodex(o) {
33593
33691
  // src/connectRemote.ts
33594
33692
  import { spawnSync as spawnSync4 } from "node:child_process";
33595
33693
  import os9 from "node:os";
33596
- import path125 from "node:path";
33694
+ import path126 from "node:path";
33597
33695
 
33598
33696
  // src/probeEndpoint.ts
33599
33697
  var INITIALIZE = {
@@ -33680,8 +33778,8 @@ function connectClaude2(o) {
33680
33778
  fail(
33681
33779
  `Claude Code keeps the token in its config, so connect needs it: --token-stdin, $${BRAND.tokenEnv} or --token`
33682
33780
  );
33683
- const file9 = path125.join(o.cwd, ".claude", "commands", "scout.md");
33684
- o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path125.relative(o.cwd, file9)}`);
33781
+ const file9 = path126.join(o.cwd, ".claude", "commands", "scout.md");
33782
+ o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path126.relative(o.cwd, file9)}`);
33685
33783
  const shown3 = `claude mcp add --transport http ${BRAND.slug} ${o.url} --header "Authorization: Bearer $${BRAND.tokenEnv}"`;
33686
33784
  const add3 = ["mcp", "add", "--transport", "http", BRAND.slug, o.url, "--header", `Authorization: Bearer ${o.token}`];
33687
33785
  const r = (o.run ?? runCli2)("claude", add3);
@@ -33700,12 +33798,12 @@ function connectClaude2(o) {
33700
33798
  In Claude Code: /scout new "<idea>", /scout resume, /scout status, /scout inbox`);
33701
33799
  }
33702
33800
  function connectCodex2(o) {
33703
- const home = process.env.CODEX_HOME || path125.join(os9.homedir(), ".codex");
33704
- const file9 = path125.join(home, "prompts", "scout.md");
33801
+ const home = process.env.CODEX_HOME || path126.join(os9.homedir(), ".codex");
33802
+ const file9 = path126.join(home, "prompts", "scout.md");
33705
33803
  o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33706
33804
  const args = ["mcp", "add", BRAND.slug, "--url", o.url, "--bearer-token-env-var", BRAND.tokenEnv];
33707
33805
  const r = (o.run ?? runCli2)("codex", args);
33708
- const config4 = path125.join(home, "config.toml");
33806
+ const config4 = path126.join(home, "config.toml");
33709
33807
  if (r.missing) o.print(` MCP server Codex not found on PATH. Add this to ${config4}:`);
33710
33808
  else if (r.status === 0) o.print(` MCP server registered \xB7 codex ${args.join(" ")}`);
33711
33809
  else o.print(` MCP server not registered (exit ${r.status}). Add it to ${config4} (below).`);
@@ -33734,11 +33832,11 @@ async function connectToken(o) {
33734
33832
  }
33735
33833
 
33736
33834
  // src/guides/guidesCommand.ts
33737
- import path132 from "node:path";
33835
+ import path133 from "node:path";
33738
33836
 
33739
33837
  // src/guides/guidesAdd.ts
33740
- import { existsSync as existsSync39, readFileSync as readFileSync34 } from "node:fs";
33741
- import path126 from "node:path";
33838
+ import { existsSync as existsSync40, readFileSync as readFileSync34 } from "node:fs";
33839
+ import path127 from "node:path";
33742
33840
 
33743
33841
  // src/guides/argvLine.ts
33744
33842
  function argvLine(spec) {
@@ -33886,17 +33984,17 @@ async function installText(input2) {
33886
33984
  }
33887
33985
 
33888
33986
  // src/guides/guidesAdd.ts
33889
- var isFile = (ref2) => ref2.endsWith(".md") || existsSync39(path126.resolve(ref2));
33987
+ var isFile = (ref2) => ref2.endsWith(".md") || existsSync40(path127.resolve(ref2));
33890
33988
  async function guidesAdd(a, io) {
33891
33989
  const ref2 = a.rest[0];
33892
33990
  if (!ref2) {
33893
33991
  io.err("usage: guides add <id>|<catalog/id>|<file.md> [--registry <name>] [--sha256 <hash>] [--approve-checks]\n");
33894
33992
  return 2;
33895
33993
  }
33896
- const root = path126.resolve(a.dir);
33994
+ const root = path127.resolve(a.dir);
33897
33995
  const common = { root, io, approveAll: a.approveChecks, ...a.sha256 ? { sha256: a.sha256 } : {} };
33898
33996
  if (isFile(ref2)) {
33899
- const text12 = readFileSync34(path126.resolve(ref2), "utf8");
33997
+ const text12 = readFileSync34(path127.resolve(ref2), "utf8");
33900
33998
  return installText({ ...common, text: text12, source: "local", where: ref2 });
33901
33999
  }
33902
34000
  const { registries } = readGuidesConfig(root).config;
@@ -33943,30 +34041,30 @@ function parseGuidesArgs(argv2) {
33943
34041
  }
33944
34042
 
33945
34043
  // src/guides/guidesLint.ts
33946
- import { existsSync as existsSync40, readdirSync as readdirSync26, readFileSync as readFileSync35, statSync as statSync16 } from "node:fs";
33947
- import path127 from "node:path";
33948
- var isTracker = (dir4, trackerDir) => path127.resolve(dir4) === path127.resolve(trackerDir) || path127.basename(dir4) === BRAND.dataDir || existsSync40(path127.join(dir4, "guides.lock.json")) || existsSync40(path127.join(dir4, "guides.json"));
34044
+ import { existsSync as existsSync41, readdirSync as readdirSync27, readFileSync as readFileSync35, statSync as statSync16 } from "node:fs";
34045
+ import path128 from "node:path";
34046
+ var isTracker = (dir4, trackerDir) => path128.resolve(dir4) === path128.resolve(trackerDir) || path128.basename(dir4) === BRAND.dataDir || existsSync41(path128.join(dir4, "guides.lock.json")) || existsSync41(path128.join(dir4, "guides.json"));
33949
34047
  function targetsOf(p, trackerDir) {
33950
34048
  if (!statSync16(p).isDirectory()) {
33951
- const top = path127.dirname(path127.dirname(p));
33952
- const inCatalog = path127.basename(path127.dirname(p)) === "guides" && !isTracker(top, trackerDir);
34049
+ const top = path128.dirname(path128.dirname(p));
34050
+ const inCatalog = path128.basename(path128.dirname(p)) === "guides" && !isTracker(top, trackerDir);
33953
34051
  return [{ file: p, ...inCatalog ? { catalog: top } : {} }];
33954
34052
  }
33955
- const guides = path127.join(p, "guides");
33956
- const dir4 = existsSync40(guides) ? guides : p;
34053
+ const guides = path128.join(p, "guides");
34054
+ const dir4 = existsSync41(guides) ? guides : p;
33957
34055
  const catalog = isTracker(p, trackerDir) ? {} : { catalog: p };
33958
- return readdirSync26(dir4).filter((n) => n.endsWith(".md") && n.toLowerCase() !== "readme.md").sort().map((n) => ({ file: path127.join(dir4, n), ...catalog }));
34056
+ return readdirSync27(dir4).filter((n) => n.endsWith(".md") && n.toLowerCase() !== "readme.md").sort().map((n) => ({ file: path128.join(dir4, n), ...catalog }));
33959
34057
  }
33960
34058
  var hasExample = (catalog, id) => {
33961
- const dir4 = path127.join(catalog, "examples", id);
33962
- return existsSync40(dir4) && readdirSync26(dir4).length > 0;
34059
+ const dir4 = path128.join(catalog, "examples", id);
34060
+ return existsSync41(dir4) && readdirSync27(dir4).length > 0;
33963
34061
  };
33964
34062
  function lintTarget(t) {
33965
34063
  const text11 = readFileSync35(t.file, "utf8");
33966
34064
  const lint = lintGuide(text11);
33967
- const id = lint.guide?.id ?? path127.basename(t.file, ".md");
34065
+ const id = lint.guide?.id ?? path128.basename(t.file, ".md");
33968
34066
  const extra = [];
33969
- if (lint.guide && lint.guide.id !== path127.basename(t.file, ".md"))
34067
+ if (lint.guide && lint.guide.id !== path128.basename(t.file, ".md"))
33970
34068
  extra.push({ line: 3, rule: "schema", level: "error", message: `id "${id}" must match the file name` });
33971
34069
  if (t.catalog && !hasExample(t.catalog, id))
33972
34070
  extra.push({ line: 1, rule: "example", level: "error", message: `no test example in examples/${id}/` });
@@ -33986,13 +34084,13 @@ function lintTarget(t) {
33986
34084
  };
33987
34085
  }
33988
34086
  function guidesLint(a, io) {
33989
- const fallback = existsSync40(path127.join(a.dir, "guides")) ? a.dir : ".";
33990
- const targets = (a.rest.length ? a.rest : [fallback]).flatMap((p) => targetsOf(path127.resolve(p), a.dir));
34087
+ const fallback = existsSync41(path128.join(a.dir, "guides")) ? a.dir : ".";
34088
+ const targets = (a.rest.length ? a.rest : [fallback]).flatMap((p) => targetsOf(path128.resolve(p), a.dir));
33991
34089
  const results = targets.map(lintTarget);
33992
34090
  if (a.json) io.out(`${JSON.stringify(results, null, 2)}
33993
34091
  `);
33994
34092
  else {
33995
- for (const r of results) printFindings(io, path127.relative(process.cwd(), r.path) || r.path, r.findings);
34093
+ for (const r of results) printFindings(io, path128.relative(process.cwd(), r.path) || r.path, r.findings);
33996
34094
  const bad = results.filter((r) => !r.ok).length;
33997
34095
  io.out(`${results.length} guides linted, ${bad ? `${bad} with errors` : "all clean"}
33998
34096
  `);
@@ -34003,9 +34101,9 @@ function guidesLint(a, io) {
34003
34101
  }
34004
34102
 
34005
34103
  // src/guides/guidesList.ts
34006
- import path128 from "node:path";
34104
+ import path129 from "node:path";
34007
34105
  function guidesList(a, io) {
34008
- const guides = listGuides(path128.resolve(a.dir));
34106
+ const guides = listGuides(path129.resolve(a.dir));
34009
34107
  if (a.json) {
34010
34108
  io.out(`${JSON.stringify(guides, null, 2)}
34011
34109
  `);
@@ -34027,7 +34125,7 @@ function originOf(origin, fromCatalog) {
34027
34125
  }
34028
34126
 
34029
34127
  // src/guides/guidesNew.ts
34030
- import path129 from "node:path";
34128
+ import path130 from "node:path";
34031
34129
  var gitName = (cwd) => gitConfigValue(cwd, "user.name") ?? "";
34032
34130
  function guidesNew(a, io) {
34033
34131
  const id = a.rest[0];
@@ -34035,10 +34133,10 @@ function guidesNew(a, io) {
34035
34133
  io.err("usage: guides new <id>\n");
34036
34134
  return 2;
34037
34135
  }
34038
- const root = path129.resolve(a.dir);
34039
- const author = a.author ?? gitName(path129.dirname(root));
34136
+ const root = path130.resolve(a.dir);
34137
+ const author = a.author ?? gitName(path130.dirname(root));
34040
34138
  const { file: file9, lint } = newGuide({ root, id, author });
34041
- const shown3 = path129.relative(process.cwd(), file9) || file9;
34139
+ const shown3 = path130.relative(process.cwd(), file9) || file9;
34042
34140
  printFindings(io, shown3, lint.findings);
34043
34141
  io.out(
34044
34142
  [
@@ -34057,7 +34155,7 @@ function guidesNew(a, io) {
34057
34155
  }
34058
34156
 
34059
34157
  // src/guides/guidesSearch.ts
34060
- import path130 from "node:path";
34158
+ import path131 from "node:path";
34061
34159
 
34062
34160
  // src/guides/hostOf.ts
34063
34161
  function hostOf2(url2) {
@@ -34083,7 +34181,7 @@ function registryForUrl(root, url2) {
34083
34181
 
34084
34182
  // src/guides/guidesSearch.ts
34085
34183
  async function guidesSearch(a, io) {
34086
- const root = path130.resolve(a.dir);
34184
+ const root = path131.resolve(a.dir);
34087
34185
  let found = 0;
34088
34186
  for (const registry3 of pickRegistries(root, a.registry)) {
34089
34187
  const index = await fetchCatalog(registry3, { fetch: io.fetch });
@@ -34109,7 +34207,7 @@ function badgeOf(e, url2) {
34109
34207
 
34110
34208
  // src/guides/guidesUpdate.ts
34111
34209
  import { readFileSync as readFileSync36 } from "node:fs";
34112
- import path131 from "node:path";
34210
+ import path132 from "node:path";
34113
34211
 
34114
34212
  // src/guides/updateChanges.ts
34115
34213
  function textChanges(before, after) {
@@ -34189,7 +34287,7 @@ async function updateOne(a, io, id, entry) {
34189
34287
  return installText({ root: a.root, text: text11, source, io, where: where2, expectId: id, approveAll: false, changes: changes2, ...sha256 });
34190
34288
  }
34191
34289
  async function guidesUpdate(a, io) {
34192
- const root = path131.resolve(a.dir);
34290
+ const root = path132.resolve(a.dir);
34193
34291
  const approved = readApprovedLock(root).guides;
34194
34292
  const pinned = readGuideLock(root).guides;
34195
34293
  const ids2 = a.rest.length ? a.rest : Object.keys(approved);
@@ -34216,8 +34314,8 @@ function guidesRemove(a, io) {
34216
34314
  io.err("usage: guides remove <id>\n");
34217
34315
  return 2;
34218
34316
  }
34219
- const r = removeGuide({ root: path132.resolve(a.dir), id });
34220
- journalGuide2(path132.resolve(a.dir), { action: "removed", guide: id });
34317
+ const r = removeGuide({ root: path133.resolve(a.dir), id });
34318
+ journalGuide2(path133.resolve(a.dir), { action: "removed", guide: id });
34221
34319
  io.out(
34222
34320
  `Removed ${id}${r.builtinBack ? "; the built-in guide is back" : ""}. Its approved checks stay in verification.json.
34223
34321
  `
@@ -34264,9 +34362,9 @@ async function guidesCli(argv2) {
34264
34362
 
34265
34363
  // src/knowledgeImport.ts
34266
34364
  import { readFileSync as readFileSync37 } from "node:fs";
34267
- import path133 from "node:path";
34365
+ import path134 from "node:path";
34268
34366
  function importKnowledge(root, file9) {
34269
- const parts2 = splitForImport(readFileSync37(file9, "utf8"), path133.basename(file9));
34367
+ const parts2 = splitForImport(readFileSync37(file9, "utf8"), path134.basename(file9));
34270
34368
  const now2 = Date.now();
34271
34369
  const ids2 = [];
34272
34370
  for (const p of parts2) {
@@ -34302,7 +34400,7 @@ function mcpHttpOptions(o, root) {
34302
34400
  allowHosts: o.allowHosts,
34303
34401
  leaseMinutes: o.leaseMinutes,
34304
34402
  noRegister: o.noRegister,
34305
- version: "0.61.2"
34403
+ version: "0.64.2"
34306
34404
  };
34307
34405
  }
34308
34406
 
@@ -35952,10 +36050,10 @@ function mergeDefs(...defs) {
35952
36050
  function cloneDef(schema) {
35953
36051
  return mergeDefs(schema._zod.def);
35954
36052
  }
35955
- function getElementAtPath(obj2, path148) {
35956
- if (!path148)
36053
+ function getElementAtPath(obj2, path149) {
36054
+ if (!path149)
35957
36055
  return obj2;
35958
- return path148.reduce((acc, key) => acc?.[key], obj2);
36056
+ return path149.reduce((acc, key) => acc?.[key], obj2);
35959
36057
  }
35960
36058
  function promiseAllObject(promisesObj) {
35961
36059
  const keys2 = Object.keys(promisesObj);
@@ -36295,11 +36393,11 @@ function explicitlyAborted(x, startIndex = 0) {
36295
36393
  }
36296
36394
  return false;
36297
36395
  }
36298
- function prefixIssues(path148, issues) {
36396
+ function prefixIssues(path149, issues) {
36299
36397
  return issues.map((iss) => {
36300
36398
  var _a5;
36301
36399
  (_a5 = iss).path ?? (_a5.path = []);
36302
- iss.path.unshift(path148);
36400
+ iss.path.unshift(path149);
36303
36401
  return iss;
36304
36402
  });
36305
36403
  }
@@ -36362,14 +36460,14 @@ function codePointLength(str14) {
36362
36460
  const units = str14.length;
36363
36461
  if (!highSurrogate.test(str14))
36364
36462
  return units;
36365
- let count2 = units;
36463
+ let count3 = units;
36366
36464
  for (let i = 0; i < units - 1; i++) {
36367
36465
  if ((str14.charCodeAt(i) & 64512) === 55296 && (str14.charCodeAt(i + 1) & 64512) === 56320) {
36368
- count2--;
36466
+ count3--;
36369
36467
  i++;
36370
36468
  }
36371
36469
  }
36372
- return count2;
36470
+ return count3;
36373
36471
  }
36374
36472
  function getLengthableOrigin(input2) {
36375
36473
  if (Array.isArray(input2))
@@ -36757,16 +36855,16 @@ function flattenError(error63, mapper = (issue3) => issue3.message) {
36757
36855
  }
36758
36856
  function formatError(error63, mapper = (issue3) => issue3.message) {
36759
36857
  const fieldErrors = { _errors: [] };
36760
- const processError = (error64, path148 = []) => {
36858
+ const processError = (error64, path149 = []) => {
36761
36859
  for (const issue3 of error64.issues) {
36762
36860
  if (issue3.code === "invalid_union" && issue3.errors.length) {
36763
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
36861
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
36764
36862
  } else if (issue3.code === "invalid_key") {
36765
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
36863
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
36766
36864
  } else if (issue3.code === "invalid_element") {
36767
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
36865
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
36768
36866
  } else {
36769
- const fullpath = [...path148, ...issue3.path];
36867
+ const fullpath = [...path149, ...issue3.path];
36770
36868
  if (fullpath.length === 0) {
36771
36869
  fieldErrors._errors.push(mapper(issue3));
36772
36870
  } else {
@@ -44873,10 +44971,10 @@ function mcpHttpListener(mcp) {
44873
44971
 
44874
44972
  // src/mcp/trail/agentContext.ts
44875
44973
  import { randomUUID as randomUUID4 } from "node:crypto";
44876
- import path134 from "node:path";
44974
+ import path135 from "node:path";
44877
44975
 
44878
44976
  // src/ownVersion.ts
44879
- var OWN_VERSION = true ? "0.61.2" : void 0;
44977
+ var OWN_VERSION = true ? "0.64.2" : void 0;
44880
44978
 
44881
44979
  // src/mcp/trail/agentLeases.ts
44882
44980
  var AgentLeases = class {
@@ -45143,18 +45241,18 @@ var AgentContext = class {
45143
45241
  if (this.trailName) return this.trailName;
45144
45242
  if (this.opts.agent) return this.trailName = this.opts.agent;
45145
45243
  const family = trailNameFamily(this.opts.client?.());
45146
- const taken = new Set(
45244
+ const taken2 = new Set(
45147
45245
  (await readAgentDocs(this.root)).filter((d) => d.session.status === "running").map((d) => d.session.agent)
45148
45246
  );
45149
45247
  this.nameHolder = this.opts.remote ? randomUUID4() : void 0;
45150
- return this.trailName = claimTrailName(this.root, family, taken, this.nameHolder);
45248
+ return this.trailName = claimTrailName(this.root, family, taken2, this.nameHolder);
45151
45249
  }
45152
45250
  lookout() {
45153
45251
  const lock = readLookoutLock(this.root);
45154
45252
  const skew = versionSkew({ agentVersion: OWN_VERSION, lookoutVersion: lock?.version });
45155
45253
  return lock ? { running: true, url: lock.url, ...skew ? { versionNote: skew } : {} } : {
45156
45254
  running: false,
45157
- hint: `Run \`npx ${packageSpec(OWN_VERSION)} --dir ${path134.relative(process.cwd(), this.root) || "."}\` in this folder to watch live.`
45255
+ hint: `Run \`npx ${packageSpec(OWN_VERSION)} --dir ${path135.relative(process.cwd(), this.root) || "."}\` in this folder to watch live.`
45158
45256
  };
45159
45257
  }
45160
45258
  async load(mapId) {
@@ -45312,7 +45410,7 @@ async function proposeKnowledge(ctx, input2) {
45312
45410
  const snap = await ctx.resolveTrail(input2.trail).catch(() => void 0);
45313
45411
  const ticketId = ctx.sessions.current?.info.ticketId;
45314
45412
  const now2 = Date.now();
45315
- const anchors = repoPaths(input2.files, pathRoots(ctx)).map((path148) => ({ path: path148 }));
45413
+ const anchors = repoPaths(input2.files, pathRoots(ctx)).map((path149) => ({ path: path149 }));
45316
45414
  const draft = {
45317
45415
  title: input2.title.trim(),
45318
45416
  body: input2.body.trim(),
@@ -46662,7 +46760,7 @@ function ticketView(snap, t, records = []) {
46662
46760
  }
46663
46761
  function trailView(snap, docs, records, keyOf11) {
46664
46762
  const states = deriveStates(snap.tickets, snap.map.mode);
46665
- const count2 = (st) => snap.tickets.filter((t) => states.get(t.id) === st).length;
46763
+ const count3 = (st) => snap.tickets.filter((t) => states.get(t.id) === st).length;
46666
46764
  const mine2 = docs.filter((d) => d.session.mapId === snap.map.id);
46667
46765
  const usage = mine2.map((d) => d.session.usage).filter((u) => !!u);
46668
46766
  return {
@@ -46671,20 +46769,20 @@ function trailView(snap, docs, records, keyOf11) {
46671
46769
  title: snap.map.title,
46672
46770
  mode: snap.map.mode,
46673
46771
  destination: snap.map.sections.destination,
46674
- progress: `${count2("decided")}/${snap.tickets.filter((t) => states.get(t.id) !== "out-of-scope").length} decided`,
46772
+ progress: `${count3("decided")}/${snap.tickets.filter((t) => states.get(t.id) !== "out-of-scope").length} decided`,
46675
46773
  counts: {
46676
- decided: count2("decided"),
46677
- claimed: count2("claimed"),
46678
- ready: count2("frontier"),
46679
- blocked: count2("blocked"),
46680
- parked: count2("parked"),
46681
- outOfScope: count2("out-of-scope"),
46682
- ...snap.map.verification || count2("verifying") || count2("rework") || count2("held") ? { verifying: count2("verifying"), rework: count2("rework"), waitingOnHuman: count2("held") } : {}
46774
+ decided: count3("decided"),
46775
+ claimed: count3("claimed"),
46776
+ ready: count3("frontier"),
46777
+ blocked: count3("blocked"),
46778
+ parked: count3("parked"),
46779
+ outOfScope: count3("out-of-scope"),
46780
+ ...snap.map.verification || count3("verifying") || count3("rework") || count3("held") ? { verifying: count3("verifying"), rework: count3("rework"), waitingOnHuman: count3("held") } : {}
46683
46781
  },
46684
46782
  ready: snap.tickets.filter((t) => states.get(t.id) === "frontier").map((t) => ({ key: t.key, title: t.title, type: t.type, attention: attention(t) })),
46685
46783
  claimed: snap.tickets.filter((t) => states.get(t.id) === "claimed").map((t) => ({ key: t.key, title: t.title, assignee: t.assignee })),
46686
46784
  blocked: snap.tickets.filter((t) => states.get(t.id) === "blocked").map((t) => ({ key: t.key, title: t.title })),
46687
- ...snap.map.verification || count2("verifying") || count2("rework") || count2("held") ? {
46785
+ ...snap.map.verification || count3("verifying") || count3("rework") || count3("held") ? {
46688
46786
  verification: {
46689
46787
  level: snap.map.verification ?? "off",
46690
46788
  verifying: snap.tickets.filter((t) => states.get(t.id) === "verifying").map((t) => t.key),
@@ -46731,12 +46829,12 @@ function noTicketReason(snap, discovery) {
46731
46829
  if (discovery.gate)
46732
46830
  return `No ready ${discovery.gate.join(", ")} ticket, and implementation tickets wait for the discovery brief: ${discovery.next}`;
46733
46831
  const states = deriveStates(snap.tickets, snap.map.mode);
46734
- const count2 = (state) => open4.filter((x) => states.get(x.id) === state).length;
46832
+ const count3 = (state) => open4.filter((x) => states.get(x.id) === state).length;
46735
46833
  const waiting2 = [
46736
- { label: "verifying", n: count2("verifying") },
46737
- { label: "waiting on the human", n: count2("held") }
46834
+ { label: "verifying", n: count3("verifying") },
46835
+ { label: "waiting on the human", n: count3("held") }
46738
46836
  ].filter((w) => w.n > 0).map((w) => `, ${w.n} ${w.label}`).join("");
46739
- return `No ready ticket: ${count2("claimed")} claimed, ${count2("blocked")} blocked, ${count2("parked")} parked${waiting2}.`;
46837
+ return `No ready ticket: ${count3("claimed")} claimed, ${count3("blocked")} blocked, ${count3("parked")} parked${waiting2}.`;
46740
46838
  }
46741
46839
 
46742
46840
  // src/mcp/trail/ticketOps.ts
@@ -47781,6 +47879,8 @@ async function resumeTrail(ctx, trailRef) {
47781
47879
  };
47782
47880
  }
47783
47881
  async function updateTrail(ctx, input2) {
47882
+ const tooLong = trailTextProblem({ destination: input2.destination, notes: input2.notes });
47883
+ if (tooLong) throw new OperationError(tooLong);
47784
47884
  const snap = await ctx.resolveTrail(input2.trail);
47785
47885
  const requests = await settingRequests(ctx, snap, input2);
47786
47886
  const trail2 = await applyUpdate(ctx, { snap, input: { ...input2, mode: void 0, destination: void 0 } });
@@ -48332,8 +48432,8 @@ function getErrorMap() {
48332
48432
 
48333
48433
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js
48334
48434
  var makeIssue = (params) => {
48335
- const { data, path: path148, errorMaps, issueData } = params;
48336
- const fullPath = [...path148, ...issueData.path || []];
48435
+ const { data, path: path149, errorMaps, issueData } = params;
48436
+ const fullPath = [...path149, ...issueData.path || []];
48337
48437
  const fullIssue = {
48338
48438
  ...issueData,
48339
48439
  path: fullPath
@@ -48448,11 +48548,11 @@ var errorUtil;
48448
48548
 
48449
48549
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js
48450
48550
  var ParseInputLazyPath = class {
48451
- constructor(parent, value, path148, key) {
48551
+ constructor(parent, value, path149, key) {
48452
48552
  this._cachedPath = [];
48453
48553
  this.parent = parent;
48454
48554
  this.data = value;
48455
- this._path = path148;
48555
+ this._path = path149;
48456
48556
  this._key = key;
48457
48557
  }
48458
48558
  get path() {
@@ -52004,11 +52104,11 @@ function normalizeObjectSchema(schema) {
52004
52104
  }
52005
52105
  return void 0;
52006
52106
  }
52007
- function getDotPath(path148) {
52008
- if (path148.length === 0) {
52107
+ function getDotPath(path149) {
52108
+ if (path149.length === 0) {
52009
52109
  return "object root";
52010
52110
  }
52011
- return path148.reduce((acc, seg, index) => {
52111
+ return path149.reduce((acc, seg, index) => {
52012
52112
  if (index === 0) {
52013
52113
  return String(seg);
52014
52114
  }
@@ -55164,7 +55264,7 @@ var ExperimentalMcpServerTasks = class {
55164
55264
 
55165
55265
  // ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
55166
55266
  function toolInputElementCount(value, max) {
55167
- let count2 = 0;
55267
+ let count3 = 0;
55168
55268
  const stack = [value];
55169
55269
  while (stack.length > 0) {
55170
55270
  const node3 = stack.pop();
@@ -55172,8 +55272,8 @@ function toolInputElementCount(value, max) {
55172
55272
  continue;
55173
55273
  if (Array.isArray(node3)) {
55174
55274
  for (const child2 of node3) {
55175
- if (++count2 > max)
55176
- return count2;
55275
+ if (++count3 > max)
55276
+ return count3;
55177
55277
  if (child2 !== null && typeof child2 === "object")
55178
55278
  stack.push(child2);
55179
55279
  }
@@ -55181,15 +55281,15 @@ function toolInputElementCount(value, max) {
55181
55281
  for (const key in node3) {
55182
55282
  if (!Object.prototype.hasOwnProperty.call(node3, key))
55183
55283
  continue;
55184
- if (++count2 > max)
55185
- return count2;
55284
+ if (++count3 > max)
55285
+ return count3;
55186
55286
  const child2 = node3[key];
55187
55287
  if (child2 !== null && typeof child2 === "object")
55188
55288
  stack.push(child2);
55189
55289
  }
55190
55290
  }
55191
55291
  }
55192
- return count2;
55292
+ return count3;
55193
55293
  }
55194
55294
  function resolveMaxToolInputElements(value) {
55195
55295
  if (value === void 0 || value === Infinity)
@@ -56112,11 +56212,11 @@ var StdioServerTransport = class {
56112
56212
 
56113
56213
  // src/usage/meter.ts
56114
56214
  import os11 from "node:os";
56115
- import path136 from "node:path";
56215
+ import path137 from "node:path";
56116
56216
 
56117
56217
  // src/usage/logLocations.ts
56118
56218
  import fs10 from "node:fs";
56119
- import path135 from "node:path";
56219
+ import path136 from "node:path";
56120
56220
 
56121
56221
  // src/usage/quietFs.ts
56122
56222
  import fs9 from "node:fs";
@@ -56163,31 +56263,31 @@ var claudeProjectDirName = (dir4) => dir4.replace(/[^a-zA-Z0-9]/g, "-");
56163
56263
  function claudeCandidates(root, env, cwd, home) {
56164
56264
  const since2 = Date.now() - 2 * DAY2;
56165
56265
  const out = [];
56166
- const links = path135.join(root, agentPaths.hosts);
56266
+ const links = path136.join(root, agentPaths.hosts);
56167
56267
  for (const n of ls(links)) {
56168
56268
  try {
56169
- const l = JSON.parse(fs10.readFileSync(path135.join(links, n), "utf8"));
56269
+ const l = JSON.parse(fs10.readFileSync(path136.join(links, n), "utf8"));
56170
56270
  if (l.agent === "claude-code" && l.at >= since2 && l.transcriptPath) out.push(l.transcriptPath);
56171
56271
  } catch {
56172
56272
  }
56173
56273
  }
56174
- const config4 = env.CLAUDE_CONFIG_DIR || path135.join(home, ".claude");
56175
- const dir4 = path135.join(config4, "projects", claudeProjectDirName(env.CLAUDE_PROJECT_DIR || cwd));
56176
- if (env.CLAUDE_CODE_SESSION_ID) out.push(path135.join(dir4, `${env.CLAUDE_CODE_SESSION_ID}.jsonl`));
56177
- const byAge = ls(dir4).filter((n) => n.endsWith(".jsonl")).map((n) => path135.join(dir4, n)).filter((f) => recent(f, since2)).sort((a, b) => fs10.statSync(b).mtimeMs - fs10.statSync(a).mtimeMs).slice(0, 12);
56274
+ const config4 = env.CLAUDE_CONFIG_DIR || path136.join(home, ".claude");
56275
+ const dir4 = path136.join(config4, "projects", claudeProjectDirName(env.CLAUDE_PROJECT_DIR || cwd));
56276
+ if (env.CLAUDE_CODE_SESSION_ID) out.push(path136.join(dir4, `${env.CLAUDE_CODE_SESSION_ID}.jsonl`));
56277
+ const byAge = ls(dir4).filter((n) => n.endsWith(".jsonl")).map((n) => path136.join(dir4, n)).filter((f) => recent(f, since2)).sort((a, b) => fs10.statSync(b).mtimeMs - fs10.statSync(a).mtimeMs).slice(0, 12);
56178
56278
  return [.../* @__PURE__ */ new Set([...out, ...byAge])].filter((f) => recent(f, since2));
56179
56279
  }
56180
56280
  function findCodexRollout(thread, env, home) {
56181
- const sessions = path135.join(env.CODEX_HOME || path135.join(home, ".codex"), "sessions");
56281
+ const sessions = path136.join(env.CODEX_HOME || path136.join(home, ".codex"), "sessions");
56182
56282
  const desc = (dir4) => ls(dir4).sort().reverse();
56183
56283
  const dayDirs = desc(sessions).flatMap(
56184
- (y) => desc(path135.join(sessions, y)).flatMap(
56185
- (m) => desc(path135.join(sessions, y, m)).map((d) => path135.join(sessions, y, m, d))
56284
+ (y) => desc(path136.join(sessions, y)).flatMap(
56285
+ (m) => desc(path136.join(sessions, y, m)).map((d) => path136.join(sessions, y, m, d))
56186
56286
  )
56187
56287
  );
56188
56288
  for (const dir4 of dayDirs.slice(0, 400)) {
56189
56289
  const hit = ls(dir4).find((n) => n.startsWith("rollout-") && n.endsWith(`-${thread}.jsonl`));
56190
- if (hit) return path135.join(dir4, hit);
56290
+ if (hit) return path136.join(dir4, hit);
56191
56291
  }
56192
56292
  return void 0;
56193
56293
  }
@@ -56426,7 +56526,7 @@ var UsageMeter = class {
56426
56526
  }
56427
56527
  poll() {
56428
56528
  for (const [file9, f] of this.files) {
56429
- const own3 = path136.basename(path136.dirname(file9)) !== "subagents";
56529
+ const own3 = path137.basename(path137.dirname(file9)) !== "subagents";
56430
56530
  for (const e of f.read()) {
56431
56531
  if (own3 && e.model && (!this.latest || e.at >= this.latest.at)) this.latest = { at: e.at, model: e.model };
56432
56532
  const prev = this.events.get(e.key);
@@ -56447,9 +56547,9 @@ var UsageMeter = class {
56447
56547
  /** Subagent (Task) transcripts sit next to the main one, under `<session>/subagents/`. */
56448
56548
  attachSubagents() {
56449
56549
  for (const file9 of [...this.files.keys()]) {
56450
- if (path136.basename(path136.dirname(file9)) === "subagents") continue;
56451
- const dir4 = path136.join(file9.replace(/\.jsonl$/, ""), "subagents");
56452
- for (const n of ls(dir4)) if (n.endsWith(".jsonl")) this.attach(path136.join(dir4, n), "claude-code");
56550
+ if (path137.basename(path137.dirname(file9)) === "subagents") continue;
56551
+ const dir4 = path137.join(file9.replace(/\.jsonl$/, ""), "subagents");
56552
+ for (const n of ls(dir4)) if (n.endsWith(".jsonl")) this.attach(path137.join(dir4, n), "claude-code");
56453
56553
  }
56454
56554
  }
56455
56555
  /**
@@ -57348,10 +57448,10 @@ function mergeDefs2(...defs) {
57348
57448
  function cloneDef2(schema) {
57349
57449
  return mergeDefs2(schema._zod.def);
57350
57450
  }
57351
- function getElementAtPath2(obj2, path148) {
57352
- if (!path148)
57451
+ function getElementAtPath2(obj2, path149) {
57452
+ if (!path149)
57353
57453
  return obj2;
57354
- return path148.reduce((acc, key) => acc?.[key], obj2);
57454
+ return path149.reduce((acc, key) => acc?.[key], obj2);
57355
57455
  }
57356
57456
  function promiseAllObject2(promisesObj) {
57357
57457
  const keys2 = Object.keys(promisesObj);
@@ -57691,11 +57791,11 @@ function explicitlyAborted2(x, startIndex = 0) {
57691
57791
  }
57692
57792
  return false;
57693
57793
  }
57694
- function prefixIssues2(path148, issues) {
57794
+ function prefixIssues2(path149, issues) {
57695
57795
  return issues.map((iss) => {
57696
57796
  var _a5;
57697
57797
  (_a5 = iss).path ?? (_a5.path = []);
57698
- iss.path.unshift(path148);
57798
+ iss.path.unshift(path149);
57699
57799
  return iss;
57700
57800
  });
57701
57801
  }
@@ -57758,14 +57858,14 @@ function codePointLength2(str14) {
57758
57858
  const units = str14.length;
57759
57859
  if (!highSurrogate2.test(str14))
57760
57860
  return units;
57761
- let count2 = units;
57861
+ let count3 = units;
57762
57862
  for (let i = 0; i < units - 1; i++) {
57763
57863
  if ((str14.charCodeAt(i) & 64512) === 55296 && (str14.charCodeAt(i + 1) & 64512) === 56320) {
57764
- count2--;
57864
+ count3--;
57765
57865
  i++;
57766
57866
  }
57767
57867
  }
57768
- return count2;
57868
+ return count3;
57769
57869
  }
57770
57870
  function getLengthableOrigin2(input2) {
57771
57871
  if (Array.isArray(input2))
@@ -58157,16 +58257,16 @@ function flattenError2(error63, mapper = (issue3) => issue3.message) {
58157
58257
  }
58158
58258
  function formatError2(error63, mapper = (issue3) => issue3.message) {
58159
58259
  const fieldErrors = { _errors: [] };
58160
- const processError = (error64, path148 = []) => {
58260
+ const processError = (error64, path149 = []) => {
58161
58261
  for (const issue3 of error64.issues) {
58162
58262
  if (issue3.code === "invalid_union" && issue3.errors.length) {
58163
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
58263
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
58164
58264
  } else if (issue3.code === "invalid_key") {
58165
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58265
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58166
58266
  } else if (issue3.code === "invalid_element") {
58167
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58267
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58168
58268
  } else {
58169
- const fullpath = [...path148, ...issue3.path];
58269
+ const fullpath = [...path149, ...issue3.path];
58170
58270
  if (fullpath.length === 0) {
58171
58271
  fieldErrors._errors.push(mapper(issue3));
58172
58272
  } else {
@@ -58205,17 +58305,17 @@ function formatError2(error63, mapper = (issue3) => issue3.message) {
58205
58305
  }
58206
58306
  function treeifyError(error63, mapper = (issue3) => issue3.message) {
58207
58307
  const result2 = { errors: [] };
58208
- const processError = (error64, path148 = []) => {
58308
+ const processError = (error64, path149 = []) => {
58209
58309
  var _a5;
58210
58310
  for (const issue3 of error64.issues) {
58211
58311
  if (issue3.code === "invalid_union" && issue3.errors.length) {
58212
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
58312
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
58213
58313
  } else if (issue3.code === "invalid_key") {
58214
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58314
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58215
58315
  } else if (issue3.code === "invalid_element") {
58216
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58316
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58217
58317
  } else {
58218
- const fullpath = [...path148, ...issue3.path];
58318
+ const fullpath = [...path149, ...issue3.path];
58219
58319
  if (fullpath.length === 0) {
58220
58320
  result2.errors.push(mapper(issue3));
58221
58321
  continue;
@@ -58254,8 +58354,8 @@ function treeifyError(error63, mapper = (issue3) => issue3.message) {
58254
58354
  }
58255
58355
  function toDotPath(_path) {
58256
58356
  const segs = [];
58257
- const path148 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
58258
- for (const seg of path148) {
58357
+ const path149 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
58358
+ for (const seg of path149) {
58259
58359
  if (typeof seg === "number")
58260
58360
  segs.push(`[${seg}]`);
58261
58361
  else if (typeof seg === "symbol")
@@ -62145,8 +62245,8 @@ function az_default() {
62145
62245
  }
62146
62246
 
62147
62247
  // node_modules/zod/v4/locales/be.js
62148
- function getBelarusianPlural(count2, one, few, many) {
62149
- const absCount = Math.abs(count2);
62248
+ function getBelarusianPlural(count3, one, few, many) {
62249
+ const absCount = Math.abs(count3);
62150
62250
  const lastDigit = absCount % 10;
62151
62251
  const lastTwoDigits = absCount % 100;
62152
62252
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -64792,8 +64892,8 @@ function hu_default() {
64792
64892
  }
64793
64893
 
64794
64894
  // node_modules/zod/v4/locales/hy.js
64795
- function getArmenianPlural(count2, one, many) {
64796
- return Math.abs(count2) === 1 ? one : many;
64895
+ function getArmenianPlural(count3, one, many) {
64896
+ return Math.abs(count3) === 1 ? one : many;
64797
64897
  }
64798
64898
  function withDefiniteArticle(word) {
64799
64899
  if (!word)
@@ -67531,8 +67631,8 @@ function ro_default() {
67531
67631
  }
67532
67632
 
67533
67633
  // node_modules/zod/v4/locales/ru.js
67534
- function getRussianPlural(count2, one, few, many) {
67535
- const absCount = Math.abs(count2);
67634
+ function getRussianPlural(count3, one, few, many) {
67635
+ const absCount = Math.abs(count3);
67536
67636
  const lastDigit = absCount % 10;
67537
67637
  const lastTwoDigits = absCount % 100;
67538
67638
  if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
@@ -75384,13 +75484,13 @@ function resolveRef(ref2, ctx) {
75384
75484
  if (!ref2.startsWith("#")) {
75385
75485
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
75386
75486
  }
75387
- const path148 = ref2.slice(1).split("/").filter(Boolean);
75388
- if (path148.length === 0) {
75487
+ const path149 = ref2.slice(1).split("/").filter(Boolean);
75488
+ if (path149.length === 0) {
75389
75489
  return ctx.rootSchema;
75390
75490
  }
75391
75491
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
75392
- if (path148[0] === defsKey) {
75393
- const key = path148[1] === void 0 ? void 0 : decodeJSONPointerSegment(path148[1]);
75492
+ if (path149[0] === defsKey) {
75493
+ const key = path149[1] === void 0 ? void 0 : decodeJSONPointerSegment(path149[1]);
75394
75494
  if (!key || !ctx.defs[key]) {
75395
75495
  throw new Error(`Reference not found: ${ref2}`);
75396
75496
  }
@@ -76269,24 +76369,24 @@ function childOf(node3, value, key) {
76269
76369
  var REFUSAL = "must be a single line: it holds a line break or another control character";
76270
76370
  var INPUT_LIMITS = { line: 500, text: 5e4, items: 500 };
76271
76371
  function assertLineSafe(tool, shape, args) {
76272
- const walk = (value, node3, path148) => {
76372
+ const walk = (value, node3, path149) => {
76273
76373
  if (typeof value === "string") {
76274
76374
  const free = multilineAt(node3);
76275
- if (hasControl(value) && !free) throw new OperationError(`${tool}: \`${path148}\` ${REFUSAL}.`);
76375
+ if (hasControl(value) && !free) throw new OperationError(`${tool}: \`${path149}\` ${REFUSAL}.`);
76276
76376
  const max = free ? INPUT_LIMITS.text : INPUT_LIMITS.line;
76277
76377
  if (value.length > max)
76278
- throw new OperationError(`${tool}: \`${path148}\` is too long (${value.length} characters; at most ${max}).`);
76378
+ throw new OperationError(`${tool}: \`${path149}\` is too long (${value.length} characters; at most ${max}).`);
76279
76379
  return;
76280
76380
  }
76281
76381
  if (Array.isArray(value) && value.length > INPUT_LIMITS.items)
76282
76382
  throw new OperationError(
76283
- `${tool}: \`${path148}\` has too many items (${value.length}; at most ${INPUT_LIMITS.items}).`
76383
+ `${tool}: \`${path149}\` has too many items (${value.length}; at most ${INPUT_LIMITS.items}).`
76284
76384
  );
76285
- if (Array.isArray(value)) return value.forEach((v, i) => walk(v, childOf(node3, value, String(i)), `${path148}[${i}]`));
76385
+ if (Array.isArray(value)) return value.forEach((v, i) => walk(v, childOf(node3, value, String(i)), `${path149}[${i}]`));
76286
76386
  if (!value || typeof value !== "object") return;
76287
76387
  for (const [k, v] of Object.entries(value)) {
76288
- if (hasControl(k)) throw new OperationError(`${tool}: a key of \`${path148 || "the input"}\` ${REFUSAL}.`);
76289
- walk(v, childOf(node3, value, k), path148 ? `${path148}.${k}` : k);
76388
+ if (hasControl(k)) throw new OperationError(`${tool}: a key of \`${path149 || "the input"}\` ${REFUSAL}.`);
76389
+ walk(v, childOf(node3, value, k), path149 ? `${path149}.${k}` : k);
76290
76390
  }
76291
76391
  };
76292
76392
  walk(args, external_exports.object(shape), "");
@@ -77284,7 +77384,7 @@ ${exposure}
77284
77384
  }
77285
77385
 
77286
77386
  // src/pairCli.ts
77287
- import path138 from "node:path";
77387
+ import path139 from "node:path";
77288
77388
 
77289
77389
  // src/serve/openSignedIn.ts
77290
77390
  import { spawn as spawn4 } from "node:child_process";
@@ -77296,12 +77396,12 @@ import { readFileSync as readFileSync38 } from "node:fs";
77296
77396
  import os12 from "node:os";
77297
77397
 
77298
77398
  // src/serve/browser/linuxHttpHandler.ts
77299
- import path137 from "node:path";
77399
+ import path138 from "node:path";
77300
77400
  var DESKTOP_ID = /^[A-Za-z0-9][\w.-]{0,200}\.desktop$/;
77301
77401
  function applicationDirs(deps) {
77302
- const home = deps.env.XDG_DATA_HOME || path137.join(deps.home, ".local", "share");
77402
+ const home = deps.env.XDG_DATA_HOME || path138.join(deps.home, ".local", "share");
77303
77403
  const system = (deps.env.XDG_DATA_DIRS || "/usr/local/share:/usr/share").split(":").filter(Boolean);
77304
- return [home, ...system].map((d) => path137.join(d, "applications"));
77404
+ return [home, ...system].map((d) => path138.join(d, "applications"));
77305
77405
  }
77306
77406
  function linuxHttpHandler(deps) {
77307
77407
  let id;
@@ -77312,7 +77412,7 @@ function linuxHttpHandler(deps) {
77312
77412
  }
77313
77413
  if (!DESKTOP_ID.test(id)) return { kind: "none", why: "no default browser is set (xdg-settings)" };
77314
77414
  for (const dir4 of applicationDirs(deps)) {
77315
- const entry = path137.join(dir4, id);
77415
+ const entry = path138.join(dir4, id);
77316
77416
  const text11 = deps.readFile(entry);
77317
77417
  if (text11 === void 0) continue;
77318
77418
  if (/snap|flatpak/i.test(`${entry}
@@ -77461,7 +77561,7 @@ var WHY4 = {
77461
77561
  async function pairCli(argv2) {
77462
77562
  const o = parseSubArgs(argv2, ["--dir", "--no-open"]);
77463
77563
  if (o.rest.length) fail(`unexpected argument: ${o.rest[0]}`);
77464
- const root = path138.resolve(process.cwd(), o.dir);
77564
+ const root = path139.resolve(process.cwd(), o.dir);
77465
77565
  const lookout = await runningLookout(root);
77466
77566
  if (lookout.kind !== "running") fail(WHY4[lookout.kind]);
77467
77567
  const { instance } = lookout;
@@ -77539,7 +77639,7 @@ ${footer}
77539
77639
  function printGreeting() {
77540
77640
  process.stdout.write(
77541
77641
  greeting({
77542
- version: "0.61.2",
77642
+ version: "0.64.2",
77543
77643
  tagline: BRAND.tagline,
77544
77644
  isTTY: !!process.stdout.isTTY,
77545
77645
  columns: process.stdout.columns ?? 80,
@@ -77549,11 +77649,11 @@ function printGreeting() {
77549
77649
  }
77550
77650
 
77551
77651
  // src/projects.ts
77552
- import path139 from "node:path";
77652
+ import path140 from "node:path";
77553
77653
  function add2(target2, dir4, print) {
77554
- const where2 = path139.resolve(process.cwd(), target2 ?? ".");
77654
+ const where2 = path140.resolve(process.cwd(), target2 ?? ".");
77555
77655
  try {
77556
- const custom3 = target2 === void 0 && dir4 !== BRAND.dataDir ? path139.resolve(process.cwd(), dir4) : void 0;
77656
+ const custom3 = target2 === void 0 && dir4 !== BRAND.dataDir ? path140.resolve(process.cwd(), dir4) : void 0;
77557
77657
  const root = trackerRootFor(custom3 ?? where2, { create: true });
77558
77658
  const { entry, added } = registerProject({ configDir: configDir(), root });
77559
77659
  print(` ${added ? "Added" : "Already registered"} ${entry.name} ${entry.id} ${entry.root}`);
@@ -77583,7 +77683,7 @@ function runProjects(rest, dir4, print = (s) => process.stdout.write(`${s}
77583
77683
  `)) {
77584
77684
  const [cmd, target2] = rest;
77585
77685
  print(`
77586
- ${BRAND.name} \xB7 projects (${path139.join(configDir(), "projects.json")})
77686
+ ${BRAND.name} \xB7 projects (${path140.join(configDir(), "projects.json")})
77587
77687
  `);
77588
77688
  switch (cmd) {
77589
77689
  case "add":
@@ -77600,7 +77700,7 @@ function runProjects(rest, dir4, print = (s) => process.stdout.write(`${s}
77600
77700
  }
77601
77701
 
77602
77702
  // src/proof/proofCli.ts
77603
- import path141 from "node:path";
77703
+ import path142 from "node:path";
77604
77704
 
77605
77705
  // src/proof/findProofTicket.ts
77606
77706
  var norm4 = (s) => s.trim().replace(/^#/, "").toLowerCase();
@@ -77623,7 +77723,7 @@ function findProofTicket(input2) {
77623
77723
 
77624
77724
  // src/proof/proofVerifyCli.ts
77625
77725
  import { readFileSync as readFileSync39 } from "node:fs";
77626
- import path140 from "node:path";
77726
+ import path141 from "node:path";
77627
77727
  var FLAGS = /* @__PURE__ */ new Set(["--dir", "--keys-ref", "--pr", "--repo"]);
77628
77728
  function parse6(argv2) {
77629
77729
  const o = { dir: ".teamtrail", keysRef: "HEAD", status: false };
@@ -77675,7 +77775,7 @@ async function verifyPr(o, keys2) {
77675
77775
  }
77676
77776
  async function proofVerifyCli(argv2) {
77677
77777
  const o = parse6(argv2);
77678
- const keys2 = await proofKeysAt(path140.resolve(process.cwd(), o.dir), o.keysRef);
77778
+ const keys2 = await proofKeysAt(path141.resolve(process.cwd(), o.dir), o.keysRef);
77679
77779
  if (!keys2.size) process.stdout.write(`No proof keys committed at ${o.keysRef} in ${o.dir}/proof-keys.
77680
77780
  `);
77681
77781
  if (o.pr !== void 0) {
@@ -77740,7 +77840,7 @@ function parse7(argv2) {
77740
77840
  async function proofCli(argv2) {
77741
77841
  if (argv2[0] === "verify") return proofVerifyCli(argv2.slice(1));
77742
77842
  const o = parse7(argv2);
77743
- const root = path141.resolve(process.cwd(), o.dir);
77843
+ const root = path142.resolve(process.cwd(), o.dir);
77744
77844
  const markdown = new MarkdownAdapter({ ...nodeMarkdownFs(root), watch: void 0 }, root);
77745
77845
  const tracker = activeTracker({ root, markdown, unapproved: "stay" });
77746
77846
  try {
@@ -77799,18 +77899,18 @@ async function askSandbox(o) {
77799
77899
  }
77800
77900
 
77801
77901
  // src/selfCommand.ts
77802
- import path142 from "node:path";
77902
+ import path143 from "node:path";
77803
77903
  function selfCommand(o) {
77804
77904
  const spec = packageSpec(o.version);
77805
- const fromNpm = o.file.split(path142.sep).includes("node_modules") || o.file.includes("/node_modules/");
77905
+ const fromNpm = o.file.split(path143.sep).includes("node_modules") || o.file.includes("/node_modules/");
77806
77906
  if (fromNpm && spec.includes("@")) return { command: "npx", args: ["-y", spec], pinned: spec };
77807
77907
  return { command: "node", args: [o.file] };
77808
77908
  }
77809
77909
 
77810
77910
  // src/serve/serveLookout.ts
77811
- import { existsSync as existsSync42 } from "node:fs";
77911
+ import { existsSync as existsSync43 } from "node:fs";
77812
77912
  import http2 from "node:http";
77813
- import path146 from "node:path";
77913
+ import path147 from "node:path";
77814
77914
  import { fileURLToPath } from "node:url";
77815
77915
 
77816
77916
  // ../connector-slack/src/service/connectState.ts
@@ -80066,10 +80166,10 @@ function scoutService(env) {
80066
80166
 
80067
80167
  // ../connector-slack/src/settingStore.ts
80068
80168
  import { readFileSync as readFileSync40 } from "node:fs";
80069
- import path143 from "node:path";
80169
+ import path144 from "node:path";
80070
80170
  var FILE13 = ".agents/slack-settings.json";
80071
80171
  function settingStore(root) {
80072
- const file9 = path143.join(root, FILE13);
80172
+ const file9 = path144.join(root, FILE13);
80073
80173
  return {
80074
80174
  read: () => {
80075
80175
  try {
@@ -80084,7 +80184,7 @@ function settingStore(root) {
80084
80184
 
80085
80185
  // ../connector-slack/src/store.ts
80086
80186
  import { readFileSync as readFileSync41, rmSync as rmSync26 } from "node:fs";
80087
- import path144 from "node:path";
80187
+ import path145 from "node:path";
80088
80188
  var DEFAULTS = {
80089
80189
  enabled: false,
80090
80190
  owners: [],
@@ -80102,7 +80202,7 @@ function readJson3(file9) {
80102
80202
  }
80103
80203
  var KEPT2 = ["enabled", "workspace", "bot", "appId", "owners", "allow", "notify", "command", "channelTrail"];
80104
80204
  function slackStore(dir4) {
80105
- const file9 = path144.join(dir4, "slack.json");
80205
+ const file9 = path145.join(dir4, "slack.json");
80106
80206
  const creds = credentialStore(dir4);
80107
80207
  const read4 = () => {
80108
80208
  const c = readJson3(file9);
@@ -80161,7 +80261,7 @@ function alive3(pid) {
80161
80261
  }
80162
80262
  }
80163
80263
  function slackLock(dir4, owner) {
80164
- const file9 = path144.join(dir4, "slack.lock");
80264
+ const file9 = path145.join(dir4, "slack.lock");
80165
80265
  const current = () => {
80166
80266
  const l = readJson3(file9);
80167
80267
  return l.pid && alive3(l.pid) ? l : void 0;
@@ -80187,14 +80287,14 @@ function slackLock(dir4, owner) {
80187
80287
  var ASKS_FILE = ".agents/slack.json";
80188
80288
  var APPROVALS_FILE = ".agents/slack-approvals.json";
80189
80289
  function askStore(root) {
80190
- const file9 = path144.join(root, ASKS_FILE);
80290
+ const file9 = path145.join(root, ASKS_FILE);
80191
80291
  return {
80192
80292
  read: () => readJson3(file9).asks ?? {},
80193
80293
  write: (asks) => writeLocalJson(root, ASKS_FILE, { asks })
80194
80294
  };
80195
80295
  }
80196
80296
  function approvalStore(root) {
80197
- const file9 = path144.join(root, APPROVALS_FILE);
80297
+ const file9 = path145.join(root, APPROVALS_FILE);
80198
80298
  return {
80199
80299
  read: () => readJson3(file9).approvals ?? {},
80200
80300
  write: (approvals) => writeLocalJson(root, APPROVALS_FILE, { approvals })
@@ -80592,9 +80692,9 @@ async function agentVersionWarnings(root, own3) {
80592
80692
  }
80593
80693
 
80594
80694
  // src/serve/staticFiles.ts
80595
- import { existsSync as existsSync41, statSync as statSync17 } from "node:fs";
80695
+ import { existsSync as existsSync42, statSync as statSync17 } from "node:fs";
80596
80696
  import fs12 from "node:fs/promises";
80597
- import path145 from "node:path";
80697
+ import path146 from "node:path";
80598
80698
  var TYPES = {
80599
80699
  ".html": "text/html; charset=utf-8",
80600
80700
  ".js": "text/javascript; charset=utf-8",
@@ -80615,12 +80715,12 @@ function decoded(pathname) {
80615
80715
  }
80616
80716
  async function serveStatic(appDir, pathname, res) {
80617
80717
  let rel = decoded(pathname);
80618
- let file9 = path145.join(appDir, path145.normalize(rel));
80619
- if (!file9.startsWith(appDir + path145.sep) || !existsSync41(file9) || statSync17(file9).isDirectory()) {
80718
+ let file9 = path146.join(appDir, path146.normalize(rel));
80719
+ if (!file9.startsWith(appDir + path146.sep) || !existsSync42(file9) || statSync17(file9).isDirectory()) {
80620
80720
  rel = "/index.html";
80621
- file9 = path145.join(appDir, "index.html");
80721
+ file9 = path146.join(appDir, "index.html");
80622
80722
  }
80623
- res.setHeader("Content-Type", TYPES[path145.extname(file9)] ?? "application/octet-stream");
80723
+ res.setHeader("Content-Type", TYPES[path146.extname(file9)] ?? "application/octet-stream");
80624
80724
  res.setHeader("Cache-Control", rel.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache");
80625
80725
  res.end(await fs12.readFile(file9));
80626
80726
  }
@@ -80664,12 +80764,12 @@ function firstCode(signIn) {
80664
80764
  }
80665
80765
  }
80666
80766
  async function serveLookout(opts, slackSetup) {
80667
- const appDir = path146.join(path146.dirname(fileURLToPath(import.meta.url)), "app");
80668
- if (!existsSync42(path146.join(appDir, "index.html"))) fail(`Lookout bundle missing at ${appDir}; reinstall the package`);
80669
- const root = path146.resolve(process.cwd(), opts.dir);
80767
+ const appDir = path147.join(path147.dirname(fileURLToPath(import.meta.url)), "app");
80768
+ if (!existsSync43(path147.join(appDir, "index.html"))) fail(`Lookout bundle missing at ${appDir}; reinstall the package`);
80769
+ const root = path147.resolve(process.cwd(), opts.dir);
80670
80770
  const mcp = createMcpHttp({
80671
80771
  auth: tokenFileAuth(root),
80672
- open: remoteAgentOpener({ root, version: "0.61.2" }),
80772
+ open: remoteAgentOpener({ root, version: "0.64.2" }),
80673
80773
  thisMachineOnly: true
80674
80774
  });
80675
80775
  let hub;
@@ -80706,12 +80806,12 @@ async function serveLookout(opts, slackSetup) {
80706
80806
  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";
80707
80807
  process.stdout.write(
80708
80808
  `
80709
- ${BRAND.name} ${"0.61.2"} \xB7 ${BRAND.assistant.name} online
80809
+ ${BRAND.name} ${"0.64.2"} \xB7 ${BRAND.assistant.name} online
80710
80810
 
80711
80811
  Lookout ${url2}
80712
80812
  Sign in ${signInLink}
80713
80813
  ${howToSignIn}: once, within 10 minutes. \`${BRAND.slug} pair\` makes another.
80714
- Tracker ${path146.relative(process.cwd(), bridge.root) || "."}${path146.sep} (${bridge.root})
80814
+ Tracker ${path147.relative(process.cwd(), bridge.root) || "."}${path147.sep} (${bridge.root})
80715
80815
 
80716
80816
  Press Ctrl+C to stop.
80717
80817
 
@@ -80725,7 +80825,7 @@ async function serveLookout(opts, slackSetup) {
80725
80825
  openSignedIn({ root: bridge.root, mint, fallback: `${url2}${next}` });
80726
80826
  }
80727
80827
  const unlock = writeLookoutLock(bridge.root, url2);
80728
- for (const w of await agentVersionWarnings(bridge.root, "0.61.2"))
80828
+ for (const w of await agentVersionWarnings(bridge.root, "0.64.2"))
80729
80829
  process.stdout.write(` Heads up ${w}
80730
80830
  `);
80731
80831
  const unlist = writeMcpEndpoint(bridge.root, {
@@ -80764,7 +80864,7 @@ var MCP_FLAGS = [
80764
80864
  async function mcpCommand(argv2) {
80765
80865
  const o = parseSubArgs(argv2, MCP_FLAGS);
80766
80866
  if (o.rest.length) fail(`unexpected argument: ${o.rest[0]}`);
80767
- const root = path147.resolve(process.cwd(), o.dir);
80867
+ const root = path148.resolve(process.cwd(), o.dir);
80768
80868
  if (o.http) return runMcpHttp(mcpHttpOptions(o, root));
80769
80869
  if (o.host || o.port !== void 0 || o.allowHosts.length) fail("--host, --port and --allow-host need --http");
80770
80870
  await runMcpServer({
@@ -80772,7 +80872,7 @@ async function mcpCommand(argv2) {
80772
80872
  agent: o.agent,
80773
80873
  leaseMinutes: o.leaseMinutes,
80774
80874
  noRegister: o.noRegister,
80775
- version: "0.61.2"
80875
+ version: "0.64.2"
80776
80876
  });
80777
80877
  }
80778
80878
  function sandboxFlagFits(o, target2) {
@@ -80817,7 +80917,7 @@ async function connectCommand(argv2) {
80817
80917
  protectConfig: !o.noProtectConfig
80818
80918
  });
80819
80919
  else {
80820
- const self = selfCommand({ version: "0.61.2", file: fileURLToPath2(import.meta.url) });
80920
+ const self = selfCommand({ version: "0.64.2", file: fileURLToPath2(import.meta.url) });
80821
80921
  const protect = !o.noProtectConfig;
80822
80922
  const sandbox = target2 === "claude" ? await askSandbox({ cwd: process.cwd(), flag: o.sandbox, protect }) : void 0;
80823
80923
  runConnect(target2, {
@@ -80832,7 +80932,7 @@ async function connectCommand(argv2) {
80832
80932
  process.stdout.write("\n");
80833
80933
  }
80834
80934
  async function main() {
80835
- setRunningVersion("0.61.2");
80935
+ setRunningVersion("0.64.2");
80836
80936
  const argv2 = process.argv.slice(2);
80837
80937
  if (argv2[0] === "mcp") return mcpCommand(argv2.slice(1));
80838
80938
  if (argv2[0] === "hook") {
@@ -80853,7 +80953,7 @@ async function main() {
80853
80953
  if (argv2[0] === "knowledge") {
80854
80954
  const o = parseSubArgs(argv2.slice(1), ["--dir"]);
80855
80955
  if (o.rest[0] !== "import" || !o.rest[1]) fail("usage: knowledge import <file.md> [--dir <path>]");
80856
- const ids2 = importKnowledge(path147.resolve(process.cwd(), o.dir), path147.resolve(process.cwd(), o.rest[1]));
80956
+ const ids2 = importKnowledge(path148.resolve(process.cwd(), o.dir), path148.resolve(process.cwd(), o.rest[1]));
80857
80957
  process.stdout.write(
80858
80958
  `
80859
80959
  ${BRAND.name} \xB7 imported ${ids2.length} suggestions (${ids2[0] ?? "\u2014"}\u2026${ids2.at(-1) ?? ""}). Review them in the Lookout: Knowledge.