docs: hooks-v2 master implementation plan (28 events, cross-9-repo research)#354
Open
quangdang46 wants to merge 11 commits into
Open
docs: hooks-v2 master implementation plan (28 events, cross-9-repo research)#354quangdang46 wants to merge 11 commits into
quangdang46 wants to merge 11 commits into
Conversation
Comprehensive 2724-line plan covering 28 hook events across 7 categories, based on research across 9 reference repos (claude-code, opencode, codex, oh-my-openagent, oh-my-claudecode, oh-my-codex, oh-my-pi, pi-agent-rust, codebuff). Includes full TypeScript+Rust type definitions, TOML config spec, module-by-module code, CLI commands, test plan, migration path.
- New crate: crates/jcode-hooks/ (7,445 lines) - types.rs: HookInput/HookOutput/HookResult/AggregatedDecision/HookMetrics - config.rs: HookEvent (28+1 variants), 4 handler types, 3-layer TOML loader - dispatch.rs: Parallel dispatch with FuturesUnordered + Semaphore - execute.rs: Command/Http/Agent/Plugin execution with exit code protocol - registry.rs: HookRegistry with matcher-based filtering - matcher.rs: Pattern matching (Exact/Multi/Regex/Wildcard) - cli.rs: CLI commands (list/enable/disable/test/metrics) - tests.rs: 186 unit tests - Integration points wired (28 events): - PreToolUse, PostToolUse, PostToolUseFailure, ToolError - UserPromptSubmit, UserPromptExpansion - SessionStart, SessionEnd, SessionUpdated, SessionDiff, SessionError, SessionIdle - PermissionRequest, PermissionDenied, PermissionAsked, PermissionReplied - AgentStart, AgentEnd, SubagentStart, SubagentStop - Stop - PreCompact, PostCompact, AutoCompactionControl - Setup, TaskCreated, TaskCompleted - FileChanged - Features: - Parallel dispatch via FuturesUnordered + Semaphore - Deny > Ask > Allow precedence chain - Kill-switch env vars (DISABLE_JCODE_HOOKS, JCODE_SKIP_HOOKS, JCODE_SKIP_EVENT_*) - Per-handler timeout (1-300s) - Exit code protocol (0=continue, 1=fail, 2=block) - Metrics collection Tests: 186/186 passing Build: cargo check passes with zero errors Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- cargo fmt on all hooks and integration files - Fix clippy: derive Default for HooksConfig instead of manual impl - Fix clippy: doc_overindented_list_items in dispatch.rs - Fix clippy: needless_borrow in registry.rs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Fix redundant closure in client_lifecycle.rs - Gate Mutex import behind dcp feature flag Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Hooks v2 — Master Implementation Plan
Summary
Comprehensive implementation plan for jcode hooks v2, expanding from the current 7 HookEvent variants to full parity with Claude Code (27 events), OpenCode plugin system (14+ events), and Codex CLI (10 events).
Research Scope
All 9 reference repos researched and cross-referenced:
Plan Contents
Status
📋 Plan only — implementation pending.
This PR establishes the baseline document. Implementation will start in subsequent PRs.