Skip to content

DotCraft 完整配置参考

按子系统罗列配置字段、默认值和 JSON 示例。第一次配置请先读快速开始。想知道某个功能做什么、什么时候用它,先读对应的功能页,需要准确字段时再回到这里。

DotCraft 先读取全局 ~/.craft/config.json,再叠加工作区 .craft/config.json,工作区字段优先生效。配置字符串支持 $VAR${VAR} 环境变量占位。变量不存在时保留原始占位符。

从 CLI 查看配置

dotcraft config schema 打印当前构建认识的全部配置节和字段,包括类型、默认值、是否敏感和重载方式。dotcraft config show 打印某个工作区合并后的配置,其中 ApiKeyPasswordToken 的值会被遮蔽为 ***

bash
dotcraft config schema --section Tools.Web
dotcraft config schema --json
dotcraft config show --json

--section 接受配置节的显示名或 JSON 路径。--json 输出机器可读的格式,config show 无论是否加 --json 都是缩进的 JSON。config show 默认读取当前目录的工作区,用 --workspace 指定其他目录。

基础模型与 Provider

配置项说明默认值
ProviderId当前选择的个人 Provider id。为空表示未选择 Provider
ProviderPreferences按 provider id 保存的完整 MainAgent 偏好。当前 provider 必须存在有效条目{}
NetworkTimeoutSeconds全局模型请求超时时间,单位秒。Provider 可单独覆盖600
Providers个人模型 Provider 字典,通常写在 ~/.craft/config.json
SubagentMaxConcurrency最大并发 subagent 数量3
MaxSessionQueueSize每个 Session 最大排队请求数,0 表示无限制3
ConsolidationModel记忆整合专用模型,空值使用主模型
DebugMode控制台不截断工具调用参数输出false
EnabledTools全局启用的工具名称列表,为空时启用所有工具[]

个人 Provider 示例:

json
{
  "Providers": {
    "anthropic": {
      "DisplayName": "Anthropic",
      "Protocol": "anthropic",
      "ApiKey": "${ANTHROPIC_API_KEY}"
    },
    "openrouter": {
      "DisplayName": "OpenRouter",
      "Protocol": "openai-chat-completions",
      "ApiKey": "${OPENROUTER_API_KEY}",
      "EndPoint": "https://openrouter.ai/api/v1"
    }
  }
}

工作区模型选择示例:

json
{
  "ProviderId": "anthropic",
  "ProviderPreferences": {
    "anthropic": {
      "Model": "claude-sonnet-4-5",
      "Reasoning": {
        "Enabled": true,
        "Effort": "High",
        "Output": "Full"
      },
      "Speed": "Fast",
      "ContextWindow": {
        "Mode": "Max"
      }
    }
  }
}

ProviderPreferences 按 provider id 整条合并,不做字段级合并。全局和工作区同时配置同一 provider id 时,工作区记录完整替换全局记录。

偏好字段可选值说明
Model非空模型 id新 MainAgent 线程使用的模型
Reasoning.Enabledtruefalse模型支持时启用或关闭 reasoning
Reasoning.EffortLowMediumHighExtraHigh请求的思考程度
Reasoning.OutputNoneSummaryFull请求的 reasoning 输出
SpeedStandardFast请求的推理速率。不支持 Fast 时按 Standard 执行
ContextWindow.ModeDefaultMax请求的上下文窗口模式。不支持 Max 时恢复 Default

Provider 对象字段:

字段说明默认值
DisplayName面向用户显示的 Provider 名称。为空时使用 provider id
ProtocolProvider 协议:anthropicopenai-chat-completionsopenai-responses。空值默认使用 openai-chat-completionsopenai-chat-completions
ApiKeyProvider API Key。建议使用 ${ENV_NAME} 引用环境变量
AuthMethod认证方式。apiKey 使用静态 ApiKeychatgptOAuth 以 ChatGPT 订阅账号认证(仅限 OpenAI 协议,见下文)。无法识别的取值回退为 apiKeyapiKey
ChatGptAccountId由 Sign in with ChatGPT 流程写入的 ChatGPT 账号 id,不要手动编辑
ChatGptPlanType由 Sign in with ChatGPT 流程写入的 ChatGPT 订阅档位(freeplusprobusinessenterpriseedu),不要手动编辑
EndPointProvider base URL。为空时使用协议默认地址OpenAI 协议:https://api.openai.com/v1anthropichttps://api.anthropic.com
NetworkTimeoutSeconds单个 Provider 请求超时时间,覆盖全局 NetworkTimeoutSeconds
MaxOutputTokens单个 Provider 的默认最大输出 token 数,请求自己没有指定时使用该值
StreamMaxRetries单个 Provider 的流式响应断线重连次数,设为 0 可关闭 stream retry5
StreamIdleTimeoutMs单个 Provider 的流式响应空闲超时时间,单位毫秒300000
SupportsHostedImageGeneration是否为该提供商启用 hosted image generation。省略时,ChatGPT OAuth 和官方 OpenAI Responses API-key endpoint 默认按 true 处理。OpenAI-compatible 自定义 Responses endpoint 默认按 false 处理。提供商默认值

