@mariozechner/pi-coding-agent 0.52.11 → 0.53.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 (42) hide show
  1. package/CHANGELOG.md +33 -1
  2. package/README.md +3 -3
  3. package/dist/core/auth-storage.d.ts +34 -7
  4. package/dist/core/auth-storage.d.ts.map +1 -1
  5. package/dist/core/auth-storage.js +189 -93
  6. package/dist/core/auth-storage.js.map +1 -1
  7. package/dist/core/sdk.d.ts +1 -1
  8. package/dist/core/sdk.d.ts.map +1 -1
  9. package/dist/core/sdk.js +2 -1
  10. package/dist/core/sdk.js.map +1 -1
  11. package/dist/core/settings-manager.d.ts +45 -7
  12. package/dist/core/settings-manager.d.ts.map +1 -1
  13. package/dist/core/settings-manager.js +227 -134
  14. package/dist/core/settings-manager.js.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/main.d.ts.map +1 -1
  20. package/dist/main.js +13 -1
  21. package/dist/main.js.map +1 -1
  22. package/dist/modes/interactive/components/settings-selector.d.ts +3 -0
  23. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  24. package/dist/modes/interactive/components/settings-selector.js +10 -0
  25. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  26. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  27. package/dist/modes/interactive/interactive-mode.js +5 -0
  28. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  29. package/docs/sdk.md +12 -5
  30. package/docs/settings.md +3 -1
  31. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  32. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  33. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  34. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  35. package/examples/extensions/with-deps/package-lock.json +2 -2
  36. package/examples/extensions/with-deps/package.json +1 -1
  37. package/examples/sdk/02-custom-model.ts +1 -1
  38. package/examples/sdk/09-api-keys-and-oauth.ts +2 -2
  39. package/examples/sdk/10-settings.ts +13 -0
  40. package/examples/sdk/12-full-control.ts +1 -1
  41. package/examples/sdk/README.md +3 -3
  42. package/package.json +4 -4
package/docs/sdk.md CHANGED
@@ -19,7 +19,7 @@ See [examples/sdk/](../examples/sdk/) for working examples from minimal to full
19
19
  import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@mariozechner/pi-coding-agent";
20
20
 
21
21
  // Set up credential storage and model registry
22
- const authStorage = new AuthStorage();
22
+ const authStorage = AuthStorage.create();
23
23
  const modelRegistry = new ModelRegistry(authStorage);
24
24
 
