@vectorize-io/hindsight-coding-agents 0.4.1 → 0.4.3
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 +86 -5
- package/dist/antigravity-hook.js +35 -10
- package/dist/antigravity-statusline.js +24 -2
- package/dist/antigravity-stop-hook.js +48 -11
- package/dist/claude-hook.js +35 -10
- package/dist/claude-sessionstart-hook.js +62 -16
- package/dist/claude-stop-hook.js +48 -11
- package/dist/cline.js +64 -17
- package/dist/codex-hook.js +35 -10
- package/dist/codex-sessionstart-hook.js +62 -16
- package/dist/codex-stop-hook.js +48 -11
- package/dist/copilot-hook.js +35 -10
- package/dist/copilot-sessionstart-hook.js +62 -16
- package/dist/copilot-stop-hook.js +48 -11
- package/dist/cursor-hook.js +35 -10
- package/dist/cursor-sessionstart-hook.js +62 -16
- package/dist/cursor-stop-hook.js +48 -11
- package/dist/daemon-start.js +15 -3
- package/dist/deepen.js +37 -9
- package/dist/devin-hook.js +35 -10
- package/dist/devin-sessionstart-hook.js +62 -16
- package/dist/devin-stop-hook.js +48 -11
- package/dist/dsh.js +64 -17
- package/dist/grok-hook.js +35 -10
- package/dist/grok-sessionstart-hook.js +62 -16
- package/dist/grok-stop-hook.js +48 -11
- package/dist/hindsight-seed.js +26 -3
- package/dist/index.js +64 -17
- package/dist/installer.js +35 -14
- package/dist/kilo.js +64 -17
- package/dist/mcp-server.js +38 -9
- package/dist/prime-agent.js +64 -17
- package/dist/status.js +38 -9
- 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", () => {
|
|
@@ -826,14 +849,16 @@ var HindsightClient = class {
|
|
|
826
849
|
return;
|
|
827
850
|
}
|
|
828
851
|
if (r.status !== 409) created++;
|
|
829
|
-
} else
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
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) {
|
|
834
858
|
patch.source_query = page.source_query;
|
|
835
859
|
patch.tags = page.tags;
|
|
836
860
|
}
|
|
861
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
837
862
|
const r = await this.req(
|
|
838
863
|
"PATCH",
|
|
839
864
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1205,9 +1230,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
1205
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>").
|
|
1206
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.
|
|
1207
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).`;
|
|
1208
|
-
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";
|
|
1209
1234
|
function toolGuide(opts) {
|
|
1210
|
-
return (opts?.reflectOnNewGoals ?
|
|
1235
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
1211
1236
|
}
|
|
1212
1237
|
function buildKnowledgePreamble(pages, opts) {
|
|
1213
1238
|
const body = pages.length ? `Knowledge pages currently in this repository:
|
|
@@ -1291,7 +1316,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1291
1316
|
function hasRustToolchain() {
|
|
1292
1317
|
if (process.platform !== "darwin") return true;
|
|
1293
1318
|
try {
|
|
1294
|
-
execFileSync2("cargo", ["--version"], {
|
|
1319
|
+
execFileSync2("cargo", ["--version"], {
|
|
1320
|
+
stdio: "pipe",
|
|
1321
|
+
timeout: 1e4,
|
|
1322
|
+
windowsHide: true
|
|
1323
|
+
});
|
|
1295
1324
|
return true;
|
|
1296
1325
|
} catch {
|
|
1297
1326
|
return false;
|
|
@@ -1299,7 +1328,11 @@ function hasRustToolchain() {
|
|
|
1299
1328
|
}
|
|
1300
1329
|
function hasUvx() {
|
|
1301
1330
|
try {
|
|
1302
|
-
execFileSync2("uvx", ["--version"], {
|
|
1331
|
+
execFileSync2("uvx", ["--version"], {
|
|
1332
|
+
stdio: "pipe",
|
|
1333
|
+
timeout: 1e4,
|
|
1334
|
+
windowsHide: true
|
|
1335
|
+
});
|
|
1303
1336
|
return true;
|
|
1304
1337
|
} catch {
|
|
1305
1338
|
return false;
|
|
@@ -1331,7 +1364,11 @@ function detectLlm(env = process.env) {
|
|
|
1331
1364
|
}
|
|
1332
1365
|
function onPath(bin) {
|
|
1333
1366
|
try {
|
|
1334
|
-
execFileSync2("which", [bin], {
|
|
1367
|
+
execFileSync2("which", [bin], {
|
|
1368
|
+
stdio: "pipe",
|
|
1369
|
+
timeout: 5e3,
|
|
1370
|
+
windowsHide: true
|
|
1371
|
+
});
|
|
1335
1372
|
return true;
|
|
1336
1373
|
} catch {
|
|
1337
1374
|
return false;
|
|
@@ -1342,7 +1379,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1342
1379
|
const starter = join6(dirname5(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1343
1380
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1344
1381
|
detached: true,
|
|
1345
|
-
stdio: "ignore"
|
|
1382
|
+
stdio: "ignore",
|
|
1383
|
+
windowsHide: true
|
|
1346
1384
|
});
|
|
1347
1385
|
child.on("error", () => {
|
|
1348
1386
|
});
|
|
@@ -1541,7 +1579,11 @@ import { readFileSync as readFileSync6 } from "fs";
|
|
|
1541
1579
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
1542
1580
|
import { resolve } from "path";
|
|
1543
1581
|
function git(repo, ...args) {
|
|
1544
|
-
return execFileSync3("git", ["-C", repo, ...args], {
|
|
1582
|
+
return execFileSync3("git", ["-C", repo, ...args], {
|
|
1583
|
+
encoding: "utf8",
|
|
1584
|
+
maxBuffer: 1 << 28,
|
|
1585
|
+
windowsHide: true
|
|
1586
|
+
});
|
|
1545
1587
|
}
|
|
1546
1588
|
function gitHeadSha(dir) {
|
|
1547
1589
|
try {
|
|
@@ -1752,6 +1794,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
1752
1794
|
cwd: repoDir,
|
|
1753
1795
|
detached: true,
|
|
1754
1796
|
stdio: "ignore",
|
|
1797
|
+
windowsHide: true,
|
|
1755
1798
|
env: plan.env
|
|
1756
1799
|
});
|
|
1757
1800
|
child.on("error", () => {
|
|
@@ -1818,7 +1861,10 @@ async function gitSyncNote(args) {
|
|
|
1818
1861
|
try {
|
|
1819
1862
|
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
1820
1863
|
const n = Number(
|
|
1821
|
-
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()
|
|
1822
1868
|
);
|
|
1823
1869
|
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
|
|
1824
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
|
}
|
|
@@ -814,14 +836,16 @@ var HindsightClient = class {
|
|
|
814
836
|
return;
|
|
815
837
|
}
|
|
816
838
|
if (r.status !== 409) created++;
|
|
817
|
-
} else
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
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) {
|
|
822
845
|
patch.source_query = page.source_query;
|
|
823
846
|
patch.tags = page.tags;
|
|
824
847
|
}
|
|
848
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
825
849
|
const r = await this.req(
|
|
826
850
|
"PATCH",
|
|
827
851
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1392,7 +1416,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1392
1416
|
function hasRustToolchain() {
|
|
1393
1417
|
if (process.platform !== "darwin") return true;
|
|
1394
1418
|
try {
|
|
1395
|
-
execFileSync2("cargo", ["--version"], {
|
|
1419
|
+
execFileSync2("cargo", ["--version"], {
|
|
1420
|
+
stdio: "pipe",
|
|
1421
|
+
timeout: 1e4,
|
|
1422
|
+
windowsHide: true
|
|
1423
|
+
});
|
|
1396
1424
|
return true;
|
|
1397
1425
|
} catch {
|
|
1398
1426
|
return false;
|
|
@@ -1400,7 +1428,11 @@ function hasRustToolchain() {
|
|
|
1400
1428
|
}
|
|
1401
1429
|
function hasUvx() {
|
|
1402
1430
|
try {
|
|
1403
|
-
execFileSync2("uvx", ["--version"], {
|
|
1431
|
+
execFileSync2("uvx", ["--version"], {
|
|
1432
|
+
stdio: "pipe",
|
|
1433
|
+
timeout: 1e4,
|
|
1434
|
+
windowsHide: true
|
|
1435
|
+
});
|
|
1404
1436
|
return true;
|
|
1405
1437
|
} catch {
|
|
1406
1438
|
return false;
|
|
@@ -1432,7 +1464,11 @@ function detectLlm(env = process.env) {
|
|
|
1432
1464
|
}
|
|
1433
1465
|
function onPath(bin) {
|
|
1434
1466
|
try {
|
|
1435
|
-
execFileSync2("which", [bin], {
|
|
1467
|
+
execFileSync2("which", [bin], {
|
|
1468
|
+
stdio: "pipe",
|
|
1469
|
+
timeout: 5e3,
|
|
1470
|
+
windowsHide: true
|
|
1471
|
+
});
|
|
1436
1472
|
return true;
|
|
1437
1473
|
} catch {
|
|
1438
1474
|
return false;
|
|
@@ -1443,7 +1479,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1443
1479
|
const starter = join6(dirname5(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1444
1480
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1445
1481
|
detached: true,
|
|
1446
|
-
stdio: "ignore"
|
|
1482
|
+
stdio: "ignore",
|
|
1483
|
+
windowsHide: true
|
|
1447
1484
|
});
|
|
1448
1485
|
child.on("error", () => {
|
|
1449
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
|
}
|
|
@@ -844,14 +867,16 @@ var HindsightClient = class {
|
|
|
844
867
|
return;
|
|
845
868
|
}
|
|
846
869
|
if (r.status !== 409) created++;
|
|
847
|
-
} else
|
|
848
|
-
const
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
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) {
|
|
852
876
|
patch.source_query = page.source_query;
|
|
853
877
|
patch.tags = page.tags;
|
|
854
878
|
}
|
|
879
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
855
880
|
const r = await this.req(
|
|
856
881
|
"PATCH",
|
|
857
882
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1232,7 +1257,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1232
1257
|
function hasRustToolchain() {
|
|
1233
1258
|
if (process.platform !== "darwin") return true;
|
|
1234
1259
|
try {
|
|
1235
|
-
execFileSync2("cargo", ["--version"], {
|
|
1260
|
+
execFileSync2("cargo", ["--version"], {
|
|
1261
|
+
stdio: "pipe",
|
|
1262
|
+
timeout: 1e4,
|
|
1263
|
+
windowsHide: true
|
|
1264
|
+
});
|
|
1236
1265
|
return true;
|
|
1237
1266
|
} catch {
|
|
1238
1267
|
return false;
|
|
@@ -1240,7 +1269,11 @@ function hasRustToolchain() {
|
|
|
1240
1269
|
}
|
|
1241
1270
|
function hasUvx() {
|
|
1242
1271
|
try {
|
|
1243
|
-
execFileSync2("uvx", ["--version"], {
|
|
1272
|
+
execFileSync2("uvx", ["--version"], {
|
|
1273
|
+
stdio: "pipe",
|
|
1274
|
+
timeout: 1e4,
|
|
1275
|
+
windowsHide: true
|
|
1276
|
+
});
|
|
1244
1277
|
return true;
|
|
1245
1278
|
} catch {
|
|
1246
1279
|
return false;
|
|
@@ -1272,7 +1305,11 @@ function detectLlm(env = process.env) {
|
|
|
1272
1305
|
}
|
|
1273
1306
|
function onPath(bin) {
|
|
1274
1307
|
try {
|
|
1275
|
-
execFileSync2("which", [bin], {
|
|
1308
|
+
execFileSync2("which", [bin], {
|
|
1309
|
+
stdio: "pipe",
|
|
1310
|
+
timeout: 5e3,
|
|
1311
|
+
windowsHide: true
|
|
1312
|
+
});
|
|
1276
1313
|
return true;
|
|
1277
1314
|
} catch {
|
|
1278
1315
|
return false;
|
|
@@ -1283,7 +1320,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1283
1320
|
const starter = join5(dirname4(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1284
1321
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1285
1322
|
detached: true,
|
|
1286
|
-
stdio: "ignore"
|
|
1323
|
+
stdio: "ignore",
|
|
1324
|
+
windowsHide: true
|
|
1287
1325
|
});
|
|
1288
1326
|
child.on("error", () => {
|
|
1289
1327
|
});
|
|
@@ -15858,7 +15896,11 @@ import { execFileSync as execFileSync4 } from "child_process";
|
|
|
15858
15896
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
15859
15897
|
import { resolve } from "path";
|
|
15860
15898
|
function git(repo, ...args) {
|
|
15861
|
-
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15899
|
+
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15900
|
+
encoding: "utf8",
|
|
15901
|
+
maxBuffer: 1 << 28,
|
|
15902
|
+
windowsHide: true
|
|
15903
|
+
});
|
|
15862
15904
|
}
|
|
15863
15905
|
function repoNameOf(repo) {
|
|
15864
15906
|
return projectNameOf(resolve(repo));
|
|
@@ -15906,9 +15948,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
15906
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>").
|
|
15907
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.
|
|
15908
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).`;
|
|
15909
|
-
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";
|
|
15910
15952
|
function toolGuide(opts) {
|
|
15911
|
-
return (opts?.reflectOnNewGoals ?
|
|
15953
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
15912
15954
|
}
|
|
15913
15955
|
function buildKnowledgePreamble(pages, opts) {
|
|
15914
15956
|
const body = pages.length ? `Knowledge pages currently in this repository:
|
|
@@ -16113,6 +16155,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
16113
16155
|
cwd: repoDir,
|
|
16114
16156
|
detached: true,
|
|
16115
16157
|
stdio: "ignore",
|
|
16158
|
+
windowsHide: true,
|
|
16116
16159
|
env: plan.env
|
|
16117
16160
|
});
|
|
16118
16161
|
child.on("error", () => {
|
|
@@ -16129,7 +16172,8 @@ var DEEPEN_DIFF_TARGET = 300;
|
|
|
16129
16172
|
function commitCount(repoDir) {
|
|
16130
16173
|
try {
|
|
16131
16174
|
const out = execFileSync4("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
|
|
16132
|
-
encoding: "utf8"
|
|
16175
|
+
encoding: "utf8",
|
|
16176
|
+
windowsHide: true
|
|
16133
16177
|
});
|
|
16134
16178
|
return Number(out.trim()) || 0;
|
|
16135
16179
|
} catch {
|
|
@@ -16638,7 +16682,10 @@ async function gitSyncNote(args) {
|
|
|
16638
16682
|
try {
|
|
16639
16683
|
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
16640
16684
|
const n = Number(
|
|
16641
|
-
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()
|
|
16642
16689
|
);
|
|
16643
16690
|
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
|
|
16644
16691
|
} catch {
|
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", () => {
|
|
@@ -837,14 +860,16 @@ var HindsightClient = class {
|
|
|
837
860
|
return;
|
|
838
861
|
}
|
|
839
862
|
if (r.status !== 409) created++;
|
|
840
|
-
} else
|
|
841
|
-
const
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
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) {
|
|
845
869
|
patch.source_query = page.source_query;
|
|
846
870
|
patch.tags = page.tags;
|
|
847
871
|
}
|
|
872
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
848
873
|
const r = await this.req(
|
|
849
874
|
"PATCH",
|
|
850
875
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1245,9 +1270,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
1245
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>").
|
|
1246
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.
|
|
1247
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).`;
|
|
1248
|
-
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";
|
|
1249
1274
|
function toolGuide(opts) {
|
|
1250
|
-
return (opts?.reflectOnNewGoals ?
|
|
1275
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
1251
1276
|
}
|
|
1252
1277
|
function buildRosterRefresh(pages, opts) {
|
|
1253
1278
|
const rosterBlock = pages.length ? `Current Hindsight knowledge pages (may have changed):
|