86 lines
2.4 KiB
Markdown
86 lines
2.4 KiB
Markdown
# Server CLAUDE.md
|
|
|
|
Clojure backend for Spiceflow.
|
|
|
|
## Commands
|
|
|
|
```bash
|
|
clj -M:dev # REPL with dev tools
|
|
clj -M:run # Production mode
|
|
clj -M:test # Unit tests
|
|
clj -M:test --focus ns # Specific namespace
|
|
```
|
|
|
|
**REPL commands** (in `dev/user.clj`):
|
|
```clojure
|
|
(go) ; Start server + auto-reload
|
|
(reset) ; Reload code + restart
|
|
(stop) ; Stop server
|
|
(reload) ; Reload code only
|
|
(reload-all) ; Force reload all namespaces
|
|
```
|
|
|
|
## Directory Structure
|
|
|
|
```
|
|
server/
|
|
├── src/spiceflow/
|
|
│ ├── core.clj # Entry point, Mount states
|
|
│ ├── config.clj # Configuration (aero)
|
|
│ ├── db/ # Database layer
|
|
│ ├── adapters/ # CLI integrations
|
|
│ ├── api/ # HTTP & WebSocket
|
|
│ ├── session/ # Session lifecycle
|
|
│ └── terminal/ # Terminal diff caching
|
|
├── dev/user.clj # REPL helpers
|
|
├── test/ # Unit tests
|
|
├── resources/config.edn # Configuration
|
|
└── deps.edn # Dependencies
|
|
```
|
|
|
|
## Mount States (start order)
|
|
|
|
1. `store` - SQLite database
|
|
2. `server` - Jetty HTTP server
|
|
|
|
## Namespaces
|
|
|
|
| Namespace | Purpose |
|
|
|-----------|---------|
|
|
| `spiceflow.core` | Entry point, Mount states |
|
|
| `spiceflow.config` | Configuration |
|
|
| `spiceflow.db.protocol` | DataStore protocol |
|
|
| `spiceflow.db.sqlite` | SQLite implementation |
|
|
| `spiceflow.db.memory` | In-memory (tests) |
|
|
| `spiceflow.adapters.protocol` | AgentAdapter protocol |
|
|
| `spiceflow.adapters.claude` | Claude Code CLI |
|
|
| `spiceflow.adapters.opencode` | OpenCode CLI |
|
|
| `spiceflow.adapters.tmux` | Tmux terminal |
|
|
| `spiceflow.api.routes` | HTTP handlers |
|
|
| `spiceflow.api.websocket` | WebSocket management |
|
|
| `spiceflow.session.manager` | Session lifecycle |
|
|
|
|
## Configuration (aero)
|
|
|
|
```edn
|
|
{:server {:port #long #or [#env SPICEFLOW_PORT 3000]
|
|
:host #or [#env SPICEFLOW_HOST "0.0.0.0"]}
|
|
:database {:type :sqlite
|
|
:dbname #or [#env SPICEFLOW_DB "spiceflow.db"]}}
|
|
```
|
|
|
|
Access: `(get-in config/config [:server :port])`
|
|
|
|
## Conventions
|
|
|
|
| Thing | Convention |
|
|
|-------|------------|
|
|
| Files | kebab-case |
|
|
| Namespaces | kebab-case |
|
|
| Functions | kebab-case |
|
|
| Protocols | PascalCase |
|
|
| Records | PascalCase |
|
|
| Private vars | `^:private` |
|
|
|
|
Thread safety: `ConcurrentHashMap` for processes, `atom` for simpler state.
|