apex-code 0.5.1 → 0.6.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +41 -2
  3. package/dist/core/agent-session.d.ts +37 -0
  4. package/dist/core/agent-session.d.ts.map +1 -1
  5. package/dist/core/agent-session.js +264 -60
  6. package/dist/core/agent-session.js.map +1 -1
  7. package/dist/core/default-tool-names.d.ts +7 -0
  8. package/dist/core/default-tool-names.d.ts.map +1 -0
  9. package/dist/core/default-tool-names.js +14 -0
  10. package/dist/core/default-tool-names.js.map +1 -0
  11. package/dist/core/extensions/runner.d.ts.map +1 -1
  12. package/dist/core/extensions/runner.js +2 -0
  13. package/dist/core/extensions/runner.js.map +1 -1
  14. package/dist/core/extensions/types.d.ts +3 -0
  15. package/dist/core/extensions/types.d.ts.map +1 -1
  16. package/dist/core/extensions/types.js.map +1 -1
  17. package/dist/core/keybindings.d.ts +11 -1
  18. package/dist/core/keybindings.d.ts.map +1 -1
  19. package/dist/core/keybindings.js +6 -1
  20. package/dist/core/keybindings.js.map +1 -1
  21. package/dist/core/permissions/startup.d.ts +1 -1
  22. package/dist/core/permissions/startup.d.ts.map +1 -1
  23. package/dist/core/permissions/startup.js.map +1 -1
  24. package/dist/core/sdk.d.ts.map +1 -1
  25. package/dist/core/sdk.js +13 -9
  26. package/dist/core/sdk.js.map +1 -1
  27. package/dist/core/settings-manager.d.ts +4 -0
  28. package/dist/core/settings-manager.d.ts.map +1 -1
  29. package/dist/core/settings-manager.js +13 -0
  30. package/dist/core/settings-manager.js.map +1 -1
  31. package/dist/core/slash-commands.d.ts.map +1 -1
  32. package/dist/core/slash-commands.js +1 -0
  33. package/dist/core/slash-commands.js.map +1 -1
  34. package/dist/core/tools/contract.d.ts +1 -0
  35. package/dist/core/tools/contract.d.ts.map +1 -1
  36. package/dist/core/tools/contract.js.map +1 -1
  37. package/dist/core/tools/index.d.ts +1 -1
  38. package/dist/core/tools/index.d.ts.map +1 -1
  39. package/dist/core/tools/index.js.map +1 -1
  40. package/dist/core/tools/plan-present.d.ts +13 -12
  41. package/dist/core/tools/plan-present.d.ts.map +1 -1
  42. package/dist/core/tools/plan-present.js +32 -19
  43. package/dist/core/tools/plan-present.js.map +1 -1
  44. package/dist/core/tools/renderers/index.d.ts +1 -1
  45. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  46. package/dist/core/tools/renderers/index.js +2 -0
  47. package/dist/core/tools/renderers/index.js.map +1 -1
  48. package/dist/core/tools/renderers/todo-write.d.ts +7 -0
  49. package/dist/core/tools/renderers/todo-write.d.ts.map +1 -0
  50. package/dist/core/tools/renderers/todo-write.js +58 -0
  51. package/dist/core/tools/renderers/todo-write.js.map +1 -0
  52. package/dist/index.d.ts +2 -2
  53. package/dist/index.d.ts.map +1 -1
  54. package/dist/index.js +1 -1
  55. package/dist/index.js.map +1 -1
  56. package/dist/modes/interactive/components/first-use-hints.d.ts +1 -1
  57. package/dist/modes/interactive/components/first-use-hints.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/first-use-hints.js +1 -0
  59. package/dist/modes/interactive/components/first-use-hints.js.map +1 -1
  60. package/dist/modes/interactive/components/footer.d.ts +3 -1
  61. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/footer.js +25 -11
  63. package/dist/modes/interactive/components/footer.js.map +1 -1
  64. package/dist/modes/interactive/components/settings-selector.d.ts +5 -0
  65. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/settings-selector.js +20 -1
  67. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  68. package/dist/modes/interactive/components/task-panel.d.ts +27 -0
  69. package/dist/modes/interactive/components/task-panel.d.ts.map +1 -0
  70. package/dist/modes/interactive/components/task-panel.js +92 -0
  71. package/dist/modes/interactive/components/task-panel.js.map +1 -0
  72. package/dist/modes/interactive/components/turn-summary.d.ts +6 -0
  73. package/dist/modes/interactive/components/turn-summary.d.ts.map +1 -0
  74. package/dist/modes/interactive/components/turn-summary.js +12 -0
  75. package/dist/modes/interactive/components/turn-summary.js.map +1 -0
  76. package/dist/modes/interactive/interactive-mode.d.ts +9 -0
  77. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  78. package/dist/modes/interactive/interactive-mode.js +162 -11
  79. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  80. package/dist/package-manager-cli.d.ts.map +1 -1
  81. package/dist/package-manager-cli.js +31 -72
  82. package/dist/package-manager-cli.js.map +1 -1
  83. package/docs/keybindings.md +19 -1
  84. package/docs/settings.md +8 -0
  85. package/npm-shrinkwrap.json +5 -5
  86. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Apex Code changelog
