mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-16 08:17:11 +00:00
Implement target adapter pattern enabling CCS CLI to support multiple backend targets (Claude, Droid) via pluggable adapters. Core additions: - TargetAdapter interface for pluggable target implementations - ClaudeAdapter and DroidAdapter concrete implementations - Target registry (singleton Map-based storage) - Target resolver with precedence: --target flag > per-profile config > busybox detection - Droid config manager with atomic writes and file locking to ~/.factory/settings.json - Droid binary detector to validate runtime environment - Adapter dispatch integrated into ccs.ts main execution flow - ccsd busybox alias for seamless Droid invocation - --target flag documentation in help - Session tracking enriched with target metadata - Dashboard target badge for visual identification Testing: - 43 unit tests covering resolver, registry, config manager, and adapters - Full coverage of target detection logic and edge cases Documentation: - Refactored system-architecture.md into modular docs/system-architecture/ subdirectory - Updated code-standards.md with target adapter guidelines - Updated codebase-summary.md with architecture overview - Updated maintainability baseline (33.8% → 35.2%) This establishes extensible foundation for multi-target support without breaking existing Claude workflows. Droid adapter is production-ready but defaults to Claude for backward compatibility.
CCS Test Suite
Organization
tests/
├── unit/ # Module unit tests (Mocha)
│ ├── glmt/ # GLMT transformer tests
│ └── delegation/ # Delegation module tests
├── npm/ # npm package tests (Mocha)
├── native/ # Native installation tests (bash/PowerShell)
│ ├── unix/ # Unix/Linux/macOS tests
│ └── windows/ # Windows PowerShell tests
├── integration/ # Integration tests (manual execution)
└── shared/ # Shared utilities
├── fixtures/ # Test configuration and environment
├── unit/ # Helper function tests
├── helpers.sh # Bash test utilities
└── test-data.js # Test data for npm tests
Running Tests
bun run test # All automated tests (unit + npm)
bun run test:unit # Unit tests only (Mocha)
bun run test:npm # npm package tests (Mocha)
bun run test:native # Native Unix tests (bash)
Test Categories
Unit Tests (unit/)
Module-level tests using Mocha framework:
unit/glmt/- GLMT transformer, SSE parser, delta accumulatorunit/delegation/- Permission mode, session manager, result formatter
npm Tests (npm/)
npm package functionality tests using Mocha:
postinstall.test.js- Postinstall behaviorcli.test.js- CLI argument parsingcross-platform.test.js- Cross-platform compatibilityspecial-commands.test.js- Integration tests
Native Tests (native/)
Installation tests for curl|bash (Unix) and irm|iex (Windows):
native/unix/edge-cases.sh- Unix edge case testsnative/windows/edge-cases.ps1- Windows edge case tests
Integration Tests (integration/)
Manual execution tests for specific scenarios:
token-counting-test.js- Token counting validationz-ai-streaming-test.js- Z.AI streamingglmt-integration-test.sh- GLMT integrationsymlink-chain-test.sh- Symlink chain handlingux-integration-test.sh- CLI UX integration
Adding New Tests
- Unit tests: Add to
unit/<module>/using Mocha + Node.js assert - npm tests: Add to
npm/using Mocha - Native tests: Add to
native/unix/ornative/windows/ - Integration tests: Add to
integration/