@kaitranntt/ccs 3.4.6 → 4.1.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/.claude/agents/ccs-delegator.md +117 -0
- package/.claude/commands/ccs/glm/continue.md +22 -0
- package/.claude/commands/ccs/glm.md +22 -0
- package/.claude/commands/ccs/kimi/continue.md +22 -0
- package/.claude/commands/ccs/kimi.md +22 -0
- package/.claude/skills/ccs-delegation/SKILL.md +54 -0
- package/.claude/skills/ccs-delegation/references/README.md +24 -0
- package/.claude/skills/ccs-delegation/references/delegation-guidelines.md +99 -0
- package/.claude/skills/ccs-delegation/references/headless-workflow.md +174 -0
- package/.claude/skills/ccs-delegation/references/troubleshooting.md +268 -0
- package/README.ja.md +470 -146
- package/README.md +532 -145
- package/README.vi.md +484 -157
- package/VERSION +1 -1
- package/bin/auth/auth-commands.js +98 -13
- package/bin/auth/profile-detector.js +11 -6
- package/bin/ccs.js +148 -2
- package/bin/delegation/README.md +189 -0
- package/bin/delegation/delegation-handler.js +212 -0
- package/bin/delegation/headless-executor.js +617 -0
- package/bin/delegation/result-formatter.js +483 -0
- package/bin/delegation/session-manager.js +156 -0
- package/bin/delegation/settings-parser.js +109 -0
- package/bin/management/doctor.js +94 -1
- package/bin/utils/claude-symlink-manager.js +238 -0
- package/bin/utils/delegation-validator.js +154 -0
- package/bin/utils/error-codes.js +59 -0
- package/bin/utils/error-manager.js +38 -32
- package/bin/utils/helpers.js +65 -1
- package/bin/utils/progress-indicator.js +111 -0
- package/bin/utils/prompt.js +134 -0
- package/bin/utils/shell-completion.js +234 -0
- package/lib/ccs +575 -25
- package/lib/ccs.ps1 +381 -20
- package/lib/error-codes.ps1 +55 -0
- package/lib/error-codes.sh +63 -0
- package/lib/progress-indicator.ps1 +120 -0
- package/lib/progress-indicator.sh +117 -0
- package/lib/prompt.ps1 +109 -0
- package/lib/prompt.sh +99 -0
- package/package.json +2 -1
- package/scripts/completion/README.md +308 -0
- package/scripts/completion/ccs.bash +81 -0
- package/scripts/completion/ccs.fish +92 -0
- package/scripts/completion/ccs.ps1 +157 -0
- package/scripts/completion/ccs.zsh +130 -0
- package/scripts/postinstall.js +35 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Shell Completion Installer
|
|
10
|
+
* Auto-configures shell completion for bash, zsh, fish, PowerShell
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
class ShellCompletionInstaller {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.homeDir = os.homedir();
|
|
16
|
+
this.ccsDir = path.join(this.homeDir, '.ccs');
|
|
17
|
+
this.completionDir = path.join(this.ccsDir, 'completions');
|
|
18
|
+
this.scriptsDir = path.join(__dirname, '../../scripts/completion');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Detect current shell
|
|
23
|
+
*/
|
|
24
|
+
detectShell() {
|
|
25
|
+
const shell = process.env.SHELL || '';
|
|
26
|
+
|
|
27
|
+
if (shell.includes('bash')) return 'bash';
|
|
28
|
+
if (shell.includes('zsh')) return 'zsh';
|
|
29
|
+
if (shell.includes('fish')) return 'fish';
|
|
30
|
+
if (process.platform === 'win32') return 'powershell';
|
|
31
|
+
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Ensure completion files are in ~/.ccs/completions/
|
|
37
|
+
*/
|
|
38
|
+
ensureCompletionFiles() {
|
|
39
|
+
if (!fs.existsSync(this.completionDir)) {
|
|
40
|
+
fs.mkdirSync(this.completionDir, { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Copy completion scripts
|
|
44
|
+
const files = ['ccs.bash', 'ccs.zsh', 'ccs.fish', 'ccs.ps1'];
|
|
45
|
+
files.forEach(file => {
|
|
46
|
+
const src = path.join(this.scriptsDir, file);
|
|
47
|
+
const dest = path.join(this.completionDir, file);
|
|
48
|
+
|
|
49
|
+
if (fs.existsSync(src)) {
|
|
50
|
+
fs.copyFileSync(src, dest);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Install bash completion
|
|
57
|
+
*/
|
|
58
|
+
installBash() {
|
|
59
|
+
const rcFile = path.join(this.homeDir, '.bashrc');
|
|
60
|
+
const completionPath = path.join(this.completionDir, 'ccs.bash');
|
|
61
|
+
|
|
62
|
+
if (!fs.existsSync(completionPath)) {
|
|
63
|
+
throw new Error('Completion file not found. Please reinstall CCS.');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const marker = '# CCS shell completion';
|
|
67
|
+
const sourceCmd = `source "${completionPath}"`;
|
|
68
|
+
const block = `\n${marker}\n${sourceCmd}\n`;
|
|
69
|
+
|
|
70
|
+
// Check if already installed
|
|
71
|
+
if (fs.existsSync(rcFile)) {
|
|
72
|
+
const content = fs.readFileSync(rcFile, 'utf8');
|
|
73
|
+
if (content.includes(marker)) {
|
|
74
|
+
return { success: true, alreadyInstalled: true };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Append to .bashrc
|
|
79
|
+
fs.appendFileSync(rcFile, block);
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
success: true,
|
|
83
|
+
message: `Added to ${rcFile}`,
|
|
84
|
+
reload: 'source ~/.bashrc'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Install zsh completion
|
|
90
|
+
*/
|
|
91
|
+
installZsh() {
|
|
92
|
+
const rcFile = path.join(this.homeDir, '.zshrc');
|
|
93
|
+
const completionPath = path.join(this.completionDir, 'ccs.zsh');
|
|
94
|
+
const zshCompDir = path.join(this.homeDir, '.zsh', 'completion');
|
|
95
|
+
|
|
96
|
+
if (!fs.existsSync(completionPath)) {
|
|
97
|
+
throw new Error('Completion file not found. Please reinstall CCS.');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Create zsh completion directory
|
|
101
|
+
if (!fs.existsSync(zshCompDir)) {
|
|
102
|
+
fs.mkdirSync(zshCompDir, { recursive: true });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Copy to zsh completion directory
|
|
106
|
+
const destFile = path.join(zshCompDir, '_ccs');
|
|
107
|
+
fs.copyFileSync(completionPath, destFile);
|
|
108
|
+
|
|
109
|
+
const marker = '# CCS shell completion';
|
|
110
|
+
const setupCmds = [
|
|
111
|
+
'fpath=(~/.zsh/completion $fpath)',
|
|
112
|
+
'autoload -Uz compinit && compinit'
|
|
113
|
+
];
|
|
114
|
+
const block = `\n${marker}\n${setupCmds.join('\n')}\n`;
|
|
115
|
+
|
|
116
|
+
// Check if already installed
|
|
117
|
+
if (fs.existsSync(rcFile)) {
|
|
118
|
+
const content = fs.readFileSync(rcFile, 'utf8');
|
|
119
|
+
if (content.includes(marker)) {
|
|
120
|
+
return { success: true, alreadyInstalled: true };
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Append to .zshrc
|
|
125
|
+
fs.appendFileSync(rcFile, block);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
success: true,
|
|
129
|
+
message: `Added to ${rcFile}`,
|
|
130
|
+
reload: 'source ~/.zshrc'
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Install fish completion
|
|
136
|
+
*/
|
|
137
|
+
installFish() {
|
|
138
|
+
const completionPath = path.join(this.completionDir, 'ccs.fish');
|
|
139
|
+
const fishCompDir = path.join(this.homeDir, '.config', 'fish', 'completions');
|
|
140
|
+
|
|
141
|
+
if (!fs.existsSync(completionPath)) {
|
|
142
|
+
throw new Error('Completion file not found. Please reinstall CCS.');
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Create fish completion directory
|
|
146
|
+
if (!fs.existsSync(fishCompDir)) {
|
|
147
|
+
fs.mkdirSync(fishCompDir, { recursive: true });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// Copy to fish completion directory (fish auto-loads from here)
|
|
151
|
+
const destFile = path.join(fishCompDir, 'ccs.fish');
|
|
152
|
+
fs.copyFileSync(completionPath, destFile);
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
success: true,
|
|
156
|
+
message: `Installed to ${destFile}`,
|
|
157
|
+
reload: 'Fish auto-loads completions (no reload needed)'
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Install PowerShell completion
|
|
163
|
+
*/
|
|
164
|
+
installPowerShell() {
|
|
165
|
+
const profilePath = process.env.PROFILE || path.join(
|
|
166
|
+
this.homeDir,
|
|
167
|
+
'Documents',
|
|
168
|
+
'PowerShell',
|
|
169
|
+
'Microsoft.PowerShell_profile.ps1'
|
|
170
|
+
);
|
|
171
|
+
const completionPath = path.join(this.completionDir, 'ccs.ps1');
|
|
172
|
+
|
|
173
|
+
if (!fs.existsSync(completionPath)) {
|
|
174
|
+
throw new Error('Completion file not found. Please reinstall CCS.');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const marker = '# CCS shell completion';
|
|
178
|
+
const sourceCmd = `. "${completionPath.replace(/\\/g, '\\\\')}"`;
|
|
179
|
+
const block = `\n${marker}\n${sourceCmd}\n`;
|
|
180
|
+
|
|
181
|
+
// Create profile directory if needed
|
|
182
|
+
const profileDir = path.dirname(profilePath);
|
|
183
|
+
if (!fs.existsSync(profileDir)) {
|
|
184
|
+
fs.mkdirSync(profileDir, { recursive: true });
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Check if already installed
|
|
188
|
+
if (fs.existsSync(profilePath)) {
|
|
189
|
+
const content = fs.readFileSync(profilePath, 'utf8');
|
|
190
|
+
if (content.includes(marker)) {
|
|
191
|
+
return { success: true, alreadyInstalled: true };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Append to PowerShell profile
|
|
196
|
+
fs.appendFileSync(profilePath, block);
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
success: true,
|
|
200
|
+
message: `Added to ${profilePath}`,
|
|
201
|
+
reload: '. $PROFILE'
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Install for detected or specified shell
|
|
207
|
+
*/
|
|
208
|
+
install(shell = null) {
|
|
209
|
+
const targetShell = shell || this.detectShell();
|
|
210
|
+
|
|
211
|
+
if (!targetShell) {
|
|
212
|
+
throw new Error('Could not detect shell. Please specify: --bash, --zsh, --fish, or --powershell');
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Ensure completion files exist
|
|
216
|
+
this.ensureCompletionFiles();
|
|
217
|
+
|
|
218
|
+
// Install for target shell
|
|
219
|
+
switch (targetShell) {
|
|
220
|
+
case 'bash':
|
|
221
|
+
return this.installBash();
|
|
222
|
+
case 'zsh':
|
|
223
|
+
return this.installZsh();
|
|
224
|
+
case 'fish':
|
|
225
|
+
return this.installFish();
|
|
226
|
+
case 'powershell':
|
|
227
|
+
return this.installPowerShell();
|
|
228
|
+
default:
|
|
229
|
+
throw new Error(`Unsupported shell: ${targetShell}`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports = { ShellCompletionInstaller };
|