feat: replace shell hook scripts with native Go subcommands (#79)#104
Merged
nvandessel merged 1 commit intomainfrom Feb 17, 2026
Merged
feat: replace shell hook scripts with native Go subcommands (#79)#104nvandessel merged 1 commit intomainfrom
nvandessel merged 1 commit intomainfrom
Conversation
Greptile SummaryThis PR replaces bash/jq-dependent shell scripts with native Go Key changes:
Migration path:
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| cmd/floop/cmd_hook.go | New file implementing 4 native Go hook subcommands (session-start, first-prompt, dynamic-context, detect-correction) to replace shell scripts |
| cmd/floop/cmd_hook_test.go | Comprehensive test coverage for all 4 hook subcommands with edge cases (empty input, missing fields, dedup verification) |
| internal/mcp/signal_unix.go | Platform-specific signal handling for Unix (SIGINT + SIGTERM) using build tags |
| internal/mcp/signal_windows.go | Platform-specific signal handling for Windows (os.Interrupt only) using build tags |
| cmd/floop/cmd_upgrade.go | Upgrade command detects and migrates old .sh scripts to native commands, handles both global and project scopes |
| cmd/floop/cmd_init.go | Updated to skip shell script extraction, now configures native hook commands directly |
| internal/hooks/claude.go | Updated GenerateHookConfig to generate "floop hook " commands instead of .sh script paths |
| .github/workflows/ci.yml | Added Windows cross-compilation step to verify GOOS=windows builds succeed |
Flowchart
flowchart TD
A[Claude Code Hook Events] --> B{Event Type}
B -->|SessionStart| C[floop hook session-start]
B -->|UserPromptSubmit| D[floop hook first-prompt]
B -->|UserPromptSubmit| E[floop hook detect-correction]
B -->|PreToolUse| F[floop hook dynamic-context]
C --> G[Load behaviors from local + global stores]
D --> H{Session already seen?}
H -->|No - first time| G
H -->|Yes - dedup| I[Exit silently]
E --> J{MightBeCorrection?}
J -->|Yes| K[LLM extraction with 5s timeout]
J -->|No| I
K --> L{Valid correction?}
L -->|Yes| M[Process & store behavior]
L -->|No| I
F --> N{Tool Type}
N -->|Read/Edit/Write| O[Extract file path]
N -->|Bash| P[Detect task from command]
N -->|Other| I
O --> Q[Spreading activation pipeline]
P --> Q
G --> R[Evaluate activation conditions]
R --> S[Apply token budget tiering]
Q --> S
S --> T[Output markdown injection text]
M --> U[Append to corrections.jsonl]
style C fill:#90EE90
style D fill:#90EE90
style E fill:#FFD700
style F fill:#87CEEB
style T fill:#98FB98
style M fill:#FFA07A
Last reviewed commit: b410f4b
Eliminates bash/jq dependency for Claude Code hooks, enabling Windows support. Shell scripts are replaced by `floop hook` subcommands (session-start, first-prompt, dynamic-context, detect-correction) that read JSON from stdin and output behavior injection text directly. - Add build-tagged signal helpers (signal_unix.go, signal_windows.go) to fix syscall.SIGTERM compilation on Windows - Add `floop hook` parent command with 4 subcommands handling all Claude Code hook events (SessionStart, UserPromptSubmit, PreToolUse) - Update GenerateHookConfig to emit "floop hook <name>" commands - Update init (remove script extraction) and upgrade (migrate .sh to native) - Delete embedded shell scripts, embed.go, and ExtractScripts function - Add Windows cross-compile step to CI - Update CLI_REFERENCE.md and claude-code.md integration docs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b410f4b to
1c97bba
Compare
3 tasks
Owner
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
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
floop hooksubcommands, eliminating the primary blocker for Windows buildssyscall.SIGTERM(Unix-only) into platform-specific files (signal_unix.go,signal_windows.go) soGOOS=windows go buildsucceedsfloop hook session-start,first-prompt,dynamic-context,detect-correction— each reads JSON from stdin and outputs behavior injection text to stdoutfloop upgradedetects old.shscripts, removes them, and reconfigures with native commands;floop initno longer extracts embedded scriptsGOOS=windows GOARCH=amd64 go build)Test plan
go test ./...— 27 packages)cmd_hook_test.gocovers all 4 subcommands (session-start, first-prompt with dedup, dynamic-context routing, detect-correction)cmd_upgrade_test.gocovers migration, up-to-date, and force scenariosmain_test.goverifies init produces native commands (not .sh references)gofmtcleanGOOS=windows GOARCH=amd64 go build ./cmd/floopsucceeds🤖 Generated with Claude Code