Skip to content

Commit aadd1b7

Browse files
committed
fix Neuron CLI
1 parent 25dc353 commit aadd1b7

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace NeuronAI\Console\Make;
6+
7+
use RuntimeException;
8+
9+
use function file_get_contents;
10+
use function str_replace;
11+
12+
class MakeEventCommand extends MakeCommand
13+
{
14+
public function __construct()
15+
{
16+
parent::__construct('Event');
17+
}
18+
19+
protected function getStubContent(string $namespace, string $className): string
20+
{
21+
$stubPath = __DIR__ . '/Stubs/event.stub';
22+
$stub = file_get_contents($stubPath);
23+
24+
if ($stub === false) {
25+
throw new RuntimeException("Failed to read stub file: {$stubPath}");
26+
}
27+
28+
return str_replace(
29+
['[namespace]', '[classname]'],
30+
[$namespace, $className],
31+
$stub
32+
);
33+
}
34+
}

src/Console/Make/Stubs/event.stub

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace [namespace];
6+
7+
use NeuronAI\Workflow\Events\Event;
8+
9+
class [classname] implements Event
10+
{
11+
/**
12+
* Add class properties to carry custom data.
13+
*/
14+
public function __construct()
15+
{
16+
}
17+
}

src/Console/NeuronCli.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use NeuronAI\Console\Evaluation\EvaluationCommand;
88
use NeuronAI\Console\Make\MakeAgentCommand;
9+
use NeuronAI\Console\Make\MakeEventCommand;
910
use NeuronAI\Console\Make\MakeMiddlewareCommand;
1011
use NeuronAI\Console\Make\MakeNodeCommand;
1112
use NeuronAI\Console\Make\MakeRagCommand;
@@ -29,6 +30,7 @@ class NeuronCli
2930
'make:tool' => MakeToolCommand::class,
3031
'make:rag' => MakeRagCommand::class,
3132
'make:workflow' => MakeWorkflowCommand::class,
33+
'make:event' => MakeEventCommand::class,
3234
];
3335

3436
/**
@@ -87,6 +89,7 @@ private function printUsage(): void
8789
make:tool Create a new Tool class
8890
make:rag Create a new RAG class
8991
make:workflow Create a new Workflow class
92+
make:event Create a new Event class
9093
9194
Options:
9295
--help, -h Show this help message

0 commit comments

Comments
 (0)