token-goat 2.9.28 → 2.9.29

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.
Files changed (77) hide show
  1. package/README.md +2 -0
  2. package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-2AWQ2R5X.mjs} +2 -2
  3. package/dist/{token-goat-chunk-5NNYIUGV.mjs → token-goat-chunk-2NNUA2LR.mjs} +4 -4
  4. package/dist/{token-goat-chunk-4RN64ZND.mjs → token-goat-chunk-2WOUYWLM.mjs} +2 -1
  5. package/dist/{token-goat-chunk-HUDC5GS5.mjs → token-goat-chunk-435UQTKD.mjs} +5 -3
  6. package/dist/{token-goat-chunk-6DQNNFJ6.mjs → token-goat-chunk-44BM7DDQ.mjs} +3 -3
  7. package/dist/{token-goat-chunk-4JMWPWCS.mjs → token-goat-chunk-52NSDWYY.mjs} +2 -2
  8. package/dist/{token-goat-chunk-IHKZ3QNA.mjs → token-goat-chunk-67BNIKKO.mjs} +19 -16
  9. package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-6AK46ZT7.mjs} +2 -3
  10. package/dist/{token-goat-chunk-M56BWPBN.mjs → token-goat-chunk-7CPMDFGB.mjs} +166 -40
  11. package/dist/token-goat-chunk-ASLWOQ3I.mjs +14 -0
  12. package/dist/{token-goat-chunk-QM76S6YS.mjs → token-goat-chunk-BGYOZ6DO.mjs} +6 -4
  13. package/dist/{token-goat-chunk-JXK2HQXS.mjs → token-goat-chunk-C5YPNZKQ.mjs} +3 -3
  14. package/dist/{token-goat-chunk-MVSWBNMD.mjs → token-goat-chunk-CIQ2FTY3.mjs} +19 -14
  15. package/dist/{token-goat-chunk-BJBRGPBX.mjs → token-goat-chunk-D4ETHJD6.mjs} +6 -4
  16. package/dist/{token-goat-chunk-VE27HPIF.mjs → token-goat-chunk-DNRPXHYH.mjs} +21 -17
  17. package/dist/{token-goat-chunk-YWSP6IU7.mjs → token-goat-chunk-DNSPXQXQ.mjs} +2 -2
  18. package/dist/token-goat-chunk-DPNLUJWB.mjs +220 -0
  19. package/dist/{token-goat-chunk-I7CB3X4K.mjs → token-goat-chunk-E4ZOJIZK.mjs} +10 -7
  20. package/dist/{token-goat-chunk-IZXKVT4A.mjs → token-goat-chunk-E5TK5DNO.mjs} +11 -4
  21. package/dist/{token-goat-chunk-MMLMALWK.mjs → token-goat-chunk-EUSDXRXU.mjs} +60 -12
  22. package/dist/{token-goat-chunk-7R2XYKC5.mjs → token-goat-chunk-FTP4U4QA.mjs} +12 -9
  23. package/dist/{token-goat-chunk-LEG3JNJ6.mjs → token-goat-chunk-G23DWHV4.mjs} +17 -14
  24. package/dist/{token-goat-chunk-L7SDVGBT.mjs → token-goat-chunk-G7IWXCFF.mjs} +49 -23
  25. package/dist/{token-goat-chunk-NILVK7XM.mjs → token-goat-chunk-GLXRTTLE.mjs} +7 -5
  26. package/dist/{token-goat-chunk-6CCQDAYY.mjs → token-goat-chunk-H5J3C56Q.mjs} +35 -16
  27. package/dist/{token-goat-chunk-Q4S3UQGO.mjs → token-goat-chunk-HNFZZHFW.mjs} +2 -2
  28. package/dist/{token-goat-chunk-CBMY2FGI.mjs → token-goat-chunk-HUYUHODZ.mjs} +572 -230
  29. package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
  30. package/dist/{token-goat-chunk-F7QZRIWM.mjs → token-goat-chunk-IVWI2OCK.mjs} +8 -30
  31. package/dist/{token-goat-chunk-GMOUBOX4.mjs → token-goat-chunk-JTKCQMQA.mjs} +37 -5
  32. package/dist/{token-goat-chunk-6SGLIPQB.mjs → token-goat-chunk-KOPIR3KZ.mjs} +12 -9
  33. package/dist/token-goat-chunk-L7H3U27L.mjs +35 -0
  34. package/dist/{token-goat-chunk-FSTWAOW6.mjs → token-goat-chunk-LZNBQTDK.mjs} +6 -4
  35. package/dist/token-goat-chunk-MELOKFDJ.mjs +199 -0
  36. package/dist/{token-goat-chunk-VWZKZPSR.mjs → token-goat-chunk-NMBWLRHW.mjs} +76 -39
  37. package/dist/{token-goat-chunk-HXNAC4ZF.mjs → token-goat-chunk-O6I2XU4P.mjs} +12 -10
  38. package/dist/{token-goat-chunk-MAMQPC43.mjs → token-goat-chunk-ONXH6NZ5.mjs} +1 -1
  39. package/dist/token-goat-chunk-ORNFMIER.mjs +295 -0
  40. package/dist/{token-goat-chunk-66LODAUT.mjs → token-goat-chunk-PGTH2U4C.mjs} +1 -1
  41. package/dist/{token-goat-chunk-SJEKA7Y2.mjs → token-goat-chunk-PKRWMHVP.mjs} +76 -64
  42. package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-PQ53BSCF.mjs} +1 -1
  43. package/dist/{token-goat-chunk-RSS3TLXU.mjs → token-goat-chunk-PYSUADX4.mjs} +2 -2
  44. package/dist/{token-goat-chunk-EL7M26WP.mjs → token-goat-chunk-QO3LXVVR.mjs} +185 -104
  45. package/dist/{token-goat-chunk-XI2VFAV6.mjs → token-goat-chunk-RLP6J7WR.mjs} +6 -6
  46. package/dist/token-goat-chunk-RQGGMPCR.mjs +205 -0
  47. package/dist/{token-goat-chunk-6Z5ULNE5.mjs → token-goat-chunk-RTMVLHWX.mjs} +165 -60
  48. package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-S4VSXURL.mjs} +8 -6
  49. package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-SE6E4BKJ.mjs} +1 -1
  50. package/dist/token-goat-chunk-TCQANXYC.mjs +351 -0
  51. package/dist/{token-goat-chunk-GGLEE35R.mjs → token-goat-chunk-TDUT2CL6.mjs} +7 -7
  52. package/dist/{token-goat-chunk-CC2PYJM7.mjs → token-goat-chunk-TGOXNAHW.mjs} +54 -112
  53. package/dist/{token-goat-chunk-XKY4VKJ4.mjs → token-goat-chunk-UA5BKWWQ.mjs} +1 -1
  54. package/dist/{token-goat-chunk-UBUKHVYW.mjs → token-goat-chunk-UXSXQQIY.mjs} +1 -1
  55. package/dist/{token-goat-chunk-D5ICEPSB.mjs → token-goat-chunk-VMFWNHGR.mjs} +79 -68
  56. package/dist/token-goat-chunk-VQ6F6T7X.mjs +36 -0
  57. package/dist/{token-goat-chunk-4STDIGYC.mjs → token-goat-chunk-VZQEWRVH.mjs} +6 -4
  58. package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
  59. package/dist/{token-goat-chunk-L45ZQRT7.mjs → token-goat-chunk-XYWPOSCN.mjs} +57 -615
  60. package/dist/{token-goat-chunk-4JJBFT7V.mjs → token-goat-chunk-YAGLESS3.mjs} +8 -5
  61. package/dist/token-goat-chunk-YKSRAWUU.mjs +33 -0
  62. package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-YOOVFPTP.mjs} +2 -2
  63. package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
  64. package/dist/token-goat-chunk-Z6KBMOBI.mjs +53 -0
  65. package/dist/{token-goat-chunk-RJH64KQH.mjs → token-goat-chunk-ZER6EAXZ.mjs} +3 -3
  66. package/dist/token-goat-hook-client.cjs +475 -0
  67. package/dist/token-goat-hook-client.mjs +26 -0
  68. package/dist/token-goat-hook.mjs +31 -27
  69. package/dist/token-goat.core.mjs +9 -44
  70. package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
  71. package/docs/cli.md +3 -2
  72. package/docs/install.md +16 -14
  73. package/package.json +1 -1
  74. package/dist/token-goat-chunk-7MAFDRVR.mjs +0 -47
  75. package/dist/token-goat-chunk-BCN2YQC6.mjs +0 -32
  76. package/dist/token-goat-chunk-D7GHQKQD.mjs +0 -30
  77. package/dist/token-goat-chunk-IFORDBGC.mjs +0 -192
