mirror of
https://github.com/tiennm99/ccs.git
synced 2026-09-02 18:18:43 +00:00
feat(delegation): add passthrough args for claude cli flags
Support passing through additional CLI flags like --agent, --system-prompt-file to the underlying Claude CLI when using delegation mode.
This commit is contained in:
@@ -16,6 +16,7 @@ interface ParsedArgs {
|
|||||||
timeout?: number;
|
timeout?: number;
|
||||||
resumeSession?: boolean;
|
resumeSession?: boolean;
|
||||||
sessionId?: string;
|
sessionId?: string;
|
||||||
|
extraArgs?: string[]; // Passthrough args for Claude CLI
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +186,39 @@ export class DelegationHandler {
|
|||||||
options.timeout = parseInt(args[timeoutIndex + 1], 10);
|
options.timeout = parseInt(args[timeoutIndex + 1], 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Collect extra args to pass through to Claude CLI
|
||||||
|
// CCS-handled flags with values (skip these and their values):
|
||||||
|
const ccsFlagsWithValue = new Set(['-p', '--prompt', '--timeout', '--permission-mode']);
|
||||||
|
const extraArgs: string[] = [];
|
||||||
|
const profile = this._extractProfile(args);
|
||||||
|
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
const arg = args[i];
|
||||||
|
|
||||||
|
// Skip profile name (non-flag first arg)
|
||||||
|
if (arg === profile && !arg.startsWith('-')) continue;
|
||||||
|
|
||||||
|
// Skip CCS-handled flags and their values
|
||||||
|
if (ccsFlagsWithValue.has(arg)) {
|
||||||
|
i++; // Skip next arg (the value)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collect flags and their values as passthrough
|
||||||
|
if (arg.startsWith('-')) {
|
||||||
|
extraArgs.push(arg);
|
||||||
|
// If next arg exists and doesn't start with '-', it's likely a value
|
||||||
|
if (i + 1 < args.length && !args[i + 1].startsWith('-')) {
|
||||||
|
extraArgs.push(args[i + 1]);
|
||||||
|
i++; // Skip the value we just added
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extraArgs.length > 0) {
|
||||||
|
options.extraArgs = extraArgs;
|
||||||
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ interface ExecutionOptions {
|
|||||||
resumeSession?: boolean;
|
resumeSession?: boolean;
|
||||||
sessionId?: string;
|
sessionId?: string;
|
||||||
maxRetries?: number;
|
maxRetries?: number;
|
||||||
|
extraArgs?: string[]; // Passthrough args for Claude CLI
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ExecutionResult {
|
interface ExecutionResult {
|
||||||
@@ -112,6 +113,7 @@ export class HeadlessExecutor {
|
|||||||
permissionMode = 'acceptEdits',
|
permissionMode = 'acceptEdits',
|
||||||
resumeSession = false,
|
resumeSession = false,
|
||||||
sessionId = null,
|
sessionId = null,
|
||||||
|
extraArgs = [],
|
||||||
} = options;
|
} = options;
|
||||||
|
|
||||||
// Validate permission mode
|
// Validate permission mode
|
||||||
@@ -210,6 +212,11 @@ export class HeadlessExecutor {
|
|||||||
|
|
||||||
// Note: No max-turns limit - using time-based limits instead (default 10min timeout)
|
// Note: No max-turns limit - using time-based limits instead (default 10min timeout)
|
||||||
|
|
||||||
|
// Passthrough extra args (from Claude CLI flags like --agent, --system-prompt-file, etc.)
|
||||||
|
if (extraArgs.length > 0) {
|
||||||
|
args.push(...extraArgs);
|
||||||
|
}
|
||||||
|
|
||||||
// Debug log args
|
// Debug log args
|
||||||
if (process.env.CCS_DEBUG) {
|
if (process.env.CCS_DEBUG) {
|
||||||
console.error(`[i] Claude CLI args: ${args.join(' ')}`);
|
console.error(`[i] Claude CLI args: ${args.join(' ')}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user