@ia-ccun/code-agent-cli 0.0.51-beta.5 → 0.0.51-beta.8

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.
@@ -557,10 +557,10 @@ export default function aicodePlan(pi: ExtensionAPI) {
557
557
  return;
558
558
  }
559
559
 
560
- ctx.ui.setStatus(
561
- STATUS_KEY,
562
- planModeEnabled ? ctx.ui.theme.fg("warning", "⏸ 计划") : undefined,
563
- );
560
+ const statusText = planModeEnabled
561
+ ? ctx.ui.theme.fg("warning", "⏸ 计划") + ctx.ui.theme.fg("dim", " | plan (Ctrl+Alt+P)")
562
+ : undefined;
563
+ ctx.ui.setStatus(STATUS_KEY, statusText);
564
564
  updateTodoWidget(ctx);
565
565
  };
566
566
 
@@ -584,6 +584,7 @@ export default function aicodePlan(pi: ExtensionAPI) {
584
584
  pi.setActiveTools(planTools);
585
585
  planModeEnabled = true;
586
586
  setStatus(ctx);
587
+ pi.events.emit("aicode-plan:mode-changed", { planModeEnabled: true });
587
588
  ctx.ui.notify(`计划模式已启用(只读): ${planTools.join(", ")}`, "info");
588
589
  };
589
590
 
@@ -605,6 +606,7 @@ export default function aicodePlan(pi: ExtensionAPI) {
605
606
  }
606
607
 
607
608
  planModeEnabled = false;
609
+ pi.events.emit("aicode-plan:mode-changed", { planModeEnabled: false });
608
610
  restoreNormalTools();
609
611
  if (options.resetProgress) {
610
612
  executionMode = false;
@@ -647,14 +649,18 @@ export default function aicodePlan(pi: ExtensionAPI) {
647
649
  }
648
650
 
649
651
  if (["status", "state", "状态"].includes(command)) {
650
- ctx.ui.notify(
652
+ const statusLines = [
651
653
  planModeEnabled
652
654
  ? "计划模式:开启(只读规划)"
653
655
  : executionMode
654
656
  ? "计划模式:关闭(正在执行已批准的计划)"
655
657
  : "计划模式:关闭(默认直接执行模式)",
656
- "info",
657
- );
658
+ ];
659
+ if (!planModeEnabled && !executionMode) {
660
+ statusLines.push("");
661
+ statusLines.push("快捷键:Alt+Shift+P 快速切换计划模式");
662
+ }
663
+ ctx.ui.notify(statusLines.join("\n"), "info");
658
664
  return;
659
665
  }
660
666
 
@@ -683,6 +689,21 @@ export default function aicodePlan(pi: ExtensionAPI) {
683
689
  },
684
690
  });
685
691
 
692
+ // 注册快捷键
693
+ pi.registerShortcut("ctrl+alt+p", {
694
+ description: "切换计划模式",
695
+ handler: async (ctx) => {
696
+ if (planModeEnabled) {
697
+ exitPlanMode(ctx, "计划模式已禁用。返回直接执行模式。", {
698
+ resetProgress: true,
699
+ });
700
+ } else {
701
+ enterPlanMode(ctx);
702
+ }
703
+ ctx.ui.notify(`计划模式已${planModeEnabled ? "禁用" : "启用"}`, "info");
704
+ },
705
+ });
706
+
686
707
  // 注册消息渲染器
687
708
  pi.registerMessageRenderer(CUSTOM_TYPE, (message, { expanded }, theme) => {
688
709
  const details = message.details as { kind?: string; message?: string } | undefined;
@@ -26,6 +26,16 @@ function getVersion() {
26
26
  }
27
27
 
28
28
  export default function (pi: ExtensionAPI) {
29
+ // Plan 模式状态(由 EventBus 更新)
30
+ let planModeEnabled = false;
31
+ let footerTui: import("@earendil-works/pi-tui").TUI | null = null;
32
+
33
+ // 监听 plan 模式变化事件(全局监听,只注册一次)
34
+ pi.events.on("aicode-plan:mode-changed", (data: any) => {
35
+ planModeEnabled = data.enabled;
36
+ footerTui?.requestRender();
37
+ });
38
+
29
39
  pi.on("session_start", async (_event, ctx) => {
30
40
  // 检查版本更新并显示通知
31
41
  const cachePath = process.env.AICODE_CLI_VERSION_CACHE;
@@ -47,6 +57,7 @@ export default function (pi: ExtensionAPI) {
47
57
  }
48
58
 
49
59
  ctx.ui.setFooter((tui, theme, footerData) => {
60
+ footerTui = tui;
50
61
  const unsub = footerData.onBranchChange(() => tui.requestRender());
51
62
 
52
63
  return {
@@ -184,6 +195,14 @@ export default function (pi: ExtensionAPI) {
184
195
  if (statsColored) segments.push(statsColored);
185
196
  segments.push(ctxColored);
186
197
  segments.push(modelColored);
198
+
199
+ // ── Plan mode segment ────────────────────────────────────
200
+ if (planModeEnabled) {
201
+ segments.push(theme.fg("success", "⏸ plan mode on"));
202
+ }else{
203
+ segments.push(theme.fg("error", "> yolo mode on"));
204
+ }
205
+
187
206
  segments.push(theme.fg("muted", quote));
188
207
 
189
208
  // ── Version segment (rightmost) ─────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ia-ccun/code-agent-cli",
3
- "version": "0.0.51-beta.5",
3
+ "version": "0.0.51-beta.8",
4
4
  "description": "AI Coding Agent CLI - 基于OpenClaw🦞底层Agent(pi)原理封装的编码智能体(供学习使用)。",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",