mirror of
https://github.com/garrytan/gstack.git
synced 2026-11-23 00:21:14 +01:00
The prompt-routing hook suggests skills you install, and stops sending bug reports to /qa (GST-3123) (#4506)
The prompt-routing hook can now suggest skills you installed yourself: any skill that lists `triggers:` in its SKILL.md, not only gstack's /review, /qa and /verify. It also stops sending ordinary bug reports to /qa. Why: a bug-fix skill you install was never named (0 of 60 real bug reports); now it's named on 40 of 60, and /qa takes none of them instead of 3. Nothing to do after merge. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com> Review-Finding: p1/red-team#1 reader=red-team Review-Finding: p1/specialist-batched#2 reader=api-contract Review-Finding: p1/specialist-batched#1 reader=security
This commit is contained in:
1 parent
f79a8905c7
commit
5afef04e31
9 files changed
+244
-44
No files matched your search
+2
-1
@@ -40,7 +40,8 @@ explicit "no" removes a live registration. `GSTACK_TIMELINE_STOP_HOOK=no` and
|
||||
removes it too.
|
||||
|
||||
Three more hooks are on by default: skill routing (a `UserPromptSubmit` hook
|
||||
that names the gstack skill a prompt fits), skill contracts (a `Stop` hook that
|
||||
that names the gstack skill, or an installed skill with its own `triggers:`, that
|
||||
a prompt fits), skill contracts (a `Stop` hook that
|
||||
blocks once when a skill ends without its required outputs) and the
|
||||
destructive-command check (a `PreToolUse` hook that runs /careful's check before
|
||||
every Bash and PowerShell command). Turn one off with `./setup --no-skill-routing`,
|
||||
|
||||
@@ -39,8 +39,11 @@ The off switch is for people. The text the Stop hook shows the model never menti
|
||||
The hook scores the prompt against the `triggers:` list in each installed `SKILL.md` (`~/.claude/skills/*/SKILL.md`, or `$CLAUDE_CONFIG_DIR/skills`). It makes no model call and no network request, and the same prompt always gets the same answer.
|
||||
|
||||
- A trigger scores 1 when its whole phrase appears in the prompt. Otherwise it scores the share of its content words (common words dropped, light stemming, so "failing" matches "fails") that the prompt contains. A trigger with one content word counts only on its whole phrase, unless that word has five or more letters and is not a question word.
|
||||
- Only /review, /qa and /verify route (/investigate did too until it was cut, GST-1717). In the d7 check (PR #3912), scoring every installed skill's triggers sent 17 of 32 non-fit Terminal-Bench prompts to some skill at 0.66; routing only the four routed skills of that time sent 4. The other skills wait for their own trigger review.
|
||||
- The skill with the best score routes when it reaches the threshold, 0.66: both words of a two-word trigger, or two of three.
|
||||
- A bug report is full of everyday words (find, test, run, site) and defect words, so they never add up to a request by themselves. A trigger only partly present needs one of its five-letter-or-longer words, other than the defect word, among the words it shares: "pip cannot find the package and the install fails" no longer matches "find bugs on site". A trigger made only of shorter everyday words, with no defect word, needs them within 8 words of each other: a report that mentions a "call site" and, much later, "regression tests" no longer matches "test the site" (GST-3123).
|
||||
- Of gstack's own skills, only /review, /qa and /verify route (/investigate did too until it was cut, GST-1717). In the d7 check (PR #3912), scoring every gstack skill's triggers sent 17 of 32 non-fit Terminal-Bench prompts to some skill at 0.66; routing only the four routed skills of that time sent 4. The other gstack skills wait for their own trigger review.
|
||||
- Any other installed skill that lists `triggers:` in its own SKILL.md routes too (GST-3123). No host but gstack reads that field, so writing it is how a skill asks gstack to route it. A skill is gstack's own when its directory holds `.gstack-owned`, its SKILL.md links into gstack's checkout, or its name is one gstack generates or installs as an alias. A skill built from a gstack-style template, with the same generated-file banner, is not gstack's own.
|
||||
- An installed skill's triggers are used only when its name is letters, digits, `_`, `:` and `-`, it lists at most 12 triggers of at most 200 characters, and every trigger is letters, digits, spaces and `. , ' ? ! / -`. Otherwise the whole skill is skipped and named in `gstack-skill-route --explain` and the routing log, so trigger text cannot leave its quotes or add markup or shell characters to the hook's line. The quoted trigger is still the skill author's own words, so install only skills you trust.
|
||||
- The skills that reach the threshold, 0.66 (both words of a two-word trigger, or two of three), are ranked by score; at the same score gstack's own skill comes first, then the trigger with more matched words, then the name. The line names the top skill, or the top two different skills: "this request fits /verify or /prove-it. Run the one that fits better ...".
|
||||
- Words a bug report uses for the defect (error, exception, traceback, crash, fails, failure, broken, regression, incorrect, wrong, defect, and exception names such as `ValueError`) score as "bug", so "parse_one raises ValueError, please fix" matches a "fix this bug" trigger. Paths and identifiers stay whole (`site-packages`, `src/review.ts`, `max_retries`), so a traceback's paths never match a trigger's words.
|
||||
- When a trigger ties with another of the same skill on score and words, a whole-phrase match wins.
|
||||
- A prompt longer than 5,000 characters is scored on its first 4,000 and last 1,000 characters, where the request usually sits; a log pasted between them is not scored, so its words cannot match everything. Until GST-3110 such prompts (over 8,000 characters) were never routed.
|
||||
@@ -56,8 +59,8 @@ The hook scores the prompt against the `triggers:` list in each installed `SKILL
|
||||
threshold: 0.66
|
||||
skills: 63 scanned in /home/you/.claude/skills
|
||||
candidates:
|
||||
1.00 /verify "verify my change" (2 words)
|
||||
0.50 /review "check my diff" (1 words)
|
||||
1.00 /verify "verify my change" (2 words, gstack)
|
||||
0.50 /review "review my changes" (1 words, gstack)
|
||||
route: /verify
|
||||
hint: gstack skill routing (UserPromptSubmit hook; ...
|
||||
|
||||
@@ -65,7 +68,7 @@ Add `--json` for a machine-readable answer, or `--threshold <n>` to see another
|
||||
|
||||
### Routing log
|
||||
|
||||
Every decision is one line in `$GSTACK_STATE_ROOT/hooks/skill-route.log`: the session, the event (`routed`, `no-route` with its reason, or an error) and, for errors, `failures=<n>` for that session. The log never holds prompt text. On any error the hook prints nothing and exits 0; it never blocks a prompt.
|
||||
Every decision is one line in `$GSTACK_STATE_ROOT/hooks/skill-route.log`: the session, the event (`routed`, `no-route` with its reason, or an error), for a route the skill, its score and its `source` (`gstack`, or the installed SKILL.md's path) plus `also=` for a second skill, and, for errors, `failures=<n>` for that session. The log never holds prompt text. On any error the hook prints nothing and exits 0; it never blocks a prompt.
|
||||
|
||||
<a id="destructive-command-check"></a>
|
||||
## Destructive-command check
|
||||
|
||||
Reference in new issue
Block a user