CodePapr Tutorial
v0.1.0 macOS + Windows Tauri Desktop ← Home

CodePapr Tutorial

CodePapr is a DeepSeek cache-friendly local coding agent system. It's not just a code generator — it's an intelligent agent workbench with comprehension and execution capabilities: reading projects, searching code, running commands, modifying files, and previewing results — all done locally.

CodePapr Introduction

What is CodePapr

CodePapr is a cache-first coding agent system offering two entry points: a Tauri desktop workbench and a CLI terminal interface. It shares a common Agent Runtime to provide desktop and terminal CLI with the same capabilities, enabling AI agents to read, modify, execute, verify, and preview within real project repositories.

CodePapr is neither a traditional AI chat tool nor an IDE plugin. It is an autonomous agent running in the terminal/desktop that genuinely understands your project context and automatically executes development tasks.

Core Design Principles

  • Local-first: Project context stays within the workspace as much as possible; file and command execution happen locally
  • Single Runtime, Multiple Entry Points: The desktop workbench and CLI terminal share the same Agent, Session, ToolRegistry, and Provider semantics
  • DeepSeek Cache Optimization: Stable content upfront, volatile content at the end, maximizing prefix cache hit rates to reduce token costs
  • Structured Code Editing: Uses Search/Replace Diff mechanism, validates before writing, avoids line-number drift
  • Verifiable Execution Chain: Every round of request, response, tool call, and cache statistics is traceable

CodePapr vs. Mainstream AI Coding Tools

By 2026, AI coding tools are already very mature. The comparison below is based on each tool's current public capabilities, presented truthfully.

DimensionCline (62k⭐)Aider (46k⭐)Devin DesktopCodePapr
Form FactorSDK / VS Code / JetBrains / CLI / KanbanTerminal CommandStandalone Desktop IDEStandalone Desktop App (Tauri 2)
Multi-Agent✅ Team + Coordinator + Scheduled Dispatch❌ Single Agent✅ Multi-Agent Fleet + ACP Protocol✅ Main Agent + 3 Built-in Sub-agents + Custom
Task PlanningKanban BoardSpaces + KanbanTodoList: auto-create / progress tracking / re-plan
Code UnderstandingRead Files + grep + LSPRepo MapFast Context (milliseconds)ProjectGraph Semantic Graph: 14 analysis actions
RollbackCheckpoints SnapshotGit commit rollbackDiff reviewGit auto-commit checkpoint + reset --hard: atomic code and message recovery
Cache OptimizationDeepSeek three-layer prefix caching, reusable across sessions
Model SupportAlmost all (incl. local)Almost all (incl. local)Built-in free model + third-partyDeepSeek / OpenAI / Claude / Local
ExtensibilitySDK + MCP + Plugin SystemConfig FilesMCP + Extension + ACPCustom Agents / Skills / Commands / Rules
PricingOpen Source Free + API CostsOpen Source Free + API CostsFree / $20 Pro / $200 MaxOpen Source Free + API Costs
CodePapr's Unique Value: Complementary rather than a replacement for other tools. If you need deep IDE integration and a rich plugin ecosystem, Cline/Aider/Devin Desktop are more mature. If you value a standalone desktop workbench, extreme cost savings through DeepSeek prefix caching, a multi-sub-agent collaboration system, and in-place conversation rollback — CodePapr is the best choice.

Who Should Use CodePapr

  • You have mastered at least one programming language and can read basic syntax and project structure
  • Engineers looking to dramatically boost development efficiency with AI
  • Independent developers or tech leads maintaining complex projects long-term
  • Developers comfortable switching between command line and visual interfaces
  • Teams concerned about token costs who want to leverage DeepSeek cache optimization to reduce expenses

Prerequisites

  • Basic programming skills (can read and write simple code)
  • Basic code reading and comprehension ability
  • Familiarity with common dev tools (editor, command line, Git)
  • Basic understanding of project structure (directories, module organization)
  • Willingness to understand code rather than fully relying on AI

Supported LLM Providers

DeepSeek (Native) OpenAI (Compatible) Claude / Anthropic (Compatible) Local OpenAI-Compatible Endpoint

Installation & Environment Setup

Requirements

ComponentMinimum VersionPurpose
Node.js18+Runtime and package management
npm9+Dependency management
Rust toolchain + CargostableDesktop build (debug/release/publish)
.NET SDK-C# Roslyn analyzer (required for release builds)
Note: If you only do frontend development or source code reading, running npm install and npm run build is usually enough. Desktop debugging and packaging require the Rust toolchain.

Standard Installation

# After cloning the repository
npm install
npm run build

Installation Verification

npm run verify

Passing this step confirms that your machine at least satisfies: correct Node dependencies, successful workspace build, passing workspace tests, passing CLI E2E tests, and passing Tauri cargo check.

Supported Platforms

PlatformArchitectureStatus
macOSarm64 (Apple Silicon)Supported (outputs .dmg installer)
Windowsx64Supported (outputs .msi installer)

Both platforms share the same Rust backend and frontend codebase; the release pipeline outputs dmg/msi installers simultaneously.

External Dependencies

Depending on your operations, you may also need:

  • A valid model API key (DeepSeek / OpenAI / Claude or a local compatible endpoint)
  • Chrome or a Chromium-compatible browser (for browser interaction and screenshots)
  • VS Code (optional, for workspace tasks and debugging configuration)

Three Launch Modes

CommandPurpose
npm run debugDevelopment debugging with hot reload; suitable for long sessions and daily use
npm run releaseDirectly launch the optimized desktop runtime (no installer packaging)
npm run publishGenerate platform installer (.dmg / .msi) and organize into Release/

API Setup & Model Configuration

Configuration Storage Locations

LevelPathPurpose
App-level~/.codepapr/codepapr.sqliteProvider, model, API key, language, sampling parameters
Project-level<workspace>/.CodePapr/Project state, session records, rules, Agents, Skills

Provider Modes

ModeDescriptionUse Case
deepseekDeepSeek official providerRecommended default; best cache optimization
openaiOpenAI-compatible formatConnecting to OpenAI or compatible services
claudeClaude/Anthropic-compatible formatConnecting to Claude or compatible endpoints

DeepSeek API Reference URL

# OpenAI format (used by DeepSeek provider by default)
https://api.deepseek.com/v1

CodePapr's DeepSeek provider always uses the OpenAI-compatible https://api.deepseek.com/v1. If you want to use the Anthropic protocol with DeepSeek, select Claude as the provider and set baseURL to DeepSeek's Anthropic-compatible endpoint.

Environment Variable Fallback Order

The desktop and CLI provider compatibility layer reads API keys in the following order:

  1. DEEPSEEK_API_KEY
  2. OPENAI_API_KEY
  3. ANTHROPIC_API_KEY

App-Level Settings

LLM Settings

  • provider — Model provider
  • model — Model name
  • baseURL — Custom endpoint URL
  • API key — Authentication key
  • temperature — Generation temperature
  • maxTokens — Maximum output tokens
  • thinkingEnabled / thinkingEffort — Thinking mode

