@kaitranntt/ccs 4.3.2 → 4.3.4

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ description: Continue last CCS delegation session [AUTO ENHANCE]
3
+ argument-hint: [follow-up instruction]
4
+ ---
5
+
6
+ Activate `ccs-delegation` skill. The skill contains all execution logic.
7
+
8
+ Task: Detect last-used profile from `~/.ccs/delegation-sessions.json`, parse `$ARGUMENTS`, enhance with previous context, execute continuation via CCS CLI.
9
+
10
+ **Examples:**
11
+ ```
12
+ /ccs:continue "also update the examples section" # Use last profile
13
+ /ccs:continue --glm "add unit tests" # Switch profiles
14
+ /ccs:continue "/commit with message" # Nested slash command
15
+ ```
@@ -0,0 +1,17 @@
1
+ ---
2
+ description: Delegate task with intelligent profile selection [AUTO ENHANCE]
3
+ argument-hint: [task description]
4
+ ---
5
+
6
+ Activate `ccs-delegation` skill. The skill contains all execution logic.
7
+
8
+ Task: Parse `$ARGUMENTS`, select optimal profile from `~/.ccs/config.json`, enhance prompt, execute delegation via CCS CLI.
9
+
10
+ **Examples:**
11
+ ```
12
+ /ccs "refactor auth.js to use async/await" # Simple task
13
+ /ccs "analyze entire architecture" # Long-context task
14
+ /ccs "think about caching strategy" # Reasoning task
15
+ /ccs --glm "add tests for UserService" # Force specific profile
16
+ /ccs "/cook create landing page" # Nested slash command
17
+ ```
@@ -2,6 +2,16 @@
2
2
 
3
3
  Activate `ccs-delegation` skill for automatic delegation of eligible tasks.
4
4
 
5
+ **Commands:**
6
+ - `/ccs "task"` - Auto-select best profile (glm/kimi/custom)
7
+ - `/ccs:continue "follow-up"` - Continue last session
8
+ - `/ccs --glm "task"` - Force specific profile
9
+
5
10
  **Auto-delegates:** typo fixes, test additions, refactoring, JSDoc, docs updates
6
11
  **Override:** Say "don't delegate" to bypass automation
7
- **Commands:** `/ccs:glm "task"` or `/ccs:kimi "task"` for explicit delegation
12
+
13
+ **Examples:**
14
+ - "use ccs to fix typos in README" → Auto-selects glm
15
+ - "use ccs to analyze architecture" → Auto-selects kimi
16
+ - "use ccs --glm to add tests" → Forces glm
17
+ - "use ccs:continue to commit" → Continues last session
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ccs-delegation
3
- description: AUTO-ACTIVATE for delegation-eligible tasks. Triggers on patterns like "fix typos", "add tests", "refactor to use", "add JSDoc", "analyze architecture". Also activates when user says "use ccs glm/kimi". Handles task validation, prompt enhancement, and execution via CCS CLI headless mode.
4
- version: 2.6.0
3
+ description: Auto-activate CCS CLI delegation for deterministic tasks. Parses user input, auto-selects optimal profile (glm/kimi/custom) from ~/.ccs/config.json, enhances prompts with context, executes via `ccs {profile} -p "task"` or `ccs {profile}:continue`, and reports results. Trigger: "use ccs [task]" patterns, typo/test/refactor keywords. Excludes: complex architecture, security-critical code, performance optimization, breaking changes.
4
+ version: 3.0.0
5
5
  ---
6
6
 
7
7
  # CCS Delegation
@@ -10,50 +10,94 @@ Delegate deterministic tasks to cost-optimized models via CCS CLI.
10
10
 
11
11
  ## Core Concept
12
12
 
13
- Execute tasks via alternative models using `ccs {profile} -p "task"` equivalent to `claude --settings ~/.ccs/{profile}.settings -p "task"`
13
+ Execute tasks via alternative models using:
14
+ - **Initial delegation**: `ccs {profile} -p "task"`
15
+ - **Session continuation**: `ccs {profile}:continue -p "follow-up"`
14
16
 
15
- **Profiles:** GLM (cost-optimized), Kimi (long-context)
17
+ **Profile Selection:**
18
+ - Auto-select from `~/.ccs/config.json` via task analysis
19
+ - Profiles: glm (cost-optimized), kimi (long-context/reasoning), custom profiles
20
+ - Override: `--{profile}` flag forces specific profile
16
21
 
17
22
  ## User Invocation Patterns
18
23
 
19
24
  Users trigger delegation naturally:
20
- - "use ccs glm [task]" - Delegate to GLM (cost-optimized)
21
- - "use ccs kimi [task]" - Delegate to Kimi (long-context)
22
- - "use ccs glm:continue [task]" - Continue GLM session
23
- - "use ccs kimi:continue [task]" - Continue Kimi session
25
+ - "use ccs [task]" - Auto-select best profile
26
+ - "use ccs --glm [task]" - Force GLM profile
27
+ - "use ccs --kimi [task]" - Force Kimi profile
28
+ - "use ccs:continue [task]" - Continue last session
24
29
 
25
30
  **Examples:**
