mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-15 20:20:09 +00:00
* fix(dispatcher): preserve anthropic auth env for settings profiles on non-proxy path API profiles whose `ANTHROPIC_BASE_URL` is classified as `'anthropic'` (anthropic.com, paths containing `/anthropic`, ollama.com) skip the local OpenAI-compat proxy. The non-proxy launch path stripped `ANTHROPIC_BASE_URL` / `ANTHROPIC_AUTH_TOKEN` / `ANTHROPIC_API_KEY` from the subprocess env without re-injecting them, so Claude Code launched with no routing/auth in `process.env` and failed with `Not logged in - Please run /login`. The `--settings` env block does not satisfy Claude Code's auth check. Pre-existing for `anthropic.com` and `/anthropic` profiles. Newly broken in v7.77.0 for Ollama Cloud profiles - PR #1175 reclassified `ollama.com` from `generic-chat-completion-api` to `anthropic`, moving it from the proxy path onto this broken non-proxy path. Fix by extending `stripAnthropicRoutingEnv` with an optional `preserveFrom` parameter. Routing keys present in `preserveFrom` survive the strip (with values from `preserveFrom`). Settings-type profiles pass their own `settings.env` as the preserve source so routing they explicitly supplied is kept while routing leaked from the parent shell or `global.env` is dropped. Wired into both call sites: - `headless-executor.ts` (the `-p` headless executor) - `settings-flow.ts` (the interactive flow, which then calls `execClaude` - whose own `stripAnthropicRoutingEnv` pass on the merged env now also takes `envVars` as the preserve source so the caller-supplied routing is not stripped a second time before spawn) Native Anthropic / Bedrock / Vertex profiles are unaffected (they don't put routing keys in `settings.env`). The OpenAI-compat proxy path is unaffected because `buildOpenAICompatProxyEnv` overrides `BASE_URL` / `AUTH_TOKEN` with localhost values and explicitly deletes `API_KEY` after this strip. Replaces the Apr 21 defensive double-strip test (which was the mechanism causing this regression on the interactive path) with a test asserting the new contract: caller-supplied routing in `envVars` survives, parent-process routing is still stripped. * test: harden anthropic settings env preservation coverage * fix: preserve explicit blank anthropic routing env --------- Co-authored-by: Tam Nhu Tran <kaitran.ntt@gmail.com>
CCS Test Suite
Organization
tests/
├── unit/ # Module unit tests (Mocha)
│ ├── glmt/ # Legacy GLMT transformer/internal compatibility 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 + smoke tests
└── 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 + integration + npm)
bun run test:unit # Unit tests only
bun run test:npm # npm package tests
bun run test:native # Native Unix tests (bash)
Test Categories
Unit Tests (unit/)
Module-level tests using Mocha framework:
unit/glmt/- Legacy transformer internals kept for Cursor translation compatibilityunit/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/)
Integration and smoke coverage for scenarios that exercise multiple layers:
- Automated
*.test.tsfiles run as part ofbun run test:alland CI - Shell and standalone probe scripts remain on-demand for targeted debugging
cursor-daemon-lifecycle.test.ts- local daemon process + HTTP smoke coverageimage-analyzer-hook.test.ts- hook integration coverageglmt-integration-test.sh- legacy GLMT compatibility smoke probesymlink-chain-test.sh- Symlink chain handlingux-integration-test.sh- CLI UX integration
Adding New Tests
- Unit tests: Add to
unit/<module>/for isolated module behavior - npm tests: Add to
npm/for package behavior - Native tests: Add to
native/unix/ornative/windows/ - Integration tests: Add automated cross-layer smoke coverage to
integration/*.test.ts