Sign in with ChatGPT 示例:

json
{
  "Providers": {
    "openai": {
      "DisplayName": "OpenAI (ChatGPT)",
      "Protocol": "openai-responses",
      "AuthMethod": "chatgptOAuth"
    }
  }
}

chatgptOAuth Provider 以 ChatGPT 订阅账号认证,不使用 API key。运行 dotcraft auth openai login 完成登录:它会把 OAuth token 包保存为用户数据目录下的 auth.json,把上面的 Provider 条目写进全局配置,在尚未选择默认 Provider 时将其设为默认,并在该 Provider 没有模型偏好时补一条默认偏好。这种模式下 ApiKeyEndPoint 会被忽略,最终生效的协议始终是 openai-responses,完整解析规则见配置模型 Providerdotcraft auth openai logout 会删除 token 并把 Provider 还原为 apiKey

Workspace Memory 与 Skills

配置项说明默认值
Memory.AutoConsolidateEnabled启用长期记忆自动沉淀true
Memory.ConsolidateEveryNTurns每个线程成功完成多少轮后触发一次长期记忆沉淀5
Skills.DisabledSkills当前工作区禁用的 skill 名称列表。被禁用的 skill 仍留在磁盘上,但不会注入 Agent 上下文[]
Skills.SelfLearning.EnabledSkill 自学习主开关。关闭后模型看不到 skill 编辑能力true
Skills.SelfLearning.VariantModeSkill variant 写入模式。enabled 把自学习更新写入工作区本地 skill variant,disabled 关闭 variantenabled
Skills.SelfLearning.MaxSkillContentChars通过自学习写入单个 SKILL.md 的最大字符数100000
Skills.SelfLearning.MaxSupportingFileBytes通过自学习写入单个 supporting file 的最大字节数1048576

Skill 自学习示例:

json
{
  "Skills": {
    "SelfLearning": {
      "Enabled": true,
      "MaxSkillContentChars": 100000,
      "MaxSupportingFileBytes": 1048576
    }
  }
}

SkillManage(action, ...) 参考:

Action必填参数用途
createname, content创建新的工作区 skill
patchname, oldString, newString局部修补 SKILL.md 或 supporting file
editname, content完整替换已有工作区 skill 的 SKILL.md
write_filename, filePath, fileContent写入 supporting file
remove_filename, filePath删除 supporting file

create 会触发 kind: skill 审批,破坏性删除也需要审批。自学习只写当前工作区 skill 目录。系统和个人 skills 视为只读,supporting files 只能写在 scripts/assets/ 下,绝对路径和 .. 路径穿越会被拒绝。

Compaction

配置项说明默认值
Compaction.AutoCompactEnabled启用基于阈值的自动压缩true
Compaction.ReactiveCompactEnabled启用对 prompt_too_long 错误的反应式压缩true
Compaction.ContextWindow模型上下文窗口(Token)。未配置时按当前有效模型推导模型映射值 / 256000
Compaction.MaxContextWindow推导模型上下文窗口时使用的上限。显式值保留256000
Compaction.SummaryReserveTokens为摘要输出预留的 Token20000
Compaction.SummaryMaxOutputTokens压缩摘要请求的最大输出 Token 数12000
Compaction.AutoCompactBufferTokens低于硬上限多少 Token 时触发自动压缩13000
Compaction.WarningBufferTokens到达自动阈值前多少 Token 发出 warning20000
Compaction.ErrorBufferTokens到达自动阈值前多少 Token 发出 error10000
Compaction.ManualCompactBufferTokens上报上下文压力上限时,预留在有效上下文窗口之下的余量3000
Compaction.KeepRecentMinTokens局部摘要后尾部至少保留的 Token 数10000
Compaction.KeepRecentMinGroups局部摘要后尾部至少保留的 API 轮次数3
Compaction.KeepRecentMaxTokens局部摘要后尾部最多保留的 Token 数40000
Compaction.MicrocompactEnabled启用微压缩true
Compaction.MicrocompactKeepRecent微压缩时保留的最近工具结果数8
Compaction.MicrocompactGapMinutes距离上次助理消息超过该分钟数也触发微压缩,0 表示禁用20
Compaction.MaxConsecutiveFailures连续失败次数达到该值时熔断3

