@vectorize-io/hindsight-coding-agents 0.8.7 → 0.8.8
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 +8 -3
- package/dist/antigravity-hook.js +150 -57
- package/dist/antigravity-statusline.js +30 -24
- package/dist/antigravity-stop-hook.js +160 -57
- package/dist/claude-hook.js +150 -57
- package/dist/claude-sessionstart-hook.js +176 -86
- package/dist/claude-stop-hook.js +160 -57
- package/dist/cline.js +132 -92
- package/dist/codebuddy-hook.js +150 -57
- package/dist/codebuddy-sessionstart-hook.js +176 -86
- package/dist/codebuddy-stop-hook.js +160 -57
- package/dist/codex-hook.js +150 -57
- package/dist/codex-sessionstart-hook.js +176 -86
- package/dist/codex-stop-hook.js +160 -57
- package/dist/copilot-hook.js +150 -57
- package/dist/copilot-sessionstart-hook.js +176 -86
- package/dist/copilot-stop-hook.js +160 -57
- package/dist/cursor-hook.js +150 -57
- package/dist/cursor-sessionstart-hook.js +176 -86
- package/dist/cursor-stop-hook.js +160 -57
- package/dist/daemon-start.js +20 -16
- package/dist/dcode-hook.js +150 -57
- package/dist/dcode-sessionstart-hook.js +176 -86
- package/dist/dcode-stop-hook.js +160 -57
- package/dist/deepen.js +19 -5
- package/dist/devin-hook.js +150 -57
- package/dist/devin-sessionstart-hook.js +176 -86
- package/dist/devin-stop-hook.js +160 -57
- package/dist/droid-hook.js +150 -57
- package/dist/droid-sessionstart-hook.js +176 -86
- package/dist/droid-stop-hook.js +160 -57
- package/dist/dsh.js +155 -93
- package/dist/grok-hook.js +150 -57
- package/dist/grok-sessionstart-hook.js +176 -86
- package/dist/grok-stop-hook.js +160 -57
- package/dist/hindsight-seed.js +35 -26
- package/dist/index.js +155 -93
- package/dist/installer.js +143 -41
- package/dist/kilo.js +155 -93
- package/dist/kimi-hook.js +150 -57
- package/dist/kimi-sessionstart-hook.js +176 -86
- package/dist/kimi-stop-hook.js +160 -57
- package/dist/mcp-server.js +73 -57
- package/dist/opencode2.js +155 -93
- package/dist/pi.js +155 -93
- package/dist/prime-agent.js +155 -93
- package/dist/qwen-hook.js +150 -57
- package/dist/qwen-sessionstart-hook.js +176 -86
- package/dist/qwen-stop-hook.js +160 -57
- package/dist/status.js +55 -39
- package/dist/traecode-hook.js +150 -57
- package/dist/traecode-sessionstart-hook.js +176 -86
- package/dist/traecode-stop-hook.js +160 -57
- package/dist/workbuddy-hook.js +150 -57
- package/dist/workbuddy-sessionstart-hook.js +176 -86
- package/dist/workbuddy-stop-hook.js +160 -57
- package/dist/zcode-hook.js +150 -57
- package/dist/zcode-sessionstart-hook.js +176 -86
- package/dist/zcode-stop-hook.js +160 -57
- package/package.json +1 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +8 -3
package/dist/dcode-stop-hook.js
CHANGED
|
@@ -286,7 +286,11 @@ function configuredDir(dir) {
|
|
|
286
286
|
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
|
|
287
287
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
288
288
|
}
|
|
289
|
-
function isWithin(directory, configured) {
|
|
289
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
290
|
+
if (platform === "win32") {
|
|
291
|
+
directory = directory.toLowerCase();
|
|
292
|
+
configured = configured.toLowerCase();
|
|
293
|
+
}
|
|
290
294
|
return directory === configured || directory.startsWith(configured + sep);
|
|
291
295
|
}
|
|
292
296
|
function mapLookup(map, directory) {
|
|
@@ -366,15 +370,92 @@ import { join as join7 } from "path";
|
|
|
366
370
|
|
|
367
371
|
// src/core/seed.ts
|
|
368
372
|
import { spawn as realSpawn } from "child_process";
|
|
369
|
-
import { dirname as dirname4, join as
|
|
373
|
+
import { dirname as dirname4, join as join6 } from "path";
|
|
370
374
|
import { fileURLToPath } from "url";
|
|
375
|
+
|
|
376
|
+
// src/core/util.ts
|
|
377
|
+
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
378
|
+
import { delimiter, extname, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
379
|
+
function binOnPath(bin, opts = {}) {
|
|
380
|
+
const platform = opts.platform ?? process.platform;
|
|
381
|
+
const env = opts.env ?? process.env;
|
|
382
|
+
const runnable = (file) => {
|
|
383
|
+
try {
|
|
384
|
+
if (!statSync2(file).isFile()) return false;
|
|
385
|
+
if (platform !== "win32") accessSync(file, constants.X_OK);
|
|
386
|
+
return true;
|
|
387
|
+
} catch {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
|
|
392
|
+
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
393
|
+
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
394
|
+
if (!dir) continue;
|
|
395
|
+
for (const name of names) {
|
|
396
|
+
const file = join5(dir, name);
|
|
397
|
+
if (runnable(file)) return resolve2(file);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return void 0;
|
|
401
|
+
}
|
|
402
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
403
|
+
function semverGte(version2, min) {
|
|
404
|
+
const parts = (v) => {
|
|
405
|
+
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
406
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
407
|
+
};
|
|
408
|
+
const a = version2 ? parts(version2) : void 0;
|
|
409
|
+
const b = parts(min);
|
|
410
|
+
if (!a || !b) return false;
|
|
411
|
+
for (let i = 0; i < 3; i++) {
|
|
412
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
413
|
+
}
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
async function pool(items, n, fn, onError, onProgress) {
|
|
417
|
+
let i = 0, done = 0;
|
|
418
|
+
async function worker() {
|
|
419
|
+
while (i < items.length) {
|
|
420
|
+
const idx = i++;
|
|
421
|
+
try {
|
|
422
|
+
await fn(items[idx], idx);
|
|
423
|
+
} catch (e) {
|
|
424
|
+
onError?.(idx, e);
|
|
425
|
+
}
|
|
426
|
+
onProgress?.(++done, items.length);
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
430
|
+
}
|
|
431
|
+
function nodeBinary() {
|
|
432
|
+
return process.versions.bun || process.versions.electron ? "node" : process.execPath;
|
|
433
|
+
}
|
|
434
|
+
function hookNode(opts = {}) {
|
|
435
|
+
const platform = opts.platform ?? process.platform;
|
|
436
|
+
if (platform === "win32" || binOnPath("node", opts)) return "node";
|
|
437
|
+
return nodeBinary();
|
|
438
|
+
}
|
|
439
|
+
function isOurMcpEntry(entry) {
|
|
440
|
+
if (!entry || typeof entry !== "object") return false;
|
|
441
|
+
const candidate = entry;
|
|
442
|
+
const command = typeof candidate.command === "string" ? candidate.command : "";
|
|
443
|
+
const bin = command.replaceAll("\\", "/").split("/").at(-1);
|
|
444
|
+
if (bin !== "node" && bin !== "node.exe" || !Array.isArray(candidate.args)) return false;
|
|
445
|
+
const script = candidate.args[0];
|
|
446
|
+
if (typeof script !== "string") return false;
|
|
447
|
+
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
448
|
+
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
// src/core/seed.ts
|
|
371
452
|
var DEFAULT_SEED_LIMIT = 300;
|
|
372
453
|
|
|
373
454
|
// src/core/missions.ts
|
|
374
455
|
import { createHash } from "crypto";
|
|
375
456
|
var GIT_MISSION = "You are ingesting a single git commit: its message and its full diff. Extract the concrete technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities (functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and literal values verbatim. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123, PROJ-123) are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY, so a later question about that issue or PR retrieves this decision.";
|
|
376
457
|
var GITLOG_MISSION = "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) \u2014 the project's recent commit-message history, oldest first. Extract the project's INITIATIVES, FEATURES, ENHANCEMENTS, and notable changes or THEMES over time \u2014 what the project has been working on and how it has evolved. Do NOT extract per-line code detail (there is no diff to draw it from). Group related commits into a coherent initiative/theme where the messages make that clear; preserve exact identifiers and literal values verbatim when quoting a subject line. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY \u2014 they are how future sessions will ask about this work.";
|
|
377
|
-
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Do not invent; capture only what was actually settled.`;
|
|
458
|
+
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. When the session checked its work (a test passed or failed, a result was judged right or wrong), record the exact METHOD behind that outcome \u2014 which file, table, column, command or formula \u2014 and any caveat the session found in the data or code (a column mostly empty, a value in other units), so the same work repeats what worked and avoids what failed. Do not invent; capture only what was actually settled.`;
|
|
378
459
|
var REFLECT_MISSION = "You are a debugging assistant with the project's past decisions in memory (git rationale and developer chats). Given a bug's SYMPTOM, find the past decision whose rationale explains the ROOT CAUSE \u2014 not one that merely shares vocabulary. Answer with the PRECISE fix: state the EXACT rule and the LITERAL values, identifiers, strings, numbers, or set members that were decided \u2014 quote them VERBATIM, never paraphrase, generalize, or omit them (give the actual decided value, not 'the project standard'). If memories CONFLICT on the same rule, the LATEST decision wins \u2014 prefer facts that explicitly amend or supersede an earlier one, state the superseded rule as no longer in effect, and never present it as the fix. Name the function/file to change and cite the REF-ID(s). If NOTHING in memory genuinely explains THIS symptom, say exactly that in one short sentence \u2014 a wrong-but-confident nearest match is worse than an honest miss; never stretch an unrelated decision to fit.";
|
|
379
460
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
380
461
|
var OBSERVATIONS_MISSION = "Consolidate durable knowledge about THIS codebase \u2014 recurring patterns, conventions, module responsibilities, and how components relate \u2014 from the ingested commits and conversations. Favor stable structural understanding over one-off details. When a new fact contradicts or supersedes an existing observation, UPDATE that observation to reflect the current state rather than creating a sibling alongside it; note that the rule was revised and when, so the superseded version is visible as history rather than as a competing claim.";
|
|
@@ -633,49 +714,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
633
714
|
}
|
|
634
715
|
|
|
635
716
|
// package.json
|
|
636
|
-
var version = "0.8.
|
|
637
|
-
|
|
638
|
-
// src/core/util.ts
|
|
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
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
642
|
-
function semverGte(version2, min) {
|
|
643
|
-
const parts = (v) => {
|
|
644
|
-
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
645
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
646
|
-
};
|
|
647
|
-
const a = version2 ? parts(version2) : void 0;
|
|
648
|
-
const b = parts(min);
|
|
649
|
-
if (!a || !b) return false;
|
|
650
|
-
for (let i = 0; i < 3; i++) {
|
|
651
|
-
if (a[i] !== b[i]) return a[i] > b[i];
|
|
652
|
-
}
|
|
653
|
-
return true;
|
|
654
|
-
}
|
|
655
|
-
async function pool(items, n, fn, onError, onProgress) {
|
|
656
|
-
let i = 0, done = 0;
|
|
657
|
-
async function worker() {
|
|
658
|
-
while (i < items.length) {
|
|
659
|
-
const idx = i++;
|
|
660
|
-
try {
|
|
661
|
-
await fn(items[idx], idx);
|
|
662
|
-
} catch (e) {
|
|
663
|
-
onError?.(idx, e);
|
|
664
|
-
}
|
|
665
|
-
onProgress?.(++done, items.length);
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
669
|
-
}
|
|
670
|
-
function isOurMcpEntry(entry) {
|
|
671
|
-
if (!entry || typeof entry !== "object") return false;
|
|
672
|
-
const candidate = entry;
|
|
673
|
-
if (candidate.command !== "node" || !Array.isArray(candidate.args)) return false;
|
|
674
|
-
const script = candidate.args[0];
|
|
675
|
-
if (typeof script !== "string") return false;
|
|
676
|
-
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
677
|
-
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
678
|
-
}
|
|
717
|
+
var version = "0.8.8";
|
|
679
718
|
|
|
680
719
|
// src/core/hindsight.ts
|
|
681
720
|
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
@@ -887,7 +926,9 @@ var HindsightClient = class {
|
|
|
887
926
|
}
|
|
888
927
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
889
928
|
throw new Error(
|
|
890
|
-
|
|
929
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
930
|
+
// status and the server's reason out of the tool error (#6341).
|
|
931
|
+
`${method} ${url.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
891
932
|
);
|
|
892
933
|
return r;
|
|
893
934
|
}
|
|
@@ -1033,6 +1074,15 @@ var HindsightClient = class {
|
|
|
1033
1074
|
await this.req("DELETE", this.bankUrl());
|
|
1034
1075
|
this.log(`[bank] reset ${this.bank}`);
|
|
1035
1076
|
}
|
|
1077
|
+
await this.configureBankSettings(opts);
|
|
1078
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1079
|
+
}
|
|
1080
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
1081
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
1082
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
1083
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
1084
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
1085
|
+
async configureBankSettings(opts = {}) {
|
|
1036
1086
|
if (opts.manage === false) {
|
|
1037
1087
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
1038
1088
|
} else {
|
|
@@ -1048,7 +1098,6 @@ var HindsightClient = class {
|
|
|
1048
1098
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
1049
1099
|
}
|
|
1050
1100
|
}
|
|
1051
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1052
1101
|
}
|
|
1053
1102
|
/**
|
|
1054
1103
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -1881,10 +1930,14 @@ function resolvePartial(cfg, patch) {
|
|
|
1881
1930
|
}
|
|
1882
1931
|
|
|
1883
1932
|
// src/core/transcript-util.ts
|
|
1933
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
1884
1934
|
var MEMORY_TAG_RE = /<(hook_prompt|task-notification|system-reminder|hindsight_memory|hindsight_memories|hindsight_bank|relevant_memories|user_feedback|hindsight_pages|hindsight_page_refresh|hindsight_knowledge|hindsight_knowledge_refresh)\b[\s\S]*?<\/\1>/g;
|
|
1885
1935
|
function stripInjectedMemory(s) {
|
|
1886
1936
|
return s.replace(MEMORY_TAG_RE, "");
|
|
1887
1937
|
}
|
|
1938
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
1939
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
1940
|
+
}
|
|
1888
1941
|
var TARGET_KEYS = [
|
|
1889
1942
|
"file_path",
|
|
1890
1943
|
"path",
|
|
@@ -1912,7 +1965,25 @@ function actionLine(tool, input) {
|
|
|
1912
1965
|
target = input.trim().split("\n")[0];
|
|
1913
1966
|
}
|
|
1914
1967
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
1915
|
-
|
|
1968
|
+
const line = target ? `${tool} ${target}` : tool;
|
|
1969
|
+
const note = memoryNoteText(input);
|
|
1970
|
+
return note ? `${line}
|
|
1971
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
1972
|
+
}
|
|
1973
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
1974
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
1975
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
1976
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
1977
|
+
function memoryNoteText(input) {
|
|
1978
|
+
if (!input || typeof input !== "object") return "";
|
|
1979
|
+
const rec = input;
|
|
1980
|
+
const cmd = rec.command;
|
|
1981
|
+
if (typeof cmd === "string")
|
|
1982
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
1983
|
+
const path = rec.file_path ?? rec.path;
|
|
1984
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
1985
|
+
const text = rec.content ?? rec.new_string;
|
|
1986
|
+
return typeof text === "string" ? text.trim() : "";
|
|
1916
1987
|
}
|
|
1917
1988
|
|
|
1918
1989
|
// src/core/session-cache.ts
|
|
@@ -2406,13 +2477,18 @@ function onPath(bin) {
|
|
|
2406
2477
|
return false;
|
|
2407
2478
|
}
|
|
2408
2479
|
}
|
|
2480
|
+
var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
|
|
2409
2481
|
function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
2410
2482
|
try {
|
|
2411
2483
|
const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
2412
|
-
const child = spawnFn(
|
|
2484
|
+
const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
|
|
2413
2485
|
detached: true,
|
|
2414
2486
|
stdio: "ignore",
|
|
2415
|
-
windowsHide: true
|
|
2487
|
+
windowsHide: true,
|
|
2488
|
+
// The caller's config is already resolved for its directory and bank. Re-reading the file in
|
|
2489
|
+
// the starter lost `paths` / `banks` overrides, so a daemon enabled only there never started
|
|
2490
|
+
// (#6334).
|
|
2491
|
+
env: { ...process.env, [DAEMON_CONFIG_ENV]: JSON.stringify(cfg) }
|
|
2416
2492
|
});
|
|
2417
2493
|
child.on("error", () => {
|
|
2418
2494
|
});
|
|
@@ -2579,7 +2655,7 @@ function* readJsonl(path) {
|
|
|
2579
2655
|
}
|
|
2580
2656
|
|
|
2581
2657
|
// src/core/transcript.ts
|
|
2582
|
-
function renderLine(content, type) {
|
|
2658
|
+
function renderLine(content, type, questionIds) {
|
|
2583
2659
|
if (typeof content === "string") {
|
|
2584
2660
|
const text = stripInjectedMemory(content).trim();
|
|
2585
2661
|
return text ? [{ role: type, content: text }] : [];
|
|
@@ -2593,7 +2669,11 @@ function renderLine(content, type) {
|
|
|
2593
2669
|
const t = stripInjectedMemory(b.text).trim();
|
|
2594
2670
|
if (t) texts.push(t);
|
|
2595
2671
|
} else if (b.type === "tool_use" && typeof b.name === "string") {
|
|
2672
|
+
if (b.name === "AskUserQuestion" && typeof b.id === "string") questionIds.add(b.id);
|
|
2596
2673
|
actions.push({ role: "action", content: actionLine(b.name, b.input) });
|
|
2674
|
+
} else if (b.type === "tool_result" && b.tool_use_id && questionIds.has(b.tool_use_id)) {
|
|
2675
|
+
const answer = renderLine(b.content, type, questionIds).map((r) => r.content).join("\n");
|
|
2676
|
+
if (answer) texts.push(answer);
|
|
2597
2677
|
}
|
|
2598
2678
|
}
|
|
2599
2679
|
const out = [];
|
|
@@ -2604,6 +2684,7 @@ function renderLine(content, type) {
|
|
|
2604
2684
|
}
|
|
2605
2685
|
function readClaudeTranscript(path) {
|
|
2606
2686
|
const turns = [];
|
|
2687
|
+
const questionIds = /* @__PURE__ */ new Set();
|
|
2607
2688
|
for (const rawLine of readJsonl(path)) {
|
|
2608
2689
|
const trimmed = rawLine.trim();
|
|
2609
2690
|
if (!trimmed) continue;
|
|
@@ -2620,7 +2701,7 @@ function readClaudeTranscript(path) {
|
|
|
2620
2701
|
if (line.isSidechain === true) continue;
|
|
2621
2702
|
if (line.isCompactSummary === true) continue;
|
|
2622
2703
|
if (typeof line.message !== "object" || line.message === null) continue;
|
|
2623
|
-
for (const rendered of renderLine(line.message.content, line.type)) {
|
|
2704
|
+
for (const rendered of renderLine(line.message.content, line.type, questionIds)) {
|
|
2624
2705
|
const turn = { role: rendered.role, content: rendered.content };
|
|
2625
2706
|
if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
|
|
2626
2707
|
turns.push(turn);
|
|
@@ -2980,7 +3061,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2980
3061
|
}
|
|
2981
3062
|
const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
2982
3063
|
const entry = {
|
|
2983
|
-
command:
|
|
3064
|
+
command: hookNode(),
|
|
2984
3065
|
args: [script],
|
|
2985
3066
|
env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
|
|
2986
3067
|
};
|
|
@@ -3291,6 +3372,27 @@ function readAntigravityTranscript(path) {
|
|
|
3291
3372
|
}
|
|
3292
3373
|
return turns;
|
|
3293
3374
|
}
|
|
3375
|
+
function readAntigravityPromptTurn(path) {
|
|
3376
|
+
if (!path) return void 0;
|
|
3377
|
+
let lastRole;
|
|
3378
|
+
let lastUserPrompt;
|
|
3379
|
+
for (const line of readJsonl(path)) {
|
|
3380
|
+
try {
|
|
3381
|
+
const event = JSON.parse(line);
|
|
3382
|
+
const role = event.role ?? event.message?.role ?? event.type;
|
|
3383
|
+
if (!role || role === "CHECKPOINT" || role === "EPHEMERAL_MESSAGE") continue;
|
|
3384
|
+
lastRole = role;
|
|
3385
|
+
if (role === "user" || role === "USER_INPUT") {
|
|
3386
|
+
const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
|
|
3387
|
+
const text = typeof content === "string" ? stripInjectedMemory(content) : "";
|
|
3388
|
+
const clean = unwrapUserRequest(text).trim();
|
|
3389
|
+
lastUserPrompt = clean || void 0;
|
|
3390
|
+
}
|
|
3391
|
+
} catch {
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
return lastRole === "user" || lastRole === "USER_INPUT" ? lastUserPrompt : void 0;
|
|
3395
|
+
}
|
|
3294
3396
|
|
|
3295
3397
|
// src/core/transcript-copilot.ts
|
|
3296
3398
|
function readCopilotTranscript(path) {
|
|
@@ -4015,9 +4117,10 @@ var antigravityPrompt = {
|
|
|
4015
4117
|
harness: "antigravity-cli",
|
|
4016
4118
|
requireCwd: true,
|
|
4017
4119
|
parse: (ev) => ({
|
|
4018
|
-
// Antigravity's PreInvocation payload
|
|
4019
|
-
//
|
|
4020
|
-
prompt
|
|
4120
|
+
// Antigravity's PreInvocation payload omits the prompt and fires before EVERY planner step in
|
|
4121
|
+
// the agent loop (including after every tool call). Read the transcript's trailing record so
|
|
4122
|
+
// only a genuine user submission returns a prompt and tool-result continuations are suppressed.
|
|
4123
|
+
prompt: readAntigravityPromptTurn(ev.transcriptPath),
|
|
4021
4124
|
cwd: antigravityCwd(ev),
|
|
4022
4125
|
sessionId: ev.conversationId
|
|
4023
4126
|
}),
|
package/dist/deepen.js
CHANGED
|
@@ -267,7 +267,11 @@ function configuredDir(dir) {
|
|
|
267
267
|
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
|
|
268
268
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
269
269
|
}
|
|
270
|
-
function isWithin(directory, configured) {
|
|
270
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
271
|
+
if (platform === "win32") {
|
|
272
|
+
directory = directory.toLowerCase();
|
|
273
|
+
configured = configured.toLowerCase();
|
|
274
|
+
}
|
|
271
275
|
return directory === configured || directory.startsWith(configured + sep);
|
|
272
276
|
}
|
|
273
277
|
function mapLookup(map, directory) {
|
|
@@ -357,7 +361,7 @@ function deriveBankIdOrSkip(config, directory, harness = "coding", sessionRoot)
|
|
|
357
361
|
import { createHash } from "crypto";
|
|
358
362
|
var GIT_MISSION = "You are ingesting a single git commit: its message and its full diff. Extract the concrete technical DECISION and the CAUSE/INVARIANT it encodes, bound to the specific code entities (functions, methods, files) and behaviors it changes. Preserve exact identifiers, paths, and literal values verbatim. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Capture both WHAT changed and WHY. Issue/PR references (#123, GH-123, PROJ-123) are load-bearing: keep them VERBATIM in the fact text and emit each as an ENTITY, so a later question about that issue or PR retrieves this decision.";
|
|
359
363
|
var GITLOG_MISSION = "You are ingesting an aggregated block of git commit MESSAGES ONLY (no diffs) \u2014 the project's recent commit-message history, oldest first. Extract the project's INITIATIVES, FEATURES, ENHANCEMENTS, and notable changes or THEMES over time \u2014 what the project has been working on and how it has evolved. Do NOT extract per-line code detail (there is no diff to draw it from). Group related commits into a coherent initiative/theme where the messages make that clear; preserve exact identifiers and literal values verbatim when quoting a subject line. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY \u2014 they are how future sessions will ask about this work.";
|
|
360
|
-
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. Do not invent; capture only what was actually settled.`;
|
|
364
|
+
var CONVERSATION_MISSION = `You are ingesting a developer conversation as a JSONL transcript (one {role, content} turn per line): the user's requests, the assistant's narration, and compact 'action' turns naming each tool use and its target (e.g. "Edit boltons/strutils.py") with no arguments or outputs. It may be a SHORT decision chat or a LONG working session \u2014 scale the facts to the substance, never to the message count. Extract the FEWEST facts that capture the OUTCOME: the settled DECISIONS and their exact rules/values (quote literals VERBATIM); concrete CHANGES to specific code entities; problems and how they were resolved; conventions or invariants established; at most one fact for a notable REJECTED alternative ('initially proposed X, changed to Y because Z'). A short decision chat usually yields 1-2 facts; a substantial working session several. CRITICAL: a conversation REVISES itself \u2014 record ONLY the FINAL state as what is in effect; a superseded proposal appears ONLY inside the rejected fact, NEVER as its own 'decided' fact; if the same setting changes several times keep only the LAST, and make unmistakably clear which choice WON. Do NOT emit one fact per message, per intermediate proposal, or per action turn. Keep issue/PR references (#123, GH-123) VERBATIM and emit each as an ENTITY. Preserve the 'REF-ID: <token>' marker verbatim in every fact. When the session checked its work (a test passed or failed, a result was judged right or wrong), record the exact METHOD behind that outcome \u2014 which file, table, column, command or formula \u2014 and any caveat the session found in the data or code (a column mostly empty, a value in other units), so the same work repeats what worked and avoids what failed. Do not invent; capture only what was actually settled.`;
|
|
361
365
|
var REFLECT_MISSION = "You are a debugging assistant with the project's past decisions in memory (git rationale and developer chats). Given a bug's SYMPTOM, find the past decision whose rationale explains the ROOT CAUSE \u2014 not one that merely shares vocabulary. Answer with the PRECISE fix: state the EXACT rule and the LITERAL values, identifiers, strings, numbers, or set members that were decided \u2014 quote them VERBATIM, never paraphrase, generalize, or omit them (give the actual decided value, not 'the project standard'). If memories CONFLICT on the same rule, the LATEST decision wins \u2014 prefer facts that explicitly amend or supersede an earlier one, state the superseded rule as no longer in effect, and never present it as the fix. Name the function/file to change and cite the REF-ID(s). If NOTHING in memory genuinely explains THIS symptom, say exactly that in one short sentence \u2014 a wrong-but-confident nearest match is worse than an honest miss; never stretch an unrelated decision to fit.";
|
|
362
366
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
363
367
|
var OBSERVATIONS_MISSION = "Consolidate durable knowledge about THIS codebase \u2014 recurring patterns, conventions, module responsibilities, and how components relate \u2014 from the ingested commits and conversations. Favor stable structural understanding over one-off details. When a new fact contradicts or supersedes an existing observation, UPDATE that observation to reflect the current state rather than creating a sibling alongside it; note that the rule was revised and when, so the superseded version is visible as history rather than as a competing claim.";
|
|
@@ -616,7 +620,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
616
620
|
}
|
|
617
621
|
|
|
618
622
|
// package.json
|
|
619
|
-
var version = "0.8.
|
|
623
|
+
var version = "0.8.8";
|
|
620
624
|
|
|
621
625
|
// src/core/util.ts
|
|
622
626
|
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
@@ -861,7 +865,9 @@ var HindsightClient = class {
|
|
|
861
865
|
}
|
|
862
866
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
863
867
|
throw new Error(
|
|
864
|
-
|
|
868
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
869
|
+
// status and the server's reason out of the tool error (#6341).
|
|
870
|
+
`${method} ${url.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
865
871
|
);
|
|
866
872
|
return r;
|
|
867
873
|
}
|
|
@@ -1007,6 +1013,15 @@ var HindsightClient = class {
|
|
|
1007
1013
|
await this.req("DELETE", this.bankUrl());
|
|
1008
1014
|
this.log(`[bank] reset ${this.bank}`);
|
|
1009
1015
|
}
|
|
1016
|
+
await this.configureBankSettings(opts);
|
|
1017
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1018
|
+
}
|
|
1019
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
1020
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
1021
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
1022
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
1023
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
1024
|
+
async configureBankSettings(opts = {}) {
|
|
1010
1025
|
if (opts.manage === false) {
|
|
1011
1026
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
1012
1027
|
} else {
|
|
@@ -1022,7 +1037,6 @@ var HindsightClient = class {
|
|
|
1022
1037
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
1023
1038
|
}
|
|
1024
1039
|
}
|
|
1025
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1026
1040
|
}
|
|
1027
1041
|
/**
|
|
1028
1042
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|