Add action hook points to start, doctor, and phase-merge #331
Labels
No labels
bug
contract
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
iterative-works/iw-cli#331
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
As part of the bounded context extraction (iterative-works/dev-docs#123), Claude-specific behavior in
start,doctor, andphase-mergeneeds to move into plugins. Before #324 can cleanly remove the Claude code, these commands need hook extension points so plugins can provide the behavior.Currently, the hook mechanism only supports
Checkdiscovery fordoctor(reflection-basedCheckvalues). We need a parallel mechanism for action hooks — plugin-provided behavior that commands invoke at specific points.Relationship to #324
This issue is a prerequisite for #324. The sequence:
Hook Points Needed
1.
start/open— Post-Session HookWhen: After worktree + tmux session is set up, before attaching.
Current behavior: If
--promptis given, sendsclaude --dangerously-skip-permissions <prompt>to the tmux session. Otherwise attaches normally.Proposed hook:
*.hook-start.scalaobjects can expose aSessionActionthat receives context and optionally sends a command to the tmux session.Discovery: Same pattern as doctor hooks — reflection finds objects exposing
SessionActionvalues in*.hook-start.scalafiles. If multiple hooks exist, first non-None wins (or error on conflict).Behavior change:
--promptflag stays as a generic "pass a prompt string to hooks." If no hook provides aSessionAction,--promptis ignored (or warns). Same mechanism foropen.2.
doctor— Fix Action HookWhen: After all checks run, if
--fixflag is set and there are failures.Current behavior: Detects build system, generates
FixPrompt, spawns interactive Claude session.Proposed hook:
*.hook-doctor.scalaobjects can expose aFixAction(in addition to existingCheckvalues).Discovery: Same reflection pass that finds
Checkvalues also looks forFixActionvalues. If--fixis requested and noFixActionis found, warn that no fix provider is installed.3.
phase-merge— Recovery Action HookWhen: CI checks fail during the polling loop.
Current behavior: Builds recovery prompt from failed checks, spawns
claude --dangerously-skip-permissions, retries.Proposed hook:
*.hook-phase-merge.scalaobjects can expose aRecoveryAction.Discovery: Reflection finds
RecoveryActionin*.hook-phase-merge.scalafiles. If no hook is found,phase-mergeskips recovery and fails immediately on CI failure (current behavior minus Claude).Behavior change:
--max-retriesflag stays generic. Recovery loop calls the hook'srecover()on each attempt.Implementation Notes
iw-runalready supports plugin hooks ($plugin_dir/hooks/*.hook-{cmd}.scala). The reflection pass just needs to look for the new trait types alongsideCheck.core/model/as pure interfaces.--promptflag on start/open becomes a generic parameter passed through to hooks.Acceptance Criteria
SessionAction,FixAction,RecoveryActiontraits defined incore/model/startinvokesSessionActionhook instead of hardcoding ClaudeopeninvokesSessionActionhook instead of hardcoding Claudedoctor --fixinvokesFixActionhook instead of hardcoding Claudephase-mergeinvokesRecoveryActionhook instead of hardcoding Claude*.hook-doctor.scalacheck hooks still work unchanged--promptflag still works on start/open (passed through to hook context)Estimated Effort
3-4 hours
Related