ccjk 2.2.4 → 2.3.0
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/dist/chunks/auto-updater.mjs +15 -1
- package/dist/chunks/ccjk-config.mjs +77 -13
- package/dist/chunks/ccr.mjs +7 -10
- package/dist/chunks/ccu.mjs +4 -4
- package/dist/chunks/check-updates.mjs +4 -7
- package/dist/chunks/claude-code-config-manager.mjs +8 -11
- package/dist/chunks/claude-code-incremental-manager.mjs +4 -7
- package/dist/chunks/codex.mjs +416 -17
- package/dist/chunks/commands.mjs +392 -89
- package/dist/chunks/commands2.mjs +109 -0
- package/dist/chunks/config-consolidator.mjs +2 -2
- package/dist/chunks/config-switch.mjs +5 -8
- package/dist/chunks/doctor.mjs +6 -6
- package/dist/chunks/features.mjs +654 -35
- package/dist/chunks/help.mjs +339 -0
- package/dist/chunks/index.mjs +1020 -10
- package/dist/chunks/index2.mjs +4 -3
- package/dist/chunks/index3.mjs +1171 -0
- package/dist/chunks/init.mjs +21 -24
- package/dist/chunks/installer.mjs +178 -0
- package/dist/chunks/interview.mjs +6 -6
- package/dist/chunks/mcp-performance.mjs +79 -2
- package/dist/chunks/mcp.mjs +500 -0
- package/dist/chunks/menu.mjs +10 -10
- package/dist/chunks/notification.mjs +5 -5
- package/dist/chunks/onboarding.mjs +6 -6
- package/dist/chunks/package.mjs +1 -1
- package/dist/chunks/platform.mjs +10 -10
- package/dist/chunks/prompts.mjs +7 -8
- package/dist/chunks/session.mjs +2 -2
- package/dist/chunks/skills-sync.mjs +2 -2
- package/dist/chunks/uninstall.mjs +4 -5
- package/dist/chunks/update.mjs +4 -7
- package/dist/chunks/upgrade-manager.mjs +2 -2
- package/dist/chunks/version-checker.mjs +88 -7
- package/dist/chunks/workflows.mjs +617 -84
- package/dist/cli.mjs +295 -55
- package/dist/i18n/locales/en/agentBrowser.json +79 -0
- package/dist/i18n/locales/en/cloud-sync.json +147 -0
- package/dist/i18n/locales/en/marketplace.json +32 -1
- package/dist/i18n/locales/en/mcp.json +2 -4
- package/dist/i18n/locales/en/updater.json +3 -1
- package/dist/i18n/locales/zh/agentBrowser.json +79 -0
- package/dist/i18n/locales/zh-CN/cloud-sync.json +147 -0
- package/dist/i18n/locales/zh-CN/common.json +1 -1
- package/dist/i18n/locales/zh-CN/marketplace.json +32 -1
- package/dist/i18n/locales/zh-CN/mcp.json +2 -4
- package/dist/i18n/locales/zh-CN/updater.json +3 -1
- package/dist/index.d.mts +8 -584
- package/dist/index.d.ts +8 -584
- package/dist/index.mjs +9 -13
- package/dist/shared/{ccjk.DJM5aVQJ.mjs → ccjk.ByTIGCUC.mjs} +3 -3
- package/dist/shared/{ccjk.qYAnUMuy.mjs → ccjk.CGTmRqsu.mjs} +2 -3
- package/dist/shared/{ccjk.CUdzQluX.mjs → ccjk.CURU8gbR.mjs} +1 -1
- package/dist/{chunks/mcp-market.mjs → shared/ccjk.D-RZS4E2.mjs} +6 -65
- package/dist/shared/{ccjk.B7169qud.mjs → ccjk.tB4-Y4Qb.mjs} +3 -3
- package/package.json +4 -1
- package/templates/common/skills/en/agent-browser.md +258 -0
- package/templates/common/skills/zh-CN/agent-browser.md +260 -0
- package/dist/chunks/claude-config.mjs +0 -228
- package/dist/chunks/features2.mjs +0 -661
- package/dist/chunks/json-config.mjs +0 -59
- package/dist/chunks/mcp-doctor.mjs +0 -160
- package/dist/chunks/mcp-profile.mjs +0 -220
- package/dist/chunks/mcp-release.mjs +0 -138
- package/dist/chunks/shencha.mjs +0 -320
- package/dist/chunks/tools.mjs +0 -169
- package/dist/shared/ccjk.COdsoe-Y.mjs +0 -64
- package/dist/shared/ccjk.DwDtZ5cK.mjs +0 -266
- package/dist/shared/ccjk.n_AtlHzB.mjs +0 -186
package/dist/chunks/commands.mjs
CHANGED
|
@@ -1,109 +1,412 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { ensureI18nInitialized, i18n } from './index2.mjs';
|
|
1
|
+
import process__default from 'node:process';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import { checkAgentBrowserInstalled, getInstallPath } from './installer.mjs';
|
|
5
4
|
import 'node:fs';
|
|
6
|
-
import 'node:
|
|
7
|
-
import 'node:
|
|
8
|
-
import 'i18next';
|
|
9
|
-
import 'i18next-fs-backend';
|
|
10
|
-
import 'pathe';
|
|
5
|
+
import 'node:os';
|
|
6
|
+
import 'node:path';
|
|
11
7
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
8
|
+
const { green: green$1, yellow: yellow$1 } = chalk;
|
|
9
|
+
class AgentBrowserSession {
|
|
10
|
+
options;
|
|
11
|
+
isRunning = false;
|
|
12
|
+
sessionId = null;
|
|
13
|
+
constructor(options = {}) {
|
|
14
|
+
this.options = {
|
|
15
|
+
headless: true,
|
|
16
|
+
verbose: false,
|
|
17
|
+
timeout: 3e4,
|
|
18
|
+
browser: "chromium",
|
|
19
|
+
...options
|
|
20
|
+
};
|
|
22
21
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
/**
|
|
23
|
+
* 启动浏览器会话
|
|
24
|
+
*/
|
|
25
|
+
async start() {
|
|
26
|
+
if (this.isRunning) {
|
|
27
|
+
if (this.options.verbose) {
|
|
28
|
+
console.log(`${yellow$1("!")} Session already running`);
|
|
29
|
+
}
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
const { execSync } = await import('node:child_process');
|
|
34
|
+
this.sessionId = `session-${Date.now()}`;
|
|
35
|
+
const headlessFlag = this.options.headless ? "" : "--headed";
|
|
36
|
+
execSync(`agent-browser start ${headlessFlag} 2>/dev/null || true`, {
|
|
37
|
+
encoding: "utf-8",
|
|
38
|
+
stdio: "pipe"
|
|
39
|
+
});
|
|
40
|
+
this.isRunning = true;
|
|
41
|
+
if (this.options.verbose) {
|
|
42
|
+
console.log(`${green$1("\u2713")} Browser session started: ${this.sessionId}`);
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
this.isRunning = false;
|
|
46
|
+
throw new Error(`Failed to start browser session: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 导航到 URL
|
|
51
|
+
*/
|
|
52
|
+
async navigate(url) {
|
|
53
|
+
this.ensureRunning();
|
|
54
|
+
try {
|
|
55
|
+
const { execSync } = await import('node:child_process');
|
|
56
|
+
const fullUrl = url.startsWith("http") ? url : `https://${url}`;
|
|
57
|
+
execSync(`agent-browser open "${fullUrl}"`, {
|
|
58
|
+
encoding: "utf-8",
|
|
59
|
+
stdio: this.options.verbose ? "inherit" : "pipe",
|
|
60
|
+
timeout: this.options.timeout
|
|
61
|
+
});
|
|
62
|
+
if (this.options.verbose) {
|
|
63
|
+
console.log(`${green$1("\u2713")} Navigated to: ${fullUrl}`);
|
|
64
|
+
}
|
|
65
|
+
} catch (error) {
|
|
66
|
+
throw new Error(`Failed to navigate: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 获取页面快照
|
|
71
|
+
*/
|
|
72
|
+
async snapshot(options = {}) {
|
|
73
|
+
this.ensureRunning();
|
|
74
|
+
try {
|
|
75
|
+
const { execSync } = await import('node:child_process');
|
|
76
|
+
const flags = [];
|
|
77
|
+
if (options.interactive)
|
|
78
|
+
flags.push("-i");
|
|
79
|
+
if (options.compact)
|
|
80
|
+
flags.push("-c");
|
|
81
|
+
if (options.depth)
|
|
82
|
+
flags.push(`-d ${options.depth}`);
|
|
83
|
+
if (options.json)
|
|
84
|
+
flags.push("--json");
|
|
85
|
+
const result = execSync(`agent-browser snapshot ${flags.join(" ")}`, {
|
|
86
|
+
encoding: "utf-8",
|
|
87
|
+
timeout: this.options.timeout
|
|
88
|
+
});
|
|
89
|
+
return result.trim();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new Error(`Failed to get snapshot: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 点击元素
|
|
96
|
+
*/
|
|
97
|
+
async click(ref) {
|
|
98
|
+
this.ensureRunning();
|
|
99
|
+
try {
|
|
100
|
+
const { execSync } = await import('node:child_process');
|
|
101
|
+
const refId = ref.startsWith("@") ? ref : `@${ref}`;
|
|
102
|
+
execSync(`agent-browser click ${refId}`, {
|
|
103
|
+
encoding: "utf-8",
|
|
104
|
+
stdio: this.options.verbose ? "inherit" : "pipe",
|
|
105
|
+
timeout: this.options.timeout
|
|
106
|
+
});
|
|
107
|
+
if (this.options.verbose) {
|
|
108
|
+
console.log(`${green$1("\u2713")} Clicked: ${refId}`);
|
|
109
|
+
}
|
|
110
|
+
} catch (error) {
|
|
111
|
+
throw new Error(`Failed to click: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* 填充输入框
|
|
116
|
+
*/
|
|
117
|
+
async fill(ref, text) {
|
|
118
|
+
this.ensureRunning();
|
|
119
|
+
try {
|
|
120
|
+
const { execSync } = await import('node:child_process');
|
|
121
|
+
const refId = ref.startsWith("@") ? ref : `@${ref}`;
|
|
122
|
+
execSync(`agent-browser fill ${refId} "${text.replace(/"/g, '\\"')}"`, {
|
|
123
|
+
encoding: "utf-8",
|
|
124
|
+
stdio: this.options.verbose ? "inherit" : "pipe",
|
|
125
|
+
timeout: this.options.timeout
|
|
126
|
+
});
|
|
127
|
+
if (this.options.verbose) {
|
|
128
|
+
console.log(`${green$1("\u2713")} Filled ${refId}: ${text}`);
|
|
129
|
+
}
|
|
130
|
+
} catch (error) {
|
|
131
|
+
throw new Error(`Failed to fill: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* 获取元素文本
|
|
136
|
+
*/
|
|
137
|
+
async getText(ref) {
|
|
138
|
+
this.ensureRunning();
|
|
139
|
+
try {
|
|
140
|
+
const { execSync } = await import('node:child_process');
|
|
141
|
+
const refId = ref.startsWith("@") ? ref : `@${ref}`;
|
|
142
|
+
const result = execSync(`agent-browser get text ${refId}`, {
|
|
143
|
+
encoding: "utf-8",
|
|
144
|
+
timeout: this.options.timeout
|
|
145
|
+
});
|
|
146
|
+
return result.trim();
|
|
147
|
+
} catch (error) {
|
|
148
|
+
throw new Error(`Failed to get text: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 截图
|
|
153
|
+
*/
|
|
154
|
+
async screenshot(path, fullPage = false) {
|
|
155
|
+
this.ensureRunning();
|
|
156
|
+
try {
|
|
157
|
+
const { execSync } = await import('node:child_process');
|
|
158
|
+
const flags = [];
|
|
159
|
+
if (fullPage)
|
|
160
|
+
flags.push("--full");
|
|
161
|
+
if (path)
|
|
162
|
+
flags.push(path);
|
|
163
|
+
const result = execSync(`agent-browser screenshot ${flags.join(" ")}`, {
|
|
164
|
+
encoding: "utf-8",
|
|
165
|
+
timeout: this.options.timeout
|
|
166
|
+
});
|
|
167
|
+
if (this.options.verbose) {
|
|
168
|
+
console.log(`${green$1("\u2713")} Screenshot saved: ${path || "screenshot.png"}`);
|
|
169
|
+
}
|
|
170
|
+
return result.trim();
|
|
171
|
+
} catch (error) {
|
|
172
|
+
throw new Error(`Failed to take screenshot: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* 等待
|
|
177
|
+
*/
|
|
178
|
+
async wait(condition) {
|
|
179
|
+
this.ensureRunning();
|
|
180
|
+
try {
|
|
181
|
+
const { execSync } = await import('node:child_process');
|
|
182
|
+
let cmd;
|
|
183
|
+
if (typeof condition === "number") {
|
|
184
|
+
cmd = `agent-browser wait ${condition}`;
|
|
185
|
+
} else if (condition.startsWith("@")) {
|
|
186
|
+
cmd = `agent-browser wait ${condition}`;
|
|
187
|
+
} else {
|
|
188
|
+
cmd = `agent-browser wait --text "${condition}"`;
|
|
189
|
+
}
|
|
190
|
+
execSync(cmd, {
|
|
191
|
+
encoding: "utf-8",
|
|
192
|
+
stdio: this.options.verbose ? "inherit" : "pipe",
|
|
193
|
+
timeout: this.options.timeout
|
|
194
|
+
});
|
|
195
|
+
} catch (error) {
|
|
196
|
+
throw new Error(`Failed to wait: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 关闭会话
|
|
201
|
+
*/
|
|
202
|
+
async close() {
|
|
203
|
+
if (!this.isRunning) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const { execSync } = await import('node:child_process');
|
|
208
|
+
execSync("agent-browser close 2>/dev/null || true", {
|
|
209
|
+
encoding: "utf-8",
|
|
210
|
+
stdio: "pipe"
|
|
211
|
+
});
|
|
212
|
+
this.isRunning = false;
|
|
213
|
+
this.sessionId = null;
|
|
214
|
+
if (this.options.verbose) {
|
|
215
|
+
console.log(`${green$1("\u2713")} Browser session closed`);
|
|
216
|
+
}
|
|
217
|
+
} catch {
|
|
218
|
+
this.isRunning = false;
|
|
219
|
+
this.sessionId = null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* 获取会话状态
|
|
224
|
+
*/
|
|
225
|
+
getStatus() {
|
|
226
|
+
return {
|
|
227
|
+
running: this.isRunning,
|
|
228
|
+
sessionId: this.sessionId
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* 确保会话正在运行
|
|
233
|
+
*/
|
|
234
|
+
ensureRunning() {
|
|
235
|
+
if (!this.isRunning) {
|
|
236
|
+
throw new Error("Browser session is not running. Call start() first.");
|
|
237
|
+
}
|
|
33
238
|
}
|
|
34
239
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
240
|
+
|
|
241
|
+
const { bold, cyan, gray, green, red, yellow } = chalk;
|
|
242
|
+
function agentBrowserHelp(_options) {
|
|
243
|
+
console.log(`
|
|
244
|
+
${bold(cyan("Agent Browser"))} - ${gray("Zero-config browser automation for AI agents")}
|
|
245
|
+
|
|
246
|
+
${yellow("Usage:")}
|
|
247
|
+
ccjk browser <action> [options]
|
|
248
|
+
ccjk ab <action> [options]
|
|
249
|
+
|
|
250
|
+
${yellow("Actions:")}
|
|
251
|
+
${cyan("install")} Install Agent Browser (Rust CLI + Playwright)
|
|
252
|
+
${cyan("uninstall")} Remove Agent Browser
|
|
253
|
+
${cyan("status")} Check installation status
|
|
254
|
+
${cyan("start")} Start a browser session
|
|
255
|
+
${cyan("stop")} Stop current browser session
|
|
256
|
+
${cyan("config")} Configure browser settings
|
|
257
|
+
|
|
258
|
+
${yellow("Examples:")}
|
|
259
|
+
${gray("# Install Agent Browser")}
|
|
260
|
+
ccjk browser install
|
|
261
|
+
|
|
262
|
+
${gray("# Check status")}
|
|
263
|
+
ccjk browser status
|
|
264
|
+
|
|
265
|
+
${gray("# Start a session with URL")}
|
|
266
|
+
ccjk browser start https://example.com
|
|
267
|
+
|
|
268
|
+
${yellow("Quick Start:")}
|
|
269
|
+
${gray("After installation, use these commands directly:")}
|
|
270
|
+
agent-browser open <url> ${gray("# Navigate to URL")}
|
|
271
|
+
agent-browser snapshot -i ${gray("# Get interactive elements")}
|
|
272
|
+
agent-browser click @e1 ${gray("# Click by ref")}
|
|
273
|
+
agent-browser fill @e2 "text" ${gray("# Fill input")}
|
|
274
|
+
agent-browser screenshot ${gray("# Take screenshot")}
|
|
275
|
+
agent-browser close ${gray("# Close browser")}
|
|
276
|
+
|
|
277
|
+
${yellow("Documentation:")}
|
|
278
|
+
Run ${cyan("/browser")} in Claude Code for full skill documentation
|
|
279
|
+
`);
|
|
280
|
+
}
|
|
281
|
+
async function agentBrowserStatus(options) {
|
|
282
|
+
console.log(`
|
|
283
|
+
${bold(cyan("Agent Browser Status"))}
|
|
284
|
+
`);
|
|
285
|
+
const installed = await checkAgentBrowserInstalled();
|
|
286
|
+
const installPath = getInstallPath();
|
|
287
|
+
if (installed) {
|
|
288
|
+
console.log(` ${green("\u2713")} Agent Browser is ${green("installed")}`);
|
|
289
|
+
console.log(` ${gray("Path:")} ${installPath}`);
|
|
290
|
+
try {
|
|
291
|
+
const { execSync } = await import('node:child_process');
|
|
292
|
+
const version = execSync('agent-browser --version 2>/dev/null || echo "unknown"', {
|
|
293
|
+
encoding: "utf-8"
|
|
294
|
+
}).trim();
|
|
295
|
+
console.log(` ${gray("Version:")} ${version}`);
|
|
296
|
+
} catch {
|
|
297
|
+
console.log(` ${gray("Version:")} ${yellow("unknown")}`);
|
|
298
|
+
}
|
|
299
|
+
try {
|
|
300
|
+
const { execSync } = await import('node:child_process');
|
|
301
|
+
execSync("npx playwright --version 2>/dev/null", { encoding: "utf-8" });
|
|
302
|
+
console.log(` ${green("\u2713")} Playwright browsers available`);
|
|
303
|
+
} catch {
|
|
304
|
+
console.log(` ${yellow("!")} Playwright browsers may need installation`);
|
|
305
|
+
console.log(` ${gray("Run:")} npx playwright install chromium`);
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
console.log(` ${red("\u2717")} Agent Browser is ${red("not installed")}`);
|
|
309
|
+
console.log(`
|
|
310
|
+
${gray("To install, run:")}`);
|
|
311
|
+
console.log(` ${cyan("ccjk browser install")}`);
|
|
312
|
+
}
|
|
313
|
+
if (options.verbose) {
|
|
314
|
+
console.log(`
|
|
315
|
+
${gray("Debug Info:")}`);
|
|
316
|
+
console.log(` ${gray("Install path:")} ${installPath}`);
|
|
317
|
+
console.log(` ${gray("Platform:")} ${process__default.platform}`);
|
|
318
|
+
console.log(` ${gray("Arch:")} ${process__default.arch}`);
|
|
51
319
|
}
|
|
320
|
+
console.log();
|
|
52
321
|
}
|
|
53
|
-
async function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
322
|
+
async function startBrowserSession(url, options = {}) {
|
|
323
|
+
const installed = await checkAgentBrowserInstalled();
|
|
324
|
+
if (!installed) {
|
|
325
|
+
console.log(`
|
|
326
|
+
${red("\u2717")} Agent Browser is not installed`);
|
|
327
|
+
console.log(` ${gray("Run:")} ${cyan("ccjk browser install")} ${gray("first")}
|
|
328
|
+
`);
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
console.log(`
|
|
332
|
+
${cyan("Starting browser session...")}
|
|
333
|
+
`);
|
|
57
334
|
try {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
335
|
+
const session = new AgentBrowserSession({
|
|
336
|
+
headless: true,
|
|
337
|
+
verbose: options.verbose
|
|
338
|
+
});
|
|
339
|
+
await session.start();
|
|
340
|
+
if (url) {
|
|
341
|
+
console.log(`${gray("Navigating to:")} ${url}`);
|
|
342
|
+
await session.navigate(url);
|
|
343
|
+
}
|
|
344
|
+
console.log(`
|
|
345
|
+
${green("\u2713")} Browser session started`);
|
|
346
|
+
console.log(`
|
|
347
|
+
${yellow("Available commands:")}`);
|
|
348
|
+
console.log(` agent-browser snapshot -i ${gray("# Get interactive elements")}`);
|
|
349
|
+
console.log(` agent-browser click @e1 ${gray("# Click element")}`);
|
|
350
|
+
console.log(` agent-browser close ${gray("# Close session")}`);
|
|
351
|
+
console.log();
|
|
64
352
|
} catch (error) {
|
|
65
|
-
console.error(
|
|
66
|
-
|
|
353
|
+
console.error(`
|
|
354
|
+
${red("\u2717")} Failed to start browser session`);
|
|
355
|
+
if (options.verbose && error instanceof Error) {
|
|
356
|
+
console.error(` ${gray("Error:")} ${error.message}`);
|
|
357
|
+
}
|
|
358
|
+
console.log(`
|
|
359
|
+
${gray("Try running:")} ${cyan("ccjk browser install")} ${gray("to reinstall")}
|
|
360
|
+
`);
|
|
67
361
|
}
|
|
68
362
|
}
|
|
69
|
-
async function
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
363
|
+
async function stopBrowserSession(options = {}) {
|
|
364
|
+
console.log(`
|
|
365
|
+
${cyan("Stopping browser session...")}
|
|
366
|
+
`);
|
|
73
367
|
try {
|
|
74
|
-
const {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
console.error(ansis.yellow(stderr));
|
|
79
|
-
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
|
|
368
|
+
const { execSync } = await import('node:child_process');
|
|
369
|
+
execSync("agent-browser close 2>/dev/null || true", { encoding: "utf-8" });
|
|
370
|
+
console.log(`${green("\u2713")} Browser session stopped
|
|
371
|
+
`);
|
|
80
372
|
} catch (error) {
|
|
81
|
-
if (
|
|
82
|
-
console.log(
|
|
83
|
-
|
|
84
|
-
console.error(ansis.yellow(error.stderr));
|
|
85
|
-
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
|
|
373
|
+
if (options.verbose && error instanceof Error) {
|
|
374
|
+
console.log(`${yellow("!")} No active session found or already closed`);
|
|
375
|
+
console.log(` ${gray("Error:")} ${error.message}`);
|
|
86
376
|
} else {
|
|
87
|
-
console.
|
|
88
|
-
|
|
377
|
+
console.log(`${yellow("!")} No active session found
|
|
378
|
+
`);
|
|
89
379
|
}
|
|
90
380
|
}
|
|
91
381
|
}
|
|
92
|
-
async function
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
382
|
+
async function configureBrowser(options = {}) {
|
|
383
|
+
console.log(`
|
|
384
|
+
${bold(cyan("Agent Browser Configuration"))}
|
|
385
|
+
`);
|
|
386
|
+
const installed = await checkAgentBrowserInstalled();
|
|
387
|
+
if (!installed) {
|
|
388
|
+
console.log(`${red("\u2717")} Agent Browser is not installed`);
|
|
389
|
+
console.log(` ${gray("Run:")} ${cyan("ccjk browser install")} ${gray("first")}
|
|
390
|
+
`);
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
console.log(`${yellow("Current Settings:")}`);
|
|
394
|
+
console.log(` ${gray("Default browser:")} chromium`);
|
|
395
|
+
console.log(` ${gray("Headless mode:")} enabled`);
|
|
396
|
+
console.log(` ${gray("Timeout:")} 30000ms`);
|
|
397
|
+
console.log(`
|
|
398
|
+
${yellow("Configuration Options:")}`);
|
|
399
|
+
console.log(` ${gray("Environment variables:")}`);
|
|
400
|
+
console.log(` AGENT_BROWSER_HEADLESS=false ${gray("# Show browser window")}`);
|
|
401
|
+
console.log(` AGENT_BROWSER_TIMEOUT=60000 ${gray("# Set timeout in ms")}`);
|
|
402
|
+
console.log(` AGENT_BROWSER_BROWSER=firefox ${gray("# Use Firefox")}`);
|
|
403
|
+
if (options.verbose) {
|
|
404
|
+
console.log(`
|
|
405
|
+
${gray("Advanced:")}`);
|
|
406
|
+
console.log(` ${gray("Config file:")} ~/.agent-browser/config.json`);
|
|
407
|
+
console.log(` ${gray("Session dir:")} ~/.agent-browser/sessions/`);
|
|
106
408
|
}
|
|
409
|
+
console.log();
|
|
107
410
|
}
|
|
108
411
|
|
|
109
|
-
export {
|
|
412
|
+
export { agentBrowserHelp, agentBrowserStatus, configureBrowser, startBrowserSession, stopBrowserSession };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { exec } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
3
|
+
import ansis from 'ansis';
|
|
4
|
+
import { ensureI18nInitialized, i18n } from './index2.mjs';
|
|
5
|
+
import 'node:fs';
|
|
6
|
+
import 'node:process';
|
|
7
|
+
import 'node:url';
|
|
8
|
+
import 'i18next';
|
|
9
|
+
import 'i18next-fs-backend';
|
|
10
|
+
import 'pathe';
|
|
11
|
+
|
|
12
|
+
const execAsync = promisify(exec);
|
|
13
|
+
async function runCcrUi(apiKey) {
|
|
14
|
+
ensureI18nInitialized();
|
|
15
|
+
console.log(ansis.cyan(`
|
|
16
|
+
\u{1F5A5}\uFE0F ${i18n.t("ccr:startingCcrUi")}`));
|
|
17
|
+
if (apiKey) {
|
|
18
|
+
console.log(ansis.bold.green(`
|
|
19
|
+
\u{1F511} ${i18n.t("ccr:ccrUiApiKey") || "CCR UI API Key"}: ${apiKey}`));
|
|
20
|
+
console.log(ansis.gray(` ${i18n.t("ccr:ccrUiApiKeyHint") || "Use this API key to login to CCR UI"}
|
|
21
|
+
`));
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const { stdout, stderr } = await execAsync("ccr ui");
|
|
25
|
+
if (stdout)
|
|
26
|
+
console.log(stdout);
|
|
27
|
+
if (stderr)
|
|
28
|
+
console.error(ansis.yellow(stderr));
|
|
29
|
+
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrUiStarted")}`));
|
|
30
|
+
} catch (error) {
|
|
31
|
+
console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async function runCcrStatus() {
|
|
36
|
+
ensureI18nInitialized();
|
|
37
|
+
console.log(ansis.cyan(`
|
|
38
|
+
\u{1F4CA} ${i18n.t("ccr:checkingCcrStatus")}`));
|
|
39
|
+
try {
|
|
40
|
+
const { stdout, stderr } = await execAsync("ccr status");
|
|
41
|
+
if (stdout) {
|
|
42
|
+
console.log(`
|
|
43
|
+
${ansis.bold(i18n.t("ccr:ccrStatusTitle"))}`);
|
|
44
|
+
console.log(stdout);
|
|
45
|
+
}
|
|
46
|
+
if (stderr)
|
|
47
|
+
console.error(ansis.yellow(stderr));
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async function runCcrRestart() {
|
|
54
|
+
ensureI18nInitialized();
|
|
55
|
+
console.log(ansis.cyan(`
|
|
56
|
+
\u{1F504} ${i18n.t("ccr:restartingCcr")}`));
|
|
57
|
+
try {
|
|
58
|
+
const { stdout, stderr } = await execAsync("ccr restart");
|
|
59
|
+
if (stdout)
|
|
60
|
+
console.log(stdout);
|
|
61
|
+
if (stderr)
|
|
62
|
+
console.error(ansis.yellow(stderr));
|
|
63
|
+
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrRestarted")}`));
|
|
64
|
+
} catch (error) {
|
|
65
|
+
console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async function runCcrStart() {
|
|
70
|
+
ensureI18nInitialized();
|
|
71
|
+
console.log(ansis.cyan(`
|
|
72
|
+
\u25B6\uFE0F ${i18n.t("ccr:startingCcr")}`));
|
|
73
|
+
try {
|
|
74
|
+
const { stdout, stderr } = await execAsync("ccr start");
|
|
75
|
+
if (stdout)
|
|
76
|
+
console.log(stdout);
|
|
77
|
+
if (stderr)
|
|
78
|
+
console.error(ansis.yellow(stderr));
|
|
79
|
+
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error.stdout && error.stdout.includes("Loaded JSON config from:")) {
|
|
82
|
+
console.log(error.stdout);
|
|
83
|
+
if (error.stderr)
|
|
84
|
+
console.error(ansis.yellow(error.stderr));
|
|
85
|
+
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStarted")}`));
|
|
86
|
+
} else {
|
|
87
|
+
console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async function runCcrStop() {
|
|
93
|
+
ensureI18nInitialized();
|
|
94
|
+
console.log(ansis.cyan(`
|
|
95
|
+
\u23F9\uFE0F ${i18n.t("ccr:stoppingCcr")}`));
|
|
96
|
+
try {
|
|
97
|
+
const { stdout, stderr } = await execAsync("ccr stop");
|
|
98
|
+
if (stdout)
|
|
99
|
+
console.log(stdout);
|
|
100
|
+
if (stderr)
|
|
101
|
+
console.error(ansis.yellow(stderr));
|
|
102
|
+
console.log(ansis.green(`\u2714 ${i18n.t("ccr:ccrStopped")}`));
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.error(ansis.red(`\u2716 ${i18n.t("ccr:ccrCommandFailed")}: ${error instanceof Error ? error.message : String(error)}`));
|
|
105
|
+
throw error;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { runCcrRestart, runCcrStart, runCcrStatus, runCcrStop, runCcrUi };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync, statSync, readFileSync, mkdirSync, copyFileSync, unlinkSync } from 'node:fs';
|
|
2
2
|
import { homedir } from 'node:os';
|
|
3
|
-
import
|
|
3
|
+
import process__default from 'node:process';
|
|
4
4
|
import ansis from 'ansis';
|
|
5
5
|
import dayjs from 'dayjs';
|
|
6
6
|
import { join } from 'pathe';
|
|
@@ -68,7 +68,7 @@ function detectAllConfigs(projectDir) {
|
|
|
68
68
|
locations.push(location);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
const customPath =
|
|
71
|
+
const customPath = process__default.env.CLAUDE_CONFIG_PATH;
|
|
72
72
|
if (customPath && !locations.some((l) => l.path === customPath)) {
|
|
73
73
|
const exists = existsSync(customPath);
|
|
74
74
|
const location = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import process__default from 'node:process';
|
|
2
2
|
import ansis from 'ansis';
|
|
3
3
|
import inquirer from 'inquirer';
|
|
4
4
|
import { resolveCodeToolType, isCodeToolType, DEFAULT_CODE_TOOL_TYPE } from './constants.mjs';
|
|
5
5
|
import { ensureI18nInitialized, i18n } from './index2.mjs';
|
|
6
|
-
import { readZcfConfig } from './ccjk-config.mjs';
|
|
6
|
+
import { a as readZcfConfig } from './ccjk-config.mjs';
|
|
7
7
|
import { ClaudeCodeConfigManager } from './claude-code-config-manager.mjs';
|
|
8
|
-
import {
|
|
9
|
-
import { a as handleGeneralError } from '../shared/ccjk.
|
|
8
|
+
import { U as switchCodexProvider, H as listCodexProviders, r as readCodexConfig, y as switchToOfficialLogin, V as switchToProvider } from './codex.mjs';
|
|
9
|
+
import { a as handleGeneralError } from '../shared/ccjk.tB4-Y4Qb.mjs';
|
|
10
10
|
import { a as addNumbersToChoices } from '../shared/ccjk.DhBeLRzf.mjs';
|
|
11
11
|
import 'node:os';
|
|
12
12
|
import 'pathe';
|
|
@@ -18,17 +18,14 @@ import 'smol-toml';
|
|
|
18
18
|
import './fs-operations.mjs';
|
|
19
19
|
import 'node:crypto';
|
|
20
20
|
import 'node:fs/promises';
|
|
21
|
-
import './json-config.mjs';
|
|
22
21
|
import 'dayjs';
|
|
23
22
|
import 'ora';
|
|
24
23
|
import 'semver';
|
|
25
24
|
import 'tinyexec';
|
|
26
|
-
import './claude-config.mjs';
|
|
27
25
|
import './platform.mjs';
|
|
28
26
|
import 'inquirer-toggle';
|
|
29
27
|
import './prompts.mjs';
|
|
30
28
|
import './package.mjs';
|
|
31
|
-
import '../shared/ccjk.DwDtZ5cK.mjs';
|
|
32
29
|
import 'node:child_process';
|
|
33
30
|
|
|
34
31
|
async function configSwitchCommand(options) {
|
|
@@ -45,7 +42,7 @@ async function configSwitchCommand(options) {
|
|
|
45
42
|
}
|
|
46
43
|
await handleInteractiveSwitch(options.codeType);
|
|
47
44
|
} catch (error) {
|
|
48
|
-
if (
|
|
45
|
+
if (process__default.env.NODE_ENV === "test" || process__default.env.VITEST) {
|
|
49
46
|
throw error;
|
|
50
47
|
}
|
|
51
48
|
handleGeneralError(error);
|