@herbertgao/pi-extensions 2026.9.9 → 2026.9.11
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/README.md +1 -0
- package/THIRD_PARTY_NOTICES.md +26 -0
- package/node_modules/@herbertgao/pi-bark/package.json +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -2
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +12 -0
- package/node_modules/@herbertgao/pi-subagents/README.md +427 -120
- package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +184 -0
- package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +466 -0
- package/node_modules/@herbertgao/pi-subagents/examples/agent-tool-description.md +6 -6
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/compose.js +52 -0
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/fan-out-audit.js +56 -0
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/gated-fix.js +60 -0
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/lib/count-child.js +30 -0
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/review-panel.js +68 -0
- package/node_modules/@herbertgao/pi-subagents/examples/workflows/structured-findings.js +81 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +12 -10
- package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +52 -12
- package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +837 -146
- package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +213 -39
- package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +73 -14
- package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +101 -47
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +2249 -914
- package/node_modules/@herbertgao/pi-subagents/src/invocation-config.ts +13 -0
- package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +215 -0
- package/node_modules/@herbertgao/pi-subagents/src/mention.ts +147 -0
- package/node_modules/@herbertgao/pi-subagents/src/model-resolver.ts +9 -1
- package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +40 -26
- package/node_modules/@herbertgao/pi-subagents/src/output-file.ts +18 -8
- package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +46 -9
- package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +21 -16
- package/node_modules/@herbertgao/pi-subagents/src/settings.ts +137 -7
- package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +136 -0
- package/node_modules/@herbertgao/pi-subagents/src/types.ts +126 -8
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-mention.ts +274 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +20 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +10 -4
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +167 -22
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +555 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +1304 -0
- package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +226 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/collisions.ts +122 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/entry.ts +47 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +463 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +164 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +142 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +401 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +622 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +1399 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +230 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +333 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +200 -0
- package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +781 -0
- package/node_modules/@herbertgao/pi-subagents/src/worktree.ts +97 -95
- package/node_modules/@herbertgao/pi-subagents/src/xml.ts +13 -0
- package/node_modules/@herbertgao/resume-from/package.json +1 -1
- package/node_modules/@herbertgao/sol-pi/README.md +3 -3
- package/node_modules/@herbertgao/sol-pi/THIRD_PARTY_NOTICES.md +4 -4
- package/node_modules/@herbertgao/sol-pi/agents-install.md +4 -4
- package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +6 -6
- package/node_modules/@herbertgao/sol-pi/package.json +2 -2
- package/node_modules/@narumitw/pi-btw/dist/index.ts +39 -89
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/btw.ts +28 -87
- package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +8 -0
- package/node_modules/@narumitw/pi-btw/src/side-thread.ts +40 -37
- package/node_modules/@narumitw/pi-caffeinate/README.md +21 -66
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +10 -41
- package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-caffeinate/package.json +50 -51
- package/node_modules/@narumitw/pi-caffeinate/src/caffeinate.ts +637 -663
- package/node_modules/@narumitw/pi-caffeinate/src/dbus-inhibit.ts +114 -120
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +29 -29
- package/node_modules/@narumitw/pi-caffeinate/src/inhibitors.ts +108 -126
- package/node_modules/@narumitw/pi-caffeinate/src/settings.ts +124 -128
- package/node_modules/pi-multi-account/CHANGELOG.md +1209 -0
- package/node_modules/pi-multi-account/CONTRIBUTING.md +61 -0
- package/node_modules/pi-multi-account/LICENSE +21 -0
- package/node_modules/pi-multi-account/README.md +197 -0
- package/node_modules/pi-multi-account/SECURITY.md +27 -0
- package/node_modules/pi-multi-account/auth-file-transaction.ts +56 -0
- package/node_modules/pi-multi-account/child-usability.ts +233 -0
- package/node_modules/pi-multi-account/compaction-summary.ts +32 -0
- package/node_modules/pi-multi-account/completion-route-planner.ts +224 -0
- package/node_modules/pi-multi-account/context-guard.ts +420 -0
- package/node_modules/pi-multi-account/cursor/LICENSE +21 -0
- package/node_modules/pi-multi-account/cursor/NOTICE +2 -0
- package/node_modules/pi-multi-account/cursor/auth.ts +165 -0
- package/node_modules/pi-multi-account/cursor/bridge-handle.ts +155 -0
- package/node_modules/pi-multi-account/cursor/conversation-registry.ts +104 -0
- package/node_modules/pi-multi-account/cursor/cursor-models-raw.json +611 -0
- package/node_modules/pi-multi-account/cursor/cursor-shared.ts +192 -0
- package/node_modules/pi-multi-account/cursor/h2-bridge.mjs +175 -0
- package/node_modules/pi-multi-account/cursor/index.ts +572 -0
- package/node_modules/pi-multi-account/cursor/message-parsing.ts +323 -0
- package/node_modules/pi-multi-account/cursor/prompt-usage.ts +53 -0
- package/node_modules/pi-multi-account/cursor/proto/agent_pb.ts +15294 -0
- package/node_modules/pi-multi-account/cursor/proxy.ts +2510 -0
- package/node_modules/pi-multi-account/cursor/session-lifecycle.ts +40 -0
- package/node_modules/pi-multi-account/cursor/sse-keepalive.ts +24 -0
- package/node_modules/pi-multi-account/cursor/stream-lifecycle.ts +193 -0
- package/node_modules/pi-multi-account/cursor/upstream-watchdog.ts +88 -0
- package/node_modules/pi-multi-account/cursor-bridge.ts +240 -0
- package/node_modules/pi-multi-account/cursor-model-name.ts +12 -0
- package/node_modules/pi-multi-account/index.ts +11825 -0
- package/node_modules/pi-multi-account/model-catalog.ts +354 -0
- package/node_modules/pi-multi-account/package.json +101 -0
- package/node_modules/pi-multi-account/pi-contract.ts +281 -0
- package/node_modules/pi-multi-account/provider-payload-stream.ts +44 -0
- package/node_modules/pi-multi-account/provider-priority.ts +189 -0
- package/node_modules/pi-multi-account/slot-proxy-auth.ts +167 -0
- package/node_modules/pi-multi-account/slot-proxy.ts +344 -0
- package/node_modules/pi-multi-account/state-file-transaction.ts +67 -0
- package/node_modules/pi-multi-account/usage.ts +1099 -0
- package/node_modules/pi-typesafe/README.md +6 -2
- package/node_modules/pi-typesafe/dist/client.d.ts +11 -0
- package/node_modules/pi-typesafe/dist/client.js +45 -10
- package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
- package/node_modules/pi-typesafe/dist/index.js +1 -1
- package/node_modules/pi-typesafe/package.json +2 -2
- package/node_modules/pi-web-access/CHANGELOG.md +36 -0
- package/node_modules/pi-web-access/README.md +75 -18
- package/node_modules/pi-web-access/anysearch.ts +4 -15
- package/node_modules/pi-web-access/bocha.ts +3 -22
- package/node_modules/pi-web-access/brave.ts +3 -21
- package/node_modules/pi-web-access/brightdata.ts +5 -32
- package/node_modules/pi-web-access/content-find.ts +168 -53
- package/node_modules/pi-web-access/curator-page.ts +4 -1
- package/node_modules/pi-web-access/curator-run.ts +2 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/dist/index.js +24620 -0
- package/node_modules/pi-web-access/domain-filter-normalization.ts +14 -0
- package/node_modules/pi-web-access/duckduckgo.ts +3 -21
- package/node_modules/pi-web-access/extract.ts +3 -1
- package/node_modules/pi-web-access/firecrawl.ts +5 -29
- package/node_modules/pi-web-access/gemini-search.ts +81 -32
- package/node_modules/pi-web-access/index.ts +149 -148
- package/node_modules/pi-web-access/jina-search.ts +4 -15
- package/node_modules/pi-web-access/kagi.ts +4 -13
- package/node_modules/pi-web-access/kimi-search.ts +5 -30
- package/node_modules/pi-web-access/mistral-search.ts +1 -15
- package/node_modules/pi-web-access/ollama.ts +2 -7
- package/node_modules/pi-web-access/openai-search.ts +174 -36
- package/node_modules/pi-web-access/opencode-session-headers.ts +24 -0
- package/node_modules/pi-web-access/package.json +10 -4
- package/node_modules/pi-web-access/page-query.ts +10 -2
- package/node_modules/pi-web-access/parallel.ts +1 -15
- package/node_modules/pi-web-access/pdf-extract.ts +3 -0
- package/node_modules/pi-web-access/querit.ts +5 -29
- package/node_modules/pi-web-access/search-answer-formatting.ts +11 -0
- package/node_modules/pi-web-access/search-result-count-normalization.ts +4 -0
- package/node_modules/pi-web-access/search1api.ts +5 -29
- package/node_modules/pi-web-access/searchinfinity.ts +5 -29
- package/node_modules/pi-web-access/searxng.ts +3 -21
- package/node_modules/pi-web-access/serpapi.ts +5 -28
- package/node_modules/pi-web-access/serpbase.ts +3 -22
- package/node_modules/pi-web-access/serpdive.ts +3 -21
- package/node_modules/pi-web-access/serper.ts +5 -28
- package/node_modules/pi-web-access/serply.ts +197 -0
- package/node_modules/pi-web-access/source-check.ts +11 -47
- package/node_modules/pi-web-access/summary-review.ts +7 -3
- package/node_modules/pi-web-access/tavily.ts +3 -21
- package/node_modules/pi-web-access/tinyfish.ts +5 -29
- package/node_modules/pi-web-access/utils.ts +9 -1
- package/node_modules/pi-web-access/valyu.ts +5 -28
- package/node_modules/pi-web-access/xai-search.ts +1 -15
- package/node_modules/pi-web-access/xcrawl.ts +5 -32
- package/package.json +17 -11
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
* Creates a temporary git worktree so the agent works on an isolated copy of the repo.
|
|
5
5
|
* On completion, if no changes were made, the worktree is cleaned up.
|
|
6
6
|
* If changes exist, a branch is created and returned in the result.
|
|
7
|
+
*
|
|
8
|
+
* Every git call goes through `pi.exec` (async) rather than `execFileSync`: a
|
|
9
|
+
* worktree copy can take seconds, and a session that spawns several isolated
|
|
10
|
+
* agents at once would otherwise serialize them all on the TUI's event loop.
|
|
7
11
|
*/
|
|
8
12
|
|
|
9
|
-
import { execFileSync } from "node:child_process"
|
|
10
13
|
import { randomUUID } from "node:crypto"
|
|
11
14
|
import { existsSync, realpathSync } from "node:fs"
|
|
12
15
|
import { tmpdir } from "node:os"
|
|
13
16
|
import { join, relative } from "node:path"
|
|
17
|
+
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent"
|
|
14
18
|
|
|
15
19
|
export interface WorktreeInfo {
|
|
16
20
|
/** Absolute path to the worktree directory (the copied repo's root). */
|
|
@@ -49,49 +53,61 @@ export function isWorktreeIsolationEnabled(): boolean {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
export interface WorktreeCleanupResult {
|
|
52
|
-
/** Whether changes were found
|
|
56
|
+
/** Whether changes were found or may remain after a cleanup failure. */
|
|
53
57
|
hasChanges: boolean
|
|
54
58
|
/** Branch name if changes were committed. */
|
|
55
59
|
branch?: string
|
|
56
|
-
/** Worktree path
|
|
60
|
+
/** Worktree path. On error, the agent's changes remain here for recovery. */
|
|
57
61
|
path?: string
|
|
62
|
+
/** Cleanup failure. When present, the worktree is deliberately preserved. */
|
|
63
|
+
error?: string
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Run git and return its trimmed stdout, throwing on failure so callers keep
|
|
68
|
+
* the try/catch control flow `execFileSync` gave them.
|
|
69
|
+
*
|
|
70
|
+
* `pi.exec` never rejects — it reports failure in the result — and a command
|
|
71
|
+
* killed by its timeout comes back as `killed` with an exit code of 0, so both
|
|
72
|
+
* have to be checked to reproduce `execFileSync`'s "throws on anything but a
|
|
73
|
+
* clean exit".
|
|
74
|
+
*/
|
|
75
|
+
async function git(
|
|
76
|
+
pi: ExtensionAPI,
|
|
77
|
+
cwd: string,
|
|
78
|
+
args: string[],
|
|
79
|
+
timeout: number,
|
|
80
|
+
): Promise<string> {
|
|
81
|
+
const result = await pi.exec("git", args, { cwd, timeout })
|
|
82
|
+
if (result.killed || result.code !== 0) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
result.stderr.trim() ||
|
|
85
|
+
`git ${args.join(" ")} failed (exit ${result.code})`,
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
return result.stdout.trim()
|
|
58
89
|
}
|
|
59
90
|
|
|
60
91
|
/**
|
|
61
92
|
* Create a temporary git worktree for an agent.
|
|
62
93
|
* Returns the worktree path, or undefined if not in a git repo.
|
|
63
94
|
*/
|
|
64
|
-
export function createWorktree(
|
|
95
|
+
export async function createWorktree(
|
|
96
|
+
pi: ExtensionAPI,
|
|
65
97
|
cwd: string,
|
|
66
98
|
agentId: string,
|
|
67
|
-
): WorktreeInfo | undefined {
|
|
99
|
+
): Promise<WorktreeInfo | undefined> {
|
|
68
100
|
// Verify we're in a git repo with at least one commit (HEAD must exist)
|
|
69
101
|
let baseSha: string
|
|
70
102
|
let subdir: string
|
|
71
103
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
stdio: "pipe",
|
|
75
|
-
timeout: 5000,
|
|
76
|
-
})
|
|
77
|
-
baseSha = execFileSync("git", ["rev-parse", "HEAD"], {
|
|
78
|
-
cwd,
|
|
79
|
-
stdio: "pipe",
|
|
80
|
-
timeout: 5000,
|
|
81
|
-
})
|
|
82
|
-
.toString()
|
|
83
|
-
.trim()
|
|
104
|
+
await git(pi, cwd, ["rev-parse", "--is-inside-work-tree"], 5000)
|
|
105
|
+
baseSha = await git(pi, cwd, ["rev-parse", "HEAD"], 5000)
|
|
84
106
|
// Where cwd sits inside the repo ("" at the root): the agent must work at
|
|
85
107
|
// the same subdirectory inside the copy, or a monorepo-package cwd would
|
|
86
108
|
// silently widen to the whole repo. realpath both sides — git emits
|
|
87
109
|
// resolved paths while cwd may arrive through a symlink (macOS /tmp).
|
|
88
|
-
const topLevel =
|
|
89
|
-
cwd,
|
|
90
|
-
stdio: "pipe",
|
|
91
|
-
timeout: 5000,
|
|
92
|
-
})
|
|
93
|
-
.toString()
|
|
94
|
-
.trim()
|
|
110
|
+
const topLevel = await git(pi, cwd, ["rev-parse", "--show-toplevel"], 5000)
|
|
95
111
|
subdir = relative(realpathSync(topLevel), realpathSync(cwd))
|
|
96
112
|
} catch {
|
|
97
113
|
return undefined
|
|
@@ -103,11 +119,12 @@ export function createWorktree(
|
|
|
103
119
|
|
|
104
120
|
try {
|
|
105
121
|
// Create detached worktree at HEAD
|
|
106
|
-
|
|
122
|
+
await git(
|
|
123
|
+
pi,
|
|
107
124
|
cwd,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
125
|
+
["worktree", "add", "--detach", worktreePath, "HEAD"],
|
|
126
|
+
30000,
|
|
127
|
+
)
|
|
111
128
|
return {
|
|
112
129
|
path: worktreePath,
|
|
113
130
|
branch,
|
|
@@ -125,56 +142,49 @@ export function createWorktree(
|
|
|
125
142
|
* - If no changes: remove worktree entirely.
|
|
126
143
|
* - If changes exist: create a branch, commit changes, return branch info.
|
|
127
144
|
*/
|
|
128
|
-
export function cleanupWorktree(
|
|
145
|
+
export async function cleanupWorktree(
|
|
146
|
+
pi: ExtensionAPI,
|
|
129
147
|
cwd: string,
|
|
130
148
|
worktree: WorktreeInfo,
|
|
131
149
|
agentDescription: string,
|
|
132
|
-
): WorktreeCleanupResult {
|
|
150
|
+
): Promise<WorktreeCleanupResult> {
|
|
133
151
|
if (!existsSync(worktree.path)) {
|
|
134
152
|
return { hasChanges: false }
|
|
135
153
|
}
|
|
136
154
|
|
|
155
|
+
let preservedBranch: string | undefined
|
|
137
156
|
try {
|
|
138
157
|
// Check for uncommitted changes in the worktree
|
|
139
|
-
const status =
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.trim()
|
|
158
|
+
const status = await git(
|
|
159
|
+
pi,
|
|
160
|
+
worktree.path,
|
|
161
|
+
["status", "--porcelain"],
|
|
162
|
+
10000,
|
|
163
|
+
)
|
|
146
164
|
|
|
147
165
|
if (status) {
|
|
148
166
|
// Changes exist — stage, commit, and create a branch
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
stdio: "pipe",
|
|
152
|
-
timeout: 10000,
|
|
153
|
-
})
|
|
154
|
-
// Truncate description for commit message (no shell sanitization needed — execFileSync uses argv)
|
|
167
|
+
await git(pi, worktree.path, ["add", "-A"], 10000)
|
|
168
|
+
// Truncate description for commit message (no shell sanitization needed — pi.exec uses argv)
|
|
155
169
|
const safeDesc = agentDescription.slice(0, 200)
|
|
156
170
|
const commitMsg = `pi-agent: ${safeDesc}`
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
await git(
|
|
172
|
+
pi,
|
|
173
|
+
worktree.path,
|
|
159
174
|
["commit", "--no-verify", "--no-gpg-sign", "-m", commitMsg],
|
|
160
|
-
|
|
161
|
-
cwd: worktree.path,
|
|
162
|
-
stdio: "pipe",
|
|
163
|
-
timeout: 10000,
|
|
164
|
-
},
|
|
175
|
+
10000,
|
|
165
176
|
)
|
|
166
177
|
} else {
|
|
167
|
-
const currentSha =
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
.trim()
|
|
178
|
+
const currentSha = await git(
|
|
179
|
+
pi,
|
|
180
|
+
worktree.path,
|
|
181
|
+
["rev-parse", "HEAD"],
|
|
182
|
+
5000,
|
|
183
|
+
)
|
|
174
184
|
|
|
175
185
|
if (currentSha === worktree.baseSha) {
|
|
176
186
|
// No changes — remove worktree
|
|
177
|
-
removeWorktree(cwd, worktree.path)
|
|
187
|
+
await removeWorktree(pi, cwd, worktree.path)
|
|
178
188
|
return { hasChanges: false }
|
|
179
189
|
}
|
|
180
190
|
}
|
|
@@ -183,76 +193,68 @@ export function cleanupWorktree(
|
|
|
183
193
|
// If the branch already exists, append a suffix to avoid overwriting previous work.
|
|
184
194
|
let branchName = worktree.branch
|
|
185
195
|
try {
|
|
186
|
-
|
|
187
|
-
cwd: worktree.path,
|
|
188
|
-
stdio: "pipe",
|
|
189
|
-
timeout: 5000,
|
|
190
|
-
})
|
|
196
|
+
await git(pi, worktree.path, ["branch", branchName], 5000)
|
|
191
197
|
} catch {
|
|
192
198
|
// Branch already exists — use a unique suffix
|
|
193
199
|
branchName = `${worktree.branch}-${Date.now()}`
|
|
194
|
-
|
|
195
|
-
cwd: worktree.path,
|
|
196
|
-
stdio: "pipe",
|
|
197
|
-
timeout: 5000,
|
|
198
|
-
})
|
|
200
|
+
await git(pi, worktree.path, ["branch", branchName], 5000)
|
|
199
201
|
}
|
|
200
202
|
// Update branch name in worktree info for the caller
|
|
201
203
|
worktree.branch = branchName
|
|
204
|
+
preservedBranch = branchName
|
|
202
205
|
|
|
203
206
|
// Remove the worktree (branch persists in main repo)
|
|
204
|
-
removeWorktree(cwd, worktree.path)
|
|
207
|
+
await removeWorktree(pi, cwd, worktree.path)
|
|
205
208
|
|
|
206
209
|
return {
|
|
207
210
|
hasChanges: true,
|
|
208
211
|
branch: worktree.branch,
|
|
209
212
|
path: worktree.path,
|
|
210
213
|
}
|
|
211
|
-
} catch {
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
} catch (error) {
|
|
215
|
+
// This may be the only copy of the agent's work. Keep it recoverable and
|
|
216
|
+
// report the path instead of turning a preservation failure into "no changes".
|
|
217
|
+
return {
|
|
218
|
+
hasChanges: true,
|
|
219
|
+
...(preservedBranch ? { branch: preservedBranch } : {}),
|
|
220
|
+
path: worktree.path,
|
|
221
|
+
error: error instanceof Error ? error.message : String(error),
|
|
217
222
|
}
|
|
218
|
-
return { hasChanges: false }
|
|
219
223
|
}
|
|
220
224
|
}
|
|
221
225
|
|
|
222
226
|
/**
|
|
223
227
|
* Force-remove a worktree.
|
|
224
228
|
*/
|
|
225
|
-
function removeWorktree(
|
|
229
|
+
async function removeWorktree(
|
|
230
|
+
pi: ExtensionAPI,
|
|
231
|
+
cwd: string,
|
|
232
|
+
worktreePath: string,
|
|
233
|
+
): Promise<void> {
|
|
226
234
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
} catch {
|
|
233
|
-
// If git worktree remove fails, try pruning
|
|
235
|
+
await git(pi, cwd, ["worktree", "remove", "--force", worktreePath], 10000)
|
|
236
|
+
} catch (removeError) {
|
|
237
|
+
// A concurrent remover may have deleted the directory while Git still
|
|
238
|
+
// returned an error. Prune stale metadata, but report failure if the copy
|
|
239
|
+
// still exists — callers must not mistake a leaked worktree for success.
|
|
234
240
|
try {
|
|
235
|
-
|
|
236
|
-
cwd,
|
|
237
|
-
stdio: "pipe",
|
|
238
|
-
timeout: 5000,
|
|
239
|
-
})
|
|
241
|
+
await git(pi, cwd, ["worktree", "prune"], 5000)
|
|
240
242
|
} catch {
|
|
241
243
|
/* ignore */
|
|
242
244
|
}
|
|
245
|
+
if (existsSync(worktreePath)) throw removeError
|
|
243
246
|
}
|
|
244
247
|
}
|
|
245
248
|
|
|
246
249
|
/**
|
|
247
250
|
* Prune any orphaned worktrees (crash recovery).
|
|
248
251
|
*/
|
|
249
|
-
export function pruneWorktrees(
|
|
252
|
+
export async function pruneWorktrees(
|
|
253
|
+
pi: ExtensionAPI,
|
|
254
|
+
cwd: string,
|
|
255
|
+
): Promise<void> {
|
|
250
256
|
try {
|
|
251
|
-
|
|
252
|
-
cwd,
|
|
253
|
-
stdio: "pipe",
|
|
254
|
-
timeout: 5000,
|
|
255
|
-
})
|
|
257
|
+
await git(pi, cwd, ["worktree", "prune"], 5000)
|
|
256
258
|
} catch {
|
|
257
259
|
/* ignore */
|
|
258
260
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* xml.ts — escaping for the `<task-notification>` payloads.
|
|
3
|
+
*
|
|
4
|
+
* A module of its own because both notification builders need it and they sit
|
|
5
|
+
* on opposite sides of a dependency edge: the agent one lives in `index.ts`,
|
|
6
|
+
* which imports `workflow/task.ts`, so the workflow one cannot reach back for
|
|
7
|
+
* it without a cycle.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Escape XML special characters to prevent injection in structured notifications. */
|
|
11
|
+
export function escapeXml(s: string): string {
|
|
12
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")
|
|
13
|
+
}
|
|
@@ -56,16 +56,16 @@ Read the [SoL-Pi blog](https://nvlabs.github.io/SoL-Pi/) for a deeper look at th
|
|
|
56
56
|
|
|
57
57
|
### Requirements
|
|
58
58
|
|
|
59
|
-
- Node.js
|
|
59
|
+
- Node.js 24 or newer
|
|
60
60
|
- npm
|
|
61
|
-
- `@earendil-works/pi-coding-agent` 0.
|
|
61
|
+
- `@earendil-works/pi-coding-agent` 0.85.1
|
|
62
62
|
|
|
63
63
|
### Install
|
|
64
64
|
|
|
65
65
|
Install the tested Pi release:
|
|
66
66
|
|
|
67
67
|
```bash
|
|
68
|
-
npm install --global @earendil-works/pi-coding-agent@0.
|
|
68
|
+
npm install --global @earendil-works/pi-coding-agent@0.85.1
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
Then install SoL-Pi directly from [NVlabs/SoL-Pi](https://github.com/NVlabs/SoL-Pi):
|
|
@@ -8,10 +8,10 @@ The following packages are supplied by the user's Pi installation and retain the
|
|
|
8
8
|
|
|
9
9
|
| Package | Development-tested version | License | Source |
|
|
10
10
|
| --- | ---: | --- | --- |
|
|
11
|
-
| `@earendil-works/pi-agent-core` | 0.
|
|
12
|
-
| `@earendil-works/pi-ai` | 0.
|
|
13
|
-
| `@earendil-works/pi-coding-agent` | 0.
|
|
14
|
-
| `@earendil-works/pi-tui` | 0.
|
|
11
|
+
| `@earendil-works/pi-agent-core` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
12
|
+
| `@earendil-works/pi-ai` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
13
|
+
| `@earendil-works/pi-coding-agent` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
14
|
+
| `@earendil-works/pi-tui` | 0.85.1 | MIT | <https://github.com/earendil-works/pi> |
|
|
15
15
|
| `typebox` | 1.3.7 | MIT | <https://github.com/sinclairzx81/typebox> |
|
|
16
16
|
|
|
17
17
|
## Development-only dependencies
|
|
@@ -7,7 +7,7 @@ Installation and configuration are complete only when Pi remains unmodified, the
|
|
|
7
7
|
## Rules
|
|
8
8
|
|
|
9
9
|
- Do not modify, patch, fork, or vendor upstream Pi. SoL-Pi must load as a standalone extension through Pi's public package interface.
|
|
10
|
-
- Use Node.js
|
|
10
|
+
- Use Node.js 24 or newer and the tested Pi release `@earendil-works/pi-coding-agent@0.85.1`. Treat a different Pi version as a compatibility change and rerun the full suite before using it.
|
|
11
11
|
- Do not clean, reset, switch, or overwrite unrelated repository changes.
|
|
12
12
|
- Do not print, log, commit, upload, or include any secret in a command line. Check only whether a credential is present.
|
|
13
13
|
- Keep SoL-Pi settings in `sol-pi.json`. The Evidence-Preserving Reducer provider/model route is a SoL-Pi setting; provider URLs, credentials, the main agent model, and shell behavior remain Pi settings.
|
|
@@ -35,7 +35,7 @@ node --version
|
|
|
35
35
|
npm --version
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
Require Node.js
|
|
38
|
+
Require Node.js 24 or newer. Install from the lockfile and run the source checks:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
41
|
npm ci --ignore-scripts
|
|
@@ -54,11 +54,11 @@ Stop if any command fails. Do not hide a failure with `|| true` or replace `npm
|
|
|
54
54
|
Install the tested Pi release without changing its source:
|
|
55
55
|
|
|
56
56
|
```bash
|
|
57
|
-
npm install --global --ignore-scripts @earendil-works/pi-coding-agent@0.
|
|
57
|
+
npm install --global --ignore-scripts @earendil-works/pi-coding-agent@0.85.1
|
|
58
58
|
pi --version
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
Require `pi --version` to report `0.
|
|
61
|
+
Require `pi --version` to report `0.85.1`.
|
|
62
62
|
|
|
63
63
|
For a project-local registration, run this from `target_project` and substitute the resolved absolute `sol_pi_root`:
|
|
64
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Pi Compatibility
|
|
2
2
|
|
|
3
|
-
SoL-Pi is developed and tested against `@earendil-works/pi-coding-agent` 0.
|
|
3
|
+
SoL-Pi is developed and tested against `@earendil-works/pi-coding-agent` 0.85.1. Its public API surface is also type-checked and exercised against Pi 0.81.1, the base used by the original Pi fork. The runtime range is deliberately expressed as a peer dependency because Pi owns installation and upgrade of its packages.
|
|
4
4
|
|
|
5
5
|
SoL-Pi imports only public package exports:
|
|
6
6
|
|
|
@@ -31,7 +31,7 @@ ObservationPack changes only the messages projected through the public `context`
|
|
|
31
31
|
|
|
32
32
|
The reducer handles public `tool_result` events and resolves the configured reducer provider/model through Pi's model registry before calling `ExtensionContext.modelRegistry.complete()` when available. For the Pi 0.81.1 fork, which exposes no registry `complete()` method, it resolves authentication for that reducer model through `getApiKeyAndHeaders()` and calls the shared `@earendil-works/pi-ai/compat` completion API. The reducer preserves the original result whenever the configured reducer model is unavailable or eligibility, model-call, schema, source-hash, exact-quote, size, or likely-secret checks fail.
|
|
33
33
|
|
|
34
|
-
All persistent paths use `SessionManager.getSessionDir()` and `getSessionId()`, which are present in both the fork and Pi 0.
|
|
34
|
+
All persistent paths use `SessionManager.getSessionDir()` and `getSessionId()`, which are present in both the fork and Pi 0.85.1. SoL-Pi creates no configurable storage-path surface.
|
|
35
35
|
|
|
36
36
|
The unpublished shared artifact layout is not read or migrated. Each session starts from its own `<sessionDir>/sol-pi/<sessionId>/` directory.
|
|
37
37
|
|
|
@@ -41,13 +41,13 @@ Online Context Compact uses ordinary public `context` and `before_provider_reque
|
|
|
41
41
|
|
|
42
42
|
Before selecting or executing a boundary compaction, it also checks the optional `Symbol.for("pi-subagents:manager")` registry exposed by `pi-subagents`. A running top-level subagent, or an unreadable registry, suppresses that compaction rather than risking a context rewrite during delegated work. When the registry is absent, the check is a no-op.
|
|
43
43
|
|
|
44
|
-
Pi does not expose its active retained-tail compaction setting through the public extension context. The standalone extension therefore uses the documented Pi 0.
|
|
44
|
+
Pi does not expose its active retained-tail compaction setting through the public extension context. The standalone extension therefore uses the documented Pi 0.85.1 default of 20,000 tokens for its economic estimate. Its programmatic factory accepts an explicit matching value for a non-default Pi setting.
|
|
45
45
|
|
|
46
|
-
Pi 0.
|
|
46
|
+
Pi 0.85.1's `ExtensionContext.compact()` aborts the active agent before it summarizes, and `agent_settled` fires only once a whole run has drained every turn, retry, auto-compaction, and queued continuation. A plan boundary that selects compaction therefore saves its plan and progress state, calls `ExtensionContext.abort()` to stop the run, and runs compaction from the `agent_settled` that stop produces. The handler awaits the compaction's own `onComplete`/`onError` callbacks. On success, the extension sends a hidden reminder through public `ExtensionAPI.sendMessage()` with `triggerTurn: true`, so Pi starts a new turn against the compacted context and rebuilds the plan even when the native summary omits that instruction.
|
|
47
47
|
|
|
48
48
|
A settlement barrier keeps the original `agent_settled` dispatch open until the triggered continuation settles. Print- and JSON-mode processes therefore complete the compact-and-continue sequence within the same Pi invocation; an outer driver does not need to resume the session or send `Continue working`. This continuation is armed only by a successful boundary compaction. Cancelling or exiting does not schedule one. A Pi build that never emits `agent_settled` starts no boundary compaction.
|
|
49
49
|
|
|
50
|
-
Pi 0.
|
|
50
|
+
Pi 0.85.1 does not return a promise from `ExtensionAPI.sendMessage()`. The barrier is therefore verified for standalone SoL-Pi and depends on Pi starting the requested turn synchronously. A later-loaded third-party extension that performs long asynchronous work in its own `agent_settled` handler is outside this guarantee and needs an integration test with that extension set.
|
|
51
51
|
|
|
52
52
|
Pi reports the session as idle while an extension-requested manual compaction is running. SoL-Pi cancels `session_before_tree` during that interval to prevent tree navigation from moving the active leaf underneath the compaction. Navigation works normally after the compaction callback settles.
|
|
53
53
|
|
|
@@ -57,7 +57,7 @@ The standalone entry passes `cacheWriteReadRatio` from `sol-pi.json` directly in
|
|
|
57
57
|
|
|
58
58
|
## Interactive TUI
|
|
59
59
|
|
|
60
|
-
The lightning savings treatment uses Pi 0.
|
|
60
|
+
The lightning savings treatment uses Pi 0.85.1's public `renderCall`,
|
|
61
61
|
`renderResult`, `ctx.ui.notify()`, and keyed `ctx.ui.setStatus()` APIs. It checks
|
|
62
62
|
`ctx.mode === "tui"` rather than `ctx.hasUI`, because RPC mode also reports UI
|
|
63
63
|
support. The renderer therefore changes only the interactive terminal display;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/sol-pi",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Token-efficient context and tool extensions for Pi, maintained from NVlabs/SoL-Pi.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"vitest": "^4.0.18"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
|
-
"node": ">=
|
|
62
|
+
"node": ">=24"
|
|
63
63
|
},
|
|
64
64
|
"pi": {
|
|
65
65
|
"extensions": [
|