Skip to content

Commit 4f524d3

Browse files
committed
Fix compact mode in scripts
1 parent 32c46e4 commit 4f524d3

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

cmd/script.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ func overrideConfigWithFrontmatter(scriptFile string, variables map[string]strin
9999
if scriptConfig.Debug && !flagChanged("debug") {
100100
viper.Set("debug", scriptConfig.Debug)
101101
}
102+
if scriptConfig.Compact && !flagChanged("compact") {
103+
viper.Set("compact", scriptConfig.Compact)
104+
}
102105
if scriptConfig.SystemPrompt != "" && !flagChanged("system-prompt") {
103106
viper.Set("system-prompt", scriptConfig.SystemPrompt)
104107
}

cmd/script_test.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,3 +270,36 @@ Hello John! Please analyze /tmp.`
270270
t.Errorf("substituteVariables() backward compatibility failed.\nGot:\n%s\nWant:\n%s", result, expected)
271271
}
272272
}
273+
274+
func TestParseScriptContentWithCompactMode(t *testing.T) {
275+
content := `---
276+
compact: true
277+
mcpServers:
278+
todo:
279+
type: "builtin"
280+
name: "todo"
281+
---
282+
Test prompt with compact mode`
283+
284+
variables := make(map[string]string)
285+
config, err := parseScriptContent(content, variables)
286+
if err != nil {
287+
t.Fatalf("parseScriptContent() failed: %v", err)
288+
}
289+
290+
if !config.Compact {
291+
t.Errorf("Expected compact mode to be true, got false")
292+
}
293+
294+
if config.Prompt != "Test prompt with compact mode" {
295+
t.Errorf("Expected prompt 'Test prompt with compact mode', got '%s'", config.Prompt)
296+
}
297+
298+
if len(config.MCPServers) != 1 {
299+
t.Errorf("Expected 1 MCP server, got %d", len(config.MCPServers))
300+
}
301+
302+
if config.MCPServers["todo"].Type != "builtin" {
303+
t.Errorf("Expected todo server type 'builtin', got '%s'", config.MCPServers["todo"].Type)
304+
}
305+
}

internal/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ type Config struct {
103103
Model string `json:"model,omitempty" yaml:"model,omitempty"`
104104
MaxSteps int `json:"max-steps,omitempty" yaml:"max-steps,omitempty"`
105105
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
106+
Compact bool `json:"compact,omitempty" yaml:"compact,omitempty"`
106107
SystemPrompt string `json:"system-prompt,omitempty" yaml:"system-prompt,omitempty"`
107108
ProviderAPIKey string `json:"provider-api-key,omitempty" yaml:"provider-api-key,omitempty"`
108109
ProviderURL string `json:"provider-url,omitempty" yaml:"provider-url,omitempty"`

0 commit comments

Comments
 (0)