dim README

项目的 README,来自 github.com/arcships/dim。合并为一个 markdown 文件:README.md。

DimAgent logo above a green wave of light

Dim

Dim is a paradigm for general-purpose agents that grow into the environments they inhabit.

Rust toolchain 1.100.0 npm alpha version MIT license Join us on Discord

arcships/dim on Trendshift

An event-driven Timeline connects what an agent senses to what it does next. The runtime is built entirely from plugins. A plugin written in Rust, TypeScript or Python can give the agent a new way to act and the vocabulary to understand when to use it.

In the Rust alpha, you can ask Dim to write a TypeScript tool for itself in a session with permission to do so. Once the plugin loads, Dim can call the tool on its next model request, edit the implementation and reload it in the same session. Plugin authoring inside Dim

Install

Install the Rust alpha from dimcode-alpha and launch it with dima. We plan to ship the Rust implementation through the existing dimcode npm package and its dim command. Today that package distributes the earlier TypeScript CLI.

With Node.js ^22.19.0 || >=23.11.0 and npm optional dependencies enabled, run this from a repository you want to explore:

npm install -g dimcode-alpha@alpha
dima

Add a provider with /connect (or /provider), sign in to DimAgent with /login, or select a configured model with /models. Type ls in the chat and press Enter. In this session Dim asks to run ls -la in runtime/plugins. Choosing Allow once lets it list the three plugin directories.

A user sends ls in Dim chat, approves one directory listing, and gets goal, plugin-authoring and workflow.

For a read-only investigation, start dima --permission read-only in the retry example workspace and ask:

Read src/retry.py to see what happens when every attempt fails. Open a branch to read tests/test_retry.py. Does the existing test cover that case?

Use /lines to follow either investigation. To inspect the events that connect them, see Timeline export.

Safety. Read-only mode allows workspace reads and refuses agent file writes and shell commands. Process isolation is configured separately. Plugins, hooks and MCP servers can execute code when enabled. Project-supplied entries start disabled until you enable them locally. Permission controls · Plugin and command trust

How Dim adapts

Clients, tools and model protocols

The Rust harness can be embedded as a library. The App Server hosts it with persistence and workspace tools, and exposes sessions to clients. The terminal CLI is one such client. Architecture · Harness foundation

Entry point What it connects
Native CLI and Web The CLI keeps output in terminal scrollback. Open /web for the Web workspace, /resume to reconnect to a saved session, or use dima --prompt TEXT for a single turn. CLI contract · Web workspace
Agent Client Protocol (ACP) ACP clients such as acpx can launch dima acp over stdio. The gateway connects to the local App Server and handles protocol I/O, session projection and reconnection. Model selection and managed login depend on the daemon’s capabilities. ACP implementation · Client acceptance, including Lody
Model Context Protocol (MCP) MCP servers supply tools alongside native tools. Servers supplied by an ACP client are scoped to its session and their configuration is discarded afterwards. Older daemons without this capability ignore the list. The gateway supports one workspace root. Session-scoped MCP · MCP OAuth
Model providers Aimux connects the harness to OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, Gemini GenerateContent and compatible chat endpoints. The optional Dim account plugin supplies managed login. Model host · Dim account plugin

An ACP client can also start a source-built binary with an explicit home and model configuration:

./target/debug/dimcode acp \
  --home /absolute/path/to/isolated-home \
  --model-config /absolute/path/to/model.json

API-key setup

For Bash, from a source checkout:

mkdir -p .dev
cp crates/dim-agent-aimux/examples/openai.json .dev/model.json
export OPENAI_API_KEY=your-key

In .dev/model.json, set the provider endpoint and credential environment-variable name. Set both defaultModel.modelId and the corresponding model entry’s id to a model your account can use. Start the installed alpha with that configuration:

dima --model-config "$PWD/.dev/model.json" --permission read-only

The alpha keeps its state in ~/.dimcode-alpha and can coexist with the earlier CLI. Non-alpha Rust builds use ~/.dimcode by default. Sessions and account files are not automatically migrated. API-key providers work independently of the account plugin. Alpha package and platform details · App Server

Daily development

Install Rust through rustup. Cargo selects the version pinned in rust-toolchain.toml. The native API-key build needs no Node or pnpm. Run the following from the repository root. Build prerequisites

./dev --model-config "$PWD/.dev/model.json"

To use the same configuration on later runs, copy .env.example to the ignored .env.dev and set DIMCODE_MODEL_CONFIG to the absolute JSON path. Leave DIMCODE_PROVIDER and DIMCODE_MODEL unset to use its default, or set both to select a catalog entry. The launcher rebuilds the native executable, restarts the development daemon and retains sessions under ~/.dimcode-dev. Use DIMCODE_HOME or --home for another isolated home and --cwd for another workspace. Development contract

./dev --prompt "Explain this project"  # run one turn, then detach
./dev --resume SESSION_ID             # reconnect to the saved session
./dev restart                         # rebuild and restart
./dev stop                            # stop without building
./dev web                             # serve the Web workspace until Ctrl+C
./dev check                           # run formatting and compilation checks