Routing Settings

  • fast model switch — Whether to enable the fast model
  • fast model name — Fast model name (default deepseek-v4-flash)
  • max tool rounds — Maximum tool rounds (default 500)
  • max context tokens — Maximum context tokens (default 200k)
  • max conversation rounds — Maximum conversation rounds (default 24)

Fast Model Routing

ScenarioModel UsedTemperature
Main Agent conversationPrimary model (default deepseek-v4-pro)Default
Context compressionFast model (default deepseek-v4-flash)0.1
Sub-agent dispatch (heavy/execution type)Primary modelUser configured
Sub-agent dispatch (Explore/Scout fast mode)Fast model (switchable to primary)User configured
Slash commands declaring model: fast (e.g. /search, /lint, /clean, /commit, /summary, /build)Fast model (falls back to primary if not enabled)0.3
Tip: The desktop settings panel is divided into five tabs: General / LLM / Search / Mentor / Advanced. General covers language, debugging, and license; LLM covers primary model, fast model, sampling parameters, and thinking effort; Search configures self-hosted SearXNG and other search backends; Mentor configures an independent API key, base URL, and model selection for the mentor sub-agent; Advanced covers context compression, TodoList retry, ProjectGraph limits, and more. Voice settings are not in the main settings panel but are configured per character in the Voice Tab of the Character Modal.

First Use

Three Steps to Start

  1. Prepare configuration: Fill in your API key, provider, and model in the desktop settings
  2. Choose entry point: Use the desktop workbench directly (the current public product entry only exposes the desktop workbench)
  3. Choose mode: Ask for explanation and analysis, Plan for breaking down solutions, Agent for actual execution

Shortest Path

npm install
npm run build
npm run debug

First Use Workflow

  1. Open settings, fill in provider, model, and API key
  2. Select a project folder
  3. Choose the current task mode among Ask, Plan, and Agent
  4. Enter a task description and let the agent execute or analyze
  5. Review results in the file tree, editor, Git, and preview panels
Auto-recovery: The desktop app remembers your last opened project directory and automatically restores that project and its project-level chat history on next launch. You will only see an empty workspace if the project path is invalid or you open a different directory.

Entry Points

Entry PointBest For
Desktop WorkbenchLong sessions, file tree, Git, preview, browser interaction — a visual workbench
CLI (codepapr command)Terminal interaction, scripted automation; provides chat / ask / plan / agent / init / session / stats / config subcommands

Note: The CLI includes two built-in sub-agents: Explore and Scout; Mentor is only available and configurable in the desktop's "Sub-agents" tab.

Work Modes: Ask / Plan / Agent

Ask, Plan, and Agent are not different products but three working modes of the same Runtime.

Ask Analysis Mode

Best for: Explaining architecture, clarifying module responsibilities, analyzing error causes, asking questions before deciding whether to execute.

Characteristics:

  • Does not modify files or run commands by default
  • For time-sensitive questions, prefers read-only time/web tools for verification
  • Only enters the read-only toolchain when you explicitly request project-based verification

Plan Planning Mode

Best for: Producing execution plans before large changes, seeing affected files and verification paths, breaking complex tasks into clear steps.

Characteristics:

  • Provides a task checklist by default
  • Shows affected files, execution order, verification methods, and risks
  • Best for planning first, then switching to Agent for execution

Agent Execution Mode

Best for: Fixing bugs, implementing features, running tests and verification, tasks that require actual file read/write and tool invocation.

Characteristics:

  • Actively searches projects, reads/writes files, runs commands, performs verification
  • Uses workspace tools, background commands, shell, preview, and browser capabilities
  • The main Agent execution loop runs in a Web Worker; long tasks won't block the UI
  • Long-running commands like exec display execution status and logs in tool call cards
  • Main execution defaults to a maximum of 500 consecutive internal tool rounds
  • After file changes, background diagnostics are dispatched asynchronously; identical failure fingerprints won't trigger repeated fixes

How to Write Effective Tasks

CodePapr's actual performance depends heavily on task description quality. The most effective prompts typically include:

  • What is the goal
  • Where is the scope of changes
  • Where is the reference implementation
  • What must not be touched
  • What are the verification criteria

Recommended Style

Fix the issue in packages/@codepapr/ui where background processes aren't stopped after preview closes.
First find the binding logic between the current preview session and background processes, then make a minimal fix.
After the change, at least run verification for the affected scope; if no narrow verification exists, explain why.

Less Effective Style

Help me fix the preview.
Pro tip: Treat it as an engineering agent capable of executing tasks, not a pure chatbot, and you will get more consistent results.

Desktop Workbench

Interface Structure

  • Left: Session list and quick access
  • Center: Chat area showing messages, tool calls, status, and execution summaries
  • Right: File tree and code preview
  • Auxiliary areas: Git panel, background processes, web preview

Full Desktop Capabilities

  • Project file tree browsing
  • Monaco code preview (VS Code engine)
  • Multi-language LSP hover, definition, and problem markers
  • Ask / Plan / Agent mode switching
  • Tool call process visualization
  • Git diff, recent commits, branch switching, and safe rollback
  • Background process management
  • In-app web preview
  • Browser page interaction and screenshots
  • Project configuration entry (Rules, Agents, Skills)
  • Visual Code Review panel (line-by-line comments, review status)
  • Non-blocking Toast notifications
  • External path access permission dialog

Code Review Panel

Click Review in the top AgentOps toolbar to open the Code Review panel:

  • Default diff compares HEAD~1..HEAD
  • Left file list shows added/modified/deleted/renamed files
  • Monaco diff editor displays both original / modified sides
  • Click the line number gutter on either side to add line-level comments
  • Comments can be marked as resolved / unresolved
  • Overall review status can be set: Pending Review / Approved / Changes Requested / Commented

Toast Notifications

The desktop uses non-blocking toasts instead of alerts:

  • Four colors: info / success / warning / error
  • Default 4.5 seconds auto-dismiss; error defaults to 8 seconds
  • Maximum 5 simultaneously displayed; drops the oldest when exceeded

External Path Permissions

When the Agent requests to read or list absolute paths outside the project, the desktop shows a permission dialog:

  • Deny: Block this access
  • Allow this file: Only permit this file
  • Allow this folder: Permit this directory and its children

Authorization results are saved in a whitelist; subsequent accesses to the same path won't trigger the dialog again. Write, edit, and command execution remain restricted to the workspace.

When to Prefer the Desktop

  • You are doing multi-round fixes or refactoring
  • You need to see the file tree while the agent works
  • You need Git diff, page preview, or page automation
  • You want to consolidate sessions, files, and verification in one interface

Git Integration

  • Git Panel: Shows staged/unstaged diff, recent commit history, branch creation/switch, local commits, safe discard of local changes
  • 8 Agent Git Tools: status, diff, history, branch_checkout, stage, commit, restore, reset
  • Auto-init: If the current workspace is not yet a Git repository, the panel can directly execute git init

Conversation Reset (Git Checkpoint)

Before each user message enters the conversation history, CodePapr captures a code snapshot as an anchor:

git add -A && git commit -m "codepapr:checkpoint:<userMsgId>"

When you need to roll back:

  • Hover over any user message and click "Reset to here"
  • The system git reset --hard to the checkpoint commit before that message was sent
  • All files are atomically restored to the state before sending that message
  • The message list is synchronously truncated; all subsequent conversation is removed
  • If the workspace is not a Git repository, CodePapr will first attempt git init; if initialization fails, the "Reset to here" button on that message remains disabled

Tool Capabilities

The Agent registers a comprehensive toolset covering file operations, ProjectGraph analysis, Git, preview, browser, Shell, LSP, and all local development scenarios. Below are the key tools grouped by capability.

graph — Core Project Understanding

A unified project semantic graph tool that selects operations via the action parameter. Simultaneously returns a directory tree, code structure skeleton, and file/symbol relationship graph, serving as the foundation for all symbol lookup, dependency analysis, and impact analysis.

Tool / ActionCapability
graph fullGenerate full ProjectGraph: directory tree + code structure skeleton + dependency graph
graph overviewLightweight overview (no full code skeleton); good for quickly perceiving project shape
graph lookupLook up symbols by name/path; returns symbolId, file, and line number
graph dependencyExtract dependency subgraph; supports incoming / outgoing / both
graph entrypointsFind project entry files and entry symbols
graph impactReverse impact analysis: what would be affected by modifying a given symbol
graph implementationsFind implementations/derived symbols of an interface or base class
graph smart_contextIntelligently retrieve the most relevant project context based on a task description
graph dead_codeDetect unused symbols (classes, functions, variables)
graph circular_depsDetect circular import dependencies between files
graph type_hierarchyBuild inheritance/implementation hierarchy tree for classes, interfaces, and types
graph suggest_refactorsBased on code structure analysis, suggest extractable methods and symbols that could become standalone files
graph test_impactAnalyze which existing tests would be affected by a list of changed files
graph generate_testsAuto-generate test skeletons for exported testable symbols in the project

File Operations

ToolCapability
readRead file content; supports line ranges, line windows, context lines, and byte limits
writeCreate or fully overwrite a file; use edit for partial modifications
editSingle-file precise SEARCH/REPLACE modification; search must exactly match source file
patchMulti-file atomic SEARCH/REPLACE; all blocks validated successfully before writing together; any failure rolls back all
grepRegex search file contents; returns match locations with context
globSearch project files by filename glob patterns; supports regex union
listBrowse project directory tree structure; supports recursive depth control

LSP Language Intelligence

Tool / ActionCapability
lsp definition / referencesLanguage service read-only navigation: jump to definition, find all references
lsp_edit rename / code_action / formatLanguage service semantic edits: rename, code actions, formatting
diagnosticsSingle-file LSP diagnostics or project-level lint / typecheck

Command Execution

Tool / ActionCapability
execRun a command: blocks by default; background:true for background execution; previewUrl to launch with preview
shell open / send / read / close / listPersistent shell sessions supporting multi-step commands and interactive terminals
proc list / stop / stop_allBackground process management

Git Operations

Tool / ActionCapability
git status / diff / logRead workspace status, diff, and commit history
git branch / stage / commitSwitch or create branches, stage changes, create commits
git restore / resetRestore changes or safe rollback (auto-creates backup branch and snapshot)

Browser & Preview

Tool / ActionCapability
browser open / navigate / reload / closeBuilt-in browser: open URL, navigate, refresh, close
browser click / type / read / screenshot / getBrowser interaction: click elements, type text, read DOM, screenshot, read state
openOpen URL or project HTML file in the system default browser

Web Tools

ToolCapability
web_searchOnline web search, aggregating multi-source results
web_fetchRead web page content, auto-extracting body text and converting to plain text
web_downloadDownload files to the project's .CodePapr/downloads/ folder

Other Tools

ToolCapability
skillLoad Skill instruction files from the project's .CodePapr/skills/ directory
local_time_nowGet current local time, date, and timezone; suitable for time-sensitive queries (market open/close, event deadlines, etc.)
questionAsk the user questions in Plan mode; supports predefined options and multi-select
taskDelegate sub-tasks to declarative sub-agents (Explore / Scout / Mentor) for execution
todoPlan and track multi-step task checklists; supports initialization, progress reporting, and re-planning

External Path Permissions

In the desktop, read / list operations on absolute paths outside the project trigger a PermissionDialog popup for authorization; the CLI's read boundaries are more lenient, while writes remain restricted to the workspace.

File Size Limits

A single read / write / edit / patch operation is capped at 20MB, covering most source code and binary resource files, though large files will significantly increase token consumption.

Tool Design Principle: The LLM sees simplified "merged tools" (25 total), which delegate to 40+ independent tools under the hood. The Agent can use all tools simultaneously; sub-agents are restricted by tools config allowlists. For code modifications, prefer edit/patch via Search/Replace Diff; use write only for new files. For command execution: short commands use exec, long-lived processes use exec with background:true, and interactive terminals use shell.

Character Roleplay

CodePapr supports creating, importing, and managing AI characters, allowing the Agent to converse with you in a specific persona. Once a character is activated, their identity, tone, and style are injected into the LLM system prompt, and the Agent responds in that character's persona.

Character Data Model

Each character includes the following fields:

FieldDescription
NameCharacter display name
AvatarUploaded image, also shown in the chat interface
DescriptionAppearance, backstory, identity setting
PersonalitySpeaking style, character traits, behavioral habits
ScenarioThe situation in which the current conversation takes place
First MessageWhat the character would say in their first conversation
Example DialoguesMultiple dialogue groups separated by <START>, guiding the LLM to understand the character's style
System PromptAdditional instructions appended after the character persona
TagsCustom tags for categorization and search

Roleplay Format Conventions

When a character is activated, the system prompt specifies the following format rules to ensure TTS can correctly distinguish dialogue from actions:

FormatMeaningTTS Behavior
*Action description*Narration, scene description, character actionsNot spoken
Plain textCharacter speechSpoken
**Bold text**Emphasis, stressSpoken with emphasis
(Parentheses) or (whisper)Tone cuesNot spoken

Creating a Character

  1. Click the Character Button (avatar icon) in the toolbar to open the character management panel
  2. Click "New Character"
  3. In the Basic tab, fill in name, description, personality, scenario, first message, example dialogues, etc.
  4. Optionally upload an avatar image (PNG/JPG)
  5. In the Voice tab, configure voice synthesis (optional; see next section)
  6. Click Save

Importing Character Cards (CCv3 / SillyTavern Compatible)