2
2
 
3
+ ## [0.6.0] - 2026-10-04
4
+
5
+ ### Added
6
+
7
+ - `/tree` asks whether to keep current files, restore files to the selected checkpoint, or cancel when the workspace differs. Keeping files is the default. Navigation reports the workspace outcome, and a restore saves a pre-restore checkpoint.
8
+ - Extensions can pass `workspacePolicy` to `navigateTree`. SDK callers can inspect checkpoint drift without changing files or the conversation through `AgentSession.previewTreeWorkspace()`.
9
+ - Completed interactive runs show a dim `Worked for` duration. Aborted runs show `Interrupted after`, including cancellation during retry backoff. Runs under one second show no duration. The line is never saved to the session or sent to the model.
10
+ - Interactive permission modes have an in-memory session override. It governs tool calls, configured commands, and delegated children above configured mode sources. Bypass is available only when it was in force at startup. Reload, resume, and a new session clear the override; `/settings` still writes the saved user default.
11
+
12
+ - Plan mode activates `plan_present` when the tool registry admits it. Its selector offers approval with automatic edit acceptance, approval with edit prompts, or continued planning. Approval changes only the session mode and refreshes the footer. Explicitly selected tools remain active; tool allowlists and exclusions still apply.
13
+
14
+ - Active task lists appear in a pinned panel above the composer. Alt+J and `/tasks` toggle a globally saved expansion preference. The panel follows branch navigation and resume, retains tasks through compaction, and hides a completed list when the run settles. On macOS, Alt+J needs Option configured as Meta.
15
+ - The task-list tool remains opt-in. A `/settings` row adds or removes `todo_write` from saved defaults for new sessions while preserving other tools. Project defaults make the row read-only. Task results show a compact completion count with expandable details.
16
+
17
+ ### Changed
18
+
19
+ - Shift+Tab now cycles permission modes for this session. Alt+T cycles thinking levels. The footer marks session overrides and shows the bound cycle key; the first cycle explains the new bindings. To restore the old thinking key, set `"app.thinking.cycle": "shift+tab"` and `"app.permissionMode.cycle": "alt+t"` in `~/.apex-code/agent/keybindings.json`, then run `/reload`. On macOS, Alt+T needs Option configured as Meta.
20
+
21
+ ## [0.5.2] - 2026-09-30
22
+
23
+ ### Changed
24
+
25
+ - **Self-update shows its progress.** `apex-code update --self` reports the current version, checks for updates, names the target version, and confirms success after installation finishes. Managed and package-manager failures retain their diagnostics and never report success.
26
+
3
27
  ## [0.5.1] - 2026-09-27
4
28
 
5
29
  ### Changed
