@vectorize-io/hindsight-coding-agents 0.8.6 → 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 +31 -21
- package/dist/antigravity-hook.js +278 -190
- package/dist/antigravity-statusline.js +30 -24
- package/dist/antigravity-stop-hook.js +271 -169
- package/dist/claude-hook.js +278 -190
- package/dist/claude-sessionstart-hook.js +301 -212
- package/dist/claude-stop-hook.js +271 -169
- package/dist/cline.js +258 -214
- package/dist/codebuddy-hook.js +278 -190
- package/dist/codebuddy-sessionstart-hook.js +301 -212
- package/dist/codebuddy-stop-hook.js +271 -169
- package/dist/codex-hook.js +278 -190
- package/dist/codex-sessionstart-hook.js +301 -212
- package/dist/codex-stop-hook.js +271 -169
- package/dist/copilot-hook.js +278 -190
- package/dist/copilot-sessionstart-hook.js +301 -212
- package/dist/copilot-stop-hook.js +271 -169
- package/dist/cursor-hook.js +278 -190
- package/dist/cursor-sessionstart-hook.js +301 -212
- package/dist/cursor-stop-hook.js +271 -169
- package/dist/daemon-start.js +20 -16
- package/dist/dcode-hook.js +278 -190
- package/dist/dcode-sessionstart-hook.js +301 -212
- package/dist/dcode-stop-hook.js +271 -169
- package/dist/deepen.js +98 -83
- package/dist/devin-hook.js +278 -190
- package/dist/devin-sessionstart-hook.js +301 -212
- package/dist/devin-stop-hook.js +271 -169
- package/dist/droid-hook.js +278 -190
- package/dist/droid-sessionstart-hook.js +301 -212
- package/dist/droid-stop-hook.js +271 -169
- package/dist/dsh.js +309 -251
- package/dist/grok-hook.js +278 -190
- package/dist/grok-sessionstart-hook.js +301 -212
- package/dist/grok-stop-hook.js +271 -169
- package/dist/hindsight-seed.js +35 -26
- package/dist/index.js +310 -252
- package/dist/installer.js +172 -68
- package/dist/kilo.js +310 -252
- package/dist/kimi-hook.js +278 -190
- package/dist/kimi-sessionstart-hook.js +301 -212
- package/dist/kimi-stop-hook.js +271 -169
- package/dist/mcp-server.js +165 -148
- package/dist/opencode2.js +310 -252
- package/dist/pi.js +309 -251
- package/dist/prime-agent.js +309 -251
- package/dist/qwen-hook.js +278 -190
- package/dist/qwen-sessionstart-hook.js +301 -212
- package/dist/qwen-stop-hook.js +271 -169
- package/dist/status.js +134 -117
- package/dist/traecode-hook.js +278 -190
- package/dist/traecode-sessionstart-hook.js +301 -212
- package/dist/traecode-stop-hook.js +271 -169
- package/dist/workbuddy-hook.js +278 -190
- package/dist/workbuddy-sessionstart-hook.js +301 -212
- package/dist/workbuddy-stop-hook.js +271 -169
- package/dist/zcode-hook.js +278 -190
- package/dist/zcode-sessionstart-hook.js +301 -212
- package/dist/zcode-stop-hook.js +271 -169
- package/package.json +2 -1
- package/plugin.json +1 -1
- package/skill/SKILL.md +31 -26
package/dist/grok-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.";
|
|
@@ -417,14 +498,14 @@ var RETAIN_STRATEGIES = {
|
|
|
417
498
|
retain_chunk_size: 12e3
|
|
418
499
|
}
|
|
419
500
|
};
|
|
420
|
-
var
|
|
501
|
+
var PAGE_LABELS = {
|
|
421
502
|
key: "knowledge",
|
|
422
503
|
type: "multi-values",
|
|
423
504
|
// 0, 1, or several — empty is normal
|
|
424
505
|
optional: true,
|
|
425
506
|
tag: true,
|
|
426
507
|
// emits knowledge:<value> onto the fact's tags
|
|
427
|
-
description: "Routing labels for this project's Hindsight
|
|
508
|
+
description: "Routing labels for this project's Hindsight PAGES \u2014 curated, human-readable summaries of the repo's DURABLE engineering knowledge (architecture, key decisions, conventions, ongoing initiatives), each page rebuilt automatically from the facts labeled for it. Mark a fact only when it is durable, reusable knowledge a developer would still want surfaced in future sessions. IMPORTANT: leave this EMPTY for routine, transient, or operational facts \u2014 a passing test, a one-off command, a status update, a debugging dead-end. MOST facts should get no label here. Assign more than one value only when the fact genuinely fits several.",
|
|
428
509
|
values: [
|
|
429
510
|
{
|
|
430
511
|
value: "feature-work",
|
|
@@ -581,7 +662,7 @@ var CODING_BANK_TEMPLATE = {
|
|
|
581
662
|
retain_extraction_mode: DEFAULT_RETAIN_EXTRACTION_MODE,
|
|
582
663
|
retain_default_strategy: "git",
|
|
583
664
|
retain_strategies: RETAIN_STRATEGIES,
|
|
584
|
-
entity_labels: [
|
|
665
|
+
entity_labels: [PAGE_LABELS],
|
|
585
666
|
entities_allow_free_form: true
|
|
586
667
|
}
|
|
587
668
|
};
|
|
@@ -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}`;
|
|
@@ -702,11 +741,11 @@ function retryAfterMs(header) {
|
|
|
702
741
|
const at = Date.parse(header);
|
|
703
742
|
return Number.isNaN(at) ? 0 : Math.max(0, at - Date.now());
|
|
704
743
|
}
|
|
705
|
-
var
|
|
706
|
-
code = "
|
|
744
|
+
var PagesUnavailableError = class extends Error {
|
|
745
|
+
code = "pages_unavailable";
|
|
707
746
|
constructor() {
|
|
708
|
-
super("Hindsight server does not support
|
|
709
|
-
this.name = "
|
|
747
|
+
super("Hindsight server does not support pages");
|
|
748
|
+
this.name = "PagesUnavailableError";
|
|
710
749
|
}
|
|
711
750
|
};
|
|
712
751
|
async function isEndpointMissing(r) {
|
|
@@ -717,6 +756,10 @@ async function isEndpointMissing(r) {
|
|
|
717
756
|
return false;
|
|
718
757
|
}
|
|
719
758
|
}
|
|
759
|
+
function pagesPath(sub, legacy = false) {
|
|
760
|
+
if (!legacy) return `/pages${sub}`;
|
|
761
|
+
return /^\/(tree|folders|search|export|nodes)\b/.test(sub) ? `/knowledge-base${sub}` : `/knowledge-base/pages${sub}`;
|
|
762
|
+
}
|
|
720
763
|
var TERMINAL = /* @__PURE__ */ new Set(["completed", "failed", "cancelled", "error"]);
|
|
721
764
|
var ReflectError = class extends Error {
|
|
722
765
|
constructor(message, status, timedOut, options) {
|
|
@@ -785,7 +828,7 @@ var HindsightClient = class {
|
|
|
785
828
|
opIds = [];
|
|
786
829
|
// async operation ids collected by retain(), for drain()
|
|
787
830
|
/** Tri-state capability probe: unknown until the first page request, then cached. */
|
|
788
|
-
|
|
831
|
+
pagesSupported;
|
|
789
832
|
/** Tri-state capability probe: unknown until the first append-mode retain, then cached. */
|
|
790
833
|
idempotentRetain;
|
|
791
834
|
log;
|
|
@@ -883,7 +926,9 @@ var HindsightClient = class {
|
|
|
883
926
|
}
|
|
884
927
|
if (!r.ok && r.status !== 404 && !tolerate.includes(r.status))
|
|
885
928
|
throw new Error(
|
|
886
|
-
|
|
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)}`
|
|
887
932
|
);
|
|
888
933
|
return r;
|
|
889
934
|
}
|
|
@@ -1014,7 +1059,7 @@ var HindsightClient = class {
|
|
|
1014
1059
|
return (j.total ?? j.items?.length ?? 0) > 0;
|
|
1015
1060
|
}
|
|
1016
1061
|
/** Configure the bank: POST the coding bank manifest to /import (missions, retain strategies,
|
|
1017
|
-
* entity labels), then seed
|
|
1062
|
+
* entity labels), then seed pages when the server supports them. Both halves are
|
|
1018
1063
|
* idempotent and ADDITIVE — nothing the bank already says is overwritten (#3927), bar the
|
|
1019
1064
|
* extraction mode of the plugin's own strategies, which follows its config (#4560) — so
|
|
1020
1065
|
* the deepen engine can re-run this every pass. Creates the bank if missing; legacy servers
|
|
@@ -1029,6 +1074,15 @@ var HindsightClient = class {
|
|
|
1029
1074
|
await this.req("DELETE", this.bankUrl());
|
|
1030
1075
|
this.log(`[bank] reset ${this.bank}`);
|
|
1031
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 = {}) {
|
|
1032
1086
|
if (opts.manage === false) {
|
|
1033
1087
|
this.log(`[bank] manageBankConfig: false \u2014 leaving ${this.bank}'s configuration alone`);
|
|
1034
1088
|
} else {
|
|
@@ -1044,7 +1098,6 @@ var HindsightClient = class {
|
|
|
1044
1098
|
this.log(`[bank] applied to ${this.bank}: ${Object.keys(manifest.bank).sort().join(", ")}`);
|
|
1045
1099
|
}
|
|
1046
1100
|
}
|
|
1047
|
-
await this.seedPages(opts.pageTrigger, opts.pages, opts.customPages);
|
|
1048
1101
|
}
|
|
1049
1102
|
/**
|
|
1050
1103
|
* This bank's own config OVERRIDES, or undefined when there are none to read.
|
|
@@ -1196,29 +1249,45 @@ var HindsightClient = class {
|
|
|
1196
1249
|
const j = await r.json();
|
|
1197
1250
|
return (j.results ?? []).map((x) => (x.text ?? "").trim()).filter(Boolean);
|
|
1198
1251
|
}
|
|
1252
|
+
/** Set once a server answered on the deprecated `/knowledge-base/...` paths: one from before the
|
|
1253
|
+
* page routes moved to `/pages/...`. Remove in 2.x. */
|
|
1254
|
+
legacyPagesPaths = false;
|
|
1199
1255
|
/**
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
*
|
|
1256
|
+
* Request a page endpoint by its `/pages` sub-path (`""`, `/tree`, `/<id>`, `/nodes/<id>`, …).
|
|
1257
|
+
*
|
|
1258
|
+
* Returns `null` — and latches `pagesSupported = false` — iff the endpoint is really absent: an
|
|
1259
|
+
* unrouted 404 on the `/pages` path AND on its pre-rename `/knowledge-base` twin, which a server
|
|
1260
|
+
* older than the rename still serves (tried once, then remembered). A bank-not-found 404 is NOT
|
|
1261
|
+
* a capability verdict — it is the expected answer before the bank's first retain — so it is
|
|
1262
|
+
* returned as-is and never caches a negative (#4607). A 404's body may already be consumed.
|
|
1203
1263
|
*
|
|
1204
1264
|
* Only 404 is tested: `req` throws on every other non-ok status it was not told to tolerate, so
|
|
1205
1265
|
* the 405/501 this used to check for never reach a caller in the first place.
|
|
1206
1266
|
*/
|
|
1207
|
-
async
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
return
|
|
1267
|
+
async pagesReq(method, sub, body, tolerate = [], timeoutMs) {
|
|
1268
|
+
const send = (legacy) => this.req(method, this.bankUrl(pagesPath(sub, legacy)), body, tolerate, timeoutMs);
|
|
1269
|
+
let r = await send(this.legacyPagesPaths);
|
|
1270
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) return r;
|
|
1271
|
+
if (!this.legacyPagesPaths) {
|
|
1272
|
+
r = await send(true);
|
|
1273
|
+
if (r.status !== 404 || !await isEndpointMissing(r)) {
|
|
1274
|
+
this.legacyPagesPaths = true;
|
|
1275
|
+
return r;
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
this.pagesSupported = false;
|
|
1279
|
+
return null;
|
|
1211
1280
|
}
|
|
1212
1281
|
/**
|
|
1213
|
-
* The bank's
|
|
1282
|
+
* The bank's page tree (folders + pages, nested). The tree carries names, source
|
|
1214
1283
|
* queries and staleness but NOT synthesized content, so it is cheap enough to poll.
|
|
1215
1284
|
*/
|
|
1216
1285
|
async tree() {
|
|
1217
|
-
if (this.
|
|
1218
|
-
const r = await this.
|
|
1219
|
-
if (
|
|
1286
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1287
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1288
|
+
if (!r) throw new PagesUnavailableError();
|
|
1220
1289
|
if (r.status === 404) return [];
|
|
1221
|
-
this.
|
|
1290
|
+
this.pagesSupported = true;
|
|
1222
1291
|
try {
|
|
1223
1292
|
return (await r.json()).roots ?? [];
|
|
1224
1293
|
} catch {
|
|
@@ -1226,13 +1295,13 @@ var HindsightClient = class {
|
|
|
1226
1295
|
}
|
|
1227
1296
|
}
|
|
1228
1297
|
/**
|
|
1229
|
-
* List
|
|
1298
|
+
* List pages (ids + names only — no synthesized content), flattened out of the tree
|
|
1230
1299
|
* and shaped as `{items:[…]}` for `parsePageList`. Folders are dropped: they carry no content
|
|
1231
1300
|
* to read, and a caller enumerating pages wants leaves, not structure.
|
|
1232
1301
|
*
|
|
1233
|
-
* NOTE the ids are
|
|
1234
|
-
* page read/update in this client goes through the same
|
|
1235
|
-
* here, from `
|
|
1302
|
+
* NOTE the ids are page node ids (`kp-…`), NOT the backing mental-model ids. Every
|
|
1303
|
+
* page read/update in this client goes through the same page ids, so a page id from
|
|
1304
|
+
* here, from `searchPages`, or from a `[[page:<id>]]` link all resolve identically.
|
|
1236
1305
|
*/
|
|
1237
1306
|
async listPages() {
|
|
1238
1307
|
const items = [];
|
|
@@ -1254,34 +1323,26 @@ var HindsightClient = class {
|
|
|
1254
1323
|
return { items };
|
|
1255
1324
|
}
|
|
1256
1325
|
/**
|
|
1257
|
-
* Read one
|
|
1326
|
+
* Read one page's synthesized content by page id, shaped by `shapePage` so
|
|
1258
1327
|
* the body arrives once. The endpoint omits the internal reflect trace that built
|
|
1259
1328
|
* the page — that is 70-95% of the raw bytes and can blow past an MCP host's per-tool-result
|
|
1260
1329
|
* token cap.
|
|
1261
1330
|
*/
|
|
1262
1331
|
async getPage(pageId) {
|
|
1263
|
-
if (this.
|
|
1264
|
-
const r = await this.
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
);
|
|
1268
|
-
if (r.status === 404) throw new Error(`knowledge page not found: ${pageId}`);
|
|
1332
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1333
|
+
const r = await this.pagesReq("GET", `/${encodeURIComponent(pageId)}`);
|
|
1334
|
+
if (!r) throw new PagesUnavailableError();
|
|
1335
|
+
if (r.status === 404) throw new Error(`page not found: ${pageId}`);
|
|
1269
1336
|
return shapePage(await r.json());
|
|
1270
1337
|
}
|
|
1271
|
-
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's
|
|
1338
|
+
/** Hybrid (BM25 + vector, RRF-fused) server-side search over the bank's pages.
|
|
1272
1339
|
* Returns page-level hits with a relevance snippet — the real search behind
|
|
1273
|
-
*
|
|
1274
|
-
async
|
|
1275
|
-
if (this.
|
|
1340
|
+
* hindsight_search_pages. */
|
|
1341
|
+
async searchPages(query, opts = {}) {
|
|
1342
|
+
if (this.pagesSupported === false) throw new PagesUnavailableError();
|
|
1276
1343
|
const q = `?q=${encodeURIComponent(query)}&limit=${opts.limit ?? this.pageSearchLimit}`;
|
|
1277
|
-
const r = await this.
|
|
1278
|
-
|
|
1279
|
-
this.bankUrl(`/knowledge-base/search${q}`),
|
|
1280
|
-
void 0,
|
|
1281
|
-
[],
|
|
1282
|
-
opts.timeoutMs
|
|
1283
|
-
);
|
|
1284
|
-
if (await this.pagesUnsupported(r)) throw new KnowledgePagesUnavailableError();
|
|
1344
|
+
const r = await this.pagesReq("GET", `/search${q}`, void 0, [], opts.timeoutMs);
|
|
1345
|
+
if (!r) throw new PagesUnavailableError();
|
|
1285
1346
|
if (r.status === 404) return [];
|
|
1286
1347
|
const j = await r.json();
|
|
1287
1348
|
return (j.results ?? []).map((x) => ({
|
|
@@ -1293,9 +1354,9 @@ var HindsightClient = class {
|
|
|
1293
1354
|
}));
|
|
1294
1355
|
}
|
|
1295
1356
|
/**
|
|
1296
|
-
* Seed the fixed page taxonomy as
|
|
1357
|
+
* Seed the fixed page taxonomy as pages at the tree root, idempotently.
|
|
1297
1358
|
*
|
|
1298
|
-
* Matched by NAME, not id:
|
|
1359
|
+
* Matched by NAME, not id: `POST /pages` mints its own `kp-…` id, so a stable
|
|
1299
1360
|
* client-chosen id isn't available to match on (unlike the old mental-model path, which keyed
|
|
1300
1361
|
* off a slug). Names are unique per folder server-side, which makes them a sound key.
|
|
1301
1362
|
*
|
|
@@ -1310,8 +1371,8 @@ var HindsightClient = class {
|
|
|
1310
1371
|
try {
|
|
1311
1372
|
roots = await this.tree();
|
|
1312
1373
|
} catch (e) {
|
|
1313
|
-
if (e instanceof
|
|
1314
|
-
this.log(`[bank]
|
|
1374
|
+
if (e instanceof PagesUnavailableError) {
|
|
1375
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1315
1376
|
return;
|
|
1316
1377
|
}
|
|
1317
1378
|
throw e;
|
|
@@ -1334,11 +1395,9 @@ var HindsightClient = class {
|
|
|
1334
1395
|
trigger: pageTriggerFor(pageTrigger, this.bank, page.name)
|
|
1335
1396
|
};
|
|
1336
1397
|
if (!hit) {
|
|
1337
|
-
const r = await this.
|
|
1338
|
-
if (
|
|
1339
|
-
this.log(
|
|
1340
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1341
|
-
);
|
|
1398
|
+
const r = await this.pagesReq("POST", "", body, [409]);
|
|
1399
|
+
if (!r) {
|
|
1400
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1342
1401
|
return;
|
|
1343
1402
|
}
|
|
1344
1403
|
if (r.status === 404) {
|
|
@@ -1359,15 +1418,9 @@ var HindsightClient = class {
|
|
|
1359
1418
|
);
|
|
1360
1419
|
}
|
|
1361
1420
|
if (triggerDrift) patch.trigger = pageTriggerPatch(body.trigger);
|
|
1362
|
-
const r = await this.
|
|
1363
|
-
|
|
1364
|
-
this.
|
|
1365
|
-
patch
|
|
1366
|
-
);
|
|
1367
|
-
if (await this.pagesUnsupported(r)) {
|
|
1368
|
-
this.log(
|
|
1369
|
-
`[bank] knowledge pages unavailable on ${this.apiUrl}; continuing without pages`
|
|
1370
|
-
);
|
|
1421
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(hit.id)}`, patch);
|
|
1422
|
+
if (!r) {
|
|
1423
|
+
this.log(`[bank] pages unavailable on ${this.apiUrl}; continuing without them`);
|
|
1371
1424
|
return;
|
|
1372
1425
|
}
|
|
1373
1426
|
if (r.status === 404) {
|
|
@@ -1379,7 +1432,7 @@ var HindsightClient = class {
|
|
|
1379
1432
|
}
|
|
1380
1433
|
const initiatives = await this.resyncInitiativeTriggers(roots, pageTrigger);
|
|
1381
1434
|
this.log(
|
|
1382
|
-
`[bank]
|
|
1435
|
+
`[bank] pages seeded on ${this.bank} (scoped to ${this.project ?? "the shared bank"}): ${created} created, ${updated} re-synced, ${pages.length - created - updated - vanished} unchanged` + (vanished ? `, ${vanished} deleted under us` : "") + (initiatives ? `, ${initiatives} initiative pages re-synced` : "")
|
|
1383
1436
|
);
|
|
1384
1437
|
}
|
|
1385
1438
|
/**
|
|
@@ -1413,12 +1466,8 @@ var HindsightClient = class {
|
|
|
1413
1466
|
if (pageTriggerDrifted(page.trigger, desired)) patch.trigger = pageTriggerPatch(desired);
|
|
1414
1467
|
}
|
|
1415
1468
|
if (!patch.trigger && !patch.source_query) continue;
|
|
1416
|
-
const r = await this.
|
|
1417
|
-
|
|
1418
|
-
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(page.id)}`),
|
|
1419
|
-
patch
|
|
1420
|
-
);
|
|
1421
|
-
if (r.status === 404) continue;
|
|
1469
|
+
const r = await this.pagesReq("PATCH", `/nodes/${encodeURIComponent(page.id)}`, patch);
|
|
1470
|
+
if (!r || r.status === 404) continue;
|
|
1422
1471
|
updated++;
|
|
1423
1472
|
}
|
|
1424
1473
|
return updated;
|
|
@@ -1444,7 +1493,7 @@ var HindsightClient = class {
|
|
|
1444
1493
|
let pageId = args.relatesToPageId;
|
|
1445
1494
|
if (!pageId) {
|
|
1446
1495
|
const folderId = await this.ensureFolder("Initiatives");
|
|
1447
|
-
const r = await this.
|
|
1496
|
+
const r = await this.pagesReq("POST", "", {
|
|
1448
1497
|
name: args.title,
|
|
1449
1498
|
source_query: `Summarize the "${args.title}" initiative: what is being built or changed and why, and its current state \u2014 drawn from the project's memory.` + pageScopeRule(this.project),
|
|
1450
1499
|
parent_id: folderId,
|
|
@@ -1453,8 +1502,8 @@ var HindsightClient = class {
|
|
|
1453
1502
|
trigger: pageTriggerFor(args.pageTrigger ?? buildPageTrigger(), this.bank, args.title)
|
|
1454
1503
|
});
|
|
1455
1504
|
try {
|
|
1456
|
-
const j = await r
|
|
1457
|
-
pageId = j
|
|
1505
|
+
const j = await r?.json();
|
|
1506
|
+
pageId = j?.page_id ?? j?.id;
|
|
1458
1507
|
} catch {
|
|
1459
1508
|
}
|
|
1460
1509
|
pageId ||= `initiative-${this.slugify(args.title)}`;
|
|
@@ -1472,16 +1521,17 @@ var HindsightClient = class {
|
|
|
1472
1521
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
1473
1522
|
async ensureFolder(name) {
|
|
1474
1523
|
try {
|
|
1475
|
-
const
|
|
1476
|
-
const
|
|
1524
|
+
const r = await this.pagesReq("GET", "/tree");
|
|
1525
|
+
const tree = await r?.json();
|
|
1526
|
+
const hit = (tree?.roots || []).find(
|
|
1477
1527
|
(n) => n.kind === "folder" && (n.name || "").toLowerCase() === name.toLowerCase()
|
|
1478
1528
|
);
|
|
1479
1529
|
if (hit?.id) return hit.id;
|
|
1480
1530
|
} catch {
|
|
1481
1531
|
}
|
|
1482
1532
|
try {
|
|
1483
|
-
const r = await this.
|
|
1484
|
-
return (await r
|
|
1533
|
+
const r = await this.pagesReq("POST", "/folders", { name });
|
|
1534
|
+
return (await r?.json())?.id;
|
|
1485
1535
|
} catch {
|
|
1486
1536
|
return void 0;
|
|
1487
1537
|
}
|
|
@@ -1879,6 +1929,63 @@ function resolvePartial(cfg, patch) {
|
|
|
1879
1929
|
return out;
|
|
1880
1930
|
}
|
|
1881
1931
|
|
|
1932
|
+
// src/core/transcript-util.ts
|
|
1933
|
+
var TOOL_TEXT_CAP = 2e3;
|
|
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;
|
|
1935
|
+
function stripInjectedMemory(s) {
|
|
1936
|
+
return s.replace(MEMORY_TAG_RE, "");
|
|
1937
|
+
}
|
|
1938
|
+
function truncate(s, max = TOOL_TEXT_CAP) {
|
|
1939
|
+
return s.length > max ? `${s.slice(0, max)}\u2026 (truncated)` : s;
|
|
1940
|
+
}
|
|
1941
|
+
var TARGET_KEYS = [
|
|
1942
|
+
"file_path",
|
|
1943
|
+
"path",
|
|
1944
|
+
"notebook_path",
|
|
1945
|
+
"command",
|
|
1946
|
+
"pattern",
|
|
1947
|
+
"query",
|
|
1948
|
+
"url",
|
|
1949
|
+
"name",
|
|
1950
|
+
"id"
|
|
1951
|
+
];
|
|
1952
|
+
var ACTION_TARGET_CAP = 100;
|
|
1953
|
+
function actionLine(tool, input) {
|
|
1954
|
+
let target = "";
|
|
1955
|
+
if (input && typeof input === "object") {
|
|
1956
|
+
const rec = input;
|
|
1957
|
+
for (const k of TARGET_KEYS) {
|
|
1958
|
+
const v = rec[k];
|
|
1959
|
+
if (typeof v === "string" && v.trim()) {
|
|
1960
|
+
target = v.trim().split("\n")[0];
|
|
1961
|
+
break;
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
} else if (typeof input === "string") {
|
|
1965
|
+
target = input.trim().split("\n")[0];
|
|
1966
|
+
}
|
|
1967
|
+
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
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() : "";
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1882
1989
|
// src/core/session-cache.ts
|
|
1883
1990
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, rmSync, writeFileSync } from "fs";
|
|
1884
1991
|
import { tmpdir } from "os";
|
|
@@ -1958,43 +2065,6 @@ function fileCursorStore(harness) {
|
|
|
1958
2065
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync3, readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
1959
2066
|
import { tmpdir as tmpdir2 } from "os";
|
|
1960
2067
|
import { dirname as dirname6, join as join9 } from "path";
|
|
1961
|
-
|
|
1962
|
-
// src/core/transcript-util.ts
|
|
1963
|
-
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;
|
|
1964
|
-
function stripInjectedMemory(s) {
|
|
1965
|
-
return s.replace(MEMORY_TAG_RE, "");
|
|
1966
|
-
}
|
|
1967
|
-
var TARGET_KEYS = [
|
|
1968
|
-
"file_path",
|
|
1969
|
-
"path",
|
|
1970
|
-
"notebook_path",
|
|
1971
|
-
"command",
|
|
1972
|
-
"pattern",
|
|
1973
|
-
"query",
|
|
1974
|
-
"url",
|
|
1975
|
-
"name",
|
|
1976
|
-
"id"
|
|
1977
|
-
];
|
|
1978
|
-
var ACTION_TARGET_CAP = 100;
|
|
1979
|
-
function actionLine(tool, input) {
|
|
1980
|
-
let target = "";
|
|
1981
|
-
if (input && typeof input === "object") {
|
|
1982
|
-
const rec = input;
|
|
1983
|
-
for (const k of TARGET_KEYS) {
|
|
1984
|
-
const v = rec[k];
|
|
1985
|
-
if (typeof v === "string" && v.trim()) {
|
|
1986
|
-
target = v.trim().split("\n")[0];
|
|
1987
|
-
break;
|
|
1988
|
-
}
|
|
1989
|
-
}
|
|
1990
|
-
} else if (typeof input === "string") {
|
|
1991
|
-
target = input.trim().split("\n")[0];
|
|
1992
|
-
}
|
|
1993
|
-
if (target.length > ACTION_TARGET_CAP) target = `${target.slice(0, ACTION_TARGET_CAP)}\u2026`;
|
|
1994
|
-
return target ? `${tool} ${target}` : tool;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
// src/core/turn-journal.ts
|
|
1998
2068
|
var JOURNAL_MAX_BYTES = 8 * 1024 * 1024;
|
|
1999
2069
|
function journalPath(harness, sessionId) {
|
|
2000
2070
|
return join9(tmpdir2(), `hindsight-${harness}`, `${sessionId || "no-session"}.journal.jsonl`);
|
|
@@ -2407,13 +2477,18 @@ function onPath(bin) {
|
|
|
2407
2477
|
return false;
|
|
2408
2478
|
}
|
|
2409
2479
|
}
|
|
2480
|
+
var DAEMON_CONFIG_ENV = "HINDSIGHT_CODING_AGENTS_DAEMON_CONFIG";
|
|
2410
2481
|
function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
2411
2482
|
try {
|
|
2412
2483
|
const starter = join10(dirname7(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
2413
|
-
const child = spawnFn(
|
|
2484
|
+
const child = spawnFn(nodeBinary(), [starter, "--harness", harness], {
|
|
2414
2485
|
detached: true,
|
|
2415
2486
|
stdio: "ignore",
|
|
2416
|
-
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) }
|
|
2417
2492
|
});
|
|
2418
2493
|
child.on("error", () => {
|
|
2419
2494
|
});
|
|
@@ -2580,7 +2655,7 @@ function* readJsonl(path) {
|
|
|
2580
2655
|
}
|
|
2581
2656
|
|
|
2582
2657
|
// src/core/transcript.ts
|
|
2583
|
-
function renderLine(content, type) {
|
|
2658
|
+
function renderLine(content, type, questionIds) {
|
|
2584
2659
|
if (typeof content === "string") {
|
|
2585
2660
|
const text = stripInjectedMemory(content).trim();
|
|
2586
2661
|
return text ? [{ role: type, content: text }] : [];
|
|
@@ -2594,7 +2669,11 @@ function renderLine(content, type) {
|
|
|
2594
2669
|
const t = stripInjectedMemory(b.text).trim();
|
|
2595
2670
|
if (t) texts.push(t);
|
|
2596
2671
|
} else if (b.type === "tool_use" && typeof b.name === "string") {
|
|
2672
|
+
if (b.name === "AskUserQuestion" && typeof b.id === "string") questionIds.add(b.id);
|
|
2597
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);
|
|
2598
2677
|
}
|
|
2599
2678
|
}
|
|
2600
2679
|
const out = [];
|
|
@@ -2605,6 +2684,7 @@ function renderLine(content, type) {
|
|
|
2605
2684
|
}
|
|
2606
2685
|
function readClaudeTranscript(path) {
|
|
2607
2686
|
const turns = [];
|
|
2687
|
+
const questionIds = /* @__PURE__ */ new Set();
|
|
2608
2688
|
for (const rawLine of readJsonl(path)) {
|
|
2609
2689
|
const trimmed = rawLine.trim();
|
|
2610
2690
|
if (!trimmed) continue;
|
|
@@ -2621,7 +2701,7 @@ function readClaudeTranscript(path) {
|
|
|
2621
2701
|
if (line.isSidechain === true) continue;
|
|
2622
2702
|
if (line.isCompactSummary === true) continue;
|
|
2623
2703
|
if (typeof line.message !== "object" || line.message === null) continue;
|
|
2624
|
-
for (const rendered of renderLine(line.message.content, line.type)) {
|
|
2704
|
+
for (const rendered of renderLine(line.message.content, line.type, questionIds)) {
|
|
2625
2705
|
const turn = { role: rendered.role, content: rendered.content };
|
|
2626
2706
|
if (typeof line.timestamp === "string") turn.timestamp = line.timestamp;
|
|
2627
2707
|
turns.push(turn);
|
|
@@ -2981,7 +3061,7 @@ function registerTraecodeWorkspaceMcp(cwd, opts = {}) {
|
|
|
2981
3061
|
}
|
|
2982
3062
|
const servers = doc.mcpServers && typeof doc.mcpServers === "object" && !Array.isArray(doc.mcpServers) ? doc.mcpServers : doc.mcpServers = {};
|
|
2983
3063
|
const entry = {
|
|
2984
|
-
command:
|
|
3064
|
+
command: hookNode(),
|
|
2985
3065
|
args: [script],
|
|
2986
3066
|
env: { HINDSIGHT_MCP_HARNESS: "traecode", HINDSIGHT_MCP_PROJECT_CWD: cwd }
|
|
2987
3067
|
};
|
|
@@ -3292,6 +3372,27 @@ function readAntigravityTranscript(path) {
|
|
|
3292
3372
|
}
|
|
3293
3373
|
return turns;
|
|
3294
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
|
+
}
|
|
3295
3396
|
|
|
3296
3397
|
// src/core/transcript-copilot.ts
|
|
3297
3398
|
function readCopilotTranscript(path) {
|
|
@@ -4016,9 +4117,10 @@ var antigravityPrompt = {
|
|
|
4016
4117
|
harness: "antigravity-cli",
|
|
4017
4118
|
requireCwd: true,
|
|
4018
4119
|
parse: (ev) => ({
|
|
4019
|
-
// Antigravity's PreInvocation payload
|
|
4020
|
-
//
|
|
4021
|
-
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),
|
|
4022
4124
|
cwd: antigravityCwd(ev),
|
|
4023
4125
|
sessionId: ev.conversationId
|
|
4024
4126
|
}),
|