- 后端 (backend): the agent backend — the coding-agent engine that runs a session: JuCode's own engine, Claude Code, Codex, or an ACP agent. In code it is
BackendId/backendId; the daemon protocol calls itengine. It never means a server side, the daemon (the UI calls that 后台服务, "background service"), or a model provider (provider).
This is a lightweight Rust CLI/TUI workspace. The binary entry point is src/main.rs; agent state, sessions, tools, and LLM streaming live in crates/agent-core/; terminal rendering and input handling live in crates/tui/. Keep tests next to the module they cover with #[cfg(test)]. Build artifacts such as target/ and target-msvc/ are generated outputs.
crates/llm-provider-kit/ is a git submodule (github.com/JuCode-Team/llm-provider-kit) holding the provider layer: wire protocols (Responses/Codex/Azure, Anthropic Messages, Chat Completions), the vendored provider catalog (omp), provider templates, request builders, the blocking HTTP transport (transport), and the catalog-driven login flows (auth, oauth). It is a workspace member, so cargo fmt/clippy/test --workspace covers it. Changes to the provider layer belong there, not in agent-core; commit them in the submodule repo first, then bump the pointer here. JuCode-specific pieces stay in this repo: the gateway OAuth flow and auth.json layout (crates/agent-core/src/oauth.rs, config.rs), the gateway provider template and client name (crates/agent-core/src/providers.rs), and the agent loop, tool definitions, approvals, subagents, and safety classifier (crates/agent-core/src/llm.rs).
cargo run: run the local JuCode TUI.cargo test: run unit tests.cargo check: verify the project quickly without producing a final binary.cargo fmt: format Rust code with rustfmt.cargo clippy -- -D warnings: run lint checks and treat warnings as failures.cargo build --release: produce an optimized release binary.
Use Rust 2021 idioms and rustfmt defaults. Prefer small functions with direct control flow. Use snake_case for functions, variables, and modules; PascalCase for structs, enums, and variants; and SCREAMING_SNAKE_CASE for constants. Keep comments sparse and focused on non-obvious decisions.
Performance and lightweight behavior are the first priorities. Do not introduce heavy dependencies, framework layers, or broad abstractions without concrete need. Do not add multiple fallback paths just to make a feature appear to work without evidence; prefer one explicit, testable path and clear error handling.
This project implements a standard MCP client (stdio and streamable HTTP transports, no tokio — blocking I/O plus threads) alongside skills; MCP support must stay dependency-light (hand-rolled JSON-RPC over serde_json, HTTP via the existing blocking ureq). See docs/mcp.md. Sub-agent functionality is built in, so do not design a separate subsystem for it.
Config::load_or_createrewritesconfig.json(keys it does not know are kept, but concurrent writers race on the file); code that runs per request or concurrently reads it withConfig::load_existing.- Do not enable
ureq'stry_proxy_from_env: it readsALL_PROXYfirst, has no SOCKS support built in and ignoresNO_PROXY, so a common shell proxy setup fails every request. - Engine
Optionscarried from one open to the next (a restart, an idle close's kept options) must drop the per-open fields:resume,resume_at(a rewind point) anddirs. A rewind point carried over silently cuts the conversation back. - An engine's
agent_runsentries saystatus; only a workflow's nested agents saystate. Code reading run states reads both (seeengines::Snapshot::holds). - A
/logincan replace the saved JuCode login with another account's while the daemon runs, with no logout in between. Anything tied to the account (the relay registration, devices approved under it) must compare whose login is saved (relay::token_user), not only whether one is.
Keep the TUI minimal and fast. Chat history may use native scrolling; avoid complex custom scroll systems unless required. Use a restrained palette with only a few semantic colors. Theme selection is allowed, but themes must remain simple and readable.
Add focused unit tests for state transitions, commands, text wrapping, cursor behavior, and candidate filtering. Name tests after behavior, for example clear_command_resets_history. Run cargo test before submitting changes; run cargo clippy -- -D warnings for architecture changes.
Git history currently has only Initial commit, so keep commit messages short and imperative, for example Add theme setting or Simplify chat scrolling. Pull requests should include a concise description, test results, and screenshots or terminal captures for visible TUI changes. Call out dependency additions.