|
| 1 | +# OpenCode Development Guide |
| 2 | + |
| 3 | +## Build/Test/Lint Commands |
| 4 | + |
| 5 | +- **Build**: `go build ./...` or `go build .` (for main binary) |
| 6 | +- **Test**: `task test` or `go test ./...` |
| 7 | +- **Single test**: `go test ./internal/path/to/package -run TestName` |
| 8 | +- **Lint**: `task lint` or `golangci-lint run` |
| 9 | +- **Format**: `task fmt` or `gofumpt -w .` |
| 10 | + |
| 11 | +## Code Style Guidelines |
| 12 | + |
| 13 | +- **Imports**: Standard library first, then third-party, then internal packages (separated by blank lines) |
| 14 | +- **Types**: Use `any` instead of `interface{}`, prefer concrete types over interfaces when possible |
| 15 | +- **Naming**: Use camelCase for private, PascalCase for public, descriptive names (e.g., `messageListCmp`, `handleNewUserMessage`) |
| 16 | +- **Constants**: Use `const` blocks with descriptive names (e.g., `NotFound = -1`) |
| 17 | +- **Error handling**: Always check errors, use `require.NoError()` in tests, return errors up the stack |
| 18 | +- **Documentation**: Add comments for all public types/methods, explain complex logic in private methods |
| 19 | +- **Testing**: Use testify/assert and testify/require, table-driven tests with `t.Run()`, mark helpers with `t.Helper()` |
| 20 | +- **File organization**: Group related functionality, extract helper methods for complex logic, use meaningful method names |
| 21 | +- **TUI components**: Implement interfaces (util.Model, layout.Sizeable), document component purpose and behavior |
| 22 | +- **Message handling**: Use pubsub events, handle different message roles (User/Assistant/Tool), manage tool calls separately |
0 commit comments