Thank you for your interest in contributing. This guide covers everything you need to go from zero to a merged pull request.
- Development setup
- Running the TUI locally
- Architecture overview
- Running tests
- Code style
- Pull request checklist
- Reporting issues
Prerequisites: Bun ≥ 1.1
git clone https://github.com/plexicus/cli
cd cli
bun installType check (no emit):
bun run typecheckThe live Plexicus API is not required for development. Use mock mode to load fixture data from tests/fixtures/plexicus/:
MOCK_PLEXICUS=1 bun run src/main.tsx --token testOther subcommands:
bun run src/main.tsx login
bun run src/main.tsx repos
bun run src/main.tsx config set llm.provider claude
bun run src/main.tsx config set llm.api_key <key>Build a standalone binary:
bun build src/main.tsx --outfile dist/plexicus --target bunFor the full internals — state machine, component tree, keyboard system, and service layer — read CLAUDE.md. This section covers only what you need to orient yourself quickly.
src/main.tsx CLI entrypoint (Commander subcommands)
src/state/ useReducer + React Context (AppState)
src/components/ Ink/React TUI components
src/hooks/ Reusable React hooks (keymap, findings, LLM stream)
src/services/ API client, config, LLM routing
src/commands/ Lazily-loaded REPL command implementations
src/utils/ Pure helpers (severity, diff, paths)
All keyboard input is gated by state.inputMode:
| Mode | Who owns input |
|---|---|
navigation |
useKeymap hook + global handler in App.tsx |
repl |
Direct useInput char capture in App.tsx |
chat |
TextInput in ChatSidebar.tsx |
login |
TextInput in LoginForm.tsx |
The REPL bar intentionally bypasses ink-text-input and captures characters directly via useInput — ink-text-input v6 focus proved unreliable in tmux (focus never transferred, causing every Enter to fire onSubmit('')). The chat sidebar uses TextInput safely because its focus is managed independently by the inputMode guard and the helpOpen prop. Do not use ink-text-input for any new REPL-style input; use the same direct-capture pattern.
When adding a new keyboard shortcut, always check which inputMode it should be active in and guard accordingly.
All state changes go through dispatch. Never mutate state directly. Action types are defined as a discriminated union in src/state/actions.ts — add new actions there first.
- Create
src/commands/<name>/index.ts - Register it in
src/commands.ts(discriminated union +memoizeloader) - For inline commands handled in the REPL bar (
ask,filter,theme), add a branch inhandleReplSubmitinApp.tsx
bun test # all tests
bun test tests/services/config.test.ts # single file
bun test --watch # watch modeMock API: tests that exercise the API client set MOCK_PLEXICUS=1 (or import the module dynamically after setting the env var) to load fixture JSON from tests/fixtures/plexicus/.
Config isolation: tests that write config use mkdtemp + process.env.HOME override in beforeEach/afterEach so they never touch your real ~/.config/plexicus/config.json.
Component tests: use ink-testing-library. See tests/ for existing examples.
- Immutability: always create new objects — never mutate state or props.
- Functional state updaters: use
setState(prev => ...)instead of capturing the current value in a closure. - Small files: aim for 200–400 lines; extract when a file grows past ~800 lines.
- No comments explaining what: code and names do that. Add a comment only when the why is non-obvious.
- Error handling at boundaries: validate at system boundaries (user input, API responses via Zod). Don't add try/catch for things that can't fail.
- No direct
node:fs: useBun.file/Bun.writefor file I/O.
Before opening a PR, confirm:
-
bun run typecheckpasses with zero errors -
bun testpasses (add new tests for new behaviour) - The TUI runs in mock mode:
MOCK_PLEXICUS=1 bun run src/main.tsx --token test - New keyboard shortcuts are documented in
src/components/design-system/KeybindingsHelp.tsx - New config keys are documented in this file, in
README.md, and insrc/services/config.ts - No hardcoded API URLs or tokens in committed code
Open an issue at github.com/plexicus/cli/issues. Include:
- plexicus version (
plexicus --version) - OS and terminal emulator
- Steps to reproduce
- Expected vs actual behaviour