1
- # Symfony C
1
+ # Symfony Console Agent 🎭
2
2
3
3
[ ![ PHP] ( https://img.shields.io/packagist/php-v/llm-agents/agent-symfony-console.svg?style=flat-square )] ( https://packagist.org/packages/llm-agents/agent-symfony-console )
4
4
[ ![ Latest Version on Packagist] ( https://img.shields.io/packagist/v/llm-agents/agent-symfony-console.svg?style=flat-square )] ( https://packagist.org/packages/llm-agents/agent-symfony-console )
5
5
[ ![ Total Downloads] ( https://img.shields.io/packagist/dt/llm-agents/agent-symfony-console.svg?style=flat-square )] ( https://packagist.org/packages/llm-agents/agent-symfony-console )
6
6
7
+ Welcome to the Symfony Console Agent, your new bestie for turning natural language into command-line magic. This nifty
8
+ agent understands your human babble and translates it into console commands. It's like having a super-smart CLI
9
+ assistant right at your fingertips!
10
+
11
+ ### What's the deal? 🤔
12
+
13
+ Ever wished you could just tell your console what to do in plain English? Well, now you can! This agent takes your
14
+ casual requests and figures out which Symfony command to run. It's perfect for devs who are new to a project, can't
15
+ remember exact command syntax, or just feeling a bit lazy (we've all been there).
16
+
17
+ ### Requirements 📋
18
+
19
+ - PHP 8.3 or higher (we're living in the future, baby!)
20
+ - Symfony Console component
21
+ - A sense of humor (optional, but highly recommended)
22
+
7
23
### Installation
8
24
9
- First things first, let's get this package installed :
25
+ First, make sure you've got Composer installed. Then, run this command to add the Symfony Console Agent to your project :
10
26
11
27
``` bash
12
28
composer require llm-agents/agent-symfony-console
13
29
```
14
30
15
31
### Setup in Spiral Framework
16
32
17
- To get the Site Status Checker Agent up and running in your Spiral Framework project, you need to register its
18
- bootloader.
19
-
20
- ** Here's how:**
21
-
22
33
1 . Open up your ` app/src/Application/Kernel.php ` file.
23
34
2 . Add the bootloader like this:
24
35
``` php
@@ -33,6 +44,208 @@ bootloader.
33
44
34
45
And that's it! Your Spiral app is now ready to use the agent.
35
46
47
+ ### Laravel
48
+
49
+ For Laravel, there's a service provider you can use:
50
+
51
+ ``` php
52
+ // bootstrap/providers.php
53
+ return [
54
+ // ... other providers ...
55
+ LLM\Agents\Agent\SymfonyConsole\Integrations\Laravel\SymfonyConsoleServiceProvider::class,
56
+ ];
57
+ ```
58
+
59
+ ## Usage
60
+
61
+ To start using the Symfony Console Agent, you'll need to implement the
62
+ ` LLM\Agents\Agent\SymfonyConsole\CommandManagerInterface ` . interface. This interface is responsible for fetching command
63
+ help, listing available commands, and executing commands.
64
+
65
+ ** Here's an example of how you might use it in a Laravel application:**
66
+
67
+ ``` php
68
+ <?php
69
+
70
+ declare(strict_types=1);
71
+
72
+ namespace LLM\Agents\Agent\SymfonyConsole\Integrations\Laravel;
73
+
74
+ use Illuminate\Contracts\Console\Kernel;
75
+ use LLM\Agents\Agent\SymfonyConsole\CommandManagerInterface;
76
+ use Symfony\Component\Console\Output\BufferedOutput;
77
+ use Symfony\Component\Console\Output\OutputInterface;
78
+
79
+ final readonly class ArtisanCommandManager implements CommandManagerInterface
80
+ {
81
+ public function __construct(
82
+ private Kernel $application,
83
+ private array $enabledNamespaces = [
84
+ 'make:',
85
+ 'db:',
86
+ 'migrate',
87
+ 'route:list',
88
+ ],
89
+ ) {}
90
+
91
+ public function getCommandHelp(string $command): string
92
+ {
93
+ $output = new BufferedOutput();
94
+ $this->application->call($command, ['--help' => true], $output);
95
+
96
+ return $output->fetch();
97
+ }
98
+
99
+ public function getCommands(): array
100
+ {
101
+ $commands = $this->application->all();
102
+
103
+ $availableCommands = [];
104
+ foreach ($this->enabledNamespaces as $namespace) {
105
+ foreach ($commands as $name => $command) {
106
+ if (\str_starts_with($name, $namespace)) {
107
+ $availableCommands[$name] = $command;
108
+ }
109
+ }
110
+ }
111
+
112
+ return $availableCommands;
113
+ }
114
+
115
+ public function call(\Stringable|string $command, array $parameters = [], ?OutputInterface $output = null): int
116
+ {
117
+ return $this->application->call($command, $parameters, $output);
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## Class diagram
123
+
124
+ ``` mermaid
125
+ classDiagram
126
+ class SymfonyConsoleAgent {
127
+ +NAME: string
128
+ +create(frameworkName: string): self
129
+ -addMetadata(SolutionMetadata): void
130
+ -addAssociation(Solution): void
131
+ }
132
+ class AgentAggregate {
133
+ <<interface>>
134
+ +getKey(): string
135
+ +getName(): string
136
+ +getDescription(): string
137
+ +getInstruction(): string
138
+ +getTools(): array
139
+ +getAgents(): array
140
+ +getModel(): Model
141
+ +getMemory(): array
142
+ +getPrompts(): array
143
+ +getConfiguration(): array
144
+ }
145
+ class GetCommandsListTool {
146
+ +NAME: string
147
+ -application: CommandManagerInterface
148
+ +__construct(CommandManagerInterface)
149
+ +execute(input: object): string
150
+ }
151
+ class GetCommandDetailsTool {
152
+ +NAME: string
153
+ -application: CommandManagerInterface
154
+ +__construct(CommandManagerInterface)
155
+ +execute(input: object): string
156
+ }
157
+ class ExecuteCommandTool {
158
+ +NAME: string
159
+ -application: CommandManagerInterface
160
+ +__construct(CommandManagerInterface)
161
+ +execute(input: object): string
162
+ }
163
+ class ReadFileTool {
164
+ +NAME: string
165
+ -basePath: string
166
+ +__construct(string)
167
+ +execute(input: object): string
168
+ }
169
+ class WriteFileTool {
170
+ +NAME: string
171
+ -basePath: string
172
+ +__construct(string)
173
+ +execute(input: object): string
174
+ }
175
+ class CommandManagerInterface {
176
+ <<interface>>
177
+ +getCommandHelp(command: string): string
178
+ +getCommands(): array
179
+ +call(command: string, parameters: array, output: OutputInterface): int
180
+ }
181
+ class Tool {
182
+ <<abstract>>
183
+ +getName(): string
184
+ +getDescription(): string
185
+ +getInputSchema(): string
186
+ +getLanguage(): ToolLanguage
187
+ +execute(input: object): string|Stringable
188
+ }
189
+ class ToolInterface {
190
+ <<interface>>
191
+ +getName(): string
192
+ +getDescription(): string
193
+ +getInputSchema(): string
194
+ +getLanguage(): ToolLanguage
195
+ +execute(input: object): string|Stringable
196
+ }
197
+ class SymfonyConsoleAgentFactory {
198
+ -frameworkName: string
199
+ +__construct(frameworkName: string)
200
+ +create(): AgentInterface
201
+ }
202
+ class AgentFactoryInterface {
203
+ <<interface>>
204
+ +create(): AgentInterface
205
+ }
206
+ class GetCommandsListInput {
207
+ +namespace: string
208
+ }
209
+ class GetCommandDetailsInput {
210
+ +command: string
211
+ }
212
+ class ExecuteCommandInput {
213
+ +command: string
214
+ +arguments: array
215
+ +options: array
216
+ }
217
+ class ReadFileInput {
218
+ +path: string
219
+ }
220
+ class WriteFileInput {
221
+ +path: string
222
+ +content: string
223
+ }
224
+
225
+ SymfonyConsoleAgent --|> AgentAggregate
226
+ SymfonyConsoleAgent ..> GetCommandsListTool
227
+ SymfonyConsoleAgent ..> GetCommandDetailsTool
228
+ SymfonyConsoleAgent ..> ExecuteCommandTool
229
+ SymfonyConsoleAgent ..> ReadFileTool
230
+ SymfonyConsoleAgent ..> WriteFileTool
231
+ GetCommandsListTool --|> Tool
232
+ GetCommandDetailsTool --|> Tool
233
+ ExecuteCommandTool --|> Tool
234
+ ReadFileTool --|> Tool
235
+ WriteFileTool --|> Tool
236
+ Tool ..|> ToolInterface
237
+ GetCommandsListTool ..> CommandManagerInterface
238
+ GetCommandDetailsTool ..> CommandManagerInterface
239
+ ExecuteCommandTool ..> CommandManagerInterface
240
+ SymfonyConsoleAgentFactory ..|> AgentFactoryInterface
241
+ SymfonyConsoleAgentFactory ..> SymfonyConsoleAgent
242
+ GetCommandsListTool ..> GetCommandsListInput
243
+ GetCommandDetailsTool ..> GetCommandDetailsInput
244
+ ExecuteCommandTool ..> ExecuteCommandInput
245
+ ReadFileTool ..> ReadFileInput
246
+ WriteFileTool ..> WriteFileInput
247
+ ```
248
+
36
249
## Want to help out? 🤝
37
250
38
251
We love contributions! If you've got ideas to make this agent even cooler, here's how you can chip in:
0 commit comments