26
- - "use ccs glm to fix typos in README.md"
27
- - "use ccs kimi to analyze the entire architecture"
28
- - "use ccs glm:continue to add unit tests"
31
+ - "use ccs to fix typos in README.md"
32
+ - "use ccs to analyze the entire architecture"
33
+ - "use ccs --glm to add unit tests"
34
+ - "use ccs:continue to commit the changes"
29
35
 
30
36
  ## Agent Response Protocol
31
37
 
32
- When user says "use ccs {profile} [task]":
33
-
34
- 1. **Validate eligibility** against Decision Framework
35
- - Check: Simple, mechanical, <5 files
36
- - Check: No design decisions required
37
- - Check: Clear acceptance criteria exists
38
-
39
- 2. **Enhance prompt** with context:
40
- - Add file paths if mentioned
41
- - Include working directory
42
- - Specify success criteria
43
- - Add relevant constraints
44
-
45
- 3. **Execute via Bash tool**:
46
- ```bash
47
- ccs {profile} -p "enhanced prompt"
48
- ```
49
-
50
- 4. **Report results** to user:
51
- - Cost (USD)
52
- - Duration (seconds)
53
- - Session ID (for continuation)
54
- - Exit code/status
55
-
56
- **If ineligible:** Explain why and handle in main session.
38
+ **For `/ccs [task]`:**
39
+
40
+ 1. **Parse override flag**
41
+ - Scan task for pattern: `--(\w+)`
42
+ - If match: `profile = match[1]`, remove flag from task, skip to step 5
43
+ - If no match: continue to step 2
44
+
45
+ 2. **Discover profiles**
46
+ - Read `~/.ccs/config.json` using Read tool
47
+ - Extract `Object.keys(config.profiles)` → `availableProfiles[]`
48
+ - If file missing → Error: "CCS not configured. Run: ccs doctor"
49
+ - If empty → Error: "No profiles in config.json"
50
+
51
+ 3. **Analyze task requirements**
52
+ - Scan task for keywords:
53
+ - `/(think|analyze|reason|debug|investigate|evaluate)/i` `needsReasoning = true`
54
+ - `/(architecture|entire|all files|codebase|analyze all)/i` → `needsLongContext = true`
55
+ - `/(typo|test|refactor|update|fix)/i` → `preferCostOptimized = true`
56
+
57
+ 4. **Select profile**
58
+ - For each profile in `availableProfiles`: classify by name pattern (see Profile Characteristic Inference table)
59
+ - If `needsReasoning`: filter profiles where `reasoning=true` → prefer kimi
60
+ - Else if `needsLongContext`: filter profiles where `context=long` → prefer kimi
61
+ - Else: filter profiles where `cost=low` → prefer glm
62
+ - `selectedProfile = filteredProfiles[0]`
63
+ - If `filteredProfiles.length === 0`: fallback to `glm` if exists, else first available
64
+ - If no profiles: Error
65
+
66
+ 5. **Enhance prompt**
67
+ - If task mentions files: gather context using Read tool
68
+ - Add: file paths, current implementation, expected behavior, success criteria
69
+ - Preserve slash commands at task start (e.g., `/cook`, `/commit`)
70
+
71
+ 6. **Execute delegation**
72
+ - Run: `ccs {selectedProfile} -p "$enhancedPrompt"` via Bash tool
73
+
74
+ 7. **Report results**
75
+ - Log: "Selected {profile} (reason: {reasoning/long-context/cost-optimized})"
76
+ - Report: Cost (USD), Duration (sec), Session ID, Exit code
77
+
78
+ **For `/ccs:continue [follow-up]`:**
79
+
80
+ 1. **Detect profile**
81
+ - Read `~/.ccs/delegation-sessions.json` using Read tool
82
+ - Find most recent session (latest timestamp)
83
+ - Extract profile name from session data
84
+ - If no sessions → Error: "No previous delegation. Use /ccs first"
85
+
86
+ 2. **Parse override flag**
87
+ - Scan follow-up for pattern: `--(\w+)`
88
+ - If match: `profile = match[1]`, remove flag from follow-up, log profile switch
89
+ - If no match: use detected profile from step 1
90
+
91
+ 3. **Enhance prompt**
92
+ - Review previous work (check what was accomplished)
93
+ - Add: previous context, incomplete tasks, validation criteria
94
+ - Preserve slash commands at start
95
+
96
+ 4. **Execute continuation**
97
+ - Run: `ccs {profile}:continue -p "$enhancedPrompt"` via Bash tool
98
+
99
+ 5. **Report results**
100
+ - Report: Profile, Session #, Incremental cost, Total cost, Duration, Exit code
57
101
 
58
102
  ## Decision Framework
59
103
 
@@ -69,18 +113,58 @@ When user says "use ccs {profile} [task]":
69
113
  - Performance optimization
70
114
  - Breaking changes/migrations
71
115
 
