Repository navigation
Conversation
marina's agent awareness previously took effect only when someone ran a
command. `marina hooks install [--project] [--no-cleanup]` registers three
Claude Code command hooks (`marina hook <event>`) so every session uses it:
- SessionStart: additionalContext listing this project's running dev
servers (reuse rather than duplicate), its existing `marina port` lease
(read-only), and counts of other / orphaned servers.
- PreToolUse (Bash): for dev-server start commands only, notes when this
project's server is already running or the command hard-codes a port that
belongs elsewhere. No permissionDecision is returned, so permissions are
unchanged ("allow" would auto-approve). Non-matching commands return in
~20ms without building a snapshot.
- SessionEnd: stops targets whose launcher session id matches the ended
session (verified SIGTERM, 2s, SIGKILL). Skipped for /clear and /resume.
Each hook sets its own timeout (SessionEnd's default budget is 1.5s). Hooks
always exit 0. Settings are edited with key order preserved (serde_json
preserve_order; indexmap was already a dependency), marina's entries are
identified by command and other hooks are untouched, malformed files are
refused, writes are atomic with a one-time .marina-bak, and uninstall
restores the original structure. User scope honours CLAUDE_CONFIG_DIR.
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.
Summary
marina's agent awareness (launchers, sessions, port leases) only took effect when someone ran a command.
marina hooks installwires it into every Claude Code session:marina port, and counts of other/orphaned servers.pnpm dev,npm run dev,vite,cargo run, …): a note if this project's server is already running, or if the command hard-codes a port that belongs elsewhere. Context only./clearor/resume). Opt out with--no-cleanup.marina hooks install # user settings (honours CLAUDE_CONFIG_DIR); --project for .claude/settings.json marina hooks status marina hooks uninstallDesign notes
permissionDecision: "allow"would silently auto-approve the command andask/deferchange behaviour; the docs don't state whetheradditionalContextworks without a decision, so this was verified empirically (below).SessionEnddefaults to a 1.5s budget, too short to stop a server).serde_json/preserve_order—indexmapwas already in the tree), marina's entries identified by their command, user hooks untouched, malformed files refused, atomic writes, one-timesettings.json.marina-bak; uninstall restores the original structure.Testing
cargo fmt --check,clippy -D warnings,cargo test: 136 tests (9 new) — dev-server command detection (incl. a documented harmless false positive), hard-coded port parsing, context text for duplicates / foreign ports / silence, session-target matching, idempotent install preserving key order and user hooks,--no-cleanup, exact-restore uninstall, malformed settings refused, CLI usage errors./clearand another session's end leave a server alone; the owning session's end stops exactly its server. Install/status/uninstall against a throwawayCLAUDE_CONFIG_DIRrestored the file exactly; a malformed file was refused untouched.echoran normally — confirming context-without-decision works and leaves permissions unchanged. The headless session's own SessionEnd left the other session's server running.