@@ -6,35 +6,42 @@ import {
6
6
  isNoisePath,
7
7
  listSiblingSessionStates,
8
8
  loadSessionCache
9
- } from "./token-goat-chunk-6CCQDAYY.mjs";
9
+ } from "./token-goat-chunk-H5J3C56Q.mjs";
10
10
  import {
11
11
  WEB_FETCH_KEY_SEP,
12
12
  getSessionBashOutputs,
13
13
  getSessionBashReruns,
14
14
  getSessionFiles,
15
15
  getSessionWebFetches
16
- } from "./token-goat-chunk-GGLEE35R.mjs";
16
+ } from "./token-goat-chunk-TDUT2CL6.mjs";
17
17
  import {
18
18
  getBashOutput
19
- } from "./token-goat-chunk-HXNAC4ZF.mjs";
19
+ } from "./token-goat-chunk-O6I2XU4P.mjs";
20
20
  import {
21
21
  findProject,
22
22
  loadConfig
23
- } from "./token-goat-chunk-CC2PYJM7.mjs";
23
+ } from "./token-goat-chunk-TGOXNAHW.mjs";
24
24
  import {
25
+ LOCK_WAIT_MS_HARDENED,
25
26
  atomicWriteText,
26
- dataDir,
27
27
  ensureDirSync,
28
- foldPath,
29
28
  runGit,
30
29
  toKB,
31
- withFileLock
32
- } from "./token-goat-chunk-L45ZQRT7.mjs";
30
+ withFileLock,
31
+ withRetryOnLock
32
+ } from "./token-goat-chunk-XYWPOSCN.mjs";
33
+ import {
34
+ foldPath,
35
+ sleepSync
36
+ } from "./token-goat-chunk-TCQANXYC.mjs";
33
37
  import {
34
38
  displaySafePath,
35
39
  displaySafeText,
36
40
  neutralizeSpokenMarkers
37
41
  } from "./token-goat-chunk-NMTKNYGF.mjs";
