agent_c 2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -0
- data/CLAUDE.md +21 -0
- data/README.md +360 -0
- data/Rakefile +16 -0
- data/TODO.md +105 -0
- data/agent_c.gemspec +38 -0
- data/docs/batch.md +503 -0
- data/docs/chat-methods.md +156 -0
- data/docs/cost-reporting.md +86 -0
- data/docs/pipeline-tips-and-tricks.md +453 -0
- data/docs/session-configuration.md +274 -0
- data/docs/testing.md +747 -0
- data/docs/tools.md +103 -0
- data/docs/versioned-store.md +840 -0
- data/lib/agent_c/agent/chat.rb +211 -0
- data/lib/agent_c/agent/chat_response.rb +38 -0
- data/lib/agent_c/agent/chats/anthropic_bedrock.rb +48 -0
- data/lib/agent_c/batch.rb +102 -0
- data/lib/agent_c/configs/repo.rb +90 -0
- data/lib/agent_c/context.rb +56 -0
- data/lib/agent_c/costs/data.rb +39 -0
- data/lib/agent_c/costs/report.rb +219 -0
- data/lib/agent_c/db/store.rb +162 -0
- data/lib/agent_c/errors.rb +19 -0
- data/lib/agent_c/pipeline.rb +152 -0
- data/lib/agent_c/pipelines/agent.rb +219 -0
- data/lib/agent_c/processor.rb +98 -0
- data/lib/agent_c/prompts.yml +53 -0
- data/lib/agent_c/schema.rb +71 -0
- data/lib/agent_c/session.rb +206 -0
- data/lib/agent_c/store.rb +72 -0
- data/lib/agent_c/test_helpers.rb +173 -0
- data/lib/agent_c/tools/dir_glob.rb +46 -0
- data/lib/agent_c/tools/edit_file.rb +114 -0
- data/lib/agent_c/tools/file_metadata.rb +43 -0
- data/lib/agent_c/tools/git_status.rb +30 -0
- data/lib/agent_c/tools/grep.rb +119 -0
- data/lib/agent_c/tools/paths.rb +36 -0
- data/lib/agent_c/tools/read_file.rb +94 -0
- data/lib/agent_c/tools/run_rails_test.rb +87 -0
- data/lib/agent_c/tools.rb +61 -0
- data/lib/agent_c/utils/git.rb +87 -0
- data/lib/agent_c/utils/shell.rb +58 -0
- data/lib/agent_c/version.rb +5 -0
- data/lib/agent_c.rb +32 -0
- data/lib/versioned_store/base.rb +314 -0
- data/lib/versioned_store/config.rb +26 -0
- data/lib/versioned_store/stores/schema.rb +127 -0
- data/lib/versioned_store/version.rb +5 -0
- data/lib/versioned_store.rb +5 -0
- data/template/Gemfile +9 -0
- data/template/Gemfile.lock +152 -0
- data/template/README.md +61 -0
- data/template/Rakefile +50 -0
- data/template/bin/rake +27 -0
- data/template/lib/autoload.rb +10 -0
- data/template/lib/config.rb +59 -0
- data/template/lib/pipeline.rb +19 -0
- data/template/lib/prompts.yml +57 -0
- data/template/lib/store.rb +17 -0
- data/template/test/pipeline_test.rb +221 -0
- data/template/test/test_helper.rb +18 -0
- metadata +194 -0
data/docs/tools.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# Custom Tools
|
|
2
|
+
|
|
3
|
+
If you are using a Batch, these tools are available and will be automatically configured for the correct directories/environment variables.
|
|
4
|
+
|
|
5
|
+
## Available tools
|
|
6
|
+
|
|
7
|
+
AgentC comes with several built-in tools that the LLM can use to interact with your codebase:
|
|
8
|
+
|
|
9
|
+
- `dir_glob` - List files matching patterns
|
|
10
|
+
- `read_file` - Read file contents
|
|
11
|
+
- `edit_file` - Make changes to files
|
|
12
|
+
- `file_metadata` - Get file information
|
|
13
|
+
- `grep` - Search within files
|
|
14
|
+
- `run_rails_test` - Execute Rails tests
|
|
15
|
+
|
|
16
|
+
# Using with sessions directly
|
|
17
|
+
|
|
18
|
+
This section is only relevant if you are not using a Batch.
|
|
19
|
+
|
|
20
|
+
## Using Tools
|
|
21
|
+
|
|
22
|
+
Tools are specified when creating a chat or using session.prompt:
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
session = AgentC::Session.new(
|
|
26
|
+
agent_db_path: 'tmp/db/agent.sqlite3',
|
|
27
|
+
project: 'my_project'
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
# Chat with specific tools
|
|
31
|
+
chat = session.chat(tools: [:read_file, :grep])
|
|
32
|
+
response = chat.ask("What files contain the User model?")
|
|
33
|
+
|
|
34
|
+
# Or use session.prompt with tools
|
|
35
|
+
result = session.prompt(
|
|
36
|
+
prompt: "Summarize the README",
|
|
37
|
+
tools: [:read_file],
|
|
38
|
+
tool_args: { workspace_dir: '/path/to/project' },
|
|
39
|
+
schema: -> { string(:summary) }
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tool Examples
|
|
44
|
+
|
|
45
|
+
### dir_glob
|
|
46
|
+
|
|
47
|
+
List files matching glob patterns:
|
|
48
|
+
|
|
49
|
+
```ruby
|
|
50
|
+
chat = session.chat(tools: [:dir_glob])
|
|
51
|
+
response = chat.ask("Show me all Ruby files in the lib directory")
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### read_file
|
|
55
|
+
|
|
56
|
+
Read the contents of a file:
|
|
57
|
+
|
|
58
|
+
```ruby
|
|
59
|
+
chat = session.chat(tools: [:read_file])
|
|
60
|
+
response = chat.ask("What does lib/agent_c/chat.rb do?")
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### edit_file
|
|
64
|
+
|
|
65
|
+
Make changes to files:
|
|
66
|
+
|
|
67
|
+
```ruby
|
|
68
|
+
chat = session.chat(tools: [:edit_file])
|
|
69
|
+
response = chat.ask("Add a method called 'foo' to lib/agent_c/chat.rb")
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### grep
|
|
73
|
+
|
|
74
|
+
Search for patterns within files:
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
chat = session.chat(tools: [:grep])
|
|
78
|
+
response = chat.ask("Find all calls to the 'process' method in the codebase")
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### run_rails_test
|
|
82
|
+
|
|
83
|
+
Execute Rails tests:
|
|
84
|
+
|
|
85
|
+
```ruby
|
|
86
|
+
chat = session.chat(tools: [:run_rails_test])
|
|
87
|
+
response = chat.ask("Run the tests in test/models/user_test.rb")
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Tool Resolution with Pipelines
|
|
91
|
+
|
|
92
|
+
When using tools in Pipeline agent_steps, tools are automatically resolved to the workspace's working directory:
|
|
93
|
+
|
|
94
|
+
```ruby
|
|
95
|
+
class MyPipeline < AgentC::Pipeline
|
|
96
|
+
agent_step(
|
|
97
|
+
:analyze_code,
|
|
98
|
+
tools: [:read_file, :grep]
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The tools will operate in the context of `workspace.dir` for that pipeline execution.
|