mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-11 03:13:12 +00:00
fix: honor default target for Claude passthrough (#1539)
Honors the configured default target in the Claude subcommand passthrough resolver.
This commit is contained in:
1 parent
d2848d3931
commit
473aa082f6
2 files changed
+40
-6
No files matched your search
@@ -99,11 +99,15 @@ function usesImplicitDefaultProfile(cleanArgs: string[]): boolean {
|
|||||||
* and only reached on the profile-not-found path, so a real configured profile
|
* and only reached on the profile-not-found path, so a real configured profile
|
||||||
* of the same name always wins.
|
* of the same name always wins.
|
||||||
*/
|
*/
|
||||||
export function isBareClaudeSubcommandPassthrough(profile: string, args: string[]): boolean {
|
export function isBareClaudeSubcommandPassthrough(
|
||||||
|
profile: string,
|
||||||
|
args: string[],
|
||||||
|
profileConfig?: Parameters<typeof resolveTargetType>[1]
|
||||||
|
): boolean {
|
||||||
if (profile === 'default') return false;
|
if (profile === 'default') return false;
|
||||||
if (getClaudeSubcommandName([profile]) === null) return false;
|
if (getClaudeSubcommandName([profile]) === null) return false;
|
||||||
try {
|
try {
|
||||||
return resolveTargetType(args) === 'claude';
|
return resolveTargetType(args, profileConfig) === 'claude';
|
||||||
} catch {
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -158,10 +162,19 @@ export async function resolveProfileAndTarget(
|
|||||||
} catch (profileError) {
|
} catch (profileError) {
|
||||||
// Bare Claude subcommand passthrough: forward `ccs agents`, `ccs mcp`, ...
|
// Bare Claude subcommand passthrough: forward `ccs agents`, `ccs mcp`, ...
|
||||||
// through the default profile instead of failing as an unknown profile.
|
// through the default profile instead of failing as an unknown profile.
|
||||||
if (isBareClaudeSubcommandPassthrough(profile, args)) {
|
if (profile !== 'default' && getClaudeSubcommandName([profile]) !== null) {
|
||||||
remainingArgs = [profile, ...remainingArgs];
|
const defaultProfileInfo = detector.detectProfileType('default');
|
||||||
profile = 'default';
|
const defaultProfileConfig = defaultProfileInfo.target
|
||||||
profileInfo = detector.detectProfileType(profile);
|
? { target: defaultProfileInfo.target }
|
||||||
|
: undefined;
|
||||||
|
|
||||||
|
if (isBareClaudeSubcommandPassthrough(profile, args, defaultProfileConfig)) {
|
||||||
|
remainingArgs = [profile, ...remainingArgs];
|
||||||
|
profile = 'default';
|
||||||
|
profileInfo = defaultProfileInfo;
|
||||||
|
} else {
|
||||||
|
throw profileError;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
throw profileError;
|
throw profileError;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,4 +42,25 @@ describe('isBareClaudeSubcommandPassthrough', () => {
|
|||||||
);
|
);
|
||||||
expect(isBareClaudeSubcommandPassthrough('mcp', ['mcp', '--target', 'codex'])).toBe(false);
|
expect(isBareClaudeSubcommandPassthrough('mcp', ['mcp', '--target', 'codex'])).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not reroute through a default profile configured for a non-claude target', () => {
|
||||||
|
expect(
|
||||||
|
isBareClaudeSubcommandPassthrough('setup-token', ['setup-token', 'sk-secret'], {
|
||||||
|
target: 'droid',
|
||||||
|
})
|
||||||
|
).toBe(false);
|
||||||
|
expect(isBareClaudeSubcommandPassthrough('agents', ['agents'], { target: 'codex' })).toBe(
|
||||||
|
false
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('allows explicit claude target selection to override a non-claude default profile target', () => {
|
||||||
|
expect(
|
||||||
|
isBareClaudeSubcommandPassthrough(
|
||||||
|
'setup-token',
|
||||||
|
['setup-token', 'sk-secret', '--target', 'claude'],
|
||||||
|
{ target: 'droid' }
|
||||||
|
)
|
||||||
|
).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
Reference in new issue
Block a user