@vectorize-io/hindsight-coding-agents 0.4.0 → 0.4.1

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.
@@ -304,7 +304,7 @@ var PAGE_TAXONOMY = [
304
304
  },
305
305
  {
306
306
  name: "Initiatives and enhancements",
307
- source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory carries a 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.",
307
+ source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
308
308
  tags: ["knowledge:feature-work"]
309
309
  }
310
310
  ];
@@ -313,9 +313,10 @@ function pagesFor(project) {
313
313
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
314
314
  }
315
315
  var PAGE_MAX_TOKENS = 4096;
316
+ var PAGE_TAGS_MATCH = "all";
316
317
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
317
318
  function buildPageTrigger(cfg = {}) {
318
- const base = { fact_types: PAGE_FACT_TYPES };
319
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
319
320
  switch (cfg.pageTriggerType) {
320
321
  case "cron":
321
322
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -825,11 +826,18 @@ var HindsightClient = class {
825
826
  return;
826
827
  }
827
828
  if (r.status !== 409) created++;
828
- } else if (hit.description !== page.source_query) {
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) {
834
+ patch.source_query = page.source_query;
835
+ patch.tags = page.tags;
836
+ }
829
837
  const r = await this.req(
830
838
  "PATCH",
831
839
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
832
- { source_query: page.source_query, tags: page.tags }
840
+ patch
833
841
  );
834
842
  if ([404, 405, 501].includes(r.status)) {
835
843
  this.knowledgePagesSupported = false;
@@ -850,10 +858,17 @@ var HindsightClient = class {
850
858
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
851
859
  }
852
860
  /**
853
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
854
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
861
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
862
+ * New initiative → creates a page under the Initiatives folder.
855
863
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
856
864
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
865
+ *
866
+ * The marker carries its page id in two places, neither of them a tag (#3641):
867
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
868
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
869
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
870
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
871
+ * vocabulary that exists to be matched with exact set-ops.
857
872
  */
858
873
  async captureInitiative(args) {
859
874
  let pageId = args.relatesToPageId;
@@ -876,20 +891,11 @@ var HindsightClient = class {
876
891
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
877
892
  const content = `${verb}: ${args.title}. ${args.summary}`;
878
893
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
879
- const tags = [
880
- .../* @__PURE__ */ new Set([
881
- ...args.stamp?.tags ?? [],
882
- "knowledge:feature-work",
883
- `relatedPageId:${pageId}`
884
- ])
885
- ];
886
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
887
- await this.retain(content, "initiative marker", markerId, tags, "document", {
888
- metadata: args.stamp?.metadata
889
- });
890
- } else {
891
- await this.retain(content, "initiative marker", markerId, tags, "document");
892
- }
894
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
895
+ const context = `initiative marker for [[page:${pageId}]]`;
896
+ await this.retain(content, context, markerId, tags, "document", {
897
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
898
+ });
893
899
  return { page_id: pageId };
894
900
  }
895
901
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -292,7 +292,7 @@ var PAGE_TAXONOMY = [
292
292
  },
293
293
  {
294
294
  name: "Initiatives and enhancements",
295
- source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory carries a 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.",
295
+ source_query: "Based on this repository's commit history, what are the major initiatives, features, and enhancements the project has worked on? Summarize the themes and notable changes over time. When a source memory's context carries a `[[page:<id>]]` link, repeat that link in the summary of what it describes, so each initiative links to its detailed page.",
296
296
  tags: ["knowledge:feature-work"]
297
297
  }
298
298
  ];
@@ -301,9 +301,10 @@ function pagesFor(project) {
301
301
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
302
302
  }
303
303
  var PAGE_MAX_TOKENS = 4096;
304
+ var PAGE_TAGS_MATCH = "all";
304
305
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
305
306
  function buildPageTrigger(cfg = {}) {
306
- const base = { fact_types: PAGE_FACT_TYPES };
307
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
307
308
  switch (cfg.pageTriggerType) {
308
309
  case "cron":
309
310
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -813,11 +814,18 @@ var HindsightClient = class {
813
814
  return;
814
815
  }
815
816
  if (r.status !== 409) created++;
816
- } else if (hit.description !== page.source_query) {
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) {
822
+ patch.source_query = page.source_query;
823
+ patch.tags = page.tags;
824
+ }
817
825
  const r = await this.req(
818
826
  "PATCH",
819
827
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
820
- { source_query: page.source_query, tags: page.tags }
828
+ patch
821
829
  );
822
830
  if ([404, 405, 501].includes(r.status)) {
823
831
  this.knowledgePagesSupported = false;
@@ -838,10 +846,17 @@ var HindsightClient = class {
838
846
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
839
847
  }
840
848
  /**
841
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
842
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
849
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
850
+ * New initiative → creates a page under the Initiatives folder.
843
851
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
844
852
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
853
+ *
854
+ * The marker carries its page id in two places, neither of them a tag (#3641):
855
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
856
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
857
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
858
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
859
+ * vocabulary that exists to be matched with exact set-ops.
845
860
  */
846
861
  async captureInitiative(args) {
847
862
  let pageId = args.relatesToPageId;
@@ -864,20 +879,11 @@ var HindsightClient = class {
864
879
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
865
880
  const content = `${verb}: ${args.title}. ${args.summary}`;
866
881
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
867
- const tags = [
868
- .../* @__PURE__ */ new Set([
869
- ...args.stamp?.tags ?? [],
870
- "knowledge:feature-work",
871
- `relatedPageId:${pageId}`
872
- ])
873
- ];
874
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
875
- await this.retain(content, "initiative marker", markerId, tags, "document", {
876
- metadata: args.stamp?.metadata
877
- });
878
- } else {
879
- await this.retain(content, "initiative marker", markerId, tags, "document");
880
- }
882
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
883
+ const context = `initiative marker for [[page:${pageId}]]`;
884
+ await this.retain(content, context, markerId, tags, "document", {
885
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
886
+ });
881
887
  return { page_id: pageId };
882
888
  }
883
889
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
package/dist/index.js CHANGED
@@ -322,7 +322,7 @@ var PAGE_TAXONOMY = [
322
322
  },
323
323
  {
324
324
  name: "Initiatives and enhancements",
325
- 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.",
325
+ 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.",
326
326
  tags: ["knowledge:feature-work"]
327
327
  }
328
328
  ];
@@ -331,9 +331,10 @@ function pagesFor(project) {
331
331
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
332
332
  }
333
333
  var PAGE_MAX_TOKENS = 4096;
334
+ var PAGE_TAGS_MATCH = "all";
334
335
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
335
336
  function buildPageTrigger(cfg = {}) {
336
- const base = { fact_types: PAGE_FACT_TYPES };
337
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
337
338
  switch (cfg.pageTriggerType) {
338
339
  case "cron":
339
340
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -843,11 +844,18 @@ var HindsightClient = class {
843
844
  return;
844
845
  }
845
846
  if (r.status !== 409) created++;
846
- } else if (hit.description !== page.source_query) {
847
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
848
+ const patch = {
849
+ trigger: pageTrigger
850
+ };
851
+ if (hit.description !== page.source_query) {
852
+ patch.source_query = page.source_query;
853
+ patch.tags = page.tags;
854
+ }
847
855
  const r = await this.req(
848
856
  "PATCH",
849
857
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
850
- { source_query: page.source_query, tags: page.tags }
858
+ patch
851
859
  );
852
860
  if ([404, 405, 501].includes(r.status)) {
853
861
  this.knowledgePagesSupported = false;
@@ -868,10 +876,17 @@ var HindsightClient = class {
868
876
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
869
877
  }
870
878
  /**
871
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
872
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
879
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
880
+ * New initiative → creates a page under the Initiatives folder.
873
881
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
874
882
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
883
+ *
884
+ * The marker carries its page id in two places, neither of them a tag (#3641):
885
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
886
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
887
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
888
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
889
+ * vocabulary that exists to be matched with exact set-ops.
875
890
  */
876
891
  async captureInitiative(args) {
877
892
  let pageId = args.relatesToPageId;
@@ -894,20 +909,11 @@ var HindsightClient = class {
894
909
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
895
910
  const content = `${verb}: ${args.title}. ${args.summary}`;
896
911
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
897
- const tags = [
898
- .../* @__PURE__ */ new Set([
899
- ...args.stamp?.tags ?? [],
900
- "knowledge:feature-work",
901
- `relatedPageId:${pageId}`
902
- ])
903
- ];
904
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
905
- await this.retain(content, "initiative marker", markerId, tags, "document", {
906
- metadata: args.stamp?.metadata
907
- });
908
- } else {
909
- await this.retain(content, "initiative marker", markerId, tags, "document");
910
- }
912
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
913
+ const context = `initiative marker for [[page:${pageId}]]`;
914
+ await this.retain(content, context, markerId, tags, "document", {
915
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
916
+ });
911
917
  return { page_id: pageId };
912
918
  }
913
919
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
package/dist/kilo.js CHANGED
@@ -322,7 +322,7 @@ var PAGE_TAXONOMY = [
322
322
  },
323
323
  {
324
324
  name: "Initiatives and enhancements",
325
- 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.",
325
+ 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.",
326
326
  tags: ["knowledge:feature-work"]
327
327
  }
328
328
  ];
@@ -331,9 +331,10 @@ function pagesFor(project) {
331
331
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
332
332
  }
333
333
  var PAGE_MAX_TOKENS = 4096;
334
+ var PAGE_TAGS_MATCH = "all";
334
335
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
335
336
  function buildPageTrigger(cfg = {}) {
336
- const base = { fact_types: PAGE_FACT_TYPES };
337
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
337
338
  switch (cfg.pageTriggerType) {
338
339
  case "cron":
339
340
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -843,11 +844,18 @@ var HindsightClient = class {
843
844
  return;
844
845
  }
845
846
  if (r.status !== 409) created++;
846
- } else if (hit.description !== page.source_query) {
847
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
848
+ const patch = {
849
+ trigger: pageTrigger
850
+ };
851
+ if (hit.description !== page.source_query) {
852
+ patch.source_query = page.source_query;
853
+ patch.tags = page.tags;
854
+ }
847
855
  const r = await this.req(
848
856
  "PATCH",
849
857
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
850
- { source_query: page.source_query, tags: page.tags }
858
+ patch
851
859
  );
852
860
  if ([404, 405, 501].includes(r.status)) {
853
861
  this.knowledgePagesSupported = false;
@@ -868,10 +876,17 @@ var HindsightClient = class {
868
876
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
869
877
  }
870
878
  /**
871
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
872
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
879
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
880
+ * New initiative → creates a page under the Initiatives folder.
873
881
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
874
882
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
883
+ *
884
+ * The marker carries its page id in two places, neither of them a tag (#3641):
885
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
886
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
887
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
888
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
889
+ * vocabulary that exists to be matched with exact set-ops.
875
890
  */
876
891
  async captureInitiative(args) {
877
892
  let pageId = args.relatesToPageId;
@@ -894,20 +909,11 @@ var HindsightClient = class {
894
909
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
895
910
  const content = `${verb}: ${args.title}. ${args.summary}`;
896
911
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
897
- const tags = [
898
- .../* @__PURE__ */ new Set([
899
- ...args.stamp?.tags ?? [],
900
- "knowledge:feature-work",
901
- `relatedPageId:${pageId}`
902
- ])
903
- ];
904
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
905
- await this.retain(content, "initiative marker", markerId, tags, "document", {
906
- metadata: args.stamp?.metadata
907
- });
908
- } else {
909
- await this.retain(content, "initiative marker", markerId, tags, "document");
910
- }
912
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
913
+ const context = `initiative marker for [[page:${pageId}]]`;
914
+ await this.retain(content, context, markerId, tags, "document", {
915
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
916
+ });
911
917
  return { page_id: pageId };
912
918
  }
913
919
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -31267,7 +31267,7 @@ var PAGE_TAXONOMY = [
31267
31267
  },
31268
31268
  {
31269
31269
  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.",
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'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
31271
  tags: ["knowledge:feature-work"]
31272
31272
  }
31273
31273
  ];
@@ -31276,9 +31276,10 @@ function pagesFor(project) {
31276
31276
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
31277
31277
  }
31278
31278
  var PAGE_MAX_TOKENS = 4096;
31279
+ var PAGE_TAGS_MATCH = "all";
31279
31280
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
31280
31281
  function buildPageTrigger(cfg = {}) {
31281
- const base = { fact_types: PAGE_FACT_TYPES };
31282
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
31282
31283
  switch (cfg.pageTriggerType) {
31283
31284
  case "cron":
31284
31285
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -31788,11 +31789,18 @@ var HindsightClient = class {
31788
31789
  return;
31789
31790
  }
31790
31791
  if (r.status !== 409) created++;
31791
- } else if (hit.description !== page.source_query) {
31792
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
31793
+ const patch = {
31794
+ trigger: pageTrigger
31795
+ };
31796
+ if (hit.description !== page.source_query) {
31797
+ patch.source_query = page.source_query;
31798
+ patch.tags = page.tags;
31799
+ }
31792
31800
  const r = await this.req(
31793
31801
  "PATCH",
31794
31802
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
31795
- { source_query: page.source_query, tags: page.tags }
31803
+ patch
31796
31804
  );
31797
31805
  if ([404, 405, 501].includes(r.status)) {
31798
31806
  this.knowledgePagesSupported = false;
@@ -31813,10 +31821,17 @@ var HindsightClient = class {
31813
31821
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
31814
31822
  }
31815
31823
  /**
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>`.
31824
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
31825
+ * New initiative → creates a page under the Initiatives folder.
31818
31826
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
31819
31827
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
31828
+ *
31829
+ * The marker carries its page id in two places, neither of them a tag (#3641):
31830
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
31831
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
31832
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
31833
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
31834
+ * vocabulary that exists to be matched with exact set-ops.
31820
31835
  */
31821
31836
  async captureInitiative(args) {
31822
31837
  let pageId = args.relatesToPageId;
@@ -31839,20 +31854,11 @@ var HindsightClient = class {
31839
31854
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
31840
31855
  const content = `${verb}: ${args.title}. ${args.summary}`;
31841
31856
  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
- }
31857
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
31858
+ const context = `initiative marker for [[page:${pageId}]]`;
31859
+ await this.retain(content, context, markerId, tags, "document", {
31860
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
31861
+ });
31856
31862
  return { page_id: pageId };
31857
31863
  }
31858
31864
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -14833,7 +14833,7 @@ var PAGE_TAXONOMY = [
14833
14833
  },
14834
14834
  {
14835
14835
  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.",
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'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
14837
  tags: ["knowledge:feature-work"]
14838
14838
  }
14839
14839
  ];
@@ -14842,9 +14842,10 @@ function pagesFor(project) {
14842
14842
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
14843
14843
  }
14844
14844
  var PAGE_MAX_TOKENS = 4096;
14845
+ var PAGE_TAGS_MATCH = "all";
14845
14846
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
14846
14847
  function buildPageTrigger(cfg = {}) {
14847
- const base = { fact_types: PAGE_FACT_TYPES };
14848
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
14848
14849
  switch (cfg.pageTriggerType) {
14849
14850
  case "cron":
14850
14851
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -15354,11 +15355,18 @@ var HindsightClient = class {
15354
15355
  return;
15355
15356
  }
15356
15357
  if (r.status !== 409) created++;
15357
- } else if (hit.description !== page.source_query) {
15358
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
15359
+ const patch = {
15360
+ trigger: pageTrigger
15361
+ };
15362
+ if (hit.description !== page.source_query) {
15363
+ patch.source_query = page.source_query;
15364
+ patch.tags = page.tags;
15365
+ }
15358
15366
  const r = await this.req(
15359
15367
  "PATCH",
15360
15368
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
15361
- { source_query: page.source_query, tags: page.tags }
15369
+ patch
15362
15370
  );
15363
15371
  if ([404, 405, 501].includes(r.status)) {
15364
15372
  this.knowledgePagesSupported = false;
@@ -15379,10 +15387,17 @@ var HindsightClient = class {
15379
15387
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
15380
15388
  }
15381
15389
  /**
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>`.
15390
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
15391
+ * New initiative → creates a page under the Initiatives folder.
15384
15392
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
15385
15393
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
15394
+ *
15395
+ * The marker carries its page id in two places, neither of them a tag (#3641):
15396
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
15397
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
15398
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
15399
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
15400
+ * vocabulary that exists to be matched with exact set-ops.
15386
15401
  */
15387
15402
  async captureInitiative(args) {
15388
15403
  let pageId = args.relatesToPageId;
@@ -15405,20 +15420,11 @@ var HindsightClient = class {
15405
15420
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
15406
15421
  const content = `${verb}: ${args.title}. ${args.summary}`;
15407
15422
  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
- }
15423
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
15424
+ const context = `initiative marker for [[page:${pageId}]]`;
15425
+ await this.retain(content, context, markerId, tags, "document", {
15426
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
15427
+ });
15422
15428
  return { page_id: pageId };
15423
15429
  }
15424
15430
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
package/dist/status.js CHANGED
@@ -272,7 +272,7 @@ var PAGE_TAXONOMY = [
272
272
  },
273
273
  {
274
274
  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.",
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'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
276
  tags: ["knowledge:feature-work"]
277
277
  }
278
278
  ];
@@ -281,9 +281,10 @@ function pagesFor(project) {
281
281
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
282
282
  }
283
283
  var PAGE_MAX_TOKENS = 4096;
284
+ var PAGE_TAGS_MATCH = "all";
284
285
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
285
286
  function buildPageTrigger(cfg2 = {}) {
286
- const base = { fact_types: PAGE_FACT_TYPES };
287
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
287
288
  switch (cfg2.pageTriggerType) {
288
289
  case "cron":
289
290
  return { ...base, refresh_cron: cfg2.pageTriggerCron };
@@ -793,11 +794,18 @@ var HindsightClient = class {
793
794
  return;
794
795
  }
795
796
  if (r.status !== 409) created++;
796
- } else if (hit.description !== page.source_query) {
797
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
798
+ const patch = {
799
+ trigger: pageTrigger
800
+ };
801
+ if (hit.description !== page.source_query) {
802
+ patch.source_query = page.source_query;
803
+ patch.tags = page.tags;
804
+ }
797
805
  const r = await this.req(
798
806
  "PATCH",
799
807
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
800
- { source_query: page.source_query, tags: page.tags }
808
+ patch
801
809
  );
802
810
  if ([404, 405, 501].includes(r.status)) {
803
811
  this.knowledgePagesSupported = false;
@@ -818,10 +826,17 @@ var HindsightClient = class {
818
826
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
819
827
  }
820
828
  /**
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>`.
829
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
830
+ * New initiative → creates a page under the Initiatives folder.
823
831
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
824
832
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
833
+ *
834
+ * The marker carries its page id in two places, neither of them a tag (#3641):
835
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
836
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
837
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
838
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
839
+ * vocabulary that exists to be matched with exact set-ops.
825
840
  */
826
841
  async captureInitiative(args) {
827
842
  let pageId = args.relatesToPageId;
@@ -844,20 +859,11 @@ var HindsightClient = class {
844
859
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
845
860
  const content = `${verb}: ${args.title}. ${args.summary}`;
846
861
  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
- }
862
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
863
+ const context = `initiative marker for [[page:${pageId}]]`;
864
+ await this.retain(content, context, markerId, tags, "document", {
865
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
866
+ });
861
867
  return { page_id: pageId };
862
868
  }
863
869
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
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.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vectorize-io/hindsight.git",