|
| 1 | +# Contributing to lstk |
| 2 | + |
| 3 | +Thanks for contributing to lstk! This document covers contribution guidelines for the lstk CLI. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +### Prerequisites |
| 8 | + |
| 9 | +- Go 1.21+ (or latest stable) |
| 10 | +- Docker (for integration tests) |
| 11 | +- Make |
| 12 | + |
| 13 | +### Building |
| 14 | + |
| 15 | +```bash |
| 16 | +make build # Compiles to bin/lstk |
| 17 | +``` |
| 18 | + |
| 19 | +### Running Tests |
| 20 | + |
| 21 | +```bash |
| 22 | +make test # Run unit tests (cmd/ and internal/) via gotestsum |
| 23 | +make test-integration # Run integration tests (requires Docker) |
| 24 | +make lint # Run golangci-lint |
| 25 | +``` |
| 26 | + |
| 27 | +To run a single integration test: |
| 28 | + |
| 29 | +```bash |
| 30 | +make test-integration RUN=TestStartCommandSucceedsWithValidToken |
| 31 | +``` |
| 32 | + |
| 33 | +## Code Style |
| 34 | + |
| 35 | +- Comments: only for non-obvious "why" decisions |
| 36 | +- Error handling: always check returned errors (except in tests) |
| 37 | +- No package-level global variables; use constructors and dependency injection |
| 38 | +- No direct stdout/stderr printing; use `output.Sink` for user output, `log.Logger` for diagnostics |
| 39 | + |
| 40 | +## Architecture |
| 41 | + |
| 42 | +- `cmd/` — CLI wiring only (Cobra), no business logic |
| 43 | +- `internal/` — all business logic: |
| 44 | + - `container/` — emulator container handling |
| 45 | + - `runtime/` — container runtime abstraction (Docker) |
| 46 | + - `auth/` — authentication (env token, keyring, browser login) |
| 47 | + - `config/` — Viper-based TOML config |
| 48 | + - `output/` — event/sink system for CLI/TUI rendering |
| 49 | + - `ui/` — Bubble Tea views |
| 50 | + - `update/` — self-update logic |
| 51 | + - `log/` — internal diagnostic logging |
| 52 | + |
| 53 | +See `CLAUDE.md` for full architecture details. |
| 54 | + |
| 55 | +## Adding Features |
| 56 | + |
| 57 | +### New Commands |
| 58 | + |
| 59 | +Use the skill: |
| 60 | +``` |
| 61 | +/add-command <name> |
| 62 | +``` |
| 63 | + |
| 64 | +This scaffolds a new CLI subcommand with proper wiring, domain logic, and tests. |
| 65 | + |
| 66 | +### New Output Events |
| 67 | + |
| 68 | +Use the skill: |
| 69 | +``` |
| 70 | +/add-event <EventName> |
| 71 | +``` |
| 72 | + |
| 73 | +This adds a new typed event to the `output/` event system. |
| 74 | + |
| 75 | +### New UI Components |
| 76 | + |
| 77 | +Use the skill: |
| 78 | +``` |
| 79 | +/add-component <name> |
| 80 | +``` |
| 81 | + |
| 82 | +This scaffolds a new Bubble Tea TUI component. |
| 83 | + |
| 84 | +## Testing Guidelines |
| 85 | + |
| 86 | +- Prefer integration tests for most behavior |
| 87 | +- Unit tests for isolated logic where integration is impractical |
| 88 | +- When fixing a bug, always add an integration test that reproduces the scenario |
| 89 | + |
| 90 | +## Pull Requests |
| 91 | + |
| 92 | +1. Fork the repository |
| 93 | +2. Create a feature branch from `main` |
| 94 | +3. Run `make lint` and `make test` before submitting |
| 95 | +4. Review your own PR first — run `/review-pr <number>` |
| 96 | +5. Open a PR against `main` |
| 97 | + |
| 98 | +## Questions? |
| 99 | + |
| 100 | +Check `README.md` for usage docs and `CLAUDE.md` for architecture. |
0 commit comments