@herbertgao/pi-extensions 2026.8.12 → 2026.8.14

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 (156) hide show
  1. package/README.md +15 -8
  2. package/THIRD_PARTY_NOTICES.md +4 -0
  3. package/node_modules/@czottmann/pi-automode/CHANGELOG.md +12 -0
  4. package/node_modules/@czottmann/pi-automode/README.md +1 -1
  5. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +55 -4
  6. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +7 -3
  7. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +2 -0
  8. package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +134 -23
  9. package/node_modules/@czottmann/pi-automode/package.json +1 -1
  10. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
  11. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
  12. package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
  13. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  14. package/node_modules/@herbertgao/pi-subagents/package.json +2 -1
  15. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +8 -1
  16. package/node_modules/@luxusai/pi-hindsight/CHANGELOG.md +376 -0
  17. package/node_modules/@luxusai/pi-hindsight/README.md +92 -0
  18. package/node_modules/@luxusai/pi-hindsight/docs/adr/001-memory-lifecycle-and-scope.md +56 -0
  19. package/node_modules/@luxusai/pi-hindsight/docs/adr/002-explicit-routing-strategy-seam.md +169 -0
  20. package/node_modules/@luxusai/pi-hindsight/docs/adr/003-tui-memory-mode-vocabulary.md +107 -0
  21. package/node_modules/@luxusai/pi-hindsight/docs/adr/004-lifeos-dual-bank-design.md +89 -0
  22. package/node_modules/@luxusai/pi-hindsight/docs/adr/005-domain-banks-and-agent-first-surface.md +189 -0
  23. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark.webp +0 -0
  24. package/node_modules/@luxusai/pi-hindsight/docs/assets/logos/pi-hindsight-logo-dark@2x.webp +0 -0
  25. package/node_modules/@luxusai/pi-hindsight/docs/coding-memory-evaluation.md +54 -0
  26. package/node_modules/@luxusai/pi-hindsight/docs/compatibility.md +75 -0
  27. package/node_modules/@luxusai/pi-hindsight/docs/hindsight-core-functions.md +300 -0
  28. package/node_modules/@luxusai/pi-hindsight/docs/mission-and-mental-model-quality.md +158 -0
  29. package/node_modules/@luxusai/pi-hindsight/docs/next-opt-out-design.md +164 -0
  30. package/node_modules/@luxusai/pi-hindsight/docs/risky-memory-modes.md +139 -0
  31. package/node_modules/@luxusai/pi-hindsight/docs/starter-mental-model-suggestions.md +74 -0
  32. package/node_modules/@luxusai/pi-hindsight/docs/surface-reference.md +261 -0
  33. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-operations.ts +151 -0
  34. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-selection.ts +18 -0
  35. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-settings-presenter.ts +46 -0
  36. package/node_modules/@luxusai/pi-hindsight/extensions/banks/bank-templates.ts +383 -0
  37. package/node_modules/@luxusai/pi-hindsight/extensions/banks/banking.ts +240 -0
  38. package/node_modules/@luxusai/pi-hindsight/extensions/banks/knowledge-page-seed.ts +176 -0
  39. package/node_modules/@luxusai/pi-hindsight/extensions/banks/retain-strategies.ts +178 -0
  40. package/node_modules/@luxusai/pi-hindsight/extensions/client/client-retry.ts +41 -0
  41. package/node_modules/@luxusai/pi-hindsight/extensions/client/client.ts +386 -0
  42. package/node_modules/@luxusai/pi-hindsight/extensions/client/fetch-compat.ts +39 -0
  43. package/node_modules/@luxusai/pi-hindsight/extensions/client/timeout.ts +34 -0
  44. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-defaults.ts +140 -0
  45. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-model.ts +61 -0
  46. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-editing-registry.ts +925 -0
  47. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-field-paths.ts +247 -0
  48. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-normalize.ts +547 -0
  49. package/node_modules/@luxusai/pi-hindsight/extensions/config/config-writer.ts +480 -0
  50. package/node_modules/@luxusai/pi-hindsight/extensions/config/config.ts +182 -0
  51. package/node_modules/@luxusai/pi-hindsight/extensions/config/setup-gate.ts +86 -0
  52. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-execute.ts +1010 -0
  53. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-parse.ts +175 -0
  54. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-plan.ts +425 -0
  55. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-presentation.ts +210 -0
  56. package/node_modules/@luxusai/pi-hindsight/extensions/imports/import-sessions.ts +817 -0
  57. package/node_modules/@luxusai/pi-hindsight/extensions/index.ts +25 -0
  58. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/git-seed.ts +319 -0
  59. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-recall.ts +196 -0
  60. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-retain.ts +189 -0
  61. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle-runtime.ts +65 -0
  62. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/memory-lifecycle.ts +260 -0
  63. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/mental-models.ts +244 -0
  64. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/observation-scopes.ts +59 -0
  65. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-cleanup.ts +82 -0
  66. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall-visibility.ts +45 -0
  67. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/recall.ts +331 -0
  68. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-cursor.ts +354 -0
  69. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-job-builder.ts +66 -0
  70. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain-receipts.ts +132 -0
  71. package/node_modules/@luxusai/pi-hindsight/extensions/lifecycle/retain.ts +228 -0
  72. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-bank-template-operations.ts +74 -0
  73. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-config-operations.ts +16 -0
  74. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-control-operations.ts +648 -0
  75. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-diagnostics-operations.ts +105 -0
  76. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-identity.ts +68 -0
  77. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-service.ts +71 -0
  78. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-operation-types.ts +13 -0
  79. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-recall-operations.ts +162 -0
  80. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-retain-operations.ts +131 -0
  81. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-scope.ts +104 -0
  82. package/node_modules/@luxusai/pi-hindsight/extensions/operations/memory-session-operations.ts +37 -0
  83. package/node_modules/@luxusai/pi-hindsight/extensions/operations/operation-catalog.ts +893 -0
  84. package/node_modules/@luxusai/pi-hindsight/extensions/operations/reflect-presenter.ts +35 -0
  85. package/node_modules/@luxusai/pi-hindsight/extensions/operations/scope-migrate.ts +177 -0
  86. package/node_modules/@luxusai/pi-hindsight/extensions/operations/tools.ts +7 -0
  87. package/node_modules/@luxusai/pi-hindsight/extensions/queue/flush-presenter.ts +21 -0
  88. package/node_modules/@luxusai/pi-hindsight/extensions/queue/jsonl-queue-store.ts +112 -0
  89. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-delivery.ts +111 -0
  90. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-lock.ts +214 -0
  91. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue-operations.ts +70 -0
  92. package/node_modules/@luxusai/pi-hindsight/extensions/queue/queue.ts +392 -0
  93. package/node_modules/@luxusai/pi-hindsight/extensions/tui/bank-template-presentation.ts +45 -0
  94. package/node_modules/@luxusai/pi-hindsight/extensions/tui/commands.ts +9 -0
  95. package/node_modules/@luxusai/pi-hindsight/extensions/tui/guided-setup.ts +860 -0
  96. package/node_modules/@luxusai/pi-hindsight/extensions/tui/prefill-input.ts +105 -0
  97. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-flow.ts +189 -0
  98. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-server-probe.ts +299 -0
  99. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-actions.ts +201 -0
  100. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-facts.ts +47 -0
  101. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-render.ts +239 -0
  102. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui-types.ts +50 -0
  103. package/node_modules/@luxusai/pi-hindsight/extensions/tui/setup-tui.ts +259 -0
  104. package/node_modules/@luxusai/pi-hindsight/extensions/tui/tool-presenters.ts +77 -0
  105. package/node_modules/@luxusai/pi-hindsight/extensions/types.ts +534 -0
  106. package/node_modules/@luxusai/pi-hindsight/extensions/utils/diagnostics.ts +319 -0
  107. package/node_modules/@luxusai/pi-hindsight/extensions/utils/messages.ts +325 -0
  108. package/node_modules/@luxusai/pi-hindsight/extensions/utils/sanitize.ts +42 -0
  109. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-memory-meta.ts +244 -0
  110. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session-operations.ts +56 -0
  111. package/node_modules/@luxusai/pi-hindsight/extensions/utils/session.ts +50 -0
  112. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-fields.ts +167 -0
  113. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status-health.ts +207 -0
  114. package/node_modules/@luxusai/pi-hindsight/extensions/utils/status.ts +120 -0
  115. package/node_modules/@luxusai/pi-hindsight/extensions/version.ts +8 -0
  116. package/node_modules/@luxusai/pi-hindsight/package.json +118 -0
  117. package/node_modules/@luxusai/pi-hindsight/skills/hindsight-memory-doctor/SKILL.md +75 -0
  118. package/node_modules/@narumitw/pi-btw/package.json +2 -2
  119. package/node_modules/@tifan/pi-preferred-thinking/README.md +1 -1
  120. package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
  121. package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +15 -2
  122. package/node_modules/pi-mcp-adapter/CHANGELOG.md +33 -0
  123. package/node_modules/pi-mcp-adapter/README.md +3 -0
  124. package/node_modules/pi-mcp-adapter/cli.js +4 -4
  125. package/node_modules/pi-mcp-adapter/config.ts +11 -0
  126. package/node_modules/pi-mcp-adapter/dist/config.js +11 -0
  127. package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
  128. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +24 -0
  129. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +336 -0
  130. package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +1 -0
  131. package/node_modules/pi-mcp-adapter/dist/types.d.ts +2 -0
  132. package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
  133. package/node_modules/pi-mcp-adapter/index.ts +90 -6
  134. package/node_modules/pi-mcp-adapter/init.ts +5 -1
  135. package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +19 -0
  136. package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -2
  137. package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +89 -0
  138. package/node_modules/pi-mcp-adapter/mcp-references.ts +9 -1
  139. package/node_modules/pi-mcp-adapter/package.json +1 -1
  140. package/node_modules/pi-mcp-adapter/proxy-modes.ts +40 -10
  141. package/node_modules/pi-mcp-adapter/request-headers-command.ts +1 -1
  142. package/node_modules/pi-mcp-adapter/types.ts +2 -0
  143. package/node_modules/pi-web-access/CHANGELOG.md +22 -0
  144. package/node_modules/pi-web-access/README.md +11 -8
  145. package/node_modules/pi-web-access/curator-page.ts +12 -3
  146. package/node_modules/pi-web-access/curator-server.ts +3 -1
  147. package/node_modules/pi-web-access/extract.ts +31 -1
  148. package/node_modules/pi-web-access/gemini-search.ts +10 -5
  149. package/node_modules/pi-web-access/index.ts +39 -39
  150. package/node_modules/pi-web-access/package.json +1 -1
  151. package/node_modules/pi-web-access/xcrawl.ts +264 -0
  152. package/package.json +15 -12
  153. package/node_modules/@herbertgao/pi-stash/LICENSE +0 -22
  154. package/node_modules/@herbertgao/pi-stash/README.md +0 -34
  155. package/node_modules/@herbertgao/pi-stash/package.json +0 -51
  156. package/node_modules/@herbertgao/pi-stash/src/index.ts +0 -118
