skill-autoroute 0.11.0 → 0.11.2

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
@@ -168,7 +168,8 @@ The optional AI scan can make a result stricter. It can never clear a high findi
168
168
  - A scan is marked **partial scan** when a file is unreadable or over 1 MB, a link points outside the folder, the skill
169
169
  has `node_modules` or `.git` (never read), or the AI input is cut (about 60,000 characters).
170
170
  - A security skill that quotes attack phrases as examples is still flagged. Turn it back on with
171
- `set <skill> on`.
171
+ `set <skill> on`. That choice survives a rescan (`regenerate`, `install`) when the skill changes, as long as every
172
+ blocking finding is one you already saw (same rule in the same file). A new kind of finding turns it off again.
172
173
  - AI steps send skill text to the provider behind your CLI. Triggers send names and descriptions. The deep scan sends
173
174
  up to about 60 KB per skill. Skill text is wrapped as untrusted data.
174
175
  - Claude runs with no tools. Codex runs read-only with its shell features off
@@ -449,6 +450,8 @@ trusted project's `.hermes/skills` and `.agents/skills`.
449
450
  the user message. No match prints nothing.
450
451
  - **Subagents:** a second entry on `subagent_start` records each `delegate_task` child's session id, and the child's
451
452
  turns get no hints. The parent already chose the work.
453
+ - **Gateway notices:** turns Hermes itself sends (a finished background process or delegation, marked
454
+ `[INTERNAL NOTIFICATION`) get no hints.
452
455
  - **Config:** the first change backs up `config.yaml` to `config.yaml.bak-skill-autoroute`. Other hooks stay as they are.
453
456
 
454
457
  </details>
package/hook/route.js CHANGED
@@ -372,6 +372,11 @@ function markChild(udir, sid) {
372
372
  try { mkdirSync(dirname(file), { recursive: true }); writeFileSync(file, ''); } catch { /* a read-only folder only loses the mark */ }
373
373
  }
374
374
 
375
+ // Hermes delivers its own notices (a finished background process or delegation) as user turns. They are not the
376
+ // user's work, so they get no hints. The gateway marks them; these are its fixed openings and marker.
377
+ const HERMES_NOTICE = /^\s*\[(ASYNC DELEGATION|IMPORTANT: Background process)\b|\[INTERNAL NOTIFICATION\b/;
378
+ export const isHermesNotice = (text) => HERMES_NOTICE.test(text);
379
+
375
380
  // What the tool sent, as {prompt, sid, base}; null when there is nothing to route.
376
381
  // Claude Code and Codex send {prompt, session_id}. Hermes sends {hook_event_name, session_id, cwd, extra: {user_message}}.
377
382
  export function readInput(input, tool, udir) {
@@ -382,7 +387,7 @@ export function readInput(input, tool, udir) {
382
387
  const sid = input.session_id;
383
388
  if (childFile(udir, sid) && existsSync(childFile(udir, sid))) return null;
384
389
  const prompt = messageText(input.extra?.user_message);
385
- if (prompt === null) return null;
390
+ if (prompt === null || isHermesNotice(prompt)) return null;
386
391
  return { prompt, sid, base: typeof input.cwd === 'string' && input.cwd ? input.cwd : process.cwd() };
387
392
  }
388
393
  if (typeof input.prompt !== 'string') return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skill-autoroute",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "Per-prompt skill router hook for Claude Code, Codex and Hermes",
5
5
  "keywords": [
6
6
  "claude-code",
package/src/flow.js CHANGED
@@ -152,6 +152,13 @@ export async function runDedupe(skills, ctx, ui) {
152
152
  return out;
153
153
  }
154
154
 
155
+ // Blocking findings as `rule:file` keys. Line numbers are left out: they move with every edit to the file.
156
+ const blockKeys = (scan) => [...new Set((scan?.findings ?? []).filter((f) => f.severity === 'high').map((f) => `${f.rule}:${f.file}`))];
157
+ // A blocked skill starts off, so an old entry that is on and blocked was turned on by the user. A rescan keeps that
158
+ // choice while every blocking finding is one the user already saw (same rule in the same file); a new one turns it off.
159
+ export const userAccepted = (was, scan) => Boolean(was?.enabled) && was.scan?.verdict === 'block' && scan?.verdict === 'block'
160
+ && blockKeys(scan).every((k) => blockKeys(was.scan).includes(k));
161
+
155
162
  export function buildRows(skills, scans, dupes = new Map()) {
156
163
  return skills.map((skill) => {
157
164
  const scan = scans.get(skill.skillPath);
@@ -311,11 +318,15 @@ export async function install(o, ui) {
311
318
  if (o.dryRun) return dryRun(ctx, skills, ui);
312
319
  preflight(scope, tools); // fail before spending AI calls
313
320
  const scans = await runScans(skills, ctx, ui);
314
- const rows = await pickRows(buildRows(skills, scans, await runDedupe(skills, ctx, ui)), ui);
321
+ const before = readTable(routesPath(scope));
322
+ const prior = new Map((before?.skills ?? []).map((s) => [s.path, s]));
323
+ const rows = await pickRows(buildRows(skills, scans, await runDedupe(skills, ctx, ui)).map((r) => (
324
+ !r.enabled && !r.dup?.of && userAccepted(prior.get(keyOf(scope)(r.skill.skillPath)), r.scan)
325
+ ? { ...r, enabled: true, text: `${r.text} · kept on (you turned it on with these findings)` } : r)), ui);
315
326
  const gen = await generate(rows.filter((r) => r.enabled).map((r) => r.skill), ctx, ui);
316
327
  const table = tableOf(ctx, rows.map((r) => entry(r, gen, scope)), roots.map(keyOf(scope)), o.log, ignored.map(keyOf(scope)));
317
- keepWords(table, readTable(routesPath(scope)));
318
- keepEdited(table, readTable(routesPath(scope)), ui);
328
+ keepWords(table, before);
329
+ keepEdited(table, before, ui);
319
330
  while (!ui.yes) {
320
331
  const p = await ui.text('Preview: type a prompt to see its hints (empty to finish)');
321
332
  if (!p) break;
@@ -355,9 +366,11 @@ export async function regenerate(o, ui) {
355
366
  const rows = buildRows(fresh, await runScans(fresh, ctx, ui)).map((r) => {
356
367
  const w = was(r.skill);
357
368
  if (!w) return r;
358
- const off = Boolean(w.enabled) && r.scan.verdict === 'block'; // Ruling R35
369
+ const kept = userAccepted(w, r.scan);
370
+ const off = Boolean(w.enabled) && r.scan.verdict === 'block' && !kept; // Ruling R35, unless the user already accepted these findings
359
371
  const n = show(r.skill.name);
360
372
  if (off) ui.log(`${n} turned off: ${show(label(r.scan))}; run \`npx skill-autoroute set ${n} on\` to override`);
373
+ else if (kept) ui.log(`${n} stays on: you turned it on with the same findings before`);
361
374
  return { ...r, enabled: Boolean(w.enabled) && !off, dup: w.duplicateOf ? { of: w.duplicateOf } : undefined };
362
375
  });
363
376
  const keep = (s) => !edited(was(s)); // rules the user edited are not rewritten