模型能力目录

DotCraft 内置一份模型能力目录,用于配置上下文窗口和 Fast Mode 支持。使用以下文件补充或覆盖:

  • 全局:~/.craft/models.json
  • 工作区:.craft/models.json
json
{
  "defaultContextWindow": 256000,
  "models": {
    "my-256k-model": {
      "contextWindow": 256000
    },
    "custom-fast-model": {
      "contextWindow": 1048576,
      "fast": {
        "protocols": ["openai-responses"]
      }
    },
    "custom-anthropic-model": {
      "fast": {
        "protocols": ["anthropic"]
      }
    }
  }
}

workspace 条目覆盖全局条目,全局条目覆盖内置目录。同一模型规则的字段会独立合并。将 fast 设为 null 可禁用继承的 Fast 能力。模型规则使用不区分大小写的最长前缀匹配, 也会匹配 provider/custom-fast-model 这样的命名空间后缀。

Reasoning 与 PromptCaching

配置项说明默认值
Reasoning.Enabled是否请求 Provider 的推理支持false
Reasoning.Effort推理深度:None / Low / Medium / High / ExtraHighMedium
Reasoning.Output推理内容是否暴露在响应中:None / Summary / FullFull
PromptCaching.Enabled是否为匹配模型注入 prompt cache markertrue
PromptCaching.ModelPatterns大小写不敏感的模型名片段。为空则不匹配任何模型["claude"]
PromptCaching.Placementmarker 放置策略,当前仅支持 ConversationTailConversationTail
PromptCaching.TtlAnthropic cache TTL。为空使用默认 5 分钟,1h 使用长缓存

Deep-thinking adapter 文件:

  • 全局:~/.craft/model-thinking-adapters.json
  • 工作区:.craft/model-thinking-adapters.json

内置 catalog 会为未列入的 Anthropic 协议模型开放完整思考选项,但不会假设它们支持 Anthropic adaptive 请求形状。只有明确支持该形状的模型或 endpoint,才应添加 anthropicThinking 条目。

对 Anthropic-compatible provider,anthropicMessageContent 可以声明 DotCraft 推理历史应如何表示。内置 DeepSeek Anthropic adapter 会在发送历史前,把历史 TextReasoningContent 映射为 Anthropic-compatible thinking block。它不是通用的 unsupported-block 过滤器。

json
{
  "deepThinking": {
    "models": ["deepseek", "mimo", "my-thinking-model-"],
    "endpoints": ["deepseek", "my-thinking-gateway"]
  },
  "anthropicThinking": {
    "adapters": [
      {
        "models": ["my-adaptive-anthropic-model-"],
        "thinking": { "type": "adaptive", "display": "fromReasoningOutput" },
        "outputConfig": { "effort": "fromReasoningEffort" }
      }
    ]
  },
  "anthropicMessageContent": {
    "adapters": [
      {
        "models": ["deepseek"],
        "endpoints": ["deepseek"],
        "reasoningHistory": { "blockType": "thinking" }
      }
    ]
  }
}

Tools Security 与 Sandbox

