@vectorize-io/hindsight-coding-agents 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -6
- package/dist/antigravity-hook.js +441 -80
- package/dist/antigravity-statusline.js +9 -4
- package/dist/antigravity-stop-hook.js +441 -95
- package/dist/claude-hook.js +441 -80
- package/dist/claude-sessionstart-hook.js +473 -93
- package/dist/claude-stop-hook.js +441 -95
- package/dist/cline.js +290 -95
- package/dist/codebuddy-hook.js +4270 -0
- package/dist/codebuddy-sessionstart-hook.js +5030 -0
- package/dist/codebuddy-stop-hook.js +4564 -0
- package/dist/codex-hook.js +441 -80
- package/dist/codex-sessionstart-hook.js +473 -93
- package/dist/codex-stop-hook.js +441 -95
- package/dist/copilot-hook.js +441 -80
- package/dist/copilot-sessionstart-hook.js +473 -93
- package/dist/copilot-stop-hook.js +441 -95
- package/dist/cursor-hook.js +441 -80
- package/dist/cursor-sessionstart-hook.js +473 -93
- package/dist/cursor-stop-hook.js +441 -95
- package/dist/daemon-start.js +16 -8
- package/dist/dcode-hook.js +441 -80
- package/dist/dcode-sessionstart-hook.js +473 -93
- package/dist/dcode-stop-hook.js +441 -95
- package/dist/deepen.js +140 -49
- package/dist/devin-hook.js +441 -80
- package/dist/devin-sessionstart-hook.js +473 -93
- package/dist/devin-stop-hook.js +441 -95
- package/dist/droid-hook.js +441 -80
- package/dist/droid-sessionstart-hook.js +473 -93
- package/dist/droid-stop-hook.js +441 -95
- package/dist/dsh.js +297 -95
- package/dist/grok-hook.js +441 -80
- package/dist/grok-sessionstart-hook.js +473 -93
- package/dist/grok-stop-hook.js +441 -95
- package/dist/hindsight-seed.js +9 -4
- package/dist/index.js +299 -104
- package/dist/installer.js +1043 -647
- package/dist/kilo.js +299 -104
- package/dist/kimi-hook.js +441 -80
- package/dist/kimi-sessionstart-hook.js +473 -93
- package/dist/kimi-stop-hook.js +441 -95
- package/dist/mcp-server.js +261 -86
- package/dist/opencode2.js +296 -101
- package/dist/pi.js +352 -107
- package/dist/prime-agent.js +352 -107
- package/dist/qwen-hook.js +441 -80
- package/dist/qwen-sessionstart-hook.js +473 -93
- package/dist/qwen-stop-hook.js +441 -95
- package/dist/status.js +115 -42
- package/dist/traecode-hook.js +441 -80
- package/dist/traecode-sessionstart-hook.js +473 -93
- package/dist/traecode-stop-hook.js +441 -95
- package/dist/workbuddy-hook.js +4270 -0
- package/dist/workbuddy-sessionstart-hook.js +5030 -0
- package/dist/workbuddy-stop-hook.js +4564 -0
- package/dist/zcode-hook.js +441 -80
- package/dist/zcode-sessionstart-hook.js +473 -93
- package/dist/zcode-stop-hook.js +441 -95
- package/package.json +9 -3
- package/plugin.json +1 -1
- package/skill/SKILL.md +4 -4
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
|
|
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
|
|
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
|
|
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 = [],
|
|
913
|
+
function handleError(error, skipUntilAfter = [], skipUntil = []) {
|
|
914
914
|
onError(error);
|
|
915
|
-
if (skipUntilAfter.length +
|
|
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 (
|
|
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 (!
|
|
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 (!
|
|
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
|
|
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 (!
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
1456
|
+
TomlError.x("invalid unicode escape", ctx, errPtr);
|
|
1603
1457
|
}
|
|
1604
1458
|
parsed += String.fromCodePoint(value);
|
|
1605
|
-
sliceStart = ctx.p
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
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
|
-
|
|
1549
|
+
super(date);
|
|
1550
|
+
if (!isNaN(this.getTime())) {
|
|
1551
|
+
this.#hasDate = hasDate;
|
|
1552
|
+
this.#hasTime = hasTime;
|
|
1553
|
+
this.#offset = offset;
|
|
1554
|
+
}
|
|
1686
1555
|
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
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
|
|
1695
|
-
|
|
1696
|
-
|
|
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
|
-
|
|
1699
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1720
|
-
ctx.p
|
|
1721
|
-
|
|
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
|
-
|
|
1728
|
-
|
|
1729
|
-
let
|
|
1730
|
-
let dot = start - 1;
|
|
1845
|
+
function parseKey(ctx, end = 61) {
|
|
1846
|
+
let startPtr;
|
|
1847
|
+
let state = 0;
|
|
1731
1848
|
let parsed = [];
|
|
1732
|
-
let
|
|
1733
|
-
|
|
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
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
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 (
|
|
1788
|
-
|
|
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
|
|
1793
|
-
let
|
|
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
|
|
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
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
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 &&
|
|
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
|
-
|
|
1824
|
-
toml: ctx.s,
|
|
1825
|
-
ptr: ctx.p
|
|
1826
|
-
});
|
|
1917
|
+
TomlError.x("trying to redefine an already defined value", ctx, errPtr);
|
|
1827
1918
|
}
|
|
1828
|
-
|
|
1829
|
-
|
|
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
|
-
|
|
1836
|
-
}
|
|
1931
|
+
if (c !== 44)
|
|
1932
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
1837
1933
|
}
|
|
1838
|
-
|
|
1839
|
-
toml: ctx.s,
|
|
1840
|
-
ptr: ctx.p
|
|
1841
|
-
});
|
|
1934
|
+
TomlError.x("unfinished table", ctx, startPtr);
|
|
1842
1935
|
}
|
|
1843
|
-
function parseArray(ctx
|
|
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(
|
|
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
|
-
|
|
1860
|
-
}
|
|
1955
|
+
if (c !== 44)
|
|
1956
|
+
TomlError.x("expected comma or end of structure", ctx, ctx.p - 1);
|
|
1861
1957
|
}
|
|
1862
|
-
|
|
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
|
-
|
|
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
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
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
|
-
|
|
2050
|
+
skipping = false;
|
|
2051
|
+
let k = parseKey(
|
|
2052
|
+
ctx,
|
|
2053
|
+
93
|
|
2054
|
+
/* ] */
|
|
2055
|
+
);
|
|
1941
2056
|
if (isTableArray) {
|
|
1942
|
-
if (toml.charCodeAt(ctx.p
|
|
1943
|
-
|
|
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
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
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
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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.1";
|
|
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
|
|
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
|
|
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,15 @@ 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";
|
|
2439
2550
|
|
|
2440
2551
|
// src/core/status.ts
|
|
2441
|
-
import { execFileSync as
|
|
2552
|
+
import { execFileSync as execFileSync4 } from "child_process";
|
|
2442
2553
|
|
|
2443
2554
|
// src/core/survey.ts
|
|
2444
|
-
import { spawn as realSpawn4 } from "child_process";
|
|
2555
|
+
import { execFileSync as execFileSync3, spawn as realSpawn4 } from "child_process";
|
|
2445
2556
|
import { createHash as createHash4 } from "crypto";
|
|
2446
2557
|
import { existsSync as existsSync3 } from "fs";
|
|
2447
2558
|
import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
|
|
@@ -2470,7 +2581,7 @@ import { spawn as realSpawn5 } from "child_process";
|
|
|
2470
2581
|
import {
|
|
2471
2582
|
existsSync as existsSync4,
|
|
2472
2583
|
mkdirSync as mkdirSync5,
|
|
2473
|
-
readFileSync as
|
|
2584
|
+
readFileSync as readFileSync7,
|
|
2474
2585
|
realpathSync as realpathSync2,
|
|
2475
2586
|
unlinkSync as unlinkSync2,
|
|
2476
2587
|
writeFileSync as writeFileSync3
|
|
@@ -2484,7 +2595,7 @@ var NPM_VIEW_HARD_DEADLINE_MS = NPM_VIEW_TIMEOUT_MS + 1e3;
|
|
|
2484
2595
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
2485
2596
|
|
|
2486
2597
|
// src/core/skill-sync.ts
|
|
2487
|
-
import { cpSync, existsSync as existsSync6, readFileSync as
|
|
2598
|
+
import { cpSync, existsSync as existsSync6, readFileSync as readFileSync8 } from "fs";
|
|
2488
2599
|
import { homedir as homedir6 } from "os";
|
|
2489
2600
|
import { dirname as dirname10, join as join16 } from "path";
|
|
2490
2601
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -2520,7 +2631,12 @@ var SKILL_DIRS = {
|
|
|
2520
2631
|
// by fixed directory name, so installing to the shared one would make `uninstall pi` take Codex's
|
|
2521
2632
|
// and dsh's copy with it.
|
|
2522
2633
|
pi: [".pi", "agent", "skills"],
|
|
2523
|
-
"prime-agent": [".prime", "agent", "skills"]
|
|
2634
|
+
"prime-agent": [".prime", "agent", "skills"],
|
|
2635
|
+
// WorkBuddy's own user-level skills root (the @genie/agent-cli engine reads ~/.workbuddy).
|
|
2636
|
+
workbuddy: [".workbuddy", "skills"],
|
|
2637
|
+
// CodeBuddy Code reads that SAME engine's default root, ~/.codebuddy — WorkBuddy only overrides
|
|
2638
|
+
// its home folder (product config `dataLayout.configDir.userDirName`), so the two differ by config.
|
|
2639
|
+
codebuddy: [".codebuddy", "skills"]
|
|
2524
2640
|
};
|
|
2525
2641
|
var TRAE_DOT_DIRS = [".trae-cn", ".trae"];
|
|
2526
2642
|
var traecodeDotDirName = (home, exists = existsSync5) => {
|
|
@@ -2538,7 +2654,7 @@ var resolveSkillDirs = (harness, home) => {
|
|
|
2538
2654
|
};
|
|
2539
2655
|
|
|
2540
2656
|
// src/core/legacy.ts
|
|
2541
|
-
import { existsSync as existsSync7, readFileSync as
|
|
2657
|
+
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
|
|
2542
2658
|
import { homedir as homedir7 } from "os";
|
|
2543
2659
|
import { join as join17, relative, isAbsolute as isAbsolute2 } from "path";
|
|
2544
2660
|
var LEGACY_CONFIG_FILES = {
|
|
@@ -2564,7 +2680,7 @@ function readOne(harness, home) {
|
|
|
2564
2680
|
if (!existsSync7(source)) return void 0;
|
|
2565
2681
|
let raw;
|
|
2566
2682
|
try {
|
|
2567
|
-
raw = JSON.parse(
|
|
2683
|
+
raw = JSON.parse(readFileSync9(source, "utf8"));
|
|
2568
2684
|
} catch {
|
|
2569
2685
|
return void 0;
|
|
2570
2686
|
}
|
|
@@ -2591,8 +2707,8 @@ function readOne(harness, home) {
|
|
|
2591
2707
|
}
|
|
2592
2708
|
|
|
2593
2709
|
// src/core/traecode-mcp.ts
|
|
2594
|
-
import { execFileSync as
|
|
2595
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as
|
|
2710
|
+
import { execFileSync as execFileSync5 } from "child_process";
|
|
2711
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync10, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync4 } from "fs";
|
|
2596
2712
|
import { homedir as homedir8 } from "os";
|
|
2597
2713
|
import { dirname as dirname11, isAbsolute as isAbsolute3, join as join18 } from "path";
|
|
2598
2714
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
@@ -2629,7 +2745,7 @@ function gateStateFile() {
|
|
|
2629
2745
|
}
|
|
2630
2746
|
function readGateState(opts = {}) {
|
|
2631
2747
|
try {
|
|
2632
|
-
return JSON.parse(
|
|
2748
|
+
return JSON.parse(readFileSync10(opts.stateFile ?? gateStateFile(), "utf8"));
|
|
2633
2749
|
} catch {
|
|
2634
2750
|
return {};
|
|
2635
2751
|
}
|
|
@@ -2637,7 +2753,7 @@ function readGateState(opts = {}) {
|
|
|
2637
2753
|
function workspaceMcpGateState(settingsPath) {
|
|
2638
2754
|
let raw;
|
|
2639
2755
|
try {
|
|
2640
|
-
raw =
|
|
2756
|
+
raw = readFileSync10(settingsPath, "utf8");
|
|
2641
2757
|
} catch {
|
|
2642
2758
|
return "unknown";
|
|
2643
2759
|
}
|
|
@@ -2653,7 +2769,7 @@ function enableWorkspaceMcpSetting(settingsPath) {
|
|
|
2653
2769
|
try {
|
|
2654
2770
|
let doc = {};
|
|
2655
2771
|
try {
|
|
2656
|
-
doc = JSON.parse(
|
|
2772
|
+
doc = JSON.parse(readFileSync10(settingsPath, "utf8"));
|
|
2657
2773
|
} catch {
|
|
2658
2774
|
if (existsSync8(settingsPath)) return false;
|
|
2659
2775
|
}
|
|
@@ -2702,7 +2818,7 @@ function gitignoreCovers(lines) {
|
|
|
2702
2818
|
function ensureGitignored(repo) {
|
|
2703
2819
|
const gitignore = join18(repo, ".gitignore");
|
|
2704
2820
|
if (!existsSync8(gitignore)) return;
|
|
2705
|
-
const current2 =
|
|
2821
|
+
const current2 = readFileSync10(gitignore, "utf8");
|
|
2706
2822
|
if (gitignoreCovers(current2.split("\n"))) return;
|
|
2707
2823
|
const addition = (current2.endsWith("\n") || current2 === "" ? "" : "\n") + "# hindsight MCP registration (machine-specific)\n.trae/mcp.json\n";
|
|
2708
2824
|
writeFileSync4(gitignore, current2 + addition);
|
|
@@ -2723,7 +2839,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2723
2839
|
let doc = {};
|
|
2724
2840
|
let exists = false;
|
|
2725
2841
|
try {
|
|
2726
|
-
doc = JSON.parse(
|
|
2842
|
+
doc = JSON.parse(readFileSync10(file, "utf8"));
|
|
2727
2843
|
exists = true;
|
|
2728
2844
|
} catch {
|
|
2729
2845
|
if (existsSync8(file)) return "skipped";
|
|
@@ -2772,7 +2888,7 @@ function removeTraecodeWorkspaceMcpEntry(cwd, opts = {}) {
|
|
|
2772
2888
|
const file = join18(cwd, MCP_FILE_REL);
|
|
2773
2889
|
let doc;
|
|
2774
2890
|
try {
|
|
2775
|
-
doc = JSON.parse(
|
|
2891
|
+
doc = JSON.parse(readFileSync10(file, "utf8"));
|
|
2776
2892
|
} catch {
|
|
2777
2893
|
return false;
|
|
2778
2894
|
}
|
|
@@ -2806,7 +2922,7 @@ function removeWorkspaceMcpEnabledKeys(home) {
|
|
|
2806
2922
|
const db = join18(storage, name, "state.vscdb");
|
|
2807
2923
|
if (!existsSync8(db)) continue;
|
|
2808
2924
|
try {
|
|
2809
|
-
|
|
2925
|
+
execFileSync5(
|
|
2810
2926
|
"sqlite3",
|
|
2811
2927
|
[
|
|
2812
2928
|
db,
|
|
@@ -2832,7 +2948,7 @@ function findWorkspaceStorageDir(storage, repo) {
|
|
|
2832
2948
|
}
|
|
2833
2949
|
for (const name of entries) {
|
|
2834
2950
|
try {
|
|
2835
|
-
const doc = JSON.parse(
|
|
2951
|
+
const doc = JSON.parse(readFileSync10(join18(storage, name, "workspace.json"), "utf8"));
|
|
2836
2952
|
if (typeof doc.folder !== "string") continue;
|
|
2837
2953
|
let folder;
|
|
2838
2954
|
try {
|
|
@@ -2855,7 +2971,7 @@ function ensureWorkspaceMcpEnabled(cwd, opts = {}) {
|
|
|
2855
2971
|
if (!dir) return "failed";
|
|
2856
2972
|
const db = join18(dir, "state.vscdb");
|
|
2857
2973
|
if (!existsSync8(db)) return "failed";
|
|
2858
|
-
const sqlite = opts.sqlite ??
|
|
2974
|
+
const sqlite = opts.sqlite ?? execFileSync5;
|
|
2859
2975
|
const run2 = (sql) => sqlite("sqlite3", [db, ".timeout 3000", sql], {
|
|
2860
2976
|
encoding: "utf8",
|
|
2861
2977
|
timeout: SQLITE_TIMEOUT_MS,
|
|
@@ -2903,6 +3019,14 @@ function isSyntheticUserText(text) {
|
|
|
2903
3019
|
const s = text.trimStart();
|
|
2904
3020
|
return s.startsWith("# AGENTS.md instructions for ") || s.startsWith("<environment_context>");
|
|
2905
3021
|
}
|
|
3022
|
+
var AGENTS_BLOCK_HEADER = /^# AGENTS\.md instructions(?: for [^\n]*)?\n/;
|
|
3023
|
+
var STARTUP_TAG_BLOCK = /^<(recommended_plugins|environment_context)>(?:(?!<\1>)[\s\S])*<\/\1>$/;
|
|
3024
|
+
function isStartupItem(text) {
|
|
3025
|
+
const s = text.trim();
|
|
3026
|
+
if (AGENTS_BLOCK_HEADER.test(s))
|
|
3027
|
+
return s.includes("<INSTRUCTIONS>") && s.includes("</INSTRUCTIONS>");
|
|
3028
|
+
return STARTUP_TAG_BLOCK.test(s);
|
|
3029
|
+
}
|
|
2906
3030
|
function contentText(content) {
|
|
2907
3031
|
return (Array.isArray(content) ? content : []).filter((c) => c && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
2908
3032
|
}
|
|
@@ -2919,7 +3043,10 @@ function fallbackUserText(payload) {
|
|
|
2919
3043
|
if (Array.isArray(content) && Array.isArray(kinds) && kinds.length === content.length && kinds.every((kind) => typeof kind === "string" && kind.length > 0)) {
|
|
2920
3044
|
return contentText(content.filter((_, index) => !startupKinds.has(kinds[index])));
|
|
2921
3045
|
}
|
|
2922
|
-
const
|
|
3046
|
+
const items = (Array.isArray(content) ? content : []).filter(
|
|
3047
|
+
(c) => !(c && typeof c.text === "string" && isStartupItem(stripInjectedMemory(c.text)))
|
|
3048
|
+
);
|
|
3049
|
+
const text = contentText(items);
|
|
2923
3050
|
return isSyntheticUserText(stripInjectedMemory(text)) ? "" : text;
|
|
2924
3051
|
}
|
|
2925
3052
|
function isUserMessageEvent(line) {
|
|
@@ -3096,7 +3223,7 @@ function readCopilotTranscript(path) {
|
|
|
3096
3223
|
}
|
|
3097
3224
|
|
|
3098
3225
|
// src/core/transcript-grok.ts
|
|
3099
|
-
import { existsSync as existsSync9, readFileSync as
|
|
3226
|
+
import { existsSync as existsSync9, readFileSync as readFileSync11, readdirSync as readdirSync3 } from "fs";
|
|
3100
3227
|
import { homedir as homedir9 } from "os";
|
|
3101
3228
|
import { join as join19 } from "path";
|
|
3102
3229
|
var CHAT_HISTORY = "chat_history.jsonl";
|
|
@@ -3107,7 +3234,7 @@ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
|
|
|
3107
3234
|
try {
|
|
3108
3235
|
for (const candidate of readdirSync3(sessionsDir)) {
|
|
3109
3236
|
const directory = join19(sessionsDir, candidate);
|
|
3110
|
-
if (
|
|
3237
|
+
if (readFileSync11(join19(directory, ".cwd"), "utf8").trim() === cwd) {
|
|
3111
3238
|
return join19(directory, sessionId, CHAT_HISTORY);
|
|
3112
3239
|
}
|
|
3113
3240
|
}
|
|
@@ -3458,7 +3585,7 @@ function readDroidTranscript(path) {
|
|
|
3458
3585
|
}
|
|
3459
3586
|
|
|
3460
3587
|
// src/core/transcript-zcode.ts
|
|
3461
|
-
import { readFileSync as
|
|
3588
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
3462
3589
|
function messageText(content) {
|
|
3463
3590
|
if (typeof content === "string") return content.trim();
|
|
3464
3591
|
if (!Array.isArray(content)) return "";
|
|
@@ -3468,7 +3595,7 @@ function readZcodeTranscript(path) {
|
|
|
3468
3595
|
if (!path) return [];
|
|
3469
3596
|
let body;
|
|
3470
3597
|
try {
|
|
3471
|
-
body =
|
|
3598
|
+
body = readFileSync12(path, "utf8");
|
|
3472
3599
|
} catch {
|
|
3473
3600
|
return [];
|
|
3474
3601
|
}
|
|
@@ -3627,6 +3754,135 @@ function readKimiTranscript(path) {
|
|
|
3627
3754
|
return turns;
|
|
3628
3755
|
}
|
|
3629
3756
|
|
|
3757
|
+
// src/core/transcript-workbuddy.ts
|
|
3758
|
+
function messageText2(content) {
|
|
3759
|
+
if (typeof content === "string") return content;
|
|
3760
|
+
if (!Array.isArray(content)) return "";
|
|
3761
|
+
return content.filter((b) => b && typeof b.text === "string").map((b) => b.text).join("\n");
|
|
3762
|
+
}
|
|
3763
|
+
var USER_QUERY_RE = /^\s*<user_query>([\s\S]*?)<\/user_query>\s*(?:<image_local_path>[\s\S]*?<\/image_local_path>\s*)?$/;
|
|
3764
|
+
function unwrapUserQuery(text) {
|
|
3765
|
+
const match = USER_QUERY_RE.exec(text);
|
|
3766
|
+
return (match ? match[1] : text).trim();
|
|
3767
|
+
}
|
|
3768
|
+
function isSyntheticUserText2(text) {
|
|
3769
|
+
const s = text.trimStart();
|
|
3770
|
+
return s.startsWith("<cb_summary>") || s.startsWith("<conversation_history_summary>") || s.startsWith("Use the TaskOutput tool ");
|
|
3771
|
+
}
|
|
3772
|
+
function parseArgs2(raw) {
|
|
3773
|
+
if (!raw) return void 0;
|
|
3774
|
+
try {
|
|
3775
|
+
return JSON.parse(raw);
|
|
3776
|
+
} catch {
|
|
3777
|
+
return raw;
|
|
3778
|
+
}
|
|
3779
|
+
}
|
|
3780
|
+
function stampOf3(line) {
|
|
3781
|
+
return typeof line.timestamp === "number" ? { timestamp: new Date(line.timestamp).toISOString() } : {};
|
|
3782
|
+
}
|
|
3783
|
+
function readWorkbuddyTranscript(path) {
|
|
3784
|
+
const turns = [];
|
|
3785
|
+
for (const rawLine of readJsonl(path)) {
|
|
3786
|
+
const trimmed = rawLine.trim();
|
|
3787
|
+
if (!trimmed) continue;
|
|
3788
|
+
let parsed;
|
|
3789
|
+
try {
|
|
3790
|
+
parsed = JSON.parse(trimmed);
|
|
3791
|
+
} catch {
|
|
3792
|
+
continue;
|
|
3793
|
+
}
|
|
3794
|
+
if (typeof parsed !== "object" || parsed === null) continue;
|
|
3795
|
+
const line = parsed;
|
|
3796
|
+
const stamp = stampOf3(line);
|
|
3797
|
+
if (line.type === "message") {
|
|
3798
|
+
if (line.role !== "user" && line.role !== "assistant") continue;
|
|
3799
|
+
let text = stripInjectedMemory(messageText2(line.content)).trim();
|
|
3800
|
+
if (!text) continue;
|
|
3801
|
+
if (line.role === "user") {
|
|
3802
|
+
if (isSyntheticUserText2(text)) continue;
|
|
3803
|
+
text = unwrapUserQuery(text);
|
|
3804
|
+
if (!text) continue;
|
|
3805
|
+
}
|
|
3806
|
+
turns.push({ role: line.role, content: text, ...stamp });
|
|
3807
|
+
} else if (line.type === "function_call" && typeof line.name === "string") {
|
|
3808
|
+
turns.push({
|
|
3809
|
+
role: "action",
|
|
3810
|
+
content: actionLine(line.name, parseArgs2(line.arguments)),
|
|
3811
|
+
...stamp
|
|
3812
|
+
});
|
|
3813
|
+
}
|
|
3814
|
+
}
|
|
3815
|
+
return turns;
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
// src/core/transcript-codebuddy-ide.ts
|
|
3819
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
3820
|
+
import { basename as basename3, dirname as dirname12, join as join22 } from "path";
|
|
3821
|
+
var IDE_CONTEXT_RE = /<(user_info|git_status|additional_data|system_reminder)\b[\s\S]*?<\/\1>/g;
|
|
3822
|
+
function readJson(path) {
|
|
3823
|
+
try {
|
|
3824
|
+
return JSON.parse(readFileSync13(path, "utf8"));
|
|
3825
|
+
} catch {
|
|
3826
|
+
return void 0;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
function ideUserText(raw) {
|
|
3830
|
+
let text = stripInjectedMemory(raw).replace(IDE_CONTEXT_RE, "").trim();
|
|
3831
|
+
if (!text || isSyntheticUserText2(text)) return "";
|
|
3832
|
+
return unwrapUserQuery(text).trim();
|
|
3833
|
+
}
|
|
3834
|
+
function readCodebuddyIdeTranscript(indexPath) {
|
|
3835
|
+
const index = readJson(indexPath);
|
|
3836
|
+
const entries = index?.messages;
|
|
3837
|
+
if (!Array.isArray(entries)) return [];
|
|
3838
|
+
const messagesDir = join22(dirname12(indexPath), "messages");
|
|
3839
|
+
const turns = [];
|
|
3840
|
+
for (const entry of entries) {
|
|
3841
|
+
const id = entry?.id;
|
|
3842
|
+
if (typeof id !== "string") continue;
|
|
3843
|
+
const file = readJson(join22(messagesDir, `${id}.json`));
|
|
3844
|
+
const encoded = file?.message;
|
|
3845
|
+
if (typeof encoded !== "string") continue;
|
|
3846
|
+
let inner;
|
|
3847
|
+
try {
|
|
3848
|
+
inner = JSON.parse(encoded);
|
|
3849
|
+
} catch {
|
|
3850
|
+
continue;
|
|
3851
|
+
}
|
|
3852
|
+
const role = typeof inner.role === "string" ? inner.role : file?.role;
|
|
3853
|
+
const isUser = role === "user";
|
|
3854
|
+
const isAssistant = role === "assistant";
|
|
3855
|
+
const stamp = typeof file?.createdAt === "string" ? { timestamp: file.createdAt } : {};
|
|
3856
|
+
const blocks = Array.isArray(inner.content) ? inner.content : [];
|
|
3857
|
+
const texts = [];
|
|
3858
|
+
const calls = [];
|
|
3859
|
+
for (const block of blocks) {
|
|
3860
|
+
if (!block || typeof block !== "object") continue;
|
|
3861
|
+
const { type, text, toolName, args } = block;
|
|
3862
|
+
if (type === "text" && typeof text === "string") texts.push(text);
|
|
3863
|
+
else if (type === "tool-call" && typeof toolName === "string")
|
|
3864
|
+
calls.push({ name: toolName, args });
|
|
3865
|
+
}
|
|
3866
|
+
if (texts.length) {
|
|
3867
|
+
const raw = texts.join("\n");
|
|
3868
|
+
if (isUser) {
|
|
3869
|
+
const text = ideUserText(raw);
|
|
3870
|
+
if (text) turns.push({ role: "user", content: text, ...stamp });
|
|
3871
|
+
} else if (isAssistant) {
|
|
3872
|
+
const text = stripInjectedMemory(raw).trim();
|
|
3873
|
+
if (text) turns.push({ role: "assistant", content: text, ...stamp });
|
|
3874
|
+
}
|
|
3875
|
+
}
|
|
3876
|
+
for (const call of calls) {
|
|
3877
|
+
turns.push({ role: "action", content: actionLine(call.name, call.args), ...stamp });
|
|
3878
|
+
}
|
|
3879
|
+
}
|
|
3880
|
+
return turns;
|
|
3881
|
+
}
|
|
3882
|
+
function readCodebuddyTranscript(path) {
|
|
3883
|
+
return basename3(path) === "index.json" ? readCodebuddyIdeTranscript(path) : readWorkbuddyTranscript(path);
|
|
3884
|
+
}
|
|
3885
|
+
|
|
3630
3886
|
// src/harness/hook-lifecycle.ts
|
|
3631
3887
|
var cursorCwd = (ev) => ev.cwd ?? ev.workspace_root ?? (Array.isArray(ev.workspace_roots) ? ev.workspace_roots[0] : void 0);
|
|
3632
3888
|
var claudePrompt = {
|
|
@@ -3732,6 +3988,35 @@ var standardSessionStart = (harness) => ({
|
|
|
3732
3988
|
}
|
|
3733
3989
|
})
|
|
3734
3990
|
});
|
|
3991
|
+
var genieSessionStart = (harness) => {
|
|
3992
|
+
const base = standardSessionStart(harness);
|
|
3993
|
+
return {
|
|
3994
|
+
...base,
|
|
3995
|
+
parse: (ev) => ({
|
|
3996
|
+
cwd: ev.cwd || process.env.CODEBUDDY_PROJECT_DIR,
|
|
3997
|
+
sessionId: ev.session_id
|
|
3998
|
+
}),
|
|
3999
|
+
emit: (out) => ({ ...base.emit(out), suppressOutput: true })
|
|
4000
|
+
};
|
|
4001
|
+
};
|
|
4002
|
+
var geniePrompt = (harness) => ({
|
|
4003
|
+
...claudePrompt,
|
|
4004
|
+
harness,
|
|
4005
|
+
emit: (context, notice, ev) => ({
|
|
4006
|
+
...claudePrompt.emit(context, notice, ev),
|
|
4007
|
+
suppressOutput: true
|
|
4008
|
+
})
|
|
4009
|
+
});
|
|
4010
|
+
var genieRetain = (harness, readTranscript) => ({
|
|
4011
|
+
hostTimeoutSec: 60,
|
|
4012
|
+
harness,
|
|
4013
|
+
parse: (ev) => ({
|
|
4014
|
+
sessionId: ev.session_id,
|
|
4015
|
+
transcriptPath: ev.transcript_path,
|
|
4016
|
+
cwd: ev.cwd
|
|
4017
|
+
}),
|
|
4018
|
+
readTranscript
|
|
4019
|
+
});
|
|
3735
4020
|
var notGrokHosted = () => !process.env.GROK_HOOK_EVENT;
|
|
3736
4021
|
var HOOK_HARNESSES = {
|
|
3737
4022
|
"claude-code": {
|
|
@@ -3929,17 +4214,29 @@ var HOOK_HARNESSES = {
|
|
|
3929
4214
|
prompt: { event: "UserPromptSubmit", entry: "grok-hook.js", timeout: 30 },
|
|
3930
4215
|
stop: { event: "Stop", entry: "grok-stop-hook.js", timeout: 60 }
|
|
3931
4216
|
},
|
|
4217
|
+
// Grok hands the model `additionalContext` from TOOL hooks only: SessionStart is observe-only
|
|
4218
|
+
// and UserPromptSubmit can only block (#5467). Both stash their context instead, and the
|
|
4219
|
+
// prompt entry, also registered on PostToolUse, delivers it beside the next tool result.
|
|
4220
|
+
additionalHooks: [{ event: "PostToolUse", entry: "grok-hook.js", timeout: 30 }],
|
|
3932
4221
|
sessionStart: {
|
|
3933
4222
|
...standardSessionStart("grok-build"),
|
|
3934
4223
|
// Grok's wire envelope is camelCase, unlike Claude's similarly named hook events.
|
|
3935
4224
|
parse: (ev) => ({
|
|
3936
4225
|
cwd: ev.cwd,
|
|
3937
4226
|
sessionId: ev.sessionId
|
|
3938
|
-
})
|
|
4227
|
+
}),
|
|
4228
|
+
deferContextToToolHook: true
|
|
3939
4229
|
},
|
|
3940
4230
|
prompt: {
|
|
3941
4231
|
...claudePrompt,
|
|
3942
4232
|
harness: "grok-build",
|
|
4233
|
+
toolHook: {
|
|
4234
|
+
// Grok names the event twice: snake_case `hookEventName`, plus a Claude-named alias.
|
|
4235
|
+
accept: (ev) => ev.hookEventName === "post_tool_use" || ev.hook_event_name === "PostToolUse",
|
|
4236
|
+
emit: (context) => ({
|
|
4237
|
+
hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: context }
|
|
4238
|
+
})
|
|
4239
|
+
},
|
|
3943
4240
|
parse: (ev) => ({
|
|
3944
4241
|
prompt: ev.prompt,
|
|
3945
4242
|
cwd: ev.cwd,
|
|
@@ -4173,37 +4470,79 @@ var HOOK_HARNESSES = {
|
|
|
4173
4470
|
},
|
|
4174
4471
|
readTranscript: readKimiTranscript
|
|
4175
4472
|
}
|
|
4473
|
+
},
|
|
4474
|
+
/**
|
|
4475
|
+
* WorkBuddy (Tencent's AI workbench) keeps a durable transcript at
|
|
4476
|
+
* ~/.workbuddy/projects/<cwd-encoded>/<uuid>.jsonl and speaks Claude's hook protocol —
|
|
4477
|
+
* `session_id` / `transcript_path` / `cwd` in, hookSpecificOutput + systemMessage out — apart
|
|
4478
|
+
* from the two quirks genieSessionStart/geniePrompt handle. The other host-specific piece is the
|
|
4479
|
+
* transcript SCHEMA: `type:"message"` records carrying top-level `role`/`content`, which
|
|
4480
|
+
* core/transcript-workbuddy.ts normalizes. Its Stop payload fills `transcript_path` for real (the
|
|
4481
|
+
* engine's own getHookTranscriptPath), so it retains through `readTranscript` like every other
|
|
4482
|
+
* file-backed host rather than the journal ZCode needs.
|
|
4483
|
+
* CodeBuddy Code ships the same @genie/agent-cli engine and reuses this reader (see `codebuddy`).
|
|
4484
|
+
*/
|
|
4485
|
+
workbuddy: {
|
|
4486
|
+
configStyle: "nested",
|
|
4487
|
+
install: {
|
|
4488
|
+
sessionStart: { event: "SessionStart", entry: "workbuddy-sessionstart-hook.js", timeout: 30 },
|
|
4489
|
+
prompt: { event: "UserPromptSubmit", entry: "workbuddy-hook.js", timeout: 30 },
|
|
4490
|
+
stop: { event: "Stop", entry: "workbuddy-stop-hook.js", timeout: 60 }
|
|
4491
|
+
},
|
|
4492
|
+
sessionStart: genieSessionStart("workbuddy"),
|
|
4493
|
+
prompt: geniePrompt("workbuddy"),
|
|
4494
|
+
retain: genieRetain("workbuddy", readWorkbuddyTranscript)
|
|
4495
|
+
},
|
|
4496
|
+
/**
|
|
4497
|
+
* CodeBuddy — the same `@genie/agent-cli` engine WorkBuddy ships, running under its own product
|
|
4498
|
+
* config (`~/.codebuddy`; WorkBuddy only renames the home folder). Hook names and payload shape
|
|
4499
|
+
* are identical, so this spec differs from `workbuddy` in the files the installer writes, the
|
|
4500
|
+
* harness name stamped on what it retains — and ONE thing more: CodeBuddy ships in two hosts whose
|
|
4501
|
+
* transcripts do NOT look alike. CodeBuddy Code (the CLI) writes the WorkBuddy JSONL, while the
|
|
4502
|
+
* IDE hands the Stop hook its own `<conversation>/index.json` directory layout. So the reader is
|
|
4503
|
+
* a dispatcher on the shape it was handed (core/transcript-codebuddy-ide.ts).
|
|
4504
|
+
*/
|
|
4505
|
+
codebuddy: {
|
|
4506
|
+
configStyle: "nested",
|
|
4507
|
+
install: {
|
|
4508
|
+
sessionStart: { event: "SessionStart", entry: "codebuddy-sessionstart-hook.js", timeout: 30 },
|
|
4509
|
+
prompt: { event: "UserPromptSubmit", entry: "codebuddy-hook.js", timeout: 30 },
|
|
4510
|
+
stop: { event: "Stop", entry: "codebuddy-stop-hook.js", timeout: 60 }
|
|
4511
|
+
},
|
|
4512
|
+
sessionStart: genieSessionStart("codebuddy"),
|
|
4513
|
+
prompt: geniePrompt("codebuddy"),
|
|
4514
|
+
retain: genieRetain("codebuddy", readCodebuddyTranscript)
|
|
4176
4515
|
}
|
|
4177
4516
|
};
|
|
4178
4517
|
|
|
4179
4518
|
// src/core/history.ts
|
|
4180
|
-
import { execFileSync as
|
|
4519
|
+
import { execFileSync as execFileSync6 } from "child_process";
|
|
4181
4520
|
import {
|
|
4182
4521
|
closeSync as closeSync2,
|
|
4183
4522
|
existsSync as existsSync12,
|
|
4184
4523
|
openSync as openSync2,
|
|
4185
4524
|
readdirSync as readdirSync5,
|
|
4186
|
-
readFileSync as
|
|
4525
|
+
readFileSync as readFileSync14,
|
|
4187
4526
|
readSync as readSync2,
|
|
4188
4527
|
statSync as statSync4
|
|
4189
4528
|
} from "fs";
|
|
4190
4529
|
import { createHash as createHash5 } from "crypto";
|
|
4191
4530
|
import { homedir as homedir12 } from "os";
|
|
4192
|
-
import { join as
|
|
4531
|
+
import { join as join23 } from "path";
|
|
4193
4532
|
import * as zlib2 from "zlib";
|
|
4194
4533
|
|
|
4195
4534
|
// src/core/transcript-dsh.ts
|
|
4196
4535
|
function textOf(message) {
|
|
4197
4536
|
return (message.content || []).filter((block) => block?.type === "text" && typeof block.text === "string").map((block) => block.text).join("\n").trim();
|
|
4198
4537
|
}
|
|
4199
|
-
function
|
|
4538
|
+
function stampOf4(event) {
|
|
4200
4539
|
return typeof event.time === "number" ? { timestamp: new Date(event.time).toISOString() } : {};
|
|
4201
4540
|
}
|
|
4202
4541
|
function readDshEvents(events) {
|
|
4203
4542
|
const turns = [];
|
|
4204
4543
|
for (const event of events || []) {
|
|
4205
4544
|
if (!event || typeof event !== "object") continue;
|
|
4206
|
-
const stamp =
|
|
4545
|
+
const stamp = stampOf4(event);
|
|
4207
4546
|
if (event.type === "user/message") {
|
|
4208
4547
|
const message = event.data;
|
|
4209
4548
|
if (!message || message.source?.kind !== "user") continue;
|
|
@@ -4219,14 +4558,14 @@ function readDshEvents(events) {
|
|
|
4219
4558
|
if (!call?.name) continue;
|
|
4220
4559
|
turns.push({
|
|
4221
4560
|
role: "action",
|
|
4222
|
-
content: actionLine(call.name,
|
|
4561
|
+
content: actionLine(call.name, parseArgs3(call.arguments)),
|
|
4223
4562
|
...stamp
|
|
4224
4563
|
});
|
|
4225
4564
|
}
|
|
4226
4565
|
}
|
|
4227
4566
|
return turns;
|
|
4228
4567
|
}
|
|
4229
|
-
function
|
|
4568
|
+
function parseArgs3(raw) {
|
|
4230
4569
|
if (!raw) return void 0;
|
|
4231
4570
|
try {
|
|
4232
4571
|
return JSON.parse(raw);
|
|
@@ -4264,7 +4603,7 @@ function renderMessage(m) {
|
|
|
4264
4603
|
return out;
|
|
4265
4604
|
}
|
|
4266
4605
|
function readPiTranscript(path) {
|
|
4267
|
-
const
|
|
4606
|
+
const entries = [];
|
|
4268
4607
|
for (const rawLine of readJsonl(path)) {
|
|
4269
4608
|
const trimmed = rawLine.trim();
|
|
4270
4609
|
if (!trimmed) continue;
|
|
@@ -4274,9 +4613,14 @@ function readPiTranscript(path) {
|
|
|
4274
4613
|
} catch {
|
|
4275
4614
|
continue;
|
|
4276
4615
|
}
|
|
4277
|
-
if (typeof parsed
|
|
4278
|
-
|
|
4279
|
-
|
|
4616
|
+
if (typeof parsed === "object" && parsed !== null) entries.push(parsed);
|
|
4617
|
+
}
|
|
4618
|
+
return readPiEntries(entries);
|
|
4619
|
+
}
|
|
4620
|
+
function readPiEntries(entries) {
|
|
4621
|
+
const turns = [];
|
|
4622
|
+
for (const entry of entries) {
|
|
4623
|
+
if (!entry || entry.type !== "message" || !entry.message) continue;
|
|
4280
4624
|
for (const turn of renderMessage(entry.message)) {
|
|
4281
4625
|
turns.push(entry.timestamp ? { ...turn, timestamp: entry.timestamp } : turn);
|
|
4282
4626
|
}
|
|
@@ -4334,7 +4678,7 @@ function zstdDecompressFrames(buffer) {
|
|
|
4334
4678
|
|
|
4335
4679
|
// src/core/history.ts
|
|
4336
4680
|
function claudeProjectDir(repoDir, home = homedir12()) {
|
|
4337
|
-
return
|
|
4681
|
+
return join23(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
|
|
4338
4682
|
}
|
|
4339
4683
|
function piSessionDir(repoDir) {
|
|
4340
4684
|
return `--${repoDir.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
@@ -4344,7 +4688,7 @@ function withinRepo(dir, repoDir) {
|
|
|
4344
4688
|
}
|
|
4345
4689
|
function claudeSessionCwd(file) {
|
|
4346
4690
|
try {
|
|
4347
|
-
for (const line of
|
|
4691
|
+
for (const line of readFileSync14(file, "utf8").split("\n", 400)) {
|
|
4348
4692
|
if (!line.includes('"cwd"')) continue;
|
|
4349
4693
|
const cwd = JSON.parse(line).cwd;
|
|
4350
4694
|
if (cwd) return cwd;
|
|
@@ -4386,13 +4730,13 @@ function listDir(dir) {
|
|
|
4386
4730
|
}
|
|
4387
4731
|
}
|
|
4388
4732
|
function jsonlFiles(dir) {
|
|
4389
|
-
return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) =>
|
|
4733
|
+
return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join23(dir, f));
|
|
4390
4734
|
}
|
|
4391
4735
|
function claudeHistory(repoDir, home) {
|
|
4392
|
-
const root =
|
|
4736
|
+
const root = join23(home, ".claude", "projects");
|
|
4393
4737
|
const exact = claudeProjectDir(repoDir, home);
|
|
4394
4738
|
const prefix = exact + "-";
|
|
4395
|
-
const dirs = listDir(root).map((d) =>
|
|
4739
|
+
const dirs = listDir(root).map((d) => join23(root, d)).filter((d) => d === exact || d.startsWith(prefix));
|
|
4396
4740
|
const sessions = [];
|
|
4397
4741
|
let unattributed = 0;
|
|
4398
4742
|
for (const file of dirs.flatMap(jsonlFiles)) {
|
|
@@ -4412,12 +4756,12 @@ function claudeHistory(repoDir, home) {
|
|
|
4412
4756
|
return { supported: true, sessions, unattributed };
|
|
4413
4757
|
}
|
|
4414
4758
|
function codexHistory(repoDir, home) {
|
|
4415
|
-
const root =
|
|
4759
|
+
const root = join23(home, ".codex", "sessions");
|
|
4416
4760
|
if (!existsSync12(root)) return { supported: true, sessions: [] };
|
|
4417
4761
|
const files = [];
|
|
4418
4762
|
const walk = (dir) => {
|
|
4419
4763
|
for (const entry of readdirSync5(dir)) {
|
|
4420
|
-
const p =
|
|
4764
|
+
const p = join23(dir, entry);
|
|
4421
4765
|
if (statSync4(p).isDirectory()) walk(p);
|
|
4422
4766
|
else if (entry.endsWith(".jsonl")) files.push(p);
|
|
4423
4767
|
}
|
|
@@ -4447,13 +4791,13 @@ function dcodeTranscriptPath(root, threadId) {
|
|
|
4447
4791
|
const suffix = `--${digest}.jsonl`;
|
|
4448
4792
|
try {
|
|
4449
4793
|
const match = readdirSync5(root).find((entry) => entry.endsWith(suffix));
|
|
4450
|
-
return match ?
|
|
4794
|
+
return match ? join23(root, match) : void 0;
|
|
4451
4795
|
} catch {
|
|
4452
4796
|
return void 0;
|
|
4453
4797
|
}
|
|
4454
4798
|
}
|
|
4455
4799
|
function dcodeHistory(repoDir, home, runCli) {
|
|
4456
|
-
const root =
|
|
4800
|
+
const root = join23(process.env.DEEPAGENTS_HOME || join23(home, ".deepagents"), "transcripts");
|
|
4457
4801
|
if (!existsSync12(root)) return { supported: true, sessions: [] };
|
|
4458
4802
|
let listed;
|
|
4459
4803
|
try {
|
|
@@ -4494,7 +4838,7 @@ function dcodeHistory(repoDir, home, runCli) {
|
|
|
4494
4838
|
return { supported: true, sessions, ...unattributed ? { unattributed } : {} };
|
|
4495
4839
|
}
|
|
4496
4840
|
function dshHistory(repoDir, home) {
|
|
4497
|
-
const root = process.env.DSH_HOME ?
|
|
4841
|
+
const root = process.env.DSH_HOME ? join23(process.env.DSH_HOME, "sessions") : join23(home, ".dsh", "sessions");
|
|
4498
4842
|
if (!existsSync12(root)) return { supported: true, sessions: [] };
|
|
4499
4843
|
if (typeof zlib2.zstdDecompressSync !== "function") {
|
|
4500
4844
|
return {
|
|
@@ -4505,15 +4849,15 @@ function dshHistory(repoDir, home) {
|
|
|
4505
4849
|
}
|
|
4506
4850
|
const sessions = [];
|
|
4507
4851
|
let unattributed = 0;
|
|
4508
|
-
for (const dir of readdirSync5(root).map((project) =>
|
|
4852
|
+
for (const dir of readdirSync5(root).map((project) => join23(root, project))) {
|
|
4509
4853
|
let sessionDirs;
|
|
4510
4854
|
try {
|
|
4511
|
-
sessionDirs = readdirSync5(dir).map((id) =>
|
|
4855
|
+
sessionDirs = readdirSync5(dir).map((id) => join23(dir, id));
|
|
4512
4856
|
} catch {
|
|
4513
4857
|
continue;
|
|
4514
4858
|
}
|
|
4515
4859
|
for (const sessionDir of sessionDirs) {
|
|
4516
|
-
const file = ["session.jsonl.zstd", "session.jsonl"].map((name) =>
|
|
4860
|
+
const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join23(sessionDir, name)).find((candidate) => existsSync12(candidate));
|
|
4517
4861
|
if (!file) continue;
|
|
4518
4862
|
try {
|
|
4519
4863
|
const lines = readDshLog(file);
|
|
@@ -4539,7 +4883,7 @@ function dshHistory(repoDir, home) {
|
|
|
4539
4883
|
return { supported: true, sessions, unattributed };
|
|
4540
4884
|
}
|
|
4541
4885
|
function readDshLog(file) {
|
|
4542
|
-
const bytes =
|
|
4886
|
+
const bytes = readFileSync14(file);
|
|
4543
4887
|
const text = file.endsWith(".zstd") ? zstdDecompressFrames(bytes) : bytes.toString("utf8");
|
|
4544
4888
|
return text.split("\n").filter((line) => line.trim());
|
|
4545
4889
|
}
|
|
@@ -4565,18 +4909,18 @@ function piFamilySessions(files, repoDir) {
|
|
|
4565
4909
|
return { supported: true, sessions, unattributed };
|
|
4566
4910
|
}
|
|
4567
4911
|
function piHistory(repoDir, home) {
|
|
4568
|
-
const root =
|
|
4912
|
+
const root = join23(home, ".pi", "agent", "sessions");
|
|
4569
4913
|
if (!existsSync12(root)) return { supported: true, sessions: [] };
|
|
4570
4914
|
const exact = piSessionDir(repoDir);
|
|
4571
4915
|
const nested = `${exact.slice(0, -2)}-`;
|
|
4572
4916
|
const files = [];
|
|
4573
4917
|
for (const dir of listDir(root).filter((d) => d === exact || d.startsWith(nested))) {
|
|
4574
|
-
files.push(...jsonlFiles(
|
|
4918
|
+
files.push(...jsonlFiles(join23(root, dir)));
|
|
4575
4919
|
}
|
|
4576
4920
|
return piFamilySessions(files, repoDir);
|
|
4577
4921
|
}
|
|
4578
4922
|
function primeAgentHistory(repoDir, home) {
|
|
4579
|
-
const root =
|
|
4923
|
+
const root = join23(home, ".prime", "agent", "sessions");
|
|
4580
4924
|
if (!existsSync12(root)) return { supported: true, sessions: [] };
|
|
4581
4925
|
return piFamilySessions(jsonlFiles(root), repoDir);
|
|
4582
4926
|
}
|
|
@@ -4591,7 +4935,7 @@ function importLocalHistory(harness, repoDir, home = homedir12(), runDcodeCli) {
|
|
|
4591
4935
|
return dcodeHistory(
|
|
4592
4936
|
repoDir,
|
|
4593
4937
|
home,
|
|
4594
|
-
runDcodeCli ?? ((args) =>
|
|
4938
|
+
runDcodeCli ?? ((args) => execFileSync6("dcode", args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }))
|
|
4595
4939
|
);
|
|
4596
4940
|
case "dsh":
|
|
4597
4941
|
return dshHistory(repoDir, home);
|
|
@@ -4624,7 +4968,7 @@ function importLocalHistory(harness, repoDir, home = homedir12(), runDcodeCli) {
|
|
|
4624
4968
|
}
|
|
4625
4969
|
|
|
4626
4970
|
// src/install-ui.ts
|
|
4627
|
-
import { execFileSync as
|
|
4971
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
4628
4972
|
import { readSync as readSync3 } from "fs";
|
|
4629
4973
|
function fitSelectRow(label, hint, width) {
|
|
4630
4974
|
const room = Math.max(10, width - 6);
|
|
@@ -4719,7 +5063,7 @@ function createInstallerUi(o) {
|
|
|
4719
5063
|
return `${bar} ${question}`;
|
|
4720
5064
|
},
|
|
4721
5065
|
select(question, options, defaultIndex) {
|
|
4722
|
-
const stty = (args) =>
|
|
5066
|
+
const stty = (args) => execFileSync7("stty", args, { stdio: ["inherit", "pipe", "pipe"], encoding: "utf8" }).trim();
|
|
4723
5067
|
let savedTty;
|
|
4724
5068
|
try {
|
|
4725
5069
|
savedTty = stty(["-g"]);
|
|
@@ -4828,13 +5172,13 @@ function createInstallerUi(o) {
|
|
|
4828
5172
|
// src/installer.ts
|
|
4829
5173
|
var MARKER = "coding-agents";
|
|
4830
5174
|
var ZCODE_MAX_OUTPUT_BYTES = 32768;
|
|
4831
|
-
var zcodeConfigPath = (c) =>
|
|
5175
|
+
var zcodeConfigPath = (c) => join24(c.home, ".zcode", "cli", "config.json");
|
|
4832
5176
|
function isPlainObject(value) {
|
|
4833
5177
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
4834
5178
|
}
|
|
4835
|
-
function
|
|
5179
|
+
function readJson2(path) {
|
|
4836
5180
|
try {
|
|
4837
|
-
const parsed = JSON.parse(
|
|
5181
|
+
const parsed = JSON.parse(readFileSync15(path, "utf8"));
|
|
4838
5182
|
return isPlainObject(parsed) ? parsed : {};
|
|
4839
5183
|
} catch {
|
|
4840
5184
|
return {};
|
|
@@ -4850,7 +5194,7 @@ function parseJsonc(text) {
|
|
|
4850
5194
|
}
|
|
4851
5195
|
}
|
|
4852
5196
|
function writeJson(path, value) {
|
|
4853
|
-
mkdirSync7(
|
|
5197
|
+
mkdirSync7(dirname13(path), { recursive: true });
|
|
4854
5198
|
backupOnce(path);
|
|
4855
5199
|
writeFileSync5(path, JSON.stringify(value, null, 2) + "\n");
|
|
4856
5200
|
}
|
|
@@ -4860,7 +5204,7 @@ function backupOnce(path) {
|
|
|
4860
5204
|
}
|
|
4861
5205
|
}
|
|
4862
5206
|
function writeJsonc(path, key, value) {
|
|
4863
|
-
const text = existsSync13(path) ?
|
|
5207
|
+
const text = existsSync13(path) ? readFileSync15(path, "utf8") : "";
|
|
4864
5208
|
const edits = modify(text, [key], value, {
|
|
4865
5209
|
formattingOptions: {
|
|
4866
5210
|
tabSize: 2,
|
|
@@ -4871,7 +5215,7 @@ function writeJsonc(path, key, value) {
|
|
|
4871
5215
|
}
|
|
4872
5216
|
});
|
|
4873
5217
|
const next = applyEdits(text, edits);
|
|
4874
|
-
mkdirSync7(
|
|
5218
|
+
mkdirSync7(dirname13(path), { recursive: true });
|
|
4875
5219
|
backupOnce(path);
|
|
4876
5220
|
writeFileSync5(path, next.endsWith("\n") ? next : `${next}
|
|
4877
5221
|
`);
|
|
@@ -4888,14 +5232,14 @@ function setOrDelete(obj, key, arr) {
|
|
|
4888
5232
|
else delete obj[key];
|
|
4889
5233
|
}
|
|
4890
5234
|
var cmdHook = (dist, file, timeout) => ({
|
|
4891
|
-
hooks: [{ type: "command", command: `node "${
|
|
5235
|
+
hooks: [{ type: "command", command: `node "${join24(dist, file)}"`, timeout }]
|
|
4892
5236
|
});
|
|
4893
5237
|
var processHook = (dist, file, timeoutMs) => ({
|
|
4894
|
-
hooks: [{ type: "process", command: "node", args: [
|
|
5238
|
+
hooks: [{ type: "process", command: "node", args: [join24(dist, file)], timeoutMs }]
|
|
4895
5239
|
});
|
|
4896
5240
|
var mcpServerEntry = (dist, harness, extraArgs = []) => ({
|
|
4897
5241
|
command: "node",
|
|
4898
|
-
args: [
|
|
5242
|
+
args: [join24(dist, "mcp-server.js"), ...extraArgs],
|
|
4899
5243
|
env: { HINDSIGHT_MCP_HARNESS: harness }
|
|
4900
5244
|
});
|
|
4901
5245
|
function mergeHarnessHooks(hooks, harness, dist) {
|
|
@@ -4907,7 +5251,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
|
|
|
4907
5251
|
if (installedEvents.has(hook.event)) continue;
|
|
4908
5252
|
installedEvents.add(hook.event);
|
|
4909
5253
|
const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : spec.configStyle === "process" ? processHook(dist, hook.entry, hook.timeout) : {
|
|
4910
|
-
command: `node "${
|
|
5254
|
+
command: `node "${join24(dist, hook.entry)}"`,
|
|
4911
5255
|
...hook.timeout ? { timeout: hook.timeout } : {}
|
|
4912
5256
|
};
|
|
4913
5257
|
hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
|
|
@@ -4925,26 +5269,26 @@ function stripHarnessHooks(hooks, harness) {
|
|
|
4925
5269
|
function skillsBaseFor(c, harness) {
|
|
4926
5270
|
const parts = resolveSkillDirs(harness, c.home);
|
|
4927
5271
|
if (!parts) throw new Error(`${harness} installs a skill but names no directory in SKILL_DIRS`);
|
|
4928
|
-
return
|
|
5272
|
+
return join24(c.home, ...parts);
|
|
4929
5273
|
}
|
|
4930
5274
|
function installSkill(c, harness) {
|
|
4931
|
-
const src =
|
|
4932
|
-
if (!existsSync13(
|
|
5275
|
+
const src = join24(c.pkgRoot, "skill");
|
|
5276
|
+
if (!existsSync13(join24(src, "SKILL.md"))) return;
|
|
4933
5277
|
const skillsBase = skillsBaseFor(c, harness);
|
|
4934
|
-
const dst =
|
|
5278
|
+
const dst = join24(skillsBase, "hindsight-coding-agent");
|
|
4935
5279
|
mkdirSync7(skillsBase, { recursive: true });
|
|
4936
5280
|
cpSync2(src, dst, { recursive: true });
|
|
4937
5281
|
c.log?.(`${harness}: skill installed at ${dst}`);
|
|
4938
5282
|
}
|
|
4939
5283
|
function uninstallSkill(c, harness) {
|
|
4940
|
-
rmSync4(
|
|
5284
|
+
rmSync4(join24(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
|
|
4941
5285
|
recursive: true,
|
|
4942
5286
|
force: true
|
|
4943
5287
|
});
|
|
4944
5288
|
}
|
|
4945
5289
|
function onPath2(bin) {
|
|
4946
5290
|
try {
|
|
4947
|
-
|
|
5291
|
+
execFileSync8("which", [bin], { stdio: "pipe" });
|
|
4948
5292
|
return true;
|
|
4949
5293
|
} catch {
|
|
4950
5294
|
return false;
|
|
@@ -4952,7 +5296,7 @@ function onPath2(bin) {
|
|
|
4952
5296
|
}
|
|
4953
5297
|
function runClinePlugin(args) {
|
|
4954
5298
|
try {
|
|
4955
|
-
|
|
5299
|
+
execFileSync8("cline", args, { stdio: "pipe" });
|
|
4956
5300
|
return true;
|
|
4957
5301
|
} catch {
|
|
4958
5302
|
return false;
|
|
@@ -4960,13 +5304,13 @@ function runClinePlugin(args) {
|
|
|
4960
5304
|
}
|
|
4961
5305
|
var OPENCODE_CONFIG_CANDIDATES = ["opencode.jsonc", "opencode.json"];
|
|
4962
5306
|
function opencodeConfigPath(c) {
|
|
4963
|
-
const dir =
|
|
4964
|
-
const existing = OPENCODE_CONFIG_CANDIDATES.map((f) =>
|
|
4965
|
-
return existing ??
|
|
5307
|
+
const dir = join24(c.home, ".config", "opencode");
|
|
5308
|
+
const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join24(dir, f)).find((p) => existsSync13(p));
|
|
5309
|
+
return existing ?? join24(dir, "opencode.json");
|
|
4966
5310
|
}
|
|
4967
5311
|
function runDcodePlugin(args) {
|
|
4968
5312
|
try {
|
|
4969
|
-
|
|
5313
|
+
execFileSync8("dcode", args, { stdio: "pipe" });
|
|
4970
5314
|
return true;
|
|
4971
5315
|
} catch {
|
|
4972
5316
|
return false;
|
|
@@ -4976,7 +5320,7 @@ function registerOpencodePlugin(c, name) {
|
|
|
4976
5320
|
const path = opencodeConfigPath(c);
|
|
4977
5321
|
let cfg = {};
|
|
4978
5322
|
if (existsSync13(path)) {
|
|
4979
|
-
const parsed = parseJsonc(
|
|
5323
|
+
const parsed = parseJsonc(readFileSync15(path, "utf8"));
|
|
4980
5324
|
if (!parsed) {
|
|
4981
5325
|
c.log?.(`${name}: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
|
|
4982
5326
|
return;
|
|
@@ -4990,7 +5334,7 @@ function registerOpencodePlugin(c, name) {
|
|
|
4990
5334
|
function unregisterOpencodePlugin(c, name) {
|
|
4991
5335
|
const path = opencodeConfigPath(c);
|
|
4992
5336
|
if (!existsSync13(path)) return;
|
|
4993
|
-
const cfg = parseJsonc(
|
|
5337
|
+
const cfg = parseJsonc(readFileSync15(path, "utf8"));
|
|
4994
5338
|
if (!cfg || !Array.isArray(cfg.plugin)) return;
|
|
4995
5339
|
const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
|
|
4996
5340
|
writeJsonc(path, "plugin", kept.length ? kept : void 0);
|
|
@@ -4998,7 +5342,7 @@ function unregisterOpencodePlugin(c, name) {
|
|
|
4998
5342
|
}
|
|
4999
5343
|
var opencode = {
|
|
5000
5344
|
name: "opencode",
|
|
5001
|
-
detect: (c) => onPath2("opencode") || existsSync13(
|
|
5345
|
+
detect: (c) => onPath2("opencode") || existsSync13(join24(c.home, ".config", "opencode")),
|
|
5002
5346
|
install: (c) => registerOpencodePlugin(c, "opencode"),
|
|
5003
5347
|
uninstall: (c) => unregisterOpencodePlugin(c, "opencode")
|
|
5004
5348
|
};
|
|
@@ -5009,16 +5353,16 @@ var opencode2 = {
|
|
|
5009
5353
|
uninstall: (c) => unregisterOpencodePlugin(c, "opencode2")
|
|
5010
5354
|
};
|
|
5011
5355
|
function piFamilyInstaller(harness, configDir) {
|
|
5012
|
-
const settings = (c) =>
|
|
5356
|
+
const settings = (c) => join24(c.home, ...configDir, "settings.json");
|
|
5013
5357
|
return {
|
|
5014
5358
|
name: harness,
|
|
5015
5359
|
// Both hosts name their executable exactly as we name the harness, so the harness id doubles
|
|
5016
5360
|
// as the PATH probe here — unlike, say, antigravity-cli, whose binary is `agy`.
|
|
5017
|
-
detect: (c) => onPath2(harness) || existsSync13(
|
|
5361
|
+
detect: (c) => onPath2(harness) || existsSync13(join24(c.home, ...configDir)),
|
|
5018
5362
|
install(c) {
|
|
5019
5363
|
const path = settings(c);
|
|
5020
|
-
const cfg =
|
|
5021
|
-
const entry =
|
|
5364
|
+
const cfg = readJson2(path);
|
|
5365
|
+
const entry = join24(c.pkgRoot, "dist", `${harness}.js`);
|
|
5022
5366
|
const exts = Array.isArray(cfg.extensions) ? cfg.extensions : [];
|
|
5023
5367
|
cfg.extensions = [...exts.filter((p) => !String(p).includes(MARKER)), entry];
|
|
5024
5368
|
writeJson(path, cfg);
|
|
@@ -5029,7 +5373,7 @@ function piFamilyInstaller(harness, configDir) {
|
|
|
5029
5373
|
uninstallSkill(c, harness);
|
|
5030
5374
|
const path = settings(c);
|
|
5031
5375
|
if (!existsSync13(path)) return;
|
|
5032
|
-
const cfg =
|
|
5376
|
+
const cfg = readJson2(path);
|
|
5033
5377
|
if (Array.isArray(cfg.extensions)) {
|
|
5034
5378
|
cfg.extensions = cfg.extensions.filter((p) => !String(p).includes(MARKER));
|
|
5035
5379
|
if (!cfg.extensions.length) delete cfg.extensions;
|
|
@@ -5043,25 +5387,25 @@ var pi = piFamilyInstaller("pi", [".pi", "agent"]);
|
|
|
5043
5387
|
var primeAgent = piFamilyInstaller("prime-agent", [".prime", "agent"]);
|
|
5044
5388
|
var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
|
|
5045
5389
|
function kiloConfigPath(c) {
|
|
5046
|
-
const dir =
|
|
5047
|
-
const existing = KILO_CONFIG_CANDIDATES.map((f) =>
|
|
5048
|
-
return existing ??
|
|
5390
|
+
const dir = join24(c.home, ".config", "kilo");
|
|
5391
|
+
const existing = KILO_CONFIG_CANDIDATES.map((f) => join24(dir, f)).find((p) => existsSync13(p));
|
|
5392
|
+
return existing ?? join24(dir, "kilo.json");
|
|
5049
5393
|
}
|
|
5050
5394
|
var kilo = {
|
|
5051
5395
|
name: "kilo",
|
|
5052
|
-
detect: (c) => onPath2("kilo") || existsSync13(
|
|
5396
|
+
detect: (c) => onPath2("kilo") || existsSync13(join24(c.home, ".config", "kilo")),
|
|
5053
5397
|
install(c) {
|
|
5054
5398
|
const path = kiloConfigPath(c);
|
|
5055
5399
|
let cfg = {};
|
|
5056
5400
|
if (existsSync13(path)) {
|
|
5057
|
-
const parsed = parseJsonc(
|
|
5401
|
+
const parsed = parseJsonc(readFileSync15(path, "utf8"));
|
|
5058
5402
|
if (!parsed) {
|
|
5059
5403
|
c.log?.(`kilo: SKIPPED \u2014 could not parse ${path}; add the plugin entry manually`);
|
|
5060
5404
|
return;
|
|
5061
5405
|
}
|
|
5062
5406
|
cfg = parsed;
|
|
5063
5407
|
}
|
|
5064
|
-
const entry = pathToFileURL(
|
|
5408
|
+
const entry = pathToFileURL(join24(c.dist, "kilo.js")).href;
|
|
5065
5409
|
const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
|
|
5066
5410
|
writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), entry]);
|
|
5067
5411
|
c.log?.(`kilo: plugin registered in ${path}`);
|
|
@@ -5069,7 +5413,7 @@ var kilo = {
|
|
|
5069
5413
|
uninstall(c) {
|
|
5070
5414
|
const path = kiloConfigPath(c);
|
|
5071
5415
|
if (!existsSync13(path)) return;
|
|
5072
|
-
const cfg = parseJsonc(
|
|
5416
|
+
const cfg = parseJsonc(readFileSync15(path, "utf8"));
|
|
5073
5417
|
if (!cfg || !Array.isArray(cfg.plugin)) return;
|
|
5074
5418
|
const kept = cfg.plugin.filter((p) => !String(p).includes(MARKER));
|
|
5075
5419
|
writeJsonc(path, "plugin", kept.length ? kept : void 0);
|
|
@@ -5078,10 +5422,10 @@ var kilo = {
|
|
|
5078
5422
|
};
|
|
5079
5423
|
var claudeCode = {
|
|
5080
5424
|
name: "claude-code",
|
|
5081
|
-
detect: (c) => onPath2("claude") || existsSync13(
|
|
5425
|
+
detect: (c) => onPath2("claude") || existsSync13(join24(c.home, ".claude")),
|
|
5082
5426
|
install(c) {
|
|
5083
|
-
const path =
|
|
5084
|
-
const settings =
|
|
5427
|
+
const path = join24(c.home, ".claude", "settings.json");
|
|
5428
|
+
const settings = readJson2(path);
|
|
5085
5429
|
settings.hooks = settings.hooks ?? {};
|
|
5086
5430
|
mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
|
|
5087
5431
|
writeJson(path, settings);
|
|
@@ -5099,20 +5443,20 @@ var claudeCode = {
|
|
|
5099
5443
|
"HINDSIGHT_MCP_HARNESS=claude-code",
|
|
5100
5444
|
"--",
|
|
5101
5445
|
"node",
|
|
5102
|
-
|
|
5446
|
+
join24(c.dist, "mcp-server.js")
|
|
5103
5447
|
])) {
|
|
5104
5448
|
c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
|
|
5105
5449
|
} else {
|
|
5106
5450
|
c.log?.(
|
|
5107
5451
|
`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 "${
|
|
5452
|
+
claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join24(c.dist, "mcp-server.js")}"`
|
|
5109
5453
|
);
|
|
5110
5454
|
}
|
|
5111
5455
|
},
|
|
5112
5456
|
uninstall(c) {
|
|
5113
|
-
const path =
|
|
5457
|
+
const path = join24(c.home, ".claude", "settings.json");
|
|
5114
5458
|
if (existsSync13(path)) {
|
|
5115
|
-
const settings =
|
|
5459
|
+
const settings = readJson2(path);
|
|
5116
5460
|
if (settings.hooks) {
|
|
5117
5461
|
stripHarnessHooks(settings.hooks, "claude-code");
|
|
5118
5462
|
if (!Object.keys(settings.hooks).length) delete settings.hooks;
|
|
@@ -5127,7 +5471,7 @@ var claudeCode = {
|
|
|
5127
5471
|
};
|
|
5128
5472
|
function defaultClaudeMcp(args) {
|
|
5129
5473
|
try {
|
|
5130
|
-
|
|
5474
|
+
execFileSync8("claude", args, { stdio: "pipe" });
|
|
5131
5475
|
return true;
|
|
5132
5476
|
} catch {
|
|
5133
5477
|
return false;
|
|
@@ -5136,20 +5480,20 @@ function defaultClaudeMcp(args) {
|
|
|
5136
5480
|
var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
|
|
5137
5481
|
var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
|
|
5138
5482
|
command = "node"
|
|
5139
|
-
args = [${JSON.stringify(
|
|
5483
|
+
args = [${JSON.stringify(join24(dist, "mcp-server.js"))}]
|
|
5140
5484
|
env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
|
|
5141
5485
|
var codex = {
|
|
5142
5486
|
name: "codex",
|
|
5143
|
-
detect: (c) => onPath2("codex") || existsSync13(
|
|
5487
|
+
detect: (c) => onPath2("codex") || existsSync13(join24(c.home, ".codex")),
|
|
5144
5488
|
install(c) {
|
|
5145
|
-
const hooksPath =
|
|
5146
|
-
const cfg =
|
|
5489
|
+
const hooksPath = join24(c.home, ".codex", "hooks.json");
|
|
5490
|
+
const cfg = readJson2(hooksPath);
|
|
5147
5491
|
cfg.hooks = cfg.hooks ?? {};
|
|
5148
5492
|
mergeHarnessHooks(cfg.hooks, "codex", c.dist);
|
|
5149
5493
|
writeJson(hooksPath, cfg);
|
|
5150
5494
|
c.log?.(`codex: hooks merged into ${hooksPath}`);
|
|
5151
|
-
const tomlPath =
|
|
5152
|
-
const existing = existsSync13(tomlPath) ?
|
|
5495
|
+
const tomlPath = join24(c.home, ".codex", "config.toml");
|
|
5496
|
+
const existing = existsSync13(tomlPath) ? readFileSync15(tomlPath, "utf8") : "";
|
|
5153
5497
|
const toml = existing.replace(CODEX_MCP_BLOCK_RE, "");
|
|
5154
5498
|
const additions = [];
|
|
5155
5499
|
if (!/^\s*(codex_hooks|hooks)\s*=/m.test(toml)) {
|
|
@@ -5168,25 +5512,25 @@ var codex = {
|
|
|
5168
5512
|
if (existsSync13(tomlPath) && !existsSync13(`${tomlPath}.hindsight-backup`)) {
|
|
5169
5513
|
copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
|
|
5170
5514
|
}
|
|
5171
|
-
mkdirSync7(
|
|
5515
|
+
mkdirSync7(dirname13(tomlPath), { recursive: true });
|
|
5172
5516
|
writeFileSync5(tomlPath, next);
|
|
5173
5517
|
c.log?.(`codex: wrote ${additions.length} section(s) to ${tomlPath}`);
|
|
5174
5518
|
}
|
|
5175
5519
|
installSkill(c, "codex");
|
|
5176
5520
|
},
|
|
5177
5521
|
uninstall(c) {
|
|
5178
|
-
const hooksPath =
|
|
5522
|
+
const hooksPath = join24(c.home, ".codex", "hooks.json");
|
|
5179
5523
|
if (existsSync13(hooksPath)) {
|
|
5180
|
-
const cfg =
|
|
5524
|
+
const cfg = readJson2(hooksPath);
|
|
5181
5525
|
if (cfg.hooks) {
|
|
5182
5526
|
stripHarnessHooks(cfg.hooks, "codex");
|
|
5183
5527
|
writeJson(hooksPath, cfg);
|
|
5184
5528
|
}
|
|
5185
5529
|
}
|
|
5186
5530
|
uninstallSkill(c, "codex");
|
|
5187
|
-
const tomlPath =
|
|
5531
|
+
const tomlPath = join24(c.home, ".codex", "config.toml");
|
|
5188
5532
|
if (existsSync13(tomlPath)) {
|
|
5189
|
-
const toml =
|
|
5533
|
+
const toml = readFileSync15(tomlPath, "utf8");
|
|
5190
5534
|
const cleaned = toml.replace(CODEX_MCP_BLOCK_RE, "");
|
|
5191
5535
|
if (cleaned !== toml) writeFileSync5(tomlPath, cleaned);
|
|
5192
5536
|
}
|
|
@@ -5202,8 +5546,8 @@ var antigravity = {
|
|
|
5202
5546
|
// can consume this integration.
|
|
5203
5547
|
detect: (c) => onPath2("agy"),
|
|
5204
5548
|
install(c) {
|
|
5205
|
-
const hooksPath =
|
|
5206
|
-
const hooks =
|
|
5549
|
+
const hooksPath = join24(c.home, ".gemini", "config", "hooks.json");
|
|
5550
|
+
const hooks = readJson2(hooksPath);
|
|
5207
5551
|
for (const key of Object.keys(hooks)) {
|
|
5208
5552
|
if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
|
|
5209
5553
|
}
|
|
@@ -5213,26 +5557,26 @@ var antigravity = {
|
|
|
5213
5557
|
setOrDelete(hooks, event, stripOurs(hooks[event]));
|
|
5214
5558
|
}
|
|
5215
5559
|
writeJson(hooksPath, hooks);
|
|
5216
|
-
const mcpPath =
|
|
5217
|
-
const mcp =
|
|
5560
|
+
const mcpPath = join24(c.home, ".gemini", "config", "mcp_config.json");
|
|
5561
|
+
const mcp = readJson2(mcpPath);
|
|
5218
5562
|
mcp.mcpServers = {
|
|
5219
5563
|
...mcp.mcpServers ?? {},
|
|
5220
5564
|
hindsight: mcpServerEntry(c.dist, "antigravity-cli")
|
|
5221
5565
|
};
|
|
5222
5566
|
writeJson(mcpPath, mcp);
|
|
5223
|
-
const settingsPath =
|
|
5224
|
-
const settings =
|
|
5567
|
+
const settingsPath = join24(c.home, ".gemini", "antigravity-cli", "settings.json");
|
|
5568
|
+
const settings = readJson2(settingsPath);
|
|
5225
5569
|
if (!settings.statusLine) {
|
|
5226
5570
|
settings.statusLine = {
|
|
5227
5571
|
type: "command",
|
|
5228
|
-
command: `node "${
|
|
5572
|
+
command: `node "${join24(c.dist, "antigravity-statusline.js")}"`
|
|
5229
5573
|
};
|
|
5230
5574
|
writeJson(settingsPath, settings);
|
|
5231
5575
|
c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
|
|
5232
5576
|
} else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
|
|
5233
5577
|
settings.statusLine = {
|
|
5234
5578
|
type: "command",
|
|
5235
|
-
command: `node "${
|
|
5579
|
+
command: `node "${join24(c.dist, "antigravity-statusline.js")}"`
|
|
5236
5580
|
};
|
|
5237
5581
|
writeJson(settingsPath, settings);
|
|
5238
5582
|
} else {
|
|
@@ -5244,9 +5588,9 @@ var antigravity = {
|
|
|
5244
5588
|
installSkill(c, "antigravity-cli");
|
|
5245
5589
|
},
|
|
5246
5590
|
uninstall(c) {
|
|
5247
|
-
const hooksPath =
|
|
5591
|
+
const hooksPath = join24(c.home, ".gemini", "config", "hooks.json");
|
|
5248
5592
|
if (existsSync13(hooksPath)) {
|
|
5249
|
-
const hooks =
|
|
5593
|
+
const hooks = readJson2(hooksPath);
|
|
5250
5594
|
if (hooks[MARKER]) {
|
|
5251
5595
|
stripHarnessHooks(hooks[MARKER], "antigravity-cli");
|
|
5252
5596
|
if (!Object.keys(hooks[MARKER]).length) delete hooks[MARKER];
|
|
@@ -5256,17 +5600,17 @@ var antigravity = {
|
|
|
5256
5600
|
}
|
|
5257
5601
|
writeJson(hooksPath, hooks);
|
|
5258
5602
|
}
|
|
5259
|
-
const mcpPath =
|
|
5603
|
+
const mcpPath = join24(c.home, ".gemini", "config", "mcp_config.json");
|
|
5260
5604
|
if (existsSync13(mcpPath)) {
|
|
5261
|
-
const mcp =
|
|
5605
|
+
const mcp = readJson2(mcpPath);
|
|
5262
5606
|
if (mcp.mcpServers?.hindsight) {
|
|
5263
5607
|
delete mcp.mcpServers.hindsight;
|
|
5264
5608
|
writeJson(mcpPath, mcp);
|
|
5265
5609
|
}
|
|
5266
5610
|
}
|
|
5267
|
-
const settingsPath =
|
|
5611
|
+
const settingsPath = join24(c.home, ".gemini", "antigravity-cli", "settings.json");
|
|
5268
5612
|
if (existsSync13(settingsPath)) {
|
|
5269
|
-
const settings =
|
|
5613
|
+
const settings = readJson2(settingsPath);
|
|
5270
5614
|
if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
|
|
5271
5615
|
delete settings.statusLine;
|
|
5272
5616
|
writeJson(settingsPath, settings);
|
|
@@ -5278,7 +5622,7 @@ var antigravity = {
|
|
|
5278
5622
|
};
|
|
5279
5623
|
function pathNodeHasSqlite() {
|
|
5280
5624
|
try {
|
|
5281
|
-
|
|
5625
|
+
execFileSync8("node", ["-e", "require('node:sqlite')"], { stdio: "pipe", timeout: 1e4 });
|
|
5282
5626
|
return true;
|
|
5283
5627
|
} catch {
|
|
5284
5628
|
return false;
|
|
@@ -5286,13 +5630,13 @@ function pathNodeHasSqlite() {
|
|
|
5286
5630
|
}
|
|
5287
5631
|
function pathNodeVersion() {
|
|
5288
5632
|
try {
|
|
5289
|
-
return
|
|
5633
|
+
return execFileSync8("node", ["-v"], { encoding: "utf8", stdio: "pipe" }).trim();
|
|
5290
5634
|
} catch {
|
|
5291
5635
|
return "not found";
|
|
5292
5636
|
}
|
|
5293
5637
|
}
|
|
5294
5638
|
function runtimeDir(home) {
|
|
5295
|
-
return
|
|
5639
|
+
return join24(home, ".hindsight", "coding-agents");
|
|
5296
5640
|
}
|
|
5297
5641
|
var ORIGIN_FILE = ".install-origin.json";
|
|
5298
5642
|
function stageRuntime(c) {
|
|
@@ -5305,25 +5649,25 @@ function stageRuntime(c) {
|
|
|
5305
5649
|
}
|
|
5306
5650
|
};
|
|
5307
5651
|
if (same(c.pkgRoot, target)) return c;
|
|
5308
|
-
if (!existsSync13(
|
|
5652
|
+
if (!existsSync13(join24(c.dist, "installer.js"))) return c;
|
|
5309
5653
|
try {
|
|
5310
|
-
rmSync4(
|
|
5654
|
+
rmSync4(join24(target, "dist"), { recursive: true, force: true });
|
|
5311
5655
|
mkdirSync7(target, { recursive: true });
|
|
5312
|
-
cpSync2(c.dist,
|
|
5313
|
-
const skill =
|
|
5314
|
-
if (existsSync13(skill)) cpSync2(skill,
|
|
5315
|
-
const pkgJson =
|
|
5316
|
-
if (existsSync13(pkgJson)) copyFileSync(pkgJson,
|
|
5656
|
+
cpSync2(c.dist, join24(target, "dist"), { recursive: true });
|
|
5657
|
+
const skill = join24(c.pkgRoot, "skill");
|
|
5658
|
+
if (existsSync13(skill)) cpSync2(skill, join24(target, "skill"), { recursive: true });
|
|
5659
|
+
const pkgJson = join24(c.pkgRoot, "package.json");
|
|
5660
|
+
if (existsSync13(pkgJson)) copyFileSync(pkgJson, join24(target, "package.json"));
|
|
5317
5661
|
for (const resource of ["plugin.json", "hooks", "index.js"]) {
|
|
5318
|
-
const source =
|
|
5319
|
-
if (existsSync13(source)) cpSync2(source,
|
|
5662
|
+
const source = join24(c.pkgRoot, resource);
|
|
5663
|
+
if (existsSync13(source)) cpSync2(source, join24(target, resource), { recursive: true });
|
|
5320
5664
|
}
|
|
5321
5665
|
writeFileSync5(
|
|
5322
|
-
|
|
5666
|
+
join24(target, ORIGIN_FILE),
|
|
5323
5667
|
JSON.stringify({ source: c.pkgRoot, stagedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
5324
5668
|
);
|
|
5325
5669
|
c.log?.(`runtime staged at ${target}`);
|
|
5326
|
-
return { ...c, pkgRoot: target, dist:
|
|
5670
|
+
return { ...c, pkgRoot: target, dist: join24(target, "dist") };
|
|
5327
5671
|
} catch (error) {
|
|
5328
5672
|
c.log?.(`could not stage the runtime at ${target}: ${String(error)}`);
|
|
5329
5673
|
return c;
|
|
@@ -5345,7 +5689,7 @@ function flagValueArgs(args, names) {
|
|
|
5345
5689
|
return taken;
|
|
5346
5690
|
}
|
|
5347
5691
|
var CONFIG_RELATIVE = [".hindsight", "coding-agent.json"];
|
|
5348
|
-
var hindsightConfigPath = (c) => process.env.HINDSIGHT_CONFIG ||
|
|
5692
|
+
var hindsightConfigPath = (c) => process.env.HINDSIGHT_CONFIG || join24(c.home, ...CONFIG_RELATIVE);
|
|
5349
5693
|
var SERVER_CHOICES = [
|
|
5350
5694
|
{ mode: "cloud", label: "Hindsight Cloud", hint: "hosted, needs an API token" },
|
|
5351
5695
|
{ mode: "self-hosted", label: "Self-hosted server", hint: "a Hindsight server you already run" },
|
|
@@ -5403,7 +5747,7 @@ function configureServer(c, args, installing) {
|
|
|
5403
5747
|
return false;
|
|
5404
5748
|
}
|
|
5405
5749
|
const configPath = hindsightConfigPath(c);
|
|
5406
|
-
const existing =
|
|
5750
|
+
const existing = readJson2(configPath);
|
|
5407
5751
|
const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
|
|
5408
5752
|
let mode = explicit;
|
|
5409
5753
|
if (!mode) {
|
|
@@ -5498,7 +5842,7 @@ function reportDaemonPrereqs(c) {
|
|
|
5498
5842
|
}
|
|
5499
5843
|
var devin = {
|
|
5500
5844
|
name: "devin-cli",
|
|
5501
|
-
detect: (c) => onPath2("devin") || existsSync13(
|
|
5845
|
+
detect: (c) => onPath2("devin") || existsSync13(join24(c.home, ".config", "devin")),
|
|
5502
5846
|
// Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
|
|
5503
5847
|
// nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
|
|
5504
5848
|
// support a hard prerequisite here — and one worth checking now, because the alternative is an
|
|
@@ -5511,13 +5855,13 @@ var devin = {
|
|
|
5511
5855
|
Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
|
|
5512
5856
|
},
|
|
5513
5857
|
install(c) {
|
|
5514
|
-
const configPath =
|
|
5515
|
-
const config =
|
|
5858
|
+
const configPath = join24(c.home, ".config", "devin", "config.json");
|
|
5859
|
+
const config = readJson2(configPath);
|
|
5516
5860
|
config.hooks = config.hooks ?? {};
|
|
5517
5861
|
mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
|
|
5518
5862
|
writeJson(configPath, config);
|
|
5519
|
-
const mcpPath =
|
|
5520
|
-
const mcp =
|
|
5863
|
+
const mcpPath = join24(c.home, ".config", "devin", "mcp_config.json");
|
|
5864
|
+
const mcp = readJson2(mcpPath);
|
|
5521
5865
|
mcp.mcpServers = {
|
|
5522
5866
|
...mcp.mcpServers ?? {},
|
|
5523
5867
|
hindsight: mcpServerEntry(c.dist, "devin-cli")
|
|
@@ -5526,18 +5870,18 @@ var devin = {
|
|
|
5526
5870
|
c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
|
|
5527
5871
|
},
|
|
5528
5872
|
uninstall(c) {
|
|
5529
|
-
const configPath =
|
|
5873
|
+
const configPath = join24(c.home, ".config", "devin", "config.json");
|
|
5530
5874
|
if (existsSync13(configPath)) {
|
|
5531
|
-
const config =
|
|
5875
|
+
const config = readJson2(configPath);
|
|
5532
5876
|
if (config.hooks) {
|
|
5533
5877
|
stripHarnessHooks(config.hooks, "devin-cli");
|
|
5534
5878
|
if (!Object.keys(config.hooks).length) delete config.hooks;
|
|
5535
5879
|
writeJson(configPath, config);
|
|
5536
5880
|
}
|
|
5537
5881
|
}
|
|
5538
|
-
const mcpPath =
|
|
5882
|
+
const mcpPath = join24(c.home, ".config", "devin", "mcp_config.json");
|
|
5539
5883
|
if (existsSync13(mcpPath)) {
|
|
5540
|
-
const mcp =
|
|
5884
|
+
const mcp = readJson2(mcpPath);
|
|
5541
5885
|
if (mcp.mcpServers?.hindsight) {
|
|
5542
5886
|
delete mcp.mcpServers.hindsight;
|
|
5543
5887
|
writeJson(mcpPath, mcp);
|
|
@@ -5548,16 +5892,16 @@ var devin = {
|
|
|
5548
5892
|
};
|
|
5549
5893
|
var cursor = {
|
|
5550
5894
|
name: "cursor-cli",
|
|
5551
|
-
detect: (c) => onPath2("cursor-agent") || existsSync13(
|
|
5895
|
+
detect: (c) => onPath2("cursor-agent") || existsSync13(join24(c.home, ".cursor")),
|
|
5552
5896
|
install(c) {
|
|
5553
|
-
const hooksPath =
|
|
5554
|
-
const cfg =
|
|
5897
|
+
const hooksPath = join24(c.home, ".cursor", "hooks.json");
|
|
5898
|
+
const cfg = readJson2(hooksPath);
|
|
5555
5899
|
cfg.version ??= 1;
|
|
5556
5900
|
cfg.hooks = cfg.hooks ?? {};
|
|
5557
5901
|
mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
|
|
5558
5902
|
writeJson(hooksPath, cfg);
|
|
5559
|
-
const mcpPath =
|
|
5560
|
-
const mcp =
|
|
5903
|
+
const mcpPath = join24(c.home, ".cursor", "mcp.json");
|
|
5904
|
+
const mcp = readJson2(mcpPath);
|
|
5561
5905
|
mcp.mcpServers = {
|
|
5562
5906
|
...mcp.mcpServers ?? {},
|
|
5563
5907
|
hindsight: mcpServerEntry(c.dist, "cursor-cli", ["${workspaceFolder}"])
|
|
@@ -5567,18 +5911,18 @@ var cursor = {
|
|
|
5567
5911
|
installSkill(c, "cursor-cli");
|
|
5568
5912
|
},
|
|
5569
5913
|
uninstall(c) {
|
|
5570
|
-
const hooksPath =
|
|
5914
|
+
const hooksPath = join24(c.home, ".cursor", "hooks.json");
|
|
5571
5915
|
if (existsSync13(hooksPath)) {
|
|
5572
|
-
const cfg =
|
|
5916
|
+
const cfg = readJson2(hooksPath);
|
|
5573
5917
|
if (cfg.hooks) {
|
|
5574
5918
|
stripHarnessHooks(cfg.hooks, "cursor-cli");
|
|
5575
5919
|
if (!Object.keys(cfg.hooks).length) delete cfg.hooks;
|
|
5576
5920
|
writeJson(hooksPath, cfg);
|
|
5577
5921
|
}
|
|
5578
5922
|
}
|
|
5579
|
-
const mcpPath =
|
|
5923
|
+
const mcpPath = join24(c.home, ".cursor", "mcp.json");
|
|
5580
5924
|
if (existsSync13(mcpPath)) {
|
|
5581
|
-
const mcp =
|
|
5925
|
+
const mcp = readJson2(mcpPath);
|
|
5582
5926
|
if (mcp.mcpServers?.hindsight) {
|
|
5583
5927
|
delete mcp.mcpServers.hindsight;
|
|
5584
5928
|
writeJson(mcpPath, mcp);
|
|
@@ -5590,14 +5934,14 @@ var cursor = {
|
|
|
5590
5934
|
};
|
|
5591
5935
|
var copilot = {
|
|
5592
5936
|
name: "copilot-cli",
|
|
5593
|
-
detect: (c) => onPath2("copilot") || existsSync13(
|
|
5937
|
+
detect: (c) => onPath2("copilot") || existsSync13(join24(c.home, ".copilot")),
|
|
5594
5938
|
install(c) {
|
|
5595
|
-
const hooksPath =
|
|
5939
|
+
const hooksPath = join24(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
|
|
5596
5940
|
const hooks = {};
|
|
5597
5941
|
mergeHarnessHooks(hooks, "copilot-cli", c.dist);
|
|
5598
5942
|
writeJson(hooksPath, { version: 1, hooks });
|
|
5599
|
-
const mcpPath =
|
|
5600
|
-
const mcp =
|
|
5943
|
+
const mcpPath = join24(c.home, ".copilot", "mcp-config.json");
|
|
5944
|
+
const mcp = readJson2(mcpPath);
|
|
5601
5945
|
mcp.mcpServers = {
|
|
5602
5946
|
...mcp.mcpServers ?? {},
|
|
5603
5947
|
hindsight: mcpServerEntry(c.dist, "copilot-cli")
|
|
@@ -5607,12 +5951,12 @@ var copilot = {
|
|
|
5607
5951
|
c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
|
|
5608
5952
|
},
|
|
5609
5953
|
uninstall(c) {
|
|
5610
|
-
rmSync4(
|
|
5954
|
+
rmSync4(join24(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
|
|
5611
5955
|
force: true
|
|
5612
5956
|
});
|
|
5613
|
-
const mcpPath =
|
|
5957
|
+
const mcpPath = join24(c.home, ".copilot", "mcp-config.json");
|
|
5614
5958
|
if (existsSync13(mcpPath)) {
|
|
5615
|
-
const mcp =
|
|
5959
|
+
const mcp = readJson2(mcpPath);
|
|
5616
5960
|
if (mcp.mcpServers?.hindsight) {
|
|
5617
5961
|
delete mcp.mcpServers.hindsight;
|
|
5618
5962
|
writeJson(mcpPath, mcp);
|
|
@@ -5675,13 +6019,13 @@ function stripUnmarkedGrokEntries(toml) {
|
|
|
5675
6019
|
if (!drop.some(Boolean)) return toml;
|
|
5676
6020
|
return sections.filter((_, i) => !drop[i]).map((s) => s.lines.join("\n")).join("\n").replace(/\n{3,}/g, "\n\n");
|
|
5677
6021
|
}
|
|
5678
|
-
var grokHooksPath = (c) =>
|
|
6022
|
+
var grokHooksPath = (c) => join24(c.home, ".grok", "hooks", "hindsight.json");
|
|
5679
6023
|
var grok = {
|
|
5680
6024
|
name: "grok-build",
|
|
5681
|
-
detect: (c) => onPath2("grok") || existsSync13(
|
|
6025
|
+
detect: (c) => onPath2("grok") || existsSync13(join24(c.home, ".grok")),
|
|
5682
6026
|
install(c) {
|
|
5683
|
-
const path =
|
|
5684
|
-
const existing = existsSync13(path) ?
|
|
6027
|
+
const path = join24(c.home, ".grok", "config.toml");
|
|
6028
|
+
const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
|
|
5685
6029
|
const stripped = existing.replace(GROK_BLOCK_RE, "\n");
|
|
5686
6030
|
const withoutOurs = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
|
|
5687
6031
|
const tomlString = (value) => JSON.stringify(value);
|
|
@@ -5689,7 +6033,7 @@ var grok = {
|
|
|
5689
6033
|
${GROK_MARKER_START}
|
|
5690
6034
|
[mcp_servers.hindsight]
|
|
5691
6035
|
command = "node"
|
|
5692
|
-
args = [${tomlString(
|
|
6036
|
+
args = [${tomlString(join24(c.dist, "mcp-server.js"))}]
|
|
5693
6037
|
env = { HINDSIGHT_MCP_HARNESS = "grok-build" }
|
|
5694
6038
|
${GROK_MARKER_END}
|
|
5695
6039
|
`;
|
|
@@ -5702,10 +6046,10 @@ ${GROK_MARKER_END}
|
|
|
5702
6046
|
}
|
|
5703
6047
|
if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
|
|
5704
6048
|
copyFileSync(path, `${path}.hindsight-backup`);
|
|
5705
|
-
mkdirSync7(
|
|
6049
|
+
mkdirSync7(dirname13(path), { recursive: true });
|
|
5706
6050
|
writeFileSync5(path, next);
|
|
5707
6051
|
const hooksPath = grokHooksPath(c);
|
|
5708
|
-
const file =
|
|
6052
|
+
const file = readJson2(hooksPath);
|
|
5709
6053
|
const hooks = isPlainObject(file.hooks) ? file.hooks : {};
|
|
5710
6054
|
mergeHarnessHooks(hooks, "grok-build", c.dist);
|
|
5711
6055
|
writeJson(hooksPath, { ...file, hooks });
|
|
@@ -5713,9 +6057,9 @@ ${GROK_MARKER_END}
|
|
|
5713
6057
|
c.log?.(`grok-build: hooks installed in ${hooksPath}, MCP in ${path}`);
|
|
5714
6058
|
},
|
|
5715
6059
|
uninstall(c) {
|
|
5716
|
-
const path =
|
|
6060
|
+
const path = join24(c.home, ".grok", "config.toml");
|
|
5717
6061
|
if (existsSync13(path)) {
|
|
5718
|
-
const existing =
|
|
6062
|
+
const existing = readFileSync15(path, "utf8");
|
|
5719
6063
|
const stripped = existing.replace(GROK_BLOCK_RE, "\n");
|
|
5720
6064
|
const cleaned = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
|
|
5721
6065
|
const safe = parseGrokToml(cleaned) !== null || parseGrokToml(existing) === null;
|
|
@@ -5723,7 +6067,7 @@ ${GROK_MARKER_END}
|
|
|
5723
6067
|
}
|
|
5724
6068
|
const hooksPath = grokHooksPath(c);
|
|
5725
6069
|
if (existsSync13(hooksPath)) {
|
|
5726
|
-
const file =
|
|
6070
|
+
const file = readJson2(hooksPath);
|
|
5727
6071
|
if (isPlainObject(file.hooks)) {
|
|
5728
6072
|
stripHarnessHooks(file.hooks, "grok-build");
|
|
5729
6073
|
if (!Object.keys(file.hooks).length) delete file.hooks;
|
|
@@ -5739,20 +6083,20 @@ var KIMI_MARKER_START = "# HINDSIGHT_CODING_AGENTS_KIMI_START";
|
|
|
5739
6083
|
var KIMI_MARKER_END = "# HINDSIGHT_CODING_AGENTS_KIMI_END";
|
|
5740
6084
|
var KIMI_BLOCK_RE = new RegExp(`\\n?${KIMI_MARKER_START}[\\s\\S]*?${KIMI_MARKER_END}\\n?`);
|
|
5741
6085
|
function kimiHome(c) {
|
|
5742
|
-
return process.env.KIMI_CODE_HOME ||
|
|
6086
|
+
return process.env.KIMI_CODE_HOME || join24(c.home, ".kimi-code");
|
|
5743
6087
|
}
|
|
5744
6088
|
var kimi = {
|
|
5745
6089
|
name: "kimi-code",
|
|
5746
6090
|
detect: (c) => onPath2("kimi") || existsSync13(kimiHome(c)),
|
|
5747
6091
|
install(c) {
|
|
5748
|
-
const path =
|
|
5749
|
-
const existing = existsSync13(path) ?
|
|
6092
|
+
const path = join24(kimiHome(c), "config.toml");
|
|
6093
|
+
const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
|
|
5750
6094
|
const withoutOurs = existing.replace(KIMI_BLOCK_RE, "\n");
|
|
5751
6095
|
const spec = HOOK_HARNESSES["kimi-code"];
|
|
5752
6096
|
const entries = Object.values(spec.install).map(
|
|
5753
6097
|
(h) => `[[hooks]]
|
|
5754
6098
|
event = ${JSON.stringify(h.event)}
|
|
5755
|
-
command = ${JSON.stringify(`node "${
|
|
6099
|
+
command = ${JSON.stringify(`node "${join24(c.dist, h.entry)}"`)}
|
|
5756
6100
|
timeout = ${h.timeout}
|
|
5757
6101
|
`
|
|
5758
6102
|
).join("\n");
|
|
@@ -5762,25 +6106,25 @@ ${entries}${KIMI_MARKER_END}
|
|
|
5762
6106
|
`;
|
|
5763
6107
|
if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
|
|
5764
6108
|
copyFileSync(path, `${path}.hindsight-backup`);
|
|
5765
|
-
mkdirSync7(
|
|
6109
|
+
mkdirSync7(dirname13(path), { recursive: true });
|
|
5766
6110
|
writeFileSync5(path, `${withoutOurs.replace(/\n*$/, "\n")}${block}`);
|
|
5767
|
-
const mcpPath =
|
|
5768
|
-
const mcp =
|
|
6111
|
+
const mcpPath = join24(kimiHome(c), "mcp.json");
|
|
6112
|
+
const mcp = readJson2(mcpPath);
|
|
5769
6113
|
mcp.mcpServers = { ...mcp.mcpServers ?? {}, hindsight: mcpServerEntry(c.dist, "kimi-code") };
|
|
5770
6114
|
writeJson(mcpPath, mcp);
|
|
5771
6115
|
installSkill(c, "kimi-code");
|
|
5772
6116
|
c.log?.(`kimi-code: native hooks installed in ${path}, MCP in ${mcpPath}`);
|
|
5773
6117
|
},
|
|
5774
6118
|
uninstall(c) {
|
|
5775
|
-
const path =
|
|
6119
|
+
const path = join24(kimiHome(c), "config.toml");
|
|
5776
6120
|
if (existsSync13(path)) {
|
|
5777
|
-
const existing =
|
|
6121
|
+
const existing = readFileSync15(path, "utf8");
|
|
5778
6122
|
const cleaned = existing.replace(KIMI_BLOCK_RE, "\n");
|
|
5779
6123
|
if (cleaned !== existing) writeFileSync5(path, cleaned);
|
|
5780
6124
|
}
|
|
5781
|
-
const mcpPath =
|
|
6125
|
+
const mcpPath = join24(kimiHome(c), "mcp.json");
|
|
5782
6126
|
if (existsSync13(mcpPath)) {
|
|
5783
|
-
const mcp =
|
|
6127
|
+
const mcp = readJson2(mcpPath);
|
|
5784
6128
|
if (mcp.mcpServers?.hindsight) {
|
|
5785
6129
|
delete mcp.mcpServers.hindsight;
|
|
5786
6130
|
writeJson(mcpPath, mcp);
|
|
@@ -5794,17 +6138,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
|
|
|
5794
6138
|
var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
|
|
5795
6139
|
var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
|
|
5796
6140
|
function removeLegacyClineHooks(c) {
|
|
5797
|
-
const hooksDir =
|
|
6141
|
+
const hooksDir = join24(c.home, "Documents", "Cline", "Hooks");
|
|
5798
6142
|
for (const event of CLINE_OLD_HOOK_EVENTS) {
|
|
5799
|
-
const path =
|
|
5800
|
-
if (existsSync13(path) &&
|
|
6143
|
+
const path = join24(hooksDir, event);
|
|
6144
|
+
if (existsSync13(path) && readFileSync15(path, "utf8").includes(CLINE_HOOK_MARKER)) {
|
|
5801
6145
|
rmSync4(path, { force: true });
|
|
5802
6146
|
}
|
|
5803
6147
|
}
|
|
5804
6148
|
}
|
|
5805
6149
|
var cline = {
|
|
5806
6150
|
name: "cline-cli",
|
|
5807
|
-
detect: (c) => onPath2("cline") || existsSync13(
|
|
6151
|
+
detect: (c) => onPath2("cline") || existsSync13(join24(c.home, ".cline")),
|
|
5808
6152
|
install(c) {
|
|
5809
6153
|
removeLegacyClineHooks(c);
|
|
5810
6154
|
const installed = (c.clinePlugin ?? runClinePlugin)([
|
|
@@ -5813,8 +6157,8 @@ var cline = {
|
|
|
5813
6157
|
"--force",
|
|
5814
6158
|
c.pkgRoot
|
|
5815
6159
|
]);
|
|
5816
|
-
const mcpPath =
|
|
5817
|
-
const mcp =
|
|
6160
|
+
const mcpPath = join24(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
|
|
6161
|
+
const mcp = readJson2(mcpPath);
|
|
5818
6162
|
mcp.mcpServers = {
|
|
5819
6163
|
...mcp.mcpServers ?? {},
|
|
5820
6164
|
hindsight: mcpServerEntry(c.dist, "cline-cli")
|
|
@@ -5828,9 +6172,9 @@ var cline = {
|
|
|
5828
6172
|
uninstall(c) {
|
|
5829
6173
|
removeLegacyClineHooks(c);
|
|
5830
6174
|
(c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
|
|
5831
|
-
const mcpPath =
|
|
6175
|
+
const mcpPath = join24(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
|
|
5832
6176
|
if (existsSync13(mcpPath)) {
|
|
5833
|
-
const mcp =
|
|
6177
|
+
const mcp = readJson2(mcpPath);
|
|
5834
6178
|
if (mcp.mcpServers?.hindsight) {
|
|
5835
6179
|
delete mcp.mcpServers.hindsight;
|
|
5836
6180
|
writeJson(mcpPath, mcp);
|
|
@@ -5842,31 +6186,31 @@ var cline = {
|
|
|
5842
6186
|
};
|
|
5843
6187
|
var DCODE_MARKETPLACE = "hindsight-coding-agents";
|
|
5844
6188
|
var DCODE_PLUGIN_ID = "hindsight-coding-agents@hindsight-coding-agents";
|
|
5845
|
-
var DCODE_MARKETPLACE_RELATIVE_PATH =
|
|
6189
|
+
var DCODE_MARKETPLACE_RELATIVE_PATH = join24(".agents", "plugins", "marketplace.json");
|
|
5846
6190
|
var DCODE_FALLBACK_MARKETPLACE = "hindsight-coding-agents-marketplace.json";
|
|
5847
6191
|
function prepareDcodeMarketplace(c) {
|
|
5848
|
-
const root =
|
|
5849
|
-
const conventionalPath =
|
|
6192
|
+
const root = join24(c.home, ".hindsight");
|
|
6193
|
+
const conventionalPath = join24(root, DCODE_MARKETPLACE_RELATIVE_PATH);
|
|
5850
6194
|
let path = conventionalPath;
|
|
5851
6195
|
let registrationSource = root;
|
|
5852
6196
|
let marketplace = { plugins: [] };
|
|
5853
6197
|
if (existsSync13(conventionalPath)) {
|
|
5854
6198
|
try {
|
|
5855
|
-
const parsed = JSON.parse(
|
|
6199
|
+
const parsed = JSON.parse(readFileSync15(conventionalPath, "utf8"));
|
|
5856
6200
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins)) {
|
|
5857
|
-
path =
|
|
6201
|
+
path = join24(root, DCODE_FALLBACK_MARKETPLACE);
|
|
5858
6202
|
} else if (typeof parsed.name === "string" && parsed.name !== DCODE_MARKETPLACE) {
|
|
5859
|
-
path =
|
|
6203
|
+
path = join24(root, DCODE_FALLBACK_MARKETPLACE);
|
|
5860
6204
|
} else {
|
|
5861
6205
|
marketplace = parsed;
|
|
5862
6206
|
}
|
|
5863
6207
|
} catch {
|
|
5864
|
-
path =
|
|
6208
|
+
path = join24(root, DCODE_FALLBACK_MARKETPLACE);
|
|
5865
6209
|
}
|
|
5866
6210
|
}
|
|
5867
6211
|
if (path !== conventionalPath && existsSync13(path)) {
|
|
5868
6212
|
try {
|
|
5869
|
-
const parsed = JSON.parse(
|
|
6213
|
+
const parsed = JSON.parse(readFileSync15(path, "utf8"));
|
|
5870
6214
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins) || parsed.name !== DCODE_MARKETPLACE) {
|
|
5871
6215
|
c.log?.(`dcode: refusing to replace malformed marketplace file ${path}`);
|
|
5872
6216
|
return false;
|
|
@@ -5894,7 +6238,7 @@ function prepareDcodeMarketplace(c) {
|
|
|
5894
6238
|
}
|
|
5895
6239
|
var dcode = {
|
|
5896
6240
|
name: "dcode",
|
|
5897
|
-
detect: (c) => onPath2("dcode") || existsSync13(
|
|
6241
|
+
detect: (c) => onPath2("dcode") || existsSync13(join24(c.home, ".deepagents")),
|
|
5898
6242
|
preflight: (c) => c.dcodePlugin || onPath2("dcode") ? void 0 : "the `dcode` CLI is not on PATH",
|
|
5899
6243
|
install(c) {
|
|
5900
6244
|
const plugin = c.dcodePlugin ?? runDcodePlugin;
|
|
@@ -5903,7 +6247,7 @@ var dcode = {
|
|
|
5903
6247
|
if (installed) {
|
|
5904
6248
|
c.log?.(`dcode: native Agent Plugin installed (${DCODE_PLUGIN_ID})`);
|
|
5905
6249
|
} else {
|
|
5906
|
-
const source = marketplacePath === false ?
|
|
6250
|
+
const source = marketplacePath === false ? join24(c.home, ".hindsight") : marketplacePath;
|
|
5907
6251
|
c.log?.(
|
|
5908
6252
|
`dcode: could not install the native plugin \u2014 run dcode plugin marketplace add "${source}" && dcode plugin install ${DCODE_PLUGIN_ID}`
|
|
5909
6253
|
);
|
|
@@ -5936,16 +6280,16 @@ function dshUserPatches(existing) {
|
|
|
5936
6280
|
return others === DSH_EMPTY_LIST ? "" : others;
|
|
5937
6281
|
}
|
|
5938
6282
|
function dshHome(c) {
|
|
5939
|
-
return process.env.DSH_HOME ||
|
|
6283
|
+
return process.env.DSH_HOME || join24(c.home, ".dsh");
|
|
5940
6284
|
}
|
|
5941
6285
|
var dsh = {
|
|
5942
6286
|
name: "dsh",
|
|
5943
6287
|
detect: (c) => onPath2("dsh") || existsSync13(dshHome(c)),
|
|
5944
6288
|
install(c) {
|
|
5945
|
-
const path =
|
|
5946
|
-
const existing = existsSync13(path) ?
|
|
6289
|
+
const path = join24(dshHome(c), "cordis.patch.yml");
|
|
6290
|
+
const existing = existsSync13(path) ? readFileSync15(path, "utf8") : "";
|
|
5947
6291
|
const others = dshUserPatches(existing);
|
|
5948
|
-
const entry = pathToFileURL(
|
|
6292
|
+
const entry = pathToFileURL(join24(c.dist, "dsh.js")).href;
|
|
5949
6293
|
const block = `${DSH_MARKER_START}
|
|
5950
6294
|
- insert:
|
|
5951
6295
|
- id: hindsight
|
|
@@ -5954,7 +6298,7 @@ ${DSH_MARKER_END}
|
|
|
5954
6298
|
`;
|
|
5955
6299
|
if (existsSync13(path) && !existsSync13(`${path}.hindsight-backup`))
|
|
5956
6300
|
copyFileSync(path, `${path}.hindsight-backup`);
|
|
5957
|
-
mkdirSync7(
|
|
6301
|
+
mkdirSync7(dirname13(path), { recursive: true });
|
|
5958
6302
|
writeFileSync5(path, others ? `${others}
|
|
5959
6303
|
|
|
5960
6304
|
${block}` : block);
|
|
@@ -5964,9 +6308,9 @@ ${block}` : block);
|
|
|
5964
6308
|
);
|
|
5965
6309
|
},
|
|
5966
6310
|
uninstall(c) {
|
|
5967
|
-
const path =
|
|
6311
|
+
const path = join24(dshHome(c), "cordis.patch.yml");
|
|
5968
6312
|
if (existsSync13(path)) {
|
|
5969
|
-
const existing =
|
|
6313
|
+
const existing = readFileSync15(path, "utf8");
|
|
5970
6314
|
const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
|
|
5971
6315
|
if (others !== existing.trim())
|
|
5972
6316
|
writeFileSync5(path, others ? `${others}
|
|
@@ -5979,10 +6323,10 @@ ${block}` : block);
|
|
|
5979
6323
|
};
|
|
5980
6324
|
var qwen = {
|
|
5981
6325
|
name: "qwen-code",
|
|
5982
|
-
detect: (c) => onPath2("qwen") || existsSync13(
|
|
6326
|
+
detect: (c) => onPath2("qwen") || existsSync13(join24(c.home, ".qwen")),
|
|
5983
6327
|
install(c) {
|
|
5984
|
-
const path =
|
|
5985
|
-
const settings =
|
|
6328
|
+
const path = join24(c.home, ".qwen", "settings.json");
|
|
6329
|
+
const settings = readJson2(path);
|
|
5986
6330
|
settings.hooks = settings.hooks ?? {};
|
|
5987
6331
|
mergeHarnessHooks(settings.hooks, "qwen-code", c.dist);
|
|
5988
6332
|
writeJson(path, settings);
|
|
@@ -5999,20 +6343,20 @@ var qwen = {
|
|
|
5999
6343
|
"HINDSIGHT_MCP_HARNESS=qwen-code",
|
|
6000
6344
|
"hindsight",
|
|
6001
6345
|
"node",
|
|
6002
|
-
|
|
6346
|
+
join24(c.dist, "mcp-server.js")
|
|
6003
6347
|
])) {
|
|
6004
6348
|
c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
|
|
6005
6349
|
} else {
|
|
6006
6350
|
c.log?.(
|
|
6007
6351
|
`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 "${
|
|
6352
|
+
qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join24(c.dist, "mcp-server.js")}"`
|
|
6009
6353
|
);
|
|
6010
6354
|
}
|
|
6011
6355
|
},
|
|
6012
6356
|
uninstall(c) {
|
|
6013
|
-
const path =
|
|
6357
|
+
const path = join24(c.home, ".qwen", "settings.json");
|
|
6014
6358
|
if (existsSync13(path)) {
|
|
6015
|
-
const settings =
|
|
6359
|
+
const settings = readJson2(path);
|
|
6016
6360
|
if (settings.hooks) {
|
|
6017
6361
|
stripHarnessHooks(settings.hooks, "qwen-code");
|
|
6018
6362
|
if (!Object.keys(settings.hooks).length) delete settings.hooks;
|
|
@@ -6027,7 +6371,7 @@ var qwen = {
|
|
|
6027
6371
|
};
|
|
6028
6372
|
function defaultQwenMcp(args) {
|
|
6029
6373
|
try {
|
|
6030
|
-
|
|
6374
|
+
execFileSync8("qwen", args, { stdio: "pipe" });
|
|
6031
6375
|
return true;
|
|
6032
6376
|
} catch {
|
|
6033
6377
|
return false;
|
|
@@ -6035,19 +6379,19 @@ function defaultQwenMcp(args) {
|
|
|
6035
6379
|
}
|
|
6036
6380
|
var factoryDroid = {
|
|
6037
6381
|
name: "factory-droid",
|
|
6038
|
-
detect: (c) => onPath2("droid") || existsSync13(
|
|
6382
|
+
detect: (c) => onPath2("droid") || existsSync13(join24(c.home, ".factory")),
|
|
6039
6383
|
preflight(c) {
|
|
6040
|
-
const mcpPath =
|
|
6041
|
-
const existing =
|
|
6384
|
+
const mcpPath = join24(c.home, ".factory", "mcp.json");
|
|
6385
|
+
const existing = readJson2(mcpPath).mcpServers?.hindsight;
|
|
6042
6386
|
if (existing && !isOurMcpEntry(existing)) {
|
|
6043
6387
|
return `${mcpPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
|
|
6044
6388
|
}
|
|
6045
6389
|
},
|
|
6046
6390
|
install(c) {
|
|
6047
|
-
const hooksPath =
|
|
6048
|
-
const hooks =
|
|
6391
|
+
const hooksPath = join24(c.home, ".factory", "hooks.json");
|
|
6392
|
+
const hooks = readJson2(hooksPath);
|
|
6049
6393
|
if (!existsSync13(hooksPath)) {
|
|
6050
|
-
const fallback =
|
|
6394
|
+
const fallback = readJson2(join24(c.home, ".factory", "settings.json")).hooks;
|
|
6051
6395
|
if (fallback && typeof fallback === "object" && !Array.isArray(fallback)) {
|
|
6052
6396
|
Object.assign(hooks, fallback);
|
|
6053
6397
|
}
|
|
@@ -6056,24 +6400,24 @@ var factoryDroid = {
|
|
|
6056
6400
|
writeJson(hooksPath, hooks);
|
|
6057
6401
|
c.log?.(`factory-droid: hooks merged into ${hooksPath}`);
|
|
6058
6402
|
installSkill(c, "factory-droid");
|
|
6059
|
-
const mcpPath =
|
|
6060
|
-
const mcp =
|
|
6403
|
+
const mcpPath = join24(c.home, ".factory", "mcp.json");
|
|
6404
|
+
const mcp = readJson2(mcpPath);
|
|
6061
6405
|
mcp.mcpServers = mcp.mcpServers ?? {};
|
|
6062
6406
|
mcp.mcpServers.hindsight = mcpServerEntry(c.dist, "factory-droid");
|
|
6063
6407
|
writeJson(mcpPath, mcp);
|
|
6064
6408
|
c.log?.(`factory-droid: MCP server registered in ${mcpPath}`);
|
|
6065
6409
|
},
|
|
6066
6410
|
uninstall(c) {
|
|
6067
|
-
const hooksPath =
|
|
6411
|
+
const hooksPath = join24(c.home, ".factory", "hooks.json");
|
|
6068
6412
|
if (existsSync13(hooksPath)) {
|
|
6069
|
-
const hooks =
|
|
6413
|
+
const hooks = readJson2(hooksPath);
|
|
6070
6414
|
stripHarnessHooks(hooks, "factory-droid");
|
|
6071
6415
|
if (Object.keys(hooks).length) writeJson(hooksPath, hooks);
|
|
6072
6416
|
else rmSync4(hooksPath);
|
|
6073
6417
|
}
|
|
6074
|
-
const mcpPath =
|
|
6418
|
+
const mcpPath = join24(c.home, ".factory", "mcp.json");
|
|
6075
6419
|
if (existsSync13(mcpPath)) {
|
|
6076
|
-
const mcp =
|
|
6420
|
+
const mcp = readJson2(mcpPath);
|
|
6077
6421
|
if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
|
|
6078
6422
|
delete mcp.mcpServers.hindsight;
|
|
6079
6423
|
if (Object.keys(mcp.mcpServers).length) writeJson(mcpPath, mcp);
|
|
@@ -6086,17 +6430,17 @@ var factoryDroid = {
|
|
|
6086
6430
|
};
|
|
6087
6431
|
var zcode = {
|
|
6088
6432
|
name: "zcode",
|
|
6089
|
-
detect: (c) => onPath2("zcode") || existsSync13(
|
|
6433
|
+
detect: (c) => onPath2("zcode") || existsSync13(join24(c.home, ".zcode")),
|
|
6090
6434
|
preflight(c) {
|
|
6091
6435
|
const configPath = zcodeConfigPath(c);
|
|
6092
|
-
const existing =
|
|
6436
|
+
const existing = readJson2(configPath).mcp?.servers?.hindsight;
|
|
6093
6437
|
if (existing && !isOurMcpEntry(existing)) {
|
|
6094
6438
|
return `${configPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
|
|
6095
6439
|
}
|
|
6096
6440
|
},
|
|
6097
6441
|
install(c) {
|
|
6098
6442
|
const configPath = zcodeConfigPath(c);
|
|
6099
|
-
const config =
|
|
6443
|
+
const config = readJson2(configPath);
|
|
6100
6444
|
const hooks = config.hooks = config.hooks ?? {};
|
|
6101
6445
|
hooks.enabled = true;
|
|
6102
6446
|
hooks.maxOutputBytes = hooks.maxOutputBytes ?? ZCODE_MAX_OUTPUT_BYTES;
|
|
@@ -6112,7 +6456,7 @@ var zcode = {
|
|
|
6112
6456
|
uninstall(c) {
|
|
6113
6457
|
const configPath = zcodeConfigPath(c);
|
|
6114
6458
|
if (existsSync13(configPath)) {
|
|
6115
|
-
const config =
|
|
6459
|
+
const config = readJson2(configPath);
|
|
6116
6460
|
if (isOurMcpEntry(config.mcp?.servers?.hindsight)) {
|
|
6117
6461
|
delete config.mcp.servers.hindsight;
|
|
6118
6462
|
if (!Object.keys(config.mcp.servers).length) delete config.mcp;
|
|
@@ -6128,12 +6472,12 @@ var zcode = {
|
|
|
6128
6472
|
c.log?.(`zcode: hooks + MCP registration + skill removed`);
|
|
6129
6473
|
}
|
|
6130
6474
|
};
|
|
6131
|
-
var traecodeMcpPath = (c) =>
|
|
6475
|
+
var traecodeMcpPath = (c) => join24(traecodeUserDataDir(c.home), "User", "mcp.json");
|
|
6132
6476
|
function removeTraecodeUserMcpEntry(c) {
|
|
6133
6477
|
try {
|
|
6134
6478
|
const mcpPath = traecodeMcpPath(c);
|
|
6135
6479
|
if (!existsSync13(mcpPath)) return false;
|
|
6136
|
-
const mcp =
|
|
6480
|
+
const mcp = readJson2(mcpPath);
|
|
6137
6481
|
if (!isOurMcpEntry(mcp.mcpServers?.hindsight)) return false;
|
|
6138
6482
|
delete mcp.mcpServers.hindsight;
|
|
6139
6483
|
if (Object.keys(mcp.mcpServers).length) writeJson(mcpPath, mcp);
|
|
@@ -6173,10 +6517,10 @@ function ensureTraecodeWorkspaceMcpGate(c) {
|
|
|
6173
6517
|
}
|
|
6174
6518
|
var traecode = {
|
|
6175
6519
|
name: "traecode",
|
|
6176
|
-
detect: (c) => existsSync13(
|
|
6520
|
+
detect: (c) => existsSync13(join24(c.home, traecodeDotDirName(c.home))) || onPath2("trae"),
|
|
6177
6521
|
install(c) {
|
|
6178
|
-
const hooksPath =
|
|
6179
|
-
const doc =
|
|
6522
|
+
const hooksPath = join24(c.home, traecodeDotDirName(c.home), "hooks.json");
|
|
6523
|
+
const doc = readJson2(hooksPath);
|
|
6180
6524
|
doc.version = doc.version ?? 1;
|
|
6181
6525
|
const hooks = doc.hooks = doc.hooks ?? {};
|
|
6182
6526
|
mergeHarnessHooks(hooks, "traecode", c.dist);
|
|
@@ -6189,11 +6533,11 @@ var traecode = {
|
|
|
6189
6533
|
.trae/mcp.json files register the server instead`
|
|
6190
6534
|
);
|
|
6191
6535
|
}
|
|
6192
|
-
const sandboxPath =
|
|
6193
|
-
const sandbox =
|
|
6536
|
+
const sandboxPath = join24(c.home, traecodeDotDirName(c.home), "sandbox.json");
|
|
6537
|
+
const sandbox = readJson2(sandboxPath);
|
|
6194
6538
|
const fsRules = sandbox.filesystem = sandbox.filesystem ?? {};
|
|
6195
6539
|
const readWrite = fsRules.readWrite = fsRules.readWrite ?? [];
|
|
6196
|
-
const needed = [
|
|
6540
|
+
const needed = [join24(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
|
|
6197
6541
|
let sandboxChanged = false;
|
|
6198
6542
|
for (const dir of needed) {
|
|
6199
6543
|
if (!readWrite.includes(dir)) {
|
|
@@ -6205,7 +6549,7 @@ var traecode = {
|
|
|
6205
6549
|
writeJson(sandboxPath, sandbox);
|
|
6206
6550
|
c.log?.(`traecode: sandbox readWrite rules added (${needed.join(", ")})`);
|
|
6207
6551
|
}
|
|
6208
|
-
const config =
|
|
6552
|
+
const config = readJson2(hindsightConfigPath(c));
|
|
6209
6553
|
const repos = Object.keys(config.mapPathToBank ?? {}).sort();
|
|
6210
6554
|
if (repos.length) {
|
|
6211
6555
|
const written = [];
|
|
@@ -6241,9 +6585,9 @@ var traecode = {
|
|
|
6241
6585
|
ensureTraecodeWorkspaceMcpGate(c);
|
|
6242
6586
|
},
|
|
6243
6587
|
uninstall(c) {
|
|
6244
|
-
const hooksPath =
|
|
6588
|
+
const hooksPath = join24(c.home, traecodeDotDirName(c.home), "hooks.json");
|
|
6245
6589
|
if (existsSync13(hooksPath)) {
|
|
6246
|
-
const doc =
|
|
6590
|
+
const doc = readJson2(hooksPath);
|
|
6247
6591
|
if (doc.hooks) {
|
|
6248
6592
|
stripHarnessHooks(doc.hooks, "traecode");
|
|
6249
6593
|
if (!Object.keys(doc.hooks).length) delete doc.hooks;
|
|
@@ -6254,7 +6598,7 @@ var traecode = {
|
|
|
6254
6598
|
if (removeTraecodeUserMcpEntry(c)) {
|
|
6255
6599
|
c.log?.(`traecode: MCP entry removed from ${traecodeMcpPath(c)}`);
|
|
6256
6600
|
}
|
|
6257
|
-
const config =
|
|
6601
|
+
const config = readJson2(hindsightConfigPath(c));
|
|
6258
6602
|
const repoEntries = Object.keys(config.mapPathToBank ?? {}).sort();
|
|
6259
6603
|
const cleaned = repoEntries.filter(
|
|
6260
6604
|
(repo) => removeTraecodeWorkspaceMcpEntry(repo, { home: c.home })
|
|
@@ -6263,12 +6607,12 @@ var traecode = {
|
|
|
6263
6607
|
c.log?.(`traecode: per-repo MCP registration removed from:
|
|
6264
6608
|
${cleaned.join("\n ")}`);
|
|
6265
6609
|
}
|
|
6266
|
-
const sandboxPath =
|
|
6610
|
+
const sandboxPath = join24(c.home, traecodeDotDirName(c.home), "sandbox.json");
|
|
6267
6611
|
if (existsSync13(sandboxPath)) {
|
|
6268
|
-
const sandbox =
|
|
6612
|
+
const sandbox = readJson2(sandboxPath);
|
|
6269
6613
|
const readWrite = sandbox.filesystem?.readWrite;
|
|
6270
6614
|
if (Array.isArray(readWrite)) {
|
|
6271
|
-
const ours = [
|
|
6615
|
+
const ours = [join24(c.home, ".hindsight"), traecodeWorkspaceStorageDir(c.home)];
|
|
6272
6616
|
const filtered = readWrite.filter((p) => !ours.includes(p));
|
|
6273
6617
|
if (filtered.length !== readWrite.length) {
|
|
6274
6618
|
sandbox.filesystem.readWrite = filtered;
|
|
@@ -6281,6 +6625,56 @@ var traecode = {
|
|
|
6281
6625
|
c.log?.(`traecode: hooks + MCP registration + skill removed`);
|
|
6282
6626
|
}
|
|
6283
6627
|
};
|
|
6628
|
+
var genieInstaller = (name, homeDir, mcpPaths) => ({
|
|
6629
|
+
name,
|
|
6630
|
+
detect: (c) => existsSync13(join24(c.home, homeDir)),
|
|
6631
|
+
install(c) {
|
|
6632
|
+
const settingsPath = join24(c.home, homeDir, "settings.json");
|
|
6633
|
+
const settings = readJson2(settingsPath);
|
|
6634
|
+
settings.hooks = settings.hooks ?? {};
|
|
6635
|
+
mergeHarnessHooks(settings.hooks, name, c.dist);
|
|
6636
|
+
writeJson(settingsPath, settings);
|
|
6637
|
+
c.log?.(`${name}: hooks merged into ${settingsPath}`);
|
|
6638
|
+
const paths = mcpPaths(c.home);
|
|
6639
|
+
const mcpPath = paths.find((p) => existsSync13(p)) ?? paths[0];
|
|
6640
|
+
const mcp = readJson2(mcpPath);
|
|
6641
|
+
mcp.mcpServers = mcp.mcpServers ?? {};
|
|
6642
|
+
mcp.mcpServers.hindsight = mcpServerEntry(c.dist, name);
|
|
6643
|
+
writeJson(mcpPath, mcp);
|
|
6644
|
+
c.log?.(`${name}: MCP server registered in ${mcpPath}`);
|
|
6645
|
+
installSkill(c, name);
|
|
6646
|
+
},
|
|
6647
|
+
uninstall(c) {
|
|
6648
|
+
const settingsPath = join24(c.home, homeDir, "settings.json");
|
|
6649
|
+
if (existsSync13(settingsPath)) {
|
|
6650
|
+
const settings = readJson2(settingsPath);
|
|
6651
|
+
if (settings.hooks) {
|
|
6652
|
+
stripHarnessHooks(settings.hooks, name);
|
|
6653
|
+
if (!Object.keys(settings.hooks).length) delete settings.hooks;
|
|
6654
|
+
writeJson(settingsPath, settings);
|
|
6655
|
+
}
|
|
6656
|
+
}
|
|
6657
|
+
for (const mcpPath of mcpPaths(c.home)) {
|
|
6658
|
+
if (!existsSync13(mcpPath)) continue;
|
|
6659
|
+
const mcp = readJson2(mcpPath);
|
|
6660
|
+
if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
|
|
6661
|
+
delete mcp.mcpServers.hindsight;
|
|
6662
|
+
if (!Object.keys(mcp.mcpServers).length) delete mcp.mcpServers;
|
|
6663
|
+
writeJson(mcpPath, mcp);
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
uninstallSkill(c, name);
|
|
6667
|
+
c.log?.(`${name}: hooks + MCP registration + skill removed`);
|
|
6668
|
+
}
|
|
6669
|
+
});
|
|
6670
|
+
var workbuddy = genieInstaller("workbuddy", ".workbuddy", (home) => [
|
|
6671
|
+
join24(home, ".workbuddy", "mcp.json")
|
|
6672
|
+
]);
|
|
6673
|
+
var codebuddy = genieInstaller("codebuddy", ".codebuddy", (home) => [
|
|
6674
|
+
join24(home, ".codebuddy", ".mcp.json"),
|
|
6675
|
+
join24(home, ".codebuddy", "mcp.json"),
|
|
6676
|
+
join24(home, ".codebuddy.json")
|
|
6677
|
+
]);
|
|
6284
6678
|
var INSTALLERS = [
|
|
6285
6679
|
opencode,
|
|
6286
6680
|
opencode2,
|
|
@@ -6301,7 +6695,9 @@ var INSTALLERS = [
|
|
|
6301
6695
|
dsh,
|
|
6302
6696
|
factoryDroid,
|
|
6303
6697
|
zcode,
|
|
6304
|
-
traecode
|
|
6698
|
+
traecode,
|
|
6699
|
+
workbuddy,
|
|
6700
|
+
codebuddy
|
|
6305
6701
|
];
|
|
6306
6702
|
var HARNESS_ALIASES = { agy: "antigravity-cli" };
|
|
6307
6703
|
function importConversations(harness, ctx) {
|
|
@@ -6321,18 +6717,18 @@ function importConversations(harness, ctx) {
|
|
|
6321
6717
|
return;
|
|
6322
6718
|
}
|
|
6323
6719
|
const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
|
|
6324
|
-
const file =
|
|
6720
|
+
const file = join24(mkdtempSync2(join24(tmpdir5(), "hindsight-import-")), "conversations.json");
|
|
6325
6721
|
writeFileSync5(file, JSON.stringify(found.sessions));
|
|
6326
6722
|
ctx.log?.(
|
|
6327
6723
|
`${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
|
|
6328
6724
|
);
|
|
6329
6725
|
try {
|
|
6330
|
-
|
|
6726
|
+
execFileSync8("node", [join24(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
|
|
6331
6727
|
stdio: "inherit"
|
|
6332
6728
|
});
|
|
6333
6729
|
} catch {
|
|
6334
6730
|
ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
|
|
6335
|
-
ctx.log?.(` node "${
|
|
6731
|
+
ctx.log?.(` node "${join24(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
|
|
6336
6732
|
}
|
|
6337
6733
|
}
|
|
6338
6734
|
function run(argv, ctxIn) {
|
|
@@ -6437,18 +6833,18 @@ var mainPath = process.argv[1] ? (() => {
|
|
|
6437
6833
|
})() : void 0;
|
|
6438
6834
|
var isMain = mainPath && import.meta.url === pathToFileURL(mainPath).href;
|
|
6439
6835
|
if (isMain || mainPath?.endsWith("installer.js")) {
|
|
6440
|
-
const dist =
|
|
6441
|
-
const pkgRoot =
|
|
6442
|
-
let
|
|
6836
|
+
const dist = dirname13(fileURLToPath7(import.meta.url));
|
|
6837
|
+
const pkgRoot = dirname13(dist);
|
|
6838
|
+
let version2;
|
|
6443
6839
|
try {
|
|
6444
|
-
|
|
6840
|
+
version2 = JSON.parse(readFileSync15(join24(pkgRoot, "package.json"), "utf8")).version;
|
|
6445
6841
|
} catch {
|
|
6446
|
-
|
|
6842
|
+
version2 = void 0;
|
|
6447
6843
|
}
|
|
6448
6844
|
const ui = createInstallerUi({
|
|
6449
6845
|
home: homedir13(),
|
|
6450
6846
|
command: process.argv[2],
|
|
6451
|
-
version,
|
|
6847
|
+
version: version2,
|
|
6452
6848
|
harnessNames: INSTALLERS.map((i) => i.name),
|
|
6453
6849
|
// configureServer's messages render as their own "server" group, but don't count as an agent.
|
|
6454
6850
|
auxNames: ["server"],
|
|
@@ -6484,11 +6880,11 @@ export {
|
|
|
6484
6880
|
};
|
|
6485
6881
|
/*! Bundled license information:
|
|
6486
6882
|
|
|
6487
|
-
smol-toml/dist/date.js:
|
|
6488
6883
|
smol-toml/dist/error.js:
|
|
6489
|
-
smol-toml/dist/util.js:
|
|
6490
6884
|
smol-toml/dist/primitive.js:
|
|
6885
|
+
smol-toml/dist/date.js:
|
|
6491
6886
|
smol-toml/dist/extract.js:
|
|
6887
|
+
smol-toml/dist/util.js:
|
|
6492
6888
|
smol-toml/dist/struct.js:
|
|
6493
6889
|
smol-toml/dist/parse.js:
|
|
6494
6890
|
smol-toml/dist/stringify.js:
|