Skip to content

Commit 1c667a1

Browse files
author
Marvin Zhang
committed
Add initial Go collector scaffold, CLI, config, discovery, types, and tooling
- Create packages/collector-go module with Go CLI (cobra): start/status/version commands - Add configuration system (DefaultConfig, Load/Save, env var expansion, validation, GetBatchInterval) - Includes comprehensive unit tests (config tests, 100% coverage) - Implement log discovery & helper utilities (AgentLogLocations, globbing, FindLogFiles, GetLatestLogFile) - Includes unit tests for discovery and file heuristics (~85.5% watcher coverage) - Add core types for events (AgentEvent, EventMetrics, SessionInfo) and tests - Add developer tooling and build targets: - Makefile, build.sh (cross-platform builds), .air.toml (live reload), .golangci.yml (lint config) - .gitignore, go.mod, go.sum - Add package README with usage, dev and installation docs - Update project docs (GO_COLLECTOR_ROADMAP.md, README.md) to mark Phase 0 progress, completed tasks, and next steps This commit lays the foundation for the Go collector: project structure, config & discovery subsystems, types, tests, and local developer/build tooling.
1 parent 2b1a9bf commit 1c667a1

File tree

17 files changed

+1865
-52
lines changed

17 files changed

+1865
-52
lines changed

docs/dev/20250115-ai-agent-observability/GO_COLLECTOR_ROADMAP.md

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
**Priority**: HIGH - Foundation for production data collection
44
**Target**: Lightweight binary (~10-20MB) that runs on developer machines
5-
**Status**: Not Started (0%)
5+
**Status**: In Progress (20% - Days 1-4 Complete)
6+
7+
**Latest Achievement**: Configuration system and log discovery completed with 85%+ test coverage
68

79
## Phase 0: Project Setup (Days 1-2)
810

9-
### Day 1: Go Project Structure
10-
- [ ] Create `packages/collector-go/` directory
11-
- [ ] Initialize Go module: `go mod init github.com/codervisor/devlog/collector`
11+
### Day 1: Go Project Structure ✅ COMPLETE
12+
- [x] Create `packages/collector-go/` directory
13+
- [x] Initialize Go module: `go mod init github.com/codervisor/devlog/collector`
1214
- [ ] Set up project structure:
1315
```
1416
packages/collector-go/
@@ -27,39 +29,46 @@
2729
├── go.sum
2830
└── README.md
2931
```
30-
- [ ] Add initial dependencies:
32+
- [x] Add initial dependencies:
3133
- `github.com/fsnotify/fsnotify` (file watching)
3234
- `github.com/mattn/go-sqlite3` (local buffer)
3335
- `github.com/sirupsen/logrus` (logging)
34-
- [ ] Create basic `main.go` with CLI structure
35-
36-
### Day 2: Development Tooling
37-
- [ ] Set up cross-compilation script (darwin/linux/windows)
38-
- [ ] Create Makefile for common tasks (build, test, clean)
39-
- [ ] Add `.gitignore` for Go binaries
40-
- [ ] Set up GitHub Actions workflow for building binaries
41-
- [ ] Create initial README with build instructions
36+
- `github.com/spf13/cobra` (CLI framework)
37+
- [x] Create basic `main.go` with CLI structure
38+
39+
### Day 2: Development Tooling ✅ COMPLETE
40+
- [x] Set up cross-compilation script (darwin/linux/windows)
41+
- [x] Create Makefile for common tasks (build, test, clean)
42+
- [x] Add `.gitignore` for Go binaries
43+
- [x] Add `.air.toml` for live reload during development
44+
- [x] Add `.golangci.yml` for linting configuration
45+
- [ ] Set up GitHub Actions workflow for building binaries (deferred)
46+
- [x] Create initial README with build instructions
4247

4348
## Phase 1: Core Infrastructure (Days 3-7)
4449

