Skip to content

droid integration - #744

Closed
ahjota wants to merge 7 commits into
Gentleman-Programming:mainfrom
ahjota:fix/read-tool-ambiguous-envelope
Closed

droid integration#744
ahjota wants to merge 7 commits into
Gentleman-Programming:mainfrom
ahjota:fix/read-tool-ambiguous-envelope

Conversation

@ahjota

@ahjota ahjota commented Aug 23, 2026

Copy link
Copy Markdown

🔗 Linked Issue

Closes #


🏷️ PR Type

  • type:bug — Bug fix
  • type:feature — New feature
  • type:docs — Documentation only
  • type:refactor — Code refactoring (no behavior change)
  • type:chore — Maintenance, dependencies, tooling
  • type:breaking-change — Breaking change

📝 Summary

📂 Changes

File Change
path/to/file What changed

🧪 Test Plan

  • Unit tests pass locally: go test ./...
  • E2E tests pass locally: go test -tags e2e ./internal/server/...
  • Manually tested the affected functionality

🤖 Automated Checks

These run automatically and all must pass before merge:

Check What it verifies Status
Check Issue Reference PR body contains Closes #N / Fixes #N / Resolves #N
Check Issue Has status:approved Linked issue has status:approved label
Check PR Has type:* Label PR has exactly one type:* label
Unit Tests go test ./... passes
E2E Tests go test -tags e2e ./internal/server/... passes

