@vectorize-io/hindsight-coding-agents 0.8.0 → 0.8.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.
Files changed (62) hide show
  1. package/README.md +73 -8
  2. package/dist/antigravity-hook.js +444 -80
  3. package/dist/antigravity-statusline.js +9 -4
  4. package/dist/antigravity-stop-hook.js +444 -95
  5. package/dist/claude-hook.js +444 -80
  6. package/dist/claude-sessionstart-hook.js +476 -93
  7. package/dist/claude-stop-hook.js +444 -95
  8. package/dist/cline.js +322 -122
  9. package/dist/codebuddy-hook.js +4273 -0
  10. package/dist/codebuddy-sessionstart-hook.js +5033 -0
  11. package/dist/codebuddy-stop-hook.js +4567 -0
  12. package/dist/codex-hook.js +444 -80
  13. package/dist/codex-sessionstart-hook.js +476 -93
  14. package/dist/codex-stop-hook.js +444 -95
  15. package/dist/copilot-hook.js +444 -80
  16. package/dist/copilot-sessionstart-hook.js +476 -93
  17. package/dist/copilot-stop-hook.js +444 -95
  18. package/dist/cursor-hook.js +444 -80
  19. package/dist/cursor-sessionstart-hook.js +476 -93
  20. package/dist/cursor-stop-hook.js +444 -95
  21. package/dist/daemon-start.js +16 -8
  22. package/dist/dcode-hook.js +444 -80
  23. package/dist/dcode-sessionstart-hook.js +476 -93
  24. package/dist/dcode-stop-hook.js +444 -95
  25. package/dist/deepen.js +252 -79
  26. package/dist/devin-hook.js +444 -80
  27. package/dist/devin-sessionstart-hook.js +476 -93
  28. package/dist/devin-stop-hook.js +444 -95
  29. package/dist/droid-hook.js +444 -80
  30. package/dist/droid-sessionstart-hook.js +476 -93
  31. package/dist/droid-stop-hook.js +444 -95
  32. package/dist/dsh.js +329 -122
  33. package/dist/grok-hook.js +444 -80
  34. package/dist/grok-sessionstart-hook.js +476 -93
  35. package/dist/grok-stop-hook.js +444 -95
  36. package/dist/hindsight-seed.js +9 -4
  37. package/dist/index.js +331 -131
  38. package/dist/installer.js +1046 -647
  39. package/dist/kilo.js +331 -131
  40. package/dist/kimi-hook.js +444 -80
  41. package/dist/kimi-sessionstart-hook.js +476 -93
  42. package/dist/kimi-stop-hook.js +444 -95
  43. package/dist/mcp-server.js +272 -89
  44. package/dist/opencode2.js +328 -128
  45. package/dist/pi.js +384 -134
  46. package/dist/prime-agent.js +384 -134
  47. package/dist/qwen-hook.js +444 -80
  48. package/dist/qwen-sessionstart-hook.js +476 -93
  49. package/dist/qwen-stop-hook.js +444 -95
  50. package/dist/status.js +124 -43
  51. package/dist/traecode-hook.js +444 -80
  52. package/dist/traecode-sessionstart-hook.js +476 -93
  53. package/dist/traecode-stop-hook.js +444 -95
  54. package/dist/workbuddy-hook.js +4273 -0
  55. package/dist/workbuddy-sessionstart-hook.js +5033 -0
  56. package/dist/workbuddy-stop-hook.js +4567 -0
  57. package/dist/zcode-hook.js +444 -80
  58. package/dist/zcode-sessionstart-hook.js +476 -93
  59. package/dist/zcode-stop-hook.js +444 -95
  60. package/package.json +9 -3
  61. package/plugin.json +1 -1
  62. package/skill/SKILL.md +10 -6
package/dist/installer.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/installer.ts
4
- import { execFileSync as execFileSync7 } from "child_process";
4
+ import { execFileSync as execFileSync8 } from "child_process";
5
5
  import {
6
6
  copyFileSync,
7
7
  cpSync as cpSync2,
8
8
  existsSync as existsSync13,
9
9
  mkdirSync as mkdirSync7,
10
10
  mkdtempSync as mkdtempSync2,
11
- readFileSync as readFileSync16,
11
+ readFileSync as readFileSync15,
12
12
  readSync as readSync4,
13
13
  realpathSync as realpathSync3,
14
14
  rmSync as rmSync4,
@@ -16,7 +16,7 @@ import {
16
16
  } from "fs";
17
17
  import { homedir as homedir13, tmpdir as tmpdir5 } from "os";
18
18
  import { isatty } from "tty";
19
- import { dirname as dirname12, join as join23 } from "path";
19
+ import { dirname as dirname13, join as join24 } from "path";
20
20
  import { fileURLToPath as fileURLToPath7, pathToFileURL } from "url";
21
21
 
22
22
  // node_modules/jsonc-parser/lib/esm/impl/scanner.js
@@ -910,15 +910,15 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
910
910
  }
911
911
  }
912
912
  }
