@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.
@@ -31022,14 +31022,36 @@ function getProjectRootFromGit(directory) {
31022
31022
  const commonDir = execFileSync(
31023
31023
  "git",
31024
31024
  ["rev-parse", "--path-format=absolute", "--git-common-dir"],
31025
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
31025
+ {
31026
+ cwd: directory,
31027
+ encoding: "utf-8",
31028
+ stdio: ["ignore", "pipe", "ignore"],
31029
+ timeout: 1e3,
31030
+ windowsHide: true
31031
+ }
31026
31032
  ).trim();
31027
31033
  if (!commonDir) return null;
31028
- return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
31034
+ if (basename(commonDir) === ".git") return dirname2(commonDir);
31035
+ if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
31036
+ return dirname2(commonDir);
31037
+ }
31038
+ return commonDir;
31029
31039
  } catch {
31030
31040
  return null;
31031
31041
  }
31032
31042
  }
31043
+ function isBareRepository(commonDir) {
31044
+ try {
31045
+ return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
31046
+ encoding: "utf-8",
31047
+ stdio: ["ignore", "pipe", "ignore"],
31048
+ timeout: 1e3,
31049
+ env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
31050
+ }).trim() === "true";
31051
+ } catch {
31052
+ return false;
31053
+ }
31054
+ }
31033
31055
  function projectNameOf(directory, sessionRoot) {
31034
31056
  return gitProjectName(directory, true, sessionRoot);
31035
31057
  }
@@ -31267,7 +31289,7 @@ var PAGE_TAXONOMY = [
31267
31289
  },
31268
31290
  {
31269
31291
  name: "Initiatives and enhancements",
31270
- 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 tag of the form `relatedPageId:<id>`, include a Markdown link `[[page:<id>]]` to that page in the summary, so each initiative links to its detailed page.",
31292
+ 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.",
31271
31293
  tags: ["knowledge:feature-work"]
31272
31294
  }
31273
31295
  ];
@@ -31276,9 +31298,10 @@ function pagesFor(project) {
31276
31298
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
31277
31299
  }
31278
31300
  var PAGE_MAX_TOKENS = 4096;