CodePapr is compatible with the chara-card-v3 specification and can import characters from other tools:

  1. Click the "Import Character Card" button in the character panel
  2. Select a PNG file (JSON embedded in the image's tEXt/iTXt chunk) or a JSON file
  3. Character information is automatically parsed; PNG images are automatically set as avatars
  4. Review and adjust the imported fields, then click save

Supported PNG chunk keywords: chara, ccv3, character, character_card

Exporting Character Cards

Click a character's Export button in the character list to export it as a PNG character card. The PNG embeds the complete CCv3 JSON and can be used in tools like SillyTavern.

Activating/Switching Characters

Click a character name in the character list to activate it. The currently active character will display an "Active" marker. Every Agent response will be delivered in that character's persona.

Character personas are placed in the Session Bootstrap (not in the system prompt's ImmutablePrefix), so switching characters does not break the DeepSeek prefix cache.

Tip: Character roleplay does not affect the Agent's code understanding and execution abilities. The Agent can still search projects, modify files, and run commands — only the output tone and style will match the character setting.

Voice Synthesis (TTS)

CodePapr integrates the GPT-SoVITS voice cloning engine, capable of synthesizing a character's text replies into speech locally. Only 3-10 seconds of reference audio are needed to clone a character's voice.

TTS Data Flow: ChatPanel → useTtsPlayer (React Hook): streaming text → sentence splitting → queue management → Rust TTS module → GPT-SoVITS Python Server (local port 9880) → rodio (Rust audio library) playback

Installing GPT-SoVITS

First-time voice usage requires installing GPT-SoVITS. There are two installation entry points:

  • Click the TTS speaker button on the ChatPanel; if not installed, an installation wizard will auto-launch
  • Trigger installation in the Voice Tab of the character editing panel

The installation wizard auto-completes 5 steps: check Python → clone GPT-SoVITS repository → pip install dependencies → download pretrained models (about 2GB, using hf-mirror source) → verify.

Requires Python 3.10+ already installed on the system. The installation process writes to ~/.codepapr/gpt-sovits/.

Configuring Voice for a Character

  1. Click the Character Avatar Button in the toolbar to open the character editing panel
  2. Switch to the Voice Tab and enable "Enable Voice Output"
  3. Upload Reference Audio:
    • Duration 3-10 seconds (5 seconds recommended); too short gives poor cloning, too long gets truncated
    • Format WAV / MP3 / M4A / AAC; sample rate 16kHz or higher
    • Content: clear human voice, no background music, noise, or reverb
  4. Fill in Reference Text: must match the audio content word-for-word; otherwise cloning quality will be poor
  5. Select Reference Audio Language and Speaking Language (supports Chinese, Cantonese, English, Japanese, Korean, and mixed modes)
  6. Adjust parameters:
    • Speed: 50% - 200%
    • Synthesis Speed: only 4 / 8 / 16 tiers. 4=fastest, 8=balanced, 16=highest quality
    • Merge Sentences: 1-5, merge this many sentences in one synthesis batch to reduce round trips
  7. Click the "Preview" button to preview the effect
  8. Click Save when satisfied

Current Playback Mode

The current UI uses WebSocket batch streaming (ws-batch) as the default and only effective mode: all sentences are sent in bulk over a single persistent WebSocket connection and returned one by one, with first-word latency around 1-2 seconds and smooth inter-sentence transitions.

The code layer retains three modes: whole, streamed-pipeline, and streamed-pcm, but the character editing panel has not yet exposed a switch for them; users need not worry about this.

Voice Fine-tuning

For higher audio quality requirements, use the fine-tuning feature in the Voice Tab:

  1. Ensure reference audio and reference text are configured and the preview passes
  2. Click "Generate Training Data": the LLM generates about 500 words of dialogue script based on the character setting; GPT-SoVITS auto-synthesizes about 2 minutes of training audio, no manual recording needed
  3. Click "Start Fine-tuning": background training, typically 30-60 minutes; you can close the window
  4. After training completes, check "Use Fine-tuned Model": timbre is more stable, synthesis is faster, synthesis speed can drop to 4 (fastest tier)

Playback Controls

  • Auto-read: Characters with voice enabled will auto-read their AI replies aloud
  • Replay: Hover over any AI reply to see a “Replay” button to re-read that message
  • Stop: Canceling the current Agent message will interrupt ongoing reading
  • Service Control: The TTS speaker button on the ChatPanel starts the GPT-SoVITS service or views service logs/status
GPU Warmup (Apple Silicon): On M-series Macs, after starting the TTS service for the first time, you can manually click the “GPU Warmup” button in the Voice Tab of the character editing panel. This pre-compiles the Metal GPU kernel to avoid a 5-15 second stall on the first synthesis. Warmup is only effective on Apple Silicon.
Audio Quality Tip: Reference audio is best recorded in a quiet environment, avoiding background noise. Reference text must match the audio content exactly. Quality improves significantly after fine-tuning, especially for Chinese and Japanese.

Config Files & Rules

.CodePapr/AGENTS.md — Global Project Rules

Project-wide rules are injected into the main Agent and all sub-agents. Good for:

  • Code style and directory conventions
  • Build, test, and release commands
  • Paths or behaviors that must not be changed
  • Project background and acceptance criteria
Auto-injection Flow: The agent looks up rule files in the following priority order and merges them into the stable system prompt:
1. .CodePapr/AGENTS.md
2. .CodePapr/rules.md
Missing files are silently skipped.

.CodePapr/memory.md — Cross-Session Project Memory (Auto-Organized)

During work, the Agent automatically discovers project-specific patterns, pitfalls, and conventions and writes them into the memory file. Automatically loaded at the start of the next session, helping the Agent avoid repeating past mistakes. The file is automatically reorganized when it exceeds 200 lines to prevent unbounded growth.

  • Auto-accumulation: When the Agent discovers project-specific knowledge, it uses write to append to .CodePapr/memory.md, with each entry prefixed by ## YYYY-MM-DD Topic
  • Auto-loading: Injected into bootstrap context at the start of each session, without affecting system prompt cache
  • Auto-organization: At session start, if memory.md > 200 lines, or context compression / /compact triggers a pending flag; after the current round's Agent reply completes, the fast model asynchronously deduplicates, merges, and condenses the memory, then writes it back to the file
  • Non-blocking: Organization is fire-and-forget async; the current session uses old memory, the next session uses the organized version; on failure, silently degrades to rule-based dedup without affecting the main flow
  • No new tools: Organization is triggered by store-layer background logic, invisible to the model, not breaking ImmutablePrefix cache
  • Recording principles: User preferences, project conventions, error patterns and solutions, architectural decisions; do not record general programming knowledge, temporary task states, or rules already in .CodePapr/AGENTS.md
Organization Trigger Chain:
T1: session start reads memory.md, lines > 200 → mark pending
T2: context compression (auto or /compact) → mark pending
T3: each agent reply complete → pending? → async fast model organize → write back memory.md
Goal: retain user preferences / project conventions / error patterns / architectural decisions, keep within 200 lines.

/compact — Force Context Compression

Manually trigger conversation compression, merging earlier messages into structured checkpoints to free token space:

  • Force mode: Not limited by maxConversationRounds and maxContextTokens thresholds
  • Local command: Zero token cost; calls the existing compression pipeline to generate checkpoints
  • Incidentally triggers memory organization: After successful compression, marks memory.md as pending; next round's agent reply triggers async organization
  • Use case: When approaching context limits or responses slow down, compress to restore smooth conversation

Configuration Entry Points

The "Config" entry in the desktop project header can:

  • Create/edit .CodePapr/AGENTS.md (generates a default template if none exists)
  • Create/edit/delete custom sub-agents (.CodePapr/agents/*.md)
  • Create/edit/enable/disable/delete Skills (.CodePapr/skills/**/SKILL.md)

Data Location Overview

PathPurpose
~/.codepapr/codepapr.sqliteApp-level settings, sessions, and cache statistics
~/.codepapr/lsp-tools/Managed LSP tool download cache (downloaded on first need, reused afterwards)
<workspace>/.CodePapr/project.sqliteProject-level state, chat history, cache statistics
<workspace>/.CodePapr/memory.mdCross-session project memory; auto-accumulated by Agent + auto-organized when exceeding 200 lines
<workspace>/.CodePapr/skillsProject-level skill files
<workspace>/.CodePapr/agentsProject-level sub-agent definitions
<workspace>/.CodePapr/commandsProject-level custom commands
<workspace>/.CodePapr/downloads/Default download directory for the Scout sub-agent
~/.codepapr/voices/Character reference audio files
~/.codepapr/gpt-sovits/GPT-SoVITS installation and pretrained models

Code Editing & Diff Mechanism

Search/Replace Diff (YOLO Diff)

CodePapr's automated modifications do not rely on standard Git diff line numbers. Multiple localized modifications are preferentially generated as Search/Replace blocks:

<<<<<<< SEARCH
Existing code already in the file
=======
Replacement new code
>>>>>>> REPLACE

Application Rules

  • SEARCH must exactly match content in the target file
  • If the same SEARCH matches multiple locations, it is rejected to prevent unintended changes
  • A single batch modification validates all files and all blocks first; if any block fails, no file is written
  • Line endings are compatible with LF / CRLF
  • Failure information is fed back to the Agent context, triggering a re-read of the original file and self-healing retry

Recommended Use Cases

  • Localized modifications across multiple files
  • Fixing tests, lint, or type errors where context precision must be maintained
  • Agent mode requiring a machine-parseable, verifiable, and rollback-friendly modification format

Not Recommended For

  • Creating new files or full file rewrites → use the write file tool
  • Changing only a very small localized block → regular patch is more direct

Skills System

What is a Skill

A Skill is the main Agent's reusable operations manual, suitable for codifying search strategies, troubleshooting workflows, release checklists, review manifests, and project-specific working methods. It does not create an independent sub-agent but serves as project-level context for the model to select on demand.

Skill File Format

Organized as directory packages, placed under .CodePapr/skills/**/SKILL.md. Each directory can contain assets/, references/, scripts/, and other resources.

---
name: search
description: Conduct verifiable searches using public web, official docs, and community resources
---

# Search Skill

When a task requires public information, current facts, third-party API usage, or error troubleshooting:

- Official docs first, then GitHub issues/PRs, then community answers.
- Use double quotes for exact error strings, e.g. "Cannot find module".
- Limit to specific sites using site:, e.g. site:developer.mozilla.org fetch abort.
- Include the library name, version, runtime environment, and key error codes together.

Skill Loading Mechanism

  • At runtime, only the name + description of user-enabled Skills are injected into stable context
  • The model decides autonomously whether a Skill is needed
  • Only after selection is skill called to read the full content
  • Enable status is saved in .CodePapr/project.sqlite

Built-in search Skill

The default search Skill includes common reference sources and methods:

  • Official Documentation: Microsoft Learn, OpenAI, MDN, Node.js, npm, PyPI, Rust, Tauri, Vite, React
  • Code & Issues: GitHub repositories, issues, pull requests
  • Community Resources: Stack Overflow, package manager pages, maintainer blogs
  • Search Methods: site: to scope to a domain, double quotes for exact errors, package name plus version number

Agents & Sub-agents

Built-in Sub-agents

CodePapr comes with three built-in sub-agents that the main Agent can dispatch via the task tool without additional configuration:

AgentPurposeModelTools
exploreRead-only code analysis: search project files, locate symbols, analyze dependenciesfastread, graph, lsp, diagnostics, grep
scoutWeb search: find documentation, API references, latest resourcesfastweb_search, web_fetch, web_download, browser
mentorHigh-level architecture/algorithm/debugging guidance (no code writing, no tool usage)mentor*None

* Mentor uses the primary model by default; an independent mentor model can be enabled in settings (supports independent API Key, Base URL, and model selection).

Custom Sub-agents

Declare a sub-agent in .CodePapr/agents/<name>.md with YAML frontmatter + body. The main agent can delegate subtasks to it. An agent with the same name will override the built-in definition.

---
description: reviewer is responsible for reviewing current changes, identifying risks, and providing minimal fix suggestions
mode: subagent
model: fast
temperature: 0.2
tools:
  read: true
  grep: true
  diagnostics: true
  git: true
  write: false
  exec: false
---

You are reviewer, a read-only code review sub-agent.

Responsibilities:
- Read the goal, relevant files, and current diff delegated by the main agent.
- Prioritize finding real bugs, behavioral regressions, missing edge-case handling, and absent verification.
- Provide minimal fix suggestions, indicating which files to modify and what verification commands to run.

Boundaries:
- Do not directly modify files by default.
- Do not repeatedly summarize irrelevant code style; only report findings that affect correctness, reliability, or maintainability.

Output Format:
1. Findings: List issues by severity
2. Suggested Fix: Provide the minimal fix direction
3. Verification: List recommended verification commands

Sub-agent Configuration Reference

  • model: Override model; options: fast (fast model) or a specific model name
  • temperature: Temperature parameter; optional numeric value
  • tools: Tool switches; defaults to inheriting all tools; declaring an empty object {} means no tools
  • The filename (without .md) is the sub-agent name; same name overrides built-in agents
  • Modify description to tell the main agent when to invoke it
  • Modify tools to control read/write/command permissions

Sub-task Mechanism (Two Approaches)

ApproachTriggerDescription
Orchestration-layer auto-decompositionSystem auto-decisionIn Agent mode, when a task contains execution verbs and is sufficiently complex, the LLM decides whether to break it into 2-5 sub-tasks for parallel/serial execution
Task tool active delegationAgent actively invokesThe main Agent explicitly calls the task tool during reasoning to delegate a sub-task to an independent sub-agent (including built-in and custom)

Sub-agent Runtime Model

  • Each sub-agent has an independent Session, ToolRegistry (filtered by tools), and Provider
  • Maximum nesting depth: 2 levels (sub-agents cannot delegate to other sub-agents)
  • Sub-agents can execute up to 50 internal tool rounds (main agent: 500)
  • Explore and Scout use the fast model; Mentor uses the independent mentor model or primary model
  • Custom prompts can be overridden in the Mentor tab of the settings panel

Difference from AGENTS.md

.CodePapr/AGENTS.md contains global project rules inherited by all modes and all sub-agents; custom Agents are dedicated sub-agents, only activated when the main Agent delegates sub-tasks via the task tool. The former is for writing "what all tasks must comply with," the latter for "who handles a certain type of task and which tools they can use."

Custom Commands

Built-in Commands

Commands support both --name (recommended) and /name (legacy compatibility) formats. A command's model field determines routing: undeclared uses the primary model, fast uses the fast model, and local commands cost zero tokens.

CommandFunctionModelExample
/helpList all commands and descriptionsLocal/help
/commandsAlias for /helpLocal/commands
/compactForce compress current session context, generate checkpoint to free tokensLocal/compact
/reviewReview current changes or specified scopePrimary/review src/App.tsx
/fixLocate and fix a specified issuePrimary/fix Login button not responding
/testAdd tests or run relevant testsPrimary/test src/utils/format.ts
/explainExplain a file, symbol, error, or implementationPrimary/explain handleSubmit function
/diagnoseDiagnose errors, slow operations, or abnormal behaviorPrimary/diagnose Page load exceeds 5 seconds
/refactorReorganize code while preserving behaviorPrimary/refactor src/components/Modal.tsx
/docUpdate documentation for changes or featuresPrimary/doc New refund endpoint
/newCreate new files, components, or features from scratch based on descriptionPrimary/new Create user password reset REST API
/optimizeAnalyze and fix performance bottlenecksPrimary/optimize src/pages/Dashboard.tsx
/searchSearch codebase for patterns, usages, definitions, or referencesFast/search auth middleware
/lintRun linter and fix violationsFast/lint src/
/cleanClean up dead code, unused imports, and leftover debug statementsFast/clean src/utils/
/commitStage changes and generate a well-formed commit messageFast/commit
/summaryProvide a high-level overview of a file, module, or entire projectFast/summary src/core/
/buildBuild the project and diagnose/fix build errorsFast/build

Custom Command Templates

Declare reusable prompt templates in .CodePapr/commands/<name>.md:

---
description: Review and fix lint
agent: code-reviewer
---
Please review the changes for $ARGUMENTS and fix any lint issues.
See rules at @.CodePapr/AGENTS.md
Current status: !`git status -s`

Template Syntax

SyntaxDescription
$ARGUMENTSAll arguments
$1 $2 ...The Nth argument
@pathInline file content
!`cmd`Execute a command and embed its output (simple commands only)
Usage: Type / in the input box to bring up the command palette, listing all available commands and supporting keyboard ↑↓ navigation. Type /command-name arguments to invoke. -- format is compatible with legacy usage.

MCP Tool Integration

What is MCP

The Model Context Protocol (MCP) is an open protocol that allows Agents to extend their capabilities through external tool servers. CodePapr includes a built-in MCP host that can connect to multiple MCP servers simultaneously, exposing external tools to the main Agent for invocation.

Each MCP tool is registered in the form mcp__<serverId>__<toolName>, appearing alongside the 25 built-in tools in the ToolRegistry.

Three Transport Modes

TransportDescriptionUse Case
stdioSubprocess + stdin/stdout JSON-RPCLocal command-line MCP servers (npx / uvx / python, etc.)
sseServer-Sent EventsRemote HTTP MCP servers, unidirectional streaming
streamable-httpStreamable HTTPRemote HTTP MCP servers, bidirectional streaming

Per-MCP Server Fields

FieldTypeDescription
namestringDisplay name
categorysearch / database / customCategory; search replaces web_search routing when enabled
transportstdio / sse / streamable-httpTransport mode
command / argsstringstdio only: executable command and arguments (arguments support quoted grouping)
urlstringsse / streamable-http only: HTTP endpoint URL
envmulti-line KEY=valuestdio only: environment variables; not exposed to model context
headersmulti-line Header-Name: valuesse / streamable-http only: HTTP request headers, typically for authentication
allowedToolscomma-separated, supports * wildcardAllowlist; empty means allow all
deniedToolscomma-separated, supports * wildcardDenylist; higher priority than allowlist
permissionModeread-only / read-write / dangerousPermission tier; determines whether confirmation is required before invocation
requireConfirmationbooleanRequires confirmation for every invocation
timeoutSeconds5–600Per-tool invocation timeout

Preset Examples

The desktop provides three ready-to-use MCP servers by default (all disabled; must be manually enabled):

NameCategoryCommandPurpose
DuckDuckGo Search MCPsearchnpx -y duckduckgo-mcp-serverAPI-key-free web search
Postgres MCPdatabasenpx -y @modelcontextprotocol/server-postgres <DSN>SQL queries, schema discovery; write-disabled by default
SQLite MCPdatabaseuvx mcp-server-sqlite --db-path ./database.sqliteLocal SQLite database analysis

stdio Server Example

# Name
DuckDuckGo Search MCP

# Transport
stdio

# Command / Arguments
command: npx
args: -y duckduckgo-mcp-server

# Environment variables (one KEY=value per line)
env:
HTTP_PROXY=http://127.0.0.1:7890
USER_AGENT=CodePapr/0.1.0

# Tool filtering
allowedTools: duckduckgo_web_search

sse / streamable-http Server Example

# Name
Remote Knowledge Base

# Transport
streamable-http

# URL
url: https://example.com/mcp

# Headers (one Header-Name: value per line)
headers:
Authorization: Bearer your-token-here
X-API-Key: your-api-key

Permission Modes

  • read-only: Read-only tools, no confirmation required for invocation (suitable for search, queries)
  • read-write: Writable tools, used with requireConfirmation
  • dangerous: Dangerous tools (e.g., execute shell, delete data); strongly recommended to enable requireConfirmation

Tool Filtering

Control the subset of tools exposed by each server via allowedTools and deniedTools:

  • Supports * wildcards (e.g. describe*, list_*)
  • Comma-separated for multiple patterns
  • Denylist takes priority over allowlist
  • Typical scenario: Postgres MCP defaults to allowedTools=query,describe*,list* + deniedTools=delete*,drop*,truncate*,update*,insert*, ensuring read-only access

Global Switches

SettingDefaultDescription
enabledfalseMCP master switch; all MCP servers are disabled when off
exposeToolstrueWhether to expose MCP tools to the Agent; when off, MCP is only a background connection and does not appear in the tool list
resultMaxBytes200,000Maximum bytes per tool call result (1KB – 5MB)

Recommended Common MCP Servers

  • @modelcontextprotocol/server-filesystem: Restricted filesystem access
  • @modelcontextprotocol/server-postgres: Postgres database
  • @modelcontextprotocol/server-github: GitHub API
  • @modelcontextprotocol/server-slack: Slack integration
  • mcp-server-sqlite: SQLite database
  • duckduckgo-mcp-server: Free web search
Cache Impact: The enabled MCP server list enters the ImmutablePrefix tool definition hash. Adding/removing/modifying MCP servers will break the prefix cache, requiring cache rebuild on the next request. It is recommended to finalize MCP configuration before starting a long session.
Test Connection: The MCP settings panel provides a "Test" button, allowing you to connect to a server, list tools, and apply filter rules without entering a session, to confirm the configuration is correct before enabling.

System Architecture

Architecture Overview

User → Desktop Workbench → Shared Agent Runtime ↓ ┌─────────────┼──────────────┐ Provider SQLite Tool Registry Adapters (App/Project) (Workspace Tools) State ↓ ┌──────────┼──────────┐ DeepSeek OpenAI Claude

Package-Level Responsibilities

PackageRolePrimary Responsibility
@codepapr/typesShared protocol layerUnified message, request, response, tool, and statistics types
@codepapr/commonCommon infrastructureLogging, hashing, and general utilities
@codepapr/coreRuntime coreAgent, Session, ToolRegistry, cache partitioning, ProjectGraph, Prompt assembly
@codepapr/apiProvider adapter layerRequestBuilder, CacheValidator, provider implementations
@codepapr/dbPersistence layerSQLite wrapper and repository
@codepapr/cliTerminal Agent entryAssembles provider, workspace tools, codepapr CLI entry (chat / ask / plan / agent / init / session / stats / config)
@codepapr/editorEditor contractFramework-agnostic Monaco types, markers, navigation, and static check contracts
@codepapr/uiDesktop workbenchReact, Zustand, Tauri, WorkerBackedAgent

Rust Backend Domain Modules

The Tauri backend is split into multiple modules by responsibility:

  • browser: Headless Chromium browser automation
  • shell: Foreground/background commands, persistent shell sessions, command safety guards
  • web: HTTP fetch, web page extraction, multi-engine search
  • workspace_fs: File listing, reading, writing, SEARCH/REPLACE diff, searching
  • task_queue: Heavy I/O operation serialization queue
  • db: App and project-level SQLite persistence
  • lsp: LSP server process management
  • symbol_provider: Tree-sitter fallback symbol extraction
  • mcp_host: MCP tool server host
  • shared: Path normalization, workspace path resolution, general utilities

Desktop Agent Bridge

ChatPanel → agentStore.sendMessage() → WorkerBackedAgent.chat() ├─ Worker Thread: Agent.chat() → LLM └─ Main Thread: tool execution → Tauri invoke

The desktop does not invoke the core Agent directly; instead, it offloads the LLM chat loop into a Web Worker via WorkerBackedAgent, ensuring long tasks do not block the UI.

Worker Crash Recovery & Streaming Snapshots

  • Crash capture: The main thread catches WorkerCrashError, automatically clears the current agent instance (next send creates a new Worker), and prepends "Agent Worker crashed." to the error message
  • Streaming snapshots: During streaming responses, approximately every 2 seconds (STREAM_SNAPSHOT_INTERVAL_MS), onStreamSnapshot is triggered to persist in-flight content to the project SQLite
  • Power-loss recovery: After a crash / forced quit / power loss, the next launch shows the conversation fragments written before the crash, preventing large chunks of progress from being lost

Tech Stack Overview

LayerTechnology
Frontend UIReact 18, TypeScript, Zustand 5, Monaco Editor, Tailwind CSS 3, Vite 8
Desktop FrameworkTauri 2 (Rust)
Rust Backendrusqlite (SQLite), headless_chrome (browser), tree-sitter (16 languages), LSP stdio bridge (15 language families)
Agent OffloadWeb Workers
TestingVitest 4, Playwright (UI E2E)

DeepSeek Cache Optimization

Three-Layer Prompt Injection

The system injects prompts in three layers, ordered from most to least stable to maximize DeepSeek automatic prefix cache hits:

LayerInjection LocationContentStability
Layer 1System PromptBase Identity + Rules + Mode + Workspace Path + Core ConstraintsReused across sessions
Layer 2Session BootstrapSkills Summary + ProjectGraph + Custom GuidanceFully stable across rounds
Layer 3Runtime User PromptMode Header + User Input + DiagnosticsChanges each round

Cache Hit Patterns

Multi-round tool calls in the same session: Round 1: [system][bootstrap][user] ← Fully cached Round 2: [system][bootstrap][user][asst_1][tool_1] ← Prefix hit Round 3: [system][bootstrap][user][asst_1][tool_1][asst_2][tool_2] ← Prefix hit Cross-session (same project): Session A: [system][bootstrap][user_A] → system+bootstrap cache reused by Session B Cross-session (different projects): Each has a different workspace path → the base+constraints portion of system prompt can still be reused

Key Invariants

  • User-custom prompts go into session bootstrap, not each round's user prompt
  • Skills go into bootstrap, not the system prefix
  • The workspace path only appears in the system prompt, not duplicated in bootstrap
  • Custom guidance appears only once in bootstrap

Language Intelligence & LSP

LSP Bridge Architecture

The desktop LSP uses a Tauri native host + stdio JSON-RPC architecture, managing language server subprocesses, stdin writes, stdout reader threads, and message queues via src-tauri/src/lsp.rs.

Supported Language Families (15)

LanguagePrimary LSP ServerTypeBuilt-in
TypeScript / JS / TSX / JSXtypescript-language-serverNode.js npmYes
HTMLvscode-html-language-serverNode.js npmYes
CSS / SCSS / LESSvscode-css-language-serverNode.js npmYes
JSON / JSONCvscode-json-language-serverNode.js npmYes
YAMLyaml-language-serverNode.js npmYes
PythonpyrightNode.js npmYes
ShellScriptbash-language-serverNode.js npmYes
C#csharp-ls / CodePapr.CSharp.Analyzer / omnisharp.NET binaryYes
Rustrust-analyzerNative binaryYes
JavaEclipse JDTLS + Temurin JRE 21Java binaryYes
C / C++clangd v22.1.6Native binaryYes
GogoplsNative binaryYes (best effort)
Swiftsourcekit-lsp (macOS Xcode toolchain)SystemNo
SQLsqlsNative binaryYes
MarkdownmarksmanNative binaryYes

C# LSP Priority Chain

C# has a multi-layer fallback mechanism for LSP:

  1. csharp-ls on system PATH or in ~/.dotnet/tools
  2. Release package built-in csharp-ls binary (generated/lsp-tools/csharp-ls/bin/)
  3. Built-in CodePapr.CSharp.Analyzer (custom Roslyn sidecar, supports cross-file and cross-ProjectReference resolution)
  4. dotnet run --project CodePapr.CSharp.Analyzer.csproj (development / source code fallback)
  5. omnisharp -lsp or OmniSharp -lsp on system PATH (static candidate only)
  6. Built-in tree-sitter symbol parsing (final fallback)

Managed Installation (Managed LSP)

The desktop manages on-demand installation of missing LSP tools at runtime:

  • Node-based (5 npm packages, providing 7 language services): typescript-language-server (TypeScript / JavaScript), vscode-langservers-extracted (HTML / CSS / JSON), yaml-language-server, pyright, bash-language-server — installed via npm using the built-in Node.js runtime v20.12.2
  • Binary-based (6): clangd v22.1.6, rust-analyzer, JDTLS + Temurin JRE 21, sqls, marksman, gopls — downloaded from official sources
  • C#: Installed via dotnet tool install -g csharp-ls, or uses the built-in Roslyn sidecar
  • Auto managed downloads can be disabled with CODEPAPR_DISABLE_MANAGED_LSP_DOWNLOAD=1

Tree-sitter Syntax Parsing (16 Languages)

Built-in tree-sitter syntax tree parsing used for ProjectGraph and fallback symbol extraction: TypeScript, JavaScript, Python, Rust, Java, Go, C++, Bash, C#, CSS, HTML, JSON, PHP, Ruby, Kotlin, Swift.

LSP Loading Strategy

  • No batch warm-up of LSP at workspace startup
  • The LSP for a file is asynchronously loaded only after the file is displayed
  • After generation/modification/save-to-disk, asynchronously refreshes diagnostics and symbol cache for the related file
  • The LSP backend caches full workspace diagnostics; cross-file errors are also detectable
  • The code area only shows hints when there are problems; stays clean when there are none
  • When upper-layer LSP is unavailable, falls back to built-in tree-sitter symbol parsing

Verification & Release

Verification Command Matrix

CommandScopeSuitable Scenario
npm run buildFull workspace buildAfter source changes, confirm artifacts can be generated
npm run testFull workspace testsDaily main regression
npm run test:e2eCLI E2EChanges to CLI, session assembly, or scripted provider
npm run test:e2e:uiPlaywright UI E2EChanges to desktop UI components, Toast, permissions, Code Review
npm run test:e2e:ui:installInstall Playwright ChromiumPreparation before first UI E2E run
npm run lintStatic analysisPre-commit quality gate
npm run auditSecurity auditBefore release or after dependency changes
npm run smoke:agent-toolsReal model tool smoke testChanges to tool selection, shell, browser interaction
npm run smoke:lsp-previewMulti-language LSP smoke testChanges to LSP hover, definition
npm run verifyMost comprehensive verificationBefore local release (includes cargo check)

Recommended Pre-commit Regression Order

npm run build
npm run test
npm run test:e2e
npm run test:e2e:ui
npm run verify

Browser dependencies must be installed before the first UI E2E run:

npm run test:e2e:ui:install

Desktop Release

# Development debugging
npm run debug

# Optimized desktop runtime (no packaging)
npm run release

# Generate installer (.dmg / .msi) and organize into Release/
npm run publish

Release Helper Scripts

  • macOS: ./publish-codepapr.command
  • Windows: publish-codepapr.cmd

Pre-release Checks

npm run release:prep
npm run publish:dry-run
Release Package Bundled Contents: The official desktop release package bundles the Node.js runtime v20.12.2 required for default LSP, 5 Node-based npm packages (typescript-language-server, vscode-langservers-extracted, yaml-language-server, pyright, bash-language-server, providing TypeScript / JavaScript / HTML / CSS / JSON / YAML / Python / ShellScript — 8 language services total), C# Roslyn sidecar + .NET SDK 10.0, JDTLS + Temurin JRE 21, clangd v22.1.6, rust-analyzer, sqls, marksman, and gopls. Users do not need to download these components separately for first-time use of default languages.

Typical Workflows

1. Understand First, Then Execute

Best when working with a repository for the first time or when requirements are unclear:

  1. Ask: Explain system structure, locate modules
  2. Plan: Output task checklist and verification plan
  3. Agent: Execute according to the checklist

2. Direct Fix

Best when you already know the target but don't want to manually search and fix:

Fix the incorrect cache statistics in packages/@codepapr/api.
First locate the statistics aggregation logic, then make a minimal fix, and finally run related tests.

3. Start Frontend and Preview In-App

Best for UI adjustments, page behavior verification, and preview integration:

  1. Let the Agent start a preview session or background command
  2. View the page in the in-app preview
  3. If you need to click pages, fill forms, or take screenshots, continue using browser tools

4. Persist Terminal Context for Sequential Operations

Best for scripts, REPL, interactive CLI, or multi-step shell workflows:

  1. Open a shell session
  2. Send commands continuously
  3. Proceed based on output
  4. Close the session when done

5. Review Historical Sessions and Costs

  • View the session list
  • View stats for a specific session (cache hits/misses/token usage)
  • Assess whether costs are reasonable against the current model settings

Cost & Model Selection

DeepSeek Model Reference

ModelContextMax OutputCache Hit InputCache Miss InputOutputConcurrency
deepseek-v4-flash1M384K0.02 CNY/M tokens1 CNY/M tokens2 CNY/M tokens2500
deepseek-v4-pro1M384K0.025 CNY/M tokens3 CNY/M tokens6 CNY/M tokens500
Note: Prices are subject to change; always refer to the DeepSeek official pricing page as the final authority.

How to Choose in CodePapr

  • Primary model defaults to deepseek-v4-pro — used for Ask, Plan, and Agent main execution flow
  • Fast model defaults to deepseek-v4-flash — used for context compression, sub-task planning, read-only lightweight sub-agents
  • Thinking effort (thinkingEffort) defaults to max (strongest reasoning); can be switched to high in the LLM settings tab

Cost Optimization Tips

  • Prefer cheaper models for Ask and lightweight analysis tasks
  • Use Plan before large changes to reduce ineffective execution rounds
  • Make task descriptions more specific to reduce the number of rounds the model spends searching and fixing
  • Keep system prompts and tool boundaries stable to maximize prefix cache hits

FAQ

1. Prompt says no API key after startup

First check whether the desktop settings have been saved, and whether the corresponding environment variables are set (DEEPSEEK_API_KEY / OPENAI_API_KEY / ANTHROPIC_API_KEY).

2. Installation or CLI commands won't run / not found

Confirm whether npm install and npm run build have been executed, and whether the current repository is under a OneDrive path causing .bin shim anomalies.

3. Agent encounters vite, tsc, eslint, or missing module errors

First suspect uninstalled dependencies or unbuilt local packages, rather than cloud sync or disk issues.

4. Browser tool unavailable

Usually because no detectable Chrome or Chromium-compatible browser is installed on the machine.

5. Tests still show old results after code changes

Many packages in this repository participate in tests or references through their respective dist entry points. After changing source files, if results look unchanged, first rebuild the affected packages, then run verification.

6. Build principles after modifying source code

Important: Modify source → build first → run affected tests → run broader verification. When results appear "not taking effect," first suspect the build wasn't applied, rather than suspecting a runtime anomaly.

7. How to use local models

In settings, you can connect to a local model provider (OpenAI-compatible endpoint) for offline or private deployment scenarios. With supported models, you can paste or drag images directly into the chat box as input.

8. Why does a popup appear when reading certain absolute paths

This is the desktop's external path permission mechanism. When the Agent attempts to read or list absolute paths outside the project, it requests your explicit authorization to ensure system files are not accessed without permission.

9. UI E2E tests won't run

First confirm whether Playwright browser dependencies have been installed:

npm run test:e2e:ui:install

UI E2E uses Chromium running in a mock environment without Tauri webview; real model configuration is not required.

Usage Tips

Beginners: First use Ask to understand the system → then Plan to see the scope of changes clearly → finally use Agent for actual execution.

Experienced users: Give clear goals directly in Agent mode → specify affected files and verification requirements → use the desktop to complete conversation, Git, preview, and browser integration.


CodePapr v0.1.0 · This tutorial is based on the project source code and documentation · Content is continuously updated