@vectorize-io/hindsight-coding-agents 0.4.0 → 0.4.2
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 +84 -4
- package/dist/antigravity-hook.js +56 -25
- package/dist/antigravity-statusline.js +24 -2
- package/dist/antigravity-stop-hook.js +69 -26
- package/dist/claude-hook.js +56 -25
- package/dist/claude-sessionstart-hook.js +83 -31
- package/dist/claude-stop-hook.js +69 -26
- package/dist/cline.js +85 -32
- package/dist/codex-hook.js +56 -25
- package/dist/codex-sessionstart-hook.js +83 -31
- package/dist/codex-stop-hook.js +69 -26
- package/dist/copilot-hook.js +56 -25
- package/dist/copilot-sessionstart-hook.js +83 -31
- package/dist/copilot-stop-hook.js +69 -26
- package/dist/cursor-hook.js +56 -25
- package/dist/cursor-sessionstart-hook.js +83 -31
- package/dist/cursor-stop-hook.js +69 -26
- package/dist/daemon-start.js +15 -3
- package/dist/deepen.js +58 -24
- package/dist/devin-hook.js +56 -25
- package/dist/devin-sessionstart-hook.js +83 -31
- package/dist/devin-stop-hook.js +69 -26
- package/dist/dsh.js +85 -32
- package/dist/grok-hook.js +56 -25
- package/dist/grok-sessionstart-hook.js +83 -31
- package/dist/grok-stop-hook.js +69 -26
- package/dist/hindsight-seed.js +26 -3
- package/dist/index.js +85 -32
- package/dist/installer.js +16 -4
- package/dist/kilo.js +85 -32
- package/dist/mcp-server.js +59 -24
- package/dist/prime-agent.js +85 -32
- package/dist/status.js +59 -24
- package/package.json +3 -2
- package/skill/SKILL.md +345 -68
|
@@ -33,14 +33,36 @@ function getProjectRootFromGit(directory) {
|
|
|
33
33
|
const commonDir = execFileSync(
|
|
34
34
|
"git",
|
|
35
35
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
36
|
-
{
|
|
36
|
+
{
|
|
37
|
+
cwd: directory,
|
|
38
|
+
encoding: "utf-8",
|
|
39
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
40
|
+
timeout: 1e3,
|
|
41
|
+
windowsHide: true
|
|
42
|
+
}
|
|
37
43
|
).trim();
|
|
38
44
|
if (!commonDir) return null;
|
|
39
|
-
|
|
45
|
+
if (basename(commonDir) === ".git") return dirname(commonDir);
|
|
46
|
+
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
47
|
+
return dirname(commonDir);
|
|
48
|
+
}
|
|
49
|
+
return commonDir;
|
|
40
50
|
} catch {
|
|
41
51
|
return null;
|
|
42
52
|
}
|
|
43
53
|
}
|
|
54
|
+
function isBareRepository(commonDir) {
|
|
55
|
+
try {
|
|
56
|
+
return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
|
|
57
|
+
encoding: "utf-8",
|
|
58
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
59
|
+
timeout: 1e3,
|
|
60
|
+
env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
|
|
61
|
+
}).trim() === "true";
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
44
66
|
function projectNameOf(directory, sessionRoot) {
|
|
45
67
|
return gitProjectName(directory, true, sessionRoot);
|
|
46
68
|
}
|
|
@@ -160,7 +182,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
160
182
|
],
|
|
161
183
|
{
|
|
162
184
|
detached: true,
|
|
163
|
-
stdio: "ignore"
|
|
185
|
+
stdio: "ignore",
|
|
186
|
+
windowsHide: true
|
|
164
187
|
}
|
|
165
188
|
);
|
|
166
189
|
child.on("error", () => {
|
|
@@ -304,7 +327,7 @@ var PAGE_TAXONOMY = [
|
|
|
304
327
|
},
|
|
305
328
|
{
|
|
306
329
|
name: "Initiatives and enhancements",
|
|
307
|
-
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory carries a
|
|
330
|
+
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
|
|
308
331
|
tags: ["knowledge:feature-work"]
|
|
309
332
|
}
|
|
310
333
|
];
|
|
@@ -313,9 +336,10 @@ function pagesFor(project) {
|
|
|
313
336
|
return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
|
|
314
337
|
}
|
|
315
338
|
var PAGE_MAX_TOKENS = 4096;
|
|
339
|
+
var PAGE_TAGS_MATCH = "all";
|
|
316
340
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
317
341
|
function buildPageTrigger(cfg = {}) {
|
|
318
|
-
const base = { fact_types: PAGE_FACT_TYPES };
|
|
342
|
+
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
319
343
|
switch (cfg.pageTriggerType) {
|
|
320
344
|
case "cron":
|
|
321
345
|
return { ...base, refresh_cron: cfg.pageTriggerCron };
|
|
@@ -825,11 +849,20 @@ var HindsightClient = class {
|
|
|
825
849
|
return;
|
|
826
850
|
}
|
|
827
851
|
if (r.status !== 409) created++;
|
|
828
|
-
} else
|
|
852
|
+
} else {
|
|
853
|
+
const sourceDrift = hit.description !== page.source_query;
|
|
854
|
+
const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
|
|
855
|
+
if (!sourceDrift && !triggerDrift) continue;
|
|
856
|
+
const patch = {};
|
|
857
|
+
if (sourceDrift) {
|
|
858
|
+
patch.source_query = page.source_query;
|
|
859
|
+
patch.tags = page.tags;
|
|
860
|
+
}
|
|
861
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
829
862
|
const r = await this.req(
|
|
830
863
|
"PATCH",
|
|
831
864
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
832
|
-
|
|
865
|
+
patch
|
|
833
866
|
);
|
|
834
867
|
if ([404, 405, 501].includes(r.status)) {
|
|
835
868
|
this.knowledgePagesSupported = false;
|
|
@@ -850,10 +883,17 @@ var HindsightClient = class {
|
|
|
850
883
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
851
884
|
}
|
|
852
885
|
/**
|
|
853
|
-
* Active-path capture: register a major feature as a per-initiative page + a
|
|
854
|
-
* New initiative → creates a page under the Initiatives folder
|
|
886
|
+
* Active-path capture: register a major feature as a per-initiative page + a marker memory.
|
|
887
|
+
* New initiative → creates a page under the Initiatives folder.
|
|
855
888
|
* Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
|
|
856
889
|
* enhancement or a mid-work plan change lands on the initiative it belongs to.
|
|
890
|
+
*
|
|
891
|
+
* The marker carries its page id in two places, neither of them a tag (#3641):
|
|
892
|
+
* `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
|
|
893
|
+
* expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
|
|
894
|
+
* three channels a page synthesis actually reads — reflect's search results keep `context` and
|
|
895
|
+
* `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
|
|
896
|
+
* vocabulary that exists to be matched with exact set-ops.
|
|
857
897
|
*/
|
|
858
898
|
async captureInitiative(args) {
|
|
859
899
|
let pageId = args.relatesToPageId;
|
|
@@ -876,20 +916,11 @@ var HindsightClient = class {
|
|
|
876
916
|
const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
|
|
877
917
|
const content = `${verb}: ${args.title}. ${args.summary}`;
|
|
878
918
|
const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
|
|
879
|
-
const tags = [
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
])
|
|
885
|
-
];
|
|
886
|
-
if (Object.keys(args.stamp?.metadata ?? {}).length) {
|
|
887
|
-
await this.retain(content, "initiative marker", markerId, tags, "document", {
|
|
888
|
-
metadata: args.stamp?.metadata
|
|
889
|
-
});
|
|
890
|
-
} else {
|
|
891
|
-
await this.retain(content, "initiative marker", markerId, tags, "document");
|
|
892
|
-
}
|
|
919
|
+
const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
|
|
920
|
+
const context = `initiative marker for [[page:${pageId}]]`;
|
|
921
|
+
await this.retain(content, context, markerId, tags, "document", {
|
|
922
|
+
metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
|
|
923
|
+
});
|
|
893
924
|
return { page_id: pageId };
|
|
894
925
|
}
|
|
895
926
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
@@ -1199,9 +1230,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
1199
1230
|
- 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>").
|
|
1200
1231
|
- hindsight_capture_initiative(title, summary) \u2014 right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing (BEFORE you write any code), call this to record it as a tracked page; then call it AGAIN with relates_to_page_id set to that page whenever the goal, scope, or rationale materially changes mid-work, so the page tracks the current plan and not the opening one. Skip bug fixes, small tweaks, chores, and trivial course-corrections.
|
|
1201
1232
|
- hindsight_ingest_document(title, content) \u2014 save an external document or durable notes/findings you want remembered (not the current conversation \u2014 that is captured automatically at session end).`;
|
|
1202
|
-
var
|
|
1233
|
+
var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the knowledge pages FIRST with hindsight_search_knowledge_pages. No synthesis is injected automatically in this configuration; call hindsight_reflect only when those pages are too shallow and deeper reasoning is needed.\n";
|
|
1203
1234
|
function toolGuide(opts) {
|
|
1204
|
-
return (opts?.reflectOnNewGoals ?
|
|
1235
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
1205
1236
|
}
|
|
1206
1237
|
function buildKnowledgePreamble(pages, opts) {
|
|
1207
1238
|
const body = pages.length ? `Knowledge pages currently in this repository:
|
|
@@ -1285,7 +1316,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1285
1316
|
function hasRustToolchain() {
|
|
1286
1317
|
if (process.platform !== "darwin") return true;
|
|
1287
1318
|
try {
|
|
1288
|
-
execFileSync2("cargo", ["--version"], {
|
|
1319
|
+
execFileSync2("cargo", ["--version"], {
|
|
1320
|
+
stdio: "pipe",
|
|
1321
|
+
timeout: 1e4,
|
|
1322
|
+
windowsHide: true
|
|
1323
|
+
});
|
|
1289
1324
|
return true;
|
|
1290
1325
|
} catch {
|
|
1291
1326
|
return false;
|
|
@@ -1293,7 +1328,11 @@ function hasRustToolchain() {
|
|
|
1293
1328
|
}
|
|
1294
1329
|
function hasUvx() {
|
|
1295
1330
|
try {
|
|
1296
|
-
execFileSync2("uvx", ["--version"], {
|
|
1331
|
+
execFileSync2("uvx", ["--version"], {
|
|
1332
|
+
stdio: "pipe",
|
|
1333
|
+
timeout: 1e4,
|
|
1334
|
+
windowsHide: true
|
|
1335
|
+
});
|
|
1297
1336
|
return true;
|
|
1298
1337
|
} catch {
|
|
1299
1338
|
return false;
|
|
@@ -1325,7 +1364,11 @@ function detectLlm(env = process.env) {
|
|
|
1325
1364
|
}
|
|
1326
1365
|
function onPath(bin) {
|
|
1327
1366
|
try {
|
|
1328
|
-
execFileSync2("which", [bin], {
|
|
1367
|
+
execFileSync2("which", [bin], {
|
|
1368
|
+
stdio: "pipe",
|
|
1369
|
+
timeout: 5e3,
|
|
1370
|
+
windowsHide: true
|
|
1371
|
+
});
|
|
1329
1372
|
return true;
|
|
1330
1373
|
} catch {
|
|
1331
1374
|
return false;
|
|
@@ -1336,7 +1379,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1336
1379
|
const starter = join6(dirname5(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1337
1380
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1338
1381
|
detached: true,
|
|
1339
|
-
stdio: "ignore"
|
|
1382
|
+
stdio: "ignore",
|
|
1383
|
+
windowsHide: true
|
|
1340
1384
|
});
|
|
1341
1385
|
child.on("error", () => {
|
|
1342
1386
|
});
|
|
@@ -1535,7 +1579,11 @@ import { readFileSync as readFileSync6 } from "fs";
|
|
|
1535
1579
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
1536
1580
|
import { resolve } from "path";
|
|
1537
1581
|
function git(repo, ...args) {
|
|
1538
|
-
return execFileSync3("git", ["-C", repo, ...args], {
|
|
1582
|
+
return execFileSync3("git", ["-C", repo, ...args], {
|
|
1583
|
+
encoding: "utf8",
|
|
1584
|
+
maxBuffer: 1 << 28,
|
|
1585
|
+
windowsHide: true
|
|
1586
|
+
});
|
|
1539
1587
|
}
|
|
1540
1588
|
function gitHeadSha(dir) {
|
|
1541
1589
|
try {
|
|
@@ -1746,6 +1794,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
1746
1794
|
cwd: repoDir,
|
|
1747
1795
|
detached: true,
|
|
1748
1796
|
stdio: "ignore",
|
|
1797
|
+
windowsHide: true,
|
|
1749
1798
|
env: plan.env
|
|
1750
1799
|
});
|
|
1751
1800
|
child.on("error", () => {
|
|
@@ -1812,7 +1861,10 @@ async function gitSyncNote(args) {
|
|
|
1812
1861
|
try {
|
|
1813
1862
|
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
1814
1863
|
const n = Number(
|
|
1815
|
-
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
1864
|
+
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
1865
|
+
encoding: "utf8",
|
|
1866
|
+
windowsHide: true
|
|
1867
|
+
}).trim()
|
|
1816
1868
|
);
|
|
1817
1869
|
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
|
|
1818
1870
|
} catch {
|
package/dist/devin-stop-hook.js
CHANGED
|
@@ -33,14 +33,36 @@ function getProjectRootFromGit(directory) {
|
|
|
33
33
|
const commonDir = execFileSync(
|
|
34
34
|
"git",
|
|
35
35
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
36
|
-
{
|
|
36
|
+
{
|
|
37
|
+
cwd: directory,
|
|
38
|
+
encoding: "utf-8",
|
|
39
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
40
|
+
timeout: 1e3,
|
|
41
|
+
windowsHide: true
|
|
42
|
+
}
|
|
37
43
|
).trim();
|
|
38
44
|
if (!commonDir) return null;
|
|
39
|
-
|
|
45
|
+
if (basename(commonDir) === ".git") return dirname(commonDir);
|
|
46
|
+
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
47
|
+
return dirname(commonDir);
|
|
48
|
+
}
|
|
49
|
+
return commonDir;
|
|
40
50
|
} catch {
|
|
41
51
|
return null;
|
|
42
52
|
}
|
|
43
53
|
}
|
|
54
|
+
function isBareRepository(commonDir) {
|
|
55
|
+
try {
|
|
56
|
+
return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
|
|
57
|
+
encoding: "utf-8",
|
|
58
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
59
|
+
timeout: 1e3,
|
|
60
|
+
env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
|
|
61
|
+
}).trim() === "true";
|
|
62
|
+
} catch {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
44
66
|
function projectNameOf(directory, sessionRoot) {
|
|
45
67
|
return gitProjectName(directory, true, sessionRoot);
|
|
46
68
|
}
|
|
@@ -292,7 +314,7 @@ var PAGE_TAXONOMY = [
|
|
|
292
314
|
},
|
|
293
315
|
{
|
|
294
316
|
name: "Initiatives and enhancements",
|
|
295
|
-
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory carries a
|
|
317
|
+
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
|
|
296
318
|
tags: ["knowledge:feature-work"]
|
|
297
319
|
}
|
|
298
320
|
];
|
|
@@ -301,9 +323,10 @@ function pagesFor(project) {
|
|
|
301
323
|
return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
|
|
302
324
|
}
|
|
303
325
|
var PAGE_MAX_TOKENS = 4096;
|
|
326
|
+
var PAGE_TAGS_MATCH = "all";
|
|
304
327
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
305
328
|
function buildPageTrigger(cfg = {}) {
|
|
306
|
-
const base = { fact_types: PAGE_FACT_TYPES };
|
|
329
|
+
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
307
330
|
switch (cfg.pageTriggerType) {
|
|
308
331
|
case "cron":
|
|
309
332
|
return { ...base, refresh_cron: cfg.pageTriggerCron };
|
|
@@ -813,11 +836,20 @@ var HindsightClient = class {
|
|
|
813
836
|
return;
|
|
814
837
|
}
|
|
815
838
|
if (r.status !== 409) created++;
|
|
816
|
-
} else
|
|
839
|
+
} else {
|
|
840
|
+
const sourceDrift = hit.description !== page.source_query;
|
|
841
|
+
const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
|
|
842
|
+
if (!sourceDrift && !triggerDrift) continue;
|
|
843
|
+
const patch = {};
|
|
844
|
+
if (sourceDrift) {
|
|
845
|
+
patch.source_query = page.source_query;
|
|
846
|
+
patch.tags = page.tags;
|
|
847
|
+
}
|
|
848
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
817
849
|
const r = await this.req(
|
|
818
850
|
"PATCH",
|
|
819
851
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
820
|
-
|
|
852
|
+
patch
|
|
821
853
|
);
|
|
822
854
|
if ([404, 405, 501].includes(r.status)) {
|
|
823
855
|
this.knowledgePagesSupported = false;
|
|
@@ -838,10 +870,17 @@ var HindsightClient = class {
|
|
|
838
870
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
839
871
|
}
|
|
840
872
|
/**
|
|
841
|
-
* Active-path capture: register a major feature as a per-initiative page + a
|
|
842
|
-
* New initiative → creates a page under the Initiatives folder
|
|
873
|
+
* Active-path capture: register a major feature as a per-initiative page + a marker memory.
|
|
874
|
+
* New initiative → creates a page under the Initiatives folder.
|
|
843
875
|
* Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
|
|
844
876
|
* enhancement or a mid-work plan change lands on the initiative it belongs to.
|
|
877
|
+
*
|
|
878
|
+
* The marker carries its page id in two places, neither of them a tag (#3641):
|
|
879
|
+
* `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
|
|
880
|
+
* expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
|
|
881
|
+
* three channels a page synthesis actually reads — reflect's search results keep `context` and
|
|
882
|
+
* `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
|
|
883
|
+
* vocabulary that exists to be matched with exact set-ops.
|
|
845
884
|
*/
|
|
846
885
|
async captureInitiative(args) {
|
|
847
886
|
let pageId = args.relatesToPageId;
|
|
@@ -864,20 +903,11 @@ var HindsightClient = class {
|
|
|
864
903
|
const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
|
|
865
904
|
const content = `${verb}: ${args.title}. ${args.summary}`;
|
|
866
905
|
const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
|
|
867
|
-
const tags = [
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
])
|
|
873
|
-
];
|
|
874
|
-
if (Object.keys(args.stamp?.metadata ?? {}).length) {
|
|
875
|
-
await this.retain(content, "initiative marker", markerId, tags, "document", {
|
|
876
|
-
metadata: args.stamp?.metadata
|
|
877
|
-
});
|
|
878
|
-
} else {
|
|
879
|
-
await this.retain(content, "initiative marker", markerId, tags, "document");
|
|
880
|
-
}
|
|
906
|
+
const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
|
|
907
|
+
const context = `initiative marker for [[page:${pageId}]]`;
|
|
908
|
+
await this.retain(content, context, markerId, tags, "document", {
|
|
909
|
+
metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
|
|
910
|
+
});
|
|
881
911
|
return { page_id: pageId };
|
|
882
912
|
}
|
|
883
913
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
@@ -1386,7 +1416,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1386
1416
|
function hasRustToolchain() {
|
|
1387
1417
|
if (process.platform !== "darwin") return true;
|
|
1388
1418
|
try {
|
|
1389
|
-
execFileSync2("cargo", ["--version"], {
|
|
1419
|
+
execFileSync2("cargo", ["--version"], {
|
|
1420
|
+
stdio: "pipe",
|
|
1421
|
+
timeout: 1e4,
|
|
1422
|
+
windowsHide: true
|
|
1423
|
+
});
|
|
1390
1424
|
return true;
|
|
1391
1425
|
} catch {
|
|
1392
1426
|
return false;
|
|
@@ -1394,7 +1428,11 @@ function hasRustToolchain() {
|
|
|
1394
1428
|
}
|
|
1395
1429
|
function hasUvx() {
|
|
1396
1430
|
try {
|
|
1397
|
-
execFileSync2("uvx", ["--version"], {
|
|
1431
|
+
execFileSync2("uvx", ["--version"], {
|
|
1432
|
+
stdio: "pipe",
|
|
1433
|
+
timeout: 1e4,
|
|
1434
|
+
windowsHide: true
|
|
1435
|
+
});
|
|
1398
1436
|
return true;
|
|
1399
1437
|
} catch {
|
|
1400
1438
|
return false;
|
|
@@ -1426,7 +1464,11 @@ function detectLlm(env = process.env) {
|
|
|
1426
1464
|
}
|
|
1427
1465
|
function onPath(bin) {
|
|
1428
1466
|
try {
|
|
1429
|
-
execFileSync2("which", [bin], {
|
|
1467
|
+
execFileSync2("which", [bin], {
|
|
1468
|
+
stdio: "pipe",
|
|
1469
|
+
timeout: 5e3,
|
|
1470
|
+
windowsHide: true
|
|
1471
|
+
});
|
|
1430
1472
|
return true;
|
|
1431
1473
|
} catch {
|
|
1432
1474
|
return false;
|
|
@@ -1437,7 +1479,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1437
1479
|
const starter = join6(dirname5(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1438
1480
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1439
1481
|
detached: true,
|
|
1440
|
-
stdio: "ignore"
|
|
1482
|
+
stdio: "ignore",
|
|
1483
|
+
windowsHide: true
|
|
1441
1484
|
});
|
|
1442
1485
|
child.on("error", () => {
|
|
1443
1486
|
});
|
package/dist/dsh.js
CHANGED
|
@@ -34,7 +34,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
34
34
|
],
|
|
35
35
|
{
|
|
36
36
|
detached: true,
|
|
37
|
-
stdio: "ignore"
|
|
37
|
+
stdio: "ignore",
|
|
38
|
+
windowsHide: true
|
|
38
39
|
}
|
|
39
40
|
);
|
|
40
41
|
child.on("error", () => {
|
|
@@ -74,14 +75,36 @@ function getProjectRootFromGit(directory) {
|
|
|
74
75
|
const commonDir = execFileSync(
|
|
75
76
|
"git",
|
|
76
77
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
77
|
-
{
|
|
78
|
+
{
|
|
79
|
+
cwd: directory,
|
|
80
|
+
encoding: "utf-8",
|
|
81
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
82
|
+
timeout: 1e3,
|
|
83
|
+
windowsHide: true
|
|
84
|
+
}
|
|
78
85
|
).trim();
|
|
79
86
|
if (!commonDir) return null;
|
|
80
|
-
|
|
87
|
+
if (basename(commonDir) === ".git") return dirname2(commonDir);
|
|
88
|
+
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
89
|
+
return dirname2(commonDir);
|
|
90
|
+
}
|
|
91
|
+
return commonDir;
|
|
81
92
|
} catch {
|
|
82
93
|
return null;
|
|
83
94
|
}
|
|
84
95
|
}
|
|
96
|
+
function isBareRepository(commonDir) {
|
|
97
|
+
try {
|
|
98
|
+
return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
|
|
99
|
+
encoding: "utf-8",
|
|
100
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
101
|
+
timeout: 1e3,
|
|
102
|
+
env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
|
|
103
|
+
}).trim() === "true";
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
85
108
|
function projectNameOf(directory, sessionRoot) {
|
|
86
109
|
return gitProjectName(directory, true, sessionRoot);
|
|
87
110
|
}
|
|
@@ -322,7 +345,7 @@ var PAGE_TAXONOMY = [
|
|
|
322
345
|
},
|
|
323
346
|
{
|
|
324
347
|
name: "Initiatives and enhancements",
|
|
325
|
-
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory carries a
|
|
348
|
+
source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
|
|
326
349
|
tags: ["knowledge:feature-work"]
|
|
327
350
|
}
|
|
328
351
|
];
|
|
@@ -331,9 +354,10 @@ function pagesFor(project) {
|
|
|
331
354
|
return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
|
|
332
355
|
}
|
|
333
356
|
var PAGE_MAX_TOKENS = 4096;
|
|
357
|
+
var PAGE_TAGS_MATCH = "all";
|
|
334
358
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
335
359
|
function buildPageTrigger(cfg = {}) {
|
|
336
|
-
const base = { fact_types: PAGE_FACT_TYPES };
|
|
360
|
+
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
337
361
|
switch (cfg.pageTriggerType) {
|
|
338
362
|
case "cron":
|
|
339
363
|
return { ...base, refresh_cron: cfg.pageTriggerCron };
|
|
@@ -843,11 +867,20 @@ var HindsightClient = class {
|
|
|
843
867
|
return;
|
|
844
868
|
}
|
|
845
869
|
if (r.status !== 409) created++;
|
|
846
|
-
} else
|
|
870
|
+
} else {
|
|
871
|
+
const sourceDrift = hit.description !== page.source_query;
|
|
872
|
+
const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
|
|
873
|
+
if (!sourceDrift && !triggerDrift) continue;
|
|
874
|
+
const patch = {};
|
|
875
|
+
if (sourceDrift) {
|
|
876
|
+
patch.source_query = page.source_query;
|
|
877
|
+
patch.tags = page.tags;
|
|
878
|
+
}
|
|
879
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
847
880
|
const r = await this.req(
|
|
848
881
|
"PATCH",
|
|
849
882
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
850
|
-
|
|
883
|
+
patch
|
|
851
884
|
);
|
|
852
885
|
if ([404, 405, 501].includes(r.status)) {
|
|
853
886
|
this.knowledgePagesSupported = false;
|
|
@@ -868,10 +901,17 @@ var HindsightClient = class {
|
|
|
868
901
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
869
902
|
}
|
|
870
903
|
/**
|
|
871
|
-
* Active-path capture: register a major feature as a per-initiative page + a
|
|
872
|
-
* New initiative → creates a page under the Initiatives folder
|
|
904
|
+
* Active-path capture: register a major feature as a per-initiative page + a marker memory.
|
|
905
|
+
* New initiative → creates a page under the Initiatives folder.
|
|
873
906
|
* Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
|
|
874
907
|
* enhancement or a mid-work plan change lands on the initiative it belongs to.
|
|
908
|
+
*
|
|
909
|
+
* The marker carries its page id in two places, neither of them a tag (#3641):
|
|
910
|
+
* `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
|
|
911
|
+
* expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
|
|
912
|
+
* three channels a page synthesis actually reads — reflect's search results keep `context` and
|
|
913
|
+
* `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
|
|
914
|
+
* vocabulary that exists to be matched with exact set-ops.
|
|
875
915
|
*/
|
|
876
916
|
async captureInitiative(args) {
|
|
877
917
|
let pageId = args.relatesToPageId;
|
|
@@ -894,20 +934,11 @@ var HindsightClient = class {
|
|
|
894
934
|
const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
|
|
895
935
|
const content = `${verb}: ${args.title}. ${args.summary}`;
|
|
896
936
|
const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
|
|
897
|
-
const tags = [
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
])
|
|
903
|
-
];
|
|
904
|
-
if (Object.keys(args.stamp?.metadata ?? {}).length) {
|
|
905
|
-
await this.retain(content, "initiative marker", markerId, tags, "document", {
|
|
906
|
-
metadata: args.stamp?.metadata
|
|
907
|
-
});
|
|
908
|
-
} else {
|
|
909
|
-
await this.retain(content, "initiative marker", markerId, tags, "document");
|
|
910
|
-
}
|
|
937
|
+
const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
|
|
938
|
+
const context = `initiative marker for [[page:${pageId}]]`;
|
|
939
|
+
await this.retain(content, context, markerId, tags, "document", {
|
|
940
|
+
metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
|
|
941
|
+
});
|
|
911
942
|
return { page_id: pageId };
|
|
912
943
|
}
|
|
913
944
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
@@ -1226,7 +1257,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1226
1257
|
function hasRustToolchain() {
|
|
1227
1258
|
if (process.platform !== "darwin") return true;
|
|
1228
1259
|
try {
|
|
1229
|
-
execFileSync2("cargo", ["--version"], {
|
|
1260
|
+
execFileSync2("cargo", ["--version"], {
|
|
1261
|
+
stdio: "pipe",
|
|
1262
|
+
timeout: 1e4,
|
|
1263
|
+
windowsHide: true
|
|
1264
|
+
});
|
|
1230
1265
|
return true;
|
|
1231
1266
|
} catch {
|
|
1232
1267
|
return false;
|
|
@@ -1234,7 +1269,11 @@ function hasRustToolchain() {
|
|
|
1234
1269
|
}
|
|
1235
1270
|
function hasUvx() {
|
|
1236
1271
|
try {
|
|
1237
|
-
execFileSync2("uvx", ["--version"], {
|
|
1272
|
+
execFileSync2("uvx", ["--version"], {
|
|
1273
|
+
stdio: "pipe",
|
|
1274
|
+
timeout: 1e4,
|
|
1275
|
+
windowsHide: true
|
|
1276
|
+
});
|
|
1238
1277
|
return true;
|
|
1239
1278
|
} catch {
|
|
1240
1279
|
return false;
|
|
@@ -1266,7 +1305,11 @@ function detectLlm(env = process.env) {
|
|
|
1266
1305
|
}
|
|
1267
1306
|
function onPath(bin) {
|
|
1268
1307
|
try {
|
|
1269
|
-
execFileSync2("which", [bin], {
|
|
1308
|
+
execFileSync2("which", [bin], {
|
|
1309
|
+
stdio: "pipe",
|
|
1310
|
+
timeout: 5e3,
|
|
1311
|
+
windowsHide: true
|
|
1312
|
+
});
|
|
1270
1313
|
return true;
|
|
1271
1314
|
} catch {
|
|
1272
1315
|
return false;
|
|
@@ -1277,7 +1320,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1277
1320
|
const starter = join5(dirname4(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1278
1321
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1279
1322
|
detached: true,
|
|
1280
|
-
stdio: "ignore"
|
|
1323
|
+
stdio: "ignore",
|
|
1324
|
+
windowsHide: true
|
|
1281
1325
|
});
|
|
1282
1326
|
child.on("error", () => {
|
|
1283
1327
|
});
|
|
@@ -15852,7 +15896,11 @@ import { execFileSync as execFileSync4 } from "child_process";
|
|
|
15852
15896
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
15853
15897
|
import { resolve } from "path";
|
|
15854
15898
|
function git(repo, ...args) {
|
|
15855
|
-
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15899
|
+
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15900
|
+
encoding: "utf8",
|
|
15901
|
+
maxBuffer: 1 << 28,
|
|
15902
|
+
windowsHide: true
|
|
15903
|
+
});
|
|
15856
15904
|
}
|
|
15857
15905
|
function repoNameOf(repo) {
|
|
15858
15906
|
return projectNameOf(resolve(repo));
|
|
@@ -15900,9 +15948,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
15900
15948
|
- 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>").
|
|
15901
15949
|
- hindsight_capture_initiative(title, summary) \u2014 right after the user approves a plan or finishes brainstorming a new feature/capability and you are about to start implementing (BEFORE you write any code), call this to record it as a tracked page; then call it AGAIN with relates_to_page_id set to that page whenever the goal, scope, or rationale materially changes mid-work, so the page tracks the current plan and not the opening one. Skip bug fixes, small tweaks, chores, and trivial course-corrections.
|
|
15902
15950
|
- hindsight_ingest_document(title, content) \u2014 save an external document or durable notes/findings you want remembered (not the current conversation \u2014 that is captured automatically at session end).`;
|
|
15903
|
-
var
|
|
15951
|
+
var PAGES_FIRST_ON_GOALS = "- The user just set a NEW task or goal \u2192 search the knowledge pages FIRST with hindsight_search_knowledge_pages. No synthesis is injected automatically in this configuration; call hindsight_reflect only when those pages are too shallow and deeper reasoning is needed.\n";
|
|
15904
15952
|
function toolGuide(opts) {
|
|
15905
|
-
return (opts?.reflectOnNewGoals ?
|
|
15953
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
15906
15954
|
}
|
|
15907
15955
|
function buildKnowledgePreamble(pages, opts) {
|
|
15908
15956
|
const body = pages.length ? `Knowledge pages currently in this repository:
|
|
@@ -16107,6 +16155,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
16107
16155
|
cwd: repoDir,
|
|
16108
16156
|
detached: true,
|
|
16109
16157
|
stdio: "ignore",
|
|
16158
|
+
windowsHide: true,
|
|
16110
16159
|
env: plan.env
|
|
16111
16160
|
});
|
|
16112
16161
|
child.on("error", () => {
|
|
@@ -16123,7 +16172,8 @@ var DEEPEN_DIFF_TARGET = 300;
|
|
|
16123
16172
|
function commitCount(repoDir) {
|
|
16124
16173
|
try {
|
|
16125
16174
|
const out = execFileSync4("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
|
|
16126
|
-
encoding: "utf8"
|
|
16175
|
+
encoding: "utf8",
|
|
16176
|
+
windowsHide: true
|
|
16127
16177
|
});
|
|
16128
16178
|
return Number(out.trim()) || 0;
|
|
16129
16179
|
} catch {
|
|
@@ -16632,7 +16682,10 @@ async function gitSyncNote(args) {
|
|
|
16632
16682
|
try {
|
|
16633
16683
|
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
16634
16684
|
const n = Number(
|
|
16635
|
-
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
16685
|
+
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
16686
|
+
encoding: "utf8",
|
|
16687
|
+
windowsHide: true
|
|
16688
|
+
}).trim()
|
|
16636
16689
|
);
|
|
16637
16690
|
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
|
|
16638
16691
|
} catch {
|