@mariozechner/pi-coding-agent 0.12.3 → 0.12.5

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 (54) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/README.md +38 -1
  3. package/dist/changelog.d.ts +1 -1
  4. package/dist/changelog.d.ts.map +1 -1
  5. package/dist/changelog.js +1 -1
  6. package/dist/changelog.js.map +1 -1
  7. package/dist/config.d.ts +48 -0
  8. package/dist/config.d.ts.map +1 -0
  9. package/dist/config.js +109 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/export-html.d.ts.map +1 -1
  12. package/dist/export-html.js +1 -4
  13. package/dist/export-html.js.map +1 -1
  14. package/dist/main.d.ts.map +1 -1
  15. package/dist/main.js +23 -27
  16. package/dist/main.js.map +1 -1
  17. package/dist/model-config.d.ts.map +1 -1
  18. package/dist/model-config.js +3 -4
  19. package/dist/model-config.js.map +1 -1
  20. package/dist/oauth/storage.d.ts.map +1 -1
  21. package/dist/oauth/storage.js +4 -12
  22. package/dist/oauth/storage.js.map +1 -1
  23. package/dist/session-manager.d.ts +2 -2
  24. package/dist/session-manager.d.ts.map +1 -1
  25. package/dist/session-manager.js +2 -2
  26. package/dist/session-manager.js.map +1 -1
  27. package/dist/settings-manager.d.ts.map +1 -1
  28. package/dist/settings-manager.js +2 -2
  29. package/dist/settings-manager.js.map +1 -1
  30. package/dist/slash-commands.d.ts +2 -2
  31. package/dist/slash-commands.d.ts.map +1 -1
  32. package/dist/slash-commands.js +7 -8
  33. package/dist/slash-commands.js.map +1 -1
  34. package/dist/theme/theme.d.ts.map +1 -1
  35. package/dist/theme/theme.js +11 -15
  36. package/dist/theme/theme.js.map +1 -1
  37. package/dist/tools-manager.d.ts.map +1 -1
  38. package/dist/tools-manager.js +3 -2
  39. package/dist/tools-manager.js.map +1 -1
  40. package/dist/tui/model-selector.d.ts.map +1 -1
  41. package/dist/tui/model-selector.js +1 -1
  42. package/dist/tui/model-selector.js.map +1 -1
  43. package/dist/tui/tool-execution.d.ts.map +1 -1
  44. package/dist/tui/tool-execution.js +3 -2
  45. package/dist/tui/tool-execution.js.map +1 -1
  46. package/dist/tui/tui-renderer.d.ts +1 -0
  47. package/dist/tui/tui-renderer.d.ts.map +1 -1
  48. package/dist/tui/tui-renderer.js +40 -6
  49. package/dist/tui/tui-renderer.js.map +1 -1
  50. package/package.json +8 -4
  51. package/dist/paths.d.ts +0 -32
  52. package/dist/paths.d.ts.map +0 -1
  53. package/dist/paths.js +0 -60
  54. package/dist/paths.js.map +0 -1
@@ -1,6 +1,9 @@
1
- import { CombinedAutocompleteProvider, Container, Input, Loader, Markdown, ProcessTerminal, Spacer, Text, TruncatedText, TUI, } from "@mariozechner/pi-tui";
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { CombinedAutocompleteProvider, Container, Input, Loader, Markdown, ProcessTerminal, Spacer, Text, TruncatedText, TUI, visibleWidth, } from "@mariozechner/pi-tui";
2
4
  import { exec } from "child_process";
3
5
  import { getChangelogPath, parseChangelog } from "../changelog.js";
6
+ import { APP_NAME, getDebugLogPath, getModelsPath, getOAuthPath } from "../config.js";
4
7
  import { exportSessionToHtml } from "../export-html.js";
5
8
  import { getApiKeyForModel, getAvailableModels, invalidateOAuthCache } from "../model-config.js";
6
9
  import { listOAuthProviders, login, logout } from "../oauth/index.js";
