feat: add claude-code/opus reviewer + max-thinking spec support #5
@@ -221,7 +221,7 @@ func (e *claudeCodeEngine) runPass(ctx context.Context, system, task string, _ i
|
||||
func claudeEnv() []string {
|
||||
keep := func(k string) bool {
|
||||
switch k {
|
||||
case "PATH", "HOME", "USER", "LOGNAME", "TMPDIR", "LANG", "TERM", "SHELL":
|
||||
case "PATH", "HOME", "USER", "LOGNAME", "TMPDIR", "LANG", "TERM", "SHELL", "MAX_THINKING_TOKENS":
|
||||
return true
|
||||
}
|
||||
return strings.HasPrefix(k, "LC_") ||
|
||||
|
||||
@@ -252,3 +252,30 @@ func TestClaudeCodeThinkingEnvOverrideKeepsSuffix(t *testing.T) {
|
||||
t.Errorf("thinkingTokens = %d, want %d (suffix still applies)", e.thinkingTokens, maxThinkingTokens)
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunPassInjectsThinkingTokens verifies the engine actually puts
|
||||
// MAX_THINKING_TOKENS into the subprocess env for a ":max" spec (and not for a
|
||||
// plain spec). The stub echoes the value it received back as the result.
|
||||
func TestRunPassInjectsThinkingTokens(t *testing.T) {
|
||||
t.Setenv("GADFLY_CLAUDE_MODEL", "")
|
||||
t.Setenv("MAX_THINKING_TOKENS", "") // not in the test's own env
|
||||
dir := t.TempDir()
|
||||
stub := dir + "/claude-stub.sh"
|
||||
// Report the env var the CLI was launched with.
|
||||
script := "#!/bin/sh\nprintf '{\"result\":\"MTT=%s\",\"is_error\":false}' \"${MAX_THINKING_TOKENS:-unset}\"\n"
|
||||
if err := os.WriteFile(stub, []byte(script), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
maxEng := newClaudeCodeEngine("claude-code/opus:max", dir)
|
||||
maxEng.bin = stub
|
||||
if out, err := maxEng.runPass(context.Background(), "s", "t", 0); err != nil || out != "MTT=31999" {
|
||||
t.Fatalf(":max run: got (%q, %v), want (MTT=31999, nil)", out, err)
|
||||
}
|
||||
|
||||
plainEng := newClaudeCodeEngine("claude-code/opus", dir)
|
||||
plainEng.bin = stub
|
||||
if out, err := plainEng.runPass(context.Background(), "s", "t", 0); err != nil || out != "MTT=unset" {
|
||||
t.Fatalf("plain run: got (%q, %v), want (MTT=unset, nil)", out, err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user