Commit Graph
38 Commits
Author SHA1 Message Date
Tam Nhu Tran 8e57d59479 fix(execution): strip claudecode in remaining claude paths
- sanitize Copilot profile Claude launch environment

- sanitize auth create isolated instance launch environment

- sanitize doctor Claude CLI version check spawn environment

Refs #588
2026-02-20 23:00:59 +07:00
Tam Nhu Tran cf8070b5f0 fix(profile): handle km compatibility for legacy kimi api users 2026-02-19 12:43:41 +07:00
Tam Nhu Tran 08b2a67913 feat(cliproxy): add Kimi as OAuth CLIProxy provider
- add 'kimi' to CLIProxyProvider union type
- register Kimi capabilities (device_code flow, moonshot alias)
- add OAuth config, auth prefixes, type values, channel maps
- add CLIProxy-delegated token refresh for Kimi
- add Kimi model catalog (k2.5, k2-thinking, k2)
- switch base-kimi.settings.json to CLIProxy mode (127.0.0.1:8317)
- update comments removing kimi from settings-based profile mentions

Closes #574
2026-02-17 17:02:55 +07:00
Tam Nhu Tran 3da3407f9a fix(targets): harden adapter lifecycle and droid model edge cases 2026-02-17 04:09:48 +07:00
Tam Nhu Tran 0431adf306 fix(targets): close all remaining multi-target droid edge cases 2026-02-17 03:22:45 +07:00
Tam Nhu Tran 2816c6652d chore(merge): resolve conflicts with origin/dev 2026-02-12 16:25:25 +07:00
Tam Nhu Tran 924e3686c8 refactor(cliproxy): centralize provider capability registry 2026-02-12 12:59:17 +07:00
Tam Nhu Tran 0c7dc398f7 fix(cliproxy): add defensive null checks for composite tier config
- Add optional chaining for tier access in env-resolver
- Throw error if default tier model missing in env-builder
- Add null checks for composite.tiers in profile-detector
2026-02-12 11:01:00 +07:00
Tam Nhu Tran 07bef9f50e feat(cliproxy): wire composite variant into main execution flow
- Detect composite variants in ProfileDetector with tier metadata
- Pass isComposite/compositeTiers/compositeDefaultTier through ccs.ts
- Handle composite in loadConfigSafe() legacy adapter
- Add validateCompositeVariants() for provider string validation
- Display 'composite' label in API profile listing

Refs #506
2026-02-12 04:09:19 +07:00
kaitranntt 0e140f83e4 fix(auth): show command checks unified config for accounts
Use getAllProfilesMerged() and getDefaultResolved() to check both
unified config and legacy profiles when showing account details.

Fixes #458
2026-02-04 18:08:39 -05:00
kaitranntt 28d8bd84a5 feat(cliproxy): add Claude (Anthropic) OAuth provider support
Add Claude as a first-class OAuth provider in CCS CLI and dashboard.
Backend support already exists in CLIProxyAPIPlus (port 54545).

Changes:
- Add 'claude' to CLIProxyProvider type and profile detector
- Add Claude OAuth config (port 54545, --anthropic-login flag)
- Add Claude to oauth-port-diagnostics flow types
- Add Claude token discovery prefixes (claude-, anthropic-)
- Add Claude model catalog (Opus 4.5, Sonnet 4.5/4, Haiku 4.5)
- Add Claude logo and provider display name
- Update variant config types and adapters

Closes #380
2026-01-27 15:43:21 -05:00
kaitranntt 9b61f5318e fix(isolation): use getCcsDir() for test isolation
Replace os.homedir() with getCcsDir() in 11 source files to ensure
tests don't touch the user's real ~/.ccs/ directory. The getCcsDir()
function from config-manager.ts respects CCS_HOME env var for
test isolation.

