@vectorize-io/hindsight-coding-agents 0.4.1 → 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 +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 +16 -4
- 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
package/dist/claude-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/cline.js
CHANGED
|
@@ -31,7 +31,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
|
|
|
31
31
|
],
|
|
32
32
|
{
|
|
33
33
|
detached: true,
|
|
34
|
-
stdio: "ignore"
|
|
34
|
+
stdio: "ignore",
|
|
35
|
+
windowsHide: true
|
|
35
36
|
}
|
|
36
37
|
);
|
|
37
38
|
child.on("error", () => {
|
|
@@ -71,14 +72,36 @@ function getProjectRootFromGit(directory) {
|
|
|
71
72
|
const commonDir = execFileSync(
|
|
72
73
|
"git",
|
|
73
74
|
["rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
74
|
-
{
|
|
75
|
+
{
|
|
76
|
+
cwd: directory,
|
|
77
|
+
encoding: "utf-8",
|
|
78
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
79
|
+
timeout: 1e3,
|
|
80
|
+
windowsHide: true
|
|
81
|
+
}
|
|
75
82
|
).trim();
|
|
76
83
|
if (!commonDir) return null;
|
|
77
|
-
|
|
84
|
+
if (basename(commonDir) === ".git") return dirname2(commonDir);
|
|
85
|
+
if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
|
|
86
|
+
return dirname2(commonDir);
|
|
87
|
+
}
|
|
88
|
+
return commonDir;
|
|
78
89
|
} catch {
|
|
79
90
|
return null;
|
|
80
91
|
}
|
|
81
92
|
}
|
|
93
|
+
function isBareRepository(commonDir) {
|
|
94
|
+
try {
|
|
95
|
+
return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
|
|
96
|
+
encoding: "utf-8",
|
|
97
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
98
|
+
timeout: 1e3,
|
|
99
|
+
env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
|
|
100
|
+
}).trim() === "true";
|
|
101
|
+
} catch {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
82
105
|
function projectNameOf(directory, sessionRoot) {
|
|
83
106
|
return gitProjectName(directory, true, sessionRoot);
|
|
84
107
|
}
|
|
@@ -841,14 +864,16 @@ var HindsightClient = class {
|
|
|
841
864
|
return;
|
|
842
865
|
}
|
|
843
866
|
if (r.status !== 409) created++;
|
|
844
|
-
} else
|
|
845
|
-
const
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
867
|
+
} else {
|
|
868
|
+
const sourceDrift = hit.description !== page.source_query;
|
|
869
|
+
const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
|
|
870
|
+
if (!sourceDrift && !triggerDrift) continue;
|
|
871
|
+
const patch = {};
|
|
872
|
+
if (sourceDrift) {
|
|
849
873
|
patch.source_query = page.source_query;
|
|
850
874
|
patch.tags = page.tags;
|
|
851
875
|
}
|
|
876
|
+
if (triggerDrift) patch.trigger = pageTrigger;
|
|
852
877
|
const r = await this.req(
|
|
853
878
|
"PATCH",
|
|
854
879
|
this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
|
|
@@ -1231,7 +1256,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
|
|
|
1231
1256
|
function hasRustToolchain() {
|
|
1232
1257
|
if (process.platform !== "darwin") return true;
|
|
1233
1258
|
try {
|
|
1234
|
-
execFileSync2("cargo", ["--version"], {
|
|
1259
|
+
execFileSync2("cargo", ["--version"], {
|
|
1260
|
+
stdio: "pipe",
|
|
1261
|
+
timeout: 1e4,
|
|
1262
|
+
windowsHide: true
|
|
1263
|
+
});
|
|
1235
1264
|
return true;
|
|
1236
1265
|
} catch {
|
|
1237
1266
|
return false;
|
|
@@ -1239,7 +1268,11 @@ function hasRustToolchain() {
|
|
|
1239
1268
|
}
|
|
1240
1269
|
function hasUvx() {
|
|
1241
1270
|
try {
|
|
1242
|
-
execFileSync2("uvx", ["--version"], {
|
|
1271
|
+
execFileSync2("uvx", ["--version"], {
|
|
1272
|
+
stdio: "pipe",
|
|
1273
|
+
timeout: 1e4,
|
|
1274
|
+
windowsHide: true
|
|
1275
|
+
});
|
|
1243
1276
|
return true;
|
|
1244
1277
|
} catch {
|
|
1245
1278
|
return false;
|
|
@@ -1271,7 +1304,11 @@ function detectLlm(env = process.env) {
|
|
|
1271
1304
|
}
|
|
1272
1305
|
function onPath(bin) {
|
|
1273
1306
|
try {
|
|
1274
|
-
execFileSync2("which", [bin], {
|
|
1307
|
+
execFileSync2("which", [bin], {
|
|
1308
|
+
stdio: "pipe",
|
|
1309
|
+
timeout: 5e3,
|
|
1310
|
+
windowsHide: true
|
|
1311
|
+
});
|
|
1275
1312
|
return true;
|
|
1276
1313
|
} catch {
|
|
1277
1314
|
return false;
|
|
@@ -1282,7 +1319,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
|
|
|
1282
1319
|
const starter = join5(dirname4(fileURLToPath2(import.meta.url)), "daemon-start.js");
|
|
1283
1320
|
const child = spawnFn("node", [starter, "--harness", harness], {
|
|
1284
1321
|
detached: true,
|
|
1285
|
-
stdio: "ignore"
|
|
1322
|
+
stdio: "ignore",
|
|
1323
|
+
windowsHide: true
|
|
1286
1324
|
});
|
|
1287
1325
|
child.on("error", () => {
|
|
1288
1326
|
});
|
|
@@ -15857,7 +15895,11 @@ import { execFileSync as execFileSync4 } from "child_process";
|
|
|
15857
15895
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
15858
15896
|
import { resolve } from "path";
|
|
15859
15897
|
function git(repo, ...args) {
|
|
15860
|
-
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15898
|
+
return execFileSync3("git", ["-C", repo, ...args], {
|
|
15899
|
+
encoding: "utf8",
|
|
15900
|
+
maxBuffer: 1 << 28,
|
|
15901
|
+
windowsHide: true
|
|
15902
|
+
});
|
|
15861
15903
|
}
|
|
15862
15904
|
function repoNameOf(repo) {
|
|
15863
15905
|
return projectNameOf(resolve(repo));
|
|
@@ -15905,9 +15947,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
|
|
|
15905
15947
|
- 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>").
|
|
15906
15948
|
- 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.
|
|
15907
15949
|
- 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).`;
|
|
15908
|
-
var
|
|
15950
|
+
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";
|
|
15909
15951
|
function toolGuide(opts) {
|
|
15910
|
-
return (opts?.reflectOnNewGoals ?
|
|
15952
|
+
return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
|
|
15911
15953
|
}
|
|
15912
15954
|
function buildKnowledgePreamble(pages, opts) {
|
|
15913
15955
|
const body = pages.length ? `Knowledge pages currently in this repository:
|
|
@@ -16112,6 +16154,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
|
|
|
16112
16154
|
cwd: repoDir,
|
|
16113
16155
|
detached: true,
|
|
16114
16156
|
stdio: "ignore",
|
|
16157
|
+
windowsHide: true,
|
|
16115
16158
|
env: plan.env
|
|
16116
16159
|
});
|
|
16117
16160
|
child.on("error", () => {
|
|
@@ -16128,7 +16171,8 @@ var DEEPEN_DIFF_TARGET = 300;
|
|
|
16128
16171
|
function commitCount(repoDir) {
|
|
16129
16172
|
try {
|
|
16130
16173
|
const out = execFileSync4("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
|
|
16131
|
-
encoding: "utf8"
|
|
16174
|
+
encoding: "utf8",
|
|
16175
|
+
windowsHide: true
|
|
16132
16176
|
});
|
|
16133
16177
|
return Number(out.trim()) || 0;
|
|
16134
16178
|
} catch {
|
|
@@ -16637,7 +16681,10 @@ async function gitSyncNote(args) {
|
|
|
16637
16681
|
try {
|
|
16638
16682
|
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
16639
16683
|
const n = Number(
|
|
16640
|
-
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
16684
|
+
execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
|
|
16685
|
+
encoding: "utf8",
|
|
16686
|
+
windowsHide: true
|
|
16687
|
+
}).trim()
|
|
16641
16688
|
);
|
|
16642
16689
|
if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
|
|
16643
16690
|
} catch {
|
package/dist/codex-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):
|
|
@@ -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/codex-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
|
});
|