@vectorize-io/hindsight-coding-agents 0.5.4 → 0.6.0
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 +24 -7
- package/dist/antigravity-hook.js +205 -81
- package/dist/antigravity-statusline.js +32 -22
- package/dist/antigravity-stop-hook.js +216 -79
- package/dist/claude-hook.js +205 -81
- package/dist/claude-sessionstart-hook.js +167 -105
- package/dist/claude-stop-hook.js +216 -79
- package/dist/cline.js +279 -86
- package/dist/codex-hook.js +205 -81
- package/dist/codex-sessionstart-hook.js +167 -105
- package/dist/codex-stop-hook.js +216 -79
- package/dist/copilot-hook.js +205 -81
- package/dist/copilot-sessionstart-hook.js +167 -105
- package/dist/copilot-stop-hook.js +216 -79
- package/dist/cursor-hook.js +205 -81
- package/dist/cursor-sessionstart-hook.js +167 -105
- package/dist/cursor-stop-hook.js +216 -79
- package/dist/daemon-start.js +28 -18
- package/dist/dcode-hook.js +205 -81
- package/dist/dcode-sessionstart-hook.js +167 -105
- package/dist/dcode-stop-hook.js +216 -79
- package/dist/deepen.js +98 -40
- package/dist/devin-hook.js +205 -81
- package/dist/devin-sessionstart-hook.js +167 -105
- package/dist/devin-stop-hook.js +216 -79
- package/dist/droid-hook.js +205 -81
- package/dist/droid-sessionstart-hook.js +167 -105
- package/dist/droid-stop-hook.js +216 -79
- package/dist/dsh.js +277 -85
- package/dist/grok-hook.js +205 -81
- package/dist/grok-sessionstart-hook.js +167 -105
- package/dist/grok-stop-hook.js +216 -79
- package/dist/hindsight-seed.js +32 -22
- package/dist/index.js +280 -88
- package/dist/installer.js +308 -214
- package/dist/kilo.js +280 -88
- package/dist/mcp-server.js +97 -39
- package/dist/opencode2.js +279 -87
- package/dist/pi.js +279 -87
- package/dist/prime-agent.js +279 -87
- package/dist/qwen-hook.js +205 -81
- package/dist/qwen-sessionstart-hook.js +167 -105
- package/dist/qwen-stop-hook.js +216 -79
- package/dist/status.js +94 -36
- package/dist/zcode-hook.js +205 -81
- package/dist/zcode-sessionstart-hook.js +167 -105
- package/dist/zcode-stop-hook.js +216 -79
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +24 -7
package/dist/status.js
CHANGED
|
@@ -2,30 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
// src/core/bank.ts
|
|
4
4
|
import { existsSync } from "fs";
|
|
5
|
-
import { homedir } from "os";
|
|
6
|
-
import { basename, dirname as dirname3, join as
|
|
5
|
+
import { homedir as homedir2 } from "os";
|
|
6
|
+
import { basename, dirname as dirname3, join as join4, normalize, sep } from "path";
|
|
7
7
|
|
|
8
8
|
// src/core/diag.ts
|
|
9
|
-
import {
|
|
9
|
+
import { join as join2 } from "path";
|
|
10
10
|
|
|
11
11
|
// src/core/log.ts
|
|
12
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
13
|
-
import {
|
|
12
|
+
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
13
|
+
import { homedir } from "os";
|
|
14
14
|
import { dirname, join } from "path";
|
|
15
|
+
function logsDir() {
|
|
16
|
+
return join(homedir(), ".hindsight", "coding-agents-logs");
|
|
17
|
+
}
|
|
18
|
+
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
19
|
+
function appendLogLine(file, text) {
|
|
20
|
+
mkdirSync(dirname(file), { recursive: true, mode: 448 });
|
|
21
|
+
try {
|
|
22
|
+
if (statSync(file).size >= LOG_MAX_BYTES) renameSync(file, `${file}.1`);
|
|
23
|
+
} catch {
|
|
24
|
+
}
|
|
25
|
+
appendFileSync(file, text, { mode: 384 });
|
|
26
|
+
}
|
|
15
27
|
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
16
28
|
var current = ["debug", "info", "warn", "error"].find(
|
|
17
29
|
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
18
30
|
) ?? "info";
|
|
19
31
|
function logFilePath() {
|
|
20
|
-
return process.env.HINDSIGHT_LOG_FILE || join(
|
|
32
|
+
return process.env.HINDSIGHT_LOG_FILE || join(logsDir(), "plugin.log");
|
|
21
33
|
}
|
|
22
34
|
function write(level, scope, msg, extra) {
|
|
23
35
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
24
36
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
appendFileSync(
|
|
28
|
-
file,
|
|
37
|
+
appendLogLine(
|
|
38
|
+
logFilePath(),
|
|
29
39
|
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
30
40
|
);
|
|
31
41
|
} catch {
|
|
@@ -40,12 +50,12 @@ var log = {
|
|
|
40
50
|
|
|
41
51
|
// src/core/diag.ts
|
|
42
52
|
function diagFilePath() {
|
|
43
|
-
return process.env.HINDSIGHT_DIAG_FILE || "
|
|
53
|
+
return process.env.HINDSIGHT_DIAG_FILE || join2(logsDir(), "diag.jsonl");
|
|
44
54
|
}
|
|
45
55
|
function diag(harness, event, extra = {}) {
|
|
46
56
|
log.debug(harness, `diag:${event}`, extra);
|
|
47
57
|
try {
|
|
48
|
-
|
|
58
|
+
appendLogLine(
|
|
49
59
|
diagFilePath(),
|
|
50
60
|
JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
|
|
51
61
|
);
|
|
@@ -55,7 +65,7 @@ function diag(harness, event, extra = {}) {
|
|
|
55
65
|
|
|
56
66
|
// src/core/git-layout.ts
|
|
57
67
|
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
58
|
-
import { dirname as dirname2, isAbsolute, join as
|
|
68
|
+
import { dirname as dirname2, isAbsolute, join as join3, resolve } from "path";
|
|
59
69
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
60
70
|
var ATTEMPTS = 3;
|
|
61
71
|
var BACKOFF_MS = 20;
|
|
@@ -91,16 +101,16 @@ function gitDirFromPointer(text, holder) {
|
|
|
91
101
|
return isAbsolute(target) ? target : resolve(holder, target);
|
|
92
102
|
}
|
|
93
103
|
function commonDirOf(gitDir) {
|
|
94
|
-
const pointer = entryKind(
|
|
104
|
+
const pointer = entryKind(join3(gitDir, "commondir")) === "file" ? readTextOrNull(join3(gitDir, "commondir"))?.trim() : null;
|
|
95
105
|
if (!pointer) return gitDir;
|
|
96
106
|
return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
|
|
97
107
|
}
|
|
98
108
|
function isBare(commonDir) {
|
|
99
|
-
const config = readTextOrNull(
|
|
109
|
+
const config = readTextOrNull(join3(commonDir, "config"));
|
|
100
110
|
return config !== null && /^\s*bare\s*=\s*true\s*$/im.test(config);
|
|
101
111
|
}
|
|
102
112
|
function looksLikeBareRepository(directory) {
|
|
103
|
-
return entryKind(
|
|
113
|
+
return entryKind(join3(directory, "HEAD")) === "file" && entryKind(join3(directory, "objects")) === "dir" && entryKind(join3(directory, "refs")) === "dir";
|
|
104
114
|
}
|
|
105
115
|
function canonical(path) {
|
|
106
116
|
try {
|
|
@@ -117,7 +127,7 @@ function resolved(commonDir) {
|
|
|
117
127
|
function probeOnce(directory) {
|
|
118
128
|
let current2 = resolve(directory);
|
|
119
129
|
for (; ; ) {
|
|
120
|
-
const dotGit =
|
|
130
|
+
const dotGit = join3(current2, ".git");
|
|
121
131
|
const kind = entryKind(dotGit);
|
|
122
132
|
if (kind === "dir") {
|
|
123
133
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -231,7 +241,7 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
231
241
|
return dirName(sessionRoot || directory);
|
|
232
242
|
}
|
|
233
243
|
function configuredDir(dir) {
|
|
234
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
244
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
|
|
235
245
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
236
246
|
}
|
|
237
247
|
function isWithin(directory, configured) {
|
|
@@ -305,12 +315,12 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
|
|
|
305
315
|
|
|
306
316
|
// src/core/config.ts
|
|
307
317
|
import { readFileSync as readFileSync2 } from "fs";
|
|
308
|
-
import { homedir as
|
|
309
|
-
import { join as
|
|
318
|
+
import { homedir as homedir3 } from "os";
|
|
319
|
+
import { join as join7 } from "path";
|
|
310
320
|
|
|
311
321
|
// src/core/seed.ts
|
|
312
322
|
import { spawn as realSpawn } from "child_process";
|
|
313
|
-
import { dirname as dirname4, join as
|
|
323
|
+
import { dirname as dirname4, join as join5 } from "path";
|
|
314
324
|
import { fileURLToPath } from "url";
|
|
315
325
|
var DEFAULT_SEED_LIMIT = 300;
|
|
316
326
|
|
|
@@ -546,7 +556,7 @@ function codingBankManifest(overrides) {
|
|
|
546
556
|
|
|
547
557
|
// src/core/util.ts
|
|
548
558
|
import { accessSync, constants } from "fs";
|
|
549
|
-
import { delimiter, join as
|
|
559
|
+
import { delimiter, join as join6 } from "path";
|
|
550
560
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
551
561
|
function semverGte(version, min) {
|
|
552
562
|
const parts = (v) => {
|
|
@@ -609,6 +619,22 @@ var KnowledgePagesUnavailableError = class extends Error {
|
|
|
609
619
|
}
|
|
610
620
|
};
|
|
611
621
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
622
|
+
var ReflectError = class extends Error {
|
|
623
|
+
constructor(message, status, timedOut, options) {
|
|
624
|
+
super(message, options);
|
|
625
|
+
this.status = status;
|
|
626
|
+
this.timedOut = timedOut;
|
|
627
|
+
this.name = "ReflectError";
|
|
628
|
+
}
|
|
629
|
+
status;
|
|
630
|
+
timedOut;
|
|
631
|
+
/** A timeout or a 5xx means reflect's synthesis (the slow LLM path) broke, while the cheap
|
|
632
|
+
* retrieval endpoints may still answer — worth falling back. A 4xx will fail the same way on
|
|
633
|
+
* every endpoint (auth, missing bank), so it is not. */
|
|
634
|
+
get fallbackEligible() {
|
|
635
|
+
return this.timedOut || this.status !== void 0 && this.status >= 500;
|
|
636
|
+
}
|
|
637
|
+
};
|
|
612
638
|
var DEFAULT_MAX_PARALLEL_RETAINS = 10;
|
|
613
639
|
var POLL_CYCLE_MS = 5e3;
|
|
614
640
|
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
@@ -692,11 +718,11 @@ var HindsightClient = class {
|
|
|
692
718
|
return `${this.apiUrl}/v1/default/banks/${encodeURIComponent(this.bank)}${suffix}`;
|
|
693
719
|
}
|
|
694
720
|
/** `tolerate` adds statuses that are returned to the caller instead of thrown (404 always is). */
|
|
695
|
-
async req(method, url, body, tolerate = []) {
|
|
721
|
+
async req(method, url, body, tolerate = [], timeoutMs = 15e3) {
|
|
696
722
|
const r = await this.fetchWithAuth(url, {
|
|
697
723
|
method,
|
|
698
724
|
body: body ? JSON.stringify(body) : void 0,
|
|
699
|
-
signal: AbortSignal.timeout(
|
|
725
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
700
726
|
});
|
|
701
727
|
if (r.status === 429 && !tolerate.includes(429))
|
|
702
728
|
throw new RateLimitedError(retryAfterMs(r.headers.get("retry-after")));
|
|
@@ -889,7 +915,7 @@ var HindsightClient = class {
|
|
|
889
915
|
/**
|
|
890
916
|
* Reflect: synthesized, root-cause answer over the bank. Bounded so a slow server never hangs a
|
|
891
917
|
* caller — but `timeoutMs` is REQUIRED, deliberately: the right deadline differs by an order of
|
|
892
|
-
* magnitude between the automatic hook (
|
|
918
|
+
* magnitude between the automatic hook (20s, to fit the host's window) and the agent-invoked
|
|
893
919
|
* tool (minutes, on a populated bank). This used to default to 120s, which silently overrode the
|
|
894
920
|
* tool's configured window and aborted every high-budget synthesis mid-flight (#3590).
|
|
895
921
|
*/
|
|
@@ -903,19 +929,45 @@ var HindsightClient = class {
|
|
|
903
929
|
signal: ctrl.signal
|
|
904
930
|
});
|
|
905
931
|
if (!resp.ok)
|
|
906
|
-
throw new
|
|
907
|
-
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}
|
|
932
|
+
throw new ReflectError(
|
|
933
|
+
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`,
|
|
934
|
+
resp.status,
|
|
935
|
+
false
|
|
908
936
|
);
|
|
909
937
|
const data = await resp.json();
|
|
910
938
|
return (data.text || "").trim();
|
|
911
939
|
} catch (e) {
|
|
912
940
|
if (ctrl.signal.aborted)
|
|
913
|
-
throw new
|
|
941
|
+
throw new ReflectError(`reflect timed out after ${opts.timeoutMs}ms`, void 0, true, {
|
|
942
|
+
cause: e
|
|
943
|
+
});
|
|
914
944
|
throw e;
|
|
915
945
|
} finally {
|
|
916
946
|
clearTimeout(timer);
|
|
917
947
|
}
|
|
918
948
|
}
|
|
949
|
+
/**
|
|
950
|
+
* Raw recall restricted to consolidated observations — no LLM in the loop, so it still answers
|
|
951
|
+
* when reflect's synthesis times out or 5xxs. Returns the observation texts in rank order.
|
|
952
|
+
*/
|
|
953
|
+
async recallObservations(query, opts) {
|
|
954
|
+
const r = await this.req(
|
|
955
|
+
"POST",
|
|
956
|
+
this.bankUrl("/memories/recall"),
|
|
957
|
+
{
|
|
958
|
+
query,
|
|
959
|
+
types: ["observation"],
|
|
960
|
+
budget: "low",
|
|
961
|
+
max_tokens: opts.maxTokens,
|
|
962
|
+
include: { entities: null }
|
|
963
|
+
},
|
|
964
|
+
[],
|
|
965
|
+
opts.timeoutMs
|
|
966
|
+
);
|
|
967
|
+
if (r.status === 404) return [];
|
|
968
|
+
const j = await r.json();
|
|
969
|
+
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
970
|
+
}
|
|
919
971
|
/**
|
|
920
972
|
* The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
|
|
921
973
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
@@ -980,10 +1032,16 @@ var HindsightClient = class {
|
|
|
980
1032
|
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
|
|
981
1033
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
982
1034
|
* hindsight_search_knowledge_pages. */
|
|
983
|
-
async searchKnowledgePages(query, limit = 3) {
|
|
1035
|
+
async searchKnowledgePages(query, limit = 3, timeoutMs) {
|
|
984
1036
|
if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
|
|
985
1037
|
const q = `?q=${encodeURIComponent(query)}&limit=${limit}`;
|
|
986
|
-
const r = await this.req(
|
|
1038
|
+
const r = await this.req(
|
|
1039
|
+
"GET",
|
|
1040
|
+
this.bankUrl(`/knowledge-base/search${q}`),
|
|
1041
|
+
void 0,
|
|
1042
|
+
[],
|
|
1043
|
+
timeoutMs
|
|
1044
|
+
);
|
|
987
1045
|
const j = await r.json();
|
|
988
1046
|
return (j.results ?? []).map((x) => ({
|
|
989
1047
|
id: x.id,
|
|
@@ -1170,7 +1228,7 @@ var HindsightClient = class {
|
|
|
1170
1228
|
};
|
|
1171
1229
|
|
|
1172
1230
|
// src/core/config.ts
|
|
1173
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
1231
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
|
|
1174
1232
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
1175
1233
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
1176
1234
|
function resolvePageTrigger(raw) {
|
|
@@ -1468,8 +1526,8 @@ function parsePageList(raw) {
|
|
|
1468
1526
|
import { spawn as realSpawn3 } from "child_process";
|
|
1469
1527
|
import { createHash as createHash2 } from "crypto";
|
|
1470
1528
|
import { existsSync as existsSync2 } from "fs";
|
|
1471
|
-
import { homedir as
|
|
1472
|
-
import { dirname as dirname5, join as
|
|
1529
|
+
import { homedir as homedir4, tmpdir } from "os";
|
|
1530
|
+
import { dirname as dirname5, join as join9 } from "path";
|
|
1473
1531
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1474
1532
|
|
|
1475
1533
|
// src/core/survey-lease.ts
|
|
@@ -1479,15 +1537,15 @@ import {
|
|
|
1479
1537
|
mkdirSync as mkdirSync2,
|
|
1480
1538
|
mkdtempSync,
|
|
1481
1539
|
readdirSync,
|
|
1482
|
-
renameSync,
|
|
1540
|
+
renameSync as renameSync2,
|
|
1483
1541
|
rmdirSync,
|
|
1484
1542
|
rmSync,
|
|
1485
|
-
statSync,
|
|
1543
|
+
statSync as statSync2,
|
|
1486
1544
|
unlinkSync,
|
|
1487
1545
|
utimesSync,
|
|
1488
1546
|
writeFileSync
|
|
1489
1547
|
} from "fs";
|
|
1490
|
-
import { join as
|
|
1548
|
+
import { join as join8 } from "path";
|
|
1491
1549
|
|
|
1492
1550
|
// src/core/survey.ts
|
|
1493
1551
|
var SURVEY_DOC_IDS = [
|