package/README.md CHANGED
@@ -10,30 +10,33 @@ pi install npm:@herbertgao/pi-extensions
10
10
 
11
11
  Requires Node.js 24 or newer.
12
12
 
13
- The package bundles 4 active `@herbertgao/*` child packages—`pi-cc-extensions`, `resume-from`, `pi-stash`, and `pi-subagents`—plus the following upstream packages under their original names:
13
+ The package bundles 3 active `@herbertgao/*` child packages—`pi-cc-extensions`, `resume-from`, and `pi-subagents`—plus the following upstream packages under their original names:
14
14
 
15
15
  - `@dietrichgebert/ponytail@4.9.0`
16
16
  - `@juicesharp/rpiv-ask-user-question@2.7.1`
17
- - `@narumitw/pi-btw@0.55.3`
17
+ - `@luxusai/pi-hindsight@0.12.0`
18
+ - `@narumitw/pi-btw@0.55.4`
18
19
  - `@pi-plugins/fast-mode@0.1.10`
19
20
  - `@tifan/pi-copy-response@0.2.6`
20
21
  - `@tifan/pi-handoff@2.0.1`
21
22
  - `@tifan/pi-inline-skills@1.0.5`
22
23
  - `@tifan/pi-mermaid-open@0.2.0`
23
- - `@tifan/pi-preferred-thinking@1.0.0`
24
+ - `@tifan/pi-preferred-thinking@1.0.1`
24
25
  - `@tifan/pi-recap@0.4.5`
