Skip to content

Commit 32c119c

Browse files
authored
Merge pull request #22 from kevinelliott/copilot/fix-agents-install-claude-fail
Fix Claude CLI install using wrong npm package name
2 parents fe462eb + b8d180a commit 32c119c

File tree

9 files changed

+216
-136
lines changed

9 files changed

+216
-136
lines changed

.github/workflows/build-pr.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
pull_request:
55
types: [opened, synchronize, reopened]
66

7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
711
jobs:
812
build-pr:
913
name: Build PR Artifacts

cmd/root.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
)
1515

1616
var (
17-
cfgFile string
18-
showVersion bool
17+
cfgFile string
18+
showVersion bool
1919
globalJSONEmitter *bridge.StdoutEmitter // Shared across root and run commands for --json mode
2020
)
2121

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ require (
77
github.com/charmbracelet/bubbletea v1.3.10
88
github.com/charmbracelet/lipgloss v1.1.0
99
github.com/fsnotify/fsnotify v1.9.0
10+
github.com/google/uuid v1.6.0
1011
github.com/prometheus/client_golang v1.23.2
1112
github.com/rs/zerolog v1.34.0
1213
github.com/spf13/cobra v1.10.1
14+
github.com/spf13/pflag v1.0.10
1315
github.com/spf13/viper v1.21.0
1416
gopkg.in/yaml.v3 v3.0.1
1517
)
@@ -25,7 +27,6 @@ require (
2527
github.com/charmbracelet/x/term v0.2.1 // indirect
2628
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
2729
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
28-
github.com/google/uuid v1.6.0 // indirect
2930
github.com/inconshreveable/mousetrap v1.1.0 // indirect
3031
github.com/kylelemons/godebug v1.1.0 // indirect
3132
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
@@ -47,7 +48,6 @@ require (
4748
github.com/sourcegraph/conc v0.3.1-0.20240121214520-5f936abd7ae8 // indirect
4849
github.com/spf13/afero v1.15.0 // indirect
4950
github.com/spf13/cast v1.10.0 // indirect
50-
github.com/spf13/pflag v1.0.10 // indirect
5151
github.com/subosito/gotenv v1.6.0 // indirect
5252
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
5353
go.yaml.in/yaml/v2 v2.4.2 // indirect

internal/bridge/events.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,12 @@ type BridgeConnectedData struct {
151151
// LogEntryData contains data for log.entry events
152152
type LogEntryData struct {
153153
ConversationID string `json:"conversation_id"`
154-
Level string `json:"level"` // "message", "error", "system"
154+
Level string `json:"level"` // "message", "error", "system"
155155
AgentID string `json:"agent_id,omitempty"`
156156
AgentName string `json:"agent_name,omitempty"`
157157
AgentType string `json:"agent_type,omitempty"`
158158
Content string `json:"content"`
159-
Role string `json:"role,omitempty"` // "assistant", "system", "user"
159+
Role string `json:"role,omitempty"` // "assistant", "system", "user"
160160
Metrics *LogEntryMetrics `json:"metrics,omitempty"`
161161
Metadata map[string]interface{} `json:"metadata,omitempty"` // Additional context
162162
}

internal/bridge/zerolog_json_writer.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010

1111
// ZerologJSONWriter is a zerolog writer that emits log entries as log.entry JSON events
1212
type ZerologJSONWriter struct {
13-
emitter *StdoutEmitter
14-
mu sync.Mutex
13+
emitter *StdoutEmitter
14+
mu sync.Mutex
1515
}
1616

1717
// NewZerologJSONWriter creates a new zerolog writer that emits JSON events
@@ -49,14 +49,14 @@ func (w *ZerologJSONWriter) Write(p []byte) (n int, err error) {
4949
defer w.mu.Unlock()
5050

5151
w.emitter.EmitLogEntry(
52-
level, // level (debug, info, warn, error, etc.)
53-
"", // agent_id (not applicable for system logs)
54-
"", // agent_name (not applicable for system logs)
55-
"", // agent_type (not applicable for system logs)
56-
message, // content
57-
"diagnostic", // role (use "diagnostic" to distinguish from agent messages)
58-
nil, // metrics
59-
metadata, // metadata (all other fields from zerolog)
52+
level, // level (debug, info, warn, error, etc.)
53+
"", // agent_id (not applicable for system logs)
54+
"", // agent_name (not applicable for system logs)
55+
"", // agent_type (not applicable for system logs)
56+
message, // content
57+
"diagnostic", // role (use "diagnostic" to distinguish from agent messages)
58+
nil, // metrics
59+
metadata, // metadata (all other fields from zerolog)
6060
)
6161

6262
return len(p), nil

internal/registry/agents.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
"package_manager": "npm",
3333
"package_name": "@anthropic-ai/claude-code",
3434
"install": {
35-
"darwin": "npm install -g @anthropic-ai/claude-cli",
36-
"linux": "npm install -g @anthropic-ai/claude-cli",
37-
"windows": "npm install -g @anthropic-ai/claude-cli"
35+
"darwin": "npm install -g @anthropic-ai/claude-code",
36+
"linux": "npm install -g @anthropic-ai/claude-code",
37+
"windows": "npm install -g @anthropic-ai/claude-code"
3838
},
3939
"uninstall": {
40-
"darwin": "npm uninstall -g @anthropic-ai/claude-cli",
41-
"linux": "npm uninstall -g @anthropic-ai/claude-cli",
42-
"windows": "npm uninstall -g @anthropic-ai/claude-cli"
40+
"darwin": "npm uninstall -g @anthropic-ai/claude-code",
41+
"linux": "npm uninstall -g @anthropic-ai/claude-code",
42+
"windows": "npm uninstall -g @anthropic-ai/claude-code"
4343
},
4444
"upgrade": {
45-
"darwin": "npm update -g @anthropic-ai/claude-cli",
46-
"linux": "npm update -g @anthropic-ai/claude-cli",
47-
"windows": "npm update -g @anthropic-ai/claude-cli"
45+
"darwin": "npm update -g @anthropic-ai/claude-code",
46+
"linux": "npm update -g @anthropic-ai/claude-code",
47+
"windows": "npm update -g @anthropic-ai/claude-code"
4848
},
4949
"requires_auth": true
5050
},

internal/registry/registry_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package registry
22

33
import (
44
"runtime"
5+
"strings"
56
"testing"
67
)
78

@@ -199,3 +200,48 @@ func TestOllamaDoesNotRequireAuth(t *testing.T) {
199200
t.Error("Ollama should not require authentication")
200201
}
201202
}
203+
204+
func TestClaudePackageNameConsistency(t *testing.T) {
205+
agent, err := GetByName("Claude")
206+
if err != nil {
207+
t.Fatalf("Failed to get Claude agent: %v", err)
208+
}
209+
210+
expectedPackage := "@anthropic-ai/claude-code"
211+
wrongPackage := "@anthropic-ai/claude-cli"
212+
213+
// Verify package_name field
214+
if agent.PackageName != expectedPackage {
215+
t.Errorf("Expected package_name '%s', got '%s'", expectedPackage, agent.PackageName)
216+
}
217+
218+
// Verify all install commands use the correct package
219+
verifyCommandMap(t, agent.Install, "Install", expectedPackage, wrongPackage)
220+
221+
// Verify all uninstall commands use the correct package
222+
verifyCommandMap(t, agent.Uninstall, "Uninstall", expectedPackage, "")
223+
224+
// Verify all upgrade commands use the correct package
225+
verifyCommandMap(t, agent.Upgrade, "Upgrade", expectedPackage, "")
226+
}
227+
228+
// verifyCommandMap checks that commands in a map contain the expected package
229+
func verifyCommandMap(t *testing.T, commands map[string]string, cmdType, expectedPkg, wrongPkg string) {
230+
t.Helper()
231+
for os, cmd := range commands {
232+
if shouldSkipCommand(cmd) {
233+
continue
234+
}
235+
if !strings.Contains(cmd, expectedPkg) {
236+
t.Errorf("%s command for %s doesn't contain expected package '%s': %s", cmdType, os, expectedPkg, cmd)
237+
}
238+
if wrongPkg != "" && strings.Contains(cmd, wrongPkg) {
239+
t.Errorf("%s command for %s contains incorrect package '%s': %s", cmdType, os, wrongPkg, cmd)
240+
}
241+
}
242+
}
243+
244+
// shouldSkipCommand returns true if the command should be skipped in verification
245+
func shouldSkipCommand(cmd string) bool {
246+
return cmd == "" || (len(cmd) >= 3 && cmd[:3] == "See")
247+
}

0 commit comments

Comments
 (0)