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

# Config 命令

> 提供方、成本、仪表盘、品牌、atlas、stack 与可选 MCP 集成:config、cost、dash、brand、atlas、stack、report、tools、integrations。

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

## `forge config`

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

```bash theme={null}
forge config               # 显示当前配置
forge config switch <provider>
forge config add <provider>
```

## `forge cost`

通过实测的阶段系数计算的真实每日花销。

```bash theme={null}
forge cost                 # 真实的每日花销
forge cost --stages        # 实测的每阶段成本系数
```

<Note>
  **仅报告已实测的阶段**——没有事件的阶段会显示 “no data”,绝不使用默认值。
</Note>

## `forge dash`

对 ledger、指标与爆炸半径的本地仪表盘。

```bash theme={null}
forge dash                 # 仅本机、只读(默认端口 4242)
```

## `forge brand`

打印当前生效的品牌 token 映射。

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

品牌以单个 token(`brand.json`)存储;换品牌只需一次编辑。

## `forge atlas`

构建 / 查询代码图。

```bash theme={null}
forge atlas build [path]   # 遍历目录树 → .forge/atlas.json
forge atlas query "what calls Z"
forge atlas has <symbol>   # 幻觉符号检查
```

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 报告——把 ledger、指标和爆炸半径渲染成一个自包含文件,可分享或归档。

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

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

选择本仓库的主用 AI 编码工具,并接线相应的 `.gitignore` 条目,让生成的配置与 `.forge/` 产物按你的设置被正确忽略。

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

## `forge integrations`

按需接入的第三方 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` 会依据同一份规范化描述,把服务器写入每个工具的原生 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 帮你在所有工具间保持一致时,就用 `--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 上告警一次,写入方会拒绝覆盖一个无法解析的配置,而不是用默认值把它替换掉。
