CLI 使用

DimAgent 只有一个 CLI 入口:dim。当前 npm 版本为 [email protected]

帮助

dim --help

概要

Usage: dim [command] [options]

Run without a command to open the interactive TUI.

Commands:
  acp                            Run ACP server over stdio
  exec [--trace[=/abs/path]] [--image <path>] [prompt]
                                 Run a one-shot prompt
  exec resume <id|--last>        Resume a session
  session <command>              Manage sessions
  provider <command>             Manage providers
  model <command>                Manage models and subagent model preference
  auth <command>                 Manage auth
  mcp <command>                  Manage MCP servers
  version                        Print version
  help                           Print usage

Interactive TUI

dim

工具审批在 TUI 内通过 /approvals 或 Settings 设置。模型、MCP、插件分别用 /models/mcp/plugins 配置。

One-shot Prompt (dim exec)

dim exec 面向脚本和 CI,输出写到 stdout。one-shot 默认使用 --policy full-access

# Basic usage
dim exec "Summarize this repo and propose next steps"

# Full access (default for one-shot)
dim exec --policy full-access "hello"

# Safer policies
dim exec --policy workspace-write "Run a focused code review"
dim exec --policy read-only "Review this repo without making changes"

# With verification and one repair pass
dim exec --verify "pnpm test" --repair-attempts 1 "Find the bug and fix it"

# With trace output
dim exec --trace "Find the bug and fix it"
dim exec --trace=/abs/path/to/traces "Find the bug and fix it"

# With image input
dim exec --image screenshot.png "Describe this UI"

# Read from stdin
echo "Review this code" | dim exec --stdin

# JSONL event stream
dim exec --json "Summarize this repo"

# Resume a session
dim exec resume <session-id> "Continue the work"
dim exec resume --last "Continue the work"

Notes:

  • --policy 只接受 read-onlyworkspace-writefull-access
  • one-shot 和 resume 会自动处理 ask 权限请求;read-only 与显式 deny 仍会阻止对应动作。
  • --allowed-tools <a,b> 追加 allow 规则;--disallowed-tools <a,b> 追加 deny 规则,并优先于 allow。
  • --mode agent|plan|goal 选择运行模式,默认是 agent
  • --provider <id>--model <id> 为本次 run 指定模型。
  • --tools <a,b> 限制可用工具;--mcp-server <id> 暴露指定 MCP server。
  • --reasoning-effort <effort> 在当前模型支持时设置本次 run 的 reasoning。
  • --session-id <id> 创建或复用指定 session。

dim auth

管理认证。

dim auth login --provider <id> --api-key <key>
dim auth logout [--provider <id>]
dim auth status

子命令:

  • login:使用 API key 认证 provider。
  • logout:删除已保存的凭据。
  • status:检查认证状态。

dim session

管理会话。

dim session list [--all]
dim session show <id>
dim session delete <id>
dim session export <id>
dim session rename <id> <name>
dim session clean [--older-than <days>] [--keep-last <n>] [--dry-run]

子命令:

  • list:列出会话(默认当前 cwd,--all 列出全部)。
  • show:显示会话详情。
  • delete:删除会话。
  • export:导出会话为 JSON。
  • rename:重命名会话。
  • clean:清理旧会话(--dry-run 预览)。

dim provider

管理提供方。

dim provider list
dim provider get <id>
dim provider add <id> --api-key <key> [--base-url <url>] [--model <model>] [--adapter <adapter>]
dim provider update <id> [--api-key <key>] [--base-url <url>] [--model <model>]
dim provider remove <id>
dim provider test <id>
dim provider switch <id>

子命令:

  • list:列出已配置的提供方。
  • get:显示提供方详情。
  • add:添加提供方。
  • update:更新提供方设置。
  • remove:删除提供方。
  • test:测试提供方连接。
  • switch:切换活跃提供方。

dim model

管理模型与 subagent 模型偏好。

dim model list
dim model get <id>
dim model set <id>

dim mcp

管理 MCP 服务器。