@@ -156,7 +159,7 @@ export class TuiRenderer {
156
159
  if (this.isInitialized)
157
160
  return;
158
161
  // Add header with logo and instructions
159
- const logo = theme.bold(theme.fg("accent", "pi")) + theme.fg("dim", ` v${this.version}`);
162
+ const logo = theme.bold(theme.fg("accent", APP_NAME)) + theme.fg("dim", ` v${this.version}`);
160
163
  const instructions = theme.fg("dim", "esc") +
161
164
  theme.fg("muted", " to interrupt") +
162
165
  "\n" +
@@ -319,6 +322,12 @@ export class TuiRenderer {
319
322
  this.editor.setText("");
320
323
  return;
321
324
  }
325
+ // Check for /debug command
326
+ if (text === "/debug") {
327
+ this.handleDebugCommand();
328
+ this.editor.setText("");
329
+ return;
330
+ }
322
331
  // Check for file-based slash commands
323
332
  text = expandSlashCommand(text, this.fileCommands);
324
333
  // Normal message submission - validate model and API key first
@@ -326,7 +335,7 @@ export class TuiRenderer {
326
335
  if (!currentModel) {
327
336
  this.showError("No model selected.\n\n" +
328
337
  "Set an API key (ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.)\n" +
329
- "or create ~/.pi/agent/models.json\n\n" +
338
+ `or create ${getModelsPath()}\n\n` +
330
339
  "Then use /model to select a model.");
331
340
  return;
332
341
  }
@@ -334,7 +343,7 @@ export class TuiRenderer {
334
343
  const apiKey = await getApiKeyForModel(currentModel);
335
344
  if (!apiKey) {
336
345
  this.showError(`No API key found for ${currentModel.provider}.\n\n` +
337
- `Set the appropriate environment variable or update ~/.pi/agent/models.json`);
346
+ `Set the appropriate environment variable or update ${getModelsPath()}`);
338
347
  this.editor.setText(text);
339
348
  return;
340
349
  }
@@ -1056,7 +1065,7 @@ export class TuiRenderer {
1056
1065
  invalidateOAuthCache();
1057
1066
  this.chatContainer.addChild(new Spacer(1));
1058
1067
  this.chatContainer.addChild(new Text(theme.fg("success", `✓ Successfully logged in to ${providerId}`), 1, 0));
1059
- this.chatContainer.addChild(new Text(theme.fg("dim", `Tokens saved to ~/.pi/agent/oauth.json`), 1, 0));
1068
+ this.chatContainer.addChild(new Text(theme.fg("dim", `Tokens saved to ${getOAuthPath()}`), 1, 0));
1060
1069
  this.ui.requestRender();
1061
1070
  }
1062
1071
  catch (error) {
@@ -1071,7 +1080,7 @@ export class TuiRenderer {
1071
1080
  invalidateOAuthCache();
1072
1081
  this.chatContainer.addChild(new Spacer(1));
1073
1082
  this.chatContainer.addChild(new Text(theme.fg("success", `✓ Successfully logged out of ${providerId}`), 1, 0));
1074
- this.chatContainer.addChild(new Text(theme.fg("dim", `Credentials removed from ~/.pi/agent/oauth.json`), 1, 0));
1083
+ this.chatContainer.addChild(new Text(theme.fg("dim", `Credentials removed from ${getOAuthPath()}`), 1, 0));
1075
1084
  this.ui.requestRender();
1076
1085
  }
1077
1086
  catch (error) {
@@ -1226,6 +1235,31 @@ export class TuiRenderer {
1226
1235
  this.chatContainer.addChild(new Text(theme.fg("accent", "✓ Context cleared") + "\n" + theme.fg("muted", "Started fresh session"), 1, 1));
1227
1236
  this.ui.requestRender();
1228
1237
  }
1238
+ handleDebugCommand() {
1239
+ // Force a render and capture all lines with their widths
1240
+ const width = this.ui.terminal.columns;
1241
+ const allLines = this.ui.render(width);
1242
+ const debugLogPath = getDebugLogPath();
1243
+ const debugData = [
1244
+ `Debug output at ${new Date().toISOString()}`,
1245
+ `Terminal width: ${width}`,
1246
+ `Total lines: ${allLines.length}`,
1247
+ "",
1248
+ "=== All rendered lines with visible widths ===",
1249
+ ...allLines.map((line, idx) => {
1250
+ const vw = visibleWidth(line);
1251
+ const escaped = JSON.stringify(line);
1252
+ return `[${idx}] (w=${vw}) ${escaped}`;
1253
+ }),
1254
+ "",
1255
+ ].join("\n");
1256
+ fs.mkdirSync(path.dirname(debugLogPath), { recursive: true });
1257
+ fs.writeFileSync(debugLogPath, debugData);
1258
+ // Show confirmation
1259
+ this.chatContainer.addChild(new Spacer(1));
1260
+ this.chatContainer.addChild(new Text(theme.fg("accent", "✓ Debug log written") + "\n" + theme.fg("muted", debugLogPath), 1, 1));
1261
+ this.ui.requestRender();
1262
+ }
1229
1263
  updatePendingMessagesDisplay() {
1230
1264
  this.pendingMessagesContainer.clear();
1231
1265
  if (this.queuedMessages.length > 0) {