skill-autoroute 0.7.0 → 0.9.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/README.md CHANGED
@@ -58,6 +58,25 @@ The hook remembers which skills it already named in a session (in `~/.config/ski
58
58
  after 7 days). A later prompt, or a resumed round of a headless run (`claude -p --resume`), does not hint them again.
59
59
  `suggest` always answers and adds what it names to that memory.
60
60
 
61
+ **Machine-readable mode.** For a loop that knows its task as data, pass a JSON file (or `-` for stdin):
62
+
63
+ ```bash
64
+ echo '{"schema_version":1,"session_id":"s1","stage":"build","task":{"title":"write the orders migration","tags":["db"]},"policy":{"max_skills":2,"skip":["x"]}}' \
65
+ | node ~/.config/skill-autoroute/route.mjs claude suggest --json --context-file -
66
+ ```
67
+
68
+ Input: `schema_version` must be `1`; `session_id`, `stage`, `role`, `task.{title,summary,tags}` and `policy.{max_skills (1 to 3), skip}` are optional.
69
+ The file is at most 20000 characters. Stage, role, title, summary and tags are joined into the match text. Every string is data: it is matched
70
+ against trigger patterns and never run. Output is one JSON line, always exit 0, and no model is called:
71
+
72
+ ```json
73
+ {"schema_version":1,"status":"ok","selected":[{"id":"skill","path":"/.../SKILL.md","scope":"global","reason_code":"pattern"}],"suppressed":[{"id":"x","reason_code":"skip_list"}],"routing_version":"1a2b3c4d5e6f","duration_ms":3}
74
+ ```
75
+
76
+ `status` is `ok`, `no_match` (`selected` is empty) or `error` (`{"schema_version":1,"status":"error","error":"bad_schema_version"}`; codes: `bad_args`, `unreadable`, `too_large`, `bad_json`, `not_object`, `bad_schema_version`).
77
+ `reason_code` is `own_words` (the skill's own trigger words) or `pattern`; `scope` is `project` for a skill limited to project folders. `suppressed` lists matching skills left out as `seen_in_session`, `skip_list` or `duplicate_name`.
78
+ SKILL.md contents are never returned. On `ok`, the selected names go into the session memory like text-mode `suggest`.
79
+
61
80
  ---
62
81
 
63
82
  ## Quick start
@@ -272,7 +291,7 @@ npx skill-autoroute install --model triggers=haiku
272
291
  | `install` | The full setup flow |
273
292
  | `regenerate` | Update triggers for new or changed skills, or for all skills after an update that changes how triggers are written. Keeps your choices. |
274
293
  | `scan` | Scan and find duplicates only. Writes nothing. |
275
- | `list` | Show skills, on/off state, tools, priority, paths and trigger rules. Supports `--tools` and `--project`. Writes nothing. |
294
+ | `list [<skill>]` | Show a compact routing table, or one skill's paths, priority and numbered trigger rules. Supports `--tools` and `--project`. Writes nothing. |
276
295
  | `set <skill> on|off` | Turn one skill's hints on or off |
277
296
  | `words [<skill> [add|remove <word>...]]` | Your own trigger words for a skill. Without a skill, lists all of them. |
278
297
  | `status` | Tools, hook state, skill counts, changed skills |
@@ -292,10 +311,31 @@ Inspect the saved routing configuration:
292
311
  npx skill-autoroute list
293
312
  npx skill-autoroute list --tools codex
294
313
  npx skill-autoroute list --project
314
+ npx skill-autoroute list security-review
295
315
  ```
296
316
 
297
317
  `list` reads the user table by default; `--project` reads only the current project's table.
298
- It includes disabled skills (marked `off`). Patterns within a rule must all match (AND);
318
+ The summary groups skills by family, with aligned names, on/off state, tools and rule counts.
319
+ Families come from plugin metadata, namespaced names, plugin paths, or the Caveman, Expo, Foreman,
320
+ Superpowers and Vercel name prefixes. Other entries appear under `OTHER SKILLS`.
321
+ Families and their skills are sorted alphabetically, with `OTHER SKILLS` last.
322
+
323
+ Example layout (your skills and rule counts may differ):
324
+
325
+ ```text
326
+ EXPO
327
+ SKILL STATUS TOOLS RULES
328
+ expo-native-ui on codex 4
329
+ expo-upgrade on codex 4
330
+
331
+ VERCEL
332
+ SKILL STATUS TOOLS RULES
333
+ vercel-composition-patterns on codex 4
334
+ vercel-optimize on codex 3
335
+ ```
336
+
337
+ Use `list <skill>` for paths, priority, custom words and numbered rules; long lines wrap to fit the terminal.
338
+ Both views include disabled skills (marked `off`). Patterns within a rule must all match (AND);
299
339
  any rule can trigger the skill (OR). Custom words are another way to match.
300
340
  Enabled means eligible for routing on matching prompts, not that the agent has invoked the skill.
301
341
 
@@ -319,7 +359,7 @@ Paths are stored relative to the project, and entries that point outside the pro
319
359
  - Project tables can arrive with a clone, so the hook re-checks them. It skips risky patterns and entries outside the
320
360
  project, and it cleans skill names.
321
361
  - It reads at most 20,000 characters of the prompt.
322
- - `SKILL_AUTOROUTE_DISABLE=1` turns it off. `SKILL_AUTOROUTE_DEBUG=1` prints errors.
362
+ - `SKILL_AUTOROUTE_DISABLE=1` turns it off. `SKILL_AUTOROUTE_DEBUG=1` prints errors. `SKILL_AUTOROUTE_RANK=score` ranks hints by score (own words, rules that fit, pattern specificity) instead of the static priority number. Opt-in: on a synthetic corpus it raised precision@1, but on a hand-labeled set of real skills it made no difference.
323
363
 
324
364
  </details>
325
365
 
package/bin/cli.js CHANGED
@@ -6,7 +6,7 @@ import * as flow from '../src/flow.js';
6
6
  import { STEP_DEFAULTS } from '../src/models.js';
7
7
 
8
8
  const USAGE = `usage: skill-autoroute <command> [flags]
9
- commands: install | regenerate | scan | list | set <skill> on|off | words [<skill> [add|remove <word>...]] | status | tokens | bench | uninstall
9
+ commands: install | regenerate | scan | list [<skill>] | set <skill> on|off | words [<skill> [add|remove <word>...]] | status | tokens | bench | uninstall
10
10
  flags: --yes --dry-run --project --tools claude,codex --ai claude|codex|none --model step=model (repeatable) --log`;
11
11
 
12
12
  const COMMANDS = {
package/hook/route.js CHANGED
@@ -4,6 +4,7 @@ import { readFileSync, statSync, readdirSync, realpathSync, appendFileSync, mkdi
4
4
  import { join, dirname, resolve, sep } from 'node:path';
5
5
  import { homedir } from 'node:os';
6
6
  import { pathToFileURL } from 'node:url';
7
+ import { createRequire } from 'node:module';
7
8
 
8
9
  const MAX_PROMPT = 20000; // defence in depth against a slow pattern
9
10
  const MAX_HINTS = 3;
@@ -109,18 +110,31 @@ const compile = (src) => {
109
110
  try { return new RegExp(src, 'i'); } catch { return null; }
110
111
  };
111
112
 
112
- // A rule fits when all its patterns match; a rule with a skipped pattern never fits.
113
- function fits(rules, text) {
114
- if (!Array.isArray(rules)) return false;
115
- return rules.some((rule) => {
116
- if (!Array.isArray(rule) || !rule.length) return false;
113
+ // A rule fits when all its patterns match; a rule with a skipped pattern never fits. Returns null, or
114
+ // { rules, pats, chars } for the fitting rules (pats/chars: the best rule's pattern count and matched characters).
115
+ // `all` false stops at the first fitting rule (priority ranking only needs a boolean); true counts every rule.
116
+ function fits(rules, text, all = false) {
117
+ if (!Array.isArray(rules)) return null;
118
+ let best = null;
119
+ for (const rule of rules) {
120
+ if (!Array.isArray(rule) || !rule.length) continue;
121
+ let chars = 0;
117
122
  for (const src of rule) {
118
123
  const re = compile(src);
119
- if (!re || !re.test(text)) return false;
124
+ const m = re && re.exec(text);
125
+ if (!m) { chars = -1; break; }
126
+ chars += m[0].length;
120
127
  }
121
- return true;
122
- });
128
+ if (chars < 0) continue;
129
+ best ||= { rules: 0, pats: 0, chars: 0 };
130
+ best.rules++;
131
+ if (rule.length > best.pats || (rule.length === best.pats && chars > best.chars)) { best.pats = rule.length; best.chars = chars; }
132
+ if (!all) return best;
133
+ }
134
+ return best;
123
135
  }
136
+ // Score ranking: own-words hit dominates, then rules that fit and patterns in the best rule, then matched characters.
137
+ const score = (own, f) => own * 1e9 + (f ? (f.rules + f.pats) * 1e4 + Math.min(f.chars, 9999) : 0);
124
138
 
125
139
  // Own words are literal text, so they cannot carry a slow pattern. Edges are lookarounds, not \b, so "c++" still matches.
126
140
  export function wordsPattern(words) {
@@ -176,7 +190,7 @@ const inProject = (s, here, fs) => !Array.isArray(s.projects) || s.projects.some
176
190
  return here.some((h) => h === root || h.startsWith(root + sep));
177
191
  });
178
192
 
179
- function pick(prompt, table, { tool, base, skip, fs = FS } = {}) {
193
+ export function pick(prompt, table, { tool, base, skip, fs = FS, rank = process.env.SKILL_AUTOROUTE_RANK } = {}) {
180
194
  const text = String(prompt).slice(0, MAX_PROMPT);
181
195
  const here = places(base, fs);
182
196
  const ok = (v) => typeof v === 'string' && v !== '';
@@ -184,8 +198,11 @@ function pick(prompt, table, { tool, base, skip, fs = FS } = {}) {
184
198
  const hits = table.skills
185
199
  .filter((s) => s && s.enabled && ok(s.name) && ok(s.path) && /[\\/]SKILL\.md$/.test(s.path) && (!tool || (Array.isArray(s.tools) ? s.tools : [s.tool]).includes(tool)) && inProject(s, here, fs))
186
200
  .map((s) => ({ s, own: ownFits(s, text) }))
187
- .filter(({ s, own }) => (own || fits(s.patterns, text)) && fs.mtime(s.path) !== null)
188
- .sort((a, b) => (b.own - a.own) || ((a.s.priority ?? 1e9) - (b.s.priority ?? 1e9)))
201
+ .map((e) => (rank === 'score' ? { ...e, f: fits(e.s.patterns, text, true) } : e))
202
+ .filter((e) => (e.own || (rank === 'score' ? e.f : fits(e.s.patterns, text))) && fs.mtime(e.s.path) !== null)
203
+ .sort(rank === 'score'
204
+ ? (a, b) => (score(b.own, b.f) - score(a.own, a.f)) || ((a.s.priority ?? 1e9) - (b.s.priority ?? 1e9)) || (a.s.name < b.s.name ? -1 : a.s.name > b.s.name ? 1 : 0)
205
+ : (a, b) => (b.own - a.own) || ((a.s.priority ?? 1e9) - (b.s.priority ?? 1e9)))
189
206
  .map(({ s }) => s)
190
207
  .filter((s) => !seen.has(s.name) && seen.add(s.name) && !skip?.has(s.name))
191
208
  .slice(0, MAX_HINTS);
@@ -194,7 +211,7 @@ function pick(prompt, table, { tool, base, skip, fs = FS } = {}) {
194
211
  let out = 'Skills that fit this work (read each SKILL.md before you start): ' + hits.map((s) => `${shownName(s.name)} (${safe(s.path)})`).join('; ') + '.';
195
212
  const n = staleCount(table, fs);
196
213
  if (n) out += `\n${n} skill${n === 1 ? '' : 's'} changed since the last generate. Run: npx skill-autoroute regenerate`;
197
- return { out, count: hits.length, names: hits.map((s) => s.name) };
214
+ return { out, count: hits.length, names: hits.map((s) => s.name), detail: hits.map((s) => ({ name: s.name, path: s.path, own: ownFits(s, text), scope: Array.isArray(s.projects) ? 'project' : 'global' })) };
198
215
  }
199
216
 
200
217
  export const route = (prompt, table, opts) => pick(prompt, table, opts)?.out ?? null;
@@ -275,6 +292,7 @@ const loadTable = (udir, base) => merge(load(join(udir, 'routes.json')), resolve
275
292
 
276
293
  // `route.mjs [tool] suggest <session|-> <text...>`: the agent asks for skills in the middle of its work.
277
294
  function suggest(udir, args, i) {
295
+ if (args[i + 1] === '--json') return suggestJson(udir, args, i);
278
296
  const tool = i === 1 ? args[0] : undefined;
279
297
  const base = process.env.CLAUDE_PROJECT_DIR || process.cwd();
280
298
  const table = loadTable(udir, base);
@@ -283,6 +301,56 @@ function suggest(udir, args, i) {
283
301
  if (hit) remember(sessionFile(udir, tool, args[i + 1]), hit.names);
284
302
  }
285
303
 
304
+ // `suggest --json --context-file <path|->`: the same pick, driven by a JSON task description and answered as one JSON line.
305
+ // Every string in the file is data: it is only matched against trigger patterns, never run or put in a shell.
306
+ function suggestJson(udir, args, i) {
307
+ const t0 = Date.now();
308
+ const tool = i === 1 ? args[0] : undefined;
309
+ const done = (o) => process.stdout.write(`${JSON.stringify({ schema_version: 1, ...o, duration_ms: Date.now() - t0 })}\n`);
310
+ const fail = (error) => done({ status: 'error', error });
311
+ const f = args[i + 2] === '--context-file' ? args[i + 3] : undefined;
312
+ if (!f) return fail('bad_args');
313
+ let raw;
314
+ try { raw = readFileSync(f === '-' ? 0 : f, 'utf8'); } catch { return fail('unreadable'); }
315
+ if (raw.length > MAX_PROMPT) return fail('too_large');
316
+ let c;
317
+ try { c = JSON.parse(raw); } catch { return fail('bad_json'); }
318
+ if (!c || typeof c !== 'object' || Array.isArray(c)) return fail('not_object');
319
+ if (c.schema_version !== 1) return fail('bad_schema_version');
320
+ const str = (v) => (typeof v === 'string' ? v : '');
321
+ const strs = (v) => (Array.isArray(v) ? v.filter((x) => typeof x === 'string') : []);
322
+ const task = c.task && typeof c.task === 'object' ? c.task : {};
323
+ const policy = c.policy && typeof c.policy === 'object' ? c.policy : {};
324
+ const text = [str(c.stage), str(c.role), str(task.title), str(task.summary), strs(task.tags).join(' ')].filter(Boolean).join(' ');
325
+ const max = Number.isInteger(policy.max_skills) ? Math.min(MAX_HINTS, Math.max(1, policy.max_skills)) : MAX_HINTS;
326
+ const file = sessionFile(udir, tool, c.session_id);
327
+ const known = (file && remembered(file)) || new Set();
328
+ const skipList = new Set(strs(policy.skip));
329
+ const base = process.env.CLAUDE_PROJECT_DIR || process.cwd();
330
+ const table = loadTable(udir, base);
331
+ const hit = table && pick(text, table, { tool, base, skip: new Set([...skipList, ...known]) });
332
+ const detail = hit ? hit.detail.slice(0, max) : [];
333
+ const selected = detail.map((d) => ({ id: shownName(d.name), path: d.path, scope: d.scope, reason_code: d.own ? 'own_words' : 'pattern' }));
334
+ // Suppressed: skills that matched this text but were left out for a reason that is cheap to know.
335
+ const suppressed = [];
336
+ if (table) {
337
+ const here = places(base, FS);
338
+ const names = new Set();
339
+ for (const s of table.skills) {
340
+ if (!s.enabled || typeof s.name !== 'string' || !s.name || typeof s.path !== 'string' || !/[\\/]SKILL\.md$/.test(s.path)) continue;
341
+ if ((tool && !(Array.isArray(s.tools) ? s.tools : [s.tool]).includes(tool)) || !inProject(s, here, FS)) continue;
342
+ if (!(ownFits(s, text) || fits(s.patterns, text)) || FS.mtime(s.path) === null) continue;
343
+ const reason_code = names.has(s.name) ? 'duplicate_name' : skipList.has(s.name) ? 'skip_list' : known.has(s.name) ? 'seen_in_session' : null;
344
+ names.add(s.name);
345
+ if (reason_code && suppressed.length < 20) suppressed.push({ id: shownName(s.name), reason_code });
346
+ }
347
+ }
348
+ // crypto loads only here: a static import adds ~5 ms to every prompt's cold start.
349
+ const routing_version = createRequire(import.meta.url)('node:crypto').createHash('sha256').update(`${table?.generatedAt}${table?.skills.length}`).digest('hex').slice(0, 12);
350
+ done({ status: selected.length ? 'ok' : 'no_match', selected, suppressed, routing_version });
351
+ if (selected.length) remember(file, detail.map((d) => d.name));
352
+ }
353
+
286
354
  function main(self) {
287
355
  if (process.env.SKILL_AUTOROUTE_DISABLE === '1') return;
288
356
  const udir = join(homedir(), '.config', 'skill-autoroute');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skill-autoroute",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Per-prompt skill router hook for Claude Code and Codex",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -34,7 +34,8 @@
34
34
  "skill"
35
35
  ],
36
36
  "scripts": {
37
- "test": "node --test test/*.test.js"
37
+ "test": "node --test test/*.test.js",
38
+ "eval": "node test/eval/run.js"
38
39
  },
39
40
  "license": "MIT",
40
41
  "dependencies": {
package/src/flow.js CHANGED
@@ -410,22 +410,100 @@ export function setSkill(o, ui, name, state) {
410
410
  if (state === 'on' && hits.some((s) => !s.patterns?.length)) ui.log(`${show(name)} has no trigger rules yet, so it gets no hints. Run: npx skill-autoroute regenerate`);
411
411
  }
412
412
 
413
- export function list(o, ui) {
413
+ // Wrap long paths and patterns too; a single token must not overflow a narrow terminal.
414
+ function wrapList(text, width, indent = '', continuation = indent) {
415
+ const out = [];
416
+ while (text.length > Math.max(1, width - indent.length)) {
417
+ const room = Math.max(1, width - indent.length);
418
+ const space = text.lastIndexOf(' ', room);
419
+ const cut = space > 0 ? space : room;
420
+ out.push(indent + text.slice(0, cut));
421
+ text = text.slice(cut + (space > 0 ? 1 : 0));
422
+ indent = continuation;
423
+ }
424
+ out.push(indent + text);
425
+ return out;
426
+ }
427
+
428
+ function listFamily(s) {
429
+ const name = String(s.name ?? '');
430
+ const plugin = String(s.source ?? '').match(/^plugin:([^@]+)/)?.[1];
431
+ const packaged = String(s.path ?? '').replace(/\\/g, '/').match(/\/plugins\/.*\/([^/]+)\/[^/]+\/skills\//)?.[1];
432
+ const prefix = name.match(/^(caveman|expo|foreman|superpowers|vercel)(?:[-:]|$)/)?.[1];
433
+ return show(plugin || name.match(/^([^:]+):/)?.[1] || packaged || prefix || 'Other skills').toUpperCase();
434
+ }
435
+
436
+ export function list(o, ui, name) {
414
437
  const path = routesPath(scopeOf(o));
415
438
  const table = readTable(path);
416
439
  if (!table) return ui.log(`no table at ${show(path)}; run install first`);
417
440
  const skills = table.skills.filter((s) => s && (!o.tools?.length || o.tools.some((t) => (s.tools ?? [s.tool]).includes(t))));
441
+ const selected = name ? skills.filter((s) => s.name === name) : skills;
442
+ if (name && !selected.length) throw new Error(`no skill named "${show(name)}" in this scope for the selected tools`);
418
443
  if (!skills.length) return ui.log('No skills in this scope for the selected tools.');
419
- ui.log('Routing configuration (on = enabled for matching prompts; not proof of invocation).\nRules are case-insensitive: AND within a rule, OR between rules. Own words also trigger a match.');
420
- for (const s of skills) {
421
- ui.log(`${show(s.name)} ${s.enabled ? 'on' : 'off'} ${(s.tools ?? [s.tool]).map(show).join(', ')} priority ${show(s.priority ?? 50)}`);
422
- if (s.path) ui.log(` Path: ${show(s.path)}`);
423
- if (s.projects?.length) ui.log(` Projects: ${s.projects.map(show).join(', ')}`);
424
- ui.log(s.patterns?.length
425
- ? ` Rules: ${s.patterns.map((rule) => `(${rule.map(show).join(' AND ')})`).join(' OR ')}`
426
- : ' No trigger rules.');
427
- if (s.words?.length) ui.log(` Own words: ${s.words.map(show).join(', ')}`);
444
+ const width = Math.max(32, process.stdout.columns || 80) - 4; // room for the interactive logger's gutter
445
+ const lines = [];
446
+ const add = (text, indent = '', continuation = indent) => lines.push(...wrapList(text, width, indent, continuation));
447
+ const tools = (s) => (s.tools ?? [s.tool]).map(show).join(', ') || '-';
448
+ if (!name) {
449
+ const toolWidth = Math.max(5, ...skills.map((s) => tools(s).length));
450
+ const nameWidth = Math.max(1, Math.min(Math.max(5, ...skills.map((s) => show(s.name).length)), width - toolWidth - 19));
451
+ const narrow = nameWidth < 16 && width < 60;
452
+ const row = (n, status, tool, rules) => ` ${n.padEnd(nameWidth)} ${status.padEnd(6)} ${tool.padEnd(toolWidth)} ${rules.padStart(5)}`;
453
+ add(`Skill routes (${scopeOf(o)})`);
454
+ const groups = new Map();
455
+ for (const s of skills) {
456
+ const family = listFamily(s);
457
+ if (!groups.has(family)) groups.set(family, []);
458
+ groups.get(family).push(s);
459
+ }
460
+ const families = [...groups.keys()].sort((a, b) => (a === 'OTHER SKILLS') - (b === 'OTHER SKILLS') || a.localeCompare(b));
461
+ for (const family of families) {
462
+ lines.push('');
463
+ add(family);
464
+ if (narrow) lines.push(' SKILL', ` ${'STATUS'.padEnd(6)} ${'TOOLS'.padEnd(toolWidth)} RULES`);
465
+ else lines.push(row('SKILL', 'STATUS', 'TOOLS', 'RULES'));
466
+ for (const s of groups.get(family).sort((a, b) => String(a.name).localeCompare(String(b.name)))) {
467
+ if (narrow) {
468
+ lines.push('');
469
+ add(show(s.name), ' ');
470
+ lines.push(` ${(s.enabled ? 'on' : 'off').padEnd(6)} ${tools(s).padEnd(toolWidth)} ${String(s.patterns?.length ?? 0).padStart(5)}`);
471
+ } else {
472
+ const chunks = wrapList(show(s.name), nameWidth);
473
+ lines.push(row(chunks[0], s.enabled ? 'on' : 'off', tools(s), String(s.patterns?.length ?? 0)));
474
+ lines.push(...chunks.slice(1).map((line) => ' ' + line));
475
+ }
476
+ }
477
+ }
478
+ lines.push('');
479
+ add(`${skills.length} skills: ${skills.filter((s) => s.enabled).length} on, ${skills.filter((s) => !s.enabled).length} off`);
480
+ add('On = eligible for matching prompts; not proof of invocation.');
481
+ lines.push('');
482
+ add('Details and rules:');
483
+ add('npx skill-autoroute list <skill>' + (o.project ? ' --project' : ''), ' ');
484
+ } else {
485
+ for (const s of selected) {
486
+ if (lines.length) lines.push('');
487
+ add(show(s.name));
488
+ lines.push('');
489
+ for (const [label, value] of [
490
+ ['Status', s.enabled ? 'on' : 'off'], ['Tools', tools(s)], ['Priority', s.priority ?? 50],
491
+ ['Path', s.path], ['Projects', s.projects?.map(show).join(', ')], ['Own words', s.words?.map(show).join(', ')],
492
+ ]) if (value !== undefined && value !== '') add(show(value), ` ${(label + ':').padEnd(11)}`, ' '.repeat(13));
493
+ lines.push('');
494
+ add('Rules (case-insensitive; OR between numbered rules):');
495
+ if (!s.patterns?.length) add('No trigger rules.', ' ');
496
+ for (const [i, rule] of (s.patterns ?? []).entries()) {
497
+ if (i) lines.push('');
498
+ for (const [j, pattern] of rule.entries()) {
499
+ const prefix = j ? ' AND ' : ` ${i + 1}. `;
500
+ add(show(pattern), prefix, ' '.repeat(prefix.length));
501
+ }
502
+ }
503
+ if (s.words?.length) { lines.push(''); add('Own words also trigger a match.'); }
504
+ }
428
505
  }
506
+ ui.log(lines.join('\n'));
429
507
  }
430
508
 
431
509
  export function status(o, ui) {