45-
### Day 3: Configuration System
46-
- [ ] Create `internal/config/config.go`
47-
- [ ] Define config structure (matches design doc)
48-
- [ ] Implement config loading from `~/.devlog/collector.json`
49-
- [ ] Add environment variable expansion support
50-
- [ ] Implement config validation
51-
- [ ] Add default values
52-
- [ ] Write unit tests
53-
54-
### Day 4: Log Discovery
55-
- [ ] Create `internal/watcher/discovery.go`
56-
- [ ] Implement OS-specific log path detection:
57-
- [ ] GitHub Copilot paths (darwin/linux/windows)
58-
- [ ] Claude Code paths
59-
- [ ] Cursor paths
60-
- [ ] Add glob pattern matching for version wildcards
61-
- [ ] Implement path expansion (home dir, env vars)
62-
- [ ] Write tests for each OS (mock filesystem)
50+
### Day 3: Configuration System ✅ COMPLETE
51+
- [x] Create `internal/config/config.go`
52+
- [x] Define config structure (matches design doc)
53+
- [x] Implement config loading from `~/.devlog/collector.json`
54+
- [x] Add environment variable expansion support (`${VAR}` syntax)
55+
- [x] Implement config validation
56+
- [x] Add default values
57+
- [x] Write unit tests (100% coverage)
58+
- [x] Integrate config system into main CLI
59+
60+
### Day 4: Log Discovery ✅ COMPLETE
61+
- [x] Create `internal/watcher/discovery.go`
62+
- [x] Implement OS-specific log path detection:
63+
- [x] GitHub Copilot paths (darwin/linux/windows)
64+
- [x] Claude Code paths
65+
- [x] Cursor paths
66+
- [x] Cline paths (bonus)
67+
- [x] Aider paths (bonus)
68+
- [x] Add glob pattern matching for version wildcards
69+
- [x] Implement path expansion (home dir, env vars)
70+
- [x] Write tests for each OS (85.5% coverage)
71+
- [x] Test discovery on real system (found Cursor logs)
6372

6473
### Day 5: File Watching
6574
- [ ] Create `internal/watcher/watcher.go`

docs/dev/20250115-ai-agent-observability/README.md

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Transform devlog into a comprehensive AI coding agent observability platform tha
2121

2222
## Current Progress by Phase
2323

24-
### Phase 0: Go Collector (Days 1-20) 🎯 **PRIORITY**
24+
### Phase 0: Go Collector (Days 1-20) 🎯 **IN PROGRESS**
2525
**Target**: Production-ready collector binary
26-
**Progress**: 0% (Not Started)
26+
**Progress**: 20% (Days 1-4 Complete)
2727
**Timeline**: 20 days (~4 weeks)
2828

2929
**Purpose**: Lightweight binary that runs on developer machines to capture AI agent logs in real-time.
@@ -36,7 +36,16 @@ Transform devlog into a comprehensive AI coding agent observability platform tha
3636
- Batching and compression for efficiency
3737
- NPM distribution for easy installation
3838

39-
**Status**: Ready to begin Day 1 setup
39+
**Status**: Days 1-4 completed, Day 5 in progress
40+
41+
**Completed**:
42+
- ✅ Project structure and Go module setup
43+
- ✅ CLI with Cobra (start/status/version commands)
44+
- ✅ Cross-platform build system (Makefile, build scripts)
45+
- ✅ Configuration system with validation and env var support
46+
- ✅ Log discovery for 5 agents (Copilot, Claude, Cursor, Cline, Aider)
47+
- ✅ Test coverage: config (100%), watcher (85.5%)
48+
- ✅ Binary builds successfully (~3MB)
4049

4150
📄 **Detailed Plan**: [GO_COLLECTOR_ROADMAP.md](./GO_COLLECTOR_ROADMAP.md)
4251

@@ -124,7 +133,7 @@ Transform devlog into a comprehensive AI coding agent observability platform tha
124133
| **Event Collection Rate** | >10K events/sec | Not measured | ⏸️ Pending |
125134
| **Query Performance** | <100ms P95 | Not measured | ⏸️ Pending |
126135
| **Storage Efficiency** | <1KB per event | Not measured | ⏸️ Pending |
127-
| **Collector Binary Size** | <20MB | Not built | ⏸️ Pending |
136+
| **Collector Binary Size** | <20MB | ~3MB | ✅ Excellent |
128137
| **Collector Memory Usage** | <50MB | Not measured | ⏸️ Pending |
129138

130139
---
@@ -193,18 +202,18 @@ After Go Collector Complete:
193202

194203
## Next Actions
195204

