@dyyz1993/pi-coding-agent 0.69.26 → 0.70.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.
- package/CHANGELOG.md +14 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +15 -10
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +48 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +3 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +62 -20
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +21 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/large-input.d.ts +8 -0
- package/dist/core/large-input.d.ts.map +1 -0
- package/dist/core/large-input.js +37 -0
- package/dist/core/large-input.js.map +1 -0
- package/dist/core/messages.d.ts +10 -0
- package/dist/core/messages.d.ts.map +1 -1
- package/dist/core/messages.js +20 -0
- package/dist/core/messages.js.map +1 -1
- package/dist/core/session-manager.d.ts +9 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +29 -2
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/storage.d.ts +34 -0
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/core/storage.js +63 -1
- package/dist/core/storage.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -0
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +31 -5
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/index.d.ts +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +1 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/truncate.d.ts +1 -0
- package/dist/core/tools/truncate.d.ts.map +1 -1
- package/dist/core/tools/truncate.js +1 -0
- package/dist/core/tools/truncate.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +13 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/extensions.md +100 -0
- package/package.json +7 -4
package/docs/extensions.md
CHANGED
|
@@ -1041,6 +1041,74 @@ pi.on("before_agent_start", (event, ctx) => {
|
|
|
1041
1041
|
});
|
|
1042
1042
|
```
|
|
1043
1043
|
|
|
1044
|
+
### Project & Storage Paths
|
|
1045
|
+
|
|
1046
|
+
Extensions can access standardized storage paths at different scopes through `ExtensionContext`. All paths are automatically created on first access and namespaced per extension to prevent conflicts.
|
|
1047
|
+
|
|
1048
|
+
#### `ctx.projectRoot`
|
|
1049
|
+
|
|
1050
|
+
```typescript
|
|
1051
|
+
projectRoot: string
|
|
1052
|
+
```
|
|
1053
|
+
|
|
1054
|
+
The canonical git root directory. If `cwd` is inside a git worktree, this resolves to the main repository root. If not a git repository, falls back to `cwd`.
|
|
1055
|
+
|
|
1056
|
+
```typescript
|
|
1057
|
+
// In a worktree at /Users/alice/projects/myapp-feature/
|
|
1058
|
+
ctx.cwd // "/Users/alice/projects/myapp-feature/"
|
|
1059
|
+
ctx.projectRoot // "/Users/alice/projects/myapp/" (main repo)
|
|
1060
|
+
|
|
1061
|
+
// Not a git repo
|
|
1062
|
+
ctx.cwd // "/Users/alice/my-folder/"
|
|
1063
|
+
ctx.projectRoot // "/Users/alice/my-folder/" (same as cwd)
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
#### `ctx.extensionName`
|
|
1067
|
+
|
|
1068
|
+
```typescript
|
|
1069
|
+
extensionName: string
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
The name of the current extension. Auto-derived from the extension's file/directory/package name, or overridden via `pi.setName()`.
|
|
1073
|
+
|
|
1074
|
+
```typescript
|
|
1075
|
+
// In an extension loaded from my-tool/index.ts
|
|
1076
|
+
ctx.extensionName // "my-tool"
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
#### Storage Paths
|
|
1080
|
+
|
|
1081
|
+
All storage paths include the extension name as the final path segment, providing automatic isolation between extensions:
|
|
1082
|
+
|
|
1083
|
+
| Property | Scope | Path Template | Lifecycle |
|
|
1084
|
+
|----------|-------|---------------|-----------|
|
|
1085
|
+
| `ctx.sessionDataDir` | Session | `~/.pi/agent/sessions/<project>/data/<sessionId>/<ext-name>/` | Per-session, can be cleaned up when session ends |
|
|
1086
|
+
| `ctx.cwdDataDir` | Working directory | `~/.pi/agent/cwd-data/<encoded-cwd>/<ext-name>/` | Per-cwd, isolated in worktrees |
|
|
1087
|
+
| `ctx.projectDataDir` | Project | `~/.pi/agent/project-data/<encoded-project>/<ext-name>/` | Per-project, shared across worktrees |
|
|
1088
|
+
| `ctx.globalDataDir` | Global | `~/.pi/agent/extensions-data/<ext-name>/` | Cross-project, persists forever |
|
|
1089
|
+
|
|
1090
|
+
```typescript
|
|
1091
|
+
// Example: Store per-session cache
|
|
1092
|
+
import { writeFileSync, readFileSync } from "node:fs";
|
|
1093
|
+
import { join } from "node:path";
|
|
1094
|
+
|
|
1095
|
+
const cacheFile = join(ctx.sessionDataDir, "cache.json");
|
|
1096
|
+
writeFileSync(cacheFile, JSON.stringify(data));
|
|
1097
|
+
|
|
1098
|
+
// Example: Share data across all sessions of a project
|
|
1099
|
+
const projectConfig = join(ctx.projectDataDir, "config.json");
|
|
1100
|
+
|
|
1101
|
+
// Example: Global extension settings shared across all projects
|
|
1102
|
+
const globalSettings = join(ctx.globalDataDir, "settings.json");
|
|
1103
|
+
```
|
|
1104
|
+
|
|
1105
|
+
**Choosing the right scope:**
|
|
1106
|
+
|
|
1107
|
+
- **Session**: Temporary data for a single conversation (e.g., conversation cache, working state)
|
|
1108
|
+
- **CWD**: Data tied to the current working directory, isolated in worktrees (e.g., build artifacts, local cache)
|
|
1109
|
+
- **Project**: Data shared across all worktrees of a project (e.g., project config, shared memory)
|
|
1110
|
+
- **Global**: Cross-project data (e.g., knowledge bases, shared settings, global caches)
|
|
1111
|
+
|
|
1044
1112
|
## ExtensionCommandContext
|
|
1045
1113
|
|
|
1046
1114
|
Command handlers receive `ExtensionCommandContext`, which extends `ExtensionContext` with session control methods. These are only available in commands because they can deadlock if called from event handlers.
|
|
@@ -1413,6 +1481,38 @@ if (name) {
|
|
|
1413
1481
|
}
|
|
1414
1482
|
```
|
|
1415
1483
|
|
|
1484
|
+
### pi.setName(name)
|
|
1485
|
+
|
|
1486
|
+
```typescript
|
|
1487
|
+
setName(name: string): void
|
|
1488
|
+
```
|
|
1489
|
+
|
|
1490
|
+
Override the auto-derived extension name. Must be called before any event handlers are registered. Extension names must be unique — duplicate names cause a load-time error.
|
|
1491
|
+
|
|
1492
|
+
```typescript
|
|
1493
|
+
export default function(pi: ExtensionAPI) {
|
|
1494
|
+
pi.setName("my-custom-extension");
|
|
1495
|
+
// ctx.extensionName will now be "my-custom-extension"
|
|
1496
|
+
// Storage paths will use "my-custom-extension" as the namespace
|
|
1497
|
+
}
|
|
1498
|
+
```
|
|
1499
|
+
|
|
1500
|
+
### pi.extensionName
|
|
1501
|
+
|
|
1502
|
+
```typescript
|
|
1503
|
+
extensionName: string
|
|
1504
|
+
```
|
|
1505
|
+
|
|
1506
|
+
Read the current extension name. Returns the auto-derived name unless overridden by `setName()`.
|
|
1507
|
+
|
|
1508
|
+
**Name derivation rules:**
|
|
1509
|
+
|
|
1510
|
+
| Extension Form | Derived From | Example |
|
|
1511
|
+
|----------------|-------------|---------|
|
|
1512
|
+
| Package (with package.json) | `name` field (strips `@scope/`) | `@scope/my-ext` → `my-ext` |
|
|
1513
|
+
| Directory (index.ts/js) | Directory name | `my-ext/index.ts` → `my-ext` |
|
|
1514
|
+
| Single file | Filename without extension | `hello.ts` → `hello` |
|
|
1515
|
+
|
|
1416
1516
|
### pi.setLabel(entryId, label)
|
|
1417
1517
|
|
|
1418
1518
|
Set or clear a label on an entry. Labels are user-defined markers for bookmarking and navigation (shown in `/tree` selector).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyyz1993/pi-coding-agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.1",
|
|
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
|
"prepublishOnly": "npm run clean && npm run build"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@dyyz1993/pi-agent-core": "^0.
|
|
44
|
-
"@dyyz1993/pi-ai": "^0.
|
|
45
|
-
"@dyyz1993/pi-tui": "^0.
|
|
43
|
+
"@dyyz1993/pi-agent-core": "^0.70.1",
|
|
44
|
+
"@dyyz1993/pi-ai": "^0.70.1",
|
|
45
|
+
"@dyyz1993/pi-tui": "^0.70.1",
|
|
46
46
|
"@mariozechner/jiti": "^2.6.2",
|
|
47
47
|
"@silvia-odwyer/photon-node": "^0.3.4",
|
|
48
48
|
"chalk": "^5.5.0",
|
|
@@ -94,6 +94,9 @@
|
|
|
94
94
|
],
|
|
95
95
|
"author": "Mario Zechner",
|
|
96
96
|
"license": "MIT",
|
|
97
|
+
"publishConfig": {
|
|
98
|
+
"access": "public"
|
|
99
|
+
},
|
|
97
100
|
"repository": {
|
|
98
101
|
"type": "git",
|
|
99
102
|
"url": "git+https://github.com/dyyz1993/pi-mono.git",
|