25
26
  - `@tifan/pi-rename@0.5.1`
26
27
  - `@tifan/pi-titlebar-spinner@0.1.3`
27
- - `pi-mcp-adapter@2.28.0`
28
+ - `pi-mcp-adapter@2.30.0`
28
29
  - `pi-footer@0.5.1`
29
30
  - `pi-lens@4.1.2`
30
- - `pi-web-access@0.25.0`
31
+ - `pi-web-access@0.26.0`
31
32
  - `remote-pi@0.7.0`
32
- - `@czottmann/pi-automode@1.13.0`
33
+ - `@czottmann/pi-automode@1.14.0`
33
34
 
34
35
  Pi loads their extensions and skills through `node_modules/` paths inside one package root. The upstream companions are pinned and bundled, not forked or renamed.
35
36
 
36
- `@herbertgao/resume-from@0.2.0` keeps Claude Code sessions associated with their original repository when the active transcript later moves into a nested cwd. `pi-lens@4.1.2` improves delayed LSP diagnostics, stale-result cleanup, process cleanup, and snapshot completeness. `pi-automode@1.13.0` parses shell commands before applying policy and migrates legacy configuration safely. `pi-web-access@0.25.0` adds opt-in proxy and cloud-auth providers plus GitHub-aware fetching and a Defuddle extraction fallback.
37
+ `@herbertgao/resume-from@0.2.0` keeps Claude Code sessions associated with their original repository when the active transcript later moves into a nested cwd. `pi-lens@4.1.2` improves delayed LSP diagnostics, stale-result cleanup, process cleanup, and snapshot completeness. `pi-automode@1.14.0` bounds classifier streams and permits only validated temporary-directory subtrees. `pi-web-access@0.26.0` adds explicit XCrawl search plus safer query and extraction fallbacks. Preferred Thinking 1.0.1 preserves an explicit subagent `--thinking` choice.
38
+
39
+ `pi-stash` is no longer bundled: `/btw` already preserves the main editor draft while handling side questions outside the main conversation. Prior `@herbertgao/pi-stash` releases remain available but are no longer maintained here.
37
40
 