Files fixed:
- src/auth/profile-detector.ts
- src/auth/profile-registry.ts
- src/delegation/headless-executor.ts
- src/delegation/session-manager.ts
- src/glmt/glmt-transformer.ts
- src/management/checks/config-check.ts
- src/management/checks/profile-check.ts
- src/management/checks/system-check.ts
- src/management/instance-manager.ts
- src/management/shared-manager.ts
- src/utils/update-checker.ts
2026-01-25 21:38:27 -05:00
Kai (Tam Nhu) TranGitHubgithub-actions[bot] <github-actions[bot]@users.noreply.github.com>Shun KakinokiClaude Opus 4.5
b3ef76a07b feat(release): CLI flag passthrough, proxy fixes, and UI improvements (#239)
* fix(cliproxy): pass variant port to executor for isolation

Variants configured with dedicated ports (8318-8417) were not using
their assigned port. The executor always defaulted to 8317.

Changes:
- Add port field to ProfileDetectionResult interface
- Pass variant.port from profile-detector to ccs.ts
- Forward port to execClaudeWithCLIProxy options
- Update executor priority: CLI flags > variant port > config.yaml > default

Closes #228

* fix(cliproxy): propagate port in unified config and UI preset handlers

Edge case fixes identified in codebase review:
- Unified config variant detection: add settingsPath and port fields
- Provider editor: use variant port in handleApplyPreset/handleCustomPresetApply
- preset-utils: add optional port parameter to applyDefaultPreset()

* chore(release): 7.11.1-dev.1 [skip ci]

* fix(cliproxy): use correct default port (8317) for remote HTTP connections

Root cause: Inconsistent default port logic across code paths.
- Test Connection used 8317 (correct)
- Actual API calls used 80 (wrong)

Changes:
- Add centralized getRemoteDefaultPort() helper in config-generator.ts
- Fix proxy-target-resolver.ts to use shared helper
- Fix rewriteLocalhostUrls() and getRemoteEnvVars() in config-generator.ts
- Update remote-proxy-client.ts to use shared helper (DRY)

Fixes all 3 reported issues:
1. Port empty → now correctly uses :8317 instead of :80
2. BASEURL construction → now includes correct port
3. CLIProxy Plus auth → now fetches from remote on correct port

* chore(release): 7.11.1-dev.2 [skip ci]

* feat(delegation): add Claude Code CLI flag passthrough

Add explicit passthrough support for key Claude Code CLI flags:
- --max-turns: Limit agentic turns (prevents infinite loops)
- --fallback-model: Auto-fallback when model overloaded
- --agents: Dynamic subagent JSON injection
- --betas: Enable experimental features

Maintain extraArgs catch-all for future Claude Code flags.
Update help command with new "Delegation Flags" section.

Closes #89

* test(delegation): add comprehensive CLI flag passthrough tests

Add 45 test cases covering all edge cases for CLI flag passthrough:
- DelegationHandler: timeout/max-turns/fallback-model/agents/betas validation
- HeadlessExecutor: duplicate flag filtering, undefined vs truthy checks

* chore(release): 7.11.1-dev.3 [skip ci]

* fix(ui): enable cancel button during OAuth authentication

Resolves #234 - Cancel button was disabled during authentication flow,
preventing users from canceling the OAuth process.

Changes:
- Add auth-session-manager.ts for tracking active OAuth sessions
- Add POST /cliproxy/auth/:provider/cancel endpoint to abort sessions
- Kill spawned CLIProxy auth process when cancel is triggered
- Enable Cancel button in AddAccountDialog during authentication
- Add cancel support to QuickSetupWizard auth step
- Update useCancelAuth hook to call backend cancel endpoint

* chore(release): 7.11.1-dev.4 [skip ci]

* fix(prompt): add stdin.pause() to prevent process hang after password input

Fixes #236. The password() method called resume() on stdin but never
paused it in cleanup, keeping the event loop alive indefinitely.

* chore(release): 7.11.1-dev.5 [skip ci]

* feat(cliproxy): add --allow-self-signed flag for HTTPS connections (#227)

Previously, allowSelfSigned was hardcoded to true for all HTTPS protocol
connections, forcing use of the native https module which has issues with
Cloudflare-proxied connections causing timeouts.

This change:
- Adds --allow-self-signed CLI flag (default: false)
- Adds CCS_ALLOW_SELF_SIGNED environment variable
- Uses standard fetch API by default for HTTPS (works with valid certs)
- Only uses native https module when --allow-self-signed is specified

Usage:
- For production HTTPS proxies with valid certs: no flag needed
- For dev proxies with self-signed certs: use --allow-self-signed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>

* chore(release): 7.11.1-dev.6 [skip ci]

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Shun Kakinoki <39187513+shunkakinoki@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-31 16:36:18 -08:00
kaitranntt 9722e1905d fix(dashboard): support unified config across health checks and settings
- health-service.ts: respect isUnifiedMode() in fixHealthIssue()
- config-checks.ts: check config.yaml in unified mode
- profile-checks.ts: read profiles from unified config
- settings-routes.ts: use atomic writes (temp+rename) for presets
- profile-registry.ts: add DRY helpers getAllProfilesMerged(), getDefaultResolved()

Closes #203
2025-12-25 16:50:55 -05:00
kaitranntt 92a79aa78b test(auth): add comprehensive tests for GLM auth persistence fix
Add 26 new unit tests covering:
- isFirstTimeInstall() legacy config detection (8 tests)
- loadSettingsFromFile() path expansion (5 tests)
- ProfileDetector detectProfileType() (4 tests)
- expandPath() cross-platform handling (10 tests)

Test coverage for issue #195:
- Legacy config.json/profiles.json detection
- Tilde expansion to home directory
- Environment variable expansion (${VAR}, $VAR, %VAR%)
- Mixed path separator normalization
- Corrupted config graceful handling

Files:
- tests/unit/commands/setup-command.test.ts
- tests/unit/auth/profile-detector.test.ts
- tests/unit/utils/expand-path.test.ts
2025-12-24 18:33:52 -05:00
kaitranntt cc2d62db38 fix(profiles): prevent GLM auth regression from first-time install detection
- Check legacy config.json/profiles.json in isFirstTimeInstall()
- Use expandPath() for cross-platform path handling in profile-detector
- Add pre-flight API key validation for better error messages
- Enhance 401 error handling with Z.AI refresh guidance

Fixes #195
2025-12-24 18:09:09 -05:00
kaitranntt 036714c774 feat(cliproxy): add kiro and ghcp providers to CLIProxyProvider type
- extend CLIProxyProvider union with 'kiro' and 'ghcp'

- add both to CLIPROXY_PROFILES array
2025-12-22 00:44:03 -05:00
kaitranntt 2b441f6498 feat(auth): add Kiro and GitHub Copilot OAuth providers
- Add kiro (port 8329) and copilot (port 8330) to auth-types
- Implement OAuth flows in oauth-handler
- Update token-manager to include new providers
- Add new providers to CLIPROXY_PROFILES
- Update diagnostics and API routes for new providers
2025-12-21 22:26:11 -05:00
kaitranntt 4f4ab43eb3 refactor(config): remove secrets.yaml architecture
- delete secrets-manager.ts entirely

- remove secrets API routes and client methods

- simplify unified-config-types (remove vault/secrets)

- update profile-reader to remove secrets loading

- clean up unused hooks and API client methods
2025-12-20 23:10:35 -05:00
kaitranntt e1f135a93a refactor(utils): extract formatRelativeTime to utils/time.ts
- create utils/time.ts for centralized time formatting

- remove duplicate from auth/commands/types.ts

- re-export for backward compatibility

- export from utils/index.ts
2025-12-19 15:39:40 -05:00
kaitranntt 0341f4f86f refactor(auth): modularize auth-commands into commands/ directory
- extract create, list, show, remove, default command handlers

- extract types.ts with CommandContext and parseArgs

- slim auth-commands.ts from 725 to 235 lines (68% reduction)

- add barrel exports at commands/index.ts and auth/index.ts
2025-12-19 12:36:24 -05:00
kaitranntt 22dbfd91c5 refactor(errors): centralize error handling infrastructure
- add errors/ directory with error types, handler, cleanup registry

- extract claude-spawner.ts from auth modules

- update imports across auth, ccs, web-server

Phase 2 & 4: Error handling consolidation
2025-12-19 11:47:43 -05:00
kaitranntt e5a1f60bb6 feat(auth): add copilot profile detection
- add 'copilot' to ProfileType union

- detect copilot profile with enabled check

- include copilot in listAvailableProfiles() when enabled
2025-12-17 21:38:33 -05:00
kaitranntt 2fb266c01f fix(auth): improve default account hint and add reset-default command
- Change post-create hint from casual text to warning box
- Clearly state that running the command will SWITCH default account
- Add `ccs auth reset-default` command to restore original CCS behavior
- Add warnBox() UI helper for yellow-bordered warning boxes
- Update main help to show default/reset-default commands

Closes #106
2025-12-14 21:32:45 -05:00
kaitranntt 5efab53eb7 fix(auth): handle Windows spawn for profile creation 2025-12-14 02:50:22 -05:00
kaitranntt 3cdf84b1ba fix(auth): include unified config accounts in auth list command
The `ccs auth list` command was only reading from legacy profiles.json,
missing accounts stored in unified config (config.yaml). Now merges
profiles from both sources, with unified config taking precedence.
2025-12-14 01:42:30 -05:00
kaitranntt 1dbd7229a5 refactor(config): use settings file references instead of inline env
Changes config.yaml to store references to *.settings.json files
instead of inlining env vars. This matches Claude's ~/.claude/settings.json
pattern and gives users familiar editing experience.

Changes:
- ProfileConfig now stores 'settings' path instead of 'env' object
- CLIProxyVariantConfig uses 'settings' instead of 'model'/'env'
- Migration preserves existing *.settings.json files, only stores references
- Updated config.yaml comments to explain settings file pattern
- Create/remove commands now manage settings files alongside config.yaml

Benefits:
- Users edit familiar *.settings.json format
- config.yaml stays clean (just references)
- No confusion about where to make changes
2025-12-10 17:53:00 -05:00
kaitranntt b621b8e47b feat(config): add unified YAML config with migration support
Implements unified config.yaml format consolidating:
- config.json (API profiles)
- profiles.json (account metadata)
- *.settings.json (env vars)

Features:
- Auto-migration from v1 JSON to v2 YAML with backup
- Secrets separation into secrets.yaml (chmod 600)
- Enhanced YAML output with section comments
- CLIProxy OAuth settings migration with env var support
- Feature flag for gradual rollout (CCS_UNIFIED_CONFIG=1)
- Rollback support via ccs migrate --rollback

New commands:
- ccs migrate - Run migration
- ccs migrate --dry-run - Preview changes
- ccs migrate --rollback <path> - Restore from backup
- ccs migrate --list-backups - List available backups

Closes #75
2025-12-10 17:42:40 -05:00
kaitranntt 13d13dab51 fix(auth): prevent default profile from using stale glm env vars
Issue #37: When running `ccs` (default profile), users were unknowingly
using GLM API instead of their Claude subscription because:

1. config.json had `default: '~/.claude/settings.json'` entry
2. ProfileDetector treated this as settings-based profile
3. CCS passed `--settings ~/.claude/settings.json` flag to Claude
4. Any stale ANTHROPIC_* env vars in that file got applied

Fix (3-pronged approach):
- Remove `default` entry from new config.json template
- Add migration to remove existing `default: ~/.claude/settings.json`
- Add ProfileDetector safety net: if default points to ~/.claude/settings.json,
  treat as pass-through to Claude's native auth (no --settings flag)

Now `ccs` (no profile) correctly uses Claude's native OAuth authentication
without loading potentially polluted env vars from previous sessions.

Closes #37
2025-12-02 15:55:10 -05:00
kaitranntt 6f42a6527b feat(ui): enhance auth commands with new ui layer
- Use table formatting for auth list with status column
- Add relative time display for last used (verbose mode)
- Use styled headers, subheaders, and examples in help
- Add info box display for profile creation success
- Maintain JSON output mode unchanged for scripting
2025-12-01 19:34:34 -05:00
Kai (Tam Nhu) TranandGitHub a3f1e52ac6 feat(cliproxy): add qwen code oauth provider support (#31)
Add 'qwen' as new CLIProxy OAuth provider with --qwen-login flag.
Support qwen3-coder model with base config at config/base-qwen.settings.json.
Register qwen OAuth endpoints and token prefix handling.
Update help documentation across all CLI entry points.

Implements issue #29
2025-12-01 03:51:47 -05:00
kaitranntt ce9d60d0ca feat(cliproxy): add user-defined CLIProxy variants
Allow users to create custom profile names that route through CLIProxy
providers with different model configurations.

Config example:
{
  "cliproxy": {
    "flash": { "provider": "gemini", "settings": "~/.ccs/gemini-flash.settings.json" },
    "pro": { "provider": "gemini", "settings": "~/.ccs/gemini-pro.settings.json" }
  }
}

Usage: ccs flash "quick task" or ccs pro "complex analysis"

Changes:
- Add CLIProxyVariantConfig types to src/types/config.ts
- Update profile-detector to check config.cliproxy section (Priority 1)
- Pass customSettingsPath through executor chain
- Update getEffectiveEnvVars to support custom settings path
- Document feature in README.md and CLAUDE.md
- Bump version to 5.0.2
2025-11-30 04:02:43 -05:00
kaitranntt e54d401656 feat(cliproxy): refactor config loading and enhance base settings support
- Introduce `BaseConfigLoader` for centralized configuration management
- Add `base-agy.settings.json` configuration
- Refactor `ConfigGenerator` to utilize new loading patterns
- Update help command with improved documentation
- Clean up lint violations file
- Enhance postinstall script
2025-11-28 20:43:11 -05:00
kaitranntt efb966c96d feat(cliproxy): unified config for concurrent gemini/codex usage
- Add unified CLIProxy config supporting all providers concurrently
- Move CLIProxy files to ~/.ccs/cliproxy/ subdirectory
- Use flat auth directory structure for OAuth tokens
- Add provider-specific URL routing via /api/provider/{provider}
- Add base settings templates for gemini and codex
- Fix model registration with proper auth file discovery

Enables users to run `ccs gemini` and `ccs codex` concurrently
without config conflicts.
2025-11-28 19:41:28 -05:00
kaitranntt 5f71eba6f6 feat(cliproxy): add CLIProxyAPI integration for OAuth profiles
Complete integration of CLIProxyAPI for zero-config OAuth profiles.

New profiles:
- ccs gemini: Gemini via OAuth
- ccs chatgpt: ChatGPT via OAuth
- ccs qwen: Qwen via OAuth

Implementation:
- Phase 1: Binary infrastructure (download-on-demand)
- Phase 2: Proxy executor (spawn/kill pattern)
- Phase 3: OAuth integration (browser-based auth)
- Phase 4: Profile registration (routing + help text)
- Phase 5: Diagnostics (doctor command + errors)

Files added:
- src/cliproxy/*.ts (binary-manager, platform-detector, executor, auth-handler, config-generator, types, index)

Files modified:
- src/ccs.ts (CLIProxy routing)
- src/auth/profile-detector.ts (cliproxy profile type)
- src/commands/help-command.ts (new profiles in help)
- src/management/doctor.ts (CLIProxy health checks)
- src/utils/error-manager.ts (OAuth/port/download errors)
- CHANGELOG.md (v5.0.0 release notes)

Tests: 42/42 passed
2025-11-28 16:28:15 -05:00
kaitranntt 7a413a81b7 refactor: enhance TypeScript types and improve delegation system 2025-11-27 09:25:12 -05:00
kaitranntt 0139333146 feat: set up quality gates for CCS TypeScript package
- Migrate package manager from npm to bun
- Add ESLint configuration with TypeScript support
- Add Prettier configuration and .prettierignore
- Format all TypeScript source files
- Update CLAUDE.md with bun instructions
- Verify 39 tests passing
2025-11-26 20:43:21 -05:00
kaitranntt 77d026869e fix(tsconfig): remove duplicate compiler options
- Remove duplicate allowSyntheticDefaultImports (lines 16 & 42)
- Remove duplicate skipLibCheck (lines 18 & 46)
- Add TypeScript source files for npm package migration
- Verify build pipeline works (42/42 tests pass)
2025-11-26 19:24:40 -05:00