# Complete Implementation Plan for Onyx Phase 1 ## Milestone 0: Foundation and Core Abstractions ### Project Structure Setup 6. **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 ``` 7. **Set up dependency management** ```bash go get github.com/go-git/go-git/v5@latest go get github.com/spf13/cobra@latest go get github.com/fsnotify/fsnotify@latest ``` 8. **Create Makefile** ```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 9. **Define core interfaces** (`internal/core/interfaces.go`) ```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) } ``` 10. **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 11. **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)` 12. **Create data models** (`internal/models/`) - `oplog.go`: OplogEntry struct with serialization - `workstream.go`: Workstream, WorkstreamCommit structs - `workspace.go`: WorkspaceState struct