leaf-coding-agent 1.0.1 → 1.0.3

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.
@@ -2080,6 +2080,11 @@ export class InteractiveMode {
2080
2080
  this.editor.setText("");
2081
2081
  return;
2082
2082
  }
2083
+ if (text === "/worker" || text.startsWith("/worker ")) {
2084
+ this.handleWorkerCommand(text);
2085
+ this.editor.setText("");
2086
+ return;
2087
+ }
2083
2088
  if (text === "/quit") {
2084
2089
  this.editor.setText("");
2085
2090
  await this.shutdown();
@@ -4361,6 +4366,62 @@ export class InteractiveMode {
4361
4366
  this.chatContainer.addChild(new Text(info, 1, 0));
4362
4367
  this.ui.requestRender();
4363
4368
  }
4369
+ handleWorkerCommand(text) {
4370
+ const args = text.slice(7).trim();
4371
+ if (args === "" || args === "status") {
4372
+ // 显示 Worker 设置界面
4373
+ this.showWorkerSelector();
4374
+ }
4375
+ else if (args === "enable") {
4376
+ // 启用 Worker 模式
4377
+ this.session.workerEnabled = true;
4378
+ this.showWarning("Worker 模式已启用");
4379
+ }
4380
+ else if (args === "disable") {
4381
+ // 禁用 Worker 模式
4382
+ this.session.workerEnabled = false;
4383
+ this.showWarning("Worker 模式已禁用");
4384
+ }
4385
+ else if (args === "abort") {
4386
+ // 中止所有 Worker
4387
+ this.session.workerIntegration?.abortAllWorkers();
4388
+ this.showWarning("已中止所有 Worker");
4389
+ }
4390
+ else {
4391
+ this.showWarning(`未知的 Worker 命令: ${args}\n用法: /worker [status|enable|disable|abort]`);
4392
+ }
4393
+ }
4394
+ showWorkerSelector() {
4395
+ import("./components/worker-selector.js").then(({ WorkerSelectorComponent }) => {
4396
+ const config = {
4397
+ enabled: this.session.workerEnabled,
4398
+ maxWorkers: 4,
4399
+ communicationMode: "message",
4400
+ };
4401
+ const selector = new WorkerSelectorComponent(config, {
4402
+ onEnabledChange: (enabled) => {
4403
+ this.session.workerEnabled = enabled;
4404
+ this.showWarning(`Worker 模式已${enabled ? "启用" : "禁用"}`);
4405
+ },
4406
+ onMaxWorkersChange: (maxWorkers) => {
4407
+ this.showWarning(`最大 Worker 数已设置为 ${maxWorkers}`);
4408
+ },
4409
+ onCommunicationModeChange: (mode) => {
4410
+ this.showWarning(`通信模式已设置为 ${mode}`);
4411
+ },
4412
+ onAbortAll: () => {
4413
+ this.session.workerIntegration?.abortAllWorkers();
4414
+ this.showWarning("已中止所有 Worker");
4415
+ },
4416
+ onCancel: () => {
4417
+ this.chatContainer.removeChild(selector);
4418
+ this.ui.requestRender();
4419
+ },
4420
+ });
4421
+ this.chatContainer.addChild(selector);
4422
+ this.ui.requestRender();
4423
+ });
4424
+ }
4364
4425
  handleChangelogCommand() {
4365
4426
  const changelogPath = getChangelogPath();
4366
4427
  const allEntries = parseChangelog(changelogPath);