@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/codex-hook.js
CHANGED
|
@@ -283,7 +283,11 @@ function configuredDir(dir) {
|
|
|
283
283
|
const expanded = dir === "~" || dir.startsWith("~/") ? join4(homedir2(), dir.slice(1)) : dir;
|
|
284
284
|
return normalize(expanded).replace(new RegExp(`\\${sep}+$`), "");
|
|
285
285
|
}
|
|
286
|
-
function isWithin(directory, configured) {
|
|
286
|
+
function isWithin(directory, configured, platform = process.platform) {
|
|
287
|
+
if (platform === "win32") {
|
|
288
|
+
directory = directory.toLowerCase();
|
|
289
|
+
configured = configured.toLowerCase();
|
|
290
|
+
}
|
|
287
291
|
return directory === configured || directory.startsWith(configured + sep);
|
|
288
292
|
}
|
|
289
293
|
function mapLookup(map, directory) {
|
|
@@ -363,16 +367,93 @@ import { join as join7 } from "path";
|
|
|
363
367
|
|
|
364
368
|
// src/core/seed.ts
|
|
365
369
|
import { spawn as realSpawn } from "child_process";
|
|
366
|
-
import { dirname as dirname4, join as
|
|
370
|
+
import { dirname as dirname4, join as join6 } from "path";
|
|
367
371
|
import { fileURLToPath } from "url";
|
|
372
|
+
|
|
373
|
+
// src/core/util.ts
|
|
374
|
+
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
375
|
+
import { delimiter, extname, isAbsolute as isAbsolute2, join as join5, resolve as resolve2 } from "path";
|
|
376
|
+
function binOnPath(bin, opts = {}) {
|
|
377
|
+
const platform = opts.platform ?? process.platform;
|
|
378
|
+
const env = opts.env ?? process.env;
|
|
379
|
+
const runnable = (file) => {
|
|
380
|
+
try {
|
|
381
|
+
if (!statSync2(file).isFile()) return false;
|
|
382
|
+
if (platform !== "win32") accessSync(file, constants.X_OK);
|
|
383
|
+
return true;
|
|
384
|
+
} catch {
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
if (isAbsolute2(bin) || /[\\/]/.test(bin)) return runnable(bin) ? resolve2(bin) : void 0;
|
|
389
|
+
const names = platform !== "win32" || extname(bin) ? [bin] : (opts.exts ?? (env.PATHEXT || ".COM;.EXE;.BAT;.CMD").split(";")).filter(Boolean).map((ext) => bin + ext.toLowerCase());
|
|
390
|
+
for (const dir of (env.PATH || "").split(delimiter)) {
|
|
391
|
+
if (!dir) continue;
|
|
392
|
+
for (const name of names) {
|
|
393
|
+
const file = join5(dir, name);
|
|
394
|
+
if (runnable(file)) return resolve2(file);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
return void 0;
|
|
398
|
+
}
|
|
399
|
+
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
400
|
+
function semverGte(version2, min) {
|
|
401
|
+
const parts = (v) => {
|
|
402
|
+
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
403
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
404
|
+
};
|
|
405
|
+
const a = version2 ? parts(version2) : void 0;
|
|
406
|
+
const b = parts(min);
|
|
407
|
+
if (!a || !b) return false;
|
|
408
|
+
for (let i = 0; i < 3; i++) {
|
|
409
|
+
if (a[i] !== b[i]) return a[i] > b[i];
|
|
410
|
+
}
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
async function pool(items, n, fn, onError, onProgress) {
|
|
414
|
+
let i = 0, done = 0;
|
|
415
|
+
async function worker() {
|
|
416
|
+
while (i < items.length) {
|
|
417
|
+
const idx = i++;
|
|
418
|
+
try {
|
|
419
|
+
await fn(items[idx], idx);
|
|
420
|
+
} catch (e) {
|
|
421
|
+
onError?.(idx, e);
|
|
422
|
+
}
|
|
423
|
+
onProgress?.(++done, items.length);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
427
|
+
}
|
|
428
|
+
function nodeBinary() {
|
|
429
|
+
return process.versions.bun || process.versions.electron ? "node" : process.execPath;
|
|
430
|
+
}
|
|
431
|
+
function hookNode(opts = {}) {
|
|
432
|
+
const platform = opts.platform ?? process.platform;
|
|
433
|
+
if (platform === "win32" || binOnPath("node", opts)) return "node";
|
|
434
|
+
return nodeBinary();
|
|
435
|
+
}
|
|
436
|
+
function isOurMcpEntry(entry) {
|
|
437
|
+
if (!entry || typeof entry !== "object") return false;
|
|
438
|
+
const candidate = entry;
|
|
439
|
+
const command = typeof candidate.command === "string" ? candidate.command : "";
|
|
440
|
+
const bin = command.replaceAll("\\", "/").split("/").at(-1);
|
|
441
|
+
if (bin !== "node" && bin !== "node.exe" || !Array.isArray(candidate.args)) return false;
|
|
442
|
+
const script = candidate.args[0];
|
|
443
|
+
if (typeof script !== "string") return false;
|
|
444
|
+
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
445
|
+
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
// src/core/seed.ts
|
|
368
449
|
var DEFAULT_SEED_LIMIT = 300;
|
|
369
450
|
function startBackgroundSeed(repoDir, opts = {}) {
|
|
370
451
|
try {
|
|
371
452
|
const spawnFn = opts.spawn ?? realSpawn;
|
|
372
|
-
const enginePath = opts.enginePath ??
|
|
453
|
+
const enginePath = opts.enginePath ?? join6(dirname4(fileURLToPath(import.meta.url)), "deepen.js");
|
|
373
454
|
const limit = opts.limit ?? DEFAULT_SEED_LIMIT;
|
|
374
455
|
const child = spawnFn(
|
|
375
|
-
|
|
456
|
+
nodeBinary(),
|
|
376
457
|
[
|
|
377
458
|
enginePath,
|
|
378
459
|
"--repo",
|
|
@@ -398,7 +479,7 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
398
479
|
import { createHash } from "crypto";
|
|
399
480
|
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.";
|
|
400
481
|
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.";
|
|
401
|
-
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.`;
|
|
482
|
+
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.`;
|
|
402
483
|
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.";
|
|
403
484
|
var DOCUMENT_MISSION = "You are ingesting a standalone document (notes, docs, or structural findings). Extract the concrete facts, concepts, and structure it describes.";
|
|
404
485
|
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.";
|
|
@@ -657,49 +738,7 @@ function codingBankManifest(overrides, mode = DEFAULT_RETAIN_EXTRACTION_MODE, de
|
|
|
657
738
|
}
|
|
658
739
|
|
|
659
740
|
// package.json
|
|
660
|
-
var version = "0.8.
|
|
661
|
-
|
|
662
|
-
// src/core/util.ts
|
|
663
|
-
import { accessSync, constants, statSync as statSync2 } from "fs";
|
|
664
|
-
import { delimiter, extname, isAbsolute as isAbsolute2, join as join6, resolve as resolve2 } from "path";
|
|
665
|
-
var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
666
|
-
function semverGte(version2, min) {
|
|
667
|
-
const parts = (v) => {
|
|
668
|
-
const m = v.trim().match(/^(\d+)\.(\d+)(?:\.(\d+))?/);
|
|
669
|
-
return m ? [Number(m[1]), Number(m[2]), Number(m[3] ?? 0)] : void 0;
|
|
670
|
-
};
|
|
671
|
-
const a = version2 ? parts(version2) : void 0;
|
|
672
|
-
const b = parts(min);
|
|
673
|
-
if (!a || !b) return false;
|
|
674
|
-
for (let i = 0; i < 3; i++) {
|
|
675
|
-
if (a[i] !== b[i]) return a[i] > b[i];
|
|
676
|
-
}
|
|
677
|
-
return true;
|
|
678
|
-
}
|
|
679
|
-
async function pool(items, n, fn, onError, onProgress) {
|
|
680
|
-
let i = 0, done = 0;
|
|
681
|
-
async function worker() {
|
|
682
|
-
while (i < items.length) {
|
|
683
|
-
const idx = i++;
|
|
684
|
-
try {
|
|
685
|
-
await fn(items[idx], idx);
|
|
686
|
-
} catch (e) {
|
|
687
|
-
onError?.(idx, e);
|
|
688
|
-
}
|
|
689
|
-
onProgress?.(++done, items.length);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
await Promise.all(Array.from({ length: Math.min(n, items.length) }, worker));
|
|
693
|
-
}
|
|
694
|
-
function isOurMcpEntry(entry) {
|
|
695
|
-
if (!entry || typeof entry !== "object") return false;
|
|
696
|
-
const candidate = entry;
|
|
697
|
-
if (candidate.command !== "node" || !Array.isArray(candidate.args)) return false;
|
|
698
|
-
const script = candidate.args[0];
|
|
699
|
-
if (typeof script !== "string") return false;
|
|
700
|
-
const parts = script.replaceAll("\\", "/").split("/").filter(Boolean);
|
|
701
|
-
return parts.at(-1) === "mcp-server.js" && parts.at(-2) === "dist" && (parts.at(-3) === "coding-agents" || parts.at(-3) === "hindsight-coding-agents");
|
|
702
|
-
}
|
|
741
|
+
var version = "0.8.8";
|
|
703
742
|
|
|
704
743
|
// src/core/hindsight.ts
|
|
705
744
|
var USER_AGENT = `hindsight-coding-agents/${version}`;
|
|
@@ -911,7 +950,9 @@ var HindsightClient = class {
|
|
|
911
950
|
}
|
|
912
951
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
913
952
|
throw new Error(
|
|
914
|
-
|
|
953
|
+
// Query dropped: an encoded search query filled the 200-char error cap and pushed the
|
|
954
|
+
// status and the server's reason out of the tool error (#6341).
|
|
955
|
+
`${method} ${url.split("?")[0]} -> ${r.status} ${await r.text()}${this.authHint(r.status)}`
|
|
915
956
|
);
|
|
916
957
|
return r;
|
|
917
958
|
}
|
|
@@ -1057,6 +1098,15 @@ var HindsightClient = class {
|
|
|
1057
1098
|
await this.req("DELETE", this.bankUrl());
|
|
1058
1099
|
this.log(`[bank] reset ${this.bank}`);
|
|
1059
1100
|
}
|
|
1101
|
+
await this.configureBankSettings(opts);
|
|
1102
|
+
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1103
|
+
}
|
|
1104
|
+
/** The config half of `configureBank` (missions, retain strategies, entity labels), without
|
|
1105
|
+
* seeding pages. Session start calls it directly when the deepen engine — the usual caller of
|
|
1106
|
+
* `configureBank` — will not run (`autoSeed: false`, or a directory with no git history):
|
|
1107
|
+
* without it such a bank never got the `conversation` strategy, and every session write-back
|
|
1108
|
+
* was extracted with the server's generic rules instead of the plugin's mission. */
|
|
1109
|
+
async configureBankSettings(opts = {}) {
|
|
1060
1110
|
if (opts.manage === false) {
|
|
1061
1111
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
1062
1112
|
} else {
|
|
@@ -1072,7 +1122,6 @@ var HindsightClient = class {
|
|
|
1072
1122
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
1073
1123
|
}
|
|
1074
1124
|
}
|
|
1075
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1076
1125
|
}
|
|
1077
1126
|
/**
|
|
1078
1127
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -1905,10 +1954,14 @@ function resolvePartial(cfg, patch) {
|
|
|
1905
1954
|
}
|
|
1906
1955
|
|
|
1907
1956
|
// src/core/transcript-util.ts
|
|
1957
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
1908
1958
|
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;
|
|
1909
1959
|
function stripInjectedMemory(s) {
|
|
1910
1960
|
return s.replace(MEMORY_TAG_RE, "");
|
|
1911
1961
|
}
|
|
1962
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
1963
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
1964
|
+
}
|
|
1912
1965
|
var TARGET_KEYS = [
|
|
1913
1966
|
"file_path",
|
|
1914
1967
|
"path",
|
|
@@ -1936,7 +1989,25 @@ function actionLine(tool, input) {
|
|
|
1936
1989
|
target = input.trim().split("\n")[0];
|
|
1937
1990
|
}
|
|
1938
1991
|
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
1939
|
-
|
|
1992
|
+
const line = target ? `${tool} ${target}` : tool;
|
|
1993
|
+
const note = memoryNoteText(input);
|
|
1994
|
+
return note ? `${line}
|
|
1995
|
+
${truncate(note, MEMORY_NOTE_CAP)}` : line;
|
|
1996
|
+
}
|
|
1997
|
+
var MEMORY_NOTE_CAP = 8e3;
|
|
1998
|
+
var MEMORY_NOTE_PATH_RE = /(^|[\\/])(memory|memories)[\\/]|(^|[\\/])MEMORY\.md$/i;
|
|
1999
|
+
var MEMORY_SHELL_WRITE_RE = /[\\/](memory|memories)([\\/\s"']|$)|MEMORY\.md/i;
|
|
2000
|
+
var SHELL_WRITE_RE = /(^|[^0-9&>])>>?(?!&)|\btee\b/;
|
|
2001
|
+
function memoryNoteText(input) {
|
|
2002
|
+
if (!input || typeof input !== "object") return "";
|
|
2003
|
+
const rec = input;
|
|
2004
|
+
const cmd = rec.command;
|
|
2005
|
+
if (typeof cmd === "string")
|
|
2006
|
+
return MEMORY_SHELL_WRITE_RE.test(cmd) && SHELL_WRITE_RE.test(cmd) ? cmd.trim() : "";
|
|
2007
|
+
const path = rec.file_path ?? rec.path;
|
|
2008
|
+
if (typeof path !== "string" || !MEMORY_NOTE_PATH_RE.test(path)) return "";
|
|
2009
|
+
const text = rec.content ?? rec.new_string;
|
|
2010
|
+
return typeof text === "string" ? text.trim() : "";
|
|
1940
2011
|
}
|
|
1941
2012
|
|
|
1942
2013
|
// src/core/brand.ts
|
|
@@ -2019,7 +2090,7 @@ var TOOL_GUIDE = `- hindsight_search_pages(query) \u2014 FIRST STOP, and the way
|
|
|
2019
2090
|
\u2022 you are implementing something new, or two parts have to fit together;
|
|
2020
2091
|
\u2022 the user asks why something is the way it is, or what is left to do;
|
|
2021
2092
|
\u2022 you are about to commit, and need to know what the change was supposed to honour.
|
|
2022
|
-
It ranks the pages by relevance and
|
|
2093
|
+
It ranks the pages by relevance and shows the opening of each; every page can come back, so the ranking, not the list, is the signal. Read the top page with hindsight_read_page before you rely on it \u2014 the opening is not the passage that matched. What it returns is a past record, not a live reading: a claim that something was fixed, passes, or works is what someone said then \u2014 check it against the code before you rely on it, and say so when the two disagree.
|
|
2023
2094
|
CREDITING IS NOT OPTIONAL AND NOT A JUDGEMENT CALL. If you called this tool and anything it returned reached your reply \u2014 quoted, paraphrased, or merely confirming what you were about to say \u2014 open that part with a markdown blockquote, exactly: "> \u{1F9E0} **From Hindsight memory (<page>)** \u2014 <the specific facts you drew on>". Rewriting a snippet in your own words does not make it yours. A search that turned up nothing useful needs no mention at all \u2014 just carry on.
|
|
2024
2095
|
- hindsight_list_pages / hindsight_read_page \u2014 BEFORE substantial work, list the pages and read the relevant ones to ground yourself in this repo's architecture, conventions, and past decisions instead of re-deriving them from the code; follow any [[page:<id>]] links you see.
|
|
2025
2096
|
- hindsight_reflect(query) \u2014 when pages are too shallow and you need the WHY: deep reasoning over the repo's full memory for the past decision and exact values that explain a behavior or bug (slower \u2014 use deliberately, and credit results with a blockquote header "> \u{1F9E0} **From Hindsight memory** \u2014 <summary>").
|
|
@@ -2331,7 +2402,7 @@ async function buildHookOutput(args) {
|
|
|
2331
2402
|
});
|
|
2332
2403
|
const blocks = [];
|
|
2333
2404
|
if (reflectAnswer && reflectRanThisTurn) blocks.push(buildSystemInjection(reflectAnswer));
|
|
2334
|
-
if (cadence > 0 && turns % cadence === 0) {
|
|
2405
|
+
if (cadence > 0 && turns % cadence === 0 && !(turns === 1 && args.preambleOnFirstTurn)) {
|
|
2335
2406
|
blocks.push(
|
|
2336
2407
|
buildRosterRefresh(pages, {
|
|
2337
2408
|
reflectOnNewGoals: cfg.autoInject !== "reflect",
|
|
@@ -2654,7 +2725,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2654
2725
|
}
|
|
2655
2726
|
const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
2656
2727
|
const entry = {
|
|
2657
|
-
command:
|
|
2728
|
+
command: hookNode(),
|
|
2658
2729
|
args: [script],
|
|
2659
2730
|
env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
|
|
2660
2731
|
};
|
|
@@ -2965,6 +3036,27 @@ function readAntigravityTranscript(path) {
|
|
|
2965
3036
|
}
|
|
2966
3037
|
return turns;
|
|
2967
3038
|
}
|
|
3039
|
+
function readAntigravityPromptTurn(path) {
|
|
3040
|
+
if (!path) return void 0;
|
|
3041
|
+
let lastRole;
|
|
3042
|
+
let lastUserPrompt;
|
|
3043
|
+
for (const line of readJsonl(path)) {
|
|
3044
|
+
try {
|
|
3045
|
+
const event = JSON.parse(line);
|
|
3046
|
+
const role = event.role ?? event.message?.role ?? event.type;
|
|
3047
|
+
if (!role || role === "CHECKPOINT" || role === "EPHEMERAL_MESSAGE") continue;
|
|
3048
|
+
lastRole = role;
|
|
3049
|
+
if (role === "user" || role === "USER_INPUT") {
|
|
3050
|
+
const content = event.content ?? event.text ?? event.message?.content ?? event.message?.text;
|
|
3051
|
+
const text = typeof content === "string" ? stripInjectedMemory(content) : "";
|
|
3052
|
+
const clean = unwrapUserRequest(text).trim();
|
|
3053
|
+
lastUserPrompt = clean || void 0;
|
|
3054
|
+
}
|
|
3055
|
+
} catch {
|
|
3056
|
+
}
|
|
3057
|
+
}
|
|
3058
|
+
return lastRole === "user" || lastRole === "USER_INPUT" ? lastUserPrompt : void 0;
|
|
3059
|
+
}
|
|
2968
3060
|
|
|
2969
3061
|
// src/core/transcript-copilot.ts
|
|
2970
3062
|
function readCopilotTranscript(path) {
|
|
@@ -3689,9 +3781,10 @@ var antigravityPrompt = {
|
|
|
3689
3781
|
harness: "antigravity-cli",
|
|
3690
3782
|
requireCwd: true,
|
|
3691
3783
|
parse: (ev) => ({
|
|
3692
|
-
// Antigravity's PreInvocation payload
|
|
3693
|
-
//
|
|
3694
|
-
prompt
|
|
3784
|
+
// Antigravity's PreInvocation payload omits the prompt and fires before EVERY planner step in
|
|
3785
|
+
// the agent loop (including after every tool call). Read the transcript's trailing record so
|
|
3786
|
+
// only a genuine user submission returns a prompt and tool-result continuations are suppressed.
|
|
3787
|
+
prompt: readAntigravityPromptTurn(ev.transcriptPath),
|
|
3695
3788
|
cwd: antigravityCwd(ev),
|
|
3696
3789
|
sessionId: ev.conversationId
|
|
3697
3790
|
}),
|