claude-coder 1.5.6 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -2
- package/bin/cli.js +27 -2
- package/docs/ARCHITECTURE.md +8 -8
- package/docs/PLAYWRIGHT_CREDENTIALS.md +123 -97
- package/docs/README.en.md +3 -2
- package/package.json +4 -2
- package/src/auth.js +171 -38
- package/src/config.js +20 -4
- package/src/hooks.js +13 -3
- package/src/indicator.js +19 -37
- package/src/prompts.js +38 -10
- package/src/runner.js +14 -2
- package/src/session.js +5 -3
- package/src/setup.js +37 -25
- package/src/tasks.js +5 -1
- package/src/validator.js +66 -38
- package/templates/CLAUDE.md +13 -40
- package/templates/SCAN_PROTOCOL.md +4 -4
- package/templates/test_rule.md +158 -0
- package/docs/PHASE_INJECTION_RESEARCH.md +0 -325
package/README.md
CHANGED
|
@@ -60,6 +60,7 @@ claude-coder run "实现用户注册和登录功能"
|
|
|
60
60
|
| `claude-coder validate` | 手动校验 |
|
|
61
61
|
| `claude-coder status` | 查看进度和成本 |
|
|
62
62
|
| `claude-coder config sync` | 同步配置到 ~/.claude/ |
|
|
63
|
+
| `claude-coder config mcp <mode>` | 快速切换 Playwright 模式 |
|
|
63
64
|
|
|
64
65
|
**选项**:`--max N` 限制 session 数(默认 50),`--pause N` 每 N 个 session 暂停确认(默认不暂停)。
|
|
65
66
|
|
|
@@ -97,10 +98,10 @@ your-project/
|
|
|
97
98
|
progress.json # 会话历史 + 成本
|
|
98
99
|
tests.json # 验证记录
|
|
99
100
|
test.env # 测试凭证(API Key 等,可选)
|
|
100
|
-
playwright-auth.json #
|
|
101
|
-
browser-profile/ # 持久化浏览器 Profile(MCP 实际使用)
|
|
101
|
+
playwright-auth.json # 登录状态快照(isolated 模式,auth 命令生成)
|
|
102
102
|
.runtime/ # 临时文件
|
|
103
103
|
logs/ # 每 session 独立日志(含工具调用记录)
|
|
104
|
+
browser-profile/ # 持久化浏览器 Profile(persistent 模式,auth 命令生成)
|
|
104
105
|
requirements.md # 需求文档(可选)
|
|
105
106
|
```
|
|
106
107
|
|
package/bin/cli.js
CHANGED
|
@@ -11,7 +11,7 @@ const COMMANDS = {
|
|
|
11
11
|
auth: { desc: '导出 Playwright 登录状态', usage: 'claude-coder auth [url]' },
|
|
12
12
|
validate: { desc: '手动校验上次 session', usage: 'claude-coder validate' },
|
|
13
13
|
status: { desc: '查看任务进度和成本', usage: 'claude-coder status' },
|
|
14
|
-
config: { desc: '配置管理', usage: 'claude-coder config sync' },
|
|
14
|
+
config: { desc: '配置管理', usage: 'claude-coder config sync | config mcp <mode>' },
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
function showHelp() {
|
|
@@ -32,6 +32,7 @@ function showHelp() {
|
|
|
32
32
|
console.log(' claude-coder add "..." --model opus-4 指定模型追加任务');
|
|
33
33
|
console.log(' claude-coder auth 导出 Playwright 登录状态');
|
|
34
34
|
console.log(' claude-coder auth http://localhost:8080 指定登录 URL');
|
|
35
|
+
console.log(' claude-coder config mcp persistent 快速切换 Playwright 模式');
|
|
35
36
|
console.log(' claude-coder status 查看进度和成本');
|
|
36
37
|
console.log(`\n前置条件: npm install -g @anthropic-ai/claude-agent-sdk`);
|
|
37
38
|
}
|
|
@@ -152,8 +153,32 @@ async function main() {
|
|
|
152
153
|
const config = require('../src/config');
|
|
153
154
|
if (positional[0] === 'sync') {
|
|
154
155
|
config.syncToGlobal();
|
|
156
|
+
} else if (positional[0] === 'mcp') {
|
|
157
|
+
const validModes = ['persistent', 'isolated', 'extension'];
|
|
158
|
+
const mode = positional[1];
|
|
159
|
+
if (!mode || !validModes.includes(mode)) {
|
|
160
|
+
console.error(`用法: claude-coder config mcp <${validModes.join('|')}>`);
|
|
161
|
+
process.exit(1);
|
|
162
|
+
}
|
|
163
|
+
const ok = config.updateEnvVar('MCP_PLAYWRIGHT_MODE', mode);
|
|
164
|
+
if (!ok) {
|
|
165
|
+
console.error('未找到配置文件,请先运行 claude-coder setup');
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
config.updateEnvVar('MCP_PLAYWRIGHT', 'true');
|
|
169
|
+
const { updateMcpConfig } = require('../src/auth');
|
|
170
|
+
updateMcpConfig(config.paths(), mode);
|
|
171
|
+
const { log } = config;
|
|
172
|
+
log('ok', `Playwright 模式已切换为: ${mode}`);
|
|
173
|
+
if (mode === 'persistent') {
|
|
174
|
+
log('info', '运行 claude-coder auth <URL> 完成首次登录');
|
|
175
|
+
} else if (mode === 'isolated') {
|
|
176
|
+
log('info', '运行 claude-coder auth <URL> 录制登录状态');
|
|
177
|
+
} else {
|
|
178
|
+
log('info', '确保已安装 Playwright MCP Bridge 扩展并启动浏览器');
|
|
179
|
+
}
|
|
155
180
|
} else {
|
|
156
|
-
console.error('用法: claude-coder config sync');
|
|
181
|
+
console.error('用法: claude-coder config sync | config mcp <mode>');
|
|
157
182
|
process.exit(1);
|
|
158
183
|
}
|
|
159
184
|
break;
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -51,8 +51,8 @@ Agent 在单次 session 中应最大化推进任务进度。**任何非致命问
|
|
|
51
51
|
| 文件 | git 状态 | 说明 |
|
|
52
52
|
|------|---------|------|
|
|
53
53
|
| `test.env` | .gitignore | Agent 可写入发现的 API Key、测试账号 |
|
|
54
|
-
| `playwright-auth.json` | .gitignore |
|
|
55
|
-
|
|
|
54
|
+
| `playwright-auth.json` | .gitignore | cookies + localStorage 快照(isolated 模式,`claude-coder auth` 生成) |
|
|
55
|
+
| `.runtime/browser-profile/` | .gitignore | 持久化浏览器 Profile(persistent 模式,`claude-coder auth` 生成) |
|
|
56
56
|
| `session_result.json` | git-tracked | Agent 每次 session 覆盖写入 |
|
|
57
57
|
| `tasks.json` | git-tracked | Agent 修改 status 字段 |
|
|
58
58
|
|
|
@@ -208,10 +208,10 @@ templates/
|
|
|
208
208
|
| `tasks.json` | 首次扫描 | 任务列表 + 状态跟踪 |
|
|
209
209
|
| `progress.json` | 每次 session 结束 | 结构化会话日志 + 成本记录 |
|
|
210
210
|
| `session_result.json` | 每次 session 结束 | 当前 session 结果(扁平格式,向后兼容旧 `current` 包装) |
|
|
211
|
-
| `playwright-auth.json` | `claude-coder auth
|
|
212
|
-
|
|
|
211
|
+
| `playwright-auth.json` | `claude-coder auth`(isolated 模式) | 浏览器 cookies + localStorage 快照 |
|
|
212
|
+
| `.runtime/browser-profile/` | `claude-coder auth`(persistent 模式) | 持久化浏览器 Profile(MCP 通过 `--user-data-dir` 使用) |
|
|
213
213
|
| `tests.json` | 首次测试时 | 验证记录(防止反复测试) |
|
|
214
|
-
| `.runtime/` | 运行时 | 临时文件(
|
|
214
|
+
| `.runtime/` | 运行时 | 临时文件(logs/、browser-profile/);工具调用记录合并到 session log |
|
|
215
215
|
|
|
216
216
|
---
|
|
217
217
|
|
|
@@ -267,7 +267,7 @@ flowchart TB
|
|
|
267
267
|
| 5 | `docsHint` | profile.existing_docs 非空或 profile 有缺陷 | Step 4:读文档后再编码;profile 缺陷时提示 Agent 在 Step 6 补全 services/docs |
|
|
268
268
|
| 6 | `taskHint` | tasks.json 存在且有待办任务 | Step 1:跳过读取 tasks.json,harness 已注入当前任务上下文 + 项目绝对路径 |
|
|
269
269
|
| 6b | `testEnvHint` | 始终注入(内容因 test.env 是否存在而不同) | Step 5:存在时提示加载;不存在时告知可创建 |
|
|
270
|
-
| 6c | `playwrightAuthHint` |
|
|
270
|
+
| 6c | `playwrightAuthHint` | MCP_PLAYWRIGHT=true(按 playwrightMode 动态生成) | Step 5:告知 Agent 当前 Playwright 模式(persistent/isolated/extension)及认证状态 |
|
|
271
271
|
| 7 | `memoryHint` | session_result.json 存在(扁平格式) | Step 1:跳过读取 session_result.json,harness 已注入上次会话摘要 |
|
|
272
272
|
| 8 | `serviceHint` | 始终注入 | Step 6:单次模式停止服务,连续模式保持服务运行 |
|
|
273
273
|
| 9 | `toolGuidance` | 始终注入 | 全局:工具使用规范(Grep/Glob/Read/LS/MultiEdit/Task 替代 bash 命令),非 Claude 模型必需 |
|
|
@@ -408,8 +408,8 @@ Harness 在 `buildCodingPrompt()` 中预读 `session_result.json`,将上次会
|
|
|
408
408
|
| `tasks.json` | Agent(仅 `status` 字段) | 修改 `status` | tracked |
|
|
409
409
|
| `project_profile.json` | Agent(仅扫描阶段) | 扫描时写入 | tracked |
|
|
410
410
|
| `test.env` | Agent + 用户 | 可追加写入 | .gitignore |
|
|
411
|
-
| `playwright-auth.json` | 用户(`claude-coder auth
|
|
412
|
-
|
|
|
411
|
+
| `playwright-auth.json` | 用户(`claude-coder auth`,isolated 模式) | cookies + localStorage 快照 | .gitignore |
|
|
412
|
+
| `.runtime/browser-profile/` | 用户(`claude-coder auth`,persistent 模式) | 持久化浏览器 Profile | .gitignore |
|
|
413
413
|
|
|
414
414
|
---
|
|
415
415
|
|
|
@@ -1,152 +1,178 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Playwright MCP 浏览器模式与凭证管理
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 三种模式一览
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
| | persistent(默认推荐) | isolated | extension |
|
|
6
|
+
|---|---|---|---|
|
|
7
|
+
| **一句话** | **懒人模式** — 登录一次,永久生效 | **开发模式** — 验证登录流程的自动化测试 | 连接真实浏览器(实验性) |
|
|
8
|
+
| **使用的浏览器** | Chrome for Testing(Playwright 自带) | Chrome for Testing(Playwright 自带) | **用户的真实 Chrome/Edge** |
|
|
9
|
+
| **登录态** | 持久化,关闭后下次自动恢复 | 每次从 JSON 快照加载(auth 录制一次) | 直接复用浏览器已有登录态 |
|
|
10
|
+
| **典型场景** | Google SSO、企业内网 API 文档拉取、日常维护开发 | 验证登录流程本身、需要可重复的干净测试环境 | 需要浏览器插件或绕过自动化检测 |
|
|
11
|
+
| **状态存储** | `.claude-coder/.runtime/browser-profile/` | `.claude-coder/playwright-auth.json` | 无(浏览器自身管理) |
|
|
12
|
+
| **前置安装** | `npx playwright install chromium` | `npx playwright install chromium` | Playwright MCP Bridge 扩展 |
|
|
13
|
+
| **.mcp.json 参数** | `--user-data-dir=<path>` | `--isolated --storage-state=<path>` | `--extension` |
|
|
6
14
|
|
|
7
|
-
|
|
8
|
-
|------|------|------|
|
|
9
|
-
| 浏览器状态 | 登录 cookies、localStorage 中的用户配置 | 有过期时间,跨 session 需要持久化 |
|
|
10
|
-
| API Key | OPENAI_API_KEY、ZHIPU_API_KEY | 长期有效,需安全存储 |
|
|
11
|
-
| 测试账号 | 注册的测试用户名密码、生成的 token | 可能是 Agent 自己创建的,需跨 session 传递 |
|
|
15
|
+
### 如何选择
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
3. **零手动干预** — 首次浏览器登录后,后续由持久化 profile 自动处理
|
|
17
|
+
- **persistent(推荐)**:适合需要 Google 登录态、内网 API 获取等场景。登录一次,后续所有 MCP 会话自动复用。
|
|
18
|
+
- **isolated**:适合需要验证登录流程的自动化测试,或需要每次干净环境的场景。cookies 过期后需重新 `auth`。
|
|
19
|
+
- **extension**(实验性):适合需要浏览器插件(VPN、广告拦截等)的场景。需安装 Chrome 扩展。
|
|
17
20
|
|
|
18
21
|
---
|
|
19
22
|
|
|
20
|
-
##
|
|
23
|
+
## 前置安装
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
browser-profile/ ← 持久化浏览器 Profile(MCP 实际使用) [auth 命令创建]
|
|
25
|
+
### persistent / isolated 模式
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# 安装 Playwright 自带的 Chromium 浏览器(Chrome for Testing)
|
|
29
|
+
npx playwright install chromium
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
安装后位于 `~/Library/Caches/ms-playwright/chromium-*/`(macOS)。这不是你的真实 Chrome,是 Playwright 专用的自动化浏览器。
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|------|--------|--------|----------|----------|
|
|
34
|
-
| `.env` | `claude-coder setup` | 用户 | 是 | 长期 |
|
|
35
|
-
| `test.env` | Agent 或用户 | Agent + 用户 | 是 | 长期,按需更新 |
|
|
36
|
-
| `playwright-auth.json` | `claude-coder auth` | auth 命令 | 是 | 快照备份,不被 MCP 直接使用 |
|
|
37
|
-
| `browser-profile/` | `claude-coder auth` | MCP 自动维护 | 是 | 长期,自动续期 |
|
|
34
|
+
### extension 模式
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
1. 在真实 Chrome/Edge 中安装 [Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm) 扩展
|
|
37
|
+
2. 确保扩展已启用
|
|
38
|
+
3. 无需安装 Chromium
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|------|-------------------------|--------------------------|
|
|
43
|
-
| 上下文类型 | 隔离上下文(isolated) | 持久化上下文(persistent) |
|
|
44
|
-
| 状态保持 | 每次从 JSON 文件加载,会话结束丢弃 | Profile 自动保存,跨会话保持 |
|
|
45
|
-
| Cookies 续期 | 不支持(JSON 文件静态) | 支持(浏览器自动刷新的 cookies 被保留) |
|
|
46
|
-
| localStorage | 从 JSON 注入(可靠) | 持久保存在 Profile 中 |
|
|
47
|
-
| Google OAuth | 每次创建新上下文 → Google 检测到自动化 | 持久 Profile → Google 视为常规浏览器 |
|
|
48
|
-
| 长期运行 | 差(cookies 过期后必须重新 auth) | 优(Profile 随浏览器使用自动演进) |
|
|
40
|
+
---
|
|
49
41
|
|
|
50
|
-
|
|
51
|
-
> 调用 `launchPersistentContext(userDataDir, options)` 创建持久化浏览器上下文。
|
|
52
|
-
> `--storage-state` 虽然不强制 `isolated=true`,但官方文档明确描述其为 "load into an isolated browser context",
|
|
53
|
-
> 且 `launchPersistentContext` 的 `storageState` 参数存在已知缺陷(Issue #14949):localStorage 不注入,
|
|
54
|
-
> 旧 cookies 可能覆盖 Profile 中已刷新的 cookies。
|
|
42
|
+
## 配置流程
|
|
55
43
|
|
|
56
|
-
|
|
44
|
+
### Step 1:选择模式
|
|
57
45
|
|
|
58
|
-
|
|
46
|
+
```bash
|
|
47
|
+
claude-coder setup
|
|
48
|
+
# → 启用 Playwright MCP → 选择模式(persistent / isolated / extension)
|
|
49
|
+
# → 模式写入 .claude-coder/.env 的 MCP_PLAYWRIGHT_MODE
|
|
50
|
+
```
|
|
59
51
|
|
|
60
|
-
###
|
|
52
|
+
### Step 2:运行认证
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# persistent / isolated:打开浏览器,手动登录后关闭
|
|
56
|
+
claude-coder auth http://your-target-url.com
|
|
61
57
|
|
|
58
|
+
# extension:不开浏览器,只生成 .mcp.json 配置
|
|
59
|
+
claude-coder auth
|
|
62
60
|
```
|
|
63
|
-
|
|
61
|
+
|
|
62
|
+
`auth` 命令会自动完成:
|
|
63
|
+
1. 根据当前模式执行对应的认证流程
|
|
64
|
+
2. 生成/更新 `.mcp.json`(Claude Code SDK 读取此文件启动 MCP 服务)
|
|
65
|
+
3. 更新 `.gitignore`
|
|
66
|
+
4. 启用 `.env` 中 `MCP_PLAYWRIGHT=true`
|
|
67
|
+
|
|
68
|
+
### Step 3:开始使用
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
claude-coder run "你的需求"
|
|
72
|
+
# Agent 自动通过 Playwright MCP 工具操作浏览器
|
|
64
73
|
```
|
|
65
74
|
|
|
66
|
-
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 各模式详细说明
|
|
78
|
+
|
|
79
|
+
### persistent 模式(默认)
|
|
80
|
+
|
|
81
|
+
**原理**:使用 `--user-data-dir` 创建持久化浏览器配置文件(类似 Chrome Profile)。所有 cookies、localStorage、IndexedDB、Service Worker 状态都保留在磁盘上。
|
|
67
82
|
|
|
68
83
|
```
|
|
69
|
-
|
|
70
|
-
→ playwright codegen 打开浏览器 → 手动登录 → 关闭浏览器
|
|
71
|
-
→ cookies + localStorage 保存为快照备份(playwright-auth.json)
|
|
72
|
-
→ 创建 browser-profile/ 目录
|
|
73
|
-
→ 更新 .mcp.json(--user-data-dir 指向 browser-profile/)
|
|
74
|
-
→ 首次 MCP 会话时在浏览器窗口中登录一次
|
|
75
|
-
→ 之后 MCP 自动使用持久化 Profile,无需再次登录
|
|
84
|
+
.claude-coder/.runtime/browser-profile/ ← 持久化浏览器配置(~20-50MB)
|
|
76
85
|
```
|
|
77
86
|
|
|
78
|
-
|
|
87
|
+
**优点**:
|
|
88
|
+
- 登录状态完整保留,包括 Google SSO、OAuth 回调等复杂流程
|
|
89
|
+
- 无需重复登录
|
|
90
|
+
- cookies 自动续期
|
|
91
|
+
|
|
92
|
+
**缺点**:
|
|
93
|
+
- 配置目录较大
|
|
94
|
+
- 不同 session 共享状态(非隔离)
|
|
95
|
+
|
|
96
|
+
### isolated 模式
|
|
97
|
+
|
|
98
|
+
**原理**:使用 `--isolated --storage-state` 将 cookies + localStorage 快照注入新的隔离上下文。每次 MCP 会话从 JSON 文件重新加载。
|
|
79
99
|
|
|
80
100
|
```
|
|
81
|
-
|
|
101
|
+
.claude-coder/playwright-auth.json ← cookies + localStorage 快照(~10-20KB)
|
|
82
102
|
```
|
|
83
103
|
|
|
84
|
-
|
|
104
|
+
**优点**:
|
|
105
|
+
- 每次 session 从相同状态开始,可重复性好
|
|
106
|
+
- 状态文件小,可版本控制(脱敏后)
|
|
85
107
|
|
|
86
|
-
|
|
108
|
+
**缺点**:
|
|
109
|
+
- cookies 过期后需重新 `claude-coder auth`
|
|
110
|
+
- Google SSO 等复杂登录可能无法完整恢复(缺少 IndexedDB/Service Worker 状态)
|
|
87
111
|
|
|
88
|
-
###
|
|
112
|
+
### extension 模式
|
|
89
113
|
|
|
90
|
-
|
|
114
|
+
**原理**:使用 `--extension` 通过 Chrome 扩展(WebSocket CDP relay)连接到用户正在运行的真实浏览器。
|
|
91
115
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
# 指定 URL(如内部 API 文档平台)
|
|
97
|
-
claude-coder auth http://testyapi.example.com/group/2245
|
|
98
|
-
```
|
|
116
|
+
**优点**:
|
|
117
|
+
- 直接复用浏览器已有登录态,无需额外认证
|
|
118
|
+
- 可使用浏览器已安装的扩展(VPN、广告拦截等)
|
|
119
|
+
- 绕过自动化检测
|
|
99
120
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
4. 添加 `.gitignore` 条目(`playwright-auth.json` + `browser-profile/`)
|
|
105
|
-
5. 启用 `.claude-coder/.env` 中 `MCP_PLAYWRIGHT=true`
|
|
121
|
+
**缺点**:
|
|
122
|
+
- 需要安装 [Playwright MCP Bridge](https://chromewebstore.google.com/detail/playwright-mcp-bridge/mmlmfjhmonkocbjadbfplnigmagldckm) 扩展
|
|
123
|
+
- Agent 操作会影响用户正在使用的浏览器
|
|
124
|
+
- 首次连接需要用户审批(可用 Token 自动跳过)
|
|
106
125
|
|
|
107
126
|
---
|
|
108
127
|
|
|
109
|
-
##
|
|
128
|
+
## 测试凭证管理
|
|
129
|
+
|
|
130
|
+
除浏览器登录态外,Agent 还需要 API Key、测试账号等凭证:
|
|
110
131
|
|
|
111
|
-
|
|
132
|
+
| 文件 | 创建方 | 写入方 | 用途 |
|
|
133
|
+
|------|--------|--------|------|
|
|
134
|
+
| `.claude-coder/.env` | `setup` | 用户 | 模型配置、MCP 开关 |
|
|
135
|
+
| `.claude-coder/test.env` | Agent 或用户 | Agent + 用户 | 测试凭证(API Key、测试账号) |
|
|
112
136
|
|
|
113
137
|
```bash
|
|
114
|
-
|
|
138
|
+
# 用户预配置
|
|
115
139
|
cat >> .claude-coder/test.env << 'EOF'
|
|
116
140
|
OPENAI_API_KEY=sk-xxx
|
|
141
|
+
TEST_USER=testuser@example.com
|
|
142
|
+
TEST_PASSWORD=xxx
|
|
117
143
|
EOF
|
|
118
|
-
claude-coder auth http://localhost:3000
|
|
119
|
-
claude-coder run
|
|
120
|
-
# 首次 MCP 访问需登录的页面时,在浏览器窗口登录一次
|
|
121
|
-
# 之后所有 session 自动保持登录状态
|
|
122
144
|
```
|
|
123
145
|
|
|
124
|
-
|
|
146
|
+
Agent 在测试前会 `source .claude-coder/test.env` 加载凭证。发现新凭证需求时也会自动追加写入。
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## 切换模式
|
|
125
151
|
|
|
126
152
|
```bash
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
153
|
+
# 推荐:一行命令切换(同时更新 .env 和 .mcp.json)
|
|
154
|
+
claude-coder config mcp persistent
|
|
155
|
+
claude-coder config mcp isolated
|
|
156
|
+
claude-coder config mcp extension
|
|
157
|
+
|
|
158
|
+
# 如果新模式需要登录(persistent / isolated),还需运行 auth
|
|
159
|
+
claude-coder auth <URL>
|
|
131
160
|
```
|
|
132
161
|
|
|
133
|
-
>
|
|
134
|
-
> "回访用户"而非"新自动化会话",大幅降低重复登录要求。如果仍被检测,可在 `.mcp.json` 中
|
|
135
|
-
> 添加 `--browser chrome` 使用真实 Chrome 进一步降低检测率。
|
|
162
|
+
> **说明**:`config mcp` 会同时更新 `.env` 中的 `MCP_PLAYWRIGHT_MODE` 和重新生成 `.mcp.json`,无需重走 `setup` 全流程。如果之前已经 auth 过对应模式(如 persistent 的 browser-profile 还在),切换回去后无需重新 auth。
|
|
136
163
|
|
|
137
|
-
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## 清理
|
|
138
167
|
|
|
139
168
|
```bash
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
# - cookies 被网站刷新时,新 cookies 自动写入 Profile
|
|
143
|
-
# - 不依赖静态 JSON 文件,状态持续演进
|
|
144
|
-
# - 即使中途重启 claude-coder,Profile 中的登录状态仍然有效
|
|
145
|
-
```
|
|
169
|
+
# 清除 persistent 模式配置
|
|
170
|
+
rm -rf .claude-coder/.runtime/browser-profile
|
|
146
171
|
|
|
147
|
-
|
|
172
|
+
# 清除 isolated 模式登录状态
|
|
173
|
+
rm .claude-coder/playwright-auth.json
|
|
148
174
|
|
|
149
|
-
|
|
150
|
-
rm
|
|
151
|
-
#
|
|
175
|
+
# 完全重置 Playwright 配置
|
|
176
|
+
rm .mcp.json
|
|
177
|
+
# 然后重新运行 claude-coder auth
|
|
152
178
|
```
|
package/docs/README.en.md
CHANGED
|
@@ -60,6 +60,7 @@ Each session, the agent autonomously follows 6 steps: restore context → env ch
|
|
|
60
60
|
| `claude-coder validate` | Manually validate last session |
|
|
61
61
|
| `claude-coder status` | View progress and costs |
|
|
62
62
|
| `claude-coder config sync` | Sync config to ~/.claude/ |
|
|
63
|
+
| `claude-coder config mcp <mode>` | Switch Playwright mode (persistent/isolated/extension) |
|
|
63
64
|
|
|
64
65
|
**Options**: `--max N` limit sessions (default 50), `--pause N` pause every N sessions (default: no pause).
|
|
65
66
|
|
|
@@ -85,10 +86,10 @@ your-project/
|
|
|
85
86
|
progress.json # Session history + costs
|
|
86
87
|
tests.json # Verification records
|
|
87
88
|
test.env # Test credentials (API keys, optional)
|
|
88
|
-
playwright-auth.json # Login state snapshot (
|
|
89
|
-
browser-profile/ # Persistent browser profile (used by MCP)
|
|
89
|
+
playwright-auth.json # Login state snapshot (isolated mode, via auth command)
|
|
90
90
|
.runtime/ # Temp files
|
|
91
91
|
logs/ # Per-session logs (with tool call traces)
|
|
92
|
+
browser-profile/ # Persistent browser profile (persistent mode, via auth command)
|
|
92
93
|
requirements.md # Requirements (optional)
|
|
93
94
|
```
|
|
94
95
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-coder",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.2",
|
|
4
4
|
"description": "Claude Coder — Autonomous coding agent harness powered by Claude Code SDK. Scan, plan, code, validate, git-commit in a loop.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"claude-coder": "bin/cli.js"
|
|
@@ -38,5 +38,7 @@
|
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@anthropic-ai/claude-agent-sdk": ">=0.1.0"
|
|
40
40
|
},
|
|
41
|
-
"
|
|
41
|
+
"optionalDependencies": {
|
|
42
|
+
"playwright": "^1.58.2"
|
|
43
|
+
}
|
|
42
44
|
}
|