@agentforge/cli 0.1.0
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.
- package/README.md +225 -0
- package/bin/agentforge.js +9 -0
- package/dist/index.cjs +1114 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1103 -0
- package/dist/index.js.map +1 -0
- package/package.json +81 -0
- package/templates/README.md +163 -0
- package/templates/api/.env.example +13 -0
- package/templates/api/README.md +153 -0
- package/templates/api/package.json +41 -0
- package/templates/api/src/routes/agent.ts +54 -0
- package/templates/api/src/routes/health.ts +15 -0
- package/templates/api/src/server.ts +41 -0
- package/templates/api/tsconfig.json +10 -0
- package/templates/cli/.env.example +13 -0
- package/templates/cli/README.md +164 -0
- package/templates/cli/package.json +44 -0
- package/templates/cli/src/cli.ts +31 -0
- package/templates/cli/src/commands/analyze.ts +65 -0
- package/templates/cli/src/commands/chat.ts +65 -0
- package/templates/cli/tsconfig.json +10 -0
- package/templates/full/.env.example +13 -0
- package/templates/full/README.md +151 -0
- package/templates/full/package.json +40 -0
- package/templates/full/src/index.ts +53 -0
- package/templates/full/src/tools/example.ts +20 -0
- package/templates/full/tests/example.test.ts +17 -0
- package/templates/full/tsconfig.json +10 -0
- package/templates/minimal/README.md +64 -0
- package/templates/minimal/package.json +35 -0
- package/templates/minimal/src/index.ts +40 -0
- package/templates/minimal/tsconfig.json +10 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "{{PROJECT_DESCRIPTION}}",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "tsx watch src/index.ts",
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"test:watch": "vitest --watch",
|
|
13
|
+
"test:ui": "vitest --ui",
|
|
14
|
+
"test:coverage": "vitest --coverage",
|
|
15
|
+
"typecheck": "tsc --noEmit",
|
|
16
|
+
"lint": "eslint .",
|
|
17
|
+
"lint:fix": "eslint . --fix",
|
|
18
|
+
"format": "prettier --write .",
|
|
19
|
+
"clean": "rm -rf dist"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@agentforge/core": "workspace:*",
|
|
23
|
+
"@agentforge/patterns": "workspace:*",
|
|
24
|
+
"@langchain/openai": "^0.3.14",
|
|
25
|
+
"langchain": "^0.3.7",
|
|
26
|
+
"zod": "^3.24.1",
|
|
27
|
+
"dotenv": "^16.4.7"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.2",
|
|
31
|
+
"@vitest/ui": "^2.1.8",
|
|
32
|
+
"eslint": "^9.17.0",
|
|
33
|
+
"prettier": "^3.4.2",
|
|
34
|
+
"tsup": "^8.3.5",
|
|
35
|
+
"tsx": "^4.21.0",
|
|
36
|
+
"typescript": "^5.7.2",
|
|
37
|
+
"vitest": "^2.1.8"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
3
|
+
import { createReActAgent } from '@agentforge/patterns';
|
|
4
|
+
import { createLogger } from '@agentforge/core';
|
|
5
|
+
import { exampleTool } from './tools/example.js';
|
|
6
|
+
|
|
7
|
+
const logger = createLogger({ level: 'info' });
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Main entry point for {{PROJECT_NAME}}
|
|
11
|
+
*/
|
|
12
|
+
async function main() {
|
|
13
|
+
logger.info('š Starting {{PROJECT_NAME}}...');
|
|
14
|
+
|
|
15
|
+
// Initialize the language model
|
|
16
|
+
const model = new ChatOpenAI({
|
|
17
|
+
modelName: process.env.OPENAI_MODEL || 'gpt-4',
|
|
18
|
+
temperature: 0,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// Create a ReAct agent with tools
|
|
22
|
+
const agent = createReActAgent({
|
|
23
|
+
model,
|
|
24
|
+
tools: [exampleTool],
|
|
25
|
+
systemPrompt: 'You are a helpful AI assistant with access to various tools.',
|
|
26
|
+
maxIterations: 10,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Compile the agent
|
|
30
|
+
const compiledAgent = agent.compile();
|
|
31
|
+
|
|
32
|
+
// Run the agent
|
|
33
|
+
logger.info('Running agent...');
|
|
34
|
+
const result = await compiledAgent.invoke({
|
|
35
|
+
messages: [
|
|
36
|
+
{
|
|
37
|
+
role: 'user',
|
|
38
|
+
content: 'Use the example tool to greet me!',
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
logger.info('ā
Agent completed');
|
|
44
|
+
console.log('\nFinal response:');
|
|
45
|
+
console.log(result.messages[result.messages.length - 1].content);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Run the main function
|
|
49
|
+
main().catch((error) => {
|
|
50
|
+
logger.error('ā Error:', error);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
});
|
|
53
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createTool } from '@agentforge/core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Example tool that demonstrates the tool creation API
|
|
6
|
+
*/
|
|
7
|
+
export const exampleTool = createTool()
|
|
8
|
+
.name('example_tool')
|
|
9
|
+
.description('An example tool that greets a user by name')
|
|
10
|
+
.category('utility')
|
|
11
|
+
.schema(
|
|
12
|
+
z.object({
|
|
13
|
+
name: z.string().describe('The name of the person to greet'),
|
|
14
|
+
})
|
|
15
|
+
)
|
|
16
|
+
.implement(async ({ name }) => {
|
|
17
|
+
return `Hello, ${name}! This is an example tool response.`;
|
|
18
|
+
})
|
|
19
|
+
.build();
|
|
20
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { exampleTool } from '../src/tools/example.js';
|
|
3
|
+
|
|
4
|
+
describe('Example Tool', () => {
|
|
5
|
+
it('should greet a user by name', async () => {
|
|
6
|
+
const result = await exampleTool.invoke({ name: 'Alice' });
|
|
7
|
+
expect(result).toContain('Alice');
|
|
8
|
+
expect(result).toContain('Hello');
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('should have correct metadata', () => {
|
|
12
|
+
expect(exampleTool.name).toBe('example_tool');
|
|
13
|
+
expect(exampleTool.description).toBeDefined();
|
|
14
|
+
expect(exampleTool.category).toBe('utility');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# {{PROJECT_NAME}}
|
|
2
|
+
|
|
3
|
+
{{PROJECT_DESCRIPTION}}
|
|
4
|
+
|
|
5
|
+
## Getting Started
|
|
6
|
+
|
|
7
|
+
### Prerequisites
|
|
8
|
+
|
|
9
|
+
- Node.js 18+
|
|
10
|
+
- pnpm (recommended) or npm
|
|
11
|
+
|
|
12
|
+
### Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Development
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Run in development mode with hot reload
|
|
22
|
+
pnpm dev
|
|
23
|
+
|
|
24
|
+
# Build for production
|
|
25
|
+
pnpm build
|
|
26
|
+
|
|
27
|
+
# Run tests
|
|
28
|
+
pnpm test
|
|
29
|
+
|
|
30
|
+
# Type check
|
|
31
|
+
pnpm typecheck
|
|
32
|
+
|
|
33
|
+
# Lint code
|
|
34
|
+
pnpm lint
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Project Structure
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
{{PROJECT_NAME}}/
|
|
41
|
+
āāā src/
|
|
42
|
+
ā āāā index.ts # Main entry point
|
|
43
|
+
āāā package.json
|
|
44
|
+
āāā tsconfig.json
|
|
45
|
+
āāā README.md
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Next Steps
|
|
49
|
+
|
|
50
|
+
1. Add your tools in `src/tools/`
|
|
51
|
+
2. Customize the agent in `src/index.ts`
|
|
52
|
+
3. Add tests in `tests/`
|
|
53
|
+
4. Deploy using the deployment guides in AgentForge docs
|
|
54
|
+
|
|
55
|
+
## Learn More
|
|
56
|
+
|
|
57
|
+
- [AgentForge Documentation](../../docs/)
|
|
58
|
+
- [Agent Patterns Guide](../../docs/guides/patterns/)
|
|
59
|
+
- [Tool Development Guide](../../docs/guides/tools/)
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
|
64
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{PROJECT_NAME}}",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "{{PROJECT_DESCRIPTION}}",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"dev": "tsx watch src/index.ts",
|
|
10
|
+
"build": "tsup",
|
|
11
|
+
"test": "vitest",
|
|
12
|
+
"test:watch": "vitest --watch",
|
|
13
|
+
"typecheck": "tsc --noEmit",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"lint:fix": "eslint . --fix",
|
|
16
|
+
"format": "prettier --write ."
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@agentforge/core": "workspace:*",
|
|
20
|
+
"@agentforge/patterns": "workspace:*",
|
|
21
|
+
"@langchain/openai": "^0.3.14",
|
|
22
|
+
"langchain": "^0.3.7",
|
|
23
|
+
"zod": "^3.24.1"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/node": "^22.10.2",
|
|
27
|
+
"eslint": "^9.17.0",
|
|
28
|
+
"prettier": "^3.4.2",
|
|
29
|
+
"tsup": "^8.3.5",
|
|
30
|
+
"tsx": "^4.21.0",
|
|
31
|
+
"typescript": "^5.7.2",
|
|
32
|
+
"vitest": "^2.1.8"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
2
|
+
import { createReActAgent } from '@agentforge/patterns';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Main entry point for {{PROJECT_NAME}}
|
|
6
|
+
*/
|
|
7
|
+
async function main() {
|
|
8
|
+
console.log('š Starting {{PROJECT_NAME}}...\n');
|
|
9
|
+
|
|
10
|
+
// Initialize the language model
|
|
11
|
+
const model = new ChatOpenAI({
|
|
12
|
+
modelName: 'gpt-4',
|
|
13
|
+
temperature: 0,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Create a simple ReAct agent
|
|
17
|
+
const agent = createReActAgent({
|
|
18
|
+
model,
|
|
19
|
+
tools: [],
|
|
20
|
+
systemPrompt: 'You are a helpful AI assistant.',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Compile the agent
|
|
24
|
+
const compiledAgent = agent.compile();
|
|
25
|
+
|
|
26
|
+
// Run the agent
|
|
27
|
+
const result = await compiledAgent.invoke({
|
|
28
|
+
messages: [{ role: 'user', content: 'Hello! What can you help me with?' }],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('\nā
Agent response:');
|
|
32
|
+
console.log(result.messages[result.messages.length - 1].content);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Run the main function
|
|
36
|
+
main().catch((error) => {
|
|
37
|
+
console.error('ā Error:', error);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
|