agentsmesh 0.34.0 → 0.35.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.
@@ -304,6 +304,8 @@ interface ValidationFinding {
304
304
  readonly code: string;
305
305
  readonly message: string;
306
306
  readonly lessonId?: string;
307
+ /** Every lesson one aggregate finding covers (machine-readable; the message names a few). */
308
+ readonly lessonIds?: readonly string[];
307
309
  readonly topicId?: string;
308
310
  readonly triggerId?: string;
309
311
  }
package/dist/lessons.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as RankedLesson, j as LessonsQuery, A as AddLessonInput, a as AddLessonOptions, b as AddLessonResult } from './init-ChDbKSJ0.js';
2
- export { c as AddLessonTriggers, D as DEFAULT_RECALL_LIMIT, X as DEFAULT_RECALL_MAX_TOKENS, I as ImportLegacyOptions, d as ImportLegacyReport, Y as LESSONS_LOCK_FILENAME, L as LESSONS_PROCEDURAL_RULE, e as Lesson, f as LessonStatus, g as LessonsGraph, Z as LessonsGraphExistsError, h as LessonsGraphSchema, i as LessonsPaths, M as MatchedLesson, k as MergeLessonsOptions, l as MergeLessonsResult, m as MutateOptions, R as RankOptions, n as RankReason, S as ScaffoldLessonsResult, p as StripMarkersOptions, q as StripMarkersReport, T as Topic, r as Trigger, s as TriggerKind, U as UnknownTopicError, V as ValidationFinding, t as ValidationLevel, u as ValidationReport, v as acquireLessonsLock, w as addLesson, x as graphFilePath, y as importLegacyLessons, _ as lessonsLockPath, z as lessonsPaths, B as loadLessonsGraph, C as mergeLessons, E as mutateLessonsGraph, F as parseGraph, G as queryLessons, H as rankLessons, J as scaffoldLessons, K as serializeGraph, N as stripLegacyMarkers, O as stripMarkersInGraph, P as toRelPath, Q as tryLoadLessonsGraph, W as validateLessonsGraph } from './init-ChDbKSJ0.js';
1
+ import { o as RankedLesson, j as LessonsQuery, A as AddLessonInput, a as AddLessonOptions, b as AddLessonResult } from './init-C3pMnqoU.js';
2
+ export { c as AddLessonTriggers, D as DEFAULT_RECALL_LIMIT, X as DEFAULT_RECALL_MAX_TOKENS, I as ImportLegacyOptions, d as ImportLegacyReport, Y as LESSONS_LOCK_FILENAME, L as LESSONS_PROCEDURAL_RULE, e as Lesson, f as LessonStatus, g as LessonsGraph, Z as LessonsGraphExistsError, h as LessonsGraphSchema, i as LessonsPaths, M as MatchedLesson, k as MergeLessonsOptions, l as MergeLessonsResult, m as MutateOptions, R as RankOptions, n as RankReason, S as ScaffoldLessonsResult, p as StripMarkersOptions, q as StripMarkersReport, T as Topic, r as Trigger, s as TriggerKind, U as UnknownTopicError, V as ValidationFinding, t as ValidationLevel, u as ValidationReport, v as acquireLessonsLock, w as addLesson, x as graphFilePath, y as importLegacyLessons, _ as lessonsLockPath, z as lessonsPaths, B as loadLessonsGraph, C as mergeLessons, E as mutateLessonsGraph, F as parseGraph, G as queryLessons, H as rankLessons, J as scaffoldLessons, K as serializeGraph, N as stripLegacyMarkers, O as stripMarkersInGraph, P as toRelPath, Q as tryLoadLessonsGraph, W as validateLessonsGraph } from './init-C3pMnqoU.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
package/dist/lessons.js CHANGED
@@ -2054,11 +2054,24 @@ function sessionId(env = process.env) {
2054
2054
  function recallLogPath(projectRoot) {
2055
2055
  return join(lessonsPaths(projectRoot).base, "recall-log.jsonl");
2056
2056
  }
2057
- function isTelemetryEnabled(env = process.env) {
2058
- return env[TELEMETRY_ENV] === "1";
2057
+ function configTelemetry(projectRoot) {
2058
+ const path = lessonsPaths(projectRoot).config;
2059
+ if (!existsSync(path)) return false;
2060
+ try {
2061
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
2062
+ return typeof parsed === "object" && parsed !== null && parsed.telemetry === true;
2063
+ } catch {
2064
+ return false;
2065
+ }
2066
+ }
2067
+ function isTelemetryEnabled(env = process.env, projectRoot) {
2068
+ const raw = env[TELEMETRY_ENV];
2069
+ if (raw === "1") return true;
2070
+ if (raw === "0") return false;
2071
+ return projectRoot !== void 0 && configTelemetry(projectRoot);
2059
2072
  }
2060
2073
  function appendRecallRecord(projectRoot, record, env = process.env) {
2061
- if (!isTelemetryEnabled(env)) return;
2074
+ if (!isTelemetryEnabled(env, projectRoot)) return;
2062
2075
  appendJsonl(recallLogPath(projectRoot), record, {
2063
2076
  maxRecords: MAX_RECALL_LOG_RECORDS,
2064
2077
  trimTriggerBytes: RECALL_LOG_TRIM_TRIGGER_BYTES
@@ -2285,7 +2298,8 @@ function defaultLessonsConfig() {
2285
2298
  recallLimit: DEFAULT_RECALL_LIMIT,
2286
2299
  recallMaxTokens: DEFAULT_RECALL_MAX_TOKENS,
2287
2300
  autoPrune: false,
2288
- repairTriggers: false
2301
+ repairTriggers: false,
2302
+ telemetry: false
2289
2303
  };
2290
2304
  }
2291
2305
  function positiveInt(value) {
@@ -2506,7 +2520,7 @@ async function recallLessons(projectRoot, query, options = {}) {
2506
2520
  return { lessons, totalMatches: matches.length, suppressed: matches.length - forRank.length };
2507
2521
  }
2508
2522
  function recordRecallTelemetry(projectRoot, graph, query, matches, lessons, options = {}) {
2509
- if (!isTelemetryEnabled()) return;
2523
+ if (!isTelemetryEnabled(process.env, projectRoot)) return;
2510
2524
  const byKind = collectMatchedTriggersByKind(graph, query);
2511
2525
  const countVia = (set) => matches.filter(({ lesson }) => lesson.triggers.some((t) => set.has(t))).length;
2512
2526
  const session = options.session ?? sessionId();
@@ -2639,14 +2653,14 @@ function captureLogPath(projectRoot) {
2639
2653
  return join(lessonsPaths(projectRoot).base, "capture-log.jsonl");
2640
2654
  }
2641
2655
  function appendCaptureRecord(projectRoot, record, env = process.env) {
2642
- if (!isTelemetryEnabled(env)) return;
2656
+ if (!isTelemetryEnabled(env, projectRoot)) return;
2643
2657
  appendJsonl(captureLogPath(projectRoot), record, {
2644
2658
  maxRecords: MAX_CAPTURE_LOG_RECORDS,
2645
2659
  trimTriggerBytes: CAPTURE_LOG_TRIM_TRIGGER_BYTES
2646
2660
  });
2647
2661
  }
2648
2662
  function recordCapture(projectRoot, triggerKinds, result, env = process.env) {
2649
- if (!isTelemetryEnabled(env)) return;
2663
+ if (!isTelemetryEnabled(env, projectRoot)) return;
2650
2664
  const session = sessionId(env);
2651
2665
  appendCaptureRecord(
2652
2666
  projectRoot,
@@ -2884,7 +2898,6 @@ var RECALL_HOOK_COMMAND = "agentsmesh lessons hook";
2884
2898
  var RECALL_HOOK_TOOL_MATCHER = "Edit|Write|Bash";
2885
2899
  var RECALL_EVENTS = [
2886
2900
  { event: "PreToolUse", matcher: RECALL_HOOK_TOOL_MATCHER },
2887
- { event: "PostToolUse", matcher: RECALL_HOOK_TOOL_MATCHER },
2888
2901
  { event: "UserPromptSubmit", matcher: "*" },
2889
2902
  // Capture-on-failure nudge (see capture-nudge.ts). BEST-EFFORT: only Claude
2890
2903
  // Code's passthrough hooks emit it; whitelist targets drop it without warning
@@ -2894,6 +2907,18 @@ var RECALL_EVENTS = [
2894
2907
  // BEST-EFFORT: targets that can't represent SessionStart just keep dedup as-is.
2895
2908
  { event: "SessionStart", matcher: "*" }
2896
2909
  ];
2910
+ var RETIRED_EVENTS = ["PostToolUse"];
2911
+ function removeEvent(doc, event) {
2912
+ const existing = doc.get(event);
2913
+ if (!(existing instanceof YAMLSeq)) return false;
2914
+ const kept = existing.items.filter(
2915
+ (item) => !(item instanceof YAMLMap && item.get("command") === RECALL_HOOK_COMMAND)
2916
+ );
2917
+ if (kept.length === existing.items.length) return false;
2918
+ if (kept.length === 0) doc.delete(event);
2919
+ else existing.items = kept;
2920
+ return true;
2921
+ }
2897
2922
  function injectEvent(doc, event, matcher) {
2898
2923
  const existing = doc.get(event);
2899
2924
  const seq = existing instanceof YAMLSeq ? existing : new YAMLSeq();
@@ -2913,6 +2938,9 @@ function injectRecallHook(projectRoot) {
2913
2938
  for (const { event, matcher } of RECALL_EVENTS) {
2914
2939
  if (injectEvent(doc, event, matcher)) changed = true;
2915
2940
  }
2941
+ for (const event of RETIRED_EVENTS) {
2942
+ if (removeEvent(doc, event)) changed = true;
2943
+ }
2916
2944
  if (changed) writeFileSync(path, String(doc), "utf8");
2917
2945
  return changed;
2918
2946
  }