Skip to content

Commit 3e0f713

Browse files
author
Marvin Zhang
committed
feat: Migrate Devlog from Go to Rust
- Changed the implementation language from Go to Rust, updating the README to reflect this change. - Updated dependencies in Cargo.toml files for various modules. - Implemented the Cursor adapter for log parsing and added tests for it. - Enhanced the BackfillManager to support directory scanning and batch processing of log files. - Added integration tests for the CLI server to ensure health checks and event ingestion work correctly. - Updated configuration structures to include backfill settings. - Completed migration tasks and updated project status in documentation.
1 parent 0abd64a commit 3e0f713

File tree

15 files changed

+767
-189
lines changed

15 files changed

+767
-189
lines changed

CONTRIBUTING.md

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
# Contributing to Devlog
22

3-
A Go-based AI agent event collector. This document explains the project structure and development workflow.
3+
A Rust-based AI agent event collector. This document explains the project structure and development workflow.
44

55
## Project Structure
66

77
```
88
devlog/
9-
├── cmd/
10-
│ └── devlog/ # CLI entry point (Cobra)
11-
├── internal/
12-
│ ├── adapters/ # Agent-specific log parsers
13-
│ ├── backfill/ # Historical log processing
14-
│ ├── buffer/ # SQLite offline event buffer
15-
│ ├── client/ # HTTP client for remote endpoints
16-
│ ├── config/ # Configuration management
17-
│ ├── hierarchy/ # Workspace/project resolution
18-
│ ├── integration/ # Integration tests
19-
│ └── watcher/ # File system watching
20-
├── pkg/
21-
│ ├── models/ # Data models
22-
│ └── types/ # Event types and constants
9+
├── rust/
10+
│ ├── devlog-cli/ # CLI entry point (clap)
11+
│ ├── devlog-adapters/ # Agent-specific log parsers
12+
│ ├── devlog-backfill/ # Historical log processing
13+
│ ├── devlog-buffer/ # SQLite offline event buffer
14+
│ ├── devlog-core/ # Shared types and config
15+
│ ├── devlog-hierarchy/ # Workspace/project resolution
16+
│ └── devlog-watcher/ # File system watching with notify
17+
├── cmd/ # Legacy Go CLI (deprecated)
18+
├── internal/ # Legacy Go internal packages (deprecated)
2319
├── configs/ # Default configuration files
2420
├── docs/ # Documentation
2521
└── specs/ # Feature specifications
@@ -29,7 +25,7 @@ devlog/
2925

3026
### Prerequisites
3127

32-
- Go 1.24+
28+
- Rust 1.75+
3329
- Make
3430

3531
### Initial Setup
@@ -39,9 +35,6 @@ devlog/
3935
git clone https://github.com/codervisor/devlog.git
4036
cd devlog
4137

42-
# Download dependencies
43-
make deps
44-
4538
# Build the binary
4639
make build
4740
```
@@ -50,63 +43,60 @@ make build
5043

5144
```bash
5245
make build # Build for current platform
53-
make build-all # Build for macOS, Linux, Windows (all architectures)
5446
make clean # Remove build artifacts
5547
make install # Install to /usr/local/bin
5648
```
5749

5850
### Development
5951

6052
```bash
61-
make dev # Run with live reload (requires air)
6253
make run # Build and run
6354
make fmt # Format code
64-
make lint # Run golangci-lint
55+
make lint # Run clippy
6556
```
6657

6758
### Testing
6859

6960
```bash
70-
make test # Run all tests with race detection
71-
make test-coverage # Generate HTML coverage report
61+
make test # Run all tests
7262
```
7363

7464
## Adding a New Agent Adapter
7565

7666
To add support for a new AI coding agent:
7767

78-
1. Create a new file in `internal/adapters/` (e.g., `myagent_adapter.go`)
79-
2. Implement the `AgentAdapter` interface:
68+
1. Create a new file in `rust/devlog-adapters/src/` (e.g., `myagent.rs`)
69+
2. Implement the `AgentAdapter` trait:
8070