✅ Contributor Checklist

  • I linked an approved issue above (Closes #N)
  • I added exactly one type:* label to this PR
  • I ran unit tests locally: go test ./...
  • I ran e2e tests locally: go test -tags e2e ./internal/server/...
  • Docs updated (if behavior changed)
  • Commits follow conventional commits format
  • No Co-Authored-By trailers in commits

💬 Notes for Reviewers

Summary by CodeRabbit

  • New Features

    • Added engram setup droid integration for MCP configuration, hooks, and plugin installation.
    • Added Droid session hooks for project detection, prompt persistence, and save reminders.
    • Added guidance for resolving ambiguous projects and searching across projects.
  • Bug Fixes

    • Improved read-tool errors with available project details and recovery guidance.
  • Documentation

    • Documented Droid setup, configuration, validation, and troubleshooting.
    • Updated agent setup references and memory-tool instructions across supported integrations.

ahjota and others added 7 commits August 16, 2026 14:00
Implement engram setup droid for Factory Droid integration.

- Registers mcpServers.engram in ~/.factory/mcp.json with absolute binary path.

- Extracts UserPromptSubmit hook scripts to ~/.factory/hooks/engram/.

- Writes UserPromptSubmit entry to ~/.factory/hooks.json as a workaround for Droid not executing plugin UserPromptSubmit hooks.

- Installs the Engram plugin via droid plugin marketplace/install.

- Updates README and docs/AGENT-SETUP.md with Droid instructions.
Update the Droid installer to write ~/.factory/hooks.json in the standalone

format Droid expects, and use the correct engram___* ToolSearch select

pattern instead of the Claude Code mcp__engram__* pattern.

This ensures the UserPromptSubmit hook output is understood by Droid's

ToolSearch when the hook fires in interactive sessions.
Add DROID-SETUP-NOTES.md documenting the engram setup droid command,

validation findings, known limitations, and current user configuration.
Read tools (mem_search, mem_context, mem_stats, mem_doctor, mem_timeline,
mem_review) previously returned plain text "Project resolution failed: ..." when
project resolution hit an ambiguous cwd or unknown explicit project. This broke
REQ-314 and gave agents no available_projects to recover with.

Add a readProjectErrorResult helper that delegates to writeProjectErrorResult
and emits a structured JSON envelope with error_code, available_projects, and a
read-specific hint. No recovery_token is issued for reads because they only need
an explicit project override, not a project_choice_reason.

mem_get_observation is left unchanged; its degraded plain-text path is
intentional.

Also adds TestReadTools_AmbiguousEnvelope covering the five non-exempt read
tools and the no-recovery-token assertion.
Add a Droid-first-message recovery line for ambiguous_project errors in the
user-prompt-submit hook, and sync an AMBIGUOUS PROJECT section across all shared
protocol-text sources (setup.go memoryProtocolMarkdown, claude-code/codex
session-start and post-compaction hooks, opencode/pi TypeScript plugins, and the
claude-code/codex engram-memory skills). Also update CHANGELOG.md.
The injected protocol told agents when to call mem_save but not that
content is required, so proactive saves emitted {title,type} only and
tripped the runtime content-required guard (upstream Gentleman-Programming#363). Add a
content-format reminder to the Droid UserPromptSubmit injection and the
Claude Code ACTIVE PROTOCOL heredoc.

Refs Gentleman-Programming#363

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
When Droid starts in a parent directory containing multiple git repos,
the Engram read tools fail with ambiguous_project. The
UserPromptSubmit hook now scans child repos on the first message and,
if more than one is found, injects the candidate list and a rule that
tells the agent to always pass project=<matching repo> on read tools.

This keeps single-repo behavior unchanged and avoids the extra
ambiguous_project round-trip.

- Add list_child_projects() helper mirroring Go scanChildren.
- Update print_toolsearch_message() to emit the proactive rule.
- Document behavior in DROID-SETUP-NOTES.md.

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
@ahjota

ahjota commented Aug 23, 2026

Copy link
Copy Markdown
Author

Sorry, I did not mean to open this PR; I am working on a droid plugin.

@ahjota ahjota closed this Aug 23, 2026
@ahjota ahjota changed the title engram droid integration Aug 23, 2026
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 25ff3143-a13e-4eee-a4b8-270942900865

📥 Commits

Reviewing files that changed from the base of the PR and between 47f281c and d083af6.

📒 Files selected for processing (22)
  • CHANGELOG.md
  • DROID-SETUP-NOTES.md
  • README.md
  • docs/AGENT-SETUP.md
  • internal/mcp/mcp.go
  • internal/mcp/mcp_test.go
  • internal/setup/agents.go
  • internal/setup/droid.go
  • internal/setup/droid_test.go
  • internal/setup/plugins/droid/scripts/_helpers.sh
  • internal/setup/plugins/droid/scripts/user-prompt-submit.sh
  • internal/setup/registry_test.go
  • internal/setup/setup.go
  • internal/setup/setup_test.go
  • plugin/claude-code/scripts/post-compaction.sh
  • plugin/claude-code/scripts/session-start.sh
  • plugin/claude-code/skills/memory/SKILL.md
  • plugin/codex/scripts/post-compaction.sh
  • plugin/codex/scripts/session-start.sh
  • plugin/codex/skills/memory/SKILL.md
  • plugin/opencode/engram.ts
  • plugin/pi/index.ts

📝 Walkthrough

Walkthrough

Changes

Droid integration and project resolution

Layer / File(s) Summary
Structured read-tool project errors
internal/mcp/mcp.go, internal/mcp/mcp_test.go, CHANGELOG.md
Read-oriented MCP tools share structured project-resolution errors. Ambiguous responses include available projects and read-specific guidance without recovery tokens.
Droid installer and configuration
internal/setup/..., README.md, docs/AGENT-SETUP.md, DROID-SETUP-NOTES.md
The setup command registers Droid MCP configuration, extracts hooks, writes user-level hooks, installs the marketplace plugin, preserves existing configuration, and supports repeated installs.
Droid prompt hook behavior
internal/setup/plugins/droid/scripts/*
The prompt hook detects projects, injects first-message tool instructions, persists prompts asynchronously, and emits debounced save reminders with Windows-safe handling.
Agent protocol and recovery guidance
internal/setup/setup.go, plugin/claude-code/*, plugin/codex/*, plugin/opencode/engram.ts, plugin/pi/index.ts
Agent instructions document required mem_save fields and recovery from ambiguous_project errors through explicit project selection or cross-project search.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant EngramSetup
  participant DroidCLI
  participant DroidConfig
  participant PromptHook
  participant MCPServer
  User->>EngramSetup: run engram setup droid
  EngramSetup->>DroidCLI: validate and install plugin
  EngramSetup->>DroidConfig: write MCP and user hook configuration
  DroidCLI->>PromptHook: invoke UserPromptSubmit
  PromptHook->>MCPServer: persist prompt or inspect project activity
  MCPServer-->>PromptHook: project and observation data
  PromptHook-->>DroidCLI: ToolSearch or save reminder JSON
Loading

Suggested reviewers: gentleman-programming, alan-thegentleman

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Warning

⚠️ This pull request shows signs of AI-generated slop (description_diff_mismatch, ai_padded_prose). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

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