@vectorize-io/hindsight-coding-agents 0.5.5 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -5
- package/dist/antigravity-hook.js +87 -83
- package/dist/antigravity-statusline.js +32 -22
- package/dist/antigravity-stop-hook.js +160 -71
- package/dist/claude-hook.js +87 -83
- package/dist/claude-sessionstart-hook.js +111 -97
- package/dist/claude-stop-hook.js +160 -71
- package/dist/cline.js +161 -88
- package/dist/codex-hook.js +87 -83
- package/dist/codex-sessionstart-hook.js +111 -97
- package/dist/codex-stop-hook.js +160 -71
- package/dist/copilot-hook.js +87 -83
- package/dist/copilot-sessionstart-hook.js +111 -97
- package/dist/copilot-stop-hook.js +160 -71
- package/dist/cursor-hook.js +87 -83
- package/dist/cursor-sessionstart-hook.js +111 -97
- package/dist/cursor-stop-hook.js +160 -71
- package/dist/daemon-start.js +28 -18
- package/dist/dcode-hook.js +87 -83
- package/dist/dcode-sessionstart-hook.js +111 -97
- package/dist/dcode-stop-hook.js +160 -71
- package/dist/deepen.js +42 -32
- package/dist/devin-hook.js +87 -83
- package/dist/devin-sessionstart-hook.js +111 -97
- package/dist/devin-stop-hook.js +160 -71
- package/dist/droid-hook.js +87 -83
- package/dist/droid-sessionstart-hook.js +111 -97
- package/dist/droid-stop-hook.js +160 -71
- package/dist/dsh.js +159 -87
- package/dist/grok-hook.js +87 -83
- package/dist/grok-sessionstart-hook.js +111 -97
- package/dist/grok-stop-hook.js +160 -71
- package/dist/hindsight-seed.js +32 -22
- package/dist/index.js +162 -90
- package/dist/installer.js +308 -214
- package/dist/kilo.js +162 -90
- package/dist/mcp-server.js +41 -31
- package/dist/opencode2.js +161 -89
- package/dist/pi.js +161 -89
- package/dist/prime-agent.js +161 -89
- package/dist/qwen-hook.js +87 -83
- package/dist/qwen-sessionstart-hook.js +111 -97
- package/dist/qwen-stop-hook.js +160 -71
- package/dist/status.js +38 -28
- package/dist/zcode-hook.js +87 -83
- package/dist/zcode-sessionstart-hook.js +111 -97
- package/dist/zcode-stop-hook.js +160 -71
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +19 -5
package/dist/claude-hook.js
CHANGED
|
@@ -5,16 +5,28 @@ import { existsSync as existsSync2, readFileSync as readFileSync5 } from "fs";
|
|
|
5
5
|
|
|
6
6
|
// src/core/bank.ts
|
|
7
7
|
import { existsSync } from "fs";
|
|
8
|
-
import { homedir } from "os";
|
|
9
|
-
import { basename, dirname as dirname3, join as
|
|
8
|
+
import { homedir as homedir2 } from "os";
|
|
9
|
+
import { basename, dirname as dirname3, join as join4, normalize, sep } from "path";
|
|
10
10
|
|
|
11
11
|
// src/core/diag.ts
|
|
12
|
-
import {
|
|
12
|
+
import { join as join2 } from "path";
|
|
13
13
|
|
|
14
14
|
// src/core/log.ts
|
|
15
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
16
|
-
import {
|
|
15
|
+
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
16
|
+
import { homedir } from "os";
|
|
17
17
|
import { dirname, join } from "path";
|
|
18
|
+
function logsDir() {
|
|
19
|
+
return join(homedir(), ".hindsight", "coding-agents-logs");
|
|
20
|
+
}
|
|
21
|
+
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
22
|
+
function appendLogLine(file, text) {
|
|
23
|
+
mkdirSync(dirname(file), { recursive: true, mode: 448 });
|
|
24
|
+
try {
|
|
25
|
+
if (statSync(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
appendFileSync(file, text, { mode: 384 });
|
|
29
|
+
}
|
|
18
30
|
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
19
31
|
var current = ["debug", "info", "warn", "error"].find(
|
|
20
32
|
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
@@ -23,15 +35,13 @@ function setLogLevel(level) {
|
|
|
23
35
|
if (!process.env.HINDSIGHT_LOG_LEVEL) current = level;
|
|
24
36
|
}
|
|
25
37
|
function logFilePath() {
|
|
26
|
-
return process.env.HINDSIGHT_LOG_FILE || join(
|
|
38
|
+
return process.env.HINDSIGHT_LOG_FILE || join(logsDir(), "plugin.log");
|
|
27
39
|
}
|
|
28
40
|
function write(level, scope, msg, extra) {
|
|
29
41
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
30
42
|
try {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
appendFileSync(
|
|
34
|
-
file,
|
|
43
|
+
appendLogLine(
|
|
44
|
+
logFilePath(),
|
|
35
45
|
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
36
46
|
);
|
|
37
47
|
} catch {
|
|
@@ -60,12 +70,12 @@ function describeError(value, maxChars = 200) {
|
|
|
60
70
|
|
|
61
71
|
// src/core/diag.ts
|
|
62
72
|
function diagFilePath() {
|
|
63
|
-
return process.env.HINDSIGHT_DIAG_FILE || "
|
|
73
|
+
return process.env.HINDSIGHT_DIAG_FILE || join2(logsDir(), "diag.jsonl");
|
|
64
74
|
}
|
|
65
75
|
function diag(harness, event, extra = {}) {
|
|
66
76
|
log.debug(harness, `diag:${event}`, extra);
|
|
67
77
|
try {
|
|
68
|
-
|
|
78
|
+
appendLogLine(
|
|
69
79
|
diagFilePath(),
|
|
70
80
|
JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
|
|
71
81
|
);
|
|
@@ -75,7 +85,7 @@ function diag(harness, event, extra = {}) {
|
|
|
75
85
|
|
|
76
86
|
// src/core/git-layout.ts
|
|
77
87
|
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
78
|
-
import { dirname as dirname2, isAbsolute, join as
|
|
88
|
+
import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
|
|
79
89
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
80
90
|
var ATTEMPTS = 3;
|
|
81
91
|
var BACKOFF_MS = 20;
|
|
@@ -111,16 +121,16 @@ function gitDirFromPointer(text, holder) {
|
|
|
111
121
|
return isAbsolute(target) ? target : resolve(holder, target);
|
|
112
122
|
}
|
|
113
123
|
function commonDirOf(gitDir) {
|
|
114
|
-
const pointer = entryKind(
|
|
124
|
+
const pointer = entryKind(join3(gitDir, "commondir")) === "file" ? readTextOrNull(join3(gitDir, "commondir"))?.trim() : null;
|
|
115
125
|
if (!pointer) return gitDir;
|
|
116
126
|
return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
|
|
117
127
|
}
|
|
118
128
|
function isBare(commonDir) {
|
|
119
|
-
const config = readTextOrNull(
|
|
129
|
+
const config = readTextOrNull(join3(commonDir, "config"));
|
|
120
130
|
return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
|
|
121
131
|
}
|
|
122
132
|
function looksLikeBareRepository(directory) {
|
|
123
|
-
return entryKind(
|
|
133
|
+
return entryKind(join3(directory, "HEAD")) === "file" && entryKind(join3(directory, "objects")) === "dir" && entryKind(join3(directory, "refs")) === "dir";
|
|
124
134
|
}
|
|
125
135
|
function canonical(path) {
|
|
126
136
|
try {
|
|
@@ -137,7 +147,7 @@ function resolved(commonDir) {
|
|
|
137
147
|
function probeOnce(directory) {
|
|
138
148
|
let current2 = resolve(directory);
|
|
139
149
|
for (; ; ) {
|
|
140
|
-
const dotGit =
|
|
150
|
+
const dotGit = join3(current2, ".git");
|
|
141
151
|
const kind = entryKind(dotGit);
|
|
142
152
|
if (kind === "dir") {
|
|
143
153
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -248,7 +258,7 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
248
258
|
return dirName(sessionRoot || directory);
|
|
249
259
|
}
|
|
250
260
|
function configuredDir(dir) {
|
|
251
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
261
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
|
|
252
262
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
253
263
|
}
|
|
254
264
|
function isWithin(directory, configured) {
|
|
@@ -322,18 +332,18 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
|
|
|
322
332
|
|
|
323
333
|
// src/core/config.ts
|
|
324
334
|
import { readFileSync as readFileSync2 } from "fs";
|
|
325
|
-
import { homedir as
|
|
326
|
-
import { join as
|
|
335
|
+
import { homedir as homedir3 } from "os";
|
|
336
|
+
import { join as join7 } from "path";
|
|
327
337
|
|
|
328
338
|
// src/core/seed.ts
|
|
329
339
|
import { spawn as realSpawn } from "child_process";
|
|
330
|
-
import { dirname as dirname4, join as
|
|
340
|
+
import { dirname as dirname4, join as join5 } from "path";
|
|
331
341
|
import { fileURLToPath } from "url";
|
|
332
342
|
var DEFAULT_SEED_LIMIT = 300;
|
|
333
343
|
function startBackgroundSeed(repoDir, opts = {}) {
|
|
334
344
|
try {
|
|
335
345
|
const spawnFn = opts.spawn ?? realSpawn;
|
|
336
|
-
const enginePath = opts.enginePath ??
|
|
346
|
+
const enginePath = opts.enginePath ?? join5(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
|
|
337
347
|
const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
|
|
338
348
|
const child = spawnFn(
|
|
339
349
|
"node",
|
|
@@ -590,7 +600,7 @@ function codingBankManifest(overrides) {
|
|
|
590
600
|
|
|
591
601
|
// src/core/util.ts
|
|
592
602
|
import { accessSync, constants } from "fs";
|
|
593
|
-
import { delimiter, join as
|
|
603
|
+
import { delimiter, join as join6 } from "path";
|
|
594
604
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
595
605
|
function semverGte(version, min) {
|
|
596
606
|
const parts = (v) => {
|
|
@@ -1262,7 +1272,7 @@ var HindsightClient = class {
|
|
|
1262
1272
|
};
|
|
1263
1273
|
|
|
1264
1274
|
// src/core/config.ts
|
|
1265
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
1275
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
|
|
1266
1276
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
1267
1277
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
1268
1278
|
function resolvePageTrigger(raw) {
|
|
@@ -1604,11 +1614,11 @@ ${toolGuide(opts)}
|
|
|
1604
1614
|
}
|
|
1605
1615
|
|
|
1606
1616
|
// src/core/session-cache.ts
|
|
1607
|
-
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync } from "fs";
|
|
1608
|
-
import { tmpdir
|
|
1609
|
-
import { dirname as dirname5, join as
|
|
1617
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
|
|
1618
|
+
import { tmpdir } from "os";
|
|
1619
|
+
import { dirname as dirname5, join as join8 } from "path";
|
|
1610
1620
|
function sessionCacheFile(harness, sessionId) {
|
|
1611
|
-
return
|
|
1621
|
+
return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.json`);
|
|
1612
1622
|
}
|
|
1613
1623
|
function readSessionCache(cacheFile) {
|
|
1614
1624
|
try {
|
|
@@ -1622,7 +1632,7 @@ function writeFileAtomic(path, body) {
|
|
|
1622
1632
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
1623
1633
|
try {
|
|
1624
1634
|
writeFileSync(tmp, body);
|
|
1625
|
-
|
|
1635
|
+
renameSync2(tmp, path);
|
|
1626
1636
|
} catch (e) {
|
|
1627
1637
|
try {
|
|
1628
1638
|
rmSync(tmp, { force: true });
|
|
@@ -1638,7 +1648,7 @@ function writeSessionCache(cacheFile, cache) {
|
|
|
1638
1648
|
}
|
|
1639
1649
|
}
|
|
1640
1650
|
function sessionRootFile(harness, sessionId) {
|
|
1641
|
-
return
|
|
1651
|
+
return join8(tmpdir(), `hindsight-${harness}`, `${sessionId}.root`);
|
|
1642
1652
|
}
|
|
1643
1653
|
function sessionRootDir(harness, sessionId, cwd) {
|
|
1644
1654
|
if (!sessionId || !cwd) return cwd;
|
|
@@ -1656,9 +1666,9 @@ function sessionRootDir(harness, sessionId, cwd) {
|
|
|
1656
1666
|
}
|
|
1657
1667
|
|
|
1658
1668
|
// src/core/turn-journal.ts
|
|
1659
|
-
import { appendFileSync as
|
|
1660
|
-
import { tmpdir as
|
|
1661
|
-
import { dirname as dirname6, join as
|
|
1669
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync4, statSync as statSync2 } from "fs";
|
|
1670
|
+
import { tmpdir as tmpdir2 } from "os";
|
|
1671
|
+
import { dirname as dirname6, join as join9 } from "path";
|
|
1662
1672
|
|
|
1663
1673
|
// src/core/transcript-util.ts
|
|
1664
1674
|
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
@@ -1698,20 +1708,20 @@ function actionLine(tool, input) {
|
|
|
1698
1708
|
// src/core/turn-journal.ts
|
|
1699
1709
|
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
1700
1710
|
function journalPath(harness, sessionId) {
|
|
1701
|
-
return
|
|
1711
|
+
return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
|
|
1702
1712
|
}
|
|
1703
1713
|
function appendJournalTurn(path, turn) {
|
|
1704
1714
|
const content = stripInjectedMemory(turn.content ?? "").trim();
|
|
1705
1715
|
if (!content) return;
|
|
1706
1716
|
try {
|
|
1707
|
-
if (
|
|
1717
|
+
if (statSync2(path).size >= JOURNAL_MAX_BYTES) return;
|
|
1708
1718
|
} catch {
|
|
1709
1719
|
}
|
|
1710
1720
|
const last = readJournalTranscript(path).at(-1);
|
|
1711
1721
|
if (last && last.role === turn.role && last.content === content) return;
|
|
1712
1722
|
try {
|
|
1713
1723
|
mkdirSync3(dirname6(path), { recursive: true });
|
|
1714
|
-
|
|
1724
|
+
appendFileSync2(
|
|
1715
1725
|
path,
|
|
1716
1726
|
JSON.stringify({
|
|
1717
1727
|
role: turn.role,
|
|
@@ -1764,9 +1774,7 @@ async function reflectFallback(harness, prompt, client) {
|
|
|
1764
1774
|
try {
|
|
1765
1775
|
const hits = await client.searchKnowledgePages(query, FALLBACK_PAGE_LIMIT, remaining());
|
|
1766
1776
|
diag(harness, "reflect_fallback_pages", { ms: Date.now() - t0, count: hits.length });
|
|
1767
|
-
if (hits.length)
|
|
1768
|
-
return { memory: formatPageFallback(hits), source: "knowledge_pages", count: hits.length };
|
|
1769
|
-
}
|
|
1777
|
+
if (hits.length) return formatPageFallback(hits);
|
|
1770
1778
|
} catch (e) {
|
|
1771
1779
|
diag(harness, "reflect_fallback_pages_failed", {
|
|
1772
1780
|
ms: Date.now() - t0,
|
|
@@ -1783,13 +1791,7 @@ async function reflectFallback(harness, prompt, client) {
|
|
|
1783
1791
|
ms: Date.now() - t0,
|
|
1784
1792
|
count: observations.length
|
|
1785
1793
|
});
|
|
1786
|
-
if (observations.length)
|
|
1787
|
-
return {
|
|
1788
|
-
memory: formatObservationFallback(observations),
|
|
1789
|
-
source: "observations",
|
|
1790
|
-
count: observations.length
|
|
1791
|
-
};
|
|
1792
|
-
}
|
|
1794
|
+
if (observations.length) return formatObservationFallback(observations);
|
|
1793
1795
|
} catch (e) {
|
|
1794
1796
|
diag(harness, "reflect_fallback_observations_failed", {
|
|
1795
1797
|
ms: Date.now() - t0,
|
|
@@ -1845,7 +1847,7 @@ async function buildHookOutput(args) {
|
|
|
1845
1847
|
});
|
|
1846
1848
|
if (e instanceof ReflectError && e.fallbackEligible) {
|
|
1847
1849
|
fallback = await reflectFallback(harness, prompt, client);
|
|
1848
|
-
if (fallback) reflectAnswer = fallback
|
|
1850
|
+
if (fallback) reflectAnswer = fallback;
|
|
1849
1851
|
}
|
|
1850
1852
|
}
|
|
1851
1853
|
}
|
|
@@ -1881,8 +1883,6 @@ async function buildHookOutput(args) {
|
|
|
1881
1883
|
const kept = blocks.filter(Boolean);
|
|
1882
1884
|
let notice;
|
|
1883
1885
|
if (fallback) {
|
|
1884
|
-
const what = fallback.source === "knowledge_pages" ? "knowledge page" : "observation";
|
|
1885
|
-
notice = `${brandWord()} \xB7 reflect unavailable \u2014 fell back to ${fallback.count} ${what}${fallback.count === 1 ? "" : "s"} (see ${diagFilePath()})`;
|
|
1886
1886
|
} else if (reflectRanThisTurn && reflectAnswer) {
|
|
1887
1887
|
const q = prompt.replace(/\s+/g, " ").trim();
|
|
1888
1888
|
const excerpt = q.length > 48 ? `${q.slice(0, 48)}\u2026` : q;
|
|
@@ -1946,7 +1946,7 @@ async function runHook(spec, makeClient = (o) => new HindsightClient(o)) {
|
|
|
1946
1946
|
}
|
|
1947
1947
|
|
|
1948
1948
|
// src/core/retain-hook.ts
|
|
1949
|
-
import { readFileSync as
|
|
1949
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
1950
1950
|
|
|
1951
1951
|
// src/core/retain-cursor.ts
|
|
1952
1952
|
import { createHash as createHash2 } from "crypto";
|
|
@@ -1958,14 +1958,14 @@ import { createHash as createHash3 } from "crypto";
|
|
|
1958
1958
|
|
|
1959
1959
|
// src/core/daemon.ts
|
|
1960
1960
|
import { execFileSync, spawn as realSpawn2 } from "child_process";
|
|
1961
|
-
import { dirname as dirname7, join as
|
|
1961
|
+
import { dirname as dirname7, join as join10 } from "path";
|
|
1962
1962
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1963
1963
|
|
|
1964
1964
|
// src/core/retain-stamp.ts
|
|
1965
1965
|
import { basename as basename2 } from "path";
|
|
1966
1966
|
|
|
1967
1967
|
// src/core/jsonl.ts
|
|
1968
|
-
import { closeSync, openSync, readSync, statSync as
|
|
1968
|
+
import { closeSync, openSync, readSync, statSync as statSync3 } from "fs";
|
|
1969
1969
|
import { StringDecoder } from "string_decoder";
|
|
1970
1970
|
var CHUNK_BYTES = 64 * 1024;
|
|
1971
1971
|
var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
|
|
@@ -1973,7 +1973,7 @@ function readJsonlTail(path, opts) {
|
|
|
1973
1973
|
const maxBytes = opts.maxBytes ?? MAX_TRANSCRIPT_BYTES;
|
|
1974
1974
|
let size;
|
|
1975
1975
|
try {
|
|
1976
|
-
size =
|
|
1976
|
+
size = statSync3(path).size;
|
|
1977
1977
|
} catch {
|
|
1978
1978
|
return { lines: emptyLines(), skippedBytes: 0 };
|
|
1979
1979
|
}
|
|
@@ -2025,8 +2025,12 @@ function* streamLines(path, start) {
|
|
|
2025
2025
|
}
|
|
2026
2026
|
}
|
|
2027
2027
|
|
|
2028
|
+
// src/core/usage.ts
|
|
2029
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
2030
|
+
import { join as join11 } from "path";
|
|
2031
|
+
|
|
2028
2032
|
// src/core/session-start.ts
|
|
2029
|
-
import { readFileSync as
|
|
2033
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
2030
2034
|
|
|
2031
2035
|
// src/core/git.ts
|
|
2032
2036
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
@@ -2039,8 +2043,8 @@ import { execFileSync as execFileSync3 } from "child_process";
|
|
|
2039
2043
|
import { spawn as realSpawn4 } from "child_process";
|
|
2040
2044
|
import { createHash as createHash4 } from "crypto";
|
|
2041
2045
|
import { existsSync as existsSync3 } from "fs";
|
|
2042
|
-
import { homedir as
|
|
2043
|
-
import { dirname as dirname8, join as
|
|
2046
|
+
import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
|
|
2047
|
+
import { dirname as dirname8, join as join13 } from "path";
|
|
2044
2048
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2045
2049
|
|
|
2046
2050
|
// src/core/survey-lease.ts
|
|
@@ -2050,42 +2054,42 @@ import {
|
|
|
2050
2054
|
mkdirSync as mkdirSync4,
|
|
2051
2055
|
mkdtempSync,
|
|
2052
2056
|
readdirSync,
|
|
2053
|
-
renameSync as
|
|
2057
|
+
renameSync as renameSync3,
|
|
2054
2058
|
rmdirSync,
|
|
2055
2059
|
rmSync as rmSync2,
|
|
2056
|
-
statSync as
|
|
2060
|
+
statSync as statSync4,
|
|
2057
2061
|
unlinkSync,
|
|
2058
2062
|
utimesSync,
|
|
2059
2063
|
writeFileSync as writeFileSync2
|
|
2060
2064
|
} from "fs";
|
|
2061
|
-
import { join as
|
|
2065
|
+
import { join as join12 } from "path";
|
|
2062
2066
|
|
|
2063
2067
|
// src/core/auto-update.ts
|
|
2064
2068
|
import { spawn as realSpawn5 } from "child_process";
|
|
2065
2069
|
import {
|
|
2066
2070
|
existsSync as existsSync4,
|
|
2067
2071
|
mkdirSync as mkdirSync5,
|
|
2068
|
-
readFileSync as
|
|
2072
|
+
readFileSync as readFileSync8,
|
|
2069
2073
|
realpathSync as realpathSync2,
|
|
2070
2074
|
unlinkSync as unlinkSync2,
|
|
2071
2075
|
writeFileSync as writeFileSync3
|
|
2072
2076
|
} from "fs";
|
|
2073
|
-
import { homedir as
|
|
2074
|
-
import { dirname as dirname9, join as
|
|
2077
|
+
import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
|
|
2078
|
+
import { dirname as dirname9, join as join14 } from "path";
|
|
2075
2079
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
2076
2080
|
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
2077
2081
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
2078
2082
|
|
|
2079
2083
|
// src/core/skill-sync.ts
|
|
2080
|
-
import { cpSync, existsSync as existsSync5, readFileSync as
|
|
2081
|
-
import { homedir as
|
|
2082
|
-
import { dirname as dirname10, join as
|
|
2084
|
+
import { cpSync, existsSync as existsSync5, readFileSync as readFileSync9 } from "fs";
|
|
2085
|
+
import { homedir as homedir6 } from "os";
|
|
2086
|
+
import { dirname as dirname10, join as join15 } from "path";
|
|
2083
2087
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
2084
2088
|
|
|
2085
2089
|
// src/core/legacy.ts
|
|
2086
|
-
import { existsSync as existsSync6, readFileSync as
|
|
2087
|
-
import { homedir as
|
|
2088
|
-
import { join as
|
|
2090
|
+
import { existsSync as existsSync6, readFileSync as readFileSync10 } from "fs";
|
|
2091
|
+
import { homedir as homedir7 } from "os";
|
|
2092
|
+
import { join as join16, relative, isAbsolute as isAbsolute2 } from "path";
|
|
2089
2093
|
|
|
2090
2094
|
// src/core/transcript-codex.ts
|
|
2091
2095
|
function isSyntheticUserText(text) {
|
|
@@ -2217,19 +2221,19 @@ function readCopilotTranscript(path) {
|
|
|
2217
2221
|
}
|
|
2218
2222
|
|
|
2219
2223
|
// src/core/transcript-grok.ts
|
|
2220
|
-
import { existsSync as existsSync7, readFileSync as
|
|
2221
|
-
import { homedir as
|
|
2222
|
-
import { join as
|
|
2224
|
+
import { existsSync as existsSync7, readFileSync as readFileSync12, readdirSync as readdirSync2 } from "fs";
|
|
2225
|
+
import { homedir as homedir8 } from "os";
|
|
2226
|
+
import { join as join17 } from "path";
|
|
2223
2227
|
var CHAT_HISTORY = "chat_history.jsonl";
|
|
2224
|
-
function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
|
|
2225
|
-
const sessionsDir =
|
|
2226
|
-
const direct =
|
|
2228
|
+
function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME || join17(homedir8(), ".grok")) {
|
|
2229
|
+
const sessionsDir = join17(grokHome, "sessions");
|
|
2230
|
+
const direct = join17(sessionsDir, encodeURIComponent(cwd), sessionId, CHAT_HISTORY);
|
|
2227
2231
|
if (existsSync7(direct)) return direct;
|
|
2228
2232
|
try {
|
|
2229
2233
|
for (const candidate of readdirSync2(sessionsDir)) {
|
|
2230
|
-
const directory =
|
|
2231
|
-
if (
|
|
2232
|
-
return
|
|
2234
|
+
const directory = join17(sessionsDir, candidate);
|
|
2235
|
+
if (readFileSync12(join17(directory, ".cwd"), "utf8").trim() === cwd) {
|
|
2236
|
+
return join17(directory, sessionId, CHAT_HISTORY);
|
|
2233
2237
|
}
|
|
2234
2238
|
}
|
|
2235
2239
|
} catch {
|
|
@@ -2266,10 +2270,10 @@ function readGrokTranscript(path) {
|
|
|
2266
2270
|
// src/core/transcript-devin.ts
|
|
2267
2271
|
import { existsSync as existsSync8 } from "fs";
|
|
2268
2272
|
import { createRequire } from "module";
|
|
2269
|
-
import { homedir as
|
|
2270
|
-
import { join as
|
|
2271
|
-
function devinSessionDb(home =
|
|
2272
|
-
return
|
|
2273
|
+
import { homedir as homedir9 } from "os";
|
|
2274
|
+
import { join as join18 } from "path";
|
|
2275
|
+
function devinSessionDb(home = homedir9()) {
|
|
2276
|
+
return join18(home, ".local", "share", "devin", "cli", "sessions.db");
|
|
2273
2277
|
}
|
|
2274
2278
|
function parseDevinMessages(nodes) {
|
|
2275
2279
|
const messages = /* @__PURE__ */ new Map();
|
|
@@ -2579,7 +2583,7 @@ function readDroidTranscript(path) {
|
|
|
2579
2583
|
}
|
|
2580
2584
|
|
|
2581
2585
|
// src/core/transcript-zcode.ts
|
|
2582
|
-
import { readFileSync as
|
|
2586
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
2583
2587
|
function messageText2(content) {
|
|
2584
2588
|
if (typeof content === "string") return content.trim();
|
|
2585
2589
|
if (!Array.isArray(content)) return "";
|
|
@@ -2589,7 +2593,7 @@ function readZcodeTranscript(path) {
|
|
|
2589
2593
|
if (!path) return [];
|
|
2590
2594
|
let body;
|
|
2591
2595
|
try {
|
|
2592
|
-
body =
|
|
2596
|
+
body = readFileSync13(path, "utf8");
|
|
2593
2597
|
} catch {
|
|
2594
2598
|
return [];
|
|
2595
2599
|
}
|