@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.
@@ -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/deepen.js CHANGED
@@ -237,7 +237,7 @@ var PAGE_TAXONOMY = [
237
237
  },
238
238
  {
239
239
  name: "Initiatives and enhancements",
240
- 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.",
240
+ 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.",
241
241
  tags: ["knowledge:feature-work"]
242
242
  }
243
243
  ];
@@ -246,9 +246,10 @@ function pagesFor(project) {
246
246
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
247
247
  }
248
248
  var PAGE_MAX_TOKENS = 4096;
249
+ var PAGE_TAGS_MATCH = "all";
249
250
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
250
251
  function buildPageTrigger(cfg2 = {}) {
251
- const base = { fact_types: PAGE_FACT_TYPES };
252
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
252
253
  switch (cfg2.pageTriggerType) {
253
254
  case "cron":
254
255
  return { ...base, refresh_cron: cfg2.pageTriggerCron };
@@ -758,11 +759,18 @@ var HindsightClient = class {
758
759
  return;
759
760
  }
760
761
  if (r.status !== 409) created++;
761
- } else if (hit.description !== page.source_query) {
762
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
763
+ const patch = {
764
+ trigger: pageTrigger
765
+ };
766
+ if (hit.description !== page.source_query) {
767
+ patch.source_query = page.source_query;
768
+ patch.tags = page.tags;
769
+ }
762
770
  const r = await this.req(
763
771
  "PATCH",
764
772
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
765
- { source_query: page.source_query, tags: page.tags }
773
+ patch
766
774
  );
767
775
  if ([404, 405, 501].includes(r.status)) {
768
776
  this.knowledgePagesSupported = false;
@@ -783,10 +791,17 @@ var HindsightClient = class {
783
791
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
784
792
  }
785
793
  /**
786
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
787
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
794
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
795
+ * New initiative → creates a page under the Initiatives folder.
788
796
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
789
797
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
798
+ *
799
+ * The marker carries its page id in two places, neither of them a tag (#3641):
800
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
801
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
802
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
803
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
804
+ * vocabulary that exists to be matched with exact set-ops.
790
805
  */
791
806
  async captureInitiative(args) {
792
807
  let pageId = args.relatesToPageId;
@@ -809,20 +824,11 @@ var HindsightClient = class {
809
824
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
810
825
  const content = `${verb}: ${args.title}. ${args.summary}`;
811
826
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
812
- const tags = [
813
- .../* @__PURE__ */ new Set([
814
- ...args.stamp?.tags ?? [],
815
- "knowledge:feature-work",
816
- `relatedPageId:${pageId}`
817
- ])
818
- ];
819
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
820
- await this.retain(content, "initiative marker", markerId, tags, "document", {
821
- metadata: args.stamp?.metadata
822
- });
823
- } else {
824
- await this.retain(content, "initiative marker", markerId, tags, "document");
825
- }
827
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
828
+ const context = `initiative marker for [[page:${pageId}]]`;
829
+ await this.retain(content, context, markerId, tags, "document", {
830
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
831
+ });
826
832
  return { page_id: pageId };
827
833
  }
828
834
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -315,7 +315,7 @@ var PAGE_TAXONOMY = [
315
315
  },
316
316
  {
317
317
  name: "Initiatives and enhancements",
318
- 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.",
318
+ 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.",
319
319
  tags: ["knowledge:feature-work"]
320
320
  }
321
321
  ];
@@ -324,9 +324,10 @@ function pagesFor(project) {
324
324
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
325
325
  }
326
326
  var PAGE_MAX_TOKENS = 4096;
327
+ var PAGE_TAGS_MATCH = "all";
327
328
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
328
329
  function buildPageTrigger(cfg = {}) {
329
- const base = { fact_types: PAGE_FACT_TYPES };
330
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
330
331
  switch (cfg.pageTriggerType) {
331
332
  case "cron":
332
333
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -836,11 +837,18 @@ var HindsightClient = class {
836
837
  return;
837
838
  }
838
839
  if (r.status !== 409) created++;
839
- } else if (hit.description !== page.source_query) {
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) {
845
+ patch.source_query = page.source_query;
846
+ patch.tags = page.tags;
847
+ }
840
848
  const r = await this.req(
841
849
  "PATCH",
842
850
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
843
- { source_query: page.source_query, tags: page.tags }
851
+ patch
844
852
  );
845
853
  if ([404, 405, 501].includes(r.status)) {
846
854
  this.knowledgePagesSupported = false;
@@ -861,10 +869,17 @@ var HindsightClient = class {
861
869
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
862
870
  }
863
871
  /**
864
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
865
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
872
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
873
+ * New initiative → creates a page under the Initiatives folder.
866
874
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
867
875
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
876
+ *
877
+ * The marker carries its page id in two places, neither of them a tag (#3641):
878
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
879
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
880
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
881
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
882
+ * vocabulary that exists to be matched with exact set-ops.
868
883
  */
869
884
  async captureInitiative(args) {
870
885
  let pageId = args.relatesToPageId;
@@ -887,20 +902,11 @@ var HindsightClient = class {
887
902
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
888
903
  const content = `${verb}: ${args.title}. ${args.summary}`;
889
904
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
890
- const tags = [
891
- .../* @__PURE__ */ new Set([
892
- ...args.stamp?.tags ?? [],
893
- "knowledge:feature-work",
894
- `relatedPageId:${pageId}`
895
- ])
896
- ];
897
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
898
- await this.retain(content, "initiative marker", markerId, tags, "document", {
899
- metadata: args.stamp?.metadata
900
- });
901
- } else {
902
- await this.retain(content, "initiative marker", markerId, tags, "document");
903
- }
905
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
906
+ const context = `initiative marker for [[page:${pageId}]]`;
907
+ await this.retain(content, context, markerId, tags, "document", {
908
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
909
+ });
904
910
  return { page_id: pageId };
905
911
  }
906
912
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */
@@ -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/dsh.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/grok-hook.js CHANGED
@@ -315,7 +315,7 @@ var PAGE_TAXONOMY = [
315
315
  },
316
316
  {
317
317
  name: "Initiatives and enhancements",
318
- 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.",
318
+ 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.",
319
319
  tags: ["knowledge:feature-work"]
320
320
  }
321
321
  ];
@@ -324,9 +324,10 @@ function pagesFor(project) {
324
324
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
325
325
  }
326
326
  var PAGE_MAX_TOKENS = 4096;
327
+ var PAGE_TAGS_MATCH = "all";
327
328
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
328
329
  function buildPageTrigger(cfg = {}) {
329
- const base = { fact_types: PAGE_FACT_TYPES };
330
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
330
331
  switch (cfg.pageTriggerType) {
331
332
  case "cron":
332
333
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -836,11 +837,18 @@ var HindsightClient = class {
836
837
  return;
837
838
  }
838
839
  if (r.status !== 409) created++;
839
- } else if (hit.description !== page.source_query) {
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) {
845
+ patch.source_query = page.source_query;
846
+ patch.tags = page.tags;
847
+ }
840
848
  const r = await this.req(
841
849
  "PATCH",
842
850
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
843
- { source_query: page.source_query, tags: page.tags }
851
+ patch
844
852
  );
845
853
  if ([404, 405, 501].includes(r.status)) {
846
854
  this.knowledgePagesSupported = false;
@@ -861,10 +869,17 @@ var HindsightClient = class {
861
869
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
862
870
  }
863
871
  /**
864
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
865
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
872
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
873
+ * New initiative → creates a page under the Initiatives folder.
866
874
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
867
875
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
876
+ *
877
+ * The marker carries its page id in two places, neither of them a tag (#3641):
878
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
879
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
880
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
881
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
882
+ * vocabulary that exists to be matched with exact set-ops.
868
883
  */
869
884
  async captureInitiative(args) {
870
885
  let pageId = args.relatesToPageId;
@@ -887,20 +902,11 @@ var HindsightClient = class {
887
902
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
888
903
  const content = `${verb}: ${args.title}. ${args.summary}`;
889
904
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
890
- const tags = [
891
- .../* @__PURE__ */ new Set([
892
- ...args.stamp?.tags ?? [],
893
- "knowledge:feature-work",
894
- `relatedPageId:${pageId}`
895
- ])
896
- ];
897
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
898
- await this.retain(content, "initiative marker", markerId, tags, "document", {
899
- metadata: args.stamp?.metadata
900
- });
901
- } else {
902
- await this.retain(content, "initiative marker", markerId, tags, "document");
903
- }
905
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
906
+ const context = `initiative marker for [[page:${pageId}]]`;
907
+ await this.retain(content, context, markerId, tags, "document", {
908
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
909
+ });
904
910
  return { page_id: pageId };
905
911
  }
906
912
  /** Find a root folder by name (case-insensitive) or create it; returns its id. Fail-open to undefined. */