Skip to content

feat(droid): add Factory AI Droid support#912

Closed
skrabe wants to merge 2 commits into
rtk-ai:developfrom
skrabe:feat/droid-add-factory-ai-droid-support
Closed

feat(droid): add Factory AI Droid support#912
skrabe wants to merge 2 commits into
rtk-ai:developfrom
skrabe:feat/droid-add-factory-ai-droid-support

Conversation

@skrabe

@skrabe skrabe commented Mar 29, 2026

Copy link
Copy Markdown

Summary

  • Adds RTK integration for Factory AI Droid CLI
  • Factory Droid uses a PreToolUse hook system with the same hookSpecificOutput JSON format as Claude Code, with the shell tool named Execute instead of Bash
  • Follows the Claude Code integration pattern: hook script + RTK.md + @RTK.md in AGENTS.md + settings.json patching

Changes

New files:

  • hooks/droid/rtk-rewrite.sh — Shell hook script (delegates to rtk rewrite, same JSON protocol as Claude Code)
  • hooks/droid/rtk-awareness.md — Slim RTK awareness instructions for hook-based usage
  • hooks/droid/README.md — Integration docs

Modified files:

  • src/main.rs — Added --droid flag to Init command, dispatch to run_droid(), wired into uninstall()
  • src/hooks/init.rs — Added run_droid(), patch_droid_settings(), uninstall_droid(), resolve_droid_dir()
  • README.md — Added Factory AI Droid to supported tools table and Quick Start

Install flow (rtk init -g --droid)

  1. Writes hook script to ~/.factory/hooks/rtk-rewrite.sh (chmod 755)
  2. Writes RTK.md to ~/.factory/RTK.md
  3. Adds @RTK.md reference to ~/.factory/AGENTS.md (creates if missing, preserves existing content)
  4. Patches ~/.factory/settings.json with PreToolUse hook entry (Execute matcher)

Uninstall flow (rtk init -g --droid --uninstall)

  1. Removes ~/.factory/hooks/rtk-rewrite.sh
  2. Removes ~/.factory/RTK.md
  3. Removes @RTK.md line from ~/.factory/AGENTS.md (preserves other content)
  4. Removes RTK hook entry from ~/.factory/settings.json

Test plan

  • cargo fmt --all --check passes
  • cargo clippy --all-targets — no new warnings
  • cargo test — 1138 passed, 0 failed
  • Manual: rtk init -g --droid --auto-patch installs all artifacts correctly
  • Manual: idempotent — second install doesn't duplicate @RTK.md or settings entry
  • Manual: rtk init -g --droid --uninstall removes all RTK artifacts
  • Manual: existing AGENTS.md content and settings.json custom models preserved through install/uninstall cycle
  • Manual: uninstall idempotent — second uninstall reports "nothing to remove"

@CLAassistant

CLAassistant commented Mar 29, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@sims1253

sims1253 commented Apr 4, 2026

Copy link
Copy Markdown

In hooks/droid/rtk-rewrite.sh, if rtk rewrite "$CMD" exits with code 0 but produces empty stdout (e.g., rtk binary bug, edge case), REWRITTEN becomes empty. The equality guard [ "$CMD" = "$REWRITTEN" ] is false since
CMD was non-empty, so the script falls through and emits a JSON payload with "command": "". This would replace the user's actual command with an empty string, causing Droid to execute nothing.

Suggested fix (around line 62, after REWRITTEN=$(rtk rewrite "$CMD" 2>/dev/null)):

     REWRITTEN=$(rtk rewrite "$CMD" 2>/dev/null)
     EXIT_CODE=$?

     [ -z "$REWRITTEN" ] && exit 0

@skrabe

skrabe commented Apr 5, 2026

Copy link
Copy Markdown
Author

Valid edge case, but the Claude Code hook (hooks/claude/rtk-rewrite.sh:47-54) and Cursor hook (hooks/cursor/rtk-rewrite.sh:43-49) have the exact same pattern without the empty-stdout guard. Adding it only here would create inconsistency across hooks. Would be better to add it across all three in a follow-up PR.

@sims1253

sims1253 commented Apr 5, 2026

Copy link
Copy Markdown

Fair point

…tory-ai-droid-support

# Conflicts:
#	README.md
#	src/hooks/init.rs
#	src/main.rs
@pszymkowiak

Copy link
Copy Markdown
Collaborator

Hi @skrabe — thank you for this, and apologies for the overlap. Factory Droid support has since landed on develop via #2267 (merged 2026-07-08), which covers the same ground: rtk init --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 clean — this is 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 spot anything the merged integration is missing compared to your version, please do 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.

4 participants