|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | +This is a Go monorepo for the ShellTime CLI and daemon. |
| 5 | +- `cmd/cli/main.go`: CLI entrypoint (`shelltime`) |
| 6 | +- `cmd/daemon/main.go`: daemon entrypoint (`shelltime-daemon`) |
| 7 | +- `commands/`: CLI command implementations (for example `sync.go`, `doctor.go`, `daemon.install.go`) |
| 8 | +- `daemon/`: background services, socket handling, sync processors, OTEL handlers |
| 9 | +- `model/`: core domain logic (config, API clients, crypto, shell integrations) |
| 10 | +- `docs/`: user-facing docs (`CONFIG.md`, `CC_STATUSLINE.md`) |
| 11 | +- `fixtures/`: test fixtures |
| 12 | + |
| 13 | +Keep new code in the existing package boundary; avoid mixing CLI wiring, daemon internals, and model logic. |
| 14 | + |
| 15 | +## Build, Test, and Development Commands |
| 16 | +- `go build -o shelltime ./cmd/cli/main.go`: build the CLI binary |
| 17 | +- `go build -o shelltime-daemon ./cmd/daemon/main.go`: build the daemon binary |
| 18 | +- `go test -timeout 3m -coverprofile=coverage.txt -covermode=atomic ./...`: run full test suite with coverage (matches CI) |
| 19 | +- `go test ./commands/...` (or `./daemon/...`, `./model/...`): package-level tests |
| 20 | +- `go test -run TestName ./daemon/`: run a single test |
| 21 | +- `go fmt ./... && go vet ./...`: format and static checks |
| 22 | +- `mockery`: regenerate mocks (configured by `.mockery.yml`) |
| 23 | +- `pp g`: regenerate PromptPal-generated types before tests/releases |
| 24 | + |
| 25 | +## Coding Style & Naming Conventions |
| 26 | +Use standard Go conventions and keep code `gofmt`-clean (tabs, canonical spacing/import grouping). |
| 27 | +- File naming: lowercase with underscores or dotted qualifiers (for example `daemon.install.go`, `api.base.go`) |
| 28 | +- Tests: `*_test.go` files with clear `TestXxx` names |
| 29 | +- Commits and scopes should reflect touched package areas (`commands`, `daemon`, `model`, `docs`) |
| 30 | + |
| 31 | +## Testing Guidelines |
| 32 | +Testing uses Go `testing` plus `testify`. |
| 33 | +- Prefer table-driven tests for pure logic |
| 34 | +- Use suite-based tests (`suite.Suite`, `SetupTest`, `TearDownTest`) for stateful daemon flows |
| 35 | +- Keep fixtures in `fixtures/` when payloads are reused |
| 36 | +- Ensure `go test -timeout 3m -coverprofile=coverage.txt -covermode=atomic ./...` passes before opening PRs |
| 37 | + |
| 38 | +## Commit & Pull Request Guidelines |
| 39 | +History follows Conventional Commits with scope, e.g. `fix(daemon): ...`, `feat(commands): ...`, `refactor(model): ...`. |
| 40 | +- Write focused commits with one behavioral change each |
| 41 | +- PRs should include: concise summary, why the change is needed, and test evidence |
| 42 | +- Link related issues when applicable |
| 43 | +- If behavior/output changes, include CLI examples or screenshots |
| 44 | +- Regenerate artifacts (`pp g`, `mockery`) when relevant so CI stays green |
0 commit comments