913
- function handleError(error, skipUntilAfter = [], skipUntil2 = []) {
913
+ function handleError(error, skipUntilAfter = [], skipUntil = []) {
914
914
  onError(error);
915
- if (skipUntilAfter.length + skipUntil2.length > 0) {
915
+ if (skipUntilAfter.length + skipUntil.length > 0) {
916
916
  let token = _scanner.getToken();
917
917
  while (token !== 17) {
918
918
  if (skipUntilAfter.indexOf(token) !== -1) {
919
919
  scanNext();
920
920
  break;
921
- } else if (skipUntil2.indexOf(token) !== -1) {
921
+ } else if (skipUntil.indexOf(token) !== -1) {
922
922
  break;
923
923
  }
924
924
  token = scanNext();
@@ -978,7 +978,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
978
978
  if (_scanner.getToken() === 6) {
979
979
  onSeparator(":");
980
980
  scanNext();
981
- if (!parseValue2()) {
981
+ if (!parseValue()) {
982
982
  handleError(4, [], [
983
983
  2,
984
984
  5
@@ -1056,7 +1056,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
1056
1056
  } else {
1057
1057
  _jsonPath[_jsonPath.length - 1]++;
1058
1058
  }
1059
- if (!parseValue2()) {
1059
+ if (!parseValue()) {
1060
1060
  handleError(4, [], [
1061
1061
  4,
1062
1062
  5
@@ -1079,7 +1079,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
1079
1079
  }
1080
1080
  return true;
1081
1081
  }
1082
- function parseValue2() {
1082
+ function parseValue() {
1083
1083
  switch (_scanner.getToken()) {
1084
1084
  case 3:
1085
1085
  return parseArray2();
@@ -1099,7 +1099,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
1099
1099
  handleError(4, [], []);
1100
1100
  return false;
1101
1101
  }
1102
- if (!parseValue2()) {
1102
+ if (!parseValue()) {
1103
1103
  handleError(4, [], []);
1104
1104
  return false;
1105
1105
  }
@@ -1347,105 +1347,13 @@ function applyEdits(text, edits) {
1347
1347
  return text;
1348
1348
  }
1349
1349
 
1350
- // node_modules/smol-toml/dist/date.js
1351
- var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
1352
- var TomlDate = class _TomlDate extends Date {
1353
- #hasDate = false;
1354
- #hasTime = false;
1355
- #offset = null;
1356
- constructor(date) {
1357
- let hasDate = true;
1358
- let hasTime = true;
1359
- let offset = "Z";
1360
- if (typeof date === "string") {
1361
- let match = date.match(DATE_TIME_RE);
1362
- if (match) {
1363
- if (!match[1]) {
1364
- hasDate = false;
1365
- date = `0000-01-01T${date}`;
1366
- }
1367
- hasTime = !!match[2];
1368
- hasTime && date[10] === " " && (date = date.replace(" ", "T"));
1369
- if (match[2] && +match[2] > 23) {
1370
- date = "";
1371
- } else {
1372
- offset = match[3] || null;
1373
- date = date.toUpperCase();
1374
- if (!offset && hasTime)
1375
- date += "Z";
1376
- }
1377
- } else {
1378
- date = "";
1379
- }
1380
- }
1381
- super(date);
1382
- if (!isNaN(this.getTime())) {
1383
- this.#hasDate = hasDate;
1384
- this.#hasTime = hasTime;
1385
- this.#offset = offset;
1386
- }
1387
- }
1388
- isDateTime() {
1389
- return this.#hasDate && this.#hasTime;
1390
- }
1391
- isLocal() {
1392
- return !this.#hasDate || !this.#hasTime || !this.#offset;
1393
- }
1394
- isDate() {
1395
- return this.#hasDate && !this.#hasTime;
1396
- }
1397
- isTime() {
1398
- return this.#hasTime && !this.#hasDate;
1399
- }
1400
- isValid() {
1401
- return this.#hasDate || this.#hasTime;
1402
- }
1403
- toISOString() {
1404
- let iso = super.toISOString();
1405
- if (this.isDate())
1406
- return iso.slice(0, 10);
1407
- if (this.isTime())
1408
- return iso.slice(11, 23);
1409
- if (this.#offset === null)
1410
- return iso.slice(0, -1);
1411
- if (this.#offset === "Z")
1412
- return iso;
1413
- let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
1414
- offset = this.#offset[0] === "-" ? offset : -offset;
1415
- let offsetDate = new Date(this.getTime() - offset * 6e4);
1416
- return offsetDate.toISOString().slice(0, -1) + this.#offset;
1417
- }
1418
- static wrapAsOffsetDateTime(jsDate, offset = "Z") {
1419
- let date = new _TomlDate(jsDate);
1420
- date.#offset = offset;
1421
- return date;
1422
- }
1423
- static wrapAsLocalDateTime(jsDate) {
1424
- let date = new _TomlDate(jsDate);
1425
- date.#offset = null;
1426
- return date;
1427
- }
1428
- static wrapAsLocalDate(jsDate) {
1429
- let date = new _TomlDate(jsDate);
1430
- date.#hasTime = false;
1431
- date.#offset = null;
1432
- return date;
1433
- }
1434
- static wrapAsLocalTime(jsDate) {
1435
- let date = new _TomlDate(jsDate);
1436
- date.#hasDate = false;
1437
- date.#offset = null;
1438
- return date;
1439
- }
1440
- };
1441
-
1442
1350
  // node_modules/smol-toml/dist/error.js
1443
1351
  function getLineColFromPtr(string, ptr) {
1444
- let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
1352
+ let lines = string.slice(0, ptr).split(/\r?\n/);
1445
1353
  return [lines.length, lines.pop().length + 1];
1446
1354
  }
1447
1355
  function makeCodeBlock(string, line, column) {
1448
- let lines = string.split(/\r\n|\n|\r/g);
1356
+ let lines = string.split(/\r?\n/);
1449
1357
  let codeblock = "";
1450
1358
  let numberLen = (Math.log10(line + 1) | 0) + 1;
1451
1359
  for (let i = line - 1; i <= line + 1; i++) {
@@ -1463,7 +1371,7 @@ function makeCodeBlock(string, line, column) {
1463
1371
  }
1464
1372
  return codeblock;
1465
1373
  }
1466
- var TomlError = class extends Error {
1374
+ var TomlError = class _TomlError extends Error {
1467
1375
  line;
1468
1376
  column;
1469
1377
  codeblock;
@@ -1477,69 +1385,15 @@ ${codeblock}`, options);
1477
1385
  this.column = column;
1478
1386
  this.codeblock = codeblock;
1479
1387
  }
1480
- };
1481
-
1482
- // node_modules/smol-toml/dist/util.js
1483
- function indexOfNewline(str, start = 0) {
1484
- let idx = str.indexOf("\n", start);
1485
- if (str.charCodeAt(idx - 1) === 13)
1486
- idx--;
1487
- return idx;
1488
- }
1489
- function skipComment(ctx) {
1490
- for (; ctx.p < ctx.s.length; ctx.p++) {
1491
- let c = ctx.s.charCodeAt(ctx.p);
1492
- if (c === 10)
1493
- break;
1494
- if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
1495
- ctx.p++;
1496
- break;
1497
- }
1498
- if (c < 32 && c !== 9 || c === 127) {
1499
- throw new TomlError("control characters are not allowed in comments", {
1500
- toml: ctx.s,
1501
- ptr: ctx.p
1502
- });
1503
- }
1504
- }
1505
- }
1506
- function skipVoid(ctx, banNewLines, banComments) {
1507
- let c;
1508
- while (1) {
1509
- while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
1510
- ctx.p++;
1511
- if (banComments || c !== 35)
1512
- break;
1513
- skipComment(ctx);
1514
- }
1515
- }
1516
- function skipUntil(ctx, sep2, end) {
1517
- let ptr = ctx.p;
1518
- if (!end) {
1519
- ptr = indexOfNewline(ctx.s, ptr);
1520
- ctx.p = ptr < 0 ? ctx.s.length : ptr;
1521
- return;
1522
- }
1523
- for (; ctx.p < ctx.s.length; ctx.p++) {
1524
- let c = ctx.s.charCodeAt(ctx.p);
1525
- if (c === 35) {
1526
- skipComment(ctx);
1527
- } else if (c === end || c === sep2) {
1528
- return;
1529
- }
1388
+ /** @internal */
1389
+ static x(message, ctx, ptr) {
1390
+ throw new _TomlError(message, { toml: ctx.s, ptr: ptr ?? ctx.p });
1530
1391
  }
1531
- throw new TomlError("cannot find end of structure", {
1532
- toml: ctx.s,
1533
- ptr
1534
- });
1535
- }
1392
+ };
1536
1393
 
1537
1394
  // node_modules/smol-toml/dist/primitive.js
1538
- var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
1539
- var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
1540
- var LEADING_ZERO = /^[+-]?0[0-9_]/;
1541
1395
  function parseString(ctx) {
1542
- let start = ctx.p;
1396
+ let startPtr = ctx.p;
1543
1397
  let c = ctx.s.charCodeAt(ctx.p++);
1544
1398
  let first = c;
1545
1399
  let isLiteral = c === 39;
@@ -1558,10 +1412,7 @@ function parseString(ctx) {
1558
1412
  if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
1559
1413
  state = state && 3;
1560
1414
  } else if (c < 32 && c !== 9 || c === 127) {
1561
- throw new TomlError("control characters are not allowed in strings", {
1562
- toml: ctx.s,
1563
- ptr: ctx.p
1564
- });
1415
+ TomlError.x("control characters are not allowed in strings", ctx);
1565
1416
  } else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
1566
1417
  if (isMultiline) {
1567
1418
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
@@ -1569,8 +1420,10 @@ function parseString(ctx) {
1569
1420
  if (ctx.s.charCodeAt(ctx.p + 3) === first)
1570
1421
  ctx.p++;
1571
1422
  }
1572
- if (!state)
1573
- parsed += ctx.s.slice(sliceStart, ctx.p);
1423
+ if (!state) {
1424
+ let s = ctx.s.slice(sliceStart, ctx.p);
1425
+ parsed = parsed ? parsed + s : s;
1426
+ }
1574
1427
  ctx.p += isMultiline ? 3 : 1;
1575
1428
  return parsed;
1576
1429
  } else if (!state) {
@@ -1580,10 +1433,11 @@ function parseString(ctx) {
1580
1433
  }
1581
1434
  } else if (state === 1) {
1582
1435
  if (c === 120 || c === 117 || c === 85) {
1436
+ let errPtr = ctx.p++ - 1;
1583
1437
  let value = 0;
1584
1438
  let len = c === 120 ? 2 : c === 117 ? 4 : 8;
1585
1439
  for (let j = 0; j < len; j++, ctx.p++) {
1586
- let hex = ctx.s.charCodeAt(ctx.p + 1);
1440
+ let hex = ctx.s.charCodeAt(ctx.p);
1587
1441
  let digit = (
1588
1442
  /* 0-9 */
1589
1443
  hex >= 48 && hex <= 57 ? hex - 48 : (
@@ -1595,16 +1449,16 @@ function parseString(ctx) {
1595
1449
  )
1596
1450
  );
1597
1451
  if (digit < 0)
1598
- throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
1452
+ TomlError.x("invalid non-hex character in unicode escape", ctx);
1599
1453
  value = value << 4 | digit;
1600
1454
  }
1601
1455
  if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
1602
- throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
1456
+ TomlError.x("invalid unicode escape", ctx, errPtr);
1603
1457
  }
1604
1458
  parsed += String.fromCodePoint(value);
1605
- sliceStart = ctx.p + 1;
1459
+ sliceStart = ctx.p--;
1606
1460
  state = 0;
1607
- } else if (c === 32 || c === 9) {
1461
+ } else if (isMultiline && (c === 32 || c === 9)) {
1608
1462
  state = 2;
1609
1463
  } else {
1610
1464
  if (c === 98)
@@ -1624,84 +1478,150 @@ function parseString(ctx) {
1624
1478
  else if (c === 92)
1625
1479
  parsed += "\\";
1626
1480
  else
1627
- throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
1481
+ TomlError.x("unrecognised escape sequence", ctx);
1628
1482
  sliceStart = ctx.p + 1;
1629
1483
  state = 0;
1630
1484
  }
1631
1485
  } else if (c !== 32 && c !== 9) {
1632
- if (state === 2) {
1633
- throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
1634
- toml: ctx.s,
1635
- ptr: sliceStart
1636
- });
1637
- }
1486
+ if (state === 2)
1487
+ TomlError.x("invalid escape: only line-ending whitespace may be escaped", ctx, sliceStart);
1638
1488
  state = !isLiteral && c === 92 ? 1 : 0;
1639
1489
  sliceStart = ctx.p;
1640
1490
  }
1641
1491
  }
1642
- throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
1643
- }
1644
- function sliceAndTrimEndOf(ctx, start, end) {
1645
- let value = ctx.s.slice(start, end);
1646
- let commentIdx = value.indexOf("#");
1647
- if (commentIdx > 0) {
1648
- skipComment({ s: value, p: commentIdx, d: 0 });
1649
- value = value.slice(0, commentIdx);
1650
- }
1651
- return value.trimEnd();
1652
- }
1653
- function parseValue(ctx, integersAsBigInt, end) {
1654
- let ptr = ctx.p;
1655
- let err = { toml: ctx.s, ptr };
1656
- skipUntil(ctx, 44, end);
1657
- let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
1658
- if (!value)
1659
- throw new TomlError("incomplete declaration: value expected", err);
1660
- if (value === "-inf")
1661
- return -Infinity;
1662
- if (value === "inf" || value === "+inf")
1663
- return Infinity;
1664
- if (value === "nan" || value === "+nan" || value === "-nan")
1665
- return NaN;
1666
- if (value === "-0")
1667
- return integersAsBigInt ? 0n : 0;
1668
- let isInt = INT_REGEX.test(value);
1669
- if (isInt || FLOAT_REGEX.test(value)) {
1670
- if (LEADING_ZERO.test(value)) {
1671
- throw new TomlError("leading zeroes are not allowed", err);
1672
- }
1673
- value = value.replace(/_/g, "");
1674
- let numeric = +value;
1675
- if (isNaN(numeric)) {
1676
- throw new TomlError("invalid number", err);
1677
- }
1678
- if (isInt) {
1679
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
1680
- throw new TomlError("integer value cannot be represented losslessly", err);
1492
+ TomlError.x("unfinished string", ctx, startPtr);
1493
+ }
1494
+
1495
+ // node_modules/smol-toml/dist/date.js
1496
+ var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[Tt ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|z|[-+]\d{2}:\d{2})?$/i;
1497
+ var TomlDate = class _TomlDate extends Date {
1498
+ #hasDate = false;
1499
+ #hasTime = false;
1500
+ #offset = null;
1501
+ constructor(date, fasttype, unsafeDelim) {
1502
+ let hasDate = true;
1503
+ let hasTime = true;
1504
+ let offset = "Z";
1505
+ let c;
1506
+ if (typeof date === "string") {
1507
+ if (fasttype)
1508
+ prep: {
1509
+ if (fasttype < 3) {
1510
+ if (+date.slice(11, 13) > 23) {
1511
+ date = "";
1512
+ break prep;
1513
+ }
1514
+ if (fasttype === 2) {
1515
+ offset = null;
1516
+ date += "Z";
1517
+ } else if ((c = date.charCodeAt(date.length - 1)) !== 90 && c !== 122) {
1518
+ offset = date.slice(date.length - 6);
1519
+ }
1520
+ if (unsafeDelim)
1521
+ date = date.slice(0, 10) + "T" + date.slice(11);
1522
+ } else if (fasttype === 4) {
1523
+ date = +date.slice(0, 2) > 23 ? "" : `0000-01-01T${date}Z`;
1524
+ }
1525
+ hasDate = fasttype !== 4;
1526
+ hasTime = fasttype !== 3;
1527
+ }
1528
+ else {
1529
+ let match = date.match(DATE_TIME_RE);
1530
+ if (match) {
1531
+ if (!match[1]) {
1532
+ hasDate = false;
1533
+ date = `0000-01-01T${date}`;
1534
+ }
1535
+ hasTime = !!match[2];
1536
+ hasTime && date[10] === " " && (date = date.replace(" ", "T"));
1537
+ if (match[2] && +match[2] > 23) {
1538
+ date = "";
1539
+ } else {
1540
+ offset = match[3] || null;
1541
+ if (!offset && hasTime)
1542
+ date += "Z";
1543
+ }
1544
+ } else {
1545
+ date = "";
1546
+ }
1681
1547
  }
1682
- if (isInt || integersAsBigInt === true)
1683
- numeric = BigInt(value);
1684
1548
  }
1685
- return numeric;
1549
+ super(date);
1550
+ if (!isNaN(this.getTime())) {
1551
+ this.#hasDate = hasDate;
1552
+ this.#hasTime = hasTime;
1553
+ this.#offset = offset;
1554
+ }
1686
1555
  }
1687
- const date = new TomlDate(value);
1688
- if (!date.isValid())
1689
- throw new TomlError("invalid value", err);
1690
- return date;
1691
- }
1556
+ isDateTime() {
1557
+ return this.#hasDate && this.#hasTime;
1558
+ }
1559
+ isLocal() {
1560
+ return !this.#hasDate || !this.#hasTime || !this.#offset;
1561
+ }
1562
+ isDate() {
1563
+ return this.#hasDate && !this.#hasTime;
1564
+ }
1565
+ isTime() {
1566
+ return this.#hasTime && !this.#hasDate;
1567
+ }
1568
+ isValid() {
1569
+ return this.#hasDate || this.#hasTime;
1570
+ }
1571
+ toISOString() {
1572
+ let iso = super.toISOString();
1573
+ if (this.isDate())
1574
+ return iso.slice(0, 10);
1575
+ if (this.isTime())
1576
+ return iso.slice(11, 23);
1577
+ if (this.#offset === null)
1578
+ return iso.slice(0, -1);
1579
+ if (this.#offset === "Z" || this.#offset === "z")
1580
+ return iso;
1581
+ let offset = +this.#offset.slice(1, 3) * 60 + +this.#offset.slice(4, 6);
1582
+ offset = this.#offset[0] === "-" ? offset : -offset;
1583
+ let offsetDate = new Date(this.getTime() - offset * 6e4);
1584
+ return offsetDate.toISOString().slice(0, -1) + this.#offset;
1585
+ }
1586
+ static wrapAsOffsetDateTime(jsDate, offset = "Z") {
1587
+ let date = new _TomlDate(jsDate);
1588
+ date.#offset = offset;
1589
+ return date;
1590
+ }
1591
+ static wrapAsLocalDateTime(jsDate) {
1592
+ let date = new _TomlDate(jsDate);
1593
+ date.#offset = null;
1594
+ return date;
1595
+ }
1596
+ static wrapAsLocalDate(jsDate) {
1597
+ let date = new _TomlDate(jsDate);
1598
+ date.#hasTime = false;
1599
+ date.#offset = null;
1600
+ return date;
1601
+ }
1602
+ static wrapAsLocalTime(jsDate) {
1603
+ let date = new _TomlDate(jsDate);
1604
+ date.#hasDate = false;
1605
+ date.#offset = null;
1606
+ return date;
1607
+ }
1608
+ };
1692
1609
 
1693
1610
  // node_modules/smol-toml/dist/extract.js
1694
- function extractValue(ctx, end, integersAsBigInt) {
1695
- let ptr = ctx.p;
1696
- let c = ctx.s.charCodeAt(ptr);
1611
+ function isDigit2(char, base = 10) {
1612
+ return base === 16 ? char > 47 && char < 58 || char > 64 && char < 71 || char > 96 && char < 103 : char > 47 && char < 48 + base;
1613
+ }
1614
+ function isEndOfValue(char, delim) {
1615
+ return char === 32 || char === 9 || char === 10 || char === 13 || // Structure end or next value delimiter
1616
+ delim && (char === delim || char === 44) || // Comment
1617
+ char === 35;
1618
+ }
1619
+ function extractValue(ctx, end) {
1620
+ let errPtr = ctx.p;
1621
+ let c = ctx.s.charCodeAt(ctx.p);
1697
1622
  if (c === 91 || c === 123) {
1698
- if (!ctx.d--) {
1699
- throw new TomlError("document contains excessively nested structures. aborting.", {
1700
- toml: ctx.s,
1701
- ptr
1702
- });
1703
- }
1704
- let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
1623
+ ctx.d-- || TomlError.x("document contains excessively nested structures. aborting.", ctx);
1624
+ let value = c === 91 ? parseArray(ctx) : parseInlineTable(ctx);
1705
1625
  ctx.d++;
1706
1626
  return value;
1707
1627
  }
@@ -1710,90 +1630,262 @@ function extractValue(ctx, end, integersAsBigInt) {
1710
1630
  }
1711
1631
  if (c === 116) {
1712
1632
  if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
1713
- throw new TomlError("invalid value", { toml: ctx.s, ptr });
1714
- ctx.p++;
1715
- return true;
1633
+ TomlError.x("invalid value", ctx, errPtr);
1634
+ return ctx.p++, true;
1716
1635
  }
1717
1636
  if (c === 102) {
1718
1637
  if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
1719
- throw new TomlError("invalid value", { toml: ctx.s, ptr });
1720
- ctx.p++;
1721
- return false;
1638
+ TomlError.x("invalid value", ctx, errPtr);
1639
+ return ctx.p++, false;
1640
+ }
1641
+ if (c === 43 || c === 45) {
1642
+ return parseNumber(ctx, ctx.p, ctx.s.charCodeAt(++ctx.p), 44 - c, end);
1643
+ }
1644
+ if (ctx.s.charCodeAt(ctx.p + 4) === 45 && ctx.s.charCodeAt(ctx.p + 7) === 45) {
1645
+ return parseDate(ctx, c, end);
1646
+ }
1647
+ if (ctx.s.charCodeAt(ctx.p + 2) === 58) {
1648
+ return parseTime(ctx, c, end);
1649
+ }
1650
+ return parseNumber(ctx, ctx.p, c, 0, end);
1651
+ }
1652
+ function parseNumber(ctx, startPtr, startChr, sign, endChr) {
1653
+ let c = startChr;
1654
+ let state = 0;
1655
+ let hasUnderscores = false;
1656
+ if (c === 105) {
1657
+ if (ctx.s.charCodeAt(++ctx.p) !== 110 || ctx.s.charCodeAt(++ctx.p) !== 102)
1658
+ TomlError.x("invalid value", ctx, startPtr);
1659
+ return ctx.p++, (sign || 1) / 0;
1660
+ }
1661
+ if (c === 110) {
1662
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 110)
1663
+ TomlError.x("invalid value", ctx, startPtr);
1664
+ return ctx.p++, NaN;
1665
+ }
1666
+ if (c === 48) {
1667
+ if (++ctx.p >= ctx.s.length || isEndOfValue(c = ctx.s.charCodeAt(ctx.p), endChr))
1668
+ return ctx.bi === true ? 0n : 0;
1669
+ if (!sign) {
1670
+ if (c === 120)
1671
+ return parseIntegerBaseN(ctx, startPtr, 16, endChr);
1672
+ else if (c === 98)
1673
+ return parseIntegerBaseN(ctx, startPtr, 2, endChr);
1674
+ else if (c === 111)
1675
+ return parseIntegerBaseN(ctx, startPtr, 8, endChr);
1676
+ }
1677
+ if (c === 46)
1678
+ state = 2;
1679
+ else if (c === 101 || c === 69)
1680
+ state = 4;
1681
+ else
1682
+ TomlError.x("illegal leading zero", ctx, startPtr);
1683
+ } else if (!isDigit2(c))
1684
+ TomlError.x("invalid value", ctx, startPtr);
1685
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
1686
+ if (!state)
1687
+ state = 1;
1688
+ if (c === 95) {
1689
+ if (!(state & 1))
1690
+ TomlError.x("illegal underscore", ctx);
1691
+ state += 11;
1692
+ hasUnderscores = true;
1693
+ } else if (state === 1 && c === 46)
1694
+ state = 2;
1695
+ else if ((state === 1 || state === 3) && (c === 101 || c === 69))
1696
+ state = 4;
1697
+ else if (state === 4 && (c === 43 || c === 45)) {
1698
+ } else if (!isDigit2(c))
1699
+ TomlError.x(`illegal character in numeric literal`, ctx);
1700
+ else if (state > 9)
1701
+ state -= 11;
1702
+ else if (!(state & 1))
1703
+ state++;
1704
+ }
1705
+ if (!state) {
1706
+ let val = (startChr - 48) * (sign || 1);
1707
+ return ctx.bi === true ? BigInt(val) : val;
1708
+ }
1709
+ if (!(state & 1))
1710
+ TomlError.x("unfinished numeric value", ctx, startPtr);
1711
+ let str = ctx.s.slice(startPtr, ctx.p);
1712
+ if (hasUnderscores)
1713
+ str = str.replaceAll("_", "");
1714
+ return state > 1 ? parseFloat(str) : parseInteger(ctx, str, 10, startPtr);
1715
+ }
1716
+ function parseIntegerBaseN(ctx, startPtr, base, endChr) {
1717
+ let c, underscore = 1;
1718
+ while (++ctx.p < ctx.s.length && (c = ctx.s.charCodeAt(ctx.p), !isEndOfValue(c, endChr))) {
1719
+ if (c === 95) {
1720
+ if (underscore & 1)
1721
+ TomlError.x("illegal underscore", ctx);
1722
+ underscore = 3;
1723
+ } else if (!isDigit2(c, base))
1724
+ TomlError.x(`illegal character in numeric literal`, ctx);
1725
+ else if (underscore & 1)
1726
+ underscore--;
1727
+ }
1728
+ if (underscore & 1)
1729
+ TomlError.x("unfinished numeric value", ctx);
1730
+ let str = ctx.s.slice(startPtr + 2, ctx.p);
1731
+ if (underscore)
1732
+ str = str.replaceAll("_", "");
1733
+ return parseInteger(ctx, str, base, startPtr);
1734
+ }
1735
+ function parseInteger(ctx, str, base, startPtr) {
1736
+ if (ctx.bi !== true)
1737
+ int: {
1738
+ let val = parseInt(str, base);
1739
+ if (!Number.isSafeInteger(val)) {
1740
+ if (ctx.bi)
1741
+ break int;
1742
+ TomlError.x("integer value cannot be represented losslessly", ctx, startPtr);
1743
+ }
1744
+ return val;
1745
+ }
1746
+ return base === 10 ? BigInt(str) : BigInt((base === 2 ? "0b" : base === 8 ? "0o" : "0x") + str);
1747
+ }
1748
+ function parseDate(ctx, c, endChr) {
1749
+ let startPtr = ctx.p++, unsafeSeparator;
1750
+ if (!isDigit2(c) || !isDigit2(ctx.s.charCodeAt(ctx.p++)) || !isDigit2(ctx.s.charCodeAt(ctx.p++)) || !isDigit2(ctx.s.charCodeAt(ctx.p++))) {
1751
+ return parseNumber(ctx, ctx.p = startPtr, c, 0, endChr);
1752
+ }
1753
+ ctx.p += 5;
1754
+ if (!isDigit2(ctx.s.charCodeAt(ctx.p++)))
1755
+ TomlError.x("invalid date-time: date part is malformed", ctx, startPtr);
1756
+ if (ctx.p >= ctx.s.length || ((c = ctx.s.charCodeAt(ctx.p)) !== 32 || (unsafeSeparator = true, !isDigit2(ctx.s.charCodeAt(ctx.p + 1)))) && c !== 84 && c !== 116) {
1757
+ let t2 = ctx.s.slice(startPtr, ctx.p);
1758
+ return readDate(ctx, t2, 3, false, startPtr);
1759
+ }
1760
+ if (ctx.s.charCodeAt(ctx.p += 3) !== 58)
1761
+ TomlError.x("invalid date-time: time part is malformed", ctx, startPtr);
1762
+ if (ctx.s.charCodeAt(ctx.p += 3) === 58)
1763
+ ctx.p += 3;
1764
+ if (ctx.s.charCodeAt(ctx.p) === 46)
1765
+ while (isDigit2(ctx.s.charCodeAt(++ctx.p)))
1766
+ ;
1767
+ if (c = ctx.s.charCodeAt(ctx.p)) {
1768
+ if (c === 90 || c === 122) {
1769
+ let t2 = ctx.s.slice(startPtr, ++ctx.p);
1770
+ return readDate(ctx, t2, 1, unsafeSeparator, startPtr, "[+00:00]");
1771
+ }
1772
+ if (c === 43 || c === 45) {
1773
+ let t2 = ctx.s.slice(startPtr, ctx.p += 6);
1774
+ return readDate(ctx, t2, 1, unsafeSeparator, startPtr, !ctx.ld && "[" + ctx.s.slice(ctx.p - 6, ctx.p) + "]");
1775
+ }
1776
+ }
1777
+ let t = ctx.s.slice(startPtr, ctx.p);
1778
+ return readDate(ctx, t, 2, unsafeSeparator, startPtr);
1779
+ }
1780
+ function parseTime(ctx, c, endChr) {
1781
+ let start = ctx.p;
1782
+ if (!isDigit2(c) || !isDigit2(ctx.s.charCodeAt(++ctx.p))) {
1783
+ return parseNumber(ctx, --ctx.p, c, 0, endChr);
1784
+ }
1785
+ if (ctx.s.charCodeAt(ctx.p += 4) === 58)
1786
+ ctx.p += 3;
1787
+ if (ctx.s.charCodeAt(ctx.p) === 46)
1788
+ while (isDigit2(ctx.s.charCodeAt(++ctx.p)))
1789
+ ;
1790
+ let t = ctx.s.slice(start, ctx.p);
1791
+ return readDate(ctx, t, 4, false, start);
1792
+ }
1793
+ function readDate(ctx, str, type, unsafeDelim, errPtr, temporalSuffix) {
1794
+ if (ctx.ld) {
1795
+ let date = new TomlDate(str, type, unsafeDelim);
1796
+ if (!date.isValid())
1797
+ TomlError.x("invalid date", ctx, errPtr);
1798
+ return date;
1799
+ }
1800
+ try {
1801
+ if (temporalSuffix)
1802
+ str += temporalSuffix;
1803
+ switch (type) {
1804
+ case 1:
1805
+ return Temporal.ZonedDateTime.from(str);
1806
+ case 2:
1807
+ return Temporal.PlainDateTime.from(str);
1808
+ case 3:
1809
+ return Temporal.PlainDate.from(str);
1810
+ case 4:
1811
+ return Temporal.PlainTime.from(str);
1812
+ }
1813
+ } catch (e) {
1814
+ TomlError.x(e instanceof Error ? e.message : "" + e, ctx, errPtr);
1815
+ }
1816
+ }
1817
+
1818
+ // node_modules/smol-toml/dist/util.js
1819
+ function skipComment(ctx) {
1820
+ for (; ctx.p < ctx.s.length; ctx.p++) {
1821
+ let c = ctx.s.charCodeAt(ctx.p);
1822
+ if (c === 10)
1823
+ break;
1824
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
1825
+ ctx.p++;
1826
+ break;
1827
+ }
1828
+ if (c < 32 && c !== 9 || c === 127) {
1829
+ TomlError.x("control characters are not allowed in comments", ctx);
1830
+ }
1831
+ }
1832
+ }
1833
+ function skipVoid(ctx, banNewLines, banComments) {
1834
+ let c;
1835
+ while (ctx.p < ctx.s.length) {
1836
+ while (ctx.p < ctx.s.length && ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)))
1837
+ ctx.p++;
1838
+ if (banComments || c !== 35)
1839
+ break;
1840
+ skipComment(ctx);
1722
1841
  }
1723
- return parseValue(ctx, integersAsBigInt, end);
1724
1842
  }
1725
1843
 
1726
1844
  // node_modules/smol-toml/dist/struct.js
1727
- var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
1728
- function parseKey(ctx, end = "=") {
1729
- let start = ctx.p;
1730
- let dot = start - 1;
1845
+ function parseKey(ctx, end = 61) {
1846
+ let startPtr;
1847
+ let state = 0;
1731
1848
  let parsed = [];
1732
- let endPtr = ctx.s.indexOf(end, start);
1733
- if (endPtr < 0) {
1734
- throw new TomlError("incomplete key-value: cannot find end of key", {
1735
- toml: ctx.s,
1736
- ptr: start
1737
- });
1738
- }
1849
+ let sliceStart;
1850
+ let c = ctx.s.charCodeAt(startPtr = ctx.p);
1739
1851
  do {
1740
- let c = ctx.s.charCodeAt(ctx.p = ++dot);
1741
- if (c !== 32 && c !== 9) {
1742
- if (c === 34 || c === 39) {
1743
- if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
1744
- throw new TomlError("multiline strings are not allowed in keys", {
1745
- toml: ctx.s,
1746
- ptr: ctx.p
1747
- });
1748
- }
1749
- let part = parseString(ctx);
1750
- dot = ctx.s.indexOf(".", ctx.p);
1751
- let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1752
- let newLine = indexOfNewline(strEnd);
1753
- if (newLine > -1) {
1754
- throw new TomlError("newlines are not allowed in keys", {
1755
- toml: ctx.s,
1756
- ptr: newLine
1757
- });
1758
- }
1759
- if (strEnd.trimStart()) {
1760
- throw new TomlError("found extra tokens after the string part", {
1761
- toml: ctx.s,
1762
- ptr: ctx.p
1763
- });
1764
- }
1765
- if (endPtr < ctx.p) {
1766
- endPtr = ctx.s.indexOf(end, ctx.p);
1767
- if (endPtr < 0) {
1768
- throw new TomlError("incomplete key-value: cannot find end of key", {
1769
- toml: ctx.s,
1770
- ptr: start
1771
- });
1772
- }
1773
- }
1774
- parsed.push(part);
1775
- } else {
1776
- dot = ctx.s.indexOf(".", ctx.p);
1777
- let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
1778
- if (!KEY_PART_RE.test(part)) {
1779
- throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
1780
- toml: ctx.s,
1781
- ptr: ctx.p
1782
- });
1783
- }
1784
- parsed.push(part.trimEnd());
1852
+ if (c === end) {
1853
+ if (!state)
1854
+ TomlError.x("unexpected end of key", ctx);
1855
+ if (state === 1)
1856
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
1857
+ return ctx.p++, parsed;
1858
+ } else if (c === 46) {
1859
+ if (!state)
1860
+ TomlError.x("illegal empty bare key", ctx);
1861
+ if (state === 1)
1862
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
1863
+ state = 0;
1864
+ } else if (!state && (c === 34 || c === 39)) {
1865
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2))
1866
+ TomlError.x("illegal quoted key: multiline strings are not allowed", ctx);
1867
+ parsed.push(parseString(ctx));
1868
+ state = 2;
1869
+ ctx.p--;
1870
+ } else if (c === 32 || c === 9) {
1871
+ if (state === 1) {
1872
+ parsed.push(ctx.s.slice(sliceStart, ctx.p));
1873
+ state = 2;
1785
1874
  }
1875
+ } else if (state === 2 || c < 48 && c !== 45 || c > 57 && c < 65 || c > 90 && c < 97 && c !== 95 || c > 122) {
1876
+ TomlError.x("illegal character in key", ctx);
1877
+ } else if (!state) {
1878
+ state = 1;
1879
+ sliceStart = ctx.p;
1786
1880
  }
1787
- } while (dot + 1 && dot < endPtr);
1788
- ctx.p = endPtr + 1;
1789
- skipVoid(ctx, true, true);
1790
- return parsed;
1881
+ } while (c = ctx.s.charCodeAt(++ctx.p));
1882
+ TomlError.x("incomplete key-value: cannot find end of key", ctx, startPtr);
1791
1883
  }
1792
- function parseInlineTable(ctx, integersAsBigInt) {
1793
- let res = {};
1884
+ function parseInlineTable(ctx) {
1885
+ let startPtr = ctx.p++;
1886
+ let res = /* @__PURE__ */ Object.create(null);
1794
1887
  let seen = /* @__PURE__ */ new Set();
1795
1888
  let c;
1796
- ctx.p++;
1797
1889
  while (ctx.p < ctx.s.length) {
1798
1890
  skipVoid(ctx);
1799
1891
  if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
@@ -1803,70 +1895,71 @@ function parseInlineTable(ctx, integersAsBigInt) {
1803
1895
  let k;
1804
1896
  let t = res;
1805
1897
  let hasOwn = false;
1806
- let p = ctx.p;
1898
+ let errPtr = ctx.p;
1807
1899
  let key = parseKey(ctx);
1808
1900
  for (let i = 0; i < key.length; i++) {
1809
1901
  if (i)
1810
- t = hasOwn ? t[k] : t[k] = {};
1902
+ t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
1811
1903
  k = key[i];
1812
1904
  if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
1813
- throw new TomlError("trying to redefine an already defined value", {
1814
- toml: ctx.s,
1815
- ptr: p
1816
- });
1905
+ TomlError.x("trying to redefine an already defined value", ctx, errPtr);
1906
+ }
1907
+ let unsafe = k === "__proto__";
1908
+ if (ctx.uk && (unsafe || k === "constructor")) {
1909
+ t = ctx.uk !== 1 && TomlError.x("document contains an unsafe property", ctx, errPtr);
1910
+ break;
1817
1911
  }
1818
- if (!hasOwn && k === "__proto__") {
1912
+ if (!hasOwn && unsafe) {
1819
1913
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1820
1914
  }
1821
1915
  }
1822
1916
  if (hasOwn) {
1823
- throw new TomlError("trying to redefine an already defined value", {
1824
- toml: ctx.s,
1825
- ptr: ctx.p
1826
- });
1917
+ TomlError.x("trying to redefine an already defined value", ctx, errPtr);
1827
1918
  }
1828
- let value = extractValue(ctx, 125, integersAsBigInt);
1829
- seen.add(t[k] = value);
1919
+ skipVoid(ctx, true, true);
1920
+ let value = extractValue(
1921
+ ctx,
1922
+ 125
1923
+ /* } */
1924
+ );
1925
+ if (t && typeof (t[k] = value) === "object")
1926
+ seen.add(value);
1830
1927
  skipVoid(ctx);
1831
1928
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
1832
1929
  return res;
1833
1930
  }
1834
- if (c !== 44) {
1835
- throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1836
- }
1931
+ if (c !== 44)
1932
+ TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
1837
1933
  }
1838
- throw new TomlError("unfinished table encountered", {
1839
- toml: ctx.s,
1840
- ptr: ctx.p
1841
- });
1934
+ TomlError.x("unfinished table", ctx, startPtr);
1842
1935
  }
1843
- function parseArray(ctx, integersAsBigInt) {
1936
+ function parseArray(ctx) {
1937
+ let startPtr = ctx.p++;
1844
1938
  let res = [];
1845
1939
  let c;
1846
- ctx.p++;
1847
1940
  while (ctx.p < ctx.s.length) {
1848
1941
  skipVoid(ctx);
1849
1942
  if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
1850
1943
  ctx.p++;
1851
1944
  return res;
1852
1945
  }
1853
- res.push(extractValue(ctx, 93, integersAsBigInt));
1946
+ res.push(extractValue(
1947
+ ctx,
1948
+ 93
1949
+ /* ] */
1950
+ ));
1854
1951
  skipVoid(ctx);
1855
1952
  if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
1856
1953
  return res;
1857
1954
  }
1858
- if (c !== 44) {
1859
- throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
1860
- }
1955
+ if (c !== 44)
1956
+ TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
1861
1957
  }
1862
- throw new TomlError("unfinished array encountered", {
1863
- toml: ctx.s,
1864
- ptr: ctx.p
1865
- });
1958
+ TomlError.x("unfinished array", ctx, startPtr);
1866
1959
  }
1867
1960
 
1868
1961
  // node_modules/smol-toml/dist/parse.js
1869
- function peekTable(key, table, meta, type) {
1962
+ function peekTable(ctx, key, table, meta, type) {
1870
1963
  let t = table;
1871
1964
  let m = meta;
1872
1965
  let k;
@@ -1874,7 +1967,7 @@ function peekTable(key, table, meta, type) {
1874
1967
  let state;
1875
1968
  for (let i = 0; i < key.length; i++) {
1876
1969
  if (i) {
1877
- t = hasOwn ? t[k] : t[k] = {};
1970
+ t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
1878
1971
  m = (state = m[k]).c;
1879
1972
  if (type === 0 && (state.t === 1 || state.t === 2)) {
1880
1973
  return null;
@@ -1890,7 +1983,10 @@ function peekTable(key, table, meta, type) {
1890
1983
  return null;
1891
1984
  }
1892
1985
  if (!hasOwn) {
1893
- if (k === "__proto__") {
1986
+ let unsafe = k === "__proto__";
1987
+ if (ctx.uk && (unsafe || k === "constructor"))
1988
+ return false;
1989
+ if (unsafe) {
1894
1990
  Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
1895
1991
  Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
1896
1992
  }
@@ -1898,7 +1994,7 @@ function peekTable(key, table, meta, type) {
1898
1994
  t: i < key.length - 1 && type === 2 ? 3 : type,
1899
1995
  d: false,
1900
1996
  i: 0,
1901
- c: {}
1997
+ c: /* @__PURE__ */ Object.create(null)
1902
1998
  };
1903
1999
  }
1904
2000
  }
@@ -1911,43 +2007,60 @@ function peekTable(key, table, meta, type) {
1911
2007
  state.d = true;
1912
2008
  t[k] = [];
1913
2009
  }
1914
- t[k].push(t = {});
1915
- state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
2010
+ t[k].push(t = /* @__PURE__ */ Object.create(null));
2011
+ state.c[state.i++] = state = { t: 1, d: false, i: 0, c: /* @__PURE__ */ Object.create(null) };
1916
2012
  }
1917
2013
  if (state.d) {
1918
2014
  return null;
1919
2015
  }
1920
2016
  state.d = true;
1921
2017
  if (type === 1) {
1922
- t = hasOwn ? t[k] : t[k] = {};
2018
+ t = hasOwn ? t[k] : t[k] = /* @__PURE__ */ Object.create(null);
1923
2019
  } else if (type === 0 && hasOwn) {
1924
2020
  return null;
1925
2021
  }
1926
2022
  return [k, t, state.c];
1927
2023
  }
1928
- function parse2(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1929
- let ctx = { s: toml, p: 0, d: maxDepth };
1930
- let res = {};
1931
- let meta = {};
2024
+ function validateTablePeek(ctx, peek, ptr) {
2025
+ if (peek === null || ctx.uk === 2)
2026
+ TomlError.x(peek === null ? "trying to redefine an already defined table or value" : "document contains an unsafe property", ctx, ptr);
2027
+ }
2028
+ function parse2(toml, options = {}) {
2029
+ let ctx = {
2030
+ s: toml,
2031
+ p: 0,
2032
+ d: options.maxDepth ?? 1e3,
2033
+ bi: options.integersAsBigInt ?? false,
2034
+ ld: options.useLegacyDate ?? true,
2035
+ uk: options.unsafeKeyBehaviour === "throw" ? 2 : options.unsafeKeyBehaviour === "drop" ? 1 : 0
2036
+ };
2037
+ let res = /* @__PURE__ */ Object.create(null);
2038
+ let meta = /* @__PURE__ */ Object.create(null);
1932
2039
  let tmp;
2040
+ let skipping = false;
1933
2041
  let tbl = res;
1934
2042
  let m = meta;
2043
+ if (toml.charCodeAt(0) === 65279)
2044
+ ctx.p++;
1935
2045
  skipVoid(ctx);
1936
2046
  while (ctx.p < toml.length) {
1937
2047
  if (toml.charCodeAt(ctx.p) === 91) {
1938
2048
  let isTableArray = toml.charCodeAt(++ctx.p) === 91;
1939
2049
  tmp = ctx.p += +isTableArray;
1940
- let k = parseKey(ctx, "]");
2050
+ skipping = false;
2051
+ let k = parseKey(
2052
+ ctx,
2053
+ 93
2054
+ /* ] */
2055
+ );
1941
2056
  if (isTableArray) {
1942
- if (toml.charCodeAt(ctx.p - 1) !== 93) {
1943
- throw new TomlError("expected end of table declaration", {
1944
- toml,
1945
- ptr: ctx.p - 1
1946
- });
2057
+ if (toml.charCodeAt(ctx.p) !== 93) {
2058
+ TomlError.x("expected end of table array declaration", ctx);
1947
2059
  }
1948
2060
  ctx.p++;
1949
2061
  }
1950
2062
  let p = peekTable(
2063
+ ctx,
1951
2064
  k,
1952
2065
  res,
1953
2066
  meta,
@@ -1955,45 +2068,44 @@ function parse2(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
1955
2068
  /* Type.EXPLICIT */
1956
2069
  );
1957
2070
  if (!p) {
1958
- throw new TomlError("trying to redefine an already defined table or value", {
1959
- toml,
1960
- ptr: tmp
1961
- });
2071
+ validateTablePeek(ctx, p, tmp);
2072
+ skipping = true;
2073
+ } else {
2074
+ m = p[2];
2075
+ tbl = p[1];
1962
2076
  }
1963
- m = p[2];
1964
- tbl = p[1];
1965
2077
  } else {
1966
2078
  tmp = ctx.p;
1967
2079
  let k = parseKey(ctx);
1968
2080
  let p = peekTable(
2081
+ ctx,
1969
2082
  k,
1970
2083
  tbl,
1971
2084
  m,
1972
2085
  0
1973
2086
  /* Type.DOTTED */
1974
2087
  );
1975
- if (!p) {
1976
- throw new TomlError("trying to redefine an already defined table or value", {
1977
- toml,
1978
- ptr: tmp
1979
- });
1980
- }
1981
- p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
2088
+ if (!p && !skipping)
2089
+ validateTablePeek(ctx, p, tmp);
2090
+ skipVoid(ctx, true, true);
2091
+ let v = extractValue(ctx, void 0);
2092
+ if (p && !skipping)
2093
+ p[1][p[0]] = v;
1982
2094
  }
1983
2095
  skipVoid(ctx, true);
1984
- if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
1985
- throw new TomlError("each key-value declaration must be followed by an end-of-line", {
1986
- toml,
1987
- ptr: ctx.p
1988
- });
2096
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && (tmp !== 13 || toml.charCodeAt(ctx.p + 1) !== 10)) {
2097
+ TomlError.x("each key-value declaration must be followed by an end-of-line", ctx);
1989
2098
  }
1990
2099
  skipVoid(ctx);
1991
2100
  }
1992
2101
  return res;
1993
2102
  }
1994
2103
 
2104
+ // node_modules/smol-toml/dist/stringify.js
2105
+ var HAS_WELLFORMED = !!"".isWellFormed;
2106
+
1995
2107
  // src/core/hook.ts
1996
- import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
2108
+ import { existsSync as existsSync2 } from "fs";
1997
2109
 
1998
2110
  // src/core/bank.ts
1999
2111
  import { existsSync } from "fs";
@@ -2001,6 +2113,7 @@ import { homedir as homedir2 } from "os";
2001
2113
  import { basename, dirname as dirname3, join as join4, normalize, sep } from "path";
2002
2114
 
2003
2115
  // src/core/diag.ts
2116
+ import { readFileSync } from "fs";
2004
2117
  import { join as join2 } from "path";
2005
2118
 
2006
2119
  // src/core/log.ts
@@ -2059,11 +2172,11 @@ function diag(harness, event, extra = {}) {
2059
2172
  }
2060
2173
 
2061
2174
  // src/core/git-layout.ts
2062
- import { lstatSync, readFileSync, realpathSync } from "fs";
2175
+ import { lstatSync, readFileSync as readFileSync2, realpathSync } from "fs";
2063
2176
  import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
2064
2177
 
2065
2178
  // src/core/config.ts
2066
- import { readFileSync as readFileSync2 } from "fs";
2179
+ import { readFileSync as readFileSync3 } from "fs";
2067
2180
  import { homedir as homedir3 } from "os";
2068
2181
  import { join as join7 } from "path";
2069
2182
 
@@ -2103,6 +2216,9 @@ var PAGE_TAXONOMY = [
2103
2216
  ];
2104
2217
  var PAGE_NAMES = PAGE_TAXONOMY.map((page) => page.name);
2105
2218
 
2219
+ // package.json
2220
+ var version = "0.8.2";
2221
+
2106
2222
  // src/core/util.ts
2107
2223
  import { accessSync, constants } from "fs";
2108
2224
  import { delimiter, join as join6 } from "path";
@@ -2117,6 +2233,7 @@ function isOurMcpEntry(entry) {
2117
2233
  }
2118
2234
 
2119
2235
  // src/core/hindsight.ts
2236
+ var USER_AGENT = `hindsight-coding-agents/${version}`;
2120
2237
  var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
2121
2238
  var RETRY_AFTER_CEILING_MS = 60 * 1e3;
2122
2239
 
@@ -2139,12 +2256,12 @@ function brandWord() {
2139
2256
  }
2140
2257
 
2141
2258
  // src/core/session-cache.ts
2142
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
2259
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
2143
2260
  import { tmpdir } from "os";
2144
2261
  import { dirname as dirname5, join as join8 } from "path";
2145
2262
 
2146
2263
  // src/core/turn-journal.ts
2147
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
2264
+ import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync2 } from "fs";
2148
2265
  import { tmpdir as tmpdir2 } from "os";
2149
2266
  import { dirname as dirname6, join as join9 } from "path";
2150
2267
 
@@ -2186,9 +2303,6 @@ function actionLine(tool, input) {
2186
2303
  // src/core/turn-journal.ts
2187
2304
  var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
2188
2305
 
2189
- // src/core/retain-hook.ts
2190
- import { readFileSync as readFileSync7 } from "fs";
2191
-
2192
2306
  // src/core/retain-cursor.ts
2193
2307
  import { createHash as createHash2 } from "crypto";
2194
2308
  var PENDING_MAX_AGE_MS = 12 * 60 * 60 * 1e3;
@@ -2430,18 +2544,18 @@ function formatUsageReport(usage, path = usageFilePath()) {
2430
2544
  return out.join("\n");
2431
2545
  }
2432
2546
 
2433
- // src/core/session-start.ts
2434
- import { readFileSync as readFileSync11 } from "fs";
2435
-
2436
2547
  // src/core/git.ts
2437
2548
  import { execFileSync as execFileSync2 } from "child_process";
2438
2549
  import { resolve as resolve2 } from "path";
2550
+ var US = "";
2551
+ var RS = "";
2552
+ var GITLOG_FORMAT = `--format=%h${US}%ad${US}%an${US}%s${US}%b${RS}`;
2439
2553
 
2440
2554
  // src/core/status.ts
2441
- import { execFileSync as execFileSync3 } from "child_process";
2555
+ import { execFileSync as execFileSync4 } from "child_process";
2442
2556
 
2443
2557
  // src/core/survey.ts
2444
- import { spawn as realSpawn4 } from "child_process";
2558
+ import { execFileSync as execFileSync3, spawn as realSpawn4 } from "child_process";
2445
2559
  import { createHash as createHash4 } from "crypto";
2446
2560
  import { existsSync as existsSync3 } from "fs";
2447
2561
  import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
@@ -2470,7 +2584,7 @@ import { spawn as realSpawn5 } from "child_process";
2470
2584
  import {
2471
2585
  existsSync as existsSync4,
2472
2586
  mkdirSync as mkdirSync5,
2473
- readFileSync as readFileSync8,
2587
+ readFileSync as readFileSync7,
2474
2588
  realpathSync as realpathSync2,
2475
2589
  unlinkSync as unlinkSync2,
2476
2590
  writeFileSync as writeFileSync3
@@ -2484,7 +2598,7 @@ var NPM_VIEW_HARD_DEADLINE_MS = NPM_VIEW_TIMEOUT_MS + 1e3;
2484
2598
  var LOCK_STALE_MS = 10 * 60 * 1e3;
2485
2599
 
2486
2600
  // src/core/skill-sync.ts
2487
- import { cpSync, existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
2601
+ import { cpSync, existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
2488
2602
  import { homedir as homedir6 } from "os";
2489
2603
  import { dirname as dirname10, join as join16 } from "path";
2490
2604
  import { fileURLToPath as fileURLToPath5 } from "url";
@@ -2520,7 +2634,12 @@ var SKILL_DIRS = {
2520
2634
  // by fixed directory name, so installing to the shared one would make `uninstall pi` take Codex's
2521
2635
  // and dsh's copy with it.
2522
2636
  pi: [".pi", "agent", "skills"],
2523
- "prime-agent": [".prime", "agent", "skills"]
2637
+ "prime-agent": [".prime", "agent", "skills"],
2638
+ // WorkBuddy's own user-level skills root (the @genie/agent-cli engine reads ~/.workbuddy).
2639
+ workbuddy: [".workbuddy", "skills"],
2640
+ // CodeBuddy Code reads that SAME engine's default root, ~/.codebuddy — WorkBuddy only overrides
2641
+ // its home folder (product config `dataLayout.configDir.userDirName`), so the two differ by config.
2642
+ codebuddy: [".codebuddy", "skills"]
2524
2643
  };
2525
2644
  var TRAE_DOT_DIRS = [".trae-cn", ".trae"];
2526
2645
  var traecodeDotDirName = (home, exists = existsSync5) => {
@@ -2538,7 +2657,7 @@ var resolveSkillDirs = (harness, home) => {
2538
2657
  };
2539
2658
 
2540
2659
  // src/core/legacy.ts
2541
- import { existsSync as existsSync7, readFileSync as readFileSync10 } from "fs";
2660
+ import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
2542
2661
  import { homedir as homedir7 } from "os";
2543
2662
  import { join as join17, relative, isAbsolute as isAbsolute2 } from "path";
2544
2663
  var LEGACY_CONFIG_FILES = {
@@ -2564,7 +2683,7 @@ function readOne(harness, home) {
2564
2683
  if (!existsSync7(source)) return void 0;
2565
2684
  let raw;
2566
2685
  try {
2567
- raw = JSON.parse(readFileSync10(source, "utf8"));
2686
+ raw = JSON.parse(readFileSync9(source, "utf8"));
2568
2687
  } catch {
2569
2688
  return void 0;
2570
2689
  }
@@ -2591,8 +2710,8 @@ function readOne(harness, home) {
2591
2710
  }
2592
2711
 
2593
2712
  // src/core/traecode-mcp.ts
2594
- import { execFileSync as execFileSync4 } from "child_process";
2595
- import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync12, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
2713
+ import { execFileSync as execFileSync5 } from "child_process";
2714
+ import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync10, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
2596
2715
  import { homedir as homedir8 } from "os";
2597
2716
  import { dirname as dirname11, isAbsolute as isAbsolute3, join as join18 } from "path";
2598
2717
  import { fileURLToPath as fileURLToPath6 } from "url";
@@ -2629,7 +2748,7 @@ function gateStateFile() {
2629
2748
  }
2630
2749
  function readGateState(opts = {}) {
2631
2750
  try {
2632
- return JSON.parse(readFileSync12(opts.stateFile ?? gateStateFile(), "utf8"));
2751
+ return JSON.parse(readFileSync10(opts.stateFile ?? gateStateFile(), "utf8"));
2633
2752
  } catch {
2634
2753
  return {};
2635
2754
  }
@@ -2637,7 +2756,7 @@ function readGateState(opts = {}) {
2637
2756
  function workspaceMcpGateState(settingsPath) {
2638
2757
  let raw;
2639
2758
  try {
2640
- raw = readFileSync12(settingsPath, "utf8");
2759
+ raw = readFileSync10(settingsPath, "utf8");
2641
2760
  } catch {
2642
2761
  return "unknown";
2643
2762
  }
@@ -2653,7 +2772,7 @@ function enableWorkspaceMcpSetting(settingsPath) {
2653
2772
  try {
2654
2773
  let doc = {};
2655
2774
  try {
2656
- doc = JSON.parse(readFileSync12(settingsPath, "utf8"));
2775
+ doc = JSON.parse(readFileSync10(settingsPath, "utf8"));
2657
2776
  } catch {
2658
2777
  if (existsSync8(settingsPath)) return false;
2659
2778
  }
@@ -2702,7 +2821,7 @@ function gitignoreCovers(lines) {
2702
2821
  function ensureGitignored(repo) {
2703
2822
  const gitignore = join18(repo, ".gitignore");
2704
2823
  if (!existsSync8(gitignore)) return;
2705
- const current2 = readFileSync12(gitignore, "utf8");
2824
+ const current2 = readFileSync10(gitignore, "utf8");
2706
2825
  if (gitignoreCovers(current2.split("\n"))) return;
2707
2826
  const addition = (current2.endsWith("\n") || current2 === "" ? "" : "\n") + "# hindsight MCP registration (machine-specific)\n.trae/mcp.json\n";
2708
2827
  writeFileSync4(gitignore, current2 + addition);
@@ -2723,7 +2842,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
2723
2842
  let doc = {};
2724
2843
  let exists = false;
2725
2844
  try {
2726
- doc = JSON.parse(readFileSync12(file, "utf8"));
2845
+ doc = JSON.parse(readFileSync10(file, "utf8"));
2727
2846
  exists = true;
2728
2847
  } catch {
2729
2848
  if (existsSync8(file)) return "skipped";
@@ -2772,7 +2891,7 @@ function removeTraecodeWorkspaceMcpEntry(cwd, opts = {}) {
2772
2891
  const file = join18(cwd, MCP_FILE_REL);
2773
2892
  let doc;
2774
2893
  try {
2775
- doc = JSON.parse(readFileSync12(file, "utf8"));
2894
+ doc = JSON.parse(readFileSync10(file, "utf8"));
2776
2895
  } catch {
2777
2896
  return false;
2778
2897
  }
@@ -2806,7 +2925,7 @@ function removeWorkspaceMcpEnabledKeys(home) {
2806
2925
  const db = join18(storage, name, "state.vscdb");
2807
2926
  if (!existsSync8(db)) continue;
2808
2927
  try {
2809
- execFileSync4(
2928
+ execFileSync5(
2810
2929
  "sqlite3",
2811
2930
  [
2812
2931
  db,
@@ -2832,7 +2951,7 @@ function findWorkspaceStorageDir(storage, repo) {
2832
2951
  }
2833
2952
  for (const name of entries) {
2834
2953
  try {
2835
- const doc = JSON.parse(readFileSync12(join18(storage, name, "workspace.json"), "utf8"));
2954
+ const doc = JSON.parse(readFileSync10(join18(storage, name, "workspace.json"), "utf8"));
2836
2955
  if (typeof doc.folder !== "string") continue;
2837
2956
  let folder;
2838
2957
  try {
@@ -2855,7 +2974,7 @@ function ensureWorkspaceMcpEnabled(cwd, opts = {}) {
2855
2974
  if (!dir) return "failed";
2856
2975
  const db = join18(dir, "state.vscdb");
2857
2976
  if (!existsSync8(db)) return "failed";
2858
- const sqlite = opts.sqlite ?? execFileSync4;
2977
+ const sqlite = opts.sqlite ?? execFileSync5;
2859
2978
  const run2 = (sql) => sqlite("sqlite3", [db, ".timeout 3000", sql], {
2860
2979
  encoding: "utf8",
2861
2980
  timeout: SQLITE_TIMEOUT_MS,
@@ -2903,6 +3022,14 @@ function isSyntheticUserText(text) {
2903
3022
  const s = text.trimStart();
2904
3023
  return s.startsWith("# AGENTS.md instructions for ") || s.startsWith("<environment_context>");
2905
3024
  }
3025
+ var AGENTS_BLOCK_HEADER = /^# AGENTS\.md instructions(?: for [^\n]*)?\n/;
3026
+ var STARTUP_TAG_BLOCK = /^<(recommended_plugins|environment_context)>(?:(?!<\1>)[\s\S])*<\/\1>$/;
3027
+ function isStartupItem(text) {
3028
+ const s = text.trim();
3029
+ if (AGENTS_BLOCK_HEADER.test(s))
3030
+ return s.includes("<INSTRUCTIONS>") && s.includes("</INSTRUCTIONS>");
3031
+ return STARTUP_TAG_BLOCK.test(s);
3032
+ }
2906
3033
  function contentText(content) {
2907
3034
  return (Array.isArray(content) ? content : []).filter((c) => c && typeof c.text === "string").map((c) => c.text).join("\n");
2908
3035
  }
@@ -2919,7 +3046,10 @@ function fallbackUserText(payload) {
2919
3046
  if (Array.isArray(content) && Array.isArray(kinds) && kinds.length === content.length && kinds.every((kind) => typeof kind === "string" && kind.length > 0)) {
2920
3047
  return contentText(content.filter((_, index) => !startupKinds.has(kinds[index])));
2921
3048
  }
2922
- const text = contentText(content);
3049
+ const items = (Array.isArray(content) ? content : []).filter(
3050
+ (c) => !(c && typeof c.text === "string" && isStartupItem(stripInjectedMemory(c.text)))
3051
+ );
3052
+ const text = contentText(items);
2923
3053
  return isSyntheticUserText(stripInjectedMemory(text)) ? "" : text;
2924
3054
  }
2925
3055
  function isUserMessageEvent(line) {
@@ -3096,7 +3226,7 @@ function readCopilotTranscript(path) {
3096
3226
  }
3097
3227
 
3098
3228
  // src/core/transcript-grok.ts
3099
- import { existsSync as existsSync9, readFileSync as readFileSync13, readdirSync as readdirSync3 } from "fs";
3229
+ import { existsSync as existsSync9, readFileSync as readFileSync11, readdirSync as readdirSync3 } from "fs";
3100
3230
  import { homedir as homedir9 } from "os";
3101
3231
  import { join as join19 } from "path";
3102
3232
  var CHAT_HISTORY = "chat_history.jsonl";
@@ -3107,7 +3237,7 @@ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
3107
3237
  try {
3108
3238
  for (const candidate of readdirSync3(sessionsDir)) {
3109
3239
  const directory = join19(sessionsDir, candidate);
3110
- if (readFileSync13(join19(directory, ".cwd"), "utf8").trim() === cwd) {
3240
+ if (readFileSync11(join19(directory, ".cwd"), "utf8").trim() === cwd) {
3111
3241
  return join19(directory, sessionId, CHAT_HISTORY);
3112
3242
  }
3113
3243
  }
@@ -3458,7 +3588,7 @@ function readDroidTranscript(path) {
3458
3588
  }
3459
3589
 
3460
3590
  // src/core/transcript-zcode.ts
3461
- import { readFileSync as readFileSync14 } from "fs";
3591
+ import { readFileSync as readFileSync12 } from "fs";
3462
3592
  function messageText(content) {
3463
3593
  if (typeof content === "string") return content.trim();
3464
3594
  if (!Array.isArray(content)) return "";
@@ -3468,7 +3598,7 @@ function readZcodeTranscript(path) {
3468
3598
  if (!path) return [];
3469
3599
  let body;
3470
3600
  try {
3471
- body = readFileSync14(path, "utf8");
3601
+ body = readFileSync12(path, "utf8");
3472
3602
  } catch {
3473
3603
  return [];
3474
3604
  }
@@ -3627,6 +3757,135 @@ function readKimiTranscript(path) {
3627
3757
  return turns;
3628
3758
  }
3629
3759
 
3760
+ // src/core/transcript-workbuddy.ts
3761
+ function messageText2(content) {
3762
+ if (typeof content === "string") return content;
3763
+ if (!Array.isArray(content)) return "";
3764
+ return content.filter((b) => b && typeof b.text === "string").map((b) => b.text).join("\n");
3765
+ }
3766
+ var USER_QUERY_RE = /^\s*<user_query>([\s\S]*?)<\/user_query>\s*(?:<image_local_path>[\s\S]*?<\/image_local_path>\s*)?$/;
3767
+ function unwrapUserQuery(text) {
3768
+ const match = USER_QUERY_RE.exec(text);
3769
+ return (match ? match[1] : text).trim();
3770
+ }
3771
+ function isSyntheticUserText2(text) {
3772
+ const s = text.trimStart();
3773
+ return s.startsWith("<cb_summary>") || s.startsWith("<conversation_history_summary>") || s.startsWith("Use the TaskOutput tool ");
3774
+ }
3775
+ function parseArgs2(raw) {
3776
+ if (!raw) return void 0;
3777
+ try {
3778
+ return JSON.parse(raw);
3779
+ } catch {
3780
+ return raw;
3781
+ }
3782
+ }
3783
+ function stampOf3(line) {
3784
+ return typeof line.timestamp === "number" ? { timestamp: new Date(line.timestamp).toISOString() } : {};
3785
+ }
3786
+ function readWorkbuddyTranscript(path) {
3787
+ const turns = [];
3788
+ for (const rawLine of readJsonl(path)) {
3789
+ const trimmed = rawLine.trim();
3790
+ if (!trimmed) continue;
3791
+ let parsed;
3792
+ try {
3793
+ parsed = JSON.parse(trimmed);
3794
+ } catch {
3795
+ continue;
3796
+ }
3797
+ if (typeof parsed !== "object" || parsed === null) continue;
3798
+ const line = parsed;
3799
+ const stamp = stampOf3(line);
3800
+ if (line.type === "message") {
3801
+ if (line.role !== "user" && line.role !== "assistant") continue;
3802
+ let text = stripInjectedMemory(messageText2(line.content)).trim();
3803
+ if (!text) continue;
3804
+ if (line.role === "user") {
3805
+ if (isSyntheticUserText2(text)) continue;
3806
+ text = unwrapUserQuery(text);
3807
+ if (!text) continue;
3808
+ }
3809
+ turns.push({ role: line.role, content: text, ...stamp });
3810
+ } else if (line.type === "function_call" && typeof line.name === "string") {
3811
+ turns.push({
3812
+ role: "action",
3813
+ content: actionLine(line.name, parseArgs2(line.arguments)),
3814
+ ...stamp
3815
+ });
3816
+ }
3817
+ }
3818
+ return turns;
3819
+ }
3820
+
3821
+ // src/core/transcript-codebuddy-ide.ts
3822
+ import { readFileSync as readFileSync13 } from "fs";
3823
+ import { basename as basename3, dirname as dirname12, join as join22 } from "path";
3824
+ var IDE_CONTEXT_RE = /<(user_info|git_status|additional_data|system_reminder)\b[\s\S]*?<\/\1>/g;
3825
+ function readJson(path) {
3826
+ try {
3827
+ return JSON.parse(readFileSync13(path, "utf8"));
3828
+ } catch {
3829
+ return void 0;
3830
+ }
3831
+ }
3832
+ function ideUserText(raw) {
3833
+ let text = stripInjectedMemory(raw).replace(IDE_CONTEXT_RE, "").trim();
3834
+ if (!text || isSyntheticUserText2(text)) return "";
3835
+ return unwrapUserQuery(text).trim();
3836
+ }
3837
+ function readCodebuddyIdeTranscript(indexPath) {
3838
+ const index = readJson(indexPath);
3839
+ const entries = index?.messages;
3840
+ if (!Array.isArray(entries)) return [];
3841
+ const messagesDir = join22(dirname12(indexPath), "messages");
3842
+ const turns = [];
3843
+ for (const entry of entries) {
3844
+ const id = entry?.id;
3845
+ if (typeof id !== "string") continue;
3846
+ const file = readJson(join22(messagesDir, `${id}.json`));
3847
+ const encoded = file?.message;
3848
+ if (typeof encoded !== "string") continue;
3849
+ let inner;
3850
+ try {
3851
+ inner = JSON.parse(encoded);
3852
+ } catch {
3853
+ continue;
3854
+ }
3855
+ const role = typeof inner.role === "string" ? inner.role : file?.role;
3856
+ const isUser = role === "user";
3857
+ const isAssistant = role === "assistant";
3858
+ const stamp = typeof file?.createdAt === "string" ? { timestamp: file.createdAt } : {};
3859
+ const blocks = Array.isArray(inner.content) ? inner.content : [];
3860
+ const texts = [];
3861
+ const calls = [];
3862
+ for (const block of blocks) {
3863
+ if (!block || typeof block !== "object") continue;
3864
+ const { type, text, toolName, args } = block;
3865
+ if (type === "text" && typeof text === "string") texts.push(text);
3866
+ else if (type === "tool-call" && typeof toolName === "string")
3867
+ calls.push({ name: toolName, args });
3868
+ }
3869
+ if (texts.length) {
3870
+ const raw = texts.join("\n");
3871
+ if (isUser) {
3872
+ const text = ideUserText(raw);
3873
+ if (text) turns.push({ role: "user", content: text, ...stamp });
3874
+ } else if (isAssistant) {
3875
+ const text = stripInjectedMemory(raw).trim();
3876
+ if (text) turns.push({ role: "assistant", content: text, ...stamp });
3877
+ }
3878
+ }
3879
+ for (const call of calls) {
3880
+ turns.push({ role: "action", content: actionLine(call.name, call.args), ...stamp });
3881
+ }
3882
+ }
3883
+ return turns;
3884
+ }
3885
+ function readCodebuddyTranscript(path) {
3886
+ return basename3(path) === "index.json" ? readCodebuddyIdeTranscript(path) : readWorkbuddyTranscript(path);
3887
+ }
3888
+
3630
3889
  // src/harness/hook-lifecycle.ts
3631
3890
  var cursorCwd = (ev) => ev.cwd ?? ev.workspace_root ?? (Array.isArray(ev.workspace_roots) ? ev.workspace_roots[0] : void 0);
3632
3891
  var claudePrompt = {
@@ -3732,6 +3991,35 @@ var standardSessionStart = (harness) => ({
3732
3991
  }
3733
3992
  })
3734
3993
  });
3994
+ var genieSessionStart = (harness) => {
3995
+ const base = standardSessionStart(harness);
3996
+ return {
3997
+ ...base,
3998
+ parse: (ev) => ({
3999
+ cwd: ev.cwd || process.env.CODEBUDDY_PROJECT_DIR,
4000
+ sessionId: ev.session_id
4001
+ }),
4002
+ emit: (out) => ({ ...base.emit(out), suppressOutput: true })
4003
+ };
4004
+ };
4005
+ var geniePrompt = (harness) => ({
4006
+ ...claudePrompt,
4007
+ harness,
4008
+ emit: (context, notice, ev) => ({
4009
+ ...claudePrompt.emit(context, notice, ev),
4010
+ suppressOutput: true
4011
+ })
4012
+ });
4013
+ var genieRetain = (harness, readTranscript) => ({
4014
+ hostTimeoutSec: 60,
4015
+ harness,
4016
+ parse: (ev) => ({
4017
+ sessionId: ev.session_id,
4018
+ transcriptPath: ev.transcript_path,
4019
+ cwd: ev.cwd
4020
+ }),
4021
+ readTranscript
4022
+ });
3735
4023
  var notGrokHosted = () => !process.env.GROK_HOOK_EVENT;
3736
4024
  var HOOK_HARNESSES = {
3737
4025
  "claude-code": {
@@ -3929,17 +4217,29 @@ var HOOK_HARNESSES = {
3929
4217
  prompt: { event: "UserPromptSubmit", entry: "grok-hook.js", timeout: 30 },
3930
4218
  stop: { event: "Stop", entry: "grok-stop-hook.js", timeout: 60 }
3931
4219
  },
4220
+ // Grok hands the model `additionalContext` from TOOL hooks only: SessionStart is observe-only
4221
+ // and UserPromptSubmit can only block (#5467). Both stash their context instead, and the
4222
+ // prompt entry, also registered on PostToolUse, delivers it beside the next tool result.
4223
+ additionalHooks: [{ event: "PostToolUse", entry: "grok-hook.js", timeout: 30 }],
3932
4224
  sessionStart: {
3933
4225
  ...standardSessionStart("grok-build"),
3934
4226
  // Grok's wire envelope is camelCase, unlike Claude's similarly named hook events.
3935
4227
  parse: (ev) => ({
3936
4228
  cwd: ev.cwd,
3937
4229
  sessionId: ev.sessionId
3938
- })
4230
+ }),
4231
+ deferContextToToolHook: true
3939
4232
  },
3940
4233
  prompt: {
3941
4234
  ...claudePrompt,
3942
4235
  harness: "grok-build",
4236
+ toolHook: {
4237
+ // Grok names the event twice: snake_case `hookEventName`, plus a Claude-named alias.
4238
+ accept: (ev) => ev.hookEventName === "post_tool_use" || ev.hook_event_name === "PostToolUse",
4239
+ emit: (context) => ({
4240
+ hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: context }
4241
+ })
4242
+ },
3943
4243
  parse: (ev) => ({
3944
4244
  prompt: ev.prompt,
3945
4245
  cwd: ev.cwd,
@@ -4173,37 +4473,79 @@ var HOOK_HARNESSES = {
4173
4473
  },
4174
4474
  readTranscript: readKimiTranscript
4175
4475
  }
4476
+ },
4477
+ /**
4478
+ * WorkBuddy (Tencent's AI workbench) keeps a durable transcript at
4479
+ * ~/.workbuddy/projects/<cwd-encoded>/<uuid>.jsonl and speaks Claude's hook protocol —
4480
+ * `session_id` / `transcript_path` / `cwd` in, hookSpecificOutput + systemMessage out — apart
4481
+ * from the two quirks genieSessionStart/geniePrompt handle. The other host-specific piece is the
4482
+ * transcript SCHEMA: `type:"message"` records carrying top-level `role`/`content`, which
4483
+ * core/transcript-workbuddy.ts normalizes. Its Stop payload fills `transcript_path` for real (the
4484
+ * engine's own getHookTranscriptPath), so it retains through `readTranscript` like every other
4485
+ * file-backed host rather than the journal ZCode needs.
4486
+ * CodeBuddy Code ships the same @genie/agent-cli engine and reuses this reader (see `codebuddy`).
4487
+ */
4488
+ workbuddy: {
4489
+ configStyle: "nested",
4490
+ install: {
4491
+ sessionStart: { event: "SessionStart", entry: "workbuddy-sessionstart-hook.js", timeout: 30 },
4492
+ prompt: { event: "UserPromptSubmit", entry: "workbuddy-hook.js", timeout: 30 },
4493
+ stop: { event: "Stop", entry: "workbuddy-stop-hook.js", timeout: 60 }
4494
+ },
4495
+ sessionStart: genieSessionStart("workbuddy"),
4496
+ prompt: geniePrompt("workbuddy"),
4497
+ retain: genieRetain("workbuddy", readWorkbuddyTranscript)
4498
+ },
4499
+ /**
4500
+ * CodeBuddy — the same `@genie/agent-cli` engine WorkBuddy ships, running under its own product
4501
+ * config (`~/.codebuddy`; WorkBuddy only renames the home folder). Hook names and payload shape
4502
+ * are identical, so this spec differs from `workbuddy` in the files the installer writes, the
4503
+ * harness name stamped on what it retains — and ONE thing more: CodeBuddy ships in two hosts whose
4504
+ * transcripts do NOT look alike. CodeBuddy Code (the CLI) writes the WorkBuddy JSONL, while the
4505
+ * IDE hands the Stop hook its own `<conversation>/index.json` directory layout. So the reader is
4506
+ * a dispatcher on the shape it was handed (core/transcript-codebuddy-ide.ts).
4507
+ */
4508
+ codebuddy: {
4509
+ configStyle: "nested",
4510
+ install: {
4511
+ sessionStart: { event: "SessionStart", entry: "codebuddy-sessionstart-hook.js", timeout: 30 },
4512
+ prompt: { event: "UserPromptSubmit", entry: "codebuddy-hook.js", timeout: 30 },
4513
+ stop: { event: "Stop", entry: "codebuddy-stop-hook.js", timeout: 60 }
4514
+ },
4515
+ sessionStart: genieSessionStart("codebuddy"),
4516
+ prompt: geniePrompt("codebuddy"),
4517
+ retain: genieRetain("codebuddy", readCodebuddyTranscript)
4176
4518
  }
4177
4519
  };
4178
4520
 
4179
4521
  // src/core/history.ts
4180
- import { execFileSync as execFileSync5 } from "child_process";
4522
+ import { execFileSync as execFileSync6 } from "child_process";
4181
4523
  import {
4182
4524
  closeSync as closeSync2,
4183
4525
  existsSync as existsSync12,
4184
4526
  openSync as openSync2,
4185
4527
  readdirSync as readdirSync5,
4186
- readFileSync as readFileSync15,
4528
+ readFileSync as readFileSync14,
4187
4529
  readSync as readSync2,
4188
4530
  statSync as statSync4
4189
4531
  } from "fs";
4190
4532
  import { createHash as createHash5 } from "crypto";
4191
4533
  import { homedir as homedir12 } from "os";
4192
- import { join as join22 } from "path";
4534
+ import { join as join23 } from "path";
4193
4535
  import * as zlib2 from "zlib";
4194
4536
 
4195
4537
  // src/core/transcript-dsh.ts
4196
4538
  function textOf(message) {
4197
4539
  return (message.content || []).filter((block) => block?.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n").trim();
4198
4540
  }
4199
- function stampOf3(event) {
4541
+ function stampOf4(event) {
4200
4542
  return typeof event.time === "number" ? { timestamp: new Date(event.time).toISOString() } : {};
4201
4543
  }
4202
4544
  function readDshEvents(events) {
4203
4545
  const turns = [];
4204
4546
  for (const event of events || []) {
4205
4547
  if (!event || typeof event !== "object") continue;
4206
- const stamp = stampOf3(event);
4548
+ const stamp = stampOf4(event);
4207
4549
  if (event.type === "user/message") {
4208
4550
  const message = event.data;
4209
4551
  if (!message || message.source?.kind !== "user") continue;
@@ -4219,14 +4561,14 @@ function readDshEvents(events) {
4219
4561
  if (!call?.name) continue;
4220
4562
  turns.push({
4221
4563
  role: "action",
4222
- content: actionLine(call.name, parseArgs2(call.arguments)),
4564
+ content: actionLine(call.name, parseArgs3(call.arguments)),
4223
4565
  ...stamp
4224
4566
  });
4225
4567
  }
4226
4568
  }
4227
4569
  return turns;
4228
4570
  }
4229
- function parseArgs2(raw) {
4571
+ function parseArgs3(raw) {
4230
4572
  if (!raw) return void 0;
4231
4573
  try {
4232
4574
  return JSON.parse(raw);
@@ -4264,7 +4606,7 @@ function renderMessage(m) {
4264
4606
  return out;
4265
4607
  }
4266
4608
  function readPiTranscript(path) {
4267
- const turns = [];
4609
+ const entries = [];
4268
4610
  for (const rawLine of readJsonl(path)) {
4269
4611
  const trimmed = rawLine.trim();
4270
4612
  if (!trimmed) continue;
@@ -4274,9 +4616,14 @@ function readPiTranscript(path) {
4274
4616
  } catch {
4275
4617
  continue;
4276
4618
  }
4277
- if (typeof parsed !== "object" || parsed === null) continue;
4278
- const entry = parsed;
4279
- if (entry.type !== "message" || !entry.message) continue;
4619
+ if (typeof parsed === "object" && parsed !== null) entries.push(parsed);
4620
+ }
4621
+ return readPiEntries(entries);
4622
+ }
4623
+ function readPiEntries(entries) {
4624
+ const turns = [];
4625
+ for (const entry of entries) {
4626
+ if (!entry || entry.type !== "message" || !entry.message) continue;
4280
4627
  for (const turn of renderMessage(entry.message)) {
4281
4628
  turns.push(entry.timestamp ? { ...turn, timestamp: entry.timestamp } : turn);
4282
4629
  }
@@ -4334,7 +4681,7 @@ function zstdDecompressFrames(buffer) {
4334
4681
 
4335
4682
  // src/core/history.ts
4336
4683
  function claudeProjectDir(repoDir, home = homedir12()) {
4337
- return join22(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
4684
+ return join23(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
4338
4685
  }
4339
4686
  function piSessionDir(repoDir) {
4340
4687
  return `--${repoDir.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
@@ -4344,7 +4691,7 @@ function withinRepo(dir, repoDir) {
4344
4691
  }
4345
4692
  function claudeSessionCwd(file) {
4346
4693
  try {
4347
- for (const line of readFileSync15(file, "utf8").split("\n", 400)) {
4694
+ for (const line of readFileSync14(file, "utf8").split("\n", 400)) {
4348
4695
  if (!line.includes('"cwd"')) continue;
4349
4696
  const cwd = JSON.parse(line).cwd;
4350
4697
  if (cwd) return cwd;
@@ -4386,13 +4733,13 @@ function listDir(dir) {
4386
4733
  }
4387
4734
  }
4388
4735
  function jsonlFiles(dir) {
4389
- return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join22(dir, f));
4736
+ return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join23(dir, f));
4390
4737
  }
4391
4738
  function claudeHistory(repoDir, home) {
4392
- const root = join22(home, ".claude", "projects");
4739
+ const root = join23(home, ".claude", "projects");
4393
4740
  const exact = claudeProjectDir(repoDir, home);
4394
4741
  const prefix = exact + "-";
4395
- const dirs = listDir(root).map((d) => join22(root, d)).filter((d) => d === exact || d.startsWith(prefix));
4742
+ const dirs = listDir(root).map((d) => join23(root, d)).filter((d) => d === exact || d.startsWith(prefix));
4396
4743
  const sessions = [];
4397
4744
  let unattributed = 0;
4398
4745
  for (const file of dirs.flatMap(jsonlFiles)) {
@@ -4412,12 +4759,12 @@ function claudeHistory(repoDir, home) {
4412
4759
  return { supported: true, sessions, unattributed };
4413
4760
  }
4414
4761
  function codexHistory(repoDir, home) {
4415
- const root = join22(home, ".codex", "sessions");
4762
+ const root = join23(home, ".codex", "sessions");
4416
4763
  if (!existsSync12(root)) return { supported: true, sessions: [] };
4417
4764
  const files = [];
4418
4765
  const walk = (dir) => {
4419
4766
  for (const entry of readdirSync5(dir)) {
4420
- const p = join22(dir, entry);
4767
+ const p = join23(dir, entry);
4421
4768
  if (statSync4(p).isDirectory()) walk(p);
4422
4769
  else if (entry.endsWith(".jsonl")) files.push(p);
4423
4770
  }
@@ -4447,13 +4794,13 @@ function dcodeTranscriptPath(root, threadId) {
4447
4794
  const suffix = `--${digest}.jsonl`;
4448
4795
  try {
4449
4796
  const match = readdirSync5(root).find((entry) => entry.endsWith(suffix));
4450
- return match ? join22(root, match) : void 0;
4797
+ return match ? join23(root, match) : void 0;
4451
4798
  } catch {
4452
4799
  return void 0;
4453
4800
  }
4454
4801
  }
4455
4802
  function dcodeHistory(repoDir, home, runCli) {
4456
- const root = join22(process.env.DEEPAGENTS_HOME || join22(home, ".deepagents"), "transcripts");
4803
+ const root = join23(process.env.DEEPAGENTS_HOME || join23(home, ".deepagents"), "transcripts");
4457
4804
  if (!existsSync12(root)) return { supported: true, sessions: [] };
4458
4805
  let listed;
4459
4806
  try {
@@ -4494,7 +4841,7 @@ function dcodeHistory(repoDir, home, runCli) {
4494
4841
  return { supported: true, sessions, ...unattributed ? { unattributed } : {} };
4495
4842
  }
4496
4843
  function dshHistory(repoDir, home) {
4497
- const root = process.env.DSH_HOME ? join22(process.env.DSH_HOME, "sessions") : join22(home, ".dsh", "sessions");
4844
+ const root = process.env.DSH_HOME ? join23(process.env.DSH_HOME, "sessions") : join23(home, ".dsh", "sessions");
4498
4845
  if (!existsSync12(root)) return { supported: true, sessions: [] };
4499
4846
  if (typeof zlib2.zstdDecompressSync !== "function") {
4500
4847
  return {
@@ -4505,15 +4852,15 @@ function dshHistory(repoDir, home) {
4505
4852
  }
4506
4853
  const sessions = [];
4507
4854
  let unattributed = 0;
4508
- for (const dir of readdirSync5(root).map((project) => join22(root, project))) {
4855
+ for (const dir of readdirSync5(root).map((project) => join23(root, project))) {
4509
4856
  let sessionDirs;
4510
4857
  try {
4511
- sessionDirs = readdirSync5(dir).map((id) => join22(dir, id));
4858
+ sessionDirs = readdirSync5(dir).map((id) => join23(dir, id));
4512
4859
  } catch {
4513
4860
  continue;
4514
4861
  }
4515
4862
  for (const sessionDir of sessionDirs) {
4516
- const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join22(sessionDir, name)).find((candidate) => existsSync12(candidate));
4863
+ const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join23(sessionDir, name)).find((candidate) => existsSync12(candidate));
4517
4864
  if (!file) continue;
4518
4865
  try {
4519
4866
  const lines = readDshLog(file);
@@ -4539,7 +4886,7 @@ function dshHistory(repoDir, home) {
4539
4886
  return { supported: true, sessions, unattributed };
4540
4887
  }
4541
4888
  function readDshLog(file) {
4542
- const bytes = readFileSync15(file);
4889
+ const bytes = readFileSync14(file);
4543
4890
  const text = file.endsWith(".zstd") ? zstdDecompressFrames(bytes) : bytes.toString("utf8");
4544
4891
  return text.split("\n").filter((line) => line.trim());
4545
4892
  }
@@ -4565,18 +4912,18 @@ function piFamilySessions(files, repoDir) {
4565
4912
  return { supported: true, sessions, unattributed };
4566
4913
  }
4567
4914
  function piHistory(repoDir, home) {
4568
- const root = join22(home, ".pi", "agent", "sessions");
4915
+ const root = join23(home, ".pi", "agent", "sessions");
4569
4916
  if (!existsSync12(root)) return { supported: true, sessions: [] };
4570
4917
  const exact = piSessionDir(repoDir);
4571
4918
  const nested = `${exact.slice(0, -2)}-`;
4572
4919
  const files = [];
4573
4920
  for (const dir of listDir(root).filter((d) => d === exact || d.startsWith(nested))) {
4574
- files.push(...jsonlFiles(join22(root, dir)));
4921
+ files.push(...jsonlFiles(join23(root, dir)));
4575
4922
  }
4576
4923
  return piFamilySessions(files, repoDir);
4577
4924
  }
4578
4925
  function primeAgentHistory(repoDir, home) {
4579
- const root = join22(home, ".prime", "agent", "sessions");
4926
+ const root = join23(home, ".prime", "agent", "sessions");
4580
4927
  if (!existsSync12(root)) return { supported: true, sessions: [] };
4581
4928
  return piFamilySessions(jsonlFiles(root), repoDir);
4582
4929
  }
@@ -4591,7 +4938,7 @@ function importLocalHistory(harness, repoDir, home = homedir12(), runDcodeCli) {
4591
4938
  return dcodeHistory(
4592
4939
  repoDir,
4593
4940
  home,
4594
- runDcodeCli ?? ((args) => execFileSync5("dcode", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }))
4941
+ runDcodeCli ?? ((args) => execFileSync6("dcode", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }))
4595
4942
  );
4596
4943
  case "dsh":
4597
4944
  return dshHistory(repoDir, home);
@@ -4624,7 +4971,7 @@ function importLocalHistory(harness, repoDir, home = homedir12(), runDcodeCli) {
4624
4971
  }
4625
4972
 
4626
4973
  // src/install-ui.ts
4627
- import { execFileSync as execFileSync6 } from "child_process";
4974
+ import { execFileSync as execFileSync7 } from "child_process";
4628
4975
  import { readSync as readSync3 } from "fs";
4629
4976
  function fitSelectRow(label, hint, width) {
4630
4977
  const room = Math.max(10, width - 6);
@@ -4719,7 +5066,7 @@ function createInstallerUi(o) {
4719
5066
  return `${bar} ${question}`;
4720
5067
  },
4721
5068
  select(question, options, defaultIndex) {
4722
- const stty = (args) => execFileSync6("stty", args, { stdio: ["inherit", "pipe", "pipe"], encoding: "utf8" }).trim();
5069
+ const stty = (args) => execFileSync7("stty", args, { stdio: ["inherit", "pipe", "pipe"], encoding: "utf8" }).trim();
4723
5070
  let savedTty;
4724
5071
  try {
4725
5072
  savedTty = stty(["-g"]);
@@ -4828,13 +5175,13 @@ function createInstallerUi(o) {
4828
5175
  // src/installer.ts
4829
5176
  var MARKER = "coding-agents";
4830
5177
  var ZCODE_MAX_OUTPUT_BYTES = 32768;
4831
- var zcodeConfigPath = (c) => join23(c.home, ".zcode", "cli", "config.json");
5178
+ var zcodeConfigPath = (c) => join24(c.home, ".zcode", "cli", "config.json");
4832
5179
  function isPlainObject(value) {
4833
5180
  return value !== null && typeof value === "object" && !Array.isArray(value);
4834
5181
  }
4835
- function readJson(path) {
5182
+ function readJson2(path) {
4836
5183
  try {
4837
- const parsed = JSON.parse(readFileSync16(path, "utf8"));
5184
+ const parsed = JSON.parse(readFileSync15(path, "utf8"));
4838
5185
  return isPlainObject(parsed) ? parsed : {};
4839
5186
  } catch {
4840
5187
  return {};
@@ -4850,7 +5197,7 @@ function parseJsonc(text) {
4850
5197
  }
4851
5198
  }
4852
5199
  function writeJson(path, value) {
4853
- mkdirSync7(dirname12(path), { recursive: true });
5200
+ mkdirSync7(dirname13(path), { recursive: true });
4854
5201
  backupOnce(path);
4855
5202
  writeFileSync5(path, JSON.stringify(value, null, 2) + "\n");
4856
5203
  }
@@ -4860,7 +5207,7 @@ function backupOnce(path) {
4860
5207
  }
4861
5208
  }
4862
5209
  function writeJsonc(path, key, value) {
4863
- const text = existsSync13(path) ? readFileSync16(path, "utf8") : "";
5210
+ const text = existsSync13(path) ? readFileSync15(path, "utf8") : "";
4864
5211
  const edits = modify(text, [key], value, {
4865
5212
  formattingOptions: {
4866
5213
  tabSize: 2,
@@ -4871,7 +5218,7 @@ function writeJsonc(path, key, value) {
4871
5218
  }
4872
5219
  });
4873
5220
  const next = applyEdits(text, edits);
4874
- mkdirSync7(dirname12(path), { recursive: true });
5221
+ mkdirSync7(dirname13(path), { recursive: true });
4875
5222
  backupOnce(path);
4876
5223
  writeFileSync5(path, next.endsWith("\n") ? next : `${next}
4877
5224
  `);
@@ -4888,14 +5235,14 @@ function setOrDelete(obj, key, arr) {
4888
5235
  else delete obj[key];
4889
5236
  }
4890
5237
  var cmdHook = (dist, file, timeout) => ({
4891
- hooks: [{ type: "command", command: `node "${join23(dist, file)}"`, timeout }]
5238
+ hooks: [{ type: "command", command: `node "${join24(dist, file)}"`, timeout }]
4892
5239
  });
4893
5240
  var processHook = (dist, file, timeoutMs) => ({
4894
- hooks: [{ type: "process", command: "node", args: [join23(dist, file)], timeoutMs }]
5241
+ hooks: [{ type: "process", command: "node", args: [join24(dist, file)], timeoutMs }]
4895
5242
  });
4896
5243
  var mcpServerEntry = (dist, harness, extraArgs = []) => ({
4897
5244
  command: "node",
4898
- args: [join23(dist, "mcp-server.js"), ...extraArgs],
5245
+ args: [join24(dist, "mcp-server.js"), ...extraArgs],
4899
5246
  env: { HINDSIGHT_MCP_HARNESS: harness }
4900
5247
  });
4901
5248
  function mergeHarnessHooks(hooks, harness, dist) {
@@ -4907,7 +5254,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
4907
5254
  if (installedEvents.has(hook.event)) continue;
4908
5255
  installedEvents.add(hook.event);
4909
5256
  const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : spec.configStyle === "process" ? processHook(dist, hook.entry, hook.timeout) : {
4910
- command: `node "${join23(dist, hook.entry)}"`,
5257
+ command: `node "${join24(dist, hook.entry)}"`,
4911
5258
  ...hook.timeout ? { timeout: hook.timeout } : {}
4912
5259
  };
4913
5260
  hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
@@ -4925,26 +5272,26 @@ function stripHarnessHooks(hooks, harness) {
4925
5272
  function skillsBaseFor(c, harness) {
4926
5273
  const parts = resolveSkillDirs(harness, c.home);
4927
5274
  if (!parts) throw new Error(`${harness} installs a skill but names no directory in SKILL_DIRS`);
4928
- return join23(c.home, ...parts);
5275
+ return join24(c.home, ...parts);
4929
5276
  }
4930
5277
  function installSkill(c, harness) {
4931
- const src = join23(c.pkgRoot, "skill");
4932
- if (!existsSync13(join23(src, "SKILL.md"))) return;
5278
+ const src = join24(c.pkgRoot, "skill");
5279
+ if (!existsSync13(join24(src, "SKILL.md"))) return;
4933
5280
  const skillsBase = skillsBaseFor(c, harness);
4934
- const dst = join23(skillsBase, "hindsight-coding-agent");
5281
+ const dst = join24(skillsBase, "hindsight-coding-agent");
4935
5282
  mkdirSync7(skillsBase, { recursive: true });
4936
5283
  cpSync2(src, dst, { recursive: true });
4937
5284
  c.log?.(`${harness}: skill installed at ${dst}`);
4938
5285
  }
4939
5286
  function uninstallSkill(c, harness) {
4940
- rmSync4(join23(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
5287
+ rmSync4(join24(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
4941
5288
  recursive: true,
4942
5289
  force: true
4943
5290
  });
4944
5291
  }
4945
5292
  function onPath2(bin) {
4946
5293
  try {
4947
- execFileSync7("which", [bin], { stdio: "pipe" });
5294
+ execFileSync8("which", [bin], { stdio: "pipe" });
4948
5295
  return true;
4949
5296
  } catch {
4950
5297
  return false;
@@ -4952,7 +5299,7 @@ function onPath2(bin) {
4952
5299
  }
4953
5300
  function runClinePlugin(args) {
4954
5301
  try {
4955
- execFileSync7("cline", args, { stdio: "pipe" });
5302
+ execFileSync8("cline", args, { stdio: "pipe" });
4956
5303
  return true;
4957
5304
  } catch {
4958
5305
  return false;
@@ -4960,13 +5307,13 @@ function runClinePlugin(args) {
4960
5307
  }
4961
5308
  var OPENCODE_CONFIG_CANDIDATES = ["opencode.jsonc", "opencode.json"];
4962
5309
  function opencodeConfigPath(c) {
4963
- const dir = join23(c.home, ".config", "opencode");
4964
- const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join23(dir, f)).find((p) => existsSync13(p));
4965
- return existing ?? join23(dir, "opencode.json");
5310
+ const dir = join24(c.home, ".config", "opencode");
5311
+ const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join24(dir, f)).find((p) => existsSync13(p));
5312
+ return existing ?? join24(dir, "opencode.json");
4966
5313
  }
4967
5314
  function runDcodePlugin(args) {
4968
5315
  try {
4969
- execFileSync7("dcode", args, { stdio: "pipe" });
5316
+ execFileSync8("dcode", args, { stdio: "pipe" });
4970
5317
  return true;
4971
5318
  } catch {
4972
5319
  return false;
@@ -4976,7 +5323,7 @@ function registerOpencodePlugin(c, name) {
4976
5323
  const path = opencodeConfigPath(c);
4977
5324
  let cfg = {};
4978
5325
  if (existsSync13(path)) {
4979
- const parsed = parseJsonc(readFileSync16(path, "utf8"));
5326
+ const parsed = parseJsonc(readFileSync15(path, "utf8"));
4980
5327
  if (!parsed) {
4981
5328
  c.log?.(`${name}: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
4982
5329
  return;
@@ -4990,7 +5337,7 @@ function registerOpencodePlugin(c, name) {
4990
5337
  function unregisterOpencodePlugin(c, name) {
4991
5338
  const path = opencodeConfigPath(c);
4992
5339
  if (!existsSync13(path)) return;
4993
- const cfg = parseJsonc(readFileSync16(path, "utf8"));
5340
+ const cfg = parseJsonc(readFileSync15(path, "utf8"));
4994
5341
  if (!cfg || !Array.isArray(cfg.plugin)) return;
4995
5342
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
4996
5343
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -4998,7 +5345,7 @@ function unregisterOpencodePlugin(c, name) {
4998
5345
  }
4999
5346
  var opencode = {
5000
5347
  name: "opencode",
5001
- detect: (c) => onPath2("opencode") || existsSync13(join23(c.home, ".config", "opencode")),
5348
+ detect: (c) => onPath2("opencode") || existsSync13(join24(c.home, ".config", "opencode")),
5002
5349
  install: (c) => registerOpencodePlugin(c, "opencode"),
5003
5350
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode")
5004
5351
  };
@@ -5009,16 +5356,16 @@ var opencode2 = {
5009
5356
  uninstall: (c) => unregisterOpencodePlugin(c, "opencode2")
5010
5357
  };
5011
5358
  function piFamilyInstaller(harness, configDir) {
5012
- const settings = (c) => join23(c.home, ...configDir, "settings.json");
5359
+ const settings = (c) => join24(c.home, ...configDir, "settings.json");
5013
5360
  return {
5014
5361
  name: harness,
5015
5362
  // Both hosts name their executable exactly as we name the harness, so the harness id doubles
5016
5363
  // as the PATH probe here — unlike, say, antigravity-cli, whose binary is `agy`.
5017
- detect: (c) => onPath2(harness) || existsSync13(join23(c.home, ...configDir)),
5364
+ detect: (c) => onPath2(harness) || existsSync13(join24(c.home, ...configDir)),
5018
5365
  install(c) {
5019
5366
  const path = settings(c);
5020
- const cfg = readJson(path);
5021
- const entry = join23(c.pkgRoot, "dist", `${harness}.js`);
5367
+ const cfg = readJson2(path);
5368
+ const entry = join24(c.pkgRoot, "dist", `${harness}.js`);
5022
5369
  const exts = Array.isArray(cfg.extensions) ? cfg.extensions : [];
5023
5370
  cfg.extensions = [...exts.filter((p) => !String(p).includes(MARKER)), entry];
5024
5371
  writeJson(path, cfg);
@@ -5029,7 +5376,7 @@ function piFamilyInstaller(harness, configDir) {
5029
5376
  uninstallSkill(c, harness);
5030
5377
  const path = settings(c);
5031
5378
  if (!existsSync13(path)) return;
5032
- const cfg = readJson(path);
5379
+ const cfg = readJson2(path);
5033
5380
  if (Array.isArray(cfg.extensions)) {
5034
5381
  cfg.extensions = cfg.extensions.filter((p) => !String(p).includes(MARKER));
5035
5382
  if (!cfg.extensions.length) delete cfg.extensions;
@@ -5043,25 +5390,25 @@ var pi = piFamilyInstaller("pi", [".pi", "agent"]);
5043
5390
  var primeAgent = piFamilyInstaller("prime-agent", [".prime", "agent"]);
5044
5391
  var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
5045
5392
  function kiloConfigPath(c) {
5046
- const dir = join23(c.home, ".config", "kilo");
5047
- const existing = KILO_CONFIG_CANDIDATES.map((f) => join23(dir, f)).find((p) => existsSync13(p));
5048
- return existing ?? join23(dir, "kilo.json");
5393
+ const dir = join24(c.home, ".config", "kilo");
5394
+ const existing = KILO_CONFIG_CANDIDATES.map((f) => join24(dir, f)).find((p) => existsSync13(p));
5395
+ return existing ?? join24(dir, "kilo.json");
5049
5396
  }
5050
5397
  var kilo = {
5051
5398
  name: "kilo",
5052
- detect: (c) => onPath2("kilo") || existsSync13(join23(c.home, ".config", "kilo")),
5399
+ detect: (c) => onPath2("kilo") || existsSync13(join24(c.home, ".config", "kilo")),
5053
5400
  install(c) {
5054
5401
  const path = kiloConfigPath(c);
5055
5402
  let cfg = {};
5056
5403
  if (existsSync13(path)) {
5057
- const parsed = parseJsonc(readFileSync16(path, "utf8"));
5404
+ const parsed = parseJsonc(readFileSync15(path, "utf8"));
5058
5405
  if (!parsed) {
5059
5406
  c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
5060
5407
  return;
5061
5408
  }
5062
5409
  cfg = parsed;
5063
5410
  }
5064
- const entry = pathToFileURL(join23(c.dist, "kilo.js")).href;
5411
+ const entry = pathToFileURL(join24(c.dist, "kilo.js")).href;
5065
5412
  const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
5066
5413
  writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), entry]);
5067
5414
  c.log?.(`kilo: plugin registered in ${path}`);
@@ -5069,7 +5416,7 @@ var kilo = {
5069
5416
  uninstall(c) {
5070
5417
  const path = kiloConfigPath(c);
5071
5418
  if (!existsSync13(path)) return;
5072
- const cfg = parseJsonc(readFileSync16(path, "utf8"));
5419
+ const cfg = parseJsonc(readFileSync15(path, "utf8"));
5073
5420
  if (!cfg || !Array.isArray(cfg.plugin)) return;
5074
5421
  const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
5075
5422
  writeJsonc(path, "plugin", kept.length ? kept : void 0);
@@ -5078,10 +5425,10 @@ var kilo = {
5078
5425
  };
5079
5426
  var claudeCode = {
5080
5427
  name: "claude-code",
5081
- detect: (c) => onPath2("claude") || existsSync13(join23(c.home, ".claude")),
5428
+ detect: (c) => onPath2("claude") || existsSync13(join24(c.home, ".claude")),
5082
5429
  install(c) {
5083
- const path = join23(c.home, ".claude", "settings.json");
5084
- const settings = readJson(path);
5430
+ const path = join24(c.home, ".claude", "settings.json");
5431
+ const settings = readJson2(path);
5085
5432
  settings.hooks = settings.hooks ?? {};
5086
5433
  mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
5087
5434
  writeJson(path, settings);
@@ -5099,20 +5446,20 @@ var claudeCode = {
5099
5446
  "HINDSIGHT_MCP_HARNESS=claude-code",
5100
5447
  "--",
5101
5448
  "node",
5102
- join23(c.dist, "mcp-server.js")
5449
+ join24(c.dist, "mcp-server.js")
5103
5450
  ])) {
5104
5451
  c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
5105
5452
  } else {
5106
5453
  c.log?.(
5107
5454
  `claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
5108
- claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join23(c.dist, "mcp-server.js")}"`
5455
+ claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join24(c.dist, "mcp-server.js")}"`
5109
5456
  );
5110
5457
  }
5111
5458
  },
5112
5459
  uninstall(c) {
5113
- const path = join23(c.home, ".claude", "settings.json");
5460
+ const path = join24(c.home, ".claude", "settings.json");
5114
5461
  if (existsSync13(path)) {
5115
- const settings = readJson(path);
5462
+ const settings = readJson2(path);
5116
5463
  if (settings.hooks) {
5117
5464
  stripHarnessHooks(settings.hooks, "claude-code");
5118
5465
  if (!Object.keys(settings.hooks).length) delete settings.hooks;
@@ -5127,7 +5474,7 @@ var claudeCode = {
5127
5474
  };
5128
5475
  function defaultClaudeMcp(args) {
5129
5476
  try {
5130
- execFileSync7("claude", args, { stdio: "pipe" });
5477
+ execFileSync8("claude", args, { stdio: "pipe" });
5131
5478
  return true;
5132
5479
  } catch {
5133
5480
  return false;
@@ -5136,20 +5483,20 @@ function defaultClaudeMcp(args) {
5136
5483
  var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
5137
5484
  var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
5138
5485
  command = "node"
5139
- args = [${JSON.stringify(join23(dist, "mcp-server.js"))}]
5486
+ args = [${JSON.stringify(join24(dist, "mcp-server.js"))}]
5140
5487
  env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
5141
5488
  var codex = {
5142
5489
  name: "codex",
5143
- detect: (c) => onPath2("codex") || existsSync13(join23(c.home, ".codex")),
5490
+ detect: (c) => onPath2("codex") || existsSync13(join24(c.home, ".codex")),
5144
5491
  install(c) {
5145
- const hooksPath = join23(c.home, ".codex", "hooks.json");
5146
- const cfg = readJson(hooksPath);
5492
+ const hooksPath = join24(c.home, ".codex", "hooks.json");
5493
+ const cfg = readJson2(hooksPath);
5147
5494
  cfg.hooks = cfg.hooks ?? {};
5148
5495
  mergeHarnessHooks(cfg.hooks, "codex", c.dist);
5149
5496
  writeJson(hooksPath, cfg);
5150
5497
  c.log?.(`codex: hooks merged into ${hooksPath}`);
5151
- const tomlPath = join23(c.home, ".codex", "config.toml");
5152
- const existing = existsSync13(tomlPath) ? readFileSync16(tomlPath, "utf8") : "";
5498
+ const tomlPath = join24(c.home, ".codex", "config.toml");
5499
+ const existing = existsSync13(tomlPath) ? readFileSync15(tomlPath, "utf8") : "";
5153
5500
  const toml = existing.replace(CODEX_MCP_BLOCK_RE, "");
5154
5501
  const additions = [];
5155
5502
  if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
@@ -5168,25 +5515,25 @@ var codex = {
5168
5515
  if (existsSync13(tomlPath) && !existsSync13(`${tomlPath}.hindsight-backup`)) {
5169
5516
  copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
5170
5517
  }
5171
- mkdirSync7(dirname12(tomlPath), { recursive: true });
5518
+ mkdirSync7(dirname13(tomlPath), { recursive: true });
5172
5519
  writeFileSync5(tomlPath, next);
5173
5520
  c.log?.(`codex: wrote ${additions.length} section(s) to ${tomlPath}`);
5174
5521
  }
5175
5522
  installSkill(c, "codex");
5176
5523
  },
5177
5524
  uninstall(c) {
5178
- const hooksPath = join23(c.home, ".codex", "hooks.json");
5525
+ const hooksPath = join24(c.home, ".codex", "hooks.json");
5179
5526
  if (existsSync13(hooksPath)) {
5180
- const cfg = readJson(hooksPath);
5527
+ const cfg = readJson2(hooksPath);
5181
5528
  if (cfg.hooks) {
5182
5529
  stripHarnessHooks(cfg.hooks, "codex");
5183
5530
  writeJson(hooksPath, cfg);
5184
5531
  }
5185
5532
  }
5186
5533
  uninstallSkill(c, "codex");
5187
- const tomlPath = join23(c.home, ".codex", "config.toml");
5534
+ const tomlPath = join24(c.home, ".codex", "config.toml");
5188
5535
  if (existsSync13(tomlPath)) {
5189
- const toml = readFileSync16(tomlPath, "utf8");
5536
+ const toml = readFileSync15(tomlPath, "utf8");
5190
5537
  const cleaned = toml.replace(CODEX_MCP_BLOCK_RE, "");
5191
5538
  if (cleaned !== toml) writeFileSync5(tomlPath, cleaned);
5192
5539
  }
@@ -5202,8 +5549,8 @@ var antigravity = {
5202
5549
  // can consume this integration.
5203
5550
  detect: (c) => onPath2("agy"),
5204
5551
  install(c) {
5205
- const hooksPath = join23(c.home, ".gemini", "config", "hooks.json");
5206
- const hooks = readJson(hooksPath);
5552
+ const hooksPath = join24(c.home, ".gemini", "config", "hooks.json");
5553
+ const hooks = readJson2(hooksPath);
5207
5554
  for (const key of Object.keys(hooks)) {
5208
5555
  if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
5209
5556
  }
@@ -5213,26 +5560,26 @@ var antigravity = {
5213
5560
  setOrDelete(hooks, event, stripOurs(hooks[event]));
5214
5561
  }
5215
5562
  writeJson(hooksPath, hooks);
5216
- const mcpPath = join23(c.home, ".gemini", "config", "mcp_config.json");
5217
- const mcp = readJson(mcpPath);
5563
+ const mcpPath = join24(c.home, ".gemini", "config", "mcp_config.json");
5564
+ const mcp = readJson2(mcpPath);
5218
5565
  mcp.mcpServers = {
5219
5566
  ...mcp.mcpServers ?? {},
5220
5567
  hindsight: mcpServerEntry(c.dist, "antigravity-cli")
5221
5568
  };
5222
5569
  writeJson(mcpPath, mcp);
5223
- const settingsPath = join23(c.home, ".gemini", "antigravity-cli", "settings.json");
5224
- const settings = readJson(settingsPath);
5570
+ const settingsPath = join24(c.home, ".gemini", "antigravity-cli", "settings.json");
5571
+ const settings = readJson2(settingsPath);
5225
5572
  if (!settings.statusLine) {
5226
5573
  settings.statusLine = {
5227
5574
  type: "command",
5228
- command: `node "${join23(c.dist, "antigravity-statusline.js")}"`
5575
+ command: `node "${join24(c.dist, "antigravity-statusline.js")}"`
5229
5576
  };
5230
5577
  writeJson(settingsPath, settings);
5231
5578
  c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
5232
5579
  } else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
5233
5580
  settings.statusLine = {
5234
5581
  type: "command",
5235
- command: `node "${join23(c.dist, "antigravity-statusline.js")}"`
5582
+ command: `node "${join24(c.dist, "antigravity-statusline.js")}"`
5236
5583
  };
5237
5584
  writeJson(settingsPath, settings);
5238
5585
  } else {
@@ -5244,9 +5591,9 @@ var antigravity = {
5244
5591
  installSkill(c, "antigravity-cli");
5245
5592
  },
5246
5593
  uninstall(c) {
5247
- const hooksPath = join23(c.home, ".gemini", "config", "hooks.json");
5594
+ const hooksPath = join24(c.home, ".gemini", "config", "hooks.json");
5248
5595
  if (existsSync13(hooksPath)) {
5249
- const hooks = readJson(hooksPath);
5596
+ const hooks = readJson2(hooksPath);
5250
5597
  if (hooks[MARKER]) {
5251
5598
  stripHarnessHooks(hooks[MARKER], "antigravity-cli");
5252
5599
  if (!Object.keys(hooks[MARKER]).length) delete hooks[MARKER];
@@ -5256,17 +5603,17 @@ var antigravity = {
5256
5603
  }
5257
5604
  writeJson(hooksPath, hooks);
5258
5605
  }
5259
- const mcpPath = join23(c.home, ".gemini", "config", "mcp_config.json");
5606
+ const mcpPath = join24(c.home, ".gemini", "config", "mcp_config.json");
5260
5607
  if (existsSync13(mcpPath)) {
5261
- const mcp = readJson(mcpPath);
5608
+ const mcp = readJson2(mcpPath);
5262
5609
  if (mcp.mcpServers?.hindsight) {
5263
5610
  delete mcp.mcpServers.hindsight;
5264
5611
  writeJson(mcpPath, mcp);
5265
5612
  }
5266
5613
  }
5267
- const settingsPath = join23(c.home, ".gemini", "antigravity-cli", "settings.json");
5614
+ const settingsPath = join24(c.home, ".gemini", "antigravity-cli", "settings.json");
5268
5615
  if (existsSync13(settingsPath)) {
5269
- const settings = readJson(settingsPath);
5616
+ const settings = readJson2(settingsPath);
5270
5617
  if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
5271
5618
  delete settings.statusLine;
5272
5619
  writeJson(settingsPath, settings);
@@ -5278,7 +5625,7 @@ var antigravity = {
5278
5625
  };
5279
5626
  function pathNodeHasSqlite() {
5280
5627
  try {
5281
- execFileSync7("node", ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
5628
+ execFileSync8("node", ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
5282
5629
  return true;
5283
5630
  } catch {
5284
5631
  return false;
@@ -5286,13 +5633,13 @@ function pathNodeHasSqlite() {
5286
5633
  }
5287
5634
  function pathNodeVersion() {
5288
5635
  try {
5289
- return execFileSync7("node", ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
5636
+ return execFileSync8("node", ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
5290
5637
  } catch {
5291
5638
  return "not found";
5292
5639
  }
5293
5640
  }
5294
5641
  function runtimeDir(home) {
5295
- return join23(home, ".hindsight", "coding-agents");
5642
+ return join24(home, ".hindsight", "coding-agents");
5296
5643
  }
5297
5644
  var ORIGIN_FILE = ".install-origin.json";
5298
5645
  function stageRuntime(c) {
@@ -5305,25 +5652,25 @@ function stageRuntime(c) {
5305
5652
  }
5306
5653
  };
5307
5654
  if (same(c.pkgRoot, target)) return c;
5308
- if (!existsSync13(join23(c.dist, "installer.js"))) return c;
5655
+ if (!existsSync13(join24(c.dist, "installer.js"))) return c;
5309
5656
  try {
5310
- rmSync4(join23(target, "dist"), { recursive: true, force: true });
5657
+ rmSync4(join24(target, "dist"), { recursive: true, force: true });
5311
5658
  mkdirSync7(target, { recursive: true });
5312
- cpSync2(c.dist, join23(target, "dist"), { recursive: true });
5313
- const skill = join23(c.pkgRoot, "skill");
5314
- if (existsSync13(skill)) cpSync2(skill, join23(target, "skill"), { recursive: true });
5315
- const pkgJson = join23(c.pkgRoot, "package.json");
5316
- if (existsSync13(pkgJson)) copyFileSync(pkgJson, join23(target, "package.json"));
5659
+ cpSync2(c.dist, join24(target, "dist"), { recursive: true });
5660
+ const skill = join24(c.pkgRoot, "skill");
5661
+ if (existsSync13(skill)) cpSync2(skill, join24(target, "skill"), { recursive: true });
5662
+ const pkgJson = join24(c.pkgRoot, "package.json");
5663
+ if (existsSync13(pkgJson)) copyFileSync(pkgJson, join24(target, "package.json"));
5317
5664
  for (const resource of ["plugin.json", "hooks", "index.js"]) {
5318
- const source = join23(c.pkgRoot, resource);
5319
- if (existsSync13(source)) cpSync2(source, join23(target, resource), { recursive: true });
5665
+ const source = join24(c.pkgRoot, resource);
5666
+ if (existsSync13(source)) cpSync2(source, join24(target, resource), { recursive: true });
5320
5667
  }
5321
5668
  writeFileSync5(
5322
- join23(target, ORIGIN_FILE),
5669
+ join24(target, ORIGIN_FILE),
5323
5670
  JSON.stringify({ source: c.pkgRoot, stagedAt: (/* @__PURE__ */ new Date()).toISOString() })
5324
5671
  );
5325
5672
  c.log?.(`runtime staged at ${target}`);
5326
- return { ...c, pkgRoot: target, dist: join23(target, "dist") };
5673
+ return { ...c, pkgRoot: target, dist: join24(target, "dist") };
5327
5674
  } catch (error) {
5328
5675
  c.log?.(`could not stage the runtime at ${target}: ${String(error)}`);
5329
5676
  return c;
@@ -5345,7 +5692,7 @@ function flagValueArgs(args, names) {
5345
5692
  return taken;
5346
5693
  }
5347
5694
  var CONFIG_RELATIVE = [".hindsight", "coding-agent.json"];
5348
- var hindsightConfigPath = (c) => process.env.HINDSIGHT_CONFIG || join23(c.home, ...CONFIG_RELATIVE);
5695
+ var hindsightConfigPath = (c) => process.env.HINDSIGHT_CONFIG || join24(c.home, ...CONFIG_RELATIVE);
5349
5696
  var SERVER_CHOICES = [
5350
5697
  { mode: "cloud", label: "Hindsight Cloud", hint: "hosted, needs an API token" },
5351
5698
  { mode: "self-hosted", label: "Self-hosted server", hint: "a Hindsight server you already run" },
@@ -5403,7 +5750,7 @@ function configureServer(c, args, installing) {
5403
5750
  return false;
5404
5751
  }
5405
5752
  const configPath = hindsightConfigPath(c);
5406
- const existing = readJson(configPath);
5753
+ const existing = readJson2(configPath);
5407
5754
  const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
5408
5755
  let mode = explicit;
5409
5756
  if (!mode) {
@@ -5498,7 +5845,7 @@ function reportDaemonPrereqs(c) {
5498
5845
  }
5499
5846
  var devin = {
5500
5847
  name: "devin-cli",
5501
- detect: (c) => onPath2("devin") || existsSync13(join23(c.home, ".config", "devin")),
5848
+ detect: (c) => onPath2("devin") || existsSync13(join24(c.home, ".config", "devin")),
5502
5849
  // Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
5503
5850
  // nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
5504
5851
  // support a hard prerequisite here — and one worth checking now, because the alternative is an
@@ -5511,13 +5858,13 @@ var devin = {
5511
5858
  Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
5512
5859
  },
5513
5860
  install(c) {
5514
- const configPath = join23(c.home, ".config", "devin", "config.json");
5515
- const config = readJson(configPath);
5861
+ const configPath = join24(c.home, ".config", "devin", "config.json");
5862
+ const config = readJson2(configPath);
5516
5863
  config.hooks = config.hooks ?? {};
5517
5864
  mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
5518
5865
  writeJson(configPath, config);
5519
- const mcpPath = join23(c.home, ".config", "devin", "mcp_config.json");
5520
- const mcp = readJson(mcpPath);
5866
+ const mcpPath = join24(c.home, ".config", "devin", "mcp_config.json");
5867
+ const mcp = readJson2(mcpPath);
5521
5868
  mcp.mcpServers = {
5522
5869
  ...mcp.mcpServers ?? {},
5523
5870
  hindsight: mcpServerEntry(c.dist, "devin-cli")
@@ -5526,18 +5873,18 @@ var devin = {
5526
5873
  c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
5527
5874
  },
5528
5875
  uninstall(c) {
5529
- const configPath = join23(c.home, ".config", "devin", "config.json");
5876
+ const configPath = join24(c.home, ".config", "devin", "config.json");
5530
5877
  if (existsSync13(configPath)) {
5531
- const config = readJson(configPath);
5878
+ const config = readJson2(configPath);
5532
5879
  if (config.hooks) {
5533
5880
  stripHarnessHooks(config.hooks, "devin-cli");
5534
5881
  if (!Object.keys(config.hooks).length) delete config.hooks;
5535
5882
  writeJson(configPath, config);
5536
5883
  }
5537
5884
  }
5538
- const mcpPath = join23(c.home, ".config", "devin", "mcp_config.json");
5885
+ const mcpPath = join24(c.home, ".config", "devin", "mcp_config.json");
5539
5886
  if (existsSync13(mcpPath)) {
5540
- const mcp = readJson(mcpPath);
5887
+ const mcp = readJson2(mcpPath);
5541
5888
  if (mcp.mcpServers?.hindsight) {
5542
5889
  delete mcp.mcpServers.hindsight;
5543
5890
  writeJson(mcpPath, mcp);
@@ -5548,16 +5895,16 @@ var devin = {
5548
5895
  };
5549
5896
  var cursor = {
5550
5897
  name: "cursor-cli",
5551
- detect: (c) => onPath2("cursor-agent") || existsSync13(join23(c.home, ".cursor")),
5898
+ detect: (c) => onPath2("cursor-agent") || existsSync13(join24(c.home, ".cursor")),
5552
5899
  install(c) {
5553
- const hooksPath = join23(c.home, ".cursor", "hooks.json");
5554
- const cfg = readJson(hooksPath);
5900
+ const hooksPath = join24(c.home, ".cursor", "hooks.json");
5901
+ const cfg = readJson2(hooksPath);
5555
5902
  cfg.version ??= 1;
5556
5903
  cfg.hooks = cfg.hooks ?? {};
5557
5904
  mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
5558
5905
  writeJson(hooksPath, cfg);
5559
- const mcpPath = join23(c.home, ".cursor", "mcp.json");
5560
- const mcp = readJson(mcpPath);
5906
+ const mcpPath = join24(c.home, ".cursor", "mcp.json");
5907
+ const mcp = readJson2(mcpPath);
5561
5908
  mcp.mcpServers = {
5562
5909
  ...mcp.mcpServers ?? {},
5563
5910
  hindsight: mcpServerEntry(c.dist, "cursor-cli", ["${workspaceFolder}"])
@@ -5567,18 +5914,18 @@ var cursor = {
5567
5914
  installSkill(c, "cursor-cli");
5568
5915
  },
5569
5916
  uninstall(c) {
5570
- const hooksPath = join23(c.home, ".cursor", "hooks.json");
5917
+ const hooksPath = join24(c.home, ".cursor", "hooks.json");
5571
5918
  if (existsSync13(hooksPath)) {
5572
- const cfg = readJson(hooksPath);
5919
+ const cfg = readJson2(hooksPath);
5573
5920
  if (cfg.hooks) {
5574
5921
  stripHarnessHooks(cfg.hooks, "cursor-cli");
5575
5922
  if (!Object.keys(cfg.hooks).length) delete cfg.hooks;
5576
5923
  writeJson(hooksPath, cfg);
5577
5924
  }
5578
5925
  }
5579
- const mcpPath = join23(c.home, ".cursor", "mcp.json");
5926
+ const mcpPath = join24(c.home, ".cursor", "mcp.json");
5580
5927
  if (existsSync13(mcpPath)) {
5581
- const mcp = readJson(mcpPath);
5928
+ const mcp = readJson2(mcpPath);
5582
5929
  if (mcp.mcpServers?.hindsight) {
5583
5930
  delete mcp.mcpServers.hindsight;
5584
5931
  writeJson(mcpPath, mcp);
@@ -5590,14 +5937,14 @@ var cursor = {
5590
5937
  };
5591
5938
  var copilot = {
5592
5939
  name: "copilot-cli",
5593
- detect: (c) => onPath2("copilot") || existsSync13(join23(c.home, ".copilot")),
5940
+ detect: (c) => onPath2("copilot") || existsSync13(join24(c.home, ".copilot")),
5594
5941
  install(c) {
5595
- const hooksPath = join23(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
5942
+ const hooksPath = join24(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
5596
5943
  const hooks = {};
5597
5944
  mergeHarnessHooks(hooks, "copilot-cli", c.dist);
5598
5945
  writeJson(hooksPath, { version: 1, hooks });
5599
- const mcpPath = join23(c.home, ".copilot", "mcp-config.json");
5600
- const mcp = readJson(mcpPath);
5946
+ const mcpPath = join24(c.home, ".copilot", "mcp-config.json");
5947
+ const mcp = readJson2(mcpPath);
5601
5948
  mcp.mcpServers = {
5602
5949
  ...mcp.mcpServers ?? {},
5603
5950
  hindsight: mcpServerEntry(c.dist, "copilot-cli")
@@ -5607,12 +5954,12 @@ var copilot = {
5607
5954
  c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
5608
5955
  },
5609
5956
  uninstall(c) {
5610
- rmSync4(join23(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
5957
+ rmSync4(join24(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
5611
5958
  force: true
5612
5959
  });
5613
- const mcpPath = join23(c.home, ".copilot", "mcp-config.json");
5960
+ const mcpPath = join24(c.home, ".copilot", "mcp-config.json");
5614
5961
  if (existsSync13(mcpPath)) {
5615
- const mcp = readJson(mcpPath);
5962
+ const mcp = readJson2(mcpPath);
5616
5963
  if (mcp.mcpServers?.hindsight) {
5617
5964
  delete mcp.mcpServers.hindsight;
5618
5965
  writeJson(mcpPath, mcp);
@@ -5675,13 +6022,13 @@ function stripUnmarkedGrokEntries(toml) {
5675
6022
  if (!drop.some(Boolean)) return toml;
5676
6023
  return sections.filter((_, i) => !drop[i]).map((s) => s.lines.join("\n")).join("\n").replace(/\n{3,}/g, "\n\n");
5677
6024
  }
5678
- var grokHooksPath = (c) => join23(c.home, ".grok", "hooks", "hindsight.json");
6025
+ var grokHooksPath = (c) => join24(c.home, ".grok", "hooks", "hindsight.json");
5679
6026
  var grok = {
5680
6027
  name: "grok-build",
5681
- detect: (c) => onPath2("grok") || existsSync13(join23(c.home, ".grok")),
6028
+ detect: (c) => onPath2("grok") || existsSync13(join24(c.home, ".grok")),
5682
6029
  install(c) {
5683
- const path = join23(c.home, ".grok", "config.toml");
5684
- const existing = existsSync13(path) ? readFileSync16(path, "utf8") : "";
6030
+ const path = join24(c.home, ".grok", "config.toml");
6031
+ const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
5685
6032
  const stripped = existing.replace(GROK_BLOCK_RE, "\n");
5686
6033
  const withoutOurs = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
5687
6034
  const tomlString = (value) => JSON.stringify(value);
@@ -5689,7 +6036,7 @@ var grok = {
5689
6036
  ${GROK_MARKER_START}
5690
6037
  [mcp_servers.hindsight]
5691
6038
  command = "node"
5692
- args = [${tomlString(join23(c.dist, "mcp-server.js"))}]
6039
+ args = [${tomlString(join24(c.dist, "mcp-server.js"))}]
5693
6040
  env = { HINDSIGHT_MCP_HARNESS = "grok-build" }
5694
6041
  ${GROK_MARKER_END}
5695
6042
  `;
@@ -5702,10 +6049,10 @@ ${GROK_MARKER_END}
5702
6049
  }
5703
6050
  if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
5704
6051
  copyFileSync(path, `${path}.hindsight-backup`);
5705
- mkdirSync7(dirname12(path), { recursive: true });
6052
+ mkdirSync7(dirname13(path), { recursive: true });
5706
6053
  writeFileSync5(path, next);
5707
6054
  const hooksPath = grokHooksPath(c);
5708
- const file = readJson(hooksPath);
6055
+ const file = readJson2(hooksPath);
5709
6056
  const hooks = isPlainObject(file.hooks) ? file.hooks : {};
5710
6057
  mergeHarnessHooks(hooks, "grok-build", c.dist);
5711
6058
  writeJson(hooksPath, { ...file, hooks });
@@ -5713,9 +6060,9 @@ ${GROK_MARKER_END}
5713
6060
  c.log?.(`grok-build: hooks installed in ${hooksPath}, MCP in ${path}`);
5714
6061
  },
5715
6062
  uninstall(c) {
5716
- const path = join23(c.home, ".grok", "config.toml");
6063
+ const path = join24(c.home, ".grok", "config.toml");
5717
6064
  if (existsSync13(path)) {
5718
- const existing = readFileSync16(path, "utf8");
6065
+ const existing = readFileSync15(path, "utf8");
5719
6066
  const stripped = existing.replace(GROK_BLOCK_RE, "\n");
5720
6067
  const cleaned = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
5721
6068
  const safe = parseGrokToml(cleaned) !== null || parseGrokToml(existing) === null;
@@ -5723,7 +6070,7 @@ ${GROK_MARKER_END}
5723
6070
  }
5724
6071
  const hooksPath = grokHooksPath(c);
5725
6072
  if (existsSync13(hooksPath)) {
5726
- const file = readJson(hooksPath);
6073
+ const file = readJson2(hooksPath);
5727
6074
  if (isPlainObject(file.hooks)) {
5728
6075
  stripHarnessHooks(file.hooks, "grok-build");
5729
6076
  if (!Object.keys(file.hooks).length) delete file.hooks;
@@ -5739,20 +6086,20 @@ var KIMI_MARKER_START = "# HINDSIGHT_CODING_AGENTS_KIMI_START";
5739
6086
  var KIMI_MARKER_END = "# HINDSIGHT_CODING_AGENTS_KIMI_END";
5740
6087
  var KIMI_BLOCK_RE = new RegExp(`\\n?${KIMI_MARKER_START}[\\s\\S]*?${KIMI_MARKER_END}\\n?`);
5741
6088
  function kimiHome(c) {
5742
- return process.env.KIMI_CODE_HOME || join23(c.home, ".kimi-code");
6089
+ return process.env.KIMI_CODE_HOME || join24(c.home, ".kimi-code");
5743
6090
  }
5744
6091
  var kimi = {
5745
6092
  name: "kimi-code",
5746
6093
  detect: (c) => onPath2("kimi") || existsSync13(kimiHome(c)),
5747
6094
  install(c) {
5748
- const path = join23(kimiHome(c), "config.toml");
5749
- const existing = existsSync13(path) ? readFileSync16(path, "utf8") : "";
6095
+ const path = join24(kimiHome(c), "config.toml");
6096
+ const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
5750
6097
  const withoutOurs = existing.replace(KIMI_BLOCK_RE, "\n");
5751
6098
  const spec = HOOK_HARNESSES["kimi-code"];
5752
6099
  const entries = Object.values(spec.install).map(
5753
6100
  (h) => `[[hooks]]
5754
6101
  event = ${JSON.stringify(h.event)}
5755
- command = ${JSON.stringify(`node "${join23(c.dist, h.entry)}"`)}
6102
+ command = ${JSON.stringify(`node "${join24(c.dist, h.entry)}"`)}
5756
6103
  timeout = ${h.timeout}
5757
6104
  `
5758
6105
  ).join("\n");
@@ -5762,25 +6109,25 @@ ${entries}${KIMI_MARKER_END}
5762
6109
  `;
5763
6110
  if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
5764
6111
  copyFileSync(path, `${path}.hindsight-backup`);
5765
- mkdirSync7(dirname12(path), { recursive: true });
6112
+ mkdirSync7(dirname13(path), { recursive: true });
5766
6113
  writeFileSync5(path, `${withoutOurs.replace(/\n*$/, "\n")}${block}`);
5767
- const mcpPath = join23(kimiHome(c), "mcp.json");
5768
- const mcp = readJson(mcpPath);
6114
+ const mcpPath = join24(kimiHome(c), "mcp.json");
6115
+ const mcp = readJson2(mcpPath);
5769
6116
  mcp.mcpServers = { ...mcp.mcpServers ?? {}, hindsight: mcpServerEntry(c.dist, "kimi-code") };
5770
6117
  writeJson(mcpPath, mcp);
5771
6118
  installSkill(c, "kimi-code");
5772
6119
  c.log?.(`kimi-code: native hooks installed in ${path}, MCP in ${mcpPath}`);
5773
6120
  },
5774
6121
  uninstall(c) {
5775
- const path = join23(kimiHome(c), "config.toml");
6122
+ const path = join24(kimiHome(c), "config.toml");
5776
6123
  if (existsSync13(path)) {
5777
- const existing = readFileSync16(path, "utf8");
6124
+ const existing = readFileSync15(path, "utf8");
5778
6125
  const cleaned = existing.replace(KIMI_BLOCK_RE, "\n");
5779
6126
  if (cleaned !== existing) writeFileSync5(path, cleaned);
5780
6127
  }
5781
- const mcpPath = join23(kimiHome(c), "mcp.json");
6128
+ const mcpPath = join24(kimiHome(c), "mcp.json");
5782
6129
  if (existsSync13(mcpPath)) {
5783
- const mcp = readJson(mcpPath);
6130
+ const mcp = readJson2(mcpPath);
5784
6131
  if (mcp.mcpServers?.hindsight) {
5785
6132
  delete mcp.mcpServers.hindsight;
5786
6133
  writeJson(mcpPath, mcp);
@@ -5794,17 +6141,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
5794
6141
  var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
5795
6142
  var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
5796
6143
  function removeLegacyClineHooks(c) {
5797
- const hooksDir = join23(c.home, "Documents", "Cline", "Hooks");
6144
+ const hooksDir = join24(c.home, "Documents", "Cline", "Hooks");
5798
6145
  for (const event of CLINE_OLD_HOOK_EVENTS) {
5799
- const path = join23(hooksDir, event);
5800
- if (existsSync13(path) && readFileSync16(path, "utf8").includes(CLINE_HOOK_MARKER)) {
6146
+ const path = join24(hooksDir, event);
6147
+ if (existsSync13(path) && readFileSync15(path, "utf8").includes(CLINE_HOOK_MARKER)) {
5801
6148
  rmSync4(path, { force: true });
5802
6149
  }
5803
6150
  }
5804
6151
  }
5805
6152
  var cline = {
5806
6153
  name: "cline-cli",
5807
- detect: (c) => onPath2("cline") || existsSync13(join23(c.home, ".cline")),
6154
+ detect: (c) => onPath2("cline") || existsSync13(join24(c.home, ".cline")),
5808
6155
  install(c) {
5809
6156
  removeLegacyClineHooks(c);
5810
6157
  const installed = (c.clinePlugin ?? runClinePlugin)([
@@ -5813,8 +6160,8 @@ var cline = {
5813
6160
  "--force",
5814
6161
  c.pkgRoot
5815
6162
  ]);
5816
- const mcpPath = join23(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5817
- const mcp = readJson(mcpPath);
6163
+ const mcpPath = join24(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
6164
+ const mcp = readJson2(mcpPath);
5818
6165
  mcp.mcpServers = {
5819
6166
  ...mcp.mcpServers ?? {},
5820
6167
  hindsight: mcpServerEntry(c.dist, "cline-cli")
@@ -5828,9 +6175,9 @@ var cline = {
5828
6175
  uninstall(c) {
5829
6176
  removeLegacyClineHooks(c);
5830
6177
  (c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
5831
- const mcpPath = join23(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
6178
+ const mcpPath = join24(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
5832
6179
  if (existsSync13(mcpPath)) {
5833
- const mcp = readJson(mcpPath);
6180
+ const mcp = readJson2(mcpPath);
5834
6181
  if (mcp.mcpServers?.hindsight) {
5835
6182
  delete mcp.mcpServers.hindsight;
5836
6183
  writeJson(mcpPath, mcp);
@@ -5842,31 +6189,31 @@ var cline = {
5842
6189
  };
5843
6190
  var DCODE_MARKETPLACE = "hindsight-coding-agents";
5844
6191
  var DCODE_PLUGIN_ID = "hindsight-coding-agents@hindsight-coding-agents";
5845
- var DCODE_MARKETPLACE_RELATIVE_PATH = join23(".agents", "plugins", "marketplace.json");
6192
+ var DCODE_MARKETPLACE_RELATIVE_PATH = join24(".agents", "plugins", "marketplace.json");
5846
6193
  var DCODE_FALLBACK_MARKETPLACE = "hindsight-coding-agents-marketplace.json";
5847
6194
  function prepareDcodeMarketplace(c) {
5848
- const root = join23(c.home, ".hindsight");
5849
- const conventionalPath = join23(root, DCODE_MARKETPLACE_RELATIVE_PATH);
6195
+ const root = join24(c.home, ".hindsight");
6196
+ const conventionalPath = join24(root, DCODE_MARKETPLACE_RELATIVE_PATH);
5850
6197
  let path = conventionalPath;
5851
6198
  let registrationSource = root;
5852
6199
  let marketplace = { plugins: [] };
5853
6200
  if (existsSync13(conventionalPath)) {
5854
6201
  try {
5855
- const parsed = JSON.parse(readFileSync16(conventionalPath, "utf8"));
6202
+ const parsed = JSON.parse(readFileSync15(conventionalPath, "utf8"));
5856
6203
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins)) {
5857
- path = join23(root, DCODE_FALLBACK_MARKETPLACE);
6204
+ path = join24(root, DCODE_FALLBACK_MARKETPLACE);
5858
6205
  } else if (typeof parsed.name === "string" && parsed.name !== DCODE_MARKETPLACE) {
5859
- path = join23(root, DCODE_FALLBACK_MARKETPLACE);
6206
+ path = join24(root, DCODE_FALLBACK_MARKETPLACE);
5860
6207
  } else {
5861
6208
  marketplace = parsed;
5862
6209
  }
5863
6210
  } catch {
5864
- path = join23(root, DCODE_FALLBACK_MARKETPLACE);
6211
+ path = join24(root, DCODE_FALLBACK_MARKETPLACE);
5865
6212
  }
5866
6213
  }
5867
6214
  if (path !== conventionalPath && existsSync13(path)) {
5868
6215
  try {
5869
- const parsed = JSON.parse(readFileSync16(path, "utf8"));
6216
+ const parsed = JSON.parse(readFileSync15(path, "utf8"));
5870
6217
  if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins) || parsed.name !== DCODE_MARKETPLACE) {
5871
6218
  c.log?.(`dcode: refusing to replace malformed marketplace file ${path}`);
5872
6219
  return false;
@@ -5894,7 +6241,7 @@ function prepareDcodeMarketplace(c) {
5894
6241
  }
5895
6242
  var dcode = {
5896
6243
  name: "dcode",
5897
- detect: (c) => onPath2("dcode") || existsSync13(join23(c.home, ".deepagents")),
6244
+ detect: (c) => onPath2("dcode") || existsSync13(join24(c.home, ".deepagents")),
5898
6245
  preflight: (c) => c.dcodePlugin || onPath2("dcode") ? void 0 : "the `dcode` CLI is not on PATH",
5899
6246
  install(c) {
5900
6247
  const plugin = c.dcodePlugin ?? runDcodePlugin;
@@ -5903,7 +6250,7 @@ var dcode = {
5903
6250
  if (installed) {
5904
6251
  c.log?.(`dcode: native Agent Plugin installed (${DCODE_PLUGIN_ID})`);
5905
6252
  } else {
5906
- const source = marketplacePath === false ? join23(c.home, ".hindsight") : marketplacePath;
6253
+ const source = marketplacePath === false ? join24(c.home, ".hindsight") : marketplacePath;
5907
6254
  c.log?.(
5908
6255
  `dcode: could not install the native plugin \u2014 run dcode plugin marketplace add "${source}" && dcode plugin install ${DCODE_PLUGIN_ID}`
5909
6256
  );
@@ -5936,16 +6283,16 @@ function dshUserPatches(existing) {
5936
6283
  return others === DSH_EMPTY_LIST ? "" : others;
5937
6284
  }
5938
6285
  function dshHome(c) {
5939
- return process.env.DSH_HOME || join23(c.home, ".dsh");
6286
+ return process.env.DSH_HOME || join24(c.home, ".dsh");
5940
6287
  }
5941
6288
  var dsh = {
5942
6289
  name: "dsh",
5943
6290
  detect: (c) => onPath2("dsh") || existsSync13(dshHome(c)),
5944
6291
  install(c) {
5945
- const path = join23(dshHome(c), "cordis.patch.yml");
5946
- const existing = existsSync13(path) ? readFileSync16(path, "utf8") : "";
6292
+ const path = join24(dshHome(c), "cordis.patch.yml");
6293
+ const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
5947
6294
  const others = dshUserPatches(existing);
5948
- const entry = pathToFileURL(join23(c.dist, "dsh.js")).href;
6295
+ const entry = pathToFileURL(join24(c.dist, "dsh.js")).href;
5949
6296
  const block = `${DSH_MARKER_START}
5950
6297
  - insert:
5951
6298
  - id: hindsight
@@ -5954,7 +6301,7 @@ ${DSH_MARKER_END}
5954
6301
  `;
5955
6302
  if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
5956
6303
  copyFileSync(path, `${path}.hindsight-backup`);
5957
- mkdirSync7(dirname12(path), { recursive: true });
6304
+ mkdirSync7(dirname13(path), { recursive: true });
5958
6305
  writeFileSync5(path, others ? `${others}
5959
6306
 
5960
6307
  ${block}` : block);
@@ -5964,9 +6311,9 @@ ${block}` : block);
5964
6311
  );
5965
6312
  },
5966
6313
  uninstall(c) {
5967
- const path = join23(dshHome(c), "cordis.patch.yml");
6314
+ const path = join24(dshHome(c), "cordis.patch.yml");
5968
6315
  if (existsSync13(path)) {
5969
- const existing = readFileSync16(path, "utf8");
6316
+ const existing = readFileSync15(path, "utf8");
5970
6317
  const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
5971
6318
  if (others !== existing.trim())
5972
6319
  writeFileSync5(path, others ? `${others}
@@ -5979,10 +6326,10 @@ ${block}` : block);
5979
6326
  };
5980
6327
  var qwen = {
5981
6328
  name: "qwen-code",
5982
- detect: (c) => onPath2("qwen") || existsSync13(join23(c.home, ".qwen")),
6329
+ detect: (c) => onPath2("qwen") || existsSync13(join24(c.home, ".qwen")),
5983
6330
  install(c) {
5984
- const path = join23(c.home, ".qwen", "settings.json");
5985
- const settings = readJson(path);
6331
+ const path = join24(c.home, ".qwen", "settings.json");
6332
+ const settings = readJson2(path);
5986
6333
  settings.hooks = settings.hooks ?? {};
5987
6334
  mergeHarnessHooks(settings.hooks, "qwen-code", c.dist);
5988
6335
  writeJson(path, settings);
@@ -5999,20 +6346,20 @@ var qwen = {
5999
6346
  "HINDSIGHT_MCP_HARNESS=qwen-code",
6000
6347
  "hindsight",
6001
6348
  "node",
6002
- join23(c.dist, "mcp-server.js")
6349
+ join24(c.dist, "mcp-server.js")
6003
6350
  ])) {
6004
6351
  c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
6005
6352
  } else {
6006
6353
  c.log?.(
6007
6354
  `qwen-code: could not run \`qwen mcp add\` \u2014 register the tools manually:
6008
- qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join23(c.dist, "mcp-server.js")}"`
6355
+ qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join24(c.dist, "mcp-server.js")}"`
6009
6356
  );
6010
6357
  }
6011
6358
  },
6012
6359
  uninstall(c) {
6013
- const path = join23(c.home, ".qwen", "settings.json");
6360
+ const path = join24(c.home, ".qwen", "settings.json");
6014
6361
  if (existsSync13(path)) {
6015
- const settings = readJson(path);
6362
+ const settings = readJson2(path);
6016
6363
  if (settings.hooks) {
6017
6364
  stripHarnessHooks(settings.hooks, "qwen-code");
6018
6365
  if (!Object.keys(settings.hooks).length) delete settings.hooks;
@@ -6027,7 +6374,7 @@ var qwen = {
6027
6374
  };
6028
6375
  function defaultQwenMcp(args) {
6029
6376
  try {
6030
- execFileSync7("qwen", args, { stdio: "pipe" });
6377
+ execFileSync8("qwen", args, { stdio: "pipe" });
6031
6378
  return true;
6032
6379
  } catch {
6033
6380
  return false;
@@ -6035,19 +6382,19 @@ function defaultQwenMcp(args) {
6035
6382
  }
6036
6383
  var factoryDroid = {
6037
6384
  name: "factory-droid",
6038
- detect: (c) => onPath2("droid") || existsSync13(join23(c.home, ".factory")),
6385
+ detect: (c) => onPath2("droid") || existsSync13(join24(c.home, ".factory")),
6039
6386
  preflight(c) {
6040
- const mcpPath = join23(c.home, ".factory", "mcp.json");
6041
- const existing = readJson(mcpPath).mcpServers?.hindsight;
6387
+ const mcpPath = join24(c.home, ".factory", "mcp.json");
6388
+ const existing = readJson2(mcpPath).mcpServers?.hindsight;
6042
6389
  if (existing && !isOurMcpEntry(existing)) {
6043
6390
  return `${mcpPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
6044
6391
  }
6045
6392
  },
6046
6393
  install(c) {
6047
- const hooksPath = join23(c.home, ".factory", "hooks.json");
6048
- const hooks = readJson(hooksPath);
6394
+ const hooksPath = join24(c.home, ".factory", "hooks.json");
6395
+ const hooks = readJson2(hooksPath);
6049
6396
  if (!existsSync13(hooksPath)) {
6050
- const fallback = readJson(join23(c.home, ".factory", "settings.json")).hooks;
6397
+ const fallback = readJson2(join24(c.home, ".factory", "settings.json")).hooks;
6051
6398
  if (fallback && typeof fallback === "object" && !Array.isArray(fallback)) {
6052
6399
  Object.assign(hooks, fallback);
6053
6400
  }
@@ -6056,24 +6403,24 @@ var factoryDroid = {
6056
6403
  writeJson(hooksPath, hooks);
6057
6404
  c.log?.(`factory-droid: hooks merged into ${hooksPath}`);
6058
6405
  installSkill(c, "factory-droid");
6059
- const mcpPath = join23(c.home, ".factory", "mcp.json");
6060
- const mcp = readJson(mcpPath);
6406
+ const mcpPath = join24(c.home, ".factory", "mcp.json");
6407
+ const mcp = readJson2(mcpPath);
6061
6408
  mcp.mcpServers = mcp.mcpServers ?? {};
6062
6409
  mcp.mcpServers.hindsight = mcpServerEntry(c.dist, "factory-droid");
6063
6410
  writeJson(mcpPath, mcp);
6064
6411
  c.log?.(`factory-droid: MCP server registered in ${mcpPath}`);
6065
6412
  },
6066
6413
  uninstall(c) {
6067
- const hooksPath = join23(c.home, ".factory", "hooks.json");
6414
+ const hooksPath = join24(c.home, ".factory", "hooks.json");
6068
6415
  if (existsSync13(hooksPath)) {
6069
- const hooks = readJson(hooksPath);
6416
+ const hooks = readJson2(hooksPath);
6070
6417
  stripHarnessHooks(hooks, "factory-droid");
6071
6418
  if (Object.keys(hooks).length) writeJson(hooksPath, hooks);
6072
6419
  else rmSync4(hooksPath);
6073
6420
  }
6074
- const mcpPath = join23(c.home, ".factory", "mcp.json");
6421
+ const mcpPath = join24(c.home, ".factory", "mcp.json");
6075
6422
  if (existsSync13(mcpPath)) {
6076
- const mcp = readJson(mcpPath);
6423
+ const mcp = readJson2(mcpPath);
6077
6424
  if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
6078
6425
  delete mcp.mcpServers.hindsight;
6079
6426
  if (Object.keys(mcp.mcpServers).length) writeJson(mcpPath, mcp);
@@ -6086,17 +6433,17 @@ var factoryDroid = {
6086
6433
  };
6087
6434
  var zcode = {
6088
6435
  name: "zcode",
6089
- detect: (c) => onPath2("zcode") || existsSync13(join23(c.home, ".zcode")),
6436
+ detect: (c) => onPath2("zcode") || existsSync13(join24(c.home, ".zcode")),
6090
6437
  preflight(c) {
6091
6438
  const configPath = zcodeConfigPath(c);
6092
- const existing = readJson(configPath).mcp?.servers?.hindsight;
6439
+ const existing = readJson2(configPath).mcp?.servers?.hindsight;
6093
6440
  if (existing && !isOurMcpEntry(existing)) {
6094
6441
  return `${configPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
6095
6442
  }
6096
6443
  },
6097
6444
  install(c) {
6098
6445
  const configPath = zcodeConfigPath(c);
6099
- const config = readJson(configPath);
6446
+ const config = readJson2(configPath);
6100
6447
  const hooks = config.hooks = config.hooks ?? {};
6101
6448
  hooks.enabled = true;
6102
6449
  hooks.maxOutputBytes = hooks.maxOutputBytes ?? ZCODE_MAX_OUTPUT_BYTES;
@@ -6112,7 +6459,7 @@ var zcode = {
6112
6459
  uninstall(c) {
6113
6460
  const configPath = zcodeConfigPath(c);
6114
6461
  if (existsSync13(configPath)) {
6115
- const config = readJson(configPath);
6462
+ const config = readJson2(configPath);
6116
6463
  if (isOurMcpEntry(config.mcp?.servers?.hindsight)) {
6117
6464
  delete config.mcp.servers.hindsight;
6118
6465
  if (!Object.keys(config.mcp.servers).length) delete config.mcp;
@@ -6128,12 +6475,12 @@ var zcode = {
6128
6475
  c.log?.(`zcode: hooks + MCP registration + skill removed`);
6129
6476
  }
6130
6477
  };
6131
- var traecodeMcpPath = (c) => join23(traecodeUserDataDir(c.home), "User", "mcp.json");
6478
+ var traecodeMcpPath = (c) => join24(traecodeUserDataDir(c.home), "User", "mcp.json");
6132
6479
  function removeTraecodeUserMcpEntry(c) {
6133
6480
  try {
6134
6481
  const mcpPath = traecodeMcpPath(c);
6135
6482
  if (!existsSync13(mcpPath)) return false;
6136
- const mcp = readJson(mcpPath);
6483
+ const mcp = readJson2(mcpPath);
6137
6484
  if (!isOurMcpEntry(mcp.mcpServers?.hindsight)) return false;
6138
6485
  delete mcp.mcpServers.hindsight;
6139
6486
  if (Object.keys(mcp.mcpServers).length) writeJson(mcpPath, mcp);
@@ -6173,10 +6520,10 @@ function ensureTraecodeWorkspaceMcpGate(c) {
6173
6520
  }
6174
6521
  var traecode = {
6175
6522
  name: "traecode",
6176
- detect: (c) => existsSync13(join23(c.home, traecodeDotDirName(c.home))) || onPath2("trae"),
6523
+ detect: (c) => existsSync13(join24(c.home, traecodeDotDirName(c.home))) || onPath2("trae"),
6177
6524
  install(c) {
6178
- const hooksPath = join23(c.home, traecodeDotDirName(c.home), "hooks.json");
6179
- const doc = readJson(hooksPath);
6525
+ const hooksPath = join24(c.home, traecodeDotDirName(c.home), "hooks.json");
6526
+ const doc = readJson2(hooksPath);
6180
6527
  doc.version = doc.version ?? 1;
6181
6528
  const hooks = doc.hooks = doc.hooks ?? {};
6182
6529
  mergeHarnessHooks(hooks, "traecode", c.dist);
@@ -6189,11 +6536,11 @@ var traecode = {
6189
6536
  .trae/mcp.json files register the server instead`
6190
6537
  );
6191
6538
  }
6192
- const sandboxPath = join23(c.home, traecodeDotDirName(c.home), "sandbox.json");
6193
- const sandbox = readJson(sandboxPath);
6539
+ const sandboxPath = join24(c.home, traecodeDotDirName(c.home), "sandbox.json");
6540
+ const sandbox = readJson2(sandboxPath);
6194
6541
  const fsRules = sandbox.filesystem = sandbox.filesystem ?? {};
6195
6542
  const readWrite = fsRules.readWrite = fsRules.readWrite ?? [];
6196
- const needed = [join23(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
6543
+ const needed = [join24(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
6197
6544
  let sandboxChanged = false;
6198
6545
  for (const dir of needed) {
6199
6546
  if (!readWrite.includes(dir)) {
@@ -6205,7 +6552,7 @@ var traecode = {
6205
6552
  writeJson(sandboxPath, sandbox);
6206
6553
  c.log?.(`traecode: sandbox readWrite rules added (${needed.join(", ")})`);
6207
6554
  }
6208
- const config = readJson(hindsightConfigPath(c));
6555
+ const config = readJson2(hindsightConfigPath(c));
6209
6556
  const repos = Object.keys(config.mapPathToBank ?? {}).sort();
6210
6557
  if (repos.length) {
6211
6558
  const written = [];
@@ -6241,9 +6588,9 @@ var traecode = {
6241
6588
  ensureTraecodeWorkspaceMcpGate(c);
6242
6589
  },
6243
6590
  uninstall(c) {
6244
- const hooksPath = join23(c.home, traecodeDotDirName(c.home), "hooks.json");
6591
+ const hooksPath = join24(c.home, traecodeDotDirName(c.home), "hooks.json");
6245
6592
  if (existsSync13(hooksPath)) {
6246
- const doc = readJson(hooksPath);
6593
+ const doc = readJson2(hooksPath);
6247
6594
  if (doc.hooks) {
6248
6595
  stripHarnessHooks(doc.hooks, "traecode");
6249
6596
  if (!Object.keys(doc.hooks).length) delete doc.hooks;
@@ -6254,7 +6601,7 @@ var traecode = {
6254
6601
  if (removeTraecodeUserMcpEntry(c)) {
6255
6602
  c.log?.(`traecode: MCP entry removed from ${traecodeMcpPath(c)}`);
6256
6603
  }
6257
- const config = readJson(hindsightConfigPath(c));
6604
+ const config = readJson2(hindsightConfigPath(c));
6258
6605
  const repoEntries = Object.keys(config.mapPathToBank ?? {}).sort();
6259
6606
  const cleaned = repoEntries.filter(
6260
6607
  (repo) => removeTraecodeWorkspaceMcpEntry(repo, { home: c.home })
@@ -6263,12 +6610,12 @@ var traecode = {
6263
6610
  c.log?.(`traecode: per-repo MCP registration removed from:
6264
6611
  ${cleaned.join("\n ")}`);
6265
6612
  }
6266
- const sandboxPath = join23(c.home, traecodeDotDirName(c.home), "sandbox.json");
6613
+ const sandboxPath = join24(c.home, traecodeDotDirName(c.home), "sandbox.json");
6267
6614
  if (existsSync13(sandboxPath)) {
6268
- const sandbox = readJson(sandboxPath);
6615
+ const sandbox = readJson2(sandboxPath);
6269
6616
  const readWrite = sandbox.filesystem?.readWrite;
6270
6617
  if (Array.isArray(readWrite)) {
6271
- const ours = [join23(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
6618
+ const ours = [join24(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
6272
6619
  const filtered = readWrite.filter((p) => !ours.includes(p));
6273
6620
  if (filtered.length !== readWrite.length) {
6274
6621
  sandbox.filesystem.readWrite = filtered;
@@ -6281,6 +6628,56 @@ var traecode = {
6281
6628
  c.log?.(`traecode: hooks + MCP registration + skill removed`);
6282
6629
  }
6283
6630
  };
6631
+ var genieInstaller = (name, homeDir, mcpPaths) => ({
6632
+ name,
6633
+ detect: (c) => existsSync13(join24(c.home, homeDir)),
6634
+ install(c) {
6635
+ const settingsPath = join24(c.home, homeDir, "settings.json");
6636
+ const settings = readJson2(settingsPath);
6637
+ settings.hooks = settings.hooks ?? {};
6638
+ mergeHarnessHooks(settings.hooks, name, c.dist);
6639
+ writeJson(settingsPath, settings);
6640
+ c.log?.(`${name}: hooks merged into ${settingsPath}`);
6641
+ const paths = mcpPaths(c.home);
6642
+ const mcpPath = paths.find((p) => existsSync13(p)) ?? paths[0];
6643
+ const mcp = readJson2(mcpPath);
6644
+ mcp.mcpServers = mcp.mcpServers ?? {};
6645
+ mcp.mcpServers.hindsight = mcpServerEntry(c.dist, name);
6646
+ writeJson(mcpPath, mcp);
6647
+ c.log?.(`${name}: MCP server registered in ${mcpPath}`);
6648
+ installSkill(c, name);
6649
+ },
6650
+ uninstall(c) {
6651
+ const settingsPath = join24(c.home, homeDir, "settings.json");
6652
+ if (existsSync13(settingsPath)) {
6653
+ const settings = readJson2(settingsPath);
6654
+ if (settings.hooks) {
6655
+ stripHarnessHooks(settings.hooks, name);
6656
+ if (!Object.keys(settings.hooks).length) delete settings.hooks;
6657
+ writeJson(settingsPath, settings);
6658
+ }
6659
+ }
6660
+ for (const mcpPath of mcpPaths(c.home)) {
6661
+ if (!existsSync13(mcpPath)) continue;
6662
+ const mcp = readJson2(mcpPath);
6663
+ if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
6664
+ delete mcp.mcpServers.hindsight;
6665
+ if (!Object.keys(mcp.mcpServers).length) delete mcp.mcpServers;
6666
+ writeJson(mcpPath, mcp);
6667
+ }
6668
+ }
6669
+ uninstallSkill(c, name);
6670
+ c.log?.(`${name}: hooks + MCP registration + skill removed`);
6671
+ }
6672
+ });
6673
+ var workbuddy = genieInstaller("workbuddy", ".workbuddy", (home) => [
6674
+ join24(home, ".workbuddy", "mcp.json")
6675
+ ]);
6676
+ var codebuddy = genieInstaller("codebuddy", ".codebuddy", (home) => [
6677
+ join24(home, ".codebuddy", ".mcp.json"),
6678
+ join24(home, ".codebuddy", "mcp.json"),
6679
+ join24(home, ".codebuddy.json")
6680
+ ]);
6284
6681
  var INSTALLERS = [
6285
6682
  opencode,
6286
6683
  opencode2,
@@ -6301,7 +6698,9 @@ var INSTALLERS = [
6301
6698
  dsh,
6302
6699
  factoryDroid,
6303
6700
  zcode,
6304
- traecode
6701
+ traecode,
6702
+ workbuddy,
6703
+ codebuddy
6305
6704
  ];
6306
6705
  var HARNESS_ALIASES = { agy: "antigravity-cli" };
6307
6706
  function importConversations(harness, ctx) {
@@ -6321,18 +6720,18 @@ function importConversations(harness, ctx) {
6321
6720
  return;
6322
6721
  }
6323
6722
  const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
6324
- const file = join23(mkdtempSync2(join23(tmpdir5(), "hindsight-import-")), "conversations.json");
6723
+ const file = join24(mkdtempSync2(join24(tmpdir5(), "hindsight-import-")), "conversations.json");
6325
6724
  writeFileSync5(file, JSON.stringify(found.sessions));
6326
6725
  ctx.log?.(
6327
6726
  `${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
6328
6727
  );
6329
6728
  try {
6330
- execFileSync7("node", [join23(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
6729
+ execFileSync8("node", [join24(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
6331
6730
  stdio: "inherit"
6332
6731
  });
6333
6732
  } catch {
6334
6733
  ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
6335
- ctx.log?.(` node "${join23(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
6734
+ ctx.log?.(` node "${join24(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
6336
6735
  }
6337
6736
  }
6338
6737
  function run(argv, ctxIn) {
@@ -6437,18 +6836,18 @@ var mainPath = process.argv[1] ? (() => {
6437
6836
  })() : void 0;
6438
6837
  var isMain = mainPath && import.meta.url === pathToFileURL(mainPath).href;
6439
6838
  if (isMain || mainPath?.endsWith("installer.js")) {
6440
- const dist = dirname12(fileURLToPath7(import.meta.url));
6441
- const pkgRoot = dirname12(dist);
6442
- let version;
6839
+ const dist = dirname13(fileURLToPath7(import.meta.url));
6840
+ const pkgRoot = dirname13(dist);
6841
+ let version2;
6443
6842
  try {
6444
- version = JSON.parse(readFileSync16(join23(pkgRoot, "package.json"), "utf8")).version;
6843
+ version2 = JSON.parse(readFileSync15(join24(pkgRoot, "package.json"), "utf8")).version;
6445
6844
  } catch {
6446
- version = void 0;
6845
+ version2 = void 0;
6447
6846
  }
6448
6847
  const ui = createInstallerUi({
6449
6848
  home: homedir13(),
6450
6849
  command: process.argv[2],
6451
- version,
6850
+ version: version2,
6452
6851
  harnessNames: INSTALLERS.map((i) => i.name),
6453
6852
  // configureServer's messages render as their own "server" group, but don't count as an agent.
6454
6853
  auxNames: ["server"],
@@ -6484,11 +6883,11 @@ export {
6484
6883
  };
6485
6884
  /*! Bundled license information:
6486
6885
 
6487
- smol-toml/dist/date.js:
6488
6886
  smol-toml/dist/error.js:
6489
- smol-toml/dist/util.js:
6490
6887
  smol-toml/dist/primitive.js:
6888
+ smol-toml/dist/date.js:
6491
6889
  smol-toml/dist/extract.js:
6890
+ smol-toml/dist/util.js:
6492
6891
  smol-toml/dist/struct.js:
6493
6892
  smol-toml/dist/parse.js:
6494
6893
  smol-toml/dist/stringify.js: