agentsmesh 0.27.0 → 0.28.0

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.
package/dist/index.js CHANGED
@@ -26702,23 +26702,31 @@ async function stripMarkersInGraph(projectRoot, options = {}) {
26702
26702
  }
26703
26703
  var RECALL_HOOK_COMMAND = "agentsmesh lessons hook";
26704
26704
  var RECALL_HOOK_MATCHER = "Edit|Write|Bash";
26705
- function injectRecallHook(projectRoot) {
26706
- const path = join(projectRoot, ".agentsmesh", "hooks.yaml");
26707
- if (!existsSync(path)) return false;
26708
- const doc = parseDocument(readFileSync(path, "utf8"));
26709
- const existing = doc.get("PostToolUse");
26710
- const post = existing instanceof YAMLSeq ? existing : new YAMLSeq();
26711
- const present = post.items.some(
26705
+ var RECALL_EVENTS = ["PreToolUse", "PostToolUse"];
26706
+ function injectEvent(doc, event) {
26707
+ const existing = doc.get(event);
26708
+ const seq = existing instanceof YAMLSeq ? existing : new YAMLSeq();
26709
+ const present = seq.items.some(
26712
26710
  (item) => item instanceof YAMLMap && item.get("command") === RECALL_HOOK_COMMAND
26713
26711
  );
26714
26712
  if (present) return false;
26715
- post.add(
26713
+ seq.add(
26716
26714
  doc.createNode({ matcher: RECALL_HOOK_MATCHER, type: "command", command: RECALL_HOOK_COMMAND })
26717
26715
  );
26718
- doc.set("PostToolUse", post);
26719
- writeFileSync(path, String(doc), "utf8");
26716
+ doc.set(event, seq);
26720
26717
  return true;
26721
26718
  }
26719
+ function injectRecallHook(projectRoot) {
26720
+ const path = join(projectRoot, ".agentsmesh", "hooks.yaml");
26721
+ if (!existsSync(path)) return false;
26722
+ const doc = parseDocument(readFileSync(path, "utf8"));
26723
+ let changed = false;
26724
+ for (const event of RECALL_EVENTS) {
26725
+ if (injectEvent(doc, event)) changed = true;
26726
+ }
26727
+ if (changed) writeFileSync(path, String(doc), "utf8");
26728
+ return changed;
26729
+ }
26722
26730
 
26723
26731
  // src/utils/filesystem/gitignore.ts
26724
26732
  init_fs();