Skip to content

feat: replace shell hook scripts with native Go subcommands (#79)#104

Merged
nvandessel merged 1 commit intomainfrom
feature/windows-support
Feb 17, 2026
Merged

feat: replace shell hook scripts with native Go subcommands (#79)#104
nvandessel merged 1 commit intomainfrom
feature/windows-support

Conversation

@nvandessel
Copy link
Copy Markdown
Owner

Summary

  • Windows support: Replaces bash/jq-dependent shell scripts with native Go floop hook subcommands, eliminating the primary blocker for Windows builds
  • Build-tagged signal handling: Splits syscall.SIGTERM (Unix-only) into platform-specific files (signal_unix.go, signal_windows.go) so GOOS=windows go build succeeds
  • 4 new hook subcommands: floop hook session-start, first-prompt, dynamic-context, detect-correction — each reads JSON from stdin and outputs behavior injection text to stdout
  • Migration path: floop upgrade detects old .sh scripts, removes them, and reconfigures with native commands; floop init no longer extracts embedded scripts
  • CI: Adds Windows cross-compile step (GOOS=windows GOARCH=amd64 go build)
  • Docs: Updated CLI_REFERENCE.md and claude-code.md integration guide

Test plan

  • All existing tests pass (go test ./... — 27 packages)
  • New cmd_hook_test.go covers all 4 subcommands (session-start, first-prompt with dedup, dynamic-context routing, detect-correction)
  • Updated cmd_upgrade_test.go covers migration, up-to-date, and force scenarios
  • Updated main_test.go verifies init produces native commands (not .sh references)
  • gofmt clean
  • GOOS=windows GOARCH=amd64 go build ./cmd/floop succeeds

🤖 Generated with Claude Code

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 16, 2026

Greptile Summary

This PR replaces bash/jq-dependent shell scripts with native Go floop hook subcommands, enabling Windows support while maintaining all existing functionality. The migration is well-architected with comprehensive tests and a smooth upgrade path.

Key changes:

  • Added 4 new hook subcommands (session-start, first-prompt, dynamic-context, detect-correction) that read JSON from stdin and call internal packages directly
  • Split signal handling into platform-specific files (signal_unix.go, signal_windows.go) using build tags to resolve syscall.SIGTERM Windows incompatibility
  • Updated floop init to configure native commands instead of extracting embedded shell scripts
  • Added floop upgrade command that detects old .sh scripts and migrates them automatically
  • CI now includes Windows cross-compilation verification
  • All 27 test packages pass, new comprehensive tests added

Migration path:

  • New installations: floop init configures native commands directly
  • Existing installations: floop upgrade detects old scripts, removes them, and reconfigures with native commands
  • Backward compatibility: Upgrade command safely handles all migration scenarios (no installation, already native, old scripts present)

Confidence Score: 5/5

  • Safe to merge - well-tested Windows compatibility improvement with comprehensive migration path
  • Score reflects excellent implementation quality: comprehensive test coverage (418 lines of new tests for hooks, updated tests for upgrade/init), proper platform-specific build tags for Windows compatibility, smooth migration path for existing users, all 27 test packages passing, CI verification of Windows builds, and clean architectural separation of concerns. No security issues, no breaking changes for existing users.
  • No files require special attention

Important Files Changed

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
Loading

Last reviewed commit: b410f4b

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

28 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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>
@nvandessel nvandessel force-pushed the feature/windows-support branch from b410f4b to 1c97bba Compare February 17, 2026 02:17
@nvandessel nvandessel marked this pull request as draft February 17, 2026 02:19
@nvandessel nvandessel marked this pull request as ready for review February 17, 2026 03:20
@nvandessel
Copy link
Copy Markdown
Owner Author

Code review

No 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 👎.

@nvandessel nvandessel merged commit 125101f into main Feb 17, 2026
9 checks passed
@nvandessel nvandessel deleted the feature/windows-support branch February 17, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant