gencode-ai 0.1.1 → 0.1.3
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/.gencode/settings.local.json +7 -0
- package/CLAUDE.md +86 -0
- package/README.md +13 -16
- package/dist/agent/agent.d.ts +50 -1
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +96 -16
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/types.d.ts +14 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/cli/components/App.d.ts +8 -1
- package/dist/cli/components/App.d.ts.map +1 -1
- package/dist/cli/components/App.js +266 -29
- package/dist/cli/components/App.js.map +1 -1
- package/dist/cli/components/CommandSuggestions.d.ts.map +1 -1
- package/dist/cli/components/CommandSuggestions.js +2 -0
- package/dist/cli/components/CommandSuggestions.js.map +1 -1
- package/dist/cli/components/Header.d.ts +1 -1
- package/dist/cli/components/Header.d.ts.map +1 -1
- package/dist/cli/components/Header.js +4 -6
- package/dist/cli/components/Header.js.map +1 -1
- package/dist/cli/components/Logo.d.ts +1 -0
- package/dist/cli/components/Logo.d.ts.map +1 -1
- package/dist/cli/components/Logo.js +16 -3
- package/dist/cli/components/Logo.js.map +1 -1
- package/dist/cli/components/Messages.d.ts +4 -4
- package/dist/cli/components/Messages.d.ts.map +1 -1
- package/dist/cli/components/Messages.js +66 -23
- package/dist/cli/components/Messages.js.map +1 -1
- package/dist/cli/components/PermissionPrompt.d.ts +60 -0
- package/dist/cli/components/PermissionPrompt.d.ts.map +1 -0
- package/dist/cli/components/PermissionPrompt.js +192 -0
- package/dist/cli/components/PermissionPrompt.js.map +1 -0
- package/dist/cli/components/ProviderManager.js +3 -3
- package/dist/cli/components/ProviderManager.js.map +1 -1
- package/dist/cli/components/QuestionPrompt.d.ts +23 -0
- package/dist/cli/components/QuestionPrompt.d.ts.map +1 -0
- package/dist/cli/components/QuestionPrompt.js +231 -0
- package/dist/cli/components/QuestionPrompt.js.map +1 -0
- package/dist/cli/components/Spinner.d.ts +7 -2
- package/dist/cli/components/Spinner.d.ts.map +1 -1
- package/dist/cli/components/Spinner.js +116 -25
- package/dist/cli/components/Spinner.js.map +1 -1
- package/dist/cli/components/TodoList.d.ts +7 -0
- package/dist/cli/components/TodoList.d.ts.map +1 -0
- package/dist/cli/components/TodoList.js +34 -0
- package/dist/cli/components/TodoList.js.map +1 -0
- package/dist/cli/components/index.d.ts +2 -0
- package/dist/cli/components/index.d.ts.map +1 -1
- package/dist/cli/components/index.js +2 -0
- package/dist/cli/components/index.js.map +1 -1
- package/dist/cli/components/theme.d.ts +7 -0
- package/dist/cli/components/theme.d.ts.map +1 -1
- package/dist/cli/components/theme.js +11 -1
- package/dist/cli/components/theme.js.map +1 -1
- package/dist/cli/index.js +47 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +13 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +18 -3
- package/dist/config/index.js.map +1 -1
- package/dist/config/levels.d.ts +49 -0
- package/dist/config/levels.d.ts.map +1 -0
- package/dist/config/levels.js +222 -0
- package/dist/config/levels.js.map +1 -0
- package/dist/config/loader.d.ts +46 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +153 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/manager.d.ts +115 -15
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/config/manager.js +260 -34
- package/dist/config/manager.js.map +1 -1
- package/dist/config/manager.test.d.ts +5 -0
- package/dist/config/manager.test.d.ts.map +1 -0
- package/dist/config/manager.test.js +192 -0
- package/dist/config/manager.test.js.map +1 -0
- package/dist/config/merger.d.ts +56 -0
- package/dist/config/merger.d.ts.map +1 -0
- package/dist/config/merger.js +177 -0
- package/dist/config/merger.js.map +1 -0
- package/dist/config/test-utils.d.ts +24 -0
- package/dist/config/test-utils.d.ts.map +1 -0
- package/dist/config/test-utils.js +55 -0
- package/dist/config/test-utils.js.map +1 -0
- package/dist/config/types.d.ts +78 -9
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js +52 -2
- package/dist/config/types.js.map +1 -1
- package/dist/memory/import-resolver.d.ts +46 -0
- package/dist/memory/import-resolver.d.ts.map +1 -0
- package/dist/memory/import-resolver.js +117 -0
- package/dist/memory/import-resolver.js.map +1 -0
- package/dist/memory/index.d.ts +7 -6
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +7 -5
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/init-prompt.d.ts +22 -0
- package/dist/memory/init-prompt.d.ts.map +1 -0
- package/dist/memory/init-prompt.js +103 -0
- package/dist/memory/init-prompt.js.map +1 -0
- package/dist/memory/memory-manager.d.ts +119 -0
- package/dist/memory/memory-manager.d.ts.map +1 -0
- package/dist/memory/memory-manager.js +587 -0
- package/dist/memory/memory-manager.js.map +1 -0
- package/dist/memory/rules-parser.d.ts +38 -0
- package/dist/memory/rules-parser.d.ts.map +1 -0
- package/dist/memory/rules-parser.js +69 -0
- package/dist/memory/rules-parser.js.map +1 -0
- package/dist/memory/test-utils.d.ts +20 -0
- package/dist/memory/test-utils.d.ts.map +1 -0
- package/dist/memory/test-utils.js +44 -0
- package/dist/memory/test-utils.js.map +1 -0
- package/dist/memory/types.d.ts +70 -63
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/types.js +42 -2
- package/dist/memory/types.js.map +1 -1
- package/dist/permissions/audit.d.ts +82 -0
- package/dist/permissions/audit.d.ts.map +1 -0
- package/dist/permissions/audit.js +229 -0
- package/dist/permissions/audit.js.map +1 -0
- package/dist/permissions/index.d.ts +11 -1
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +15 -0
- package/dist/permissions/index.js.map +1 -1
- package/dist/permissions/manager.d.ts +149 -13
- package/dist/permissions/manager.d.ts.map +1 -1
- package/dist/permissions/manager.js +480 -35
- package/dist/permissions/manager.js.map +1 -1
- package/dist/permissions/manager.test.d.ts +5 -0
- package/dist/permissions/manager.test.d.ts.map +1 -0
- package/dist/permissions/manager.test.js +213 -0
- package/dist/permissions/manager.test.js.map +1 -0
- package/dist/permissions/persistence.d.ts +74 -0
- package/dist/permissions/persistence.d.ts.map +1 -0
- package/dist/permissions/persistence.js +248 -0
- package/dist/permissions/persistence.js.map +1 -0
- package/dist/permissions/persistence.test.d.ts +5 -0
- package/dist/permissions/persistence.test.d.ts.map +1 -0
- package/dist/permissions/persistence.test.js +171 -0
- package/dist/permissions/persistence.test.js.map +1 -0
- package/dist/permissions/prompt-matcher.d.ts +64 -0
- package/dist/permissions/prompt-matcher.d.ts.map +1 -0
- package/dist/permissions/prompt-matcher.js +415 -0
- package/dist/permissions/prompt-matcher.js.map +1 -0
- package/dist/permissions/prompt-matcher.test.d.ts +5 -0
- package/dist/permissions/prompt-matcher.test.d.ts.map +1 -0
- package/dist/permissions/prompt-matcher.test.js +107 -0
- package/dist/permissions/prompt-matcher.test.js.map +1 -0
- package/dist/permissions/types.d.ts +157 -0
- package/dist/permissions/types.d.ts.map +1 -1
- package/dist/permissions/types.js +45 -8
- package/dist/permissions/types.js.map +1 -1
- package/dist/prompts/index.d.ts +92 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +241 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/tools/builtin/ask-user.d.ts +64 -0
- package/dist/tools/builtin/ask-user.d.ts.map +1 -0
- package/dist/tools/builtin/ask-user.js +148 -0
- package/dist/tools/builtin/ask-user.js.map +1 -0
- package/dist/tools/builtin/bash.d.ts.map +1 -1
- package/dist/tools/builtin/bash.js +2 -1
- package/dist/tools/builtin/bash.js.map +1 -1
- package/dist/tools/builtin/edit.d.ts.map +1 -1
- package/dist/tools/builtin/edit.js +2 -1
- package/dist/tools/builtin/edit.js.map +1 -1
- package/dist/tools/builtin/glob.d.ts.map +1 -1
- package/dist/tools/builtin/glob.js +2 -1
- package/dist/tools/builtin/glob.js.map +1 -1
- package/dist/tools/builtin/grep.d.ts.map +1 -1
- package/dist/tools/builtin/grep.js +2 -1
- package/dist/tools/builtin/grep.js.map +1 -1
- package/dist/tools/builtin/read.d.ts.map +1 -1
- package/dist/tools/builtin/read.js +2 -1
- package/dist/tools/builtin/read.js.map +1 -1
- package/dist/tools/builtin/todowrite.d.ts +15 -0
- package/dist/tools/builtin/todowrite.d.ts.map +1 -0
- package/dist/tools/builtin/todowrite.js +88 -0
- package/dist/tools/builtin/todowrite.js.map +1 -0
- package/dist/tools/builtin/webfetch.d.ts.map +1 -1
- package/dist/tools/builtin/webfetch.js +2 -5
- package/dist/tools/builtin/webfetch.js.map +1 -1
- package/dist/tools/builtin/websearch.d.ts.map +1 -1
- package/dist/tools/builtin/websearch.js +2 -16
- package/dist/tools/builtin/websearch.js.map +1 -1
- package/dist/tools/builtin/write.d.ts.map +1 -1
- package/dist/tools/builtin/write.js +2 -1
- package/dist/tools/builtin/write.js.map +1 -1
- package/dist/tools/index.d.ts +19 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +8 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/types.d.ts +39 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/types.js +8 -0
- package/dist/tools/types.js.map +1 -1
- package/docs/config-system-comparison.md +707 -0
- package/docs/memory-system.md +238 -0
- package/docs/permissions.md +368 -0
- package/docs/proposals/0005-todo-system.md +350 -85
- package/docs/proposals/0006-memory-system.md +11 -10
- package/docs/proposals/0012-ask-user-question.md +1007 -207
- package/docs/proposals/0023-permission-enhancements.md +61 -2
- package/docs/proposals/0041-configuration-system.md +33 -2
- package/docs/proposals/0042-prompt-optimization.md +866 -0
- package/docs/proposals/README.md +7 -6
- package/examples/test-ask-user.ts +167 -0
- package/jest.config.js +26 -0
- package/package.json +8 -2
- package/src/agent/agent.ts +130 -16
- package/src/agent/index.ts +1 -0
- package/src/agent/types.ts +13 -1
- package/src/cli/components/App.tsx +362 -37
- package/src/cli/components/CommandSuggestions.tsx +2 -0
- package/src/cli/components/Header.tsx +11 -17
- package/src/cli/components/Logo.tsx +76 -9
- package/src/cli/components/Messages.tsx +104 -41
- package/src/cli/components/PermissionPrompt.tsx +388 -0
- package/src/cli/components/ProviderManager.tsx +5 -5
- package/src/cli/components/QuestionPrompt.tsx +462 -0
- package/src/cli/components/Spinner.tsx +138 -25
- package/src/cli/components/TodoList.tsx +54 -0
- package/src/cli/components/index.ts +7 -0
- package/src/cli/components/theme.ts +11 -1
- package/src/cli/index.tsx +54 -6
- package/src/config/index.ts +78 -4
- package/src/config/levels.test.ts +163 -0
- package/src/config/levels.ts +285 -0
- package/src/config/loader.test.ts +120 -0
- package/src/config/loader.ts +178 -0
- package/src/config/manager.test.ts +215 -0
- package/src/config/manager.ts +328 -40
- package/src/config/merger.test.ts +360 -0
- package/src/config/merger.ts +221 -0
- package/src/config/test-utils.ts +79 -0
- package/src/config/types.ts +152 -9
- package/src/memory/import-resolver.test.ts +117 -0
- package/src/memory/import-resolver.ts +149 -0
- package/src/memory/index.ts +11 -0
- package/src/memory/init-prompt.ts +113 -0
- package/src/memory/memory-manager.test.ts +198 -0
- package/src/memory/memory-manager.ts +716 -0
- package/src/memory/rules-parser.test.ts +182 -0
- package/src/memory/rules-parser.ts +82 -0
- package/src/memory/test-utils.ts +60 -0
- package/src/memory/types.ts +119 -0
- package/src/permissions/audit.ts +284 -0
- package/src/permissions/index.ts +20 -1
- package/src/permissions/manager.test.ts +260 -0
- package/src/permissions/manager.ts +592 -40
- package/src/permissions/persistence.test.ts +220 -0
- package/src/permissions/persistence.ts +301 -0
- package/src/permissions/prompt-matcher.test.ts +213 -0
- package/src/permissions/prompt-matcher.ts +472 -0
- package/src/permissions/types.ts +238 -8
- package/src/prompts/index.test.ts +279 -0
- package/src/prompts/index.ts +306 -0
- package/src/prompts/system/anthropic.txt +29 -0
- package/src/prompts/system/base.txt +166 -0
- package/src/prompts/system/gemini.txt +35 -0
- package/src/prompts/system/generic.txt +128 -0
- package/src/prompts/system/openai.txt +29 -0
- package/src/prompts/tools/ask-user.txt +110 -0
- package/src/prompts/tools/bash.txt +60 -0
- package/src/prompts/tools/edit.txt +29 -0
- package/src/prompts/tools/glob.txt +35 -0
- package/src/prompts/tools/grep.txt +43 -0
- package/src/prompts/tools/read.txt +22 -0
- package/src/prompts/tools/todowrite.txt +71 -0
- package/src/prompts/tools/webfetch.txt +34 -0
- package/src/prompts/tools/websearch.txt +41 -0
- package/src/prompts/tools/write.txt +23 -0
- package/src/tools/builtin/ask-user.ts +185 -0
- package/src/tools/builtin/bash.ts +2 -1
- package/src/tools/builtin/edit.ts +2 -1
- package/src/tools/builtin/glob.ts +2 -1
- package/src/tools/builtin/grep.ts +2 -1
- package/src/tools/builtin/read.ts +2 -1
- package/src/tools/builtin/todowrite.ts +102 -0
- package/src/tools/builtin/webfetch.ts +2 -5
- package/src/tools/builtin/websearch.ts +2 -16
- package/src/tools/builtin/write.ts +2 -1
- package/src/tools/index.ts +19 -0
- package/src/tools/types.ts +30 -0
- package/tsconfig.json +1 -1
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
import fastGlob from 'fast-glob';
|
|
6
6
|
import type { Tool, ToolResult } from '../types.js';
|
|
7
7
|
import { GlobInputSchema, type GlobInput, resolvePath, getErrorMessage } from '../types.js';
|
|
8
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
8
9
|
|
|
9
10
|
const MAX_RESULTS = 100;
|
|
10
11
|
|
|
11
12
|
export const globTool: Tool<GlobInput> = {
|
|
12
13
|
name: 'Glob',
|
|
13
|
-
description: '
|
|
14
|
+
description: loadToolDescription('glob'),
|
|
14
15
|
parameters: GlobInputSchema,
|
|
15
16
|
|
|
16
17
|
async execute(input, context): Promise<ToolResult> {
|
|
@@ -7,12 +7,13 @@ import * as path from 'path';
|
|
|
7
7
|
import fastGlob from 'fast-glob';
|
|
8
8
|
import type { Tool, ToolResult } from '../types.js';
|
|
9
9
|
import { GrepInputSchema, type GrepInput, resolvePath, getErrorMessage } from '../types.js';
|
|
10
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
10
11
|
|
|
11
12
|
const MAX_MATCHES = 50;
|
|
12
13
|
|
|
13
14
|
export const grepTool: Tool<GrepInput> = {
|
|
14
15
|
name: 'Grep',
|
|
15
|
-
description: '
|
|
16
|
+
description: loadToolDescription('grep'),
|
|
16
17
|
parameters: GrepInputSchema,
|
|
17
18
|
|
|
18
19
|
async execute(input, context): Promise<ToolResult> {
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import * as fs from 'fs/promises';
|
|
6
6
|
import type { Tool, ToolResult } from '../types.js';
|
|
7
7
|
import { ReadInputSchema, type ReadInput, resolvePath, getErrorMessage } from '../types.js';
|
|
8
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
8
9
|
|
|
9
10
|
export const readTool: Tool<ReadInput> = {
|
|
10
11
|
name: 'Read',
|
|
11
|
-
description: '
|
|
12
|
+
description: loadToolDescription('read'),
|
|
12
13
|
parameters: ReadInputSchema,
|
|
13
14
|
|
|
14
15
|
async execute(input, context): Promise<ToolResult> {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TodoWrite Tool - Manage task list for tracking progress
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type { Tool, ToolResult, TodoItem } from '../types.js';
|
|
6
|
+
import { TodoWriteInputSchema, type TodoWriteInput } from '../types.js';
|
|
7
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
8
|
+
|
|
9
|
+
// Global todo state - shared across tool invocations
|
|
10
|
+
let currentTodos: TodoItem[] = [];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get the current todo list
|
|
14
|
+
*/
|
|
15
|
+
export function getTodos(): TodoItem[] {
|
|
16
|
+
return [...currentTodos];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Clear all todos
|
|
21
|
+
*/
|
|
22
|
+
export function clearTodos(): void {
|
|
23
|
+
currentTodos = [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Format todos for display
|
|
28
|
+
*/
|
|
29
|
+
function formatTodos(todos: TodoItem[]): string {
|
|
30
|
+
if (todos.length === 0) {
|
|
31
|
+
return 'Todo list is empty.';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const statusIcons: Record<string, string> = {
|
|
35
|
+
pending: '[ ]',
|
|
36
|
+
in_progress: '[>]',
|
|
37
|
+
completed: '[x]',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const lines = todos.map((todo, index) => {
|
|
41
|
+
const icon = statusIcons[todo.status] || '[ ]';
|
|
42
|
+
return `${index + 1}. ${icon} ${todo.content}`;
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
return lines.join('\n');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Validate todo list rules
|
|
50
|
+
*/
|
|
51
|
+
function validateTodos(todos: TodoItem[]): string | null {
|
|
52
|
+
const inProgress = todos.filter((t) => t.status === 'in_progress');
|
|
53
|
+
if (inProgress.length > 1) {
|
|
54
|
+
return `Only one task should be in_progress at a time. Found ${inProgress.length} tasks in progress.`;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const todowriteTool: Tool<TodoWriteInput> = {
|
|
60
|
+
name: 'TodoWrite',
|
|
61
|
+
description: loadToolDescription('todowrite'),
|
|
62
|
+
parameters: TodoWriteInputSchema,
|
|
63
|
+
|
|
64
|
+
async execute(input): Promise<ToolResult> {
|
|
65
|
+
try {
|
|
66
|
+
// Validate the todo list
|
|
67
|
+
const validationError = validateTodos(input.todos);
|
|
68
|
+
if (validationError) {
|
|
69
|
+
return {
|
|
70
|
+
success: false,
|
|
71
|
+
output: '',
|
|
72
|
+
error: validationError,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Update the global todo state (auto-generate id if missing)
|
|
77
|
+
currentTodos = input.todos.map((todo, index) => ({
|
|
78
|
+
...todo,
|
|
79
|
+
id: todo.id || `todo-${index + 1}`,
|
|
80
|
+
}));
|
|
81
|
+
|
|
82
|
+
// Count statistics
|
|
83
|
+
const pending = currentTodos.filter((t) => t.status === 'pending').length;
|
|
84
|
+
const inProgress = currentTodos.filter((t) => t.status === 'in_progress').length;
|
|
85
|
+
const completed = currentTodos.filter((t) => t.status === 'completed').length;
|
|
86
|
+
|
|
87
|
+
const summary = `Todos updated: ${completed} completed, ${inProgress} in progress, ${pending} pending`;
|
|
88
|
+
const formatted = formatTodos(currentTodos);
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
success: true,
|
|
92
|
+
output: `${summary}\n\n${formatted}`,
|
|
93
|
+
};
|
|
94
|
+
} catch (error) {
|
|
95
|
+
return {
|
|
96
|
+
success: false,
|
|
97
|
+
output: '',
|
|
98
|
+
error: `Failed to update todos: ${error instanceof Error ? error.message : String(error)}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -7,6 +7,7 @@ import { z } from 'zod';
|
|
|
7
7
|
import type { Tool, ToolContext, ToolResult } from '../types.js';
|
|
8
8
|
import { getErrorMessage } from '../types.js';
|
|
9
9
|
import { validateUrl } from '../utils/ssrf.js';
|
|
10
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
10
11
|
|
|
11
12
|
// Constants
|
|
12
13
|
const MAX_RESPONSE_SIZE = 5 * 1024 * 1024; // 5MB
|
|
@@ -148,11 +149,7 @@ function truncateOutput(output: string): string {
|
|
|
148
149
|
*/
|
|
149
150
|
export const webfetchTool: Tool<WebFetchInput> = {
|
|
150
151
|
name: 'WebFetch',
|
|
151
|
-
description:
|
|
152
|
-
- Converts HTML to Markdown by default for easier reading
|
|
153
|
-
- Supports text, markdown, and html output formats
|
|
154
|
-
- Maximum response size: 5MB
|
|
155
|
-
- Timeout: 30 seconds (configurable up to 120 seconds)`,
|
|
152
|
+
description: loadToolDescription('webfetch'),
|
|
156
153
|
parameters: WebFetchInputSchema,
|
|
157
154
|
|
|
158
155
|
async execute(input: WebFetchInput, context: ToolContext): Promise<ToolResult> {
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
getCurrentSearchProviderName,
|
|
11
11
|
type SearchResult,
|
|
12
12
|
} from '../../providers/search/index.js';
|
|
13
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
13
14
|
|
|
14
15
|
// Constants
|
|
15
16
|
const DEFAULT_NUM_RESULTS = 10;
|
|
@@ -62,22 +63,7 @@ function formatResults(results: SearchResult[], query: string): string {
|
|
|
62
63
|
*/
|
|
63
64
|
export const websearchTool: Tool<WebSearchInput> = {
|
|
64
65
|
name: 'WebSearch',
|
|
65
|
-
description:
|
|
66
|
-
|
|
67
|
-
Use this tool when you need:
|
|
68
|
-
- Up-to-date information beyond your knowledge cutoff
|
|
69
|
-
- Current documentation or release notes
|
|
70
|
-
- Recent solutions to technical problems
|
|
71
|
-
- Current best practices
|
|
72
|
-
|
|
73
|
-
IMPORTANT: After answering, include a "Sources:" section with all relevant URLs as markdown hyperlinks.
|
|
74
|
-
|
|
75
|
-
Example:
|
|
76
|
-
[Your answer]
|
|
77
|
-
|
|
78
|
-
Sources:
|
|
79
|
-
- [Title 1](https://url1)
|
|
80
|
-
- [Title 2](https://url2)`,
|
|
66
|
+
description: loadToolDescription('websearch'),
|
|
81
67
|
parameters: WebSearchInputSchema,
|
|
82
68
|
|
|
83
69
|
async execute(input: WebSearchInput, context: ToolContext): Promise<ToolResult> {
|
|
@@ -6,10 +6,11 @@ import * as fs from 'fs/promises';
|
|
|
6
6
|
import * as path from 'path';
|
|
7
7
|
import type { Tool, ToolResult } from '../types.js';
|
|
8
8
|
import { WriteInputSchema, type WriteInput, resolvePath, getErrorMessage } from '../types.js';
|
|
9
|
+
import { loadToolDescription } from '../../prompts/index.js';
|
|
9
10
|
|
|
10
11
|
export const writeTool: Tool<WriteInput> = {
|
|
11
12
|
name: 'Write',
|
|
12
|
-
description: '
|
|
13
|
+
description: loadToolDescription('write'),
|
|
13
14
|
parameters: WriteInputSchema,
|
|
14
15
|
|
|
15
16
|
async execute(input, context): Promise<ToolResult> {
|
package/src/tools/index.ts
CHANGED
|
@@ -14,6 +14,19 @@ export { globTool } from './builtin/glob.js';
|
|
|
14
14
|
export { grepTool } from './builtin/grep.js';
|
|
15
15
|
export { webfetchTool } from './builtin/webfetch.js';
|
|
16
16
|
export { websearchTool } from './builtin/websearch.js';
|
|
17
|
+
export { todowriteTool, getTodos, clearTodos } from './builtin/todowrite.js';
|
|
18
|
+
export {
|
|
19
|
+
askUserQuestionTool,
|
|
20
|
+
formatAnswersForAgent,
|
|
21
|
+
formatAnswersForDisplay,
|
|
22
|
+
} from './builtin/ask-user.js';
|
|
23
|
+
export type {
|
|
24
|
+
Question as AskUserQuestion,
|
|
25
|
+
QuestionOption as AskUserQuestionOption,
|
|
26
|
+
QuestionAnswer as AskUserQuestionAnswer,
|
|
27
|
+
AskUserQuestionInput,
|
|
28
|
+
AskUserQuestionResult,
|
|
29
|
+
} from './builtin/ask-user.js';
|
|
17
30
|
|
|
18
31
|
import { ToolRegistry } from './registry.js';
|
|
19
32
|
import { readTool } from './builtin/read.js';
|
|
@@ -24,6 +37,8 @@ import { globTool } from './builtin/glob.js';
|
|
|
24
37
|
import { grepTool } from './builtin/grep.js';
|
|
25
38
|
import { webfetchTool } from './builtin/webfetch.js';
|
|
26
39
|
import { websearchTool } from './builtin/websearch.js';
|
|
40
|
+
import { todowriteTool } from './builtin/todowrite.js';
|
|
41
|
+
import { askUserQuestionTool } from './builtin/ask-user.js';
|
|
27
42
|
|
|
28
43
|
/**
|
|
29
44
|
* Create a registry with all built-in tools
|
|
@@ -39,6 +54,8 @@ export function createDefaultRegistry(): ToolRegistry {
|
|
|
39
54
|
grepTool,
|
|
40
55
|
webfetchTool,
|
|
41
56
|
websearchTool,
|
|
57
|
+
todowriteTool,
|
|
58
|
+
askUserQuestionTool,
|
|
42
59
|
]);
|
|
43
60
|
return registry;
|
|
44
61
|
}
|
|
@@ -55,4 +72,6 @@ export const builtinTools = [
|
|
|
55
72
|
grepTool,
|
|
56
73
|
webfetchTool,
|
|
57
74
|
websearchTool,
|
|
75
|
+
todowriteTool,
|
|
76
|
+
askUserQuestionTool,
|
|
58
77
|
];
|
package/src/tools/types.ts
CHANGED
|
@@ -9,9 +9,27 @@ import { z } from 'zod';
|
|
|
9
9
|
// Tool Definition Types
|
|
10
10
|
// ============================================================================
|
|
11
11
|
|
|
12
|
+
// Forward declaration for Question type (used by AskUserQuestion tool)
|
|
13
|
+
export interface Question {
|
|
14
|
+
question: string;
|
|
15
|
+
header: string;
|
|
16
|
+
options: Array<{ label: string; description: string }>;
|
|
17
|
+
multiSelect: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Forward declaration for QuestionAnswer type (used by AskUserQuestion tool)
|
|
21
|
+
export interface QuestionAnswer {
|
|
22
|
+
question: string;
|
|
23
|
+
header: string;
|
|
24
|
+
selectedOptions: string[];
|
|
25
|
+
customInput?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
12
28
|
export interface ToolContext {
|
|
13
29
|
cwd: string;
|
|
14
30
|
abortSignal?: AbortSignal;
|
|
31
|
+
/** Callback for AskUserQuestion tool to interact with user */
|
|
32
|
+
askUser?: (questions: Question[]) => Promise<QuestionAnswer[]>;
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
export interface ToolResultMetadata {
|
|
@@ -108,6 +126,18 @@ export const WebFetchInputSchema = z.object({
|
|
|
108
126
|
});
|
|
109
127
|
export type WebFetchInput = z.infer<typeof WebFetchInputSchema>;
|
|
110
128
|
|
|
129
|
+
export const TodoItemSchema = z.object({
|
|
130
|
+
content: z.string().min(1).describe('The task description'),
|
|
131
|
+
status: z.enum(['pending', 'in_progress', 'completed']).describe('Current status of the task'),
|
|
132
|
+
id: z.string().optional().describe('Unique task identifier'),
|
|
133
|
+
});
|
|
134
|
+
export type TodoItem = z.infer<typeof TodoItemSchema>;
|
|
135
|
+
|
|
136
|
+
export const TodoWriteInputSchema = z.object({
|
|
137
|
+
todos: z.array(TodoItemSchema).describe('The complete todo list to write'),
|
|
138
|
+
});
|
|
139
|
+
export type TodoWriteInput = z.infer<typeof TodoWriteInputSchema>;
|
|
140
|
+
|
|
111
141
|
// ============================================================================
|
|
112
142
|
// JSON Schema Conversion
|
|
113
143
|
// ============================================================================
|
package/tsconfig.json
CHANGED