31301
+ var PAGE_TAGS_MATCH = "all";
31279
31302
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
31280
31303
  function buildPageTrigger(cfg = {}) {
31281
- const base = { fact_types: PAGE_FACT_TYPES };
31304
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
31282
31305
  switch (cfg.pageTriggerType) {
31283
31306
  case "cron":
31284
31307
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -31788,11 +31811,20 @@ var HindsightClient = class {
31788
31811
  return;
31789
31812
  }
31790
31813
  if (r.status !== 409) created++;
31791
- } else if (hit.description !== page.source_query) {
31814
+ } else {
31815
+ const sourceDrift = hit.description !== page.source_query;
31816
+ const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
31817
+ if (!sourceDrift && !triggerDrift) continue;
31818
+ const patch = {};
31819
+ if (sourceDrift) {
31820
+ patch.source_query = page.source_query;
31821
+ patch.tags = page.tags;
31822
+ }
31823
+ if (triggerDrift) patch.trigger = pageTrigger;
31792
31824
  const r = await this.req(
31793
31825
  "PATCH",
31794
31826
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
31795
- { source_query: page.source_query, tags: page.tags }
31827
+ patch
31796
31828
  );
31797
31829
  if ([404, 405, 501].includes(r.status)) {
31798
31830
  this.knowledgePagesSupported = false;
@@ -31813,10 +31845,17 @@ var HindsightClient = class {
31813
31845
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
31814
31846
  }
31815
31847
  /**
31816
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
31817
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
31848
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
31849
+ * New initiative → creates a page under the Initiatives folder.
31818
31850
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
31819
31851
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
31852
+ *
31853
+ * The marker carries its page id in two places, neither of them a tag (#3641):
31854
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
31855
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
31856
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
31857
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
31858
+ * vocabulary that exists to be matched with exact set-ops.
31820
31859
  */
31821
31860
  async captureInitiative(args) {
31822
31861
  let pageId = args.relatesToPageId;
@@ -31839,20 +31878,11 @@ var HindsightClient = class {
31839
31878
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
31840
31879
  const content = `${verb}: ${args.title}. ${args.summary}`;
31841
31880
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
31842
- const tags = [
31843
- .../* @__PURE__ */ new Set([
31844
- ...args.stamp?.tags ?? [],
31845
- "knowledge:feature-work",
31846
- `relatedPageId:${pageId}`
31847
- ])
31848
- ];
31849
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
31850
- await this.retain(content, "initiative marker", markerId, tags, "document", {
31851
- metadata: args.stamp?.metadata
31852
- });
31853
- } else {
31854
- await this.retain(content, "initiative marker", markerId, tags, "document");
31855
- }
31881
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
31882
+ const context = `initiative marker for [[page:${pageId}]]`;
31883
+ await this.retain(content, context, markerId, tags, "document", {
31884
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
31885
+ });
31856
31886
  return { page_id: pageId };
31857
31887
  }
31858
31888
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -32150,7 +32180,11 @@ import { execFileSync as execFileSync3 } from "child_process";
32150
32180
  import { execFileSync as execFileSync2 } from "child_process";
32151
32181
  import { resolve } from "path";
32152
32182
  function git(repo, ...args) {
32153
- return execFileSync2("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 1 << 28 });
32183
+ return execFileSync2("git", ["-C", repo, ...args], {
32184
+ encoding: "utf8",
32185
+ maxBuffer: 1 << 28,
32186
+ windowsHide: true
32187
+ });
32154
32188
  }
32155
32189
  function repoNameOf(repo) {
32156
32190
  return projectNameOf(resolve(repo));
@@ -32195,7 +32229,8 @@ var DEEPEN_DIFF_TARGET = 300;
32195
32229
  function commitCount(repoDir) {
32196
32230
  try {
32197
32231
  const out = execFileSync3("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
32198
- encoding: "utf8"
32232
+ encoding: "utf8",
32233
+ windowsHide: true
32199
32234
  });
32200
32235
  return Number(out.trim()) || 0;
32201
32236
  } catch {
@@ -14545,7 +14545,8 @@ function startBackgroundSeed(repoDir, opts = {}) {
14545
14545
  ],
14546
14546
  {
14547
14547
  detached: true,
14548
- stdio: "ignore"
14548
+ stdio: "ignore",
14549
+ windowsHide: true
14549
14550
  }
14550
14551
  );
14551
14552
  child.on("error", () => {
@@ -14585,14 +14586,36 @@ function getProjectRootFromGit(directory) {
14585
14586
  const commonDir = execFileSync(
14586
14587
  "git",
14587
14588
  ["rev-parse", "--path-format=absolute", "--git-common-dir"],
14588
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
14589
+ {
14590
+ cwd: directory,
14591
+ encoding: "utf-8",
14592
+ stdio: ["ignore", "pipe", "ignore"],
14593
+ timeout: 1e3,
14594
+ windowsHide: true
14595
+ }
14589
14596
  ).trim();
14590
14597
  if (!commonDir) return null;
14591
- return basename(commonDir) === ".git" ? dirname2(commonDir) : commonDir;
14598
+ if (basename(commonDir) === ".git") return dirname2(commonDir);
14599
+ if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
14600
+ return dirname2(commonDir);
14601
+ }
14602
+ return commonDir;
14592
14603
  } catch {
14593
14604
  return null;
14594
14605
  }
14595
14606
  }
14607
+ function isBareRepository(commonDir) {
14608
+ try {
14609
+ return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
14610
+ encoding: "utf-8",
14611
+ stdio: ["ignore", "pipe", "ignore"],
14612
+ timeout: 1e3,
14613
+ env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
14614
+ }).trim() === "true";
14615
+ } catch {
14616
+ return false;
14617
+ }
14618
+ }
14596
14619
  function projectNameOf(directory, sessionRoot) {
14597
14620
  return gitProjectName(directory, true, sessionRoot);
14598
14621
  }
@@ -14833,7 +14856,7 @@ var PAGE_TAXONOMY = [
14833
14856
  },
14834
14857
  {
14835
14858
  name: "Initiatives and enhancements",
14836
- 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 tag of the form `relatedPageId:<id>`, include a Markdown link `[[page:<id>]]` to that page in the summary, so each initiative links to its detailed page.",
14859
+ 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.",
14837
14860
  tags: ["knowledge:feature-work"]
14838
14861
  }
14839
14862
  ];
@@ -14842,9 +14865,10 @@ function pagesFor(project) {
14842
14865
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
14843
14866
  }
14844
14867
  var PAGE_MAX_TOKENS = 4096;
14868
+ var PAGE_TAGS_MATCH = "all";
14845
14869
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
14846
14870
  function buildPageTrigger(cfg = {}) {
14847
- const base = { fact_types: PAGE_FACT_TYPES };
14871
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
14848
14872
  switch (cfg.pageTriggerType) {
14849
14873
  case "cron":
14850
14874
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -15354,11 +15378,20 @@ var HindsightClient = class {
15354
15378
  return;
15355
15379
  }
15356
15380
  if (r.status !== 409) created++;
15357
- } else if (hit.description !== page.source_query) {
15381
+ } else {
15382
+ const sourceDrift = hit.description !== page.source_query;
15383
+ const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
15384
+ if (!sourceDrift && !triggerDrift) continue;
15385
+ const patch = {};
15386
+ if (sourceDrift) {
15387
+ patch.source_query = page.source_query;
15388
+ patch.tags = page.tags;
15389
+ }
15390
+ if (triggerDrift) patch.trigger = pageTrigger;
15358
15391
  const r = await this.req(
15359
15392
  "PATCH",
15360
15393
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
15361
- { source_query: page.source_query, tags: page.tags }
15394
+ patch
15362
15395
  );
15363
15396
  if ([404, 405, 501].includes(r.status)) {
15364
15397
  this.knowledgePagesSupported = false;
@@ -15379,10 +15412,17 @@ var HindsightClient = class {
15379
15412
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
15380
15413
  }
15381
15414
  /**
15382
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
15383
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
15415
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
15416
+ * New initiative → creates a page under the Initiatives folder.
15384
15417
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
15385
15418
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
15419
+ *
15420
+ * The marker carries its page id in two places, neither of them a tag (#3641):
15421
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
15422
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
15423
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
15424
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
15425
+ * vocabulary that exists to be matched with exact set-ops.
15386
15426
  */
15387
15427
  async captureInitiative(args) {
15388
15428
  let pageId = args.relatesToPageId;
@@ -15405,20 +15445,11 @@ var HindsightClient = class {
15405
15445
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
15406
15446
  const content = `${verb}: ${args.title}. ${args.summary}`;
15407
15447
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
15408
- const tags = [
15409
- .../* @__PURE__ */ new Set([
15410
- ...args.stamp?.tags ?? [],
15411
- "knowledge:feature-work",
15412
- `relatedPageId:${pageId}`
15413
- ])
15414
- ];
15415
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
15416
- await this.retain(content, "initiative marker", markerId, tags, "document", {
15417
- metadata: args.stamp?.metadata
15418
- });
15419
- } else {
15420
- await this.retain(content, "initiative marker", markerId, tags, "document");
15421
- }
15448
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
15449
+ const context = `initiative marker for [[page:${pageId}]]`;
15450
+ await this.retain(content, context, markerId, tags, "document", {
15451
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
15452
+ });
15422
15453
  return { page_id: pageId };
15423
15454
  }
15424
15455
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -15737,7 +15768,11 @@ async function isServerHealthy(baseUrl, timeoutMs = 2e3) {
15737
15768
  function hasRustToolchain() {
15738
15769
  if (process.platform !== "darwin") return true;
15739
15770
  try {
15740
- execFileSync2("cargo", ["--version"], { stdio: "pipe", timeout: 1e4 });
15771
+ execFileSync2("cargo", ["--version"], {
15772
+ stdio: "pipe",
15773
+ timeout: 1e4,
15774
+ windowsHide: true
15775
+ });
15741
15776
  return true;
15742
15777
  } catch {
15743
15778
  return false;
@@ -15745,7 +15780,11 @@ function hasRustToolchain() {
15745
15780
  }
15746
15781
  function hasUvx() {
15747
15782
  try {
15748
- execFileSync2("uvx", ["--version"], { stdio: "pipe", timeout: 1e4 });
15783
+ execFileSync2("uvx", ["--version"], {
15784
+ stdio: "pipe",
15785
+ timeout: 1e4,
15786
+ windowsHide: true
15787
+ });
15749
15788
  return true;
15750
15789
  } catch {
15751
15790
  return false;
@@ -15777,7 +15816,11 @@ function detectLlm(env = process.env) {
15777
15816
  }
15778
15817
  function onPath(bin) {
15779
15818
  try {
15780
- execFileSync2("which", [bin], { stdio: "pipe", timeout: 5e3 });
15819
+ execFileSync2("which", [bin], {
15820
+ stdio: "pipe",
15821
+ timeout: 5e3,
15822
+ windowsHide: true
15823
+ });
15781
15824
  return true;
15782
15825
  } catch {
15783
15826
  return false;
@@ -15788,7 +15831,8 @@ function startDaemonDetached(cfg, harness, spawnFn = realSpawn2) {
15788
15831
  const starter = join5(dirname4(fileURLToPath2(import.meta.url)), "daemon-start.js");
15789
15832
  const child = spawnFn("node", [starter, "--harness", harness], {
15790
15833
  detached: true,
15791
- stdio: "ignore"
15834
+ stdio: "ignore",
15835
+ windowsHide: true
15792
15836
  });
15793
15837
  child.on("error", () => {
15794
15838
  });
@@ -15849,7 +15893,11 @@ import { execFileSync as execFileSync4 } from "child_process";
15849
15893
  import { execFileSync as execFileSync3 } from "child_process";
15850
15894
  import { resolve } from "path";
15851
15895
  function git(repo, ...args) {
15852
- return execFileSync3("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 1 << 28 });
15896
+ return execFileSync3("git", ["-C", repo, ...args], {
15897
+ encoding: "utf8",
15898
+ maxBuffer: 1 << 28,
15899
+ windowsHide: true
15900
+ });
15853
15901
  }
15854
15902
  function repoNameOf(repo) {
15855
15903
  return projectNameOf(resolve(repo));
@@ -15897,9 +15945,9 @@ var TOOL_GUIDE = `- hindsight_search_knowledge_pages(query) \u2014 FIRST STOP fo
15897
15945
  - 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>").
15898
15946
  - 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.
15899
15947
  - 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).`;
15900
- 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";
15948
+ 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";
15901
15949
  function toolGuide(opts) {
15902
- return (opts?.reflectOnNewGoals ? REFLECT_ON_GOALS : "") + TOOL_GUIDE;
15950
+ return (opts?.reflectOnNewGoals ? PAGES_FIRST_ON_GOALS : "") + TOOL_GUIDE;
15903
15951
  }
15904
15952
  function buildKnowledgePreamble(pages, opts) {
15905
15953
  const body = pages.length ? `Knowledge pages currently in this repository:
@@ -16104,6 +16152,7 @@ function startCodebaseSurvey(repoDir, opts = {}) {
16104
16152
  cwd: repoDir,
16105
16153
  detached: true,
16106
16154
  stdio: "ignore",
16155
+ windowsHide: true,
16107
16156
  env: plan.env
16108
16157
  });
16109
16158
  child.on("error", () => {
@@ -16120,7 +16169,8 @@ var DEEPEN_DIFF_TARGET = 300;
16120
16169
  function commitCount(repoDir) {
16121
16170
  try {
16122
16171
  const out = execFileSync4("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
16123
- encoding: "utf8"
16172
+ encoding: "utf8",
16173
+ windowsHide: true
16124
16174
  });
16125
16175
  return Number(out.trim()) || 0;
16126
16176
  } catch {
@@ -16629,7 +16679,10 @@ async function gitSyncNote(args) {
16629
16679
  try {
16630
16680
  const { execFileSync: execFileSync5 } = await import("child_process");
16631
16681
  const n = Number(
16632
- execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], { encoding: "utf8" }).trim()
16682
+ execFileSync5("git", ["-C", cwd, "rev-list", "--count", "HEAD"], {
16683
+ encoding: "utf8",
16684
+ windowsHide: true
16685
+ }).trim()
16633
16686
  );
16634
16687
  if (n > 0) target = Math.min(DEEPEN_DIFF_TARGET, n);
16635
16688
  } catch {
package/dist/status.js CHANGED
@@ -30,14 +30,36 @@ function getProjectRootFromGit(directory) {
30
30
  const commonDir = execFileSync(
31
31
  "git",
32
32
  ["rev-parse", "--path-format=absolute", "--git-common-dir"],
33
- { cwd: directory, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"], timeout: 1e3 }
33
+ {
34
+ cwd: directory,
35
+ encoding: "utf-8",
36
+ stdio: ["ignore", "pipe", "ignore"],
37
+ timeout: 1e3,
38
+ windowsHide: true
39
+ }
34
40
  ).trim();
35
41
  if (!commonDir) return null;
36
- return basename(commonDir) === ".git" ? dirname(commonDir) : commonDir;
42
+ if (basename(commonDir) === ".git") return dirname(commonDir);
43
+ if (basename(commonDir).startsWith(".") && isBareRepository(commonDir)) {
44
+ return dirname(commonDir);
45
+ }
46
+ return commonDir;
37
47
  } catch {
38
48
  return null;
39
49
  }
40
50
  }
51
+ function isBareRepository(commonDir) {
52
+ try {
53
+ return execFileSync("git", ["-C", commonDir, "rev-parse", "--is-bare-repository"], {
54
+ encoding: "utf-8",
55
+ stdio: ["ignore", "pipe", "ignore"],
56
+ timeout: 1e3,
57
+ env: { ...process.env, GIT_DIR: void 0, GIT_WORK_TREE: void 0 }
58
+ }).trim() === "true";
59
+ } catch {
60
+ return false;
61
+ }
62
+ }
41
63
  function projectNameOf(directory, sessionRoot) {
42
64
  return gitProjectName(directory, true, sessionRoot);
43
65
  }
@@ -272,7 +294,7 @@ var PAGE_TAXONOMY = [
272
294
  },
273
295
  {
274
296
  name: "Initiatives and enhancements",
275
- 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 tag of the form `relatedPageId:<id>`, include a Markdown link `[[page:<id>]]` to that page in the summary, so each initiative links to its detailed page.",
297
+ 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.",
276
298
  tags: ["knowledge:feature-work"]
277
299
  }
278
300
  ];
@@ -281,9 +303,10 @@ function pagesFor(project) {
281
303
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
282
304
  }
283
305
  var PAGE_MAX_TOKENS = 4096;
306
+ var PAGE_TAGS_MATCH = "all";
284
307
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
285
308
  function buildPageTrigger(cfg2 = {}) {
286
- const base = { fact_types: PAGE_FACT_TYPES };
309
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
287
310
  switch (cfg2.pageTriggerType) {
288
311
  case "cron":
289
312
  return { ...base, refresh_cron: cfg2.pageTriggerCron };
@@ -793,11 +816,20 @@ var HindsightClient = class {
793
816
  return;
794
817
  }
795
818
  if (r.status !== 409) created++;
796
- } else if (hit.description !== page.source_query) {
819
+ } else {
820
+ const sourceDrift = hit.description !== page.source_query;
821
+ const triggerDrift = hit.trigger != null && hit.trigger.tags_match !== pageTrigger.tags_match;
822
+ if (!sourceDrift && !triggerDrift) continue;
823
+ const patch = {};
824
+ if (sourceDrift) {
825
+ patch.source_query = page.source_query;
826
+ patch.tags = page.tags;
827
+ }
828
+ if (triggerDrift) patch.trigger = pageTrigger;
797
829
  const r = await this.req(
798
830
  "PATCH",
799
831
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
800
- { source_query: page.source_query, tags: page.tags }
832
+ patch
801
833
  );
802
834
  if ([404, 405, 501].includes(r.status)) {
803
835
  this.knowledgePagesSupported = false;
@@ -818,10 +850,17 @@ var HindsightClient = class {
818
850
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
819
851
  }
820
852
  /**
821
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
822
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
853
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
854
+ * New initiative → creates a page under the Initiatives folder.
823
855
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
824
856
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
857
+ *
858
+ * The marker carries its page id in two places, neither of them a tag (#3641):
859
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
860
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
861
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
862
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
863
+ * vocabulary that exists to be matched with exact set-ops.
825
864
  */
826
865
  async captureInitiative(args) {
827
866
  let pageId = args.relatesToPageId;
@@ -844,20 +883,11 @@ var HindsightClient = class {
844
883
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
845
884
  const content = `${verb}: ${args.title}. ${args.summary}`;
846
885
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
847
- const tags = [
848
- .../* @__PURE__ */ new Set([
849
- ...args.stamp?.tags ?? [],
850
- "knowledge:feature-work",
851
- `relatedPageId:${pageId}`
852
- ])
853
- ];
854
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
855
- await this.retain(content, "initiative marker", markerId, tags, "document", {
856
- metadata: args.stamp?.metadata
857
- });
858
- } else {
859
- await this.retain(content, "initiative marker", markerId, tags, "document");
860
- }
886
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
887
+ const context = `initiative marker for [[page:${pageId}]]`;
888
+ await this.retain(content, context, markerId, tags, "document", {
889
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
890
+ });
861
891
  return { page_id: pageId };
862
892
  }
863
893
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -1124,7 +1154,11 @@ import { execFileSync as execFileSync3 } from "child_process";
1124
1154
  import { execFileSync as execFileSync2 } from "child_process";
1125
1155
  import { resolve } from "path";
1126
1156
  function git(repo, ...args) {
1127
- return execFileSync2("git", ["-C", repo, ...args], { encoding: "utf8", maxBuffer: 1 << 28 });
1157
+ return execFileSync2("git", ["-C", repo, ...args], {
1158
+ encoding: "utf8",
1159
+ maxBuffer: 1 << 28,
1160
+ windowsHide: true
1161
+ });
1128
1162
  }
1129
1163
  function repoNameOf(repo) {
1130
1164
  return projectNameOf(resolve(repo));
@@ -1169,7 +1203,8 @@ var DEEPEN_DIFF_TARGET = 300;
1169
1203
  function commitCount(repoDir) {
1170
1204
  try {
1171
1205
  const out = execFileSync3("git", ["-C", repoDir, "rev-list", "--count", "HEAD"], {
1172
- encoding: "utf8"
1206
+ encoding: "utf8",
1207
+ windowsHide: true
1173
1208
  });
1174
1209
  return Number(out.trim()) || 0;
1175
1210
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectorize-io/hindsight-coding-agents",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",
@@ -66,8 +66,9 @@
66
66
  },
67
67
  "scripts": {
68
68
  "build": "tsup",
69
+ "skill:build": "node scripts/build-skill.mjs",
69
70
  "clean": "rm -rf dist",
70
- "prepublishOnly": "npm run clean && npm run build",
71
+ "prepublishOnly": "npm run clean && npm run skill:build && npm run build",
71
72
  "test": "vitest run --exclude '**/*.e2e.test.ts'",
72
73
  "test:harness-e2e": "npm run build && HINDSIGHT_HARNESS_E2E=1 vitest run src/harness.e2e.test.ts"
73
74
  },