Skip to content

Commit ed6a46c

Browse files
committed
Implement various tools for file manipulation and command execution
- Add BashTool for executing bash commands in a specified directory. - Introduce EditTool for modifying file contents based on specified edits. - Create GlobTool for matching files using glob patterns. - Implement GrepTool for searching text patterns in files with regex support. - Add ListTool for listing files and directories with size and type information. - Introduce ReadTool for reading file contents. - Create WriteTool for writing content to files, ensuring directories are created if they don't exist. - Develop a TUI (Text User Interface) for interacting with the tools, including message handling and rendering. - Implement a registry for managing tool instances and their execution. - Add tests for ReadTool and WriteTool to ensure functionality and error handling.
0 parents  commit ed6a46c

Some content is hidden

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

62 files changed

+10808
-0
lines changed

.air.toml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Air configuration for live reload during development
2+
3+
root = "."
4+
testdata_dir = "testdata"
5+
tmp_dir = "tmp"
6+
7+
[build]
8+
args_bin = []
9+
bin = "./tmp/gocode"
10+
cmd = "go build -o ./tmp/gocode ./cmd/gocode"
11+
delay = 1000
12+
exclude_dir = ["assets", "tmp", "vendor", "testdata", "docs"]
13+
exclude_file = []
14+
exclude_regex = ["_test.go"]
15+
exclude_unchanged = false
16+
follow_symlink = false
17+
full_bin = ""
18+
include_dir = []
19+
include_ext = ["go", "tpl", "tmpl", "html", "yaml", "yml"]
20+
include_file = []
21+
kill_delay = "0s"
22+
log = "build-errors.log"
23+
poll = false
24+
poll_interval = 0
25+
rerun = false
26+
rerun_delay = 500
27+
send_interrupt = false
28+
stop_on_error = false
29+
30+
[color]
31+
app = ""
32+
build = "yellow"
33+
main = "magenta"
34+
runner = "green"
35+
watcher = "cyan"
36+
37+
[log]
38+
main_only = false
39+
time = false
40+
41+
[misc]
42+
clean_on_exit = false
43+
44+
[screen]
45+
clear_on_rebuild = false
46+
keep_scroll = true

.dockerignore

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Binaries
2+
gocode
3+
*.exe
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test files
9+
*.test
10+
*.out
11+
coverage.out
12+
coverage.html
13+
14+
# Go workspace
15+
vendor/
16+
.env
17+
.envrc
18+
19+
# IDE
20+
.vscode/
21+
.idea/
22+
*.swp
23+
*.swo
24+
*~
25+
26+
# OS
27+
.DS_Store
28+
Thumbs.db
29+
30+
# Git
31+
.git/
32+
.gitignore
33+
34+
# Docker
35+
Dockerfile*
36+
docker-compose*.yml
37+
.dockerignore
38+
39+
# Documentation (not needed in runtime)
40+
docs/
41+
*.md
42+
LICENSE
43+
44+
# CI/CD
45+
.github/
46+
47+
# Temp files
48+
tmp/
49+
temp/
50+
*.tmp
51+
52+
# Config (use mounted volumes instead)
53+
.gocode/
54+
gocode.yaml

