Pull Request: Integrate Trae Agent and Implement iFlow CLI Agent (Preview)#701
Open
wangxumarshall wants to merge 18 commits intoentireio:mainfrom
Open
Pull Request: Integrate Trae Agent and Implement iFlow CLI Agent (Preview)#701wangxumarshall wants to merge 18 commits intoentireio:mainfrom
wangxumarshall wants to merge 18 commits intoentireio:mainfrom
Conversation
Add support for Trae Agent (ByteDance's LLM-based software engineering agent): - Implement Agent interface with full hook support - Add HookTypes for before_agent, after_agent, before_model, after_model, etc. - Support JSON trajectory transcript format - Implement ParseHookEvent for lifecycle event translation - Add hook installation/uninstallation for .trae/settings.json This integration is marked as preview status.
Add types, main agent struct, and lifecycle event parsing for iFlow CLI integration. - types.go: Define settings, hooks, transcript structures and constants - iflow.go: Implement Agent interface with session management - lifecycle.go: Parse hook events into normalized lifecycle events
- hooks.go: Implement HookSupport interface for auto-installation of hooks - transcript.go: Parse and extract file modifications from JSONL transcripts
- Add iflow agent to registry with AgentNameIFlow and AgentTypeIFlow - Import iflow package in hooks_cmd.go for auto-registration - Add comprehensive unit tests for all iflow agent components
CLAUDE.md is a local development file that should not be committed.
- Add comprehensive lifecycle tests for all hook types - Improve type definitions with better JSON tags - Add WriteHookResponse implementation - Add transcript parsing tests
According to iFlow CLI documentation, all hook configurations must use
the 'hooks' array wrapper format. Previously, SetUpEnvironment, Stop,
SubagentStop, and SessionEnd used a flat format which caused hooks to
not be triggered.
Changes:
- types.go: Unify all hook types to use IFlowHookMatcher format
- hooks.go: Update hook installation to use correct nested format
Before (incorrect):
"Stop": [{"type": "command", "command": "..."}]
After (correct):
"Stop": [{"hooks": [{"type": "command", "command": "..."}]}]
iFlow CLI passes hook data via environment variables in addition to stdin JSON. Add support for reading from env vars as fallback. Also add computeTranscriptPath() to derive transcript path from session_id when not provided, using pattern: ~/.iflow/projects/<sanitized-repo-path>/<session-id>.jsonl Changes: - Add env var overrides for all hook parsing functions - Add computeTranscriptPath() for fallback transcript path computation - Pass context through parsing functions for WorktreeRoot access
Previously, agent hooks were installed using opts.LocalDev directly, which caused re-running 'entire enable' without --local-dev flag to overwrite existing localDev settings in agent hook commands. Fix by loading existing settings BEFORE installing agent hooks, then using settings.LocalDev (merged with opts flags) for hook installation. This ensures existing localDev setting is preserved when re-enabling.
The agent.Agent interface doesn't have SupportsHooks() method. HookSupport interface provides hook-related methods. Changes: - Remove TestTraeAgent_SupportsHooks (method doesn't exist) - Update TestTraeAgent_GetHookNames to use HookSupport interface - Remove TestTraeAgent_GetSupportedHooks (method doesn't exist) - Minor code cleanup in traeagent.go
Fix inconsistent whitespace in map literals after gofmt run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds two key AI agent integrations to Entire CLI: Trae Agent (ByteDance's LLM-based software engineering agent) and iFlow CLI Agent, alongside a series of bug fixes, configuration optimizations, and test enhancements for the agent abstraction layer. All core agent interface implementations follow Entire's existing architecture and coding standards, with full hook lifecycle support, transcript parsing, and session management.
Key Features & Changes
1. Trae Agent Integration (Preview)
Full integration of ByteDance's Trae Agent with Entire's agent ecosystem, implementing all core and optional agent interfaces:
Agentinterface with full hook lifecycle supportHookTypes(before_agent, after_agent, before_model, after_model, etc.) for Trae Agent's lifecycleParseHookEventfor translating Trae Agent's native events to Entire's normalized lifecycle events.trae/settings.jsonSupportsHooks()/GetSupportedHooks()method tests)2. iFlow CLI Agent Full Implementation
Complete iFlow CLI agent integration with end-to-end session tracking and hook support:
types.go; implemented main agent struct and session management iniflow.golifecycle.go)HookSupportinterface for auto-installation of iFlow hooks; unified all hook configs to follow iFlow CLI spec (nestedhooksarray wrapper format)computeTranscriptPath()for fallback transcript path derivation (pattern:~/.iflow/projects/<sanitized-repo-path>/<session-id>.jsonl).iflow/settings.jsonwith full hook mappings for iFlow's key lifecycle events (Notification, PreToolUse, PostToolUse, SessionStart/End, etc.) and permission controlsAgentNameIFlowandAgentTypeIFlowfor auto-detection3. Critical Bug Fixes
IFlowHookMatchernested format (replaced flat format for Stop/SubagentStop/SessionEnd/SetUpEnvironment)entire enableoverwriting existinglocalDevsettings by loading project settings before installing agent hooks (merged with CLI opts instead of direct use)HookSupportinterface for hook-related tests)WorktreeRootaccess in parsing functions to ensure correct repo root resolution4. Documentation & Configuration
IFLOW.md: Comprehensive architecture overview for the iFlow CLI agent (follows Entire's existing agent documentation standards).gitignore: AddedCLAUDE.md(local development file) to gitignore to prevent accidental commits.iflow/settings.json: 86-line hook configuration file with all iFlow lifecycle events mapped to Entire's hook commands and basic permission controls (deny Read on./.entire/metadata/**)5. Test Enhancements
WriteHookResponseand added corresponding testscommon_test.gofor consistent code stylet.Parallel())6. Minor Refactors & Chores
hooks_cmd.gofor seamless agent detectiontraeagent.go(removed unused code)entireio/cli:mainbranch to resolve conflictsAgent Compatibility
Agentinterface (19 core methods) and optional interfaces (HookSupport,TranscriptAnalyzer)Test Coverage
mise run test:ci)Notes
How to Test
mise install && mise run buildto build the CLIentire enable --agent traeagent/entire enable --agent iflowmise run test:cito verify all tests passChecklist
gofmtandgolangci-lint(mise run fmt && mise run lint)