81-
```go
82-
type AgentAdapter interface {
83-
Name() string
84-
ParseLogLine(line string) (*types.AgentEvent, error)
85-
ParseLogFile(filePath string) ([]*types.AgentEvent, error)
86-
SupportsFormat(sample string) bool
71+
```rust
72+
#[async_trait]
73+
pub trait AgentAdapter: Send + Sync {
74+
fn name(&self) -> &str;
75+
fn parse_log_line(&self, line: &str) -> Result<Option<AgentEvent>>;
76+
async fn parse_log_file(&self, file_path: &Path) -> Result<Vec<AgentEvent>>;
77+
fn supports_format(&self, sample: &str) -> bool;
8778
}
8879
```
8980

90-
3. Register in `internal/adapters/registry.go`
91-
4. Add log discovery paths in `internal/watcher/discovery.go`
92-
5. Add tests in `internal/adapters/myagent_adapter_test.go`
81+
3. Register in `rust/devlog-adapters/src/lib.rs` and `rust/devlog-cli/src/main.rs`
82+
4. Add tests in `rust/devlog-adapters/src/myagent.rs`
9383

9484
## Code Style
9585

96-
- Follow standard Go conventions
86+
- Follow standard Rust conventions
9787
- Use `make fmt` before committing
9888
- Use `make lint` to check for issues
9989
- Add tests for new functionality
100-
- Keep functions focused and well-documented
10190

10291
## Architecture Decisions
10392

104-
### Why Go?
93+
### Why Rust?
10594

106-
- Single static binary - no runtime dependencies
107-
- Low memory footprint for always-on daemon
108-
- Excellent file watching and concurrent I/O
109-
- Cross-platform support (macOS, Linux, Windows)
95+
- Memory safety without garbage collection
96+
- Zero-cost abstractions
97+
- Excellent performance for parsing and I/O
98+
- Strong type system with Result/Option
99+
- Single static binary
110100

111101
### Design Principles
112102

@@ -118,7 +108,7 @@ type AgentAdapter interface {
118108
## Pull Request Guidelines
119109

120110
1. Fork the repository
121-
2. Create a feature branch from `develop`
111+
2. Create a feature branch
122112
3. Make your changes with tests
123113
4. Run `make test` and `make lint`
124114
5. Submit a PR with a clear description

Makefile

Lines changed: 18 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22

33
# Binary name
44
BINARY_NAME=devlog
5-
VERSION?=1.0.0
5+
VERSION?=0.1.0
66
BUILD_DIR=bin
7-
8-
# Go parameters
9-
GOCMD=go
10-
GOBUILD=$(GOCMD) build
11-
GOCLEAN=$(GOCMD) clean
12-
GOTEST=$(GOCMD) test
13-
GOGET=$(GOCMD) get
14-
GOMOD=$(GOCMD) mod
15-
16-
# Build flags
17-
LDFLAGS=-ldflags "-X main.version=$(VERSION) -s -w"
7+
RUST_DIR=rust
188

199
# Default target
2010
all: clean build
@@ -23,53 +13,31 @@ all: clean build
2313
build:
2414
@echo "Building $(BINARY_NAME) for current platform..."
2515
@mkdir -p $(BUILD_DIR)
26-
$(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/devlog
16+
cd $(RUST_DIR) && cargo build --release
17+
cp $(RUST_DIR)/target/release/devlog-cli $(BUILD_DIR)/$(BINARY_NAME)
2718

28-
# Build for all platforms
19+
# Build for all platforms (requires cross-compilation setup)
2920
build-all: clean
3021
@echo "Building for all platforms..."
3122
@mkdir -p $(BUILD_DIR)
3223

33-
@echo "Building for macOS (Intel)..."
34-
GOOS=darwin GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 ./cmd/devlog
35-
36-
@echo "Building for macOS (Apple Silicon)..."
37-
GOOS=darwin GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/devlog
38-
39-
@echo "Building for Linux (amd64)..."
40-
GOOS=linux GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/devlog
41-
42-
@echo "Building for Linux (arm64)..."
43-
GOOS=linux GOARCH=arm64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-linux-arm64 ./cmd/devlog
24+
@echo "Building for current platform..."
25+
cd $(RUST_DIR) && cargo build --release
26+
cp $(RUST_DIR)/target/release/devlog-cli $(BUILD_DIR)/$(BINARY_NAME)
4427

45-
@echo "Building for Windows (amd64)..."
46-
GOOS=windows GOARCH=amd64 $(GOBUILD) $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe ./cmd/devlog
47-
48-
@echo "Build complete! Binaries in $(BUILD_DIR)/"
28+
@echo "Build complete! Binary in $(BUILD_DIR)/"
4929
@ls -lh $(BUILD_DIR)/
5030

5131
# Clean build artifacts
5232
clean:
5333
@echo "Cleaning..."
54-
@$(GOCLEAN)
34+
cd $(RUST_DIR) && cargo clean
5535
@rm -rf $(BUILD_DIR)
5636

5737
# Run tests
5838
test:
5939
@echo "Running tests..."
60-
$(GOTEST) -v -race -coverprofile=coverage.txt -covermode=atomic ./...
61-
62-
# Run tests with coverage report
63-
test-coverage: test
64-
@echo "Generating coverage report..."
65-
@go tool cover -html=coverage.txt -o coverage.html
66-
@echo "Coverage report: coverage.html"
67-
68-
# Download dependencies
69-
deps:
70-
@echo "Downloading dependencies..."
71-
$(GOMOD) download
72-
$(GOMOD) tidy
40+
cd $(RUST_DIR) && cargo test
7341

7442
# Install binary to system
7543
install: build
@@ -78,31 +46,19 @@ install: build
7846
@echo "Installed to /usr/local/bin/$(BINARY_NAME)"
7947

8048
# Run the collector (development)
81-
run: build
49+
run:
8250
@echo "Running $(BINARY_NAME)..."
83-
@$(BUILD_DIR)/$(BINARY_NAME) start
84-
85-
# Run with live reload (requires air: go install github.com/cosmtrek/air@latest)
86-
dev:
87-
@if command -v air > /dev/null; then \
88-
air; \
89-
else \
90-
echo "Error: 'air' not found. Install with: go install github.com/cosmtrek/air@latest"; \
91-
exit 1; \
92-
fi
51+
cd $(RUST_DIR) && cargo run -- start
9352

9453
# Format code
9554
fmt:
9655
@echo "Formatting code..."
97-
@go fmt ./...
56+
cd $(RUST_DIR) && cargo fmt
9857

99-
# Lint code (requires golangci-lint)
58+
# Lint code
10059
lint:
101-
@if command -v golangci-lint > /dev/null; then \
102-
golangci-lint run; \
103-
else \
104-
echo "Warning: golangci-lint not found. Install from https://golangci-lint.run/"; \
105-
fi
60+
@echo "Linting code..."
61+
cd $(RUST_DIR) && cargo clippy -- -D warnings
10662

10763
# Show help
10864
help:
@@ -112,11 +68,8 @@ help:
11268
@echo " make build-all - Build for all platforms"
11369
@echo " make clean - Remove build artifacts"
11470
@echo " make test - Run tests"
115-
@echo " make test-coverage - Run tests with coverage report"
116-
@echo " make deps - Download dependencies"
11771
@echo " make install - Install to /usr/local/bin"
11872
@echo " make run - Build and run"
119-
@echo " make dev - Run with live reload (requires air)"
12073
@echo " make fmt - Format code"
121-
@echo " make lint - Lint code (requires golangci-lint)"
74+
@echo " make lint - Lint code"
12275
@echo " make help - Show this help"

0 commit comments

Comments
 (0)