.github/workflows/ci.yml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, dev ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
env:
11+
GO_VERSION: '1.25.4'
12+
REGISTRY: ghcr.io
13+
IMAGE_NAME: ${{ github.repository }}
14+
15+
jobs:
16+
test:
17+
name: Test
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version: ${{ env.GO_VERSION }}
28+
cache: true
29+
30+
- name: Download dependencies
31+
run: go mod download
32+
33+
- name: Run tests
34+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/codecov-action@v4
38+
with:
39+
file: ./coverage.out
40+
flags: unittests
41+
name: codecov-gocode
42+
43+
- name: Run golangci-lint
44+
uses: golangci/golangci-lint-action@v4
45+
with:
46+
version: latest
47+
args: --timeout=5m
48+
49+
build:
50+
name: Build
51+
runs-on: ubuntu-latest
52+
needs: test
53+
54+
steps:
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Set up Go
59+
uses: actions/setup-go@v5
60+
with:
61+
go-version: ${{ env.GO_VERSION }}
62+
cache: true
63+
64+
- name: Build binary
65+
run: |
66+
go build -v -o gocode ./cmd/gocode
67+
./gocode version
68+
69+
- name: Upload artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: gocode-binary
73+
path: gocode
74+
retention-days: 7
75+
76+
docker:
77+
name: Build Docker Image
78+
runs-on: ubuntu-latest
79+
needs: test
80+
permissions:
81+
contents: read
82+
packages: write
83+
84+
steps:
85+
- name: Checkout code
86+
uses: actions/checkout@v4
87+
88+
- name: Set up QEMU
89+
uses: docker/setup-qemu-action@v3
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
94+
- name: Log in to Container Registry
95+
if: github.event_name != 'pull_request'
96+
uses: docker/login-action@v3
97+
with:
98+
registry: ${{ env.REGISTRY }}
99+
username: ${{ github.actor }}
100+
password: ${{ secrets.GITHUB_TOKEN }}
101+
102+
- name: Extract metadata
103+
id: meta
104+
uses: docker/metadata-action@v5
105+
with:
106+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
107+
tags: |
108+
type=ref,event=branch
109+
type=ref,event=pr
110+
type=semver,pattern={{version}}
111+
type=semver,pattern={{major}}.{{minor}}
112+
type=raw,value=latest,enable={{is_default_branch}}
113+
114+
- name: Build and push Docker image
115+
uses: docker/build-push-action@v5
116+
with:
117+
context: .
118+
platforms: linux/amd64,linux/arm64
119+
push: ${{ github.event_name != 'pull_request' }}
120+
tags: ${{ steps.meta.outputs.tags }}
121+
labels: ${{ steps.meta.outputs.labels }}
122+
cache-from: type=gha
123+
cache-to: type=gha,mode=max
124+
125+
integration-test:
126+
name: Integration Tests
127+
runs-on: ubuntu-latest
128+
needs: docker
129+
if: github.event_name != 'pull_request'
130+
131+
services:
132+
ollama:
133+
image: ollama/ollama:latest
134+
ports:
135+
- 11434:11434
136+
137+
steps:
138+
- name: Checkout code
139+
uses: actions/checkout@v4
140+
141+
- name: Set up Go
142+
uses: actions/setup-go@v5
143+
with:
144+
go-version: ${{ env.GO_VERSION }}
145+
146+
- name: Wait for Ollama
147+
run: |
148+
timeout 60 bash -c 'until curl -f http://localhost:11434/api/tags; do sleep 2; done'
149+
150+
- name: Pull Ollama model
151+
run: |
152+
curl -X POST http://localhost:11434/api/pull -d '{"name":"llama3.2"}'
153+
sleep 10
154+
155+
- name: Run integration tests
156+
env:
157+
OLLAMA_HOST: http://localhost:11434
158+
run: go test -v -tags=integration ./...
159+
160+
release:
161+
name: Release
162+
runs-on: ubuntu-latest
163+
needs: [test, build, docker]
164+
if: startsWith(github.ref, 'refs/tags/v')
165+
permissions:
166+
contents: write
167+
168+
steps:
169+
- name: Checkout code
170+
uses: actions/checkout@v4
171+
with:
172+
fetch-depth: 0
173+
174+
- name: Set up Go
175+
uses: actions/setup-go@v5
176+
with:
177+
go-version: ${{ env.GO_VERSION }}
178+
179+
- name: Run GoReleaser
180+
uses: goreleaser/goreleaser-action@v5
181+
with:
182+
distribution: goreleaser
183+
version: latest
184+
args: release --clean
185+
env:
186+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Binaries
2+
*.exe
3+
*.dll
4+
*.so
5+
*.dylib
6+
gocode
7+
dist/
8+
build/
9+
10+
# Test binary
11+
*.test
12+
*.out
13+
14+
# Go workspace file
15+
go.work
16+
go.work.sum
17+
18+
# Dependency directories
19+
vendor/
20+
21+
# IDE
22+
.vscode/
23+
.idea/
24+
*.swp
25+
*.swo
26+
*~
27+
28+
# OS
29+
.DS_Store
30+
Thumbs.db
31+
32+
# Local config
33+
.gocode/
34+
.env
35+
*.local
36+
37+
# Logs
38+
logs/
39+
*.log
40+
41+
# Build artifacts
42+
bin/
43+
tmp/

0 commit comments

Comments
 (0)