配置项说明默认值
Security.BlacklistedPathsAgent 绝不能访问的路径,子路径也会接受检查[]
Tools.File.RequireApprovalOutsideWorkspace工作区外文件与 Shell 操作是否需要审批,false 时直接拒绝true
Tools.File.MaxFileSize最大可读取文件大小(字节)10485760
Tools.File.RipgrepPath可选 rg 路径。为空时依次尝试 DOTCRAFT_RG_PATHPATH 和内置回退""
Tools.File.SearchTimeoutSecondsGrepFiles 内容搜索最长运行时间,超时后返回超时结果30
Tools.Shell.TimeoutShell 命令超时时间(秒)300
Tools.Shell.MaxOutputLengthShell 命令最大输出长度(字符)10000
Tools.Shell.Background.Enabled是否启用后台终端会话true
Tools.Shell.Background.DefaultYieldTimeMs运行中命令返回后台会话快照前的默认等待时间1000
Tools.Shell.Background.MaxYieldTimeMs后台会话读取或写入可接受的最长等待时间30000
Tools.Shell.Background.MaxSessionsPerThread每个线程可同时运行的后台终端上限8
Tools.Shell.Background.MaxSessionsPerWorkspace每个工作区可同时运行的后台终端上限32
Tools.Shell.Background.IdleTimeoutSeconds预留字段。后台终端服务当前不执行该限制1800
Tools.Shell.Background.OutputMaxBytes预留字段。后台终端服务当前不执行该限制67108864
Tools.Shell.Background.OutputRetentionDays已完成或丢失终端的元数据与输出保留天数,不清理正在运行的终端7
Tools.Shell.Background.StallWatchdogSeconds预留字段。后台终端服务当前不执行该限制45
Tools.Shell.Background.DefaultReadMaxOutputChars终端快照默认返回的最大字符数10000
Tools.Web.MaxCharsWeb 抓取最大字符数50000
Tools.Web.TimeoutWeb 请求超时时间(秒)300
Tools.Web.SearchMaxResults联网搜索默认返回结果数5
Tools.Web.SearchProvider搜索引擎提供商:Bing / ExaExa
Tools.ResultLimits.MaxToolResultChars工具结果落盘前的默认长度上限(字符)。0 表示对使用全局默认值的工具不做限制50000
Tools.ResultLimits.SpillPreviewLines结果落盘时,预览中保留的首尾行数40
Tools.Lsp.Enabled是否启用内置 LSP 工具false
Tools.Lsp.MaxFileSizeLSP 打开或同步文件时允许的最大文件大小10485760
Tools.ImageGeneration.Enabled允许支持的 OpenAI Responses 提供商在对话中生成图片true
Tools.ImageGeneration.Model预留给图片客户端集成。对话生图使用当前 Responses 模型gpt-image-2
Tools.ImageGeneration.MaxReferenceImages预留给支持参考图的图片客户端集成5
Tools.Sandbox.Enabled是否启用沙箱模式false
Tools.Sandbox.DomainOpenSandbox 服务地址localhost:5880
Tools.Sandbox.ApiKeyOpenSandbox API Key
Tools.Sandbox.UseHttps是否使用 HTTPSfalse
Tools.Sandbox.Image沙箱容器 Docker 镜像ubuntu:latest
Tools.Sandbox.TimeoutSeconds沙箱超时时间(秒)600
Tools.Sandbox.Cpu容器 CPU 限制1
Tools.Sandbox.Memory容器内存限制512Mi
Tools.Sandbox.NetworkPolicy网络策略:deny / allow / customallow
Tools.Sandbox.AllowedEgressDomains自定义允许出站域名列表[]
Tools.Sandbox.IdleTimeoutSeconds空闲超时(秒)300
Tools.Sandbox.SyncWorkspace是否同步 workspace 到容器true
Tools.Sandbox.SyncExclude同步时排除的工作区相对路径,按路径前缀匹配。默认值用于避免敏感的 .craft/ 运行数据进入容器,建议在默认值上追加而不是整体替换[".craft/config.json", ".craft/sessions", ".craft/memory", ".craft/dashboard", ".craft/security", ".craft/logs"]

生成的图片默认保存在 Agent 数据目录的 generated_images/<threadId>/<callId>.png。连接远程电脑后,文件改为保存在远端工作区的 .craft/generated_images/<threadId>/<callId>.png。如果保存失败,对话仍会显示已生成的图片,并提示文件保存失败。

使用支持的 OpenAI Responses 提供商时,你可以在普通对话里直接让 DotCraft 生成图片。DotCraft 会请求 PNG 输出,并在支持富内容的客户端中以内联图片展示。

hosted image_generation tool 由两个开关共同决定,两者都为真才会注入:全局的 Tools.ImageGeneration.Enabled,以及提供商自己的 SupportsHostedImageGeneration。省略提供商字段时,ChatGPT OAuth 和官方 OpenAI Responses API-key endpoint 视为开启,OpenAI-compatible 自定义 Responses endpoint 视为关闭。自定义 endpoint 只有确认支持 hosted tool 时再开启。

个人本地 hardening 示例:

json
{
  "Security": {
    "BlacklistedPaths": [
      "~/.ssh",
      "~/.gnupg",
      "~/.aws"
    ]
  },
  "Tools": {
    "File": {
      "RequireApprovalOutsideWorkspace": true
    },
    "Shell": {
      "Timeout": 300
    }
  }
}

工具 allow-list 示例:

json
{
  "EnabledTools": ["ReadFile", "GrepFiles", "WebSearch"]
}

OpenSandbox 示例:

json
{
  "Tools": {
    "Sandbox": {
      "Enabled": true,
      "Domain": "localhost:5880",
      "Image": "ubuntu:latest",
      "NetworkPolicy": "allow",
      "SyncWorkspace": true
    }
  }
}

