@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.
Files changed (170) hide show
  1. package/README.md +1 -0
  2. package/THIRD_PARTY_NOTICES.md +26 -0
  3. package/node_modules/@herbertgao/pi-bark/package.json +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
  6. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -2
  7. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +12 -0
  8. package/node_modules/@herbertgao/pi-subagents/README.md +427 -120
  9. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +184 -0
  10. package/node_modules/@herbertgao/pi-subagents/docs/workflows.md +466 -0
  11. package/node_modules/@herbertgao/pi-subagents/examples/agent-tool-description.md +6 -6
  12. package/node_modules/@herbertgao/pi-subagents/examples/workflows/compose.js +52 -0
  13. package/node_modules/@herbertgao/pi-subagents/examples/workflows/fan-out-audit.js +56 -0
  14. package/node_modules/@herbertgao/pi-subagents/examples/workflows/gated-fix.js +60 -0
  15. package/node_modules/@herbertgao/pi-subagents/examples/workflows/lib/count-child.js +30 -0
  16. package/node_modules/@herbertgao/pi-subagents/examples/workflows/review-panel.js +68 -0
  17. package/node_modules/@herbertgao/pi-subagents/examples/workflows/structured-findings.js +81 -0
  18. package/node_modules/@herbertgao/pi-subagents/package.json +12 -10
  19. package/node_modules/@herbertgao/pi-subagents/src/agent-file-toggle.ts +52 -12
  20. package/node_modules/@herbertgao/pi-subagents/src/agent-manager.ts +837 -146
  21. package/node_modules/@herbertgao/pi-subagents/src/agent-runner.ts +213 -39
  22. package/node_modules/@herbertgao/pi-subagents/src/cross-extension-rpc.ts +73 -14
  23. package/node_modules/@herbertgao/pi-subagents/src/custom-agents.ts +101 -47
  24. package/node_modules/@herbertgao/pi-subagents/src/index.ts +2249 -914
  25. package/node_modules/@herbertgao/pi-subagents/src/invocation-config.ts +13 -0
  26. package/node_modules/@herbertgao/pi-subagents/src/mention-clone.ts +215 -0
  27. package/node_modules/@herbertgao/pi-subagents/src/mention.ts +147 -0
  28. package/node_modules/@herbertgao/pi-subagents/src/model-resolver.ts +9 -1
  29. package/node_modules/@herbertgao/pi-subagents/src/nested-tools.ts +40 -26
  30. package/node_modules/@herbertgao/pi-subagents/src/output-file.ts +18 -8
  31. package/node_modules/@herbertgao/pi-subagents/src/prompts.ts +46 -9
  32. package/node_modules/@herbertgao/pi-subagents/src/schedule.ts +21 -16
  33. package/node_modules/@herbertgao/pi-subagents/src/settings.ts +137 -7
  34. package/node_modules/@herbertgao/pi-subagents/src/structured-output.ts +136 -0
  35. package/node_modules/@herbertgao/pi-subagents/src/types.ts +126 -8
  36. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-mention.ts +274 -0
  37. package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +20 -5
  38. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +10 -4
  39. package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +167 -22
  40. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-card.ts +555 -0
  41. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-dialog.ts +1304 -0
  42. package/node_modules/@herbertgao/pi-subagents/src/ui/workflow-menu.ts +226 -0
  43. package/node_modules/@herbertgao/pi-subagents/src/workflow/collisions.ts +122 -0
  44. package/node_modules/@herbertgao/pi-subagents/src/workflow/entry.ts +47 -0
  45. package/node_modules/@herbertgao/pi-subagents/src/workflow/host.ts +463 -0
  46. package/node_modules/@herbertgao/pi-subagents/src/workflow/journal.ts +164 -0
  47. package/node_modules/@herbertgao/pi-subagents/src/workflow/json-schema.ts +142 -0
  48. package/node_modules/@herbertgao/pi-subagents/src/workflow/meta.ts +401 -0
  49. package/node_modules/@herbertgao/pi-subagents/src/workflow/progress.ts +622 -0
  50. package/node_modules/@herbertgao/pi-subagents/src/workflow/runtime.ts +1399 -0
  51. package/node_modules/@herbertgao/pi-subagents/src/workflow/saved.ts +230 -0
  52. package/node_modules/@herbertgao/pi-subagents/src/workflow/task.ts +333 -0
  53. package/node_modules/@herbertgao/pi-subagents/src/workflow/tool-description.ts +200 -0
  54. package/node_modules/@herbertgao/pi-subagents/src/workflow/worker-source.ts +781 -0
  55. package/node_modules/@herbertgao/pi-subagents/src/worktree.ts +97 -95
  56. package/node_modules/@herbertgao/pi-subagents/src/xml.ts +13 -0
  57. package/node_modules/@herbertgao/resume-from/package.json +1 -1
  58. package/node_modules/@herbertgao/sol-pi/README.md +3 -3
  59. package/node_modules/@herbertgao/sol-pi/THIRD_PARTY_NOTICES.md +4 -4
  60. package/node_modules/@herbertgao/sol-pi/agents-install.md +4 -4
  61. package/node_modules/@herbertgao/sol-pi/docs/compatibility.md +6 -6
  62. package/node_modules/@herbertgao/sol-pi/package.json +2 -2
  63. package/node_modules/@narumitw/pi-btw/dist/index.ts +39 -89
  64. package/node_modules/@narumitw/pi-btw/dist/index.ts.map +3 -3
  65. package/node_modules/@narumitw/pi-btw/package.json +4 -4
  66. package/node_modules/@narumitw/pi-btw/src/btw.ts +28 -87
  67. package/node_modules/@narumitw/pi-btw/src/main-tree-picker.ts +8 -0
  68. package/node_modules/@narumitw/pi-btw/src/side-thread.ts +40 -37
  69. package/node_modules/@narumitw/pi-caffeinate/README.md +21 -66
  70. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts +10 -41
  71. package/node_modules/@narumitw/pi-caffeinate/dist/index.ts.map +2 -2
  72. package/node_modules/@narumitw/pi-caffeinate/package.json +50 -51
  73. package/node_modules/@narumitw/pi-caffeinate/src/caffeinate.ts +637 -663
  74. package/node_modules/@narumitw/pi-caffeinate/src/dbus-inhibit.ts +114 -120
  75. package/node_modules/@narumitw/pi-caffeinate/src/inhibitor-process.ts +29 -29
  76. package/node_modules/@narumitw/pi-caffeinate/src/inhibitors.ts +108 -126
  77. package/node_modules/@narumitw/pi-caffeinate/src/settings.ts +124 -128
  78. package/node_modules/pi-multi-account/CHANGELOG.md +1209 -0
  79. package/node_modules/pi-multi-account/CONTRIBUTING.md +61 -0
  80. package/node_modules/pi-multi-account/LICENSE +21 -0
  81. package/node_modules/pi-multi-account/README.md +197 -0
  82. package/node_modules/pi-multi-account/SECURITY.md +27 -0
  83. package/node_modules/pi-multi-account/auth-file-transaction.ts +56 -0
  84. package/node_modules/pi-multi-account/child-usability.ts +233 -0
  85. package/node_modules/pi-multi-account/compaction-summary.ts +32 -0
  86. package/node_modules/pi-multi-account/completion-route-planner.ts +224 -0
  87. package/node_modules/pi-multi-account/context-guard.ts +420 -0
  88. package/node_modules/pi-multi-account/cursor/LICENSE +21 -0
  89. package/node_modules/pi-multi-account/cursor/NOTICE +2 -0
  90. package/node_modules/pi-multi-account/cursor/auth.ts +165 -0
  91. package/node_modules/pi-multi-account/cursor/bridge-handle.ts +155 -0
  92. package/node_modules/pi-multi-account/cursor/conversation-registry.ts +104 -0
  93. package/node_modules/pi-multi-account/cursor/cursor-models-raw.json +611 -0
  94. package/node_modules/pi-multi-account/cursor/cursor-shared.ts +192 -0
  95. package/node_modules/pi-multi-account/cursor/h2-bridge.mjs +175 -0
  96. package/node_modules/pi-multi-account/cursor/index.ts +572 -0
  97. package/node_modules/pi-multi-account/cursor/message-parsing.ts +323 -0
  98. package/node_modules/pi-multi-account/cursor/prompt-usage.ts +53 -0
  99. package/node_modules/pi-multi-account/cursor/proto/agent_pb.ts +15294 -0
  100. package/node_modules/pi-multi-account/cursor/proxy.ts +2510 -0
  101. package/node_modules/pi-multi-account/cursor/session-lifecycle.ts +40 -0
  102. package/node_modules/pi-multi-account/cursor/sse-keepalive.ts +24 -0
  103. package/node_modules/pi-multi-account/cursor/stream-lifecycle.ts +193 -0
  104. package/node_modules/pi-multi-account/cursor/upstream-watchdog.ts +88 -0
  105. package/node_modules/pi-multi-account/cursor-bridge.ts +240 -0
  106. package/node_modules/pi-multi-account/cursor-model-name.ts +12 -0
  107. package/node_modules/pi-multi-account/index.ts +11825 -0
  108. package/node_modules/pi-multi-account/model-catalog.ts +354 -0
  109. package/node_modules/pi-multi-account/package.json +101 -0
  110. package/node_modules/pi-multi-account/pi-contract.ts +281 -0
  111. package/node_modules/pi-multi-account/provider-payload-stream.ts +44 -0
  112. package/node_modules/pi-multi-account/provider-priority.ts +189 -0
  113. package/node_modules/pi-multi-account/slot-proxy-auth.ts +167 -0
  114. package/node_modules/pi-multi-account/slot-proxy.ts +344 -0
  115. package/node_modules/pi-multi-account/state-file-transaction.ts +67 -0
  116. package/node_modules/pi-multi-account/usage.ts +1099 -0
  117. package/node_modules/pi-typesafe/README.md +6 -2
  118. package/node_modules/pi-typesafe/dist/client.d.ts +11 -0
  119. package/node_modules/pi-typesafe/dist/client.js +45 -10
  120. package/node_modules/pi-typesafe/dist/index.d.ts +2 -2
  121. package/node_modules/pi-typesafe/dist/index.js +1 -1
  122. package/node_modules/pi-typesafe/package.json +2 -2
  123. package/node_modules/pi-web-access/CHANGELOG.md +36 -0
  124. package/node_modules/pi-web-access/README.md +75 -18
  125. package/node_modules/pi-web-access/anysearch.ts +4 -15
  126. package/node_modules/pi-web-access/bocha.ts +3 -22
  127. package/node_modules/pi-web-access/brave.ts +3 -21
  128. package/node_modules/pi-web-access/brightdata.ts +5 -32
  129. package/node_modules/pi-web-access/content-find.ts +168 -53
  130. package/node_modules/pi-web-access/curator-page.ts +4 -1
  131. package/node_modules/pi-web-access/curator-run.ts +2 -1
  132. package/node_modules/pi-web-access/curator-server.ts +1 -0
  133. package/node_modules/pi-web-access/dist/index.js +24620 -0
  134. package/node_modules/pi-web-access/domain-filter-normalization.ts +14 -0
  135. package/node_modules/pi-web-access/duckduckgo.ts +3 -21
  136. package/node_modules/pi-web-access/extract.ts +3 -1
  137. package/node_modules/pi-web-access/firecrawl.ts +5 -29
  138. package/node_modules/pi-web-access/gemini-search.ts +81 -32
  139. package/node_modules/pi-web-access/index.ts +149 -148
  140. package/node_modules/pi-web-access/jina-search.ts +4 -15
  141. package/node_modules/pi-web-access/kagi.ts +4 -13
  142. package/node_modules/pi-web-access/kimi-search.ts +5 -30
  143. package/node_modules/pi-web-access/mistral-search.ts +1 -15
  144. package/node_modules/pi-web-access/ollama.ts +2 -7
  145. package/node_modules/pi-web-access/openai-search.ts +174 -36
  146. package/node_modules/pi-web-access/opencode-session-headers.ts +24 -0
  147. package/node_modules/pi-web-access/package.json +10 -4
  148. package/node_modules/pi-web-access/page-query.ts +10 -2
  149. package/node_modules/pi-web-access/parallel.ts +1 -15
  150. package/node_modules/pi-web-access/pdf-extract.ts +3 -0
  151. package/node_modules/pi-web-access/querit.ts +5 -29
  152. package/node_modules/pi-web-access/search-answer-formatting.ts +11 -0
  153. package/node_modules/pi-web-access/search-result-count-normalization.ts +4 -0
  154. package/node_modules/pi-web-access/search1api.ts +5 -29
  155. package/node_modules/pi-web-access/searchinfinity.ts +5 -29
  156. package/node_modules/pi-web-access/searxng.ts +3 -21
  157. package/node_modules/pi-web-access/serpapi.ts +5 -28
  158. package/node_modules/pi-web-access/serpbase.ts +3 -22
  159. package/node_modules/pi-web-access/serpdive.ts +3 -21
  160. package/node_modules/pi-web-access/serper.ts +5 -28
  161. package/node_modules/pi-web-access/serply.ts +197 -0
  162. package/node_modules/pi-web-access/source-check.ts +11 -47
  163. package/node_modules/pi-web-access/summary-review.ts +7 -3
  164. package/node_modules/pi-web-access/tavily.ts +3 -21
  165. package/node_modules/pi-web-access/tinyfish.ts +5 -29
  166. package/node_modules/pi-web-access/utils.ts +9 -1
  167. package/node_modules/pi-web-access/valyu.ts +5 -28
  168. package/node_modules/pi-web-access/xai-search.ts +1 -15
  169. package/node_modules/pi-web-access/xcrawl.ts +5 -32
  170. 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 in the worktree. */
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 if it was kept. */
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
- execFileSync("git", ["rev-parse", "--is-inside-work-tree"], {
73
- cwd,
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 = execFileSync("git", ["rev-parse", "--show-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
- execFileSync("git", ["worktree", "add", "--detach", worktreePath, "HEAD"], {
122
+ await git(
123
+ pi,
107
124
  cwd,
108
- stdio: "pipe",
109
- timeout: 30000,
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 = execFileSync("git", ["status", "--porcelain"], {
140
- cwd: worktree.path,
141
- stdio: "pipe",
142
- timeout: 30000,
143
- })
144
- .toString()
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
- execFileSync("git", ["add", "-A"], {
150
- cwd: worktree.path,
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
- execFileSync(
158
- "git",
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 = execFileSync("git", ["rev-parse", "HEAD"], {
168
- cwd: worktree.path,
169
- stdio: "pipe",
170
- timeout: 5000,
171
- })
172
- .toString()
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
- execFileSync("git", ["branch", branchName], {
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
- execFileSync("git", ["branch", branchName], {
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
- // Best effort cleanup on error
213
- try {
214
- removeWorktree(cwd, worktree.path)
215
- } catch {
216
- /* ignore */
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(cwd: string, worktreePath: string): void {
229
+ async function removeWorktree(
230
+ pi: ExtensionAPI,
231
+ cwd: string,
232
+ worktreePath: string,
233
+ ): Promise<void> {
226
234
  try {
227
- execFileSync("git", ["worktree", "remove", "--force", worktreePath], {
228
- cwd,
229
- stdio: "pipe",
230
- timeout: 10000,
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
- execFileSync("git", ["worktree", "prune"], {
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(cwd: string): void {
252
+ export async function pruneWorktrees(
253
+ pi: ExtensionAPI,
254
+ cwd: string,
255
+ ): Promise<void> {
250
256
  try {
251
- execFileSync("git", ["worktree", "prune"], {
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, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
13
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/resume-from",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Continue a coding session in a different agent, or a different profile.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -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 22.19 or newer
59
+ - Node.js 24 or newer
60
60
  - npm
61
- - `@earendil-works/pi-coding-agent` 0.84.2
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.84.2
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.84.2 | MIT | <https://github.com/earendil-works/pi> |
12
- | `@earendil-works/pi-ai` | 0.84.2 | MIT | <https://github.com/earendil-works/pi> |
13
- | `@earendil-works/pi-coding-agent` | 0.84.2 | MIT | <https://github.com/earendil-works/pi> |
14
- | `@earendil-works/pi-tui` | 0.84.2 | MIT | <https://github.com/earendil-works/pi> |
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 22.19 or newer and the tested Pi release `@earendil-works/pi-coding-agent@0.84.2`. Treat a different Pi version as a compatibility change and rerun the full suite before using it.
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 22.19 or newer. Install from the lockfile and run the source checks:
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.84.2
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.84.2`.
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.84.2. 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.
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.84.2. SoL-Pi creates no configurable storage-path surface.
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.84.2 default of 20,000 tokens for its economic estimate. Its programmatic factory accepts an explicit matching value for a non-default Pi setting.
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.84.2'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.
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.84.2 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.
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.84.2's public `renderCall`,
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.0",
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": ">=22.19.0"
62
+ "node": ">=24"
63
63
  },
64
64
  "pi": {
65
65
  "extensions": [