To build without the launcher:

cargo build --locked -p dimcode
./target/debug/dimcode --home /absolute/path/to/isolated-home \
  --model-config "$PWD/.dev/model.json"

The CLI also accepts redirected stdin for a single turn. Ctrl+C during a turn requests a stop and waits for it to settle. At idle, Ctrl+C or EOF detaches. Empty approval answers deny the action, and a noninteractive run that needs approval exits with a nonzero status. dimcode --help and --version work without starting a daemon.

Workspace

Code Responsibility
Runtime, types, capabilities Agent and session lifecycles, Timelines, event contracts, input, model execution, permissions and branches
App Server, client, ACP gateway Session hosting, persistence, RPC transport, product events, questions and protocol adapters
dimcode, native CLI, npm One executable for the CLI and its app-server subcommand, plus platform packaging and command aliases
Model host, Dim account Model protocols and account-enabled builds. Account OAuth client IDs are supplied at build time
Tests, xtask Extension and integration flows, architecture boundary checks, generated graphs and measurements

Verify

cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
cargo run --locked -p xtask -- check
node --test scripts/*.test.mjs

Public source verification uses local HTTP fixtures for model flows. For standalone binaries, node scripts/build-all.mjs builds the release targets or accepts a single target such as --target darwin-arm64. The resulting dist/dimcode-<platform> executable includes the App Server. Web assets can be installed separately or compiled in with the embedded-web Cargo feature. Cross-compiling the script’s Linux and Windows targets requires Zig, cargo-zigbuild and the corresponding Rust target. GitHub-hosted runners build the draft GitHub Releases. Build environment · Release packaging and cross-compilation · Release procedure · Documentation index

Third-party components and licenses

Dim’s original source is licensed under MIT. The distribution retains upstream licenses and copyright notices. Distribution notices

Component Use and attribution
rutis Plugin loading, named services and cross-language bindings. Dim’s rutis integration
Aimux Model protocol implementations, taken from crates.io as aimux-core, aimux-provider-utils, aimux-providers and aimux-stream, distributed under MIT. Upstream
grok-build and Ratatui The native terminal uses components from xAI’s grok-build, including its Ratatui-derived inline terminal. The distribution carries the Apache-2.0 license and upstream attributions under licenses/grok-build/. Source and revision · Notices
Rust, Web and plugin dependencies Native archives include licenses/RUST-THIRD-PARTY-NOTICES.txt, which covers the Rust dependency licenses, aimux among them. The Web workspace ships THIRD-PARTY-NOTICES.txt, including the SIL Open Font License for Geist and Geist Mono. Bundled TypeScript plugins retain their npm license files. Full inventory

dim (arcships/dim)

正在搜索数据库…

605 ·GitHub
这是什么?Dim 是一种面向通用智能体的范式。一个由事件驱动的 Timeline 把智能体感知到的信息与它接下来要执行的动作连接起来,整个运行时由插件构成。
它是库,还是可以直接运行的工具?两者皆是。它以终端智能体的形式运行,通过 dima 命令启动;Rust 版的 harness 也可以作为库嵌入,放在 App Server 后面使用。
怎样才能把它跑起来?从 dimcode-alpha 安装 Rust 测试版,然后在你想探索的仓库里运行 dima,接着用 /login 登录,或用 /models 选择模型。
运行之前需要先装 Node.js 或 Rust 吗?README 中 npm 风格的命令需要 Node.js ^22.19.0 或 >=23.11.0,并且启用可选依赖。从源码构建需要通过 rustup 安装 Rust;而原生 API 密钥版本的构建则两者都不需要,也不需要 pnpm。
npm 包现在就是 Rust 版本了吗?还不是。Rust 测试版来自 dimcode-alpha,而现有的 dimcode npm 包仍然附带早期的 TypeScript CLI。早期 CLI 的会话和账户文件不会自动迁移。
支持哪些操作系统?构建脚本通过 node scripts/build-all.mjs 生成发布版二进制文件,使用 --target 可以只构建其中一个,例如 darwin-arm64。Linux 和 Windows 目标同样涵盖在内,但交叉编译它们需要 Zig 和 cargo-zigbuild。
智能体能在运行时扩展自身吗?可以。在 Rust 测试版中,如果你在某个会话里授予权限,Dim 就能为自己编写一个 TypeScript 工具,在下一次模型请求时调用它,并在修改后重新加载。
插件如何扩展 Dim?用 Rust、TypeScript 或 Python 编写的插件可以新增一种动作,说明何时使用它,并为它发出的信号注册指南条目。
旁支调查是如何工作的?子分支会继承父分支的历史记录,并与其共享工作区,因此两条工作线可以交换发现,同时各自构建自己的模型上下文。
我能在脚本中使用它吗?可以。dima --prompt TEXT 只运行一轮,重定向的标准输入也同样适用。非交互运行中如果需要审批,将以非零状态码退出。
作者
arcships
大小
77.9 MB
星标
605
更新
提交Nov 17
时长
1个月
提交 · 90 天