teamtrail 0.64.1 → 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
@@ -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
  }
@@ -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
@@ -9966,8 +9966,8 @@ function applyCall(e, call, now2 = Date.now()) {
9966
9966
  }
9967
9967
  }
9968
9968
  var words = (s) => s.toLowerCase().match(/[a-z0-9][a-z0-9_-]{1,}/g) ?? [];
9969
- function globMatch(glob, path148) {
9970
- return wildcardMatch(glob, path148.replace(/^\.\//, ""), { segments: true });
9969
+ function globMatch(glob, path149) {
9970
+ return wildcardMatch(glob, path149.replace(/^\.\//, ""), { segments: true });
9971
9971
  }
9972
9972
  function searchKnowledge(entries2, q) {
9973
9973
  const terms = new Set(words(q.query ?? ""));
@@ -10243,10 +10243,10 @@ function serializePolicy(p) {
10243
10243
 
10244
10244
  // ../core/src/policy/repoPath.ts
10245
10245
  var DRIVE = /^[A-Za-z]:\//;
10246
- function insideRepo(path148, declared, repoRoot) {
10246
+ function insideRepo(path149, declared, repoRoot) {
10247
10247
  const spellings = [repoRoot ?? []].flat().map((r) => r.replace(/\\/g, "/").replace(/\/+$/, ""));
10248
- const root = spellings.find((r) => path148.startsWith(`${r}/`));
10249
- 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);
10250
10250
  throw new OperationError(`"${declared}" is an absolute path outside the repo: give paths relative to the repo root`);
10251
10251
  }
10252
10252
  function repoPath(declared, repoRoot) {
@@ -10271,9 +10271,9 @@ function repoPaths(declared, repoRoot) {
10271
10271
  }
10272
10272
 
10273
10273
  // ../core/src/policy/ruleMatches.ts
10274
- function ruleMatches(glob, path148, fold2 = false) {
10274
+ function ruleMatches(glob, path149, fold2 = false) {
10275
10275
  const g = glob.normalize("NFC");
10276
- const p = path148.normalize("NFC");
10276
+ const p = path149.normalize("NFC");
10277
10277
  return fold2 ? globMatch(g.toLowerCase(), p.toLowerCase()) : globMatch(g, p);
10278
10278
  }
10279
10279
 
@@ -12781,7 +12781,7 @@ async function newDecisionFile(fs13, mapId, input2) {
12781
12781
 
12782
12782
  // ../core/src/adapters/markdown/paths.ts
12783
12783
  var DECISION_PATH = /^([^/]+)\/decisions\/([^/]+)\.md$/;
12784
- 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}`;
12785
12785
  var SEGMENT = /^[A-Za-z0-9][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_-]+)*$/;
12786
12786
  function segment(id) {
12787
12787
  if (typeof id !== "string" || id.length > 128 || !SEGMENT.test(id))
@@ -12802,19 +12802,19 @@ var ExternalChanges = class {
12802
12802
  /** Last seen text and supersededBy per decision file, to tell new records from supersessions and drop duplicate watcher hits. */
12803
12803
  seen = /* @__PURE__ */ new Map();
12804
12804
  pending = /* @__PURE__ */ new Map();
12805
- knows(path148) {
12806
- return this.seen.has(path148);
12805
+ knows(path149) {
12806
+ return this.seen.has(path149);
12807
12807
  }
12808
- remember(path148, text11, supersededBy) {
12809
- this.seen.set(path148, { text: text11, supersededBy });
12808
+ remember(path149, text11, supersededBy) {
12809
+ this.seen.set(path149, { text: text11, supersededBy });
12810
12810
  }
12811
- queue(path148) {
12812
- const mapId = path148.split("/")[0];
12811
+ queue(path149) {
12812
+ const mapId = path149.split("/")[0];
12813
12813
  const batch = this.pending.get(mapId) ?? {
12814
12814
  paths: /* @__PURE__ */ new Set(),
12815
12815
  timer: setTimeout(() => void this.flush(mapId), 250)
12816
12816
  };
12817
- batch.paths.add(path148);
12817
+ batch.paths.add(path149);
12818
12818
  this.pending.set(mapId, batch);
12819
12819
  }
12820
12820
  async flush(mapId) {
@@ -12931,6 +12931,42 @@ function serializeMapFile(m) {
12931
12931
  );
12932
12932
  }
12933
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
+
12934
12970
  // ../core/src/adapters/markdown/unreadDecision.ts
12935
12971
  function unreadDecision(file9, e) {
12936
12972
  if (e.code !== "ENOENT") console.warn(`Teamtrail: decision ${file9} can't be read: ${e.message}`);
@@ -12942,10 +12978,10 @@ var MarkdownAdapter = class {
12942
12978
  constructor(fs13, location = `./${BRAND.dataDir}`) {
12943
12979
  this.fs = fs13;
12944
12980
  this.location = location;
12945
- fs13.watch?.((path148) => {
12946
- const t = this.selfWrites.get(path148);
12981
+ fs13.watch?.((path149) => {
12982
+ const t = this.selfWrites.get(path149);
12947
12983
  if (t && Date.now() - t < 1500) return;
12948
- this.external.queue(path148);
12984
+ this.external.queue(path149);
12949
12985
  });
12950
12986
  }
12951
12987
  kind = "markdown";
@@ -12953,17 +12989,17 @@ var MarkdownAdapter = class {
12953
12989
  events = new Emitter();
12954
12990
  selfWrites = /* @__PURE__ */ new Map();
12955
12991
  external = new ExternalChanges(
12956
- (path148) => this.fs.read(path148),
12992
+ (path149) => this.fs.read(path149),
12957
12993
  (e) => this.events.emit(e)
12958
12994
  );
12959
12995
  /** `base`: the file as read before this change, so a write never undoes one made in between (signedWrite.ts). */
12960
- async put(path148, text11, base2) {
12961
- this.selfWrites.set(path148, Date.now());
12962
- 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 });
12963
12999
  }
12964
13000
  /** A new numbered file under a number nobody else has (createNumbered.ts). */
12965
13001
  putNew(make) {
12966
- 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()));
12967
13003
  }
12968
13004
  async readMap(mapId) {
12969
13005
  return parseMapFile(mapId, await this.fs.read(`${segment(mapId)}/map.md`));
@@ -12985,20 +13021,8 @@ var MarkdownAdapter = class {
12985
13021
  return { map: map2, tickets: tickets2.sort((a, b) => a.createdAt - b.createdAt) };
12986
13022
  }
12987
13023
  async createMap(input2) {
12988
- const n = await nextNumber(this.fs);
12989
- const slug2 = trailSlug(input2.title, n);
12990
- const map2 = {
12991
- id: slug2,
12992
- key: `#${n}`,
12993
- title: input2.title,
12994
- mode: input2.mode ?? DEFAULT_MAP_MODE,
12995
- ...input2.verification ? { verification: input2.verification } : {},
12996
- sections: input2.sections,
12997
- createdAt: Date.now(),
12998
- updatedAt: Date.now()
12999
- };
13000
- await this.writeMap(map2);
13001
- 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() });
13002
13026
  return map2;
13003
13027
  }
13004
13028
  async editMap(mapId, edit, event) {
@@ -13096,11 +13120,11 @@ var MarkdownAdapter = class {
13096
13120
  return d;
13097
13121
  }
13098
13122
  async markSuperseded(mapId, decisionId, supersededBy) {
13099
- const path148 = `${segment(mapId)}/decisions/${segment(decisionId)}.md`;
13100
- const base2 = await this.fs.read(path148);
13123
+ const path149 = `${segment(mapId)}/decisions/${segment(decisionId)}.md`;
13124
+ const base2 = await this.fs.read(path149);
13101
13125
  const text11 = serializeDecision({ ...parseDecision(base2), mapId, supersededBy });
13102
- this.external.remember(path148, text11, supersededBy);
13103
- await this.put(path148, text11, base2);
13126
+ this.external.remember(path149, text11, supersededBy);
13127
+ await this.put(path149, text11, base2);
13104
13128
  this.events.emit({ kind: "decision.superseded", mapId, decisionId, supersededBy, at: Date.now() });
13105
13129
  }
13106
13130
  subscribe(listener) {
@@ -14473,9 +14497,9 @@ var GitHubClient = class {
14473
14497
  return this.http.rate;
14474
14498
  }
14475
14499
  /** A REST call under `/repos/<owner>/<name>`. */
14476
- async repo(method, path148, body2, headers = {}) {
14500
+ async repo(method, path149, body2, headers = {}) {
14477
14501
  return this.http.send(
14478
- `${this.api}/repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.name)}${path148}`,
14502
+ `${this.api}/repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.name)}${path149}`,
14479
14503
  {
14480
14504
  method,
14481
14505
  headers: { ...restHeaders(this.o.token), ...body2 ? { "Content-Type": "application/json" } : {}, ...headers },
@@ -14519,8 +14543,8 @@ var GitHubPermissions = class {
14519
14543
  async lookUp(login) {
14520
14544
  const key = login.toLowerCase();
14521
14545
  try {
14522
- const path148 = `/collaborators/${encodeURIComponent(login)}/permission`;
14523
- 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);
14524
14548
  const write2 = WRITE_ROLES.has(body2.role_name ?? "") || WRITE_ROLES.has(body2.permission ?? "");
14525
14549
  this.known.set(key, { at: this.now(), ttl: OK_MS, write: write2 });
14526
14550
  } catch (err) {
@@ -14842,8 +14866,8 @@ var GitHubAdapter = class extends SyncedAdapter {
14842
14866
  });
14843
14867
  }
14844
14868
  async remoteRemoveBlocking(_map2, blocker, blocked) {
14845
- const path148 = `/issues/${blocked.id}/dependencies/blocked_by/${await this.issueId(blocker.id)}`;
14846
- 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) => {
14847
14871
  if (!(e instanceof TrackerError && e.code === "not_found")) throw e;
14848
14872
  });
14849
14873
  }
@@ -15552,8 +15576,8 @@ var CHECK_NAME_RE = /^[\w.-]+$/;
15552
15576
  function guideFields(yaml) {
15553
15577
  const findings = [];
15554
15578
  const v = yaml.value;
15555
- const lineOf = (path148) => yaml.lines[path148] ?? yaml.lines[path148.split(".")[0]] ?? 1;
15556
- 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 });
15557
15581
  for (const k of Object.keys(v)) {
15558
15582
  if (KEYS7.includes(k)) continue;
15559
15583
  if (FORBIDDEN.test(k))
@@ -15673,10 +15697,10 @@ function readMap(s, scope) {
15673
15697
  s.errors.push({ line: l.n, message: `"${key}" is not a key a guide can have` });
15674
15698
  continue;
15675
15699
  }
15676
- const path148 = scope.path ? `${scope.path}.${key}` : key;
15700
+ const path149 = scope.path ? `${scope.path}.${key}` : key;
15677
15701
  if (key in out) s.errors.push({ line: l.n, message: `"${key}" appears twice` });
15678
- s.at[path148] = l.n;
15679
- 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 });
15680
15704
  }
15681
15705
  return out;
15682
15706
  }
@@ -16892,16 +16916,16 @@ function personOf(value) {
16892
16916
  }
16893
16917
 
16894
16918
  // src/approve/approveCli.ts
16895
- import path113 from "node:path";
16919
+ import path114 from "node:path";
16896
16920
 
16897
16921
  // ../core/src/server/trackerBridge.ts
16898
- import path99 from "node:path";
16922
+ import path100 from "node:path";
16899
16923
 
16900
16924
  // ../core/src/adapters/markdown/nodeMarkdownFs.ts
16901
- import path16 from "node:path";
16925
+ import path17 from "node:path";
16902
16926
 
16903
16927
  // ../core/src/signedState/signedFs.ts
16904
- import path12 from "node:path";
16928
+ import path13 from "node:path";
16905
16929
 
16906
16930
  // ../core/src/signedState/cachedFields.ts
16907
16931
  import { readFileSync as readFileSync5, statSync as statSync5 } from "node:fs";
@@ -18012,29 +18036,11 @@ function removedTrails(root, files) {
18012
18036
 
18013
18037
  // ../core/src/signedState/signedWrite.ts
18014
18038
  import { readFileSync as readFileSync8 } from "node:fs";
18015
- import path11 from "node:path";
18016
-
18017
- // ../core/src/signedState/outsideMapText.ts
18018
- function keepOutsideMapText(input2) {
18019
- const { mapId, changed } = input2;
18020
- const written = parseMapFile(mapId, input2.written);
18021
- const raw = parseMapFile(mapId, input2.raw);
18022
- const rewritten = !changed.includes("destination") && destinationHash(raw) !== destinationHash(written);
18023
- const inRaw = new Set((raw.sections.assumptions ?? []).map((a) => a.id));
18024
- const deleted = (id) => !inRaw.has(id) && !changed.includes(`${ASSUMPTION_PREFIX}${id}`);
18025
- const assumptions = written.sections.assumptions ?? [];
18026
- const kept = assumptions.filter((a) => !deleted(a.id));
18027
- if (!rewritten && kept.length === assumptions.length) return input2.written;
18028
- const sections = { ...written.sections, assumptions: kept };
18029
- if (rewritten) sections.destination = raw.sections.destination;
18030
- return serializeMapFile({ ...written, sections });
18031
- }
18039
+ import path12 from "node:path";
18032
18040
 
18033
- // ../core/src/signedState/staleWrite.ts
18034
- function staleWrite(rel, fields2) {
18035
- const msg = `${rel} changed while this was being done (${fields2.join(", ")}): nothing was written. Read it again and redo the change.`;
18036
- return Object.assign(new Error(msg), { stale: true, status: 409 });
18037
- }
18041
+ // ../core/src/signedState/freeTrailFolder.ts
18042
+ import { existsSync as existsSync5, readdirSync as readdirSync3 } from "node:fs";
18043
+ import path11 from "node:path";
18038
18044
 
18039
18045
  // ../core/src/signedState/trackerFileWrite.ts
18040
18046
  import { randomBytes as randomBytes3 } from "node:crypto";
@@ -18111,10 +18117,49 @@ function removeTrackerFile(root, rel) {
18111
18117
  rmSync5(path10.join(dir4, path10.basename(rel)), { force: true });
18112
18118
  }
18113
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
+
18114
18159
  // ../core/src/signedState/signedWrite.ts
18115
18160
  function readIfThere(root, rel) {
18116
18161
  refuseLinks(root, rel);
18117
- const file9 = path11.join(root, rel);
18162
+ const file9 = path12.join(root, rel);
18118
18163
  if (oversizedFile(file9)) return void 0;
18119
18164
  try {
18120
18165
  return readFileSync8(file9, "utf8");
@@ -18172,6 +18217,7 @@ function signedWrite(w, mode = {}) {
18172
18217
  return withStateLock(root, item2.mapId, () => {
18173
18218
  const raw = readIfThere(root, item2.rel);
18174
18219
  if (mode.create && raw !== void 0) return false;
18220
+ if (mode.create && item2.kind === "map" && !freeTrailFolder(root, item2.mapId)) return false;
18175
18221
  const entries2 = entriesToChange(root, item2.mapId);
18176
18222
  const was = entries2[item2.key];
18177
18223
  const { written, fields: fields2 } = plan(w, mode.create ? void 0 : raw, mode.create ? void 0 : was);
@@ -18183,7 +18229,7 @@ function signedWrite(w, mode = {}) {
18183
18229
  }
18184
18230
 
18185
18231
  // ../core/src/signedState/writerDone.ts
18186
- import { existsSync as existsSync5 } from "node:fs";
18232
+ import { existsSync as existsSync6 } from "node:fs";
18187
18233
  var WAIT_MS3 = 3e3;
18188
18234
  var POLL_MS = 10;
18189
18235
  async function writerDone(root, mapId) {
@@ -18194,13 +18240,13 @@ async function writerDone(root, mapId) {
18194
18240
  return;
18195
18241
  }
18196
18242
  const until = Date.now() + WAIT_MS3;
18197
- 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));
18198
18244
  }
18199
18245
 
18200
18246
  // ../core/src/signedState/signedFs.ts
18201
18247
  var notFound = (p) => Object.assign(new Error(`not found: ${p}`), { code: "ENOENT" });
18202
18248
  async function readRaw(root, inner, p) {
18203
- if (oversizedFile(path12.join(root, p))) return void 0;
18249
+ if (oversizedFile(path13.join(root, p))) return void 0;
18204
18250
  try {
18205
18251
  return await inner.read(p);
18206
18252
  } catch (e) {
@@ -18243,29 +18289,29 @@ function signedFs(root, inner, by) {
18243
18289
  // ../core/src/adapters/markdown/rawMarkdownFs.ts
18244
18290
  import { mkdirSync as mkdirSync8 } from "node:fs";
18245
18291
  import fs from "node:fs/promises";
18246
- import path15 from "node:path";
18292
+ import path16 from "node:path";
18247
18293
 
18248
18294
  // ../core/src/lib/watchTree.ts
18249
18295
  import { watch as watch2 } from "node:fs";
18250
- import path14 from "node:path";
18296
+ import path15 from "node:path";
18251
18297
 
18252
18298
  // ../core/src/lib/watchFolders.ts
18253
- import { lstatSync as lstatSync3, readdirSync as readdirSync3, watch } from "node:fs";
18254
- import path13 from "node:path";
18299
+ import { lstatSync as lstatSync3, readdirSync as readdirSync4, watch } from "node:fs";
18300
+ import path14 from "node:path";
18255
18301
  function watchFolders(root, onChange) {
18256
18302
  const watched = /* @__PURE__ */ new Map();
18257
18303
  let closed = false;
18258
- const relOf = (full) => path13.relative(root, full).split(path13.sep).join("/");
18304
+ const relOf = (full) => path14.relative(root, full).split(path14.sep).join("/");
18259
18305
  function unwatchUnder(dir4) {
18260
18306
  for (const [d, w] of watched) {
18261
- if (d !== dir4 && !d.startsWith(dir4 + path13.sep)) continue;
18307
+ if (d !== dir4 && !d.startsWith(dir4 + path14.sep)) continue;
18262
18308
  w.watcher.close();
18263
18309
  watched.delete(d);
18264
18310
  }
18265
18311
  }
18266
18312
  function entries2(dir4) {
18267
18313
  try {
18268
- return readdirSync3(dir4, { withFileTypes: true });
18314
+ return readdirSync4(dir4, { withFileTypes: true });
18269
18315
  } catch {
18270
18316
  return [];
18271
18317
  }
@@ -18274,14 +18320,14 @@ function watchFolders(root, onChange) {
18274
18320
  if (closed) return;
18275
18321
  let watcher;
18276
18322
  try {
18277
- 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))));
18278
18324
  } catch {
18279
18325
  return;
18280
18326
  }
18281
18327
  watcher.on("error", () => unwatchUnder(dir4));
18282
18328
  watched.set(dir4, { watcher, ino });
18283
18329
  for (const e of entries2(dir4)) {
18284
- const full = path13.join(dir4, e.name);
18330
+ const full = path14.join(dir4, e.name);
18285
18331
  if (announce) onChange(relOf(full));
18286
18332
  if (e.isDirectory()) folder2(full, announce);
18287
18333
  }
@@ -18312,26 +18358,26 @@ var NATIVE_RECURSIVE = /* @__PURE__ */ new Set(["darwin", "win32"]);
18312
18358
  function watchTree(root, onChange, opts = {}) {
18313
18359
  const native = opts.native ?? NATIVE_RECURSIVE.has(process.platform);
18314
18360
  if (!native) return watchFolders(root, onChange);
18315
- 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("/")));
18316
18362
  return () => w.close();
18317
18363
  }
18318
18364
 
18319
18365
  // ../core/src/adapters/markdown/rawMarkdownFs.ts
18320
18366
  function rawMarkdownFs(root) {
18321
- const abs = path15.resolve(root);
18367
+ const abs = path16.resolve(root);
18322
18368
  mkdirSync8(abs, { recursive: true });
18323
18369
  const safe18 = (p) => {
18324
- const full = path15.resolve(abs, p);
18325
- 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");
18326
18372
  return full;
18327
18373
  };
18328
18374
  async function walk(dir4) {
18329
18375
  const entries2 = await fs.readdir(dir4, { withFileTypes: true }).catch(() => []);
18330
18376
  const out = [];
18331
18377
  for (const e of entries2) {
18332
- const full = path15.join(dir4, e.name);
18378
+ const full = path16.join(dir4, e.name);
18333
18379
  if (e.isDirectory()) out.push(...await walk(full));
18334
- 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("/"));
18335
18381
  }
18336
18382
  return out;
18337
18383
  }
@@ -18339,11 +18385,11 @@ function rawMarkdownFs(root) {
18339
18385
  list: () => walk(abs),
18340
18386
  read: (p) => fs.readFile(safe18(p), "utf8"),
18341
18387
  async write(p, text11) {
18342
- await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18388
+ await fs.mkdir(path16.dirname(safe18(p)), { recursive: true });
18343
18389
  await fs.writeFile(safe18(p), text11);
18344
18390
  },
18345
18391
  async create(p, text11) {
18346
- await fs.mkdir(path15.dirname(safe18(p)), { recursive: true });
18392
+ await fs.mkdir(path16.dirname(safe18(p)), { recursive: true });
18347
18393
  try {
18348
18394
  await fs.writeFile(safe18(p), text11, { flag: "wx" });
18349
18395
  return true;
@@ -18358,15 +18404,15 @@ function rawMarkdownFs(root) {
18358
18404
 
18359
18405
  // ../core/src/adapters/markdown/nodeMarkdownFs.ts
18360
18406
  function nodeMarkdownFs(root, opts = {}) {
18361
- const abs = path16.resolve(root);
18407
+ const abs = path17.resolve(root);
18362
18408
  const { by = "teamtrail" } = opts;
18363
18409
  return signedFs(abs, rawMarkdownFs(abs), typeof by === "function" ? by : () => by);
18364
18410
  }
18365
18411
 
18366
18412
  // ../core/src/verification/localRepoFiles.ts
18367
- import { existsSync as existsSync6, realpathSync as realpathSync3 } from "node:fs";
18413
+ import { existsSync as existsSync7, realpathSync as realpathSync3 } from "node:fs";
18368
18414
  import { readFile, realpath, stat } from "node:fs/promises";
18369
- import path17 from "node:path";
18415
+ import path18 from "node:path";
18370
18416
 
18371
18417
  // ../core/src/verification/repoPath.ts
18372
18418
  function repoPath2(...parts2) {
@@ -18388,9 +18434,9 @@ var MAX_SCREEN_BYTES = 1024 * 1024;
18388
18434
  async function inside(real7, rel) {
18389
18435
  const clean2 = repoPath2(rel);
18390
18436
  if (clean2 === void 0) return void 0;
18391
- const target2 = await realpath(path17.join(real7, clean2)).catch(() => void 0);
18437
+ const target2 = await realpath(path18.join(real7, clean2)).catch(() => void 0);
18392
18438
  if (!target2) return void 0;
18393
- return target2 === real7 || target2.startsWith(real7 + path17.sep) ? target2 : void 0;
18439
+ return target2 === real7 || target2.startsWith(real7 + path18.sep) ? target2 : void 0;
18394
18440
  }
18395
18441
  function localRepoFiles(repoRoot) {
18396
18442
  let real7;
@@ -18399,7 +18445,7 @@ function localRepoFiles(repoRoot) {
18399
18445
  } catch {
18400
18446
  return void 0;
18401
18447
  }
18402
- if (!existsSync6(path17.join(real7, ".git"))) return void 0;
18448
+ if (!existsSync7(path18.join(real7, ".git"))) return void 0;
18403
18449
  return {
18404
18450
  async read(rel) {
18405
18451
  const file9 = await inside(real7, rel);
@@ -18418,15 +18464,15 @@ function localRepoFiles(repoRoot) {
18418
18464
 
18419
18465
  // ../core/src/agents/agentDocs.ts
18420
18466
  import fs2 from "node:fs/promises";
18421
- import path21 from "node:path";
18467
+ import path22 from "node:path";
18422
18468
 
18423
18469
  // ../core/src/lib/ensureLocalDir.ts
18424
18470
  import { mkdirSync as mkdirSync9, readFileSync as readFileSync9, writeFileSync as writeFileSync6 } from "node:fs";
18425
- import path18 from "node:path";
18471
+ import path19 from "node:path";
18426
18472
  var RULE = "*\n";
18427
18473
  function ensureLocalDir(dir4) {
18428
18474
  mkdirSync9(dir4, { recursive: true });
18429
- const ignore = path18.join(dir4, ".gitignore");
18475
+ const ignore = path19.join(dir4, ".gitignore");
18430
18476
  let text11 = "";
18431
18477
  try {
18432
18478
  text11 = readFileSync9(ignore, "utf8");
@@ -18435,13 +18481,13 @@ function ensureLocalDir(dir4) {
18435
18481
  if (text11 !== RULE) writeFileSync6(ignore, RULE);
18436
18482
  }
18437
18483
  function writeLocalJson(root, rel, value) {
18438
- ensureLocalDir(path18.join(root, rel.split(/[\\/]/)[0]));
18439
- writeJsonAtomic(path18.join(root, rel), value);
18484
+ ensureLocalDir(path19.join(root, rel.split(/[\\/]/)[0]));
18485
+ writeJsonAtomic(path19.join(root, rel), value);
18440
18486
  }
18441
18487
 
18442
18488
  // ../core/src/verification/evidenceStore.ts
18443
- import { mkdirSync as mkdirSync10, readdirSync as readdirSync4, writeFileSync as writeFileSync7 } from "node:fs";
18444
- 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";
18445
18491
  var EVIDENCE_DIR = ".evidence";
18446
18492
  var safe3 = (s) => s.replace(/[^\w.-]/g, "_");
18447
18493
  var evidencePaths = {
@@ -18454,7 +18500,7 @@ var seq = (prefix) => new RegExp(`^${prefix}-(\\d+)\\.json$`);
18454
18500
  function numbered2(root, mapId, ticketId, prefix) {
18455
18501
  let names = [];
18456
18502
  try {
18457
- names = readdirSync4(path19.join(root, evidencePaths.ticket(mapId, ticketId)));
18503
+ names = readdirSync5(path20.join(root, evidencePaths.ticket(mapId, ticketId)));
18458
18504
  } catch {
18459
18505
  return [];
18460
18506
  }
@@ -18462,16 +18508,16 @@ function numbered2(root, mapId, ticketId, prefix) {
18462
18508
  return names.map((n) => Number(n.match(re)?.[1])).filter((n) => n > 0).sort((a, b) => a - b);
18463
18509
  }
18464
18510
  function writeOnce(root, rel, value) {
18465
- ensureLocalDir(path19.join(root, EVIDENCE_DIR));
18466
- mkdirSync10(path19.dirname(path19.join(root, rel)), { recursive: true });
18467
- 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" });
18468
18514
  }
18469
18515
  var nextAttemptId = (root, mapId, ticketId) => `A-${(numbered2(root, mapId, ticketId, "A").at(-1) ?? 0) + 1}`;
18470
18516
  function writeAttempt(root, a) {
18471
18517
  writeOnce(root, evidencePaths.attempt(a.mapId, a.ticketId, a.id), a);
18472
18518
  }
18473
18519
  function readAttempt(root, mapId, ticketId, id) {
18474
- const a = readJsonFile(path19.join(root, evidencePaths.attempt(mapId, ticketId, id)));
18520
+ const a = readJsonFile(path20.join(root, evidencePaths.attempt(mapId, ticketId, id)));
18475
18521
  return a?.v === 1 ? a : void 0;
18476
18522
  }
18477
18523
  var readAttempts = (root, mapId, ticketId) => numbered2(root, mapId, ticketId, "A").map((n) => readAttempt(root, mapId, ticketId, `A-${n}`)).filter((a) => !!a);
@@ -18487,7 +18533,7 @@ function writeVerdict(root, v) {
18487
18533
  }
18488
18534
  }
18489
18535
  }
18490
- 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);
18491
18537
 
18492
18538
  // ../core/src/policy/caseInsensitiveFs.ts
18493
18539
  import { statSync as statSync7 } from "node:fs";
@@ -18510,8 +18556,8 @@ function caseInsensitiveFs(dir4) {
18510
18556
  }
18511
18557
 
18512
18558
  // ../core/src/policy/policyStore.ts
18513
- import { existsSync as existsSync7, mkdirSync as mkdirSync11, readFileSync as readFileSync10, writeFileSync as writeFileSync8 } from "node:fs";
18514
- 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";
18515
18561
 
18516
18562
  // ../core/src/policy/stricterPolicy.ts
18517
18563
  var rank3 = (l) => RISK_LEVELS.indexOf(l);
@@ -18537,10 +18583,10 @@ function stricterPolicy(file9, approved) {
18537
18583
 
18538
18584
  // ../core/src/policy/policyStore.ts
18539
18585
  var POLICY_FILE = "policy.json";
18540
- var policyPath = (root) => path20.join(root, POLICY_FILE);
18586
+ var policyPath = (root) => path21.join(root, POLICY_FILE);
18541
18587
  function readPolicyFile(root) {
18542
18588
  const f = policyPath(root);
18543
- if (!existsSync7(f)) return { policy: DEFAULT_POLICY, errors: [], defaults: true };
18589
+ if (!existsSync8(f)) return { policy: DEFAULT_POLICY, errors: [], defaults: true };
18544
18590
  const { policy, errors } = parsePolicy(readFileSync10(f, "utf8"));
18545
18591
  if (policy) return { policy, errors, defaults: false };
18546
18592
  return { policy: DEFAULT_POLICY, errors, defaults: true };
@@ -18633,12 +18679,12 @@ function checkAgentAnswer(root, a, q) {
18633
18679
  // ../core/src/agents/agentDocs.ts
18634
18680
  function readAgentDoc(root, rel) {
18635
18681
  if (!SESSION_DOC_PATH.test(rel)) return void 0;
18636
- const doc = readJsonFile(path21.join(root, rel));
18682
+ const doc = readJsonFile(path22.join(root, rel));
18637
18683
  if (!doc || doc.v !== 1 || !doc.session) return void 0;
18638
18684
  return processAlive(doc.pid) ? doc : markDisconnected(doc);
18639
18685
  }
18640
18686
  async function readAgentDocs(root, opts = {}) {
18641
- const dir4 = path21.join(root, agentPaths.sessions);
18687
+ const dir4 = path22.join(root, agentPaths.sessions);
18642
18688
  const names = await fs2.readdir(dir4).catch(() => []);
18643
18689
  const since2 = Date.now() - (opts.recentMs ?? 24 * 36e5);
18644
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);
@@ -18682,10 +18728,10 @@ function writeAgentAnswer(root, input2) {
18682
18728
 
18683
18729
  // ../core/src/guides/catalogsApproval.ts
18684
18730
  import { readFileSync as readFileSync11 } from "node:fs";
18685
- import path22 from "node:path";
18731
+ import path23 from "node:path";
18686
18732
  function fileText(root) {
18687
18733
  try {
18688
- return readFileSync11(path22.join(root, GUIDES_CONFIG_FILE), "utf8");
18734
+ return readFileSync11(path23.join(root, GUIDES_CONFIG_FILE), "utf8");
18689
18735
  } catch {
18690
18736
  return void 0;
18691
18737
  }
@@ -18748,8 +18794,8 @@ function readGuidesConfig(root) {
18748
18794
  }
18749
18795
 
18750
18796
  // ../core/src/guides/guideStore.ts
18751
- import { existsSync as existsSync8, readdirSync as readdirSync5, readFileSync as readFileSync12 } from "node:fs";
18752
- 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";
18753
18799
 
18754
18800
  // ../core/src/guides/approvedLock.ts
18755
18801
  var FILE2 = "guides-approved.json";
@@ -18764,8 +18810,8 @@ var same3 = (a, b) => JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
18764
18810
  var lockChangedFor = (lock, approved, id) => !same3(lock.guides[id], approved.guides[id]);
18765
18811
 
18766
18812
  // ../core/src/guides/guideLock.ts
18767
- import path23 from "node:path";
18768
- 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);
18769
18815
  var isEntry = (e) => !!e && typeof e === "object" && typeof e.sha256 === "string";
18770
18816
  function reviewOf(raw) {
18771
18817
  const r = raw;
@@ -18851,12 +18897,12 @@ var missingGuide = (id, lock) => ({
18851
18897
  });
18852
18898
 
18853
18899
  // ../core/src/guides/guideStore.ts
18854
- var guidesDir = (root) => path24.join(root, GUIDES_DIR);
18855
- 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`);
18856
18902
  function readGuideFiles(root) {
18857
18903
  const dir4 = guidesDir(root);
18858
- if (!existsSync8(dir4)) return [];
18859
- 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") }));
18860
18906
  }
18861
18907
  function listGuides(root) {
18862
18908
  const lock = readGuideLock(root);
@@ -18880,18 +18926,18 @@ function listGuides(root) {
18880
18926
 
18881
18927
  // ../core/src/history/journalFile.ts
18882
18928
  import { appendFileSync, readFileSync as readFileSync13 } from "node:fs";
18883
- import path25 from "node:path";
18929
+ import path26 from "node:path";
18884
18930
  var TRAIL_KINDS = /* @__PURE__ */ new Set(["transition", "reroute"]);
18885
18931
  var JOURNAL_DIR = ".events";
18886
18932
  var MAX_REASON = 500;
18887
18933
  var safe4 = (s) => s.replace(/[^\w.-]/g, "_");
18888
- 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`);
18889
18935
  function journalFile(root) {
18890
18936
  const raw = (mapId) => readEntries(root, mapId);
18891
18937
  const readAll2 = (mapId) => raw(mapId).filter((e) => TRAIL_KINDS.has(e.kind));
18892
18938
  return {
18893
18939
  append(entry) {
18894
- ensureLocalDir(path25.join(root, JOURNAL_DIR));
18940
+ ensureLocalDir(path26.join(root, JOURNAL_DIR));
18895
18941
  const line5 = { ...entry, ...entry.reason ? { reason: entry.reason.slice(0, MAX_REASON) } : {} };
18896
18942
  appendFileSync(journalPath(root, entry.mapId), JSON.stringify(line5) + "\n");
18897
18943
  },
@@ -19069,13 +19115,13 @@ async function handleAgents(root, req, res, url2) {
19069
19115
  }
19070
19116
 
19071
19117
  // ../core/src/attention/attentionStore.ts
19072
- import { existsSync as existsSync9, readFileSync as readFileSync14 } from "node:fs";
19073
- import path26 from "node:path";
19118
+ import { existsSync as existsSync10, readFileSync as readFileSync14 } from "node:fs";
19119
+ import path27 from "node:path";
19074
19120
  var STATE_DIR2 = ".attention";
19075
19121
  var STATE_FILE = "state.json";
19076
19122
  function readAttentionPolicy(root) {
19077
- const file9 = path26.join(root, ATTENTION_FILE);
19078
- 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 }) };
19079
19125
  let raw;
19080
19126
  try {
19081
19127
  raw = parseJsonSafe(readFileSync14(file9, "utf8"));
@@ -19086,14 +19132,14 @@ function readAttentionPolicy(root) {
19086
19132
  return { file: ATTENTION_FILE, exists: true, ...parseAttentionPolicy(raw) };
19087
19133
  }
19088
19134
  function readAttentionPrefs(dir4 = configDir()) {
19089
- return parseAttentionPrefs(readJsonFile(path26.join(dir4, ATTENTION_FILE)) ?? {}).value;
19135
+ return parseAttentionPrefs(readJsonFile(path27.join(dir4, ATTENTION_FILE)) ?? {}).value;
19090
19136
  }
19091
19137
  function writeAttentionPrefs(raw, dir4 = configDir()) {
19092
19138
  const parsed3 = parseAttentionPrefs(raw);
19093
- 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 });
19094
19140
  return parsed3;
19095
19141
  }
19096
- var stateFile = (root) => path26.join(root, STATE_DIR2, STATE_FILE);
19142
+ var stateFile = (root) => path27.join(root, STATE_DIR2, STATE_FILE);
19097
19143
  function readAttentionState(root) {
19098
19144
  const s = readJsonFile(stateFile(root));
19099
19145
  if (s?.v !== 1) return EMPTY_ATTENTION_STATE;
@@ -19105,7 +19151,7 @@ function readAttentionState(root) {
19105
19151
  };
19106
19152
  }
19107
19153
  function writeAttentionState(root, s) {
19108
- ensureLocalDir(path26.join(root, STATE_DIR2));
19154
+ ensureLocalDir(path27.join(root, STATE_DIR2));
19109
19155
  writeJsonAtomic(stateFile(root), s);
19110
19156
  }
19111
19157
  function updateAttentionState(root, change3, now2 = Date.now()) {
@@ -19117,13 +19163,13 @@ function updateAttentionState(root, change3, now2 = Date.now()) {
19117
19163
  }
19118
19164
 
19119
19165
  // ../core/src/adapters/remote/legacyOutbox.ts
19120
- import { readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync7 } from "node:fs";
19121
- 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";
19122
19168
 
19123
19169
  // ../core/src/adapters/remote/outboxFile.ts
19124
19170
  import { createHash as createHash4 } from "node:crypto";
19125
- import { readFileSync as readFileSync15, readdirSync as readdirSync6, renameSync as renameSync7, rmSync as rmSync6 } from "node:fs";
19126
- 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";
19127
19173
 
19128
19174
  // ../core/src/adapters/remote/legacyTargetKey.ts
19129
19175
  var legacyTargetKey = (key) => key.replace(/-[0-9a-f]{16}$/, "");
@@ -19155,7 +19201,7 @@ function isQueuedWrite(w) {
19155
19201
 
19156
19202
  // ../core/src/adapters/remote/outboxFile.ts
19157
19203
  var OUTBOX_DIR = ".outbox";
19158
- var outboxDir = (root, configDir2) => path27.join(machineStore(root, configDir2).dir, "outbox");
19204
+ var outboxDir = (root, configDir2) => path28.join(machineStore(root, configDir2).dir, "outbox");
19159
19205
  var isOutboxPath = (rel) => rel === OUTBOX_DIR || rel.startsWith(`${OUTBOX_DIR}/`) || rel.startsWith(`${OUTBOX_DIR}\\`);
19160
19206
  function outboxKey(kind2, ...target2) {
19161
19207
  const parts2 = [kind2, ...target2.filter(Boolean)];
@@ -19186,7 +19232,7 @@ function mine(dir4, key) {
19186
19232
  function orphans(dir4, key) {
19187
19233
  let names;
19188
19234
  try {
19189
- names = readdirSync6(dir4);
19235
+ names = readdirSync7(dir4);
19190
19236
  } catch {
19191
19237
  return [];
19192
19238
  }
@@ -19201,11 +19247,11 @@ function readWrites(file9) {
19201
19247
  }
19202
19248
  }
19203
19249
  function orphanedWrites(dir4, key) {
19204
- 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);
19205
19251
  }
19206
19252
  function outboxFile(dir4, key) {
19207
19253
  const owner = `${process.pid}-${++instances}`;
19208
- const file9 = path27.join(dir4, `${key}.${owner}.json`);
19254
+ const file9 = path28.join(dir4, `${key}.${owner}.json`);
19209
19255
  let released = false;
19210
19256
  const save2 = (writes) => {
19211
19257
  if (released) return;
@@ -19218,9 +19264,9 @@ function outboxFile(dir4, key) {
19218
19264
  live.add(owner);
19219
19265
  const claimed = [];
19220
19266
  for (const [i, name2] of mine(dir4, key).entries()) {
19221
- const to = path27.join(dir4, `${key}.${owner}.claim-${i}.json`);
19267
+ const to = path28.join(dir4, `${key}.${owner}.claim-${i}.json`);
19222
19268
  try {
19223
- renameSync7(path27.join(dir4, name2), to);
19269
+ renameSync7(path28.join(dir4, name2), to);
19224
19270
  claimed.push(to);
19225
19271
  } catch {
19226
19272
  }
@@ -19250,10 +19296,10 @@ function readQueue(file9) {
19250
19296
  }
19251
19297
  }
19252
19298
  function legacyOutbox(root) {
19253
- const dir4 = path28.join(root, OUTBOX_DIR);
19299
+ const dir4 = path29.join(root, OUTBOX_DIR);
19254
19300
  const files = () => {
19255
19301
  try {
19256
- return readdirSync7(dir4).filter((n) => n.endsWith(".json"));
19302
+ return readdirSync8(dir4).filter((n) => n.endsWith(".json"));
19257
19303
  } catch {
19258
19304
  return [];
19259
19305
  }
@@ -19261,20 +19307,20 @@ function legacyOutbox(root) {
19261
19307
  return {
19262
19308
  list() {
19263
19309
  const names = files();
19264
- const writes = names.flatMap((n) => readQueue(path28.join(dir4, n)));
19310
+ const writes = names.flatMap((n) => readQueue(path29.join(dir4, n)));
19265
19311
  return { writes: writes.length, targets: [...new Set(names.map(targetOf))], labels: writes.map((w) => w.label) };
19266
19312
  },
19267
19313
  /** Moves every queue into `queueDir` (this machine's), where the tracker adapter for its target sends it. */
19268
19314
  send(queueDir) {
19269
19315
  files().forEach((n, i) => {
19270
- const writes = readQueue(path28.join(dir4, n));
19316
+ const writes = readQueue(path29.join(dir4, n));
19271
19317
  if (writes.length)
19272
- writePrivateFile(path28.join(queueDir, `${targetOf(n)}.legacy-${i}.json`), JSON.stringify({ v: 1, writes }));
19273
- 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 });
19274
19320
  });
19275
19321
  },
19276
19322
  discard() {
19277
- 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 });
19278
19324
  }
19279
19325
  };
19280
19326
  }
@@ -19295,19 +19341,19 @@ function connectedAgents(docs) {
19295
19341
  }
19296
19342
 
19297
19343
  // ../core/src/agents/leaseStore.ts
19298
- import { readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync8 } from "node:fs";
19299
- 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";
19300
19346
  var MAX_NOTES = 20;
19301
- 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));
19302
19348
  function readLeases(root) {
19303
- const dir4 = path29.join(root, leasePaths.dir);
19349
+ const dir4 = path30.join(root, leasePaths.dir);
19304
19350
  let names = [];
19305
19351
  try {
19306
- names = readdirSync8(dir4).filter((n) => n.endsWith(".json"));
19352
+ names = readdirSync9(dir4).filter((n) => n.endsWith(".json"));
19307
19353
  } catch {
19308
19354
  return [];
19309
19355
  }
19310
- 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);
19311
19357
  }
19312
19358
  function readLease(root, mapId, ticketId) {
19313
19359
  const l = readJsonFile(file(root, mapId, ticketId));
@@ -19344,9 +19390,9 @@ function takeLease(root, l) {
19344
19390
  } catch {
19345
19391
  return void 0;
19346
19392
  }
19347
- const taken = readJsonFile(to) ?? l;
19393
+ const taken2 = readJsonFile(to) ?? l;
19348
19394
  return {
19349
- lease: taken,
19395
+ lease: taken2,
19350
19396
  put(next) {
19351
19397
  writeLease(root, next);
19352
19398
  rmSync8(to, { force: true });
@@ -19359,11 +19405,11 @@ function takeLease(root, l) {
19359
19405
 
19360
19406
  // ../core/src/delivery/deliveryStore.ts
19361
19407
  import { readFileSync as readFileSync17 } from "node:fs";
19362
- import path30 from "node:path";
19363
- var FILE3 = path30.join(".agents", "delivery.json");
19408
+ import path31 from "node:path";
19409
+ var FILE3 = path31.join(".agents", "delivery.json");
19364
19410
  function readDeliveryProblems(root) {
19365
19411
  try {
19366
- const raw = JSON.parse(readFileSync17(path30.join(root, FILE3), "utf8"));
19412
+ const raw = JSON.parse(readFileSync17(path31.join(root, FILE3), "utf8"));
19367
19413
  return Object.values(raw.problems ?? {}).filter((p) => p && typeof p.channel === "string");
19368
19414
  } catch {
19369
19415
  return [];
@@ -19373,17 +19419,17 @@ function writeDeliveryProblem(root, channel, problem) {
19373
19419
  const problems = Object.fromEntries(readDeliveryProblems(root).map((p) => [p.channel, p]));
19374
19420
  if (problem) problems[channel] = problem;
19375
19421
  else delete problems[channel];
19376
- writeJsonAtomic(path30.join(root, FILE3), { v: 1, problems });
19422
+ writeJsonAtomic(path31.join(root, FILE3), { v: 1, problems });
19377
19423
  }
19378
19424
 
19379
19425
  // ../core/src/discovery/briefStore.ts
19380
- import { existsSync as existsSync10, mkdirSync as mkdirSync12, readdirSync as readdirSync9, readFileSync as readFileSync18, rmSync as rmSync9, writeFileSync as writeFileSync9 } from "node:fs";
19381
- 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";
19382
19428
  var safe5 = (s) => s.replace(/[^\w.-]/g, "_");
19383
- 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`);
19384
19430
  function readBriefFile(root, mapId) {
19385
19431
  const file9 = briefPath(root, mapId);
19386
- if (!existsSync10(file9)) return void 0;
19432
+ if (!existsSync11(file9)) return void 0;
19387
19433
  try {
19388
19434
  const text11 = readFileSync18(file9, "utf8");
19389
19435
  return { brief: parseBrief(mapId, text11), text: text11 };
@@ -19400,13 +19446,13 @@ function readBrief(root, mapId) {
19400
19446
  }
19401
19447
  function briefIds(root) {
19402
19448
  try {
19403
- 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));
19404
19450
  } catch {
19405
19451
  return [];
19406
19452
  }
19407
19453
  }
19408
19454
  function writeBrief(root, brief) {
19409
- mkdirSync12(path31.join(root, BRIEF_DIR), { recursive: true });
19455
+ mkdirSync12(path32.join(root, BRIEF_DIR), { recursive: true });
19410
19456
  writeFileSync9(briefPath(root, brief.mapId), serializeBrief(brief));
19411
19457
  }
19412
19458
  function approveBriefHere(root, mapId, by, text11) {
@@ -19415,7 +19461,7 @@ function approveBriefHere(root, mapId, by, text11) {
19415
19461
  }
19416
19462
  function writeBriefText(root, brief) {
19417
19463
  const text11 = serializeBrief(brief);
19418
- mkdirSync12(path31.join(root, BRIEF_DIR), { recursive: true });
19464
+ mkdirSync12(path32.join(root, BRIEF_DIR), { recursive: true });
19419
19465
  writeFileSync9(briefPath(root, brief.mapId), text11);
19420
19466
  return text11;
19421
19467
  }
@@ -19426,13 +19472,13 @@ function dropBrief(root, mapId) {
19426
19472
  }
19427
19473
 
19428
19474
  // ../core/src/evidence/syncStore.ts
19429
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync13, readdirSync as readdirSync10, rmSync as rmSync10 } from "node:fs";
19430
- 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";
19431
19477
  var SYNC_FILE = "sync.json";
19432
19478
  var STATUS_FILE = "sync-status.json";
19433
19479
  var safe6 = (s) => s.replace(/[^\w.-]/g, "_");
19434
- var ticketFile = (root, mapId, ticketId) => path32.join(root, evidencePaths.ticket(mapId, ticketId), SYNC_FILE);
19435
- 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));
19436
19482
  function readTicketSync(root, mapId, ticketId) {
19437
19483
  const s = readJsonFile(ticketFile(root, mapId, ticketId));
19438
19484
  return s?.v === 1 ? s : void 0;
@@ -19445,10 +19491,10 @@ function dropTicketSync(root, mapId, ticketId) {
19445
19491
  rmSync10(ticketFile(root, mapId, ticketId), { force: true });
19446
19492
  }
19447
19493
  function readTicketSyncs(root, mapId) {
19448
- const base2 = path32.join(root, EVIDENCE_DIR);
19494
+ const base2 = path33.join(root, EVIDENCE_DIR);
19449
19495
  const list8 = (dir4) => {
19450
19496
  try {
19451
- return readdirSync10(dir4, { withFileTypes: true }).filter((d) => d.isDirectory());
19497
+ return readdirSync11(dir4, { withFileTypes: true }).filter((d) => d.isDirectory());
19452
19498
  } catch {
19453
19499
  return [];
19454
19500
  }
@@ -19456,34 +19502,34 @@ function readTicketSyncs(root, mapId) {
19456
19502
  const maps = mapId === void 0 ? list8(base2).map((d) => d.name) : [safe6(mapId)];
19457
19503
  const out = [];
19458
19504
  for (const m of maps)
19459
- for (const t of list8(path32.join(base2, m))) {
19460
- 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));
19461
19507
  if (s?.v === 1) out.push(s);
19462
19508
  }
19463
19509
  return out;
19464
19510
  }
19465
- 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" };
19466
19512
  function writeSyncStatus(root, s) {
19467
19513
  ignored2(root, EVIDENCE_DIR);
19468
- writeJsonAtomic(path32.join(root, EVIDENCE_DIR, STATUS_FILE), s);
19514
+ writeJsonAtomic(path33.join(root, EVIDENCE_DIR, STATUS_FILE), s);
19469
19515
  }
19470
19516
  function appendFlagEntry(root, e) {
19471
19517
  ignored2(root, JOURNAL_DIR);
19472
- const dir4 = path32.join(root, JOURNAL_DIR, "flags");
19518
+ const dir4 = path33.join(root, JOURNAL_DIR, "flags");
19473
19519
  mkdirSync13(dir4, { recursive: true });
19474
- 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");
19475
19521
  }
19476
19522
 
19477
19523
  // ../core/src/knowledge/knowledgeStore.ts
19478
19524
  import { createHash as createHash5 } from "node:crypto";
19479
- import { existsSync as existsSync11, mkdirSync as mkdirSync14, readdirSync as readdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "node:fs";
19480
- import path33 from "node:path";
19481
- 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);
19482
19528
  function listKnowledgeFiles(root) {
19483
- if (!existsSync11(dir2(root))) return [];
19484
- 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) => {
19485
19531
  try {
19486
- 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"));
19487
19533
  } catch {
19488
19534
  return void 0;
19489
19535
  }
@@ -19516,7 +19562,7 @@ function writeKnowledge(root, e) {
19516
19562
  mkdirSync14(dir2(root), { recursive: true });
19517
19563
  const { approval, ...entry } = e;
19518
19564
  const kept = approval ? { ...entry, status: approval.claimed } : entry;
19519
- writeFileSync10(path33.join(dir2(root), `${e.id}.md`), serializeKnowledge(kept));
19565
+ writeFileSync10(path34.join(dir2(root), `${e.id}.md`), serializeKnowledge(kept));
19520
19566
  }
19521
19567
  function createKnowledge(root, draft) {
19522
19568
  mkdirSync14(dir2(root), { recursive: true });
@@ -19524,7 +19570,7 @@ function createKnowledge(root, draft) {
19524
19570
  for (let n = first; n < first + 50; n++) {
19525
19571
  const entry = { ...draft, id: `K-${n}` };
19526
19572
  try {
19527
- 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" });
19528
19574
  return entry;
19529
19575
  } catch (e) {
19530
19576
  if (e.code !== "EEXIST") throw e;
@@ -19537,21 +19583,21 @@ function nextKnowledgeId(root) {
19537
19583
  return `K-${n + 1}`;
19538
19584
  }
19539
19585
  function blobHash(repo, file9) {
19540
- const top = path33.resolve(repo);
19541
- const abs = path33.resolve(top, file9);
19542
- 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;
19543
19589
  const content = readFileSync19(abs);
19544
19590
  return createHash5("sha1").update(`blob ${content.length}\0`).update(content).digest("hex");
19545
19591
  }
19546
19592
  function repoRootFor(root) {
19547
- for (let d = path33.resolve(root); ; d = path33.dirname(d)) {
19548
- if (existsSync11(path33.join(d, ".git"))) return d;
19549
- 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));
19550
19596
  }
19551
19597
  }
19552
19598
 
19553
19599
  // ../core/src/mainChecks/readMainChecks.ts
19554
- import path48 from "node:path";
19600
+ import path49 from "node:path";
19555
19601
 
19556
19602
  // ../core/src/discovery/discoveryGate.ts
19557
19603
  var discoverySkipped = (root, mapId) => !!trustLedger(root).get(trustKey.discoverySkipped(mapId));
@@ -19597,16 +19643,16 @@ async function defaultHead(repoRoot) {
19597
19643
 
19598
19644
  // ../core/src/verification/checksApproval.ts
19599
19645
  import { readFileSync as readFileSync21 } from "node:fs";
19600
- import path35 from "node:path";
19646
+ import path36 from "node:path";
19601
19647
 
19602
19648
  // ../core/src/verification/configFile.ts
19603
19649
  import { createHash as createHash6 } from "node:crypto";
19604
19650
  import { readFileSync as readFileSync20 } from "node:fs";
19605
- import path34 from "node:path";
19651
+ import path35 from "node:path";
19606
19652
  var VERIFICATION_FILE = "verification.json";
19607
19653
  var configHash = (text11) => `sha256:${createHash6("sha256").update(text11).digest("hex")}`;
19608
19654
  function readVerificationConfig(root) {
19609
- const file9 = path34.join(root, VERIFICATION_FILE);
19655
+ const file9 = path35.join(root, VERIFICATION_FILE);
19610
19656
  let text11;
19611
19657
  try {
19612
19658
  text11 = readFileSync20(file9, "utf8");
@@ -19620,7 +19666,7 @@ function readVerificationConfig(root) {
19620
19666
  var NO_FILE = "none";
19621
19667
  function fileText2(root) {
19622
19668
  try {
19623
- return readFileSync21(path35.join(root, VERIFICATION_FILE), "utf8");
19669
+ return readFileSync21(path36.join(root, VERIFICATION_FILE), "utf8");
19624
19670
  } catch {
19625
19671
  return void 0;
19626
19672
  }
@@ -19638,7 +19684,7 @@ function checksApproval(root) {
19638
19684
  return { state, waiting: state !== "approved" && state !== "none", text: text11, hash: hash2, approved };
19639
19685
  }
19640
19686
  function parsed2(root, text11) {
19641
- const file9 = path35.join(root, VERIFICATION_FILE);
19687
+ const file9 = path36.join(root, VERIFICATION_FILE);
19642
19688
  if (!text11) return { path: file9, exists: false, errors: [] };
19643
19689
  return { path: file9, exists: true, ...parseVerificationConfig(text11), hash: contentHash(text11) };
19644
19690
  }
@@ -19711,7 +19757,7 @@ function updateMainChoices(root, mapId, change3) {
19711
19757
 
19712
19758
  // ../core/src/mainChecks/mainRunStore.ts
19713
19759
  import { closeSync as closeSync2, openSync as openSync2, rmSync as rmSync11, writeSync as writeSync2 } from "node:fs";
19714
- import path36 from "node:path";
19760
+ import path37 from "node:path";
19715
19761
  var MAIN_DIR = `${EVIDENCE_DIR}/_main`;
19716
19762
  var RUNNING2 = `${MAIN_DIR}/running.json`;
19717
19763
  var STUCK_MARGIN_MS = 5 * 6e4;
@@ -19721,7 +19767,7 @@ var mainPaths = {
19721
19767
  logs: (id) => `${MAIN_DIR}/runs/${safe7(id)}`
19722
19768
  };
19723
19769
  function readMainRun(root, id) {
19724
- const r = readJsonFile(path36.join(root, mainPaths.run(id)));
19770
+ const r = readJsonFile(path37.join(root, mainPaths.run(id)));
19725
19771
  return r?.v === 1 ? r : void 0;
19726
19772
  }
19727
19773
  function writeMainRun(root, run3) {
@@ -19729,7 +19775,7 @@ function writeMainRun(root, run3) {
19729
19775
  writeLocalJson(root, `${MAIN_DIR}/latest.json`, { id: run3.id });
19730
19776
  }
19731
19777
  function latestMainRun(root, budgetMs = 0) {
19732
- const id = readJsonFile(path36.join(root, MAIN_DIR, "latest.json"))?.id;
19778
+ const id = readJsonFile(path37.join(root, MAIN_DIR, "latest.json"))?.id;
19733
19779
  const run3 = typeof id === "string" ? readMainRun(root, id) : void 0;
19734
19780
  if (!run3 || run3.result !== "running") return run3;
19735
19781
  const alive4 = !!run3.pid && processAlive(run3.pid);
@@ -19737,9 +19783,9 @@ function latestMainRun(root, budgetMs = 0) {
19737
19783
  return alive4 && !stuck ? run3 : void 0;
19738
19784
  }
19739
19785
  function lockMainRun(root, id, budgetMs) {
19740
- ensureLocalDir(path36.join(root, EVIDENCE_DIR));
19741
- ensureLocalDir(path36.join(root, MAIN_DIR));
19742
- 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);
19743
19789
  for (let tries = 0; tries < 2; tries++) {
19744
19790
  try {
19745
19791
  const fd = openSync2(file9, "wx");
@@ -19758,7 +19804,7 @@ function lockMainRun(root, id, budgetMs) {
19758
19804
 
19759
19805
  // ../core/src/mainChecks/startMainRun.ts
19760
19806
  import { randomBytes as randomBytes4 } from "node:crypto";
19761
- import path47 from "node:path";
19807
+ import path48 from "node:path";
19762
19808
 
19763
19809
  // ../core/src/verification/redact.ts
19764
19810
  var SECRETS = [
@@ -19775,12 +19821,12 @@ function tailOf(text11, lines = 60, bytes2 = 4096) {
19775
19821
  }
19776
19822
 
19777
19823
  // ../core/src/mainChecks/runMainHere.ts
19778
- import path44 from "node:path";
19824
+ import path45 from "node:path";
19779
19825
 
19780
19826
  // ../core/src/verification/runCheck.ts
19781
19827
  import { spawn as spawn2 } from "node:child_process";
19782
19828
  import { mkdirSync as mkdirSync16, realpathSync as realpathSync4, writeFileSync as writeFileSync11 } from "node:fs";
19783
- import path37 from "node:path";
19829
+ import path38 from "node:path";
19784
19830
 
19785
19831
  // ../core/src/verification/checkEnv.ts
19786
19832
  var CHECK_ENV = `${BRAND.slug.toUpperCase()}_CHECK_ENV`;
@@ -19806,8 +19852,8 @@ var safe8 = (s) => s.replace(/[^\w.-]/g, "_");
19806
19852
  function confinedCwd(repoRoot, cwd = ".") {
19807
19853
  try {
19808
19854
  const root = realpathSync4(repoRoot);
19809
- const dir4 = realpathSync4(path37.resolve(root, cwd));
19810
- 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;
19811
19857
  } catch {
19812
19858
  return void 0;
19813
19859
  }
@@ -19888,14 +19934,14 @@ function runCheck(name2, spec, run3) {
19888
19934
  if (exit?.code !== 0) text11 += withheldNote(withheld);
19889
19935
  try {
19890
19936
  mkdirSync16(run3.logDir, { recursive: true });
19891
- writeFileSync11(path37.join(run3.logDir, `${safe8(name2)}.log`), redact(text11));
19937
+ writeFileSync11(path38.join(run3.logDir, `${safe8(name2)}.log`), redact(text11));
19892
19938
  } catch {
19893
19939
  }
19894
19940
  const note = timedOut ? `
19895
19941
  [timed out after ${Math.round(timeoutMs / 1e3)} s]` : "";
19896
19942
  resolve2({
19897
19943
  ...base2,
19898
- cwd: path37.relative(realpathSync4(run3.repoRoot), cwd) || ".",
19944
+ cwd: path38.relative(realpathSync4(run3.repoRoot), cwd) || ".",
19899
19945
  exitCode: exit?.code ?? null,
19900
19946
  ...exit?.signal ? { signal: exit.signal } : {},
19901
19947
  timedOut,
@@ -19948,12 +19994,12 @@ async function runChecks(config4, names, run3) {
19948
19994
 
19949
19995
  // ../core/src/mainChecks/mainCheckResult.ts
19950
19996
  import { readFileSync as readFileSync22 } from "node:fs";
19951
- import path38 from "node:path";
19997
+ import path39 from "node:path";
19952
19998
  var MAX_LOG = 1048576;
19953
19999
  function outputOf(root, c) {
19954
20000
  if (!c.log) return c.tail;
19955
20001
  try {
19956
- const text11 = readFileSync22(path38.join(root, c.log), "utf8");
20002
+ const text11 = readFileSync22(path39.join(root, c.log), "utf8");
19957
20003
  return text11.length > MAX_LOG ? text11.slice(-MAX_LOG) : text11;
19958
20004
  } catch {
19959
20005
  return c.tail;
@@ -19976,34 +20022,34 @@ function mainCheckResult(root, c, folders) {
19976
20022
  }
19977
20023
 
19978
20024
  // ../core/src/mainChecks/mainWorktree.ts
19979
- import { existsSync as existsSync16, lstatSync as lstatSync5, symlinkSync, unlinkSync } from "node:fs";
19980
- import path43 from "node:path";
20025
+ import { existsSync as existsSync17, lstatSync as lstatSync5, symlinkSync, unlinkSync } from "node:fs";
20026
+ import path44 from "node:path";
19981
20027
 
19982
20028
  // ../core/src/workspaces/trustedWorkspace.ts
19983
- 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";
19984
20030
 
19985
20031
  // ../core/src/workspaces/workspaceStore.ts
19986
- import { existsSync as existsSync12, mkdirSync as mkdirSync17, readdirSync as readdirSync12, readFileSync as readFileSync23, rmSync as rmSync12, writeFileSync as writeFileSync12 } from "node:fs";
19987
- 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";
19988
20034
  var safe9 = (s) => s.replace(/[^\w.-]/g, "_");
19989
- var recordsDir = (root) => path39.join(root, AGENTS_DIR, "workspaces");
19990
- 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`);
19991
20037
  function readWorkspaceSettings(root) {
19992
- const file9 = path39.join(root, WORKSPACES_FILE);
19993
- 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 };
19994
20040
  const parsed3 = parseWorkspaceSettings(readFileSync23(file9, "utf8"));
19995
20041
  return { settings: parsed3.settings ?? DEFAULT_WORKSPACE_SETTINGS, errors: parsed3.errors, exists: true };
19996
20042
  }
19997
20043
  function writeWorkspaceSettings(root, s) {
19998
20044
  mkdirSync17(root, { recursive: true });
19999
- writeFileSync12(path39.join(root, WORKSPACES_FILE), serializeWorkspaceSettings(s));
20045
+ writeFileSync12(path40.join(root, WORKSPACES_FILE), serializeWorkspaceSettings(s));
20000
20046
  }
20001
20047
  function readWorkspace(root, mapId, ticketId) {
20002
20048
  const r = readJsonFile(recordFile(root, mapId, ticketId));
20003
20049
  return r?.v === 1 ? r : void 0;
20004
20050
  }
20005
20051
  function writeWorkspace(root, r) {
20006
- ensureLocalDir(path39.join(root, AGENTS_DIR));
20052
+ ensureLocalDir(path40.join(root, AGENTS_DIR));
20007
20053
  writeJsonAtomic(recordFile(root, r.mapId, r.ticketId), r);
20008
20054
  }
20009
20055
  function dropWorkspace(root, mapId, ticketId) {
@@ -20012,11 +20058,11 @@ function dropWorkspace(root, mapId, ticketId) {
20012
20058
  function listWorkspaces(root) {
20013
20059
  let names = [];
20014
20060
  try {
20015
- names = readdirSync12(recordsDir(root)).filter((n) => n.endsWith(".json"));
20061
+ names = readdirSync13(recordsDir(root)).filter((n) => n.endsWith(".json"));
20016
20062
  } catch {
20017
20063
  return [];
20018
20064
  }
20019
- 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));
20020
20066
  }
20021
20067
 
20022
20068
  // ../core/src/workspaces/trustedWorkspace.ts
@@ -20053,7 +20099,7 @@ function preparedWorktree(root, mapId, ticketId) {
20053
20099
  }
20054
20100
  function trustedWorkspace(root, mapId, ticketId) {
20055
20101
  const ws = readWorkspace(root, mapId, ticketId);
20056
- if (!ws || !existsSync13(ws.path)) return void 0;
20102
+ if (!ws || !existsSync14(ws.path)) return void 0;
20057
20103
  let prepared;
20058
20104
  try {
20059
20105
  prepared = machineStore(root).read(FILE5)?.[keyOf4(mapId, ticketId)];
@@ -20064,12 +20110,12 @@ function trustedWorkspace(root, mapId, ticketId) {
20064
20110
  }
20065
20111
 
20066
20112
  // ../core/src/workspaces/worktreeDir.ts
20067
- import { existsSync as existsSync15, realpathSync as realpathSync7 } from "node:fs";
20068
- import path41 from "node:path";
20113
+ import { existsSync as existsSync16, realpathSync as realpathSync7 } from "node:fs";
20114
+ import path42 from "node:path";
20069
20115
 
20070
20116
  // ../core/src/workspaces/siblingProblem.ts
20071
- import { existsSync as existsSync14, readdirSync as readdirSync13, readFileSync as readFileSync24, realpathSync as realpathSync6, statSync as statSync8 } from "node:fs";
20072
- 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";
20073
20119
  var real2 = (p) => {
20074
20120
  try {
20075
20121
  return realpathSync6(p);
@@ -20078,62 +20124,62 @@ var real2 = (p) => {
20078
20124
  }
20079
20125
  };
20080
20126
  function commonGitDir(repo) {
20081
- const dotGit = path40.join(repo, ".git");
20082
- 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);
20083
20129
  const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
20084
- const abs = real2(path40.resolve(repo, pointed));
20085
- 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}`);
20086
20132
  return at2 === -1 ? abs : abs.slice(0, at2);
20087
20133
  }
20088
20134
  function ownWorktree(folder2, gitDir) {
20089
- const dotGit = path40.join(folder2, ".git");
20090
- if (!existsSync14(dotGit) || statSync8(dotGit).isDirectory()) return false;
20135
+ const dotGit = path41.join(folder2, ".git");
20136
+ if (!existsSync15(dotGit) || statSync8(dotGit).isDirectory()) return false;
20091
20137
  const pointed = /^gitdir:\s*(.+)$/m.exec(readFileSync24(dotGit, "utf8"))?.[1]?.trim() ?? "";
20092
- 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}`);
20093
20139
  }
20094
20140
  function siblingProblem(o) {
20095
20141
  if (o.target === o.parent) return "is the folder your projects live in";
20096
- for (let at2 = o.target; at2 !== o.parent && at2.startsWith(o.parent); at2 = path40.dirname(at2))
20097
- if (existsSync14(path40.join(at2, ".git")) && at2 !== o.target) return "is inside another git repository";
20098
- if (!existsSync14(o.target)) return void 0;
20099
- 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";
20100
20146
  const gitDir = commonGitDir(o.repo);
20101
- 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));
20102
20148
  return strangers.length ? "already holds files that aren't this repo's worktrees" : void 0;
20103
20149
  }
20104
20150
 
20105
20151
  // ../core/src/workspaces/worktreeDir.ts
20106
20152
  function realish(p) {
20107
- if (existsSync15(p)) return realpathSync7(p);
20108
- const parent = path41.dirname(p);
20109
- 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));
20110
20156
  }
20111
- var inside2 = (parent, p) => p === parent || p.startsWith(parent + path41.sep);
20157
+ var inside2 = (parent, p) => p === parent || p.startsWith(parent + path42.sep);
20112
20158
  function worktreeDir(top, dir4) {
20113
- 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`) };
20114
20160
  const refused2 = (why2) => ({
20115
20161
  refused: `workspaces.json "dir" (${dir4}) ${why2}. Worktrees go next to the repo: use a folder like "../worktrees".`
20116
20162
  });
20117
20163
  const problem = dirProblem(dir4);
20118
20164
  if (problem) return refused2(problem);
20119
20165
  const repo = realish(top);
20120
- const parent = path41.dirname(repo);
20121
- const target2 = realish(path41.resolve(repo, dir4));
20166
+ const parent = path42.dirname(repo);
20167
+ const target2 = realish(path42.resolve(repo, dir4));
20122
20168
  if (!inside2(parent, target2) || parent === repo) return refused2("is outside the repo's parent folder");
20123
20169
  if (target2 === repo) return refused2("is the repo itself");
20124
20170
  if (inside2(repo, target2)) {
20125
- const first = path41.relative(repo, target2).split(path41.sep)[0];
20171
+ const first = path42.relative(repo, target2).split(path42.sep)[0];
20126
20172
  return first === ".git" ? refused2("is inside the repo's .git folder") : { dir: target2 };
20127
20173
  }
20128
- 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("."));
20129
20175
  if (hidden) return refused2("is in a hidden folder");
20130
20176
  const sibling = siblingProblem({ repo, parent, target: target2 });
20131
20177
  return sibling ? refused2(sibling) : { dir: target2 };
20132
20178
  }
20133
20179
 
20134
20180
  // ../core/src/mainChecks/dependencyFolders.ts
20135
- import { lstatSync as lstatSync4, readdirSync as readdirSync14, realpathSync as realpathSync8 } from "node:fs";
20136
- 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";
20137
20183
  var DEPENDENCIES = /* @__PURE__ */ new Set(["node_modules", ".venv"]);
20138
20184
  var SKIP = /* @__PURE__ */ new Set([".git", ".teamtrail", "node_modules", ".venv", "dist", "build"]);
20139
20185
  var DEPTH = 4;
@@ -20141,15 +20187,15 @@ var MAX_FOLDERS = 20;
20141
20187
  var MAX_VISITS = 2e3;
20142
20188
  function entries(dir4) {
20143
20189
  try {
20144
- return readdirSync14(dir4).sort();
20190
+ return readdirSync15(dir4).sort();
20145
20191
  } catch {
20146
20192
  return [];
20147
20193
  }
20148
20194
  }
20149
20195
  function insideRepo2(top, realTop, rel) {
20150
20196
  try {
20151
- const real7 = realpathSync8(path42.join(top, rel));
20152
- return real7.startsWith(realTop + path42.sep);
20197
+ const real7 = realpathSync8(path43.join(top, rel));
20198
+ return real7.startsWith(realTop + path43.sep);
20153
20199
  } catch {
20154
20200
  return false;
20155
20201
  }
@@ -20168,12 +20214,12 @@ function dependencyFolders(top) {
20168
20214
  const queue = [{ rel: "", depth: 0 }];
20169
20215
  for (let visits = 0; queue.length && visits < MAX_VISITS && found.length < MAX_FOLDERS; visits++) {
20170
20216
  const { rel, depth } = queue.shift();
20171
- const names = entries(path42.join(top, rel));
20172
- 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));
20173
20219
  found.push(...deps.filter((d) => insideRepo2(top, realTop, d)));
20174
20220
  if (depth >= DEPTH) continue;
20175
- const folders = names.filter((n) => !SKIP.has(n) && !n.startsWith(".") && isFolder(path42.join(top, rel, n)));
20176
- 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 })));
20177
20223
  }
20178
20224
  return found.slice(0, MAX_FOLDERS);
20179
20225
  }
@@ -20183,10 +20229,10 @@ var MAIN_WORKTREE_KEY = "_main";
20183
20229
  function linkDependencies(top, wt) {
20184
20230
  const links = [];
20185
20231
  for (const rel of dependencyFolders(top)) {
20186
- const at2 = path43.join(wt, rel);
20187
- 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;
20188
20234
  try {
20189
- symlinkSync(path43.join(top, rel), at2, "dir");
20235
+ symlinkSync(path44.join(top, rel), at2, "dir");
20190
20236
  links.push(at2);
20191
20237
  } catch {
20192
20238
  }
@@ -20196,8 +20242,8 @@ function linkDependencies(top, wt) {
20196
20242
  async function prepareMainWorktree(o) {
20197
20243
  const where2 = worktreeDir(o.top, readWorkspaceSettings(o.root).settings.dir);
20198
20244
  if ("refused" in where2) return { note: where2.refused };
20199
- const dir4 = path43.join(where2.dir, `_main-${o.commit.slice(0, 12)}-${o.id.slice(-6)}`);
20200
- 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` };
20201
20247
  const r = await git(o.top, ["worktree", "add", "--detach", "--end-of-options", dir4, o.commit]);
20202
20248
  if (r.code !== 0) return { note: r.stderr.trim().split("\n")[0] || "git worktree add failed" };
20203
20249
  recordWorktree(o.root, { mapId: MAIN_WORKTREE_KEY, ticketId: o.id, path: dir4 });
@@ -20215,7 +20261,7 @@ async function sweepMainWorktrees(o) {
20215
20261
  const prefix = `${MAIN_WORKTREE_KEY}--`;
20216
20262
  for (const key of Object.keys(known4).filter((k) => k.startsWith(prefix))) {
20217
20263
  const dir4 = known4[key];
20218
- 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());
20219
20265
  await removeMainWorktree({ ...o, id: key.slice(prefix.length), links });
20220
20266
  }
20221
20267
  }
@@ -20239,7 +20285,7 @@ async function runMainHere(o) {
20239
20285
  const rel = o.logRel ?? mainPaths.logs(o.id);
20240
20286
  const out = await runChecks(o.config, o.names, {
20241
20287
  repoRoot: wt.path,
20242
- logDir: path44.join(o.root, rel),
20288
+ logDir: path45.join(o.root, rel),
20243
20289
  logRel: rel,
20244
20290
  signal: o.signal
20245
20291
  });
@@ -20257,11 +20303,11 @@ async function runMainHere(o) {
20257
20303
  }
20258
20304
 
20259
20305
  // ../core/src/mainChecks/runMainOnRunner.ts
20260
- import path46 from "node:path";
20306
+ import path47 from "node:path";
20261
20307
 
20262
20308
  // ../core/src/verification/runnerReport.ts
20263
20309
  import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync13 } from "node:fs";
20264
- import path45 from "node:path";
20310
+ import path46 from "node:path";
20265
20311
 
20266
20312
  // ../core/src/evidence/noChangesFlag.ts
20267
20313
  var NO_CHANGES_EFFECT = { fail: "; completing needs a change", human: "; a human decides" };
@@ -20364,7 +20410,7 @@ function resultOf(asked, got, log) {
20364
20410
  const output2 = redact(raw.slice(-MAX_OUTPUT));
20365
20411
  const file9 = `${safe10(asked.name)}.log`;
20366
20412
  mkdirSync19(log.dir, { recursive: true });
20367
- writeFileSync13(path45.join(log.dir, file9), output2);
20413
+ writeFileSync13(path46.join(log.dir, file9), output2);
20368
20414
  const error63 = text(got.error, 300);
20369
20415
  return {
20370
20416
  name: asked.name,
@@ -20435,7 +20481,7 @@ async function runMainOnRunner(o) {
20435
20481
  runner,
20436
20482
  report: report3,
20437
20483
  asked,
20438
- log: { dir: path46.join(o.root, rel), rel },
20484
+ log: { dir: path47.join(o.root, rel), rel },
20439
20485
  config: o.config,
20440
20486
  ticketType: "research"
20441
20487
  });
@@ -20455,7 +20501,7 @@ async function runMainOnRunner(o) {
20455
20501
  // ../core/src/mainChecks/startMainRun.ts
20456
20502
  var newId = () => `M-${Date.now().toString(36)}-${randomBytes4(3).toString("hex")}`;
20457
20503
  function outcome(env, o) {
20458
- const repoRoot = env.repoRoot ?? path47.dirname(env.root);
20504
+ const repoRoot = env.repoRoot ?? path48.dirname(env.root);
20459
20505
  const job = { root: env.root, repoRoot, id: o.id, config: o.plan.config, names: o.plan.names, signal: env.signal };
20460
20506
  return env.checkRunner ? runMainOnRunner({ ...job, runner: env.checkRunner }) : runMainHere(job);
20461
20507
  }
@@ -20503,9 +20549,9 @@ function startMainRun(env, by) {
20503
20549
 
20504
20550
  // ../core/src/mainChecks/readMainChecks.ts
20505
20551
  var SEEN = `${MAIN_DIR}/trails.json`;
20506
- var seenRun = (root, mapId) => readJsonFile(path48.join(root, SEEN))?.[mapId];
20552
+ var seenRun = (root, mapId) => readJsonFile(path49.join(root, SEEN))?.[mapId];
20507
20553
  function markSeen(root, mapId, runId) {
20508
- const all = readJsonFile(path48.join(root, SEEN)) ?? {};
20554
+ const all = readJsonFile(path49.join(root, SEEN)) ?? {};
20509
20555
  if (all[mapId] !== runId) writeLocalJson(root, SEEN, { ...all, [mapId]: runId });
20510
20556
  }
20511
20557
  async function due(env, o) {
@@ -20513,7 +20559,7 @@ async function due(env, o) {
20513
20559
  if (!run3 || run3.configHash !== o.hash) return true;
20514
20560
  if (run3.result === "running" || seenRun(env.root, o.mapId)) return false;
20515
20561
  if (env.checkRunner) return false;
20516
- const head = await defaultHead(env.repoRoot ?? path48.dirname(env.root));
20562
+ const head = await defaultHead(env.repoRoot ?? path49.dirname(env.root));
20517
20563
  return "commit" in head && !!run3.commit && head.commit !== run3.commit;
20518
20564
  }
20519
20565
  async function triggered(env, o) {
@@ -20737,7 +20783,7 @@ function pendingTrackerMessage(t) {
20737
20783
  }
20738
20784
 
20739
20785
  // ../core/src/trailChecks/readTrailChecks.ts
20740
- import path51 from "node:path";
20786
+ import path52 from "node:path";
20741
20787
 
20742
20788
  // ../core/src/trailChecks/readTrailMerges.ts
20743
20789
  function readTrailMerges(root, snap) {
@@ -20752,7 +20798,7 @@ function readTrailMerges(root, snap) {
20752
20798
  import { randomBytes as randomBytes5 } from "node:crypto";
20753
20799
 
20754
20800
  // ../core/src/trailChecks/runTrailChecks.ts
20755
- import path50 from "node:path";
20801
+ import path51 from "node:path";
20756
20802
 
20757
20803
  // ../core/src/trailChecks/trailHead.ts
20758
20804
  async function contains(top, head, ancestor) {
@@ -20783,7 +20829,7 @@ async function trailHead(repoRoot, commits) {
20783
20829
  }
20784
20830
 
20785
20831
  // ../core/src/trailChecks/trailRunStore.ts
20786
- import path49 from "node:path";
20832
+ import path50 from "node:path";
20787
20833
  var TRAIL_DIR = "_trail";
20788
20834
  var safe11 = (s) => s.replace(/[^\w.-]/g, "_");
20789
20835
  var STUCK_MARGIN_MS2 = 5 * 6e4;
@@ -20794,7 +20840,7 @@ var trailPaths = {
20794
20840
  latest: (mapId) => `${dir3(mapId)}/latest.json`
20795
20841
  };
20796
20842
  function readTrailRun(root, mapId, id) {
20797
- const r = readJsonFile(path49.join(root, trailPaths.run(mapId, id)));
20843
+ const r = readJsonFile(path50.join(root, trailPaths.run(mapId, id)));
20798
20844
  return r?.v === 1 && r.mapId === mapId ? r : void 0;
20799
20845
  }
20800
20846
  function writeTrailRun(root, run3) {
@@ -20802,7 +20848,7 @@ function writeTrailRun(root, run3) {
20802
20848
  writeLocalJson(root, trailPaths.latest(run3.mapId), { id: run3.id });
20803
20849
  }
20804
20850
  function latestTrailRun(root, mapId, budgetMs = 0) {
20805
- const id = readJsonFile(path49.join(root, trailPaths.latest(mapId)))?.id;
20851
+ const id = readJsonFile(path50.join(root, trailPaths.latest(mapId)))?.id;
20806
20852
  const run3 = typeof id === "string" ? readTrailRun(root, mapId, id) : void 0;
20807
20853
  if (!run3 || run3.result !== "running") return run3;
20808
20854
  const alive4 = !!run3.pid && processAlive(run3.pid);
@@ -20816,7 +20862,7 @@ function latestTrailRun(root, mapId, budgetMs = 0) {
20816
20862
  var commitsOf = (merges) => merges.flatMap((m) => m.state === "merged" && m.commit ? [m.commit] : []);
20817
20863
  var marked = (merges, has2) => merges.map((m) => m.state === "merged" && m.commit ? { ...m, contained: has2(m.commit) } : m);
20818
20864
  async function here(env, o) {
20819
- const repoRoot = env.repoRoot ?? path50.dirname(env.root);
20865
+ const repoRoot = env.repoRoot ?? path51.dirname(env.root);
20820
20866
  const head = await trailHead(repoRoot, commitsOf(o.merges));
20821
20867
  if ("note" in head) {
20822
20868
  const none = { commit: null, branch: null, checks: [], result: "unavailable", note: head.note };
@@ -20832,7 +20878,7 @@ async function namedHead(repoRoot, commits) {
20832
20878
  return head;
20833
20879
  }
20834
20880
  async function onRunner(env, o) {
20835
- const repoRoot = env.repoRoot ?? path50.dirname(env.root);
20881
+ const repoRoot = env.repoRoot ?? path51.dirname(env.root);
20836
20882
  const known4 = await namedHead(repoRoot, commitsOf(o.merges));
20837
20883
  const found = await runMainOnRunner({
20838
20884
  root: env.root,
@@ -20939,7 +20985,7 @@ async function withReverts(root, snap, merges) {
20939
20985
  async function marked2(env, merges) {
20940
20986
  const commits = merges.flatMap((m) => m.state === "merged" && m.commit ? [m.commit] : []);
20941
20987
  if (env.checkRunner || !commits.length) return merges;
20942
- const head = await trailHead(env.repoRoot ?? path51.dirname(env.root), commits);
20988
+ const head = await trailHead(env.repoRoot ?? path52.dirname(env.root), commits);
20943
20989
  const has2 = (c) => !("note" in head) && head.contained.has(c);
20944
20990
  return merges.map((m) => m.state === "merged" && m.commit ? { ...m, contained: has2(m.commit) } : m);
20945
20991
  }
@@ -20964,28 +21010,28 @@ async function readTrailChecks(env, snap, o = {}) {
20964
21010
  }
20965
21011
 
20966
21012
  // ../core/src/signedState/outsideChanges.ts
20967
- import { readdirSync as readdirSync15 } from "node:fs";
20968
- import path52 from "node:path";
21013
+ import { readdirSync as readdirSync16 } from "node:fs";
21014
+ import path53 from "node:path";
20969
21015
  function listDir(dir4) {
20970
21016
  try {
20971
- return readdirSync15(dir4);
21017
+ return readdirSync16(dir4);
20972
21018
  } catch {
20973
21019
  return [];
20974
21020
  }
20975
21021
  }
20976
21022
  function trailFiles(root) {
20977
- 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")));
20978
21024
  return trails.flatMap((mapId) => [
20979
21025
  `${mapId}/map.md`,
20980
- ...listDir(path52.join(root, mapId, "tickets")).map((f) => `${mapId}/tickets/${f}`),
20981
- ...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}`)
20982
21028
  ]);
20983
21029
  }
20984
21030
  function judgeFile(root, item2, strict, out) {
20985
21031
  const record3 = readStateRecord(root, item2.mapId);
20986
21032
  const entry = record3.entries[item2.key];
20987
21033
  const unreadable2 = record3.problem ? { unreadable: true } : {};
20988
- const text11 = cachedText(path52.join(root, item2.rel));
21034
+ const text11 = cachedText(path53.join(root, item2.rel));
20989
21035
  if (isOversized(text11)) {
20990
21036
  out.changes.push({ ...item2, fields: ["oversized"], counts: entry?.f, signed: !!entry, ...unreadable2 });
20991
21037
  return;
@@ -21282,8 +21328,8 @@ function checksDiff(approved, current) {
21282
21328
  }
21283
21329
 
21284
21330
  // ../core/src/verification/approvedLevel.ts
21285
- import { existsSync as existsSync17 } from "node:fs";
21286
- import path53 from "node:path";
21331
+ import { existsSync as existsSync18 } from "node:fs";
21332
+ import path54 from "node:path";
21287
21333
  var rank4 = (l) => VERIFICATION_LEVELS.indexOf(l);
21288
21334
  var recorded = (ledger, key) => levelOf(ledger[key]?.content);
21289
21335
  var recordedType = (ledger, mapId, t) => ledger[trustKey.type(mapId, t.id)]?.content ?? t.type;
@@ -21317,7 +21363,7 @@ function recordLevel(root, at2, level) {
21317
21363
  }
21318
21364
  function levelFile(root, mapId, ticketId) {
21319
21365
  const rel = ticketId ? `${mapId}/tickets/${ticketId}.md` : `${mapId}/map.md`;
21320
- return existsSync17(path53.join(root, rel)) ? rel : void 0;
21366
+ return existsSync18(path54.join(root, rel)) ? rel : void 0;
21321
21367
  }
21322
21368
 
21323
21369
  // ../core/src/verification/levelItems.ts
@@ -21408,8 +21454,8 @@ function catalogsItem(root) {
21408
21454
  }
21409
21455
 
21410
21456
  // ../core/src/trust/discoveryItems.ts
21411
- import { existsSync as existsSync18 } from "node:fs";
21412
- import path54 from "node:path";
21457
+ import { existsSync as existsSync19 } from "node:fs";
21458
+ import path55 from "node:path";
21413
21459
  function discoveryItems(root, ledger, snaps) {
21414
21460
  return snaps.flatMap((s) => {
21415
21461
  const mapId = s.map.id;
@@ -21429,7 +21475,7 @@ function discoveryItems(root, ledger, snaps) {
21429
21475
  lines: [line5],
21430
21476
  warnings: [],
21431
21477
  mapId,
21432
- ...existsSync18(path54.join(root, map2)) ? { file: map2 } : {},
21478
+ ...existsSync19(path55.join(root, map2)) ? { file: map2 } : {},
21433
21479
  // never adopted with others: an agent can commit a trail folder without a brief, or a brief's removal
21434
21480
  alone: true
21435
21481
  }
@@ -21438,13 +21484,13 @@ function discoveryItems(root, ledger, snaps) {
21438
21484
  }
21439
21485
 
21440
21486
  // ../core/src/criteria/criteriaStore.ts
21441
- import { existsSync as existsSync19, mkdirSync as mkdirSync20, readdirSync as readdirSync16, readFileSync as readFileSync25, writeFileSync as writeFileSync14 } from "node:fs";
21442
- 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";
21443
21489
  var safe12 = (s) => s.replace(/[^\w.-]/g, "_");
21444
- 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`);
21445
21491
  function readCriteriaFile(root, mapId) {
21446
21492
  const f = file2(root, mapId);
21447
- if (!existsSync19(f)) return [];
21493
+ if (!existsSync20(f)) return [];
21448
21494
  try {
21449
21495
  return parseCriteria(readFileSync25(f, "utf8"));
21450
21496
  } catch {
@@ -21469,7 +21515,7 @@ function readCriteria(root, mapId) {
21469
21515
  }
21470
21516
  function criteriaIds(root) {
21471
21517
  try {
21472
- 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));
21473
21519
  } catch {
21474
21520
  return [];
21475
21521
  }
@@ -21490,7 +21536,7 @@ function writeTicketCriteria(root, map2, ticket2, patch) {
21490
21536
  criteria: prev?.criteria ?? [],
21491
21537
  confirmed: patch.confirmed || void 0
21492
21538
  };
21493
- mkdirSync20(path55.join(root, CRITERIA_DIR), { recursive: true });
21539
+ mkdirSync20(path56.join(root, CRITERIA_DIR), { recursive: true });
21494
21540
  writeFileSync14(file2(root, map2.id), serializeCriteria(map2.title, [...all, next]));
21495
21541
  return next;
21496
21542
  }
@@ -21586,7 +21632,7 @@ function pendingTrust(root, snaps = []) {
21586
21632
  }
21587
21633
 
21588
21634
  // ../core/src/verification/verifyCompletion.ts
21589
- import path66 from "node:path";
21635
+ import path67 from "node:path";
21590
21636
 
21591
21637
  // ../core/src/verification/recordGate.ts
21592
21638
  function recordGate(o) {
@@ -21628,11 +21674,11 @@ function applyGuard(graded, o) {
21628
21674
 
21629
21675
  // ../core/src/checkGuard/localGuard.ts
21630
21676
  import { realpathSync as realpathSync9 } from "node:fs";
21631
- import path57 from "node:path";
21677
+ import path58 from "node:path";
21632
21678
 
21633
21679
  // ../core/src/checkGuard/gitReaders.ts
21634
21680
  import { lstat } from "node:fs/promises";
21635
- import path56 from "node:path";
21681
+ import path57 from "node:path";
21636
21682
  var MAX_BYTES = 1024 * 1024;
21637
21683
  var unread = async () => void 0;
21638
21684
  async function commitReader(cwd, commit) {
@@ -21657,7 +21703,7 @@ function worktreeReader(toplevel) {
21657
21703
  if (text11 !== void 0) return text11;
21658
21704
  const clean2 = repoPath2(rel);
21659
21705
  if (!clean2) return void 0;
21660
- const there = await lstat(path56.join(toplevel, clean2)).catch(() => void 0);
21706
+ const there = await lstat(path57.join(toplevel, clean2)).catch(() => void 0);
21661
21707
  return there ? void 0 : null;
21662
21708
  };
21663
21709
  }
@@ -22273,8 +22319,8 @@ var real3 = (p) => {
22273
22319
  }
22274
22320
  };
22275
22321
  function prefixOf(toplevel, checkout) {
22276
- const rel = path57.relative(real3(toplevel), real3(checkout)).split(path57.sep).join("/");
22277
- 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;
22278
22324
  }
22279
22325
  function noBaseline(config4) {
22280
22326
  const mode = gateModeFor(config4, "check-guard");
@@ -22305,15 +22351,15 @@ async function withLocalGuard(graded, o) {
22305
22351
  }
22306
22352
 
22307
22353
  // ../core/src/evidence/collectEvidence.ts
22308
- import { existsSync as existsSync21 } from "node:fs";
22354
+ import { existsSync as existsSync22 } from "node:fs";
22309
22355
 
22310
22356
  // ../core/src/evidence/baselineStore.ts
22311
- import { linkSync as linkSync4, mkdirSync as mkdirSync21, readdirSync as readdirSync17, rmSync as rmSync13, writeFileSync as writeFileSync15 } from "node:fs";
22312
- import path58 from "node:path";
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";
22313
22359
  var DIR = "baselines";
22314
22360
  var RE = /^baseline-(\d+)\.json$/;
22315
22361
  var safe13 = (s) => s.replace(/[^\w-]/g, "_");
22316
- 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)}`);
22317
22363
  var macParts = (root, b) => [
22318
22364
  "baseline",
22319
22365
  machineId(root),
@@ -22323,7 +22369,7 @@ var macParts = (root, b) => [
22323
22369
  ];
22324
22370
  function numbers(dir4) {
22325
22371
  try {
22326
- 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);
22327
22373
  } catch {
22328
22374
  return [];
22329
22375
  }
@@ -22352,7 +22398,7 @@ var baselineStore = {
22352
22398
  latest(root, mapId, ticketId) {
22353
22399
  const dir4 = folder(root, mapId, ticketId);
22354
22400
  const n = numbers(dir4).at(-1);
22355
- 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;
22356
22402
  },
22357
22403
  /** Records a new baseline under the next number, signed; returns it with its id. Throws when it can't be kept. */
22358
22404
  add(root, rec) {
@@ -22363,7 +22409,7 @@ var baselineStore = {
22363
22409
  const baseline = { ...rec, id };
22364
22410
  const signed3 = { v: 1, baseline, mac: machineSign(macParts(root, baseline)) };
22365
22411
  try {
22366
- createWhole(path58.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
22412
+ createWhole(path59.join(dir4, `${id}.json`), `${JSON.stringify(signed3, null, 2)}
22367
22413
  `);
22368
22414
  return baseline;
22369
22415
  } catch (e) {
@@ -22375,26 +22421,26 @@ var baselineStore = {
22375
22421
 
22376
22422
  // ../core/src/evidence/treeState.ts
22377
22423
  import { createHash as createHash7 } from "node:crypto";
22378
- import { existsSync as existsSync20, realpathSync as realpathSync10 } from "node:fs";
22379
- import path59 from "node:path";
22380
- 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("/");
22381
22427
  async function findWorktree(cwd, trackerRoot) {
22382
- if (!existsSync20(cwd)) return { error: `${cwd} does not exist` };
22428
+ if (!existsSync21(cwd)) return { error: `${cwd} does not exist` };
22383
22429
  const r = await git(cwd, ["rev-parse", "--show-toplevel"]);
22384
22430
  if (r.code === null) return { error: `git is not available (${r.stderr.trim()})` };
22385
22431
  if (r.code !== 0) return { error: `${cwd} is not inside a git repository` };
22386
22432
  const toplevel = realpathSync10(r.stdout.toString("utf8").trim());
22387
22433
  const pathspec = ["--", "."];
22388
- if (trackerRoot && existsSync20(trackerRoot)) {
22389
- const rel = path59.relative(toplevel, realpathSync10(trackerRoot));
22390
- 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)}`);
22391
22437
  }
22392
22438
  return { toplevel, pathspec };
22393
22439
  }
22394
22440
  var emptyTree = (wt) => gitText(wt.toplevel, ["hash-object", "-t", "tree", "--stdin"], "").then((s) => s ?? "");
22395
22441
  async function hashFiles(wt, files) {
22396
22442
  const out = {};
22397
- const present = files.filter((f) => existsSync20(path59.join(wt.toplevel, f)));
22443
+ const present = files.filter((f) => existsSync21(path60.join(wt.toplevel, f)));
22398
22444
  for (const f of files) out[f] = null;
22399
22445
  if (!present.length) return out;
22400
22446
  const r = await git(wt.toplevel, ["hash-object", "--stdin-paths"], present.join("\n") + "\n");
@@ -22454,7 +22500,7 @@ async function baselineForClaim(c) {
22454
22500
 
22455
22501
  // ../core/src/evidence/changes.ts
22456
22502
  import { readFileSync as readFileSync26 } from "node:fs";
22457
- import path60 from "node:path";
22503
+ import path61 from "node:path";
22458
22504
  function numstat(out) {
22459
22505
  const rows = /* @__PURE__ */ new Map();
22460
22506
  for (const line5 of out.toString("utf8").split("\0")) {
@@ -22465,7 +22511,7 @@ function numstat(out) {
22465
22511
  }
22466
22512
  function lineCount(wt, f) {
22467
22513
  try {
22468
- const b = readFileSync26(path60.join(wt.toplevel, f));
22514
+ const b = readFileSync26(path61.join(wt.toplevel, f));
22469
22515
  if (b.includes(0)) return null;
22470
22516
  const text11 = b.toString("utf8");
22471
22517
  return text11 ? text11.split("\n").length - (text11.endsWith("\n") ? 1 : 0) : 0;
@@ -22605,7 +22651,7 @@ async function otherWork(root, snap, self) {
22605
22651
  async function collectEvidence(r) {
22606
22652
  const base2 = latestBaseline(r.root, r.snap.map.id, r.ticket.id);
22607
22653
  const b = base2?.git ?? void 0;
22608
- const dir4 = b && existsSync21(b.toplevel) ? b.toplevel : r.cwd;
22654
+ const dir4 = b && existsSync22(b.toplevel) ? b.toplevel : r.cwd;
22609
22655
  const found = await findWorktree(dir4, r.root);
22610
22656
  const wt = "error" in found ? void 0 : found;
22611
22657
  const now2 = wt && await readTreeState(wt);
@@ -22648,14 +22694,14 @@ var treeOf = (now2) => ({
22648
22694
  });
22649
22695
 
22650
22696
  // ../core/src/evidence/stale.ts
22651
- import { existsSync as existsSync22 } from "node:fs";
22652
- import path61 from "node:path";
22697
+ import { existsSync as existsSync23 } from "node:fs";
22698
+ import path62 from "node:path";
22653
22699
  var short3 = (sha2) => sha2?.slice(0, 8) ?? "none";
22654
22700
  async function staleness(root, ev) {
22655
22701
  const hash2 = trustedChecks(root).config.hash;
22656
22702
  if (ev && (ev.configHash ?? null) !== (hash2 ?? null))
22657
22703
  return { checked: true, stale: true, reason: "verification.json changed since the checks ran" };
22658
- 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))
22659
22705
  return { checked: false, stale: false };
22660
22706
  const wt = await findWorktree(ev.tree.toplevel, root);
22661
22707
  if ("error" in wt) return { checked: false, stale: false, reason: wt.error };
@@ -22800,13 +22846,13 @@ function attemptBase(o) {
22800
22846
  }
22801
22847
 
22802
22848
  // ../core/src/verification/checkoutFor.ts
22803
- import { existsSync as existsSync23 } from "node:fs";
22804
- import path62 from "node:path";
22849
+ import { existsSync as existsSync24 } from "node:fs";
22850
+ import path63 from "node:path";
22805
22851
  function checkoutFor(env, mapId, ticketId) {
22806
- const repo = env.repoRoot ?? path62.dirname(env.root);
22852
+ const repo = env.repoRoot ?? path63.dirname(env.root);
22807
22853
  if (env.repoRoot) return { kind: "here", path: repo };
22808
22854
  const prepared = preparedWorktree(env.root, mapId, ticketId);
22809
- if (prepared && existsSync23(prepared)) return { kind: "here", path: prepared };
22855
+ if (prepared && existsSync24(prepared)) return { kind: "here", path: prepared };
22810
22856
  const record3 = readWorkspace(env.root, mapId, ticketId);
22811
22857
  if (!prepared && !record3) return { kind: "here", path: repo };
22812
22858
  const where2 = prepared ?? record3?.path;
@@ -22817,7 +22863,7 @@ function checkoutFor(env, mapId, ticketId) {
22817
22863
  }
22818
22864
 
22819
22865
  // ../core/src/verification/gradeAttempt.ts
22820
- import path63 from "node:path";
22866
+ import path64 from "node:path";
22821
22867
 
22822
22868
  // ../core/src/verification/gradeCriteria.ts
22823
22869
  function gradeCriteria(at2, checks, known4 = []) {
@@ -22852,11 +22898,11 @@ async function checksOrError(i) {
22852
22898
  return { checks: [], result: "error", note };
22853
22899
  }
22854
22900
  const rel = evidencePaths.logs(i.mapId, i.ticketId, i.attemptId);
22855
- ensureLocalDir(path63.join(i.root, EVIDENCE_DIR));
22901
+ ensureLocalDir(path64.join(i.root, EVIDENCE_DIR));
22856
22902
  const failFast = config4.config.failFast && !i.known?.length;
22857
22903
  return runChecks({ ...config4.config, failFast }, i.info.checks, {
22858
22904
  repoRoot: i.repoRoot,
22859
- logDir: path63.join(i.root, rel),
22905
+ logDir: path64.join(i.root, rel),
22860
22906
  logRel: rel,
22861
22907
  signal: i.signal
22862
22908
  });
@@ -23043,20 +23089,20 @@ ${note}` : reviewBody(t, a)
23043
23089
  }
23044
23090
 
23045
23091
  // ../core/src/verification/runLock.ts
23046
- import { mkdirSync as mkdirSync22, readdirSync as readdirSync18, renameSync as renameSync9, rmSync as rmSync14, writeFileSync as writeFileSync16 } from "node:fs";
23047
- 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";
23048
23094
  var RUNS_DIR = `${AGENTS_DIR}/runs`;
23049
23095
  var safe14 = (s) => s.replace(/[^\w.-]/g, "_");
23050
- 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`);
23051
23097
  var readRunLock = (root, mapId, ticketId) => readJsonFile(lockFile(root, mapId, ticketId));
23052
23098
  function readRunLocks(root) {
23053
23099
  let names = [];
23054
23100
  try {
23055
- 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"));
23056
23102
  } catch {
23057
23103
  return [];
23058
23104
  }
23059
- 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);
23060
23106
  }
23061
23107
  function recover(root, lock, now2) {
23062
23108
  const file9 = lockFile(root, lock.mapId, lock.ticketId);
@@ -23096,8 +23142,8 @@ function acquireRunLock(root, lock, now2 = Date.now()) {
23096
23142
  const file9 = lockFile(root, lock.mapId, lock.ticketId);
23097
23143
  const mine2 = { ...lock, pid: process.pid, startedAt: now2 };
23098
23144
  let recovered;
23099
- ensureLocalDir(path64.join(root, AGENTS_DIR));
23100
- mkdirSync22(path64.dirname(file9), { recursive: true });
23145
+ ensureLocalDir(path65.join(root, AGENTS_DIR));
23146
+ mkdirSync22(path65.dirname(file9), { recursive: true });
23101
23147
  for (let i = 0; i < 3; i++) {
23102
23148
  try {
23103
23149
  writeFileSync16(file9, JSON.stringify(mine2, null, 2), { flag: "wx" });
@@ -23121,7 +23167,7 @@ function releaseRunLock(root, mapId, ticketId, pid = process.pid) {
23121
23167
  var recoverInterrupted = (root, now2 = Date.now()) => readRunLocks(root).filter((l) => !processAlive(l.pid)).map((l) => recover(root, l, now2)).filter((a) => !!a);
23122
23168
 
23123
23169
  // ../core/src/verification/runnerGraded.ts
23124
- import path65 from "node:path";
23170
+ import path66 from "node:path";
23125
23171
 
23126
23172
  // ../core/src/checkGuard/runnerGuard.ts
23127
23173
  var MAX_CHARS = 1024 * 1024;
@@ -23206,12 +23252,12 @@ async function runnerGraded(env, job, run3) {
23206
23252
  const report3 = await ask2(env.checkRunner, runJob, config4.totalTimeoutSec * 1e3 + RUNNER_MARGIN_MS2);
23207
23253
  if (typeof report3 === "string") return { checks: [], result: "error", note: report3 };
23208
23254
  const rel = evidencePaths.logs(job.mapId, job.ticket.id, run3.id);
23209
- ensureLocalDir(path65.join(env.root, EVIDENCE_DIR));
23255
+ ensureLocalDir(path66.join(env.root, EVIDENCE_DIR));
23210
23256
  const read4 = readRunnerReport({
23211
23257
  runner: env.checkRunner.name,
23212
23258
  report: report3,
23213
23259
  asked,
23214
- log: { dir: path65.join(env.root, rel), rel },
23260
+ log: { dir: path66.join(env.root, rel), rel },
23215
23261
  config: config4,
23216
23262
  configHash: run3.config.hash,
23217
23263
  ticketType: job.ticket.type,
@@ -23235,7 +23281,7 @@ async function runnerGraded(env, job, run3) {
23235
23281
  );
23236
23282
  const unmet = criteria ? [...criteria.missing, ...criteria.failed] : [];
23237
23283
  const graded = { ...outcome3, git: read4.git, ...criteria ? { criteria } : {} };
23238
- const repoRoot = env.repoRoot ?? path65.dirname(env.root);
23284
+ const repoRoot = env.repoRoot ?? path66.dirname(env.root);
23239
23285
  const guard2 = await runnerGuard({
23240
23286
  config: config4,
23241
23287
  checks: job.info.checks,
@@ -23437,7 +23483,7 @@ function withRules(o) {
23437
23483
 
23438
23484
  // ../core/src/verification/verifyCompletion.ts
23439
23485
  var CHECK_RUNNER = BRAND.slug;
23440
- var repoRootOf = (env) => env.repoRoot ?? path66.dirname(env.root);
23486
+ var repoRootOf = (env) => env.repoRoot ?? path67.dirname(env.root);
23441
23487
  function levelFor(root, snap, t) {
23442
23488
  const { config: config4 } = trustedChecks(root);
23443
23489
  const asked = verificationFor(config4.config, snap.map, t);
@@ -23641,14 +23687,14 @@ function reviewItem({ base: base2, last, verdict: verdict2 }, level) {
23641
23687
  }
23642
23688
 
23643
23689
  // ../core/src/workspaces/integrationStore.ts
23644
- import path67 from "node:path";
23645
- 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");
23646
23692
  function readIntegrationScan(root) {
23647
23693
  const s = readJsonFile(file3(root));
23648
23694
  return s?.v === 1 ? s : { v: 1, at: 0, overlaps: [] };
23649
23695
  }
23650
23696
  function writeIntegrationScan(root, s) {
23651
- ensureLocalDir(path67.join(root, AGENTS_DIR));
23697
+ ensureLocalDir(path68.join(root, AGENTS_DIR));
23652
23698
  writeJsonAtomic(file3(root), s);
23653
23699
  }
23654
23700
 
@@ -23737,26 +23783,26 @@ async function readViolations(input2) {
23737
23783
  }
23738
23784
 
23739
23785
  // ../core/src/planning/reroute/rerouteStore.ts
23740
- import { mkdirSync as mkdirSync25, readdirSync as readdirSync19, writeFileSync as writeFileSync17 } from "node:fs";
23741
- 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";
23742
23788
  var REROUTES_DIR = ".reroutes";
23743
23789
  var safe15 = (s) => s.replace(/[^\w.-]/g, "_");
23744
- var mapDir = (root, mapId) => path68.join(root, REROUTES_DIR, safe15(mapId));
23745
- var fileOf = (root, mapId, id) => path68.join(mapDir(root, mapId), `${safe15(id)}.json`);
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`);
23746
23792
  var idNumber2 = (id) => Number(id.match(/^R-(\d+)$/)?.[1] ?? 0);
23747
23793
  function listReroutes(root, mapId) {
23748
23794
  let names = [];
23749
23795
  try {
23750
- 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));
23751
23797
  } catch {
23752
23798
  return [];
23753
23799
  }
23754
- 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));
23755
23801
  }
23756
23802
  function listAllReroutes(root) {
23757
23803
  let maps = [];
23758
23804
  try {
23759
- maps = readdirSync19(path68.join(root, REROUTES_DIR)).filter((n) => !n.startsWith("."));
23805
+ maps = readdirSync20(path69.join(root, REROUTES_DIR)).filter((n) => !n.startsWith("."));
23760
23806
  } catch {
23761
23807
  return [];
23762
23808
  }
@@ -23765,7 +23811,7 @@ function listAllReroutes(root) {
23765
23811
  var readReroute = (root, mapId, id) => readJsonFile(fileOf(root, mapId, id));
23766
23812
  function createReroute(root, draft) {
23767
23813
  const dir4 = mapDir(root, draft.mapId);
23768
- ensureLocalDir(path68.join(root, REROUTES_DIR));
23814
+ ensureLocalDir(path69.join(root, REROUTES_DIR));
23769
23815
  mkdirSync25(dir4, { recursive: true });
23770
23816
  let n = Math.max(0, ...listReroutes(root, draft.mapId).map((p) => idNumber2(p.id))) + 1;
23771
23817
  for (; ; ) {
@@ -23780,7 +23826,7 @@ function createReroute(root, draft) {
23780
23826
  }
23781
23827
  }
23782
23828
  function writeReroute(root, p) {
23783
- ensureLocalDir(path68.join(root, REROUTES_DIR));
23829
+ ensureLocalDir(path69.join(root, REROUTES_DIR));
23784
23830
  writeJsonAtomic(fileOf(root, p.mapId, p.id), p);
23785
23831
  }
23786
23832
 
@@ -23904,12 +23950,12 @@ async function attentionView(input2) {
23904
23950
  }
23905
23951
 
23906
23952
  // ../core/src/attention/writeReviewLimit.ts
23907
- import { existsSync as existsSync24, readFileSync as readFileSync27 } from "node:fs";
23908
- import path69 from "node:path";
23953
+ import { existsSync as existsSync25, readFileSync as readFileSync27 } from "node:fs";
23954
+ import path70 from "node:path";
23909
23955
  function writeReviewLimit(root, limit) {
23910
- const file9 = path69.join(root, ATTENTION_FILE);
23956
+ const file9 = path70.join(root, ATTENTION_FILE);
23911
23957
  let raw = { v: 1 };
23912
- if (existsSync24(file9)) {
23958
+ if (existsSync25(file9)) {
23913
23959
  try {
23914
23960
  const read4 = parseJsonSafe(readFileSync27(file9, "utf8"));
23915
23961
  if (!read4 || typeof read4 !== "object" || Array.isArray(read4)) throw new Error("not a JSON object");
@@ -24123,20 +24169,20 @@ async function seedAssumptions(adapter, brief) {
24123
24169
 
24124
24170
  // ../core/src/criteria/criteriaProposals.ts
24125
24171
  import { rmSync as rmSync15 } from "node:fs";
24126
- import path71 from "node:path";
24172
+ import path72 from "node:path";
24127
24173
 
24128
24174
  // ../core/src/agents/ignoreAgentsDir.ts
24129
- import { existsSync as existsSync25, mkdirSync as mkdirSync26, writeFileSync as writeFileSync18 } from "node:fs";
24130
- 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";
24131
24177
  function ignoreAgentsDir(root) {
24132
- const ignore = path70.join(root, AGENTS_DIR, ".gitignore");
24133
- mkdirSync26(path70.dirname(ignore), { recursive: true });
24134
- 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");
24135
24181
  }
24136
24182
 
24137
24183
  // ../core/src/criteria/criteriaProposals.ts
24138
24184
  var safe16 = (s) => s.replace(/[^\w.-]/g, "_");
24139
- 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`);
24140
24186
  var isProposal = (p) => !!p && typeof p.ticketId === "string" && typeof p.by === "string" && Array.isArray(p.criteria);
24141
24187
  function readCriteriaProposals(root, mapId) {
24142
24188
  const f = readJsonFile(file4(root, mapId));
@@ -24183,13 +24229,13 @@ async function handleCriteriaProposals(root, req, res, url2) {
24183
24229
  if (!waiting2) return sendJson(res, 404, { error: "no proposed criteria for this ticket" }), true;
24184
24230
  const shown3 = action === "accept" ? checkShown(b.hash, contentOf2(waiting2), "The proposal") : { ok: true };
24185
24231
  if (!shown3.ok) return sendJson(res, shown3.status, { error: shown3.error }), true;
24186
- const taken = dropCriteriaProposal(root, b.mapId, b.ticketId);
24187
- 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;
24188
24234
  const map2 = { id: b.mapId, title: text3(b.title) ? b.title : b.mapId };
24189
- const ticket2 = { id: taken.ticketId, key: taken.ticketKey };
24190
- writeTicketCriteria(root, map2, ticket2, { criteria: taken.criteria });
24235
+ const ticket2 = { id: taken2.ticketId, key: taken2.ticketKey };
24236
+ writeTicketCriteria(root, map2, ticket2, { criteria: taken2.criteria });
24191
24237
  const confirmed = writeTicketCriteria(root, map2, ticket2, { confirmed: true });
24192
- 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");
24193
24239
  sendJson(res, 200, { ticket: confirmed });
24194
24240
  return true;
24195
24241
  }
@@ -24343,21 +24389,21 @@ async function handleDecisions({ adapter, root }, req, res, url2) {
24343
24389
 
24344
24390
  // ../core/src/projects/confinePath.ts
24345
24391
  import { realpathSync as realpathSync11 } from "node:fs";
24346
- import path72 from "node:path";
24392
+ import path73 from "node:path";
24347
24393
  function realOrParent(p) {
24348
24394
  try {
24349
24395
  return realpathSync11(p);
24350
24396
  } catch {
24351
- const parent = path72.dirname(p);
24397
+ const parent = path73.dirname(p);
24352
24398
  if (parent === p) return p;
24353
- return path72.join(realOrParent(parent), path72.basename(p));
24399
+ return path73.join(realOrParent(parent), path73.basename(p));
24354
24400
  }
24355
24401
  }
24356
24402
  function insideRoot(root, rel) {
24357
- if (path72.isAbsolute(rel) || rel.includes("\0")) return false;
24358
- const base2 = realOrParent(path72.resolve(root));
24359
- const full = realOrParent(path72.resolve(root, rel));
24360
- 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);
24361
24407
  }
24362
24408
 
24363
24409
  // ../core/src/server/trustFields.ts
@@ -24510,7 +24556,7 @@ async function handleFlakyChecks(ctx, req, res, url2) {
24510
24556
 
24511
24557
  // ../core/src/guides/approveCheck.ts
24512
24558
  import { writeFileSync as writeFileSync19 } from "node:fs";
24513
- import path73 from "node:path";
24559
+ import path74 from "node:path";
24514
24560
 
24515
24561
  // ../core/src/verification/rawConfig.ts
24516
24562
  import { readFileSync as readFileSync28 } from "node:fs";
@@ -24546,7 +24592,7 @@ function approveCheck(input2) {
24546
24592
  const notice = checkNotice(proposed2);
24547
24593
  if (notice && !input2.acknowledged)
24548
24594
  throw new OperationError(`check ${input2.name}: ${notice}; approve it again, acknowledging that`);
24549
- const file9 = path73.join(input2.root, VERIFICATION_FILE);
24595
+ const file9 = path74.join(input2.root, VERIFICATION_FILE);
24550
24596
  const raw = readRaw2(file9);
24551
24597
  const checks = { ...raw.checks ?? {} };
24552
24598
  const spec = specOf(proposed2);
@@ -24571,10 +24617,10 @@ function approveCheck(input2) {
24571
24617
  }
24572
24618
 
24573
24619
  // ../core/src/guides/checklistStore.ts
24574
- import path74 from "node:path";
24575
- 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");
24576
24622
  function writeChecklist(root, rec) {
24577
- ensureLocalDir(path74.join(root, EVIDENCE_DIR));
24623
+ ensureLocalDir(path75.join(root, EVIDENCE_DIR));
24578
24624
  writeJsonAtomic(fileOf2(root, rec.mapId, rec.ticketId), rec);
24579
24625
  }
24580
24626
  function readChecklist(root, mapId, ticketId) {
@@ -24827,12 +24873,12 @@ function changeOf(b) {
24827
24873
  if (typeof b.remove === "string" && b.remove) return { kind: "remove", id: b.remove };
24828
24874
  throw new BadRequest('"add" or "remove" is required');
24829
24875
  }
24830
- async function guideTrailAction(ctx, req, path148) {
24876
+ async function guideTrailAction(ctx, req, path149) {
24831
24877
  const b = await readJson2(req, "{}");
24832
24878
  const mapId = str5(b.mapId, "mapId");
24833
24879
  const adapter = await ctx.active();
24834
24880
  const guides = listGuides(ctx.root);
24835
- if (path148 === "/guides/trail") {
24881
+ if (path149 === "/guides/trail") {
24836
24882
  const byType = byTypeOf(b.byType);
24837
24883
  const before = trailGuidesByType((await adapter.loadMap(mapId)).map).byType;
24838
24884
  const added = Object.entries(byType ?? {}).flatMap(
@@ -24856,13 +24902,13 @@ var str6 = (v, name2) => {
24856
24902
  if (typeof v !== "string" || !v) throw new BadRequest(`"${name2}" is required`);
24857
24903
  return v;
24858
24904
  };
24859
- async function projectAction(ctx, req, path148) {
24905
+ async function projectAction(ctx, req, path149) {
24860
24906
  const b = await readJson2(req, "{}");
24861
24907
  const id = str6(b.id, "id");
24862
- if (path148 === "/guides/approve") {
24908
+ if (path149 === "/guides/approve") {
24863
24909
  const r = approveGuide({ root: ctx.root, id, by: TRAIL_LEAD2, sha256: str6(b.sha256, "sha256") });
24864
24910
  journalGuide(ctx.root, { action: "approved", guide: id, version: r.guide.version });
24865
- } else if (path148 === "/guides/checks/approve") {
24911
+ } else if (path149 === "/guides/checks/approve") {
24866
24912
  const acknowledged = b.acknowledged === true;
24867
24913
  const r = approveCheck({ root: ctx.root, id, name: str6(b.name, "name"), acknowledged });
24868
24914
  journalGuide(ctx.root, { action: "check-approved", guide: id, version: r.version, check: r.check });
@@ -24993,7 +25039,7 @@ function trailLeadCall(root, b, hashOf) {
24993
25039
  // ../core/src/server/lanPlaces.ts
24994
25040
  import { realpathSync as realpathSync12 } from "node:fs";
24995
25041
  import os2 from "node:os";
24996
- import path75 from "node:path";
25042
+ import path76 from "node:path";
24997
25043
  function real4(p) {
24998
25044
  try {
24999
25045
  return realpathSync12(p);
@@ -25002,28 +25048,28 @@ function real4(p) {
25002
25048
  }
25003
25049
  }
25004
25050
  function lanPlaces(root, configDir2) {
25005
- const repo = path75.basename(root) === BRAND.dataDir ? path75.dirname(root) : root;
25006
- 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);
25007
25053
  const temp = process.platform === "win32" ? [] : ["/tmp", "/private/tmp", "/var/folders", "/private/var/folders"];
25008
- 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);
25009
25055
  }
25010
25056
 
25011
25057
  // ../core/src/agents/returnToQueue.ts
25012
25058
  var LEASE_REAPER = "teamtrail";
25013
25059
  async function returnToQueue(root, adapter, lease, why2) {
25014
25060
  const { reason, by, now: now2 = Date.now() } = why2;
25015
- const taken = takeLease(root, lease);
25016
- if (!taken) return { busy: true };
25017
- const l = taken.lease;
25061
+ const taken2 = takeLease(root, lease);
25062
+ if (!taken2) return { busy: true };
25063
+ const l = taken2.lease;
25018
25064
  if (l.returned || reason === "expired" && leaseHealth(l, now2) !== "expired") {
25019
- taken.put(l);
25065
+ taken2.put(l);
25020
25066
  return { busy: true };
25021
25067
  }
25022
25068
  try {
25023
25069
  const snap = await adapter.loadMap(l.mapId);
25024
25070
  const t = snap.tickets.find((x) => x.id === l.ticketId);
25025
25071
  if (!t || t.state === "closed" || t.assignee !== l.agent) {
25026
- taken.drop();
25072
+ taken2.drop();
25027
25073
  return { dropped: l };
25028
25074
  }
25029
25075
  await adapter.comment(l.mapId, l.ticketId, by, handoffComment(l, reason, by));
@@ -25036,11 +25082,11 @@ async function returnToQueue(root, adapter, lease, why2) {
25036
25082
  journal: journalFile(root)
25037
25083
  });
25038
25084
  } catch (e) {
25039
- taken.put(l);
25085
+ taken2.put(l);
25040
25086
  throw e;
25041
25087
  }
25042
25088
  const tomb = { ...l, returned: { at: now2, reason, by } };
25043
- taken.put(tomb);
25089
+ taken2.put(tomb);
25044
25090
  return { returned: tomb };
25045
25091
  }
25046
25092
  async function reclaimExpired(root, adapter, now2 = Date.now()) {
@@ -25600,11 +25646,11 @@ async function handleMergeAnyway(ctx, req, res, url2) {
25600
25646
  }
25601
25647
 
25602
25648
  // ../core/src/planning/matching/modelsStore.ts
25603
- import { existsSync as existsSync26, readFileSync as readFileSync30 } from "node:fs";
25604
- import path76 from "node:path";
25649
+ import { existsSync as existsSync27, readFileSync as readFileSync30 } from "node:fs";
25650
+ import path77 from "node:path";
25605
25651
  function readModelsConfig(root) {
25606
- const file9 = path76.join(root, MODELS_FILE);
25607
- 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 };
25608
25654
  const parsed3 = parseModelsConfig(readFileSync30(file9, "utf8"));
25609
25655
  return { models: parsed3.models ?? {}, errors: parsed3.errors, exists: true };
25610
25656
  }
@@ -25672,14 +25718,14 @@ function proofPostSetting(root, dir4) {
25672
25718
  }
25673
25719
 
25674
25720
  // ../core/src/proof/proofPostStore.ts
25675
- import path77 from "node:path";
25676
- 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");
25677
25723
  function readProofPost(root, mapId, ticketId) {
25678
25724
  const r = readJsonFile(file5(root, mapId, ticketId));
25679
25725
  return r?.v === 1 ? r : void 0;
25680
25726
  }
25681
25727
  function writeProofPost(root, r) {
25682
- ensureLocalDir(path77.join(root, EVIDENCE_DIR));
25728
+ ensureLocalDir(path78.join(root, EVIDENCE_DIR));
25683
25729
  writeJsonAtomic(file5(root, r.mapId, r.ticketId), r);
25684
25730
  }
25685
25731
 
@@ -25849,13 +25895,13 @@ function gitLines(p) {
25849
25895
  ];
25850
25896
  }
25851
25897
  var SCOPE_SHOWN = 10;
25852
- var path78 = (s) => md(s, 120);
25898
+ var path79 = (s) => md(s, 120);
25853
25899
  function scopeLines(s) {
25854
25900
  if (!s) return [];
25855
- const declared = s.declared.slice(0, SCOPE_SHOWN).map(path78).join(", ");
25901
+ const declared = s.declared.slice(0, SCOPE_SHOWN).map(path79).join(", ");
25856
25902
  if (!s.outside.length) return ["", `**Scope:** every changed file is inside the declared ${declared}.`];
25857
25903
  const more = s.outside.length > SCOPE_SHOWN ? `, and ${s.outside.length - SCOPE_SHOWN} more` : "";
25858
- const files = s.outside.slice(0, SCOPE_SHOWN).map(path78).join(", ");
25904
+ const files = s.outside.slice(0, SCOPE_SHOWN).map(path79).join(", ");
25859
25905
  return [
25860
25906
  "",
25861
25907
  `**Scope:** ${s.outside.length} changed file${s.outside.length === 1 ? "" : "s"} outside the declared ${declared}: ${files}${more}.`
@@ -25896,13 +25942,13 @@ function proofMarkdown(p, signature4) {
25896
25942
  }
25897
25943
 
25898
25944
  // ../core/src/proof/repoProofKey.ts
25899
- import { existsSync as existsSync27, mkdirSync as mkdirSync30, writeFileSync as writeFileSync21 } from "node:fs";
25900
- 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";
25901
25947
 
25902
25948
  // ../core/src/machine/proofKey.ts
25903
25949
  import { createHash as createHash9, createPrivateKey, generateKeyPairSync, randomBytes as randomBytes6 } from "node:crypto";
25904
25950
  import { linkSync as linkSync5, readFileSync as readFileSync31, rmSync as rmSync17 } from "node:fs";
25905
- import path79 from "node:path";
25951
+ import path80 from "node:path";
25906
25952
  var PROOF_KEY_FILE = "proof-key.json";
25907
25953
  var proofKeyId = (publicKeyB64) => createHash9("sha256").update(Buffer.from(publicKeyB64, "base64")).digest("hex").slice(0, 16);
25908
25954
  function read(file9) {
@@ -25925,7 +25971,7 @@ function fresh() {
25925
25971
  };
25926
25972
  }
25927
25973
  function machineProofKey(dir4 = configDir()) {
25928
- const file9 = path79.join(dir4, PROOF_KEY_FILE);
25974
+ const file9 = path80.join(dir4, PROOF_KEY_FILE);
25929
25975
  let s = read(file9);
25930
25976
  if (!s) {
25931
25977
  const draft = `${file9}.${process.pid}.${randomBytes6(4).toString("hex")}`;
@@ -25955,10 +26001,10 @@ function ensureRepoProofKey(root, dir4) {
25955
26001
  } catch {
25956
26002
  return void 0;
25957
26003
  }
25958
- const rel = path80.join(PROOF_KEYS_DIR, `${key.id}.pub`);
25959
- const file9 = path80.join(root, rel);
25960
- if (!existsSync27(file9)) {
25961
- 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 });
25962
26008
  try {
25963
26009
  writeFileSync21(file9, proofKeyLine(key.publicKey), { flag: "wx" });
25964
26010
  } catch (e) {
@@ -26184,9 +26230,9 @@ function redactResponse(res, places = []) {
26184
26230
  }
26185
26231
 
26186
26232
  // ../core/src/remoteAgents/mcpEndpoints.ts
26187
- import { readdirSync as readdirSync20, rmSync as rmSync18 } from "node:fs";
26233
+ import { readdirSync as readdirSync21, rmSync as rmSync18 } from "node:fs";
26188
26234
  import os3 from "node:os";
26189
- import path81 from "node:path";
26235
+ import path82 from "node:path";
26190
26236
 
26191
26237
  // ../core/src/machine/announcementSig.ts
26192
26238
  function announcementSig(root, what2, fields2) {
@@ -26228,8 +26274,8 @@ var DIR2 = `${AGENTS_DIR}/mcp-endpoints`;
26228
26274
  var ENDPOINT_SIG = "mcp-endpoint";
26229
26275
  var fieldsOf = (e) => [e.url, e.pid, e.kind, e.network === true, e.startedAt];
26230
26276
  function writeMcpEndpoint(root, e) {
26231
- const file9 = path81.join(root, DIR2, `${process.pid}.json`);
26232
- ensureLocalDir(path81.join(root, AGENTS_DIR));
26277
+ const file9 = path82.join(root, DIR2, `${process.pid}.json`);
26278
+ ensureLocalDir(path82.join(root, AGENTS_DIR));
26233
26279
  const base2 = { url: e.url, kind: e.kind, network: e.network, pid: process.pid, startedAt: Date.now() };
26234
26280
  const sig = announcementSig(root, ENDPOINT_SIG, fieldsOf(base2));
26235
26281
  const endpoint = { ...base2, ...sig ? { sig } : {} };
@@ -26249,40 +26295,40 @@ function believed(root, at2, e) {
26249
26295
  function readMcpEndpoints(root) {
26250
26296
  let names = [];
26251
26297
  try {
26252
- names = readdirSync20(path81.join(root, DIR2)).filter((n) => n.endsWith(".json"));
26298
+ names = readdirSync21(path82.join(root, DIR2)).filter((n) => n.endsWith(".json"));
26253
26299
  } catch {
26254
26300
  return [];
26255
26301
  }
26256
26302
  const addresses = ownAddresses();
26257
- return names.map((n) => believed(root, { name: n, addresses }, readJsonFile(path81.join(root, DIR2, n)))).filter((e) => !!e).sort((a, b) => Number(b.kind === "standalone") - Number(a.kind === "standalone") || a.startedAt - b.startedAt);
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);
26258
26304
  }
26259
26305
 
26260
26306
  // ../core/src/remoteAgents/remoteTokens.ts
26261
26307
  import { createHash as createHash10, randomBytes as randomBytes7, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
26262
26308
 
26263
26309
  // ../core/src/remoteAgents/remoteTokenStore.ts
26264
- import path82 from "node:path";
26310
+ import path83 from "node:path";
26265
26311
  var REMOTE_TOKENS_FILE = `${AGENTS_DIR}/remote-tokens.json`;
26266
26312
  var REMOTE_TOKENS_USED_FILE = `${AGENTS_DIR}/remote-tokens-used.json`;
26267
26313
  var TOKEN_FIELDS = ["id", "name", "hash"];
26268
26314
  var isToken = (t) => !!t && TOKEN_FIELDS.every((k) => typeof t[k] === "string" && t[k]) && typeof t.createdAt === "number";
26269
- var ignoreAgentsDir2 = (root) => ensureLocalDir(path82.join(root, AGENTS_DIR));
26315
+ var ignoreAgentsDir2 = (root) => ensureLocalDir(path83.join(root, AGENTS_DIR));
26270
26316
  function readRemoteTokens(root) {
26271
- const raw = readJsonFile(path82.join(root, REMOTE_TOKENS_FILE));
26317
+ const raw = readJsonFile(path83.join(root, REMOTE_TOKENS_FILE));
26272
26318
  if (raw?.v !== 1 || !Array.isArray(raw.tokens)) return [];
26273
26319
  return raw.tokens.filter(isToken);
26274
26320
  }
26275
26321
  function writeRemoteTokens(root, tokens) {
26276
26322
  ignoreAgentsDir2(root);
26277
- writeJsonAtomic(path82.join(root, REMOTE_TOKENS_FILE), { v: 1, tokens });
26323
+ writeJsonAtomic(path83.join(root, REMOTE_TOKENS_FILE), { v: 1, tokens });
26278
26324
  }
26279
26325
  function readRemoteTokenUse(root) {
26280
- const raw = readJsonFile(path82.join(root, REMOTE_TOKENS_USED_FILE));
26326
+ const raw = readJsonFile(path83.join(root, REMOTE_TOKENS_USED_FILE));
26281
26327
  return raw?.v === 1 && raw.used && typeof raw.used === "object" ? raw.used : {};
26282
26328
  }
26283
26329
  function writeRemoteTokenUse(root, used) {
26284
26330
  ignoreAgentsDir2(root);
26285
- writeJsonAtomic(path82.join(root, REMOTE_TOKENS_USED_FILE), { v: 1, used });
26331
+ writeJsonAtomic(path83.join(root, REMOTE_TOKENS_USED_FILE), { v: 1, used });
26286
26332
  }
26287
26333
 
26288
26334
  // ../core/src/remoteAgents/remoteTokens.ts
@@ -27037,8 +27083,8 @@ var GitHubCiProvider = class {
27037
27083
  this.#base = `${apiBase(o.apiUrl)}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name2)}`;
27038
27084
  this.#limit = Math.min(100, o.recentLimit ?? 50);
27039
27085
  }
27040
- async #get(path148) {
27041
- 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;
27042
27088
  }
27043
27089
  #snapshot(p, review2 = "none") {
27044
27090
  const sha2 = SHA2.test(p.head.sha) ? p.head.sha.toLowerCase() : "";
@@ -27567,11 +27613,11 @@ async function handleLinearTeams(req, res, o) {
27567
27613
  }
27568
27614
 
27569
27615
  // ../core/src/adapters/remote/acceptedSettingsFile.ts
27570
- 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";
27571
27617
  import { open, rename, rm, stat as stat2 } from "node:fs/promises";
27572
- import path83 from "node:path";
27618
+ import path84 from "node:path";
27573
27619
  var ACCEPTED_DIR = "tracker-settings";
27574
- 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`);
27575
27621
  var LOCK_STALE_MS = 5e3;
27576
27622
  var BACKOFF_MS = [0, 5, 10, 20, 40, 80, 160, 320, 400];
27577
27623
  var macParts2 = (root, target2, issues) => [
@@ -27628,7 +27674,7 @@ function migrate(root, target2) {
27628
27674
  const legacy = legacyTargetKey(target2);
27629
27675
  const from = acceptedSettingsPath(root, legacy);
27630
27676
  const to = acceptedSettingsPath(root, target2);
27631
- if (legacy === target2 || !existsSync28(from) || existsSync28(to)) return;
27677
+ if (legacy === target2 || !existsSync29(from) || existsSync29(to)) return;
27632
27678
  const issues = readDoc(root, from, legacy);
27633
27679
  try {
27634
27680
  const mac4 = machineSign(macParts2(root, target2, issues));
@@ -27645,7 +27691,7 @@ function acceptedSettingsFile(root, target2) {
27645
27691
  read: () => readDoc(root, file9, target2),
27646
27692
  async update(change3) {
27647
27693
  try {
27648
- mkdirSync31(path83.dirname(file9), { recursive: true, mode: 448 });
27694
+ mkdirSync31(path84.dirname(file9), { recursive: true, mode: 448 });
27649
27695
  } catch {
27650
27696
  return false;
27651
27697
  }
@@ -27659,7 +27705,7 @@ function acceptedSettingsFile(root, target2) {
27659
27705
  writePrivateFile(file9, `${JSON.stringify({ v: 1, target: target2, issues, mac: mac4 }, null, 2)}
27660
27706
  `);
27661
27707
  });
27662
- 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`);
27663
27709
  return done2;
27664
27710
  }
27665
27711
  };
@@ -28435,7 +28481,7 @@ async function handleTrailChecks(ctx, req, res, url2) {
28435
28481
 
28436
28482
  // ../core/src/signedState/revertState.ts
28437
28483
  import { readFileSync as readFileSync32 } from "node:fs";
28438
- import path84 from "node:path";
28484
+ import path85 from "node:path";
28439
28485
 
28440
28486
  // ../core/src/trust/itemFiles.ts
28441
28487
  var itemFiles = (i) => i.files ?? (i.file ? [i.file] : []);
@@ -28453,7 +28499,7 @@ function readRaw3(root, c) {
28453
28499
  refuseLinks(root, c.rel);
28454
28500
  if (c.fields.includes("oversized")) return void 0;
28455
28501
  try {
28456
- return readFileSync32(path84.join(root, c.rel), "utf8");
28502
+ return readFileSync32(path85.join(root, c.rel), "utf8");
28457
28503
  } catch {
28458
28504
  return void 0;
28459
28505
  }
@@ -28548,7 +28594,7 @@ function adoptableWithoutFile(root, item2) {
28548
28594
 
28549
28595
  // ../core/src/trust/committedFiles.ts
28550
28596
  import { realpathSync as realpathSync13 } from "node:fs";
28551
- import path85 from "node:path";
28597
+ import path86 from "node:path";
28552
28598
  async function committedFiles(root, files) {
28553
28599
  if (!files.length) return /* @__PURE__ */ new Set();
28554
28600
  let real7;
@@ -28559,7 +28605,7 @@ async function committedFiles(root, files) {
28559
28605
  }
28560
28606
  const top = await gitText(real7, ["rev-parse", "--show-toplevel"]);
28561
28607
  if (!top) return /* @__PURE__ */ new Set();
28562
- 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]));
28563
28609
  const paths = [...rel.keys()];
28564
28610
  const listed3 = await git(top, ["ls-files", "-z", "--end-of-options", ...paths]);
28565
28611
  const diffed = await git(top, ["diff", "--name-only", "-z", "--end-of-options", "HEAD", "--", ...paths]);
@@ -29118,7 +29164,7 @@ async function withdraw({ env, r, ticketId }) {
29118
29164
 
29119
29165
  // ../core/src/verification/ticketEvidence.ts
29120
29166
  import { closeSync as closeSync3, openSync as openSync3, readSync, realpathSync as realpathSync14, statSync as statSync9 } from "node:fs";
29121
- import path86 from "node:path";
29167
+ import path87 from "node:path";
29122
29168
  var LOG_VIEW_BYTES = 256 * 1024;
29123
29169
  function ticketEvidence(root, mapId, ticketId) {
29124
29170
  const attempts = readAttempts(root, mapId, ticketId);
@@ -29135,12 +29181,12 @@ function readEvidenceLog(root, rel) {
29135
29181
  let file9;
29136
29182
  let base2;
29137
29183
  try {
29138
- base2 = realpathSync14(path86.join(root, EVIDENCE_DIR));
29139
- file9 = realpathSync14(path86.join(root, rel));
29184
+ base2 = realpathSync14(path87.join(root, EVIDENCE_DIR));
29185
+ file9 = realpathSync14(path87.join(root, rel));
29140
29186
  } catch {
29141
29187
  return void 0;
29142
29188
  }
29143
- if (!file9.startsWith(base2 + path86.sep)) return void 0;
29189
+ if (!file9.startsWith(base2 + path87.sep)) return void 0;
29144
29190
  const size3 = statSync9(file9).size;
29145
29191
  const len = Math.min(size3, LOG_VIEW_BYTES);
29146
29192
  const buf = Buffer.alloc(len);
@@ -29154,15 +29200,15 @@ function readEvidenceLog(root, rel) {
29154
29200
  }
29155
29201
 
29156
29202
  // ../core/src/verification/setChecks.ts
29157
- import path88 from "node:path";
29203
+ import path89 from "node:path";
29158
29204
 
29159
29205
  // ../core/src/verification/writeApprovedConfig.ts
29160
29206
  import { lstatSync as lstatSync6, renameSync as renameSync10, writeFileSync as writeFileSync22 } from "node:fs";
29161
- import path87 from "node:path";
29207
+ import path88 from "node:path";
29162
29208
  function writeApprovedConfig(o) {
29163
29209
  const { errors } = parseVerificationConfig(o.text);
29164
29210
  if (errors.length) throw new OperationError(`${VERIFICATION_FILE} would be invalid: ${errors.join("; ")}`);
29165
- const file9 = path87.join(o.root, VERIFICATION_FILE);
29211
+ const file9 = path88.join(o.root, VERIFICATION_FILE);
29166
29212
  if (lstatSync6(file9, { throwIfNoEntry: false })?.isSymbolicLink())
29167
29213
  throw new OperationError(`${VERIFICATION_FILE} is a link; replace it by hand`);
29168
29214
  const tmp = `${file9}.${process.pid}.tmp`;
@@ -29210,7 +29256,7 @@ function setChecks(o) {
29210
29256
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29211
29257
  const problem = problemOf(o.checks, o.acknowledged === true);
29212
29258
  if (problem) throw new OperationError(problem);
29213
- const file9 = path88.join(o.root, VERIFICATION_FILE);
29259
+ const file9 = path89.join(o.root, VERIFICATION_FILE);
29214
29260
  const raw = readRawConfig(file9, { v: 1, default: "checks" });
29215
29261
  const kept = raw.checks ?? {};
29216
29262
  const checks = Object.fromEntries(o.checks.map((c) => [c.name, { ...kept[c.name] ?? {}, run: c.run }]));
@@ -29272,8 +29318,8 @@ function readGateLog(o) {
29272
29318
  }
29273
29319
 
29274
29320
  // ../core/src/verification/setGateMode.ts
29275
- import { existsSync as existsSync29 } from "node:fs";
29276
- import path89 from "node:path";
29321
+ import { existsSync as existsSync30 } from "node:fs";
29322
+ import path90 from "node:path";
29277
29323
  var LABEL = {
29278
29324
  off: "off",
29279
29325
  observe: "observed, nothing held",
@@ -29287,8 +29333,8 @@ function setGateMode(o) {
29287
29333
  const mode = o.mode;
29288
29334
  const now2 = checksApproval(o.root);
29289
29335
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29290
- const file9 = path89.join(o.root, VERIFICATION_FILE);
29291
- if (!existsSync29(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
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");
29292
29338
  if (now2.waiting)
29293
29339
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29294
29340
  const raw = readRawConfig(file9, { v: 1 });
@@ -29322,8 +29368,8 @@ async function handleGates(o, req, res) {
29322
29368
  }
29323
29369
 
29324
29370
  // ../core/src/verification/setScope.ts
29325
- import { existsSync as existsSync30 } from "node:fs";
29326
- import path90 from "node:path";
29371
+ import { existsSync as existsSync31 } from "node:fs";
29372
+ import path91 from "node:path";
29327
29373
  var POLICIES = ["flag", "fail", "human"];
29328
29374
  var LABEL2 = {
29329
29375
  flag: "shown to the reviewer",
@@ -29335,8 +29381,8 @@ function setScope(o) {
29335
29381
  const scope = o.scope;
29336
29382
  const now2 = checksApproval(o.root);
29337
29383
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29338
- const file9 = path90.join(o.root, VERIFICATION_FILE);
29339
- if (!existsSync30(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
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");
29340
29386
  if (now2.waiting)
29341
29387
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29342
29388
  const raw = readRawConfig(file9, { v: 1 });
@@ -29436,15 +29482,15 @@ async function handleVerification({ root, active, local, repoFiles }, req, res,
29436
29482
 
29437
29483
  // ../core/src/verification/heldRulesStore.ts
29438
29484
  import { rmSync as rmSync20 } from "node:fs";
29439
- import path91 from "node:path";
29440
- 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");
29441
29487
  var heldRulesStore = {
29442
29488
  read(root, mapId, ticketId) {
29443
29489
  const r = readJsonFile(file6(root, mapId, ticketId));
29444
29490
  return r?.v === 1 && Array.isArray(r.rules) ? r : void 0;
29445
29491
  },
29446
29492
  write(root, mapId, ticketId, held) {
29447
- ensureLocalDir(path91.join(root, EVIDENCE_DIR));
29493
+ ensureLocalDir(path92.join(root, EVIDENCE_DIR));
29448
29494
  writeJsonAtomic(file6(root, mapId, ticketId), held);
29449
29495
  },
29450
29496
  clear(root, mapId, ticketId) {
@@ -29453,28 +29499,28 @@ var heldRulesStore = {
29453
29499
  };
29454
29500
 
29455
29501
  // ../core/src/verification/rulesLastMatched.ts
29456
- import { readdirSync as readdirSync21 } from "node:fs";
29457
- import path92 from "node:path";
29502
+ import { readdirSync as readdirSync22 } from "node:fs";
29503
+ import path93 from "node:path";
29458
29504
  var dirs = (dir4) => {
29459
29505
  try {
29460
- 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);
29461
29507
  } catch {
29462
29508
  return [];
29463
29509
  }
29464
29510
  };
29465
29511
  function rulesLastMatched(root) {
29466
29512
  const out = {};
29467
- const base2 = path92.join(root, EVIDENCE_DIR);
29513
+ const base2 = path93.join(root, EVIDENCE_DIR);
29468
29514
  const attempts = dirs(base2).flatMap(
29469
- (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))
29470
29516
  );
29471
29517
  for (const a of attempts) for (const r of a.rules ?? []) out[r.id] = Math.max(out[r.id] ?? 0, a.finishedAt);
29472
29518
  return out;
29473
29519
  }
29474
29520
 
29475
29521
  // ../core/src/verification/setRules.ts
29476
- import { existsSync as existsSync31 } from "node:fs";
29477
- import path93 from "node:path";
29522
+ import { existsSync as existsSync32 } from "node:fs";
29523
+ import path94 from "node:path";
29478
29524
  var isObj5 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
29479
29525
  var text7 = (v) => typeof v === "string" && v.trim() ? v.trim() : void 0;
29480
29526
  function nextId(used) {
@@ -29500,8 +29546,8 @@ function setRules(o) {
29500
29546
  const rules2 = shapeRules(o.rules);
29501
29547
  const now2 = checksApproval(o.root);
29502
29548
  if (o.base !== now2.hash) throw new StaleChecks(`${VERIFICATION_FILE} changed since you opened it; look again`);
29503
- const file9 = path93.join(o.root, VERIFICATION_FILE);
29504
- if (!existsSync31(file9)) throw new OperationError("Set the checks first: without them nothing is verified");
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");
29505
29551
  if (now2.waiting)
29506
29552
  throw new OperationError(`Approve ${VERIFICATION_FILE} first: it changed since it was approved here`);
29507
29553
  const { rules: _old, ...raw } = readRawConfig(file9, { v: 1 });
@@ -30182,14 +30228,14 @@ function watchIntegration(root, opts = {}) {
30182
30228
  }
30183
30229
 
30184
30230
  // ../core/src/server/watchLeases.ts
30185
- import { readdirSync as readdirSync22, statSync as statSync10 } from "node:fs";
30186
- import path94 from "node:path";
30231
+ import { readdirSync as readdirSync23, statSync as statSync10 } from "node:fs";
30232
+ import path95 from "node:path";
30187
30233
  function watchLeases(root, active, send, opts = {}) {
30188
- const dir4 = path94.join(root, leasePaths.dir);
30234
+ const dir4 = path95.join(root, leasePaths.dir);
30189
30235
  let last = "";
30190
30236
  const signature4 = () => {
30191
30237
  try {
30192
- 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("|");
30193
30239
  } catch {
30194
30240
  return "";
30195
30241
  }
@@ -30243,13 +30289,13 @@ function watchMainChecks(ctx, send, opts = {}) {
30243
30289
  }
30244
30290
 
30245
30291
  // ../core/src/server/watchRemoteAgents.ts
30246
- import { readdirSync as readdirSync23, statSync as statSync11 } from "node:fs";
30247
- import path95 from "node:path";
30292
+ import { readdirSync as readdirSync24, statSync as statSync11 } from "node:fs";
30293
+ import path96 from "node:path";
30248
30294
  function watchRemoteAgents(root, send, pollMs = 1e3) {
30249
- 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;
30250
30296
  const endpoints = () => {
30251
30297
  try {
30252
- return readdirSync23(path95.join(root, AGENTS_DIR, "mcp-endpoints")).join(",");
30298
+ return readdirSync24(path96.join(root, AGENTS_DIR, "mcp-endpoints")).join(",");
30253
30299
  } catch {
30254
30300
  return "";
30255
30301
  }
@@ -30267,8 +30313,8 @@ function watchRemoteAgents(root, send, pollMs = 1e3) {
30267
30313
  }
30268
30314
 
30269
30315
  // ../core/src/server/watchTrackerFolder.ts
30270
- import { readdirSync as readdirSync24, statSync as statSync12 } from "node:fs";
30271
- import path96 from "node:path";
30316
+ import { readdirSync as readdirSync25, statSync as statSync12 } from "node:fs";
30317
+ import path97 from "node:path";
30272
30318
 
30273
30319
  // ../core/src/server/criteriaProposalEvent.ts
30274
30320
  var PROPOSALS = /^\.agents\/criteria-proposals\/([^/]+)\.json$/;
@@ -30370,13 +30416,13 @@ data: ${text11}
30370
30416
  const recheck = ++ticks % 10 === 0;
30371
30417
  let names = [];
30372
30418
  try {
30373
- 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"));
30374
30420
  } catch {
30375
30421
  return;
30376
30422
  }
30377
30423
  for (const n of names) {
30378
30424
  const rel = `${agentPaths.sessions}/${n}`;
30379
- const m = statSync12(path96.join(abs, rel), { throwIfNoEntry: false })?.mtimeMs;
30425
+ const m = statSync12(path97.join(abs, rel), { throwIfNoEntry: false })?.mtimeMs;
30380
30426
  if (m === void 0) continue;
30381
30427
  if (mtimes.get(rel) !== m || recheck && sentDocs.get(rel)?.includes('"status":"running"')) {
30382
30428
  mtimes.set(rel, m);
@@ -30534,22 +30580,22 @@ data: ${JSON.stringify(event)}
30534
30580
  }
30535
30581
 
30536
30582
  // ../core/src/workspaces/removeWorkspace.ts
30537
- import { existsSync as existsSync32 } from "node:fs";
30538
- import path98 from "node:path";
30583
+ import { existsSync as existsSync33 } from "node:fs";
30584
+ import path99 from "node:path";
30539
30585
 
30540
30586
  // ../core/src/workspaces/ownWorktree.ts
30541
30587
  import { realpathSync as realpathSync15 } from "node:fs";
30542
- import path97 from "node:path";
30588
+ import path98 from "node:path";
30543
30589
  var real5 = (p) => {
30544
30590
  try {
30545
30591
  return realpathSync15(p);
30546
30592
  } catch {
30547
- return path97.resolve(p);
30593
+ return path98.resolve(p);
30548
30594
  }
30549
30595
  };
30550
- var inside3 = (dir4, p) => p.startsWith(dir4 + path97.sep);
30596
+ var inside3 = (dir4, p) => p.startsWith(dir4 + path98.sep);
30551
30597
  async function ownWorktree2(root, folder2) {
30552
- const top = await gitText(path97.dirname(root), ["rev-parse", "--show-toplevel"]);
30598
+ const top = await gitText(path98.dirname(root), ["rev-parse", "--show-toplevel"]);
30553
30599
  if (!top) return void 0;
30554
30600
  const listed3 = await git(top, ["worktree", "list", "--porcelain", "-z"]);
30555
30601
  if (listed3.code !== 0) return void 0;
@@ -30570,14 +30616,14 @@ var isClaimed = (root, mapId, ticketId) => {
30570
30616
  async function removeWorkspace(i) {
30571
30617
  const record3 = readWorkspace(i.root, i.mapId, i.ticketId);
30572
30618
  if (!record3) return refused("This ticket has no workspace.");
30573
- 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;
30574
30620
  if (!ws)
30575
30621
  return refused(`${record3.path} isn't a worktree ${BRAND.name} prepared for this ticket, so it won't remove it.`);
30576
30622
  if (isClaimed(i.root, i.mapId, i.ticketId))
30577
30623
  return refused(`${ws.ticketKey} is still claimed. Finish it or release it to the queue first.`);
30578
- if (typeof ws.path !== "string" || !path98.isAbsolute(ws.path))
30624
+ if (typeof ws.path !== "string" || !path99.isAbsolute(ws.path))
30579
30625
  return refused("This ticket's workspace record doesn't name a folder, so Teamtrail won't remove anything.");
30580
- if (!existsSync32(ws.path)) {
30626
+ if (!existsSync33(ws.path)) {
30581
30627
  dropWorkspace(i.root, i.mapId, i.ticketId);
30582
30628
  return { kind: "removed", workspace: ws };
30583
30629
  }
@@ -30658,7 +30704,7 @@ function createTrackerBridge(root, options = {}) {
30658
30704
  repoFiles = localRepoFiles,
30659
30705
  ...trackers
30660
30706
  } = options;
30661
- const abs = path99.resolve(root);
30707
+ const abs = path100.resolve(root);
30662
30708
  const fs13 = nodeMarkdownFs(abs, { by: "lookout" });
30663
30709
  const lanFs = nodeMarkdownFs(abs, { by: "lookout on another device" });
30664
30710
  const markdown = new MarkdownAdapter({ ...fs13, watch: void 0 }, abs);
@@ -30671,7 +30717,7 @@ function createTrackerBridge(root, options = {}) {
30671
30717
  };
30672
30718
  const unwatch = watchTrackerFolder(abs, fs13, send);
30673
30719
  const unwatchLeases = watchLeases(abs, () => routes.active(), send, leaseTiming);
30674
- 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)) };
30675
30721
  const places = lanPlaces(abs, trackers.configDir);
30676
30722
  const proofs = postProofs(ctx, { access: routes.proofAccess, configDir: trackers.configDir });
30677
30723
  const reconciler = watchVerification(ctx, { access: routes.ciAccess, send, postProofs: proofs }, reconcilerTiming);
@@ -30850,7 +30896,7 @@ function activeTracker(o) {
30850
30896
 
30851
30897
  // ../core/src/agents/lookoutLock.ts
30852
30898
  import { rmSync as rmSync21 } from "node:fs";
30853
- import path100 from "node:path";
30899
+ import path101 from "node:path";
30854
30900
  var LOCK_SIG = "lookout-lock";
30855
30901
  function writeLookoutLock(root, url2) {
30856
30902
  const startedAt = Date.now();
@@ -30865,30 +30911,30 @@ function writeLookoutLock(root, url2) {
30865
30911
  };
30866
30912
  writeLocalJson(root, agentPaths.lock, lock);
30867
30913
  return () => {
30868
- const cur = readJsonFile(path100.join(root, agentPaths.lock));
30869
- 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 });
30870
30916
  };
30871
30917
  }
30872
30918
  function readLookoutLock(root) {
30873
- const lock = readJsonFile(path100.join(root, agentPaths.lock));
30919
+ const lock = readJsonFile(path101.join(root, agentPaths.lock));
30874
30920
  return lock && processAlive(lock.pid) ? lock : void 0;
30875
30921
  }
30876
30922
 
30877
30923
  // ../core/src/server/projectsHub.ts
30878
- import path106 from "node:path";
30924
+ import path107 from "node:path";
30879
30925
 
30880
30926
  // ../core/src/projects/elsewhereUrl.ts
30881
- import path102 from "node:path";
30927
+ import path103 from "node:path";
30882
30928
 
30883
30929
  // ../core/src/projects/projectId.ts
30884
30930
  import { createHash as createHash12 } from "node:crypto";
30885
30931
  import { realpathSync as realpathSync16 } from "node:fs";
30886
- import path101 from "node:path";
30932
+ import path102 from "node:path";
30887
30933
  function realRoot(root) {
30888
30934
  try {
30889
30935
  return realpathSync16.native(root);
30890
30936
  } catch {
30891
- return path101.resolve(root);
30937
+ return path102.resolve(root);
30892
30938
  }
30893
30939
  }
30894
30940
  function projectId(root) {
@@ -30913,7 +30959,7 @@ async function answersFor(url2, root, fetcher) {
30913
30959
  }
30914
30960
  }
30915
30961
  function signedLock(root, url2) {
30916
- const lock = readJsonFile(path102.join(root, agentPaths.lock));
30962
+ const lock = readJsonFile(path103.join(root, agentPaths.lock));
30917
30963
  return !!lock && lock.url === url2 && announcementSigned(root, LOCK_SIG, [lock.url, lock.pid, lock.startedAt], lock.sig);
30918
30964
  }
30919
30965
  async function verifiedElsewhere(root, state, fetcher = fetch) {
@@ -30929,9 +30975,9 @@ ${url2}`;
30929
30975
  }
30930
30976
 
30931
30977
  // ../core/src/projects/fileAdapter.ts
30932
- import { existsSync as existsSync33 } from "node:fs";
30978
+ import { existsSync as existsSync34 } from "node:fs";
30933
30979
  function fileAdapter(root, configDir2) {
30934
- if (!existsSync33(root)) return void 0;
30980
+ if (!existsSync34(root)) return void 0;
30935
30981
  if (trackerPin(root, configDir2).read().config.active !== "markdown") return void 0;
30936
30982
  return new MarkdownAdapter({ ...nodeMarkdownFs(root), watch: void 0 }, root);
30937
30983
  }
@@ -31015,18 +31061,18 @@ var ProjectBridges = class {
31015
31061
  };
31016
31062
 
31017
31063
  // ../core/src/projects/projectName.ts
31018
- import path103 from "node:path";
31064
+ import path104 from "node:path";
31019
31065
  function repoOfRoot(root) {
31020
- const abs = path103.resolve(root);
31021
- 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;
31022
31068
  }
31023
31069
  function projectName(root) {
31024
- return path103.basename(repoOfRoot(root)) || "repo";
31070
+ return path104.basename(repoOfRoot(root)) || "repo";
31025
31071
  }
31026
31072
 
31027
31073
  // ../core/src/projects/projectsFile.ts
31028
- import path104 from "node:path";
31029
- var projectsPath = (configDir2) => path104.join(configDir2, PROJECTS_FILE);
31074
+ import path105 from "node:path";
31075
+ var projectsPath = (configDir2) => path105.join(configDir2, PROJECTS_FILE);
31030
31076
  var EMPTY2 = { v: 1, projects: [], autoRegister: true };
31031
31077
  function validEntry(e) {
31032
31078
  if (!e || typeof e !== "object") return false;
@@ -31065,9 +31111,9 @@ function projectEntries(configDir2, homeRoot) {
31065
31111
  }
31066
31112
 
31067
31113
  // ../core/src/projects/projectState.ts
31068
- import { existsSync as existsSync34 } from "node:fs";
31114
+ import { existsSync as existsSync35 } from "node:fs";
31069
31115
  function projectState(root, pid = process.pid) {
31070
- if (!existsSync34(root)) return { kind: "missing" };
31116
+ if (!existsSync35(root)) return { kind: "missing" };
31071
31117
  const lock = readLookoutLock(root);
31072
31118
  if (lock && lock.pid !== pid)
31073
31119
  return isLoopbackLookoutUrl(lock.url) ? { kind: "elsewhere", url: lock.url } : { kind: "elsewhere" };
@@ -31179,10 +31225,10 @@ import os4 from "node:os";
31179
31225
 
31180
31226
  // ../core/src/evidence/gitConfigValue.ts
31181
31227
  import { spawnSync } from "node:child_process";
31182
- import { existsSync as existsSync35 } from "node:fs";
31228
+ import { existsSync as existsSync36 } from "node:fs";
31183
31229
  function gitConfigValue(cwd, key) {
31184
31230
  const r = spawnSync("git", ["config", "--get", "--end-of-options", key], {
31185
- cwd: existsSync35(cwd) ? cwd : void 0,
31231
+ cwd: existsSync36(cwd) ? cwd : void 0,
31186
31232
  encoding: "utf8",
31187
31233
  timeout: 2e3,
31188
31234
  stdio: ["ignore", "pipe", "ignore"],
@@ -31222,16 +31268,16 @@ async function projectBriefing(input2) {
31222
31268
  }
31223
31269
 
31224
31270
  // ../core/src/projects/registerProject.ts
31225
- import { existsSync as existsSync36, mkdirSync as mkdirSync32, statSync as statSync13 } from "node:fs";
31226
- 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";
31227
31273
  var ProjectPathError = class extends Error {
31228
31274
  };
31229
31275
  function trackerRootFor(input2, opts = {}) {
31230
- const abs = path105.resolve(input2);
31231
- if (!existsSync36(abs) || !statSync13(abs).isDirectory()) throw new ProjectPathError(`no folder at ${abs}`);
31232
- if (path105.basename(abs) === BRAND.dataDir || existsSync36(path105.join(abs, "trackers.json"))) return realRoot(abs);
31233
- const root = path105.join(abs, BRAND.dataDir);
31234
- 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 });
31235
31281
  return realRoot(root);
31236
31282
  }
31237
31283
  function registerProject(input2) {
@@ -31639,7 +31685,7 @@ data: ${sig}
31639
31685
  function checkPath(root, url2) {
31640
31686
  const p = url2.searchParams.get("path");
31641
31687
  if (p === null) return;
31642
- 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");
31643
31689
  }
31644
31690
  function createProjectsHub(o) {
31645
31691
  const configDir2 = o.configDir ?? configDir();
@@ -31948,7 +31994,7 @@ function streamTickets(now2) {
31948
31994
  }
31949
31995
 
31950
31996
  // ../core/src/signIn/sweepSignInRedirects.ts
31951
- 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";
31952
31998
 
31953
31999
  // ../core/src/signIn/signInRedirectFile.ts
31954
32000
  import { randomBytes as randomBytes12 } from "node:crypto";
@@ -31969,7 +32015,7 @@ function sweepSignInRedirects(at2) {
31969
32015
  const store = machineStore(at2.root, at2.configDir);
31970
32016
  let names;
31971
32017
  try {
31972
- 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));
31973
32019
  } catch {
31974
32020
  return;
31975
32021
  }
@@ -32218,7 +32264,7 @@ function verifyProofText(o) {
32218
32264
  }
32219
32265
 
32220
32266
  // ../core/src/proof/proofKeysAt.ts
32221
- import path107 from "node:path";
32267
+ import path108 from "node:path";
32222
32268
 
32223
32269
  // ../core/src/proof/parseProofKeys.ts
32224
32270
  var LINE2 = /^ed25519\s+([A-Za-z0-9+/]+={0,2})(?:\s|$)/;
@@ -32238,7 +32284,7 @@ async function proofKeysAt(root, ref2) {
32238
32284
  if (ref2.startsWith("-")) return /* @__PURE__ */ new Map();
32239
32285
  const top = await gitText(root, ["rev-parse", "--show-toplevel"]);
32240
32286
  if (!top) return /* @__PURE__ */ new Map();
32241
- 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("/");
32242
32288
  const listing = await gitText(top, ["ls-tree", "--name-only", "--end-of-options", `${ref2}:${rel}`]);
32243
32289
  const names = (listing ?? "").split("\n").filter((n) => n.endsWith(".pub"));
32244
32290
  const texts2 = await Promise.all(names.map((n) => gitText(top, ["show", "--end-of-options", `${ref2}:${rel}/${n}`])));
@@ -32470,11 +32516,11 @@ function ttyIo() {
32470
32516
  }
32471
32517
 
32472
32518
  // src/approve/runApprove.ts
32473
- import path112 from "node:path";
32519
+ import path113 from "node:path";
32474
32520
 
32475
32521
  // ../core/src/agents/agentDocWriter.ts
32476
32522
  import { rmSync as rmSync24 } from "node:fs";
32477
- import path108 from "node:path";
32523
+ import path109 from "node:path";
32478
32524
  var teamtrailVersion = () => {
32479
32525
  const v = runningVersion();
32480
32526
  return v ? { teamtrail: v } : {};
@@ -32541,7 +32587,7 @@ var AgentDocWriter = class {
32541
32587
  */
32542
32588
  pullAnswers() {
32543
32589
  for (const q of this.activity.snapshot.pending) {
32544
- 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));
32545
32591
  const ans = readJsonFile(file9);
32546
32592
  if (ans) this.take(file9, ans, q);
32547
32593
  }
@@ -32603,17 +32649,17 @@ var AgentDocWriter = class {
32603
32649
 
32604
32650
  // ../core/src/agents/trailNameClaim.ts
32605
32651
  import fs3 from "node:fs";
32606
- import path109 from "node:path";
32652
+ import path110 from "node:path";
32607
32653
  var TRAIL_NAMES_DIR = "trailNames";
32608
32654
  var name = (family, n) => `${family}-${String(n).padStart(2, "0")}`;
32609
- function claimTrailName(root, family, taken = /* @__PURE__ */ new Set(), holder) {
32610
- const dir4 = path109.join(root, AGENTS_DIR, TRAIL_NAMES_DIR);
32611
- 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));
32612
32658
  fs3.mkdirSync(dir4, { recursive: true });
32613
32659
  for (let n = 1; ; n++) {
32614
32660
  const trailName = name(family, n);
32615
- if (taken.has(trailName)) continue;
32616
- const file9 = path109.join(dir4, `${trailName}.json`);
32661
+ if (taken2.has(trailName)) continue;
32662
+ const file9 = path110.join(dir4, `${trailName}.json`);
32617
32663
  try {
32618
32664
  fs3.writeFileSync(file9, JSON.stringify({ pid: process.pid, holder, at: Date.now() }), { flag: "wx" });
32619
32665
  } catch (e) {
@@ -32639,7 +32685,7 @@ function readLock(file9) {
32639
32685
  }
32640
32686
  }
32641
32687
  function releaseTrailName(root, trailName, holder) {
32642
- 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`);
32643
32689
  const lock = readLock(file9);
32644
32690
  if (lock?.pid === process.pid && lock.holder === holder) fs3.rmSync(file9, { force: true });
32645
32691
  }
@@ -32655,9 +32701,9 @@ function repoRootSpellings(repoRoot) {
32655
32701
  }
32656
32702
 
32657
32703
  // ../core/src/agents/chartedStore.ts
32658
- import path110 from "node:path";
32704
+ import path111 from "node:path";
32659
32705
  var safe17 = (s) => s.replace(/[^\w.-]/g, "_");
32660
- 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`);
32661
32707
  var read3 = (root, mapId) => {
32662
32708
  const f = readJsonFile(file7(root, mapId));
32663
32709
  return f?.v === 1 && f.tickets && typeof f.tickets === "object" ? f.tickets : {};
@@ -32858,8 +32904,8 @@ async function moveReviewed(m) {
32858
32904
  }
32859
32905
 
32860
32906
  // ../core/src/workspaces/prepareWorktree.ts
32861
- import { existsSync as existsSync37 } from "node:fs";
32862
- import path111 from "node:path";
32907
+ import { existsSync as existsSync38 } from "node:fs";
32908
+ import path112 from "node:path";
32863
32909
  var slugOf = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 40) || "trail";
32864
32910
  function worktreeLocation(top, settings2, mapId, key) {
32865
32911
  const slug2 = slugOf(mapId);
@@ -32869,7 +32915,7 @@ function worktreeLocation(top, settings2, mapId, key) {
32869
32915
  return { note: `No workspace: ticket id ${JSON.stringify(key)} can't name a branch. Work in the repo.` };
32870
32916
  const where2 = worktreeDir(top, settings2.dir);
32871
32917
  if ("refused" in where2) return { note: `No workspace: ${where2.refused} Work in the repo.` };
32872
- return { branch: branch2, path: path111.join(where2.dir, `${slug2}-${n}`) };
32918
+ return { branch: branch2, path: path112.join(where2.dir, `${slug2}-${n}`) };
32873
32919
  }
32874
32920
  async function prepareWorktree(i) {
32875
32921
  const known4 = trustedWorkspace(i.root, i.mapId, i.ticket.id);
@@ -32895,7 +32941,7 @@ async function prepareWorktree(i) {
32895
32941
  return made;
32896
32942
  }
32897
32943
  async function addWorktree(top, where2, head) {
32898
- if (existsSync37(where2.path)) {
32944
+ if (existsSync38(where2.path)) {
32899
32945
  const onBranch = await gitText(where2.path, ["rev-parse", "--abbrev-ref", "HEAD"]);
32900
32946
  if (onBranch === where2.branch) return { workspace: { ...where2, base: await baseOf(where2.path, head) } };
32901
32947
  return { note: `No workspace: ${where2.path} already exists and isn't on ${where2.branch}. Work in the repo.` };
@@ -32961,7 +33007,7 @@ async function findCatalogGuide(input2) {
32961
33007
  }
32962
33008
 
32963
33009
  // ../core/src/guides/newGuide.ts
32964
- 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";
32965
33011
  var ID_RE2 = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
32966
33012
  var nameOf3 = (id) => {
32967
33013
  const words7 = id.split("-").join(" ");
@@ -32999,7 +33045,7 @@ function newGuide(input2) {
32999
33045
  `${input2.id} is a built-in guide; pick another id (a file named ${input2.id}.md replaces it)`
33000
33046
  );
33001
33047
  const file9 = guideFilePath(input2.root, input2.id);
33002
- if (existsSync38(file9)) throw new OperationError(`${file9} already exists`);
33048
+ if (existsSync39(file9)) throw new OperationError(`${file9} already exists`);
33003
33049
  const text11 = guideTemplate(input2);
33004
33050
  mkdirSync35(guidesDir(input2.root), { recursive: true });
33005
33051
  writeFileSync24(file9, text11);
@@ -33049,7 +33095,7 @@ function byHash(input2, items) {
33049
33095
  }
33050
33096
  async function runApprove(input2) {
33051
33097
  const committed2 = await withCommitted(input2.root, pendingTrust(input2.root, input2.snaps));
33052
- const items = await withScreening(committed2, localRepoFiles(path112.dirname(input2.root)));
33098
+ const items = await withScreening(committed2, localRepoFiles(path113.dirname(input2.root)));
33053
33099
  if (!items.length)
33054
33100
  return input2.io.out("\n Nothing waiting: everything the repo asks for is approved here.\n\n"), 0;
33055
33101
  for (const item2 of items) input2.io.out(showItem(item2));
@@ -33094,7 +33140,7 @@ async function snapsOf2(root) {
33094
33140
  }
33095
33141
  async function approveCli(argv2) {
33096
33142
  const o = parse(argv2);
33097
- const root = path113.resolve(process.cwd(), o.dir);
33143
+ const root = path114.resolve(process.cwd(), o.dir);
33098
33144
  process.exitCode = await runApprove({ root, io: ttyIo(), hashes: o.hashes, snaps: await snapsOf2(root) });
33099
33145
  }
33100
33146
 
@@ -33127,7 +33173,7 @@ function parseArgs(argv2) {
33127
33173
  process.exit(0);
33128
33174
  case "-v":
33129
33175
  case "--version":
33130
- process.stdout.write(`${"0.64.1"}
33176
+ process.stdout.write(`${"0.64.2"}
33131
33177
  `);
33132
33178
  process.exit(0);
33133
33179
  case "--no-open":
@@ -33192,33 +33238,33 @@ function parseSubArgs(argv2, allowed2) {
33192
33238
  // src/connect.ts
33193
33239
  import { spawnSync as spawnSync3 } from "node:child_process";
33194
33240
  import os8 from "node:os";
33195
- import path124 from "node:path";
33241
+ import path125 from "node:path";
33196
33242
 
33197
33243
  // commands/scout.md
33198
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";
33199
33245
 
33200
33246
  // src/files.ts
33201
33247
  import fs4 from "node:fs";
33202
- import path114 from "node:path";
33248
+ import path115 from "node:path";
33203
33249
  function writeIfChanged(file9, text11) {
33204
33250
  const prev = fs4.existsSync(file9) ? fs4.readFileSync(file9, "utf8") : void 0;
33205
33251
  if (prev === text11) return "unchanged";
33206
- fs4.mkdirSync(path114.dirname(file9), { recursive: true });
33252
+ fs4.mkdirSync(path115.dirname(file9), { recursive: true });
33207
33253
  fs4.writeFileSync(file9, text11);
33208
33254
  return prev === void 0 ? "added" : "updated";
33209
33255
  }
33210
33256
 
33211
33257
  // src/protect/claudeLocalSettings.ts
33212
- import path115 from "node:path";
33213
- 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");
33214
33260
 
33215
33261
  // src/protect/claudeSandboxState.ts
33216
- import path117 from "node:path";
33262
+ import path118 from "node:path";
33217
33263
 
33218
33264
  // src/protect/claudeSettingsFile.ts
33219
33265
  import os5 from "node:os";
33220
- import path116 from "node:path";
33221
- 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");
33222
33268
 
33223
33269
  // src/protect/readSettings.ts
33224
33270
  import fs5 from "node:fs";
@@ -33241,7 +33287,7 @@ function enabledIn(file9) {
33241
33287
  return typeof enabled === "boolean" ? enabled : void 0;
33242
33288
  }
33243
33289
  function claudeSandboxState(cwd, env = process.env) {
33244
- 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)];
33245
33291
  for (const file9 of files) {
33246
33292
  const enabled = enabledIn(file9);
33247
33293
  if (enabled === void 0) continue;
@@ -33252,7 +33298,7 @@ function claudeSandboxState(cwd, env = process.env) {
33252
33298
 
33253
33299
  // src/protect/writeSettings.ts
33254
33300
  import fs6 from "node:fs";
33255
- import path118 from "node:path";
33301
+ import path119 from "node:path";
33256
33302
  function indentOf(text11) {
33257
33303
  const m = text11?.match(/^[{[][^\n]*\n([ \t]+)\S/);
33258
33304
  return m ? m[1] : 2;
@@ -33261,8 +33307,8 @@ function writeSettings(file9, settings2) {
33261
33307
  const target2 = fs6.existsSync(file9) ? fs6.realpathSync(file9) : file9;
33262
33308
  const before = fs6.existsSync(target2) ? fs6.readFileSync(target2, "utf8") : void 0;
33263
33309
  const mode = before === void 0 ? void 0 : fs6.statSync(target2).mode & 511;
33264
- fs6.mkdirSync(path118.dirname(target2), { recursive: true });
33265
- 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`);
33266
33312
  try {
33267
33313
  fs6.writeFileSync(temp, `${JSON.stringify(settings2, null, indentOf(before))}
33268
33314
  `, { mode: mode ?? 420 });
@@ -33299,7 +33345,7 @@ function applySandbox(o) {
33299
33345
 
33300
33346
  // src/protect/protectConfig.ts
33301
33347
  import os7 from "node:os";
33302
- import path121 from "node:path";
33348
+ import path122 from "node:path";
33303
33349
 
33304
33350
  // src/protect/claudeProtectionLines.ts
33305
33351
  var PAD = " ";
@@ -33337,10 +33383,10 @@ function claudeProtectionLines(p, dirs2) {
33337
33383
  }
33338
33384
 
33339
33385
  // src/protect/codexProtectionLines.ts
33340
- import path119 from "node:path";
33386
+ import path120 from "node:path";
33341
33387
  var PAD2 = " ";
33342
33388
  function codexProtectionLines(dirs2, codexHome) {
33343
- const config4 = path119.join(codexHome, "config.toml");
33389
+ const config4 = path120.join(codexHome, "config.toml");
33344
33390
  return [
33345
33391
  ` Config folder readable by Codex's commands: ${dirs2.join(" and ")} (this machine's key, approvals, credentials).`,
33346
33392
  `${PAD2}Its default sandbox (workspace-write) keeps its commands' writes inside the repo, so not there: leave it on.`,
@@ -33414,21 +33460,21 @@ function protectClaude(file9, dirs2) {
33414
33460
  // src/protect/protectedDirs.ts
33415
33461
  import fs7 from "node:fs";
33416
33462
  import os6 from "node:os";
33417
- import path120 from "node:path";
33463
+ import path121 from "node:path";
33418
33464
  function realOf(p) {
33419
33465
  const rest = [];
33420
- for (let cur = p; ; cur = path120.dirname(cur)) {
33466
+ for (let cur = p; ; cur = path121.dirname(cur)) {
33421
33467
  try {
33422
- return path120.join(fs7.realpathSync(cur), ...rest.reverse());
33468
+ return path121.join(fs7.realpathSync(cur), ...rest.reverse());
33423
33469
  } catch {
33424
- if (path120.dirname(cur) === cur) return p;
33425
- rest.push(path120.basename(cur));
33470
+ if (path121.dirname(cur) === cur) return p;
33471
+ rest.push(path121.basename(cur));
33426
33472
  }
33427
33473
  }
33428
33474
  }
33429
33475
  function protectedDirs(dir4 = configDir()) {
33430
- const named4 = path120.resolve(dir4);
33431
- 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);
33432
33478
  return [.../* @__PURE__ */ new Set([named4, realOf(named4), fallback, realOf(fallback)])];
33433
33479
  }
33434
33480
 
@@ -33446,7 +33492,7 @@ function protectConfig(target2, o) {
33446
33492
  return void 0;
33447
33493
  }
33448
33494
  if (target2 === "codex") {
33449
- 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);
33450
33496
  return false;
33451
33497
  }
33452
33498
  const done2 = protectClaude(claudeSettingsFile(), dirs2);
@@ -33455,7 +33501,7 @@ function protectConfig(target2, o) {
33455
33501
  }
33456
33502
 
33457
33503
  // src/protect/sandboxLines.ts
33458
- import path122 from "node:path";
33504
+ import path123 from "node:path";
33459
33505
  var PAD3 = " ";
33460
33506
  var LINUX = `${PAD3}On Linux it needs bubblewrap and socat (e.g. apt install bubblewrap socat); without them commands run unsandboxed.`;
33461
33507
  var LEFT = {
@@ -33465,8 +33511,8 @@ var LEFT = {
33465
33511
  };
33466
33512
  function sandboxLines(o) {
33467
33513
  const r = o.result;
33468
- const relative = path122.relative(o.cwd, r.file);
33469
- const outside = relative.startsWith("..") || path122.isAbsolute(relative);
33514
+ const relative = path123.relative(o.cwd, r.file);
33515
+ const outside = relative.startsWith("..") || path123.isAbsolute(relative);
33470
33516
  const shown3 = outside ? r.file : relative;
33471
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)";
33472
33518
  const turnOn = `${PAD3}To turn it on: connect claude --sandbox, or set "sandbox": { "enabled": true } in ${shown3}.`;
@@ -33496,7 +33542,7 @@ function sandboxLines(o) {
33496
33542
 
33497
33543
  // src/usage/hook.ts
33498
33544
  import fs8 from "node:fs";
33499
- import path123 from "node:path";
33545
+ import path124 from "node:path";
33500
33546
  function recordClaudeSession(input2, opts) {
33501
33547
  let p;
33502
33548
  try {
@@ -33507,7 +33553,7 @@ function recordClaudeSession(input2, opts) {
33507
33553
  if (!p.session_id || !p.transcript_path) return void 0;
33508
33554
  const env = opts.env ?? process.env;
33509
33555
  const project = env.CLAUDE_PROJECT_DIR || p.cwd || opts.cwd || process.cwd();
33510
- const root = path123.resolve(project, opts.dir);
33556
+ const root = path124.resolve(project, opts.dir);
33511
33557
  const link = {
33512
33558
  agent: "claude-code",
33513
33559
  hostSessionId: p.session_id,
@@ -33518,7 +33564,7 @@ function recordClaudeSession(input2, opts) {
33518
33564
  };
33519
33565
  const rel = agentPaths.host("claude-code", p.session_id);
33520
33566
  writeLocalJson(root, rel, link);
33521
- return path123.join(root, rel);
33567
+ return path124.join(root, rel);
33522
33568
  }
33523
33569
  async function readStdin(timeoutMs = 5e3) {
33524
33570
  if (process.stdin.isTTY) return "";
@@ -33579,7 +33625,7 @@ function runConnect(target2, opts) {
33579
33625
  `));
33580
33626
  const project = autoRegister({
33581
33627
  configDir: configDir(),
33582
- root: path124.resolve(opts.cwd, opts.dir ?? BRAND.dataDir),
33628
+ root: path125.resolve(opts.cwd, opts.dir ?? BRAND.dataDir),
33583
33629
  optOut: opts.noRegister
33584
33630
  });
33585
33631
  if (project) print(` Project ${project.name} \xB7 listed in the Lookout's All projects (${project.id})`);
@@ -33611,27 +33657,27 @@ function registerClaude(o, server) {
33611
33657
  return `not updated (${again.out || `exit ${again.status}`}). Run: claude mcp remove ${BRAND.slug}, then ${shown3}`;
33612
33658
  }
33613
33659
  function connectClaude(o) {
33614
- const file9 = path124.join(o.cwd, ".claude", "commands", "scout.md");
33615
- o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path124.relative(o.cwd, file9)}`);
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)}`);
33616
33662
  o.print(` MCP server ${registerClaude(o, serverCommand(o.self, o.dir))}`);
33617
33663
  const settings2 = claudeLocalSettings(o.cwd);
33618
33664
  o.print(
33619
- ` 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)`
33620
33666
  );
33621
33667
  }
33622
33668
  function connectCodex(o) {
33623
- const home = process.env.CODEX_HOME || path124.join(os8.homedir(), ".codex");
33624
- 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");
33625
33671
  o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33626
33672
  const [command, ...args] = serverCommand(o.self, o.dir);
33627
33673
  const env = process.env.CODEX_HOME ? ["--env", `CODEX_HOME=${process.env.CODEX_HOME}`] : [];
33628
33674
  const r = o.run("codex", ["mcp", "add", BRAND.slug, ...env, "--", command, ...args]);
33629
- const config4 = path124.join(home, "config.toml");
33675
+ const config4 = path125.join(home, "config.toml");
33630
33676
  if (r.missing) o.print(` MCP server Codex not found on PATH. Add this to ${config4}:`);
33631
33677
  else if (r.status === 0)
33632
33678
  o.print(` MCP server registered \xB7 codex mcp add ${BRAND.slug} -- ${shellLine([command, ...args])}`);
33633
33679
  else o.print(` MCP server not registered. Add it to ${config4} (below).`);
33634
- 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)`);
33635
33681
  o.print(
33636
33682
  `
33637
33683
  [mcp_servers.${BRAND.slug}]
@@ -33645,7 +33691,7 @@ function connectCodex(o) {
33645
33691
  // src/connectRemote.ts
33646
33692
  import { spawnSync as spawnSync4 } from "node:child_process";
33647
33693
  import os9 from "node:os";
33648
- import path125 from "node:path";
33694
+ import path126 from "node:path";
33649
33695
 
33650
33696
  // src/probeEndpoint.ts
33651
33697
  var INITIALIZE = {
@@ -33732,8 +33778,8 @@ function connectClaude2(o) {
33732
33778
  fail(
33733
33779
  `Claude Code keeps the token in its config, so connect needs it: --token-stdin, $${BRAND.tokenEnv} or --token`
33734
33780
  );
33735
- const file9 = path125.join(o.cwd, ".claude", "commands", "scout.md");
33736
- o.print(` /scout command ${writeIfChanged(file9, scout_default)} \xB7 ${path125.relative(o.cwd, file9)}`);
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)}`);
33737
33783
  const shown3 = `claude mcp add --transport http ${BRAND.slug} ${o.url} --header "Authorization: Bearer $${BRAND.tokenEnv}"`;
33738
33784
  const add3 = ["mcp", "add", "--transport", "http", BRAND.slug, o.url, "--header", `Authorization: Bearer ${o.token}`];
33739
33785
  const r = (o.run ?? runCli2)("claude", add3);
@@ -33752,12 +33798,12 @@ function connectClaude2(o) {
33752
33798
  In Claude Code: /scout new "<idea>", /scout resume, /scout status, /scout inbox`);
33753
33799
  }
33754
33800
  function connectCodex2(o) {
33755
- const home = process.env.CODEX_HOME || path125.join(os9.homedir(), ".codex");
33756
- 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");
33757
33803
  o.print(` /scout prompt ${writeIfChanged(file9, scout_default)} \xB7 ${file9}`);
33758
33804
  const args = ["mcp", "add", BRAND.slug, "--url", o.url, "--bearer-token-env-var", BRAND.tokenEnv];
33759
33805
  const r = (o.run ?? runCli2)("codex", args);
33760
- const config4 = path125.join(home, "config.toml");
33806
+ const config4 = path126.join(home, "config.toml");
33761
33807
  if (r.missing) o.print(` MCP server Codex not found on PATH. Add this to ${config4}:`);
33762
33808
  else if (r.status === 0) o.print(` MCP server registered \xB7 codex ${args.join(" ")}`);
33763
33809
  else o.print(` MCP server not registered (exit ${r.status}). Add it to ${config4} (below).`);
@@ -33786,11 +33832,11 @@ async function connectToken(o) {
33786
33832
  }
33787
33833
 
33788
33834
  // src/guides/guidesCommand.ts
33789
- import path132 from "node:path";
33835
+ import path133 from "node:path";
33790
33836
 
33791
33837
  // src/guides/guidesAdd.ts
33792
- import { existsSync as existsSync39, readFileSync as readFileSync34 } from "node:fs";
33793
- import path126 from "node:path";
33838
+ import { existsSync as existsSync40, readFileSync as readFileSync34 } from "node:fs";
33839
+ import path127 from "node:path";
33794
33840
 
33795
33841
  // src/guides/argvLine.ts
33796
33842
  function argvLine(spec) {
@@ -33938,17 +33984,17 @@ async function installText(input2) {
33938
33984
  }
33939
33985
 
33940
33986
  // src/guides/guidesAdd.ts
33941
- var isFile = (ref2) => ref2.endsWith(".md") || existsSync39(path126.resolve(ref2));
33987
+ var isFile = (ref2) => ref2.endsWith(".md") || existsSync40(path127.resolve(ref2));
33942
33988
  async function guidesAdd(a, io) {
33943
33989
  const ref2 = a.rest[0];
33944
33990
  if (!ref2) {
33945
33991
  io.err("usage: guides add <id>|<catalog/id>|<file.md> [--registry <name>] [--sha256 <hash>] [--approve-checks]\n");
33946
33992
  return 2;
33947
33993
  }
33948
- const root = path126.resolve(a.dir);
33994
+ const root = path127.resolve(a.dir);
33949
33995
  const common = { root, io, approveAll: a.approveChecks, ...a.sha256 ? { sha256: a.sha256 } : {} };
33950
33996
  if (isFile(ref2)) {
33951
- const text12 = readFileSync34(path126.resolve(ref2), "utf8");
33997
+ const text12 = readFileSync34(path127.resolve(ref2), "utf8");
33952
33998
  return installText({ ...common, text: text12, source: "local", where: ref2 });
33953
33999
  }
33954
34000
  const { registries } = readGuidesConfig(root).config;
@@ -33995,30 +34041,30 @@ function parseGuidesArgs(argv2) {
33995
34041
  }
33996
34042
 
33997
34043
  // src/guides/guidesLint.ts
33998
- import { existsSync as existsSync40, readdirSync as readdirSync26, readFileSync as readFileSync35, statSync as statSync16 } from "node:fs";
33999
- import path127 from "node:path";
34000
- 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"));
34001
34047
  function targetsOf(p, trackerDir) {
34002
34048
  if (!statSync16(p).isDirectory()) {
34003
- const top = path127.dirname(path127.dirname(p));
34004
- 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);
34005
34051
  return [{ file: p, ...inCatalog ? { catalog: top } : {} }];
34006
34052
  }
34007
- const guides = path127.join(p, "guides");
34008
- const dir4 = existsSync40(guides) ? guides : p;
34053
+ const guides = path128.join(p, "guides");
34054
+ const dir4 = existsSync41(guides) ? guides : p;
34009
34055
  const catalog = isTracker(p, trackerDir) ? {} : { catalog: p };
34010
- 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 }));
34011
34057
  }
34012
34058
  var hasExample = (catalog, id) => {
34013
- const dir4 = path127.join(catalog, "examples", id);
34014
- return existsSync40(dir4) && readdirSync26(dir4).length > 0;
34059
+ const dir4 = path128.join(catalog, "examples", id);
34060
+ return existsSync41(dir4) && readdirSync27(dir4).length > 0;
34015
34061
  };
34016
34062
  function lintTarget(t) {
34017
34063
  const text11 = readFileSync35(t.file, "utf8");
34018
34064
  const lint = lintGuide(text11);
34019
- const id = lint.guide?.id ?? path127.basename(t.file, ".md");
34065
+ const id = lint.guide?.id ?? path128.basename(t.file, ".md");
34020
34066
  const extra = [];
34021
- if (lint.guide && lint.guide.id !== path127.basename(t.file, ".md"))
34067
+ if (lint.guide && lint.guide.id !== path128.basename(t.file, ".md"))
34022
34068
  extra.push({ line: 3, rule: "schema", level: "error", message: `id "${id}" must match the file name` });
34023
34069
  if (t.catalog && !hasExample(t.catalog, id))
34024
34070
  extra.push({ line: 1, rule: "example", level: "error", message: `no test example in examples/${id}/` });
@@ -34038,13 +34084,13 @@ function lintTarget(t) {
34038
34084
  };
34039
34085
  }
34040
34086
  function guidesLint(a, io) {
34041
- const fallback = existsSync40(path127.join(a.dir, "guides")) ? a.dir : ".";
34042
- 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));
34043
34089
  const results = targets.map(lintTarget);
34044
34090
  if (a.json) io.out(`${JSON.stringify(results, null, 2)}
34045
34091
  `);
34046
34092
  else {
34047
- 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);
34048
34094
  const bad = results.filter((r) => !r.ok).length;
34049
34095
  io.out(`${results.length} guides linted, ${bad ? `${bad} with errors` : "all clean"}
34050
34096
  `);
@@ -34055,9 +34101,9 @@ function guidesLint(a, io) {
34055
34101
  }
34056
34102
 
34057
34103
  // src/guides/guidesList.ts
34058
- import path128 from "node:path";
34104
+ import path129 from "node:path";
34059
34105
  function guidesList(a, io) {
34060
- const guides = listGuides(path128.resolve(a.dir));
34106
+ const guides = listGuides(path129.resolve(a.dir));
34061
34107
  if (a.json) {
34062
34108
  io.out(`${JSON.stringify(guides, null, 2)}
34063
34109
  `);
@@ -34079,7 +34125,7 @@ function originOf(origin, fromCatalog) {
34079
34125
  }
34080
34126
 
34081
34127
  // src/guides/guidesNew.ts
34082
- import path129 from "node:path";
34128
+ import path130 from "node:path";
34083
34129
  var gitName = (cwd) => gitConfigValue(cwd, "user.name") ?? "";
34084
34130
  function guidesNew(a, io) {
34085
34131
  const id = a.rest[0];
@@ -34087,10 +34133,10 @@ function guidesNew(a, io) {
34087
34133
  io.err("usage: guides new <id>\n");
34088
34134
  return 2;
34089
34135
  }
34090
- const root = path129.resolve(a.dir);
34091
- const author = a.author ?? gitName(path129.dirname(root));
34136
+ const root = path130.resolve(a.dir);
34137
+ const author = a.author ?? gitName(path130.dirname(root));
34092
34138
  const { file: file9, lint } = newGuide({ root, id, author });
34093
- const shown3 = path129.relative(process.cwd(), file9) || file9;
34139
+ const shown3 = path130.relative(process.cwd(), file9) || file9;
34094
34140
  printFindings(io, shown3, lint.findings);
34095
34141
  io.out(
34096
34142
  [
@@ -34109,7 +34155,7 @@ function guidesNew(a, io) {
34109
34155
  }
34110
34156
 
34111
34157
  // src/guides/guidesSearch.ts
34112
- import path130 from "node:path";
34158
+ import path131 from "node:path";
34113
34159
 
34114
34160
  // src/guides/hostOf.ts
34115
34161
  function hostOf2(url2) {
@@ -34135,7 +34181,7 @@ function registryForUrl(root, url2) {
34135
34181
 
34136
34182
  // src/guides/guidesSearch.ts
34137
34183
  async function guidesSearch(a, io) {
34138
- const root = path130.resolve(a.dir);
34184
+ const root = path131.resolve(a.dir);
34139
34185
  let found = 0;
34140
34186
  for (const registry3 of pickRegistries(root, a.registry)) {
34141
34187
  const index = await fetchCatalog(registry3, { fetch: io.fetch });
@@ -34161,7 +34207,7 @@ function badgeOf(e, url2) {
34161
34207
 
34162
34208
  // src/guides/guidesUpdate.ts
34163
34209
  import { readFileSync as readFileSync36 } from "node:fs";
34164
- import path131 from "node:path";
34210
+ import path132 from "node:path";
34165
34211
 
34166
34212
  // src/guides/updateChanges.ts
34167
34213
  function textChanges(before, after) {
@@ -34241,7 +34287,7 @@ async function updateOne(a, io, id, entry) {
34241
34287
  return installText({ root: a.root, text: text11, source, io, where: where2, expectId: id, approveAll: false, changes: changes2, ...sha256 });
34242
34288
  }
34243
34289
  async function guidesUpdate(a, io) {
34244
- const root = path131.resolve(a.dir);
34290
+ const root = path132.resolve(a.dir);
34245
34291
  const approved = readApprovedLock(root).guides;
34246
34292
  const pinned = readGuideLock(root).guides;
34247
34293
  const ids2 = a.rest.length ? a.rest : Object.keys(approved);
@@ -34268,8 +34314,8 @@ function guidesRemove(a, io) {
34268
34314
  io.err("usage: guides remove <id>\n");
34269
34315
  return 2;
34270
34316
  }
34271
- const r = removeGuide({ root: path132.resolve(a.dir), id });
34272
- 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 });
34273
34319
  io.out(
34274
34320
  `Removed ${id}${r.builtinBack ? "; the built-in guide is back" : ""}. Its approved checks stay in verification.json.
34275
34321
  `
@@ -34316,9 +34362,9 @@ async function guidesCli(argv2) {
34316
34362
 
34317
34363
  // src/knowledgeImport.ts
34318
34364
  import { readFileSync as readFileSync37 } from "node:fs";
34319
- import path133 from "node:path";
34365
+ import path134 from "node:path";
34320
34366
  function importKnowledge(root, file9) {
34321
- const parts2 = splitForImport(readFileSync37(file9, "utf8"), path133.basename(file9));
34367
+ const parts2 = splitForImport(readFileSync37(file9, "utf8"), path134.basename(file9));
34322
34368
  const now2 = Date.now();
34323
34369
  const ids2 = [];
34324
34370
  for (const p of parts2) {
@@ -34354,7 +34400,7 @@ function mcpHttpOptions(o, root) {
34354
34400
  allowHosts: o.allowHosts,
34355
34401
  leaseMinutes: o.leaseMinutes,
34356
34402
  noRegister: o.noRegister,
34357
- version: "0.64.1"
34403
+ version: "0.64.2"
34358
34404
  };
34359
34405
  }
34360
34406
 
@@ -36004,10 +36050,10 @@ function mergeDefs(...defs) {
36004
36050
  function cloneDef(schema) {
36005
36051
  return mergeDefs(schema._zod.def);
36006
36052
  }
36007
- function getElementAtPath(obj2, path148) {
36008
- if (!path148)
36053
+ function getElementAtPath(obj2, path149) {
36054
+ if (!path149)
36009
36055
  return obj2;
36010
- return path148.reduce((acc, key) => acc?.[key], obj2);
36056
+ return path149.reduce((acc, key) => acc?.[key], obj2);
36011
36057
  }
36012
36058
  function promiseAllObject(promisesObj) {
36013
36059
  const keys2 = Object.keys(promisesObj);
@@ -36347,11 +36393,11 @@ function explicitlyAborted(x, startIndex = 0) {
36347
36393
  }
36348
36394
  return false;
36349
36395
  }
36350
- function prefixIssues(path148, issues) {
36396
+ function prefixIssues(path149, issues) {
36351
36397
  return issues.map((iss) => {
36352
36398
  var _a5;
36353
36399
  (_a5 = iss).path ?? (_a5.path = []);
36354
- iss.path.unshift(path148);
36400
+ iss.path.unshift(path149);
36355
36401
  return iss;
36356
36402
  });
36357
36403
  }
@@ -36809,16 +36855,16 @@ function flattenError(error63, mapper = (issue3) => issue3.message) {
36809
36855
  }
36810
36856
  function formatError(error63, mapper = (issue3) => issue3.message) {
36811
36857
  const fieldErrors = { _errors: [] };
36812
- const processError = (error64, path148 = []) => {
36858
+ const processError = (error64, path149 = []) => {
36813
36859
  for (const issue3 of error64.issues) {
36814
36860
  if (issue3.code === "invalid_union" && issue3.errors.length) {
36815
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
36861
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
36816
36862
  } else if (issue3.code === "invalid_key") {
36817
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
36863
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
36818
36864
  } else if (issue3.code === "invalid_element") {
36819
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
36865
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
36820
36866
  } else {
36821
- const fullpath = [...path148, ...issue3.path];
36867
+ const fullpath = [...path149, ...issue3.path];
36822
36868
  if (fullpath.length === 0) {
36823
36869
  fieldErrors._errors.push(mapper(issue3));
36824
36870
  } else {
@@ -44925,10 +44971,10 @@ function mcpHttpListener(mcp) {
44925
44971
 
44926
44972
  // src/mcp/trail/agentContext.ts
44927
44973
  import { randomUUID as randomUUID4 } from "node:crypto";
44928
- import path134 from "node:path";
44974
+ import path135 from "node:path";
44929
44975
 
44930
44976
  // src/ownVersion.ts
44931
- var OWN_VERSION = true ? "0.64.1" : void 0;
44977
+ var OWN_VERSION = true ? "0.64.2" : void 0;
44932
44978
 
44933
44979
  // src/mcp/trail/agentLeases.ts
44934
44980
  var AgentLeases = class {
@@ -45195,18 +45241,18 @@ var AgentContext = class {
45195
45241
  if (this.trailName) return this.trailName;
45196
45242
  if (this.opts.agent) return this.trailName = this.opts.agent;
45197
45243
  const family = trailNameFamily(this.opts.client?.());
45198
- const taken = new Set(
45244
+ const taken2 = new Set(
45199
45245
  (await readAgentDocs(this.root)).filter((d) => d.session.status === "running").map((d) => d.session.agent)
45200
45246
  );
45201
45247
  this.nameHolder = this.opts.remote ? randomUUID4() : void 0;
45202
- return this.trailName = claimTrailName(this.root, family, taken, this.nameHolder);
45248
+ return this.trailName = claimTrailName(this.root, family, taken2, this.nameHolder);
45203
45249
  }
45204
45250
  lookout() {
45205
45251
  const lock = readLookoutLock(this.root);
45206
45252
  const skew = versionSkew({ agentVersion: OWN_VERSION, lookoutVersion: lock?.version });
45207
45253
  return lock ? { running: true, url: lock.url, ...skew ? { versionNote: skew } : {} } : {
45208
45254
  running: false,
45209
- 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.`
45210
45256
  };
45211
45257
  }
45212
45258
  async load(mapId) {
@@ -45364,7 +45410,7 @@ async function proposeKnowledge(ctx, input2) {
45364
45410
  const snap = await ctx.resolveTrail(input2.trail).catch(() => void 0);
45365
45411
  const ticketId = ctx.sessions.current?.info.ticketId;
45366
45412
  const now2 = Date.now();
45367
- const anchors = repoPaths(input2.files, pathRoots(ctx)).map((path148) => ({ path: path148 }));
45413
+ const anchors = repoPaths(input2.files, pathRoots(ctx)).map((path149) => ({ path: path149 }));
45368
45414
  const draft = {
45369
45415
  title: input2.title.trim(),
45370
45416
  body: input2.body.trim(),
@@ -48386,8 +48432,8 @@ function getErrorMap() {
48386
48432
 
48387
48433
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/helpers/parseUtil.js
48388
48434
  var makeIssue = (params) => {
48389
- const { data, path: path148, errorMaps, issueData } = params;
48390
- const fullPath = [...path148, ...issueData.path || []];
48435
+ const { data, path: path149, errorMaps, issueData } = params;
48436
+ const fullPath = [...path149, ...issueData.path || []];
48391
48437
  const fullIssue = {
48392
48438
  ...issueData,
48393
48439
  path: fullPath
@@ -48502,11 +48548,11 @@ var errorUtil;
48502
48548
 
48503
48549
  // ../../node_modules/@modelcontextprotocol/sdk/node_modules/zod/v3/types.js
48504
48550
  var ParseInputLazyPath = class {
48505
- constructor(parent, value, path148, key) {
48551
+ constructor(parent, value, path149, key) {
48506
48552
  this._cachedPath = [];
48507
48553
  this.parent = parent;
48508
48554
  this.data = value;
48509
- this._path = path148;
48555
+ this._path = path149;
48510
48556
  this._key = key;
48511
48557
  }
48512
48558
  get path() {
@@ -52058,11 +52104,11 @@ function normalizeObjectSchema(schema) {
52058
52104
  }
52059
52105
  return void 0;
52060
52106
  }
52061
- function getDotPath(path148) {
52062
- if (path148.length === 0) {
52107
+ function getDotPath(path149) {
52108
+ if (path149.length === 0) {
52063
52109
  return "object root";
52064
52110
  }
52065
- return path148.reduce((acc, seg, index) => {
52111
+ return path149.reduce((acc, seg, index) => {
52066
52112
  if (index === 0) {
52067
52113
  return String(seg);
52068
52114
  }
@@ -56166,11 +56212,11 @@ var StdioServerTransport = class {
56166
56212
 
56167
56213
  // src/usage/meter.ts
56168
56214
  import os11 from "node:os";
56169
- import path136 from "node:path";
56215
+ import path137 from "node:path";
56170
56216
 
56171
56217
  // src/usage/logLocations.ts
56172
56218
  import fs10 from "node:fs";
56173
- import path135 from "node:path";
56219
+ import path136 from "node:path";
56174
56220
 
56175
56221
  // src/usage/quietFs.ts
56176
56222
  import fs9 from "node:fs";
@@ -56217,31 +56263,31 @@ var claudeProjectDirName = (dir4) => dir4.replace(/[^a-zA-Z0-9]/g, "-");
56217
56263
  function claudeCandidates(root, env, cwd, home) {
56218
56264
  const since2 = Date.now() - 2 * DAY2;
56219
56265
  const out = [];
56220
- const links = path135.join(root, agentPaths.hosts);
56266
+ const links = path136.join(root, agentPaths.hosts);
56221
56267
  for (const n of ls(links)) {
56222
56268
  try {
56223
- const l = JSON.parse(fs10.readFileSync(path135.join(links, n), "utf8"));
56269
+ const l = JSON.parse(fs10.readFileSync(path136.join(links, n), "utf8"));
56224
56270
  if (l.agent === "claude-code" && l.at >= since2 && l.transcriptPath) out.push(l.transcriptPath);
56225
56271
  } catch {
56226
56272
  }
56227
56273
  }
56228
- const config4 = env.CLAUDE_CONFIG_DIR || path135.join(home, ".claude");
56229
- const dir4 = path135.join(config4, "projects", claudeProjectDirName(env.CLAUDE_PROJECT_DIR || cwd));
56230
- if (env.CLAUDE_CODE_SESSION_ID) out.push(path135.join(dir4, `${env.CLAUDE_CODE_SESSION_ID}.jsonl`));
56231
- 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);
56232
56278
  return [.../* @__PURE__ */ new Set([...out, ...byAge])].filter((f) => recent(f, since2));
56233
56279
  }
56234
56280
  function findCodexRollout(thread, env, home) {
56235
- 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");
56236
56282
  const desc = (dir4) => ls(dir4).sort().reverse();
56237
56283
  const dayDirs = desc(sessions).flatMap(
56238
- (y) => desc(path135.join(sessions, y)).flatMap(
56239
- (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))
56240
56286
  )
56241
56287
  );
56242
56288
  for (const dir4 of dayDirs.slice(0, 400)) {
56243
56289
  const hit = ls(dir4).find((n) => n.startsWith("rollout-") && n.endsWith(`-${thread}.jsonl`));
56244
- if (hit) return path135.join(dir4, hit);
56290
+ if (hit) return path136.join(dir4, hit);
56245
56291
  }
56246
56292
  return void 0;
56247
56293
  }
@@ -56480,7 +56526,7 @@ var UsageMeter = class {
56480
56526
  }
56481
56527
  poll() {
56482
56528
  for (const [file9, f] of this.files) {
56483
- const own3 = path136.basename(path136.dirname(file9)) !== "subagents";
56529
+ const own3 = path137.basename(path137.dirname(file9)) !== "subagents";
56484
56530
  for (const e of f.read()) {
56485
56531
  if (own3 && e.model && (!this.latest || e.at >= this.latest.at)) this.latest = { at: e.at, model: e.model };
56486
56532
  const prev = this.events.get(e.key);
@@ -56501,9 +56547,9 @@ var UsageMeter = class {
56501
56547
  /** Subagent (Task) transcripts sit next to the main one, under `<session>/subagents/`. */
56502
56548
  attachSubagents() {
56503
56549
  for (const file9 of [...this.files.keys()]) {
56504
- if (path136.basename(path136.dirname(file9)) === "subagents") continue;
56505
- const dir4 = path136.join(file9.replace(/\.jsonl$/, ""), "subagents");
56506
- 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");
56507
56553
  }
56508
56554
  }
56509
56555
  /**
@@ -57402,10 +57448,10 @@ function mergeDefs2(...defs) {
57402
57448
  function cloneDef2(schema) {
57403
57449
  return mergeDefs2(schema._zod.def);
57404
57450
  }
57405
- function getElementAtPath2(obj2, path148) {
57406
- if (!path148)
57451
+ function getElementAtPath2(obj2, path149) {
57452
+ if (!path149)
57407
57453
  return obj2;
57408
- return path148.reduce((acc, key) => acc?.[key], obj2);
57454
+ return path149.reduce((acc, key) => acc?.[key], obj2);
57409
57455
  }
57410
57456
  function promiseAllObject2(promisesObj) {
57411
57457
  const keys2 = Object.keys(promisesObj);
@@ -57745,11 +57791,11 @@ function explicitlyAborted2(x, startIndex = 0) {
57745
57791
  }
57746
57792
  return false;
57747
57793
  }
57748
- function prefixIssues2(path148, issues) {
57794
+ function prefixIssues2(path149, issues) {
57749
57795
  return issues.map((iss) => {
57750
57796
  var _a5;
57751
57797
  (_a5 = iss).path ?? (_a5.path = []);
57752
- iss.path.unshift(path148);
57798
+ iss.path.unshift(path149);
57753
57799
  return iss;
57754
57800
  });
57755
57801
  }
@@ -58211,16 +58257,16 @@ function flattenError2(error63, mapper = (issue3) => issue3.message) {
58211
58257
  }
58212
58258
  function formatError2(error63, mapper = (issue3) => issue3.message) {
58213
58259
  const fieldErrors = { _errors: [] };
58214
- const processError = (error64, path148 = []) => {
58260
+ const processError = (error64, path149 = []) => {
58215
58261
  for (const issue3 of error64.issues) {
58216
58262
  if (issue3.code === "invalid_union" && issue3.errors.length) {
58217
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
58263
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
58218
58264
  } else if (issue3.code === "invalid_key") {
58219
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58265
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58220
58266
  } else if (issue3.code === "invalid_element") {
58221
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58267
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58222
58268
  } else {
58223
- const fullpath = [...path148, ...issue3.path];
58269
+ const fullpath = [...path149, ...issue3.path];
58224
58270
  if (fullpath.length === 0) {
58225
58271
  fieldErrors._errors.push(mapper(issue3));
58226
58272
  } else {
@@ -58259,17 +58305,17 @@ function formatError2(error63, mapper = (issue3) => issue3.message) {
58259
58305
  }
58260
58306
  function treeifyError(error63, mapper = (issue3) => issue3.message) {
58261
58307
  const result2 = { errors: [] };
58262
- const processError = (error64, path148 = []) => {
58308
+ const processError = (error64, path149 = []) => {
58263
58309
  var _a5;
58264
58310
  for (const issue3 of error64.issues) {
58265
58311
  if (issue3.code === "invalid_union" && issue3.errors.length) {
58266
- issue3.errors.map((issues) => processError({ issues }, [...path148, ...issue3.path]));
58312
+ issue3.errors.map((issues) => processError({ issues }, [...path149, ...issue3.path]));
58267
58313
  } else if (issue3.code === "invalid_key") {
58268
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58314
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58269
58315
  } else if (issue3.code === "invalid_element") {
58270
- processError({ issues: issue3.issues }, [...path148, ...issue3.path]);
58316
+ processError({ issues: issue3.issues }, [...path149, ...issue3.path]);
58271
58317
  } else {
58272
- const fullpath = [...path148, ...issue3.path];
58318
+ const fullpath = [...path149, ...issue3.path];
58273
58319
  if (fullpath.length === 0) {
58274
58320
  result2.errors.push(mapper(issue3));
58275
58321
  continue;
@@ -58308,8 +58354,8 @@ function treeifyError(error63, mapper = (issue3) => issue3.message) {
58308
58354
  }
58309
58355
  function toDotPath(_path) {
58310
58356
  const segs = [];
58311
- const path148 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
58312
- for (const seg of path148) {
58357
+ const path149 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
58358
+ for (const seg of path149) {
58313
58359
  if (typeof seg === "number")
58314
58360
  segs.push(`[${seg}]`);
58315
58361
  else if (typeof seg === "symbol")
@@ -75438,13 +75484,13 @@ function resolveRef(ref2, ctx) {
75438
75484
  if (!ref2.startsWith("#")) {
75439
75485
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
75440
75486
  }
75441
- const path148 = ref2.slice(1).split("/").filter(Boolean);
75442
- if (path148.length === 0) {
75487
+ const path149 = ref2.slice(1).split("/").filter(Boolean);
75488
+ if (path149.length === 0) {
75443
75489
  return ctx.rootSchema;
75444
75490
  }
75445
75491
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
75446
- if (path148[0] === defsKey) {
75447
- 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]);
75448
75494
  if (!key || !ctx.defs[key]) {
75449
75495
  throw new Error(`Reference not found: ${ref2}`);
75450
75496
  }
@@ -76323,24 +76369,24 @@ function childOf(node3, value, key) {
76323
76369
  var REFUSAL = "must be a single line: it holds a line break or another control character";
76324
76370
  var INPUT_LIMITS = { line: 500, text: 5e4, items: 500 };
76325
76371
  function assertLineSafe(tool, shape, args) {
76326
- const walk = (value, node3, path148) => {
76372
+ const walk = (value, node3, path149) => {
76327
76373
  if (typeof value === "string") {
76328
76374
  const free = multilineAt(node3);
76329
- if (hasControl(value) && !free) throw new OperationError(`${tool}: \`${path148}\` ${REFUSAL}.`);
76375
+ if (hasControl(value) && !free) throw new OperationError(`${tool}: \`${path149}\` ${REFUSAL}.`);
76330
76376
  const max = free ? INPUT_LIMITS.text : INPUT_LIMITS.line;
76331
76377
  if (value.length > max)
76332
- 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}).`);
76333
76379
  return;
76334
76380
  }
76335
76381
  if (Array.isArray(value) && value.length > INPUT_LIMITS.items)
76336
76382
  throw new OperationError(
76337
- `${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}).`
76338
76384
  );
76339
- 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}]`));
76340
76386
  if (!value || typeof value !== "object") return;
76341
76387
  for (const [k, v] of Object.entries(value)) {
76342
- if (hasControl(k)) throw new OperationError(`${tool}: a key of \`${path148 || "the input"}\` ${REFUSAL}.`);
76343
- 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);
76344
76390
  }
76345
76391
  };
76346
76392
  walk(args, external_exports.object(shape), "");
@@ -77338,7 +77384,7 @@ ${exposure}
77338
77384
  }
77339
77385
 
77340
77386
  // src/pairCli.ts
77341
- import path138 from "node:path";
77387
+ import path139 from "node:path";
77342
77388
 
77343
77389
  // src/serve/openSignedIn.ts
77344
77390
  import { spawn as spawn4 } from "node:child_process";
@@ -77350,12 +77396,12 @@ import { readFileSync as readFileSync38 } from "node:fs";
77350
77396
  import os12 from "node:os";
77351
77397
 
77352
77398
  // src/serve/browser/linuxHttpHandler.ts
77353
- import path137 from "node:path";
77399
+ import path138 from "node:path";
77354
77400
  var DESKTOP_ID = /^[A-Za-z0-9][\w.-]{0,200}\.desktop$/;
77355
77401
  function applicationDirs(deps) {
77356
- 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");
77357
77403
  const system = (deps.env.XDG_DATA_DIRS || "/usr/local/share:/usr/share").split(":").filter(Boolean);
77358
- return [home, ...system].map((d) => path137.join(d, "applications"));
77404
+ return [home, ...system].map((d) => path138.join(d, "applications"));
77359
77405
  }
77360
77406
  function linuxHttpHandler(deps) {
77361
77407
  let id;
@@ -77366,7 +77412,7 @@ function linuxHttpHandler(deps) {
77366
77412
  }
77367
77413
  if (!DESKTOP_ID.test(id)) return { kind: "none", why: "no default browser is set (xdg-settings)" };
77368
77414
  for (const dir4 of applicationDirs(deps)) {
77369
- const entry = path137.join(dir4, id);
77415
+ const entry = path138.join(dir4, id);
77370
77416
  const text11 = deps.readFile(entry);
77371
77417
  if (text11 === void 0) continue;
77372
77418
  if (/snap|flatpak/i.test(`${entry}
@@ -77515,7 +77561,7 @@ var WHY4 = {
77515
77561
  async function pairCli(argv2) {
77516
77562
  const o = parseSubArgs(argv2, ["--dir", "--no-open"]);
77517
77563
  if (o.rest.length) fail(`unexpected argument: ${o.rest[0]}`);
77518
- const root = path138.resolve(process.cwd(), o.dir);
77564
+ const root = path139.resolve(process.cwd(), o.dir);
77519
77565
  const lookout = await runningLookout(root);
77520
77566
  if (lookout.kind !== "running") fail(WHY4[lookout.kind]);
77521
77567
  const { instance } = lookout;
@@ -77593,7 +77639,7 @@ ${footer}
77593
77639
  function printGreeting() {
77594
77640
  process.stdout.write(
77595
77641
  greeting({
77596
- version: "0.64.1",
77642
+ version: "0.64.2",
77597
77643
  tagline: BRAND.tagline,
77598
77644
  isTTY: !!process.stdout.isTTY,
77599
77645
  columns: process.stdout.columns ?? 80,
@@ -77603,11 +77649,11 @@ function printGreeting() {
77603
77649
  }
77604
77650
 
77605
77651
  // src/projects.ts
77606
- import path139 from "node:path";
77652
+ import path140 from "node:path";
77607
77653
  function add2(target2, dir4, print) {
77608
- const where2 = path139.resolve(process.cwd(), target2 ?? ".");
77654
+ const where2 = path140.resolve(process.cwd(), target2 ?? ".");
77609
77655
  try {
77610
- 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;
77611
77657
  const root = trackerRootFor(custom3 ?? where2, { create: true });
77612
77658
  const { entry, added } = registerProject({ configDir: configDir(), root });
77613
77659
  print(` ${added ? "Added" : "Already registered"} ${entry.name} ${entry.id} ${entry.root}`);
@@ -77637,7 +77683,7 @@ function runProjects(rest, dir4, print = (s) => process.stdout.write(`${s}
77637
77683
  `)) {
77638
77684
  const [cmd, target2] = rest;
77639
77685
  print(`
77640
- ${BRAND.name} \xB7 projects (${path139.join(configDir(), "projects.json")})
77686
+ ${BRAND.name} \xB7 projects (${path140.join(configDir(), "projects.json")})
77641
77687
  `);
77642
77688
  switch (cmd) {
77643
77689
  case "add":
@@ -77654,7 +77700,7 @@ function runProjects(rest, dir4, print = (s) => process.stdout.write(`${s}
77654
77700
  }
77655
77701
 
77656
77702
  // src/proof/proofCli.ts
77657
- import path141 from "node:path";
77703
+ import path142 from "node:path";
77658
77704
 
77659
77705
  // src/proof/findProofTicket.ts
77660
77706
  var norm4 = (s) => s.trim().replace(/^#/, "").toLowerCase();
@@ -77677,7 +77723,7 @@ function findProofTicket(input2) {
77677
77723
 
77678
77724
  // src/proof/proofVerifyCli.ts
77679
77725
  import { readFileSync as readFileSync39 } from "node:fs";
77680
- import path140 from "node:path";
77726
+ import path141 from "node:path";
77681
77727
  var FLAGS = /* @__PURE__ */ new Set(["--dir", "--keys-ref", "--pr", "--repo"]);
77682
77728
  function parse6(argv2) {
77683
77729
  const o = { dir: ".teamtrail", keysRef: "HEAD", status: false };
@@ -77729,7 +77775,7 @@ async function verifyPr(o, keys2) {
77729
77775
  }
77730
77776
  async function proofVerifyCli(argv2) {
77731
77777
  const o = parse6(argv2);
77732
- 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);
77733
77779
  if (!keys2.size) process.stdout.write(`No proof keys committed at ${o.keysRef} in ${o.dir}/proof-keys.
77734
77780
  `);
77735
77781
  if (o.pr !== void 0) {
@@ -77794,7 +77840,7 @@ function parse7(argv2) {
77794
77840
  async function proofCli(argv2) {
77795
77841
  if (argv2[0] === "verify") return proofVerifyCli(argv2.slice(1));
77796
77842
  const o = parse7(argv2);
77797
- const root = path141.resolve(process.cwd(), o.dir);
77843
+ const root = path142.resolve(process.cwd(), o.dir);
77798
77844
  const markdown = new MarkdownAdapter({ ...nodeMarkdownFs(root), watch: void 0 }, root);
77799
77845
  const tracker = activeTracker({ root, markdown, unapproved: "stay" });
77800
77846
  try {
@@ -77853,18 +77899,18 @@ async function askSandbox(o) {
77853
77899
  }
77854
77900
 
77855
77901
  // src/selfCommand.ts
77856
- import path142 from "node:path";
77902
+ import path143 from "node:path";
77857
77903
  function selfCommand(o) {
77858
77904
  const spec = packageSpec(o.version);
77859
- 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/");
77860
77906
  if (fromNpm && spec.includes("@")) return { command: "npx", args: ["-y", spec], pinned: spec };
77861
77907
  return { command: "node", args: [o.file] };
77862
77908
  }
77863
77909
 
77864
77910
  // src/serve/serveLookout.ts
77865
- import { existsSync as existsSync42 } from "node:fs";
77911
+ import { existsSync as existsSync43 } from "node:fs";
77866
77912
  import http2 from "node:http";
77867
- import path146 from "node:path";
77913
+ import path147 from "node:path";
77868
77914
  import { fileURLToPath } from "node:url";
77869
77915
 
77870
77916
  // ../connector-slack/src/service/connectState.ts
@@ -80120,10 +80166,10 @@ function scoutService(env) {
80120
80166
 
80121
80167
  // ../connector-slack/src/settingStore.ts
80122
80168
  import { readFileSync as readFileSync40 } from "node:fs";
80123
- import path143 from "node:path";
80169
+ import path144 from "node:path";
80124
80170
  var FILE13 = ".agents/slack-settings.json";
80125
80171
  function settingStore(root) {
80126
- const file9 = path143.join(root, FILE13);
80172
+ const file9 = path144.join(root, FILE13);
80127
80173
  return {
80128
80174
  read: () => {
80129
80175
  try {
@@ -80138,7 +80184,7 @@ function settingStore(root) {
80138
80184
 
80139
80185
  // ../connector-slack/src/store.ts
80140
80186
  import { readFileSync as readFileSync41, rmSync as rmSync26 } from "node:fs";
80141
- import path144 from "node:path";
80187
+ import path145 from "node:path";
80142
80188
  var DEFAULTS = {
80143
80189
  enabled: false,
80144
80190
  owners: [],
@@ -80156,7 +80202,7 @@ function readJson3(file9) {
80156
80202
  }
80157
80203
  var KEPT2 = ["enabled", "workspace", "bot", "appId", "owners", "allow", "notify", "command", "channelTrail"];
80158
80204
  function slackStore(dir4) {
80159
- const file9 = path144.join(dir4, "slack.json");
80205
+ const file9 = path145.join(dir4, "slack.json");
80160
80206
  const creds = credentialStore(dir4);
80161
80207
  const read4 = () => {
80162
80208
  const c = readJson3(file9);
@@ -80215,7 +80261,7 @@ function alive3(pid) {
80215
80261
  }
80216
80262
  }
80217
80263
  function slackLock(dir4, owner) {
80218
- const file9 = path144.join(dir4, "slack.lock");
80264
+ const file9 = path145.join(dir4, "slack.lock");
80219
80265
  const current = () => {
80220
80266
  const l = readJson3(file9);
80221
80267
  return l.pid && alive3(l.pid) ? l : void 0;
@@ -80241,14 +80287,14 @@ function slackLock(dir4, owner) {
80241
80287
  var ASKS_FILE = ".agents/slack.json";
80242
80288
  var APPROVALS_FILE = ".agents/slack-approvals.json";
80243
80289
  function askStore(root) {
80244
- const file9 = path144.join(root, ASKS_FILE);
80290
+ const file9 = path145.join(root, ASKS_FILE);
80245
80291
  return {
80246
80292
  read: () => readJson3(file9).asks ?? {},
80247
80293
  write: (asks) => writeLocalJson(root, ASKS_FILE, { asks })
80248
80294
  };
80249
80295
  }
80250
80296
  function approvalStore(root) {
80251
- const file9 = path144.join(root, APPROVALS_FILE);
80297
+ const file9 = path145.join(root, APPROVALS_FILE);
80252
80298
  return {
80253
80299
  read: () => readJson3(file9).approvals ?? {},
80254
80300
  write: (approvals) => writeLocalJson(root, APPROVALS_FILE, { approvals })
@@ -80646,9 +80692,9 @@ async function agentVersionWarnings(root, own3) {
80646
80692
  }
80647
80693
 
80648
80694
  // src/serve/staticFiles.ts
80649
- import { existsSync as existsSync41, statSync as statSync17 } from "node:fs";
80695
+ import { existsSync as existsSync42, statSync as statSync17 } from "node:fs";
80650
80696
  import fs12 from "node:fs/promises";
80651
- import path145 from "node:path";
80697
+ import path146 from "node:path";
80652
80698
  var TYPES = {
80653
80699
  ".html": "text/html; charset=utf-8",
80654
80700
  ".js": "text/javascript; charset=utf-8",
@@ -80669,12 +80715,12 @@ function decoded(pathname) {
80669
80715
  }
80670
80716
  async function serveStatic(appDir, pathname, res) {
80671
80717
  let rel = decoded(pathname);
80672
- let file9 = path145.join(appDir, path145.normalize(rel));
80673
- 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()) {
80674
80720
  rel = "/index.html";
80675
- file9 = path145.join(appDir, "index.html");
80721
+ file9 = path146.join(appDir, "index.html");
80676
80722
  }
80677
- res.setHeader("Content-Type", TYPES[path145.extname(file9)] ?? "application/octet-stream");
80723
+ res.setHeader("Content-Type", TYPES[path146.extname(file9)] ?? "application/octet-stream");
80678
80724
  res.setHeader("Cache-Control", rel.startsWith("/assets/") ? "public, max-age=31536000, immutable" : "no-cache");
80679
80725
  res.end(await fs12.readFile(file9));
80680
80726
  }
@@ -80718,12 +80764,12 @@ function firstCode(signIn) {
80718
80764
  }
80719
80765
  }
80720
80766
  async function serveLookout(opts, slackSetup) {
80721
- const appDir = path146.join(path146.dirname(fileURLToPath(import.meta.url)), "app");
80722
- if (!existsSync42(path146.join(appDir, "index.html"))) fail(`Lookout bundle missing at ${appDir}; reinstall the package`);
80723
- 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);
80724
80770
  const mcp = createMcpHttp({
80725
80771
  auth: tokenFileAuth(root),
80726
- open: remoteAgentOpener({ root, version: "0.64.1" }),
80772
+ open: remoteAgentOpener({ root, version: "0.64.2" }),
80727
80773
  thisMachineOnly: true
80728
80774
  });
80729
80775
  let hub;
@@ -80760,12 +80806,12 @@ async function serveLookout(opts, slackSetup) {
80760
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";
80761
80807
  process.stdout.write(
80762
80808
  `
80763
- ${BRAND.name} ${"0.64.1"} \xB7 ${BRAND.assistant.name} online
80809
+ ${BRAND.name} ${"0.64.2"} \xB7 ${BRAND.assistant.name} online
80764
80810
 
80765
80811
  Lookout ${url2}
80766
80812
  Sign in ${signInLink}
80767
80813
  ${howToSignIn}: once, within 10 minutes. \`${BRAND.slug} pair\` makes another.
80768
- Tracker ${path146.relative(process.cwd(), bridge.root) || "."}${path146.sep} (${bridge.root})
80814
+ Tracker ${path147.relative(process.cwd(), bridge.root) || "."}${path147.sep} (${bridge.root})
80769
80815
 
80770
80816
  Press Ctrl+C to stop.
80771
80817
 
@@ -80779,7 +80825,7 @@ async function serveLookout(opts, slackSetup) {
80779
80825
  openSignedIn({ root: bridge.root, mint, fallback: `${url2}${next}` });
80780
80826
  }
80781
80827
  const unlock = writeLookoutLock(bridge.root, url2);
80782
- for (const w of await agentVersionWarnings(bridge.root, "0.64.1"))
80828
+ for (const w of await agentVersionWarnings(bridge.root, "0.64.2"))
80783
80829
  process.stdout.write(` Heads up ${w}
80784
80830
  `);
80785
80831
  const unlist = writeMcpEndpoint(bridge.root, {
@@ -80818,7 +80864,7 @@ var MCP_FLAGS = [
80818
80864
  async function mcpCommand(argv2) {
80819
80865
  const o = parseSubArgs(argv2, MCP_FLAGS);
80820
80866
  if (o.rest.length) fail(`unexpected argument: ${o.rest[0]}`);
80821
- const root = path147.resolve(process.cwd(), o.dir);
80867
+ const root = path148.resolve(process.cwd(), o.dir);
80822
80868
  if (o.http) return runMcpHttp(mcpHttpOptions(o, root));
80823
80869
  if (o.host || o.port !== void 0 || o.allowHosts.length) fail("--host, --port and --allow-host need --http");
80824
80870
  await runMcpServer({
@@ -80826,7 +80872,7 @@ async function mcpCommand(argv2) {
80826
80872
  agent: o.agent,
80827
80873
  leaseMinutes: o.leaseMinutes,
80828
80874
  noRegister: o.noRegister,
80829
- version: "0.64.1"
80875
+ version: "0.64.2"
80830
80876
  });
80831
80877
  }
80832
80878
  function sandboxFlagFits(o, target2) {
@@ -80871,7 +80917,7 @@ async function connectCommand(argv2) {
80871
80917
  protectConfig: !o.noProtectConfig
80872
80918
  });
80873
80919
  else {
80874
- const self = selfCommand({ version: "0.64.1", file: fileURLToPath2(import.meta.url) });
80920
+ const self = selfCommand({ version: "0.64.2", file: fileURLToPath2(import.meta.url) });
80875
80921
  const protect = !o.noProtectConfig;
80876
80922
  const sandbox = target2 === "claude" ? await askSandbox({ cwd: process.cwd(), flag: o.sandbox, protect }) : void 0;
80877
80923
  runConnect(target2, {
@@ -80886,7 +80932,7 @@ async function connectCommand(argv2) {
80886
80932
  process.stdout.write("\n");
80887
80933
  }
80888
80934
  async function main() {
80889
- setRunningVersion("0.64.1");
80935
+ setRunningVersion("0.64.2");
80890
80936
  const argv2 = process.argv.slice(2);
80891
80937
  if (argv2[0] === "mcp") return mcpCommand(argv2.slice(1));
80892
80938
  if (argv2[0] === "hook") {
@@ -80907,7 +80953,7 @@ async function main() {
80907
80953
  if (argv2[0] === "knowledge") {
80908
80954
  const o = parseSubArgs(argv2.slice(1), ["--dir"]);
80909
80955
  if (o.rest[0] !== "import" || !o.rest[1]) fail("usage: knowledge import <file.md> [--dir <path>]");
80910
- 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]));
80911
80957
  process.stdout.write(
80912
80958
  `
80913
80959
  ${BRAND.name} \xB7 imported ${ids2.length} suggestions (${ids2[0] ?? "\u2014"}\u2026${ids2.at(-1) ?? ""}). Review them in the Lookout: Knowledge.