mirror of
https://github.com/Twigpine/zero.git
synced 2026-11-12 08:41:32 -10:00
* audit tail: fix remaining medium/low correctness findings A sweep of the remaining audit findings across CLI, config, OAuth, tools, LSP, and the TUI. Each fix has a regression test; build/vet/gofmt clean and the touched packages' suites pass. CLI - `zero -p "<prompt>"` now forwards the prompt as the inline `--prompt=<value>` form so a prompt whose first character is a dash (e.g. `zero -p "-foo"`) is taken verbatim instead of being rejected as a missing flag value (matches the cron path). Config - mergeProfile no longer drops parseThinkTags across profile merges; an explicit value carries over and a nil (unset) never clobbers an existing one. OAuth - Refresh carries the existing token_type forward when the refresh response omits it (previously silently lost). - RefreshScheduler.Stop resets started/done so the scheduler can be started again instead of being permanently inert after the first Stop. Tools - apply_patch header parsing takes the whole post-prefix value (dropping a trailing tab timestamp and undoing git's C-style quoting) instead of splitting on spaces, so a diff target whose name contains spaces is recognized. LSP - Server.Shutdown honors its context (kills immediately on cancel rather than waiting out the full grace window), and Manager.Shutdown shuts servers down concurrently so total shutdown is bounded by one grace window, not N×grace. TUI - /theme auto re-probes the terminal background (RequestBackgroundColor) instead of reusing a stale startup reading, so switching to auto re-detects light/dark. - Specialist card: wire the tool-call count from progress events (was always 0) and omit the token segment when the total is 0 rather than show "0 tokens". - Resume: extract the tool-call row id the same way as the result row and the specialist pre-pass (toolCallId first), so call/result dedup and the failed-Task visibility rule key on the same string. - Plan panel: height takes an injected clock (testable, consistent with render), and duplicate-content steps inherit distinct prior timestamps positionally. * tui: test that /theme auto re-probes the terminal background (M17) The M17 fix lives in handleSubmit's command dispatch (`return m, tea.RequestBackgroundColor` when the mode is auto), which no test exercised — only the handleThemeCommand helper was covered. Add a dispatch-level test: /theme auto must return the background re-probe command, /theme dark must not. Verified to fail if the dispatch is reverted to `return m, nil`.
24 lines
787 B
Go
24 lines
787 B
Go
package cli
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// TestParseExecArgsInlinePromptKeepsLeadingDash guards the M19 fix: the top-level
|
|
// `zero -p "<prompt>"` path forwards the prompt as the inline `--prompt=<value>`
|
|
// form precisely so a prompt whose first character is a dash is taken verbatim
|
|
// instead of being mistaken for a flag and rejected.
|
|
func TestParseExecArgsInlinePromptKeepsLeadingDash(t *testing.T) {
|
|
opts, early, err := parseExecArgs([]string{"--prompt=-foo bar"})
|
|
if err != nil {
|
|
t.Fatalf("inline dash-leading prompt rejected: %v", err)
|
|
}
|
|
if early {
|
|
t.Fatal("a normal prompt parse must not request early exit")
|
|
}
|
|
if got := strings.TrimSpace(strings.Join(opts.promptParts, " ")); got != "-foo bar" {
|
|
t.Fatalf("inline prompt = %q, want %q", got, "-foo bar")
|
|
}
|
|
}
|