@caupulican/pi-adaptative 0.80.21 → 0.80.23

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 (79) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/cli/file-processor.d.ts.map +1 -1
  3. package/dist/cli/file-processor.js +28 -1
  4. package/dist/cli/file-processor.js.map +1 -1
  5. package/dist/core/agent-session.d.ts.map +1 -1
  6. package/dist/core/agent-session.js +10 -76
  7. package/dist/core/agent-session.js.map +1 -1
  8. package/dist/core/bash-executor.d.ts.map +1 -1
  9. package/dist/core/bash-executor.js +16 -7
  10. package/dist/core/bash-executor.js.map +1 -1
  11. package/dist/core/exec.d.ts +20 -1
  12. package/dist/core/exec.d.ts.map +1 -1
  13. package/dist/core/exec.js +52 -19
  14. package/dist/core/exec.js.map +1 -1
  15. package/dist/core/extensions/loader.d.ts +6 -0
  16. package/dist/core/extensions/loader.d.ts.map +1 -1
  17. package/dist/core/extensions/loader.js +33 -1
  18. package/dist/core/extensions/loader.js.map +1 -1
  19. package/dist/core/extensions/types.d.ts +2 -0
  20. package/dist/core/extensions/types.d.ts.map +1 -1
  21. package/dist/core/extensions/types.js.map +1 -1
  22. package/dist/core/message-retention.d.ts +26 -0
  23. package/dist/core/message-retention.d.ts.map +1 -0
  24. package/dist/core/message-retention.js +95 -0
  25. package/dist/core/message-retention.js.map +1 -0
  26. package/dist/core/package-manager.d.ts.map +1 -1
  27. package/dist/core/package-manager.js +50 -29
  28. package/dist/core/package-manager.js.map +1 -1
  29. package/dist/core/resource-loader.d.ts.map +1 -1
  30. package/dist/core/resource-loader.js +4 -1
  31. package/dist/core/resource-loader.js.map +1 -1
  32. package/dist/core/session-manager.d.ts +3 -1
  33. package/dist/core/session-manager.d.ts.map +1 -1
  34. package/dist/core/session-manager.js +45 -9
  35. package/dist/core/session-manager.js.map +1 -1
  36. package/dist/core/settings-manager.d.ts +8 -0
  37. package/dist/core/settings-manager.d.ts.map +1 -1
  38. package/dist/core/settings-manager.js.map +1 -1
  39. package/dist/core/skills.d.ts.map +1 -1
  40. package/dist/core/skills.js +12 -0
  41. package/dist/core/skills.js.map +1 -1
  42. package/dist/core/tools/git-filter.d.ts +9 -1
  43. package/dist/core/tools/git-filter.d.ts.map +1 -1
  44. package/dist/core/tools/git-filter.js +94 -8
  45. package/dist/core/tools/git-filter.js.map +1 -1
  46. package/dist/core/tools/read.d.ts +31 -0
  47. package/dist/core/tools/read.d.ts.map +1 -1
  48. package/dist/core/tools/read.js +164 -33
  49. package/dist/core/tools/read.js.map +1 -1
  50. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  51. package/dist/modes/interactive/components/tool-execution.js +37 -4
  52. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  53. package/dist/modes/interactive/interactive-mode.d.ts +2 -1
  54. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  55. package/dist/modes/interactive/interactive-mode.js +54 -18
  56. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  57. package/dist/modes/rpc/jsonl.d.ts +0 -7
  58. package/dist/modes/rpc/jsonl.d.ts.map +1 -1
  59. package/dist/modes/rpc/jsonl.js +17 -0
  60. package/dist/modes/rpc/jsonl.js.map +1 -1
  61. package/dist/utils/safe-write-stream.d.ts +10 -0
  62. package/dist/utils/safe-write-stream.d.ts.map +1 -0
  63. package/dist/utils/safe-write-stream.js +16 -0
  64. package/dist/utils/safe-write-stream.js.map +1 -0
  65. package/dist/utils/sleep.d.ts +3 -1
  66. package/dist/utils/sleep.d.ts.map +1 -1
  67. package/dist/utils/sleep.js +10 -4
  68. package/dist/utils/sleep.js.map +1 -1
  69. package/docs/extensions.md +9 -3
  70. package/docs/skills.md +14 -2
  71. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  72. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  73. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  74. package/examples/extensions/sandbox/package-lock.json +2 -2
  75. package/examples/extensions/sandbox/package.json +1 -1
  76. package/examples/extensions/with-deps/package-lock.json +2 -2
  77. package/examples/extensions/with-deps/package.json +1 -1
  78. package/npm-shrinkwrap.json +12 -12
  79. package/package.json +4 -4
