agentsmesh 0.30.2 → 0.32.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.
@@ -73,6 +73,79 @@ type TriggerKind = z.infer<typeof TriggerKindSchema>;
73
73
  type LessonStatus = z.infer<typeof LessonStatusSchema>;
74
74
  declare function parseGraph(raw: unknown): LessonsGraph;
75
75
 
76
+ interface LessonsQuery {
77
+ /** Project-relative path of the file about to be edited. */
78
+ readonly file?: string;
79
+ /** Shell command about to be executed. */
80
+ readonly command?: string;
81
+ /** Free-form text describing the current task. */
82
+ readonly keyword?: string;
83
+ }
84
+ interface MatchedLesson {
85
+ readonly id: string;
86
+ readonly lesson: Lesson;
87
+ }
88
+ /**
89
+ * Recall primitive — returns every active lesson whose triggers match any of
90
+ * the supplied query fields. The query fields combine as OR across triggers:
91
+ * a lesson matches if ANY of its triggers match ANY supplied field.
92
+ * Deprecated and superseded lessons are excluded.
93
+ */
94
+ declare function queryLessons(graph: LessonsGraph, query: LessonsQuery): MatchedLesson[];
95
+
96
+ interface RankReason {
97
+ readonly matchedTriggers: string[];
98
+ readonly bm25: number;
99
+ readonly specificity: number;
100
+ readonly topicCoherence: number;
101
+ }
102
+ interface RankedLesson {
103
+ readonly id: string;
104
+ readonly lesson: Lesson;
105
+ readonly score: number;
106
+ readonly reason: RankReason;
107
+ }
108
+ interface RankOptions {
109
+ /** Keep at most this many results (after ranking). */
110
+ readonly limit?: number;
111
+ /**
112
+ * Best-effort token budget: keep results while their cumulative estimated
113
+ * rule-token cost fits. The single most-relevant result is ALWAYS returned
114
+ * even if it alone exceeds the budget — an empty recall for a matched query is
115
+ * worse for the agent than one slightly-over-budget rule.
116
+ */
117
+ readonly maxTokens?: number;
118
+ /**
119
+ * Per-lesson effectiveness score in [0,1] from the outcome log (1 = always
120
+ * helped; absent = neutral). Fed as a LOW-weight RRF signal so a proven
121
+ * fire-but-fail lesson sinks below an equally-matched effective one — a
122
+ * corrective nudge, never a driver. Empty/absent ⇒ every lesson ties on this
123
+ * signal ⇒ ordering is unchanged from the pre-effectiveness ranker.
124
+ */
125
+ readonly effectiveness?: ReadonlyMap<string, number>;
126
+ }
127
+ /** Default recall cap: a broad trigger match returns the most-relevant few, not the whole topic. */
128
+ declare const DEFAULT_RECALL_LIMIT = 10;
129
+ /**
130
+ * Default recall token budget applied by the application APIs (CLI `query`, MCP
131
+ * `lessons_query`, {@link recallLessons}) when the caller does not specify one.
132
+ * Mandatory recall runs before every edit/command, so its payload must stay
133
+ * lean; without a budget a broad match can return ~450+ rule-tokens. `--all`
134
+ * (CLI) bypasses both caps. The top result is always kept (see RankOptions).
135
+ */
136
+ declare const DEFAULT_RECALL_MAX_TOKENS = 400;
137
+ /**
138
+ * Rank matched lessons by relevance and apply optional caps. Three lightweight
139
+ * signals are weighted-reciprocal-rank-fused (RRF): trigger specificity (inverse
140
+ * fanout — a discriminating trigger beats a topic-wide one; highest weight),
141
+ * per-query topic coherence (a lesson in the topic that dominates this query's
142
+ * matched set is boosted; middle weight), and BM25 over the rule text (so the
143
+ * lesson whose wording best fits breaks ties the structural signals cannot;
144
+ * lowest weight). Ties break by recency (createdAt) then id. No embeddings, no
145
+ * I/O — pure and sub-millisecond.
146
+ */
147
+ declare function rankLessons(graph: LessonsGraph, query: LessonsQuery, matches: readonly MatchedLesson[], options?: RankOptions): RankedLesson[];
148
+
76
149
  interface AutoPruneSummary {
77
150
  readonly removedTriggers: number;
78
151
  readonly removedTopics: number;
@@ -93,7 +166,7 @@ interface AutoPruneSummary {
93
166
  * because that lesson is captured then silently never recalled. These guardrails
94
167
  * are the warn-only complement to that single hard block.
95
168
  */
96
- type GuardrailCode = 'OVERSIZED_LESSON_TRIGGERS' | 'BROAD_GLOB_TRIGGER' | 'WIDE_GLOB_MATCH' | 'KEYWORD_ONLY_LESSON' | 'LOW_SIGNAL_KEYWORD' | 'STOPWORD_KEYWORD' | 'DEAD_GLOB' | 'NEAR_DUPLICATE_LESSON';
169
+ type GuardrailCode = 'OVERSIZED_LESSON_TRIGGERS' | 'BROAD_GLOB_TRIGGER' | 'WIDE_GLOB_MATCH' | 'KEYWORD_ONLY_LESSON' | 'LOW_SIGNAL_KEYWORD' | 'STOPWORD_KEYWORD' | 'DEAD_GLOB' | 'NEAR_DUPLICATE_LESSON' | 'NARROWED_GLOB' | 'KEYWORD_VARIANT_ADDED' | 'DROPPED_KEYWORD';
97
170
  interface GuardrailWarning {
98
171
  readonly code: GuardrailCode;
99
172
  readonly message: string;
@@ -159,79 +232,6 @@ interface AddLessonResult {
159
232
  }
160
233
  declare function addLesson(projectRoot: string, input: AddLessonInput, options?: AddLessonOptions): Promise<AddLessonResult>;
161
234
 
162
- interface LessonsQuery {
163
- /** Project-relative path of the file about to be edited. */
164
- readonly file?: string;
165
- /** Shell command about to be executed. */
166
- readonly command?: string;
167
- /** Free-form text describing the current task. */
168
- readonly keyword?: string;
169
- }
170
- interface MatchedLesson {
171
- readonly id: string;
172
- readonly lesson: Lesson;
173
- }
174
- /**
175
- * Recall primitive — returns every active lesson whose triggers match any of
176
- * the supplied query fields. The query fields combine as OR across triggers:
177
- * a lesson matches if ANY of its triggers match ANY supplied field.
178
- * Deprecated and superseded lessons are excluded.
179
- */
180
- declare function queryLessons(graph: LessonsGraph, query: LessonsQuery): MatchedLesson[];
181
-
182
- interface RankReason {
183
- readonly matchedTriggers: string[];
184
- readonly bm25: number;
185
- readonly specificity: number;
186
- readonly topicCoherence: number;
187
- }
188
- interface RankedLesson {
189
- readonly id: string;
190
- readonly lesson: Lesson;
191
- readonly score: number;
192
- readonly reason: RankReason;
193
- }
194
- interface RankOptions {
195
- /** Keep at most this many results (after ranking). */
196
- readonly limit?: number;
197
- /**
198
- * Best-effort token budget: keep results while their cumulative estimated
199
- * rule-token cost fits. The single most-relevant result is ALWAYS returned
200
- * even if it alone exceeds the budget — an empty recall for a matched query is
201
- * worse for the agent than one slightly-over-budget rule.
202
- */
203
- readonly maxTokens?: number;
204
- /**
205
- * Per-lesson effectiveness score in [0,1] from the outcome log (1 = always
206
- * helped; absent = neutral). Fed as a LOW-weight RRF signal so a proven
207
- * fire-but-fail lesson sinks below an equally-matched effective one — a
208
- * corrective nudge, never a driver. Empty/absent ⇒ every lesson ties on this
209
- * signal ⇒ ordering is unchanged from the pre-effectiveness ranker.
210
- */
211
- readonly effectiveness?: ReadonlyMap<string, number>;
212
- }
213
- /** Default recall cap: a broad trigger match returns the most-relevant few, not the whole topic. */
214
- declare const DEFAULT_RECALL_LIMIT = 10;
215
- /**
216
- * Default recall token budget applied by the application APIs (CLI `query`, MCP
217
- * `lessons_query`, {@link recallLessons}) when the caller does not specify one.
218
- * Mandatory recall runs before every edit/command, so its payload must stay
219
- * lean; without a budget a broad match can return ~450+ rule-tokens. `--all`
220
- * (CLI) bypasses both caps. The top result is always kept (see RankOptions).
221
- */
222
- declare const DEFAULT_RECALL_MAX_TOKENS = 400;
223
- /**
224
- * Rank matched lessons by relevance and apply optional caps. Three lightweight
225
- * signals are weighted-reciprocal-rank-fused (RRF): trigger specificity (inverse
226
- * fanout — a discriminating trigger beats a topic-wide one; highest weight),
227
- * per-query topic coherence (a lesson in the topic that dominates this query's
228
- * matched set is boosted; middle weight), and BM25 over the rule text (so the
229
- * lesson whose wording best fits breaks ties the structural signals cannot;
230
- * lowest weight). Ties break by recency (createdAt) then id. No embeddings, no
231
- * I/O — pure and sub-millisecond.
232
- */
233
- declare function rankLessons(graph: LessonsGraph, query: LessonsQuery, matches: readonly MatchedLesson[], options?: RankOptions): RankedLesson[];
234
-
235
235
  interface MutateOptions {
236
236
  readonly retries?: number;
237
237
  }
package/dist/lessons.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { o as RankedLesson, A as AddLessonInput, a as AddLessonOptions, b as AddLessonResult, j as LessonsQuery } from './init-PvpXanVd.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-PvpXanVd.js';
1
+ import { o as RankedLesson, j as LessonsQuery, A as AddLessonInput, a as AddLessonOptions, b as AddLessonResult } from './init-CrZhoNTj.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-CrZhoNTj.js';
3
3
  import 'zod';
4
4
 
5
5
  /**
@@ -15,8 +15,9 @@ import 'zod';
15
15
  * The low-level READ primitives (`tryLoadLessonsGraph`, `loadLessonsGraph`,
16
16
  * `queryLessons`) do NOT migrate — a first read through them on a legacy project
17
17
  * would see no graph. `recallLessons` closes that: it migrates first, then
18
- * loads + ranks. `captureLesson` is the symmetric capture entry point. Prefer
19
- * these application APIs; reach for the read primitives only post-migration.
18
+ * loads + ranks. `captureLesson` (capture.ts) is the symmetric capture entry
19
+ * point. Prefer these application APIs; reach for the read primitives only
20
+ * post-migration.
20
21
  */
21
22
  interface RecallOptions {
22
23
  /** Max ranked lessons to return. Defaults to {@link DEFAULT_RECALL_LIMIT}. */
@@ -62,9 +63,12 @@ interface RecallResult {
62
63
  * lessons matching `query`, relevance-ranked and capped by limit + token budget.
63
64
  */
64
65
  declare function recallLessons(projectRoot: string, query: LessonsQuery, options?: RecallOptions): Promise<RecallResult>;
66
+
65
67
  /**
66
68
  * Capture primitive for applications: migrate if needed, then add the lesson
67
69
  * through the transactional write path. Idempotent on repeat (same rule+topic).
70
+ * The symmetric counterpart of `recallLessons` (recall.ts), split out for the
71
+ * 200-line limit.
68
72
  *
69
73
  * Both CLI `lessons add` and MCP `lessons_add` route through here, so capture
70
74
  * telemetry is recorded once at this single entry point (mirroring how every