@agentforge/cli 0.3.9 → 0.4.1

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.
@@ -0,0 +1,169 @@
1
+ # {{TOOL_NAME_PASCAL}} Tool
2
+
3
+ {{TOOL_DESCRIPTION}}
4
+
5
+ ## Category
6
+
7
+ `{{TOOL_CATEGORY}}`
8
+
9
+ ## Installation
10
+
11
+ This tool is part of your AgentForge project. No additional installation required.
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { {{TOOL_NAME_CAMEL}}Tool } from './tools/{{TOOL_NAME}}/index.js';
17
+
18
+ // Use in an agent
19
+ const agent = createReActAgent({
20
+ model,
21
+ tools: [{{TOOL_NAME_CAMEL}}Tool],
22
+ // ...
23
+ });
24
+
25
+ // Or invoke directly
26
+ const result = await {{TOOL_NAME_CAMEL}}Tool.invoke({
27
+ input: 'example input',
28
+ });
29
+
30
+ console.log(result);
31
+ ```
32
+
33
+ ## Input Schema
34
+
35
+ ```typescript
36
+ {
37
+ input: string; // Input parameter (required, non-empty)
38
+ }
39
+ ```
40
+
41
+ ## Output Schema
42
+
43
+ ```typescript
44
+ {
45
+ success: boolean; // Whether the operation was successful
46
+ data?: any; // Result data (when successful)
47
+ error?: string; // Error message (when failed)
48
+ metadata?: { // Additional metadata
49
+ responseTime?: number;
50
+ [key: string]: any;
51
+ };
52
+ }
53
+ ```
54
+
55
+ ## File Structure
56
+
57
+ ```
58
+ {{TOOL_NAME}}/
59
+ ├── index.ts # Main tool definition
60
+ ├── types.ts # TypeScript type definitions
61
+ ├── schemas.ts # Zod validation schemas
62
+ ├── utils.ts # Utility functions
63
+ ├── providers/ # External service integrations
64
+ │ └── example.ts # Example provider
65
+ ├── __tests__/ # Test files
66
+ │ └── index.test.ts # Main test suite
67
+ └── README.md # This file
68
+ ```
69
+
70
+ ## Development
71
+
72
+ ### Running Tests
73
+
74
+ ```bash
75
+ # Run all tests
76
+ pnpm test
77
+
78
+ # Run tests for this tool only
79
+ pnpm test {{TOOL_NAME}}
80
+
81
+ # Watch mode
82
+ pnpm test:watch {{TOOL_NAME}}
83
+ ```
84
+
85
+ ### Adding Providers
86
+
87
+ To add a new provider (e.g., for integrating with an external API):
88
+
89
+ 1. Create a new file in `providers/` directory:
90
+ ```typescript
91
+ // providers/myProvider.ts
92
+ export async function myProvider(input: string): Promise<{{TOOL_NAME_PASCAL}}Output> {
93
+ // Implementation
94
+ }
95
+ ```
96
+
97
+ 2. Import and use in `index.ts`:
98
+ ```typescript
99
+ import { myProvider } from './providers/myProvider.js';
100
+ ```
101
+
102
+ ### Extending Types
103
+
104
+ Add new types in `types.ts`:
105
+
106
+ ```typescript
107
+ export interface MyCustomType {
108
+ // Your properties
109
+ }
110
+ ```
111
+
112
+ ### Adding Validation
113
+
114
+ Add new schemas in `schemas.ts`:
115
+
116
+ ```typescript
117
+ export const MyCustomSchema = z.object({
118
+ // Your schema
119
+ });
120
+ ```
121
+
122
+ ## Examples
123
+
124
+ ### Basic Usage
125
+
126
+ ```typescript
127
+ const result = await {{TOOL_NAME_CAMEL}}Tool.invoke({
128
+ input: 'test input',
129
+ });
130
+
131
+ if (result.success) {
132
+ console.log('Success:', result.data);
133
+ } else {
134
+ console.error('Error:', result.error);
135
+ }
136
+ ```
137
+
138
+ ### Error Handling
139
+
140
+ ```typescript
141
+ try {
142
+ const result = await {{TOOL_NAME_CAMEL}}Tool.invoke({
143
+ input: 'test',
144
+ });
145
+
146
+ if (!result.success) {
147
+ throw new Error(result.error);
148
+ }
149
+
150
+ // Process result.data
151
+ } catch (error) {
152
+ console.error('Tool execution failed:', error);
153
+ }
154
+ ```
155
+
156
+ ## TODO
157
+
158
+ - [ ] Implement core functionality in `index.ts`
159
+ - [ ] Add provider implementations in `providers/`
160
+ - [ ] Define proper input/output types in `types.ts`
161
+ - [ ] Add comprehensive validation in `schemas.ts`
162
+ - [ ] Write tests in `__tests__/index.test.ts`
163
+ - [ ] Add utility functions in `utils.ts`
164
+ - [ ] Update this README with actual usage examples
165
+
166
+ ## License
167
+
168
+ MIT
169
+
@@ -0,0 +1,50 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { {{TOOL_NAME_CAMEL}}Tool } from '../index.js';
3
+
4
+ describe('{{TOOL_NAME_PASCAL}} Tool', () => {
5
+ it('should have correct metadata', () => {
6
+ expect({{TOOL_NAME_CAMEL}}Tool.name).toBe('{{TOOL_NAME}}');
7
+ expect({{TOOL_NAME_CAMEL}}Tool.description).toBe('{{TOOL_DESCRIPTION}}');
8
+ expect({{TOOL_NAME_CAMEL}}Tool.category).toBe('{{TOOL_CATEGORY}}');
9
+ });
10
+
11
+ it('should validate input schema', async () => {
12
+ // Valid input
13
+ const validInput = {
14
+ input: 'test input',
15
+ };
16
+
17
+ const result = await {{TOOL_NAME_CAMEL}}Tool.invoke(validInput);
18
+ expect(result).toBeDefined();
19
+ expect(result.success).toBe(true);
20
+ });
21
+
22
+ it('should reject invalid input', async () => {
23
+ // Invalid input (empty string)
24
+ const invalidInput = {
25
+ input: '',
26
+ };
27
+
28
+ await expect({{TOOL_NAME_CAMEL}}Tool.invoke(invalidInput)).rejects.toThrow();
29
+ });
30
+
31
+ it('should execute successfully with valid input', async () => {
32
+ const input = {
33
+ input: 'test',
34
+ };
35
+
36
+ const result = await {{TOOL_NAME_CAMEL}}Tool.invoke(input);
37
+
38
+ expect(result).toBeDefined();
39
+ expect(result.success).toBe(true);
40
+ expect(result.data).toBeDefined();
41
+ });
42
+
43
+ it('should handle errors gracefully', async () => {
44
+ // TODO: Add error handling tests
45
+ // Example: Test with invalid API key, network errors, etc.
46
+ });
47
+
48
+ // TODO: Add more specific tests for your tool
49
+ });
50
+
@@ -0,0 +1,47 @@
1
+ import { z } from 'zod';
2
+ import { createTool } from '@agentforge/core';
3
+ import { {{TOOL_NAME_PASCAL}}Schema } from './schemas.js';
4
+ import type { {{TOOL_NAME_PASCAL}}Input, {{TOOL_NAME_PASCAL}}Output } from './types.js';
5
+
6
+ /**
7
+ * {{TOOL_DESCRIPTION}}
8
+ *
9
+ * Category: {{TOOL_CATEGORY}}
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const result = await {{TOOL_NAME_CAMEL}}Tool.invoke({
14
+ * input: 'example input',
15
+ * });
16
+ * console.log(result);
17
+ * ```
18
+ */
19
+ export const {{TOOL_NAME_CAMEL}}Tool = createTool()
20
+ .name('{{TOOL_NAME}}')
21
+ .description('{{TOOL_DESCRIPTION}}')
22
+ .category('{{TOOL_CATEGORY}}')
23
+ .schema({{TOOL_NAME_PASCAL}}Schema)
24
+ .implement(async (input: {{TOOL_NAME_PASCAL}}Input): Promise<{{TOOL_NAME_PASCAL}}Output> => {
25
+ try {
26
+ // TODO: Implement your tool logic here
27
+
28
+ // Example implementation:
29
+ const result = `Processed: ${input.input}`;
30
+
31
+ return {
32
+ success: true,
33
+ data: result,
34
+ };
35
+ } catch (error: any) {
36
+ return {
37
+ success: false,
38
+ error: error.message,
39
+ };
40
+ }
41
+ })
42
+ .build();
43
+
44
+ // Re-export types for convenience
45
+ export * from './types.js';
46
+ export * from './schemas.js';
47
+
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Example provider for {{TOOL_NAME}} tool
3
+ *
4
+ * This is a template for creating providers that integrate with external services.
5
+ * Replace this with your actual provider implementation.
6
+ */
7
+
8
+ import type { {{TOOL_NAME_PASCAL}}Output } from '../types.js';
9
+
10
+ /**
11
+ * Example provider function
12
+ *
13
+ * @param input - Input parameter
14
+ * @returns Provider result
15
+ */
16
+ export async function exampleProvider(input: string): Promise<{{TOOL_NAME_PASCAL}}Output> {
17
+ try {
18
+ // TODO: Implement your provider logic here
19
+ // Example: Call external API, process data, etc.
20
+
21
+ const result = `Provider processed: ${input}`;
22
+
23
+ return {
24
+ success: true,
25
+ data: result,
26
+ };
27
+ } catch (error: any) {
28
+ return {
29
+ success: false,
30
+ error: error.message,
31
+ };
32
+ }
33
+ }
34
+
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Zod schema for {{TOOL_NAME}} tool input validation
5
+ */
6
+ export const {{TOOL_NAME_PASCAL}}Schema = z.object({
7
+ /**
8
+ * Input parameter
9
+ * TODO: Define your input schema
10
+ */
11
+ input: z.string()
12
+ .min(1, 'Input cannot be empty')
13
+ .describe('Input parameter'),
14
+ });
15
+
16
+ /**
17
+ * Infer the input type from the schema
18
+ */
19
+ export type {{TOOL_NAME_PASCAL}}Input = z.infer<typeof {{TOOL_NAME_PASCAL}}Schema>;
20
+
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Type definitions for {{TOOL_NAME}} tool
3
+ */
4
+
5
+ /**
6
+ * Input type for {{TOOL_NAME}} tool
7
+ */
8
+ export interface {{TOOL_NAME_PASCAL}}Input {
9
+ /**
10
+ * Input parameter
11
+ * TODO: Define your input properties
12
+ */
13
+ input: string;
14
+ }
15
+
16
+ /**
17
+ * Output type for {{TOOL_NAME}} tool
18
+ */
19
+ export interface {{TOOL_NAME_PASCAL}}Output {
20
+ /**
21
+ * Whether the operation was successful
22
+ */
23
+ success: boolean;
24
+
25
+ /**
26
+ * Result data (when successful)
27
+ */
28
+ data?: any;
29
+
30
+ /**
31
+ * Error message (when failed)
32
+ */
33
+ error?: string;
34
+
35
+ /**
36
+ * Additional metadata
37
+ */
38
+ metadata?: {
39
+ /**
40
+ * Response time in milliseconds
41
+ */
42
+ responseTime?: number;
43
+
44
+ /**
45
+ * Additional context
46
+ */
47
+ [key: string]: any;
48
+ };
49
+ }
50
+
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Utility functions for {{TOOL_NAME}} tool
3
+ */
4
+
5
+ /**
6
+ * Delay execution for a specified number of milliseconds
7
+ *
8
+ * @param ms - Milliseconds to delay
9
+ * @returns Promise that resolves after the delay
10
+ */
11
+ export function delay(ms: number): Promise<void> {
12
+ return new Promise((resolve) => setTimeout(resolve, ms));
13
+ }
14
+
15
+ /**
16
+ * Format error message
17
+ *
18
+ * @param error - Error object or message
19
+ * @returns Formatted error message
20
+ */
21
+ export function formatError(error: unknown): string {
22
+ if (error instanceof Error) {
23
+ return error.message;
24
+ }
25
+ if (typeof error === 'string') {
26
+ return error;
27
+ }
28
+ return 'An unknown error occurred';
29
+ }
30
+
31
+ /**
32
+ * Validate environment variable
33
+ *
34
+ * @param name - Environment variable name
35
+ * @returns Environment variable value
36
+ * @throws Error if environment variable is not set
37
+ */
38
+ export function getEnvVar(name: string): string {
39
+ const value = process.env[name];
40
+ if (!value) {
41
+ throw new Error(`Environment variable ${name} is not set`);
42
+ }
43
+ return value;
44
+ }
45
+
46
+ /**
47
+ * Get optional environment variable
48
+ *
49
+ * @param name - Environment variable name
50
+ * @returns Environment variable value or undefined
51
+ */
52
+ export function getOptionalEnvVar(name: string): string | undefined {
53
+ return process.env[name];
54
+ }
55
+
package/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Tom Van Schoor
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-