> ## Documentation Index
> Fetch the complete documentation index at: https://forgekit-docs-mintlify-7cd64f48.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Config 命令

> 提供方、成本、仪表盘、品牌、atlas、技术栈和可选 MCP 集成：config、cost、dash、brand、atlas、stack、report、tools、integrations。

Config 分组涵盖提供方、可观测性、代码图和技术栈探测。

## `forge config`

提供方配置 —— 显示 / 切换 / 添加提供方，设置默认模型。

```bash theme={null}
forge config               # show current config
forge config switch <provider>
forge config add <provider>
```

## `forge cost`

通过实测的阶段系数得到真实的每日开销。

```bash theme={null}
forge cost                 # real per-day spend
forge cost --stages        # measured per-stage cost factors
```

<Note>
  只报告**实测的阶段** —— 一个没有事件记录的阶段会显示"no data"，绝不会给出
  一个默认值。
</Note>

## `forge dash`

跑在账本、指标和爆炸半径之上的本地仪表盘。

```bash theme={null}
forge dash                 # localhost-only, read-only (default port 4242)
```

## `forge brand`

打印当前的品牌 token 映射。

```bash theme={null}
forge brand
```

品牌以一份 token 存储在（`brand.json`）里；换品牌就是一次编辑。

## `forge atlas`

构建 / 查询代码图。

```bash theme={null}
forge atlas build [path]   # walk the tree → .forge/atlas.json
forge atlas query "what calls Z"
forge atlas has <symbol>   # hallucinated-symbol check
```

atlas 是纯 JSON —— 任何工具都能读，不需要 MCP。

## `forge stack`

从本仓库的清单文件里探测它真实的技术栈。

```bash theme={null}
forge stack
```

会读取 `package.json`、`pyproject.toml`、`go.mod`、`Cargo.toml`、`Gemfile`、
`composer.json`、`pom.xml` / `build.gradle` 以及 `*.csproj`，报告语言、
框架、包管理器和仓库**真正**的测试命令 —— 这些会喂给
基底的验证清单。

## `forge report` <sub>v0.19+</sub>

生成本仓库 Forge 状态的静态 HTML 报告 —— 把账本、指标和爆炸
半径渲染成一个可以分享或归档的、自包含的文件。

```bash theme={null}
forge report
```

## `forge tools` <sub>v0.19+</sub>

选择本仓库的主 AI 编码工具，并接通对应的 `.gitignore` 条目，让
生成的配置和 `.forge/` 产物在你的这套配置里被正确忽略。

```bash theme={null}
forge tools
```

## `forge integrations`

按需接入（opt-in）的第三方 MCP 服务器（例如 `context7`），以非破坏性的方式管理，
覆盖 Forge 为之输出配置的每一个工具 —— Claude Code、Codex、Cursor、Gemini、Continue
以及其他所有工具。

第三方 MCP 服务器**默认不安装**。在你执行 `forge integrations add <name> --yes`
之前，什么都不会落到磁盘上。

```bash theme={null}
forge integrations                        # list opt-in servers with package + purpose
forge integrations add <name>             # dry-run: prints package, network, files it would touch
forge integrations add <name> --yes       # apply — write MCP config for every tool
forge integrations add <name> --yes --adopt   # also claim a same-name entry you already configured
forge integrations remove <name>          # reverse the add — deletes only forge-owned entries
```

### `add` 会写什么

`add --yes` 从一份规范的 spec 出发，把这个服务器写入每个工具原生的 MCP 配置：

* `.mcp.json`（Claude Code）
* `.cursor/mcp.json`（Cursor）
* `.gemini/settings.json`（Gemini）
* `.codex/config.toml` —— 作为一个 `# forge:managed:<name>` 代码块，通过逐字节比对
  来刷新
* `.continue/mcpServers/<name>.yaml` —— 每个被管理的服务器一个带 forge 标记的 YAML
* 以及 Forge 为之输出配置的其他工具

已安装的集合记录在 `.forge/forge.config.json` 的 `mcp.integrations` 下，因此之后每一次
`forge sync` 都会重新输出同一批服务器。stop-hook 的自动同步会对整份配置文件做逐字节
比对，所以对该文件的手工编辑会被检测到并被修复。

### `--adopt` 的语义

如果一个同名的服务器已经存在于某个工具的配置文件里，而且不是 Forge 放进去的，`add`
**不会覆盖它**。它会报告是哪个文件，并给出一个 `--adopt` 提示。加上 `--adopt` 重新
运行来接管所有权 —— Forge 会把这条记录写到 `.forge/forge.config.json` 的
`mcp.adopted` 下，从此由 Forge 来管理它。

当你之前手工配了某个服务器，现在又想让 Forge 在每个工具之间把它同步保持一致时，
就用 `--adopt`。

### `remove`

`forge integrations remove <name>` 反转一次 add。它只删除 forge 所拥有的条目、
代码块和文件 —— 用户自己配的、并且从没 `--adopt` 过的同名服务器会被保留下来。
连续跑两次 `remove` 是个无操作。

```bash theme={null}
forge integrations remove context7
```

### `.forge/forge.config.json`

每个仓库的 Forge 状态 —— 这份统一配置里也存着 `primaryTool`、`tools` 和
`profile` —— 在两个键下记录按需接入的集成：

```json theme={null}
{
  "mcp": {
    "integrations": ["context7"],
    "adopted": []
  }
}
```

未知的键在写入时会被原样保留。一个损坏的文件不会被静默丢弃：读取时每个进程会在
stderr 上告警一次，而写入者会拒绝用默认值覆盖一份无法解析的配置。
