skill-autoroute 0.6.0 → 0.8.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
@@ -272,6 +272,7 @@ npx skill-autoroute install --model triggers=haiku
272
272
  | `install` | The full setup flow |
273
273
  | `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
274
  | `scan` | Scan and find duplicates only. Writes nothing. |
275
+ | `list [<skill>]` | Show a compact routing table, or one skill's paths, priority and numbered trigger rules. Supports `--tools` and `--project`. Writes nothing. |
275
276
  | `set <skill> on|off` | Turn one skill's hints on or off |
276
277
  | `words [<skill> [add|remove <word>...]]` | Your own trigger words for a skill. Without a skill, lists all of them. |
277
278
  | `status` | Tools, hook state, skill counts, changed skills |
@@ -285,6 +286,40 @@ npx skill-autoroute install --model triggers=haiku
285
286
 
286
287
  When your skills change, the hint line tells you so. Run `regenerate`.
287
288
 
289
+ Inspect the saved routing configuration:
290
+
291
+ ```bash
292
+ npx skill-autoroute list
293
+ npx skill-autoroute list --tools codex
294
+ npx skill-autoroute list --project
295
+ npx skill-autoroute list security-review
296
+ ```
297
+
298
+ `list` reads the user table by default; `--project` reads only the current project's table.
299
+ The summary groups skills by family, with aligned names, on/off state, tools and rule counts.
300
+ Families come from plugin metadata, namespaced names, plugin paths, or the Caveman, Expo, Foreman,
301
+ Superpowers and Vercel name prefixes. Other entries appear under `OTHER SKILLS`.
302
+ Families and their skills are sorted alphabetically, with `OTHER SKILLS` last.
303
+
304
+ Example layout (your skills and rule counts may differ):
305
+
306
+ ```text
307
+ EXPO
308
+ SKILL STATUS TOOLS RULES
309
+ expo-native-ui on codex 4
310
+ expo-upgrade on codex 4
311
+
312
+ VERCEL
313
+ SKILL STATUS TOOLS RULES
314
+ vercel-composition-patterns on codex 4
315
+ vercel-optimize on codex 3
316
+ ```
317
+
318
+ Use `list <skill>` for paths, priority, custom words and numbered rules; long lines wrap to fit the terminal.
319
+ Both views include disabled skills (marked `off`). Patterns within a rule must all match (AND);
320
+ any rule can trigger the skill (OR). Custom words are another way to match.
321
+ Enabled means eligible for routing on matching prompts, not that the agent has invoked the skill.
322
+
288
323
  ---
289
324
 
290
325
  ## User or project install
@@ -345,4 +380,4 @@ The tests use fake `claude` and `codex` programs and a fake `HOME`. They make no
345
380
 
346
381
  ## License
347
382
 
348
- [MIT](LICENSE)
383
+ [MIT](LICENSE)
package/bin/cli.js CHANGED
@@ -6,12 +6,12 @@ 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 | 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 = {
13
13
  install: flow.install, regenerate: flow.regenerate, scan: flow.scan, set: flow.setSkill, words: flow.setWords,
14
- status: flow.status, tokens: flow.tokens, bench: flow.bench, uninstall: flow.uninstall,
14
+ list: flow.list, status: flow.status, tokens: flow.tokens, bench: flow.bench, uninstall: flow.uninstall,
15
15
  };
16
16
 
17
17
  function options() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skill-autoroute",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Per-prompt skill router hook for Claude Code and Codex",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/flow.js CHANGED
@@ -410,6 +410,102 @@ 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
+ // 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) {
437
+ const path = routesPath(scopeOf(o));
438
+ const table = readTable(path);
439
+ if (!table) return ui.log(`no table at ${show(path)}; run install first`);
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`);
443
+ if (!skills.length) return ui.log('No skills in this scope for the selected tools.');
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
+ }
505
+ }
506
+ ui.log(lines.join('\n'));
507
+ }
508
+
413
509
  export function status(o, ui) {
414
510
  const scope = scopeOf(o);
415
511
  for (const t of findTools()) ui.log(`${t.name}: CLI ${t.cli ? 'found' : 'not found'}, config ${t.configDir ? 'found' : 'not found'}, ${ADAPTERS[t.name].hasHook(scope) ? 'hook installed' : 'no hook'}`);