@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.
@@ -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
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
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
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
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 if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
841
- const patch = {
842
- trigger: pageTrigger
843
- };
844
- if (hit.description !== page.source_query) {
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 REFLECT_ON_GOALS = "- The user just set a NEW task or goal \u2192 call hindsight_reflect with that goal FIRST, before planning: no memory is injected automatically in this configuration, so this call is the only way past decisions, constraints, and failed attempts relevant to the goal reach you.\n";
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 ? REFLECT_ON_GOALS : "") + TOOL_GUIDE;
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
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
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
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
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 if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
830
- const patch = {
831
- trigger: pageTrigger
832
- };
833
- if (hit.description !== page.source_query) {
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 REFLECT_ON_GOALS = "- The user just set a NEW task or goal \u2192 call hindsight_reflect with that goal FIRST, before planning: no memory is injected automatically in this configuration, so this call is the only way past decisions, constraints, and failed attempts relevant to the goal reach you.\n";
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 ? REFLECT_ON_GOALS : "") + TOOL_GUIDE;
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"], { stdio: "pipe", timeout: 1e4 });
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"], { stdio: "pipe", timeout: 1e4 });
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], { stdio: "pipe", timeout: 5e3 });
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], { encoding: "utf8", maxBuffer: 1 << 28 });
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"], { encoding: "utf8" }).trim()
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 {
@@ -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
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
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
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
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 if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
818
- const patch = {
819
- trigger: pageTrigger
820
- };
821
- if (hit.description !== page.source_query) {
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"], { stdio: "pipe", timeout: 1e4 });
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"], { stdio: "pipe", timeout: 1e4 });
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], { stdio: "pipe", timeout: 5e3 });
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
  });
@@ -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
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
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
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
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 if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
841
- const patch = {
842
- trigger: pageTrigger
843
- };
844
- if (hit.description !== page.source_query) {
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 REFLECT_ON_GOALS = "- The user just set a NEW task or goal \u2192 call hindsight_reflect with that goal FIRST, before planning: no memory is injected automatically in this configuration, so this call is the only way past decisions, constraints, and failed attempts relevant to the goal reach you.\n";
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 ? REFLECT_ON_GOALS : "") + TOOL_GUIDE;
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
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
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
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
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 if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
830
- const patch = {
831
- trigger: pageTrigger
832
- };
833
- if (hit.description !== page.source_query) {
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 REFLECT_ON_GOALS = "- The user just set a NEW task or goal \u2192 call hindsight_reflect with that goal FIRST, before planning: no memory is injected automatically in this configuration, so this call is the only way past decisions, constraints, and failed attempts relevant to the goal reach you.\n";
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 ? REFLECT_ON_GOALS : "") + TOOL_GUIDE;
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"], { stdio: "pipe", timeout: 1e4 });
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"], { stdio: "pipe", timeout: 1e4 });
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], { stdio: "pipe", timeout: 5e3 });
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], { encoding: "utf8", maxBuffer: 1 << 28 });
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"], { encoding: "utf8" }).trim()
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 {