ccem 2.91.0 → 2.92.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/index.js +262 -192
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1232,8 +1232,8 @@ function registerRemoteBridge(program2) {
|
|
|
1232
1232
|
import { Command } from "commander";
|
|
1233
1233
|
import Conf2 from "conf";
|
|
1234
1234
|
import inquirer from "inquirer";
|
|
1235
|
-
import
|
|
1236
|
-
import
|
|
1235
|
+
import chalk9 from "chalk";
|
|
1236
|
+
import Table4 from "cli-table3";
|
|
1237
1237
|
import { spawn as spawn4 } from "child_process";
|
|
1238
1238
|
import * as fs14 from "fs";
|
|
1239
1239
|
import * as path12 from "path";
|
|
@@ -4007,6 +4007,7 @@ Manage scheduled tasks for Claude Code/Codex through the structured \`ccem cron\
|
|
|
4007
4007
|
Determine the user's intent from their message:
|
|
4008
4008
|
|
|
4009
4009
|
- **List/view**: user says "list", "show", "view", "\u67E5\u770B", "\u5217\u51FA"
|
|
4010
|
+
- **Run now**: user says "run now", "trigger", "\u7ACB\u5373\u8FD0\u884C", "\u9A6C\u4E0A\u8DD1", "\u624B\u52A8\u89E6\u53D1"
|
|
4010
4011
|
- **Delete/remove**: user says "delete", "remove", "\u5220\u9664", "\u79FB\u9664"
|
|
4011
4012
|
- **Create**: default for anything else
|
|
4012
4013
|
|
|
@@ -4074,6 +4075,18 @@ ccem cron list
|
|
|
4074
4075
|
|
|
4075
4076
|
Use \`ccem cron list --json\` when you need exact fields.
|
|
4076
4077
|
|
|
4078
|
+
## Running A Task Now
|
|
4079
|
+
|
|
4080
|
+
When the user wants an existing task to run immediately (instead of waiting for its schedule), trigger it through the CLI:
|
|
4081
|
+
|
|
4082
|
+
\`\`\`bash
|
|
4083
|
+
ccem cron trigger "TASK_ID_OR_EXACT_NAME"
|
|
4084
|
+
\`\`\`
|
|
4085
|
+
|
|
4086
|
+
- CCEM Desktop must be running; the task executes in the desktop's background and its run history appears there.
|
|
4087
|
+
- Triggering is not destructive and does not modify the task or its schedule, so no confirmation is needed beyond identifying the right task.
|
|
4088
|
+
- Report the task name/id from the command output. Run status is not available in the CLI.
|
|
4089
|
+
|
|
4077
4090
|
## Deleting A Task
|
|
4078
4091
|
|
|
4079
4092
|
1. List all tasks first so the user can identify which one to delete.
|
|
@@ -4087,12 +4100,16 @@ ccem cron delete "TASK_ID_OR_EXACT_NAME"
|
|
|
4087
4100
|
## Safety Rules
|
|
4088
4101
|
|
|
4089
4102
|
- Do not directly read, write, or hand-edit \`~/.ccem/cron-tasks.json\`.
|
|
4090
|
-
- Use \`ccem cron create/list/delete\` as the stable contract.
|
|
4103
|
+
- Use \`ccem cron create/list/trigger/delete\` as the stable contract.
|
|
4091
4104
|
- Never construct JSON by string concatenation; pass valid JSON to \`--from-json\`.
|
|
4092
4105
|
- After creating or deleting a task, read back with \`ccem cron list --json\` and report the actual stored task.
|
|
4093
4106
|
- Ask for confirmation first only when the request is ambiguous or destructive.
|
|
4094
4107
|
`;
|
|
4095
4108
|
|
|
4109
|
+
// src/cronCommands.ts
|
|
4110
|
+
import chalk7 from "chalk";
|
|
4111
|
+
import Table3 from "cli-table3";
|
|
4112
|
+
|
|
4096
4113
|
// src/cron.ts
|
|
4097
4114
|
import crypto5 from "crypto";
|
|
4098
4115
|
import * as fs11 from "fs";
|
|
@@ -4111,6 +4128,39 @@ async function getCronNotificationTargets(request = requestDesktopControl) {
|
|
|
4111
4128
|
if (!Array.isArray(result)) throw new Error("Invalid notification targets response");
|
|
4112
4129
|
return result;
|
|
4113
4130
|
}
|
|
4131
|
+
async function listCronTasksViaDesktop(request = requestDesktopControl, tasksPath = getCronTasksPath()) {
|
|
4132
|
+
try {
|
|
4133
|
+
const tasks = await request("ccem.cron.list");
|
|
4134
|
+
if (!Array.isArray(tasks)) {
|
|
4135
|
+
throw new Error("Invalid cron tasks response from CCEM Desktop.");
|
|
4136
|
+
}
|
|
4137
|
+
return tasks;
|
|
4138
|
+
} catch {
|
|
4139
|
+
return readCronTasks(tasksPath);
|
|
4140
|
+
}
|
|
4141
|
+
}
|
|
4142
|
+
function resolveCronTaskSelector(tasks, selector) {
|
|
4143
|
+
const normalized = selector.trim();
|
|
4144
|
+
if (!normalized) {
|
|
4145
|
+
throw new Error("Task id or name is required");
|
|
4146
|
+
}
|
|
4147
|
+
const matches = tasks.filter((task) => task.id === normalized || task.name === normalized);
|
|
4148
|
+
if (matches.length === 0) {
|
|
4149
|
+
throw new Error(`Cron task not found: ${normalized}`);
|
|
4150
|
+
}
|
|
4151
|
+
if (matches.length > 1) {
|
|
4152
|
+
throw new Error(`Cron task selector is ambiguous: ${normalized}`);
|
|
4153
|
+
}
|
|
4154
|
+
return matches[0];
|
|
4155
|
+
}
|
|
4156
|
+
async function triggerCronTask(selector, request = requestDesktopControl) {
|
|
4157
|
+
const task = resolveCronTaskSelector(await listCronTasksViaDesktop(request), selector);
|
|
4158
|
+
const triggered = await request("ccem.cron.trigger", { id: task.id });
|
|
4159
|
+
if (!triggered || typeof triggered !== "object" || Array.isArray(triggered) || typeof triggered.id !== "string") {
|
|
4160
|
+
throw new Error("Invalid cron trigger response from CCEM Desktop.");
|
|
4161
|
+
}
|
|
4162
|
+
return triggered;
|
|
4163
|
+
}
|
|
4114
4164
|
async function createCronTaskWithNotifications(input, tasksPath = getCronTasksPath(), request = requestDesktopControl) {
|
|
4115
4165
|
const target = parseHermesNotification(input.hermesNotification);
|
|
4116
4166
|
if (target) {
|
|
@@ -4321,8 +4371,114 @@ function formatCronTaskTableRows(tasks) {
|
|
|
4321
4371
|
]);
|
|
4322
4372
|
}
|
|
4323
4373
|
|
|
4374
|
+
// src/cronCommands.ts
|
|
4375
|
+
function registerCronCommands(program2) {
|
|
4376
|
+
const cronCmd = program2.command("cron").description("Manage CCEM cron tasks");
|
|
4377
|
+
cronCmd.command("list").description("List CCEM cron tasks").option("--json", "Output as JSON").action(async (options) => {
|
|
4378
|
+
try {
|
|
4379
|
+
const tasks = await listCronTasksViaDesktop();
|
|
4380
|
+
if (options.json) {
|
|
4381
|
+
console.log(JSON.stringify(tasks, null, 2));
|
|
4382
|
+
return;
|
|
4383
|
+
}
|
|
4384
|
+
if (tasks.length === 0) {
|
|
4385
|
+
console.log(chalk7.yellow("No cron tasks found."));
|
|
4386
|
+
return;
|
|
4387
|
+
}
|
|
4388
|
+
const table = new Table3({
|
|
4389
|
+
head: ["Name", "Schedule", "Enabled", "Working Dir", "Env", "Timeout"]
|
|
4390
|
+
});
|
|
4391
|
+
table.push(...formatCronTaskTableRows(tasks));
|
|
4392
|
+
console.log(table.toString());
|
|
4393
|
+
} catch (err) {
|
|
4394
|
+
console.error(chalk7.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
4395
|
+
process.exitCode = 1;
|
|
4396
|
+
}
|
|
4397
|
+
});
|
|
4398
|
+
cronCmd.command("notification-targets").description("List paired Hermes recipients for task result notifications (Desktop must be running)").option("--json", "Output as JSON").action(async (options) => {
|
|
4399
|
+
try {
|
|
4400
|
+
const targets = await getCronNotificationTargets();
|
|
4401
|
+
if (options.json) {
|
|
4402
|
+
console.log(JSON.stringify(targets, null, 2));
|
|
4403
|
+
return;
|
|
4404
|
+
}
|
|
4405
|
+
const table = new Table3({ head: ["Bot", "Platform", "Chat", "Route ID", "Generation"] });
|
|
4406
|
+
table.push(...targets.map((target) => [target.label, target.platform, target.chatId, target.routeId, String(target.generation)]));
|
|
4407
|
+
console.log(targets.length ? table.toString() : "No paired Hermes notification targets. Pair a bot in CCEM Remote Control first.");
|
|
4408
|
+
} catch (err) {
|
|
4409
|
+
console.error(chalk7.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
4410
|
+
process.exitCode = 1;
|
|
4411
|
+
}
|
|
4412
|
+
});
|
|
4413
|
+
cronCmd.command("create").description("Create a CCEM cron task").option("--from-json <json>", "Read task input from inline JSON, @file, or - for stdin").option("--name <name>", "Task name").option("--cron-expression <expr>", "5-field cron expression").option("--schedule <expr>", "Alias for --cron-expression").option("--prompt <prompt>", "Prompt to run when the task fires").option("--working-dir <dir>", "Task working directory").option("--env-name <name>", "CCEM environment name").option("--execution-profile <profile>", "conservative, standard, or autonomous").option("--max-budget-usd <amount>", "Optional max budget in USD").option("--allowed-tools <items>", "Comma-separated or JSON array of allowed tools").option("--disallowed-tools <items>", "Comma-separated or JSON array of disallowed tools").option("--timeout-secs <seconds>", "Task timeout in seconds").option("--template-id <id>", "Optional template id").option("--wecom-result", "Send cron result summary to the configured WeCom default target").option("--wecom-bot-id <id>", "WeCom bot id for cron result notifications").option("--wecom-peer-id <id>", "WeCom peer id for cron result notifications").option("--disabled", "Create task disabled").option("--json", "Output as JSON").action(async (options) => {
|
|
4414
|
+
try {
|
|
4415
|
+
const input = options.fromJson ? parseCronCreateJson(options.fromJson) : {
|
|
4416
|
+
name: options.name,
|
|
4417
|
+
cronExpression: options.cronExpression ?? options.schedule,
|
|
4418
|
+
prompt: options.prompt,
|
|
4419
|
+
workingDir: options.workingDir,
|
|
4420
|
+
envName: options.envName,
|
|
4421
|
+
executionProfile: options.executionProfile,
|
|
4422
|
+
maxBudgetUsd: options.maxBudgetUsd === void 0 ? null : Number(options.maxBudgetUsd),
|
|
4423
|
+
allowedTools: parseStringList(options.allowedTools),
|
|
4424
|
+
disallowedTools: parseStringList(options.disallowedTools),
|
|
4425
|
+
enabled: options.disabled ? false : true,
|
|
4426
|
+
timeoutSecs: options.timeoutSecs === void 0 ? null : Number(options.timeoutSecs),
|
|
4427
|
+
templateId: options.templateId,
|
|
4428
|
+
wecomNotification: options.wecomResult || options.wecomBotId || options.wecomPeerId ? {
|
|
4429
|
+
botId: options.wecomBotId ?? null,
|
|
4430
|
+
peerId: options.wecomPeerId ?? null,
|
|
4431
|
+
enabled: true
|
|
4432
|
+
} : null
|
|
4433
|
+
};
|
|
4434
|
+
const task = await createCronTaskWithNotifications(input);
|
|
4435
|
+
if (options.json) {
|
|
4436
|
+
console.log(JSON.stringify(task, null, 2));
|
|
4437
|
+
return;
|
|
4438
|
+
}
|
|
4439
|
+
console.log(chalk7.green("\u2713 Cron task created"));
|
|
4440
|
+
console.log(chalk7.gray(` id: ${task.id}`));
|
|
4441
|
+
console.log(chalk7.gray(` name: ${task.name}`));
|
|
4442
|
+
console.log(chalk7.gray(` cronExpression: ${task.cronExpression}`));
|
|
4443
|
+
console.log(chalk7.gray(` workingDir: ${task.workingDir}`));
|
|
4444
|
+
} catch (err) {
|
|
4445
|
+
console.error(chalk7.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
4446
|
+
process.exitCode = 1;
|
|
4447
|
+
}
|
|
4448
|
+
});
|
|
4449
|
+
cronCmd.command("delete <selector>").description("Delete a cron task by exact id or exact name").option("--json", "Output deleted task as JSON").action((selector, options) => {
|
|
4450
|
+
try {
|
|
4451
|
+
const task = deleteCronTask(selector);
|
|
4452
|
+
if (options.json) {
|
|
4453
|
+
console.log(JSON.stringify(task, null, 2));
|
|
4454
|
+
return;
|
|
4455
|
+
}
|
|
4456
|
+
console.log(chalk7.green(`\u2713 Deleted cron task: ${task.name}`));
|
|
4457
|
+
console.log(chalk7.gray(` id: ${task.id}`));
|
|
4458
|
+
} catch (err) {
|
|
4459
|
+
console.error(chalk7.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
4460
|
+
process.exitCode = 1;
|
|
4461
|
+
}
|
|
4462
|
+
});
|
|
4463
|
+
cronCmd.command("trigger <selector>").description("Trigger a cron task to run immediately in CCEM Desktop (exact id or exact name; Desktop must be running)").option("--json", "Output triggered task as JSON").action(async (selector, options) => {
|
|
4464
|
+
try {
|
|
4465
|
+
const task = await triggerCronTask(selector);
|
|
4466
|
+
if (options.json) {
|
|
4467
|
+
console.log(JSON.stringify(task, null, 2));
|
|
4468
|
+
return;
|
|
4469
|
+
}
|
|
4470
|
+
console.log(chalk7.green(`\u2713 Triggered cron task: ${task.name}`));
|
|
4471
|
+
console.log(chalk7.gray(` id: ${task.id}`));
|
|
4472
|
+
console.log(chalk7.gray(" Runs in the background; run history is in CCEM Desktop \u2192 Cron."));
|
|
4473
|
+
} catch (err) {
|
|
4474
|
+
console.error(chalk7.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
4475
|
+
process.exitCode = 1;
|
|
4476
|
+
}
|
|
4477
|
+
});
|
|
4478
|
+
}
|
|
4479
|
+
|
|
4324
4480
|
// src/dsh/cli.ts
|
|
4325
|
-
import
|
|
4481
|
+
import chalk8 from "chalk";
|
|
4326
4482
|
|
|
4327
4483
|
// src/dsh/provider.ts
|
|
4328
4484
|
import { createHash } from "crypto";
|
|
@@ -5108,9 +5264,9 @@ function buildDshInspectReport(input, meta) {
|
|
|
5108
5264
|
|
|
5109
5265
|
// src/dsh/cli.ts
|
|
5110
5266
|
var STATUS_MARKS = {
|
|
5111
|
-
pass:
|
|
5112
|
-
fail:
|
|
5113
|
-
warn:
|
|
5267
|
+
pass: chalk8.green("\u2713"),
|
|
5268
|
+
fail: chalk8.red("\u2717"),
|
|
5269
|
+
warn: chalk8.yellow("\u26A0")
|
|
5114
5270
|
};
|
|
5115
5271
|
function resolveEnvironment(context, envFlag) {
|
|
5116
5272
|
const envName = envFlag?.trim() || context.getCurrentEnvName();
|
|
@@ -5118,12 +5274,12 @@ function resolveEnvironment(context, envFlag) {
|
|
|
5118
5274
|
}
|
|
5119
5275
|
function failWith(error, exit = (c) => process.exit(c)) {
|
|
5120
5276
|
const message = error instanceof DshProjectionError || error instanceof Error ? error.message : String(error);
|
|
5121
|
-
console.error(
|
|
5277
|
+
console.error(chalk8.red(`\u2717 ${message}`));
|
|
5122
5278
|
exit(1);
|
|
5123
5279
|
}
|
|
5124
5280
|
function formatVersionLine(version, compatible) {
|
|
5125
5281
|
if (version === null) return "not found";
|
|
5126
|
-
const suffix = compatible === false ?
|
|
5282
|
+
const suffix = compatible === false ? chalk8.red(" (incompatible)") : "";
|
|
5127
5283
|
return `${version}${suffix}`;
|
|
5128
5284
|
}
|
|
5129
5285
|
function parseDeriveOptions(options) {
|
|
@@ -5189,7 +5345,7 @@ Note: Use -- to separate task text from options if the task could be
|
|
|
5189
5345
|
cwd: options.cwd
|
|
5190
5346
|
});
|
|
5191
5347
|
if (result.spawnError) {
|
|
5192
|
-
console.error(
|
|
5348
|
+
console.error(chalk8.red(`\u2717 ${result.spawnError}`));
|
|
5193
5349
|
}
|
|
5194
5350
|
doProcessExit(result.exitCode);
|
|
5195
5351
|
} catch (error) {
|
|
@@ -5214,21 +5370,21 @@ Note: Use -- to separate task text from options if the task could be
|
|
|
5214
5370
|
} else {
|
|
5215
5371
|
const env = report.environment;
|
|
5216
5372
|
if (env.error) {
|
|
5217
|
-
console.error(
|
|
5373
|
+
console.error(chalk8.red(`\u2717 ${env.error}`));
|
|
5218
5374
|
} else {
|
|
5219
|
-
console.log(
|
|
5375
|
+
console.log(chalk8.bold(`Environment ${chalk8.cyan(env.name)} \u2192 dsh provider`));
|
|
5220
5376
|
console.log(` endpoint: ${env.baseURL}`);
|
|
5221
5377
|
console.log(` models: ${env.models.join(", ")}`);
|
|
5222
|
-
console.log(` selected model: ${
|
|
5378
|
+
console.log(` selected model: ${chalk8.cyan(env.selectedModel ?? "-")}`);
|
|
5223
5379
|
console.log(` credential: ${env.credentialState} (value redacted)`);
|
|
5224
5380
|
}
|
|
5225
5381
|
console.log(` dsh root: ${report.dsh.root}`);
|
|
5226
5382
|
console.log(` dsh version: ${formatVersionLine(report.dsh.version, report.dsh.versionCompatible)}`);
|
|
5227
5383
|
console.log(` node version: ${formatVersionLine(report.node.version, report.node.versionCompatible)}`);
|
|
5228
5384
|
if (report.patchPreview) {
|
|
5229
|
-
console.log(
|
|
5385
|
+
console.log(chalk8.gray(" --- patch preview (secret-free) ---"));
|
|
5230
5386
|
for (const line of report.patchPreview.trimEnd().split("\n")) {
|
|
5231
|
-
console.log(
|
|
5387
|
+
console.log(chalk8.gray(` ${line}`));
|
|
5232
5388
|
}
|
|
5233
5389
|
}
|
|
5234
5390
|
}
|
|
@@ -5245,9 +5401,9 @@ Note: Use -- to separate task text from options if the task could be
|
|
|
5245
5401
|
console.log(JSON.stringify(report, null, 2));
|
|
5246
5402
|
} else {
|
|
5247
5403
|
for (const check of report.checks) {
|
|
5248
|
-
console.log(`${STATUS_MARKS[check.status]} ${
|
|
5404
|
+
console.log(`${STATUS_MARKS[check.status]} ${chalk8.bold(check.label)}: ${check.detail}`);
|
|
5249
5405
|
if (check.remediation && check.status !== "pass") {
|
|
5250
|
-
console.log(
|
|
5406
|
+
console.log(chalk8.gray(` \u2192 ${check.remediation}`));
|
|
5251
5407
|
}
|
|
5252
5408
|
}
|
|
5253
5409
|
}
|
|
@@ -5540,22 +5696,22 @@ var showCurrentEnv = (usageStats2, usageLoading2) => {
|
|
|
5540
5696
|
var switchEnvironment = async (name) => {
|
|
5541
5697
|
const registries = getRegistries();
|
|
5542
5698
|
if (!registries[name]) {
|
|
5543
|
-
console.error(
|
|
5699
|
+
console.error(chalk9.red(`Environment '${name}' not found.`));
|
|
5544
5700
|
return;
|
|
5545
5701
|
}
|
|
5546
5702
|
config2.set("current", name);
|
|
5547
5703
|
if (process.stdout.isTTY) {
|
|
5548
|
-
console.log(
|
|
5704
|
+
console.log(chalk9.green(`Switched to environment '${name}'`));
|
|
5549
5705
|
} else {
|
|
5550
|
-
console.error(
|
|
5706
|
+
console.error(chalk9.green(`Switched to environment '${name}'`));
|
|
5551
5707
|
}
|
|
5552
5708
|
showCurrentEnv(null, false);
|
|
5553
5709
|
const env = registries[name];
|
|
5554
5710
|
const exportCmds = buildShellEnvCommands(name, env);
|
|
5555
5711
|
if (process.stdout.isTTY) {
|
|
5556
|
-
console.log(
|
|
5557
|
-
console.log(
|
|
5558
|
-
console.log(
|
|
5712
|
+
console.log(chalk9.yellow("\nTo apply to current shell immediately, run:"));
|
|
5713
|
+
console.log(chalk9.cyan("eval $(ccem env)"));
|
|
5714
|
+
console.log(chalk9.yellow("\nOr manually export:"));
|
|
5559
5715
|
exportCmds.forEach((cmd) => console.log(cmd));
|
|
5560
5716
|
} else {
|
|
5561
5717
|
exportCmds.forEach((cmd) => console.log(cmd));
|
|
@@ -5669,14 +5825,14 @@ var appendBotBindRequest = (payload) => {
|
|
|
5669
5825
|
program.command("ls").description("List all configured environments").action(() => {
|
|
5670
5826
|
const registries = getRegistries();
|
|
5671
5827
|
const current = config2.get("current");
|
|
5672
|
-
const table = new
|
|
5828
|
+
const table = new Table4({
|
|
5673
5829
|
head: ["Name", "Base URL", "Opus"],
|
|
5674
5830
|
style: { head: ["cyan"] }
|
|
5675
5831
|
});
|
|
5676
5832
|
Object.keys(registries).forEach((name) => {
|
|
5677
5833
|
const reg = registries[name];
|
|
5678
5834
|
const displayReg = resolveEnvConfigForRuntime(name, reg);
|
|
5679
|
-
const prefix = name === current ?
|
|
5835
|
+
const prefix = name === current ? chalk9.green("* ") : " ";
|
|
5680
5836
|
table.push([
|
|
5681
5837
|
prefix + name,
|
|
5682
5838
|
displayReg.ANTHROPIC_BASE_URL || "-",
|
|
@@ -5691,10 +5847,10 @@ program.command("use <name>").description("Switch to a specific environment").ac
|
|
|
5691
5847
|
program.command("sessions").description("List tmux-backed interactive sessions").action(() => {
|
|
5692
5848
|
const sessions = readInteractiveAttachSessions();
|
|
5693
5849
|
if (sessions.length === 0) {
|
|
5694
|
-
console.log(
|
|
5850
|
+
console.log(chalk9.yellow("No tmux-backed interactive sessions found."));
|
|
5695
5851
|
return;
|
|
5696
5852
|
}
|
|
5697
|
-
const table = new
|
|
5853
|
+
const table = new Table4({
|
|
5698
5854
|
head: ["ID", "Project", "Env", "Status", "Tmux"],
|
|
5699
5855
|
style: { head: ["cyan"] }
|
|
5700
5856
|
});
|
|
@@ -5712,39 +5868,39 @@ program.command("sessions").description("List tmux-backed interactive sessions")
|
|
|
5712
5868
|
program.command("attach [id]").description("Attach to a tmux-backed interactive session").action(async (id) => {
|
|
5713
5869
|
const session = findAttachSession(id);
|
|
5714
5870
|
if (!session) {
|
|
5715
|
-
console.error(
|
|
5871
|
+
console.error(chalk9.red(id ? `Interactive session '${id}' not found.` : "No interactive session available to attach."));
|
|
5716
5872
|
process.exit(1);
|
|
5717
5873
|
}
|
|
5718
5874
|
try {
|
|
5719
5875
|
await attachTmuxTarget(session.tmuxTarget);
|
|
5720
5876
|
} catch (error) {
|
|
5721
|
-
console.error(
|
|
5877
|
+
console.error(chalk9.red(`Failed to attach ${session.tmuxTarget}: ${String(error)}`));
|
|
5722
5878
|
process.exit(1);
|
|
5723
5879
|
}
|
|
5724
5880
|
});
|
|
5725
5881
|
program.command("bot-bind").description("Request binding the current ccem session to a chat bot target").requiredOption("--platform <platform>", "target platform: telegram, weixin, or wecom").option("--peer-id <peerId>", "target user/chat id").option("--peer <peerId>", "alias for --peer-id").option("--runtime-id <runtimeId>", "ccem runtime id; defaults to CCEM_RUNTIME_ID").option("--bot-id <botId>", "WeCom bot id or platform bot id").option("--thread-id <threadId>", "thread/topic id for platforms that support it").option("--title <title>", "task card title").option("--summary <summary>", "task card summary").option("--no-send-card", "bind without sending the initial task card").option("--json", "print the queued request as JSON").action((options) => {
|
|
5726
5882
|
const platform = normalizeBotBindPlatform(options.platform);
|
|
5727
5883
|
if (!platform) {
|
|
5728
|
-
console.error(
|
|
5884
|
+
console.error(chalk9.red("\u2717 --platform must be telegram, weixin, or wecom"));
|
|
5729
5885
|
process.exitCode = 1;
|
|
5730
5886
|
return;
|
|
5731
5887
|
}
|
|
5732
5888
|
const peerId = (options.peerId ?? options.peer ?? "").trim();
|
|
5733
5889
|
if (!peerId) {
|
|
5734
|
-
console.error(
|
|
5890
|
+
console.error(chalk9.red("\u2717 --peer-id is required"));
|
|
5735
5891
|
process.exitCode = 1;
|
|
5736
5892
|
return;
|
|
5737
5893
|
}
|
|
5738
5894
|
const runtimeId = resolveBotBindRuntimeId(options.runtimeId);
|
|
5739
5895
|
if (!runtimeId) {
|
|
5740
|
-
console.error(
|
|
5741
|
-
console.error(
|
|
5896
|
+
console.error(chalk9.red("\u2717 Unable to resolve ccem runtime id"));
|
|
5897
|
+
console.error(chalk9.gray(" Run from a ccem-launched session or pass --runtime-id explicitly."));
|
|
5742
5898
|
process.exitCode = 1;
|
|
5743
5899
|
return;
|
|
5744
5900
|
}
|
|
5745
5901
|
const botId = options.botId?.trim() || void 0;
|
|
5746
5902
|
if (platform === "wecom" && !botId) {
|
|
5747
|
-
console.error(
|
|
5903
|
+
console.error(chalk9.red("\u2717 --bot-id is required for WeCom bot bindings"));
|
|
5748
5904
|
process.exitCode = 1;
|
|
5749
5905
|
return;
|
|
5750
5906
|
}
|
|
@@ -5765,18 +5921,18 @@ program.command("bot-bind").description("Request binding the current ccem sessio
|
|
|
5765
5921
|
console.log(JSON.stringify({ requestPath, payload }, null, 2));
|
|
5766
5922
|
return;
|
|
5767
5923
|
}
|
|
5768
|
-
console.log(
|
|
5769
|
-
console.log(
|
|
5770
|
-
console.log(
|
|
5771
|
-
console.log(
|
|
5772
|
-
console.log(
|
|
5924
|
+
console.log(chalk9.green("\u2713 \u5DF2\u63D0\u4EA4 bot \u7ED1\u5B9A\u8BF7\u6C42"));
|
|
5925
|
+
console.log(chalk9.gray(` runtime: ${runtimeId}`));
|
|
5926
|
+
console.log(chalk9.gray(` target: ${platform}/${peerId}`));
|
|
5927
|
+
console.log(chalk9.gray(` queue: ${requestPath}`));
|
|
5928
|
+
console.log(chalk9.cyan(
|
|
5773
5929
|
options.sendCard === false ? " \u5982\u679C CCEM Desktop \u6B63\u5728\u8FD0\u884C\uFF0C\u4F1A\u81EA\u52A8\u6D88\u8D39\u8BE5\u8BF7\u6C42\u5E76\u5EFA\u7ACB\u7ED1\u5B9A\u3002" : " \u5982\u679C CCEM Desktop \u6B63\u5728\u8FD0\u884C\uFF0C\u4F1A\u81EA\u52A8\u6D88\u8D39\u8BE5\u8BF7\u6C42\u5E76\u53D1\u9001\u4EFB\u52A1\u5361\u7247\u5230\u7ED1\u5B9A\u76EE\u6807\u3002"
|
|
5774
5930
|
));
|
|
5775
5931
|
});
|
|
5776
5932
|
program.command("add <name>").description("Add a new environment configuration").action(async (name) => {
|
|
5777
5933
|
const registries = getRegistries();
|
|
5778
5934
|
if (registries[name]) {
|
|
5779
|
-
console.log(
|
|
5935
|
+
console.log(chalk9.red(`Environment '${name}' already exists.`));
|
|
5780
5936
|
return;
|
|
5781
5937
|
}
|
|
5782
5938
|
const { usePreset } = await inquirer.prompt([
|
|
@@ -5802,7 +5958,7 @@ program.command("add <name>").description("Add a new environment configuration")
|
|
|
5802
5958
|
const answers = await promptForEnvironmentConfig(presetConfig);
|
|
5803
5959
|
registries[name] = applyPromptAnswers(normalizeEnvConfig(presetConfig), answers, false);
|
|
5804
5960
|
setRegistries(registries);
|
|
5805
|
-
console.log(
|
|
5961
|
+
console.log(chalk9.green(`Environment '${name}' added successfully.`));
|
|
5806
5962
|
});
|
|
5807
5963
|
program.command("del <name>").description("Delete an environment configuration").action(async (name) => {
|
|
5808
5964
|
const wasCurrent = config2.get("current") === name;
|
|
@@ -5815,13 +5971,13 @@ program.command("del <name>").description("Delete an environment configuration")
|
|
|
5815
5971
|
setEnvironmentMutationConfig(outcome.config);
|
|
5816
5972
|
}
|
|
5817
5973
|
if (wasCurrent) {
|
|
5818
|
-
console.log(
|
|
5974
|
+
console.log(chalk9.yellow(`Deleted current environment. Switched back to 'official'.`));
|
|
5819
5975
|
}
|
|
5820
5976
|
} catch (error) {
|
|
5821
|
-
console.log(
|
|
5977
|
+
console.log(chalk9.red(error instanceof Error ? error.message : String(error)));
|
|
5822
5978
|
return;
|
|
5823
5979
|
}
|
|
5824
|
-
console.log(
|
|
5980
|
+
console.log(chalk9.green(`Environment '${name}' deleted.`));
|
|
5825
5981
|
});
|
|
5826
5982
|
program.command("rename <old> <new>").description("Rename an environment configuration").action(async (oldName, newName) => {
|
|
5827
5983
|
try {
|
|
@@ -5834,24 +5990,24 @@ program.command("rename <old> <new>").description("Rename an environment configu
|
|
|
5834
5990
|
setEnvironmentMutationConfig(outcome.config);
|
|
5835
5991
|
}
|
|
5836
5992
|
} catch (error) {
|
|
5837
|
-
console.log(
|
|
5993
|
+
console.log(chalk9.red(error instanceof Error ? error.message : String(error)));
|
|
5838
5994
|
return;
|
|
5839
5995
|
}
|
|
5840
|
-
console.log(
|
|
5996
|
+
console.log(chalk9.green(`Environment '${oldName}' renamed to '${newName}'.`));
|
|
5841
5997
|
});
|
|
5842
5998
|
program.command("cp <source> <target>").description("Copy an environment configuration").action(async (source, target) => {
|
|
5843
5999
|
const registries = getRegistries();
|
|
5844
6000
|
if (!registries[source]) {
|
|
5845
|
-
console.log(
|
|
6001
|
+
console.log(chalk9.red(`Environment '${source}' not found.`));
|
|
5846
6002
|
return;
|
|
5847
6003
|
}
|
|
5848
6004
|
if (registries[target]) {
|
|
5849
|
-
console.log(
|
|
6005
|
+
console.log(chalk9.red(`Environment '${target}' already exists.`));
|
|
5850
6006
|
return;
|
|
5851
6007
|
}
|
|
5852
6008
|
registries[target] = { ...registries[source] };
|
|
5853
6009
|
setRegistries(registries);
|
|
5854
|
-
console.log(
|
|
6010
|
+
console.log(chalk9.green(`Environment '${source}' copied to '${target}'.`));
|
|
5855
6011
|
const { modify } = await inquirer.prompt([
|
|
5856
6012
|
{
|
|
5857
6013
|
type: "confirm",
|
|
@@ -5865,12 +6021,12 @@ program.command("cp <source> <target>").description("Copy an environment configu
|
|
|
5865
6021
|
const answers = await promptForEnvironmentConfig(current, true);
|
|
5866
6022
|
registries[target] = applyPromptAnswers(current, answers, true);
|
|
5867
6023
|
setRegistries(registries);
|
|
5868
|
-
console.log(
|
|
6024
|
+
console.log(chalk9.green(`Environment '${target}' updated.`));
|
|
5869
6025
|
}
|
|
5870
6026
|
});
|
|
5871
6027
|
program.command("current").description("Show current environment name").action(() => {
|
|
5872
6028
|
const current = config2.get("current");
|
|
5873
|
-
console.log(
|
|
6029
|
+
console.log(chalk9.green(current));
|
|
5874
6030
|
});
|
|
5875
6031
|
program.command("env").description("Output environment variables for shell eval").option("--json", "Output as JSON").action((options) => {
|
|
5876
6032
|
const registries = getRegistries();
|
|
@@ -5889,7 +6045,7 @@ program.command("run <command...>").description("Run a command with the current
|
|
|
5889
6045
|
const current = config2.get("current");
|
|
5890
6046
|
const envConfig = registries[current];
|
|
5891
6047
|
if (!envConfig) {
|
|
5892
|
-
console.error(
|
|
6048
|
+
console.error(chalk9.red("No environment configuration found."));
|
|
5893
6049
|
process.exit(1);
|
|
5894
6050
|
}
|
|
5895
6051
|
const env = { ...process.env };
|
|
@@ -5905,93 +6061,7 @@ program.command("run <command...>").description("Run a command with the current
|
|
|
5905
6061
|
process.exit(code ?? 0);
|
|
5906
6062
|
});
|
|
5907
6063
|
});
|
|
5908
|
-
|
|
5909
|
-
cronCmd.command("list").description("List CCEM cron tasks").option("--json", "Output as JSON").action((options) => {
|
|
5910
|
-
try {
|
|
5911
|
-
const tasks = readCronTasks();
|
|
5912
|
-
if (options.json) {
|
|
5913
|
-
console.log(JSON.stringify(tasks, null, 2));
|
|
5914
|
-
return;
|
|
5915
|
-
}
|
|
5916
|
-
if (tasks.length === 0) {
|
|
5917
|
-
console.log(chalk8.yellow("No cron tasks found."));
|
|
5918
|
-
return;
|
|
5919
|
-
}
|
|
5920
|
-
const table = new Table3({
|
|
5921
|
-
head: ["Name", "Schedule", "Enabled", "Working Dir", "Env", "Timeout"]
|
|
5922
|
-
});
|
|
5923
|
-
table.push(...formatCronTaskTableRows(tasks));
|
|
5924
|
-
console.log(table.toString());
|
|
5925
|
-
} catch (err) {
|
|
5926
|
-
console.error(chalk8.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
5927
|
-
process.exitCode = 1;
|
|
5928
|
-
}
|
|
5929
|
-
});
|
|
5930
|
-
cronCmd.command("notification-targets").description("List paired Hermes recipients for task result notifications (Desktop must be running)").option("--json", "Output as JSON").action(async (options) => {
|
|
5931
|
-
try {
|
|
5932
|
-
const targets = await getCronNotificationTargets();
|
|
5933
|
-
if (options.json) {
|
|
5934
|
-
console.log(JSON.stringify(targets, null, 2));
|
|
5935
|
-
return;
|
|
5936
|
-
}
|
|
5937
|
-
const table = new Table3({ head: ["Bot", "Platform", "Chat", "Route ID", "Generation"] });
|
|
5938
|
-
table.push(...targets.map((target) => [target.label, target.platform, target.chatId, target.routeId, String(target.generation)]));
|
|
5939
|
-
console.log(targets.length ? table.toString() : "No paired Hermes notification targets. Pair a bot in CCEM Remote Control first.");
|
|
5940
|
-
} catch (err) {
|
|
5941
|
-
console.error(chalk8.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
5942
|
-
process.exitCode = 1;
|
|
5943
|
-
}
|
|
5944
|
-
});
|
|
5945
|
-
cronCmd.command("create").description("Create a CCEM cron task").option("--from-json <json>", "Read task input from inline JSON, @file, or - for stdin").option("--name <name>", "Task name").option("--cron-expression <expr>", "5-field cron expression").option("--schedule <expr>", "Alias for --cron-expression").option("--prompt <prompt>", "Prompt to run when the task fires").option("--working-dir <dir>", "Task working directory").option("--env-name <name>", "CCEM environment name").option("--execution-profile <profile>", "conservative, standard, or autonomous").option("--max-budget-usd <amount>", "Optional max budget in USD").option("--allowed-tools <items>", "Comma-separated or JSON array of allowed tools").option("--disallowed-tools <items>", "Comma-separated or JSON array of disallowed tools").option("--timeout-secs <seconds>", "Task timeout in seconds").option("--template-id <id>", "Optional template id").option("--wecom-result", "Send cron result summary to the configured WeCom default target").option("--wecom-bot-id <id>", "WeCom bot id for cron result notifications").option("--wecom-peer-id <id>", "WeCom peer id for cron result notifications").option("--disabled", "Create task disabled").option("--json", "Output as JSON").action(async (options) => {
|
|
5946
|
-
try {
|
|
5947
|
-
const input = options.fromJson ? parseCronCreateJson(options.fromJson) : {
|
|
5948
|
-
name: options.name,
|
|
5949
|
-
cronExpression: options.cronExpression ?? options.schedule,
|
|
5950
|
-
prompt: options.prompt,
|
|
5951
|
-
workingDir: options.workingDir,
|
|
5952
|
-
envName: options.envName,
|
|
5953
|
-
executionProfile: options.executionProfile,
|
|
5954
|
-
maxBudgetUsd: options.maxBudgetUsd === void 0 ? null : Number(options.maxBudgetUsd),
|
|
5955
|
-
allowedTools: parseStringList(options.allowedTools),
|
|
5956
|
-
disallowedTools: parseStringList(options.disallowedTools),
|
|
5957
|
-
enabled: options.disabled ? false : true,
|
|
5958
|
-
timeoutSecs: options.timeoutSecs === void 0 ? null : Number(options.timeoutSecs),
|
|
5959
|
-
templateId: options.templateId,
|
|
5960
|
-
wecomNotification: options.wecomResult || options.wecomBotId || options.wecomPeerId ? {
|
|
5961
|
-
botId: options.wecomBotId ?? null,
|
|
5962
|
-
peerId: options.wecomPeerId ?? null,
|
|
5963
|
-
enabled: true
|
|
5964
|
-
} : null
|
|
5965
|
-
};
|
|
5966
|
-
const task = await createCronTaskWithNotifications(input);
|
|
5967
|
-
if (options.json) {
|
|
5968
|
-
console.log(JSON.stringify(task, null, 2));
|
|
5969
|
-
return;
|
|
5970
|
-
}
|
|
5971
|
-
console.log(chalk8.green("\u2713 Cron task created"));
|
|
5972
|
-
console.log(chalk8.gray(` id: ${task.id}`));
|
|
5973
|
-
console.log(chalk8.gray(` name: ${task.name}`));
|
|
5974
|
-
console.log(chalk8.gray(` cronExpression: ${task.cronExpression}`));
|
|
5975
|
-
console.log(chalk8.gray(` workingDir: ${task.workingDir}`));
|
|
5976
|
-
} catch (err) {
|
|
5977
|
-
console.error(chalk8.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
5978
|
-
process.exitCode = 1;
|
|
5979
|
-
}
|
|
5980
|
-
});
|
|
5981
|
-
cronCmd.command("delete <selector>").description("Delete a cron task by exact id or exact name").option("--json", "Output deleted task as JSON").action((selector, options) => {
|
|
5982
|
-
try {
|
|
5983
|
-
const task = deleteCronTask(selector);
|
|
5984
|
-
if (options.json) {
|
|
5985
|
-
console.log(JSON.stringify(task, null, 2));
|
|
5986
|
-
return;
|
|
5987
|
-
}
|
|
5988
|
-
console.log(chalk8.green(`\u2713 Deleted cron task: ${task.name}`));
|
|
5989
|
-
console.log(chalk8.gray(` id: ${task.id}`));
|
|
5990
|
-
} catch (err) {
|
|
5991
|
-
console.error(chalk8.red(`\u2717 ${err instanceof Error ? err.message : String(err)}`));
|
|
5992
|
-
process.exitCode = 1;
|
|
5993
|
-
}
|
|
5994
|
-
});
|
|
6064
|
+
registerCronCommands(program);
|
|
5995
6065
|
var setupCmd = program.command("setup").description("Setup commands for permanent configurations");
|
|
5996
6066
|
setupCmd.command("perms").description("\u6C38\u4E45\u914D\u7F6E\u6743\u9650\u6A21\u5F0F").option("--yolo", "\u5E94\u7528 YOLO \u6A21\u5F0F\uFF08\u5168\u90E8\u653E\u5F00\uFF09").option("--dev", "\u5E94\u7528\u5F00\u53D1\u6A21\u5F0F").option("--readonly", "\u5E94\u7528\u53EA\u8BFB\u6A21\u5F0F").option("--safe", "\u5E94\u7528\u5B89\u5168\u6A21\u5F0F").option("--ci", "\u5E94\u7528 CI/CD \u6A21\u5F0F").option("--audit", "\u5E94\u7528\u5BA1\u8BA1\u6A21\u5F0F").option("--reset", "\u91CD\u7F6E\u6743\u9650\u914D\u7F6E").action(function() {
|
|
5997
6067
|
const options = this.opts();
|
|
@@ -6005,34 +6075,34 @@ setupCmd.command("perms").description("\u6C38\u4E45\u914D\u7F6E\u6743\u9650\u6A2
|
|
|
6005
6075
|
return;
|
|
6006
6076
|
}
|
|
6007
6077
|
}
|
|
6008
|
-
console.log(
|
|
6009
|
-
console.log(
|
|
6010
|
-
console.log(
|
|
6078
|
+
console.log(chalk9.yellow("\u8BF7\u6307\u5B9A\u4E00\u4E2A\u6743\u9650\u6A21\u5F0F\uFF0C\u4F8B\u5982: ccem setup perms --dev"));
|
|
6079
|
+
console.log(chalk9.gray("\u53EF\u7528\u6A21\u5F0F: " + PERMISSION_MODES.join(", ")));
|
|
6080
|
+
console.log(chalk9.gray("\u91CD\u7F6E\u6743\u9650: ccem setup perms --reset"));
|
|
6011
6081
|
});
|
|
6012
6082
|
setupCmd.command("default-mode").description("\u8BBE\u7F6E\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F").option("--yolo", "YOLO \u6A21\u5F0F").option("--dev", "\u5F00\u53D1\u6A21\u5F0F").option("--readonly", "\u53EA\u8BFB\u6A21\u5F0F").option("--safe", "\u5B89\u5168\u6A21\u5F0F").option("--ci", "CI/CD \u6A21\u5F0F").option("--audit", "\u5BA1\u8BA1\u6A21\u5F0F").option("--reset", "\u6E05\u9664\u9ED8\u8BA4\u6A21\u5F0F").action(function() {
|
|
6013
6083
|
const options = this.opts();
|
|
6014
6084
|
if (options.reset) {
|
|
6015
6085
|
config2.set("defaultMode", null);
|
|
6016
|
-
console.log(
|
|
6086
|
+
console.log(chalk9.green("\u5DF2\u6E05\u9664\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F"));
|
|
6017
6087
|
return;
|
|
6018
6088
|
}
|
|
6019
6089
|
for (const mode of PERMISSION_MODES) {
|
|
6020
6090
|
if (options[mode]) {
|
|
6021
6091
|
config2.set("defaultMode", mode);
|
|
6022
|
-
console.log(
|
|
6023
|
-
console.log(
|
|
6092
|
+
console.log(chalk9.green(`\u5DF2\u8BBE\u7F6E\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F: ${PERMISSION_PRESETS[mode].name}`));
|
|
6093
|
+
console.log(chalk9.gray(`\u4E0B\u6B21\u542F\u52A8 ccem \u65F6\u5C06\u9ED8\u8BA4\u4F7F\u7528\u6B64\u6A21\u5F0F`));
|
|
6024
6094
|
return;
|
|
6025
6095
|
}
|
|
6026
6096
|
}
|
|
6027
6097
|
const currentDefault = config2.get("defaultMode");
|
|
6028
6098
|
if (currentDefault && PERMISSION_PRESETS[currentDefault]) {
|
|
6029
|
-
console.log(
|
|
6099
|
+
console.log(chalk9.green(`\u5F53\u524D\u9ED8\u8BA4\u6A21\u5F0F: ${PERMISSION_PRESETS[currentDefault].name}`));
|
|
6030
6100
|
} else {
|
|
6031
|
-
console.log(
|
|
6101
|
+
console.log(chalk9.yellow("\u672A\u8BBE\u7F6E\u9ED8\u8BA4\u6743\u9650\u6A21\u5F0F"));
|
|
6032
6102
|
}
|
|
6033
|
-
console.log(
|
|
6034
|
-
console.log(
|
|
6035
|
-
console.log(
|
|
6103
|
+
console.log(chalk9.gray("\n\u8BBE\u7F6E\u9ED8\u8BA4\u6A21\u5F0F: ccem setup default-mode --dev"));
|
|
6104
|
+
console.log(chalk9.gray("\u6E05\u9664\u9ED8\u8BA4\u6A21\u5F0F: ccem setup default-mode --reset"));
|
|
6105
|
+
console.log(chalk9.gray("\u53EF\u7528\u6A21\u5F0F: " + PERMISSION_MODES.join(", ")));
|
|
6036
6106
|
});
|
|
6037
6107
|
setupCmd.command("init").description("\u521D\u59CB\u5316 Claude Code \u5168\u5C40\u914D\u7F6E\uFF08\u8DF3\u8FC7 onboarding\u3001\u7981\u7528\u9065\u6D4B\uFF09").option("--chrome", "\u540C\u65F6\u5B89\u88C5 chrome-devtools MCP \u5DE5\u5177").action(async function() {
|
|
6038
6108
|
const options = this.opts();
|
|
@@ -6042,16 +6112,16 @@ setupCmd.command("migrate").description("\u8FC1\u79FB\u65E7\u7248\u914D\u7F6E\u5
|
|
|
6042
6112
|
const options = this.opts();
|
|
6043
6113
|
const newConfigPath = getCcemConfigPath();
|
|
6044
6114
|
const legacyConfigPath = getLegacyConfigPath();
|
|
6045
|
-
console.log(
|
|
6115
|
+
console.log(chalk9.cyan("\n\u{1F504} \u914D\u7F6E\u8FC1\u79FB\n"));
|
|
6046
6116
|
if (!fs14.existsSync(legacyConfigPath)) {
|
|
6047
|
-
console.log(
|
|
6048
|
-
console.log(
|
|
6117
|
+
console.log(chalk9.yellow("\u672A\u627E\u5230\u65E7\u7248\u914D\u7F6E\u6587\u4EF6"));
|
|
6118
|
+
console.log(chalk9.gray(` \u65E7\u8DEF\u5F84: ${legacyConfigPath}`));
|
|
6049
6119
|
return;
|
|
6050
6120
|
}
|
|
6051
6121
|
if (fs14.existsSync(newConfigPath) && !options.force) {
|
|
6052
|
-
console.log(
|
|
6053
|
-
console.log(
|
|
6054
|
-
console.log(
|
|
6122
|
+
console.log(chalk9.green("\u2713 \u914D\u7F6E\u5DF2\u5728\u65B0\u8DEF\u5F84"));
|
|
6123
|
+
console.log(chalk9.gray(` \u8DEF\u5F84: ${newConfigPath}`));
|
|
6124
|
+
console.log(chalk9.gray("\n\u4F7F\u7528 --force \u5F3A\u5236\u91CD\u65B0\u8FC1\u79FB"));
|
|
6055
6125
|
return;
|
|
6056
6126
|
}
|
|
6057
6127
|
try {
|
|
@@ -6063,9 +6133,9 @@ setupCmd.command("migrate").description("\u8FC1\u79FB\u65E7\u7248\u914D\u7F6E\u5
|
|
|
6063
6133
|
}
|
|
6064
6134
|
assertOfficialEnvironmentInvariant(migrated.registries);
|
|
6065
6135
|
setEnvironmentMutationConfig(migrated);
|
|
6066
|
-
console.log(
|
|
6067
|
-
console.log(
|
|
6068
|
-
console.log(
|
|
6136
|
+
console.log(chalk9.green("\u2713 \u914D\u7F6E\u5DF2\u8FC1\u79FB"));
|
|
6137
|
+
console.log(chalk9.gray(` \u4ECE: ${legacyConfigPath}`));
|
|
6138
|
+
console.log(chalk9.gray(` \u5230: ${newConfigPath}`));
|
|
6069
6139
|
if (options.clean) {
|
|
6070
6140
|
fs14.unlinkSync(legacyConfigPath);
|
|
6071
6141
|
const legacyDir = path12.dirname(legacyConfigPath);
|
|
@@ -6073,10 +6143,10 @@ setupCmd.command("migrate").description("\u8FC1\u79FB\u65E7\u7248\u914D\u7F6E\u5
|
|
|
6073
6143
|
fs14.rmdirSync(legacyDir);
|
|
6074
6144
|
} catch {
|
|
6075
6145
|
}
|
|
6076
|
-
console.log(
|
|
6146
|
+
console.log(chalk9.green("\u2713 \u5DF2\u5220\u9664\u65E7\u914D\u7F6E\u6587\u4EF6"));
|
|
6077
6147
|
}
|
|
6078
6148
|
} catch (err) {
|
|
6079
|
-
console.error(
|
|
6149
|
+
console.error(chalk9.red(`\u2717 \u8FC1\u79FB\u5931\u8D25: ${err}`));
|
|
6080
6150
|
}
|
|
6081
6151
|
});
|
|
6082
6152
|
setupCmd.command("cron").description("\u5B89\u88C5 ccem-cron skill \u5230 Claude Code\uFF08~/.claude/skills/\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u6587\u4EF6").action(async function() {
|
|
@@ -6085,7 +6155,7 @@ setupCmd.command("cron").description("\u5B89\u88C5 ccem-cron skill \u5230 Claude
|
|
|
6085
6155
|
const targetPath = path12.join(skillDir, "ccem-cron.md");
|
|
6086
6156
|
if (!fs14.existsSync(skillDir)) {
|
|
6087
6157
|
fs14.mkdirSync(skillDir, { recursive: true });
|
|
6088
|
-
console.log(
|
|
6158
|
+
console.log(chalk9.gray(`\u521B\u5EFA\u76EE\u5F55: ${skillDir}`));
|
|
6089
6159
|
}
|
|
6090
6160
|
if (fs14.existsSync(targetPath) && !options.force) {
|
|
6091
6161
|
const { overwrite } = await inquirer.prompt([
|
|
@@ -6097,14 +6167,14 @@ setupCmd.command("cron").description("\u5B89\u88C5 ccem-cron skill \u5230 Claude
|
|
|
6097
6167
|
}
|
|
6098
6168
|
]);
|
|
6099
6169
|
if (!overwrite) {
|
|
6100
|
-
console.log(
|
|
6170
|
+
console.log(chalk9.yellow("\u5DF2\u53D6\u6D88"));
|
|
6101
6171
|
return;
|
|
6102
6172
|
}
|
|
6103
6173
|
}
|
|
6104
6174
|
fs14.writeFileSync(targetPath, CCEM_CRON_SKILL_CONTENT, "utf-8");
|
|
6105
|
-
console.log(
|
|
6106
|
-
console.log(
|
|
6107
|
-
console.log(
|
|
6175
|
+
console.log(chalk9.green(`\u2713 \u5DF2\u5B89\u88C5 ccem-cron skill`));
|
|
6176
|
+
console.log(chalk9.gray(` \u8DEF\u5F84: ${targetPath}`));
|
|
6177
|
+
console.log(chalk9.cyan(`
|
|
6108
6178
|
\u5728 Claude Code \u4E2D\u4F7F\u7528 /ccem-cron \u5373\u53EF\u8C03\u7528\u6B64 skill`));
|
|
6109
6179
|
});
|
|
6110
6180
|
setupCmd.command("bot-bind").description("\u5B89\u88C5 ccem-bot-bind skill \u5230 Claude Code\uFF08~/.claude/skills/\uFF09").option("--force", "\u5F3A\u5236\u8986\u76D6\u5DF2\u6709\u6587\u4EF6").action(async function() {
|
|
@@ -6113,7 +6183,7 @@ setupCmd.command("bot-bind").description("\u5B89\u88C5 ccem-bot-bind skill \u523
|
|
|
6113
6183
|
const targetPath = path12.join(skillDir, "ccem-bot-bind.md");
|
|
6114
6184
|
if (!fs14.existsSync(skillDir)) {
|
|
6115
6185
|
fs14.mkdirSync(skillDir, { recursive: true });
|
|
6116
|
-
console.log(
|
|
6186
|
+
console.log(chalk9.gray(`\u521B\u5EFA\u76EE\u5F55: ${skillDir}`));
|
|
6117
6187
|
}
|
|
6118
6188
|
if (fs14.existsSync(targetPath) && !options.force) {
|
|
6119
6189
|
const { overwrite } = await inquirer.prompt([
|
|
@@ -6125,14 +6195,14 @@ setupCmd.command("bot-bind").description("\u5B89\u88C5 ccem-bot-bind skill \u523
|
|
|
6125
6195
|
}
|
|
6126
6196
|
]);
|
|
6127
6197
|
if (!overwrite) {
|
|
6128
|
-
console.log(
|
|
6198
|
+
console.log(chalk9.yellow("\u5DF2\u53D6\u6D88"));
|
|
6129
6199
|
return;
|
|
6130
6200
|
}
|
|
6131
6201
|
}
|
|
6132
6202
|
fs14.writeFileSync(targetPath, CCEM_BOT_BIND_SKILL_CONTENT, "utf-8");
|
|
6133
|
-
console.log(
|
|
6134
|
-
console.log(
|
|
6135
|
-
console.log(
|
|
6203
|
+
console.log(chalk9.green(`\u2713 \u5DF2\u5B89\u88C5 ccem-bot-bind skill`));
|
|
6204
|
+
console.log(chalk9.gray(` \u8DEF\u5F84: ${targetPath}`));
|
|
6205
|
+
console.log(chalk9.cyan(`
|
|
6136
6206
|
\u5728 Claude Code \u4E2D\u8BA9\u5B83\u4F7F\u7528 ccem-bot-bind skill \u5373\u53EF\u7ED1\u5B9A\u5F53\u524D\u4F1A\u8BDD\u5230 bot`));
|
|
6137
6207
|
});
|
|
6138
6208
|
var skillCmd = program.command("skill").description("\u7BA1\u7406 Claude Code skills");
|
|
@@ -6142,7 +6212,7 @@ skillCmd.command("add [url]").description("\u6DFB\u52A0 skill\uFF08\u4ECE\u5B98\
|
|
|
6142
6212
|
} else {
|
|
6143
6213
|
const result = await runSkillSelector();
|
|
6144
6214
|
if (result.type === "cancelled") {
|
|
6145
|
-
console.log(
|
|
6215
|
+
console.log(chalk9.yellow("\u5DF2\u53D6\u6D88"));
|
|
6146
6216
|
return;
|
|
6147
6217
|
}
|
|
6148
6218
|
if (result.type === "custom") {
|
|
@@ -6169,16 +6239,16 @@ skillCmd.command("add [url]").description("\u6DFB\u52A0 skill\uFF08\u4ECE\u5B98\
|
|
|
6169
6239
|
skillCmd.command("ls").description("\u5217\u51FA\u5DF2\u5B89\u88C5\u7684 skills").action(() => {
|
|
6170
6240
|
const skills = listInstalledSkills();
|
|
6171
6241
|
if (skills.length === 0) {
|
|
6172
|
-
console.log(
|
|
6173
|
-
console.log(
|
|
6242
|
+
console.log(chalk9.yellow("\u5F53\u524D\u76EE\u5F55\u6CA1\u6709\u5B89\u88C5\u4EFB\u4F55 skill"));
|
|
6243
|
+
console.log(chalk9.gray("\u4F7F\u7528 ccem skill add \u6DFB\u52A0 skills"));
|
|
6174
6244
|
return;
|
|
6175
6245
|
}
|
|
6176
|
-
const table = new
|
|
6246
|
+
const table = new Table4({
|
|
6177
6247
|
head: ["Name", "Path"],
|
|
6178
6248
|
style: { head: ["cyan"] }
|
|
6179
6249
|
});
|
|
6180
6250
|
skills.forEach((skill) => {
|
|
6181
|
-
table.push([
|
|
6251
|
+
table.push([chalk9.green(skill.name), chalk9.gray(skill.path)]);
|
|
6182
6252
|
});
|
|
6183
6253
|
console.log(table.toString());
|
|
6184
6254
|
});
|
|
@@ -6191,7 +6261,7 @@ program.command("load <url>").description("\u4ECE\u8FDC\u7A0B\u670D\u52A1\u5668\
|
|
|
6191
6261
|
const stdinInput = options.credentialsStdin ? await readAllStdin() : "";
|
|
6192
6262
|
credentials = resolveLoadCredentials(options, stdinInput);
|
|
6193
6263
|
} catch (err) {
|
|
6194
|
-
console.error(
|
|
6264
|
+
console.error(chalk9.red(`Error: ${err.message}`));
|
|
6195
6265
|
process.exit(1);
|
|
6196
6266
|
}
|
|
6197
6267
|
const results = await loadFromRemote(url, credentials.key, credentials.secret);
|
|
@@ -6213,12 +6283,12 @@ program.command("launch").description(false).option("--env <name>", "\u73AF\u588
|
|
|
6213
6283
|
const registries = getRegistries();
|
|
6214
6284
|
const envConfig = registries[envName];
|
|
6215
6285
|
if (!envConfig) {
|
|
6216
|
-
console.error(
|
|
6286
|
+
console.error(chalk9.red(`Environment '${envName}' not found.`));
|
|
6217
6287
|
process.exit(1);
|
|
6218
6288
|
}
|
|
6219
6289
|
const proxyBaseUrl = opts.proxyBaseUrl || opts.anthropicBaseUrl;
|
|
6220
6290
|
if (proxyBaseUrl && !isTrustedDesktopProxyBaseUrl(proxyBaseUrl)) {
|
|
6221
|
-
console.error(
|
|
6291
|
+
console.error(chalk9.red("Desktop proxy override must use the local CCEM Claude proxy endpoint."));
|
|
6222
6292
|
process.exitCode = 1;
|
|
6223
6293
|
return;
|
|
6224
6294
|
}
|
|
@@ -6253,7 +6323,7 @@ desktopCmd.command("create").description("Create a workspace session in the runn
|
|
|
6253
6323
|
const hasRouteOptions = opts.route.length > 0 || opts.routesJson !== void 0;
|
|
6254
6324
|
const routes = provider === "claude" ? parseDesktopRoutes(opts.route, opts.routesJson) : void 0;
|
|
6255
6325
|
if (provider === "codex" && hasRouteOptions) {
|
|
6256
|
-
console.error(
|
|
6326
|
+
console.error(chalk9.yellow(
|
|
6257
6327
|
"Warning: Codex sessions do not support routing; --route and --routes-json were ignored."
|
|
6258
6328
|
));
|
|
6259
6329
|
}
|
|
@@ -6326,7 +6396,7 @@ program.command("usage").description("\u663E\u793A\u4F7F\u7528\u7EDF\u8BA1\u5E76
|
|
|
6326
6396
|
if (stats) {
|
|
6327
6397
|
console.log(renderUsageDetail(stats));
|
|
6328
6398
|
} else {
|
|
6329
|
-
console.log(
|
|
6399
|
+
console.log(chalk9.yellow("No usage data available"));
|
|
6330
6400
|
}
|
|
6331
6401
|
}
|
|
6332
6402
|
});
|
|
@@ -6352,9 +6422,9 @@ program.action(async (options) => {
|
|
|
6352
6422
|
{
|
|
6353
6423
|
type: "list",
|
|
6354
6424
|
name: "action",
|
|
6355
|
-
message:
|
|
6425
|
+
message: chalk9.gray("Select action"),
|
|
6356
6426
|
choices: getMainMenuChoices(defaultMode),
|
|
6357
|
-
prefix:
|
|
6427
|
+
prefix: chalk9.gray("?")
|
|
6358
6428
|
}
|
|
6359
6429
|
]);
|
|
6360
6430
|
if (action === "start") {
|
|
@@ -6384,7 +6454,7 @@ program.action(async (options) => {
|
|
|
6384
6454
|
{
|
|
6385
6455
|
type: "input",
|
|
6386
6456
|
name: "continue",
|
|
6387
|
-
message:
|
|
6457
|
+
message: chalk9.gray("Press Enter to continue..."),
|
|
6388
6458
|
prefix: ""
|
|
6389
6459
|
}
|
|
6390
6460
|
]);
|
|
@@ -6394,7 +6464,7 @@ program.action(async (options) => {
|
|
|
6394
6464
|
config2.set("current", result.name);
|
|
6395
6465
|
} else if (result.action === "edit") {
|
|
6396
6466
|
const envToEdit = registries[result.name];
|
|
6397
|
-
console.log(
|
|
6467
|
+
console.log(chalk9.yellow(`
|
|
6398
6468
|
Editing environment '${result.name}'`));
|
|
6399
6469
|
const answers = await promptForEnvironmentConfig(envToEdit, true);
|
|
6400
6470
|
registries[result.name] = applyPromptAnswers(envToEdit, answers, true);
|
|
@@ -6504,9 +6574,9 @@ Editing environment '${result.name}'`));
|
|
|
6504
6574
|
{
|
|
6505
6575
|
type: "list",
|
|
6506
6576
|
name: "permMode",
|
|
6507
|
-
message:
|
|
6577
|
+
message: chalk9.gray("Select permission mode"),
|
|
6508
6578
|
choices: getPermModeChoices(null, false),
|
|
6509
|
-
prefix:
|
|
6579
|
+
prefix: chalk9.gray("?")
|
|
6510
6580
|
}
|
|
6511
6581
|
]);
|
|
6512
6582
|
if (permMode !== "back") {
|
|
@@ -6519,9 +6589,9 @@ Editing environment '${result.name}'`));
|
|
|
6519
6589
|
{
|
|
6520
6590
|
type: "list",
|
|
6521
6591
|
name: "selectedMode",
|
|
6522
|
-
message:
|
|
6592
|
+
message: chalk9.gray("Set default permission mode"),
|
|
6523
6593
|
choices: getPermModeChoices(currentDefault, true),
|
|
6524
|
-
prefix:
|
|
6594
|
+
prefix: chalk9.gray("?")
|
|
6525
6595
|
}
|
|
6526
6596
|
]);
|
|
6527
6597
|
if (selectedMode === "clear") {
|
|
@@ -6540,14 +6610,14 @@ Editing environment '${result.name}'`));
|
|
|
6540
6610
|
});
|
|
6541
6611
|
function handleCliError(error) {
|
|
6542
6612
|
if (error instanceof StaleDesktopControlDescriptorError) {
|
|
6543
|
-
console.error(
|
|
6613
|
+
console.error(chalk9.red(error.message));
|
|
6544
6614
|
process.exit(1);
|
|
6545
6615
|
}
|
|
6546
6616
|
if (error instanceof Error) {
|
|
6547
|
-
console.error(
|
|
6617
|
+
console.error(chalk9.red(error.message));
|
|
6548
6618
|
process.exit(1);
|
|
6549
6619
|
}
|
|
6550
|
-
console.error(
|
|
6620
|
+
console.error(chalk9.red(String(error)));
|
|
6551
6621
|
process.exit(1);
|
|
6552
6622
|
}
|
|
6553
6623
|
registerDshCommands(program, {
|