Skip to content

Commit 47582d8

Browse files
committed
fix: resolve ops-metrics test failure and sync README_ZH for mode separation
- Fix ops-metrics test: use dynamic date instead of hardcoded 2026-04-05 to prevent Logger cleanupOldLogs from deleting test fixtures before ops:metrics can read them - Sync README_ZH.md with mode separation: add --mode flag to setup:local, update integration modes section, add CONTEXTATLAS_EXPOSURE_MODE to Claude Desktop config example
1 parent de23ab3 commit 47582d8

2 files changed

Lines changed: 25 additions & 8 deletions

File tree

README_ZH.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,10 @@ npm install -g @codefromkarl/context-atlas
133133

134134
```bash
135135
contextatlas init
136-
contextatlas setup:local
136+
# 选择接入模式:
137+
contextatlas setup:local --mode cli-skill # 终端 + skill 集成
138+
#
139+
contextatlas setup:local --mode mcp # MCP 客户端集成
137140
```
138141

139142
默认配置文件位置:
@@ -169,7 +172,7 @@ INDEX_UPDATE_MIN_CHANGED_FILES=5
169172
- `contextatlas index:diagnose`:直接回显当前阈值和升级判定配置,适合排查“为什么升级成 full / 为什么仍保持 incremental”
170173

171174
> `init` 会写入一份可直接编辑的示例 `.env`,包括默认的 SiliconFlow endpoint 和推荐模型配置。
172-
> `setup:local` 会继续把 Claude / Codex / Gemini 所需的 MCP 配置、提示词文档和 Codex skill 一起写好
175+
> `setup:local --mode <mode>` 仅写入所选模式的配置文件。模式选择指引见 [首次使用](./docs/guides/first-use.md)
173176
174177
更多配置与部署细节见 [部署手册](./docs/guides/deployment.md)[CLI 文档](./docs/reference/cli.md)
175178

@@ -218,7 +221,14 @@ contextatlas mcp
218221

219222
## 接入方式
220223

221-
### 1. 作为本地 CLI / Skill Backend
224+
ContextAtlas 支持两种互斥的接入模式,通过 `setup:local --mode <mode>` 选择:
225+
226+
- **cli-skill**:终端 + skill 集成,所有操作通过 `contextatlas` CLI 命令完成,不暴露 MCP server
227+
- **mcp**:MCP 客户端集成,通过 Claude Desktop、Cursor、Codex MCP 等标准工具协议调用
228+
229+
详见 [首次使用](./docs/guides/first-use.md) 中的模式选择指引。
230+
231+
### 1. 作为本地 CLI / Skill Backend(cli-skill 模式)
222232

223233
适合:
224234

@@ -240,7 +250,7 @@ contextatlas decision:list
240250
contextatlas health:full
241251
```
242252

243-
### 2. 作为 MCP Server
253+
### 2. 作为 MCP Server(mcp 模式)
244254

245255
适合:
246256

@@ -254,7 +264,10 @@ Claude Desktop 配置示例:
254264
"mcpServers": {
255265
"contextatlas": {
256266
"command": "contextatlas",
257-
"args": ["mcp"]
267+
"args": ["mcp"],
268+
"env": {
269+
"CONTEXTATLAS_EXPOSURE_MODE": "mcp"
270+
}
258271
}
259272
}
260273
}

tests/ops-metrics.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,13 @@ test('ops:metrics CLI 在未显式传 log-dir 时默认读取 baseDir/logs', ()
240240
const previousBaseDir = process.env.CONTEXTATLAS_BASE_DIR;
241241
process.env.CONTEXTATLAS_BASE_DIR = baseDir;
242242

243+
// 使用当天日期,避免日志被 Logger.cleanupOldLogs 在启动时自动清理
244+
const today = new Date();
245+
const todayStr = today.toISOString().slice(0, 10);
246+
243247
try {
244248
recordToolUsage({
245-
timestamp: '2026-04-05T09:00:00.000Z',
249+
timestamp: `${todayStr}T09:00:00.000Z`,
246250
source: 'mcp',
247251
toolName: 'codebase-retrieval',
248252
projectId: 'proj-metrics-default-log',
@@ -258,8 +262,8 @@ test('ops:metrics CLI 在未显式传 log-dir 时默认读取 baseDir/logs', ()
258262
const logsDir = path.join(baseDir, 'logs');
259263
fs.mkdirSync(logsDir, { recursive: true });
260264
fs.writeFileSync(
261-
path.join(logsDir, 'app.2026-04-05.log'),
262-
`2026-04-05 09:00:00 [INFO] MCP codebase-retrieval 完成 ${JSON.stringify({
265+
path.join(logsDir, `app.${todayStr}.log`),
266+
`${todayStr} 09:00:00 [INFO] MCP codebase-retrieval 完成 ${JSON.stringify({
263267
requestId: 'req-default-log',
264268
projectId: 'proj-metrics-default-log',
265269
totalMs: 321,

0 commit comments

Comments
 (0)