42
+ import {
43
+ dataDir
44
+ } from "./token-goat-chunk-MELOKFDJ.mjs";
38
45
  import {
39
46
  init_define_import_meta_env
40
47
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -64,9 +71,9 @@ function validateKey(key) {
64
71
  );
65
72
  }
66
73
  }
67
- function parseTOML(content) {
74
+ function parseTOML(content, unparsed = []) {
68
75
  const result = {};
69
- for (const line of content.split("\n")) {
76
+ for (const [i, line] of content.split("\n").entries()) {
70
77
  const trimmed = line.trim();
71
78
  if (!trimmed || trimmed.startsWith("#")) {
72
79
  continue;
@@ -91,20 +98,29 @@ function parseTOML(content) {
91
98
  });
92
99
  result[key] = unescaped;
93
100
  }
101
+ } else {
102
+ unparsed.push(i + 1);
94
103
  }
95
104
  }
96
105
  return result;
97
106
  }
98
- function loadRaw(filePath) {
107
+ function loadRaw(filePath, forUpdate = false) {
108
+ let content = "";
99
109
  try {
100
- if (!fs.existsSync(filePath)) {
101
- return {};
102
- }
103
- const content = fs.readFileSync(filePath, "utf-8");
104
- return parseTOML(content);
105
- } catch {
106
- return {};
110
+ withRetryOnLock(() => {
111
+ content = fs.readFileSync(filePath, "utf-8");
112
+ });
113
+ } catch (err) {
114
+ if (err.code === "ENOENT") return {};
115
+ throw err;
116
+ }
117
+ const unparsed = [];
118
+ const entries = parseTOML(content, unparsed);
119
+ if (forUpdate && unparsed.length > 0) {
120
+ const one = unparsed.length === 1;
121
+ throw new Error(`Not updating ${filePath}: ${one ? "line" : "lines"} ${unparsed.join(", ")} ${one ? "is" : "are"} not in the key = "value" form, and saving would drop ${one ? "it" : "them"}. Fix or remove ${one ? "it" : "them"}, then try again.`);
107
122
  }
123
+ return entries;
108
124
  }
109
125
  function save(filePath, entries) {
110
126
  const lines = [];
@@ -127,7 +143,7 @@ function setEntry(projectHash, key, value) {
127
143
  const dir = path.dirname(p);
128
144
  ensureDirSync(dir);
129
145
  const doSet = () => {
130
- const entries = loadRaw(p);
146
+ const entries = loadRaw(p, true);
131
147
  const isNewKey = !(key in entries);
132
148
  if (isNewKey && Object.keys(entries).length >= MAX_ENTRIES) {
133
149
  const keysToKeep = MAX_ENTRIES - 1;
@@ -140,20 +156,30 @@ function setEntry(projectHash, key, value) {
140
156
  save(p, entries);
141
157
  return true;
142
158
  };
143
- if (withFileLock(`${p}.lock`, doSet) === void 0) doSet();
159
+ underNotesLock(p, doSet);
160
+ }
161
+ function underNotesLock(p, update) {
162
+ const lockPath = `${p}.lock`;
163
+ ensureDirSync(path.dirname(p));
164
+ for (let attempt = 1; attempt <= 3; attempt++) {
165
+ if (withFileLock(lockPath, update, { waitMs: LOCK_WAIT_MS_HARDENED }) !== void 0) return;
166
+ if (fs.existsSync(lockPath)) break;
167
+ if (attempt < 3) sleepSync(50 * attempt);
168
+ }
169
+ throw new Error(`Could not lock ${p} for writing; no note was changed. Another token-goat process may be writing notes: try again.`);
144
170
  }
145
171
  function unsetEntry(projectHash, key) {
146
172
  validateKey(key);
147
173
  const p = memoryPath(projectHash);
148
174
  const doUnset = () => {
149
- const entries = loadRaw(p);
175
+ const entries = loadRaw(p, true);
150
176
  if (key in entries) {
151
177
  delete entries[key];
152
178
  save(p, entries);
153
179
  }
154
180
  return true;
155
181
  };
156
- if (withFileLock(`${p}.lock`, doUnset) === void 0) doUnset();
182
+ underNotesLock(p, doUnset);
157
183
  }
158
184
  function clearAll(projectHash) {
159
185
  const p = memoryPath(projectHash);
@@ -163,7 +189,7 @@ function clearAll(projectHash) {
163
189
  }
164
190
  return true;
165
191
  };
166
- if (withFileLock(`${p}.lock`, doClear) === void 0) doClear();
192
+ underNotesLock(p, doClear);
167
193
  }
168
194
  function buildInjection(projectHash) {
169
195
  try {
@@ -10,16 +10,18 @@ import {
10
10
  querySheet,
11
11
  rangeSheet,
12
12
  xlsxColumns
13
- } from "./token-goat-chunk-RSS3TLXU.mjs";
14
- import "./token-goat-chunk-YWSP6IU7.mjs";
13
+ } from "./token-goat-chunk-PYSUADX4.mjs";
14
+ import "./token-goat-chunk-DNSPXQXQ.mjs";
15
15
  import "./token-goat-chunk-3BTK54F3.mjs";
16
- import "./token-goat-chunk-UBUKHVYW.mjs";
16
+ import "./token-goat-chunk-UXSXQQIY.mjs";
17
17
  import "./token-goat-chunk-XTQAOTSO.mjs";
18
18
  import "./token-goat-chunk-AH6QILZM.mjs";
19
- import "./token-goat-chunk-L45ZQRT7.mjs";
19
+ import "./token-goat-chunk-XYWPOSCN.mjs";
20
+ import "./token-goat-chunk-TCQANXYC.mjs";
20
21
  import "./token-goat-chunk-NMTKNYGF.mjs";
22
+ import "./token-goat-chunk-MELOKFDJ.mjs";
21
23
  import "./token-goat-chunk-Y4AFKTHK.mjs";
22
- import "./token-goat-chunk-GMOUBOX4.mjs";
24
+ import "./token-goat-chunk-JTKCQMQA.mjs";
23
25
  import "./token-goat-chunk-A37V4PBF.mjs";
24
26
  export {
25
27
  XlsxScanTooLargeError,
@@ -22,44 +22,49 @@ import {
22
22
  outstandingAgentSpawnKey,
23
23
  outstandingAgentSpawnsAtLoad,
24
24
  pendingLargeFileHintsAtLoad
25
- } from "./token-goat-chunk-GGLEE35R.mjs";
25
+ } from "./token-goat-chunk-TDUT2CL6.mjs";
26
26
  import {
27
27
  claudeConfigDir,
28
28
  readTranscriptTail
29
- } from "./token-goat-chunk-MAMQPC43.mjs";
29
+ } from "./token-goat-chunk-ONXH6NZ5.mjs";
30
30
  import {
31
31
  DEFAULT_MAX_AGE_MS,
32
32
  DEFAULT_MAX_COUNT
33
- } from "./token-goat-chunk-BJBRGPBX.mjs";
33
+ } from "./token-goat-chunk-D4ETHJD6.mjs";
34
34
  import {
35
35
  recordStat,
36
36
  redactSecrets
37
- } from "./token-goat-chunk-MVSWBNMD.mjs";
37
+ } from "./token-goat-chunk-CIQ2FTY3.mjs";
38
38
  import {
39
39
  detectHarness,
40
40
  isAutoTriggerMultiplierExplicit,
41
41
  loadConfig,
42
42
  shortFingerprint
43
- } from "./token-goat-chunk-CC2PYJM7.mjs";
43
+ } from "./token-goat-chunk-TGOXNAHW.mjs";
44
44
  import {
45
45
  registerReset
46
- } from "./token-goat-chunk-EEIDFMEM.mjs";
46
+ } from "./token-goat-chunk-YZAAZU2S.mjs";
47
47
  import {
48
48
  LOCK_WAIT_MS_HARDENED,
49
49
  atomicWriteText,
50
- dataDir,
51
50
  ensureDirSync,
52
- foldPath,
53
51
  isCodeFenceDelimiter,
54
52
  normalizePathForwardSlash,
55
53
  sanitizeIdForFilename,
56
54
  stripLower,
57
- tokenGoatHome,
58
- withFileLock
59
- } from "./token-goat-chunk-L45ZQRT7.mjs";
55
+ withFileLock,
56
+ withRetryOnLock
57
+ } from "./token-goat-chunk-XYWPOSCN.mjs";
58
+ import {
59
+ foldPath
60
+ } from "./token-goat-chunk-TCQANXYC.mjs";
60
61
  import {
61
62
  normalizePath
62
63
  } from "./token-goat-chunk-NMTKNYGF.mjs";
