@kingingwang/pi-darwin-arm64 0.86.1 → 0.87.1

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 (60) hide show
  1. package/bin/CHANGELOG.md +62 -0
  2. package/bin/README.md +25 -675
  3. package/bin/docs/cli-integration.md +106 -0
  4. package/bin/docs/cli.md +268 -0
  5. package/bin/docs/compaction.md +45 -26
  6. package/bin/docs/configuration.md +45 -0
  7. package/bin/docs/containerization.md +109 -82
  8. package/bin/docs/custom-provider.md +132 -784
  9. package/bin/docs/docs.json +139 -99
  10. package/bin/docs/environment-variables.md +3 -5
  11. package/bin/docs/extensions.md +134 -2956
  12. package/bin/docs/how-pi-works.md +49 -0
  13. package/bin/docs/images/interactive-mode.png +0 -0
  14. package/bin/docs/index.md +24 -69
  15. package/bin/docs/json.md +193 -65
  16. package/bin/docs/keybindings.md +57 -102
  17. package/bin/docs/llama-cpp.md +3 -3
  18. package/bin/docs/message-types.md +261 -0
  19. package/bin/docs/models.md +64 -546
  20. package/bin/docs/packages.md +66 -167
  21. package/bin/docs/prompt-templates.md +31 -68
  22. package/bin/docs/providers.md +102 -240
  23. package/bin/docs/quickstart.md +61 -106
  24. package/bin/docs/rpc-commands.md +854 -0
  25. package/bin/docs/rpc-extension-ui.md +200 -0
  26. package/bin/docs/rpc.md +129 -1556
  27. package/bin/docs/sdk.md +76 -1160
  28. package/bin/docs/security.md +70 -32
  29. package/bin/docs/session-format.md +25 -216
  30. package/bin/docs/sessions.md +35 -141
  31. package/bin/docs/settings.md +109 -386
  32. package/bin/docs/shell-aliases.md +85 -5
  33. package/bin/docs/skills.md +51 -190
  34. package/bin/docs/slash-commands.md +60 -0
  35. package/bin/docs/terminal-setup.md +105 -78
  36. package/bin/docs/termux.md +74 -83
  37. package/bin/docs/themes.md +68 -280
  38. package/bin/docs/tmux.md +31 -39
  39. package/bin/docs/tui.md +69 -923
  40. package/bin/docs/usage.md +54 -272
  41. package/bin/docs/windows.md +43 -17
  42. package/bin/examples/README.md +13 -2
  43. package/bin/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  44. package/bin/examples/extensions/custom-provider-anthropic/package.json +1 -1
  45. package/bin/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  46. package/bin/examples/extensions/gondolin/package-lock.json +2 -2
  47. package/bin/examples/extensions/gondolin/package.json +1 -1
  48. package/bin/examples/extensions/sandbox/package-lock.json +2 -2
  49. package/bin/examples/extensions/sandbox/package.json +1 -1
  50. package/bin/examples/extensions/with-deps/package-lock.json +2 -2
  51. package/bin/examples/extensions/with-deps/package.json +1 -1
  52. package/bin/examples/plugins/pi-example-plugin/src/session.ts +3 -2
  53. package/bin/examples/rpc-client.ts +35 -0
  54. package/bin/examples/rpc-extension-ui.ts +25 -5
  55. package/bin/examples/sdk/README.md +1 -1
  56. package/bin/export-html/template.js +6 -1
  57. package/bin/package.json +8 -8
  58. package/bin/pi +2 -2
  59. package/package.json +1 -1
  60. package/bin/docs/development.md +0 -90
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Run one prompt through a Pi RPC child process.
3
+ *
4
+ * Build the coding-agent package first, then run:
5
+ * npx tsx examples/rpc-client.ts "Explain this repository"
6
+ */
7
+
8
+ import { dirname, join } from "node:path";
9
+ import { fileURLToPath } from "node:url";
10
+ import { RpcClient } from "@earendil-works/pi-coding-agent";
11
+
12
+ const exampleDirectory = dirname(fileURLToPath(import.meta.url));
13
+ const prompt = process.argv.slice(2).join(" ") || "Explain this repository in one paragraph.";
14
+
15
+ const client = new RpcClient({
16
+ cliPath: join(exampleDirectory, "../dist/cli.js"),
17
+ args: ["--no-session"],
18
+ });
19
+
20
+ const unsubscribe = client.onEvent((event) => {
21
+ if (event.type === "message_update" && event.assistantMessageEvent.type === "text_delta") {
22
+ process.stdout.write(event.assistantMessageEvent.delta);
23
+ } else if (event.type === "tool_execution_start") {
24
+ process.stderr.write(`\n[tool: ${event.toolName}]\n`);
25
+ }
26
+ });
27
+
28
+ try {
29
+ await client.start();
30
+ await client.promptAndWait(prompt);
31
+ process.stdout.write("\n");
32
+ } finally {
33
+ unsubscribe();
34
+ await client.stop();
35
+ }
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { spawn } from "node:child_process";
18
18
  import { dirname, join } from "node:path";
