Cargo by Harness (CbH)
A DeepSeek Harness session mode, That gives everyone the ability to build reliable, efficient Rust software
Select Cargo by Harness when starting a new session in DSH. The Agent prioritizes retrieving crate sources and API signatures from the local Cargo cache rather than relying on memory. Core features:
- Local-cache-first retrieval
- Pure JS
macro_rules!expansion (zero external binaries) - Compile-feedback loop (check → fix → verify)
- Beginner-first guided workflow
- Physical isolation of publish/install commands
Screenshots

Building a full terminal Tetris game from a single prompt.

Use axum to build a “Hello world” example program that returns JSON.

Tracklogs During DSH Operation.
How It Works
CbH reuses DSH capability seams instead of reinventing them:
| DSH Capability | Plugin Usage |
|---|---|
@deepseek-ai/dsh-agent-preset |
Declares preset-cbh, exposing "Cargo by Harness" in the new-session mode selector |
ctx.tools.register |
Registers 4 model tools: cargo_search, cargo_read, cargo, cargo_expand |
ctx.commands.register |
Registers 6 deterministic slash commands; handlers answer directly without creating model messages |
ctx.skills.register |
Registers 4 bundled skills: rust-beginner-workflow, rust-compile-fix, rust-crate-choice, rust-daily-loop |
| File System | Reads local sources and rustdoc JSON under $CARGO_HOME/registry/ |
Data flow in one sentence: The model uses cargo_search / cargo_read to fetch real APIs from the local cache, cargo to execute toolchain commands with structured diagnostics, and cargo_expand to see through generated code from macro_rules!.
Tools
| Tool | Description |
|---|---|
cargo_search |
Searches local crate caches for crates, symbols, trait impls, or code patterns. Returns up to 20 item summaries without full doc bodies. |
cargo_read |
Reads exact signatures, docs, sources, implementations, or cache status by precise ID or full Rust path. |
cargo |
Executes daily toolchain commands (build/check/test/run/fmt/clippy/add/tree, etc.) with exit status and structured diagnostics. Does NOT expose publish, install, or yank. |
cargo_expand |
Pure JavaScript macro_rules! expander. Parses top-level use aliases and resolves definitions from locally cached crates. No external binaries or Rust builds required. |
Installation
If you haven't installed Rust yet, click here and follow the instructions to download and install it.
dsh plugin --profile <profile> add https://github.com/Lavaver/Cargo-by-Harness
After installation, select "Cargo by Harness" in the mode selector of a new DSH session. If you modify the bundle's sub-rows (e.g., adding skills), restart the DSH process to remount the preset composition.
Usage
Once in CbH mode, describe your Rust needs in natural language. The Agent follows a "local cache → minimal implementation → compile verify → fix" rhythm.
Example prompt:
I'm a Rust beginner. Help me write a hello world using axum that returns JSON, and make sure it runs.
The Agent will first use cargo_search to check the local axum version and API, write the code, run cargo check to verify, and automatically apply the rust-compile-fix skill when errors occur.
Retrieval Order
Both tools and commands follow the same non-skippable order:
$CARGO_HOME/registry/src/<index>/<crate>-<version>/— Cargo unpacked source.- Workspace's exact version:
Cargo.lockfirst, then manifest version requirements. - Cached rustdoc JSON as the structured layer; registry source remains authoritative for declarations,
whereclauses, and feature-gated code. - Only if steps 1–3 miss, perform a single minimal remote completion (crates.io
.crateor docs.rs rustdoc JSON), written under$CARGO_HOME/cbh-cache/before returning.
Commands
| Command | Purpose |
|---|---|
/cargo-doctor |
Diagnose Rust toolchain, workspace, lockfile, and target directory. |
/cargo-check [--all-targets] [--clippy] [--offline] [--timeout <s>] |
Compile-verify and deterministically summarize diagnostics (error/warning counts, error codes, file:line:col). |
/cargo-cache [status|list|prune|verify] |
Inspect, list, prune unreferenced cache entries, or verify cached crates. |
/cargo-fetch <crate>[@version] [--from crates.io|docs.rs|local] |
Perform one minimal remote completion. |
/cargo-workspace [deps|features|target] |
View current workspace dependency resolution. |
/cargo-item <crate::path> [--source] |
Read an exact single item, optionally including the source snippet. |
Commands perform deterministic, cacheable work only. Anything requiring natural-language judgment of "what to look up" is delegated to cargo_search / cargo_read tools.
Verification
Local check scripts are provided under the ../tools/ directory:
node tools/cbh-smoke.mjs # registry, version precedence, all commands
node tools/cbh-command-test.mjs # command registration and handlers
node tools/cbh-tool-test.mjs # fallback compiler path
node --import ./tools/register-cbh-stubs.mjs tools/cbh-tool-test.mjs # host compiler path + schema parity + cargo_expand
node tools/cbh-macro-expander-test.mjs # pure-JS macro expansion and graceful degradation
node tools/cbh-skills-test.mjs # bundled skill discovery and registration
node tools/cbh-cargo-run-test.mjs # cargo runner: whitelist, diagnostics, metadata
node tools/cbh-toolchain-test.mjs # real cargo doctor / check (fixtures)
node tools/cbh-remote-smoke.mjs # crates.io completion (throwaway CARGO_HOME)
tools/vendor/dsh-tools is a test-only extraction of @deepseek-ai/dsh-tools from the installed app, used to run the schema compiler outside the Host.
Verified Records: Real run of cargo check --offline on a failure correctly reported error [E0308] src/main.rs:2:22 mismatched types. /cargo-doctor correctly identified cargo 1.99.1 / rustc 1.99.1 / edition 2021.
Known Limitations
- No Procedural Macro Expansion:
#[derive], attribute macros, and functional proc-macros are left untouched;cargo_expandreturns the original code. Reason: Proc-macros require compilation execution, which pure static analysis cannot cover. Mitigation: The Agent can fall back tocargo_readto inspect the macro crate's source for alternative context. - No Glob Import Resolution: Imports like
use tokio::*;do not establish macro alias mappings. Reason: Static text cannot determine which macros a glob actually imports. Mitigation: When a bare call cannot be resolved,cargo_expandreports it as unresolved, and the Agent can switch to a fully qualified path. - No Macro Hygiene: Identifier capture checks are skipped during expansion. Reason: Pursuing compiler-level hygiene significantly increases the complexity of a pure JS implementation. Mitigation: Expanded calls are appended with
/* <- [original call] */comments to preserve a trace back to the original invocation. - Restart Required for Preset Reinstall: Modifying preset sub-rows (skills, tool rows) mounts new compositions at startup; a DSH restart is required to load them. Mitigation: This is inherent to the DSH preset mechanism and is documented.
License
MIT
No comments yet. Be the first to write one.