Skip to content

feat: add Factory Droid agent integration (rtk init -g --agent droid)#1308

Closed
ZaynJarvis wants to merge 1 commit into
rtk-ai:masterfrom
ZaynJarvis:feat/droid-integration
Closed

feat: add Factory Droid agent integration (rtk init -g --agent droid)#1308
ZaynJarvis wants to merge 1 commit into
rtk-ai:masterfrom
ZaynJarvis:feat/droid-integration

Conversation

@ZaynJarvis

Copy link
Copy Markdown

Summary

Add support for Factory Droid (factory.ai) as a supported agent in RTK.

Factory Droid uses the same PreToolUse hook architecture as Claude Code. The only differences are:

Claude Code Factory Droid
Tool name Bash Execute
Settings path ~/.claude/settings.json ~/.factory/settings.json
Hook directory ~/.claude/hooks/ ~/.factory/hooks/
Awareness doc @RTK.md in CLAUDE.md ~/.factory/RTK.md

The JSON input/output format (hookSpecificOutput, permissionDecision, updatedInput) is identical to Claude Code, so the hook script is a thin adaptation with the same delegating pattern.

Changes

New files

  • hooks/droid/rtk-rewrite.sh — Shell hook that intercepts Execute tool commands and rewrites them via rtk rewrite
  • hooks/droid/rtk-awareness.md — Slim awareness doc for Droid context
  • hooks/droid/README.md — Integration documentation with installation, testing, and uninstall instructions

Source changes

  • src/main.rs — Add Droid variant to AgentTarget enum, wire up install_droid and droid_uninstall flags
  • src/hooks/init.rs — Add:
    • install_droid_hooks() — writes hook script, RTK.md, patches settings.json
    • remove_droid_hooks() — cleans up all Droid artifacts
    • patch_droid_settings_json() — adds PreToolUse entry for Execute matcher
    • droid_hook_already_present() / remove_droid_hook_from_json() — idempotency helpers
    • Droid status checks in show_config()
    • Validation: rtk init -g --agent droid is global-only

Documentation

  • hooks/README.md — Add Factory Droid row in Supported Agents table, JSON format section, and directory listing

Usage

# Install
rtk init -g --agent droid

# Verify
rtk init --show

# Uninstall
rtk init -g --agent droid --uninstall

Testing

# Manual test
echo '{"tool_name":"Execute","tool_input":{"command":"git status"}}' | ~/.factory/hooks/rtk-rewrite.sh
# Expected: {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"allow","permissionDecisionReason":"RTK auto-rewrite","updatedInput":{"command":"rtk git status"}}}

# Build check
cargo check  # 0 errors

Design Notes

  • Follows the Full hook integration tier (shell script, intercepts commands via agent hook API)
  • Follows the exit code contract: exits 0 on all error paths (missing jq, missing rtk, old version, no match)
  • Same version guard as Claude Code hook (requires rtk >= 0.23.0)
  • Settings.json patch uses matcher: "Execute" to match Droid shell execution tool
  • Graceful degradation: if anything fails, the original command runs unmodified

Add support for Factory Droid (factory.ai) as a supported agent. Droid
uses the same PreToolUse hook architecture as Claude Code, with the
only difference being the tool name (Execute vs Bash) and the settings
file location (~/.factory/settings.json vs ~/.claude/settings.json).

New files:
- hooks/droid/rtk-rewrite.sh: Shell hook for Execute tool commands
- hooks/droid/rtk-awareness.md: Slim awareness doc for Droid context
- hooks/droid/README.md: Integration documentation

Source changes:
- Add Droid to AgentTarget enum in main.rs
- Add install_droid_hooks/remove_droid_hooks in init.rs
- Add patch_droid_settings_json for ~/.factory/settings.json
- Add droid status checks to show_config
- Wire up --agent droid to init and uninstall flows

Documented in hooks/README.md with JSON format examples.
@CLAassistant

CLAassistant commented Apr 14, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ZaynJarvis

Copy link
Copy Markdown
Author

not sure what's the CI error.

@hataiit9x

Copy link
Copy Markdown

+1 please add droid

@sims1253

Copy link
Copy Markdown

duplicate of #912 ?

@skrabe

skrabe commented May 7, 2026

Copy link
Copy Markdown

duplicate of #912 ?

yup

@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hi @ZaynJarvis — thank you for this, and apologies for the overlap. Factory Droid support has since landed on develop via #2267 (merged 2026-07-08): rtk init -g --agent droid, uninstall, and the PreToolUse hook are all in place now.

Since the feature is already shipped, I'm closing this as superseded to keep the queue tidy — no reflection on your work, the timing just didn't line up (your PR predated #2267 but sat in merge conflict while the other landed).

If you notice anything the merged integration is missing compared to your version, please open a follow-up PR or an issue pointing at the gap — happy to review that. Thanks again for contributing!

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.

6 participants