This project implements a Git client and server in Guile Scheme 3.0+, following the excellent โWrite Yourself a Git!โ tutorial. The implementation emphasizes functional programming patterns, experiment-driven development, and FreeBSD-specific optimizations.
The Guile Git server is now running in a tmux session and accepting connections!
# Server session: guile-git-server
# Port: 9418
# Status: RUNNING โ
# Connect to view logs:
tmux attach -t guile-git-server- [X] TCP server on port 9418 (
minimal-server-daemon.scm:45) - [X] Git protocol handshake (
src/core/pkt-line.scm:23) - [X] receive-pack command recognition (
minimal-server-storage.scm:67) - [X] Reference advertisement (
minimal-server-storage.scm:78) - [X] Basic push negotiation (
minimal-server-storage.scm:89) - [X] Plain text storage system (
src/storage/plain-text.scm:31) - [X] Push data persistence (
src/storage/plain-text.scm:45) - [X] AI-powered commit summaries (
plugins/woof-ai-summary.sh:87) - [X] Experiment-driven development structure (
experiments/) - [X] Comprehensive testing with โROOF ROOFโ methodology
- [X] tmux-based continuous dogfooding environment
- [ ] Pack file parsing (
src/core/pack.scm- planned) - [ ] Object decompression and storage (
src/core/objects.scm- partial) - [ ] Reference updates (
src/refs/- planned) - [ ] Full clone/fetch support
graph TB
subgraph "Core Layer - IMPLEMENTED"
PKT["Packet Line Protocol<br/>src/core/pkt-line.scm"]
SHA1["SHA-1 Hashing<br/>src/core/sha1-simple.scm"]
ZLIB["Zlib Compression<br/>src/core/zlib-simple.scm"]
end
subgraph "Storage Layer - IMPLEMENTED"
PLAIN["Plain Text Storage<br/>src/storage/plain-text.scm"]
DATA["Data Directory<br/>./data/pushes/"]
WOOFS["AI Analysis Storage<br/>./data/woofs/"]
end
subgraph "Server Layer - IMPLEMENTED"
LISTEN["TCP Listener<br/>minimal-server-daemon.scm:25"]
HANDLER["Push Handler<br/>minimal-server-storage.scm:67"]
STORAGE["Storage Engine<br/>src/storage/plain-text.scm:31"]
end
subgraph "Plugin System - IMPLEMENTED"
AI["Ollama Integration<br/>plugins/woof-ai-summary.sh"]
ANALYSIS["Changeset Analysis<br/>plugins/woof-analyzer.scm"]
end
subgraph "Development Infrastructure"
EXP["Experiments<br/>experiments/000-006/"]
TESTS["Test Suite<br/>tests/"]
DOCS["Documentation<br/>*.org, *.md"]
end
LISTEN --> HANDLER
HANDLER --> PKT
PKT --> STORAGE
STORAGE --> PLAIN
PLAIN --> DATA
HANDLER --> AI
AI --> WOOFS
SHA1 --> STORAGE
ZLIB --> STORAGE
sequenceDiagram
participant Client as Git Client
participant Server as Guile Git Server
participant Storage as Plain Text Storage
participant AI as Ollama AI
Note over Client,AI: Git Push Operation Flow
Client->>Server: TCP connect :9418
Server->>Server: Accept connection (daemon.scm:45)
Client->>Server: git-receive-pack /repo.git
Server->>Server: Parse request (storage.scm:67)
Server->>Server: Extract repo name (storage.scm:58)
Server->>Client: capabilities^{} (storage.scm:78)
Server->>Client: flush packet
Client->>Server: push commands + pack data
Server->>Storage: Store push data (plain-text.scm:45)
Storage->>Storage: Create timestamped file
Server->>Client: report-status success
Server->>Server: Log completion
Note over AI: Background AI Analysis (Optional)
Storage-->>AI: Trigger analysis
AI-->>AI: Generate dog-themed summary
AI-->>Storage: Save to woofs/
guile-git-scratch/
โโโ experiments/ # Experiment-driven development โ
โ โโโ 000-deps-check/ # Environment verification โ
โ โโโ 001-book-analysis/ # WYAG structure analysis โ
โ โโโ 002-git-repository-structure/ # .git exploration โ
โ โโโ 003-object-model-design/ # Core object design โ
โ โโโ 004-protocol-exploration/ # Git wire protocol โ
โ โโโ 005-server-implementation/ # TCP server basics โ
โ โโโ 006-guile-freebsd-segfault/ # Platform issue analysis โ
โโโ src/ # Main implementation โ
โ โโโ core/ # Core Git functionality
โ โ โโโ pkt-line.scm # Git packet protocol โ
โ โ โโโ sha1-simple.scm # SHA-1 hashing (shell-based) โ
โ โ โโโ zlib-simple.scm # Compression (gzip/gunzip) โ
โ โโโ storage/ # Storage systems
โ โโโ plain-text.scm # Plain text debugging storage โ
โโโ plugins/ # Plugin system โ
โ โโโ woof-ai-summary.sh # AI-powered commit summaries โ
โ โโโ woof-analyzer.scm # Guile integration wrapper
โ โโโ ollama-*.scm # Various AI plugins
โโโ data/ # Runtime data (git ignored) โ
โ โโโ pushes/ # Push operation logs โ
โ โโโ woofs/ # AI analysis results โ
โโโ tests/ # Test suite โ
โ โโโ test-pkt-line.scm # Protocol tests โ
โ โโโ test-storage.scm # Storage tests โ
โ โโโ run-tests.scm # Test runner โ
โโโ minimal-server-daemon.scm # Persistent server โ
โโโ minimal-server-storage.scm # Server with storage โ
โโโ start-dogfood-server.sh # tmux session manager โ
โโโ SAMPLE-SESSION.md # Development workflow demo โ
โโโ ROOF-ROOF-EXPERIMENT.md # Testing methodology โ
โโโ tmp/ # Reference materials
โโโ wyag.html
โโโ Git_in_Practice.pdf
- [X] Environment setup and verification
- [X] Book structure analysis
- [X] Object model design
- [ ] SHA-1 hashing implementation
- [ ] Zlib compression integration
- [ ] Basic repository operations (init)
- [ ] Object storage (hash-object)
- [ ] Object retrieval (cat-file)
- [ ] Commit object handling
- [ ] Log command implementation
- [ ] Tree parsing and manipulation
- [ ] Basic checkout functionality
- [ ] Reference management
- [ ] Tag support (lightweight and annotated)
- [ ] Branch operations
- [ ] Object name resolution (rev-parse)
- [ ] Index file format parsing
- [ ] Staging area operations (add, rm)
- [ ] Status command
- [ ] Commit creation from index
- [ ] Packfile support
- [ ] Network protocol basics
- [ ] Fetch operation
- [ ] Push operation
- [ ] Git server protocol
- [ ] receive-pack implementation
- [ ] upload-pack implementation
- [ ] Hook system
- [ ] kqueue integration for file watching
- [ ] Capsicum sandboxing
- [ ] Performance tuning
- [ ] Complete API documentation
- [ ] Usage examples
- [ ] Migration guide from Git
- [ ] Comprehensive test coverage
- [ ] Performance benchmarks
- [ ] Bug fixes and refinements
- [ ] API stability
- [ ] Full Git compatibility subset
- [ ] Production-ready documentation
All data structures are immutable by default, using SRFI-9 records and functional transformations.
Each major feature starts as an isolated experiment in the experiments/ directory, allowing for exploration and validation before integration.
Core modules are written using Org-mode with Babel, combining documentation and code for better understanding.
Leveraging FreeBSD-specific features like kqueue for efficient file monitoring and Capsicum for security.
| Command | Status | Description |
|---|---|---|
| init | Planned | Initialize repository |
| hash-object | Planned | Store object in database |
| cat-file | Planned | Display object contents |
| log | Planned | Show commit logs |
| ls-tree | Planned | List tree object |
| checkout | Planned | Switch branches |
| show-ref | Planned | List references |
| tag | Planned | Create tags |
| rev-parse | Planned | Parse revision names |
| ls-files | Planned | Show index contents |
| check-ignore | Planned | Check gitignore rules |
| status | Planned | Show working tree status |
| rm | Planned | Remove from index |
| add | Planned | Add to index |
| commit | Planned | Record changes |
See CONTRIBUTING.md for detailed development guidelines, coding standards, and contribution workflow.
This project practices extreme dogfooding with โROOF ROOFโ methodology - we use our own Git implementation as soon as possible, even with minimal functionality. This approach:
- Forces immediate practical validation
- Reveals real-world issues quickly
- Creates a tight feedback loop
- Demonstrates confidence in the implementation
- Makes testing enjoyable with dog-themed commits!
# Start the Guile Git server in persistent tmux session
./start-dogfood-server.sh
# โ Server started in tmux session: guile-git-server
# View real-time server logs
tmux attach -t guile-git-server
# (Press Ctrl-B then D to detach without stopping server)
# Add as remote to any git repo
git remote add dogfood git://localhost:9418/my-project.git
git push dogfood main
# Watch what gets stored
ls data/pushes/$(ls -t data/pushes/ | head -1) | cat
# ==> Push to my-project.git at 20250820-081142 ===
# Get AI analysis of your changes
./plugins/woof-ai-summary.sh latest
# ๐ Woof woof! The developer just pushed their changes...See ROOF-ROOF-EXPERIMENT.md for the complete testing methodology:
- Make It Fun: Dog-themed commits create emotional investment
- Make It Real: Use actual Git operations, not mocks
- Make It Visible: Plain text storage shows everything
- Make It Repeatable: Documented workflow for consistent testing
- [X] v0.0.1 - Server accepts connections (
minimal-server.scm) - [X] v0.0.2 - Basic push handshake works (
minimal-server-daemon.scm) - [X] v0.0.3 - Push data is received and stored (
minimal-server-storage.scm) - [X] v0.0.4 - AI-powered commit analysis works (
plugins/woof-ai-summary.sh) - [X] v0.0.5 - Continuous dogfooding environment (
start-dogfood-server.sh) - [ ] v0.1.0 - Pack file parsing and object storage
- [ ] v0.2.0 - Clone/fetch operations
- [ ] v1.0.0 - Self-hosting development (using our Git for our Git!)
Implements the Git wire protocol packet format:
(define (pkt-line-write socket data)
"Send a packet line with 4-byte hex length prefix")
(define (pkt-line-read socket)
"Read a packet line, handling flush packets")Plain text storage for maximum debuggability:
(define (store-push-data repo-name data)
"Store raw push data with timestamp for debugging")
(define (extract-repo-name line)
"Parse repository name from Git request")Main server with actual storage capabilities:
(define (handle-receive-pack socket)
"Handle git push operations with storage")
(define (handle-client-connection socket)
"Main request handling with repository parsing")Shell-based Ollama integration for commit analysis:
generate_ai_summary() {
# Calls qwen2.5-coder:7b for dog-themed commit summaries
curl -s -X POST "$OLLAMA_URL" -d "$json_payload"
}Documented segmentation fault in experiments/006-guile-freebsd-segfault/:
- Guile3 process spawning incompatible with FreeBSDโs
posix_spawn_file_actions_addclosefrom_np - Workaround: Use shell scripts for system integration
- Impact: No functionality lost, improved portability
# FreeBSD packages (required)
pkg install guile3 gmake tmux curl
# AI integration (optional)
pkg install ollama # or install from GitHub
# Development tools (optional)
pkg install emacs gdb # debugging and org-mode# Clone the repository
git clone https://github.com/dsp-dr/guile-git-scratch.git
cd guile-git-scratch
# Start the dogfood server (persistent tmux session)
./start-dogfood-server.sh
# In another terminal, test pushing
git remote add dogfood git://localhost:9418/guile-git-scratch.git
echo "๐ Testing our dogfood server!" > woof-test.txt
git add woof-test.txt && git commit -m "woof: testing dogfood server"
git push dogfood main
# Generate AI analysis of the push (requires ollama)
./plugins/woof-ai-summary.sh latest
# Output: ๐ AI WOOF ANALYSIS - dog-themed commit summary!
# Watch server logs and see stored data
tmux attach -t guile-git-server
ls data/pushes/ # See stored push attempts
ls data/woofs/ # See AI analyses# Run experiments
cd experiments
gmake list # See all experiments
gmake run EXP=000-deps-check # Run specific experiment
# Build main project
gmake build
# Run tests
gmake test
# Start server
gmake run-server # Port 9418
gmake test-server # Port 9419# Minimal server (working now!)
./minimal-server.scm
# Full server (in development)
./run-server.scm
# With custom port and repo path
./run-server.scm -p 9419 -r ./my-reposGet dog-themed summaries of your Git pushes using Ollama:
./plugins/woof-ai-summary.sh test
# ๐ TESTING WOOF AI ANALYSIS...
# ๐ AI WOOF ANALYSIS - 2025-08-20 08:15:21
# Woof woof! The developer just pushed their changes to the 'test-doghouse'
# repository ๐ก and it sounds like they were trying to communicate with their
# localhost server on port 9418. Looks like someone's project is growing
# furiously, as if a new puppy was added to the team! ๐พSee SAMPLE-SESSION.md for a complete โscreenshotโ of a development session showing:
- tmux server session with live logs
- Real Git push operations being handled
- Storage system capturing all data
- AI analysis generation
Each major feature starts as a numbered experiment:
000-deps-check/- Environment verification001-book-analysis/- WYAG tutorial exploration006-guile-freebsd-segfault/- Platform compatibility analysis
This is an experimental implementation for learning purposes. Contributions focusing on:
- Functional programming patterns in Scheme
- Guile-specific optimizations and idioms
- FreeBSD integration and platform features
- Educational documentation and literate programming
- Creative AI integrations and plugin development
- Dog-themed humor in commit messages and documentation ๐
are especially welcome!
- โWrite Yourself a Git!โ - Thibault Polgeโs excellent tutorial
- Pro Git Book - Git internals and protocol details
- Git Protocol Documentation - Wire protocol specification
- Guile Reference Manual - Scheme implementation
- Scheme SRFIs - Standard extension libraries
- FreeBSD Documentation - Platform-specific features
- Ollama - Local LLM serving platform
- QWen2.5-Coder - Code analysis model used for commit summaries
MIT License - See LICENSE file for details.
- Complete Git wire protocol implementation
- TCP server accepting real Git pushes
- Plain text storage system for debugging
- AI-powered commit analysis with dog themes
- Continuous dogfooding environment
- Comprehensive experiment-driven development structure
- Platform-specific issue documentation and workarounds
- Pack file parsing and object extraction
- Proper object storage with SHA-1 addressing
- Reference management and updates
- Clone and fetch operations
- Full self-hosting capability
- Lines of Code: ~2000+ (Scheme + Shell + Docs)
- Experiments Completed: 7 major experiments
- Test Coverage: Core protocol and storage functions
- Dogfooding Status: โ Daily use for development
- AI Integration: โ Ollama-powered commit summaries
- Platform Compatibility: FreeBSD with documented workarounds
- Thibault Polge for the excellent WYAG tutorial
- The Guile and Scheme communities for functional programming inspiration
- Git developers for the original implementation and protocol design
- The FreeBSD community for platform-specific insights
- Ollama team for making local AI accessible
- Every dog who inspired our ROOF ROOF methodology ๐