@vectorize-io/hindsight-coding-agents 0.8.2 → 0.8.3
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 +13 -3
- package/dist/antigravity-hook.js +95 -42
- package/dist/antigravity-statusline.js +6 -6
- package/dist/antigravity-stop-hook.js +132 -51
- package/dist/claude-hook.js +95 -42
- package/dist/claude-sessionstart-hook.js +383 -99
- package/dist/claude-stop-hook.js +132 -51
- package/dist/cline.js +401 -91
- package/dist/codebuddy-hook.js +95 -42
- package/dist/codebuddy-sessionstart-hook.js +383 -99
- package/dist/codebuddy-stop-hook.js +132 -51
- package/dist/codex-hook.js +95 -42
- package/dist/codex-sessionstart-hook.js +383 -99
- package/dist/codex-stop-hook.js +132 -51
- package/dist/copilot-hook.js +95 -42
- package/dist/copilot-sessionstart-hook.js +383 -99
- package/dist/copilot-stop-hook.js +132 -51
- package/dist/cursor-hook.js +95 -42
- package/dist/cursor-sessionstart-hook.js +383 -99
- package/dist/cursor-stop-hook.js +132 -51
- package/dist/daemon-start.js +10 -10
- package/dist/dcode-hook.js +95 -42
- package/dist/dcode-sessionstart-hook.js +383 -99
- package/dist/dcode-stop-hook.js +132 -51
- package/dist/deepen.js +82 -23
- package/dist/devin-hook.js +95 -42
- package/dist/devin-sessionstart-hook.js +383 -99
- package/dist/devin-stop-hook.js +132 -51
- package/dist/droid-hook.js +95 -42
- package/dist/droid-sessionstart-hook.js +383 -99
- package/dist/droid-stop-hook.js +132 -51
- package/dist/dsh.js +420 -98
- package/dist/grok-hook.js +95 -42
- package/dist/grok-sessionstart-hook.js +383 -99
- package/dist/grok-stop-hook.js +132 -51
- package/dist/hindsight-seed.js +6 -6
- package/dist/index.js +425 -110
- package/dist/installer.js +89 -80
- package/dist/kilo.js +425 -110
- package/dist/kimi-hook.js +95 -42
- package/dist/kimi-sessionstart-hook.js +383 -99
- package/dist/kimi-stop-hook.js +132 -51
- package/dist/mcp-server.js +169 -62
- package/dist/opencode2.js +581 -104
- package/dist/pi.js +401 -98
- package/dist/prime-agent.js +401 -98
- package/dist/qwen-hook.js +95 -42
- package/dist/qwen-sessionstart-hook.js +383 -99
- package/dist/qwen-stop-hook.js +132 -51
- package/dist/status.js +67 -17
- package/dist/survey-supervisor.js +73 -9
- package/dist/traecode-hook.js +95 -42
- package/dist/traecode-sessionstart-hook.js +383 -99
- package/dist/traecode-stop-hook.js +132 -51
- package/dist/workbuddy-hook.js +95 -42
- package/dist/workbuddy-sessionstart-hook.js +383 -99
- package/dist/workbuddy-stop-hook.js +132 -51
- package/dist/zcode-hook.js +95 -42
- package/dist/zcode-sessionstart-hook.js +383 -99
- package/dist/zcode-stop-hook.js +132 -51
- package/index.js +4 -1
- package/package.json +6 -4
- package/plugin.json +1 -1
- package/skill/SKILL.md +10 -2
package/dist/zcode-stop-hook.js
CHANGED
|
@@ -207,14 +207,14 @@ function probeGitLayout(directory) {
|
|
|
207
207
|
var PLACEHOLDER = /\{([a-zA-Z_]+)\}/g;
|
|
208
208
|
function applyTemplate(template, resolvers, what) {
|
|
209
209
|
return template.replace(PLACEHOLDER, (_, name) => {
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
210
|
+
const resolve4 = resolvers[name];
|
|
211
|
+
if (!resolve4) {
|
|
212
212
|
console.error(
|
|
213
213
|
`hindsight: unknown ${what} placeholder "{${name}}" \u2014 valid: ` + Object.keys(resolvers).sort().map((k) => `{${k}}`).join(", ")
|
|
214
214
|
);
|
|
215
215
|
return "unknown";
|
|
216
216
|
}
|
|
217
|
-
return
|
|
217
|
+
return resolve4();
|
|
218
218
|
});
|
|
219
219
|
}
|
|
220
220
|
|
|
@@ -633,11 +633,11 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
633
633
|
}
|
|
634
634
|
|
|
635
635
|
// package.json
|
|
636
|
-
var version = "0.8.
|
|
636
|
+
var version = "0.8.3";
|
|
637
637
|
|
|
638
638
|
// src/core/util.ts
|
|
639
|
-
import { accessSync, constants } from "fs";
|
|
640
|
-
import { delimiter, join as join6 } from "path";
|
|
639
|
+
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
640
|
+
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
641
641
|
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
642
642
|
function semverGte(version2, min) {
|
|
643
643
|
const parts = (v) => {
|
|
@@ -915,15 +915,19 @@ var HindsightClient = class {
|
|
|
915
915
|
}
|
|
916
916
|
/**
|
|
917
917
|
* Whether this server honours `operation_id` on an async retain, and can therefore be appended to
|
|
918
|
-
* safely (see MIN_IDEMPOTENT_RETAIN_VERSION). Probed
|
|
918
|
+
* safely (see MIN_IDEMPOTENT_RETAIN_VERSION). Probed via the version endpoint; anything
|
|
919
919
|
* unreachable, unparseable or older answers "no", which costs efficiency, never correctness.
|
|
920
|
+
* Only a "yes" is cached: a long-lived plugin client would otherwise keep replacing for the rest
|
|
921
|
+
* of the process after one probe that hit a restarting server (#5735).
|
|
920
922
|
*/
|
|
921
923
|
async supportsIdempotentRetain() {
|
|
922
|
-
if (this.idempotentRetain
|
|
923
|
-
|
|
924
|
-
|
|
924
|
+
if (this.idempotentRetain) return true;
|
|
925
|
+
const supported = await this.probeIdempotentRetain();
|
|
926
|
+
if (supported || this.idempotentRetain === void 0) {
|
|
927
|
+
this.log(`server retain idempotency: ${supported ? "supported" : "unavailable"}`);
|
|
925
928
|
}
|
|
926
|
-
|
|
929
|
+
this.idempotentRetain = supported;
|
|
930
|
+
return supported;
|
|
927
931
|
}
|
|
928
932
|
/** `/v1/version` first: an ingress that routes only `/v1` to the API (the Helm chart's default)
|
|
929
933
|
* hands a bare `/version` to the control plane, whose HTML 404 or login redirect read as "no",
|
|
@@ -1951,7 +1955,7 @@ function fileCursorStore(harness) {
|
|
|
1951
1955
|
}
|
|
1952
1956
|
|
|
1953
1957
|
// src/core/turn-journal.ts
|
|
1954
|
-
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as
|
|
1958
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
1955
1959
|
import { tmpdir as tmpdir2 } from "os";
|
|
1956
1960
|
import { dirname as dirname6, join as join9 } from "path";
|
|
1957
1961
|
|
|
@@ -1999,7 +2003,7 @@ function appendJournalTurn(path, turn) {
|
|
|
1999
2003
|
const content = stripInjectedMemory(turn.content ?? "").trim();
|
|
2000
2004
|
if (!content) return;
|
|
2001
2005
|
try {
|
|
2002
|
-
if (
|
|
2006
|
+
if (statSync3(path).size >= JOURNAL_MAX_BYTES) return;
|
|
2003
2007
|
} catch {
|
|
2004
2008
|
}
|
|
2005
2009
|
const last = readJournalTranscript(path).at(-1);
|
|
@@ -2061,6 +2065,18 @@ function pendingReplayable(cursor, now) {
|
|
|
2061
2065
|
if (pending.some((p) => now - p.at > PENDING_MAX_AGE_MS)) return false;
|
|
2062
2066
|
return pending.reduce((n, p) => n + p.content.length, 0) <= PENDING_MAX_BYTES;
|
|
2063
2067
|
}
|
|
2068
|
+
function advanceSegments(cursor, bank) {
|
|
2069
|
+
if (!cursor || cursor.bank === bank) return cursor?.segments;
|
|
2070
|
+
return [...cursor.segments ?? [{ bank: cursor.bank, from: 0 }], { bank, from: cursor.turns }];
|
|
2071
|
+
}
|
|
2072
|
+
function bankTurns(turns, segments, bank) {
|
|
2073
|
+
if (!segments) return turns;
|
|
2074
|
+
return turns.filter((_, i) => {
|
|
2075
|
+
let owner;
|
|
2076
|
+
for (const s of segments) if (s.from <= i) owner = s.bank;
|
|
2077
|
+
return owner === bank;
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2064
2080
|
var MAX_CURSOR_OPS = 8;
|
|
2065
2081
|
function fingerprintTurns(turns, count) {
|
|
2066
2082
|
const h = createHash2("sha1").update(String(count));
|
|
@@ -2071,7 +2087,8 @@ function planRetain(turns, cursor, opts) {
|
|
|
2071
2087
|
if (!turns.length) return { mode: "skip" };
|
|
2072
2088
|
if (!opts.appendSupported || !cursor || cursor.dirty) return { mode: "replace" };
|
|
2073
2089
|
if (!pendingReplayable(cursor, opts.now ?? Date.now())) return { mode: "replace" };
|
|
2074
|
-
if (cursor.bank !== opts.bank)
|
|
2090
|
+
if (cursor.bank !== opts.bank && !cursor.segments?.some((s) => s.bank === opts.bank))
|
|
2091
|
+
return { mode: "replace" };
|
|
2075
2092
|
const seen = cursor.paths ?? [];
|
|
2076
2093
|
const newFile = Boolean(opts.path && seen.length && !seen.includes(opts.path));
|
|
2077
2094
|
const continues = cursor.turns <= turns.length && fingerprintTurns(turns, cursor.turns) === cursor.fingerprint;
|
|
@@ -2206,8 +2223,17 @@ async function writeSession(client, sessionId, turns, startTs, harness, stamp, c
|
|
|
2206
2223
|
let cursor = cursors?.read(sessionId);
|
|
2207
2224
|
const probed = Boolean(cursors) && cursor?.appendSupported !== true;
|
|
2208
2225
|
const appendSupported = Boolean(cursors) && (cursor?.appendSupported === true || await supportsAppend(client));
|
|
2226
|
+
const moved = Boolean(cursor && cursor.bank !== client.bank);
|
|
2227
|
+
if (moved)
|
|
2228
|
+
log.warn(harness ?? "", "session moved to another bank mid-session", {
|
|
2229
|
+
session: sessionId,
|
|
2230
|
+
from: cursor?.bank,
|
|
2231
|
+
to: client.bank,
|
|
2232
|
+
atTurn: cursor?.turns
|
|
2233
|
+
});
|
|
2234
|
+
const segments = advanceSegments(cursor, client.bank);
|
|
2209
2235
|
let ops = [];
|
|
2210
|
-
if (appendSupported && cursor?.ops?.length && !cursor.dirty)
|
|
2236
|
+
if (appendSupported && cursor?.ops?.length && !cursor.dirty && !moved)
|
|
2211
2237
|
({ cursor, ops } = await settleOps(client, cursor));
|
|
2212
2238
|
const plan = planRetain(turns, cursor, {
|
|
2213
2239
|
appendSupported,
|
|
@@ -2216,7 +2242,7 @@ async function writeSession(client, sessionId, turns, startTs, harness, stamp, c
|
|
|
2216
2242
|
});
|
|
2217
2243
|
if (probed) diag(harness ?? "", "retain_mode", { mode: plan.mode, appendSupported });
|
|
2218
2244
|
const paths = plan.mode === "replace" ? transcriptPath ? [transcriptPath] : void 0 : advancePaths(cursor?.paths, transcriptPath);
|
|
2219
|
-
const outbox = plan.mode === "replace" ? [] : cursor?.pending ?? [];
|
|
2245
|
+
const outbox = plan.mode === "replace" || moved ? [] : cursor?.pending ?? [];
|
|
2220
2246
|
if (plan.mode === "skip" && !outbox.length) return;
|
|
2221
2247
|
const opId = (mode, content) => uuidV5(`${client.bank}
|
|
2222
2248
|
${refId}
|
|
@@ -2258,6 +2284,7 @@ ${content}`);
|
|
|
2258
2284
|
fingerprint: fingerprintTurns(turns, turns.length),
|
|
2259
2285
|
bank: client.bank,
|
|
2260
2286
|
...paths ? { paths } : {},
|
|
2287
|
+
...segments ? { segments } : {},
|
|
2261
2288
|
...appendSupported ? { appendSupported: true } : {}
|
|
2262
2289
|
};
|
|
2263
2290
|
const accepted = (id) => {
|
|
@@ -2270,9 +2297,14 @@ ${content}`);
|
|
|
2270
2297
|
return now?.turns === next.turns && now?.fingerprint === next.fingerprint;
|
|
2271
2298
|
};
|
|
2272
2299
|
if (plan.mode === "replace") {
|
|
2273
|
-
const
|
|
2300
|
+
const share = bankTurns(turns, segments, client.bank);
|
|
2301
|
+
if (!share.length) return;
|
|
2302
|
+
const content = renderSessionJsonl(refId, share, startTs);
|
|
2303
|
+
const base = cursor ? `${cursor.turns}
|
|
2304
|
+
${cursor.fingerprint}` : "";
|
|
2274
2305
|
cursors?.write(sessionId, { ...next, dirty: true });
|
|
2275
|
-
const operationId = opId("replace",
|
|
2306
|
+
const operationId = opId("replace", `${base}
|
|
2307
|
+
${content}`);
|
|
2276
2308
|
await submitWithRetry(() => submit(content, operationId, false), stillOurs, retryUntil);
|
|
2277
2309
|
ops = [];
|
|
2278
2310
|
cursors?.write(sessionId, accepted(operationId));
|
|
@@ -2396,8 +2428,8 @@ async function waitBounded(p, ms) {
|
|
|
2396
2428
|
try {
|
|
2397
2429
|
await Promise.race([
|
|
2398
2430
|
p,
|
|
2399
|
-
new Promise((
|
|
2400
|
-
timer = setTimeout(
|
|
2431
|
+
new Promise((resolve4) => {
|
|
2432
|
+
timer = setTimeout(resolve4, Math.max(ms, 0));
|
|
2401
2433
|
})
|
|
2402
2434
|
]);
|
|
2403
2435
|
} finally {
|
|
@@ -2489,12 +2521,12 @@ function buildRetainStamp(cfg, ctx) {
|
|
|
2489
2521
|
const base = resolversFor(ctx);
|
|
2490
2522
|
const cache = /* @__PURE__ */ new Map();
|
|
2491
2523
|
const resolvers = Object.fromEntries(
|
|
2492
|
-
Object.entries(base).map(([name,
|
|
2524
|
+
Object.entries(base).map(([name, resolve4]) => [
|
|
2493
2525
|
name,
|
|
2494
2526
|
() => {
|
|
2495
2527
|
const hit = cache.get(name);
|
|
2496
2528
|
if (hit !== void 0) return hit;
|
|
2497
|
-
const value =
|
|
2529
|
+
const value = resolve4();
|
|
2498
2530
|
cache.set(name, value);
|
|
2499
2531
|
return value;
|
|
2500
2532
|
}
|
|
@@ -2765,7 +2797,7 @@ async function runRetainHook(spec, makeClient = (o) => new HindsightClient(o)) {
|
|
|
2765
2797
|
|
|
2766
2798
|
// src/core/git.ts
|
|
2767
2799
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
2768
|
-
import { resolve as
|
|
2800
|
+
import { resolve as resolve3 } from "path";
|
|
2769
2801
|
var US = "";
|
|
2770
2802
|
var RS = "";
|
|
2771
2803
|
var GITLOG_FORMAT = `--format=%h${US}%ad${US}%an${US}%s${US}%b${RS}`;
|
|
@@ -2776,11 +2808,14 @@ import { execFileSync as execFileSync4 } from "child_process";
|
|
|
2776
2808
|
// src/core/survey.ts
|
|
2777
2809
|
import { execFileSync as execFileSync3, spawn as realSpawn4 } from "child_process";
|
|
2778
2810
|
import { createHash as createHash4 } from "crypto";
|
|
2779
|
-
import { existsSync as existsSync3 } from "fs";
|
|
2811
|
+
import { existsSync as existsSync3, readFileSync as readFileSync7, writeFileSync as writeFileSync3 } from "fs";
|
|
2780
2812
|
import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
|
|
2781
2813
|
import { dirname as dirname8, join as join13 } from "path";
|
|
2782
2814
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2783
2815
|
|
|
2816
|
+
// node_modules/smol-toml/dist/stringify.js
|
|
2817
|
+
var HAS_WELLFORMED = !!"".isWellFormed;
|
|
2818
|
+
|
|
2784
2819
|
// src/core/survey-lease.ts
|
|
2785
2820
|
import { spawn as realSpawn3 } from "child_process";
|
|
2786
2821
|
import { randomUUID } from "crypto";
|
|
@@ -2791,7 +2826,7 @@ import {
|
|
|
2791
2826
|
renameSync as renameSync3,
|
|
2792
2827
|
rmdirSync,
|
|
2793
2828
|
rmSync as rmSync2,
|
|
2794
|
-
statSync as
|
|
2829
|
+
statSync as statSync4,
|
|
2795
2830
|
unlinkSync,
|
|
2796
2831
|
utimesSync,
|
|
2797
2832
|
writeFileSync as writeFileSync2
|
|
@@ -2803,10 +2838,10 @@ import { spawn as realSpawn5 } from "child_process";
|
|
|
2803
2838
|
import {
|
|
2804
2839
|
existsSync as existsSync4,
|
|
2805
2840
|
mkdirSync as mkdirSync5,
|
|
2806
|
-
readFileSync as
|
|
2841
|
+
readFileSync as readFileSync8,
|
|
2807
2842
|
realpathSync as realpathSync2,
|
|
2808
2843
|
unlinkSync as unlinkSync2,
|
|
2809
|
-
writeFileSync as
|
|
2844
|
+
writeFileSync as writeFileSync4
|
|
2810
2845
|
} from "fs";
|
|
2811
2846
|
import { homedir as homedir5, tmpdir as tmpdir4 } from "os";
|
|
2812
2847
|
import { dirname as dirname9, join as join14 } from "path";
|
|
@@ -2817,7 +2852,7 @@ var NPM_VIEW_HARD_DEADLINE_MS = NPM_VIEW_TIMEOUT_MS + 1e3;
|
|
|
2817
2852
|
var LOCK_STALE_MS = 10 * 60 * 1e3;
|
|
2818
2853
|
|
|
2819
2854
|
// src/core/skill-sync.ts
|
|
2820
|
-
import { cpSync, existsSync as existsSync6, readFileSync as
|
|
2855
|
+
import { cpSync, existsSync as existsSync6, readFileSync as readFileSync9 } from "fs";
|
|
2821
2856
|
import { homedir as homedir6 } from "os";
|
|
2822
2857
|
import { dirname as dirname10, join as join16 } from "path";
|
|
2823
2858
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -2827,15 +2862,15 @@ import { existsSync as existsSync5 } from "fs";
|
|
|
2827
2862
|
import { join as join15 } from "path";
|
|
2828
2863
|
|
|
2829
2864
|
// src/core/legacy.ts
|
|
2830
|
-
import { existsSync as existsSync7, readFileSync as
|
|
2865
|
+
import { existsSync as existsSync7, readFileSync as readFileSync10 } from "fs";
|
|
2831
2866
|
import { homedir as homedir7 } from "os";
|
|
2832
|
-
import { join as join17, relative, isAbsolute as
|
|
2867
|
+
import { join as join17, relative, isAbsolute as isAbsolute3 } from "path";
|
|
2833
2868
|
|
|
2834
2869
|
// src/core/traecode-mcp.ts
|
|
2835
2870
|
import { execFileSync as execFileSync5 } from "child_process";
|
|
2836
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as
|
|
2871
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync11, readdirSync as readdirSync2, rmSync as rmSync3, writeFileSync as writeFileSync5 } from "fs";
|
|
2837
2872
|
import { homedir as homedir8 } from "os";
|
|
2838
|
-
import { dirname as dirname11, isAbsolute as
|
|
2873
|
+
import { dirname as dirname11, isAbsolute as isAbsolute4, join as join18 } from "path";
|
|
2839
2874
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
2840
2875
|
var MCP_SERVER_NAME = "hindsight";
|
|
2841
2876
|
var MCP_FILE_REL = join18(".trae", "mcp.json");
|
|
@@ -2870,7 +2905,7 @@ function gateStateFile() {
|
|
|
2870
2905
|
}
|
|
2871
2906
|
function readGateState(opts = {}) {
|
|
2872
2907
|
try {
|
|
2873
|
-
return JSON.parse(
|
|
2908
|
+
return JSON.parse(readFileSync11(opts.stateFile ?? gateStateFile(), "utf8"));
|
|
2874
2909
|
} catch {
|
|
2875
2910
|
return {};
|
|
2876
2911
|
}
|
|
@@ -2878,7 +2913,7 @@ function readGateState(opts = {}) {
|
|
|
2878
2913
|
function workspaceMcpGateState(settingsPath) {
|
|
2879
2914
|
let raw;
|
|
2880
2915
|
try {
|
|
2881
|
-
raw =
|
|
2916
|
+
raw = readFileSync11(settingsPath, "utf8");
|
|
2882
2917
|
} catch {
|
|
2883
2918
|
return "unknown";
|
|
2884
2919
|
}
|
|
@@ -2900,7 +2935,7 @@ function workspaceMcpHint(opts = {}) {
|
|
|
2900
2935
|
if (typeof state.lastHint === "number" && now - state.lastHint < HINT_MIN_INTERVAL_MS) {
|
|
2901
2936
|
return void 0;
|
|
2902
2937
|
}
|
|
2903
|
-
|
|
2938
|
+
writeFileSync5(
|
|
2904
2939
|
opts.stateFile ?? gateStateFile(),
|
|
2905
2940
|
JSON.stringify({ ...state, lastHint: now }, null, 2) + "\n"
|
|
2906
2941
|
);
|
|
@@ -2918,10 +2953,10 @@ function gitignoreCovers(lines) {
|
|
|
2918
2953
|
function ensureGitignored(repo) {
|
|
2919
2954
|
const gitignore = join18(repo, ".gitignore");
|
|
2920
2955
|
if (!existsSync8(gitignore)) return;
|
|
2921
|
-
const current2 =
|
|
2956
|
+
const current2 = readFileSync11(gitignore, "utf8");
|
|
2922
2957
|
if (gitignoreCovers(current2.split("\n"))) return;
|
|
2923
2958
|
const addition = (current2.endsWith("\n") || current2 === "" ? "" : "\n") + "# hindsight MCP registration (machine-specific)\n.trae/mcp.json\n";
|
|
2924
|
-
|
|
2959
|
+
writeFileSync5(gitignore, current2 + addition);
|
|
2925
2960
|
}
|
|
2926
2961
|
function ensureTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
2927
2962
|
registerTraecodeWorkspaceMcp(cwd, opts);
|
|
@@ -2931,7 +2966,7 @@ function ensureTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2931
2966
|
function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
2932
2967
|
try {
|
|
2933
2968
|
const home = opts.home ?? homedir8();
|
|
2934
|
-
if (!cwd || !
|
|
2969
|
+
if (!cwd || !isAbsolute4(cwd) || dirname11(cwd) === cwd || cwd === home) return "skipped";
|
|
2935
2970
|
const dist = opts.dist ?? bundledDistDir();
|
|
2936
2971
|
const script = join18(dist, "mcp-server.js");
|
|
2937
2972
|
if (!existsSync8(script)) return "skipped";
|
|
@@ -2939,7 +2974,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2939
2974
|
let doc = {};
|
|
2940
2975
|
let exists = false;
|
|
2941
2976
|
try {
|
|
2942
|
-
doc = JSON.parse(
|
|
2977
|
+
doc = JSON.parse(readFileSync11(file, "utf8"));
|
|
2943
2978
|
exists = true;
|
|
2944
2979
|
} catch {
|
|
2945
2980
|
if (existsSync8(file)) return "skipped";
|
|
@@ -2969,7 +3004,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2969
3004
|
if (existing !== void 0 && canon(merged) === canon(existing)) return "current";
|
|
2970
3005
|
servers[MCP_SERVER_NAME] = merged;
|
|
2971
3006
|
mkdirSync6(dirname11(file), { recursive: true });
|
|
2972
|
-
|
|
3007
|
+
writeFileSync5(file, JSON.stringify(doc, null, 2) + "\n");
|
|
2973
3008
|
if (!exists) ensureGitignored(cwd);
|
|
2974
3009
|
diag("traecode", "workspace_mcp_registered", { cwd, file });
|
|
2975
3010
|
return "registered";
|
|
@@ -2995,7 +3030,7 @@ function findWorkspaceStorageDir(storage, repo) {
|
|
|
2995
3030
|
}
|
|
2996
3031
|
for (const name of entries) {
|
|
2997
3032
|
try {
|
|
2998
|
-
const doc = JSON.parse(
|
|
3033
|
+
const doc = JSON.parse(readFileSync11(join18(storage, name, "workspace.json"), "utf8"));
|
|
2999
3034
|
if (typeof doc.folder !== "string") continue;
|
|
3000
3035
|
let folder;
|
|
3001
3036
|
try {
|
|
@@ -3013,7 +3048,7 @@ function findWorkspaceStorageDir(storage, repo) {
|
|
|
3013
3048
|
function ensureWorkspaceMcpEnabled(cwd, opts = {}) {
|
|
3014
3049
|
try {
|
|
3015
3050
|
const home = opts.home ?? homedir8();
|
|
3016
|
-
if (!cwd || !
|
|
3051
|
+
if (!cwd || !isAbsolute4(cwd) || dirname11(cwd) === cwd || cwd === home) return "failed";
|
|
3017
3052
|
const dir = findWorkspaceStorageDir(traecodeWorkspaceStorageDir(home), cwd);
|
|
3018
3053
|
if (!dir) return "failed";
|
|
3019
3054
|
const db = join18(dir, "state.vscdb");
|
|
@@ -3048,7 +3083,7 @@ function workspaceEnableHint(opts = {}) {
|
|
|
3048
3083
|
if (typeof state.lastEnableHint === "number" && now - state.lastEnableHint < HINT_MIN_INTERVAL_MS) {
|
|
3049
3084
|
return void 0;
|
|
3050
3085
|
}
|
|
3051
|
-
|
|
3086
|
+
writeFileSync5(
|
|
3052
3087
|
opts.stateFile ?? gateStateFile(),
|
|
3053
3088
|
JSON.stringify({ ...state, lastEnableHint: now }, null, 2) + "\n"
|
|
3054
3089
|
);
|
|
@@ -3230,6 +3265,10 @@ function readCursorTranscript(path) {
|
|
|
3230
3265
|
}
|
|
3231
3266
|
|
|
3232
3267
|
// src/core/transcript-antigravity.ts
|
|
3268
|
+
function unwrapUserRequest(text) {
|
|
3269
|
+
const request = /<USER_REQUEST>([\s\S]*?)<\/USER_REQUEST>/.exec(text);
|
|
3270
|
+
return request ? request[1] : text.replace(/<ADDITIONAL_METADATA>[\s\S]*?<\/ADDITIONAL_METADATA>/g, "");
|
|
3271
|
+
}
|
|
3233
3272
|
function readAntigravityTranscript(path) {
|
|
3234
3273
|
if (!path) return [];
|
|
3235
3274
|
const turns = [];
|
|
@@ -3239,7 +3278,8 @@ function readAntigravityTranscript(path) {
|
|
|
3239
3278
|
const role = event.role ?? event.message?.role ?? event.type;
|
|
3240
3279
|
const normalizedRole = role === "user" || role === "USER_INPUT" ? "user" : role === "assistant" || role === "model" || role === "PLANNER_RESPONSE" ? "assistant" : void 0;
|
|
3241
3280
|
const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
|
|
3242
|
-
const
|
|
3281
|
+
const text = typeof content === "string" ? stripInjectedMemory(content) : "";
|
|
3282
|
+
const clean = (normalizedRole === "user" ? unwrapUserRequest(text) : text).trim();
|
|
3243
3283
|
if (normalizedRole && clean) {
|
|
3244
3284
|
turns.push({
|
|
3245
3285
|
role: normalizedRole,
|
|
@@ -3270,7 +3310,7 @@ function readCopilotTranscript(path) {
|
|
|
3270
3310
|
}
|
|
3271
3311
|
|
|
3272
3312
|
// src/core/transcript-grok.ts
|
|
3273
|
-
import { existsSync as existsSync9, readFileSync as
|
|
3313
|
+
import { existsSync as existsSync9, readFileSync as readFileSync12, readdirSync as readdirSync3 } from "fs";
|
|
3274
3314
|
import { homedir as homedir9 } from "os";
|
|
3275
3315
|
import { join as join19 } from "path";
|
|
3276
3316
|
var CHAT_HISTORY = "chat_history.jsonl";
|
|
@@ -3281,7 +3321,7 @@ function grokTranscriptPath(cwd, sessionId, grokHome = process.env.GROK_HOME ||
|
|
|
3281
3321
|
try {
|
|
3282
3322
|
for (const candidate of readdirSync3(sessionsDir)) {
|
|
3283
3323
|
const directory = join19(sessionsDir, candidate);
|
|
3284
|
-
if (
|
|
3324
|
+
if (readFileSync12(join19(directory, ".cwd"), "utf8").trim() === cwd) {
|
|
3285
3325
|
return join19(directory, sessionId, CHAT_HISTORY);
|
|
3286
3326
|
}
|
|
3287
3327
|
}
|
|
@@ -3632,7 +3672,7 @@ function readDroidTranscript(path) {
|
|
|
3632
3672
|
}
|
|
3633
3673
|
|
|
3634
3674
|
// src/core/transcript-zcode.ts
|
|
3635
|
-
import { readFileSync as
|
|
3675
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
3636
3676
|
function messageText(content) {
|
|
3637
3677
|
if (typeof content === "string") return content.trim();
|
|
3638
3678
|
if (!Array.isArray(content)) return "";
|
|
@@ -3642,7 +3682,7 @@ function readZcodeTranscript(path) {
|
|
|
3642
3682
|
if (!path) return [];
|
|
3643
3683
|
let body;
|
|
3644
3684
|
try {
|
|
3645
|
-
body =
|
|
3685
|
+
body = readFileSync13(path, "utf8");
|
|
3646
3686
|
} catch {
|
|
3647
3687
|
return [];
|
|
3648
3688
|
}
|
|
@@ -3863,12 +3903,12 @@ function readWorkbuddyTranscript(path) {
|
|
|
3863
3903
|
}
|
|
3864
3904
|
|
|
3865
3905
|
// src/core/transcript-codebuddy-ide.ts
|
|
3866
|
-
import { readFileSync as
|
|
3906
|
+
import { readFileSync as readFileSync14 } from "fs";
|
|
3867
3907
|
import { basename as basename3, dirname as dirname12, join as join22 } from "path";
|
|
3868
3908
|
var IDE_CONTEXT_RE = /<(user_info|git_status|additional_data|system_reminder)\b[\s\S]*?<\/\1>/g;
|
|
3869
3909
|
function readJson(path) {
|
|
3870
3910
|
try {
|
|
3871
|
-
return JSON.parse(
|
|
3911
|
+
return JSON.parse(readFileSync14(path, "utf8"));
|
|
3872
3912
|
} catch {
|
|
3873
3913
|
return void 0;
|
|
3874
3914
|
}
|
|
@@ -4082,7 +4122,9 @@ var HOOK_HARNESSES = {
|
|
|
4082
4122
|
parse: (ev) => ({
|
|
4083
4123
|
sessionId: ev.session_id,
|
|
4084
4124
|
transcriptPath: ev.transcript_path,
|
|
4085
|
-
cwd: ev.cwd
|
|
4125
|
+
cwd: ev.cwd,
|
|
4126
|
+
// The transcript may not hold the final reply yet when Stop fires after a tool call (#5790).
|
|
4127
|
+
lastAssistantMessage: ev.last_assistant_message
|
|
4086
4128
|
})
|
|
4087
4129
|
}
|
|
4088
4130
|
},
|
|
@@ -4565,3 +4607,42 @@ var runHarnessRetain = (harness) => runRetainHook(HOOK_HARNESSES[harness].retain
|
|
|
4565
4607
|
|
|
4566
4608
|
// src/zcode-stop-hook.ts
|
|
4567
4609
|
void runHarnessRetain("zcode");
|
|
4610
|
+
/*! Bundled license information:
|
|
4611
|
+
|
|
4612
|
+
smol-toml/dist/error.js:
|
|
4613
|
+
smol-toml/dist/primitive.js:
|
|
4614
|
+
smol-toml/dist/date.js:
|
|
4615
|
+
smol-toml/dist/extract.js:
|
|
4616
|
+
smol-toml/dist/util.js:
|
|
4617
|
+
smol-toml/dist/struct.js:
|
|
4618
|
+
smol-toml/dist/parse.js:
|
|
4619
|
+
smol-toml/dist/stringify.js:
|
|
4620
|
+
smol-toml/dist/index.js:
|
|
4621
|
+
(*!
|
|
4622
|
+
* Copyright (c) Squirrel Chat et al., All rights reserved.
|
|
4623
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
4624
|
+
*
|
|
4625
|
+
* Redistribution and use in source and binary forms, with or without
|
|
4626
|
+
* modification, are permitted provided that the following conditions are met:
|
|
4627
|
+
*
|
|
4628
|
+
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
4629
|
+
* list of conditions and the following disclaimer.
|
|
4630
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
4631
|
+
* this list of conditions and the following disclaimer in the
|
|
4632
|
+
* documentation and/or other materials provided with the distribution.
|
|
4633
|
+
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
4634
|
+
* may be used to endorse or promote products derived from this software without
|
|
4635
|
+
* specific prior written permission.
|
|
4636
|
+
*
|
|
4637
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
4638
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
4639
|
+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
4640
|
+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
4641
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
4642
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
4643
|
+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
4644
|
+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
4645
|
+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
4646
|
+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
4647
|
+
*)
|
|
4648
|
+
*/
|
package/index.js
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
* sees v2's `plugins` key, so both hosts have to load from the ONE package path already registered
|
|
6
6
|
* in the user's `plugin` array. They resolve a plugin directory differently, which is what makes
|
|
7
7
|
* that work: v1 follows package.json `main` (→ dist/index.js, the v1 plugin), while v2 ignores
|
|
8
|
-
* `main` and loads `<dir>/index.js` — this file.
|
|
8
|
+
* `main` and loads `<dir>/index.js` — this file. A host that resolves the package by name instead
|
|
9
|
+
* (v2 2.2+ does that for any directory with a package.json `name` and `exports`) reads
|
|
10
|
+
* `exports["./server"]`, which also points here. Keep `exports["."]` on the v1 plugin: v1 hosts that
|
|
11
|
+
* resolve by name without reading `./server` follow it. See src/opencode2.ts.
|
|
9
12
|
*/
|
|
10
13
|
export { default, HindsightOpencode2Plugin } from "./dist/opencode2.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vectorize-io/hindsight-coding-agents",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/vectorize-io/hindsight.git",
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
"types": "./dist/index.d.ts",
|
|
57
57
|
"default": "./dist/index.js"
|
|
58
58
|
},
|
|
59
|
+
"./server": "./index.js",
|
|
59
60
|
"./dsh": "./dist/dsh.js",
|
|
60
61
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
61
62
|
"./package.json": "./package.json",
|
|
@@ -106,15 +107,16 @@
|
|
|
106
107
|
"smol-toml": "^1.8.0",
|
|
107
108
|
"tsup": "^8.3.0",
|
|
108
109
|
"typescript": "^5.6.0",
|
|
109
|
-
"vitest": "^4.1.
|
|
110
|
+
"vitest": "^4.1.12",
|
|
110
111
|
"zod": "^4.4.3"
|
|
111
112
|
},
|
|
112
113
|
"overrides": {
|
|
113
114
|
"esbuild": ">=0.25.0 <1.0.0",
|
|
114
|
-
"fast-uri": ">=3.1.
|
|
115
|
-
"hono": ">=4.13.
|
|
115
|
+
"fast-uri": ">=3.1.9 <4.0.0",
|
|
116
|
+
"hono": ">=4.13.11 <5.0.0",
|
|
116
117
|
"ip-address": ">=10.5.1 <11.0.0",
|
|
117
118
|
"postcss": ">=8.5.23 <9.0.0",
|
|
119
|
+
"toml": ">=5.0.1 <6.0.0",
|
|
118
120
|
"vite": ">=6.4.3 <7.0.0"
|
|
119
121
|
}
|
|
120
122
|
}
|
package/plugin.json
CHANGED
package/skill/SKILL.md
CHANGED
|
@@ -226,7 +226,7 @@ hook by Codex...), so one shared config serves several agents side by side:
|
|
|
226
226
|
| `pages` | every page | per-page configuration for the seeded knowledge pages, keyed by page name (case-insensitive): `false` skips a page entirely, `{"source_query": "..."}` seeds it with your question instead of the built-in one. Omitted, all five pages are seeded with their built-in queries. This is the supported way to own a page's wording — the plugin re-syncs a page whose live query differs from the one it is configured to have, so a query edited through the API or the control plane is replaced on the next session. A skipped page is **not deleted**: one already seeded keeps its content and stops being re-synced. The scoping clause is appended to your query too, so a reworded page cannot start reporting a dependency's decisions as this project's. File-only, like `recallOptions`; in a `banks.<id>` section it replaces the global map rather than merging into it |
|
|
227
227
|
| `customPages` | — | knowledge pages of your own, seeded alongside the five above and keyed by the name they get: `{"Security posture": {"source_query": "...", "tags": ["knowledge:decision"]}}`. `source_query` is required; `tags` picks which facts feed the page and is optional — omitted, the page draws on everything the bank holds. A separate setting from `pages` on purpose, so that an unknown name there stays a typo warning rather than quietly creating a page. File-only, and replaced (not merged) by a `banks.<id>` section |
|
|
228
228
|
| `autoSeed` | `true` | SessionStart: auto-seed a cold repo's bank from git history |
|
|
229
|
-
| `seedLimit` | `300` |
|
|
229
|
+
| `seedLimit` | `300` | git-log document size: a full write keeps the newest commits, between half of this and this many (the window moves in steps of half), and logs how many older ones it drops |
|
|
230
230
|
| `codebaseSurvey` | `true` | SessionStart: headless survey of a cold repo's structure, run under the current harness's own CLI (claude/codex/antigravity/opencode), falling back to any available agent |
|
|
231
231
|
| `surveyModel` | `haiku` | model for the survey — Claude recipe only (`claude -p --model`); other agents use their configured default |
|
|
232
232
|
| `surveyBudgetUsd` | `2` | survey spend cap — Claude recipe only (`claude -p --max-budget-usd`); other agents rely on their read-only sandbox |
|
|
@@ -561,6 +561,12 @@ Coding memory is **per repository**. Resolution order for the working directory:
|
|
|
561
561
|
The default `"coding-agent::{gitProject}"` is **harness-neutral**, so opencode, Claude Code, and Codex
|
|
562
562
|
all share one memory per repo — use `"{harness}-{gitProject}"` to split per agent instead.
|
|
563
563
|
|
|
564
|
+
The bank is resolved on every turn from where the agent is working. A session that moves into a
|
|
565
|
+
directory with a different bank (say, `cd` across a `mapPathToBank` prefix) **follows the folder from
|
|
566
|
+
that turn on**: the new bank gets the turns from the move onward, never the ones already saved
|
|
567
|
+
elsewhere, and going back appends to the conversation the first bank already holds. Each move is
|
|
568
|
+
logged as a warning in `plugin.log`.
|
|
569
|
+
|
|
564
570
|
### Recording where a memory came from
|
|
565
571
|
|
|
566
572
|
With a bank per repo, the bank _is_ the answer to "where did this come from". On a deliberately
|
|
@@ -701,7 +707,9 @@ npx @vectorize-io/hindsight-coding-agents stats
|
|
|
701
707
|
that: `"synced": true` means the seeded memory is queryable. It also reports gitlog freshness, how
|
|
702
708
|
far per-commit deepening has got, the codebase survey's state (`surveyBaseline` is the HEAD the last
|
|
703
709
|
survey started from, `surveyDocs` counts the findings documents that have landed, 0–4 — a baseline
|
|
704
|
-
with no findings retries automatically), and the extraction
|
|
710
|
+
with no findings retries automatically, at most three times per commit), and the extraction
|
|
711
|
+
operations still in flight. Each survey agent that could not be found, failed to launch or exited
|
|
712
|
+
with an error leaves one `[survey]` line in the plugin log.
|
|
705
713
|
|
|
706
714
|
### Resetting a repo's memory
|
|
707
715
|
|