Merged
Conversation
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.
Summary
This PR introduces the analyzer agent — a general-purpose agent for filesystem and CLI tasks (document analysis, code inspection, etc.) — alongside a major refactor that extracts a reusable
workflowpackage and adds several new tools with unit tests. It also adds anARCHITECTURE.mddocument.Changes
New:
workflowpackage (workflow/)Extracts the session-creation + runner-event-loop pattern (previously inlined in the documentor command) into a reusable
workflow.Workflowtype. Both the documentor and the new analyzer agent now share this:•
workflow.go—New()constructs a workflow from an agent + session service + initial state;Start()creates a session, runs the agent loop, and logs token usage.•
runner.go— Defines theRunnerinterface wrappinggoogle.golang.org/adk/runner.New: Analyzer agent (agents/analyzer/)A new agent type focused on local filesystem operations and document analysis:
•
analyzer.go— Configures the agent with its tool set (list_dir,read_local_file,write_file,edit_file,exec_command,search_files).•
prompt.go— System instructions with a structured workflow for exploring directories, reading files, handling binary documents (PDF, DOCX, archives), and writing output.•
config.go—Configstruct with validation.New:cmd/analyze.goCobra command (
agent run analyzer) with flags for--work-dir,--task,--output,--model, and--provider. Wires up the analyzer agent through the sharedworkflowpackage.New tools (tools/)•
fake_ctx_test.go— Lightweighttool.Contextfake backed by an in-memory state map, enabling isolated tool tests without the full ADK runtime.•
tools_test.go— 12 test cases coveringedit_file(replace once, not-found, ambiguous, replace-all),list_dir(basic, not-a-directory),read_local_file(snippet, missing file), andexec_command(success, non-zero exit, empty command).Refactored:state/packageMoved
tools/state.go→state/state.goas a standalone package with shared session state keys for both agents (StateWorkDir,StateOutputPath,StateRepoURL, etc.).Refactored: Documentor command (cmd/documentor.go)Simplified significantly by delegating to the shared
workflowpackage — the session/runner boilerplate is removed in favour ofworkflow.New()+workflow.Start().Refactored: Existing tools•
search.go→search_files.go(renamed for consistency).•
tools.go—Kindenum andGetTools()/GetToolByEnum()registry pattern replacing per-agent tool wiring.New:ARCHITECTURE.mdComprehensive architecture documentation covering project structure, packages, agent workflows, tool system, LLM provider support, and session/state management.Other
•
.gitignore— Updated with additional patterns.•
agents/documentor/prompt.go— AddedUserMessage()helper.•
cmd/cmd.go— Wires up the newrun→analyzersubcommand.•
cmd/constants.go— AddsuserCLIconstant.Stats