mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-13 18:15:23 +00:00
fix(codex): align cliproxy guidance with runtime behavior
This commit is contained in:
1 parent
0ffde4f3a2
commit
bd1ff02521
22 files changed
+342
-64
No files matched your search
@@ -198,16 +198,21 @@ Resolves which adapter to use via `resolveTargetType()`:
|
||||
```
|
||||
1. --target <name> flag (highest priority)
|
||||
↓
|
||||
2. argv[0] detection (runtime alias pattern):
|
||||
2. explicit runtime entrypoint (`CCS_INTERNAL_ENTRY_TARGET`):
|
||||
- ccs-droid / ccsd → droid
|
||||
- ccs-codex / ccsx → codex
|
||||
- ccsxp → codex (provider shortcut)
|
||||
↓
|
||||
3. argv[0] detection (runtime alias pattern / custom alias map):
|
||||
- ccs-droid → droid
|
||||
- ccsd → droid
|
||||
- ccs-codex → codex
|
||||
- ccsx → codex
|
||||
- ccs → default
|
||||
↓
|
||||
3. Profile config: profileConfig.target field
|
||||
4. Profile config: profileConfig.target field
|
||||
↓
|
||||
4. Fallback: 'claude' (lowest priority)
|
||||
5. Fallback: 'claude' (lowest priority)
|
||||
```
|
||||
|
||||
### Registration Pattern
|
||||
|
||||
@@ -36,8 +36,9 @@ The main CLI is organized into domain-specific modules with barrel exports.
|
||||
src/
|
||||
├── ccs.ts # Main entry point & profile execution flow
|
||||
├── bin/ # Dedicated runtime entrypoints
|
||||
│ ├── droid-runtime.ts # argv[0] shim for ccs-droid / ccsd
|
||||
│ └── codex-runtime.ts # argv[0] shim for ccs-codex / ccsx
|
||||
│ ├── droid-runtime.ts # Forces droid target for ccs-droid / ccsd package bins
|
||||
│ ├── codex-runtime.ts # Forces codex target for ccs-codex / ccsx package bins
|
||||
│ └── ccsxp-runtime.ts # Forces built-in codex profile + codex target for ccsxp
|
||||
├── types/ # TypeScript type definitions
|
||||
│ ├── index.ts # Barrel export (aggregates all types)
|
||||
│ ├── cli.ts # CLI types (ParsedArgs, ExitCode)
|
||||
@@ -69,7 +70,7 @@ src/
|
||||
│ ├── index.ts # Barrel export
|
||||
│ ├── target-adapter.ts # TargetAdapter interface contract
|
||||
│ ├── target-registry.ts # Registry for runtime adapter lookup
|
||||
│ ├── target-resolver.ts # Resolution logic (flag > argv[0] > config)
|
||||
│ ├── target-resolver.ts # Resolution logic (flag > runtime entrypoint / argv[0] > config)
|
||||
│ ├── target-metadata.ts # Runtime vs persisted target metadata and alias lists
|
||||
│ ├── target-runtime-compatibility.ts # Guardrails for target/profile combinations
|
||||
│ ├── claude-adapter.ts # Claude Code CLI implementation
|
||||
@@ -248,7 +249,9 @@ src/
|
||||
|
||||
### Native Codex Runtime Target
|
||||
|
||||
- Runtime aliases: `ccs-codex` and `ccsx` resolve through `src/bin/codex-runtime.ts` and `src/targets/target-resolver.ts`.
|
||||
- Dedicated runtime entrypoints: `ccs-codex` and `ccsx` resolve through `src/bin/codex-runtime.ts`, while `ccsxp` resolves through `src/bin/ccsxp-runtime.ts`; all three set `CCS_INTERNAL_ENTRY_TARGET=codex` before delegating to `src/targets/target-resolver.ts`.
|
||||
- Provider shortcut behavior: `ccsxp` also strips user-supplied `--target` overrides and rewrites argv to `ccs codex --target codex ...`, so it always lands on the built-in Codex-via-CLIProxy route.
|
||||
- `argv[0]` alias mapping still exists in `src/targets/target-resolver.ts` for same-binary/custom alias scenarios, but the built-in npm bins above do not depend on that map at runtime.
|
||||
- Metadata boundary: `src/targets/target-metadata.ts` keeps Codex runtime-only in v1, so persisted default targets remain `claude | droid`.
|
||||
- Compatibility guardrails: `src/targets/target-runtime-compatibility.ts` centralizes which profile types can execute on Codex.
|
||||
- Adapter behavior: `src/targets/codex-adapter.ts` and `src/targets/codex-detector.ts` launch native Codex without rewriting `~/.codex/config.toml`; CCS-backed routes use transient `codex -c key=value` overrides and env-key injection.
|
||||
@@ -279,7 +282,8 @@ The targets module provides an extensible interface for dispatching profiles to
|
||||
|
||||
2. **Target Resolution** - Priority order:
|
||||
- `--target <cli>` flag (CLI argument)
|
||||
- `argv[0]` detection (runtime alias pattern: `ccs-droid` / `ccsd` → droid)
|
||||
- Explicit runtime entrypoint via `CCS_INTERNAL_ENTRY_TARGET` (used by `src/bin/droid-runtime.ts`, `src/bin/codex-runtime.ts`, and `src/bin/ccsxp-runtime.ts`)
|
||||
- `argv[0]` detection for custom/same-binary runtime aliases
|
||||
- Per-profile `target` field (from config.yaml)
|
||||
- Default: `claude`
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ CCS v7.45 introduces the Target Adapter pattern, enabling seamless integration w
|
||||
Profile Resolution (CLIProxy, Settings/API, Account-based)
|
||||
|
|
||||
v
|
||||
Target Resolution (--target flag > argv[0] > config > default)
|
||||
Target Resolution (--target flag > runtime entrypoint / argv[0] > config > default)
|
||||
|
|
||||
v
|
||||
Get Target Adapter (Claude, Droid, or Codex)
|
||||
@@ -91,7 +91,7 @@ Spawn Target Process
|
||||
- Preserves native `~/.codex/config.toml` ownership
|
||||
- Dashboard page reads/writes only the user config layer with explicit runtime-vs-provider warnings
|
||||
|
||||
**Runtime alias pattern (built-in bins / argv[0]-style):**
|
||||
**Runtime entrypoints (built-in bins) and argv[0]-style aliases:**
|
||||
|
||||
```
|
||||
ccs → Target: claude (default)
|
||||
@@ -99,6 +99,7 @@ ccs-droid → Target: droid (explicit alias)
|
||||
ccsd → Target: droid (legacy shortcut)
|
||||
ccs-codex → Target: codex (explicit alias)
|
||||
ccsx → Target: codex (short alias)
|
||||
ccsxp → Target: codex (provider shortcut; rewrites argv to `ccs codex --target codex`)
|
||||
```
|
||||
|
||||
For details on the adapter architecture, see [Target Adapters](./target-adapters.md).
|
||||
|
||||
@@ -85,20 +85,25 @@ CCS resolves which adapter to use via priority-ordered checks:
|
||||
└─ ccs --target droid glm
|
||||
└─ ccs --target codex
|
||||
|
||||
2. argv[0] detection (runtime alias pattern) — binary name mapping
|
||||
2. Explicit runtime entrypoint (`CCS_INTERNAL_ENTRY_TARGET`) — dedicated bin shims
|
||||
└─ ccs-droid / ccsd → droid
|
||||
└─ ccs-codex / ccsx → codex
|
||||
└─ ccsxp → codex, then rewrites argv to `ccs codex --target codex ...`
|
||||
|
||||
3. argv[0] detection (runtime alias pattern) — binary name mapping for same-binary/custom aliases
|
||||
└─ ccs-droid (explicit alias) → droid
|
||||
└─ ccsd (legacy shortcut) → droid
|
||||
└─ ccs-codex (explicit alias) → codex
|
||||
└─ ccsx (short alias) → codex
|
||||
└─ ccs (regular command) → default
|
||||
|
||||
3. Per-profile config (from ~/.ccs/config.yaml or settings.json)
|
||||
4. Per-profile config (from ~/.ccs/config.yaml or settings.json)
|
||||
└─ persisted targets are currently only `claude` and `droid`
|
||||
└─ profiles:
|
||||
glm:
|
||||
target: droid
|
||||
|
||||
4. Fallback: 'claude' — lowest priority
|
||||
5. Fallback: 'claude' — lowest priority
|
||||
```
|
||||
|
||||
### Implementation
|
||||
@@ -117,19 +122,25 @@ export function resolveTargetType(
|
||||
return parsed.targetOverride;
|
||||
}
|
||||
|
||||
// 2. Check argv[0] (binary name)
|
||||
// 2. Check explicit runtime entrypoint shim
|
||||
const entrypointTarget = resolveEntrypointTarget();
|
||||
if (entrypointTarget) {
|
||||
return entrypointTarget;
|
||||
}
|
||||
|
||||
// 3. Check argv[0] (binary name / custom alias map)
|
||||
const binName = path.basename(process.argv[1] || process.argv0 || '').replace(/\.(cmd|bat|ps1|exe)$/i, '');
|
||||
if (ARGV0_TARGET_MAP[binName]) {
|
||||
return ARGV0_TARGET_MAP[binName];
|
||||
}
|
||||
|
||||
// 3. Check profile config
|
||||
// 4. Check profile config
|
||||
if (profileConfig?.target) {
|
||||
// Persisted targets intentionally exclude runtime-only codex.
|
||||
return profileConfig.target;
|
||||
}
|
||||
|
||||
// 4. Default to claude
|
||||
// 5. Default to claude
|
||||
return 'claude';
|
||||
}
|
||||
```
|
||||
@@ -488,20 +499,27 @@ longer read-mostly:
|
||||
This keeps the dashboard honest about Codex's merged configuration model while still giving users
|
||||
one place to inspect and manage the user-owned layer safely.
|
||||
|
||||
### Runtime Alias Pattern
|
||||
### Runtime Entrypoints and argv[0] Fallback
|
||||
|
||||
```bash
|
||||
# Built-in package bin aliases
|
||||
# Built-in package bin entrypoints
|
||||
ccs-codex
|
||||
→ Target: codex (forced by runtime alias)
|
||||
→ dist/bin/codex-runtime.js
|
||||
→ CCS_INTERNAL_ENTRY_TARGET=codex
|
||||
|
||||
ccsx codex
|
||||
→ Target: codex (forced by runtime alias)
|
||||
→ codex ...args
|
||||
ccsx
|
||||
→ dist/bin/codex-runtime.js
|
||||
→ CCS_INTERNAL_ENTRY_TARGET=codex
|
||||
|
||||
ccsxp
|
||||
→ dist/bin/ccsxp-runtime.js
|
||||
→ CCS_INTERNAL_ENTRY_TARGET=codex
|
||||
→ injects built-in codex profile shortcut
|
||||
```
|
||||
|
||||
Runtime aliases can also be extended with `CCS_TARGET_ALIASES` or legacy
|
||||
`CCS_CODEX_ALIASES` after creating a matching launcher:
|
||||
If a user launches CCS through a custom shim instead of the built-in package bins, target
|
||||
resolution falls back to `argv[0]` aliases from `CCS_TARGET_ALIASES` or legacy
|
||||
`CCS_CODEX_ALIASES`:
|
||||
|
||||
```bash
|
||||
ln -s /path/to/ccs /path/to/mycodex
|
||||
@@ -757,6 +775,7 @@ ccs --target droid help
|
||||
# Test Codex adapter (if installed)
|
||||
ccs --target codex
|
||||
ccs-codex
|
||||
ccsxp
|
||||
|
||||
# Test argv[0] detection
|
||||
ccs-droid help
|
||||
|
||||
Reference in new issue
Block a user