@defai.digital/ax-cli 2.3.0 → 2.4.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/.ax-cli/CUSTOM.md +111 -89
- package/.ax-cli/index.json +4 -3
- package/README.md +43 -16
- package/config/prompts.yaml +9 -0
- package/config/settings.yaml +2 -0
- package/dist/agent/llm-agent.d.ts +17 -0
- package/dist/agent/llm-agent.js +151 -52
- package/dist/agent/llm-agent.js.map +1 -1
- package/dist/commands/init/wizard.d.ts +66 -0
- package/dist/commands/init/wizard.js +310 -0
- package/dist/commands/init/wizard.js.map +1 -0
- package/dist/commands/init.js +146 -26
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp.js +3 -2
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/memory.d.ts +5 -0
- package/dist/commands/memory.js +257 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/setup.js +1 -1
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/templates.d.ts +5 -0
- package/dist/commands/templates.js +244 -0
- package/dist/commands/templates.js.map +1 -0
- package/dist/commands/update.js +9 -2
- package/dist/commands/update.js.map +1 -1
- package/dist/commands/usage.js +1 -1
- package/dist/commands/usage.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/constants.js.map +1 -1
- package/dist/hooks/use-input-handler.js +49 -12
- package/dist/hooks/use-input-handler.js.map +1 -1
- package/dist/index.js +143 -16
- package/dist/index.js.map +1 -1
- package/dist/llm/client.d.ts +5 -0
- package/dist/llm/client.js +43 -37
- package/dist/llm/client.js.map +1 -1
- package/dist/schemas/index.d.ts +69 -0
- package/dist/schemas/index.js +29 -0
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/yaml-schemas.d.ts +10 -0
- package/dist/schemas/yaml-schemas.js +2 -0
- package/dist/schemas/yaml-schemas.js.map +1 -1
- package/dist/tools/search.js +7 -1
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/text-editor.js +24 -14
- package/dist/tools/text-editor.js.map +1 -1
- package/dist/tools/todo-tool.js +62 -21
- package/dist/tools/todo-tool.js.map +1 -1
- package/dist/types/template.d.ts +53 -0
- package/dist/types/template.js +5 -0
- package/dist/types/template.js.map +1 -0
- package/dist/ui/components/command-suggestions.js +2 -2
- package/dist/ui/components/command-suggestions.js.map +1 -1
- package/dist/utils/cache.d.ts +1 -0
- package/dist/utils/cache.js +39 -5
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/config-loader.d.ts +2 -0
- package/dist/utils/config-loader.js +2 -1
- package/dist/utils/config-loader.js.map +1 -1
- package/dist/utils/confirmation-service.js +6 -3
- package/dist/utils/confirmation-service.js.map +1 -1
- package/dist/utils/error-handler.d.ts +5 -0
- package/dist/utils/error-handler.js +9 -3
- package/dist/utils/error-handler.js.map +1 -1
- package/dist/utils/init-previewer.d.ts +56 -0
- package/dist/utils/init-previewer.js +217 -0
- package/dist/utils/init-previewer.js.map +1 -0
- package/dist/utils/init-validator.d.ts +61 -0
- package/dist/utils/init-validator.js +248 -0
- package/dist/utils/init-validator.js.map +1 -0
- package/dist/utils/llm-optimized-instruction-generator.d.ts +31 -0
- package/dist/utils/llm-optimized-instruction-generator.js +296 -0
- package/dist/utils/llm-optimized-instruction-generator.js.map +1 -0
- package/dist/utils/onboarding-manager.d.ts +45 -0
- package/dist/utils/onboarding-manager.js +130 -0
- package/dist/utils/onboarding-manager.js.map +1 -0
- package/dist/utils/path-utils.d.ts +83 -0
- package/dist/utils/path-utils.js +122 -0
- package/dist/utils/path-utils.js.map +1 -0
- package/dist/utils/progress-tracker.d.ts +51 -0
- package/dist/utils/progress-tracker.js +152 -0
- package/dist/utils/progress-tracker.js.map +1 -0
- package/dist/utils/project-analyzer.js +8 -14
- package/dist/utils/project-analyzer.js.map +1 -1
- package/dist/utils/settings-manager.d.ts +3 -3
- package/dist/utils/settings-manager.js +6 -13
- package/dist/utils/settings-manager.js.map +1 -1
- package/dist/utils/string-utils.d.ts +19 -0
- package/dist/utils/string-utils.js +28 -0
- package/dist/utils/string-utils.js.map +1 -0
- package/dist/utils/template-manager.d.ts +54 -0
- package/dist/utils/template-manager.js +421 -0
- package/dist/utils/template-manager.js.map +1 -0
- package/dist/utils/text-utils.js +3 -1
- package/dist/utils/text-utils.js.map +1 -1
- package/package.json +2 -1
- package/vitest.config.ts +6 -0
- package/dist/utils/model-config.d.ts +0 -28
- package/dist/utils/model-config.js +0 -43
- package/dist/utils/model-config.js.map +0 -1
- package/dist/utils/tool-helpers.d.ts +0 -25
- package/dist/utils/tool-helpers.js +0 -53
- package/dist/utils/tool-helpers.js.map +0 -1
package/.ax-cli/CUSTOM.md
CHANGED
|
@@ -1,97 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @defai.digital/ax-cli - Quick Reference
|
|
2
2
|
|
|
3
|
-
**
|
|
4
|
-
**
|
|
5
|
-
**Language**: TypeScript
|
|
6
|
-
**Stack**: React, Vitest, Zod, Commander, Ink, ESM, TypeScript
|
|
3
|
+
**Type:** cli | **Lang:** TypeScript | **Ver:** v2.3.1
|
|
4
|
+
**Stack:** React, Vitest, Zod, Commander, Ink, ESM, TypeScript
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
---
|
|
9
7
|
|
|
10
|
-
##
|
|
8
|
+
## 🎯 Critical Rules
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
1. **ESM Imports:** Always use `.js` extension: `import { x } from './y.js'`
|
|
11
|
+
2. **Validation:** Use zod for all external inputs
|
|
12
|
+
3. **Types:** Explicit return types required on all functions
|
|
13
|
+
4. **Testing:** 80%+ coverage, test error paths
|
|
14
|
+
5. **Modules:** Use `import/export` (not `require/module.exports`)
|
|
16
15
|
|
|
17
|
-
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📋 Project Overview
|
|
19
|
+
|
|
20
|
+
**Entry:** `dist/index.js` | **PM:** npm | **Module:** ESM
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
**Directories:**
|
|
24
|
+
- `src/` - Source code
|
|
25
|
+
- `tests/` - Tests
|
|
26
|
+
- `src/tools/` - Tools
|
|
27
|
+
- `src/commands/` - Commands
|
|
28
|
+
- `src/utils/` - Utilities
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## 🔧 Code Patterns
|
|
18
33
|
|
|
19
34
|
### TypeScript
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
- Test edge cases: empty inputs, null/undefined, boundary conditions
|
|
78
|
-
- Include Unicode and special character tests where relevant
|
|
79
|
-
|
|
80
|
-
### Coverage Requirements
|
|
81
|
-
- Aim for high test coverage (80%+ for new code)
|
|
82
|
-
- Always test error paths and edge cases
|
|
83
|
-
- Test both success and failure scenarios
|
|
84
|
-
|
|
85
|
-
## Available Scripts
|
|
86
|
-
|
|
87
|
-
- **Development**: `bun run src/index.ts`
|
|
88
|
-
- **Build**: `tsc`
|
|
89
|
-
- **Test**: `vitest run`
|
|
90
|
-
- **Lint**: `eslint . --ext .js,.jsx,.ts,.tsx`
|
|
91
|
-
|
|
92
|
-
### Quick Commands
|
|
35
|
+
|
|
36
|
+
✅ **DO:**
|
|
37
|
+
```typescript
|
|
38
|
+
// Explicit types
|
|
39
|
+
function process(x: string): Promise<Result> { }
|
|
40
|
+
|
|
41
|
+
// ESM imports with .js extension
|
|
42
|
+
import { foo } from './bar.js';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
❌ **DON'T:**
|
|
46
|
+
```typescript
|
|
47
|
+
// No any types
|
|
48
|
+
function process(x: any) { } // ❌
|
|
49
|
+
|
|
50
|
+
// Missing .js extension
|
|
51
|
+
import { foo } from './bar'; // ❌
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Validation (zod)
|
|
55
|
+
|
|
56
|
+
✅ **DO:**
|
|
57
|
+
```typescript
|
|
58
|
+
const result = schema.safeParse(data);
|
|
59
|
+
if (!result.success) {
|
|
60
|
+
return { success: false, error: result.error };
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### CLI Commands
|
|
65
|
+
Commands should:
|
|
66
|
+
- Accept options via flags (`-f, --flag <value>`)
|
|
67
|
+
- Validate input before execution
|
|
68
|
+
- Provide clear error messages
|
|
69
|
+
- Return exit codes (0 = success, 1+ = error)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 🔄 Workflow
|
|
74
|
+
|
|
75
|
+
**Before:**
|
|
76
|
+
- Read files to understand implementation
|
|
77
|
+
- Search for related patterns
|
|
78
|
+
- Review tests for expected behavior
|
|
79
|
+
|
|
80
|
+
**Changes:**
|
|
81
|
+
- Edit existing files (never recreate)
|
|
82
|
+
- Keep changes focused and atomic
|
|
83
|
+
- Preserve code style
|
|
84
|
+
- Update tests when changing functionality
|
|
85
|
+
|
|
86
|
+
**After:**
|
|
87
|
+
1. Lint: `eslint . --ext .js,.jsx,.ts,.tsx`
|
|
88
|
+
2. Test: `vitest run`
|
|
89
|
+
3. Build: `npm run build:schemas && tsc`
|
|
90
|
+
|
|
91
|
+
**Quick Commands:**
|
|
93
92
|
```bash
|
|
94
|
-
npm run dev
|
|
95
|
-
npm test
|
|
96
|
-
npm run build
|
|
97
|
-
```
|
|
93
|
+
npm run dev # Development
|
|
94
|
+
npm test # Run tests
|
|
95
|
+
npm run build # Production build
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🐛 Troubleshooting
|
|
101
|
+
|
|
102
|
+
### "Module not found" errors
|
|
103
|
+
**Solution:** Add `.js` extension to imports (ESM requirement)
|
|
104
|
+
```typescript
|
|
105
|
+
// ✅ Correct
|
|
106
|
+
import { x } from './y.js';
|
|
107
|
+
|
|
108
|
+
// ❌ Wrong
|
|
109
|
+
import { x } from './y'; // Missing .js
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### zod validation errors
|
|
113
|
+
**Solution:** Use `.safeParse()` for detailed error messages. Check schema matches data structure.
|
|
114
|
+
|
|
115
|
+
### Tests fail locally but pass in CI
|
|
116
|
+
**Solution:** Check Node version, clear node_modules, check environment-specific code
|
|
117
|
+
|
|
118
|
+
### TypeScript compilation errors
|
|
119
|
+
**Solution:** Check `tsconfig.json` settings, ensure all types are imported, verify `moduleResolution`
|
package/.ax-cli/index.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"projectName": "@defai.digital/ax-cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"primaryLanguage": "TypeScript",
|
|
5
5
|
"techStack": [
|
|
6
6
|
"React",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"directories": {
|
|
17
17
|
"source": "src",
|
|
18
18
|
"tests": "tests",
|
|
19
|
+
"config": "config",
|
|
19
20
|
"tools": "src/tools"
|
|
20
21
|
},
|
|
21
22
|
"keyFiles": [
|
|
@@ -33,11 +34,11 @@
|
|
|
33
34
|
"validation": "zod"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
|
-
"build": "tsc",
|
|
37
|
+
"build": "npm run build:schemas && tsc",
|
|
37
38
|
"test": "vitest run",
|
|
38
39
|
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
|
|
39
40
|
"dev": "bun run src/index.ts"
|
|
40
41
|
},
|
|
41
42
|
"packageManager": "npm",
|
|
42
|
-
"lastAnalyzed": "2025-11-
|
|
43
|
+
"lastAnalyzed": "2025-11-19T22:52:24.501Z"
|
|
43
44
|
}
|
package/README.md
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
[](https://www.typescriptlang.org/)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
[](https://www.apple.com/macos/)
|
|
10
|
+
[](https://www.microsoft.com/windows/)
|
|
11
|
+
[](https://ubuntu.com/)
|
|
12
12
|
|
|
13
13
|

|
|
14
14
|
|
|
@@ -29,9 +29,6 @@ ax-cli init
|
|
|
29
29
|
|
|
30
30
|
# Start interactive mode
|
|
31
31
|
ax-cli
|
|
32
|
-
|
|
33
|
-
# Run headless command
|
|
34
|
-
ax-cli -p "list all TypeScript files"
|
|
35
32
|
```
|
|
36
33
|
|
|
37
34
|
## ✨ Features
|
|
@@ -93,16 +90,6 @@ AX CLI officially supports the following platforms:
|
|
|
93
90
|
npm install -g @defai.digital/ax-cli
|
|
94
91
|
```
|
|
95
92
|
|
|
96
|
-
### Local Development
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
git clone https://github.com/defai-digital/ax-cli.git
|
|
100
|
-
cd ax-cli
|
|
101
|
-
npm install
|
|
102
|
-
npm run build
|
|
103
|
-
npm link
|
|
104
|
-
```
|
|
105
|
-
|
|
106
93
|
[Installation Guide →](docs/installation.md)
|
|
107
94
|
|
|
108
95
|
## ⚙️ Configuration
|
|
@@ -156,6 +143,46 @@ ax-cli -p "write tests for utils/" --max-tool-rounds 50
|
|
|
156
143
|
ax-cli -p "refactor" --model glm-4.6
|
|
157
144
|
```
|
|
158
145
|
|
|
146
|
+
### 🔌 VSCode Integration (NEW!)
|
|
147
|
+
|
|
148
|
+
AX CLI integrates seamlessly with Visual Studio Code via tasks and keyboard shortcuts:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
# Analyze current file
|
|
152
|
+
ax-cli --prompt "Analyze this file" --file src/index.ts --json --vscode
|
|
153
|
+
|
|
154
|
+
# Explain selected code
|
|
155
|
+
ax-cli --prompt "Explain this code" --selection "function foo() {...}" --json --vscode
|
|
156
|
+
|
|
157
|
+
# Review git changes
|
|
158
|
+
ax-cli --prompt "Review my changes" --git-diff --json --vscode
|
|
159
|
+
|
|
160
|
+
# Analyze specific line range
|
|
161
|
+
ax-cli --prompt "Optimize this section" --file app.ts --line-range 50-100 --json
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Quick Setup:**
|
|
165
|
+
```bash
|
|
166
|
+
# Copy VSCode templates to your project
|
|
167
|
+
cd your-project
|
|
168
|
+
mkdir -p .vscode
|
|
169
|
+
cp node_modules/@defai.digital/ax-cli/templates/vscode/*.json .vscode/
|
|
170
|
+
|
|
171
|
+
# Start using with Cmd+Shift+P → "Tasks: Run Task" → Select AX task
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
**Pre-configured Tasks:**
|
|
175
|
+
- 🔍 Analyze Current File
|
|
176
|
+
- 📝 Explain Selection
|
|
177
|
+
- 🔄 Review Git Changes
|
|
178
|
+
- 🧪 Generate Tests
|
|
179
|
+
- 📚 Document Code
|
|
180
|
+
- ♻️ Refactor Selection
|
|
181
|
+
- 🐛 Find Bugs
|
|
182
|
+
- ⚡ Optimize Performance
|
|
183
|
+
|
|
184
|
+
[VSCode Integration Guide →](docs/vscode-integration-guide.md)
|
|
185
|
+
|
|
159
186
|
### Project Initialization
|
|
160
187
|
|
|
161
188
|
```bash
|
package/config/prompts.yaml
CHANGED
|
@@ -12,6 +12,7 @@ system_prompt:
|
|
|
12
12
|
- "Precision: Make exact, targeted changes - never broad strokes"
|
|
13
13
|
- "Self-Correction: Validate your work and fix issues immediately"
|
|
14
14
|
- "Minimal Verbosity: Show results, not commentary"
|
|
15
|
+
- "Smart Tool Usage: Answer simple questions directly. Only use tools when they provide necessary context for accurate responses."
|
|
15
16
|
|
|
16
17
|
tools_header: "Available Tools:"
|
|
17
18
|
|
|
@@ -84,6 +85,12 @@ system_prompt:
|
|
|
84
85
|
- Configuration files (package.json, tsconfig.json)
|
|
85
86
|
- Then specific modules as needed
|
|
86
87
|
|
|
88
|
+
4. CRITICAL - Complete the task:
|
|
89
|
+
- Gather information ONCE, then act on it
|
|
90
|
+
- Don't repeat the same exploration tools
|
|
91
|
+
- After getting tool results, USE them to complete the user's request
|
|
92
|
+
- Example: If asked for line count and you found files, COUNT them - don't search again
|
|
93
|
+
|
|
87
94
|
file_operations:
|
|
88
95
|
title: "FILE OPERATION SAFETY"
|
|
89
96
|
steps:
|
|
@@ -108,6 +115,8 @@ system_prompt:
|
|
|
108
115
|
- "Explain complex decisions only when necessary"
|
|
109
116
|
- "Errors: state problem → show fix → done"
|
|
110
117
|
- "Success: confirm completion → show key changes"
|
|
118
|
+
- "Simple questions: Answer directly without unnecessary tool calls"
|
|
119
|
+
- "If you find yourself calling the same tool multiple times with no progress, STOP and provide a direct answer"
|
|
111
120
|
|
|
112
121
|
confirmation_behavior:
|
|
113
122
|
title: "USER CONFIRMATION FLOW"
|
package/config/settings.yaml
CHANGED
|
@@ -5,6 +5,7 @@ agent:
|
|
|
5
5
|
max_tool_rounds: 400
|
|
6
6
|
default_timeout: 360000 # 6 minutes in milliseconds
|
|
7
7
|
default_max_tokens: 8192
|
|
8
|
+
max_recent_tool_calls: 20 # Keep only last 20 unique tool calls
|
|
8
9
|
|
|
9
10
|
file:
|
|
10
11
|
max_file_size: 1048576 # 1MB in bytes
|
|
@@ -29,6 +30,7 @@ token:
|
|
|
29
30
|
default_model: gpt-4
|
|
30
31
|
default_encoding: cl100k_base
|
|
31
32
|
cache_max_size: 1000
|
|
33
|
+
chars_per_token_estimate: 4 # Rough approximation for token estimation
|
|
32
34
|
|
|
33
35
|
cache:
|
|
34
36
|
default_max_size: 1000
|
|
@@ -40,11 +40,28 @@ export declare class LLMAgent extends EventEmitter {
|
|
|
40
40
|
private contextManager;
|
|
41
41
|
private abortController;
|
|
42
42
|
private maxToolRounds;
|
|
43
|
+
private recentToolCalls;
|
|
43
44
|
constructor(apiKey: string, baseURL?: string, model?: string, maxToolRounds?: number);
|
|
44
45
|
private initializeMCP;
|
|
45
46
|
private isGrokModel;
|
|
47
|
+
/**
|
|
48
|
+
* Detect if a tool call is repetitive (likely causing a loop)
|
|
49
|
+
* Returns true if the same tool with similar arguments was called multiple times recently
|
|
50
|
+
*/
|
|
51
|
+
private isRepetitiveToolCall;
|
|
52
|
+
/**
|
|
53
|
+
* Reset the tool call tracking (called at start of new user message)
|
|
54
|
+
*/
|
|
55
|
+
private resetToolCallTracking;
|
|
46
56
|
private shouldUseSearchFor;
|
|
47
57
|
processUserMessage(message: string): Promise<ChatEntry[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Recursively merge streaming delta into accumulated message
|
|
60
|
+
*/
|
|
61
|
+
private reduceStreamDelta;
|
|
62
|
+
/**
|
|
63
|
+
* Accumulate streaming message chunks
|
|
64
|
+
*/
|
|
48
65
|
private messageReducer;
|
|
49
66
|
/**
|
|
50
67
|
* Prepare user message and apply context management
|