19
- import * as readline from "node:readline";
19
+ import { StringDecoder } from "node:string_decoder";
20
20
  import { fileURLToPath } from "node:url";
21
21
  import {
22
22
  type Component,
@@ -258,7 +258,7 @@ async function main() {
258
258
 
259
259
  const agent = spawn(
260
260
  "node",
261
- [cliPath, "--mode", "rpc", "--no-session", "--no-extension", "--extension", extensionPath],
261
+ [cliPath, "--mode", "rpc", "--no-session", "--no-extensions", "--extension", extensionPath],
262
262
  { stdio: ["pipe", "pipe", "pipe"] },
263
263
  );
264
264
 
@@ -518,9 +518,7 @@ async function main() {
518
518
 
519
519
  // -- Process agent stdout --
520
520
 
521
- const stdoutRl = readline.createInterface({ input: agent.stdout!, terminal: false });
522
-
523
- stdoutRl.on("line", (line) => {
521
+ function handleAgentLine(line: string): void {
524
522
  let data: Record<string, unknown>;
525
523
  try {
526
524
  data = JSON.parse(line);
@@ -583,6 +581,28 @@ async function main() {
583
581
  tui.requestRender();
584
582
  return;
585
583
  }
584
+ }
585
+
586
+ const stdoutDecoder = new StringDecoder("utf8");
587
+ let stdoutBuffer = "";
588
+
589
+ agent.stdout!.on("data", (chunk: Buffer) => {
590
+ stdoutBuffer += stdoutDecoder.write(chunk);
591
+ while (true) {
592
+ const newlineIndex = stdoutBuffer.indexOf("\n");
593
+ if (newlineIndex === -1) break;
594
+
595
+ const line = stdoutBuffer.slice(0, newlineIndex);
596
+ stdoutBuffer = stdoutBuffer.slice(newlineIndex + 1);
597
+ handleAgentLine(line.endsWith("\r") ? line.slice(0, -1) : line);
598
+ }
599
+ });
600
+
601
+ agent.stdout!.on("end", () => {
602
+ stdoutBuffer += stdoutDecoder.end();
603
+ if (stdoutBuffer.length > 0) {
604
+ handleAgentLine(stdoutBuffer.endsWith("\r") ? stdoutBuffer.slice(0, -1) : stdoutBuffer);
605
+ }
586
606
  });
587
607
 
588
608
  // -- User input --
@@ -15,7 +15,7 @@ The runtime example shows how to build a recreate function that closes over proc
15
15
  | `05-tools.ts` | Built-in tool allowlists |
16
16
  | `06-extensions.ts` | Logging, blocking, result modification |
17
17
  | `07-context-files.ts` | AGENTS.md context files |
18
- | `08-slash-commands.ts` | File-based slash commands |
18
+ | `08-prompt-templates.ts` | File-based prompt templates |
19
19
  | `09-api-keys-and-oauth.ts` | API key resolution, OAuth config |
20
20
  | `10-settings.ts` | Override compaction, retry, terminal settings |
21
21
  | `11-sessions.ts` | In-memory, persistent, continue, list sessions |
@@ -357,6 +357,9 @@
357
357
  case 'thinking_level_change':
358
358
  parts.push('thinking', entry.thinkingLevel);
359
359
  break;
360
+ case 'context_edit':
361
+ parts.push('context edit', entry.replacement === null ? 'omit' : 'replace', entry.targetId);
362
+ break;
360
363
  }
361
364
 
362
365
  return parts.join(' ').toLowerCase();
@@ -385,7 +388,7 @@
385
388
  }
386
389
 
387
390
  // Apply filter mode
388
- const isSettingsEntry = ['label', 'custom', 'model_change', 'thinking_level_change'].includes(entry.type);
391
+ const isSettingsEntry = ['label', 'custom', 'context_edit', 'model_change', 'thinking_level_change'].includes(entry.type);
389
392
  let passesFilter = true;
390
393
 
391
394
  switch (filterMode) {
@@ -696,6 +699,8 @@
696
699
  return labelHtml + `<span class="tree-muted">[model: ${escapeHtml(entry.modelId)}]</span>`;
697
700
  case 'thinking_level_change':
698
701
  return labelHtml + `<span class="tree-muted">[thinking: ${escapeHtml(entry.thinkingLevel)}]</span>`;
702
+ case 'context_edit':
703
+ return labelHtml + `<span class="tree-muted">[context ${entry.replacement === null ? 'omit' : 'replace'}: ${escapeHtml(entry.targetId)}]</span>`;
699
704
  default:
700
705
  return labelHtml + `<span class="tree-muted">[${escapeHtml(entry.type)}]</span>`;
701
706
  }
package/bin/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@earendil-works/pi-coding-agent",
3
- "version": "0.86.1",
3
+ "version": "0.87.1",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {
@@ -49,10 +49,10 @@
49
49
  "prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
50
50
  },
51
51
  "dependencies": {
52
- "@earendil-works/chord": "^0.86.1",
53
- "@earendil-works/pi-agent-core": "^0.86.1",
54
- "@earendil-works/pi-ai": "^0.86.1",
55
- "@earendil-works/pi-tui": "^0.86.1",
52
+ "@earendil-works/chord": "^0.87.1",
53
+ "@earendil-works/pi-agent-core": "^0.87.1",
54
+ "@earendil-works/pi-ai": "^0.87.1",
55
+ "@earendil-works/pi-tui": "^0.87.1",
56
56
  "@silvia-odwyer/photon-node": "0.3.4",
57
57
  "chalk": "6.0.0",
58
58
  "cross-spawn": "7.0.6",
@@ -73,9 +73,9 @@
73
73
  "protobufjs": "7.6.6"
74
74
  },
75
75
  "devDependencies": {
76
- "@earendil-works/pi-client": "^0.86.1",
77
- "@earendil-works/pi-protocol": "^0.86.1",
78
- "@earendil-works/pi-server": "^0.86.1",
76
+ "@earendil-works/pi-client": "^0.87.1",
77
+ "@earendil-works/pi-protocol": "^0.87.1",
78
+ "@earendil-works/pi-server": "^0.87.1",
79
79
  "@types/cross-spawn": "6.0.6",
80
80
  "@types/hosted-git-info": "3.0.5",
81
81
  "@types/node": "22.19.19",
package/bin/pi CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/bin/pi
3
- size: 75466850 bytes
4
- sha256: c7a62eb311c42f12782407049d3f9fda901f71c288baa1488971789d40e1ca81
3
+ size: 75664994 bytes
4
+ sha256: bd52af222345ddee0299cb5f989034365789c0fdf0e4771c0e92ca357bba7aff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingingwang/pi-darwin-arm64",
3
- "version": "0.86.1",
3
+ "version": "0.87.1",
4
4
  "description": "Pi standalone binary for darwin-arm64 (fork distribution)",
5
5
  "license": "MIT",
6
6
  "os": [
@@ -1,90 +0,0 @@
1
- # Development
2
-
3
- See [AGENTS.md](https://github.com/earendil-works/pi/blob/main/AGENTS.md) for additional guidelines.
4
-
5
- ## Setup
6
-
7
- ```bash
8
- git clone https://github.com/earendil-works/pi
9
- cd pi
10
- npm install
11
- npm run build
12
- ```
13
-
14
- Run from source:
15
-
16
- ```bash
17
- /path/to/pi/pi-test.sh
18
- ```
19
-
20
- The script can be run from any directory. Pi keeps the caller's current working directory.
21
-
22
- ### Experimental remote harness
23
-
24
- The remote harness server/client integration is development-only. Run it from the repository with:
25
-
26
- ```bash
27
- PI_EXPERIMENTAL=1 ./pi-test.sh server
28
- PI_EXPERIMENTAL=1 ./pi-test.sh client
29
- ```
30
-
31
- `PI_SERVER_DIR` overrides the server profile and socket directory (default: `~/.pi/server`). `PI_SERVER_ID` selects the logical server ID when `--server-id` is omitted.
32
-
33
- The `client` and `experimental/plugin` package subpaths resolve only under the `source` condition in a checkout. Their implementations and the server/client commands are excluded from npm packages and standalone binaries. `pi-client`, `pi-protocol`, and `pi-server` are development dependencies of coding-agent, not runtime dependencies. The local SDK and stdio RPC API are unchanged.
34
-
35
- ## Forking / Rebranding
36
-
37
- Configure via `package.json`:
38
-
39
- ```json
40
- {
41
- "piConfig": {
42
- "name": "pi",
43
- "configDir": ".pi"
44
- }
45
- }
46
- ```
47
-
48
- Change `name`, `configDir`, and `bin` field for your fork. Affects CLI banner, config paths, and environment variable names.
49
-
50
- ## Path Resolution
51
-
52
- Three execution modes: npm install, standalone binary, tsx from source.
53
-
54
- **Always use `src/config.ts`** for package assets:
55
-
56
- ```typescript
57
- import { getPackageDir, getThemeDir } from "./config.js";
58
- ```
59
-
60
- Never use `__dirname` directly for package assets.
61
-
62
- ## Debug Command
63
-
64
- `/debug` (hidden) writes to `~/.pi/agent/pi-debug.log`:
65
- - Rendered TUI lines with ANSI codes
66
- - Last messages sent to the LLM
67
-
68
- ## Testing
69
-
70
- ```bash
71
- ./test.sh # Run non-LLM tests (no API keys needed)
72
- npm test # Run all tests
73
- npm test -- test/specific.test.ts # Run specific test
74
- ```
75
-
76
- ### Published package smoke test
77
-
78
- After building, run `npm run check:package-install`. It packs the public packages and installs only coding-agent as a direct dependency in a temporary directory outside the repository. Local tarball overrides select declared transitive dependencies without installing development-only packages. The check verifies SDK imports and CLI startup without credentials or model requests.
79
-
80
- `npm run check` also checks runtime dependency declarations and rejects excluded development sources pulled into a package's build through imports.
81
-
82
- ## Project Structure
83
-
84
- ```
85
- packages/
86
- ai/ # LLM provider abstraction
87
- agent/ # Agent loop and message types
88
- tui/ # Terminal UI components
89
- coding-agent/ # CLI and interactive mode
90
- ```