@mariozechner/pi-coding-agent 0.51.2 → 0.51.4

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 (63) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +5 -0
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +1 -1
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/config.d.ts.map +1 -1
  7. package/dist/config.js +1 -1
  8. package/dist/config.js.map +1 -1
  9. package/dist/core/agent-session.d.ts.map +1 -1
  10. package/dist/core/agent-session.js +49 -2
  11. package/dist/core/agent-session.js.map +1 -1
  12. package/dist/core/extensions/index.d.ts +2 -1
  13. package/dist/core/extensions/index.d.ts.map +1 -1
  14. package/dist/core/extensions/index.js.map +1 -1
  15. package/dist/core/extensions/loader.d.ts.map +1 -1
  16. package/dist/core/extensions/loader.js +4 -0
  17. package/dist/core/extensions/loader.js.map +1 -1
  18. package/dist/core/extensions/runner.d.ts.map +1 -1
  19. package/dist/core/extensions/runner.js +1 -0
  20. package/dist/core/extensions/runner.js.map +1 -1
  21. package/dist/core/extensions/types.d.ts +5 -0
  22. package/dist/core/extensions/types.d.ts.map +1 -1
  23. package/dist/core/extensions/types.js.map +1 -1
  24. package/dist/core/package-manager.d.ts +2 -0
  25. package/dist/core/package-manager.d.ts.map +1 -1
  26. package/dist/core/package-manager.js +43 -11
  27. package/dist/core/package-manager.js.map +1 -1
  28. package/dist/core/sdk.d.ts +1 -1
  29. package/dist/core/sdk.d.ts.map +1 -1
  30. package/dist/core/sdk.js +7 -1
  31. package/dist/core/sdk.js.map +1 -1
  32. package/dist/core/slash-commands.d.ts +15 -0
  33. package/dist/core/slash-commands.d.ts.map +1 -0
  34. package/dist/core/slash-commands.js +21 -0
  35. package/dist/core/slash-commands.js.map +1 -0
  36. package/dist/index.d.ts +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/main.d.ts.map +1 -1
  40. package/dist/main.js +60 -12
  41. package/dist/main.js.map +1 -1
  42. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  43. package/dist/modes/interactive/interactive-mode.js +31 -46
  44. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  45. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  46. package/dist/modes/rpc/rpc-mode.js +1 -1
  47. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  48. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  49. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  50. package/dist/modes/rpc/rpc-types.js.map +1 -1
  51. package/docs/extensions.md +25 -0
  52. package/docs/images/exy.png +0 -0
  53. package/docs/packages.md +3 -1
  54. package/docs/rpc.md +2 -2
  55. package/examples/extensions/commands.ts +72 -0
  56. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  57. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  58. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  59. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  60. package/examples/extensions/notify.ts +41 -11
  61. package/examples/extensions/with-deps/package-lock.json +2 -2
  62. package/examples/extensions/with-deps/package.json +1 -1
  63. package/package.json +4 -4
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Commands Extension
3
+ *
4
+ * Demonstrates the pi.getCommands() API by providing a /commands command
5
+ * that lists all available slash commands in the current session.
6
+ *
7
+ * Usage:
8
+ * 1. Copy this file to ~/.pi/agent/extensions/ or your project's .pi/extensions/
9
+ * 2. Use /commands to see available commands
10
+ * 3. Use /commands extensions to filter by source
11
+ */
12
+
13
+ import type { ExtensionAPI, SlashCommandInfo } from "@mariozechner/pi-coding-agent";
14
+
15
+ export default function commandsExtension(pi: ExtensionAPI) {
16
+ pi.registerCommand("commands", {
17
+ description: "List available slash commands",
18
+ getArgumentCompletions: (prefix) => {
19
+ const sources = ["extension", "prompt", "skill"];
20
+ const filtered = sources.filter((s) => s.startsWith(prefix));
21
+ return filtered.length > 0 ? filtered.map((s) => ({ value: s, label: s })) : null;
22
+ },
23
+ handler: async (args, ctx) => {
24
+ const commands = pi.getCommands();
25
+ const sourceFilter = args.trim() as "extension" | "prompt" | "skill" | "";
26
+
27
+ // Filter by source if specified
28
+ const filtered = sourceFilter ? commands.filter((c) => c.source === sourceFilter) : commands;
29
+
30
+ if (filtered.length === 0) {
31
+ ctx.ui.notify(sourceFilter ? `No ${sourceFilter} commands found` : "No commands found", "info");
32
+ return;
33
+ }
34
+
35
+ // Build selection items grouped by source
36
+ const formatCommand = (cmd: SlashCommandInfo): string => {
37
+ const desc = cmd.description ? ` - ${cmd.description}` : "";
38
+ return `/${cmd.name}${desc}`;
39
+ };
40
+
41
+ const items: string[] = [];
42
+ const sources: Array<{ key: "extension" | "prompt" | "skill"; label: string }> = [
43
+ { key: "extension", label: "Extensions" },
44
+ { key: "prompt", label: "Prompts" },
45
+ { key: "skill", label: "Skills" },
46
+ ];
47
+
48
+ for (const { key, label } of sources) {
49
+ const cmds = filtered.filter((c) => c.source === key);
50
+ if (cmds.length > 0) {
51
+ items.push(`--- ${label} ---`);
52
+ items.push(...cmds.map(formatCommand));
53
+ }
54
+ }
55
+
56
+ // Show in a selector (user can scroll and see all commands)
57
+ const selected = await ctx.ui.select("Available Commands", items);
58
+
59
+ // If user selected a command (not a header), offer to show its path
60
+ if (selected && !selected.startsWith("---")) {
61
+ const cmdName = selected.split(" - ")[0].slice(1); // Remove leading /
62
+ const cmd = commands.find((c) => c.name === cmdName);
63
+ if (cmd?.path) {
64
+ const showPath = await ctx.ui.confirm(cmd.name, `View source path?\n${cmd.path}`);
65
+ if (showPath) {
66
+ ctx.ui.notify(cmd.path, "info");
67
+ }
68
+ }
69
+ }
70
+ },
71
+ });
72
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "1.2.2",
9
+ "version": "1.2.4",
10
10
  "dependencies": {
11
11
  "@anthropic-ai/sdk": "^0.52.0"
12
12
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-anthropic",
3
3
  "private": true,
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-gitlab-duo",
3
3
  "private": true,
4
- "version": "1.2.2",
4
+ "version": "1.2.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider-qwen-cli",
3
3
  "private": true,
4
- "version": "1.1.2",
4
+ "version": "1.1.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,23 +1,53 @@
1
1
  /**
2
- * Desktop Notification Extension
2
+ * Pi Notify Extension
3
3
  *
4
- * Sends a native desktop notification when the agent finishes and is waiting for input.
5
- * Uses OSC 777 escape sequence - no external dependencies.
6
- *
7
- * Supported terminals: Ghostty, iTerm2, WezTerm, rxvt-unicode
8
- * Not supported: Kitty (uses OSC 99), Terminal.app, Windows Terminal, Alacritty
4
+ * Sends a native terminal notification when Pi agent is done and waiting for input.
5
+ * Supports multiple terminal protocols:
6
+ * - OSC 777: Ghostty, iTerm2, WezTerm, rxvt-unicode
7
+ * - OSC 99: Kitty
8
+ * - Windows toast: Windows Terminal (WSL)
9
9
  */
10
10
 
11
11
  import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
12
12
 
13
- /**
14
- * Send a desktop notification via OSC 777 escape sequence.
15
- */
16
- function notify(title: string, body: string): void {
17
- // OSC 777 format: ESC ] 777 ; notify ; title ; body BEL
13
+ function windowsToastScript(title: string, body: string): string {
14
+ const type = "Windows.UI.Notifications";
15
+ const mgr = `[${type}.ToastNotificationManager, ${type}, ContentType = WindowsRuntime]`;
16
+ const template = `[${type}.ToastTemplateType]::ToastText01`;
17
+ const toast = `[${type}.ToastNotification]::new($xml)`;
18
+ return [
19
+ `${mgr} > $null`,
20
+ `$xml = [${type}.ToastNotificationManager]::GetTemplateContent(${template})`,
21
+ `$xml.GetElementsByTagName('text')[0].AppendChild($xml.CreateTextNode('${body}')) > $null`,
22
+ `[${type}.ToastNotificationManager]::CreateToastNotifier('${title}').Show(${toast})`,
23
+ ].join("; ");
24
+ }
25
+
26
+ function notifyOSC777(title: string, body: string): void {
18
27
  process.stdout.write(`\x1b]777;notify;${title};${body}\x07`);
19
28
  }
20
29
 
30
+ function notifyOSC99(title: string, body: string): void {
31
+ // Kitty OSC 99: i=notification id, d=0 means not done yet, p=body for second part
32
+ process.stdout.write(`\x1b]99;i=1:d=0;${title}\x1b\\`);
33
+ process.stdout.write(`\x1b]99;i=1:p=body;${body}\x1b\\`);
34
+ }
35
+
36
+ function notifyWindows(title: string, body: string): void {
37
+ const { execFile } = require("child_process");
38
+ execFile("powershell.exe", ["-NoProfile", "-Command", windowsToastScript(title, body)]);
39
+ }
40
+
41
+ function notify(title: string, body: string): void {
42
+ if (process.env.WT_SESSION) {
43
+ notifyWindows(title, body);
44
+ } else if (process.env.KITTY_WINDOW_ID) {
45
+ notifyOSC99(title, body);
46
+ } else {
47
+ notifyOSC777(title, body);
48
+ }
49
+ }
50
+
21
51
  export default function (pi: ExtensionAPI) {
22
52
  pi.on("agent_end", async () => {
23
53
  notify("Pi", "Ready for input");
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "1.15.2",
3
+ "version": "1.15.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "1.15.2",
9
+ "version": "1.15.4",
10
10
  "dependencies": {
11
11
  "ms": "^2.1.3"
12
12
  },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
3
  "private": true,
4
- "version": "1.15.2",
4
+ "version": "1.15.4",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mariozechner/pi-coding-agent",
3
- "version": "0.51.2",
3
+ "version": "0.51.4",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -40,9 +40,9 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@mariozechner/jiti": "^2.6.2",
43
- "@mariozechner/pi-agent-core": "^0.51.2",
44
- "@mariozechner/pi-ai": "^0.51.2",
45
- "@mariozechner/pi-tui": "^0.51.2",
43
+ "@mariozechner/pi-agent-core": "^0.51.4",
44
+ "@mariozechner/pi-ai": "^0.51.4",
45
+ "@mariozechner/pi-tui": "^0.51.4",
46
46
  "@silvia-odwyer/photon-node": "^0.3.4",
47
47
  "chalk": "^5.5.0",
48
48
  "cli-highlight": "^2.1.11",