Add Autohand Code agent integration#585
Conversation
Register autohand-code as a new agent in the registry with its corresponding display name "Autohand Code".
Create the autohandcode package with: - Core agent struct implementing the Agent interface - Self-registration via init() - Session storage at ~/.autohand/sessions/<id>/conversation.jsonl - AUTOHAND_HOME env var support for custom home directory - Type definitions for Autohand's config format, hook stdin JSON schema, transcript message format, and file modification tool names (write_file, edit_file, create_file, patch_file)
Implement InstallHooks, UninstallHooks, AreHooksInstalled for .autohand/config.json. Hooks use Autohand's array-based config format with event/command/description fields. Installs hooks for session-start, pre-prompt, stop, session-end, and subagent-stop events. Adds permission deny rule for .entire/metadata files.
Implement ParseHookEvent mapping Autohand hooks to normalized events: - session-start -> SessionStart - pre-prompt -> TurnStart (with instruction as prompt) - stop -> TurnEnd - session-end -> SessionEnd - subagent-stop -> SubagentEnd - notification -> no-op Also implement TranscriptAnalyzer, TokenCalculator, SubagentAwareExtractor, and HookResponseWriter interfaces. Transcript path is computed from session_id since Autohand does not include transcript_path in hook stdin.
Parse Autohand's JSONL transcript format which uses direct role fields (no envelope wrapper). Extract modified files from the toolCalls array on assistant messages. Calculate token usage from _meta fields. Support subagent transcript aggregation.
86 tests covering all agent components: - autohandcode_test.go: identity, session storage, transcript I/O - hooks_test.go: install/uninstall, idempotency, force reinstall, permission rules, user hook preservation - lifecycle_test.go: event parsing for all hook types, table-driven - transcript_test.go: JSONL parsing, file extraction from toolCalls, token usage from _meta, subagent ID extraction, deduplication
Add blank imports in config.go and hooks_cmd.go to trigger init() self-registration. This makes autohand-code available in the agent registry and generates hook subcommands under entire hooks autohand-code.
Apply gofmt -s -w to fix struct tag alignment and spacing issues in types.go and hooks.go.
Verify entire enable --agent autohand-code: - Installs all 5 required hooks in .autohand/config.json - Adds permission deny rule for .entire/metadata/** - Preserves existing user hooks and custom config fields
Add Autohand Code and Factory AI Droid to the agent implementations list in the Key Directories section.
There was a problem hiding this comment.
Pull request overview
Adds Autohand Code as a first-class agent integration in Entire CLI, following the established agent strategy pattern (hooks + lifecycle events + transcript parsing/token usage) so Autohand sessions can be captured and analyzed like other supported agents.
Changes:
- Introduces
cmd/entire/cli/agent/autohandcode/implementing agent identity, hook installation/uninstall, lifecycle parsing, transcript analysis, and token accounting. - Registers the new agent via blank imports and adds new agent name/type constants to the registry.
- Adds extensive unit tests and an integration test to validate hook installation into
.autohand/config.json.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/integration_test/setup_autohand_hooks_test.go | Integration coverage ensuring entire enable --agent autohand-code writes hooks + deny rule to .autohand/config.json. |
| cmd/entire/cli/hooks_cmd.go | Ensures Autohand agent is registered before hook subcommands enumerate agents. |
| cmd/entire/cli/config.go | Ensures Autohand agent self-registers during CLI initialization. |
| cmd/entire/cli/agent/registry.go | Adds AgentNameAutohandCode / AgentTypeAutohandCode constants. |
| cmd/entire/cli/agent/autohandcode/types.go | Defines Autohand config schema + transcript/hook payload types used across the integration. |
| cmd/entire/cli/agent/autohandcode/transcript.go | Implements JSONL parsing, modified-file extraction, subagent detection, and token usage aggregation. |
| cmd/entire/cli/agent/autohandcode/lifecycle.go | Implements lifecycle hook parsing + transcript analyzer/token calculator adapters for Entire’s normalized event model. |
| cmd/entire/cli/agent/autohandcode/hooks.go | Implements .autohand/config.json hook installation/uninstall and permissions deny rule management. |
| cmd/entire/cli/agent/autohandcode/transcript_test.go | Unit tests for transcript parsing, file extraction, subagent handling, prompts/summary, and token logic. |
| cmd/entire/cli/agent/autohandcode/lifecycle_test.go | Unit tests for lifecycle hook parsing and hook response writer behavior. |
| cmd/entire/cli/agent/autohandcode/hooks_test.go | Unit tests for hook installation/uninstall idempotency, preservation, and permissions deny rule behavior. |
| cmd/entire/cli/agent/autohandcode/autohandcode_test.go | Unit tests for agent identity, session dir resolution, transcript read/write, and session round-trips. |
| cmd/entire/cli/agent/autohandcode/autohandcode.go | New agent implementation + self-registration with the agent registry. |
| CLAUDE.md | Documentation update to include Autohand Code in the agent list. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Doesn't change the functionality. Just name convention. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@igorcosta thanks for making this PR. We are right now rethinking how we integrate more agents and especially how we can make sure that if we keep merging agent support into the codebase how we can maintain them going forward. For this reason we started this PR #604 once it in we will work on more documentation/instructions but I was wondering if you would be interested in giving this approach a try? |
We're delighted to join the alliance, this
PRintroduces Autohand code cli to it.autohand-codeas a new agent in the Entire CLI, following the same pattern asthe Factory AI Droid integration (Add Factory AI Droid agent integration #435)
parsing, transcript analysis, and token calculation
.autohand/config.json(session-start, pre-prompt, stop,session-end, subagent-stop) plus a permission deny rule for
.entire/metadata/**extracted from
toolCallsarrays and token usage from_metafieldsNew Files
cmd/entire/cli/agent/autohandcode/- Full agent package (autohandcode.go,types.go, hooks.go, lifecycle.go, transcript.go)
cmd/entire/cli/agent/autohandcode/*_test.go- Unit tests (4 files)cmd/entire/cli/integration_test/setup_autohand_hooks_test.go- Integration testsModified Files
cmd/entire/cli/agent/registry.go- Added agent name/type constantscmd/entire/cli/config.go- Added blank import for self-registrationcmd/entire/cli/hooks_cmd.go- Added blank import for hook subcommandsCLAUDE.md- Updated agent listTest plan
mise run test- all unit tests passmise run test:integration- integration tests pass with race detectionmise run lint- no lint issuesentire enable --agent autohand-codeinstalls hooks to.autohand/config.jsonentire hooks autohand-code <event>andverify processing