Automations Goals 与 Hooks

配置项说明默认值
Automations.Enabled是否启用 Automations 编排器true
Automations.PollingInterval轮询间隔00:00:10
Automations.MaxConcurrentTasks本地任务最大并发数3
Automations.TurnTimeout单轮对话超时时间00:30:00
Automations.WorktreeRetentionEnabled是否启用空闲自动化任务 worktree 清理true
Automations.WorktreeRetentionIdlePeriod干净自动化任务 worktree 进入清理候选前的空闲时间21.00:00:00
Goals.Enabled启用目标存储、AppServer 方法、目标上下文注入、用量统计和模型 Goal 工具true
Goals.AutoContinueEnabled允许 active 目标在线程空闲时自动继续true
Hooks.Enabled是否启用 Hookstrue
Hooks.State按稳定 hook key 保存的用户态配置。Desktop toggle/trust 会写入 EnabledTrustedHash{}

Automations.WorktreeRetentionIdlePeriod 必须至少为 14.00:00:00。Retention sweep 只会移除空闲、干净、且没有领先基础版本提交的受管自动化任务 worktree。

Automation AppServer 方法:

Method说明
automation/list列出自动化
automation/read读取自动化
automation/create创建自动化
automation/update检查版本后保存
automation/run排队执行一次
automation/delete删除自动化
automation/runs/list读取运行历史
automation/presets/list列出对话预设

Goal AppServer 方法:

Method说明
thread/goal/set设置、替换、暂停或恢复 Thread goal
thread/goal/get读取当前 Thread goal 状态
thread/goal/clear清除当前 Thread goal

Hook 命令放在 hooks.json,不是 config.json。DotCraft 会从 ~/.craft/hooks.json 加载全局 hooks,从 .craft/hooks.json 加载工作区 hooks,并从已启用插件的 hook 文件加载 plugin hooks。概念说明和 Desktop 操作入口见 生命周期 Hooks

Hook 快速示例(.craft/hooks.json):

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Exec",
        "hooks": [
          {
            "type": "command",
            "command": "node .craft/hooks/log-tool-call.js",
            "timeout": 10
          }
        ]
      }
    ]
  }
}

Hook matcher group 字段:

字段说明
matcher匹配工具名的正则。为空时匹配所有工具相关事件
hooks当前事件和 matcher 下按顺序执行的 hook handler 列表

Hook handler 字段:

字段说明
type支持 "command"
command要运行的 Shell 命令
timeoutHook 超时时间(秒)
if可选条件,例如 Bash(git commit:*)
shell可选 Shell 覆盖
statusMessage可选 UI 状态文案
async不阻塞当前动作,异步运行
asyncRewake允许 hook 反馈入队为后续 turn
rewakeMessage后续反馈的前缀
rewakeSummary简短后续反馈摘要

生命周期事件:

Event用途
SessionStart新会话开始时运行
UserPromptSubmit用户提交 prompt 时运行,早于 prompt 组装
PrePromptDotCraft 原生兼容事件,在组装后的 prompt 发送前运行
PreToolUse工具调用前检查或阻塞
PermissionRequest请求权限前运行
PostToolUse工具调用成功后记录、格式化或通知
PostToolUseFailure工具调用失败后运行
PreCompact / PostCompact上下文压缩前后运行
SubagentStart / SubagentStopsubagent 生命周期前后运行
Stopassistant 响应后运行,并可入队后续反馈
StopFailureStop hook 处理失败后运行

工具相关 Hook stdin 通常包含:

json
{
  "hook_event_name": "PreToolUse",
  "cwd": "/workspace/example",
  "sessionId": "thread-id",
  "session_id": "thread-id",
  "toolName": "Bash",
  "tool_name": "Bash",
  "toolArgs": {
    "command": "dotnet test"
  },
  "tool_input": {
    "command": "dotnet test"
  }
}

Turn 相关 Hook stdin 通常包含:

json
{
  "hook_event_name": "Stop",
  "cwd": "/workspace/example",
  "sessionId": "thread-id",
  "session_id": "thread-id",
  "last_assistant_message": "Agent completed the turn",
  "stop_hook_active": false
}

DotCraft 会同时输出 camelCase 和 snake_case 字段。JSON stdout 可以返回 hookSpecificOutput.additionalContext 注入模型可见上下文,也可以返回 decision: "block"reason 来阻塞支持阻塞的事件,或让 asyncRewake hook 入队后续反馈。完整工程协议位于 specs/features/lifecycle-hooks.md

退出码语义:

退出码含义
0成功,继续执行
2阻塞支持阻塞的事件,或为 rewake hooks 请求后续反馈
其他非零Hook 失败。DotCraft 记录失败并按该事件的运行时策略继续

Matcher 示例:

matcher匹配
WriteFile|EditFile文件写入和编辑
ExecShell 命令
.*所有工具

Desktop 会把每个 hook 的用户态写入 ~/.craft/config.json

json
{
  "Hooks": {
    "State": {
      "/workspace/.craft/hooks.json:pre_tool_use:0:0": {
        "Enabled": false,
        "TrustedHash": "sha256:..."
      }
    }
  }
}

Enabled: false 可以在不编辑来源文件的情况下停用单个 hook。TrustedHash 记录上次信任的规范化 hook 定义。来自 config 和 plugins 的 hooks 必须被信任后才会运行,修改后的 hooks 需要重新信任。Desktop 通常把插件 hooks 作为一个插件能力包整体信任,但保存的状态仍然是每条 hook 一条。

Plugin hook 文件使用同样的 hooks.json 结构。在 plugin hook 命令中,DotCraft 会展开 ${DOTCRAFT_PLUGIN_ROOT}${DOTCRAFT_PLUGIN_DATA},并注入同名环境变量。

运行日志

DotCraft 将工作区宿主的诊断信息写入 <workspace>/.craft/logs,将 Hub 的诊断 信息写入 ~/.craft/logs

字段说明默认值
Logging.Enabled将运行诊断信息写入滚动日志文件true
Logging.Console同时将诊断信息写入控制台。协议宿主使用 stderr,确保 stdout 只承载协议数据false
Logging.MinLevel最低日志级别:TraceDebugInformationWarningErrorCriticalInformation
Logging.Directory相对于宿主 .craft 目录的日志目录logs
Logging.RetentionDays启动时删除更早的滚动日志,0 表示不清理7
json
{
  "Logging": {
    "Enabled": true,
    "Console": false,
    "MinLevel": "Information",
    "Directory": "logs",
    "RetentionDays": 7
  }
}

运行日志包含时间、级别、进程 ID、类别、消息、异常和当前诊断 scope。原始 ACP 流量与按需启用的 session stream debug 记录使用独立文件,因为它们可能包含敏感内容或大量数据。

Entry Points 与 Services

配置项说明默认值
Acp.Enabled是否启用 ACP 模式false
DashBoard.Enabled是否启用 Dashboardtrue
DashBoard.HostDashboard 监听地址127.0.0.1
DashBoard.PortDashboard 监听端口8080
AppServer.ModeAppServer 传输模式:DisabledStdioWebSocketStdioAndWebSocketDisabled
AppServer.WebSocket.HostWebSocket 监听地址127.0.0.1
AppServer.WebSocket.PortWebSocket 监听端口9100
AppServer.WebSocket.Token远程 WebSocket 客户端需要使用的 token
ExternalChannels外部渠道注册表{}

Dashboard 示例:

json
{
  "DashBoard": {
    "Enabled": true,
    "Host": "127.0.0.1",
    "Port": 8080
  }
}

外部渠道注册示例:

Desktop 托管的内置 TypeScript 渠道:

json
{
  "ExternalChannels": {
    "qq": {
      "enabled": true,
      "transport": "managedWebsocket",
      "builtinModule": "channel-qq"
    }
  }
}

独立适配器:

json
{
  "AppServer": {
    "Mode": "WebSocket",
    "WebSocket": {
      "Host": "127.0.0.1",
      "Port": 9100,
      "Token": ""
    }
  },
  "ExternalChannels": {
    "wecom": {
      "enabled": true,
      "transport": "websocket"
    }
  }
}

平台连接、权限白名单和审批超时等渠道专属设置分别放在 .craft/qq.json.craft/wecom.json 等适配器配置文件中。TypeScript 渠道示例见渠道配置参考

Plugins MCP 与 LSP

配置项说明默认值
Plugins.EnabledPlugins当前工作区显式启用的插件 id 列表[]
Plugins.DisabledPlugins当前工作区显式禁用的插件 id 列表。禁用条目优先于启用条目,也优先于插件自身的默认状态[]
Plugins.PluginRoots.craft/plugins/ 之外额外维护的 plugin root 目录[]
Plugins.PluginRegistries用于发现插件目录的 plugin marketplace 来源[]
Plugins.DisableDefaultPluginRegistry忽略宿主提供的默认官方 plugin registryfalse
McpServersMCP 服务配置集合{}
Tools.DeferredLoading.Strategy工具延迟加载策略:OffAutoSimulatedNativeAuto
Tools.DeferredLoading.AlwaysLoadedTools始终预加载的 MCP 工具名列表[]
Tools.DeferredLoading.DeferThresholdMCP 工具数量达到该阈值后才延迟加载 MCP 工具10
Tools.DeferredLoading.MaxSearchResults每次延迟工具搜索最多返回的结果数5
LspServersLSP 服务配置集合{}
Tools.Lsp.Enabled是否启用内置 LSP 工具false