196-
### Immediate (Day 1)
197-
1. Create `packages/collector-go/` directory structure
198-
2. Initialize Go module
199-
3. Set up basic CLI skeleton
200-
4. Configure cross-compilation
205+
### Completed (Days 1-4)
206+
1. ✅ Created `packages/collector-go/` directory structure
207+
2. ✅ Initialized Go module with dependencies
208+
3. ✅ Set up CLI with Cobra framework
209+
4. ✅ Configured cross-compilation (Makefile + scripts)
210+
5. ✅ Implemented configuration system
211+
6. ✅ Built log discovery mechanism
201212

202-
### This Week (Days 1-7)
203-
1. Complete project setup
204-
2. Implement configuration system
205-
3. Build log discovery mechanism
206-
4. Create file watcher
207-
5. Implement SQLite buffer
213+
### Next (Days 5-7)
214+
1. Implement file watcher with fsnotify
215+
2. Implement SQLite buffer
216+
3. Test offline mode behavior
208217

209218
### This Month (Days 1-20)
210219
1. Complete Go collector with all adapters
@@ -230,12 +239,12 @@ After Go Collector Complete:
230239

231240
### Phase 0 (Go Collector)
232241
- [x] Binary builds on all platforms (mac/linux/windows)
233-
- [x] Binary size < 20MB
234-
- [x] Memory usage < 50MB during operation
235-
- [x] Processes > 1K events/sec
236-
- [x] Works offline, syncs when online
237-
- [x] NPM package installs successfully
238-
- [x] At least 2 agent adapters working (Copilot, Claude)
242+
- [x] Binary size < 20MB (~3MB achieved)
243+
- [ ] Memory usage < 50MB during operation
244+
- [ ] Processes > 1K events/sec
245+
- [ ] Works offline, syncs when online
246+
- [ ] NPM package installs successfully
247+
- [ ] At least 2 agent adapters working (Copilot, Claude)
239248

240249
### Overall Project
241250
- [ ] Event collection rate > 10K events/sec
@@ -257,4 +266,6 @@ After Go Collector Complete:
257266
---
258267

259268
**Last Updated**: October 21, 2025
269+
**Latest Progress**: Days 1-4 completed (20% of Phase 0)
270+
**Next Milestone**: Complete Days 5-7 (file watching + buffer)
260271
**Next Review**: After Phase 0 completion

packages/collector-go/.air.toml

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

packages/collector-go/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Binaries
2+
/bin/
3+
/dist/
4+
devlog-collector
5+
devlog-collector-*
6+
*.exe
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool
15+
*.out
16+
coverage.txt
17+
18+
# Dependency directories
19+
vendor/
20+
21+
# Go workspace file
22+
go.work
23+
24+
# IDEs
25+
.idea/
26+
.vscode/
27+
*.swp
28+
*.swo
29+
*~
30+
31+
# OS files
32+
.DS_Store
33+
Thumbs.db
34+
35+
# Local config and data
36+
*.db
37+
*.sqlite
38+
*.sqlite3
39+
collector.json
40+
.env
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# golangci-lint configuration
2+
# https://golangci-lint.run/usage/configuration/
3+
4+
run:
5+
timeout: 5m
6+
tests: true
7+
build-tags: []
8+
skip-dirs:
9+
- vendor
10+
- testdata
11+
skip-files: []
12+
13+
linters:
14+
enable:
15+
- errcheck
16+
- gosimple
17+
- govet
18+
- ineffassign
19+
- staticcheck
20+
- typecheck
21+
- unused
22+
- gofmt
23+
- goimports
24+
- misspell
25+
- revive
26+
- gosec
27+
- goconst
28+
- unconvert
29+
30+
linters-settings:
31+
errcheck:
32+
check-type-assertions: true
33+
check-blank: true
34+
35+
govet:
36+
check-shadowing: true
37+
38+
revive:
39+
rules:
40+
- name: var-naming
41+
severity: warning
42+
- name: exported
43+
severity: warning
44+
45+
goimports:
46+
local-prefixes: github.com/codervisor/devlog/collector
47+
48+
issues:
49+
exclude-use-default: false
50+
max-issues-per-linter: 0
51+
max-same-issues: 0

0 commit comments

Comments
 (0)