> ## Documentation Index
> Fetch the complete documentation index at: https://ccsafetynet.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 DeepSeek Harness 中安装 CC Safety Net

> 以 profile 插件 bundle 的形式为 DeepSeek Harness 的 web 和 Desktop profile 安装 CC Safety Net，把它添加到其他 profile，了解其工具 guard 检查什么、如何卸载，以及如何解决桌面应用和启用相关的错误。

先退出 DeepSeek Harness 桌面应用，再运行 `npx -y cc-safety-net@latest install --deepseek-harness`。它会把 CC Safety Net 作为插件 bundle 添加到 `web` profile 和 `desktop` profile。该 bundle 注册一个只能拒绝的工具 guard：它可以阻止工具调用，但从不批准调用。bundle 加载失败时只会发出警告，因此该 profile 会在没有保护的情况下运行。安装后运行 `npx cc-safety-net doctor`，确认 bundle 已生效。

## 在 DeepSeek Harness 中安装 CC Safety Net

**1. 打开一次桌面应用，然后退出**

打开一次 DeepSeek Harness 桌面应用，然后退出。

**2. 确认 pnpm 在 PATH 上**

确保 `pnpm` 在你的 `PATH` 上。

**3. 运行安装程序**

```bash theme={"dark"}
npx -y cc-safety-net@latest install --deepseek-harness
```

**4. 确认 bundle 已生效**

```bash theme={"dark"}
npx cc-safety-net doctor
```

只有 `desktop` profile 已存在时，安装才会覆盖它，所以要先打开一次桌面应用。之所以要退出，是因为桌面应用的插件只能在应用关闭时改动。DeepSeek Harness 需要 `PATH` 上有 `pnpm` 才能添加 bundle。

安装成功会报告 `Added cc-safety-net to the DeepSeek Harness Desktop and web profiles.`。只覆盖 web profile 时，消息中的 `the Desktop and web profiles` 会换成 `the web profile`。

## DeepSeek Harness 安装会改动什么

DeepSeek Harness 把 CC Safety Net 作为 profile 插件 bundle 加载，而不是 hook 进程，因此它没有对应的 `hook` 选项。安装会向每个 profile 添加 `cc-safety-net`，版本与你运行的安装程序相同。之后，每个 profile 的 `package.json` 都会列出 `cc-safety-net` 依赖，并启用它的 bundle。

### 安装覆盖的 DeepSeek Harness profile

一次安装覆盖两个 profile：

* `web` profile，由 `npx @deepseek-ai/dsh web` 和全局安装共用
* `desktop` profile，由桌面应用使用（仅当该 profile 已存在时）

`acp`、`headless`、`sdk`、`sdk-minimal` profile 以及之后新建的 profile 都不受 CC Safety Net 保护，需要你自己为每个 profile 添加插件：

```bash theme={"dark"}
dsh plugin --profile <name> add cc-safety-net
```

对 `desktop` profile，安装会运行桌面应用自带的 `dsh`，并在以下位置查找该程序：

| 平台 | 路径 |
| - | - |
| macOS | 先在 `~/Applications` 下、再在 `/Applications` 下查找 `DeepSeek Harness.app/Contents/Resources/runtime/cli/bin/dsh` |
| Windows | `%LOCALAPPDATA%\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd` |

## DeepSeek Harness 工具 guard 检查什么

DeepSeek Harness 在其他所有 `tools/pre-execute` 监听器（包括审批和 Auto review）之后运行该 guard。

* `bash` 调用交给 POSIX 分析器。
* `pwsh` 调用交给 PowerShell 分析器。
* 文件类和搜索类工具调用由路径保护和机密保护检查。

## DeepSeek Harness 检查失败时会怎样

CC Safety Net 的 guard 出错时，DeepSeek Harness 会阻止该调用。如果插件 bundle 加载失败，DeepSeek Harness 只会打印一条警告，该 profile 将在没有任何检查的情况下运行。

## DeepSeek Harness 的覆盖限制

