mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 14:17:11 +00:00
fix(dispatcher): preserve --permission-mode for claude agents subcommand
`stripClaudeSubcommandSessionArgs` was unconditionally stripping `--permission-mode`, `--dangerously-skip-permissions`, and `--allow-dangerously-skip-permissions` from every Claude subcommand invocation. That's correct for `auth`/`doctor`/`mcp`/etc. — their parsers reject those flags with `error: unknown option '...'`. But `claude agents` does accept all three (see `claude agents --help`): they configure the default permission mode for sessions dispatched from the agent view. As a result, `ccs <profile> agents --permission-mode bypassPermissions` silently dropped the flag before forwarding to Claude and the agent view kept its previous default. Add a small per-subcommand allowlist (`SUBCOMMAND_ALLOWED_SESSION_FLAGS`) and a `getClaudeSubcommandName(args)` helper, then branch the strip logic on the detected subcommand. `agents` keeps the three permission flags; every other subcommand (including unknown future ones) falls through to the existing strip behavior. `--teammate-mode` is still stripped for every subcommand — no upstream subcommand accepts it. Tests cover both before- and after-position arguments, the `--flag=value` form, the `--teammate-mode` exclusion for `agents`, and regression coverage for non-`agents` subcommands.
This commit is contained in:
1 parent
e7fed040ee
commit
ef4b746876
2 files changed
+103
-13
No files matched your search
@@ -86,28 +86,74 @@ describe('stripClaudeCodeFeatureBlockingEnv', () => {
|
||||
});
|
||||
|
||||
describe('stripClaudeSubcommandSessionArgs', () => {
|
||||
it('removes session-only flags before a Claude subcommand', () => {
|
||||
it('removes session-only flags before a non-agents Claude subcommand', () => {
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs([
|
||||
'--dangerously-skip-permissions',
|
||||
'--teammate-mode',
|
||||
'in-process',
|
||||
'agents',
|
||||
'doctor',
|
||||
])
|
||||
).toEqual(['agents']);
|
||||
).toEqual(['doctor']);
|
||||
});
|
||||
|
||||
it('removes session-only flags after a Claude subcommand while preserving subcommand flags', () => {
|
||||
it('removes session-only flags after a non-agents subcommand while preserving subcommand flags', () => {
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs([
|
||||
'agents',
|
||||
'mcp',
|
||||
'--dangerously-skip-permissions',
|
||||
'--teammate-mode',
|
||||
'in-process',
|
||||
'--setting-sources',
|
||||
'user',
|
||||
])
|
||||
).toEqual(['agents', '--setting-sources', 'user']);
|
||||
).toEqual(['mcp', '--setting-sources', 'user']);
|
||||
});
|
||||
|
||||
it('preserves --permission-mode for the agents subcommand (after)', () => {
|
||||
// `claude agents` accepts `--permission-mode <mode>` as the default
|
||||
// permission mode for dispatched sessions; CCS must not strip it.
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs([
|
||||
'agents',
|
||||
'--permission-mode',
|
||||
'bypassPermissions',
|
||||
'--teammate-mode',
|
||||
'in-process',
|
||||
])
|
||||
).toEqual(['agents', '--permission-mode', 'bypassPermissions']);
|
||||
});
|
||||
|
||||
it('preserves --permission-mode for the agents subcommand (before, --flag=value form)', () => {
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs(['--permission-mode=bypassPermissions', 'agents'])
|
||||
).toEqual(['--permission-mode=bypassPermissions', 'agents']);
|
||||
});
|
||||
|
||||
it('preserves --dangerously-skip-permissions and --allow-dangerously-skip-permissions for agents', () => {
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs([
|
||||
'--dangerously-skip-permissions',
|
||||
'--allow-dangerously-skip-permissions',
|
||||
'agents',
|
||||
])
|
||||
).toEqual([
|
||||
'--dangerously-skip-permissions',
|
||||
'--allow-dangerously-skip-permissions',
|
||||
'agents',
|
||||
]);
|
||||
});
|
||||
|
||||
it('still strips --teammate-mode for the agents subcommand (not accepted by upstream)', () => {
|
||||
expect(
|
||||
stripClaudeSubcommandSessionArgs([
|
||||
'agents',
|
||||
'--teammate-mode',
|
||||
'in-process',
|
||||
'--permission-mode',
|
||||
'bypassPermissions',
|
||||
])
|
||||
).toEqual(['agents', '--permission-mode', 'bypassPermissions']);
|
||||
});
|
||||
|
||||
it('leaves non-subcommand interactive launches unchanged', () => {
|
||||
|
||||
Reference in new issue
Block a user