2.7 KiB
2.7 KiB
Complete Implementation Plan for Onyx Phase 1
Milestone 0: Foundation and Core Abstractions
Project Structure Setup
-
Create directory structure
onyx/ ├── cmd/ │ ├── onx/ # CLI entry point │ └── onxd/ # Daemon entry point ├── internal/ │ ├── core/ # Core abstractions │ ├── git/ # Git interaction layer │ ├── models/ # Data models │ ├── storage/ # .onx directory management │ ├── commands/ # CLI command implementations │ ├── daemon/ # Daemon implementation │ └── utils/ # Utilities ├── pkg/ # Public APIs (if needed) ├── test/ # Integration tests ├── docs/ # Documentation └── scripts/ # Build/deployment scripts
-
Set up dependency management
go get github.com/go-git/go-git/v5@latest go get github.com/spf13/cobra@latest go get github.com/fsnotify/fsnotify@latest
-
Create Makefile
# Makefile .PHONY: build test clean install build: go build -o bin/onx ./cmd/onx go build -o bin/onxd ./cmd/onxd test: go test -v ./... install: go install ./cmd/onx go install ./cmd/onxd clean: rm -rf bin/
Core Abstractions Implementation
-
Define core interfaces (
internal/core/interfaces.go
)type Repository interface { Init(path string) error GetGitRepo() *git.Repository GetOnyxMetadata() *OnyxMetadata } type GitBackend interface { CreateCommit(tree, parent, message string) (string, error) CreateTree(entries []TreeEntry) (string, error) UpdateRef(name, sha string) error GetRef(name string) (string, error) }
-
Implement Repository struct (
internal/core/repository.go
)- Fields: gitRepo (*git.Repository), onyxPath (string), gitPath (string)
- Methods: Open(), Close(), IsOnyxRepo()
- Error handling for missing .git or .onx directories
-
Implement Git object operations (
internal/git/objects.go
)CreateBlob(content []byte) (string, error)
CreateTree(entries []TreeEntry) (string, error)
CreateCommit(tree, parent, message, author string) (string, error)
GetObject(sha string) (Object, error)
-
Create data models (
internal/models/
)oplog.go
: OplogEntry struct with serializationworkstream.go
: Workstream, WorkstreamCommit structsworkspace.go
: WorkspaceState struct