Personal Codex is a local-first coding assistant with a ChatGPT-style web UI and Ollama-powered model execution. This plan covers Phase 1 only, targeting the minimal viable backend and frontend foundations required to support local Ollama chat streaming and persisted conversations.
- Establish backend architecture with FastAPI, SQLite, SQLAlchemy 2, Alembic, Pydantic v2, and Ollama client integration.
- Build conversation persistence and streaming chat API.
- Create a basic Angular 18+ frontend with a chat UI, conversation sidebar, settings placeholder, dark/light themes, markdown rendering, syntax-highlighted code blocks, and streaming assistant output.
- Ensure backend and frontend can run locally without cloud services.
- Produce documentation and setup artifacts for Phase 1.
- Backend project structure
backend/with Python 3.12 target supportbackend/app/package containerbackend/app/main.pyFastAPI appbackend/app/config.pyconfiguration managementbackend/app/db/SQLAlchemy models, session, migrations setupbackend/app/schemas/Pydantic request/response modelsbackend/app/routers/conversation and chat endpointsbackend/app/ollama.pyOllama HTTP client integrationbackend/app/services/conversation service layerbackend/app/tests/pytest tests
- Database and persistence
- SQLite database bound to backend root
- SQLAlchemy 2 ORM models for Conversation, Message
- Alembic migration skeleton and initial migration
- Ollama local client
- Use the local Ollama HTTP API endpoint at
http://127.0.0.1:11434by default - Default model
qwen2.5-coder:7b - Chat flow integration using streaming via SSE or chunked response
- Validate responses and handle offline/unavailable Ollama gracefully
- Use the local Ollama HTTP API endpoint at
- Conversation API
/api/conversationslist/create/rename/delete/search/api/conversations/{id}/messagesretrieval/api/conversations/{id}/chatstreaming endpoint for assistant generation- Backend SSE channel for incremental assistant chunks
- Security and config
- Bind backend to
127.0.0.1only by default - Strict CORS allowing only Angular origin from
.envor default localhost frontend - No shell invocation for Ollama or subprocesses in Phase 1
- Store config in
backend/.env.example
- Bind backend to
- Tests
- Pytest backend tests for models, conversation CRUD, Ollama offline fallback, streaming endpoint structure, and path/security core behavior.
- Angular 18+ app scaffold
- Standalone components only
- Strict TypeScript configuration
- Angular Material for UI controls and theming
- Core UI screens/components
ConversationShellComponentwith sidebar and chat panelConversationListComponentfor conversation managementChatMessageComponentfor markdown and code renderingSettingsComponentstub with theme/model selectorAppComponentminimal routing and layout
- Features for Phase 1
- Collapsible conversation sidebar
- New conversation button
- Rename and delete conversation actions
- Responsive chat window with streaming assistant output
- Markdown rendering and syntax-highlighted code blocks
- Copy-code button on code blocks
- Stop-generation button during streaming
- Dark/light theme toggle
- Model selector stub wired to settings and API config
- Error state when backend/Ollama unavailable
- Testing
- Vitest or Angular supported test runner for core components and services
- Basic UI snapshot/behavior test for chat stream rendering
README.mdupdated for local development and Phase 1 startup instructionsAGENTS.mdplaceholder with high-level agent guidance and phase boundaries.env.examplefor backend/frontend local configarchitecture.mddescribing the backend/frontend architecture, Ollama integration, and security boundariesPLAN.md(this file)
- Backend application skeleton and conversation API
- Basic frontend chat UI with streaming demo
- Tests for backend and frontend foundations
- Documentation files: README, AGENTS, .env.example, architecture notes
- Exact commands to start backend and frontend
- Full tool execution system and typed agent tools
- Workspace filesystem tools and path enforcement beyond future design
- Approval workflow and change management UI
- Git diff viewer and tool execution cards
- Multi-model orchestration beyond default model selection
- Docker Compose production stack beyond placeholder compose files
- Register local workspace roots securely with canonical path normalization.
- Block UNC paths when disabled and prevent traversal outside the registered project.
- Hide excluded directories and sensitive files from listings and content previews.
- Provide read-only file browsing and file content preview.
- Search code using ripgrep and return paginated matches.
- Expose Git status and diff details for tracked repositories.
- Read AGENTS.md instructions from workspace roots in a secure read-only manner.
- All workspace requests are confined to the registered root.
- Binary files, excluded directories, and secret files are not exposed.
- File reads are capped by configured file size limits.
- Build a thin local VS Code client only.
- Do not duplicate AI model execution or conversation storage.
- Reuse the existing FastAPI backend for all chat, workspace, and code tooling.
- Maintain strictly local-only connectivity and no cloud APIs.
- Add a Personal Codex Activity Bar pane using
WebviewViewProvider. - Provide a sidebar with conversation list, new-chat action, chat UI, model selector, backend status, workspace status, approval controls, and tool execution cards.
- Render markdown securely and highlight code using bundled syntax highlighting.
- Use VS Code theme variables for native appearance.
- Enforce a strict CSP with nonces; block remote resources and unsafe inline execution.
- Add VS Code settings for backend URL, default model, auto-register workspace, write approval, and notifications.
- Check backend health with timeout, retry/backoff, and friendly offline messages.
- Stream assistant output from
/api/conversations/{id}/chatand support cancellation. - Use a typed client for all backend API calls.
- Detect open
vscode.workspace.workspaceFoldersand support multi-root workspaces. - Ask the user before registering folders with the backend; do not silently register.
- Send canonical workspace paths and let the backend authorize final access.
- Show active registered workspace state in the sidebar.
- Contribute commands for chat, new chat, explain selected code, fix selected code, refactor selected code, generate tests, ask about current file, review current changes, register workspace, check connection, and start the local backend.
- Add editor context menu entries for selected-code actions.
- Send selected text, relative path, language ID, selection range, and workspace ID to the backend.
- Support references such as
@currentFile,@selection,@workspace,@problems, and@gitDiffby resolving them in the extension before sending. - Enforce explicit selection for large context and apply client-side size limits.
- Use
vscode.languages.getDiagnosticsto collect diagnostics for current files. - Allow commands to explain diagnostics, suggest fixes, and send selected diagnostics to chat without editing.
- Use VS Code/Git APIs to show current branch, modified files, staged files, and untracked files.
- Send only diff metadata and relevant file information to the backend.
- Default to localhost backend connection only; warn on non-local URLs.
- Do not read outside opened workspace folders.
- Do not read excluded or secret files from the extension.
- Do not execute shell commands or perform file writes during Phase 3.5.
- Treat webview messages as untrusted and validate all message payloads at runtime.
- Escape rendered markdown and disable raw HTML in the UI.
- Add unit tests with Vitest and integration tests with
@vscode/test-electron. - Add scripts for build, watch, lint, test, test:integration, and package.
- Package a local
.vsixfile for manual installation.
- Review PLAN.md and approve Phase 3.5 extension design.
- Implement the
vscode-extension/folder and build the local VS Code client. - Run unit and integration tests, then package
personal-codex-0.1.0.vsix.