Skip to content

Commit f995a99

Browse files
authored
fix: respect --quiet/--json flags consistently, surface swallowed errors (#17)
- ask: respect --quiet flag (was printing results unconditionally) - start: respect --quiet for banner, dashboard, and status messages - version: support --json output, --quiet prints bare version string - task start: respect --quiet on success message - task complete: log git commit/push failures to stderr instead of silently swallowing them (users had no idea their work wasn't pushed) - knowledge ingest: log DB errors on node upsert and link operations instead of silently dropping knowledge - Remove unused FilterByMinConfidence export
1 parent 3aa1197 commit f995a99

7 files changed

Lines changed: 60 additions & 49 deletions

File tree

cmd/ask.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ func runAsk(cmd *cobra.Command, args []string) error {
114114
return printJSON(result)
115115
}
116116

117-
ui.RenderAskResult(result, viper.GetBool("verbose"))
117+
if !isQuiet() {
118+
ui.RenderAskResult(result, viper.GetBool("verbose"))
119+
}
118120
return nil
119121
}

cmd/start.go

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,17 @@ func runStart(cmd *cobra.Command, args []string) error {
8888
}
8989

9090
// Print banner
91-
fmt.Println()
92-
fmt.Println("🚀 TaskWing Starting...")
93-
fmt.Println("━━━━━━━━━━━━━━━━━━━━━━━━")
94-
fmt.Printf("📁 Project: %s\n", cwd)
95-
fmt.Printf("🌐 API: %s\n", apiURL(startHost, startPort))
96-
if !noWatch {
97-
fmt.Println("👁️ Watch: enabled")
91+
if !isQuiet() {
92+
fmt.Println()
93+
fmt.Println("🚀 TaskWing Starting...")
94+
fmt.Println("━━━━━━━━━━━━━━━━━━━━━━━━")
95+
fmt.Printf("📁 Project: %s\n", cwd)
96+
fmt.Printf("🌐 API: %s\n", apiURL(startHost, startPort))
97+
if !noWatch {
98+
fmt.Println("👁️ Watch: enabled")
99+
}
100+
fmt.Println()
98101
}
99-
fmt.Println()
100102

101103
// WaitGroup to track goroutines
102104
var wg sync.WaitGroup
@@ -143,16 +145,20 @@ func runStart(cmd *cobra.Command, args []string) error {
143145
// Give server a moment to start
144146
time.Sleep(500 * time.Millisecond)
145147
if err := openBrowser(resolvedDashboardURL); err != nil {
146-
fmt.Printf("⚠️ Could not open browser: %v\n", err)
147-
fmt.Printf(" Open manually: %s\n", resolvedDashboardURL)
148-
} else {
148+
if !isQuiet() {
149+
fmt.Printf("⚠️ Could not open browser: %v\n", err)
150+
fmt.Printf(" Open manually: %s\n", resolvedDashboardURL)
151+
}
152+
} else if !isQuiet() {
149153
fmt.Printf("🌐 Dashboard opened: %s\n", resolvedDashboardURL)
150154
}
151155
}
152156

153-
fmt.Println()
154-
fmt.Println("✅ TaskWing is running! Press Ctrl+C to stop")
155-
fmt.Println()
157+
if !isQuiet() {
158+
fmt.Println()
159+
fmt.Println("✅ TaskWing is running! Press Ctrl+C to stop")
160+
fmt.Println()
161+
}
156162

157163
// Handle graceful shutdown
158164
sigChan := make(chan os.Signal, 1)

cmd/task.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,13 @@ func runTaskStart(cmd *cobra.Command, args []string) error {
755755
return nil
756756
}
757757

758-
fmt.Printf("✓ Started task: %s\n", result.Task.Title)
759-
fmt.Printf(" ID: %s\n", result.Task.ID)
758+
if !isQuiet() {
759+
fmt.Printf("✓ Started task: %s\n", result.Task.Title)
760+
fmt.Printf(" ID: %s\n", result.Task.ID)
760761

761-
if result.Hint != "" {
762-
fmt.Printf("\n💡 %s\n", result.Hint)
762+
if result.Hint != "" {
763+
fmt.Printf("\n💡 %s\n", result.Hint)
764+
}
763765
}
764766

765767
return nil

cmd/version.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,28 @@ var versionCmd = &cobra.Command{
1414
Use: "version",
1515
Short: "Print the version number of TaskWing",
1616
Long: `All software has versions. This is TaskWing's.`,
17-
Run: func(cmd *cobra.Command, args []string) {
17+
RunE: func(cmd *cobra.Command, args []string) error {
18+
if isJSON() {
19+
return printJSON(map[string]string{"version": version})
20+
}
21+
if isQuiet() {
22+
fmt.Println(version)
23+
return nil
24+
}
1825
fmt.Printf(`
19-
████████╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ██╗ ██████╗
20-
╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝██║ ██║██║████╗ ██║██╔════╝
26+
████████╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ██╗ ██████╗
27+
╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝██║ ██║██║████╗ ██║██╔════╝
2128
██║ ███████║███████╗█████╔╝ ██║ █╗ ██║██║██╔██╗ ██║██║ ███╗
2229
██║ ██╔══██║╚════██║██╔═██╗ ██║███╗██║██║██║╚██╗██║██║ ██║
2330
██║ ██║ ██║███████║██║ ██╗╚███╔███╔╝██║██║ ╚████║╚██████╔╝
24-
╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
31+
╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝
2532
2633
TaskWing CLI version %s
2734
`, version)
35+
return nil
2836
},
2937
}
3038

3139
func init() {
3240
rootCmd.AddCommand(versionCmd)
33-
34-
// Here you will define your flags and configuration settings.
35-
36-
// Cobra supports Persistent Flags which will work for this command
37-
// and all subcommands, e.g.:
38-
// versionCmd.PersistentFlags().String("foo", "", "A help for foo")
39-
40-
// Cobra supports local flags which will only run when this command
41-
// is called directly, e.g.:
42-
// versionCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
4341
}

internal/agents/verification/agent.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,3 @@ func FilterVerifiedFindings(findings []core.Finding) []core.Finding {
372372
return result
373373
}
374374

375-
// FilterByMinConfidence returns findings with confidence score >= minScore.
376-
func FilterByMinConfidence(findings []core.Finding, minScore float64) []core.Finding {
377-
var result []core.Finding
378-
for _, f := range findings {
379-
if f.ConfidenceScore >= minScore {
380-
result = append(result, f)
381-
}
382-
}
383-
return result
384-
}

internal/app/task.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,13 +468,17 @@ func (a *TaskApp) Complete(ctx context.Context, opts TaskCompleteOptions) (*Task
468468
}
469469

470470
// Commit task progress with conventional commit message
471-
if err := gitClient.CommitTaskProgress(taskBeforeComplete.Title, taskBeforeComplete.Scope); err == nil {
471+
if err := gitClient.CommitTaskProgress(taskBeforeComplete.Title, taskBeforeComplete.Scope); err != nil {
472+
fmt.Fprintf(os.Stderr, "⚠️ git commit failed: %v\n", err)
473+
} else {
472474
gitCommitApplied = true
473475
}
474476

475477
// Push to remote if we have a branch and commit was successful
476478
if gitCommitApplied && gitBranch != "" {
477-
if err := gitClient.PushTaskProgress(gitBranch); err == nil {
479+
if err := gitClient.PushTaskProgress(gitBranch); err != nil {
480+
fmt.Fprintf(os.Stderr, "⚠️ git push failed: %v\n", err)
481+
} else {
478482
gitPushApplied = true
479483
}
480484
}

internal/knowledge/ingest.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7+
"os"
78
"strings"
89
"time"
910

@@ -265,7 +266,9 @@ func (s *Service) ingestNodesWithIndex(ctx context.Context, findings []core.Find
265266
}
266267
}
267268

268-
if err := s.repo.UpsertNodeBySummary(node); err == nil {
269+
if err := s.repo.UpsertNodeBySummary(node); err != nil {
270+
fmt.Fprintf(os.Stderr, "⚠️ failed to upsert node %q: %v\n", f.Title, err)
271+
} else {
269272
nodesCreated++
270273
nodesByTitle[strings.ToLower(f.Title)] = nodeID
271274
}
@@ -366,7 +369,9 @@ func (s *Service) linkByEvidence(allNodes []memory.Node) int {
366369
"shared_file": filePath,
367370
"shared_count": sharedFiles,
368371
}
369-
if err := s.repo.LinkNodes(nodeA, nodeB, memory.NodeRelationSharesEvidence, weight, props); err == nil {
372+
if err := s.repo.LinkNodes(nodeA, nodeB, memory.NodeRelationSharesEvidence, weight, props); err != nil {
373+
fmt.Fprintf(os.Stderr, "⚠️ failed to link nodes (evidence): %v\n", err)
374+
} else {
370375
count++
371376
}
372377
}
@@ -414,7 +419,9 @@ func (s *Service) linkSemantic(allNodes []memory.Node) int {
414419
similarity := CosineSimilarity(nodeA.Embedding, nodeB.Embedding)
415420
if similarity >= float32(threshold) {
416421
props := map[string]any{"similarity": similarity}
417-
if err := s.repo.LinkNodes(nodeA.ID, nodeB.ID, memory.NodeRelationSemanticallySimilar, float64(similarity), props); err == nil {
422+
if err := s.repo.LinkNodes(nodeA.ID, nodeB.ID, memory.NodeRelationSemanticallySimilar, float64(similarity), props); err != nil {
423+
fmt.Fprintf(os.Stderr, "⚠️ failed to link nodes (semantic): %v\n", err)
424+
} else {
418425
count++
419426
}
420427
}
@@ -466,7 +473,9 @@ func (s *Service) linkByLLMRelationships(relationships []core.Relationship, node
466473
"reason": rel.Reason,
467474
}
468475

469-
if err := s.repo.LinkNodes(fromID, toID, relationType, weight, props); err == nil {
476+
if err := s.repo.LinkNodes(fromID, toID, relationType, weight, props); err != nil {
477+
fmt.Fprintf(os.Stderr, "⚠️ failed to link nodes (llm): %v\n", err)
478+
} else {
470479
count++
471480
}
472481
}

0 commit comments

Comments
 (0)