官方 DotCraft Desktop 和 Docker host 会通过 DOTCRAFT_DEFAULT_PLUGIN_REGISTRY_URL 提供默认官方插件市场。通过 Desktop 添加的市场来源保存在全局配置中。工作区中的 PluginRegistries 值遵循普通的工作区覆盖全局规则。Docker Stack 部署会把全局配置和 Marketplace 缓存持久化到 state/dotcraft

每个 McpServersLspServers 条目只接受当前 schema 定义的字段。出现未知属性时,配置解析会失败。

Plugins.PluginRegistries 条目字段:

字段说明默认值
Name市场标识。手动配置时必填且必须与市场文档一致,通过 Desktop 或 AppServer 添加时自动维护
SourceType来源类型:gitlocalarchive省略时自动推断
UrlGit URL、本地目录、归档 URL 或归档文件
Ref要检出的 Git 分支、标签或 commit来源默认值
SparsePathsGit checkout 中包含的仓库内相对路径[]
MarketplacePath来源根目录内的市场文档路径.craft/plugins/marketplace.json
LastUpdated最近一次成功添加或刷新的 UTC 时间
LastRevision最近一次成功获取的 Git revision

省略 SourceType 时,已存在的目录或归档文件按本地来源读取,其他值按归档 URL 处理。RefSparsePaths 只适用于 Git 来源。

来源格式、市场文档和生命周期见插件市场

插件设置文件

插件自定义设置不放在主 config.jsonPlugins 下。插件在 .craft-plugin/plugin.json 中声明 "settings": "./settings.schema.json",宿主读取两个独立文件:

作用域路径
个人<UserDataPath>/plugin-config.json,官方应用使用 ~/.craft/plugin-config.json
工作区<DataPath>/plugin-config.json,默认是 <workspace>/.craft/plugin-config.json

根对象直接以 canonical plugin id 为键:

json
{
  "acme.review-core": {
    "checklistLimit": 5,
    "tone": "concise"
  }
}

有效设置依次解析 schema 默认值、个人值和工作区值。对象递归合并,数组与标量整体替换。namespace 一旦包含未声明字段或非法值,就会整体失效。移除工作区值后,会重新显露下层的个人值或 schema 默认值。

这些文件只用于小型 JSON 配置,不能存放 blob、数据库或缓存。插件数据单独保存在:配置了 UserDataPath 时使用 <UserDataPath>/plugins/<id>/data,否则使用 <DataPath>/plugin-data/<id>。禁用、移除或重装插件都不会删除其配置 namespace 或数据目录。

本地插件开发覆盖示例:

json
{
  "Plugins": {
    "PluginRoots": ["/path/to/local/plugins"]
  }
}

MCP 示例:

json
{
  "McpServers": {
    "everything": {
      "command": "npx",
      "arguments": ["-y", "@modelcontextprotocol/server-everything"]
    }
  },
  "Tools": {
    "DeferredLoading": {
      "Strategy": "Auto",
      "DeferThreshold": 10
    }
  }
}

Tools.DeferredLoading.Strategy = Auto 时,所有模式都使用规范名称 SearchTools。OpenAI Responses 将它映射为 Provider 的 client-executed tool_search wire 类型,Anthropic 返回原生 tool reference,chat-completions 则在下一次模型请求中注入已发现的 schema。

Subagent 与 External CLI Profiles

概念和日常用法见 Subagents

配置项说明默认值
SubAgent.MaxDepthsession-backed subagent 的最大生成深度。第一级 subagent 深度为 11
SubAgent.MaxConcurrentSubAgents同一根线程子树内同时驻留的 session-backed subagent 上限。超出时自动关闭最旧的空闲 subagent,若驻留的 subagent 全部仍在运行则本次 spawn 失败16
SubAgent.ProviderPreferences按父线程 provider 保存的完整原生 subagent 偏好。缺少对应项时继承该线程完整的 MainAgent 偏好{}
SubAgent.MinWaitTimeoutMsWaitAgent.timeoutMs 接受的最小值,单位毫秒15000
SubAgent.DefaultWaitTimeoutMsWaitAgent 调用未传 timeout 时使用的默认毫秒数60000
SubAgent.MaxWaitTimeoutMsWaitAgent.timeoutMs 接受的最大值,单位毫秒3600000
SubAgent.EnableExternalCliSessionResume是否允许支持 resume 的 external CLI profile 复用已保存外部会话false
SubAgent.DisabledProfiles当前工作区隐藏和禁用的 subagent profile 名称列表[]
SubAgent.Roles工作区自定义 subagent role。同名条目覆盖内置 role[]

