feat(hooks): opt-in agent-type scoping for SubagentStart injection (#… (#522)
* feat(hooks): opt-in agent-type scoping for SubagentStart injection (#506) The SubagentStart hook injected the ~1,300-token persona into every subagent, including read-only search agents where it is dead weight. Consumers could not narrow a plugin-provided hook from their own settings, so the scoping has to live here. Add an opt-in allowlist: PONYTAIL_SUBAGENT_AGENTS (comma-separated env var) or a subagentAgents array in config.json, matching getDefaultMode precedence. The hook now reads agent_type from stdin and skips injection only on a positive mismatch; unconfigured or missing agent_type keeps the inject-everywhere behavior from issue #252. Stdin reading follows the never-hang contract from issue #443. Closes #506 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Address review: regex matcher, stdin-free default path, exit on skip Rework the SubagentStart scoping per review on #522: - Replace the comma-separated PONYTAIL_SUBAGENT_AGENTS allowlist with a regex PONYTAIL_SUBAGENT_MATCHER, matching the reviewed API on #507 and the PONYTAIL_DEFAULT_MODE naming convention. - Default path (no matcher) injects synchronously and never reads stdin, fixing the #443-class Windows regression where the persona was delayed until a 1s timeout. - On a definite agent_type mismatch the hook now process.exit(0)s immediately instead of lingering until the fallback timer. - Drop the config-file (subagentAgents) source, so no config read on the subagent hot path; env-only keeps it lazy (YAGNI). - Revert the unrelated tests/hooks-windows.test.js change; the scoped path mirrors the mode-tracker never-hang contract already tested there. Fail open on unparseable input, missing agent_type, invalid regex, or timeout so scoping never silently drops the persona (#252). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Emeriko <dietrich.gebert@gmail.com>
K
krish rathi committed
1715abccac3c3996d9c4c9a01061b1ffb1da68c2
Parent: 83493b9
Committed by GitHub <noreply@github.com>
on 7/9/2026, 3:23:07 PM