@tanagram/cli 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/tanagram CHANGED
Binary file
package/commands/run.go CHANGED
@@ -4,6 +4,8 @@ import (
4
4
  "context"
5
5
  "fmt"
6
6
  "os"
7
+ "path/filepath"
8
+ "time"
7
9
 
8
10
  "github.com/tanagram/cli/checker"
9
11
  "github.com/tanagram/cli/extractor"
@@ -11,6 +13,23 @@ import (
11
13
  "github.com/tanagram/cli/storage"
12
14
  )
13
15
 
16
+ // spinner shows a simple spinner animation
17
+ func spinner(stop chan bool, message string) {
18
+ chars := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
19
+ i := 0
20
+ for {
21
+ select {
22
+ case <-stop:
23
+ fmt.Print("\r")
24
+ return
25
+ default:
26
+ fmt.Printf("\r%s %s", chars[i%len(chars)], message)
27
+ i++
28
+ time.Sleep(100 * time.Millisecond)
29
+ }
30
+ }
31
+ }
32
+
14
33
  // Run executes the main policy check with auto-sync
15
34
  func Run() error {
16
35
  // Find git root
@@ -50,13 +69,27 @@ func Run() error {
50
69
 
51
70
  // Auto-sync if any files changed
52
71
  if needsSync {
53
- fmt.Println("Instruction files changed, syncing with LLM...")
72
+ fmt.Printf("\nSyncing policies with LLM...\n")
73
+
54
74
  totalPolicies := 0
55
75
  ctx := context.Background()
56
76
 
57
- for _, file := range instructionFiles {
77
+ for i, file := range instructionFiles {
78
+ relPath, _ := filepath.Rel(gitRoot, file)
79
+
80
+ // Start spinner
81
+ stop := make(chan bool)
82
+ go spinner(stop, fmt.Sprintf("Processing %s (%d/%d)", relPath, i+1, len(instructionFiles)))
83
+
58
84
  policies, err := extractor.ExtractPoliciesFromFile(ctx, file)
85
+
86
+ // Stop spinner
87
+ stop <- true
88
+ close(stop)
89
+ time.Sleep(50 * time.Millisecond)
90
+
59
91
  if err != nil {
92
+ fmt.Printf("\r✗ Failed to process %s\n", relPath)
60
93
  return fmt.Errorf("failed to extract policies from %s: %w", file, err)
61
94
  }
62
95
 
@@ -64,6 +97,7 @@ func Run() error {
64
97
  return fmt.Errorf("failed to update cache for %s: %w", file, err)
65
98
  }
66
99
 
100
+ fmt.Printf("\r✓ %s - %d policies\n", relPath, len(policies))
67
101
  totalPolicies += len(policies)
68
102
  }
69
103
 
@@ -71,7 +105,7 @@ func Run() error {
71
105
  return fmt.Errorf("failed to save cache: %w", err)
72
106
  }
73
107
 
74
- fmt.Printf("Synced %d policies from %d file(s)\n", totalPolicies, len(instructionFiles))
108
+ fmt.Printf("\n✓ Synced %d policies from %d file(s)\n", totalPolicies, len(instructionFiles))
75
109
  }
76
110
 
77
111
  // Load all policies from cache
package/commands/sync.go CHANGED
@@ -5,6 +5,7 @@ import (
5
5
  "fmt"
6
6
  "os"
7
7
  "path/filepath"
8
+ "time"
8
9
 
9
10
  "github.com/tanagram/cli/extractor"
10
11
  "github.com/tanagram/cli/storage"
@@ -37,15 +38,27 @@ func Sync() error {
37
38
  }
38
39
 
39
40
  // Parse and sync each file using LLM
41
+ fmt.Printf("\nSyncing policies with LLM...\n")
42
+
40
43
  totalPolicies := 0
41
44
  ctx := context.Background()
42
45
 
43
- for _, file := range instructionFiles {
46
+ for i, file := range instructionFiles {
44
47
  relPath, _ := filepath.Rel(gitRoot, file)
45
- fmt.Printf("Syncing %s (using LLM)...\n", relPath)
48
+
49
+ // Start spinner
50
+ stop := make(chan bool)
51
+ go spinner(stop, fmt.Sprintf("Processing %s (%d/%d)", relPath, i+1, len(instructionFiles)))
46
52
 
47
53
  policies, err := extractor.ExtractPoliciesFromFile(ctx, file)
54
+
55
+ // Stop spinner
56
+ stop <- true
57
+ close(stop)
58
+ time.Sleep(50 * time.Millisecond)
59
+
48
60
  if err != nil {
61
+ fmt.Printf("\r✗ Failed to process %s\n", relPath)
49
62
  return fmt.Errorf("failed to extract policies from %s: %w", file, err)
50
63
  }
51
64
 
@@ -53,7 +66,7 @@ func Sync() error {
53
66
  return fmt.Errorf("failed to update cache for %s: %w", file, err)
54
67
  }
55
68
 
56
- fmt.Printf(" Extracted %d policies\n", len(policies))
69
+ fmt.Printf("\r%s - %d policies\n", relPath, len(policies))
57
70
  totalPolicies += len(policies)
58
71
  }
59
72
 
@@ -62,7 +75,7 @@ func Sync() error {
62
75
  return fmt.Errorf("failed to save cache: %w", err)
63
76
  }
64
77
 
65
- fmt.Printf("\nSync complete! Total: %d policies from %d file(s)\n", totalPolicies, len(instructionFiles))
78
+ fmt.Printf("\n✓ Synced %d policies from %d file(s)\n", totalPolicies, len(instructionFiles))
66
79
  return nil
67
80
  }
68
81
 
package/go.mod CHANGED
@@ -5,6 +5,7 @@ go 1.23.0
5
5
  require github.com/anthropics/anthropic-sdk-go v1.17.0
6
6
 
7
7
  require (
8
+ github.com/stretchr/testify v1.9.0 // indirect
8
9
  github.com/tidwall/gjson v1.18.0 // indirect
9
10
  github.com/tidwall/match v1.1.1 // indirect
10
11
  github.com/tidwall/pretty v1.2.1 // indirect
package/go.sum CHANGED
@@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
4
4
  github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5
5
  github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6
6
  github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7
- github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
8
- github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
7
+ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
8
+ github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
9
9
  github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
10
10
  github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
11
11
  github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanagram/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Tanagram - Catch sloppy code before it ships",
5
5
  "main": "index.js",
6
6
  "bin": {