Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ codex-mcp setup
| `codex-mcp logs -f` | 持续跟随运行日志 |
| `codex-mcp setup` | 首次设置或管理现有配置 |
| `codex-mcp doctor` | 只读检查安装、配置和依赖 |
| `codex-mcp doctor --fix` | 创建缺失本机目录、清理失效 daemon 状态等安全修复 |
| `codex-mcp doctor --fix` | 补齐文件搜索组件、创建本机目录、清理失效 daemon 状态等安全修复 |
| `codex-mcp auth` | 修改 ChatGPT 连接密码 |
| `codex-mcp update` | 更新到最新版本 |
| `codex-mcp tunnel` | 重新配置公网连接(兼容快捷入口) |
Expand Down Expand Up @@ -648,6 +648,12 @@ codex-mcp doctor

这是排查问题时最先应该运行的命令。

如果文件搜索组件缺失,可以自动恢复:

```bash
codex-mcp doctor --fix
```

---

# 常见问题
Expand Down
12 changes: 12 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
import { configurePublicAccess } from "./tunnel/public-access-manager.js";
import { ensureUserConfigDirs, loadUserConfig } from "./config/user-config.js";
import { runSelfUpdate } from "./doctor/update.js";
import { findRipgrep } from "./lib/search/ripgrep.js";
import { ensureManagedTool } from "./managed-tools/install.js";
import { randomBytes } from "node:crypto";
import {
cleanStaleDaemonState,
Expand Down Expand Up @@ -690,6 +692,16 @@ async function printDoctorReport(fix: boolean): Promise<void> {
if (removedStaleDaemon) {
printSuccess("已清理失效的 daemon 状态文件。");
}
if (!(await findRipgrep())) {
printInfo("正在恢复文件搜索组件…");
try {
const installed = await ensureManagedTool("ripgrep");
printSuccess(`已安装文件搜索组件:${installed.path}`);
} catch (error) {
const detail = error instanceof Error ? error.message : String(error);
printWarning(`文件搜索组件自动恢复失败:${detail}`);
}
}
printInfo("--fix 不会修改 Cloudflare DNS、OAuth 身份、连接密码或项目文件。");
}

Expand Down
2 changes: 1 addition & 1 deletion src/doctor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ async function checkRipgrep(): Promise<DoctorCheck> {
return {
label: "文件搜索",
level: "error",
detail: "文件搜索组件缺失;重新运行安装脚本可以自动恢复",
detail: "文件搜索组件缺失;运行 `codex-mcp doctor --fix` 可以自动恢复",
};
}
try {
Expand Down
3 changes: 1 addition & 2 deletions src/lib/search/ripgrep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { spawn } from "node:child_process";
import { getManagedToolPath } from "../../managed-tools/paths.js";
import { terminateChildProcess } from "../process/tree.js";

let cachedRgPath: string | null | undefined;
let cachedRgPath: string | undefined;

export async function findRipgrep(): Promise<string | null> {
if (cachedRgPath !== undefined) {
Expand Down Expand Up @@ -43,7 +43,6 @@ export async function findRipgrep(): Promise<string | null> {
}
}

cachedRgPath = null;
return null;
}

Expand Down