@defai.digital/ax-cli 3.15.25 → 4.0.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.
Files changed (59) hide show
  1. package/README.md +59 -6
  2. package/dist/commands/init.d.ts +3 -0
  3. package/dist/commands/init.js +98 -122
  4. package/dist/commands/init.js.map +1 -1
  5. package/dist/commands/setup.js +4 -4
  6. package/dist/commands/setup.js.map +1 -1
  7. package/dist/llm/tools.d.ts +14 -0
  8. package/dist/llm/tools.js +17 -4
  9. package/dist/llm/tools.js.map +1 -1
  10. package/dist/planner/types.d.ts +4 -4
  11. package/dist/tools/definitions/ask-user.d.ts +8 -0
  12. package/dist/tools/definitions/ask-user.js +168 -0
  13. package/dist/tools/definitions/ask-user.js.map +1 -0
  14. package/dist/tools/definitions/ax-agent.d.ts +7 -0
  15. package/dist/tools/definitions/ax-agent.js +149 -0
  16. package/dist/tools/definitions/ax-agent.js.map +1 -0
  17. package/dist/tools/definitions/bash-output.d.ts +7 -0
  18. package/dist/tools/definitions/bash-output.js +78 -0
  19. package/dist/tools/definitions/bash-output.js.map +1 -0
  20. package/dist/tools/definitions/bash.d.ts +8 -0
  21. package/dist/tools/definitions/bash.js +152 -0
  22. package/dist/tools/definitions/bash.js.map +1 -0
  23. package/dist/tools/definitions/create-file.d.ts +7 -0
  24. package/dist/tools/definitions/create-file.js +129 -0
  25. package/dist/tools/definitions/create-file.js.map +1 -0
  26. package/dist/tools/definitions/design.d.ts +12 -0
  27. package/dist/tools/definitions/design.js +368 -0
  28. package/dist/tools/definitions/design.js.map +1 -0
  29. package/dist/tools/definitions/index.d.ts +48 -0
  30. package/dist/tools/definitions/index.js +96 -0
  31. package/dist/tools/definitions/index.js.map +1 -0
  32. package/dist/tools/definitions/multi-edit.d.ts +7 -0
  33. package/dist/tools/definitions/multi-edit.js +123 -0
  34. package/dist/tools/definitions/multi-edit.js.map +1 -0
  35. package/dist/tools/definitions/search.d.ts +7 -0
  36. package/dist/tools/definitions/search.js +159 -0
  37. package/dist/tools/definitions/search.js.map +1 -0
  38. package/dist/tools/definitions/str-replace-editor.d.ts +7 -0
  39. package/dist/tools/definitions/str-replace-editor.js +145 -0
  40. package/dist/tools/definitions/str-replace-editor.js.map +1 -0
  41. package/dist/tools/definitions/todo.d.ts +8 -0
  42. package/dist/tools/definitions/todo.js +261 -0
  43. package/dist/tools/definitions/todo.js.map +1 -0
  44. package/dist/tools/definitions/view-file.d.ts +7 -0
  45. package/dist/tools/definitions/view-file.js +111 -0
  46. package/dist/tools/definitions/view-file.js.map +1 -0
  47. package/dist/tools/format-generators.d.ts +62 -0
  48. package/dist/tools/format-generators.js +291 -0
  49. package/dist/tools/format-generators.js.map +1 -0
  50. package/dist/tools/index.d.ts +4 -0
  51. package/dist/tools/index.js +6 -0
  52. package/dist/tools/index.js.map +1 -1
  53. package/dist/tools/result-enhancer.d.ts +64 -0
  54. package/dist/tools/result-enhancer.js +215 -0
  55. package/dist/tools/result-enhancer.js.map +1 -0
  56. package/dist/tools/types.d.ts +249 -0
  57. package/dist/tools/types.js +11 -0
  58. package/dist/tools/types.js.map +1 -0
  59. package/package.json +1 -1
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Rich Tool Definition Types for ax-cli Tool System v3.0
3
+ *
4
+ * This file defines the comprehensive ToolDefinition interface that serves as
5
+ * the single source of truth for all tool metadata. OpenAI/Anthropic formats
6
+ * are DERIVED from these definitions, not the other way around.
7
+ *
8
+ * @see PRD-AX-CLI-TOOL-SYSTEM-V3-FINAL.md
9
+ */
10
+ /**
11
+ * Tool categories for organization and filtering
12
+ */
13
+ export type ToolCategory = 'file-operations' | 'command-execution' | 'search' | 'task-management' | 'user-interaction' | 'web' | 'agent-delegation' | 'design';
14
+ /**
15
+ * Safety level classification for tools
16
+ * - safe: No risk of data loss or security issues
17
+ * - moderate: Some risk, but typically reversible
18
+ * - dangerous: High risk, requires confirmation
19
+ */
20
+ export type ToolSafetyLevel = 'safe' | 'moderate' | 'dangerous';
21
+ /**
22
+ * Parameter type definitions (JSON Schema compatible)
23
+ */
24
+ export type ParameterType = 'string' | 'number' | 'boolean' | 'array' | 'object';
25
+ /**
26
+ * Detailed parameter definition with rich metadata
27
+ */
28
+ export interface ParameterDefinition {
29
+ /** JSON Schema type */
30
+ type: ParameterType;
31
+ /** Comprehensive description of the parameter */
32
+ description: string;
33
+ /** Default value if not provided */
34
+ default?: unknown;
35
+ /** Allowed values (for enum-like parameters) */
36
+ enum?: string[];
37
+ /** Format hint (e.g., 'file-path', 'url', 'date-iso8601') */
38
+ format?: string;
39
+ /** Example values for LLM guidance */
40
+ examples?: unknown[];
41
+ /** Constraints that must be satisfied */
42
+ constraints?: string[];
43
+ /** For array types: schema of array items */
44
+ items?: ParameterDefinition | {
45
+ type: ParameterType;
46
+ properties?: Record<string, ParameterDefinition>;
47
+ required?: string[];
48
+ };
49
+ }
50
+ /**
51
+ * Tool parameter schema (JSON Schema object format)
52
+ */
53
+ export interface ToolParameterSchema {
54
+ type: 'object';
55
+ properties: Record<string, ParameterDefinition>;
56
+ required: string[];
57
+ }
58
+ /**
59
+ * Concrete usage example for a tool
60
+ */
61
+ export interface ToolExample {
62
+ /** Short description of what the example demonstrates */
63
+ description: string;
64
+ /** Scenario context - when would you use this */
65
+ scenario: string;
66
+ /** Example input arguments */
67
+ input: Record<string, unknown>;
68
+ /** Expected behavior/output description */
69
+ expectedBehavior: string;
70
+ /** Additional notes about the example */
71
+ notes?: string;
72
+ }
73
+ /**
74
+ * Rich Tool Definition - Single Source of Truth
75
+ *
76
+ * This interface defines everything about a tool. OpenAI function calling
77
+ * format and Anthropic tool format are derived from this definition.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const viewFileTool: ToolDefinition = {
82
+ * name: 'view_file',
83
+ * displayName: 'View File',
84
+ * description: 'Read and display file contents...',
85
+ * parameters: { ... },
86
+ * usageNotes: ['Always read before editing', ...],
87
+ * constraints: ['Cannot modify files', ...],
88
+ * examples: [{ description: 'Read a source file', ... }],
89
+ * tokenCost: 439,
90
+ * safetyLevel: 'safe',
91
+ * requiresConfirmation: false,
92
+ * categories: ['file-operations'],
93
+ * };
94
+ * ```
95
+ */
96
+ export interface ToolDefinition {
97
+ /** Tool identifier (lowercase with underscores) */
98
+ name: string;
99
+ /** Display name for UI (Title Case) */
100
+ displayName: string;
101
+ /**
102
+ * Comprehensive description (500+ words for complex tools)
103
+ *
104
+ * Should include:
105
+ * - What the tool does
106
+ * - When to use it
107
+ * - When NOT to use it
108
+ * - Important caveats
109
+ */
110
+ description: string;
111
+ /** Input parameter schema */
112
+ parameters: ToolParameterSchema;
113
+ /**
114
+ * Detailed usage guidance for LLM
115
+ * Aim for 5-10 notes covering common patterns and best practices
116
+ */
117
+ usageNotes: string[];
118
+ /**
119
+ * Constraints and limitations
120
+ * Things the LLM should NEVER do with this tool
121
+ */
122
+ constraints: string[];
123
+ /**
124
+ * Concrete usage examples (3-5 per tool)
125
+ * Each example should cover a realistic scenario
126
+ */
127
+ examples: ToolExample[];
128
+ /**
129
+ * Estimated token cost for this tool's description
130
+ * Used for token budget planning
131
+ */
132
+ tokenCost: number;
133
+ /** Safety classification */
134
+ safetyLevel: ToolSafetyLevel;
135
+ /** Requires user confirmation before execution */
136
+ requiresConfirmation: boolean;
137
+ /** Alternative tools to consider */
138
+ alternatives?: string[];
139
+ /** Tool categories for organization */
140
+ categories: ToolCategory[];
141
+ /**
142
+ * When NOT to use this tool
143
+ * Common misuses that should be avoided
144
+ */
145
+ antiPatterns?: string[];
146
+ /** Related tools that work well together */
147
+ relatedTools?: string[];
148
+ }
149
+ /**
150
+ * Result from tool execution
151
+ */
152
+ export interface ToolResult {
153
+ /** Whether the tool executed successfully */
154
+ success: boolean;
155
+ /** Output content (success message or error description) */
156
+ output: string;
157
+ /** Error message if success is false */
158
+ error?: string;
159
+ /** Additional structured data */
160
+ data?: Record<string, unknown>;
161
+ }
162
+ /**
163
+ * Enhanced result with embedded instructions
164
+ */
165
+ export interface EnhancedToolResult {
166
+ /** Original tool result content */
167
+ content: string;
168
+ /** Whether the execution was successful */
169
+ success: boolean;
170
+ /** Reminders to inject into context */
171
+ reminders: string[];
172
+ }
173
+ /**
174
+ * Tool implementation interface
175
+ * All tool implementations must implement this interface
176
+ */
177
+ export interface ToolImplementation {
178
+ /** Execute the tool with given arguments */
179
+ execute(args: Record<string, unknown>): Promise<ToolResult>;
180
+ }
181
+ /**
182
+ * Configuration for the result enhancer
183
+ */
184
+ export interface ResultEnhancerConfig {
185
+ /** Include security reminders based on content patterns */
186
+ securityReminders: boolean;
187
+ /** Include failure guidance from tool constraints */
188
+ toolGuidance: boolean;
189
+ /** Include format reminders (truncation, etc.) */
190
+ formatReminders: boolean;
191
+ }
192
+ /**
193
+ * Pre-execution hook result
194
+ */
195
+ export interface PreHookResult {
196
+ /** Whether to allow execution */
197
+ allow: boolean;
198
+ /** Modified arguments (if any) */
199
+ args: Record<string, unknown>;
200
+ /** Reason for blocking (if allow is false) */
201
+ blockReason?: string;
202
+ /** Reminders to add to result */
203
+ reminders: string[];
204
+ }
205
+ /**
206
+ * Post-execution hook result
207
+ */
208
+ export interface PostHookResult {
209
+ /** Reminders to add to result */
210
+ reminders: string[];
211
+ }
212
+ /**
213
+ * OpenAI function calling format (derived from ToolDefinition)
214
+ */
215
+ export interface OpenAITool {
216
+ type: 'function';
217
+ function: {
218
+ name: string;
219
+ description: string;
220
+ parameters: {
221
+ type: 'object';
222
+ properties: Record<string, unknown>;
223
+ required: string[];
224
+ };
225
+ };
226
+ }
227
+ /**
228
+ * Anthropic tool format (derived from ToolDefinition)
229
+ */
230
+ export interface AnthropicTool {
231
+ name: string;
232
+ description: string;
233
+ input_schema: {
234
+ type: 'object';
235
+ properties: Record<string, unknown>;
236
+ required: string[];
237
+ };
238
+ }
239
+ /**
240
+ * Tool execution result with context
241
+ */
242
+ export interface ToolExecutionResult {
243
+ /** Whether the tool executed successfully */
244
+ success: boolean;
245
+ /** Result content */
246
+ result: string;
247
+ /** Reminders to include in context */
248
+ reminders: string[];
249
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Rich Tool Definition Types for ax-cli Tool System v3.0
3
+ *
4
+ * This file defines the comprehensive ToolDefinition interface that serves as
5
+ * the single source of truth for all tool metadata. OpenAI/Anthropic formats
6
+ * are DERIVED from these definitions, not the other way around.
7
+ *
8
+ * @see PRD-AX-CLI-TOOL-SYSTEM-V3-FINAL.md
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defai.digital/ax-cli",
3
- "version": "3.15.25",
3
+ "version": "4.0.0",
4
4
  "sdkVersion": "1.3.0",
5
5
  "description": "Enterprise-Class AI Command Line Interface - Primary support for GLM (General Language Model) with multi-provider AI orchestration powered by AutomatosX.",
6
6
  "type": "module",