Repository navigation
feat(claude): add SessionStart routing hook - #30
Merged
Merged
Conversation
The Claude Code plugin now registers a SessionStart hook that adds a short note routing multi-file changes and unknown-cause bugs to mstack:meta-mode. One Node script serves every platform, fails open, and is disabled by sessionHook: false in ~/.config/mstack/models.json. Validation covers the hook file, its script reference, and the agent list. Adds guide page 12. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ontext Reject hook script and manifest agent paths that leave the plugin root, and report a non-file or unreadable hooks/session-start-context.md instead of throwing. Update the installer artifacts note that no longer matches the plugin hook. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
readModelConfig now reads the BOM and UTF-16 LE files the hook already accepts, and the guide no longer promises confirmation for reversible externally visible actions. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
mstack's Claude Code plugin ships skills and agents but nothing tells a fresh session to route multi-file changes or bugs with an unknown cause through
/meta-mode. pstack-claude closes that gap with a SessionStart hook, but with Bash and PowerShell copies and a Cursor-style sheet. mstack needs a portable version that follows its own config layout.Solution
hooks/hooks.jsonregisters aSessionStarthook (matcherstartup|resume|clear|compact) runningnode "${CLAUDE_PLUGIN_ROOT}/scripts/session-hook.mjs". Claude Code loadshooks/hooks.jsonby default, soplugin.jsondoes not reference it.validatePluginHooksrejects a duplicate manifest reference.scripts/session-hook.mjsis one Node script for Windows, macOS, and Linux. It printshookSpecificOutput.additionalContextJSON fromhooks/session-start-context.md(routing tomstack:meta-mode, reversible work proceeds, irreversible asks, user CLAUDE.md wins). It always exits 0 and prints nothing on any failure."sessionHook": falsein~/.config/mstack/models.json. Only booleanfalsedisables it. A missing, unreadable, or malformed config leaves the hook on. A UTF-8 or UTF-16 LE byte-order mark and CRLF are accepted.validateModelConfigrejects a non-boolean value (small additive edit tomodel-config-lib.mjs).validate.mjsnow checks the hook file, its script reference, the context file, andagents/*.md(frontmatter name equals file name, manifest agent paths exist).check-packagerequires the new files in the npm tarball.package.jsonfilesgainshooks.docs/harness-adapters.md.settings.json, which mstack leaves to the user, so installer-only setups get no hook and the two routes cannot double-load it.meta-agent-<effort>variants. Nothing in the skills dispatches by effort,agents/is shared with Codex TOML conversion (which rejects aneffortfield) and OpenCode, and a Claude-only generated copy would be dead code. The guide explainsclaude --effortand user-owned agent files instead.Verification
npm test: 258 tests pass, including 8 new ones inscripts/session-hook.test.mjs(output shape through the real script, off switch with BOM, UTF-16, CRLF, missing, directory-in-place-of-file, malformed, non-boolean values, context skill names exist, manifest and hook reference checks).npm run check-packagepasses.claude plugin validate . --strictpasses (Claude Code 2.1.289).claude --plugin-dir .in stream-json mode: theSessionStart:startuphook ran, exit 0, and returned the expected additionalContext.Model: Claude Sonnet 5.5 | Harness: Claude Code
🤖 Generated with Claude Code