@vectorize-io/hindsight-coding-agents 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/antigravity-hook.js +67 -33
- package/dist/antigravity-stop-hook.js +61 -31
- package/dist/claude-hook.js +67 -33
- package/dist/claude-sessionstart-hook.js +239 -71
- package/dist/claude-stop-hook.js +61 -31
- package/dist/cline.js +213 -50
- package/dist/codex-hook.js +67 -33
- package/dist/codex-sessionstart-hook.js +239 -71
- package/dist/codex-stop-hook.js +61 -31
- package/dist/copilot-hook.js +67 -33
- package/dist/copilot-sessionstart-hook.js +239 -71
- package/dist/copilot-stop-hook.js +61 -31
- package/dist/cursor-hook.js +67 -33
- package/dist/cursor-sessionstart-hook.js +239 -71
- package/dist/cursor-stop-hook.js +61 -31
- package/dist/dcode-hook.js +67 -33
- package/dist/dcode-sessionstart-hook.js +239 -71
- package/dist/dcode-stop-hook.js +61 -31
- package/dist/deepen.js +40 -13
- package/dist/devin-hook.js +67 -33
- package/dist/devin-sessionstart-hook.js +239 -71
- package/dist/devin-stop-hook.js +61 -31
- package/dist/droid-hook.js +67 -33
- package/dist/droid-sessionstart-hook.js +239 -71
- package/dist/droid-stop-hook.js +61 -31
- package/dist/dsh.js +215 -52
- package/dist/grok-hook.js +67 -33
- package/dist/grok-sessionstart-hook.js +239 -71
- package/dist/grok-stop-hook.js +61 -31
- package/dist/index.js +215 -52
- package/dist/installer.js +1030 -268
- package/dist/kilo.js +215 -52
- package/dist/mcp-server.js +33 -6
- package/dist/opencode2.js +215 -52
- package/dist/pi.js +214 -51
- package/dist/prime-agent.js +214 -51
- package/dist/qwen-hook.js +67 -33
- package/dist/qwen-sessionstart-hook.js +239 -71
- package/dist/qwen-stop-hook.js +61 -31
- package/dist/status.js +31 -4
- package/dist/survey-supervisor.js +81 -0
- package/dist/zcode-hook.js +67 -33
- package/dist/zcode-sessionstart-hook.js +239 -71
- package/dist/zcode-stop-hook.js +61 -31
- package/package.json +2 -1
- package/plugin.json +1 -1
package/dist/installer.js
CHANGED
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
copyFileSync,
|
|
7
7
|
cpSync as cpSync2,
|
|
8
8
|
existsSync as existsSync10,
|
|
9
|
-
mkdirSync as
|
|
10
|
-
mkdtempSync,
|
|
9
|
+
mkdirSync as mkdirSync6,
|
|
10
|
+
mkdtempSync as mkdtempSync2,
|
|
11
11
|
readFileSync as readFileSync14,
|
|
12
12
|
readSync as readSync4,
|
|
13
13
|
realpathSync as realpathSync3,
|
|
14
|
-
rmSync as
|
|
15
|
-
writeFileSync as
|
|
14
|
+
rmSync as rmSync3,
|
|
15
|
+
writeFileSync as writeFileSync4
|
|
16
16
|
} from "fs";
|
|
17
|
-
import { homedir as homedir10, tmpdir as
|
|
17
|
+
import { homedir as homedir10, tmpdir as tmpdir6 } from "os";
|
|
18
18
|
import { isatty } from "tty";
|
|
19
|
-
import { dirname as dirname11, join as
|
|
19
|
+
import { dirname as dirname11, join as join18 } from "path";
|
|
20
20
|
import { fileURLToPath as fileURLToPath6, pathToFileURL } from "url";
|
|
21
21
|
|
|
22
22
|
// node_modules/jsonc-parser/lib/esm/impl/scanner.js
|
|
@@ -910,22 +910,22 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
910
910
|
}
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
|
-
function handleError(error, skipUntilAfter = [],
|
|
913
|
+
function handleError(error, skipUntilAfter = [], skipUntil2 = []) {
|
|
914
914
|
onError(error);
|
|
915
|
-
if (skipUntilAfter.length +
|
|
915
|
+
if (skipUntilAfter.length + skipUntil2.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 (skipUntil2.indexOf(token) !== -1) {
|
|
922
922
|
break;
|
|
923
923
|
}
|
|
924
924
|
token = scanNext();
|
|
925
925
|
}
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
|
-
function
|
|
928
|
+
function parseString2(isValue) {
|
|
929
929
|
const value = _scanner.getTokenValue();
|
|
930
930
|
if (isValue) {
|
|
931
931
|
onLiteralValue(value);
|
|
@@ -974,11 +974,11 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
974
974
|
]);
|
|
975
975
|
return false;
|
|
976
976
|
}
|
|
977
|
-
|
|
977
|
+
parseString2(false);
|
|
978
978
|
if (_scanner.getToken() === 6) {
|
|
979
979
|
onSeparator(":");
|
|
980
980
|
scanNext();
|
|
981
|
-
if (!
|
|
981
|
+
if (!parseValue2()) {
|
|
982
982
|
handleError(4, [], [
|
|
983
983
|
2,
|
|
984
984
|
5
|
|
@@ -1032,7 +1032,7 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1032
1032
|
}
|
|
1033
1033
|
return true;
|
|
1034
1034
|
}
|
|
1035
|
-
function
|
|
1035
|
+
function parseArray2() {
|
|
1036
1036
|
onArrayBegin();
|
|
1037
1037
|
scanNext();
|
|
1038
1038
|
let isFirstElement = true;
|
|
@@ -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 (!parseValue2()) {
|
|
1060
1060
|
handleError(4, [], [
|
|
1061
1061
|
4,
|
|
1062
1062
|
5
|
|
@@ -1079,14 +1079,14 @@ function visit(text, visitor, options = ParseOptions.DEFAULT) {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
return true;
|
|
1081
1081
|
}
|
|
1082
|
-
function
|
|
1082
|
+
function parseValue2() {
|
|
1083
1083
|
switch (_scanner.getToken()) {
|
|
1084
1084
|
case 3:
|
|
1085
|
-
return
|
|
1085
|
+
return parseArray2();
|
|
1086
1086
|
case 1:
|
|
1087
1087
|
return parseObject();
|
|
1088
1088
|
case 10:
|
|
1089
|
-
return
|
|
1089
|
+
return parseString2(true);
|
|
1090
1090
|
default:
|
|
1091
1091
|
return parseLiteral();
|
|
1092
1092
|
}
|
|
@@ -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 (!parseValue2()) {
|
|
1103
1103
|
handleError(4, [], []);
|
|
1104
1104
|
return false;
|
|
1105
1105
|
}
|
|
@@ -1347,6 +1347,651 @@ 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
|
+
// node_modules/smol-toml/dist/error.js
|
|
1443
|
+
function getLineColFromPtr(string, ptr) {
|
|
1444
|
+
let lines = string.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1445
|
+
return [lines.length, lines.pop().length + 1];
|
|
1446
|
+
}
|
|
1447
|
+
function makeCodeBlock(string, line, column) {
|
|
1448
|
+
let lines = string.split(/\r\n|\n|\r/g);
|
|
1449
|
+
let codeblock = "";
|
|
1450
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
1451
|
+
for (let i = line - 1; i <= line + 1; i++) {
|
|
1452
|
+
let l = lines[i - 1];
|
|
1453
|
+
if (!l)
|
|
1454
|
+
continue;
|
|
1455
|
+
codeblock += i.toString().padEnd(numberLen, " ");
|
|
1456
|
+
codeblock += ": ";
|
|
1457
|
+
codeblock += l;
|
|
1458
|
+
codeblock += "\n";
|
|
1459
|
+
if (i === line) {
|
|
1460
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
1461
|
+
codeblock += "^\n";
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return codeblock;
|
|
1465
|
+
}
|
|
1466
|
+
var TomlError = class extends Error {
|
|
1467
|
+
line;
|
|
1468
|
+
column;
|
|
1469
|
+
codeblock;
|
|
1470
|
+
constructor(message, options) {
|
|
1471
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
1472
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
1473
|
+
super(`Invalid TOML document: ${message}
|
|
1474
|
+
|
|
1475
|
+
${codeblock}`, options);
|
|
1476
|
+
this.line = line;
|
|
1477
|
+
this.column = column;
|
|
1478
|
+
this.codeblock = codeblock;
|
|
1479
|
+
}
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
// node_modules/smol-toml/dist/util.js
|
|
1483
|
+
function indexOfNewline(str, start = 0) {
|
|
1484
|
+
let idx = str.indexOf("\n", start);
|
|
1485
|
+
if (str.charCodeAt(idx - 1) === 13)
|
|
1486
|
+
idx--;
|
|
1487
|
+
return idx;
|
|
1488
|
+
}
|
|
1489
|
+
function skipComment(ctx) {
|
|
1490
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1491
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1492
|
+
if (c === 10)
|
|
1493
|
+
break;
|
|
1494
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
1495
|
+
ctx.p++;
|
|
1496
|
+
break;
|
|
1497
|
+
}
|
|
1498
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
1499
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
1500
|
+
toml: ctx.s,
|
|
1501
|
+
ptr: ctx.p
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
1507
|
+
let c;
|
|
1508
|
+
while (1) {
|
|
1509
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
1510
|
+
ctx.p++;
|
|
1511
|
+
if (banComments || c !== 35)
|
|
1512
|
+
break;
|
|
1513
|
+
skipComment(ctx);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
function skipUntil(ctx, sep2, end) {
|
|
1517
|
+
let ptr = ctx.p;
|
|
1518
|
+
if (!end) {
|
|
1519
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
1520
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1524
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1525
|
+
if (c === 35) {
|
|
1526
|
+
skipComment(ctx);
|
|
1527
|
+
} else if (c === end || c === sep2) {
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
throw new TomlError("cannot find end of structure", {
|
|
1532
|
+
toml: ctx.s,
|
|
1533
|
+
ptr
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
// 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
|
+
function parseString(ctx) {
|
|
1542
|
+
let start = ctx.p;
|
|
1543
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
1544
|
+
let first = c;
|
|
1545
|
+
let isLiteral = c === 39;
|
|
1546
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
1547
|
+
if (isMultiline) {
|
|
1548
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
1549
|
+
ctx.p++;
|
|
1550
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
1551
|
+
ctx.p += 2;
|
|
1552
|
+
}
|
|
1553
|
+
let parsed = "";
|
|
1554
|
+
let sliceStart = ctx.p;
|
|
1555
|
+
let state = 0;
|
|
1556
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1557
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
1558
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
1559
|
+
state = state && 3;
|
|
1560
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
1561
|
+
throw new TomlError("control characters are not allowed in strings", {
|
|
1562
|
+
toml: ctx.s,
|
|
1563
|
+
ptr: ctx.p
|
|
1564
|
+
});
|
|
1565
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
1566
|
+
if (isMultiline) {
|
|
1567
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1568
|
+
ctx.p++;
|
|
1569
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1570
|
+
ctx.p++;
|
|
1571
|
+
}
|
|
1572
|
+
if (!state)
|
|
1573
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
1574
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
1575
|
+
return parsed;
|
|
1576
|
+
} else if (!state) {
|
|
1577
|
+
if (!isLiteral && c === 92) {
|
|
1578
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
1579
|
+
state = 1;
|
|
1580
|
+
}
|
|
1581
|
+
} else if (state === 1) {
|
|
1582
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
1583
|
+
let value = 0;
|
|
1584
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
1585
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
1586
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
1587
|
+
let digit = (
|
|
1588
|
+
/* 0-9 */
|
|
1589
|
+
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
1590
|
+
/* A-F */
|
|
1591
|
+
hex >= 65 && hex <= 70 ? hex - 65 + 10 : (
|
|
1592
|
+
/* a-f */
|
|
1593
|
+
hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1
|
|
1594
|
+
)
|
|
1595
|
+
)
|
|
1596
|
+
);
|
|
1597
|
+
if (digit < 0)
|
|
1598
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
1599
|
+
value = value << 4 | digit;
|
|
1600
|
+
}
|
|
1601
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
1602
|
+
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
1603
|
+
}
|
|
1604
|
+
parsed += String.fromCodePoint(value);
|
|
1605
|
+
sliceStart = ctx.p + 1;
|
|
1606
|
+
state = 0;
|
|
1607
|
+
} else if (c === 32 || c === 9) {
|
|
1608
|
+
state = 2;
|
|
1609
|
+
} else {
|
|
1610
|
+
if (c === 98)
|
|
1611
|
+
parsed += "\b";
|
|
1612
|
+
else if (c === 116)
|
|
1613
|
+
parsed += " ";
|
|
1614
|
+
else if (c === 110)
|
|
1615
|
+
parsed += "\n";
|
|
1616
|
+
else if (c === 102)
|
|
1617
|
+
parsed += "\f";
|
|
1618
|
+
else if (c === 114)
|
|
1619
|
+
parsed += "\r";
|
|
1620
|
+
else if (c === 101)
|
|
1621
|
+
parsed += "\x1B";
|
|
1622
|
+
else if (c === 34)
|
|
1623
|
+
parsed += '"';
|
|
1624
|
+
else if (c === 92)
|
|
1625
|
+
parsed += "\\";
|
|
1626
|
+
else
|
|
1627
|
+
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
1628
|
+
sliceStart = ctx.p + 1;
|
|
1629
|
+
state = 0;
|
|
1630
|
+
}
|
|
1631
|
+
} else if (c !== 32 && c !== 9) {
|
|
1632
|
+
if (state === 2) {
|
|
1633
|
+
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
1634
|
+
toml: ctx.s,
|
|
1635
|
+
ptr: sliceStart
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
1639
|
+
sliceStart = ctx.p;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
1643
|
+
}
|
|
1644
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
1645
|
+
let value = ctx.s.slice(start, end);
|
|
1646
|
+
let commentIdx = value.indexOf("#");
|
|
1647
|
+
if (commentIdx > 0) {
|
|
1648
|
+
skipComment({ s: value, p: commentIdx, d: 0 });
|
|
1649
|
+
value = value.slice(0, commentIdx);
|
|
1650
|
+
}
|
|
1651
|
+
return value.trimEnd();
|
|
1652
|
+
}
|
|
1653
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
1654
|
+
let ptr = ctx.p;
|
|
1655
|
+
let err = { toml: ctx.s, ptr };
|
|
1656
|
+
skipUntil(ctx, 44, end);
|
|
1657
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
1658
|
+
if (!value)
|
|
1659
|
+
throw new TomlError("incomplete declaration: value expected", err);
|
|
1660
|
+
if (value === "-inf")
|
|
1661
|
+
return -Infinity;
|
|
1662
|
+
if (value === "inf" || value === "+inf")
|
|
1663
|
+
return Infinity;
|
|
1664
|
+
if (value === "nan" || value === "+nan" || value === "-nan")
|
|
1665
|
+
return NaN;
|
|
1666
|
+
if (value === "-0")
|
|
1667
|
+
return integersAsBigInt ? 0n : 0;
|
|
1668
|
+
let isInt = INT_REGEX.test(value);
|
|
1669
|
+
if (isInt || FLOAT_REGEX.test(value)) {
|
|
1670
|
+
if (LEADING_ZERO.test(value)) {
|
|
1671
|
+
throw new TomlError("leading zeroes are not allowed", err);
|
|
1672
|
+
}
|
|
1673
|
+
value = value.replace(/_/g, "");
|
|
1674
|
+
let numeric = +value;
|
|
1675
|
+
if (isNaN(numeric)) {
|
|
1676
|
+
throw new TomlError("invalid number", err);
|
|
1677
|
+
}
|
|
1678
|
+
if (isInt) {
|
|
1679
|
+
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
1680
|
+
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
1681
|
+
}
|
|
1682
|
+
if (isInt || integersAsBigInt === true)
|
|
1683
|
+
numeric = BigInt(value);
|
|
1684
|
+
}
|
|
1685
|
+
return numeric;
|
|
1686
|
+
}
|
|
1687
|
+
const date = new TomlDate(value);
|
|
1688
|
+
if (!date.isValid())
|
|
1689
|
+
throw new TomlError("invalid value", err);
|
|
1690
|
+
return date;
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
// node_modules/smol-toml/dist/extract.js
|
|
1694
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
1695
|
+
let ptr = ctx.p;
|
|
1696
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
1697
|
+
if (c === 91 || c === 123) {
|
|
1698
|
+
if (!ctx.d--) {
|
|
1699
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
1700
|
+
toml: ctx.s,
|
|
1701
|
+
ptr
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
1705
|
+
ctx.d++;
|
|
1706
|
+
return value;
|
|
1707
|
+
}
|
|
1708
|
+
if (c === 34 || c === 39) {
|
|
1709
|
+
return parseString(ctx);
|
|
1710
|
+
}
|
|
1711
|
+
if (c === 116) {
|
|
1712
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1713
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1714
|
+
ctx.p++;
|
|
1715
|
+
return true;
|
|
1716
|
+
}
|
|
1717
|
+
if (c === 102) {
|
|
1718
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1719
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1720
|
+
ctx.p++;
|
|
1721
|
+
return false;
|
|
1722
|
+
}
|
|
1723
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// node_modules/smol-toml/dist/struct.js
|
|
1727
|
+
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1728
|
+
function parseKey(ctx, end = "=") {
|
|
1729
|
+
let start = ctx.p;
|
|
1730
|
+
let dot = start - 1;
|
|
1731
|
+
let parsed = [];
|
|
1732
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
1733
|
+
if (endPtr < 0) {
|
|
1734
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1735
|
+
toml: ctx.s,
|
|
1736
|
+
ptr: start
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
do {
|
|
1740
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
1741
|
+
if (c !== 32 && c !== 9) {
|
|
1742
|
+
if (c === 34 || c === 39) {
|
|
1743
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
1744
|
+
throw new TomlError("multiline strings are not allowed in keys", {
|
|
1745
|
+
toml: ctx.s,
|
|
1746
|
+
ptr: ctx.p
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
let part = parseString(ctx);
|
|
1750
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1751
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1752
|
+
let newLine = indexOfNewline(strEnd);
|
|
1753
|
+
if (newLine > -1) {
|
|
1754
|
+
throw new TomlError("newlines are not allowed in keys", {
|
|
1755
|
+
toml: ctx.s,
|
|
1756
|
+
ptr: newLine
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (strEnd.trimStart()) {
|
|
1760
|
+
throw new TomlError("found extra tokens after the string part", {
|
|
1761
|
+
toml: ctx.s,
|
|
1762
|
+
ptr: ctx.p
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
if (endPtr < ctx.p) {
|
|
1766
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
1767
|
+
if (endPtr < 0) {
|
|
1768
|
+
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1769
|
+
toml: ctx.s,
|
|
1770
|
+
ptr: start
|
|
1771
|
+
});
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
parsed.push(part);
|
|
1775
|
+
} else {
|
|
1776
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1777
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1778
|
+
if (!KEY_PART_RE.test(part)) {
|
|
1779
|
+
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1780
|
+
toml: ctx.s,
|
|
1781
|
+
ptr: ctx.p
|
|
1782
|
+
});
|
|
1783
|
+
}
|
|
1784
|
+
parsed.push(part.trimEnd());
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
} while (dot + 1 && dot < endPtr);
|
|
1788
|
+
ctx.p = endPtr + 1;
|
|
1789
|
+
skipVoid(ctx, true, true);
|
|
1790
|
+
return parsed;
|
|
1791
|
+
}
|
|
1792
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
1793
|
+
let res = {};
|
|
1794
|
+
let seen = /* @__PURE__ */ new Set();
|
|
1795
|
+
let c;
|
|
1796
|
+
ctx.p++;
|
|
1797
|
+
while (ctx.p < ctx.s.length) {
|
|
1798
|
+
skipVoid(ctx);
|
|
1799
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
1800
|
+
ctx.p++;
|
|
1801
|
+
return res;
|
|
1802
|
+
}
|
|
1803
|
+
let k;
|
|
1804
|
+
let t = res;
|
|
1805
|
+
let hasOwn = false;
|
|
1806
|
+
let p = ctx.p;
|
|
1807
|
+
let key = parseKey(ctx);
|
|
1808
|
+
for (let i = 0; i < key.length; i++) {
|
|
1809
|
+
if (i)
|
|
1810
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1811
|
+
k = key[i];
|
|
1812
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1813
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
1814
|
+
toml: ctx.s,
|
|
1815
|
+
ptr: p
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
if (!hasOwn && k === "__proto__") {
|
|
1819
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
if (hasOwn) {
|
|
1823
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
1824
|
+
toml: ctx.s,
|
|
1825
|
+
ptr: ctx.p
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
1829
|
+
seen.add(t[k] = value);
|
|
1830
|
+
skipVoid(ctx);
|
|
1831
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
1832
|
+
return res;
|
|
1833
|
+
}
|
|
1834
|
+
if (c !== 44) {
|
|
1835
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
throw new TomlError("unfinished table encountered", {
|
|
1839
|
+
toml: ctx.s,
|
|
1840
|
+
ptr: ctx.p
|
|
1841
|
+
});
|
|
1842
|
+
}
|
|
1843
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
1844
|
+
let res = [];
|
|
1845
|
+
let c;
|
|
1846
|
+
ctx.p++;
|
|
1847
|
+
while (ctx.p < ctx.s.length) {
|
|
1848
|
+
skipVoid(ctx);
|
|
1849
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
1850
|
+
ctx.p++;
|
|
1851
|
+
return res;
|
|
1852
|
+
}
|
|
1853
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
1854
|
+
skipVoid(ctx);
|
|
1855
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
1856
|
+
return res;
|
|
1857
|
+
}
|
|
1858
|
+
if (c !== 44) {
|
|
1859
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
throw new TomlError("unfinished array encountered", {
|
|
1863
|
+
toml: ctx.s,
|
|
1864
|
+
ptr: ctx.p
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// node_modules/smol-toml/dist/parse.js
|
|
1869
|
+
function peekTable(key, table, meta, type) {
|
|
1870
|
+
let t = table;
|
|
1871
|
+
let m = meta;
|
|
1872
|
+
let k;
|
|
1873
|
+
let hasOwn = false;
|
|
1874
|
+
let state;
|
|
1875
|
+
for (let i = 0; i < key.length; i++) {
|
|
1876
|
+
if (i) {
|
|
1877
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1878
|
+
m = (state = m[k]).c;
|
|
1879
|
+
if (type === 0 && (state.t === 1 || state.t === 2)) {
|
|
1880
|
+
return null;
|
|
1881
|
+
}
|
|
1882
|
+
if (state.t === 2) {
|
|
1883
|
+
let l = t.length - 1;
|
|
1884
|
+
t = t[l];
|
|
1885
|
+
m = m[l].c;
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
k = key[i];
|
|
1889
|
+
if ((hasOwn = Object.hasOwn(t, k)) && m[k]?.t === 0 && m[k]?.d) {
|
|
1890
|
+
return null;
|
|
1891
|
+
}
|
|
1892
|
+
if (!hasOwn) {
|
|
1893
|
+
if (k === "__proto__") {
|
|
1894
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1895
|
+
Object.defineProperty(m, k, { enumerable: true, configurable: true, writable: true });
|
|
1896
|
+
}
|
|
1897
|
+
m[k] = {
|
|
1898
|
+
t: i < key.length - 1 && type === 2 ? 3 : type,
|
|
1899
|
+
d: false,
|
|
1900
|
+
i: 0,
|
|
1901
|
+
c: {}
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
state = m[k];
|
|
1906
|
+
if (state.t !== type && !(type === 1 && state.t === 3)) {
|
|
1907
|
+
return null;
|
|
1908
|
+
}
|
|
1909
|
+
if (type === 2) {
|
|
1910
|
+
if (!state.d) {
|
|
1911
|
+
state.d = true;
|
|
1912
|
+
t[k] = [];
|
|
1913
|
+
}
|
|
1914
|
+
t[k].push(t = {});
|
|
1915
|
+
state.c[state.i++] = state = { t: 1, d: false, i: 0, c: {} };
|
|
1916
|
+
}
|
|
1917
|
+
if (state.d) {
|
|
1918
|
+
return null;
|
|
1919
|
+
}
|
|
1920
|
+
state.d = true;
|
|
1921
|
+
if (type === 1) {
|
|
1922
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1923
|
+
} else if (type === 0 && hasOwn) {
|
|
1924
|
+
return null;
|
|
1925
|
+
}
|
|
1926
|
+
return [k, t, state.c];
|
|
1927
|
+
}
|
|
1928
|
+
function parse2(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
1929
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
1930
|
+
let res = {};
|
|
1931
|
+
let meta = {};
|
|
1932
|
+
let tmp;
|
|
1933
|
+
let tbl = res;
|
|
1934
|
+
let m = meta;
|
|
1935
|
+
skipVoid(ctx);
|
|
1936
|
+
while (ctx.p < toml.length) {
|
|
1937
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
1938
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
1939
|
+
tmp = ctx.p += +isTableArray;
|
|
1940
|
+
let k = parseKey(ctx, "]");
|
|
1941
|
+
if (isTableArray) {
|
|
1942
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
1943
|
+
throw new TomlError("expected end of table declaration", {
|
|
1944
|
+
toml,
|
|
1945
|
+
ptr: ctx.p - 1
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
ctx.p++;
|
|
1949
|
+
}
|
|
1950
|
+
let p = peekTable(
|
|
1951
|
+
k,
|
|
1952
|
+
res,
|
|
1953
|
+
meta,
|
|
1954
|
+
isTableArray ? 2 : 1
|
|
1955
|
+
/* Type.EXPLICIT */
|
|
1956
|
+
);
|
|
1957
|
+
if (!p) {
|
|
1958
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1959
|
+
toml,
|
|
1960
|
+
ptr: tmp
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
m = p[2];
|
|
1964
|
+
tbl = p[1];
|
|
1965
|
+
} else {
|
|
1966
|
+
tmp = ctx.p;
|
|
1967
|
+
let k = parseKey(ctx);
|
|
1968
|
+
let p = peekTable(
|
|
1969
|
+
k,
|
|
1970
|
+
tbl,
|
|
1971
|
+
m,
|
|
1972
|
+
0
|
|
1973
|
+
/* Type.DOTTED */
|
|
1974
|
+
);
|
|
1975
|
+
if (!p) {
|
|
1976
|
+
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1977
|
+
toml,
|
|
1978
|
+
ptr: tmp
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
1982
|
+
}
|
|
1983
|
+
skipVoid(ctx, true);
|
|
1984
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
1985
|
+
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
1986
|
+
toml,
|
|
1987
|
+
ptr: ctx.p
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
skipVoid(ctx);
|
|
1991
|
+
}
|
|
1992
|
+
return res;
|
|
1993
|
+
}
|
|
1994
|
+
|
|
1350
1995
|
// src/core/hook.ts
|
|
1351
1996
|
import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
1352
1997
|
|
|
@@ -1687,7 +2332,7 @@ function readClaudeTranscript(path) {
|
|
|
1687
2332
|
}
|
|
1688
2333
|
|
|
1689
2334
|
// src/core/session-start.ts
|
|
1690
|
-
import { readFileSync as
|
|
2335
|
+
import { readFileSync as readFileSync10 } from "fs";
|
|
1691
2336
|
|
|
1692
2337
|
// src/core/git.ts
|
|
1693
2338
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
@@ -1697,24 +2342,42 @@ import { resolve as resolve2 } from "path";
|
|
|
1697
2342
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
1698
2343
|
|
|
1699
2344
|
// src/core/survey.ts
|
|
1700
|
-
import { spawn as
|
|
2345
|
+
import { spawn as realSpawn4 } from "child_process";
|
|
2346
|
+
import { createHash as createHash4 } from "crypto";
|
|
1701
2347
|
import { existsSync as existsSync3 } from "fs";
|
|
1702
|
-
import { homedir as homedir3 } from "os";
|
|
1703
|
-
import { dirname as dirname8, join as
|
|
2348
|
+
import { homedir as homedir3, tmpdir as tmpdir4 } from "os";
|
|
2349
|
+
import { dirname as dirname8, join as join11 } from "path";
|
|
1704
2350
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
1705
2351
|
|
|
2352
|
+
// src/core/survey-lease.ts
|
|
2353
|
+
import { spawn as realSpawn3 } from "child_process";
|
|
2354
|
+
import { randomUUID } from "crypto";
|
|
2355
|
+
import {
|
|
2356
|
+
mkdirSync as mkdirSync4,
|
|
2357
|
+
mkdtempSync,
|
|
2358
|
+
readdirSync,
|
|
2359
|
+
renameSync as renameSync2,
|
|
2360
|
+
rmdirSync,
|
|
2361
|
+
rmSync as rmSync2,
|
|
2362
|
+
statSync as statSync3,
|
|
2363
|
+
unlinkSync,
|
|
2364
|
+
utimesSync,
|
|
2365
|
+
writeFileSync as writeFileSync2
|
|
2366
|
+
} from "fs";
|
|
2367
|
+
import { join as join10 } from "path";
|
|
2368
|
+
|
|
1706
2369
|
// src/core/auto-update.ts
|
|
1707
|
-
import { spawn as
|
|
2370
|
+
import { spawn as realSpawn5 } from "child_process";
|
|
1708
2371
|
import {
|
|
1709
2372
|
existsSync as existsSync4,
|
|
1710
|
-
mkdirSync as
|
|
2373
|
+
mkdirSync as mkdirSync5,
|
|
1711
2374
|
readFileSync as readFileSync7,
|
|
1712
2375
|
realpathSync as realpathSync2,
|
|
1713
|
-
unlinkSync,
|
|
1714
|
-
writeFileSync as
|
|
2376
|
+
unlinkSync as unlinkSync2,
|
|
2377
|
+
writeFileSync as writeFileSync3
|
|
1715
2378
|
} from "fs";
|
|
1716
|
-
import { homedir as homedir4, tmpdir as
|
|
1717
|
-
import { dirname as dirname9, join as
|
|
2379
|
+
import { homedir as homedir4, tmpdir as tmpdir5 } from "os";
|
|
2380
|
+
import { dirname as dirname9, join as join12 } from "path";
|
|
1718
2381
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
1719
2382
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
1720
2383
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
@@ -1722,7 +2385,7 @@ var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
|
1722
2385
|
// src/core/skill-sync.ts
|
|
1723
2386
|
import { cpSync, existsSync as existsSync5, readFileSync as readFileSync8 } from "fs";
|
|
1724
2387
|
import { homedir as homedir5 } from "os";
|
|
1725
|
-
import { dirname as dirname10, join as
|
|
2388
|
+
import { dirname as dirname10, join as join13 } from "path";
|
|
1726
2389
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
1727
2390
|
|
|
1728
2391
|
// src/core/skill-dirs.ts
|
|
@@ -1752,6 +2415,59 @@ var SKILL_DIRS = {
|
|
|
1752
2415
|
"prime-agent": [".prime", "agent", "skills"]
|
|
1753
2416
|
};
|
|
1754
2417
|
|
|
2418
|
+
// src/core/legacy.ts
|
|
2419
|
+
import { existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
|
|
2420
|
+
import { homedir as homedir6 } from "os";
|
|
2421
|
+
import { join as join14, relative, isAbsolute as isAbsolute2 } from "path";
|
|
2422
|
+
var LEGACY_CONFIG_FILES = {
|
|
2423
|
+
"claude-code": "claude-code.json",
|
|
2424
|
+
codex: "codex.json"
|
|
2425
|
+
};
|
|
2426
|
+
function legacyConfigPath(harness, home = homedir6()) {
|
|
2427
|
+
return join14(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
|
|
2428
|
+
}
|
|
2429
|
+
var CLOUD_URL = "https://api.hindsight.vectorize.io";
|
|
2430
|
+
function readLegacyEndpoint(home = homedir6(), prefer = []) {
|
|
2431
|
+
const order = [...prefer, ...Object.keys(LEGACY_CONFIG_FILES)].filter(
|
|
2432
|
+
(h, i, all) => h in LEGACY_CONFIG_FILES && all.indexOf(h) === i
|
|
2433
|
+
);
|
|
2434
|
+
for (const harness of order) {
|
|
2435
|
+
const found = readOne(harness, home);
|
|
2436
|
+
if (found) return found;
|
|
2437
|
+
}
|
|
2438
|
+
return void 0;
|
|
2439
|
+
}
|
|
2440
|
+
function readOne(harness, home) {
|
|
2441
|
+
const source = legacyConfigPath(harness, home);
|
|
2442
|
+
if (!existsSync6(source)) return void 0;
|
|
2443
|
+
let raw;
|
|
2444
|
+
try {
|
|
2445
|
+
raw = JSON.parse(readFileSync9(source, "utf8"));
|
|
2446
|
+
} catch {
|
|
2447
|
+
return void 0;
|
|
2448
|
+
}
|
|
2449
|
+
if (!raw || typeof raw !== "object") return void 0;
|
|
2450
|
+
const apiToken = typeof raw.hindsightApiToken === "string" ? raw.hindsightApiToken : void 0;
|
|
2451
|
+
const url = typeof raw.hindsightApiUrl === "string" ? raw.hindsightApiUrl.trim() : "";
|
|
2452
|
+
if (url) {
|
|
2453
|
+
return {
|
|
2454
|
+
harness,
|
|
2455
|
+
serverMode: url.replace(/\/+$/, "") === CLOUD_URL ? "cloud" : "self-hosted",
|
|
2456
|
+
apiUrl: url,
|
|
2457
|
+
...apiToken ? { apiToken } : {},
|
|
2458
|
+
source
|
|
2459
|
+
};
|
|
2460
|
+
}
|
|
2461
|
+
const port = typeof raw.apiPort === "number" ? raw.apiPort : void 0;
|
|
2462
|
+
return {
|
|
2463
|
+
harness,
|
|
2464
|
+
serverMode: "daemon",
|
|
2465
|
+
...apiToken ? { apiToken } : {},
|
|
2466
|
+
...port && port !== DEFAULT_DAEMON_PORT ? { apiPort: port } : {},
|
|
2467
|
+
source
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
|
|
1755
2471
|
// src/core/transcript-codex.ts
|
|
1756
2472
|
function isSyntheticUserText(text) {
|
|
1757
2473
|
const s = text.trimStart();
|
|
@@ -1882,19 +2598,19 @@ function readCopilotTranscript(path) {
|
|
|
1882
2598
|
}
|
|
1883
2599
|
|
|
1884
2600
|
// src/core/transcript-grok.ts
|
|
1885
|
-
import { existsSync as
|
|
1886
|
-
import { homedir as
|
|
1887
|
-
import { join as
|
|
2601
|
+
import { existsSync as existsSync7, readFileSync as readFileSync11, readdirSync as readdirSync2 } from "fs";
|
|
2602
|
+
import { homedir as homedir7 } from "os";
|
|
2603
|
+
import { join as join15 } from "path";
|
|
1888
2604
|
var CHAT_HISTORY = "chat_history.jsonl";
|
|
1889
|
-
function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
|
|
1890
|
-
const sessionsDir =
|
|
1891
|
-
const direct =
|
|
1892
|
-
if (
|
|
2605
|
+
function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join15(homedir7(), ".grok")) {
|
|
2606
|
+
const sessionsDir = join15(grokHome, "sessions");
|
|
2607
|
+
const direct = join15(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
|
|
2608
|
+
if (existsSync7(direct)) return direct;
|
|
1893
2609
|
try {
|
|
1894
|
-
for (const candidate of
|
|
1895
|
-
const directory =
|
|
1896
|
-
if (
|
|
1897
|
-
return
|
|
2610
|
+
for (const candidate of readdirSync2(sessionsDir)) {
|
|
2611
|
+
const directory = join15(sessionsDir, candidate);
|
|
2612
|
+
if (readFileSync11(join15(directory, ".cwd"), "utf8").trim() === cwd) {
|
|
2613
|
+
return join15(directory, sessionId, CHAT_HISTORY);
|
|
1898
2614
|
}
|
|
1899
2615
|
}
|
|
1900
2616
|
} catch {
|
|
@@ -1929,12 +2645,12 @@ function readGrokTranscript(path) {
|
|
|
1929
2645
|
}
|
|
1930
2646
|
|
|
1931
2647
|
// src/core/transcript-devin.ts
|
|
1932
|
-
import { existsSync as
|
|
2648
|
+
import { existsSync as existsSync8 } from "fs";
|
|
1933
2649
|
import { createRequire } from "module";
|
|
1934
|
-
import { homedir as
|
|
1935
|
-
import { join as
|
|
1936
|
-
function devinSessionDb(home =
|
|
1937
|
-
return
|
|
2650
|
+
import { homedir as homedir8 } from "os";
|
|
2651
|
+
import { join as join16 } from "path";
|
|
2652
|
+
function devinSessionDb(home = homedir8()) {
|
|
2653
|
+
return join16(home, ".local", "share", "devin", "cli", "sessions.db");
|
|
1938
2654
|
}
|
|
1939
2655
|
function parseDevinMessages(nodes) {
|
|
1940
2656
|
const messages = /* @__PURE__ */ new Map();
|
|
@@ -1971,7 +2687,7 @@ function readDevinTranscript(sessionId, dbPath = devinSessionDb()) {
|
|
|
1971
2687
|
diag("devin-cli", "sqlite_unavailable", { node: process.version, dbPath });
|
|
1972
2688
|
return [];
|
|
1973
2689
|
}
|
|
1974
|
-
if (!
|
|
2690
|
+
if (!existsSync8(dbPath)) {
|
|
1975
2691
|
diag("devin-cli", "session_db_missing", { dbPath });
|
|
1976
2692
|
return [];
|
|
1977
2693
|
}
|
|
@@ -2244,7 +2960,7 @@ function readDroidTranscript(path) {
|
|
|
2244
2960
|
}
|
|
2245
2961
|
|
|
2246
2962
|
// src/core/transcript-zcode.ts
|
|
2247
|
-
import { readFileSync as
|
|
2963
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
2248
2964
|
function messageText2(content) {
|
|
2249
2965
|
if (typeof content === "string") return content.trim();
|
|
2250
2966
|
if (!Array.isArray(content)) return "";
|
|
@@ -2254,7 +2970,7 @@ function readZcodeTranscript(path) {
|
|
|
2254
2970
|
if (!path) return [];
|
|
2255
2971
|
let body;
|
|
2256
2972
|
try {
|
|
2257
|
-
body =
|
|
2973
|
+
body = readFileSync12(path, "utf8");
|
|
2258
2974
|
} catch {
|
|
2259
2975
|
return [];
|
|
2260
2976
|
}
|
|
@@ -2728,16 +3444,16 @@ var HOOK_HARNESSES = {
|
|
|
2728
3444
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
2729
3445
|
import {
|
|
2730
3446
|
closeSync as closeSync2,
|
|
2731
|
-
existsSync as
|
|
3447
|
+
existsSync as existsSync9,
|
|
2732
3448
|
openSync as openSync2,
|
|
2733
|
-
readdirSync as
|
|
2734
|
-
readFileSync as
|
|
3449
|
+
readdirSync as readdirSync3,
|
|
3450
|
+
readFileSync as readFileSync13,
|
|
2735
3451
|
readSync as readSync2,
|
|
2736
|
-
statSync as
|
|
3452
|
+
statSync as statSync4
|
|
2737
3453
|
} from "fs";
|
|
2738
|
-
import { createHash as
|
|
2739
|
-
import { homedir as
|
|
2740
|
-
import { join as
|
|
3454
|
+
import { createHash as createHash5 } from "crypto";
|
|
3455
|
+
import { homedir as homedir9 } from "os";
|
|
3456
|
+
import { join as join17 } from "path";
|
|
2741
3457
|
import * as zlib2 from "zlib";
|
|
2742
3458
|
|
|
2743
3459
|
// src/core/transcript-dsh.ts
|
|
@@ -2881,8 +3597,8 @@ function zstdDecompressFrames(buffer) {
|
|
|
2881
3597
|
}
|
|
2882
3598
|
|
|
2883
3599
|
// src/core/history.ts
|
|
2884
|
-
function claudeProjectDir(repoDir, home =
|
|
2885
|
-
return
|
|
3600
|
+
function claudeProjectDir(repoDir, home = homedir9()) {
|
|
3601
|
+
return join17(home, ".claude", "projects", repoDir.replace(/[^a-zA-Z0-9]/g, "-"));
|
|
2886
3602
|
}
|
|
2887
3603
|
function piSessionDir(repoDir) {
|
|
2888
3604
|
return `--${repoDir.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
|
|
@@ -2892,7 +3608,7 @@ function withinRepo(dir, repoDir) {
|
|
|
2892
3608
|
}
|
|
2893
3609
|
function claudeSessionCwd(file) {
|
|
2894
3610
|
try {
|
|
2895
|
-
for (const line of
|
|
3611
|
+
for (const line of readFileSync13(file, "utf8").split("\n", 400)) {
|
|
2896
3612
|
if (!line.includes('"cwd"')) continue;
|
|
2897
3613
|
const cwd = JSON.parse(line).cwd;
|
|
2898
3614
|
if (cwd) return cwd;
|
|
@@ -2928,19 +3644,19 @@ function firstLine(path, cap = 1e6) {
|
|
|
2928
3644
|
}
|
|
2929
3645
|
function listDir(dir) {
|
|
2930
3646
|
try {
|
|
2931
|
-
return
|
|
3647
|
+
return readdirSync3(dir);
|
|
2932
3648
|
} catch {
|
|
2933
3649
|
return [];
|
|
2934
3650
|
}
|
|
2935
3651
|
}
|
|
2936
3652
|
function jsonlFiles(dir) {
|
|
2937
|
-
return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) =>
|
|
3653
|
+
return listDir(dir).filter((f) => f.endsWith(".jsonl")).map((f) => join17(dir, f));
|
|
2938
3654
|
}
|
|
2939
3655
|
function claudeHistory(repoDir, home) {
|
|
2940
|
-
const root =
|
|
3656
|
+
const root = join17(home, ".claude", "projects");
|
|
2941
3657
|
const exact = claudeProjectDir(repoDir, home);
|
|
2942
3658
|
const prefix = exact + "-";
|
|
2943
|
-
const dirs = listDir(root).map((d) =>
|
|
3659
|
+
const dirs = listDir(root).map((d) => join17(root, d)).filter((d) => d === exact || d.startsWith(prefix));
|
|
2944
3660
|
const sessions = [];
|
|
2945
3661
|
let unattributed = 0;
|
|
2946
3662
|
for (const file of dirs.flatMap(jsonlFiles)) {
|
|
@@ -2960,13 +3676,13 @@ function claudeHistory(repoDir, home) {
|
|
|
2960
3676
|
return { supported: true, sessions, unattributed };
|
|
2961
3677
|
}
|
|
2962
3678
|
function codexHistory(repoDir, home) {
|
|
2963
|
-
const root =
|
|
2964
|
-
if (!
|
|
3679
|
+
const root = join17(home, ".codex", "sessions");
|
|
3680
|
+
if (!existsSync9(root)) return { supported: true, sessions: [] };
|
|
2965
3681
|
const files = [];
|
|
2966
3682
|
const walk = (dir) => {
|
|
2967
|
-
for (const entry of
|
|
2968
|
-
const p =
|
|
2969
|
-
if (
|
|
3683
|
+
for (const entry of readdirSync3(dir)) {
|
|
3684
|
+
const p = join17(dir, entry);
|
|
3685
|
+
if (statSync4(p).isDirectory()) walk(p);
|
|
2970
3686
|
else if (entry.endsWith(".jsonl")) files.push(p);
|
|
2971
3687
|
}
|
|
2972
3688
|
};
|
|
@@ -2991,18 +3707,18 @@ function codexHistory(repoDir, home) {
|
|
|
2991
3707
|
}
|
|
2992
3708
|
var DCODE_THREADS_SCHEMA_VERSION = 1;
|
|
2993
3709
|
function dcodeTranscriptPath(root, threadId) {
|
|
2994
|
-
const digest =
|
|
3710
|
+
const digest = createHash5("sha256").update(threadId, "utf8").digest("hex");
|
|
2995
3711
|
const suffix = `--${digest}.jsonl`;
|
|
2996
3712
|
try {
|
|
2997
|
-
const match =
|
|
2998
|
-
return match ?
|
|
3713
|
+
const match = readdirSync3(root).find((entry) => entry.endsWith(suffix));
|
|
3714
|
+
return match ? join17(root, match) : void 0;
|
|
2999
3715
|
} catch {
|
|
3000
3716
|
return void 0;
|
|
3001
3717
|
}
|
|
3002
3718
|
}
|
|
3003
3719
|
function dcodeHistory(repoDir, home, runCli) {
|
|
3004
|
-
const root =
|
|
3005
|
-
if (!
|
|
3720
|
+
const root = join17(process.env.DEEPAGENTS_HOME || join17(home, ".deepagents"), "transcripts");
|
|
3721
|
+
if (!existsSync9(root)) return { supported: true, sessions: [] };
|
|
3006
3722
|
let listed;
|
|
3007
3723
|
try {
|
|
3008
3724
|
listed = JSON.parse(runCli(["threads", "list", "--json"]));
|
|
@@ -3042,8 +3758,8 @@ function dcodeHistory(repoDir, home, runCli) {
|
|
|
3042
3758
|
return { supported: true, sessions, ...unattributed ? { unattributed } : {} };
|
|
3043
3759
|
}
|
|
3044
3760
|
function dshHistory(repoDir, home) {
|
|
3045
|
-
const root = process.env.DSH_HOME ?
|
|
3046
|
-
if (!
|
|
3761
|
+
const root = process.env.DSH_HOME ? join17(process.env.DSH_HOME, "sessions") : join17(home, ".dsh", "sessions");
|
|
3762
|
+
if (!existsSync9(root)) return { supported: true, sessions: [] };
|
|
3047
3763
|
if (typeof zlib2.zstdDecompressSync !== "function") {
|
|
3048
3764
|
return {
|
|
3049
3765
|
supported: false,
|
|
@@ -3053,15 +3769,15 @@ function dshHistory(repoDir, home) {
|
|
|
3053
3769
|
}
|
|
3054
3770
|
const sessions = [];
|
|
3055
3771
|
let unattributed = 0;
|
|
3056
|
-
for (const dir of
|
|
3772
|
+
for (const dir of readdirSync3(root).map((project) => join17(root, project))) {
|
|
3057
3773
|
let sessionDirs;
|
|
3058
3774
|
try {
|
|
3059
|
-
sessionDirs =
|
|
3775
|
+
sessionDirs = readdirSync3(dir).map((id) => join17(dir, id));
|
|
3060
3776
|
} catch {
|
|
3061
3777
|
continue;
|
|
3062
3778
|
}
|
|
3063
3779
|
for (const sessionDir of sessionDirs) {
|
|
3064
|
-
const file = ["session.jsonl.zstd", "session.jsonl"].map((name) =>
|
|
3780
|
+
const file = ["session.jsonl.zstd", "session.jsonl"].map((name) => join17(sessionDir, name)).find((candidate) => existsSync9(candidate));
|
|
3065
3781
|
if (!file) continue;
|
|
3066
3782
|
try {
|
|
3067
3783
|
const lines = readDshLog(file);
|
|
@@ -3087,7 +3803,7 @@ function dshHistory(repoDir, home) {
|
|
|
3087
3803
|
return { supported: true, sessions, unattributed };
|
|
3088
3804
|
}
|
|
3089
3805
|
function readDshLog(file) {
|
|
3090
|
-
const bytes =
|
|
3806
|
+
const bytes = readFileSync13(file);
|
|
3091
3807
|
const text = file.endsWith(".zstd") ? zstdDecompressFrames(bytes) : bytes.toString("utf8");
|
|
3092
3808
|
return text.split("\n").filter((line) => line.trim());
|
|
3093
3809
|
}
|
|
@@ -3113,23 +3829,23 @@ function piFamilySessions(files, repoDir) {
|
|
|
3113
3829
|
return { supported: true, sessions, unattributed };
|
|
3114
3830
|
}
|
|
3115
3831
|
function piHistory(repoDir, home) {
|
|
3116
|
-
const root =
|
|
3117
|
-
if (!
|
|
3832
|
+
const root = join17(home, ".pi", "agent", "sessions");
|
|
3833
|
+
if (!existsSync9(root)) return { supported: true, sessions: [] };
|
|
3118
3834
|
const exact = piSessionDir(repoDir);
|
|
3119
3835
|
const nested = `${exact.slice(0, -2)}-`;
|
|
3120
3836
|
const files = [];
|
|
3121
3837
|
for (const dir of listDir(root).filter((d) => d === exact || d.startsWith(nested))) {
|
|
3122
|
-
files.push(...jsonlFiles(
|
|
3838
|
+
files.push(...jsonlFiles(join17(root, dir)));
|
|
3123
3839
|
}
|
|
3124
3840
|
return piFamilySessions(files, repoDir);
|
|
3125
3841
|
}
|
|
3126
3842
|
function primeAgentHistory(repoDir, home) {
|
|
3127
|
-
const root =
|
|
3128
|
-
if (!
|
|
3843
|
+
const root = join17(home, ".prime", "agent", "sessions");
|
|
3844
|
+
if (!existsSync9(root)) return { supported: true, sessions: [] };
|
|
3129
3845
|
return piFamilySessions(jsonlFiles(root), repoDir);
|
|
3130
3846
|
}
|
|
3131
3847
|
var SQLITE_HISTORY = "keeps session history in an internal SQLite database, whose schema is unversioned and would break on any upstream change";
|
|
3132
|
-
function importLocalHistory(harness, repoDir, home =
|
|
3848
|
+
function importLocalHistory(harness, repoDir, home = homedir9(), runDcodeCli) {
|
|
3133
3849
|
switch (harness) {
|
|
3134
3850
|
case "claude-code":
|
|
3135
3851
|
return claudeHistory(repoDir, home);
|
|
@@ -3167,59 +3883,6 @@ function importLocalHistory(harness, repoDir, home = homedir8(), runDcodeCli) {
|
|
|
3167
3883
|
}
|
|
3168
3884
|
}
|
|
3169
3885
|
|
|
3170
|
-
// src/core/legacy.ts
|
|
3171
|
-
import { existsSync as existsSync9, readFileSync as readFileSync13 } from "fs";
|
|
3172
|
-
import { homedir as homedir9 } from "os";
|
|
3173
|
-
import { join as join16 } from "path";
|
|
3174
|
-
var LEGACY_CONFIG_FILES = {
|
|
3175
|
-
"claude-code": "claude-code.json",
|
|
3176
|
-
codex: "codex.json"
|
|
3177
|
-
};
|
|
3178
|
-
function legacyConfigPath(harness, home = homedir9()) {
|
|
3179
|
-
return join16(home, ".hindsight", LEGACY_CONFIG_FILES[harness] ?? `${harness}.json`);
|
|
3180
|
-
}
|
|
3181
|
-
var CLOUD_URL = "https://api.hindsight.vectorize.io";
|
|
3182
|
-
function readLegacyEndpoint(home = homedir9(), prefer = []) {
|
|
3183
|
-
const order = [...prefer, ...Object.keys(LEGACY_CONFIG_FILES)].filter(
|
|
3184
|
-
(h, i, all) => h in LEGACY_CONFIG_FILES && all.indexOf(h) === i
|
|
3185
|
-
);
|
|
3186
|
-
for (const harness of order) {
|
|
3187
|
-
const found = readOne(harness, home);
|
|
3188
|
-
if (found) return found;
|
|
3189
|
-
}
|
|
3190
|
-
return void 0;
|
|
3191
|
-
}
|
|
3192
|
-
function readOne(harness, home) {
|
|
3193
|
-
const source = legacyConfigPath(harness, home);
|
|
3194
|
-
if (!existsSync9(source)) return void 0;
|
|
3195
|
-
let raw;
|
|
3196
|
-
try {
|
|
3197
|
-
raw = JSON.parse(readFileSync13(source, "utf8"));
|
|
3198
|
-
} catch {
|
|
3199
|
-
return void 0;
|
|
3200
|
-
}
|
|
3201
|
-
if (!raw || typeof raw !== "object") return void 0;
|
|
3202
|
-
const apiToken = typeof raw.hindsightApiToken === "string" ? raw.hindsightApiToken : void 0;
|
|
3203
|
-
const url = typeof raw.hindsightApiUrl === "string" ? raw.hindsightApiUrl.trim() : "";
|
|
3204
|
-
if (url) {
|
|
3205
|
-
return {
|
|
3206
|
-
harness,
|
|
3207
|
-
serverMode: url.replace(/\/+$/, "") === CLOUD_URL ? "cloud" : "self-hosted",
|
|
3208
|
-
apiUrl: url,
|
|
3209
|
-
...apiToken ? { apiToken } : {},
|
|
3210
|
-
source
|
|
3211
|
-
};
|
|
3212
|
-
}
|
|
3213
|
-
const port = typeof raw.apiPort === "number" ? raw.apiPort : void 0;
|
|
3214
|
-
return {
|
|
3215
|
-
harness,
|
|
3216
|
-
serverMode: "daemon",
|
|
3217
|
-
...apiToken ? { apiToken } : {},
|
|
3218
|
-
...port && port !== DEFAULT_DAEMON_PORT ? { apiPort: port } : {},
|
|
3219
|
-
source
|
|
3220
|
-
};
|
|
3221
|
-
}
|
|
3222
|
-
|
|
3223
3886
|
// src/install-ui.ts
|
|
3224
3887
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
3225
3888
|
import { readSync as readSync3 } from "fs";
|
|
@@ -3425,7 +4088,7 @@ function createInstallerUi(o) {
|
|
|
3425
4088
|
// src/installer.ts
|
|
3426
4089
|
var MARKER = "coding-agents";
|
|
3427
4090
|
var ZCODE_MAX_OUTPUT_BYTES = 32768;
|
|
3428
|
-
var zcodeConfigPath = (c) =>
|
|
4091
|
+
var zcodeConfigPath = (c) => join18(c.home, ".zcode", "cli", "config.json");
|
|
3429
4092
|
function readJson(path) {
|
|
3430
4093
|
try {
|
|
3431
4094
|
return JSON.parse(readFileSync14(path, "utf8"));
|
|
@@ -3443,9 +4106,9 @@ function parseJsonc(text) {
|
|
|
3443
4106
|
}
|
|
3444
4107
|
}
|
|
3445
4108
|
function writeJson(path, value) {
|
|
3446
|
-
|
|
4109
|
+
mkdirSync6(dirname11(path), { recursive: true });
|
|
3447
4110
|
backupOnce(path);
|
|
3448
|
-
|
|
4111
|
+
writeFileSync4(path, JSON.stringify(value, null, 2) + "\n");
|
|
3449
4112
|
}
|
|
3450
4113
|
function backupOnce(path) {
|
|
3451
4114
|
if (existsSync10(path) && !existsSync10(`${path}.hindsight-backup`)) {
|
|
@@ -3464,9 +4127,9 @@ function writeJsonc(path, key, value) {
|
|
|
3464
4127
|
}
|
|
3465
4128
|
});
|
|
3466
4129
|
const next = applyEdits(text, edits);
|
|
3467
|
-
|
|
4130
|
+
mkdirSync6(dirname11(path), { recursive: true });
|
|
3468
4131
|
backupOnce(path);
|
|
3469
|
-
|
|
4132
|
+
writeFileSync4(path, next.endsWith("\n") ? next : `${next}
|
|
3470
4133
|
`);
|
|
3471
4134
|
}
|
|
3472
4135
|
function mergeHookEvent(existing, entry) {
|
|
@@ -3481,14 +4144,14 @@ function setOrDelete(obj, key, arr) {
|
|
|
3481
4144
|
else delete obj[key];
|
|
3482
4145
|
}
|
|
3483
4146
|
var cmdHook = (dist, file, timeout) => ({
|
|
3484
|
-
hooks: [{ type: "command", command: `node "${
|
|
4147
|
+
hooks: [{ type: "command", command: `node "${join18(dist, file)}"`, timeout }]
|
|
3485
4148
|
});
|
|
3486
4149
|
var processHook = (dist, file, timeoutMs) => ({
|
|
3487
|
-
hooks: [{ type: "process", command: "node", args: [
|
|
4150
|
+
hooks: [{ type: "process", command: "node", args: [join18(dist, file)], timeoutMs }]
|
|
3488
4151
|
});
|
|
3489
4152
|
var mcpServerEntry = (dist, harness) => ({
|
|
3490
4153
|
command: "node",
|
|
3491
|
-
args: [
|
|
4154
|
+
args: [join18(dist, "mcp-server.js")],
|
|
3492
4155
|
env: { HINDSIGHT_MCP_HARNESS: harness }
|
|
3493
4156
|
});
|
|
3494
4157
|
function isOurMcpEntry(entry) {
|
|
@@ -3507,7 +4170,7 @@ function mergeHarnessHooks(hooks, harness, dist) {
|
|
|
3507
4170
|
if (installedEvents.has(hook.event)) continue;
|
|
3508
4171
|
installedEvents.add(hook.event);
|
|
3509
4172
|
const entry = spec.configStyle === "nested" ? cmdHook(dist, hook.entry, hook.timeout) : spec.configStyle === "process" ? processHook(dist, hook.entry, hook.timeout) : {
|
|
3510
|
-
command: `node "${
|
|
4173
|
+
command: `node "${join18(dist, hook.entry)}"`,
|
|
3511
4174
|
...hook.timeout ? { timeout: hook.timeout } : {}
|
|
3512
4175
|
};
|
|
3513
4176
|
hooks[hook.event] = mergeHookEvent(hooks[hook.event], entry);
|
|
@@ -3525,19 +4188,19 @@ function stripHarnessHooks(hooks, harness) {
|
|
|
3525
4188
|
function skillsBaseFor(c, harness) {
|
|
3526
4189
|
const parts = SKILL_DIRS[harness];
|
|
3527
4190
|
if (!parts) throw new Error(`${harness} installs a skill but names no directory in SKILL_DIRS`);
|
|
3528
|
-
return
|
|
4191
|
+
return join18(c.home, ...parts);
|
|
3529
4192
|
}
|
|
3530
4193
|
function installSkill(c, harness) {
|
|
3531
|
-
const src =
|
|
3532
|
-
if (!existsSync10(
|
|
4194
|
+
const src = join18(c.pkgRoot, "skill");
|
|
4195
|
+
if (!existsSync10(join18(src, "SKILL.md"))) return;
|
|
3533
4196
|
const skillsBase = skillsBaseFor(c, harness);
|
|
3534
|
-
const dst =
|
|
3535
|
-
|
|
4197
|
+
const dst = join18(skillsBase, "hindsight-coding-agent");
|
|
4198
|
+
mkdirSync6(skillsBase, { recursive: true });
|
|
3536
4199
|
cpSync2(src, dst, { recursive: true });
|
|
3537
4200
|
c.log?.(`${harness}: skill installed at ${dst}`);
|
|
3538
4201
|
}
|
|
3539
4202
|
function uninstallSkill(c, harness) {
|
|
3540
|
-
|
|
4203
|
+
rmSync3(join18(skillsBaseFor(c, harness), "hindsight-coding-agent"), {
|
|
3541
4204
|
recursive: true,
|
|
3542
4205
|
force: true
|
|
3543
4206
|
});
|
|
@@ -3560,9 +4223,9 @@ function runClinePlugin(args) {
|
|
|
3560
4223
|
}
|
|
3561
4224
|
var OPENCODE_CONFIG_CANDIDATES = ["opencode.jsonc", "opencode.json"];
|
|
3562
4225
|
function opencodeConfigPath(c) {
|
|
3563
|
-
const dir =
|
|
3564
|
-
const existing = OPENCODE_CONFIG_CANDIDATES.map((f) =>
|
|
3565
|
-
return existing ??
|
|
4226
|
+
const dir = join18(c.home, ".config", "opencode");
|
|
4227
|
+
const existing = OPENCODE_CONFIG_CANDIDATES.map((f) => join18(dir, f)).find((p) => existsSync10(p));
|
|
4228
|
+
return existing ?? join18(dir, "opencode.json");
|
|
3566
4229
|
}
|
|
3567
4230
|
function runDcodePlugin(args) {
|
|
3568
4231
|
try {
|
|
@@ -3598,7 +4261,7 @@ function unregisterOpencodePlugin(c, name) {
|
|
|
3598
4261
|
}
|
|
3599
4262
|
var opencode = {
|
|
3600
4263
|
name: "opencode",
|
|
3601
|
-
detect: (c) => onPath2("opencode") || existsSync10(
|
|
4264
|
+
detect: (c) => onPath2("opencode") || existsSync10(join18(c.home, ".config", "opencode")),
|
|
3602
4265
|
install: (c) => registerOpencodePlugin(c, "opencode"),
|
|
3603
4266
|
uninstall: (c) => unregisterOpencodePlugin(c, "opencode")
|
|
3604
4267
|
};
|
|
@@ -3609,16 +4272,16 @@ var opencode2 = {
|
|
|
3609
4272
|
uninstall: (c) => unregisterOpencodePlugin(c, "opencode2")
|
|
3610
4273
|
};
|
|
3611
4274
|
function piFamilyInstaller(harness, configDir) {
|
|
3612
|
-
const settings = (c) =>
|
|
4275
|
+
const settings = (c) => join18(c.home, ...configDir, "settings.json");
|
|
3613
4276
|
return {
|
|
3614
4277
|
name: harness,
|
|
3615
4278
|
// Both hosts name their executable exactly as we name the harness, so the harness id doubles
|
|
3616
4279
|
// as the PATH probe here — unlike, say, antigravity-cli, whose binary is `agy`.
|
|
3617
|
-
detect: (c) => onPath2(harness) || existsSync10(
|
|
4280
|
+
detect: (c) => onPath2(harness) || existsSync10(join18(c.home, ...configDir)),
|
|
3618
4281
|
install(c) {
|
|
3619
4282
|
const path = settings(c);
|
|
3620
4283
|
const cfg = readJson(path);
|
|
3621
|
-
const entry =
|
|
4284
|
+
const entry = join18(c.pkgRoot, "dist", `${harness}.js`);
|
|
3622
4285
|
const exts = Array.isArray(cfg.extensions) ? cfg.extensions : [];
|
|
3623
4286
|
cfg.extensions = [...exts.filter((p) => !String(p).includes(MARKER)), entry];
|
|
3624
4287
|
writeJson(path, cfg);
|
|
@@ -3643,13 +4306,13 @@ var pi = piFamilyInstaller("pi", [".pi", "agent"]);
|
|
|
3643
4306
|
var primeAgent = piFamilyInstaller("prime-agent", [".prime", "agent"]);
|
|
3644
4307
|
var KILO_CONFIG_CANDIDATES = ["kilo.jsonc", "kilo.json", "opencode.json"];
|
|
3645
4308
|
function kiloConfigPath(c) {
|
|
3646
|
-
const dir =
|
|
3647
|
-
const existing = KILO_CONFIG_CANDIDATES.map((f) =>
|
|
3648
|
-
return existing ??
|
|
4309
|
+
const dir = join18(c.home, ".config", "kilo");
|
|
4310
|
+
const existing = KILO_CONFIG_CANDIDATES.map((f) => join18(dir, f)).find((p) => existsSync10(p));
|
|
4311
|
+
return existing ?? join18(dir, "kilo.json");
|
|
3649
4312
|
}
|
|
3650
4313
|
var kilo = {
|
|
3651
4314
|
name: "kilo",
|
|
3652
|
-
detect: (c) => onPath2("kilo") || existsSync10(
|
|
4315
|
+
detect: (c) => onPath2("kilo") || existsSync10(join18(c.home, ".config", "kilo")),
|
|
3653
4316
|
install(c) {
|
|
3654
4317
|
const path = kiloConfigPath(c);
|
|
3655
4318
|
let cfg = {};
|
|
@@ -3661,7 +4324,7 @@ var kilo = {
|
|
|
3661
4324
|
}
|
|
3662
4325
|
cfg = parsed;
|
|
3663
4326
|
}
|
|
3664
|
-
const entry = pathToFileURL(
|
|
4327
|
+
const entry = pathToFileURL(join18(c.dist, "kilo.js")).href;
|
|
3665
4328
|
const plugins = Array.isArray(cfg.plugin) ? cfg.plugin : [];
|
|
3666
4329
|
writeJsonc(path, "plugin", [...plugins.filter((p) => !String(p).includes(MARKER)), entry]);
|
|
3667
4330
|
c.log?.(`kilo: plugin registered in ${path}`);
|
|
@@ -3678,9 +4341,9 @@ var kilo = {
|
|
|
3678
4341
|
};
|
|
3679
4342
|
var claudeCode = {
|
|
3680
4343
|
name: "claude-code",
|
|
3681
|
-
detect: (c) => onPath2("claude") || existsSync10(
|
|
4344
|
+
detect: (c) => onPath2("claude") || existsSync10(join18(c.home, ".claude")),
|
|
3682
4345
|
install(c) {
|
|
3683
|
-
const path =
|
|
4346
|
+
const path = join18(c.home, ".claude", "settings.json");
|
|
3684
4347
|
const settings = readJson(path);
|
|
3685
4348
|
settings.hooks = settings.hooks ?? {};
|
|
3686
4349
|
mergeHarnessHooks(settings.hooks, "claude-code", c.dist);
|
|
@@ -3699,18 +4362,18 @@ var claudeCode = {
|
|
|
3699
4362
|
"HINDSIGHT_MCP_HARNESS=claude-code",
|
|
3700
4363
|
"--",
|
|
3701
4364
|
"node",
|
|
3702
|
-
|
|
4365
|
+
join18(c.dist, "mcp-server.js")
|
|
3703
4366
|
])) {
|
|
3704
4367
|
c.log?.("claude-code: MCP server registered (claude mcp add, user scope)");
|
|
3705
4368
|
} else {
|
|
3706
4369
|
c.log?.(
|
|
3707
4370
|
`claude-code: could not run \`claude mcp add\` \u2014 register the tools manually:
|
|
3708
|
-
claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${
|
|
4371
|
+
claude mcp add --scope user hindsight --env HINDSIGHT_MCP_HARNESS=claude-code -- node "${join18(c.dist, "mcp-server.js")}"`
|
|
3709
4372
|
);
|
|
3710
4373
|
}
|
|
3711
4374
|
},
|
|
3712
4375
|
uninstall(c) {
|
|
3713
|
-
const path =
|
|
4376
|
+
const path = join18(c.home, ".claude", "settings.json");
|
|
3714
4377
|
if (existsSync10(path)) {
|
|
3715
4378
|
const settings = readJson(path);
|
|
3716
4379
|
if (settings.hooks) {
|
|
@@ -3736,19 +4399,19 @@ function defaultClaudeMcp(args) {
|
|
|
3736
4399
|
var CODEX_MCP_BLOCK_RE = /^\[mcp_servers\.hindsight(?:\.[^\]]+)?\][^\n]*\n(?:(?!\[)[^\n]*\n?)*/gm;
|
|
3737
4400
|
var codexMcpBlock = (dist) => `[mcp_servers.hindsight]
|
|
3738
4401
|
command = "node"
|
|
3739
|
-
args = [${JSON.stringify(
|
|
4402
|
+
args = [${JSON.stringify(join18(dist, "mcp-server.js"))}]
|
|
3740
4403
|
env = { HINDSIGHT_MCP_HARNESS = "codex" }`;
|
|
3741
4404
|
var codex = {
|
|
3742
4405
|
name: "codex",
|
|
3743
|
-
detect: (c) => onPath2("codex") || existsSync10(
|
|
4406
|
+
detect: (c) => onPath2("codex") || existsSync10(join18(c.home, ".codex")),
|
|
3744
4407
|
install(c) {
|
|
3745
|
-
const hooksPath =
|
|
4408
|
+
const hooksPath = join18(c.home, ".codex", "hooks.json");
|
|
3746
4409
|
const cfg = readJson(hooksPath);
|
|
3747
4410
|
cfg.hooks = cfg.hooks ?? {};
|
|
3748
4411
|
mergeHarnessHooks(cfg.hooks, "codex", c.dist);
|
|
3749
4412
|
writeJson(hooksPath, cfg);
|
|
3750
4413
|
c.log?.(`codex: hooks merged into ${hooksPath}`);
|
|
3751
|
-
const tomlPath =
|
|
4414
|
+
const tomlPath = join18(c.home, ".codex", "config.toml");
|
|
3752
4415
|
const existing = existsSync10(tomlPath) ? readFileSync14(tomlPath, "utf8") : "";
|
|
3753
4416
|
const toml = existing.replace(CODEX_MCP_BLOCK_RE, "");
|
|
3754
4417
|
const additions = [];
|
|
@@ -3768,14 +4431,14 @@ var codex = {
|
|
|
3768
4431
|
if (existsSync10(tomlPath) && !existsSync10(`${tomlPath}.hindsight-backup`)) {
|
|
3769
4432
|
copyFileSync(tomlPath, `${tomlPath}.hindsight-backup`);
|
|
3770
4433
|
}
|
|
3771
|
-
|
|
3772
|
-
|
|
4434
|
+
mkdirSync6(dirname11(tomlPath), { recursive: true });
|
|
4435
|
+
writeFileSync4(tomlPath, next);
|
|
3773
4436
|
c.log?.(`codex: wrote ${additions.length} section(s) to ${tomlPath}`);
|
|
3774
4437
|
}
|
|
3775
4438
|
installSkill(c, "codex");
|
|
3776
4439
|
},
|
|
3777
4440
|
uninstall(c) {
|
|
3778
|
-
const hooksPath =
|
|
4441
|
+
const hooksPath = join18(c.home, ".codex", "hooks.json");
|
|
3779
4442
|
if (existsSync10(hooksPath)) {
|
|
3780
4443
|
const cfg = readJson(hooksPath);
|
|
3781
4444
|
if (cfg.hooks) {
|
|
@@ -3784,11 +4447,11 @@ var codex = {
|
|
|
3784
4447
|
}
|
|
3785
4448
|
}
|
|
3786
4449
|
uninstallSkill(c, "codex");
|
|
3787
|
-
const tomlPath =
|
|
4450
|
+
const tomlPath = join18(c.home, ".codex", "config.toml");
|
|
3788
4451
|
if (existsSync10(tomlPath)) {
|
|
3789
4452
|
const toml = readFileSync14(tomlPath, "utf8");
|
|
3790
4453
|
const cleaned = toml.replace(CODEX_MCP_BLOCK_RE, "");
|
|
3791
|
-
if (cleaned !== toml)
|
|
4454
|
+
if (cleaned !== toml) writeFileSync4(tomlPath, cleaned);
|
|
3792
4455
|
}
|
|
3793
4456
|
c.log?.(
|
|
3794
4457
|
"codex: hooks + MCP section + skill removed ([features] hooks flag left as-is \u2014 other hooks may use it)"
|
|
@@ -3802,7 +4465,7 @@ var antigravity = {
|
|
|
3802
4465
|
// can consume this integration.
|
|
3803
4466
|
detect: (c) => onPath2("agy"),
|
|
3804
4467
|
install(c) {
|
|
3805
|
-
const hooksPath =
|
|
4468
|
+
const hooksPath = join18(c.home, ".gemini", "config", "hooks.json");
|
|
3806
4469
|
const hooks = readJson(hooksPath);
|
|
3807
4470
|
for (const key of Object.keys(hooks)) {
|
|
3808
4471
|
if (key !== MARKER && key.includes(MARKER)) delete hooks[key];
|
|
@@ -3813,26 +4476,26 @@ var antigravity = {
|
|
|
3813
4476
|
setOrDelete(hooks, event, stripOurs(hooks[event]));
|
|
3814
4477
|
}
|
|
3815
4478
|
writeJson(hooksPath, hooks);
|
|
3816
|
-
const mcpPath =
|
|
4479
|
+
const mcpPath = join18(c.home, ".gemini", "config", "mcp_config.json");
|
|
3817
4480
|
const mcp = readJson(mcpPath);
|
|
3818
4481
|
mcp.mcpServers = {
|
|
3819
4482
|
...mcp.mcpServers ?? {},
|
|
3820
4483
|
hindsight: mcpServerEntry(c.dist, "antigravity-cli")
|
|
3821
4484
|
};
|
|
3822
4485
|
writeJson(mcpPath, mcp);
|
|
3823
|
-
const settingsPath =
|
|
4486
|
+
const settingsPath = join18(c.home, ".gemini", "antigravity-cli", "settings.json");
|
|
3824
4487
|
const settings = readJson(settingsPath);
|
|
3825
4488
|
if (!settings.statusLine) {
|
|
3826
4489
|
settings.statusLine = {
|
|
3827
4490
|
type: "command",
|
|
3828
|
-
command: `node "${
|
|
4491
|
+
command: `node "${join18(c.dist, "antigravity-statusline.js")}"`
|
|
3829
4492
|
};
|
|
3830
4493
|
writeJson(settingsPath, settings);
|
|
3831
4494
|
c.log?.(`antigravity-cli: Hindsight status line enabled in ${settingsPath}`);
|
|
3832
4495
|
} else if (JSON.stringify(settings.statusLine).includes(MARKER)) {
|
|
3833
4496
|
settings.statusLine = {
|
|
3834
4497
|
type: "command",
|
|
3835
|
-
command: `node "${
|
|
4498
|
+
command: `node "${join18(c.dist, "antigravity-statusline.js")}"`
|
|
3836
4499
|
};
|
|
3837
4500
|
writeJson(settingsPath, settings);
|
|
3838
4501
|
} else {
|
|
@@ -3844,7 +4507,7 @@ var antigravity = {
|
|
|
3844
4507
|
installSkill(c, "antigravity-cli");
|
|
3845
4508
|
},
|
|
3846
4509
|
uninstall(c) {
|
|
3847
|
-
const hooksPath =
|
|
4510
|
+
const hooksPath = join18(c.home, ".gemini", "config", "hooks.json");
|
|
3848
4511
|
if (existsSync10(hooksPath)) {
|
|
3849
4512
|
const hooks = readJson(hooksPath);
|
|
3850
4513
|
if (hooks[MARKER]) {
|
|
@@ -3856,7 +4519,7 @@ var antigravity = {
|
|
|
3856
4519
|
}
|
|
3857
4520
|
writeJson(hooksPath, hooks);
|
|
3858
4521
|
}
|
|
3859
|
-
const mcpPath =
|
|
4522
|
+
const mcpPath = join18(c.home, ".gemini", "config", "mcp_config.json");
|
|
3860
4523
|
if (existsSync10(mcpPath)) {
|
|
3861
4524
|
const mcp = readJson(mcpPath);
|
|
3862
4525
|
if (mcp.mcpServers?.hindsight) {
|
|
@@ -3864,7 +4527,7 @@ var antigravity = {
|
|
|
3864
4527
|
writeJson(mcpPath, mcp);
|
|
3865
4528
|
}
|
|
3866
4529
|
}
|
|
3867
|
-
const settingsPath =
|
|
4530
|
+
const settingsPath = join18(c.home, ".gemini", "antigravity-cli", "settings.json");
|
|
3868
4531
|
if (existsSync10(settingsPath)) {
|
|
3869
4532
|
const settings = readJson(settingsPath);
|
|
3870
4533
|
if (JSON.stringify(settings.statusLine ?? {}).includes(MARKER)) {
|
|
@@ -3892,7 +4555,7 @@ function pathNodeVersion() {
|
|
|
3892
4555
|
}
|
|
3893
4556
|
}
|
|
3894
4557
|
function runtimeDir(home) {
|
|
3895
|
-
return
|
|
4558
|
+
return join18(home, ".hindsight", "coding-agents");
|
|
3896
4559
|
}
|
|
3897
4560
|
var ORIGIN_FILE = ".install-origin.json";
|
|
3898
4561
|
function stageRuntime(c) {
|
|
@@ -3905,25 +4568,25 @@ function stageRuntime(c) {
|
|
|
3905
4568
|
}
|
|
3906
4569
|
};
|
|
3907
4570
|
if (same(c.pkgRoot, target)) return c;
|
|
3908
|
-
if (!existsSync10(
|
|
4571
|
+
if (!existsSync10(join18(c.dist, "installer.js"))) return c;
|
|
3909
4572
|
try {
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
cpSync2(c.dist,
|
|
3913
|
-
const skill =
|
|
3914
|
-
if (existsSync10(skill)) cpSync2(skill,
|
|
3915
|
-
const pkgJson =
|
|
3916
|
-
if (existsSync10(pkgJson)) copyFileSync(pkgJson,
|
|
4573
|
+
rmSync3(join18(target, "dist"), { recursive: true, force: true });
|
|
4574
|
+
mkdirSync6(target, { recursive: true });
|
|
4575
|
+
cpSync2(c.dist, join18(target, "dist"), { recursive: true });
|
|
4576
|
+
const skill = join18(c.pkgRoot, "skill");
|
|
4577
|
+
if (existsSync10(skill)) cpSync2(skill, join18(target, "skill"), { recursive: true });
|
|
4578
|
+
const pkgJson = join18(c.pkgRoot, "package.json");
|
|
4579
|
+
if (existsSync10(pkgJson)) copyFileSync(pkgJson, join18(target, "package.json"));
|
|
3917
4580
|
for (const resource of ["plugin.json", "hooks", "index.js"]) {
|
|
3918
|
-
const source =
|
|
3919
|
-
if (existsSync10(source)) cpSync2(source,
|
|
4581
|
+
const source = join18(c.pkgRoot, resource);
|
|
4582
|
+
if (existsSync10(source)) cpSync2(source, join18(target, resource), { recursive: true });
|
|
3920
4583
|
}
|
|
3921
|
-
|
|
3922
|
-
|
|
4584
|
+
writeFileSync4(
|
|
4585
|
+
join18(target, ORIGIN_FILE),
|
|
3923
4586
|
JSON.stringify({ source: c.pkgRoot, stagedAt: (/* @__PURE__ */ new Date()).toISOString() })
|
|
3924
4587
|
);
|
|
3925
4588
|
c.log?.(`runtime staged at ${target}`);
|
|
3926
|
-
return { ...c, pkgRoot: target, dist:
|
|
4589
|
+
return { ...c, pkgRoot: target, dist: join18(target, "dist") };
|
|
3927
4590
|
} catch (error) {
|
|
3928
4591
|
c.log?.(`could not stage the runtime at ${target}: ${String(error)}`);
|
|
3929
4592
|
return c;
|
|
@@ -4001,7 +4664,7 @@ function configureServer(c, args, installing) {
|
|
|
4001
4664
|
c.log?.(`unknown --server "${explicit}" \u2014 expected one of: ${SERVER_MODES.join(", ")}`);
|
|
4002
4665
|
return false;
|
|
4003
4666
|
}
|
|
4004
|
-
const configPath = process.env.HINDSIGHT_CONFIG ||
|
|
4667
|
+
const configPath = process.env.HINDSIGHT_CONFIG || join18(c.home, ...CONFIG_RELATIVE);
|
|
4005
4668
|
const existing = readJson(configPath);
|
|
4006
4669
|
const alreadyConfigured = !!(existing.serverMode || existing.apiUrl);
|
|
4007
4670
|
let mode = explicit;
|
|
@@ -4097,7 +4760,7 @@ function reportDaemonPrereqs(c) {
|
|
|
4097
4760
|
}
|
|
4098
4761
|
var devin = {
|
|
4099
4762
|
name: "devin-cli",
|
|
4100
|
-
detect: (c) => onPath2("devin") || existsSync10(
|
|
4763
|
+
detect: (c) => onPath2("devin") || existsSync10(join18(c.home, ".config", "devin")),
|
|
4101
4764
|
// Devin is the ONLY harness whose hooks never hand over a transcript: they carry a session id and
|
|
4102
4765
|
// nothing else, so retain can only work by reading the CLI's own sessions.db. That makes SQLite
|
|
4103
4766
|
// support a hard prerequisite here — and one worth checking now, because the alternative is an
|
|
@@ -4110,12 +4773,12 @@ var devin = {
|
|
|
4110
4773
|
Upgrade to Node 22.5 or newer (24 LTS recommended) and re-run this command.`;
|
|
4111
4774
|
},
|
|
4112
4775
|
install(c) {
|
|
4113
|
-
const configPath =
|
|
4776
|
+
const configPath = join18(c.home, ".config", "devin", "config.json");
|
|
4114
4777
|
const config = readJson(configPath);
|
|
4115
4778
|
config.hooks = config.hooks ?? {};
|
|
4116
4779
|
mergeHarnessHooks(config.hooks, "devin-cli", c.dist);
|
|
4117
4780
|
writeJson(configPath, config);
|
|
4118
|
-
const mcpPath =
|
|
4781
|
+
const mcpPath = join18(c.home, ".config", "devin", "mcp_config.json");
|
|
4119
4782
|
const mcp = readJson(mcpPath);
|
|
4120
4783
|
mcp.mcpServers = {
|
|
4121
4784
|
...mcp.mcpServers ?? {},
|
|
@@ -4125,7 +4788,7 @@ var devin = {
|
|
|
4125
4788
|
c.log?.(`devin-cli: hooks merged into ${configPath}, MCP into ${mcpPath}`);
|
|
4126
4789
|
},
|
|
4127
4790
|
uninstall(c) {
|
|
4128
|
-
const configPath =
|
|
4791
|
+
const configPath = join18(c.home, ".config", "devin", "config.json");
|
|
4129
4792
|
if (existsSync10(configPath)) {
|
|
4130
4793
|
const config = readJson(configPath);
|
|
4131
4794
|
if (config.hooks) {
|
|
@@ -4134,7 +4797,7 @@ var devin = {
|
|
|
4134
4797
|
writeJson(configPath, config);
|
|
4135
4798
|
}
|
|
4136
4799
|
}
|
|
4137
|
-
const mcpPath =
|
|
4800
|
+
const mcpPath = join18(c.home, ".config", "devin", "mcp_config.json");
|
|
4138
4801
|
if (existsSync10(mcpPath)) {
|
|
4139
4802
|
const mcp = readJson(mcpPath);
|
|
4140
4803
|
if (mcp.mcpServers?.hindsight) {
|
|
@@ -4147,14 +4810,14 @@ var devin = {
|
|
|
4147
4810
|
};
|
|
4148
4811
|
var cursor = {
|
|
4149
4812
|
name: "cursor-cli",
|
|
4150
|
-
detect: (c) => onPath2("cursor-agent") || existsSync10(
|
|
4813
|
+
detect: (c) => onPath2("cursor-agent") || existsSync10(join18(c.home, ".cursor")),
|
|
4151
4814
|
install(c) {
|
|
4152
|
-
const hooksPath =
|
|
4815
|
+
const hooksPath = join18(c.home, ".cursor", "hooks.json");
|
|
4153
4816
|
const cfg = readJson(hooksPath);
|
|
4154
4817
|
cfg.hooks = cfg.hooks ?? {};
|
|
4155
4818
|
mergeHarnessHooks(cfg.hooks, "cursor-cli", c.dist);
|
|
4156
4819
|
writeJson(hooksPath, cfg);
|
|
4157
|
-
const mcpPath =
|
|
4820
|
+
const mcpPath = join18(c.home, ".cursor", "mcp.json");
|
|
4158
4821
|
const mcp = readJson(mcpPath);
|
|
4159
4822
|
mcp.mcpServers = {
|
|
4160
4823
|
...mcp.mcpServers ?? {},
|
|
@@ -4165,7 +4828,7 @@ var cursor = {
|
|
|
4165
4828
|
installSkill(c, "cursor-cli");
|
|
4166
4829
|
},
|
|
4167
4830
|
uninstall(c) {
|
|
4168
|
-
const hooksPath =
|
|
4831
|
+
const hooksPath = join18(c.home, ".cursor", "hooks.json");
|
|
4169
4832
|
if (existsSync10(hooksPath)) {
|
|
4170
4833
|
const cfg = readJson(hooksPath);
|
|
4171
4834
|
if (cfg.hooks) {
|
|
@@ -4174,7 +4837,7 @@ var cursor = {
|
|
|
4174
4837
|
writeJson(hooksPath, cfg);
|
|
4175
4838
|
}
|
|
4176
4839
|
}
|
|
4177
|
-
const mcpPath =
|
|
4840
|
+
const mcpPath = join18(c.home, ".cursor", "mcp.json");
|
|
4178
4841
|
if (existsSync10(mcpPath)) {
|
|
4179
4842
|
const mcp = readJson(mcpPath);
|
|
4180
4843
|
if (mcp.mcpServers?.hindsight) {
|
|
@@ -4188,13 +4851,13 @@ var cursor = {
|
|
|
4188
4851
|
};
|
|
4189
4852
|
var copilot = {
|
|
4190
4853
|
name: "copilot-cli",
|
|
4191
|
-
detect: (c) => onPath2("copilot") || existsSync10(
|
|
4854
|
+
detect: (c) => onPath2("copilot") || existsSync10(join18(c.home, ".copilot")),
|
|
4192
4855
|
install(c) {
|
|
4193
|
-
const hooksPath =
|
|
4856
|
+
const hooksPath = join18(c.home, ".copilot", "hooks", "hindsight-coding-agents.json");
|
|
4194
4857
|
const hooks = {};
|
|
4195
4858
|
mergeHarnessHooks(hooks, "copilot-cli", c.dist);
|
|
4196
4859
|
writeJson(hooksPath, { version: 1, hooks });
|
|
4197
|
-
const mcpPath =
|
|
4860
|
+
const mcpPath = join18(c.home, ".copilot", "mcp-config.json");
|
|
4198
4861
|
const mcp = readJson(mcpPath);
|
|
4199
4862
|
mcp.mcpServers = {
|
|
4200
4863
|
...mcp.mcpServers ?? {},
|
|
@@ -4205,10 +4868,10 @@ var copilot = {
|
|
|
4205
4868
|
c.log?.(`copilot-cli: hooks installed at ${hooksPath}, MCP into ${mcpPath}`);
|
|
4206
4869
|
},
|
|
4207
4870
|
uninstall(c) {
|
|
4208
|
-
|
|
4871
|
+
rmSync3(join18(c.home, ".copilot", "hooks", "hindsight-coding-agents.json"), {
|
|
4209
4872
|
force: true
|
|
4210
4873
|
});
|
|
4211
|
-
const mcpPath =
|
|
4874
|
+
const mcpPath = join18(c.home, ".copilot", "mcp-config.json");
|
|
4212
4875
|
if (existsSync10(mcpPath)) {
|
|
4213
4876
|
const mcp = readJson(mcpPath);
|
|
4214
4877
|
if (mcp.mcpServers?.hindsight) {
|
|
@@ -4222,15 +4885,66 @@ var copilot = {
|
|
|
4222
4885
|
};
|
|
4223
4886
|
var GROK_MARKER_START = "# HINDSIGHT_CODING_AGENTS_GROK_START";
|
|
4224
4887
|
var GROK_MARKER_END = "# HINDSIGHT_CODING_AGENTS_GROK_END";
|
|
4225
|
-
var GROK_BLOCK_RE = new RegExp(`\\n?${GROK_MARKER_START}[\\s\\S]*?${GROK_MARKER_END}\\n
|
|
4888
|
+
var GROK_BLOCK_RE = new RegExp(`\\n?${GROK_MARKER_START}[\\s\\S]*?${GROK_MARKER_END}\\n?`, "g");
|
|
4889
|
+
var GROK_HOOK_SCRIPT_RE = /(grok-(?:sessionstart-|stop-)?hook\.js|hindsight-coding-agents)/;
|
|
4890
|
+
function parseGrokToml(text) {
|
|
4891
|
+
try {
|
|
4892
|
+
return parse2(text);
|
|
4893
|
+
} catch {
|
|
4894
|
+
return null;
|
|
4895
|
+
}
|
|
4896
|
+
}
|
|
4897
|
+
function hasUnmarkedGrokEntries(text) {
|
|
4898
|
+
const cfg = parseGrokToml(text);
|
|
4899
|
+
if (!cfg)
|
|
4900
|
+
return /\[\s*mcp_servers\s*\.\s*hindsight\s*[.\]]/.test(text) || GROK_HOOK_SCRIPT_RE.test(text);
|
|
4901
|
+
if (cfg.mcp_servers && "hindsight" in cfg.mcp_servers) return true;
|
|
4902
|
+
return Object.values(cfg.hooks ?? {}).some(
|
|
4903
|
+
(entries) => (entries ?? []).some(
|
|
4904
|
+
(entry) => (entry?.hooks ?? []).some(
|
|
4905
|
+
(h) => typeof h?.command === "string" && GROK_HOOK_SCRIPT_RE.test(h.command)
|
|
4906
|
+
)
|
|
4907
|
+
)
|
|
4908
|
+
);
|
|
4909
|
+
}
|
|
4910
|
+
function stripUnmarkedGrokEntries(toml) {
|
|
4911
|
+
const lines = toml.split("\n");
|
|
4912
|
+
const sections = [{ header: "", lines: [] }];
|
|
4913
|
+
for (const line of lines) {
|
|
4914
|
+
if (/^\s*\[/.test(line)) sections.push({ header: line.trim(), lines: [line] });
|
|
4915
|
+
else sections[sections.length - 1].lines.push(line);
|
|
4916
|
+
}
|
|
4917
|
+
const isOurs = (s) => s.lines.some((l) => /^\s*(command|args)\s*=/.test(l) && GROK_HOOK_SCRIPT_RE.test(l));
|
|
4918
|
+
const hasKeys = (s) => s.lines.slice(1).some((l) => /^\s*[^#\s]/.test(l));
|
|
4919
|
+
const drop = sections.map((s) => {
|
|
4920
|
+
if (/^\[mcp_servers\.hindsight(\.|\])/.test(s.header)) return true;
|
|
4921
|
+
if (/^\[\[hooks\..+\.hooks\]\]$/.test(s.header)) return isOurs(s);
|
|
4922
|
+
return false;
|
|
4923
|
+
});
|
|
4924
|
+
for (let i = 0; i < sections.length; i++) {
|
|
4925
|
+
if (!/^\[\[hooks\.[^.\]]+\]\]$/.test(sections[i].header) || hasKeys(sections[i])) continue;
|
|
4926
|
+
let j = i + 1;
|
|
4927
|
+
let sawChild = false;
|
|
4928
|
+
while (j < sections.length && /^\[\[hooks\..+\.hooks\]\]$/.test(sections[j].header)) {
|
|
4929
|
+
if (!drop[j]) break;
|
|
4930
|
+
sawChild = true;
|
|
4931
|
+
j++;
|
|
4932
|
+
}
|
|
4933
|
+
const childrenAllDropped = sawChild && (j >= sections.length || !/^\[\[hooks\..+\.hooks\]\]$/.test(sections[j].header));
|
|
4934
|
+
if (childrenAllDropped) drop[i] = true;
|
|
4935
|
+
}
|
|
4936
|
+
if (!drop.some(Boolean)) return toml;
|
|
4937
|
+
return sections.filter((_, i) => !drop[i]).map((s) => s.lines.join("\n")).join("\n").replace(/\n{3,}/g, "\n\n");
|
|
4938
|
+
}
|
|
4226
4939
|
var grok = {
|
|
4227
4940
|
name: "grok-build",
|
|
4228
|
-
detect: (c) => onPath2("grok") || existsSync10(
|
|
4941
|
+
detect: (c) => onPath2("grok") || existsSync10(join18(c.home, ".grok")),
|
|
4229
4942
|
install(c) {
|
|
4230
|
-
const path =
|
|
4943
|
+
const path = join18(c.home, ".grok", "config.toml");
|
|
4231
4944
|
const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
|
|
4232
|
-
const
|
|
4233
|
-
const
|
|
4945
|
+
const stripped = existing.replace(GROK_BLOCK_RE, "\n");
|
|
4946
|
+
const withoutOurs = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
|
|
4947
|
+
const command = (entry) => JSON.stringify(`node "${join18(c.dist, entry)}"`);
|
|
4234
4948
|
const tomlString = (value) => JSON.stringify(value);
|
|
4235
4949
|
const block = `
|
|
4236
4950
|
${GROK_MARKER_START}
|
|
@@ -4254,23 +4968,32 @@ ${GROK_MARKER_START}
|
|
|
4254
4968
|
|
|
4255
4969
|
[mcp_servers.hindsight]
|
|
4256
4970
|
command = "node"
|
|
4257
|
-
args = [${tomlString(
|
|
4971
|
+
args = [${tomlString(join18(c.dist, "mcp-server.js"))}]
|
|
4258
4972
|
env = { HINDSIGHT_MCP_HARNESS = "grok-build" }
|
|
4259
4973
|
${GROK_MARKER_END}
|
|
4260
4974
|
`;
|
|
4975
|
+
const next = `${withoutOurs.replace(/\n*$/, "\n")}${block}`;
|
|
4976
|
+
if (parseGrokToml(next) === null) {
|
|
4977
|
+
c.log?.(
|
|
4978
|
+
`grok-build: refusing to write ${path} \u2014 the result would not be valid TOML. Remove the Hindsight hooks and [mcp_servers.hindsight] from it by hand, then re-run install.`
|
|
4979
|
+
);
|
|
4980
|
+
return false;
|
|
4981
|
+
}
|
|
4261
4982
|
if (existsSync10(path) && !existsSync10(`${path}.hindsight-backup`))
|
|
4262
4983
|
copyFileSync(path, `${path}.hindsight-backup`);
|
|
4263
|
-
|
|
4264
|
-
|
|
4984
|
+
mkdirSync6(dirname11(path), { recursive: true });
|
|
4985
|
+
writeFileSync4(path, next);
|
|
4265
4986
|
installSkill(c, "grok-build");
|
|
4266
4987
|
c.log?.(`grok-build: native hooks + MCP installed in ${path}`);
|
|
4267
4988
|
},
|
|
4268
4989
|
uninstall(c) {
|
|
4269
|
-
const path =
|
|
4990
|
+
const path = join18(c.home, ".grok", "config.toml");
|
|
4270
4991
|
if (existsSync10(path)) {
|
|
4271
4992
|
const existing = readFileSync14(path, "utf8");
|
|
4272
|
-
const
|
|
4273
|
-
|
|
4993
|
+
const stripped = existing.replace(GROK_BLOCK_RE, "\n");
|
|
4994
|
+
const cleaned = hasUnmarkedGrokEntries(stripped) ? stripUnmarkedGrokEntries(stripped) : stripped;
|
|
4995
|
+
const safe = parseGrokToml(cleaned) !== null || parseGrokToml(existing) === null;
|
|
4996
|
+
if (cleaned !== existing && safe) writeFileSync4(path, cleaned);
|
|
4274
4997
|
}
|
|
4275
4998
|
uninstallSkill(c, "grok-build");
|
|
4276
4999
|
c.log?.("grok-build: native hooks + MCP + skill removed");
|
|
@@ -4280,17 +5003,17 @@ var CLINE_HOOK_MARKER = "HINDSIGHT_CODING_AGENTS_CLINE";
|
|
|
4280
5003
|
var CLINE_OLD_HOOK_EVENTS = ["TaskStart", "UserPromptSubmit", "TaskComplete"];
|
|
4281
5004
|
var CLINE_PLUGIN_NAME = "@vectorize-io/hindsight-coding-agents";
|
|
4282
5005
|
function removeLegacyClineHooks(c) {
|
|
4283
|
-
const hooksDir =
|
|
5006
|
+
const hooksDir = join18(c.home, "Documents", "Cline", "Hooks");
|
|
4284
5007
|
for (const event of CLINE_OLD_HOOK_EVENTS) {
|
|
4285
|
-
const path =
|
|
5008
|
+
const path = join18(hooksDir, event);
|
|
4286
5009
|
if (existsSync10(path) && readFileSync14(path, "utf8").includes(CLINE_HOOK_MARKER)) {
|
|
4287
|
-
|
|
5010
|
+
rmSync3(path, { force: true });
|
|
4288
5011
|
}
|
|
4289
5012
|
}
|
|
4290
5013
|
}
|
|
4291
5014
|
var cline = {
|
|
4292
5015
|
name: "cline-cli",
|
|
4293
|
-
detect: (c) => onPath2("cline") || existsSync10(
|
|
5016
|
+
detect: (c) => onPath2("cline") || existsSync10(join18(c.home, ".cline")),
|
|
4294
5017
|
install(c) {
|
|
4295
5018
|
removeLegacyClineHooks(c);
|
|
4296
5019
|
const installed = (c.clinePlugin ?? runClinePlugin)([
|
|
@@ -4299,7 +5022,7 @@ var cline = {
|
|
|
4299
5022
|
"--force",
|
|
4300
5023
|
c.pkgRoot
|
|
4301
5024
|
]);
|
|
4302
|
-
const mcpPath =
|
|
5025
|
+
const mcpPath = join18(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
|
|
4303
5026
|
const mcp = readJson(mcpPath);
|
|
4304
5027
|
mcp.mcpServers = {
|
|
4305
5028
|
...mcp.mcpServers ?? {},
|
|
@@ -4314,7 +5037,7 @@ var cline = {
|
|
|
4314
5037
|
uninstall(c) {
|
|
4315
5038
|
removeLegacyClineHooks(c);
|
|
4316
5039
|
(c.clinePlugin ?? runClinePlugin)(["plugin", "uninstall", CLINE_PLUGIN_NAME]);
|
|
4317
|
-
const mcpPath =
|
|
5040
|
+
const mcpPath = join18(c.home, ".cline", "data", "settings", "cline_mcp_settings.json");
|
|
4318
5041
|
if (existsSync10(mcpPath)) {
|
|
4319
5042
|
const mcp = readJson(mcpPath);
|
|
4320
5043
|
if (mcp.mcpServers?.hindsight) {
|
|
@@ -4328,11 +5051,11 @@ var cline = {
|
|
|
4328
5051
|
};
|
|
4329
5052
|
var DCODE_MARKETPLACE = "hindsight-coding-agents";
|
|
4330
5053
|
var DCODE_PLUGIN_ID = "hindsight-coding-agents@hindsight-coding-agents";
|
|
4331
|
-
var DCODE_MARKETPLACE_RELATIVE_PATH =
|
|
5054
|
+
var DCODE_MARKETPLACE_RELATIVE_PATH = join18(".agents", "plugins", "marketplace.json");
|
|
4332
5055
|
var DCODE_FALLBACK_MARKETPLACE = "hindsight-coding-agents-marketplace.json";
|
|
4333
5056
|
function prepareDcodeMarketplace(c) {
|
|
4334
|
-
const root =
|
|
4335
|
-
const conventionalPath =
|
|
5057
|
+
const root = join18(c.home, ".hindsight");
|
|
5058
|
+
const conventionalPath = join18(root, DCODE_MARKETPLACE_RELATIVE_PATH);
|
|
4336
5059
|
let path = conventionalPath;
|
|
4337
5060
|
let registrationSource = root;
|
|
4338
5061
|
let marketplace = { plugins: [] };
|
|
@@ -4340,14 +5063,14 @@ function prepareDcodeMarketplace(c) {
|
|
|
4340
5063
|
try {
|
|
4341
5064
|
const parsed = JSON.parse(readFileSync14(conventionalPath, "utf8"));
|
|
4342
5065
|
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.plugins)) {
|
|
4343
|
-
path =
|
|
5066
|
+
path = join18(root, DCODE_FALLBACK_MARKETPLACE);
|
|
4344
5067
|
} else if (typeof parsed.name === "string" && parsed.name !== DCODE_MARKETPLACE) {
|
|
4345
|
-
path =
|
|
5068
|
+
path = join18(root, DCODE_FALLBACK_MARKETPLACE);
|
|
4346
5069
|
} else {
|
|
4347
5070
|
marketplace = parsed;
|
|
4348
5071
|
}
|
|
4349
5072
|
} catch {
|
|
4350
|
-
path =
|
|
5073
|
+
path = join18(root, DCODE_FALLBACK_MARKETPLACE);
|
|
4351
5074
|
}
|
|
4352
5075
|
}
|
|
4353
5076
|
if (path !== conventionalPath && existsSync10(path)) {
|
|
@@ -4380,7 +5103,7 @@ function prepareDcodeMarketplace(c) {
|
|
|
4380
5103
|
}
|
|
4381
5104
|
var dcode = {
|
|
4382
5105
|
name: "dcode",
|
|
4383
|
-
detect: (c) => onPath2("dcode") || existsSync10(
|
|
5106
|
+
detect: (c) => onPath2("dcode") || existsSync10(join18(c.home, ".deepagents")),
|
|
4384
5107
|
preflight: (c) => c.dcodePlugin || onPath2("dcode") ? void 0 : "the `dcode` CLI is not on PATH",
|
|
4385
5108
|
install(c) {
|
|
4386
5109
|
const plugin = c.dcodePlugin ?? runDcodePlugin;
|
|
@@ -4389,7 +5112,7 @@ var dcode = {
|
|
|
4389
5112
|
if (installed) {
|
|
4390
5113
|
c.log?.(`dcode: native Agent Plugin installed (${DCODE_PLUGIN_ID})`);
|
|
4391
5114
|
} else {
|
|
4392
|
-
const source = marketplacePath === false ?
|
|
5115
|
+
const source = marketplacePath === false ? join18(c.home, ".hindsight") : marketplacePath;
|
|
4393
5116
|
c.log?.(
|
|
4394
5117
|
`dcode: could not install the native plugin \u2014 run dcode plugin marketplace add "${source}" && dcode plugin install ${DCODE_PLUGIN_ID}`
|
|
4395
5118
|
);
|
|
@@ -4417,16 +5140,16 @@ var DSH_MARKER_START = "# HINDSIGHT_CODING_AGENTS_DSH_START";
|
|
|
4417
5140
|
var DSH_MARKER_END = "# HINDSIGHT_CODING_AGENTS_DSH_END";
|
|
4418
5141
|
var DSH_BLOCK_RE = new RegExp(`\\n?${DSH_MARKER_START}[\\s\\S]*?${DSH_MARKER_END}\\n?`);
|
|
4419
5142
|
function dshHome(c) {
|
|
4420
|
-
return process.env.DSH_HOME ||
|
|
5143
|
+
return process.env.DSH_HOME || join18(c.home, ".dsh");
|
|
4421
5144
|
}
|
|
4422
5145
|
var dsh = {
|
|
4423
5146
|
name: "dsh",
|
|
4424
5147
|
detect: (c) => onPath2("dsh") || existsSync10(dshHome(c)),
|
|
4425
5148
|
install(c) {
|
|
4426
|
-
const path =
|
|
5149
|
+
const path = join18(dshHome(c), "cordis.patch.yml");
|
|
4427
5150
|
const existing = existsSync10(path) ? readFileSync14(path, "utf8") : "";
|
|
4428
5151
|
const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
|
|
4429
|
-
const entry = pathToFileURL(
|
|
5152
|
+
const entry = pathToFileURL(join18(c.dist, "dsh.js")).href;
|
|
4430
5153
|
const block = `${DSH_MARKER_START}
|
|
4431
5154
|
- insert:
|
|
4432
5155
|
- id: hindsight
|
|
@@ -4435,19 +5158,19 @@ ${DSH_MARKER_END}
|
|
|
4435
5158
|
`;
|
|
4436
5159
|
if (existsSync10(path) && !existsSync10(`${path}.hindsight-backup`))
|
|
4437
5160
|
copyFileSync(path, `${path}.hindsight-backup`);
|
|
4438
|
-
|
|
4439
|
-
|
|
5161
|
+
mkdirSync6(dirname11(path), { recursive: true });
|
|
5162
|
+
writeFileSync4(path, others ? `${others}
|
|
4440
5163
|
|
|
4441
5164
|
${block}` : block);
|
|
4442
5165
|
installSkill(c, "dsh");
|
|
4443
5166
|
c.log?.(`dsh: plugin registered in ${path} (applies to every dsh profile)`);
|
|
4444
5167
|
},
|
|
4445
5168
|
uninstall(c) {
|
|
4446
|
-
const path =
|
|
5169
|
+
const path = join18(dshHome(c), "cordis.patch.yml");
|
|
4447
5170
|
if (existsSync10(path)) {
|
|
4448
5171
|
const existing = readFileSync14(path, "utf8");
|
|
4449
5172
|
const others = existing.replace(DSH_BLOCK_RE, "\n").trim();
|
|
4450
|
-
if (others !== existing.trim())
|
|
5173
|
+
if (others !== existing.trim()) writeFileSync4(path, others ? `${others}
|
|
4451
5174
|
` : "[]\n");
|
|
4452
5175
|
}
|
|
4453
5176
|
uninstallSkill(c, "dsh");
|
|
@@ -4456,9 +5179,9 @@ ${block}` : block);
|
|
|
4456
5179
|
};
|
|
4457
5180
|
var qwen = {
|
|
4458
5181
|
name: "qwen-code",
|
|
4459
|
-
detect: (c) => onPath2("qwen") || existsSync10(
|
|
5182
|
+
detect: (c) => onPath2("qwen") || existsSync10(join18(c.home, ".qwen")),
|
|
4460
5183
|
install(c) {
|
|
4461
|
-
const path =
|
|
5184
|
+
const path = join18(c.home, ".qwen", "settings.json");
|
|
4462
5185
|
const settings = readJson(path);
|
|
4463
5186
|
settings.hooks = settings.hooks ?? {};
|
|
4464
5187
|
mergeHarnessHooks(settings.hooks, "qwen-code", c.dist);
|
|
@@ -4476,18 +5199,18 @@ var qwen = {
|
|
|
4476
5199
|
"HINDSIGHT_MCP_HARNESS=qwen-code",
|
|
4477
5200
|
"hindsight",
|
|
4478
5201
|
"node",
|
|
4479
|
-
|
|
5202
|
+
join18(c.dist, "mcp-server.js")
|
|
4480
5203
|
])) {
|
|
4481
5204
|
c.log?.("qwen-code: MCP server registered (qwen mcp add, user scope)");
|
|
4482
5205
|
} else {
|
|
4483
5206
|
c.log?.(
|
|
4484
5207
|
`qwen-code: could not run \`qwen mcp add\` \u2014 register the tools manually:
|
|
4485
|
-
qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${
|
|
5208
|
+
qwen mcp add -s user -e HINDSIGHT_MCP_HARNESS=qwen-code hindsight node "${join18(c.dist, "mcp-server.js")}"`
|
|
4486
5209
|
);
|
|
4487
5210
|
}
|
|
4488
5211
|
},
|
|
4489
5212
|
uninstall(c) {
|
|
4490
|
-
const path =
|
|
5213
|
+
const path = join18(c.home, ".qwen", "settings.json");
|
|
4491
5214
|
if (existsSync10(path)) {
|
|
4492
5215
|
const settings = readJson(path);
|
|
4493
5216
|
if (settings.hooks) {
|
|
@@ -4512,19 +5235,19 @@ function defaultQwenMcp(args) {
|
|
|
4512
5235
|
}
|
|
4513
5236
|
var factoryDroid = {
|
|
4514
5237
|
name: "factory-droid",
|
|
4515
|
-
detect: (c) => onPath2("droid") || existsSync10(
|
|
5238
|
+
detect: (c) => onPath2("droid") || existsSync10(join18(c.home, ".factory")),
|
|
4516
5239
|
preflight(c) {
|
|
4517
|
-
const mcpPath =
|
|
5240
|
+
const mcpPath = join18(c.home, ".factory", "mcp.json");
|
|
4518
5241
|
const existing = readJson(mcpPath).mcpServers?.hindsight;
|
|
4519
5242
|
if (existing && !isOurMcpEntry(existing)) {
|
|
4520
5243
|
return `${mcpPath} already contains a user-managed MCP server named "hindsight". Rename or remove that entry, then re-run install.`;
|
|
4521
5244
|
}
|
|
4522
5245
|
},
|
|
4523
5246
|
install(c) {
|
|
4524
|
-
const hooksPath =
|
|
5247
|
+
const hooksPath = join18(c.home, ".factory", "hooks.json");
|
|
4525
5248
|
const hooks = readJson(hooksPath);
|
|
4526
5249
|
if (!existsSync10(hooksPath)) {
|
|
4527
|
-
const fallback = readJson(
|
|
5250
|
+
const fallback = readJson(join18(c.home, ".factory", "settings.json")).hooks;
|
|
4528
5251
|
if (fallback && typeof fallback === "object" && !Array.isArray(fallback)) {
|
|
4529
5252
|
Object.assign(hooks, fallback);
|
|
4530
5253
|
}
|
|
@@ -4533,7 +5256,7 @@ var factoryDroid = {
|
|
|
4533
5256
|
writeJson(hooksPath, hooks);
|
|
4534
5257
|
c.log?.(`factory-droid: hooks merged into ${hooksPath}`);
|
|
4535
5258
|
installSkill(c, "factory-droid");
|
|
4536
|
-
const mcpPath =
|
|
5259
|
+
const mcpPath = join18(c.home, ".factory", "mcp.json");
|
|
4537
5260
|
const mcp = readJson(mcpPath);
|
|
4538
5261
|
mcp.mcpServers = mcp.mcpServers ?? {};
|
|
4539
5262
|
mcp.mcpServers.hindsight = mcpServerEntry(c.dist, "factory-droid");
|
|
@@ -4541,20 +5264,20 @@ var factoryDroid = {
|
|
|
4541
5264
|
c.log?.(`factory-droid: MCP server registered in ${mcpPath}`);
|
|
4542
5265
|
},
|
|
4543
5266
|
uninstall(c) {
|
|
4544
|
-
const hooksPath =
|
|
5267
|
+
const hooksPath = join18(c.home, ".factory", "hooks.json");
|
|
4545
5268
|
if (existsSync10(hooksPath)) {
|
|
4546
5269
|
const hooks = readJson(hooksPath);
|
|
4547
5270
|
stripHarnessHooks(hooks, "factory-droid");
|
|
4548
5271
|
if (Object.keys(hooks).length) writeJson(hooksPath, hooks);
|
|
4549
|
-
else
|
|
5272
|
+
else rmSync3(hooksPath);
|
|
4550
5273
|
}
|
|
4551
|
-
const mcpPath =
|
|
5274
|
+
const mcpPath = join18(c.home, ".factory", "mcp.json");
|
|
4552
5275
|
if (existsSync10(mcpPath)) {
|
|
4553
5276
|
const mcp = readJson(mcpPath);
|
|
4554
5277
|
if (isOurMcpEntry(mcp.mcpServers?.hindsight)) {
|
|
4555
5278
|
delete mcp.mcpServers.hindsight;
|
|
4556
5279
|
if (Object.keys(mcp.mcpServers).length) writeJson(mcpPath, mcp);
|
|
4557
|
-
else
|
|
5280
|
+
else rmSync3(mcpPath);
|
|
4558
5281
|
}
|
|
4559
5282
|
}
|
|
4560
5283
|
uninstallSkill(c, "factory-droid");
|
|
@@ -4563,7 +5286,7 @@ var factoryDroid = {
|
|
|
4563
5286
|
};
|
|
4564
5287
|
var zcode = {
|
|
4565
5288
|
name: "zcode",
|
|
4566
|
-
detect: (c) => onPath2("zcode") || existsSync10(
|
|
5289
|
+
detect: (c) => onPath2("zcode") || existsSync10(join18(c.home, ".zcode")),
|
|
4567
5290
|
preflight(c) {
|
|
4568
5291
|
const configPath = zcodeConfigPath(c);
|
|
4569
5292
|
const existing = readJson(configPath).mcp?.servers?.hindsight;
|
|
@@ -4643,18 +5366,18 @@ function importConversations(harness, ctx) {
|
|
|
4643
5366
|
return;
|
|
4644
5367
|
}
|
|
4645
5368
|
const turns = found.sessions.reduce((n, s) => n + s.turns.length, 0);
|
|
4646
|
-
const file =
|
|
4647
|
-
|
|
5369
|
+
const file = join18(mkdtempSync2(join18(tmpdir6(), "hindsight-import-")), "conversations.json");
|
|
5370
|
+
writeFileSync4(file, JSON.stringify(found.sessions));
|
|
4648
5371
|
ctx.log?.(
|
|
4649
5372
|
`${harness}: importing ${found.sessions.length} past sessions (${turns} turns) from ${repo} \u2014 this runs extraction and may take a while`
|
|
4650
5373
|
);
|
|
4651
5374
|
try {
|
|
4652
|
-
execFileSync6("node", [
|
|
5375
|
+
execFileSync6("node", [join18(ctx.dist, "deepen.js"), "--repo", repo, "--conversations", file], {
|
|
4653
5376
|
stdio: "inherit"
|
|
4654
5377
|
});
|
|
4655
5378
|
} catch {
|
|
4656
5379
|
ctx.log?.(`${harness}: conversation import did not finish \u2014 re-run it any time with:`);
|
|
4657
|
-
ctx.log?.(` node "${
|
|
5380
|
+
ctx.log?.(` node "${join18(ctx.dist, "deepen.js")}" --repo "${repo}" --conversations "${file}"`);
|
|
4658
5381
|
}
|
|
4659
5382
|
}
|
|
4660
5383
|
function run(argv, ctxIn) {
|
|
@@ -4757,7 +5480,7 @@ if (isMain || mainPath?.endsWith("installer.js")) {
|
|
|
4757
5480
|
const pkgRoot = dirname11(dist);
|
|
4758
5481
|
let version;
|
|
4759
5482
|
try {
|
|
4760
|
-
version = JSON.parse(readFileSync14(
|
|
5483
|
+
version = JSON.parse(readFileSync14(join18(pkgRoot, "package.json"), "utf8")).version;
|
|
4761
5484
|
} catch {
|
|
4762
5485
|
version = void 0;
|
|
4763
5486
|
}
|
|
@@ -4798,3 +5521,42 @@ export {
|
|
|
4798
5521
|
run,
|
|
4799
5522
|
runtimeDir
|
|
4800
5523
|
};
|
|
5524
|
+
/*! Bundled license information:
|
|
5525
|
+
|
|
5526
|
+
smol-toml/dist/date.js:
|
|
5527
|
+
smol-toml/dist/error.js:
|
|
5528
|
+
smol-toml/dist/util.js:
|
|
5529
|
+
smol-toml/dist/primitive.js:
|
|
5530
|
+
smol-toml/dist/extract.js:
|
|
5531
|
+
smol-toml/dist/struct.js:
|
|
5532
|
+
smol-toml/dist/parse.js:
|
|
5533
|
+
smol-toml/dist/stringify.js:
|
|
5534
|
+
smol-toml/dist/index.js:
|
|
5535
|
+
(*!
|
|
5536
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
5537
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5538
|
+
*
|
|
5539
|
+
* Redistribution and use in source and binary forms, with or without
|
|
5540
|
+
* modification, are permitted provided that the following conditions are met:
|
|
5541
|
+
*
|
|
5542
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
5543
|
+
* list of conditions and the following disclaimer.
|
|
5544
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
5545
|
+
* this list of conditions and the following disclaimer in the
|
|
5546
|
+
* documentation and/or other materials provided with the distribution.
|
|
5547
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
5548
|
+
* may be used to endorse or promote products derived from this software without
|
|
5549
|
+
* specific prior written permission.
|
|
5550
|
+
*
|
|
5551
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
5552
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
5553
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
5554
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
5555
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
5556
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
5557
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
5558
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
5559
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
5560
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
5561
|
+
*)
|
|
5562
|
+
*/
|