72
- ## Profile Selection
116
+ ## Profile Selection Logic
117
+
118
+ **Task Analysis Keywords** (scan task string with regex):
119
+
120
+ | Pattern | Variable | Example |
121
+ |---------|----------|---------|
122
+ | `/(think\|analyze\|reason\|debug\|investigate\|evaluate)/i` | `needsReasoning = true` | "think about caching" |
123
+ | `/(architecture\|entire\|all files\|codebase\|analyze all)/i` | `needsLongContext = true` | "analyze all files" |
124
+ | `/(typo\|test\|refactor\|update\|fix)/i` | `preferCostOptimized = true` | "fix typo in README" |
125
+
126
+ **Profile Characteristic Inference** (classify by name pattern):
127
+
128
+ | Profile Pattern | Cost | Context | Reasoning |
129
+ |----------------|------|---------|-----------|
130
+ | `/^glm/i` | low | standard | false |
131
+ | `/^kimi/i` | medium | long | true |
132
+ | `/^claude/i` | high | standard | false |
133
+ | others | low | standard | false |
134
+
135
+ **Selection Algorithm** (apply filters sequentially):
136
+
137
+ ```
138
+ profiles = Object.keys(config.profiles)
139
+ classified = profiles.map(p => ({name: p, ...inferCharacteristics(p)}))
140
+
141
+ if (needsReasoning):
142
+ filtered = classified.filter(p => p.reasoning === true).sort(['kimi'])
143
+ else if (needsLongContext):
144
+ filtered = classified.filter(p => p.context === 'long').sort(['kimi'])
145
+ else:
146
+ filtered = classified.filter(p => p.cost === 'low').sort(['glm', ...])
147
+
148
+ selected = filtered[0] || profiles.find(p => p === 'glm') || profiles[0]
149
+ if (!selected): throw Error("No profiles configured")
150
+
151
+ log("Selected {selected} (reason: {reasoning|long-context|cost-optimized})")
152
+ ```
73
153
 
74
- - **GLM**: Simple tasks (<5 files, clear scope, cost-optimized)
75
- - **Kimi**: Long-context (multi-file analysis, architecture docs)
154
+ **Override Logic**:
155
+ - Parse task for `/--(\w+)/`. If match: `profile = match[1]`, remove from task, skip selection
76
156
 
77
157
  ## Example Delegation Tasks
78
158
 
79
159
  **Good candidates:**
80
- - "add unit tests for UserService using Jest"
81
- - "fix typos in README.md"
82
- - "refactor parseConfig to use destructuring"
83
- - "add JSDoc comments to auth.js"
160
+ - "/ccs add unit tests for UserService using Jest"
161
+ → Auto-selects: glm (simple task)
162
+ - "/ccs analyze entire architecture in src/"
163
+ → Auto-selects: kimi (long-context)
164
+ - "/ccs think about the best database schema design"
165
+ → Auto-selects: kimi (reasoning)
166
+ - "/ccs --glm refactor parseConfig to use destructuring"
167
+ → Forces: glm (override)
84
168
 
85
169
  **Bad candidates (keep in main):**
86
170
  - "implement OAuth" (too complex, needs design)
@@ -89,9 +173,15 @@ When user says "use ccs {profile} [task]":
89
173
 
90
174
  ## Execution
91
175
 
92
- Slash commands: `/ccs:glm "task"` or `/ccs:glm:continue "follow-up"`
176
+ **Commands:**
177
+ - `/ccs "task"` - Intelligent delegation (auto-select profile)
178
+ - `/ccs --{profile} "task"` - Force specific profile
179
+ - `/ccs:continue "follow-up"` - Continue last session (auto-detect profile)
180
+ - `/ccs:continue --{profile} "follow-up"` - Continue with profile switch
93
181
 
94
- Agent via Bash: `ccs glm -p "task"` or `ccs glm:continue -p "follow-up"`
182
+ **Agent via Bash:**
183
+ - Auto: `ccs {auto-selected} -p "task"`
184
+ - Continue: `ccs {detected}:continue -p "follow-up"`
95
185
 
96
186
  ## References
97
187
 
@@ -195,11 +195,6 @@ jq '.glm.turns' ~/.ccs/delegation-sessions.json
195
195
  rm ~/.ccs/delegation-sessions.json # Fresh start (loses all sessions)
196
196
  ```
197
197
 
198
- **Bypass delegation (use CLI directly):**
199
- ```bash
200
- claude -p "task" --settings ~/.ccs/{profile}.settings.json
201
- ```
202
-
203
198
  **Interactive mode (no -p flag):**
204
199
  ```bash
205
200
  ccs {profile} # Opens interactive session
package/README.md CHANGED
@@ -322,7 +322,7 @@ graph LR
322
322
  ```plaintext
323
323
  ~/.ccs/
324
324
  ├── .claude/ # CCS items (ships with package, v4.1)
325
- │ ├── commands/ccs/ # Delegation commands (/ccs:glm, /ccs:kimi)
325
+ │ ├── commands/ccs/ # Delegation commands (/ccs, /ccs:continue)
326
326
  │ ├── skills/ccs-delegation/ # AI decision framework
327
327
  │ └── agents/ccs-delegator.md # Proactive delegation agent
328
328
  ├── shared/ # Symlinks to ~/.claude/ (for profiles)
@@ -401,7 +401,7 @@ ccs --help # Show all commands and options
401
401
 
402
402
  ### What is Delegation?
403
403
 
404
- CCS Delegation lets you **send tasks to alternative models** (`glm`, `kimi`) **from your main Claude session** using the `-p` flag or slash commands (`/ccs:glm`, `/ccs:kimi`).
404
+ CCS Delegation lets you **send tasks to alternative models** (`glm`, `kimi`) **from your main Claude session** using the `-p` flag or intelligent slash commands (`/ccs`, `/ccs:continue`).
405
405
 
406
406
  **Why use it?**
407
407
  - **Token efficiency**: Simple tasks cost 81% less on GLM vs main Claude session
@@ -426,9 +426,10 @@ ccs glm:continue -p "run the tests and fix any failures"
426
426
  **Via Slash Commands** (inside Claude sessions):
427
427
  ```bash