package/README.md CHANGED
@@ -170,6 +170,7 @@ Type `/` in the editor to trigger commands. [Extensions](#extensions) can regist
170
170
  | `/thinking` | Switch thinking level; Ctrl+S in the picker saves the startup default |
171
171
  | `/scoped-models` | Enable/disable models for Ctrl+P cycling |
172
172
  | `/settings` | Theme, message delivery, transport, and other preferences |
173
+ | `/tasks` | Expand or collapse the pinned task panel |
173
174
  | `/resume` | Pick from previous sessions |
174
175
  | `/new` | Start a new session |
175
176
  | `/name <name>` | Set session display name |
@@ -203,11 +204,49 @@ See `/hotkeys` for the full list. Customize via `~/.apex-code/agent/keybindings.
203
204
  | Escape twice | Open `/tree` |
204
205
  | Ctrl+L | Open model selector |
205
206
  | Ctrl+P / Shift+Ctrl+P | Cycle scoped models forward/backward |
206
- | Shift+Tab | Cycle thinking level |
207
+ | Shift+Tab | Cycle permission mode for this session |
208
+ | Alt+T | Cycle thinking level |
207
209
  | Ctrl+O | Collapse/expand tool output |
208
210
  | Ctrl+T | Collapse/expand thinking blocks |
211
+ | Alt+J | Expand or collapse the task panel |
209
212
  | Ctrl+X | Copy the last assistant message; with fullscreen copy-on-select disabled, copy the active text selection |
210
213
 
214
+ The permission cycle affects only the running session. The footer marks a session
215
+ override, and `/settings` still changes the saved default. The cycle includes bypass
216
+ only when bypass was in force at startup. On macOS, Alt+T needs Option configured as
217
+ Meta. See [keybinding configuration](docs/keybindings.md#custom-configuration) to
218
+ restore Shift+Tab for thinking levels.
219
+
220
+ ### Plan approval
221
+
222
+ Plan mode activates `plan_present` when your tool selection admits it. When the agent
223
+ presents a plan, choose **Yes, and accept edits**, **Yes, and ask before each edit**,
224
+ or **No, keep planning**. Approval changes the permission mode for this session
225
+ and updates the footer. Keeping planning or dismissing the selector leaves plan
226
+ mode unchanged. Reload clears the session override.
227
+
228
+ If you use `--tools`, include `plan_present` to allow the approval flow. A tool
229
+ listed explicitly stays active after approval. `--no-tools` and tool exclusions
230
+ remain authoritative.
231
+
232
+ ### Task list
233
+
234
+ When `todo_write` is active and the agent records tasks, a panel above the
235
+ composer shows completed and total counts plus the task in progress. Press Alt+J
236
+ or run `/tasks` to expand up to five items and an overflow count. Your expansion
237
+ choice is saved globally. On macOS, configure Option as Meta for Alt+J.
238
+
239
+ The panel follows the current branch through `/tree` and resume, and retains
240
+ tasks through compaction. A newly completed list hides when the run settles.
241
+ The transcript keeps a compact `Task list updated · N/M complete` result;
242
+ expand that result to inspect the recorded list.
243
+
244
+ Enable the task-list tool in `/settings` for new sessions. This preserves your
245
+ other default tools and does not change the current session. A project
246
+ `defaultTools` selection makes the row read-only. CLI tool selection and
247
+ exclusions take precedence. To enable it for one invocation, include
248
+ `todo_write` in `--tools` alongside the other tools you want.
249
+
211
250
  ### Message Queue
212
251
 
213
252
  Submit messages while the agent is working:
@@ -525,7 +564,7 @@ Pi is aggressively extensible so it doesn't have to dictate your workflow. Featu
525
564
 
526
565
  **No permission popups.** Run in a container, or build your own confirmation flow with [extensions](#extensions) inline with your environment and security requirements.
527
566
 
528
- **No plan mode.** Write plans to files, or build it with [extensions](#extensions), or install a package.
567
+ **Plan mode.** Apex Code supports a session permission mode for planning and an interactive [plan approval flow](#plan-approval). Approval selects the edit policy for the running session.
529
568
 
530
569
  **No built-in to-dos.** They confuse models. Use a TODO.md file, or build your own with [extensions](#extensions).
531
570
 
@@ -102,6 +102,7 @@ export type AgentSessionEvent = Exclude<AgentEvent, {
102
102
  success: boolean;
103
103
  attempt: number;
104
104
  finalError?: string;
105
+ aborted?: boolean;
105
106
  } | {
106
107
  type: "summarization_retry_scheduled";
107
108
  attempt: number;
@@ -137,6 +138,7 @@ export interface AggregateBudgetUsageSnapshot {
137
138
  startedAtMs: number;
138
139
  }
139
140
  export interface AgentSessionConfig {
141
+ implicitDefaultToolNames?: readonly string[];
140
142
  childRunRegistry?: ChildRunRegistry;
141
143
  /**
142
144
  * The session's delegation runtime options when delegation is configured.
@@ -302,6 +304,16 @@ export interface SessionStats {
302
304
  }
303
305
  /** Explicit workspace policy for `/tree` and `/fork`-family navigation (spec § 4). */
304
306
  export type TreeWorkspacePolicy = "keep" | "restore" | "fail-if-drifted" | "cancel";
307
+ export type TreeWorkspacePreview = {
308
+ state: "no-checkpoint";
309
+ } | {
310
+ state: "unavailable";
311
+ reason: string;
312
+ } | {
313
+ state: "matches";
314
+ } | {
315
+ state: "differs";
316
+ };
305
317
  /** What the navigation did to the workspace, reported separately from the conversation move. */
306
318
  export interface TreeWorkspaceOutcome {
307
319
  policy: TreeWorkspacePolicy;
@@ -386,9 +398,13 @@ export declare class AgentSession {
386
398
  private _initialActiveToolNames?;
387
399
  private _allowedToolNames?;
388
400
  private _excludedToolNames?;
401
+ private readonly _implicitDefaultToolNames?;
389
402
  private _baseToolsOverride?;
390
403
  private _sessionStartEvent;
391
404
  private _permissionGate?;
405
+ private _interactivePermissionMode?;
406
+ private _interactivePermissionModeGeneration;
407
+ private readonly _startupPermissionMode?;
392
408
  private _evidenceSink?;
393
409
  private _diagnosticsOperations?;
394
410
  private _lspOperations?;
@@ -422,6 +438,13 @@ export declare class AgentSession {
422
438
  private _baseSystemPromptOptions;
423
439
  /** Prompt options after before_agent_start mutations for the active run. */
424
440
  private _runSystemPromptOptions?;
441
+ private _requestedToolNames;
442
+ private _runRequestedToolNames?;
443
+ private _planToolMode?;
444
+ private _planToolSyncGeneration;
445
+ private _pendingPlanToolSync?;
446
+ private _planToolSyncChange;
447
+ private _planPresentationGeneration;
425
448
  constructor(config: AgentSessionConfig);
426
449
  get modelRuntime(): ModelRuntime;
427
450
  private _getRequiredRequestAuth;
@@ -638,6 +661,7 @@ export declare class AgentSession {
638
661
  get systemPrompt(): string;
639
662
  /** Current retry attempt (0 if not retrying) */
640
663
  get retryAttempt(): number;
664
+ getImplicitDefaultToolNames(): string[];
641
665
  /**
642
666
  * Get the names of currently active tools.
643
667
  * Returns the names of tools currently set on the agent.
@@ -660,6 +684,12 @@ export declare class AgentSession {
660
684
  * Changes take effect on the next agent turn.
661
685
  */
662
686
  setActiveToolsByName(toolNames: string[]): void;
687
+ private _projectToolNames;
688
+ private _applyRequestedTools;
689
+ private _setPendingPlanToolSync;
690
+ private _syncPlanToolMode;
691
+ private _schedulePlanToolSync;
692
+ private _presentPlan;
663
693
  /** Whether compaction or branch summarization is currently running */
664
694
  get isCompacting(): boolean;
665
695
  /** All messages including custom types like BashExecutionMessage */
@@ -831,6 +861,11 @@ export declare class AgentSession {
831
861
  * to the next tool call with no restart.
832
862
  */
833
863
  getPermissionMode(): Promise<EffectiveModeResolution | undefined>;
864
+ getInteractivePermissionMode(): PermissionMode | undefined;
865
+ getInteractivePermissionModeCycle(): Promise<readonly PermissionMode[]>;
866
+ setInteractivePermissionMode(mode: PermissionMode): Promise<EffectiveModeResolution | undefined>;
867
+ private _setInteractivePermissionMode;
868
+ clearInteractivePermissionMode(): void;
834
869
  /**
835
870
  * Persist a permission mode to user scope (`~/.apex-code/agent/permissions.json`).
836
871
  * Returns the resolution that is actually in force afterwards, which is *not*
@@ -1077,6 +1112,8 @@ export declare class AgentSession {
1077
1112
  label?: string;
1078
1113
  workspacePolicy?: TreeWorkspacePolicy;
1079
1114
  }): Promise<TreeNavigationResult>;
1115
+ previewTreeWorkspace(targetId: string): Promise<TreeWorkspacePreview>;
1116
+ private _inspectTreeWorkspace;
1080
1117
  private _resolveTreeWorkspaceStep;
1081
1118
  /**
1082
1119
  * Get all user messages from session for fork selector.