38
41
  If `pi-footer` was installed separately before upgrading to an aggregate release that includes it, remove the standalone source shown by `pi list` so only the bundled copy loads. For the pinned standalone install used while preparing this integration:
39
42
 
@@ -77,6 +80,10 @@ The copy command replaces an existing `pi-footer.json`; review or back it up fir
77
80
 
78
81
  Pi 0.84.1 or newer should use native `fullscreen` TUI mode.
79
82
 
83
+ ### Hindsight memory server
84
+
85
+ `@luxusai/pi-hindsight` is enabled by the aggregate, but automatic memory network I/O stays behind its setup gate until a server and coding bank are configured. Run `/hindsight` for guided setup. Prefer a self-hosted, authenticated endpoint reachable only over Tailscale or another private network; use one shared coding bank with stable project tags for cross-host development, and keep user memory disabled unless explicitly needed.
86
+
80
87
  ### Remote Pi trust boundary
81
88
 
82
89
  Configure `REMOTE_PI_RELAY` to a private relay, preferably reachable only through Tailscale or another private network, **before** first running `/remote-pi`. TLS/Tailscale protects traffic in transit but the relay process can read routed content; `remote-pi@0.7.0` is not end-to-end encrypted.
@@ -87,4 +94,4 @@ See the [repository README](https://github.com/HerbertGao/pi-extensions#readme)
87
94
 
88
95
  ## License
89
96
 
90
- [MIT](LICENSE). Bundled Tifan package notices are included in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
97
+ [MIT](LICENSE). Bundled upstream notices are included in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -34,3 +34,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34
34
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35
35
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36
36
  THE SOFTWARE.
37
+
38
+ ## `@luxusai/pi-hindsight`
39
+
40
+ The aggregate also bundles [`@luxusai/pi-hindsight`](https://github.com/luxus/pi-hindsight) version 0.12.0. Its published `package.json` declares the SPDX license identifier `MIT`. The reviewed upstream repository and npm tarball do not currently include a standalone license or copyright notice, so this aggregate does not invent one; it preserves the published package metadata and upstream attribution verbatim.
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [Unreleased]
6
+
7
+ ## [1.14.0] - 2026-08-27
8
+
9
+ ## Bug fixes
10
+
11
+ - **Classifier stream timeout** — Apply `classifierTimeoutMs` to the full response stream. Provider behavior cannot keep classifier calls pending after the deadline. Parent cancellation remains active. Reject values above the Node.js timer limit. (#30)
12
+ - **OS temp-directory deletes** — Stop hard-denying recursive-delete subtrees under `os.tmpdir()` and `/tmp`. On macOS these resolve into `/private/tmp` and `/private/var/folders`, which matched the `/private` system root and blocked every temp cleanup. Deleting a temp root itself stays blocked. (#31)
13
+ - **Validated temp-root declarations** — Derive the exempt temp roots only from launcher-declared values that stay safe: reject values such as `/`, empty strings, aliases of `HOME`, `/`, or a system root, and ancestors of `HOME`. Without validation, a malformed `TMPDIR` could disable deterministic denials for protected targets, and a broad `permissions.allow` rule could then allow the action without classifier review. Recompute candidates when the effective tmpdir changes. (#31)
14
+
5
15
  ## [1.13.0] - 2026-08-25
6
16
 
7
17
  ## New features
@@ -35,5 +45,7 @@ All notable changes to this project are documented in this file.
35
45
  - **Project config trust gate** — Ignore `.pi/automode.local.json` and `.pi/automode.json` until Pi trusts the project. Apply the trust gate during startup and config reloads. (#16)
36
46
  - **In-memory observability logs** — Write logs to an extension-owned directory (`~/.pi/agent/extensions/pi-automode/logs/`) instead of the launching project directory. Thanks, @HerbertGao! (#13)
37
47
 
48
+ [Unreleased]: https://github.com/czottmann/pi-automode/compare/v1.14.0...HEAD
49
+ [1.14.0]: https://github.com/czottmann/pi-automode/compare/v1.13.0...v1.14.0
38
50
  [1.13.0]: https://github.com/czottmann/pi-automode/compare/v1.12.0...v1.13.0
39
51
  [1.12.0]: https://github.com/czottmann/pi-automode/compare/v1.11.0...v1.12.0
@@ -101,7 +101,7 @@ The extension blocks these before any allow or classifier decision:
101
101
  - SSH `authorized_keys` writes
102
102
  - cron, launch agent, and system service persistence
103
103
  - TLS/certificate/auth weakening patterns
104
- - root, home, and system-path destructive deletes
104
+ - root, home, and system-path destructive deletes. Subtrees of validated launcher-declared temp directories are treated as disposable. Declared roots that alias `HOME`, `/`, or a system root, or that contain `HOME`, are rejected instead.
105
105
  - edits to `.pi/automode*`, `.pi` auto-mode files, and this extension's safety-control files
106
106
 
107
107
  After these checks, pi-automode applies `permissions.allow`. Protected `write` and `edit` targets continue to the classifier.
@@ -155,6 +155,55 @@ export type ClassifierCompletionPlan = {
155
155
  reasoningLevel?: Exclude<EffectiveClassifierReasoningLevel, "off">;
156
156
  };
157
157
 
158
+ async function completeClassifierAttempt(
159
+ completeFn: ClassifierCompletionFn,
160
+ model: Model<any>,
161
+ prompt: Parameters<ClassifierCompletionFn>[1],
162
+ parentSignal: AbortSignal | undefined,
163
+ options: Omit<Parameters<ClassifierCompletionFn>[2], "signal">,
164
+ ): Promise<AssistantMessage> {
165
+ if (options.timeoutMs === undefined) {
166
+ return completeFn(model, prompt, {
167
+ ...options,
168
+ ...(parentSignal === undefined ? {} : { signal: parentSignal }),
169
+ });
170
+ }
171
+
172
+ const controller = new AbortController();
173
+ const onParentAbort = () => controller.abort(parentSignal?.reason);
174
+ if (parentSignal?.aborted) onParentAbort();
175
+ else parentSignal?.addEventListener("abort", onParentAbort, { once: true });
176
+
177
+ let onAbort: (() => void) | undefined;
178
+ const aborted = new Promise<never>((_resolve, reject) => {
179
+ onAbort = () => {
180
+ const reason = controller.signal.reason;
181
+ reject(reason instanceof Error ? reason : new Error("Classifier request aborted."));
182
+ };
183
+ if (controller.signal.aborted) onAbort();
184
+ else controller.signal.addEventListener("abort", onAbort, { once: true });
185
+ });
186
+ const timer = setTimeout(() => {
187
+ controller.abort(
188
+ new Error(`Classifier request timed out after ${options.timeoutMs} ms.`),
189
+ );
190
+ }, options.timeoutMs);
191
+
192
+ try {
193
+ return await Promise.race([
194
+ completeFn(model, prompt, {
195
+ ...options,
196
+ signal: controller.signal,
197
+ }),
198
+ aborted,
199
+ ]);
200
+ } finally {
201
+ clearTimeout(timer);
202
+ if (onAbort) controller.signal.removeEventListener("abort", onAbort);
203
+ parentSignal?.removeEventListener("abort", onParentAbort);
204
+ }
205
+ }
206
+
158
207
  /**
159
208
  * Run normalized Pi AI completion through the provider in Pi's runtime registry.
160
209
  * This temporary bridge is only valid until Pi exposes
@@ -435,14 +484,15 @@ export async function classifyWithRetry(
435
484
  const started = Date.now();
436
485
  let response: AssistantMessage;
437
486
  try {
438
- response = await completeFn(
487
+ response = await completeClassifierAttempt(
488
+ completeFn,
439
489
  classifier.model,
440
490
  prompt,
491
+ signal,
441
492
  {
442
493
  apiKey: classifier.apiKey,
443
494
  headers: classifier.headers,
444
495
  env: classifier.env,
445
- signal,
446
496
  maxTokens,
447
497
  ...(temperature === undefined ? {} : { temperature }),
448
498
  ...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
@@ -505,7 +555,8 @@ export async function classifyInStages(
505
555
  const fastStarted = Date.now();
506
556
  let fastResponse: AssistantMessage;
507
557
  try {
508
- fastResponse = await completeFn(
558
+ fastResponse = await completeClassifierAttempt(
559
+ completeFn,
509
560
  classifier.model,
510
561
  {
511
562
  systemPrompt: prompt.systemPrompt,
@@ -515,11 +566,11 @@ export async function classifyInStages(
515
566
  stageMessage(CLASSIFIER_FAST_INSTRUCTION),
516
567
  ],
517
568
  },
569
+ signal,
518
570
  {
519
571
  apiKey: classifier.apiKey,
520
572
  headers: classifier.headers,
521
573
  env: classifier.env,
522
- signal,
523
574
  // Reasoning and OpenAI-compatible models may consume hidden reasoning,
524
575
  // control, and EOS tokens before emitting the required visible digit.
525
576
  maxTokens: options.fastClassifierMaxTokens ??
@@ -22,6 +22,7 @@ import {
22
22
  DEFAULT_MAX_USER_TRANSCRIPT_TOKENS,
23
23
  DEFAULT_PROTECTED_PATHS,
24
24
  DEFAULT_SOFT_DENY,
25
+ MAX_CLASSIFIER_TIMEOUT_MS,
25
26
  PI_GLOBAL_SETTINGS,
26
27
  PI_LEGACY_GLOBAL_SETTINGS,
27
28
  PI_PROJECT_LOCAL_SETTINGS,
@@ -324,10 +325,11 @@ export function validateSettingsFile(
324
325
  if (
325
326
  hasOwn(autoMode, "classifierTimeoutMs") &&
326
327
  (!Number.isInteger(autoMode.classifierTimeoutMs) ||
327
- (autoMode.classifierTimeoutMs as number) < 1000)
328
+ (autoMode.classifierTimeoutMs as number) < 1000 ||
329
+ (autoMode.classifierTimeoutMs as number) > MAX_CLASSIFIER_TIMEOUT_MS)
328
330
  ) {
329
331
  diagnostics.push(
330
- `${source}: autoMode.classifierTimeoutMs must be an integer of at least 1000`,
332
+ `${source}: autoMode.classifierTimeoutMs must be an integer from 1000 through ${MAX_CLASSIFIER_TIMEOUT_MS}`,
331
333
  );
332
334
  }
333
335
  if (
@@ -591,7 +593,9 @@ function validFastClassifierBudget(value: unknown): value is number {
591
593
  }
592
594
 
593
595
  function validClassifierTimeout(value: unknown): value is number {
594
- return Number.isInteger(value) && Number(value) >= 1000;
596
+ return Number.isInteger(value) &&
597
+ Number(value) >= 1000 &&
598
+ Number(value) <= MAX_CLASSIFIER_TIMEOUT_MS;
595
599
  }
596
600
 
597
601
  function applyAutoModeScalars(
@@ -61,6 +61,8 @@ export const DENIAL_HISTORY_LIMIT = 12;
61
61
 
62
62
  /** Per-request timeout for classifier completions (fast and detailed stages). */
63
63
  export const DEFAULT_CLASSIFIER_TIMEOUT_MS = 20_000;
64
+ /** Largest timeout that Node can represent without reducing it to 1 ms. */
65
+ export const MAX_CLASSIFIER_TIMEOUT_MS = 2_147_483_647;
64
66
 
65
67
  /** Built-in trusted environment. Users extend this with `$defaults`. */
66
68
  export const DEFAULT_ENVIRONMENT = [
@@ -1,4 +1,5 @@
1
1
  import { statSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
2
3
  import { resolve } from "node:path";
3
4
  import {
4
5
  analyzeBash,
@@ -77,9 +78,115 @@ function matchesPathRoot(path: string, root: string): boolean {
77
78
  return isSameExistingPath(path.slice(0, root.length), root);
78
79
  }
79
80
 
81
+ /**
82
+ * Top-level directories whose deletion or wholesale modification is a
83
+ * system-wide event. Shared between candidate validation and path
84
+ * classification; do not inline copies.
85
+ */
86
+ const SYSTEM_ROOTS: ReadonlyArray<string> = [
87
+ "/bin",
88
+ "/boot",
89
+ "/dev",
90
+ "/etc",
91
+ "/home",
92
+ "/lib",
93
+ "/lib64",
94
+ "/Library",
95
+ "/private",
96
+ "/proc",
97
+ "/root",
98
+ "/run",
99
+ "/sbin",
100
+ "/sys",
101
+ "/System",
102
+ "/usr",
103
+ "/var",
104
+ ];
105
+
106
+ /**
107
+ * Normalize a proposed temp-root value into a comparable absolute path.
108
+ * Returns undefined for values that cannot denote a subdirectory: the
109
+ * empty string, `/`, and slash-only artifacts.
110
+ */
111
+ function normalizeRootCandidate(value: string): string | undefined {
112
+ const stripped = value.replace(/\/+$/, "");
113
+ // An empty stripped value must not fall through to `resolve()`, which
114
+ // would silently turn `/` into the process working directory.
115
+ if (!stripped) return undefined;
116
+ const normalized = resolve(stripped);
117
+ if (normalized === "/") return undefined;
118
+ return normalized;
119
+ }
120
+
121
+ /**
122
+ * True when a candidate temp root would weaken the deterministic deny tiers:
123
+ * it aliases (exact, case-folded, or dev/inode) `HOME`, `/`, or any system
124
+ * root, or it is a proper ancestor of the canonical home directory.
125
+ *
126
+ * Dev/inode identity covers symlinked spellings of existing directories;
127
+ * string comparison alone handles candidates that do not exist yet. See
128
+ * issue #31: without these guards, `TMPDIR=/` reduced every absolute path
129
+ * below an empty-string prefix match, and `TMPDIR=/private` made
130
+ * `/private/etc/**` disposable.
131
+ */
132
+ function conflictsWithProtectedRoots(candidate: string, home: string): boolean {
133
+ if (candidate === "/") return true;
134
+ for (const protectedRoot of ["/", home, ...SYSTEM_ROOTS]) {
135
+ const canonical = resolve(protectedRoot);
136
+ if (
137
+ candidate === canonical ||
138
+ candidate.toLowerCase() === canonical.toLowerCase()
139
+ ) {
140
+ return true;
141
+ }
142
+ if (isSameExistingPath(candidate, canonical)) return true;
143
+ }
144
+ const homeCanonical = resolvePathForPolicy(home) ?? resolve(home);
145
+ return homeCanonical.toLowerCase().startsWith(`${candidate.toLowerCase()}/`);
146
+ }
147
+
148
+ let cachedTempRoots: ReadonlyArray<string> | undefined;
149
+ let cachedTmpdirValue: string | undefined;
150
+
151
+ /**
152
+ * Validated launcher-declared temp-dir roots whose subtrees are treated as
153
+ * disposable by `isRootHomeOrSystemPath`: the platform tmpdir, plus `/tmp` on
154
+ * macOS where it exists independently of `os.tmpdir()`. Each root appears in
155
+ * canonical and resolved spelling because callers pass symlink-resolved
156
+ * policy paths (`/tmp` → `/private/tmp` on macOS) and unresolved fallbacks
157
+ * alike. Values from `os.tmpdir()` are not trusted blindly; see
158
+ * `conflictsWithProtectedRoots`. The roots themselves are never exempt:
159
+ * deleting one is a system-wide delete.
160
+ *
161
+ * The memoization keys on the effective `os.tmpdir()` return value so tests
162
+ * can mutate `TMPDIR`, `TMP`, or `TEMP` between calls.
163
+ */
164
+ export function tempRootCandidates(): ReadonlyArray<string> {
165
+ const currentTmpdir = tmpdir();
166
+ if (cachedTempRoots && cachedTmpdirValue === currentTmpdir) {
167
+ return cachedTempRoots;
168
+ }
169
+ cachedTmpdirValue = currentTmpdir;
170
+ cachedTempRoots = (() => {
171
+ const roots = new Set<string>();
172
+ const consider = (value: string) => {
173
+ const candidate = normalizeRootCandidate(value);
174
+ if (!candidate || conflictsWithProtectedRoots(candidate, HOME)) return;
175
+ roots.add(candidate);
176
+ const resolved = resolvePathForPolicy(candidate);
177
+ if (resolved) roots.add(resolved);
178
+ };
179
+ consider(currentTmpdir);
180
+ if (process.platform === "darwin") consider("/tmp");
181
+ return [...roots];
182
+ })();
183
+ return cachedTempRoots;
184
+ }
185
+
80
186
  /**
81
187
  * True for `/`, the user's home root, or a top-level system root such as
82
- * `/etc`, `/usr`, or `/var`. Excludes the home *subtree*.
188
+ * `/etc`, `/usr`, or `/var`. Excludes the home *subtree* and the subtrees of
189
+ * platform temp directories (`os.tmpdir()` and `/tmp` on macOS).
83
190
  *
84
191
  * On some distros (e.g. Fedora Silverblue) HOME lives under `/var`, which is
85
192
  * in `systemRoots`. Without the subtree exemption, `path.startsWith("/var/")`
@@ -87,32 +194,36 @@ function matchesPathRoot(path: string, root: string): boolean {
87
194
  * `rm -rf ~/...`. HOME itself is still matched below, so `rm -rf ~` stays
88
195
  * blocked. `home` is a parameter so this can be unit-tested with a synthetic
89
196
  * `/var/home/...` value.
197
+ *
198
+ * The temp exemption mirrors the home one and covers cleanup of directories
199
+ * created with `mktemp`, `os.tmpdir()`, or plain `/tmp` paths. On macOS these
200
+ * resolve into `/private/tmp` or `/private/var/folders`, which used to match
201
+ * the `/private` system root and hard-deny every temp cleanup. Deleting a
202
+ * temp root itself still returns true; `tempRoots` is injectable for tests.
203
+ *
204
+ * Protection order matters (issue #31): exact `/`, the exact home root, and
205
+ * system roots win over every exemption. Injected `tempRoots` values are
206
+ * validated per call so hostile or malformed candidates cannot weaken the
207
+ * deterministic tiers.
90
208
  */
91
- export function isRootHomeOrSystemPath(path: string, home: string): boolean {
92
- const systemRoots = [
93
- "/bin",
94
- "/boot",
95
- "/dev",
96
- "/etc",
97
- "/home",
98
- "/lib",
99
- "/lib64",
100
- "/Library",
101
- "/private",
102
- "/proc",
103
- "/root",
104
- "/run",
105
- "/sbin",
106
- "/sys",
107
- "/System",
108
- "/usr",
109
- "/var",
110
- ];
209
+ export function isRootHomeOrSystemPath(
210
+ path: string,
211
+ home: string,
212
+ tempRoots: ReadonlyArray<string> = tempRootCandidates(),
213
+ ): boolean {
214
+ if (path === "/") return true;
215
+ if (path === home || isSameExistingPath(path, home)) return true;
111
216
  if (matchesPathRoot(path, home) && path.length > home.length) return false;
217
+ for (const root of tempRoots) {
218
+ const candidate = normalizeRootCandidate(root);
219
+ if (!candidate || conflictsWithProtectedRoots(candidate, home)) continue;
220
+ if (!matchesPathRoot(path, candidate)) continue;
221
+ // Subtree: disposable. Exact match: the temp root stays protected.
222
+ return path.length > candidate.length ? false : true;
223
+ }
112
224
  return (
113
- path === "/" ||
114
225
  matchesPathRoot(path, home) ||
115
- systemRoots.some((root) => matchesPathRoot(path, root))
226
+ SYSTEM_ROOTS.some((root) => matchesPathRoot(path, root))
116
227
  );
117
228
  }
118
229
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@czottmann/pi-automode",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "Claude Code-style auto mode guardrail for pi.",
5
5
  "repository": {
6
6
  "url": "https://github.com/czottmann/pi-automode"
@@ -102,5 +102,5 @@ bun run typecheck
102
102
 
103
103
  ## Credits
104
104
 
105
- - Derived from [`minuque/pi-cc-extensions` v0.8.67](https://github.com/minuque/pi-cc-extensions/releases/tag/v0.8.67) (`bc58504`) under the MIT license.
105
+ - Derived from [`minuque/pi-cc-extensions` v0.8.68](https://github.com/minuque/pi-cc-extensions/releases/tag/v0.8.68) (`1ca144c`) under the MIT license.
106
106
  - Rich diffs are adapted from [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display) (MIT). See [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md).
@@ -102,5 +102,5 @@ bun run typecheck
102
102
 
103
103
  ## 致谢
104
104
 
105
- - 基于 MIT 许可的 [`minuque/pi-cc-extensions` v0.8.67](https://github.com/minuque/pi-cc-extensions/releases/tag/v0.8.67)(`bc58504`)衍生维护。
105
+ - 基于 MIT 许可的 [`minuque/pi-cc-extensions` v0.8.68](https://github.com/minuque/pi-cc-extensions/releases/tag/v0.8.68)(`1ca144c`)衍生维护。
106
106
  - Rich diff 改编自 [`MasuRii/pi-tool-display`](https://github.com/MasuRii/pi-tool-display)(MIT);详见 [`extensions/renderer/tool/diff/ATTRIBUTION.md`](./extensions/renderer/tool/diff/ATTRIBUTION.md)。
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-cc-extensions",
3
- "version": "0.8.59",
3
+ "version": "0.8.60",
4
4
  "license": "MIT",
5
5
  "description": "A Pi productivity suite with Claude Code-style UI, context inspection, and agent/session references",
6
6
  "type": "module",
@@ -69,8 +69,8 @@
69
69
  },
70
70
  "x-upstream": {
71
71
  "package": "pi-cc-extensions",
72
- "version": "0.8.67",
72
+ "version": "0.8.68",
73
73
  "repository": "https://github.com/minuque/pi-cc-extensions",
74
- "commit": "bc585044e3032f1368560bb289fb4485389ead99"
74
+ "commit": "1ca144c8fa3f2b391fd76d008f0148e04bad14be"
75
75
  }
76
76
  }
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.17.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#132](https://github.com/HerbertGao/pi-extensions/pull/132) [`e873d36`](https://github.com/HerbertGao/pi-extensions/commit/e873d36513deb902028faa0bf095641a57cb2ae4) Thanks [@HerbertGao](https://github.com/HerbertGao)! - Review pi-subagents 0.19.0 and adopt readable bounded-result counts while retaining the unsigned worktree-preservation safeguard that upstream still lacks.
8
+
3
9
  ## 0.17.0
4
10
 
5
11
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@herbertgao/pi-subagents",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Claude Code-style autonomous subagents for Pi, with HerbertGao-maintained UI extensions.",
5
5
  "keywords": [
6
6
  "agent",
@@ -69,6 +69,7 @@
69
69
  "x-upstream": {
70
70
  "package": "@tintinweb/pi-subagents",
71
71
  "version": "0.18.2",
72
+ "reviewedVersion": "0.19.0",
72
73
  "repository": "https://github.com/tintinweb/pi-subagents",
73
74
  "commit": "ad81024825b315577692b785831262874e66be95"
74
75
  }
@@ -156,8 +156,15 @@ function capResult(text: string): { text: string; elided: number } {
156
156
  }
157
157
  }
158
158
 
159
+ function humanCount(count: number): string {
160
+ if (count < 1_000) return `${count}`
161
+ const thousands = count < 999_950
162
+ const value = thousands ? count / 1_000 : count / 1_000_000
163
+ return `${value.toFixed(1).replace(/\.0$/, "")}${thousands ? "k" : "M"}`
164
+ }
165
+
159
166
  function truncationNote(elided: number): string {
160
- return `... (truncated, ${elided} more character${elided === 1 ? "" : "s"})`
167
+ return `... (truncated, ${humanCount(elided)} more character${elided === 1 ? "" : "s"})`
161
168
  }
162
169
 
163
170
  export class ConversationViewer implements Component {