@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/mcp-server.js
CHANGED
|
@@ -31266,8 +31266,8 @@ var StdioServerTransport = class {
|
|
|
31266
31266
|
|
|
31267
31267
|
// src/core/config.ts
|
|
31268
31268
|
import { readFileSync as readFileSync2 } from "fs";
|
|
31269
|
-
import { homedir as
|
|
31270
|
-
import { join as
|
|
31269
|
+
import { homedir as homedir3 } from "os";
|
|
31270
|
+
import { join as join7 } from "path";
|
|
31271
31271
|
|
|
31272
31272
|
// src/core/seed.ts
|
|
31273
31273
|
import { spawn as realSpawn } from "child_process";
|
|
@@ -31277,30 +31277,40 @@ var DEFAULT_SEED_LIMIT = 300;
|
|
|
31277
31277
|
|
|
31278
31278
|
// src/core/bank.ts
|
|
31279
31279
|
import { existsSync } from "fs";
|
|
31280
|
-
import { homedir } from "os";
|
|
31281
|
-
import { basename, dirname as dirname4, join as
|
|
31280
|
+
import { homedir as homedir2 } from "os";
|
|
31281
|
+
import { basename, dirname as dirname4, join as join5, normalize, sep } from "path";
|
|
31282
31282
|
|
|
31283
31283
|
// src/core/diag.ts
|
|
31284
|
-
import {
|
|
31284
|
+
import { join as join3 } from "path";
|
|
31285
31285
|
|
|
31286
31286
|
// src/core/log.ts
|
|
31287
|
-
import { appendFileSync, mkdirSync } from "fs";
|
|
31288
|
-
import {
|
|
31287
|
+
import { appendFileSync, mkdirSync, renameSync, statSync } from "fs";
|
|
31288
|
+
import { homedir } from "os";
|
|
31289
31289
|
import { dirname as dirname2, join as join2 } from "path";
|
|
31290
|
+
function logsDir() {
|
|
31291
|
+
return join2(homedir(), ".hindsight", "coding-agents-logs");
|
|
31292
|
+
}
|
|
31293
|
+
var LOG_MAX_BYTES = 10 * 1024 * 1024;
|
|
31294
|
+
function appendLogLine(file2, text) {
|
|
31295
|
+
mkdirSync(dirname2(file2), { recursive: true, mode: 448 });
|
|
31296
|
+
try {
|
|
31297
|
+
if (statSync(file2).size >= LOG_MAX_BYTES) renameSync(file2, `${file2}.1`);
|
|
31298
|
+
} catch {
|
|
31299
|
+
}
|
|
31300
|
+
appendFileSync(file2, text, { mode: 384 });
|
|
31301
|
+
}
|
|
31290
31302
|
var WEIGHT = { debug: 10, info: 20, warn: 30, error: 40 };
|
|
31291
31303
|
var current = ["debug", "info", "warn", "error"].find(
|
|
31292
31304
|
(l) => l === process.env.HINDSIGHT_LOG_LEVEL
|
|
31293
31305
|
) ?? "info";
|
|
31294
31306
|
function logFilePath() {
|
|
31295
|
-
return process.env.HINDSIGHT_LOG_FILE || join2(
|
|
31307
|
+
return process.env.HINDSIGHT_LOG_FILE || join2(logsDir(), "plugin.log");
|
|
31296
31308
|
}
|
|
31297
31309
|
function write(level, scope, msg, extra) {
|
|
31298
31310
|
if (WEIGHT[level] < WEIGHT[current]) return;
|
|
31299
31311
|
try {
|
|
31300
|
-
|
|
31301
|
-
|
|
31302
|
-
appendFileSync(
|
|
31303
|
-
file2,
|
|
31312
|
+
appendLogLine(
|
|
31313
|
+
logFilePath(),
|
|
31304
31314
|
`${(/* @__PURE__ */ new Date()).toISOString()} ${level.toUpperCase().padEnd(5)} [${scope}] ${msg}` + (extra && Object.keys(extra).length ? ` ${JSON.stringify(extra)}` : "") + "\n"
|
|
31305
31315
|
);
|
|
31306
31316
|
} catch {
|
|
@@ -31329,12 +31339,12 @@ function describeError(value, maxChars = 200) {
|
|
|
31329
31339
|
|
|
31330
31340
|
// src/core/diag.ts
|
|
31331
31341
|
function diagFilePath() {
|
|
31332
|
-
return process.env.HINDSIGHT_DIAG_FILE || "
|
|
31342
|
+
return process.env.HINDSIGHT_DIAG_FILE || join3(logsDir(), "diag.jsonl");
|
|
31333
31343
|
}
|
|
31334
31344
|
function diag(harness, event, extra = {}) {
|
|
31335
31345
|
log.debug(harness, `diag:${event}`, extra);
|
|
31336
31346
|
try {
|
|
31337
|
-
|
|
31347
|
+
appendLogLine(
|
|
31338
31348
|
diagFilePath(),
|
|
31339
31349
|
JSON.stringify({ ts: (/* @__PURE__ */ new Date()).toISOString(), harness, event, ...extra }) + "\n"
|
|
31340
31350
|
);
|
|
@@ -31344,7 +31354,7 @@ function diag(harness, event, extra = {}) {
|
|
|
31344
31354
|
|
|
31345
31355
|
// src/core/git-layout.ts
|
|
31346
31356
|
import { lstatSync, readFileSync, realpathSync } from "fs";
|
|
31347
|
-
import { dirname as dirname3, isAbsolute, join as
|
|
31357
|
+
import { dirname as dirname3, isAbsolute, join as join4, resolve } from "path";
|
|
31348
31358
|
var TRANSIENT = /* @__PURE__ */ new Set(["EAGAIN", "EMFILE", "ENFILE", "EBUSY", "EINTR", "EIO", "ETIMEDOUT"]);
|
|
31349
31359
|
var ATTEMPTS = 3;
|
|
31350
31360
|
var BACKOFF_MS = 20;
|
|
@@ -31380,16 +31390,16 @@ function gitDirFromPointer(text, holder) {
|
|
|
31380
31390
|
return isAbsolute(target) ? target : resolve(holder, target);
|
|
31381
31391
|
}
|
|
31382
31392
|
function commonDirOf(gitDir) {
|
|
31383
|
-
const pointer = entryKind(
|
|
31393
|
+
const pointer = entryKind(join4(gitDir, "commondir")) === "file" ? readTextOrNull(join4(gitDir, "commondir"))?.trim() : null;
|
|
31384
31394
|
if (!pointer) return gitDir;
|
|
31385
31395
|
return isAbsolute(pointer) ? pointer : resolve(gitDir, pointer);
|
|
31386
31396
|
}
|
|
31387
31397
|
function isBare(commonDir) {
|
|
31388
|
-
const config2 = readTextOrNull(
|
|
31398
|
+
const config2 = readTextOrNull(join4(commonDir, "config"));
|
|
31389
31399
|
return config2 !== null && /^\s*bare\s*=\s*true\s*$/im.test(config2);
|
|
31390
31400
|
}
|
|
31391
31401
|
function looksLikeBareRepository(directory) {
|
|
31392
|
-
return entryKind(
|
|
31402
|
+
return entryKind(join4(directory, "HEAD")) === "file" && entryKind(join4(directory, "objects")) === "dir" && entryKind(join4(directory, "refs")) === "dir";
|
|
31393
31403
|
}
|
|
31394
31404
|
function canonical(path) {
|
|
31395
31405
|
try {
|
|
@@ -31406,7 +31416,7 @@ function resolved(commonDir) {
|
|
|
31406
31416
|
function probeOnce(directory) {
|
|
31407
31417
|
let current2 = resolve(directory);
|
|
31408
31418
|
for (; ; ) {
|
|
31409
|
-
const dotGit =
|
|
31419
|
+
const dotGit = join4(current2, ".git");
|
|
31410
31420
|
const kind = entryKind(dotGit);
|
|
31411
31421
|
if (kind === "dir") {
|
|
31412
31422
|
const layout = resolved(commonDirOf(dotGit));
|
|
@@ -31520,7 +31530,7 @@ function gitProjectName(directory, resolveWorktrees, sessionRoot = "") {
|
|
|
31520
31530
|
return dirName(sessionRoot || directory);
|
|
31521
31531
|
}
|
|
31522
31532
|
function configuredDir(dir) {
|
|
31523
|
-
const expanded = dir === "~" || dir.startsWith("~/") ?
|
|
31533
|
+
const expanded = dir === "~" || dir.startsWith("~/") ? join5(homedir2(), dir.slice(1)) : dir;
|
|
31524
31534
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
31525
31535
|
}
|
|
31526
31536
|
function isWithin(directory, configured) {
|
|
@@ -31824,7 +31834,7 @@ function codingBankManifest(overrides) {
|
|
|
31824
31834
|
|
|
31825
31835
|
// src/core/util.ts
|
|
31826
31836
|
import { accessSync, constants } from "fs";
|
|
31827
|
-
import { delimiter, join as
|
|
31837
|
+
import { delimiter, join as join6 } from "path";
|
|
31828
31838
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
31829
31839
|
function semverGte(version2, min) {
|
|
31830
31840
|
const parts = (v) => {
|
|
@@ -31887,6 +31897,22 @@ var KnowledgePagesUnavailableError = class extends Error {
|
|
|
31887
31897
|
}
|
|
31888
31898
|
};
|
|
31889
31899
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
31900
|
+
var ReflectError = class extends Error {
|
|
31901
|
+
constructor(message, status, timedOut, options) {
|
|
31902
|
+
super(message, options);
|
|
31903
|
+
this.status = status;
|
|
31904
|
+
this.timedOut = timedOut;
|
|
31905
|
+
this.name = "ReflectError";
|
|
31906
|
+
}
|
|
31907
|
+
status;
|
|
31908
|
+
timedOut;
|
|
31909
|
+
/** A timeout or a 5xx means reflect's synthesis (the slow LLM path) broke, while the cheap
|
|
31910
|
+
* retrieval endpoints may still answer — worth falling back. A 4xx will fail the same way on
|
|
31911
|
+
* every endpoint (auth, missing bank), so it is not. */
|
|
31912
|
+
get fallbackEligible() {
|
|
31913
|
+
return this.timedOut || this.status !== void 0 && this.status >= 500;
|
|
31914
|
+
}
|
|
31915
|
+
};
|
|
31890
31916
|
var DEFAULT_MAX_PARALLEL_RETAINS = 10;
|
|
31891
31917
|
var POLL_CYCLE_MS = 5e3;
|
|
31892
31918
|
var RETRY_AFTER_FLOOR_MS = 10 * 1e3;
|
|
@@ -31970,11 +31996,11 @@ var HindsightClient = class {
|
|
|
31970
31996
|
return `${this.apiUrl}/v1/default/banks/${encodeURIComponent(this.bank)}${suffix}`;
|
|
31971
31997
|
}
|
|
31972
31998
|
/** `tolerate` adds statuses that are returned to the caller instead of thrown (404 always is). */
|
|
31973
|
-
async req(method, url2, body, tolerate = []) {
|
|
31999
|
+
async req(method, url2, body, tolerate = [], timeoutMs = 15e3) {
|
|
31974
32000
|
const r = await this.fetchWithAuth(url2, {
|
|
31975
32001
|
method,
|
|
31976
32002
|
body: body ? JSON.stringify(body) : void 0,
|
|
31977
|
-
signal: AbortSignal.timeout(
|
|
32003
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
31978
32004
|
});
|
|
31979
32005
|
if (r.status === 429 && !tolerate.includes(429))
|
|
31980
32006
|
throw new RateLimitedError(retryAfterMs(r.headers.get("retry-after")));
|
|
@@ -32167,7 +32193,7 @@ var HindsightClient = class {
|
|
|
32167
32193
|
/**
|
|
32168
32194
|
* Reflect: synthesized, root-cause answer over the bank. Bounded so a slow server never hangs a
|
|
32169
32195
|
* caller — but `timeoutMs` is REQUIRED, deliberately: the right deadline differs by an order of
|
|
32170
|
-
* magnitude between the automatic hook (
|
|
32196
|
+
* magnitude between the automatic hook (20s, to fit the host's window) and the agent-invoked
|
|
32171
32197
|
* tool (minutes, on a populated bank). This used to default to 120s, which silently overrode the
|
|
32172
32198
|
* tool's configured window and aborted every high-budget synthesis mid-flight (#3590).
|
|
32173
32199
|
*/
|
|
@@ -32181,19 +32207,45 @@ var HindsightClient = class {
|
|
|
32181
32207
|
signal: ctrl.signal
|
|
32182
32208
|
});
|
|
32183
32209
|
if (!resp.ok)
|
|
32184
|
-
throw new
|
|
32185
|
-
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}
|
|
32210
|
+
throw new ReflectError(
|
|
32211
|
+
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`,
|
|
32212
|
+
resp.status,
|
|
32213
|
+
false
|
|
32186
32214
|
);
|
|
32187
32215
|
const data = await resp.json();
|
|
32188
32216
|
return (data.text || "").trim();
|
|
32189
32217
|
} catch (e) {
|
|
32190
32218
|
if (ctrl.signal.aborted)
|
|
32191
|
-
throw new
|
|
32219
|
+
throw new ReflectError(`reflect timed out after ${opts.timeoutMs}ms`, void 0, true, {
|
|
32220
|
+
cause: e
|
|
32221
|
+
});
|
|
32192
32222
|
throw e;
|
|
32193
32223
|
} finally {
|
|
32194
32224
|
clearTimeout(timer);
|
|
32195
32225
|
}
|
|
32196
32226
|
}
|
|
32227
|
+
/**
|
|
32228
|
+
* Raw recall restricted to consolidated observations — no LLM in the loop, so it still answers
|
|
32229
|
+
* when reflect's synthesis times out or 5xxs. Returns the observation texts in rank order.
|
|
32230
|
+
*/
|
|
32231
|
+
async recallObservations(query, opts) {
|
|
32232
|
+
const r = await this.req(
|
|
32233
|
+
"POST",
|
|
32234
|
+
this.bankUrl("/memories/recall"),
|
|
32235
|
+
{
|
|
32236
|
+
query,
|
|
32237
|
+
types: ["observation"],
|
|
32238
|
+
budget: "low",
|
|
32239
|
+
max_tokens: opts.maxTokens,
|
|
32240
|
+
include: { entities: null }
|
|
32241
|
+
},
|
|
32242
|
+
[],
|
|
32243
|
+
opts.timeoutMs
|
|
32244
|
+
);
|
|
32245
|
+
if (r.status === 404) return [];
|
|
32246
|
+
const j = await r.json();
|
|
32247
|
+
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
32248
|
+
}
|
|
32197
32249
|
/**
|
|
32198
32250
|
* The bank's knowledge-base tree (folders + pages, nested). The tree carries names, source
|
|
32199
32251
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
@@ -32258,10 +32310,16 @@ var HindsightClient = class {
|
|
|
32258
32310
|
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's knowledge pages.
|
|
32259
32311
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
32260
32312
|
* hindsight_search_knowledge_pages. */
|
|
32261
|
-
async searchKnowledgePages(query, limit = 3) {
|
|
32313
|
+
async searchKnowledgePages(query, limit = 3, timeoutMs) {
|
|
32262
32314
|
if (this.knowledgePagesSupported === false) throw new KnowledgePagesUnavailableError();
|
|
32263
32315
|
const q = `?q=${encodeURIComponent(query)}&limit=${limit}`;
|
|
32264
|
-
const r = await this.req(
|
|
32316
|
+
const r = await this.req(
|
|
32317
|
+
"GET",
|
|
32318
|
+
this.bankUrl(`/knowledge-base/search${q}`),
|
|
32319
|
+
void 0,
|
|
32320
|
+
[],
|
|
32321
|
+
timeoutMs
|
|
32322
|
+
);
|
|
32265
32323
|
const j = await r.json();
|
|
32266
32324
|
return (j.results ?? []).map((x) => ({
|
|
32267
32325
|
id: x.id,
|
|
@@ -32448,7 +32506,7 @@ var HindsightClient = class {
|
|
|
32448
32506
|
};
|
|
32449
32507
|
|
|
32450
32508
|
// src/core/config.ts
|
|
32451
|
-
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG ||
|
|
32509
|
+
var CONFIG_PATH = process.env.HINDSIGHT_CONFIG || join7(homedir3(), ".hindsight", "coding-agent.json");
|
|
32452
32510
|
var DEFAULT_DAEMON_PORT = 9077;
|
|
32453
32511
|
var DEFAULT_DAEMON_PROFILE = "coding-agent";
|
|
32454
32512
|
function resolvePageTrigger(raw) {
|
|
@@ -32734,8 +32792,8 @@ function resolveHostMemory(harness, directory) {
|
|
|
32734
32792
|
|
|
32735
32793
|
// src/core/knowledge-tools.ts
|
|
32736
32794
|
import { existsSync as existsSync3 } from "fs";
|
|
32737
|
-
import { homedir as
|
|
32738
|
-
import { join as
|
|
32795
|
+
import { homedir as homedir5 } from "os";
|
|
32796
|
+
import { join as join10 } from "path";
|
|
32739
32797
|
|
|
32740
32798
|
// src/core/status.ts
|
|
32741
32799
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
@@ -32779,8 +32837,8 @@ function parsePageList(raw) {
|
|
|
32779
32837
|
import { spawn as realSpawn3 } from "child_process";
|
|
32780
32838
|
import { createHash as createHash2 } from "crypto";
|
|
32781
32839
|
import { existsSync as existsSync2 } from "fs";
|
|
32782
|
-
import { homedir as
|
|
32783
|
-
import { dirname as dirname5, join as
|
|
32840
|
+
import { homedir as homedir4, tmpdir } from "os";
|
|
32841
|
+
import { dirname as dirname5, join as join9 } from "path";
|
|
32784
32842
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
32785
32843
|
|
|
32786
32844
|
// src/core/survey-lease.ts
|
|
@@ -32790,15 +32848,15 @@ import {
|
|
|
32790
32848
|
mkdirSync as mkdirSync2,
|
|
32791
32849
|
mkdtempSync,
|
|
32792
32850
|
readdirSync,
|
|
32793
|
-
renameSync,
|
|
32851
|
+
renameSync as renameSync2,
|
|
32794
32852
|
rmdirSync,
|
|
32795
32853
|
rmSync,
|
|
32796
|
-
statSync,
|
|
32854
|
+
statSync as statSync2,
|
|
32797
32855
|
unlinkSync,
|
|
32798
32856
|
utimesSync,
|
|
32799
32857
|
writeFileSync
|
|
32800
32858
|
} from "fs";
|
|
32801
|
-
import { join as
|
|
32859
|
+
import { join as join8 } from "path";
|
|
32802
32860
|
|
|
32803
32861
|
// src/core/survey.ts
|
|
32804
32862
|
var SURVEY_DOC_IDS = [
|
|
@@ -32918,7 +32976,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
32918
32976
|
inputSchema: {},
|
|
32919
32977
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
32920
32978
|
handler: async (_args) => {
|
|
32921
|
-
const configPath = process.env.HINDSIGHT_CONFIG ||
|
|
32979
|
+
const configPath = process.env.HINDSIGHT_CONFIG || join10(homedir5(), ".hindsight", "coding-agent.json");
|
|
32922
32980
|
const harness = opts.harness ?? "unknown";
|
|
32923
32981
|
const cfg = applyBankConfig(
|
|
32924
32982
|
loadConfig({ harness: opts.harness }),
|
|
@@ -32948,7 +33006,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
32948
33006
|
config_override: Boolean(process.env.HINDSIGHT_CONFIG),
|
|
32949
33007
|
hooks_disabled: Boolean(process.env.HINDSIGHT_DISABLE_HOOKS),
|
|
32950
33008
|
log_level: process.env.HINDSIGHT_LOG_LEVEL ?? null,
|
|
32951
|
-
diagnostics_file:
|
|
33009
|
+
diagnostics_file: diagFilePath(),
|
|
32952
33010
|
channel_id_configured: Boolean(process.env.HINDSIGHT_CHANNEL_ID),
|
|
32953
33011
|
user_id_configured: Boolean(process.env.HINDSIGHT_USER_ID)
|
|
32954
33012
|
}
|