dim mcp list
dim mcp list --json
dim mcp get <name>
dim mcp add <name> -- <command> [args...]
dim mcp add <name> --command <cmd> [--args <comma-separated-args>] [--env <KEY=VALUE>]
dim mcp add --transport http <name> <url> [--header <KEY: VALUE>]
dim mcp add --transport streamable-http <name> <url>
dim mcp add-json <name> '<json>'
dim mcp remove <name> [--scope user|project]
dim mcp test <name>
dim mcp toggle <name> --enabled <true|false> [--scope user|project]

子命令:

  • list:列出合并后的 MCP 服务器、状态、scope、transport 和 warnings。
  • get:显示 MCP 服务器详情。
  • add:添加 stdio 或 HTTP MCP server,默认写入 user scope。
  • add-json:从单个 server JSON object 添加 MCP server。
  • remove:删除 MCP server;省略 --scope 时删除当前生效 scope。
  • test:临时连接 MCP server,发现工具后断开。
  • toggle:启用或禁用 MCP server;禁用后保留配置并从运行时工具集中移除。

示例:

dim mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem .
dim mcp add --transport http remote https://example.com/mcp
dim mcp add --transport http remote https://example.com/mcp \
  --header 'Authorization: Bearer ${MCP_TOKEN}'
dim mcp add-json remote '{"type":"streamable-http","url":"https://example.com/mcp"}'

MCP 配置文件位于 ~/.dimcode/v2/mcp.json,项目级配置位于 <project>/.mcp.json。项目级同名 server 覆盖用户级 server。

dim acp

启动 ACP server 模式,用于编辑器集成。

dim acp

见 ACP 页面。

dim version

输出版本与运行时信息。

dim version
dim --version
dim -v

该命令也会输出 npm 与 standalone binary 安装方式的升级诊断信息。

dim upgrade

升级 standalone binary 安装。

# Check for updates
dim upgrade --check

# Upgrade to latest
dim upgrade

# Upgrade to specific version
dim upgrade 0.2.28

# Quiet mode
dim upgrade --quiet

参数:

  • --check:检查更新并退出。
  • --quiet--background:抑制输出,适合后台更新。

npm/pnpm/yarn/bun 安装方式使用包管理器升级:

npm install -g dimcode@latest

Auto-update

自动更新检查默认开启。

  • 设置 DIMCODE_DISABLE_AUTOUPDATE=1 可禁用更新检查。
  • 设置 DIMCODE_AUTOUPDATE=0 可禁用后台安装。
  • Standalone binary 更新元数据存放在 ~/.dimcode/dimcode/bin/binary-upgrade.json

快捷键

  • Ctrl+P:命令面板
  • F1:帮助与快捷键
  • Enter:发送
  • Shift+EnterCtrl+J:换行
  • Ctrl+O:展开/折叠工具调用与思考
  • Ctrl+C:输入框有内容时清空输入,输入框为空时退出

斜杠命令

命令 作用
/new 新建会话
/sessions 列出或切换会话
/timeline/tl 跳转到某条用户消息
/resume 恢复暂停的队列
/redo 重新应用被撤回的消息
/compact 压缩对话
/skills 打开 skills 选择器
/approvals 工具审批(auto / normal / strict
/rename <title> 重命名当前会话
/connect 连接提供方,或添加自定义/本地提供方
/models 选择提供方与模型
/mcp/mcp-settings 管理 MCP 连接器与高级设置
/plugins 管理 Serper Search 等插件
/language 切换界面语言
/theme 切换亮/暗主题
/settings/config 打开自定义提供方设置
/exit 退出

数据存储位置

DimAgent v2 默认把本地数据存放在 ~/.dimcode/v2/

  • dimcode.sqlite:主存储数据库(会话、提供方等)
  • credentials.json:全局凭据
  • credentials/<providerId>.json:按提供方存储的凭据
  • mcp.json:MCP 服务器配置

使用 DIMCODE_HOME=/absolute/path 可迁移基础目录。

诊断

dim --debug
DIMCODE_DEBUG_LOG=/path/to/file dim --debug