mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 22:16:41 +00:00
## 🚀 Release v4.1.0 - Major Update **Breaking changes from v3.5.0**. This release includes the complete v4.0.0 delegation overhaul plus v4.1.0 architecture improvements. --- ## 🎯 v4.0.0: Delegation System Overhaul **Complete rewrite of the delegation infrastructure with enhanced decision-making and streaming support.** ### New Delegation Features **Stream-JSON Communication Protocol:** - Real-time token streaming with `{type: "content", data: "..."}` format - Progress indicators during delegation execution - Clean separation: stdout for data, stderr for errors - Handles tool calls, thinking blocks, and text content **Enhanced Decision Framework:** - `/ccs:glm` and `/ccs:kimi` slash commands with auto-enhancement - `[AUTO ENHANCE]` prompts for better model understanding - Context-aware task delegation with clear boundaries - Continuation support: `/ccs:glm:continue` and `/ccs:kimi:continue` **Robust Error Handling:** - Graceful degradation when profiles unconfigured - Clear error messages with actionable fixes - Signal handling (SIGINT/SIGTERM) for clean child process termination - Session state recovery on interruption **Performance & Reliability:** - Headless mode (`-p` flag) for background execution - Slash command detection and auto-routing - Validation system with `DelegationValidator` - Profile readiness checks in `ccs --version` ### Delegation Components **New Files:** - `bin/delegation/delegation-handler.js` - Core delegation orchestrator - `bin/delegation/stream-processor.js` - Real-time output handling - `bin/utils/delegation-validator.js` - Profile validation - `.claude/commands/ccs/*.md` - Slash command definitions - `.claude/skills/ccs-delegation/` - AI decision framework - `.claude/agents/ccs-delegator.md` - Proactive delegation agent **Documentation:** - Complete delegation workflows with mermaid diagrams - Troubleshooting guides for common issues - Headless execution patterns --- ## ✨ v4.1.0: Selective Symlinking Architecture **Single source of truth for CCS items with automatic propagation.** ### New Architecture **Ship .claude/ Directory:** - CCS items now ship with npm/sh/ps1 packages - Selective item-level symlinks: `~/.ccs/.claude/` → `~/.claude/` - Auto-propagation on `npm update` - zero manual sync - Backward compatible with existing `~/.ccs/shared/` mechanism **Symlink Chain:** ``` ~/.ccs/.claude/ (source) ↓ selective symlinks ~/.claude/ (CCS items installed here) ↑ symlinked by ~/.ccs/shared/ ↑ symlinked by profiles (work, personal, team) ``` ### New Commands **Maintenance Tools:** - `ccs update` - Re-install CCS symlinks to ~/.claude/ - `ccs doctor` - Added Check 9: CCS symlinks health verification **Safe Installation:** - Automatic conflict backup before symlinking - Idempotent operations (safe to run multiple times) - Health monitoring and recovery ### New Components - `bin/utils/claude-symlink-manager.js` - Manages selective symlinks - Updated all 3 installers (npm postinstall, install.sh, install.ps1) - Enhanced `ccs doctor` with symlink health checks --- ## 💥 Breaking Changes **From v3.5.0 → v4.x:** 1. **Delegation commands moved**: - Old: User manually created in `~/.claude/commands/` - New: Auto-shipped in `~/.ccs/.claude/`, symlinked to `~/.claude/commands/ccs/` 2. **Slash command format**: - New: `/ccs:glm`, `/ccs:kimi`, `/ccs:glm:continue` - Old custom commands may need migration 3. **Profile validation**: - Placeholders (`YOUR_API_KEY_HERE`) now detected and marked invalid - Must configure real API keys for delegation to work 4. **Stream output format**: - Headless mode (`-p`) now uses stream-JSON protocol - Old text output replaced with structured `{type, data}` format
195 lines
5.1 KiB
JavaScript
195 lines
5.1 KiB
JavaScript
#!/usr/bin/env node
|
|
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const { SettingsParser } = require('../../../bin/delegation/settings-parser');
|
|
|
|
/**
|
|
* Test runner
|
|
*/
|
|
class TestRunner {
|
|
constructor() {
|
|
this.tests = [];
|
|
this.passed = 0;
|
|
this.failed = 0;
|
|
}
|
|
|
|
test(name, fn) {
|
|
this.tests.push({ name, fn });
|
|
}
|
|
|
|
async run() {
|
|
console.log('\n=== Settings Parser Tests ===\n');
|
|
|
|
for (const { name, fn } of this.tests) {
|
|
try {
|
|
await fn();
|
|
console.log(`[OK] ${name}`);
|
|
this.passed++;
|
|
} catch (error) {
|
|
console.error(`[X] ${name}`);
|
|
console.error(` Error: ${error.message}`);
|
|
this.failed++;
|
|
}
|
|
}
|
|
|
|
console.log(`\nResults: ${this.passed} passed, ${this.failed} failed`);
|
|
process.exit(this.failed > 0 ? 1 : 0);
|
|
}
|
|
}
|
|
|
|
function assert(condition, message) {
|
|
if (!condition) throw new Error(message || 'Assertion failed');
|
|
}
|
|
|
|
function assertEqual(actual, expected, message) {
|
|
if (actual !== expected) {
|
|
throw new Error(message || `Expected ${expected}, got ${actual}`);
|
|
}
|
|
}
|
|
|
|
// Test suite
|
|
const runner = new TestRunner();
|
|
|
|
// Test fixture directory
|
|
const testDir = path.join(os.tmpdir(), 'ccs-test-settings');
|
|
const claudeDir = path.join(testDir, '.claude');
|
|
|
|
// Cleanup helpers
|
|
function setupTestDir() {
|
|
if (fs.existsSync(testDir)) {
|
|
fs.rmSync(testDir, { recursive: true });
|
|
}
|
|
fs.mkdirSync(claudeDir, { recursive: true });
|
|
}
|
|
|
|
function cleanupTestDir() {
|
|
if (fs.existsSync(testDir)) {
|
|
fs.rmSync(testDir, { recursive: true });
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test 1: No settings files
|
|
*/
|
|
runner.test('Return empty arrays when no settings files', () => {
|
|
setupTestDir();
|
|
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 0, 'Should have 0 allowed tools');
|
|
assertEqual(restrictions.disallowedTools.length, 0, 'Should have 0 disallowed tools');
|
|
});
|
|
|
|
/**
|
|
* Test 2: Parse shared settings.json
|
|
*/
|
|
runner.test('Parse shared settings.json', () => {
|
|
setupTestDir();
|
|
|
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
fs.writeFileSync(settingsPath, JSON.stringify({
|
|
permissions: {
|
|
allow: ['Bash(git:*)', 'Read'],
|
|
deny: ['Bash(rm:*)']
|
|
}
|
|
}));
|
|
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 2, 'Should have 2 allowed tools');
|
|
assertEqual(restrictions.disallowedTools.length, 1, 'Should have 1 disallowed tool');
|
|
assert(restrictions.allowedTools.includes('Bash(git:*)'), 'Should include git bash');
|
|
assert(restrictions.disallowedTools.includes('Bash(rm:*)'), 'Should include rm deny');
|
|
});
|
|
|
|
/**
|
|
* Test 3: Parse local settings overriding shared
|
|
*/
|
|
runner.test('Local settings override shared', () => {
|
|
setupTestDir();
|
|
|
|
// Shared settings
|
|
fs.writeFileSync(path.join(claudeDir, 'settings.json'), JSON.stringify({
|
|
permissions: {
|
|
allow: ['Read'],
|
|
deny: []
|
|
}
|
|
}));
|
|
|
|
// Local settings (adds more permissions)
|
|
fs.writeFileSync(path.join(claudeDir, 'settings.local.json'), JSON.stringify({
|
|
permissions: {
|
|
allow: ['Bash(git:*)'],
|
|
deny: ['Bash(rm:*)']
|
|
}
|
|
}));
|
|
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 2, 'Should merge allowed tools');
|
|
assert(restrictions.allowedTools.includes('Read'), 'Should have shared Read');
|
|
assert(restrictions.allowedTools.includes('Bash(git:*)'), 'Should have local git');
|
|
assertEqual(restrictions.disallowedTools.length, 1, 'Should have local deny');
|
|
});
|
|
|
|
/**
|
|
* Test 4: Handle malformed JSON
|
|
*/
|
|
runner.test('Handle malformed JSON gracefully', () => {
|
|
setupTestDir();
|
|
|
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
fs.writeFileSync(settingsPath, '{ invalid json }');
|
|
|
|
// Should not throw
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 0, 'Should return empty arrays on parse error');
|
|
assertEqual(restrictions.disallowedTools.length, 0);
|
|
});
|
|
|
|
/**
|
|
* Test 5: Handle missing permissions key
|
|
*/
|
|
runner.test('Handle settings without permissions key', () => {
|
|
setupTestDir();
|
|
|
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
fs.writeFileSync(settingsPath, JSON.stringify({
|
|
someOtherKey: 'value'
|
|
}));
|
|
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 0, 'Should handle missing permissions');
|
|
assertEqual(restrictions.disallowedTools.length, 0);
|
|
});
|
|
|
|
/**
|
|
* Test 6: Handle empty permissions arrays
|
|
*/
|
|
runner.test('Handle empty permissions arrays', () => {
|
|
setupTestDir();
|
|
|
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
|
fs.writeFileSync(settingsPath, JSON.stringify({
|
|
permissions: {
|
|
allow: [],
|
|
deny: []
|
|
}
|
|
}));
|
|
|
|
const restrictions = SettingsParser.parseToolRestrictions(testDir);
|
|
|
|
assertEqual(restrictions.allowedTools.length, 0);
|
|
assertEqual(restrictions.disallowedTools.length, 0);
|
|
});
|
|
|
|
// Run tests and cleanup
|
|
runner.run().finally(() => {
|
|
cleanupTestDir();
|
|
});
|