|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is **jupyter_ai_jupyternaut**, a JupyterLab extension that provides the default AI persona "Jupyternaut" for Jupyter AI. It consists of: |
| 8 | + |
| 9 | +- **Python package**: `jupyter_ai_jupyternaut` (server extension) |
| 10 | +- **NPM package**: `@jupyter-ai/jupyternaut` (frontend extension) |
| 11 | +- **Entry point**: Provides the Jupyternaut persona via the `jupyter_ai.personas` entry point |
| 12 | + |
| 13 | +## Development Commands |
| 14 | + |
| 15 | +### Setup |
| 16 | +```bash |
| 17 | +micromamba install uv jupyterlab nodejs=22 |
| 18 | +jlpm |
| 19 | +jlpm dev:install |
| 20 | +``` |
| 21 | + |
| 22 | +### Build Commands |
| 23 | +- `jlpm build` - Build TypeScript sources with source maps |
| 24 | +- `jlpm build:prod` - Production build (clean + lib + labextension) |
| 25 | +- `jlpm build:lib` - Build TypeScript library only |
| 26 | +- `jlpm build:labextension` - Build JupyterLab extension |
| 27 | + |
| 28 | +### Development |
| 29 | +- `jlpm watch` - Watch source files and auto-rebuild |
| 30 | +- `jlpm dev:install` - Full development installation |
| 31 | +- `jlpm dev:uninstall` - Remove development installation |
| 32 | + |
| 33 | +### Testing |
| 34 | +- **Frontend**: `jlpm test` (Jest) |
| 35 | +- **Backend**: `pytest -vv -r ap --cov jupyter_ai_jupyternaut` |
| 36 | +- **UI Tests**: See `ui-tests/README.md` (Playwright/Galata) |
| 37 | + |
| 38 | +### Code Quality |
| 39 | +- `jlpm lint` - Run all linters (stylelint + prettier + eslint) |
| 40 | +- `jlpm lint:check` - Check without fixing |
| 41 | +- Individual tools: `jlpm eslint`, `jlpm prettier`, `jlpm stylelint` |
| 42 | + |
| 43 | +### Clean Commands |
| 44 | +- `jlpm clean` - Clean lib directory |
| 45 | +- `jlpm clean:all` - Clean everything including labextension |
| 46 | + |
| 47 | +## Architecture |
| 48 | + |
| 49 | +### Core Components |
| 50 | + |
| 51 | +1. **JupyternautPersona** (`jupyter_ai_jupyternaut/jupyternaut/jupyternaut.py`): |
| 52 | + - Main persona class extending `BasePersona` |
| 53 | + - Handles chat model configuration and message processing |
| 54 | + - Integrates with `litellm` for LLM completions |
| 55 | + - Manages conversation history and context |
| 56 | + |
| 57 | +2. **Frontend Plugins** (`src/index.ts`): |
| 58 | + - Main plugin: Basic extension activation |
| 59 | + - Settings plugin: AI configuration interface |
| 60 | + - Stop button plugin: Message interaction controls |
| 61 | + - Status plugin: Extension status management |
| 62 | + |
| 63 | +3. **Configuration System**: |
| 64 | + - Uses `jupyter_ai_persona_manager` for persona management |
| 65 | + - Chat model configuration via settings UI |
| 66 | + - Server-side config management and REST APIs |
| 67 | + |
| 68 | +### Key Dependencies |
| 69 | + |
| 70 | +- **Backend**: `jupyter_server`, `pydantic>=2.10.0`, `litellm>=1.73`, `jupyterlab-chat>=0.17.0` |
| 71 | +- **Frontend**: `@jupyter/chat`, `@mui/material`, `@emotion/react`, JupyterLab 4.x |
| 72 | + |
| 73 | +### File Structure |
| 74 | +- `jupyter_ai_jupyternaut/` - Python package (server extension) |
| 75 | + - `jupyternaut/` - Core persona implementation |
| 76 | + - `config/` - Configuration management |
| 77 | + - `models/` - REST API models |
| 78 | + - `secrets/` - Secret management |
| 79 | +- `src/` - TypeScript source (frontend extension) |
| 80 | +- `lib/` - Compiled JavaScript output |
| 81 | +- `style/` - CSS styling |
| 82 | + |
| 83 | +### Development Notes |
| 84 | + |
| 85 | +- Extension follows JupyterLab 4.x plugin architecture |
| 86 | +- Uses `hatch` for Python packaging and `jlpm` (yarn) for Node.js |
| 87 | +- Frontend built with React/TypeScript and Material-UI |
| 88 | +- Backend provides REST APIs for configuration and model management |
| 89 | +- Entry point registration allows automatic persona discovery by Jupyter AI |
| 90 | + |
| 91 | +### Code Style |
| 92 | +- TypeScript: ESLint with Prettier, single quotes, no trailing commas |
| 93 | +- Python: Standard formatting (details in pyproject.toml) |
| 94 | +- Interface naming: Must start with `I` and use PascalCase |
| 95 | +- CSS: Stylelint with standard config |
0 commit comments