64
+ import {
65
+ dataDir,
66
+ tokenGoatHome
67
+ } from "./token-goat-chunk-MELOKFDJ.mjs";
63
68
  import {
64
69
  init_define_import_meta_env
65
70
  } from "./token-goat-chunk-A37V4PBF.mjs";
@@ -392,8 +397,23 @@ function capFiles(s, max) {
392
397
  }
393
398
  function readDiskState(p) {
394
399
  try {
395
- if (!fs.existsSync(p)) return null;
396
- return coerce(JSON.parse(fs.readFileSync(p, "utf8")));
400
+ return readDiskStateForMerge(p);
401
+ } catch {
402
+ return null;
403
+ }
404
+ }
405
+ function readDiskStateForMerge(p) {
406
+ let text = "";
407
+ try {
408
+ withRetryOnLock(() => {
409
+ text = fs.readFileSync(p, "utf8");
410
+ });
411
+ } catch (err) {
412
+ if (err.code === "ENOENT") return null;
413
+ throw err;
414
+ }
415
+ try {
416
+ return coerce(JSON.parse(text));
397
417
  } catch {
398
418
  return null;
399
419
  }
@@ -424,8 +444,7 @@ function listSiblingSessionStates(sessionId) {
424
444
  var EMPTY_SESSION = { files: [], hintsShown: [], webFetches: [], bashOutputs: [], curlDownloads: [] };
425
445
  function loadSessionState(sessionId) {
426
446
  const p = sessionPath(sessionId);
427
- if (!p) return;
428
- importSessionState(readDiskState(p) ?? EMPTY_SESSION);
447
+ importSessionState((p ? readDiskState(p) : null) ?? EMPTY_SESSION);
429
448
  }
430
449
  function saveSessionState(sessionId) {
431
450
  const p = sessionPath(sessionId);
@@ -435,7 +454,7 @@ function saveSessionState(sessionId) {
435
454
  if (!fs.existsSync(dir)) ensureDirSync(dir);
436
455
  const mem = exportSessionState();
437
456
  const writeMerged = () => {
438
- const disk = readDiskState(p);
457
+ const disk = readDiskStateForMerge(p);
439
458
  const merged = capFiles(disk ? mergeSessionState(disk, mem) : mem, MAX_FILES);
440
459
  if (merged.created_ts === void 0) merged.created_ts = Date.now() / 1e3;
441
460
  let json;
@@ -12,10 +12,10 @@ import {
12
12
  parseOoxmlPart,
13
13
  readOoxmlZip,
14
14
  sortNumberedParts
15
- } from "./token-goat-chunk-UBUKHVYW.mjs";
15
+ } from "./token-goat-chunk-UXSXQQIY.mjs";
16
16
  import {
17
17
  compileGuardedRegex
18
- } from "./token-goat-chunk-GMOUBOX4.mjs";
18
+ } from "./token-goat-chunk-JTKCQMQA.mjs";
19
19
  import {
20
20
  init_define_import_meta_env
21
21
  } from "./token-goat-chunk-A37V4PBF.mjs";