The main agent implementation file cmd/entire/cli/agent/factoryaidroid/factoryaidroid.go has no unit tests. The sibling files (hooks.go, lifecycle.go, transcript.go) all have tests, but the core Agent interface methods are untested. This is a coverage gap for the identity methods, transcript handling, hook parsing, session stubs, and presence detection.
Approach
Create cmd/entire/cli/agent/factoryaidroid/factoryaidroid_test.go following the same patterns used by:
All tests use t.Parallel() except TestDetectPresence (uses t.Chdir)
Factory AI Droid uses JSONL format (not JSON like Gemini), so chunk/reassemble delegates to agent.ChunkJSONL/agent.ReassembleJSONL
ParseHookInput uses agent.ReadAndParseHookInput[sessionInfoRaw] generically — tests confirm the JSON fields map correctly to HookInput
Verification
bash
mise run fmt && mise run lint && mise run test:ci
If you need specific details from before exiting plan mode (like exact code snippets, error messages, or content you generated), read the full transcript at: /Users/alisha/.REDACTED.jsonl
Assistant
I'll start by reading the source files I need to understand before writing the tests.
Assistant
Let me also check the agent package for the shared types and the ChunkJSONL/ReassembleJSONL functions.
Assistant
Let me check ReadAndParseHookInput and how DetectPresence uses paths.RepoRoot().
Assistant
Now I have a thorough understanding of the codebase. Let me write the test file.
★ Insight ─────────────────────────────────────
Factory AI Droid uses JSONL format (newline-delimited JSON), unlike Gemini which uses a single JSON object with a messages array. This means ChunkJSONL splits on line boundaries, while Gemini's chunker splits on message boundaries within the JSON structure.
DetectPresence has a graceful fallback: when paths.RepoRoot() fails (e.g., not in a git repo), it falls back to ".". This lets tests work in temp dirs without needing a git init.
ParseHookInput uses Go generics (ReadAndParseHookInput[sessionInfoRaw]) to deserialize the hook's stdin JSON into the agent-specific type, then maps it to the common HookInput struct. Each agent defines its own raw types but returns the same shared interface.
─────────────────────────────────────────────────
Assistant
Now let me run the tests to verify they pass.
Assistant
All 23 new tests pass. Now let me run the full verification suite as specified in the plan.
Assistant
All green — formatting, linting, and full CI test suite pass with zero issues.
★ Insight ─────────────────────────────────────
Test parallelism strategy: TestDetectPresence cannot use t.Parallel() because t.Chdir() modifies process-global state (Go's test framework panics if you call t.Chdir after t.Parallel). All other tests are parallel since they operate on independent temp dirs or pure functions.
JSONL round-trip testing: The round-trip test (ChunkTranscript → ReassembleTranscript) verifies exact byte equality, which works because JSONL chunking splits on line boundaries and reassembly joins with \n. This is simpler than Gemini's JSON-based chunking which requires deserializing and comparing message counts since JSON marshaling may reorder fields.
Stub method testing: Even though GetSessionDir, ReadSession, and WriteSession are stubs returning "not implemented" errors, testing them documents the current contract and will catch regressions if someone accidentally removes the error return or changes the behavior.
─────────────────────────────────────────────────
Here's a summary of what was created:
New file: cmd/entire/cli/agent/factoryaidroid/factoryaidroid_test.go
23 test functions covering all public methods on FactoryAIDroidAgent:
add factoryaidroid to integration test folder like agent_test.go
User
[Request interrupted by user]
User
add factoryaidroid to integration test folder like agent_test.go
Assistant
Let me start by reading the existing plan file and exploring the integration test folder to understand the current patterns.
Assistant
Good, I have a thorough understanding from the explore agent. Let me now read the key files directly to confirm the patterns before designing the plan.
Assistant
Now let me check what HookSupport interface looks like and whether factoryaidroid implements it.
Assistant
Now let me check the agent_strategy_test.go and the hooks helper to understand how they work with different agents.
Assistant
Let me check the hooks.go helper for what's available for Droid simulation, and the lifecycle.go in the factoryaidroid package.
Assistant
Let me check the relevant parts of testenv.go for agent initialization and the Gemini-specific integration tests in agent_strategy.
Assistant
Let me check if there's an existing setup_factoryai hooks test or Gemini strategy test to see the full pattern.
Assistant
Now let me check the lifecycle.go to understand how the Droid hooks work with the transcript format.
Assistant
Now I have a complete picture. Let me design the plan with a Plan agent.
Assistant
Let me verify the Droid transcript format before finalizing the plan.
Assistant
Now I have everything I need. Let me write the final plan.