@@ -694,7 +694,9 @@ export class InteractiveMode {
694
694
  rawKeyHint("!", "to run bash"),
695
695
  rawKeyHint("!!", "to run bash (no context)"),
696
696
  hint("app.message.followUp", "to queue follow-up"),
697
+ rawKeyHint(">>", "prefix to queue follow-up"),
697
698
  hint("app.message.dequeue", "to edit all queued messages"),
699
+ rawKeyHint("↑", "(empty editor) to recall queued messages"),
698
700
  hint("app.clipboard.pasteImage", "to paste image"),
699
701
  rawKeyHint("drop files", "to attach"),
700
702
  ].join("\n");
@@ -735,7 +737,7 @@ export class InteractiveMode {
735
737
  // Initialize extensions first so resources are shown before messages
736
738
  await this.rebindCurrentSession();
737
739
  // Render initial messages AFTER showing loaded resources
738
- this.renderInitialMessages();
740
+ await this.renderInitialMessages();
739
741
  this.renderProjectTrustWarningIfNeeded();
740
742
  // Set up theme file watcher
741
743
  onThemeChange(() => {
@@ -1433,7 +1435,7 @@ export class InteractiveMode {
1433
1435
  return { cancelled: true };
1434
1436
  }
1435
1437
  this.chatContainer.clear();
1436
- this.renderInitialMessages();
1438
+ await this.renderInitialMessages();
1437
1439
  if (result.editorText && !this.editor.getText().trim()) {
1438
1440
  this.editor.setText(result.editorText);
1439
1441
  }
@@ -1506,7 +1508,7 @@ export class InteractiveMode {
1506
1508
  this.streamingComponent = undefined;
1507
1509
  this.streamingMessage = undefined;
1508
1510
  this.clearRenderedToolPanelState();
1509
- this.renderInitialMessages();
1511
+ void this.renderInitialMessages();
1510
1512
  }
1511
1513
  /**
1512
1514
  * Get a registered tool definition by name (for custom rendering).
@@ -2285,10 +2287,14 @@ export class InteractiveMode {
2285
2287
  this.ui.onDebug = () => this.handleDebugCommand();
2286
2288
  this.defaultEditor.onAction("app.model.select", () => void this.showModelSelector());
2287
2289
  this.defaultEditor.onAction("app.tools.expand", () => this.toggleToolOutputExpansion());
2288
- this.defaultEditor.onAction("app.thinking.toggle", () => this.toggleThinkingBlockVisibility());
2290
+ this.defaultEditor.onAction("app.thinking.toggle", () => void this.toggleThinkingBlockVisibility());
2289
2291
  this.defaultEditor.onAction("app.editor.external", () => this.openExternalEditor());
2290
2292
  this.defaultEditor.onAction("app.message.followUp", () => this.handleFollowUp());
2291
2293
  this.defaultEditor.onAction("app.message.dequeue", () => this.handleDequeue());
2294
+ // Plain Up arrow on an empty editor recalls queued messages for editing
2295
+ // before history navigation. Many terminals (e.g. Windows Terminal) swallow
2296
+ // the alt-chord bindings, so the queue must be reachable without them.
2297
+ this.defaultEditor.onRecallQueued = () => this.restoreQueuedMessagesToEditor() > 0;
2292
2298
  this.defaultEditor.onAction("app.session.new", () => this.handleClearCommand());
2293
2299
  this.defaultEditor.onAction("app.session.tree", () => this.showTreeSelector());
2294
2300
  this.defaultEditor.onAction("app.session.fork", () => this.showUserMessageSelector());
@@ -2357,19 +2363,33 @@ export class InteractiveMode {
2357
2363
  text = text.trim();
2358
2364
  if (!text)
2359
2365
  return;
2366
+ // A ">>" prefix queues the message as a follow-up (delivered after the
2367
+ // current work finishes, starting the next round) instead of steering.
2368
+ // This is the chord-free alternative to app.message.followUp, which many
2369
+ // terminals swallow (e.g. Windows Terminal claims alt+enter).
2370
+ const queueAsFollowUp = text.startsWith(">>");
2371
+ if (queueAsFollowUp) {
2372
+ text = text.slice(2).trim();
2373
+ if (!text)
2374
+ return;
2375
+ }
2360
2376
  // User input submitted while work is active is always steering. Treat
2361
2377
  // slash/bang text as user steering text instead of executing commands that
2362
2378
  // would interrupt the current stream or compaction.
2363
2379
  if (this.session.isCompacting) {
2364
2380
  const images = this.takeClipboardImagesForText(text);
2365
- this.queueCompactionMessage(text, "steer", images);
2381
+ this.queueCompactionMessage(text, queueAsFollowUp ? "followUp" : "steer", images);
2366
2382
  return;
2367
2383
  }
2368
- if (this.session.isStreaming) {
2384
+ if (this.session.isStreaming || this.session.isRetrying) {
2369
2385
  const images = this.takeClipboardImagesForText(text);
2370
2386
  this.editor.addToHistory?.(text);
2371
2387
  this.editor.setText("");
2372
- await this.session.prompt(text, { streamingBehavior: "steer", images, processSlashCommands: false });
2388
+ await this.session.prompt(text, {
2389
+ streamingBehavior: queueAsFollowUp ? "followUp" : "steer",
2390
+ images,
2391
+ processSlashCommands: false,
2392
+ });
2373
2393
  this.updatePendingMessagesDisplay();
2374
2394
  this.ui.requestRender();
2375
2395
  return;
@@ -2758,7 +2778,7 @@ export class InteractiveMode {
2758
2778
  }
2759
2779
  else if (event.result) {
2760
2780
  this.chatContainer.clear();
2761
- this.rebuildChatFromMessages();
2781
+ await this.rebuildChatFromMessages();
2762
2782
  this.addMessageToChat(createCompactionSummaryMessage(event.result.summary, event.result.tokensBefore, new Date().toISOString()));
2763
2783
  this.footer.invalidate();
2764
2784
  }
@@ -2934,7 +2954,14 @@ export class InteractiveMode {
2934
2954
  * @param options.updateFooter Update footer state
2935
2955
  * @param options.populateHistory Add user messages to editor history
2936
2956
  */
2937
- renderSessionContext(sessionContext, options = {}) {
2957
+ renderGeneration = 0;
2958
+ async renderSessionContext(sessionContext, options = {}) {
2959
+ // Rebuilding a long session's scrollback synchronously blocks the event loop
2960
+ // for seconds (reload/resume feel frozen). Yield between chunks so input and
2961
+ // repaints keep flowing; a newer rebuild supersedes this one via generation.
2962
+ const generation = ++this.renderGeneration;
2963
+ const CHUNK_SIZE = 20;
2964
+ let processed = 0;
2938
2965
  this.clearRenderedToolPanelState();
2939
2966
  const renderedPendingTools = new Map();
2940
2967
  if (options.updateFooter) {
@@ -2942,6 +2969,13 @@ export class InteractiveMode {
2942
2969
  this.updateEditorBorderColor();
2943
2970
  }
2944
2971
  for (const message of sessionContext.messages) {
2972
+ if (processed > 0 && processed % CHUNK_SIZE === 0) {
2973
+ this.ui.requestRender();
2974
+ await new Promise((resolve) => setImmediate(resolve));
2975
+ if (generation !== this.renderGeneration)
2976
+ return;
2977
+ }
2978
+ processed++;
2945
2979
  // Assistant messages need special handling for tool calls
2946
2980
  if (message.role === "assistant") {
2947
2981
  this.addMessageToChat(message);
@@ -2986,10 +3020,10 @@ export class InteractiveMode {
2986
3020
  }
2987
3021
  this.ui.requestRender();
2988
3022
  }
2989
- renderInitialMessages() {
3023
+ async renderInitialMessages() {
2990
3024
  // Get aligned messages and entries from session context
2991
3025
  const context = this.sessionManager.buildSessionContext();
2992
- this.renderSessionContext(context, {
3026
+ await this.renderSessionContext(context, {
2993
3027
  updateFooter: true,
2994
3028
  populateHistory: true,
2995
3029
  });
@@ -3013,10 +3047,10 @@ export class InteractiveMode {
3013
3047
  };
3014
3048
  });
3015
3049
  }
3016
- rebuildChatFromMessages() {
3050
+ async rebuildChatFromMessages() {
3017
3051
  this.chatContainer.clear();
3018
3052
  const context = this.sessionManager.buildSessionContext();
3019
- this.renderSessionContext(context);
3053
+ await this.renderSessionContext(context);
3020
3054
  }
3021
3055
  // =========================================================================
3022
3056
  // Key handlers
@@ -3292,12 +3326,12 @@ export class InteractiveMode {
3292
3326
  }
3293
3327
  this.ui.requestRender();
3294
3328
  }
3295
- toggleThinkingBlockVisibility() {
3329
+ async toggleThinkingBlockVisibility() {
3296
3330
  this.hideThinkingBlock = !this.hideThinkingBlock;
3297
3331
  this.settingsManager.setHideThinkingBlock(this.hideThinkingBlock);
3298
3332
  // Rebuild chat from session messages
3299
3333
  this.chatContainer.clear();
3300
- this.rebuildChatFromMessages();
3334
+ await this.rebuildChatFromMessages();
3301
3335
  // If streaming, re-add the streaming component with updated visibility and re-render
3302
3336
  if (this.streamingComponent && this.streamingMessage) {
3303
3337
  this.streamingComponent.setHideThinkingBlock(this.hideThinkingBlock);
@@ -4532,6 +4566,7 @@ export class InteractiveMode {
4532
4566
  child.setShowImages(enabled);
4533
4567
  }
4534
4568
  }
4569
+ this.ui.requestRender();
4535
4570
  },
4536
4571
  onImageWidthCellsChange: (width) => {
4537
4572
  this.settingsManager.setImageWidthCells(width);
@@ -4540,6 +4575,7 @@ export class InteractiveMode {
4540
4575
  child.setImageWidthCells(width);
4541
4576
  }
4542
4577
  }
4578
+ this.ui.requestRender();
4543
4579
  },
4544
4580
  onAutoResizeImagesChange: (enabled) => {
4545
4581
  this.settingsManager.setImageAutoResize(enabled);
@@ -4595,7 +4631,7 @@ export class InteractiveMode {
4595
4631
  }
4596
4632
  }
4597
4633
  this.chatContainer.clear();
4598
- this.rebuildChatFromMessages();
4634
+ void this.rebuildChatFromMessages();
4599
4635
  },
4600
4636
  onCollapseChangelogChange: (collapsed) => {
4601
4637
  this.settingsManager.setCollapseChangelog(collapsed);
@@ -4975,7 +5011,7 @@ export class InteractiveMode {
4975
5011
  }
4976
5012
  // Update UI
4977
5013
  this.chatContainer.clear();
4978
- this.renderInitialMessages();
5014
+ await this.renderInitialMessages();
4979
5015
  if (result.editorText && !this.editor.getText().trim()) {
4980
5016
  this.editor.setText(result.editorText);
4981
5017
  }
@@ -5523,7 +5559,7 @@ export class InteractiveMode {
5523
5559
  this.setupAutocompleteProvider();
5524
5560
  const runner = this.session.extensionRunner;
5525
5561
  this.setupExtensionShortcuts(runner);
5526
- this.rebuildChatFromMessages();
5562
+ await this.rebuildChatFromMessages();
5527
5563
  dismissReloadBox(this.editor);
5528
5564
  this.showLoadedResources({
5529
5565
  force: false,