agentsmesh 0.26.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/lessons.js CHANGED
@@ -2401,23 +2401,31 @@ async function stripMarkersInGraph(projectRoot, options = {}) {
2401
2401
  }
2402
2402
  var RECALL_HOOK_COMMAND = "agentsmesh lessons hook";
2403
2403
  var RECALL_HOOK_MATCHER = "Edit|Write|Bash";
2404
- function injectRecallHook(projectRoot) {
2405
- const path = join(projectRoot, ".agentsmesh", "hooks.yaml");
2406
- if (!existsSync(path)) return false;
2407
- const doc = parseDocument(readFileSync(path, "utf8"));
2408
- const existing = doc.get("PostToolUse");
2409
- const post = existing instanceof YAMLSeq ? existing : new YAMLSeq();
2410
- const present = post.items.some(
2404
+ var RECALL_EVENTS = ["PreToolUse", "PostToolUse"];
2405
+ function injectEvent(doc, event) {
2406
+ const existing = doc.get(event);
2407
+ const seq = existing instanceof YAMLSeq ? existing : new YAMLSeq();
2408
+ const present = seq.items.some(
2411
2409
  (item) => item instanceof YAMLMap && item.get("command") === RECALL_HOOK_COMMAND
2412
2410
  );
2413
2411
  if (present) return false;
2414
- post.add(
2412
+ seq.add(
2415
2413
  doc.createNode({ matcher: RECALL_HOOK_MATCHER, type: "command", command: RECALL_HOOK_COMMAND })
2416
2414
  );
2417
- doc.set("PostToolUse", post);
2418
- writeFileSync(path, String(doc), "utf8");
2415
+ doc.set(event, seq);
2419
2416
  return true;
2420
2417
  }
2418
+ function injectRecallHook(projectRoot) {
2419
+ const path = join(projectRoot, ".agentsmesh", "hooks.yaml");
2420
+ if (!existsSync(path)) return false;
2421
+ const doc = parseDocument(readFileSync(path, "utf8"));
2422
+ let changed = false;
2423
+ for (const event of RECALL_EVENTS) {
2424
+ if (injectEvent(doc, event)) changed = true;
2425
+ }
2426
+ if (changed) writeFileSync(path, String(doc), "utf8");
2427
+ return changed;
2428
+ }
2421
2429
  var UTF8_BOM = "\uFEFF";
2422
2430
  var TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
2423
2431
  ".md",