ccjk 3.6.1 → 3.7.2
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 +1014 -13
- package/bin/ccjk.ts +119 -113
- package/dist/chunks/cli.mjs +2203 -0
- package/dist/chunks/package.mjs +1 -1
- package/dist/cli.mjs +38 -0
- package/dist/index.d.mts +1463 -1460
- package/dist/index.d.ts +1463 -1460
- package/dist/index.mjs +2300 -2286
- package/package.json +62 -53
- package/templates/common/error-prevention.md +267 -0
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ccjk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.7.2",
|
|
5
|
+
"packageManager": "pnpm@10.17.1",
|
|
5
6
|
"description": "Ultimate AI Development Tool - Code Tool Abstraction Layer with 83% Token Savings",
|
|
6
7
|
"author": {
|
|
7
8
|
"name": "CCJK Team",
|
|
@@ -73,62 +74,12 @@
|
|
|
73
74
|
"engines": {
|
|
74
75
|
"node": ">=20"
|
|
75
76
|
},
|
|
76
|
-
"dependencies": {
|
|
77
|
-
"@anthropic-ai/sdk": "^0.52.0",
|
|
78
|
-
"@iarna/toml": "^2.2.5",
|
|
79
|
-
"@types/semver": "^7.7.1",
|
|
80
|
-
"@types/tar": "^6.1.13",
|
|
81
|
-
"ansis": "^4.1.0",
|
|
82
|
-
"cac": "^6.7.14",
|
|
83
|
-
"chalk": "^5.6.2",
|
|
84
|
-
"chokidar": "^4.0.3",
|
|
85
|
-
"commander": "^14.0.2",
|
|
86
|
-
"dayjs": "^1.11.18",
|
|
87
|
-
"find-up-simple": "^1.0.1",
|
|
88
|
-
"fs-extra": "^11.3.2",
|
|
89
|
-
"gray-matter": "^4.0.3",
|
|
90
|
-
"i18next": "^25.5.2",
|
|
91
|
-
"i18next-fs-backend": "^2.6.0",
|
|
92
|
-
"inquirer": "^12.9.6",
|
|
93
|
-
"inquirer-toggle": "^1.0.1",
|
|
94
|
-
"nanoid": "^5.1.6",
|
|
95
|
-
"ora": "^9.0.0",
|
|
96
|
-
"pathe": "^2.0.3",
|
|
97
|
-
"semver": "^7.7.2",
|
|
98
|
-
"smol-toml": "^1.4.2",
|
|
99
|
-
"tar": "^7.5.2",
|
|
100
|
-
"tinyexec": "^1.0.1",
|
|
101
|
-
"trash": "^10.0.0",
|
|
102
|
-
"zod": "^3.22.0"
|
|
103
|
-
},
|
|
104
|
-
"devDependencies": {
|
|
105
|
-
"@antfu/eslint-config": "^5.4.1",
|
|
106
|
-
"@types/fs-extra": "^11.0.4",
|
|
107
|
-
"@types/inquirer": "^9.0.9",
|
|
108
|
-
"@types/jest": "^29.5.0",
|
|
109
|
-
"@types/node": "^22.18.6",
|
|
110
|
-
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
111
|
-
"@typescript-eslint/parser": "^6.0.0",
|
|
112
|
-
"@vitest/coverage-v8": "^3.2.4",
|
|
113
|
-
"@vitest/ui": "^3.2.4",
|
|
114
|
-
"eslint": "^9.36.0",
|
|
115
|
-
"eslint-plugin-format": "^1.0.2",
|
|
116
|
-
"glob": "^11.0.3",
|
|
117
|
-
"husky": "^9.1.7",
|
|
118
|
-
"jest": "^29.5.0",
|
|
119
|
-
"lint-staged": "^16.2.0",
|
|
120
|
-
"prettier": "^3.0.0",
|
|
121
|
-
"ts-jest": "^29.1.0",
|
|
122
|
-
"tsx": "^4.20.5",
|
|
123
|
-
"typescript": "^5.9.2",
|
|
124
|
-
"unbuild": "^3.6.1",
|
|
125
|
-
"vitest": "^3.2.4"
|
|
126
|
-
},
|
|
127
77
|
"scripts": {
|
|
128
78
|
"dev": "tsx ./src/cli.ts",
|
|
129
79
|
"build": "unbuild",
|
|
130
80
|
"start": "node bin/ccjk.mjs",
|
|
131
81
|
"typecheck": "tsc --noEmit",
|
|
82
|
+
"prepublishOnly": "pnpm build",
|
|
132
83
|
"lint": "eslint",
|
|
133
84
|
"lint:fix": "eslint --fix",
|
|
134
85
|
"test": "vitest",
|
|
@@ -136,6 +87,64 @@
|
|
|
136
87
|
"test:coverage": "vitest run --coverage",
|
|
137
88
|
"test:run": "vitest run",
|
|
138
89
|
"test:watch": "vitest watch",
|
|
90
|
+
"prepare": "husky",
|
|
139
91
|
"format": "prettier --write src/**/*.ts"
|
|
92
|
+
},
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"@anthropic-ai/sdk": "catalog:",
|
|
95
|
+
"@iarna/toml": "catalog:",
|
|
96
|
+
"@types/semver": "catalog:",
|
|
97
|
+
"@types/tar": "catalog:",
|
|
98
|
+
"ansis": "catalog:",
|
|
99
|
+
"cac": "catalog:",
|
|
100
|
+
"chalk": "catalog:",
|
|
101
|
+
"chokidar": "catalog:",
|
|
102
|
+
"commander": "catalog:",
|
|
103
|
+
"dayjs": "catalog:",
|
|
104
|
+
"find-up-simple": "catalog:",
|
|
105
|
+
"fs-extra": "catalog:",
|
|
106
|
+
"gray-matter": "catalog:",
|
|
107
|
+
"i18next": "catalog:",
|
|
108
|
+
"i18next-fs-backend": "catalog:",
|
|
109
|
+
"imap": "catalog:",
|
|
110
|
+
"inquirer": "catalog:",
|
|
111
|
+
"inquirer-toggle": "catalog:",
|
|
112
|
+
"mailparser": "catalog:",
|
|
113
|
+
"nanoid": "catalog:",
|
|
114
|
+
"nodemailer": "catalog:",
|
|
115
|
+
"ora": "catalog:",
|
|
116
|
+
"pathe": "catalog:",
|
|
117
|
+
"semver": "catalog:",
|
|
118
|
+
"smol-toml": "catalog:",
|
|
119
|
+
"tar": "catalog:",
|
|
120
|
+
"tinyexec": "catalog:",
|
|
121
|
+
"trash": "catalog:",
|
|
122
|
+
"zod": "catalog:"
|
|
123
|
+
},
|
|
124
|
+
"devDependencies": {
|
|
125
|
+
"@antfu/eslint-config": "catalog:",
|
|
126
|
+
"@types/fs-extra": "catalog:",
|
|
127
|
+
"@types/imap": "catalog:",
|
|
128
|
+
"@types/inquirer": "catalog:",
|
|
129
|
+
"@types/jest": "catalog:",
|
|
130
|
+
"@types/mailparser": "catalog:",
|
|
131
|
+
"@types/node": "catalog:conflicts_@types/node_h20_11_5",
|
|
132
|
+
"@types/nodemailer": "catalog:",
|
|
133
|
+
"@typescript-eslint/eslint-plugin": "catalog:",
|
|
134
|
+
"@typescript-eslint/parser": "catalog:",
|
|
135
|
+
"@vitest/coverage-v8": "catalog:",
|
|
136
|
+
"@vitest/ui": "catalog:",
|
|
137
|
+
"eslint": "catalog:",
|
|
138
|
+
"eslint-plugin-format": "catalog:",
|
|
139
|
+
"glob": "catalog:",
|
|
140
|
+
"husky": "catalog:",
|
|
141
|
+
"jest": "catalog:",
|
|
142
|
+
"lint-staged": "catalog:",
|
|
143
|
+
"prettier": "catalog:",
|
|
144
|
+
"ts-jest": "catalog:",
|
|
145
|
+
"tsx": "catalog:conflicts_tsx_h4_7_2",
|
|
146
|
+
"typescript": "catalog:conflicts_typescript_h5_3_3",
|
|
147
|
+
"unbuild": "catalog:",
|
|
148
|
+
"vitest": "catalog:"
|
|
140
149
|
}
|
|
141
|
-
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# CCJK Error Prevention System
|
|
2
|
+
|
|
3
|
+
**IMPORTANT**: This project uses the CCJK Error Prevention System to automatically prevent and fix common Claude Code CLI errors.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 🛡️ Automatic Error Prevention
|
|
8
|
+
|
|
9
|
+
All file operations and commands are automatically protected by CCJK's intelligent error prevention system.
|
|
10
|
+
|
|
11
|
+
### What It Does
|
|
12
|
+
|
|
13
|
+
The Error Prevention System operates in 5 layers:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
17
|
+
│ CCJK Error Prevention System │
|
|
18
|
+
├─────────────────────────────────────────────────────────────────┤
|
|
19
|
+
│ │
|
|
20
|
+
│ Layer 1: Pre-Execution Validation │
|
|
21
|
+
│ ├─ Parameter format validation │
|
|
22
|
+
│ ├─ Path validity checks │
|
|
23
|
+
│ ├─ Permission verification │
|
|
24
|
+
│ └─ Command existence validation │
|
|
25
|
+
│ │
|
|
26
|
+
│ Layer 2: Intelligent Wrappers │
|
|
27
|
+
│ ├─ Smart Write: Handles existing files automatically │
|
|
28
|
+
│ ├─ Smart Bash: Validates and retries commands │
|
|
29
|
+
│ ├─ Smart Path: Resolves cross-platform paths │
|
|
30
|
+
│ └─ Smart Edit: Detects content changes before editing │
|
|
31
|
+
│ │
|
|
32
|
+
│ Layer 3: Auto-Recovery │
|
|
33
|
+
│ ├─ Retry with exponential backoff │
|
|
34
|
+
│ ├─ Automatic error correction │
|
|
35
|
+
│ ├─ Rollback support │
|
|
36
|
+
│ └─ Fallback mechanisms │
|
|
37
|
+
│ │
|
|
38
|
+
│ Layer 4: Real-time Monitoring │
|
|
39
|
+
│ ├─ Error detection and classification │
|
|
40
|
+
│ ├─ Pattern analysis │
|
|
41
|
+
│ └─ Alert system │
|
|
42
|
+
│ │
|
|
43
|
+
│ Layer 5: Learning System │
|
|
44
|
+
│ ├─ Error history tracking │
|
|
45
|
+
│ └─ Solution database │
|
|
46
|
+
│ │
|
|
47
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 📋 Errors That Are Automatically Prevented
|
|
53
|
+
|
|
54
|
+
### 1. Error Writing File
|
|
55
|
+
|
|
56
|
+
**Causes**: File already exists, permission denied, path errors
|
|
57
|
+
|
|
58
|
+
**CCJK Auto-Fix**:
|
|
59
|
+
- ✅ Checks if file exists before writing
|
|
60
|
+
- ✅ Automatically backs up existing files
|
|
61
|
+
- ✅ Uses Edit instead of Write when file exists
|
|
62
|
+
- ✅ Creates missing directories automatically
|
|
63
|
+
- ✅ Retries on transient failures
|
|
64
|
+
|
|
65
|
+
### 2. Invalid Tool Parameters
|
|
66
|
+
|
|
67
|
+
**Causes**: Wrong parameter format, missing required parameters, type mismatch
|
|
68
|
+
|
|
69
|
+
**CCJK Auto-Fix**:
|
|
70
|
+
- ✅ Validates parameter format before execution
|
|
71
|
+
- ✅ Checks for unclosed quotes
|
|
72
|
+
- ✅ Validates file paths
|
|
73
|
+
- ✅ Provides specific error messages
|
|
74
|
+
|
|
75
|
+
### 3. Bash Command Failures (Exit Code 1)
|
|
76
|
+
|
|
77
|
+
**Causes**: Command not found, syntax errors, missing environment variables
|
|
78
|
+
|
|
79
|
+
**CCJK Auto-Fix**:
|
|
80
|
+
- ✅ Validates command exists before execution
|
|
81
|
+
- ✅ Checks parameter format
|
|
82
|
+
- ✅ Sets up environment automatically
|
|
83
|
+
- ✅ Retries on failures with exponential backoff
|
|
84
|
+
- ✅ Suggests alternative commands
|
|
85
|
+
|
|
86
|
+
### 4. Path Resolution Issues
|
|
87
|
+
|
|
88
|
+
**Causes**: Relative path errors, symlinks, cross-platform differences
|
|
89
|
+
|
|
90
|
+
**CCJK Auto-Fix**:
|
|
91
|
+
- ✅ Handles ~ (home directory)
|
|
92
|
+
- ✅ Expands environment variables
|
|
93
|
+
- ✅ Resolves symlinks
|
|
94
|
+
- ✅ Cross-platform path normalization
|
|
95
|
+
- ✅ Provides path fix suggestions
|
|
96
|
+
|
|
97
|
+
### 5. Permission Denied Errors
|
|
98
|
+
|
|
99
|
+
**Causes**: File permissions, directory permissions, read-only filesystem
|
|
100
|
+
|
|
101
|
+
**CCJK Auto-Fix**:
|
|
102
|
+
- ✅ Checks permissions before operations
|
|
103
|
+
- ✅ Attempts to fix script permissions (chmod +x)
|
|
104
|
+
- ✅ Provides specific permission error messages
|
|
105
|
+
- ✅ Suggests appropriate fixes
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 🚀 Best Practices
|
|
110
|
+
|
|
111
|
+
### When Writing Files
|
|
112
|
+
|
|
113
|
+
**❌ Don't worry about**:
|
|
114
|
+
- File already existing → CCJK handles it
|
|
115
|
+
- Creating directories → CCJK does it automatically
|
|
116
|
+
- Backing up files → CCJK backs up automatically
|
|
117
|
+
- Content validation → CCJK checks before writing
|
|
118
|
+
|
|
119
|
+
**✅ Just write**:
|
|
120
|
+
- CCJK will detect if file exists
|
|
121
|
+
- CCJK will use Edit tool if appropriate
|
|
122
|
+
- CCJK will create directories if needed
|
|
123
|
+
- CCJK will retry if write fails
|
|
124
|
+
|
|
125
|
+
### When Running Commands
|
|
126
|
+
|
|
127
|
+
**❌ Don't worry about**:
|
|
128
|
+
- Command not existing → CCJK checks first
|
|
129
|
+
- Parameter format → CCJK validates
|
|
130
|
+
- Environment setup → CCJK sets up automatically
|
|
131
|
+
- Command failing → CCJK retries with auto-fix
|
|
132
|
+
|
|
133
|
+
**✅ Just run**:
|
|
134
|
+
- CCJK will validate command exists
|
|
135
|
+
- CCJK will check parameters
|
|
136
|
+
- CCJK will handle dangerous command warnings
|
|
137
|
+
- CCJK will retry on failures
|
|
138
|
+
|
|
139
|
+
### When Reading Files
|
|
140
|
+
|
|
141
|
+
**❌ Don't worry about**:
|
|
142
|
+
- Path resolution → CCJK resolves paths
|
|
143
|
+
- File not found → CCJK provides clear error
|
|
144
|
+
- Permission issues → CCJK checks permissions
|
|
145
|
+
|
|
146
|
+
**✅ Just read**:
|
|
147
|
+
- CCJK will resolve relative paths
|
|
148
|
+
- CCJK will handle symlinks
|
|
149
|
+
- CCJK will provide helpful error messages
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 💡 Error Recovery Flow
|
|
154
|
+
|
|
155
|
+
When an error occurs, CCJK follows this process:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
1. Detect → Classify error type
|
|
159
|
+
2. Analyze → Determine if retryable
|
|
160
|
+
3. Auto-fix → Apply automatic correction if possible
|
|
161
|
+
4. Retry → Retry with exponential backoff
|
|
162
|
+
5. Fallback → Suggest alternative approach
|
|
163
|
+
6. Report → Provide detailed error and suggestion
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 🔧 Debugging
|
|
169
|
+
|
|
170
|
+
### Enable Debug Logging
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Enable error prevention debug output
|
|
174
|
+
export CCJK_ERROR_PREVENTION_DEBUG=1
|
|
175
|
+
|
|
176
|
+
# Or enable all CCJK debug output
|
|
177
|
+
export CCJK_DEBUG=1
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### View Error Statistics
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
import { getMiddleware } from 'ccjk/error-prevention'
|
|
184
|
+
|
|
185
|
+
const middleware = getMiddleware()
|
|
186
|
+
const errorStats = middleware.getErrorStats()
|
|
187
|
+
const fixStats = middleware.getFixStats()
|
|
188
|
+
|
|
189
|
+
console.log('Error Stats:', errorStats)
|
|
190
|
+
console.log('Fix Stats:', fixStats)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## 📊 Expected Impact
|
|
196
|
+
|
|
197
|
+
| Error Type | Before CCJK | After CCJK | Reduction |
|
|
198
|
+
|------------|-------------|------------|-----------|
|
|
199
|
+
| Error writing file | ⭐⭐⭐⭐⭐ | ⭐ | **80%** |
|
|
200
|
+
| Invalid tool parameters | ⭐⭐⭐⭐ | ⭐ | **75%** |
|
|
201
|
+
| Bash command failures | ⭐⭐⭐⭐ | ⭐ | **70%** |
|
|
202
|
+
| Path resolution issues | ⭐⭐⭐ | ⭐ | **85%** |
|
|
203
|
+
| Permission denied | ⭐⭐⭐ | ⭐ | **90%** |
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## 🎯 Tips
|
|
208
|
+
|
|
209
|
+
1. **Trust CCJK's automatic handling** - Let the system prevent errors
|
|
210
|
+
2. **Check console for CCJK messages** - Look for `[CCJK ErrorPrevention]` prefix
|
|
211
|
+
3. **Review suggestions when errors occur** - CCJK provides specific fix suggestions
|
|
212
|
+
4. **Report persistent errors** - Help improve the system
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 📖 API Reference
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
import {
|
|
220
|
+
getMiddleware,
|
|
221
|
+
SmartWriteTool,
|
|
222
|
+
SmartBashTool,
|
|
223
|
+
SmartPathResolver,
|
|
224
|
+
} from 'ccjk/error-prevention'
|
|
225
|
+
|
|
226
|
+
// Use middleware (recommended)
|
|
227
|
+
const middleware = getMiddleware()
|
|
228
|
+
|
|
229
|
+
// Write files
|
|
230
|
+
const writeResult = await middleware.interceptWrite(path, content)
|
|
231
|
+
|
|
232
|
+
// Execute commands
|
|
233
|
+
const bashResult = await middleware.interceptBash(command, options)
|
|
234
|
+
|
|
235
|
+
// Read files
|
|
236
|
+
const readResult = await middleware.interceptRead(path)
|
|
237
|
+
|
|
238
|
+
// Edit files
|
|
239
|
+
const editResult = await middleware.interceptEdit(path, oldString, newString)
|
|
240
|
+
|
|
241
|
+
// Get path info
|
|
242
|
+
const pathInfo = await middleware.getPathInfo(path)
|
|
243
|
+
|
|
244
|
+
// Get statistics
|
|
245
|
+
const errors = middleware.getErrorStats()
|
|
246
|
+
const fixes = middleware.getFixStats()
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
---
|
|
250
|
+
|
|
251
|
+
## 🎉 Summary
|
|
252
|
+
|
|
253
|
+
**Before CCJK Error Prevention**:
|
|
254
|
+
- ❌ Frequent errors
|
|
255
|
+
- ❌ Manual debugging
|
|
256
|
+
- ❌ Time wasted
|
|
257
|
+
- ❌ Frustration
|
|
258
|
+
|
|
259
|
+
**After CCJK Error Prevention**:
|
|
260
|
+
- ✅ Automatic prevention
|
|
261
|
+
- ✅ Intelligent fixes
|
|
262
|
+
- ✅ Efficient development
|
|
263
|
+
- ✅ Peace of mind
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
**Let CCJK handle the errors, focus on your code! 🚀**
|