@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.
@@ -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. */
@@ -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. */
@@ -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/cline.js CHANGED
@@ -319,7 +319,7 @@ var PAGE_TAXONOMY = [
319
319
  },
320
320
  {
321
321
  name: "Initiatives and enhancements",
322
- 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.",
322
+ 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.",
323
323
  tags: ["knowledge:feature-work"]
324
324
  }
325
325
  ];
@@ -328,9 +328,10 @@ function pagesFor(project) {
328
328
  return PAGE_TAXONOMY.map((page) => ({ ...page, source_query: page.source_query + scope }));
329
329
  }
330
330
  var PAGE_MAX_TOKENS = 4096;
331
+ var PAGE_TAGS_MATCH = "all";
331
332
  var PAGE_FACT_TYPES = ["world", "experience", "observation"];
332
333
  function buildPageTrigger(cfg = {}) {
333
- const base = { fact_types: PAGE_FACT_TYPES };
334
+ const base = { fact_types: PAGE_FACT_TYPES, tags_match: PAGE_TAGS_MATCH };
334
335
  switch (cfg.pageTriggerType) {
335
336
  case "cron":
336
337
  return { ...base, refresh_cron: cfg.pageTriggerCron };
@@ -840,11 +841,18 @@ var HindsightClient = class {
840
841
  return;
841
842
  }
842
843
  if (r.status !== 409) created++;
843
- } else if (hit.description !== page.source_query) {
844
+ } else if (hit.description !== page.source_query || hit.trigger?.tags_match !== pageTrigger.tags_match) {
845
+ const patch = {
846
+ trigger: pageTrigger
847
+ };
848
+ if (hit.description !== page.source_query) {
849
+ patch.source_query = page.source_query;
850
+ patch.tags = page.tags;
851
+ }
844
852
  const r = await this.req(
845
853
  "PATCH",
846
854
  this.bankUrl(`/knowledge-base/nodes/${encodeURIComponent(hit.id)}`),
847
- { source_query: page.source_query, tags: page.tags }
855
+ patch
848
856
  );
849
857
  if ([404, 405, 501].includes(r.status)) {
850
858
  this.knowledgePagesSupported = false;
@@ -865,10 +873,17 @@ var HindsightClient = class {
865
873
  return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 60) || "initiative";
866
874
  }
867
875
  /**
868
- * Active-path capture: register a major feature as a per-initiative page + a tagged marker memory.
869
- * New initiative → creates a page under the Initiatives folder tagged `relatedPageId:<pageId>`.
876
+ * Active-path capture: register a major feature as a per-initiative page + a marker memory.
877
+ * New initiative → creates a page under the Initiatives folder.
870
878
  * Update (relatesToPageId) → no new page; only a marker accruing to the existing page, so an
871
879
  * enhancement or a mid-work plan change lands on the initiative it belongs to.
880
+ *
881
+ * The marker carries its page id in two places, neither of them a tag (#3641):
882
+ * `metadata.relatedPageId` for provenance (visible on the document, and to a reflect loop that
883
+ * expands one), and a `[[page:<id>]]` link in the retain CONTEXT, which is the only one of the
884
+ * three channels a page synthesis actually reads — reflect's search results keep `context` and
885
+ * `tags` but strip `metadata` (`_UNREAD_RESULT_FIELDS`), and the id has no business in a tag
886
+ * vocabulary that exists to be matched with exact set-ops.
872
887
  */
873
888
  async captureInitiative(args) {
874
889
  let pageId = args.relatesToPageId;
@@ -891,20 +906,11 @@ var HindsightClient = class {
891
906
  const verb = args.relatesToPageId ? "Update to an existing initiative" : "New initiative";
892
907
  const content = `${verb}: ${args.title}. ${args.summary}`;
893
908
  const markerId = `initiative-marker-${this.slugify(args.title)}-${Date.now()}`;
894
- const tags = [
895
- .../* @__PURE__ */ new Set([
896
- ...args.stamp?.tags ?? [],
897
- "knowledge:feature-work",
898
- `relatedPageId:${pageId}`
899
- ])
900
- ];
901
- if (Object.keys(args.stamp?.metadata ?? {}).length) {
902
- await this.retain(content, "initiative marker", markerId, tags, "document", {
903
- metadata: args.stamp?.metadata
904
- });
905
- } else {
906
- await this.retain(content, "initiative marker", markerId, tags, "document");
907
- }
909
+ const tags = [.../* @__PURE__ */ new Set([...args.stamp?.tags ?? [], "knowledge:feature-work"])];
910
+ const context = `initiative marker for [[page:${pageId}]]`;
911
+ await this.retain(content, context, markerId, tags, "document", {
912
+ metadata: { ...args.stamp?.metadata ?? {}, relatedPageId: pageId }
913
+ });
908
914
  return { page_id: pageId };
909
915
  }
910
916
  /** 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. */