@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
package/dist/grok-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
|
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
45
67
|
function nearestExistingDir(directory) {
|
|
46
68
|
let current2 = directory;
|
|
@@ -157,7 +179,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
157
179
|
],
|
|
158
180
|
{
|
|
159
181
|
detached: true,
|
|
160
|
-
stdio: "ignore"
|
|
182
|
+
stdio: "ignore",
|
|
183
|
+
windowsHide: true
|
|
161
184
|
}
|
|
162
185
|
);
|
|
163
186
|
child.on("error", () => {
|
|
@@ -315,7 +338,7 @@ var PAGE_TAXONOMY = [
|
|
|
315
338
|
},
|
|
316
339
|
{
|
|
317
340
|
name: "Initiatives and enhancements",
|
|
318
|
-
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
|
|
341
|
+
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.",
|
|
319
342
|
tags: ["knowledge:feature-work"]
|
|
320
343
|
}
|
|
321
344
|
];
|
|
@@ -324,9 +347,10 @@ function pagesFor(project) {
|
|
|
324
347
|
return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
|
|
325
348
|
}
|
|
326
349
|
var PAGE_MAX_TOKENS = 4096;
|
|
350
|
+
var PAGE_TAGS_MATCH = "all";
|
|
327
351
|
var PAGE_FACT_TYPES = ["world", "experience", "observation"];
|
|
328
352
|
function buildPageTrigger(cfg = {}) {
|
|
329
|
-
const base = { fact_types: PAGE_FACT_TYPES };
|
|
353
|
+
const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
|
|
330
354
|
switch (cfg.pageTriggerType) {
|
|
331
355
|
case "cron":
|
|
332
356
|
return { ...base, refresh_cron: cfg.pageTriggerCron };
|
|
@@ -836,11 +860,20 @@ var HindsightClient = class {
|
|
|
836
860
|
return;
|
|
837
861
|
}
|
|
838
862
|
if (r.status !== 409) created++;
|
|
839
|
-
} else
|
|
863
|
+
} else {
|
|
864
|
+
const sourceDrift = hit.description !== page.source_query;
|
|
865
|
+
const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
|
|
866
|
+
if (!sourceDrift && !triggerDrift) continue;
|
|
867
|
+
const patch = {};
|
|
868
|
+
if (sourceDrift) {
|
|
869
|
+
patch.source_query = page.source_query;
|
|
870
|
+
patch.tags = page.tags;
|
|
871
|
+
}
|
|
872
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
840
873
|
const r = await this.req(
|
|
841
874
|
"PATCH",
|
|
842
875
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
843
|
-
|
|
876
|
+
patch
|
|
844
877
|
);
|
|
845
878
|
if ([404, 405, 501].includes(r.status)) {
|
|
846
879
|
this.knowledgePagesSupported = false;
|
|
@@ -861,10 +894,17 @@ var HindsightClient = class {
|
|
|
861
894
|
return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
|
|
862
895
|
}
|
|
863
896
|
/**
|
|
864
|
-
* Active-path capture: register a major feature as a per-initiative page + a
|
|
865
|
-
* New initiative → creates a page under the Initiatives folder
|
|
897
|
+
* Active-path capture: register a major feature as a per-initiative page + a marker memory.
|
|
898
|
+
* New initiative → creates a page under the Initiatives folder.
|
|
866
899
|
* Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
|
|
867
900
|
* enhancement or a mid-work plan change lands on the initiative it belongs to.
|
|
901
|
+
*
|
|
902
|
+
* The marker carries its page id in two places, neither of them a tag (#3641):
|
|
903
|
+
* `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
|
|
904
|
+
* expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
|
|
905
|
+
* three channels a page synthesis actually reads — reflect's search results keep `context` and
|
|
906
|
+
* `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
|
|
907
|
+
* vocabulary that exists to be matched with exact set-ops.
|
|
868
908
|
*/
|
|
869
909
|
async captureInitiative(args) {
|
|
870
910
|
let pageId = args.relatesToPageId;
|
|
@@ -887,20 +927,11 @@ var HindsightClient = class {
|
|
|
887
927
|
const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
|
|
888
928
|
const content = `${verb}: ${args.title}. ${args.summary}`;
|
|
889
929
|
const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
|
|
890
|
-
const tags = [
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
])
|
|
896
|
-
];
|
|
897
|
-
if (Object.keys(args.stamp?.metadata ?? {}).length) {
|
|
898
|
-
await this.retain(content, "initiative marker", markerId, tags, "document", {
|
|
899
|
-
metadata: args.stamp?.metadata
|
|
900
|
-
});
|
|
901
|
-
} else {
|
|
902
|
-
await this.retain(content, "initiative marker", markerId, tags, "document");
|
|
903
|
-
}
|
|
930
|
+
const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
|
|
931
|
+
const context = `initiative marker for [[page:${pageId}]]`;
|
|
932
|
+
await this.retain(content, context, markerId, tags, "document", {
|
|
933
|
+
metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
|
|
934
|
+
});
|
|
904
935
|
return { page_id: pageId };
|
|
905
936
|
}
|
|
906
937
|
/** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
|
|
@@ -1239,9 +1270,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
1239
1270
|
- 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>").
|
|
1240
1271
|
- 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.
|
|
1241
1272
|
- 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).`;
|
|
1242
|
-
var
|
|
1273
|
+
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";
|
|
1243
1274
|
function toolGuide(opts) {
|
|
1244
|
-
return (opts?.reflectOnNewGoals ?
|
|
1275
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
1245
1276
|
}
|
|
1246
1277
|
function buildRosterRefresh(pages, opts) {
|
|
1247
1278
|
const rosterBlock = pages.length ? `Current Hindsight knowledge pages (may have 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
|
}
|
|
@@ -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/grok-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/hindsight-seed.js
CHANGED
|
@@ -27,7 +27,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
27
27
|
],
|
|
28
28
|
{
|
|
29
29
|
detached: true,
|
|
30
|
-
stdio: "ignore"
|
|
30
|
+
stdio: "ignore",
|
|
31
|
+
windowsHide: true
|
|
31
32
|
}
|
|
32
33
|
);
|
|
33
34
|
child.on("error", () => {
|
|
@@ -77,14 +78,36 @@ function getProjectRootFromGit(directory) {
|
|
|
77
78
|
const commonDir = execFileSync(
|
|
78
79
|
"git",
|
|
79
80
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
80
|
-
{
|
|
81
|
+
{
|
|
82
|
+
cwd: directory,
|
|
83
|
+
encoding: "utf-8",
|
|
84
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
85
|
+
timeout: 1e3,
|
|
86
|
+
windowsHide: true
|
|
87
|
+
}
|
|
81
88
|
).trim();
|
|
82
89
|
if (!commonDir) return null;
|
|
83
|
-
|
|
90
|
+
if (basename(commonDir) === ".git") return dirname2(commonDir);
|
|
91
|
+
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
92
|
+
return dirname2(commonDir);
|
|
93
|
+
}
|
|
94
|
+
return commonDir;
|
|
84
95
|
} catch {
|
|
85
96
|
return null;
|
|
86
97
|
}
|
|
87
98
|
}
|
|
99
|
+
function isBareRepository(commonDir) {
|
|
100
|
+
try {
|
|
101
|
+
return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
|
|
102
|
+
encoding: "utf-8",
|
|
103
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
104
|
+
timeout: 1e3,
|
|
105
|
+
env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
|
|
106
|
+
}).trim() === "true";
|
|
107
|
+
} catch {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
88
111
|
var PROJECT_ROOT_ENV = ["CLAUDE_PROJECT_DIR"];
|
|
89
112
|
function nearestExistingDir(directory) {
|
|
90
113
|
let current2 = directory;
|