mirror of
https://github.com/cline/cline.git
synced 2026-10-24 02:02:27 +08:00
feat(cli): allow --thinking flag to accept custom token budget (#9177)
The --thinking flag now accepts an optional number argument to set a custom thinking budget instead of always using the 1024 default. cline "prompt" --thinking # 1024 tokens (default) cline "prompt" --thinking 8000 # 8000 tokens Invalid values get a warning and fall back to 1024.
This commit is contained in:
+14
-2
@@ -30,7 +30,7 @@ describe("CLI Commands", () => {
|
||||
.option("-v, --verbose", "Show verbose output")
|
||||
.option("-c, --cwd <path>", "Working directory")
|
||||
.option("--config <path>", "Configuration directory")
|
||||
.option("--thinking", "Enable extended thinking")
|
||||
.option("--thinking [tokens]", "Enable extended thinking")
|
||||
.option("--reasoning-effort <effort>", "Reasoning effort")
|
||||
.action(() => {})
|
||||
|
||||
@@ -68,7 +68,7 @@ describe("CLI Commands", () => {
|
||||
.option("-v, --verbose", "Verbose output")
|
||||
.option("-c, --cwd <path>", "Working directory")
|
||||
.option("--config <path>", "Configuration directory")
|
||||
.option("--thinking", "Enable extended thinking")
|
||||
.option("--thinking [tokens]", "Enable extended thinking")
|
||||
.option("--reasoning-effort <effort>", "Reasoning effort")
|
||||
.action(() => {})
|
||||
})
|
||||
@@ -148,6 +148,13 @@ describe("CLI Commands", () => {
|
||||
expect(taskCmd.opts().thinking).toBe(true)
|
||||
})
|
||||
|
||||
it("should parse --thinking with token budget", () => {
|
||||
const taskCmd = program.commands.find((c) => c.name() === "task")!
|
||||
const args = ["test prompt", "--thinking", "8000"]
|
||||
taskCmd.parse(args, { from: "user" })
|
||||
expect(taskCmd.opts().thinking).toBe("8000")
|
||||
})
|
||||
|
||||
it("should parse --reasoning-effort option", () => {
|
||||
const taskCmd = program.commands.find((c) => c.name() === "task")!
|
||||
const args = ["test prompt", "--reasoning-effort", "high"]
|
||||
@@ -291,6 +298,11 @@ describe("CLI Commands", () => {
|
||||
expect(program.opts().thinking).toBe(true)
|
||||
})
|
||||
|
||||
it("should parse --thinking with token budget", () => {
|
||||
program.parse(["node", "cli", "--thinking", "4096"])
|
||||
expect(program.opts().thinking).toBe("4096")
|
||||
})
|
||||
|
||||
it("should parse --reasoning-effort option", () => {
|
||||
program.parse(["node", "cli", "--reasoning-effort", "medium"])
|
||||
expect(program.opts().reasoningEffort).toBe("medium")
|
||||
|
||||
+18
-5
@@ -54,7 +54,7 @@ interface TaskOptions {
|
||||
verbose?: boolean
|
||||
cwd?: string
|
||||
config?: string
|
||||
thinking?: boolean
|
||||
thinking?: boolean | string
|
||||
reasoningEffort?: string
|
||||
yolo?: boolean
|
||||
timeout?: string
|
||||
@@ -115,8 +115,21 @@ function applyTaskOptions(options: TaskOptions): void {
|
||||
telemetryService.captureHostEvent("model_flag", options.model)
|
||||
}
|
||||
|
||||
// Set thinking budget based on --thinking flag
|
||||
const thinkingBudget = options.thinking ? 1024 : 0
|
||||
// Set thinking budget based on --thinking flag (boolean or number)
|
||||
let thinkingBudget = 0
|
||||
if (options.thinking) {
|
||||
if (typeof options.thinking === "string") {
|
||||
const parsed = Number.parseInt(options.thinking, 10)
|
||||
if (Number.isNaN(parsed) || parsed < 0) {
|
||||
printWarning(`Invalid --thinking value '${options.thinking}'. Using default 1024.`)
|
||||
thinkingBudget = 1024
|
||||
} else {
|
||||
thinkingBudget = parsed
|
||||
}
|
||||
} else {
|
||||
thinkingBudget = 1024
|
||||
}
|
||||
}
|
||||
const currentMode = (StateManager.get().getGlobalSettingsKey("mode") || "act") as "act" | "plan"
|
||||
setModeScopedState(currentMode, (mode) => {
|
||||
const thinkingKey = mode === "act" ? "actModeThinkingBudgetTokens" : "planModeThinkingBudgetTokens"
|
||||
@@ -686,7 +699,7 @@ program
|
||||
.option("-v, --verbose", "Show verbose output")
|
||||
.option("-c, --cwd <path>", "Working directory for the task")
|
||||
.option("--config <path>", "Path to Cline configuration directory")
|
||||
.option("--thinking", "Enable extended thinking (1024 token budget)")
|
||||
.option("--thinking [tokens]", "Enable extended thinking (default: 1024 tokens)")
|
||||
.option("--reasoning-effort <effort>", "Reasoning effort: none|low|medium|high|xhigh")
|
||||
.option("--json", "Output messages as JSON instead of styled text")
|
||||
.option("-T, --taskId <id>", "Resume an existing task by ID")
|
||||
@@ -917,7 +930,7 @@ program
|
||||
.option("-v, --verbose", "Show verbose output")
|
||||
.option("-c, --cwd <path>", "Working directory")
|
||||
.option("--config <path>", "Configuration directory")
|
||||
.option("--thinking", "Enable extended thinking (1024 token budget)")
|
||||
.option("--thinking [tokens]", "Enable extended thinking (default: 1024 tokens)")
|
||||
.option("--reasoning-effort <effort>", "Reasoning effort: none|low|medium|high|xhigh")
|
||||
.option("--json", "Output messages as JSON instead of styled text")
|
||||
.option("--acp", "Run in ACP (Agent Client Protocol) mode for editor integration")
|
||||
|
||||
Reference in New Issue
Block a user