@vectorize-io/hindsight-coding-agents 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/antigravity-hook.js +67 -33
- package/dist/antigravity-stop-hook.js +61 -31
- package/dist/claude-hook.js +67 -33
- package/dist/claude-sessionstart-hook.js +239 -71
- package/dist/claude-stop-hook.js +61 -31
- package/dist/cline.js +213 -50
- package/dist/codex-hook.js +67 -33
- package/dist/codex-sessionstart-hook.js +239 -71
- package/dist/codex-stop-hook.js +61 -31
- package/dist/copilot-hook.js +67 -33
- package/dist/copilot-sessionstart-hook.js +239 -71
- package/dist/copilot-stop-hook.js +61 -31
- package/dist/cursor-hook.js +67 -33
- package/dist/cursor-sessionstart-hook.js +239 -71
- package/dist/cursor-stop-hook.js +61 -31
- package/dist/dcode-hook.js +67 -33
- package/dist/dcode-sessionstart-hook.js +239 -71
- package/dist/dcode-stop-hook.js +61 -31
- package/dist/deepen.js +40 -13
- package/dist/devin-hook.js +67 -33
- package/dist/devin-sessionstart-hook.js +239 -71
- package/dist/devin-stop-hook.js +61 -31
- package/dist/droid-hook.js +67 -33
- package/dist/droid-sessionstart-hook.js +239 -71
- package/dist/droid-stop-hook.js +61 -31
- package/dist/dsh.js +215 -52
- package/dist/grok-hook.js +67 -33
- package/dist/grok-sessionstart-hook.js +239 -71
- package/dist/grok-stop-hook.js +61 -31
- package/dist/index.js +215 -52
- package/dist/installer.js +1030 -268
- package/dist/kilo.js +215 -52
- package/dist/mcp-server.js +33 -6
- package/dist/opencode2.js +215 -52
- package/dist/pi.js +214 -51
- package/dist/prime-agent.js +214 -51
- package/dist/qwen-hook.js +67 -33
- package/dist/qwen-sessionstart-hook.js +239 -71
- package/dist/qwen-stop-hook.js +61 -31
- package/dist/status.js +31 -4
- package/dist/survey-supervisor.js +81 -0
- package/dist/zcode-hook.js +67 -33
- package/dist/zcode-sessionstart-hook.js +239 -71
- package/dist/zcode-stop-hook.js +61 -31
- package/package.json +2 -1
- package/plugin.json +1 -1
package/dist/pi.js
CHANGED
|
@@ -15483,9 +15483,16 @@ var HindsightClient = class {
|
|
|
15483
15483
|
body: JSON.stringify({ query, budget: opts.budget ?? "high" }),
|
|
15484
15484
|
signal: ctrl.signal
|
|
15485
15485
|
});
|
|
15486
|
-
if (!resp.ok)
|
|
15486
|
+
if (!resp.ok)
|
|
15487
|
+
throw new Error(
|
|
15488
|
+
`reflect ${resp.status} ${(await resp.text()).slice(0, 1e3)}${this.authHint(resp.status)}`
|
|
15489
|
+
);
|
|
15487
15490
|
const data = await resp.json();
|
|
15488
15491
|
return (data.text || "").trim();
|
|
15492
|
+
} catch (e) {
|
|
15493
|
+
if (ctrl.signal.aborted)
|
|
15494
|
+
throw new Error(`reflect timed out after ${opts.timeoutMs}ms`, { cause: e });
|
|
15495
|
+
throw e;
|
|
15489
15496
|
} finally {
|
|
15490
15497
|
clearTimeout(timer);
|
|
15491
15498
|
}
|
|
@@ -16353,7 +16360,7 @@ function preflightDaemon(cfg, harness) {
|
|
|
16353
16360
|
// src/core/knowledge-tools.ts
|
|
16354
16361
|
import { existsSync as existsSync4 } from "fs";
|
|
16355
16362
|
import { homedir as homedir5 } from "os";
|
|
16356
|
-
import { join as
|
|
16363
|
+
import { join as join11 } from "path";
|
|
16357
16364
|
|
|
16358
16365
|
// src/core/status.ts
|
|
16359
16366
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
@@ -16439,11 +16446,86 @@ ${toolGuide(opts)}
|
|
|
16439
16446
|
}
|
|
16440
16447
|
|
|
16441
16448
|
// src/core/survey.ts
|
|
16442
|
-
import { spawn as
|
|
16449
|
+
import { spawn as realSpawn5 } from "child_process";
|
|
16450
|
+
import { createHash as createHash2 } from "crypto";
|
|
16443
16451
|
import { existsSync as existsSync3 } from "fs";
|
|
16444
|
-
import { homedir as homedir4 } from "os";
|
|
16445
|
-
import { dirname as dirname7, join as
|
|
16452
|
+
import { homedir as homedir4, tmpdir as tmpdir3 } from "os";
|
|
16453
|
+
import { dirname as dirname7, join as join10 } from "path";
|
|
16446
16454
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
16455
|
+
|
|
16456
|
+
// src/core/survey-lease.ts
|
|
16457
|
+
import { spawn as realSpawn4 } from "child_process";
|
|
16458
|
+
import { randomUUID } from "crypto";
|
|
16459
|
+
import {
|
|
16460
|
+
mkdirSync as mkdirSync3,
|
|
16461
|
+
mkdtempSync,
|
|
16462
|
+
readdirSync,
|
|
16463
|
+
renameSync,
|
|
16464
|
+
rmdirSync,
|
|
16465
|
+
rmSync,
|
|
16466
|
+
statSync,
|
|
16467
|
+
unlinkSync as unlinkSync2,
|
|
16468
|
+
utimesSync,
|
|
16469
|
+
writeFileSync as writeFileSync2
|
|
16470
|
+
} from "fs";
|
|
16471
|
+
import { join as join9 } from "path";
|
|
16472
|
+
var LEASE_STALE_MS = 3e4;
|
|
16473
|
+
var SURVEY_SPEC_ENV = "HINDSIGHT_SURVEY_SPEC";
|
|
16474
|
+
function tryRename(from, to) {
|
|
16475
|
+
try {
|
|
16476
|
+
renameSync(from, to);
|
|
16477
|
+
return true;
|
|
16478
|
+
} catch {
|
|
16479
|
+
return false;
|
|
16480
|
+
}
|
|
16481
|
+
}
|
|
16482
|
+
function releaseLease(lease) {
|
|
16483
|
+
try {
|
|
16484
|
+
unlinkSync2(join9(lease.directory, lease.owner));
|
|
16485
|
+
} catch {
|
|
16486
|
+
return;
|
|
16487
|
+
}
|
|
16488
|
+
try {
|
|
16489
|
+
rmdirSync(lease.directory);
|
|
16490
|
+
} catch {
|
|
16491
|
+
}
|
|
16492
|
+
}
|
|
16493
|
+
function reclaimIfStale(directory, staleMs) {
|
|
16494
|
+
const owners = readdirSync(directory);
|
|
16495
|
+
if (owners.length === 0) {
|
|
16496
|
+
try {
|
|
16497
|
+
rmdirSync(directory);
|
|
16498
|
+
} catch {
|
|
16499
|
+
}
|
|
16500
|
+
return true;
|
|
16501
|
+
}
|
|
16502
|
+
if (owners.length !== 1) return false;
|
|
16503
|
+
const age = Date.now() - statSync(join9(directory, owners[0])).mtimeMs;
|
|
16504
|
+
if (Math.abs(age) <= staleMs) return false;
|
|
16505
|
+
releaseLease({ directory, owner: owners[0] });
|
|
16506
|
+
return true;
|
|
16507
|
+
}
|
|
16508
|
+
function acquireLease(root, key, staleMs = LEASE_STALE_MS) {
|
|
16509
|
+
let staging;
|
|
16510
|
+
try {
|
|
16511
|
+
mkdirSync3(root, { recursive: true, mode: 448 });
|
|
16512
|
+
staging = mkdtempSync(join9(root, "claim-"));
|
|
16513
|
+
const owner = randomUUID();
|
|
16514
|
+
writeFileSync2(join9(staging, owner), "", { flag: "wx", mode: 384 });
|
|
16515
|
+
const directory = join9(root, `survey-${key}.lock`);
|
|
16516
|
+
if (!tryRename(staging, directory)) {
|
|
16517
|
+
if (!reclaimIfStale(directory, staleMs)) return void 0;
|
|
16518
|
+
if (!tryRename(staging, directory)) return void 0;
|
|
16519
|
+
}
|
|
16520
|
+
return { directory, owner };
|
|
16521
|
+
} catch {
|
|
16522
|
+
return void 0;
|
|
16523
|
+
} finally {
|
|
16524
|
+
if (staging) rmSync(staging, { recursive: true, force: true });
|
|
16525
|
+
}
|
|
16526
|
+
}
|
|
16527
|
+
|
|
16528
|
+
// src/core/survey.ts
|
|
16447
16529
|
var SURVEY_DOC_IDS = [
|
|
16448
16530
|
"repository-component-map",
|
|
16449
16531
|
"repository-core-concepts",
|
|
@@ -16453,7 +16535,7 @@ var SURVEY_DOC_IDS = [
|
|
|
16453
16535
|
function resolveClaudeBin(explicit) {
|
|
16454
16536
|
if (explicit) return explicit;
|
|
16455
16537
|
if (process.env.HINDSIGHT_CLAUDE_BIN) return process.env.HINDSIGHT_CLAUDE_BIN;
|
|
16456
|
-
const nativeInstallPath =
|
|
16538
|
+
const nativeInstallPath = join10(homedir4(), ".claude", "local", "claude");
|
|
16457
16539
|
try {
|
|
16458
16540
|
if (existsSync3(nativeInstallPath)) return nativeInstallPath;
|
|
16459
16541
|
} catch {
|
|
@@ -16567,11 +16649,11 @@ function buildSurveyPlan(harness, bin, repoDir, opts) {
|
|
|
16567
16649
|
}
|
|
16568
16650
|
}
|
|
16569
16651
|
}
|
|
16570
|
-
function startCodebaseSurvey(repoDir, opts = {}) {
|
|
16652
|
+
async function startCodebaseSurvey(repoDir, opts = {}) {
|
|
16571
16653
|
try {
|
|
16572
|
-
const spawnFn = opts.spawn ??
|
|
16654
|
+
const spawnFn = opts.spawn ?? realSpawn5;
|
|
16573
16655
|
const exists = opts.exists ?? binOnPath;
|
|
16574
|
-
const mcpServerPath = opts.mcpServerPath ??
|
|
16656
|
+
const mcpServerPath = opts.mcpServerPath ?? join10(dirname7(fileURLToPath4(import.meta.url)), "mcp-server.js");
|
|
16575
16657
|
const preferred = opts.harness ?? "claude-code";
|
|
16576
16658
|
const order = [
|
|
16577
16659
|
preferred,
|
|
@@ -16591,20 +16673,51 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
16591
16673
|
budgetUsd: opts.budgetUsd,
|
|
16592
16674
|
mcpServerPath
|
|
16593
16675
|
});
|
|
16594
|
-
const
|
|
16595
|
-
|
|
16596
|
-
|
|
16597
|
-
|
|
16598
|
-
|
|
16599
|
-
|
|
16600
|
-
|
|
16601
|
-
|
|
16676
|
+
const { cfg, bankId } = resolveHostConfig(harness, repoDir);
|
|
16677
|
+
if (cfg.disabled) return false;
|
|
16678
|
+
const key = createHash2("sha256").update(JSON.stringify([cfg.apiUrl.replace(/\/+$/, ""), cfg.apiToken ?? "", bankId])).digest("hex");
|
|
16679
|
+
const lease = acquireLease(
|
|
16680
|
+
opts.lease?.dir ?? join10(tmpdir3(), "hindsight-coding-agent", "surveys"),
|
|
16681
|
+
key,
|
|
16682
|
+
opts.lease?.staleMs ?? LEASE_STALE_MS
|
|
16683
|
+
);
|
|
16684
|
+
if (!lease) return false;
|
|
16685
|
+
const spec = {
|
|
16686
|
+
lease,
|
|
16687
|
+
bin: plan.bin,
|
|
16688
|
+
args: plan.args,
|
|
16689
|
+
...opts.lease?.heartbeatMs ? { heartbeatMs: opts.lease.heartbeatMs } : {}
|
|
16690
|
+
};
|
|
16691
|
+
const supervisorPath = opts.supervisorPath ?? join10(dirname7(fileURLToPath4(import.meta.url)), "survey-supervisor.js");
|
|
16692
|
+
return await new Promise((resolve3) => {
|
|
16693
|
+
try {
|
|
16694
|
+
const child = spawnFn("node", [supervisorPath], {
|
|
16695
|
+
cwd: repoDir,
|
|
16696
|
+
detached: true,
|
|
16697
|
+
stdio: "ignore",
|
|
16698
|
+
windowsHide: true,
|
|
16699
|
+
env: { ...plan.env, [SURVEY_SPEC_ENV]: JSON.stringify(spec) }
|
|
16700
|
+
});
|
|
16701
|
+
let spawned = false;
|
|
16702
|
+
child.on("error", () => {
|
|
16703
|
+
if (spawned) return;
|
|
16704
|
+
releaseLease(lease);
|
|
16705
|
+
resolve3(false);
|
|
16706
|
+
});
|
|
16707
|
+
child.once("spawn", () => {
|
|
16708
|
+
spawned = true;
|
|
16709
|
+
child.unref();
|
|
16710
|
+
resolve3(true);
|
|
16711
|
+
});
|
|
16712
|
+
} catch {
|
|
16713
|
+
releaseLease(lease);
|
|
16714
|
+
resolve3(false);
|
|
16715
|
+
}
|
|
16602
16716
|
});
|
|
16603
|
-
child.unref();
|
|
16604
|
-
return;
|
|
16605
16717
|
}
|
|
16606
16718
|
} catch {
|
|
16607
16719
|
}
|
|
16720
|
+
return false;
|
|
16608
16721
|
}
|
|
16609
16722
|
|
|
16610
16723
|
// src/core/status.ts
|
|
@@ -16717,7 +16830,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
16717
16830
|
inputSchema: {},
|
|
16718
16831
|
annotations: READ_ONLY_ANNOTATIONS,
|
|
16719
16832
|
handler: async (_args) => {
|
|
16720
|
-
const configPath = process.env.HINDSIGHT_CONFIG ||
|
|
16833
|
+
const configPath = process.env.HINDSIGHT_CONFIG || join11(homedir5(), ".hindsight", "coding-agent.json");
|
|
16721
16834
|
const harness = opts.harness ?? "unknown";
|
|
16722
16835
|
const cfg = applyBankConfig(
|
|
16723
16836
|
loadConfig({ harness: opts.harness }),
|
|
@@ -16853,7 +16966,7 @@ function buildKnowledgeTools(client, bankId, opts = {}) {
|
|
|
16853
16966
|
}
|
|
16854
16967
|
|
|
16855
16968
|
// src/core/retain-cursor.ts
|
|
16856
|
-
import { createHash as
|
|
16969
|
+
import { createHash as createHash3 } from "crypto";
|
|
16857
16970
|
var PENDING_MAX_AGE_MS = 12 * 60 * 60 * 1e3;
|
|
16858
16971
|
var PENDING_MAX_BYTES = 256 * 1024;
|
|
16859
16972
|
function pendingReplayable(cursor, now) {
|
|
@@ -16863,7 +16976,7 @@ function pendingReplayable(cursor, now) {
|
|
|
16863
16976
|
return pending.reduce((n, p) => n + p.content.length, 0) <= PENDING_MAX_BYTES;
|
|
16864
16977
|
}
|
|
16865
16978
|
function fingerprintTurns(turns, count) {
|
|
16866
|
-
const h =
|
|
16979
|
+
const h = createHash3("sha1").update(String(count));
|
|
16867
16980
|
for (let i = 0; i < count; i++) h.update("\n" + JSON.stringify(turns[i]));
|
|
16868
16981
|
return h.digest("hex");
|
|
16869
16982
|
}
|
|
@@ -16886,13 +16999,13 @@ function memoryCursorStore() {
|
|
|
16886
16999
|
}
|
|
16887
17000
|
|
|
16888
17001
|
// src/core/uuid.ts
|
|
16889
|
-
import { createHash as
|
|
17002
|
+
import { createHash as createHash4 } from "crypto";
|
|
16890
17003
|
var HINDSIGHT_NAMESPACE = "e75686a4-e923-4326-a0d1-358f1c6c3eb4";
|
|
16891
17004
|
function uuidV5(name, namespace = HINDSIGHT_NAMESPACE) {
|
|
16892
17005
|
const ns = Buffer.from(namespace.replace(/-/g, ""), "hex");
|
|
16893
17006
|
if (ns.length !== 16) throw new Error(`invalid UUID namespace: ${namespace}`);
|
|
16894
17007
|
const bytes = Buffer.from(
|
|
16895
|
-
|
|
17008
|
+
createHash4("sha1").update(ns).update(Buffer.from(name, "utf8")).digest().subarray(0, 16)
|
|
16896
17009
|
);
|
|
16897
17010
|
bytes[6] = bytes[6] & 15 | 80;
|
|
16898
17011
|
bytes[8] = bytes[8] & 63 | 128;
|
|
@@ -17096,12 +17209,12 @@ function buildRetainStamp(cfg, ctx) {
|
|
|
17096
17209
|
}
|
|
17097
17210
|
|
|
17098
17211
|
// src/core/session-start.ts
|
|
17099
|
-
import { readFileSync as
|
|
17212
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
17100
17213
|
|
|
17101
17214
|
// src/core/skill-sync.ts
|
|
17102
17215
|
import { cpSync, existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
17103
17216
|
import { homedir as homedir6 } from "os";
|
|
17104
|
-
import { dirname as dirname8, join as
|
|
17217
|
+
import { dirname as dirname8, join as join12 } from "path";
|
|
17105
17218
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
17106
17219
|
|
|
17107
17220
|
// src/core/brand.ts
|
|
@@ -17118,29 +17231,66 @@ function brandWord() {
|
|
|
17118
17231
|
return `${out}\x1B[0m`;
|
|
17119
17232
|
}
|
|
17120
17233
|
|
|
17234
|
+
// src/core/legacy.ts
|
|
17235
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
17236
|
+
import { homedir as homedir7 } from "os";
|
|
17237
|
+
import { join as join13, relative, isAbsolute as isAbsolute2 } from "path";
|
|
17238
|
+
var LEGACY_CLAUDE_PLUGIN = "hindsight-memory";
|
|
17239
|
+
function detectLegacyClaudePlugin(cwd, claudeDir = join13(homedir7(), ".claude")) {
|
|
17240
|
+
const registry2 = readJson(join13(claudeDir, "plugins", "installed_plugins.json"));
|
|
17241
|
+
const plugins = registry2?.plugins;
|
|
17242
|
+
if (!plugins || typeof plugins !== "object") return void 0;
|
|
17243
|
+
const enabled = readJson(join13(claudeDir, "settings.json"))?.enabledPlugins;
|
|
17244
|
+
for (const [key, raw] of Object.entries(plugins)) {
|
|
17245
|
+
if (key.split("@")[0] !== LEGACY_CLAUDE_PLUGIN) continue;
|
|
17246
|
+
if (enabled && enabled[key] === false) continue;
|
|
17247
|
+
const installs = Array.isArray(raw) ? raw : [raw];
|
|
17248
|
+
const active = installs.some((i) => {
|
|
17249
|
+
if (!i || typeof i !== "object") return false;
|
|
17250
|
+
if (typeof i.projectPath !== "string") return true;
|
|
17251
|
+
const rel = relative(i.projectPath, cwd);
|
|
17252
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
17253
|
+
});
|
|
17254
|
+
if (active) return key;
|
|
17255
|
+
}
|
|
17256
|
+
return void 0;
|
|
17257
|
+
}
|
|
17258
|
+
function readJson(path) {
|
|
17259
|
+
try {
|
|
17260
|
+
const parsed = JSON.parse(readFileSync5(path, "utf8"));
|
|
17261
|
+
return parsed && typeof parsed === "object" ? parsed : void 0;
|
|
17262
|
+
} catch {
|
|
17263
|
+
return void 0;
|
|
17264
|
+
}
|
|
17265
|
+
}
|
|
17266
|
+
function legacyClaudePluginWarning(key) {
|
|
17267
|
+
return `\u26A0\uFE0F The old Hindsight Claude Code plugin (${key}) is still installed \u2014 it runs alongside this one, so memory is recalled and retained twice.
|
|
17268
|
+
\u21B3 remove it: claude plugin uninstall ${key}`;
|
|
17269
|
+
}
|
|
17270
|
+
|
|
17121
17271
|
// src/core/session-cache.ts
|
|
17122
|
-
import { mkdirSync as
|
|
17123
|
-
import { tmpdir as
|
|
17124
|
-
import { dirname as dirname9, join as
|
|
17272
|
+
import { mkdirSync as mkdirSync4, readFileSync as readFileSync6, renameSync as renameSync2, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
17273
|
+
import { tmpdir as tmpdir4 } from "os";
|
|
17274
|
+
import { dirname as dirname9, join as join14 } from "path";
|
|
17125
17275
|
function sessionCacheFile(harness, sessionId) {
|
|
17126
|
-
return
|
|
17276
|
+
return join14(tmpdir4(), `hindsight-${harness}`, `${sessionId}.json`);
|
|
17127
17277
|
}
|
|
17128
17278
|
function readSessionCache(cacheFile) {
|
|
17129
17279
|
try {
|
|
17130
|
-
return JSON.parse(
|
|
17280
|
+
return JSON.parse(readFileSync6(cacheFile, "utf8"));
|
|
17131
17281
|
} catch {
|
|
17132
17282
|
return {};
|
|
17133
17283
|
}
|
|
17134
17284
|
}
|
|
17135
17285
|
function writeFileAtomic(path, body) {
|
|
17136
|
-
|
|
17286
|
+
mkdirSync4(dirname9(path), { recursive: true });
|
|
17137
17287
|
const tmp = `${path}.${process.pid}.tmp`;
|
|
17138
17288
|
try {
|
|
17139
|
-
|
|
17140
|
-
|
|
17289
|
+
writeFileSync3(tmp, body);
|
|
17290
|
+
renameSync2(tmp, path);
|
|
17141
17291
|
} catch (e) {
|
|
17142
17292
|
try {
|
|
17143
|
-
|
|
17293
|
+
rmSync2(tmp, { force: true });
|
|
17144
17294
|
} catch {
|
|
17145
17295
|
}
|
|
17146
17296
|
throw e;
|
|
@@ -17233,13 +17383,13 @@ async function buildSessionStartContext(args) {
|
|
|
17233
17383
|
startSeed(cwd, { limit: cfg.seedLimit, harness });
|
|
17234
17384
|
if (docIds.size === 0) {
|
|
17235
17385
|
if (cfg.codebaseSurvey !== false) {
|
|
17236
|
-
startSurvey(cwd, {
|
|
17386
|
+
const started = await startSurvey(cwd, {
|
|
17237
17387
|
harness,
|
|
17238
17388
|
model: cfg.surveyModel,
|
|
17239
17389
|
budgetUsd: cfg.surveyBudgetUsd
|
|
17240
17390
|
});
|
|
17241
17391
|
const sha = resolveHeadSha(cwd);
|
|
17242
|
-
if (sha) recordSurveyBaseline(sha);
|
|
17392
|
+
if (started && sha) recordSurveyBaseline(sha);
|
|
17243
17393
|
}
|
|
17244
17394
|
diag(harness, "seed_started", { bank: bankId });
|
|
17245
17395
|
} else if (cfg.codebaseSurvey !== false && cfg.surveyRefreshCommits > 0) {
|
|
@@ -17256,17 +17406,19 @@ async function buildSessionStartContext(args) {
|
|
|
17256
17406
|
const uploads = await client.listDocumentIds("source:upload", "all_strict").catch(() => /* @__PURE__ */ new Set());
|
|
17257
17407
|
const findingsAbsent = counts.length > 0 && !SURVEY_DOC_IDS.some((id) => uploads.has(id));
|
|
17258
17408
|
if (sinceLast !== null && sinceLast >= cfg.surveyRefreshCommits || findingsAbsent) {
|
|
17259
|
-
startSurvey(cwd, {
|
|
17409
|
+
const started = await startSurvey(cwd, {
|
|
17260
17410
|
harness,
|
|
17261
17411
|
model: cfg.surveyModel,
|
|
17262
17412
|
budgetUsd: cfg.surveyBudgetUsd
|
|
17263
17413
|
});
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17414
|
+
if (started) {
|
|
17415
|
+
recordSurveyBaseline(sha);
|
|
17416
|
+
diag(harness, "survey_refresh", {
|
|
17417
|
+
bank: bankId,
|
|
17418
|
+
commits: sinceLast,
|
|
17419
|
+
retry: findingsAbsent
|
|
17420
|
+
});
|
|
17421
|
+
}
|
|
17270
17422
|
} else if (sinceLast === null) {
|
|
17271
17423
|
recordSurveyBaseline(sha);
|
|
17272
17424
|
}
|
|
@@ -17299,12 +17451,19 @@ async function buildSessionStartContext(args) {
|
|
|
17299
17451
|
}).catch(() => void 0);
|
|
17300
17452
|
}
|
|
17301
17453
|
systemMessage = buildSeedBanner(bankId, cold === true, gitNote);
|
|
17454
|
+
const detectLegacy = args.detectLegacyPlugin ?? (harness === "claude-code" ? detectLegacyClaudePlugin : void 0);
|
|
17455
|
+
const legacyPlugin = detectLegacy?.(cwd);
|
|
17456
|
+
if (legacyPlugin) {
|
|
17457
|
+
systemMessage += `
|
|
17458
|
+
${legacyClaudePluginWarning(legacyPlugin)}`;
|
|
17459
|
+
diag(harness, "legacy_plugin_active", { plugin: legacyPlugin });
|
|
17460
|
+
}
|
|
17302
17461
|
diag(harness, "session_start", { bank: bankId, cold, pages: pages.length, ms: Date.now() - t0 });
|
|
17303
17462
|
return { systemMessage, additionalContext, deferInitialReflect };
|
|
17304
17463
|
}
|
|
17305
17464
|
|
|
17306
17465
|
// src/core/hook.ts
|
|
17307
|
-
import { existsSync as
|
|
17466
|
+
import { existsSync as existsSync7, readFileSync as readFileSync9 } from "fs";
|
|
17308
17467
|
|
|
17309
17468
|
// src/core/inject.ts
|
|
17310
17469
|
function buildReflectQuery(prompt) {
|
|
@@ -17336,9 +17495,9 @@ If you VERIFY this memory is wrong or outdated (the code or facts contradict it)
|
|
|
17336
17495
|
}
|
|
17337
17496
|
|
|
17338
17497
|
// src/core/turn-journal.ts
|
|
17339
|
-
import { appendFileSync as appendFileSync3, mkdirSync as
|
|
17340
|
-
import { tmpdir as
|
|
17341
|
-
import { dirname as dirname10, join as
|
|
17498
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync5, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
|
|
17499
|
+
import { tmpdir as tmpdir5 } from "os";
|
|
17500
|
+
import { dirname as dirname10, join as join15 } from "path";
|
|
17342
17501
|
|
|
17343
17502
|
// src/core/transcript-util.ts
|
|
17344
17503
|
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;
|
|
@@ -17393,13 +17552,14 @@ async function buildHookOutput(args) {
|
|
|
17393
17552
|
} else if (cfg.autoReflect && reflectAnswer === void 0) {
|
|
17394
17553
|
reflectRanThisTurn = true;
|
|
17395
17554
|
const t0 = Date.now();
|
|
17555
|
+
const timeoutMs = Math.min(cfg.reflectTimeoutMs, HOOK_REFLECT_CAP_MS);
|
|
17396
17556
|
try {
|
|
17397
17557
|
reflectAnswer = await client.reflect(buildReflectQuery(prompt), {
|
|
17398
17558
|
// Automatic reflection runs inside a hard 25s hook window. Hindsight's low budget is the
|
|
17399
17559
|
// supported default for bounded reflect calls; callers that explicitly invoke the MCP
|
|
17400
17560
|
// tool still get the deeper high-budget path.
|
|
17401
17561
|
budget: "low",
|
|
17402
|
-
timeoutMs
|
|
17562
|
+
timeoutMs
|
|
17403
17563
|
});
|
|
17404
17564
|
diag(harness, reflectAnswer ? "reflect_ok" : "reflect_empty", {
|
|
17405
17565
|
ms: Date.now() - t0,
|
|
@@ -17417,7 +17577,10 @@ async function buildHookOutput(args) {
|
|
|
17417
17577
|
});
|
|
17418
17578
|
diag(harness, "reflect_failed", {
|
|
17419
17579
|
ms: Date.now() - t0,
|
|
17420
|
-
|
|
17580
|
+
bank: client.bank,
|
|
17581
|
+
timeoutMs,
|
|
17582
|
+
// Wider than describeError's default: the server's error body is the useful part.
|
|
17583
|
+
error: describeError(e, 1500),
|
|
17421
17584
|
query: prompt.slice(0, 80)
|
|
17422
17585
|
});
|
|
17423
17586
|
}
|
|
@@ -17688,7 +17851,7 @@ var RuntimeCore = class {
|
|
|
17688
17851
|
};
|
|
17689
17852
|
|
|
17690
17853
|
// src/core/jsonl.ts
|
|
17691
|
-
import { closeSync, openSync, readSync, statSync as
|
|
17854
|
+
import { closeSync, openSync, readSync, statSync as statSync3 } from "fs";
|
|
17692
17855
|
import { StringDecoder } from "string_decoder";
|
|
17693
17856
|
var CHUNK_BYTES = 64 * 1024;
|
|
17694
17857
|
var MAX_TRANSCRIPT_BYTES = 32 * 1024 * 1024;
|