428
428
  # In your main Claude session:
429
- /ccs:glm "refactor auth.js to use async/await"
430
- /ccs:kimi "find all deprecated API usages across codebase"
431
- /ccs:glm:continue "also update the README examples"
429
+ /ccs "refactor auth.js to use async/await" # Auto-selects best profile
430
+ /ccs --glm "fix typo in documentation" # Forces GLM profile
431
+ /ccs --kimi "analyze entire architecture" # Forces Kimi profile
432
+ /ccs:continue "also update the README examples" # Continues last session
432
433
  ```
433
434
 
434
435
  **Via Natural Language** (Claude auto-delegates):
package/VERSION CHANGED
@@ -1 +1 @@
1
- 4.3.2
1
+ 4.3.4
package/bin/ccs.js CHANGED
@@ -172,8 +172,10 @@ function handleHelpCommand() {
172
172
 
173
173
  // Delegation (inside Claude Code CLI)
174
174
  console.log(colored('Delegation (inside Claude Code CLI):', 'cyan'));
175
- console.log(` ${colored('/ccs:glm "task"', 'yellow')} Delegate to GLM-4.6 for simple tasks`);
176
- console.log(` ${colored('/ccs:kimi "task"', 'yellow')} Delegate to Kimi for long context`);
175
+ console.log(` ${colored('/ccs "task"', 'yellow')} Delegate task (auto-selects best profile)`);
176
+ console.log(` ${colored('/ccs --glm "task"', 'yellow')} Force GLM-4.6 for simple tasks`);
177
+ console.log(` ${colored('/ccs --kimi "task"', 'yellow')} Force Kimi for long context`);
178
+ console.log(` ${colored('/ccs:continue "follow-up"', 'yellow')} Continue last delegation session`);
177
179
  console.log(' Save tokens by delegating simple tasks to cost-optimized models');
178
180
  console.log('');
179
181
 
@@ -296,6 +298,150 @@ async function handleSyncCommand() {
296
298
  process.exit(0);
297
299
  }
298
300
 
301
+ /**
302
+ * Detect installation method
303
+ * @returns {'npm'|'direct'} - Installation method
304
+ */
305
+ function detectInstallationMethod() {
306
+ const scriptPath = process.argv[1];
307
+
308
+ // Method 1: Check if script is inside node_modules
309
+ if (scriptPath.includes('node_modules')) {
310
+ return 'npm';
311
+ }
312
+
313
+ // Method 2: Check if script is in npm global bin directory
314
+ // Common patterns for npm global installations
315
+ const npmGlobalBinPatterns = [
316
+ /\.npm\/global\/bin\//, // ~/.npm/global/bin/ccs
317
+ /\/\.nvm\/versions\/node\/[^\/]+\/bin\//, // ~/.nvm/versions/node/v22.19.0/bin/ccs
318
+ /\/usr\/local\/bin\//, // /usr/local/bin/ccs (if npm global prefix is /usr/local)
319
+ /\/usr\/bin\// // /usr/bin/ccs (if npm global prefix is /usr)
320
+ ];
321
+
322
+ for (const pattern of npmGlobalBinPatterns) {
323
+ if (pattern.test(scriptPath)) {
324
+ // Verify this is actually CCS by checking the linked target
325
+ try {
326
+ const binDir = path.dirname(scriptPath);
327
+ const nodeModulesDir = path.join(binDir, '..', 'lib', 'node_modules', '@kaitranntt', 'ccs');
328
+ const globalModulesDir = path.join(binDir, '..', 'node_modules', '@kaitranntt', 'ccs');
329
+
330
+ if (fs.existsSync(nodeModulesDir) || fs.existsSync(globalModulesDir)) {
331
+ return 'npm';
332
+ }
333
+ } catch (err) {
334
+ // Continue checking other patterns
335
+ }
336
+ }
337
+ }
338
+
339
+ // Method 3: Check if package.json exists in parent directory (development mode)
340
+ const packageJsonPath = path.join(__dirname, '..', 'package.json');
341
+
342
+ if (fs.existsSync(packageJsonPath)) {
343
+ try {
344
+ const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
345
+ // If package.json has name "@kaitranntt/ccs", it's npm install
346
+ if (pkg.name === '@kaitranntt/ccs') {
347
+ return 'npm';
348
+ }
349
+ } catch (err) {
350
+ // Ignore parse errors
351
+ }
352
+ }
353
+
354
+ // Method 4: Check if script is a symlink pointing to node_modules
355
+ try {
356
+ const stats = fs.lstatSync(scriptPath);
357
+ if (stats.isSymbolicLink()) {
358
+ const targetPath = fs.readlinkSync(scriptPath);
359
+ if (targetPath.includes('node_modules') || targetPath.includes('@kaitranntt/ccs')) {
360
+ return 'npm';
361
+ }
362
+ }
363
+ } catch (err) {
364
+ // Continue to default
365
+ }
366
+
367
+ // Default to direct installation
368
+ return 'direct';
369
+ }
370
+
371
+ /**
372
+ * Detect which package manager was used for installation
373
+ * @returns {'npm'|'yarn'|'pnpm'|'bun'|'unknown'}
374
+ */
375
+ function detectPackageManager() {
376
+ const scriptPath = process.argv[1];
377
+
378
+ // Check if script path contains package manager indicators
379
+ if (scriptPath.includes('.pnpm')) return 'pnpm';
380
+ if (scriptPath.includes('yarn')) return 'yarn';
381
+ if (scriptPath.includes('bun')) return 'bun';
382
+
383
+ // Check parent directories for lock files
384
+ const binDir = path.dirname(scriptPath);
385
+ const fs = require('fs');
386
+
387
+ // Check global node_modules parent for lock files
388
+ let checkDir = binDir;
389
+ for (let i = 0; i < 5; i++) {
390
+ if (fs.existsSync(path.join(checkDir, 'pnpm-lock.yaml'))) return 'pnpm';
391
+ if (fs.existsSync(path.join(checkDir, 'yarn.lock'))) return 'yarn';
392
+ if (fs.existsSync(path.join(checkDir, 'bun.lockb'))) return 'bun';
393
+ checkDir = path.dirname(checkDir);
394
+ }
395
+
396
+ // Check if package managers are available on the system
397
+ const { spawnSync } = require('child_process');
398
+
399
+ // Try yarn global list to see if CCS is installed via yarn
400
+ try {
401
+ const yarnResult = spawnSync('yarn', ['global', 'list', '--pattern', '@kaitranntt/ccs'], {
402
+ encoding: 'utf8',
403
+ shell: true,
404
+ timeout: 5000
405
+ });
406
+ if (yarnResult.status === 0 && yarnResult.stdout.includes('@kaitranntt/ccs')) {
407
+ return 'yarn';
408
+ }
409
+ } catch (err) {
410
+ // Continue to next check
411
+ }
412
+
413
+ // Try pnpm list -g to see if CCS is installed via pnpm
414
+ try {
415
+ const pnpmResult = spawnSync('pnpm', ['list', '-g', '--pattern', '@kaitranntt/ccs'], {
416
+ encoding: 'utf8',
417
+ shell: true,
418
+ timeout: 5000
419
+ });
420
+ if (pnpmResult.status === 0 && pnpmResult.stdout.includes('@kaitranntt/ccs')) {
421
+ return 'pnpm';
422
+ }
423
+ } catch (err) {
424
+ // Continue to next check
425
+ }
426
+
427
+ // Try bun pm ls -g to see if CCS is installed via bun
428
+ try {
429
+ const bunResult = spawnSync('bun', ['pm', 'ls', '-g', '--pattern', '@kaitranntt/ccs'], {
430
+ encoding: 'utf8',
431
+ shell: true,
432
+ timeout: 5000
433
+ });
434
+ if (bunResult.status === 0 && bunResult.stdout.includes('@kaitranntt/ccs')) {
435
+ return 'bun';
436
+ }
437
+ } catch (err) {
438
+ // Continue to default
439
+ }
440
+
441
+ // Default to npm
442
+ return 'npm';
443
+ }
444
+
299
445
  async function handleUpdateCommand() {
300
446
  const { checkForUpdates } = require('./utils/update-checker');
301
447
  const { spawn } = require('child_process');
@@ -305,8 +451,8 @@ async function handleUpdateCommand() {
305
451
  console.log('');
306
452
 
307
453
  // Detect installation method for proper update source
308
- const isNpmInstall = process.argv[1].includes('node_modules');
309
- const installMethod = isNpmInstall ? 'npm' : 'direct';
454
+ const installMethod = detectInstallationMethod();
455
+ const isNpmInstall = installMethod === 'npm';
310
456
 
311
457
  // Check for updates (force check)
312
458
  const updateResult = await checkForUpdates(CCS_VERSION, true, installMethod);
@@ -321,7 +467,27 @@ async function handleUpdateCommand() {
321
467
  console.log('');
322
468
  console.log('Try again later or update manually:');
323
469
  if (isNpmInstall) {
324
- console.log(colored(' npm install -g @kaitranntt/ccs@latest', 'yellow'));
470
+ const packageManager = detectPackageManager();
471
+ let manualCommand;
472
+
473
+ switch (packageManager) {
474
+ case 'npm':
475
+ manualCommand = 'npm install -g @kaitranntt/ccs@latest';
476
+ break;
477
+ case 'yarn':
478
+ manualCommand = 'yarn global add @kaitranntt/ccs@latest';
479
+ break;
480
+ case 'pnpm':
481
+ manualCommand = 'pnpm add -g @kaitranntt/ccs@latest';
482
+ break;
483
+ case 'bun':
484
+ manualCommand = 'bun add -g @kaitranntt/ccs@latest';
485
+ break;
486
+ default:
487
+ manualCommand = 'npm install -g @kaitranntt/ccs@latest';
488
+ }
489
+
490
+ console.log(colored(` ${manualCommand}`, 'yellow'));
325
491
  } else {
326
492
  const isWindows = process.platform === 'win32';
327
493
  if (isWindows) {
@@ -359,13 +525,38 @@ async function handleUpdateCommand() {
359
525
  console.log('');
360
526
 
361
527
  if (isNpmInstall) {
362
- // npm installation - use npm update
363
- console.log(colored('Updating via npm...', 'cyan'));
528
+ // npm installation - detect package manager and update
529
+ const packageManager = detectPackageManager();
530
+ let updateCommand, updateArgs;
531
+
532
+ switch (packageManager) {
533
+ case 'npm':
534
+ updateCommand = 'npm';
535
+ updateArgs = ['install', '-g', '@kaitranntt/ccs@latest'];
536
+ break;
537
+ case 'yarn':
538
+ updateCommand = 'yarn';
539
+ updateArgs = ['global', 'add', '@kaitranntt/ccs@latest'];
540
+ break;
541
+ case 'pnpm':
542
+ updateCommand = 'pnpm';
543
+ updateArgs = ['add', '-g', '@kaitranntt/ccs@latest'];
544
+ break;
545
+ case 'bun':
546
+ updateCommand = 'bun';
547
+ updateArgs = ['add', '-g', '@kaitranntt/ccs@latest'];
548
+ break;
549
+ default:
550
+ updateCommand = 'npm';
551
+ updateArgs = ['install', '-g', '@kaitranntt/ccs@latest'];
552
+ }
553
+
554
+ console.log(colored(`Updating via ${packageManager}...`, 'cyan'));
364
555
  console.log('');
365
556
 
366
- const child = spawn('npm', ['install', '-g', '@kaitranntt/ccs@latest'], {
367
- stdio: 'inherit',
368
- shell: true
557
+ const child = spawn(updateCommand, updateArgs, {
558
+ stdio: 'inherit'
559
+ // No shell needed for direct commands
369
560
  });
370
561
 
371
562
  child.on('exit', (code) => {
@@ -380,7 +571,7 @@ async function handleUpdateCommand() {
380
571
  console.log(colored('[X] Update failed', 'red'));
381
572
  console.log('');
382
573
  console.log('Try manually:');
383
- console.log(colored(' npm install -g @kaitranntt/ccs@latest', 'yellow'));
574
+ console.log(colored(` ${updateCommand} ${updateArgs.join(' ')}`, 'yellow'));
384
575
  console.log('');
385
576
  }
386
577
  process.exit(code || 0);
@@ -388,10 +579,10 @@ async function handleUpdateCommand() {
388
579
 
389
580
  child.on('error', (err) => {
390
581
  console.log('');
391
- console.log(colored('[X] Failed to run npm update', 'red'));
582
+ console.log(colored(`[X] Failed to run ${packageManager} update`, 'red'));
392
583
  console.log('');
393
584
  console.log('Try manually:');
394
- console.log(colored(' npm install -g @kaitranntt/ccs@latest', 'yellow'));
585
+ console.log(colored(` ${updateCommand} ${updateArgs.join(' ')}`, 'yellow'));
395
586
  console.log('');
396
587
  process.exit(1);
397
588
  });
@@ -404,16 +595,19 @@ async function handleUpdateCommand() {
404
595
  let command, args;
405
596
 
406
597
  if (isWindows) {
598
+ // PowerShell
407
599
  command = 'powershell.exe';
408
- args = ['-Command', 'irm ccs.kaitran.ca/install | iex'];
600
+ args = ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command',
601
+ 'irm ccs.kaitran.ca/install | iex'];
409
602
  } else {
410
- command = 'bash';
603
+ // Unix (bash with proper shell invocation)
604
+ command = '/bin/bash';
411
605
  args = ['-c', 'curl -fsSL ccs.kaitran.ca/install | bash'];
412
606
  }
413
607
 
414
608
  const child = spawn(command, args, {
415
- stdio: 'inherit',
416
- shell: true
609
+ stdio: 'inherit'
610
+ // Do NOT use shell: true
417
611
  });
418
612
 
419
613
  child.on('exit', (code) => {
@@ -25,7 +25,7 @@ Enhanced Claude Code delegation system for multi-model task delegation.
25
25
 
26
26
  ### Session Management
27
27
  - Persistence: `~/.ccs/delegation-sessions.json`
28
- - Resume via `/ccs:glm:continue` and `/ccs:kimi:continue`
28
+ - Resume via `/ccs:continue` (auto-detects profile)
29
29
  - Auto-cleanup expired sessions (>30 days)
30
30
  - Cost aggregation across turns
31
31
 
@@ -91,12 +91,13 @@ Automatically applied as CLI flags:
91
91
  The delegation system is invoked via simple slash commands in `.claude/commands/ccs/`:
92
92
 
93
93
  ### Basic Commands
94
- - `/ccs:glm "task"` - Delegate to GLM-4.6
95
- - `/ccs:kimi "task"` - Delegate to Kimi (long-context)
94
+ - `/ccs "task"` - Delegate task (auto-selects best profile)
95
+ - `/ccs --glm "task"` - Force GLM-4.6 delegation
96
+ - `/ccs --kimi "task"` - Force Kimi delegation (long-context)
96
97
 
97
- ### Multi-Turn Commands
98
- - `/ccs:glm:continue "follow-up"` - Resume last GLM session
99
- - `/ccs:kimi:continue "follow-up"` - Resume last Kimi session
98
+ ### Session Continuation
99
+ - `/ccs:continue "follow-up"` - Resume last delegation session (auto-detect profile)
100
+ - `/ccs:continue --glm "follow-up"` - Resume with specific profile switch
100
101
 
101
102
  Each command directly invokes:
102
103
  ```bash
