Skip to content

feat(ghook): add Droid CLI route#5

Merged
joshwilhelmi merged 1 commit intomainfrom
ghook-droid-route
Apr 28, 2026
Merged

feat(ghook): add Droid CLI route#5
joshwilhelmi merged 1 commit intomainfrom
ghook-droid-route

Conversation

@joshwilhelmi
Copy link
Copy Markdown
Contributor

@joshwilhelmi joshwilhelmi commented Apr 28, 2026

Adds Factory Droid as a first-class ghook source via --cli=droid, including diagnose support, inbox envelope source handling, daemon forwarding to /api/hooks/execute with source droid, and Droid-specific success/failure exit behavior.

Validation:

  • cargo test --manifest-path crates/ghook/Cargo.toml --no-default-features
  • cargo clippy --manifest-path crates/ghook/Cargo.toml --no-default-features -- -D warnings

Summary by CodeRabbit

  • New Features

    • Added support for Factory's droid CLI as a recognized source
    • Droid hook requests are now forwarded to the unified daemon endpoint
    • Updated exit code behavior: blocks return exit code 2 with daemon-provided reason; transport errors return exit code 1
  • Documentation

    • Updated README and guides to list droid as a supported CLI option
    • Added droid-specific hook conventions and behavior documentation
    • Version bumped to 0.4.0

Copilot AI review requested due to automatic review settings April 28, 2026 03:33
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The pull request introduces version 0.4.0 of ghook, adding support for Factory's Droid CLI as a first-class source. The daemon recognizes incoming droid envelopes with source: "droid", and response handling now includes droid-specific logic: exit code 2 with reason for daemon blocks, exit 1 with stderr diagnostics for transport failures, and exit 0 for successful processing. Configuration, schema, and comprehensive test coverage are included.

Changes

Cohort / File(s) Summary
Version & Release Notes
CHANGELOG.md, crates/ghook/Cargo.toml, crates/ghook/README.md
Version bump to 0.4.0 with changelog entry documenting droid CLI recognition, unified daemon forwarding, and droid-specific block/failure handling; README updated to list Droid as a supported CLI.
Schema & Configuration
crates/ghook/schemas/inbox-envelope.v1.schema.json, crates/ghook/src/cli_config.rs
JSON schema updated to document droid as a supported source identifier; cli_config.rs adds droid CLI entry with empty critical/terminal-context hooks, json_error_exit_code: 1, and test coverage for droid configuration and case-insensitivity.
Core Response Logic
crates/ghook/src/main.rs, crates/ghook/src/transport.rs
main.rs implements droid-specific response handling: checks continue field for blocks (exit 2 with reason), exits 0 for meaningful JSON, and routes transport failures to stderr-only diagnostics (exit 1); CLI help text lists droid as available value; transport.rs adds test verifying droid envelope POST construction and delivery.
Serialization & Diagnostics Tests
crates/ghook/src/envelope.rs, crates/ghook/src/diagnose.rs
envelope.rs adds test verifying droid source serialization with PascalCase hook type preservation; diagnose.rs adds test confirming droid hook recognition, non-critical classification, and no terminal-context preview.
Documentation Guides
docs/guides/ghook-development-guide.md, docs/guides/ghook-user-guide.md
Development guide updates CLI architecture list, cli_config.rs registry description, and Envelope.source to include droid; user guide adds droid entry to per-CLI registry table, updates --cli help text, and bumps documented version to 0.4.0 with example output.

Sequence Diagram

sequenceDiagram
    actor User
    participant ghook as ghook CLI
    participant Daemon as Unified Daemon
    participant DroidCLI as Droid CLI

    User->>ghook: Invoke hook (from Droid CLI context)
    ghook->>ghook: Detect source: "droid"<br/>(CliConfig::for_cli)
    ghook->>ghook: Create Envelope<br/>(source: "droid",<br/>hook_type, input_data)
    ghook->>Daemon: POST /hook<br/>(envelope JSON)
    Daemon->>DroidCLI: Execute hook
    DroidCLI-->>Daemon: Return response
    Daemon-->>ghook: 200 OK<br/>{continue: true/false,<br/>reason, ...}
    alt continue: false (Block)
        ghook->>ghook: Extract reason
        ghook-->>User: exit 2, stdout: response JSON<br/>stderr: reason
    else continue: true (Success)
        ghook-->>User: exit 0, stdout: response JSON
    end
    alt Daemon Transport Error
        Daemon-->>ghook: Connection error / Timeout
        ghook-->>User: exit 1, stderr: error message
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A droid now joins our hook brigade,
With daemon flows that will not fade,
Exit codes sing their tales so true—
Two for blocks, one for error's brew! 🚀

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 76.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely summarizes the main change: adding Droid CLI as a new route/source to ghook, which is the primary purpose of this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ghook-droid-route