Role 示例:

json
{
  "SubAgent": {
    "MaxDepth": 2,
    "Roles": [
      {
        "Name": "docs-explorer",
        "Description": "Read-only documentation and code explorer.",
        "ToolAllowList": ["ReadFile", "GrepFiles", "FindFiles", "WebSearch", "WebFetch", "SkillView", "Exec"],
        "ShellAccess": "ReadOnly",
        "AgentControlToolAccess": "Disabled",
        "Instructions": "Inspect files, web sources, and non-mutating shell output such as `git diff`. Do not edit files, manage skills, or spawn agents."
      }
    ]
  }
}

SubAgent.Roles 的条目字段:

字段说明
Namerole 名称,也是 SpawnAgent.agentRole 使用的值
Descriptionrole 简短说明,会暴露给主 Agent
ToolAllowList精确工具允许列表。为空表示不额外限制候选工具
ToolDenyList精确工具拒绝列表,会在工具集合构建完成后移除
ShellAccess可达的 Shell 工具能走多远:None / ReadOnly / Full。与允许/拒绝列表叠加生效,而非取代。默认 Full
AgentControlToolAccessAgentTools 策略:Disabled / Full / AllowList
AllowedAgentControlToolsAgentControlToolAccessAllowList 时允许的 AgentTools 名称
Instructions作为 subagent 线程角色上下文消息送达的 role instructions
Mode可选 mode 覆盖
Model可选 model 覆盖
OverrideBasePrompt是否用 Instructions 覆盖基础 prompt。默认追加而不是覆盖

自定义外部 CLI profile 位于 SubAgentProfiles。工作区配置覆盖同名全局 profile。

json
{
  "SubAgent": {
    "EnableExternalCliSessionResume": true
  },
  "SubAgentProfiles": {
    "my-cli": {
      "runtime": "cli-oneshot",
      "bin": "my-cli",
      "workingDirectoryMode": "workspace",
      "inputMode": "arg",
      "outputFormat": "text",
      "supportsResume": true,
      "resumeArgTemplate": "--resume {sessionId}",
      "resumeSessionIdJsonPath": "session_id"
    }
  }
}

SubAgentProfiles 条目字段:

字段说明
runtimeRuntime 类型。外部短进程 CLI 使用 cli-oneshot
binCLI 可执行文件名或绝对路径
args固定参数列表
workingDirectoryModeworkspace / specified
inputModestdin / arg / arg-template / env
inputArgTemplatearg-template 模式下的输入参数模板
inputEnvKeyenv 模式下接收任务文本的环境变量名
env注入子进程的固定环境变量
envPassthrough从父进程透传的环境变量名
outputFormattextjson
outputJsonPathjson 模式下提取最终结果的路径
readOutputFile优先读取输出文件作为最终结果
outputFileArgTemplate输出文件参数模板,支持 {path}
supportsResume是否允许 DotCraft 保存和复用外部 session id
resumeArgTemplateResume 参数模板,支持 {sessionId}
resumeSessionIdJsonPath从 stdout 提取 session id 的 JSON path
resumeSessionIdRegexstdout 不是单个 JSON object 时的正则 fallback
timeout单次运行超时时间(秒)
maxOutputBytes最大捕获输出字节数
trustLeveltrusted / prompt / restricted
permissionModeMapping将 DotCraft 审批模式映射为 CLI 参数

厂商 headless 参考:

Profile行为
cursor-cliDotCraft 注入 -p --output-format json,恢复时追加 --resume {sessionId}
codex-cliDotCraft 注入 exec 和输出文件参数。恢复时使用 exec resume {sessionId}

自定义命令

自定义命令是 Markdown 文件,不是 config.json 里的字段。DotCraft 从全局 ~/.craft/commands/ 目录和工作区 .craft/commands/ 目录加载它们,同名时工作区文件优先。每个文件对应一条 /name 命令,可以在 CLI、Desktop 和其他入口使用。

命令文件开头可以写 YAML frontmatter,发送前会被剥离。正文中 $ARGUMENTS 展开为完整参数串,$1$9 展开为位置参数。

相关文档