@kaitranntt/ccs 2.5.1 → 3.0.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.
- package/README.ja.md +325 -0
- package/README.md +149 -102
- package/README.vi.md +147 -94
- package/VERSION +1 -1
- package/bin/auth-commands.js +405 -0
- package/bin/ccs.js +113 -35
- package/bin/config-manager.js +36 -7
- package/bin/doctor.js +365 -0
- package/bin/error-manager.js +159 -0
- package/bin/instance-manager.js +218 -0
- package/bin/profile-detector.js +199 -0
- package/bin/profile-registry.js +226 -0
- package/bin/recovery-manager.js +135 -0
- package/lib/ccs +856 -301
- package/lib/ccs.ps1 +792 -122
- package/package.json +1 -1
- package/scripts/postinstall.js +111 -12
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -14,6 +14,52 @@ const os = require('os');
|
|
|
14
14
|
* Cross-platform: Works on Unix, macOS, Windows
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Validate created configuration files
|
|
19
|
+
* @returns {object} { success: boolean, errors: string[], warnings: string[] }
|
|
20
|
+
*/
|
|
21
|
+
function validateConfiguration() {
|
|
22
|
+
const homedir = os.homedir();
|
|
23
|
+
const errors = [];
|
|
24
|
+
const warnings = [];
|
|
25
|
+
|
|
26
|
+
// Check ~/.ccs/ directory
|
|
27
|
+
const ccsDir = path.join(homedir, '.ccs');
|
|
28
|
+
if (!fs.existsSync(ccsDir)) {
|
|
29
|
+
errors.push('~/.ccs/ directory not found');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Check required files
|
|
33
|
+
const requiredFiles = [
|
|
34
|
+
{ path: path.join(ccsDir, 'config.json'), name: 'config.json' },
|
|
35
|
+
{ path: path.join(ccsDir, 'glm.settings.json'), name: 'glm.settings.json' },
|
|
36
|
+
{ path: path.join(ccsDir, 'kimi.settings.json'), name: 'kimi.settings.json' }
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
for (const file of requiredFiles) {
|
|
40
|
+
if (!fs.existsSync(file.path)) {
|
|
41
|
+
errors.push(`${file.name} not found`);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Validate JSON syntax
|
|
46
|
+
try {
|
|
47
|
+
const content = fs.readFileSync(file.path, 'utf8');
|
|
48
|
+
JSON.parse(content);
|
|
49
|
+
} catch (e) {
|
|
50
|
+
errors.push(`${file.name} has invalid JSON: ${e.message}`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Check ~/.claude/settings.json (warning only, not critical)
|
|
55
|
+
const claudeSettings = path.join(homedir, '.claude', 'settings.json');
|
|
56
|
+
if (!fs.existsSync(claudeSettings)) {
|
|
57
|
+
warnings.push('~/.claude/settings.json not found - run "claude /login"');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return { success: errors.length === 0, errors, warnings };
|
|
61
|
+
}
|
|
62
|
+
|
|
17
63
|
function createConfigFiles() {
|
|
18
64
|
try {
|
|
19
65
|
// Get user home directory (cross-platform)
|
|
@@ -107,23 +153,76 @@ function createConfigFiles() {
|
|
|
107
153
|
console.log('[OK] Kimi profile exists: ~/.ccs/kimi.settings.json (preserved)');
|
|
108
154
|
}
|
|
109
155
|
|
|
156
|
+
// Create ~/.claude/settings.json if missing (NEW)
|
|
157
|
+
const claudeDir = path.join(homedir, '.claude');
|
|
158
|
+
const claudeSettingsPath = path.join(claudeDir, 'settings.json');
|
|
159
|
+
|
|
160
|
+
if (!fs.existsSync(claudeDir)) {
|
|
161
|
+
fs.mkdirSync(claudeDir, { recursive: true, mode: 0o755 });
|
|
162
|
+
console.log('[OK] Created directory: ~/.claude/');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (!fs.existsSync(claudeSettingsPath)) {
|
|
166
|
+
// Create empty settings (matches Claude CLI behavior)
|
|
167
|
+
const tmpPath = `${claudeSettingsPath}.tmp`;
|
|
168
|
+
fs.writeFileSync(tmpPath, '{}\n', 'utf8');
|
|
169
|
+
fs.renameSync(tmpPath, claudeSettingsPath);
|
|
170
|
+
|
|
171
|
+
console.log('[OK] Created default settings: ~/.claude/settings.json');
|
|
172
|
+
console.log('');
|
|
173
|
+
console.log(' [i] Configure Claude CLI:');
|
|
174
|
+
console.log(' Run: claude /login');
|
|
175
|
+
console.log('');
|
|
176
|
+
} else {
|
|
177
|
+
console.log('[OK] Claude settings exist: ~/.claude/settings.json (preserved)');
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Validate configuration
|
|
181
|
+
console.log('');
|
|
182
|
+
console.log('[i] Validating configuration...');
|
|
183
|
+
const validation = validateConfiguration();
|
|
184
|
+
|
|
185
|
+
if (!validation.success) {
|
|
186
|
+
console.error('');
|
|
187
|
+
console.error('[X] Configuration validation failed:');
|
|
188
|
+
validation.errors.forEach(err => console.error(` - ${err}`));
|
|
189
|
+
console.error('');
|
|
190
|
+
throw new Error('Configuration incomplete');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// Show warnings (non-critical)
|
|
194
|
+
if (validation.warnings.length > 0) {
|
|
195
|
+
console.warn('');
|
|
196
|
+
console.warn('[!] Warnings:');
|
|
197
|
+
validation.warnings.forEach(warn => console.warn(` - ${warn}`));
|
|
198
|
+
}
|
|
199
|
+
|
|
110
200
|
console.log('');
|
|
111
201
|
console.log('[OK] CCS configuration ready!');
|
|
112
202
|
console.log(' Run: ccs --version');
|
|
113
203
|
|
|
114
204
|
} catch (err) {
|
|
115
|
-
//
|
|
116
|
-
console.
|
|
117
|
-
console.
|
|
118
|
-
console.
|
|
119
|
-
console.
|
|
120
|
-
console.
|
|
121
|
-
console.
|
|
122
|
-
console.
|
|
123
|
-
console.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
205
|
+
// Show error details
|
|
206
|
+
console.error('');
|
|
207
|
+
console.error('[X] CCS configuration failed');
|
|
208
|
+
console.error(` Error: ${err.message}`);
|
|
209
|
+
console.error('');
|
|
210
|
+
console.error('Recovery steps:');
|
|
211
|
+
console.error(' 1. Create directory manually:');
|
|
212
|
+
console.error(' mkdir -p ~/.ccs ~/.claude');
|
|
213
|
+
console.error('');
|
|
214
|
+
console.error(' 2. Create empty settings:');
|
|
215
|
+
console.error(' echo "{}" > ~/.claude/settings.json');
|
|
216
|
+
console.error('');
|
|
217
|
+
console.error(' 3. Retry installation:');
|
|
218
|
+
console.error(' npm install -g @kaitranntt/ccs --force');
|
|
219
|
+
console.error('');
|
|
220
|
+
console.error(' 4. If issue persists, report at:');
|
|
221
|
+
console.error(' https://github.com/kaitranntt/ccs/issues');
|
|
222
|
+
console.error('');
|
|
223
|
+
|
|
224
|
+
// Exit with error code (npm will show warning)
|
|
225
|
+
process.exit(1);
|
|
127
226
|
}
|
|
128
227
|
}
|
|
129
228
|
|