Skip to content

Commit 20eea71

Browse files
authored
Merge pull request #69 from zhujian0805/worktree-go-rewrite
Rewrite CLI in Go
2 parents 84112ee + 013e7ee commit 20eea71

94 files changed

Lines changed: 1881 additions & 903 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Example environment variables for code-assistant-manager
1+
# Example environment variables for code-agent-manager
22
# Copy this file to .env and fill in your secrets. Do NOT commit .env with real keys.
33
# Example:
44
# API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
# Flake8 configuration for code-assistant-manager
2+
# Flake8 configuration for code-agent-manager
33

44
# Compatibility with Black
55
max-line-length = 100

.specify/memory/constitution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ After any code changes, reinstall the project using the standard sequence:
4141
rm -rf dist/*
4242
./install.sh uninstall
4343
./install.sh
44-
cp ~/.config/code-assistant-manager/providers.json.bak ~/.config/code-assistant-manager/providers.json
44+
cp ~/.config/code-agent-manager/providers.json.bak ~/.config/code-agent-manager/providers.json
4545
```
4646

4747
### Quality Gates

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ This file documents repository-level expectations and instructions intended to g
1212
rm -rf dist/*
1313
./install.sh uninstall
1414
./install.sh
15-
cp ~/.config/code-assistant-manager/providers.json.bak ~/.config/code-assistant-manager/providers.json
15+
cp ~/.config/code-agent-manager/providers.json.bak ~/.config/code-agent-manager/providers.json
1616
```

Makefile

Lines changed: 31 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,51 @@
1-
.PHONY: help install dev-install clean test lint format type-check security check pre-commit-install pre-commit-run build release
1+
.PHONY: help install clean test test-race build release fmt vet check
2+
3+
VERSION ?= dev
4+
GOFLAGS ?=
25

3-
# Default target
46
help:
57
@echo "Available commands:"
6-
@echo " make install - Install package for production use"
7-
@echo " make dev-install - Install package with development dependencies"
8-
@echo " make clean - Remove build artifacts and caches"
9-
@echo " make test - Run test suite"
10-
@echo " make test-cov - Run tests with coverage (HTML + terminal)"
11-
@echo " make test-cov-xml - Run tests with coverage (HTML + terminal + XML)"
12-
@echo " make test-comprehensive - Run comprehensive tests with full coverage"
13-
@echo " make test-coverage-summary - Show coverage summary report"
14-
@echo " make lint - Run linting (flake8)"
15-
@echo " make format - Format code (black, isort)"
16-
@echo " make type-check - Run type checking (mypy)"
17-
@echo " make security - Run security checks (bandit)"
18-
@echo " make check - Run all quality checks (lint, type-check, test)"
19-
@echo " make pre-commit-install - Install pre-commit hooks"
20-
@echo " make pre-commit-run - Run pre-commit on all files"
21-
@echo " make build - Build distribution packages"
22-
@echo " make release - Full release workflow (clean, test, build)"
8+
@echo " make build - Build Go binaries into dist/"
9+
@echo " make install - Build and install cam/code-agent-manager"
10+
@echo " make test - Run Go test suite"
11+
@echo " make test-race - Run Go tests with race detector"
12+
@echo " make fmt - Format Go code"
13+
@echo " make vet - Run go vet"
14+
@echo " make check - Run fmt check, vet, tests, and install smoke test"
15+
@echo " make clean - Remove build artifacts"
2316

24-
# Installation
2517
install:
26-
pip install -e .
27-
28-
dev-install:
29-
pip install -e ".[dev]"
30-
$(MAKE) pre-commit-install
18+
VERSION=$(VERSION) ./install.sh install
3119

32-
# Cleaning
3320
clean:
34-
rm -rf build/
3521
rm -rf dist/
36-
rm -rf *.egg-info
37-
rm -rf .pytest_cache/
38-
rm -rf .mypy_cache/
39-
rm -rf .tox/
40-
rm -rf htmlcov/
41-
rm -rf .coverage
42-
find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
43-
find . -type f -name "*.pyc" -delete
44-
find . -type f -name "*.pyo" -delete
45-
find . -type f -name "*.orig" -delete
46-
47-
# Testing
48-
test:
49-
pytest tests/ -v
50-
51-
test-cov:
52-
pytest tests/ -v --cov=code_assistant_manager --cov-report=html --cov-report=term
53-
54-
test-cov-xml:
55-
pytest tests/ -v --cov=code_assistant_manager --cov-report=html --cov-report=term --cov-report=xml
56-
57-
test-comprehensive:
58-
pytest tests/ -v --cov=code_assistant_manager --cov-report=html --cov-report=term --cov-report=xml --tb=short --maxfail=5
59-
60-
test-coverage-summary:
61-
python -m coverage report --include="code_assistant_manager/*" --omit="tests/*" --sort=cover
22+
find . -type f -name "*.test" -delete
23+
find . -type f -name "coverage.out" -delete
6224

63-
# Code quality
64-
lint:
65-
@echo "Running flake8..."
66-
flake8 code_assistant_manager/
25+
build:
26+
mkdir -p dist
27+
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/cam ./cmd/cam
28+
go build $(GOFLAGS) -ldflags "-X main.version=$(VERSION)" -o dist/code-agent-manager ./cmd/code-agent-manager
6729

68-
format:
69-
@echo "Running isort..."
70-
isort code_assistant_manager/ tests/
71-
@echo "Running black..."
72-
black code_assistant_manager/ tests/
30+
test:
31+
go test $(GOFLAGS) ./...
7332

74-
format-check:
75-
@echo "Checking isort..."
76-
isort --check-only code_assistant_manager/ tests/
77-
@echo "Checking black..."
78-
black --check code_assistant_manager/ tests/
33+
test-race:
34+
go test $(GOFLAGS) -race ./...
7935

80-
type-check:
81-
@echo "Running mypy..."
82-
mypy code_assistant_manager/
36+
fmt:
37+
gofmt -s -w cmd internal
8338

84-
security:
85-
@echo "Running bandit..."
86-
bandit -r code_assistant_manager/ -c pyproject.toml
39+
fmt-check:
40+
@test -z "$$(gofmt -s -l cmd internal)" || (gofmt -s -l cmd internal && exit 1)
8741

88-
docstring-check:
89-
@echo "Checking docstring coverage..."
90-
interrogate code_assistant_manager/ -c pyproject.toml
42+
vet:
43+
go vet ./...
9144

92-
# Combined checks
93-
check: format-check lint type-check test
45+
check: fmt-check vet test
46+
bash tests/verify_go_cli_install.sh
9447
@echo "All checks passed!"
9548

96-
# Pre-commit
97-
pre-commit-install:
98-
pre-commit install
99-
@echo "Pre-commit hooks installed successfully!"
100-
101-
pre-commit-run:
102-
pre-commit run --all-files
103-
104-
pre-commit-update:
105-
pre-commit autoupdate
106-
107-
# Building
108-
build: clean
109-
python3 setup.py bdist_wheel
110-
111-
# Release workflow
11249
release: clean check build
11350
@echo "Release build completed successfully!"
114-
@echo "Distribution files:"
11551
@ls -lh dist/
116-
117-
# Docker commands (future)
118-
docker-build:
119-
@echo "Docker build not yet implemented"
120-
121-
docker-run:
122-
@echo "Docker run not yet implemented"

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<div align="center">
44

55
[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
6-
[![Code Quality](https://img.shields.io/badge/code%20quality-A+-brightgreen.svg)](https://github.com/Chat2AnyLLM/code-assistant-manager/actions)
6+
[![Code Quality](https://img.shields.io/badge/code%20quality-A+-brightgreen.svg)](https://github.com/Chat2AnyLLM/code-agent-manager/actions)
77

88
**One CLI to Rule Them All.**
99
<br>
10-
Tired of juggling multiple AI coding assistants? **CAM** is a unified Python CLI to manage configurations, prompts, skills, and plugins for **17 AI assistants** including Claude, Codex, Gemini, Qwen, Copilot, Blackbox, Goose, Continue, and more from a single, polished terminal interface.
10+
Tired of juggling multiple AI coding assistants? **CAM** is a unified Go CLI to manage configurations, prompts, skills, plugins, MCP servers, and launch settings for **17 AI assistants** including Claude, Codex, Gemini, Qwen, Copilot, Blackbox, Goose, Continue, and more from a single terminal interface.
1111

1212
</div>
1313

@@ -17,12 +17,12 @@ Tired of juggling multiple AI coding assistants? **CAM** is a unified Python CLI
1717

1818
### Quick Install (Recommended)
1919

20-
Since CAM is not yet published to PyPI, install it locally:
20+
Since CAM is distributed from source, build and install the Go binaries locally:
2121

2222
```bash
2323
# Clone the repository
24-
git clone https://github.com/Chat2AnyLLM/code-assistant-manager.git
25-
cd code-assistant-manager
24+
git clone https://github.com/Chat2AnyLLM/code-agent-manager.git
25+
cd code-agent-manager
2626

2727
# Run the install script
2828
./install.sh
@@ -49,12 +49,13 @@ Or use pipx (Works on MacOS)
4949
./install.sh
5050

5151
# Or install from the web
52-
curl -fsSL https://raw.githubusercontent.com/Chat2AnyLLM/code-assistant-manager/main/install.sh | bash
52+
curl -fsSL https://raw.githubusercontent.com/Chat2AnyLLM/code-agent-manager/main/install.sh | bash
5353

5454
# Install from source directly
55-
git clone https://github.com/Chat2AnyLLM/code-assistant-manager.git
56-
cd code-assistant-manager
57-
pip install -e ".[dev]"
55+
git clone https://github.com/Chat2AnyLLM/code-agent-manager.git
56+
cd code-agent-manager
57+
go test ./...
58+
go build -o dist/cam ./cmd/cam
5859
```
5960

6061
---
@@ -63,8 +64,8 @@ pip install -e ".[dev]"
6364

6465
1. **Create your base config files**:
6566
```bash
66-
mkdir -p ~/.config/code-assistant-manager
67-
cp code_assistant_manager/providers.json ~/.config/code-assistant-manager/providers.json
67+
mkdir -p ~/.config/code-agent-manager
68+
cp providers.json.example ~/.config/code-agent-manager/providers.json
6869
touch ~/.env
6970
chmod 600 ~/.env
7071
```
@@ -93,17 +94,17 @@ pip install -e ".[dev]"
9394

9495
CAM uses these main configuration files:
9596

96-
- `~/.config/code-assistant-manager/providers.json`: endpoint/provider settings used by `cam`.
97+
- `~/.config/code-agent-manager/providers.json`: endpoint/provider settings used by `cam`.
9798
- `~/.env`: API keys and sensitive environment variables.
98-
- `~/.config/code-assistant-manager/config.yaml`: repository-source config for skills, agents, and plugins.
99+
- `~/.config/code-agent-manager/config.yaml`: repository-source config for skills, agents, and plugins.
99100

100101
### How `config.yaml` is used for skill/agent/plugin repos
101102

102-
- CAM loads `~/.config/code-assistant-manager/config.yaml` first; if missing, it falls back to bundled `code_assistant_manager/config.yaml`.
103+
- CAM loads `~/.config/code-agent-manager/config.yaml` first; if missing, it falls back to bundled `code_assistant_manager/config.yaml`.
103104
- The file defines source lists for `skills`, `agents`, and `plugins`.
104105
- Local JSON sources (`skill_repos.json`, `agent_repos.json`, `plugin_repos.json`) are loaded first.
105106
- Remote sources are merged after local sources and do not override existing local keys.
106-
- Remote responses are cached in `~/.cache/code-assistant-manager/repos` (TTL controlled by `config.yaml`).
107+
- Remote responses are cached in `~/.cache/code-agent-manager/repos` (TTL controlled by `config.yaml`).
107108

108109
---
109110

cmd/cam/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/chat2anyllm/code-agent-manager/internal/cli"
7+
)
8+
9+
var version = "dev"
10+
11+
func main() {
12+
app := cli.New(cli.Options{Version: version, Stdout: os.Stdout, Stderr: os.Stderr})
13+
os.Exit(app.Run(os.Args[1:]))
14+
}

cmd/cam/main_test.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main_test
2+
3+
import (
4+
"os/exec"
5+
"path/filepath"
6+
"runtime"
7+
"strings"
8+
"testing"
9+
)
10+
11+
func TestBuiltBinarySupportsBothExecutableNames(t *testing.T) {
12+
dir := t.TempDir()
13+
binary := filepath.Join(dir, "cam")
14+
if runtime.GOOS == "windows" {
15+
binary += ".exe"
16+
}
17+
18+
build := exec.Command("go", "build", "-o", binary, "./cmd/cam")
19+
build.Dir = "../.."
20+
if output, err := build.CombinedOutput(); err != nil {
21+
t.Fatalf("go build failed: %v\n%s", err, output)
22+
}
23+
24+
for _, args := range [][]string{{"--version"}, {"version"}, {"doctor", "--help"}, {"mcp", "--help"}} {
25+
run := exec.Command(binary, args...)
26+
run.Dir = "../.."
27+
output, err := run.CombinedOutput()
28+
if err != nil {
29+
t.Fatalf("cam %s failed: %v\n%s", strings.Join(args, " "), err, output)
30+
}
31+
if len(output) == 0 {
32+
t.Fatalf("cam %s produced no output", strings.Join(args, " "))
33+
}
34+
}
35+
36+
alias := filepath.Join(dir, "code-agent-manager")
37+
if runtime.GOOS == "windows" {
38+
alias += ".exe"
39+
}
40+
build = exec.Command("go", "build", "-o", alias, "./cmd/code-agent-manager")
41+
build.Dir = "../.."
42+
if output, err := build.CombinedOutput(); err != nil {
43+
t.Fatalf("go build alias failed: %v\n%s", err, output)
44+
}
45+
46+
run := exec.Command(alias, "--version")
47+
run.Dir = "../.."
48+
output, err := run.CombinedOutput()
49+
if err != nil {
50+
t.Fatalf("code-agent-manager --version failed: %v\n%s", err, output)
51+
}
52+
if !strings.Contains(string(output), "dev") {
53+
t.Fatalf("version output = %q, want dev", output)
54+
}
55+
}

cmd/code-agent-manager/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package main
2+
3+
import (
4+
"os"
5+
6+
"github.com/chat2anyllm/code-agent-manager/internal/cli"
7+
)
8+
9+
var version = "dev"
10+
11+
func main() {
12+
app := cli.New(cli.Options{Version: version, Stdout: os.Stdout, Stderr: os.Stderr})
13+
os.Exit(app.Run(os.Args[1:]))
14+
}

code_assistant_manager/agents/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def _download_repo(
307307
logger.debug(f"Trying to download: {url}")
308308

309309
try:
310-
req = Request(url, headers={"User-Agent": "code-assistant-manager"})
310+
req = Request(url, headers={"User-Agent": "code-agent-manager"})
311311
with urlopen(req, timeout=60) as response:
312312
zip_data = response.read()
313313

0 commit comments

Comments
 (0)