@@ -143,7 +144,8 @@ node tests/unit/delegation/result-formatter.test.js
143
144
  ## Architecture
144
145
 
145
146
  ```
146
- User → SlashCommand (/ccs:glm)
147
+ User → SlashCommand (/ccs)
148
+ → ccs-delegation skill (auto-selects profile)
147
149
  → Directly invokes: claude -p
148
150
  → HeadlessExecutor (monitors execution)
149
151
  → SessionManager (load last session)
@@ -364,12 +364,12 @@ class Doctor {
364
364
  checkDelegation() {
365
365
  const spinner = ora('Checking delegation').start();
366
366
 
367
- // Check if delegation commands exist in ~/.ccs/.claude/commands/ccs/
368
- const ccsClaudeCommandsDir = path.join(this.ccsDir, '.claude', 'commands', 'ccs');
369
- const hasGlmCommand = fs.existsSync(path.join(ccsClaudeCommandsDir, 'glm.md'));
370
- const hasKimiCommand = fs.existsSync(path.join(ccsClaudeCommandsDir, 'kimi.md'));
367
+ // Check if delegation commands exist in ~/.ccs/.claude/commands/
368
+ const ccsClaudeCommandsDir = path.join(this.ccsDir, '.claude', 'commands');
369
+ const hasCcsCommand = fs.existsSync(path.join(ccsClaudeCommandsDir, 'ccs.md'));
370
+ const hasContinueCommand = fs.existsSync(path.join(ccsClaudeCommandsDir, 'ccs', 'continue.md'));
371
371
 
372
- if (!hasGlmCommand || !hasKimiCommand) {
372
+ if (!hasCcsCommand || !hasContinueCommand) {
373
373
  spinner.warn(` ${'Delegation'.padEnd(26)}${colored('[!]', 'yellow')} Not installed`);
374
374
  this.results.addCheck(
375
375
  'Delegation',
package/lib/ccs CHANGED
@@ -2,7 +2,7 @@
2
2
  set -euo pipefail
3
3
 
4
4
  # Version (updated by scripts/bump-version.sh)
5
- CCS_VERSION="4.3.2"
5
+ CCS_VERSION="4.3.4"
6
6
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
7
  readonly CONFIG_FILE="${CCS_CONFIG:-$HOME/.ccs/config.json}"
8
8
  readonly PROFILES_JSON="$HOME/.ccs/profiles.json"
@@ -191,8 +191,10 @@ show_help() {
191
191
  echo ""
192
192
 
193
193
  echo -e "${CYAN}Delegation (inside Claude Code CLI):${RESET}"
194
- echo -e " ${YELLOW}/ccs:glm \"task\"${RESET} Delegate to GLM-4.6 for simple tasks"
195
- echo -e " ${YELLOW}/ccs:kimi \"task\"${RESET} Delegate to Kimi for long context"
194
+ echo -e " ${YELLOW}/ccs \"task\"${RESET} Delegate task (auto-selects best profile)"
195
+ echo -e " ${YELLOW}/ccs --glm \"task\"${RESET} Force GLM-4.6 for simple tasks"
196
+ echo -e " ${YELLOW}/ccs --kimi \"task\"${RESET} Force Kimi for long context"
197
+ echo -e " ${YELLOW}/ccs:continue \"follow-up\"${RESET} Continue last delegation session"
196
198
  echo -e " Save tokens by delegating simple tasks to cost-optimized models"
197
199
  echo ""
198
200
 
package/lib/ccs.ps1 CHANGED
@@ -12,7 +12,7 @@ param(
12
12
  $ErrorActionPreference = "Stop"
13
13
 
14
14
  # Version (updated by scripts/bump-version.sh)
15
- $CcsVersion = "4.3.2"
15
+ $CcsVersion = "4.3.4"
16
16
  $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
17
17
  $ConfigFile = if ($env:CCS_CONFIG) { $env:CCS_CONFIG } else { "$env:USERPROFILE\.ccs\config.json" }
18
18
  $ProfilesJson = "$env:USERPROFILE\.ccs\profiles.json"
@@ -238,8 +238,10 @@ function Show-Help {
238
238
  Write-Host ""
239
239
 
240
240
  Write-ColorLine "Delegation (inside Claude Code CLI):" "Cyan"
241
- Write-ColorLine " /ccs:glm `"task`" Delegate to GLM-4.6 for simple tasks" "Yellow"
242
- Write-ColorLine " /ccs:kimi `"task`" Delegate to Kimi for long context" "Yellow"
241
+ Write-ColorLine " /ccs `"task`" Delegate task (auto-selects best profile)" "Yellow"
242
+ Write-ColorLine " /ccs --glm `"task`" Force GLM-4.6 for simple tasks" "Yellow"
243
+ Write-ColorLine " /ccs --kimi `"task`" Force Kimi for long context" "Yellow"
244
+ Write-ColorLine " /ccs:continue `"follow-up`" Continue last delegation session" "Yellow"
243
245
  Write-Host " Save tokens by delegating simple tasks to cost-optimized models"
244
246
  Write-Host ""
245
247
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "4.3.2",
3
+ "version": "4.3.4",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -1,21 +0,0 @@
1
- ---
2
- description: Continue last GLM delegation session [AUTO ENHANCE]
3
- argument-hint: [follow-up instruction]
4
- ---
5
-
6
- Continue last GLM delegation session for iterative refinement.
7
-
8
- **Workflow:**
9
- - Review what was accomplished in previous session
10
- - Analyze the follow-up instruction in `$ARGUMENTS`
11
- - Enhance prompt with context (reference files, incomplete tasks, next steps)
12
- - Execute continuation via `ccs glm:continue -p "$ENHANCED_PROMPT"`
13
-
14
- **Note:** `$ENHANCED_PROMPT` is an enhanced version that references previous work, highlights incomplete tasks, and adds specific validation criteria. If the follow-up contains a slash command (e.g., /commit), keep it at the start of the enhanced prompt.
15
-
16
- **Usage:**
17
- ```
18
- /ccs:glm "fix typo in README"
19
- /ccs:glm:continue "also update the examples section"
20
- /ccs:glm:continue "/commit with descriptive message"
21
- ```
@@ -1,21 +0,0 @@
1
- ---
2
- description: Delegate task to GLM-4.6 (cost-optimized model) [AUTO ENHANCE]
3
- argument-hint: [task description]
4
- ---
5
-
6
- Delegate simple, deterministic tasks to GLM-4.6 for token optimization.
7
-
8
- **Workflow:**
9
- - Analyze the task description in `$ARGUMENTS`
10
- - Gather context if needed (read files, check structure)
11
- - Enhance prompt with specific details (file paths, context, success criteria)
12
- - Execute delegation via `ccs glm -p "$ENHANCED_PROMPT"`
13
-
14
- **Note:** `$ENHANCED_PROMPT` is an enhanced version that adds specifics like file paths, current implementation context, expected behavior, and success criteria. If the task contains a slash command (e.g., /cook, /plan), keep it at the start of the enhanced prompt.
15
-
16
- **Usage:**
17
- ```
18
- /ccs:glm "refactor auth.js to use async/await"
19
- /ccs:glm "add tests for UserService"
20
- /ccs:glm "/cook create a landing page"
21
- ```
@@ -1,21 +0,0 @@
1
- ---
2
- description: Continue last Kimi delegation session [AUTO ENHANCE]
3
- argument-hint: [follow-up instruction]
4
- ---
5
-
6
- Continue last Kimi delegation session for multi-turn analysis.
7
-
8
- **Workflow:**
9
- - Review analysis/work from previous session
10
- - Analyze the follow-up instruction in `$ARGUMENTS`
11
- - Enhance prompt with comprehensive context (findings, scope, deliverables, priority)
12
- - Execute continuation via `ccs kimi:continue -p "$ENHANCED_PROMPT"`
13
-
14
- **Note:** `$ENHANCED_PROMPT` is an enhanced version that references previous findings, specifies next scope, and adds actionable deliverables with priorities. If the follow-up contains a slash command (e.g., /plan), keep it at the start of the enhanced prompt.
15
-
16
- **Usage:**
17
- ```
18
- /ccs:kimi "analyze all files in src/"
19
- /ccs:kimi:continue "suggest architectural improvements"
20
- /ccs:kimi:continue "/plan for refactoring with phases"
21
- ```
@@ -1,21 +0,0 @@
1
- ---
2
- description: Delegate task to Kimi (long-context model) [AUTO ENHANCE]
3
- argument-hint: [task description]
4
- ---
5
-
6
- Delegate long-context, multi-file tasks to Kimi for comprehensive analysis.
7
-
8
- **Workflow:**
9
- - Analyze the task description in `$ARGUMENTS`
10
- - Gather context across multiple files/directories
11
- - Enhance prompt with comprehensive details (structure, relationships, scope)
12
- - Execute delegation via `ccs kimi -p "$ENHANCED_PROMPT"`
13
-
14
- **Note:** `$ENHANCED_PROMPT` is an enhanced version that adds directory structures, cross-file relationships, architecture context, and deliverables. If the task contains a slash command (e.g., /plan, /commit), keep it at the start of the enhanced prompt.
15
-
16
- **Usage:**
17
- ```
18
- /ccs:kimi "analyze all files in src/ and document architecture"
19
- /ccs:kimi "find all deprecated API usages across codebase"
20
- /ccs:kimi "/plan for authentication system"
21
- ```