Skip to content

Latest commit

 

History

History
81 lines (63 loc) · 2.5 KB

File metadata and controls

81 lines (63 loc) · 2.5 KB

Contributing to RustLabs CLI

Thanks for your interest in contributing! Here's how to get started.

Development Setup

# Clone the repo
git clone https://github.com/rustlabs/nexus-cli.git
cd nexus-cli

# Install dependencies
npm install

# Run in dev mode (hot reload)
npm run dev

# Build
npm run build

# Run built version
npm run start

Visual Testing

Use ttyd to test the TUI in a browser:

ttyd --port 7681 --writable node dist/index.js
# Open http://localhost:7681

Project Structure

src/
├── index.ts              # CLI entry point (commander)
├── commands/             # CLI command handlers
│   ├── auth.ts           # Login/logout
│   ├── chat.ts           # Chat sessions
│   ├── config.ts         # Configuration
│   ├── nexus.tsx         # TUI launcher
│   ├── status.ts         # Status & diagnostics
│   ├── swarm.tsx         # Swarm CLI actions
│   └── tasks.ts          # Task management
├── ui/
│   ├── app/              # App shell, keyboard router, state
│   ├── layout/           # TopBar, StatusBar, ThreePaneLayout
│   ├── views/            # LogsView, MarketplaceView, SettingsView, SwarmView
│   ├── overlays/         # CommandPalette, WorkspaceSwitcher, ConfirmDialog
│   ├── constants/        # Theme, keybinds, copy
│   └── state/            # AppContext, types
├── runtime/              # Mock runtime, types
├── data/                 # Provider configs
├── types/                # Agent types & presets
├── api/                  # API client
└── utils/                # Config, logger, updater

Key Patterns

  • Keyboard routing: useKeyboardRouter.ts uses a stable useCallback with refs to avoid ink's keystroke-dropping bug
  • Views stay mounted: All views render simultaneously with display: none — each view's useInput must guard with activeMode check
  • Mode handlers: Each view registers modeHandlers[mode].onKey in a useEffect with [] deps, accessing state via refs

Making Changes

  1. Fork the repo
  2. Create a feature branch: git checkout -b feat/my-feature
  3. Make your changes
  4. Build and test: npm run build
  5. Commit with a descriptive message
  6. Open a PR against master

Code Style

  • TypeScript strict mode
  • Functional React components with hooks
  • Keep views focused — one file per tab
  • Use THEME and COLORS from constants for styling