* **其他 profile。** 只有 `web` 和 `desktop` profile 会装上 bundle。见[安装覆盖的 DeepSeek Harness profile](#deepseek-harness-profiles-the-install-covers)。
* **加载失败的 bundle。** 可选插件的导入或 `apply()` 失败时，DeepSeek Harness 只当作警告处理并继续运行，因此该 profile 没有保护。`doctor` 读取的是磁盘上的 manifest，而不是正在运行的宿主，所以仍会把该 profile 报告为已配置。
* **桌面应用的崩溃恢复。** 桌面应用的崩溃恢复操作会禁用第三方 bundle，在你从 Plugins 页面重新启用之前，它们一直处于关闭状态。
* **PTC 模式下的 `run_code`。** PTC 模式默认关闭。开启后，`run_code` 会运行模型编写的 TypeScript，这些代码可以直接调用 Node.js API。只有这些代码发起的工具调用会到达 guard，因此它通过 `node:fs` 进行的写入不会得到任何决策。
* **`terminal_send`。** 需要手动开启的终端工具会把 `terminal_send` 文本直接写入持久 shell，不经分析。持久的 `bash` 或 `pwsh` shell 会在多次调用之间保留目录切换，而 CC Safety Net 以会话工作区为基准检查每次调用，因此两者可能不一致。
* **Windows 桌面应用。** Windows 上的桌面应用路径未经测试，包括上面的 `dsh.cmd` 路径，以及安装用来判断桌面应用是否正在运行的 `%APPDATA%\@deepseek-ai\dsh-desktop\lockfile`。web profile 不受影响。

## 从 DeepSeek Harness 卸载 CC Safety Net

```bash theme={"dark"}
npx -y cc-safety-net@latest uninstall --deepseek-harness
```

如果 `web` 和 `desktop` profile 的 manifest 中列有该 bundle，卸载会将其移除；你自行添加到其他 profile 的副本保持不动。与安装一样，桌面应用运行时卸载会停止。

这两个 profile 都没有该 bundle 时，卸载会停止并输出：

```text theme={"dark"}
cc-safety-net is not installed in the DeepSeek Harness web or Desktop profile
```

## 在 DeepSeek Harness 中更新 CC Safety Net

[`update`](/docs/zh-Hans/reference/cli/update) 会为每个 profile 重新运行安装，因此桌面应用打开时它会失败。请先退出桌面应用。

## DeepSeek Harness 的 profile 存放位置

设置了 `DSH_HOME` 时，DeepSeek Harness 把 profile 放在 `$DSH_HOME/profiles`，否则放在 `<home>/.dsh/profiles`。`DSH_HOME` 开头的 `~` 会按你的主目录展开。

## DeepSeek Harness 故障排除

* **`Quit DeepSeek Harness Desktop, then run this command again: Desktop plugins can only change while it is closed.`** 桌面应用正在运行。在你退出它之前，安装和卸载都会停止。
* **`DeepSeek Harness Desktop is not in its default location, so add cc-safety-net from its Plugins page.`** `desktop` profile 已存在，但桌面应用不在[上表](#deepseek-harness-profiles-the-install-covers)所列的路径中。安装仍会覆盖 web profile，桌面应用这边请自行从其 Plugins 页面添加插件。
* **`DeepSeek Harness installed cc-safety-net in the web profile but did not enable it. Enable it from the Plugins page.`** DeepSeek Harness 添加了 bundle 却没有启用它，因此它不提供任何保护。请从 Plugins 页面启用它。消息中会写出安装覆盖的 profile。
* **`doctor` 报告 `cc-safety-net is installed in the <name> profile but its bundle is disabled`。** 该 profile 的 `package.json` 列有 `cc-safety-net` 依赖，但 `dsh.profile.bundles` 中没有它。请从 Plugins 页面启用该 bundle。

### 桌面应用不在默认位置时卸载

如果 Desktop profile 中有该 bundle，但桌面应用不在默认位置，卸载会先移除 web profile 中的副本，然后以 `1` 退出：

```text theme={"dark"}
Removed cc-safety-net from the DeepSeek Harness web profile, but DeepSeek Harness Desktop is not in its default location, so remove cc-safety-net from its Plugins page.
```

请从桌面应用的 Plugins 页面移除该 bundle。如果只有 Desktop profile 带有该 bundle，卸载不会移除任何内容，只单独输出同一条提示。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.