25
25
  const { session } = await createAgentSession({
@@ -281,7 +281,7 @@ When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control
281
281
  import { getModel } from "@mariozechner/pi-ai";
282
282
  import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
283
283
 
284
- const authStorage = new AuthStorage();
284
+ const authStorage = AuthStorage.create();
285
285
  const modelRegistry = new ModelRegistry(authStorage);
286
286
 
287
287
  // Find specific built-in model (doesn't check if API key exists)
@@ -329,7 +329,7 @@ API key resolution priority (handled by AuthStorage):
329
329
  import { AuthStorage, ModelRegistry } from "@mariozechner/pi-coding-agent";
330
330
 
331
331
  // Default: uses ~/.pi/agent/auth.json and ~/.pi/agent/models.json
332
- const authStorage = new AuthStorage();
332
+ const authStorage = AuthStorage.create();
333
333
  const modelRegistry = new ModelRegistry(authStorage);
334
334
 
335
335
  const { session } = await createAgentSession({
@@ -342,7 +342,7 @@ const { session } = await createAgentSession({
342
342
  authStorage.setRuntimeApiKey("anthropic", "sk-my-temp-key");
343
343
 
344
344
  // Custom auth storage location
345
- const customAuth = new AuthStorage("/my/app/auth.json");
345
+ const customAuth = AuthStorage.create("/my/app/auth.json");
346
346
  const customRegistry = new ModelRegistry(customAuth, "/my/app/models.json");
347
347
 
348
348
  const { session } = await createAgentSession({
@@ -700,6 +700,13 @@ Settings load from two locations and merge:
700
700
 
701
701
  Project overrides global. Nested objects merge keys. Setters modify global settings by default.
702
702
 
703
+ **Persistence and error handling semantics:**
704
+
705
+ - Settings getters/setters are synchronous for in-memory state.
706
+ - Setters enqueue persistence writes asynchronously.
707
+ - Call `await settingsManager.flush()` when you need a durability boundary (for example, before process exit or before asserting file contents in tests).
708
+ - `SettingsManager` does not print settings I/O errors. Use `settingsManager.drainErrors()` and report them in your app layer.
709
+
703
710
  > See [examples/sdk/10-settings.ts](../examples/sdk/10-settings.ts)
704
711
 
705
712
  ## ResourceLoader
@@ -766,7 +773,7 @@ import {
766
773
  } from "@mariozechner/pi-coding-agent";
767
774
 
768
775
  // Set up auth storage (custom location)
769
- const authStorage = new AuthStorage("/custom/agent/auth.json");
776
+ const authStorage = AuthStorage.create("/custom/agent/auth.json");
770
777
 
771
778
  // Runtime API key override (not persisted)
772
779
  if (process.env.MY_KEY) {
package/docs/settings.md CHANGED
@@ -41,7 +41,7 @@ Edit directly or use `/settings` for common options.
41
41
  | `theme` | string | `"dark"` | Theme name (`"dark"`, `"light"`, or custom) |
42
42
  | `quietStartup` | boolean | `false` | Hide startup header |
43
43
  | `collapseChangelog` | boolean | `false` | Show condensed changelog after updates |
44
- | `doubleEscapeAction` | string | `"tree"` | Action for double-escape: `"tree"` or `"fork"` |
44
+ | `doubleEscapeAction` | string | `"tree"` | Action for double-escape: `"tree"`, `"fork"`, or `"none"` |
45
45
  | `editorPaddingX` | number | `0` | Horizontal padding for input editor (0-3) |
46
46
  | `autocompleteMaxVisible` | number | `5` | Max visible items in autocomplete dropdown (3-20) |
47
47
  | `showHardwareCursor` | boolean | `false` | Show terminal cursor |
@@ -98,12 +98,14 @@ When a provider requests a retry delay longer than `maxDelayMs` (e.g., Google's
98
98
  |---------|------|---------|-------------|
99
99
  | `steeringMode` | string | `"one-at-a-time"` | How steering messages are sent: `"all"` or `"one-at-a-time"` |
100
100
  | `followUpMode` | string | `"one-at-a-time"` | How follow-up messages are sent: `"all"` or `"one-at-a-time"` |
101
+ | `transport` | string | `"sse"` | Preferred transport for providers that support multiple transports: `"sse"`, `"websocket"`, or `"auto"` |
101
102
 
102
103
  ### Terminal & Images
103
104
 
104
105
  | Setting | Type | Default | Description |
105
106
  |---------|------|---------|-------------|
106
107
  | `terminal.showImages` | boolean | `true` | Show images in terminal (if supported) |
108
+ | `terminal.clearOnShrink` | boolean | `false` | Clear empty rows when content shrinks (can cause flicker) |
107
109
  | `images.autoResize` | boolean | `true` | Resize images to 2000x2000 max |
108
110
  | `images.blockImages` | boolean | `false` | Block all images from being sent to LLM |
109
111
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-custom-provider",
3
- "version": "1.3.11",
3
+ "version": "1.4.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-custom-provider",
9
- "version": "1.3.11",
9
+ "version": "1.4.0",
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.3.11",
4
+ "version": "1.4.0",
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.3.11",
4
+ "version": "1.4.0",
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.2.11",
4
+ "version": "1.3.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pi-extension-with-deps",
3
- "version": "1.16.11",
3
+ "version": "1.17.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pi-extension-with-deps",
9
- "version": "1.16.11",
9
+ "version": "1.17.0",
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.16.11",
4
+ "version": "1.17.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "clean": "echo 'nothing to clean'",
@@ -8,7 +8,7 @@ import { getModel } from "@mariozechner/pi-ai";
8
8
  import { AuthStorage, createAgentSession, ModelRegistry } from "@mariozechner/pi-coding-agent";
9
9
 
10
10
  // Set up auth storage and model registry
11
- const authStorage = new AuthStorage();
11
+ const authStorage = AuthStorage.create();
12
12
  const modelRegistry = new ModelRegistry(authStorage);
13
13
 
14
14
  // Option 1: Find a specific built-in model by provider/id
@@ -8,7 +8,7 @@ import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "
8
8
 
9
9
  // Default: AuthStorage uses ~/.pi/agent/auth.json
10
10
  // ModelRegistry loads built-in + custom models from ~/.pi/agent/models.json
11
- const authStorage = new AuthStorage();
11
+ const authStorage = AuthStorage.create();
12
12
  const modelRegistry = new ModelRegistry(authStorage);
13
13
 
14
14
  await createAgentSession({
@@ -19,7 +19,7 @@ await createAgentSession({
19
19
  console.log("Session with default auth storage and model registry");
20
20
 
21
21
  // Custom auth storage location
22
- const customAuthStorage = new AuthStorage("/tmp/my-app/auth.json");
22
+ const customAuthStorage = AuthStorage.create("/tmp/my-app/auth.json");
23
23
  const customModelRegistry = new ModelRegistry(customAuthStorage, "/tmp/my-app/models.json");
24
24
 
25
25
  await createAgentSession({
@@ -24,6 +24,19 @@ await createAgentSession({
24
24
 
25
25
  console.log("Session created with custom settings");
26
26
 
27
+ // Setters update memory immediately and queue persistence writes.
28
+ // Call flush() when you need a durability boundary.
29
+ settingsManager.setDefaultThinkingLevel("low");
30
+ await settingsManager.flush();
31
+
32
+ // Surface settings I/O errors at the app layer.
33
+ const settingsErrors = settingsManager.drainErrors();
34
+ if (settingsErrors.length > 0) {
35
+ for (const { scope, error } of settingsErrors) {
36
+ console.warn(`Warning (${scope} settings): ${error.message}`);
37
+ }
38
+ }
39
+
27
40
  // For testing without file I/O:
28
41
  const inMemorySettings = SettingsManager.inMemory({
29
42
  compaction: { enabled: false },
@@ -22,7 +22,7 @@ import {
22
22
  } from "@mariozechner/pi-coding-agent";
23
23
 
24
24
  // Custom auth storage location
25
- const authStorage = new AuthStorage("/tmp/my-agent/auth.json");
25
+ const authStorage = AuthStorage.create("/tmp/my-agent/auth.json");
26
26
 
27
27
  // Runtime API key override (not persisted)
28
28
  if (process.env.MY_ANTHROPIC_KEY) {
@@ -43,7 +43,7 @@ import {
43
43
  } from "@mariozechner/pi-coding-agent";
44
44
 
45
45
  // Auth and models setup
46
- const authStorage = new AuthStorage();
46
+ const authStorage = AuthStorage.create();
47
47
  const modelRegistry = new ModelRegistry(authStorage);
48
48
 
49
49
  // Minimal
@@ -71,7 +71,7 @@ const { session } = await createAgentSession({
71
71
  });
72
72
 
73
73
  // Full control
74
- const customAuth = new AuthStorage("/my/app/auth.json");
74
+ const customAuth = AuthStorage.create("/my/app/auth.json");
75
75
  customAuth.setRuntimeApiKey("anthropic", process.env.MY_KEY!);
76
76
  const customRegistry = new ModelRegistry(customAuth);
77
77
 
@@ -108,7 +108,7 @@ await session.prompt("Hello");
108
108
 
109
109
  | Option | Default | Description |
110
110
  |--------|---------|-------------|
111
- | `authStorage` | `new AuthStorage()` | Credential storage |
111
+ | `authStorage` | `AuthStorage.create()` | Credential storage |
112
112
  | `modelRegistry` | `new ModelRegistry(authStorage)` | Model registry |
113
113
  | `cwd` | `process.cwd()` | Working directory |
114
114
  | `agentDir` | `~/.pi/agent` | Config directory |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mariozechner/pi-coding-agent",
3
- "version": "0.52.11",
3
+ "version": "0.53.0",
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.52.11",
44
- "@mariozechner/pi-ai": "^0.52.11",
45
- "@mariozechner/pi-tui": "^0.52.11",
43
+ "@mariozechner/pi-agent-core": "^0.53.0",
44
+ "@mariozechner/pi-ai": "^0.53.0",
45
+ "@mariozechner/pi-tui": "^0.53.0",
46
46
  "@silvia-odwyer/photon-node": "^0.3.4",
47
47
  "chalk": "^5.5.0",
48
48
  "cli-highlight": "^2.1.11",