Comment @coderabbitai help to get the list of available commands and usage tips.

@joshwilhelmi joshwilhelmi merged commit 4fd5f44 into main Apr 28, 2026
3 of 4 checks passed
@joshwilhelmi joshwilhelmi deleted the ghook-droid-route branch April 28, 2026 03:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Factory droid as a first-class ghook host CLI (--cli=droid), wiring it through diagnose/dispatch flows and updating versioning/docs to reflect the new integration.

Changes:

  • Register droid in the per-CLI config/diagnose surfaces and preserve droid hook payload + source through the envelope/POST request.
  • Implement Droid-specific response/exit-code handling for daemon success/failure responses.
  • Bump gobby-hooks to 0.4.0 and update docs/schemas/changelog accordingly.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/guides/ghook-user-guide.md Documents --cli=droid and Droid-specific behavior; updates sample diagnose output to 0.4.0.
docs/guides/ghook-development-guide.md Updates architecture/module docs for Droid + version 0.4.0 references.
crates/ghook/src/transport.rs Adds a droid-focused POST test ensuring the request contains source: "droid" and uses the unified endpoint.
crates/ghook/src/main.rs Adds Droid-specific success/failure response handling and unit tests.
crates/ghook/src/envelope.rs Adds a test asserting droid envelope preserves PascalCase hook type + source: "droid".
crates/ghook/src/diagnose.rs Adds a test ensuring --diagnose recognizes droid and reports noncritical/no terminal context.
crates/ghook/src/cli_config.rs Registers droid as a recognized CLI with empty critical/terminal-context sets.
crates/ghook/schemas/inbox-envelope.v1.schema.json Updates schema description to include droid as a valid source identifier.
crates/ghook/README.md Adds Factory droid to the supported host-CLI list.
crates/ghook/Cargo.toml Bumps gobby-hooks version to 0.4.0.
Cargo.lock Updates lockfile entry for gobby-hooks 0.4.0.
CHANGELOG.md Adds gobby-hooks 0.4.0 release notes for the droid integration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/ghook/README.md
Comment on lines 5 to 7
`ghook` is invoked by host AI CLIs (Claude Code, Codex, Gemini CLI, Qwen
CLI) on lifecycle and tool-use events. It enqueues an envelope to
CLI, Factory droid) on lifecycle and tool-use events. It enqueues an envelope to
`~/.gobby/hooks/inbox/` *before* attempting to POST to the local Gobby
Comment on lines +466 to +469
assert!(request.contains("\"hook_type\":\"PreToolUse\""));
assert!(request.contains("\"source\":\"droid\""));
assert!(request.contains("\"input_data\":{\"hook_event_name\":\"PreToolUse\""));
assert!(request.contains("\"tool_input\":{\"file_path\":\"src/main.rs\"}"));
| `qwen` | `SessionStart` | `SessionStart` |
| `droid` | none | none |

Droid uses PascalCase hook types (`SessionStart`, `PreToolUse`, `PostToolUse`, `UserPromptSubmit`, `Notification`, `Stop`, `SubagentStop`, `PreCompact`, `SessionEnd`) and ghook forwards droid's stdin payload unchanged to the daemon with `source: "droid"`. Droid-specific block handling differs slightly from the other CLIs: daemon responses containing `continue:false` exit 2, while other meaningful response JSON is written to stdout with exit 0.

```text
host AI CLI (Claude Code / Codex / Gemini / Qwen)
host AI CLI (Claude Code / Codex / Gemini / Qwen / Droid)
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.

2 participants