@earendil-works/pi-coding-agent 0.77.0 → 0.78.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 (55) hide show
  1. package/CHANGELOG.md +28 -1
  2. package/README.md +5 -0
  3. package/dist/cli/args.d.ts +1 -0
  4. package/dist/cli/args.d.ts.map +1 -1
  5. package/dist/cli/args.js +12 -0
  6. package/dist/cli/args.js.map +1 -1
  7. package/dist/core/tools/edit.d.ts.map +1 -1
  8. package/dist/core/tools/edit.js +7 -10
  9. package/dist/core/tools/edit.js.map +1 -1
  10. package/dist/core/tools/find.d.ts.map +1 -1
  11. package/dist/core/tools/find.js.map +1 -1
  12. package/dist/core/tools/grep.d.ts.map +1 -1
  13. package/dist/core/tools/grep.js.map +1 -1
  14. package/dist/core/tools/ls.d.ts.map +1 -1
  15. package/dist/core/tools/ls.js +5 -7
  16. package/dist/core/tools/ls.js.map +1 -1
  17. package/dist/core/tools/read.d.ts.map +1 -1
  18. package/dist/core/tools/read.js +6 -7
  19. package/dist/core/tools/read.js.map +1 -1
  20. package/dist/core/tools/render-utils.d.ts +5 -2
  21. package/dist/core/tools/render-utils.d.ts.map +1 -1
  22. package/dist/core/tools/render-utils.js +17 -1
  23. package/dist/core/tools/render-utils.js.map +1 -1
  24. package/dist/core/tools/write.d.ts.map +1 -1
  25. package/dist/core/tools/write.js +5 -6
  26. package/dist/core/tools/write.js.map +1 -1
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +2 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/main.d.ts.map +1 -1
  32. package/dist/main.js +8 -0
  33. package/dist/main.js.map +1 -1
  34. package/dist/modes/interactive/interactive-mode.d.ts +3 -0
  35. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  36. package/dist/modes/interactive/interactive-mode.js +34 -0
  37. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  38. package/docs/quickstart.md +1 -0
  39. package/docs/rpc.md +2 -1
  40. package/docs/session-format.md +1 -1
  41. package/docs/sessions.md +8 -0
  42. package/docs/settings.md +1 -1
  43. package/docs/terminal-setup.md +2 -0
  44. package/docs/tui.md +2 -2
  45. package/docs/usage.md +5 -0
  46. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  47. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  48. package/examples/extensions/custom-provider-gitlab-duo/index.ts +53 -2
  49. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  50. package/examples/extensions/sandbox/package-lock.json +2 -2
  51. package/examples/extensions/sandbox/package.json +1 -1
  52. package/examples/extensions/with-deps/package-lock.json +2 -2
  53. package/examples/extensions/with-deps/package.json +1 -1
  54. package/npm-shrinkwrap.json +12 -12
  55. package/package.json +4 -4
@@ -8,6 +8,7 @@ import * as os from "node:os";
8
8
  import * as path from "node:path";
9
9
  import { getProviders, } from "@earendil-works/pi-ai";
10
10
  import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Loader, Markdown, matchesKey, ProcessTerminal, Spacer, setKeybindings, Text, TruncatedText, TUI, visibleWidth, } from "@earendil-works/pi-tui";
11
+ import chalk from "chalk";
11
12
  import { spawn, spawnSync } from "child_process";
12
13
  import { APP_NAME, APP_TITLE, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, getShareViewerUrl, VERSION, } from "../../config.js";
13
14
  import { parseSkillBlock } from "../../core/agent-session.js";
@@ -91,6 +92,27 @@ function isAnthropicSubscriptionAuthKey(apiKey) {
91
92
  function isUnknownModel(model) {
92
93
  return !!model && model.provider === "unknown" && model.id === "unknown" && model.api === "unknown";
93
94
  }
95
+ function quoteIfNeeded(value) {
96
+ if (value.length > 0 && !/[^a-zA-Z0-9_\-./~:@]/.test(value)) {
97
+ return value;
98
+ }
99
+ return `'${value.replace(/'/g, `'\\''`)}'`;
100
+ }
101
+ export function formatResumeCommand(sessionManager) {
102
+ if (!process.stdout.isTTY)
103
+ return undefined;
104
+ if (!sessionManager.isPersisted())
105
+ return undefined;
106
+ const sessionFile = sessionManager.getSessionFile();
107
+ if (!sessionFile || !fs.existsSync(sessionFile))
108
+ return undefined;
109
+ const args = [APP_NAME];
110
+ if (!sessionManager.usesDefaultSessionDir()) {
111
+ args.push("--session-dir", quoteIfNeeded(sessionManager.getSessionDir()));
112
+ }
113
+ args.push("--session", sessionManager.getSessionId());
114
+ return args.join(" ");
115
+ }
94
116
  function hasDefaultModelProvider(providerId) {
95
117
  return providerId in defaultModelPerProvider;
96
118
  }
@@ -125,6 +147,7 @@ export class InteractiveMode {
125
147
  version;
126
148
  isInitialized = false;
127
149
  onInputCallback;
150
+ pendingUserInputs = [];
128
151
  loadingAnimation = undefined;
129
152
  workingMessage = undefined;
130
153
  workingVisible = true;
@@ -2130,6 +2153,9 @@ export class InteractiveMode {
2130
2153
  if (this.onInputCallback) {
2131
2154
  this.onInputCallback(text);
2132
2155
  }
2156
+ else {
2157
+ this.pendingUserInputs.push(text);
2158
+ }
2133
2159
  this.editor.addToHistory?.(text);
2134
2160
  };
2135
2161
  }
@@ -2608,6 +2634,10 @@ export class InteractiveMode {
2608
2634
  }
2609
2635
  }
2610
2636
  async getUserInput() {
2637
+ const queuedInput = this.pendingUserInputs.shift();
2638
+ if (queuedInput !== undefined) {
2639
+ return queuedInput;
2640
+ }
2611
2641
  return new Promise((resolve) => {
2612
2642
  this.onInputCallback = (text) => {
2613
2643
  this.onInputCallback = undefined;
@@ -2669,6 +2699,10 @@ export class InteractiveMode {
2669
2699
  await this.ui.terminal.drainInput(1000);
2670
2700
  this.stop();
2671
2701
  await this.runtimeHost.dispose();
2702
+ const resumeCommand = formatResumeCommand(this.sessionManager);
2703
+ if (resumeCommand) {
2704
+ process.stdout.write(`${chalk.dim("To resume this session:")} ${resumeCommand}\n`);
2705
+ }
2672
2706
  process.exit(0);
2673
2707
  }
2674
2708
  emergencyTerminalExit() {