@herbertgao/pi-extensions 2026.8.13 → 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.
- package/README.md +8 -6
- package/node_modules/@czottmann/pi-automode/CHANGELOG.md +12 -0
- package/node_modules/@czottmann/pi-automode/README.md +1 -1
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/classifier.ts +55 -4
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/config.ts +7 -3
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/constants.ts +2 -0
- package/node_modules/@czottmann/pi-automode/extensions/auto-mode/hard-deny.ts +134 -23
- package/node_modules/@czottmann/pi-automode/package.json +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
- package/node_modules/@herbertgao/pi-cc-extensions/package.json +3 -3
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +2 -1
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +8 -1
- package/node_modules/@tifan/pi-preferred-thinking/README.md +1 -1
- package/node_modules/@tifan/pi-preferred-thinking/package.json +1 -1
- package/node_modules/@tifan/pi-preferred-thinking/src/index.ts +15 -2
- package/node_modules/pi-mcp-adapter/CHANGELOG.md +20 -0
- package/node_modules/pi-mcp-adapter/README.md +3 -0
- package/node_modules/pi-mcp-adapter/cli.js +4 -4
- package/node_modules/pi-mcp-adapter/config.ts +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.js +1 -0
- package/node_modules/pi-mcp-adapter/dist/config.js.map +1 -1
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.d.ts +24 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js +336 -0
- package/node_modules/pi-mcp-adapter/dist/mcp-bearer-store.js.map +1 -0
- package/node_modules/pi-mcp-adapter/dist/types.d.ts +2 -0
- package/node_modules/pi-mcp-adapter/dist/types.js.map +1 -1
- package/node_modules/pi-mcp-adapter/index.ts +90 -6
- package/node_modules/pi-mcp-adapter/mcp-auth-flow.ts +19 -0
- package/node_modules/pi-mcp-adapter/mcp-bearer-store.ts +0 -2
- package/node_modules/pi-mcp-adapter/mcp-oauth-provider.ts +89 -0
- package/node_modules/pi-mcp-adapter/mcp-references.ts +9 -1
- package/node_modules/pi-mcp-adapter/package.json +1 -1
- package/node_modules/pi-mcp-adapter/proxy-modes.ts +40 -10
- package/node_modules/pi-mcp-adapter/request-headers-command.ts +1 -1
- package/node_modules/pi-mcp-adapter/types.ts +2 -0
- package/node_modules/pi-web-access/CHANGELOG.md +22 -0
- package/node_modules/pi-web-access/README.md +11 -8
- package/node_modules/pi-web-access/curator-page.ts +12 -3
- package/node_modules/pi-web-access/curator-server.ts +3 -1
- package/node_modules/pi-web-access/extract.ts +31 -1
- package/node_modules/pi-web-access/gemini-search.ts +10 -5
- package/node_modules/pi-web-access/index.ts +39 -39
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/xcrawl.ts +264 -0
- package/package.json +7 -10
- package/node_modules/@herbertgao/pi-stash/LICENSE +0 -22
- package/node_modules/@herbertgao/pi-stash/README.md +0 -34
- package/node_modules/@herbertgao/pi-stash/package.json +0 -51
- package/node_modules/@herbertgao/pi-stash/src/index.ts +0 -118
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ pi install npm:@herbertgao/pi-extensions
|
|
|
10
10
|
|
|
11
11
|
Requires Node.js 24 or newer.
|
|
12
12
|
|
|
13
|
-
The package bundles
|
|
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`
|
|
@@ -21,20 +21,22 @@ The package bundles 4 active `@herbertgao/*` child packages—`pi-cc-extensions`
|
|
|
21
21
|
- `@tifan/pi-handoff@2.0.1`
|
|
22
22
|
- `@tifan/pi-inline-skills@1.0.5`
|
|
23
23
|
- `@tifan/pi-mermaid-open@0.2.0`
|
|
24
|
-
- `@tifan/pi-preferred-thinking@1.0.
|
|
24
|
+
- `@tifan/pi-preferred-thinking@1.0.1`
|
|
25
25
|
- `@tifan/pi-recap@0.4.5`
|
|
26
26
|
- `@tifan/pi-rename@0.5.1`
|
|
27
27
|
- `@tifan/pi-titlebar-spinner@0.1.3`
|
|
28
|
-
- `pi-mcp-adapter@2.
|
|
28
|
+
- `pi-mcp-adapter@2.30.0`
|
|
29
29
|
- `pi-footer@0.5.1`
|
|
30
30
|
- `pi-lens@4.1.2`
|
|
31
|
-
- `pi-web-access@0.
|
|
31
|
+
- `pi-web-access@0.26.0`
|
|
32
32
|
- `remote-pi@0.7.0`
|
|
33
|
-
- `@czottmann/pi-automode@1.
|
|
33
|
+
- `@czottmann/pi-automode@1.14.0`
|
|
34
34
|
|
|
35
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.
|
|
36
36
|
|
|
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.
|
|
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.
|
|
38
40
|
|
|
39
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:
|
|
40
42
|
|
|
@@ -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
|
|
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
|
|
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
|
|
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) &&
|
|
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(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
-
|
|
226
|
+
SYSTEM_ROOTS.some((root) => matchesPathRoot(path, root))
|
|
116
227
|
);
|
|
117
228
|
}
|
|
118
229
|
|
|
@@ -102,5 +102,5 @@ bun run typecheck
|
|
|
102
102
|
|
|
103
103
|
## Credits
|
|
104
104
|
|
|
105
|
-
- Derived from [`minuque/pi-cc-extensions` v0.8.
|
|
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.
|
|
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.
|
|
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.
|
|
72
|
+
"version": "0.8.68",
|
|
73
73
|
"repository": "https://github.com/minuque/pi-cc-extensions",
|
|
74
|
-
"commit": "
|
|
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.
|
|
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 {
|
|
@@ -41,7 +41,7 @@ The extension requires `enabledModels` to exist before it can save a pin. If
|
|
|
41
41
|
the selected model is not listed, it adds an exact entry without removing other
|
|
42
42
|
models or patterns.
|
|
43
43
|
|
|
44
|
-
The old
|
|
44
|
+
The old `$PI_CODING_AGENT_DIR/extensions/pi-preferred-thinking.json` file is no longer
|
|
45
45
|
read. Existing users must move preferences to `enabledModels` or set them with
|
|
46
46
|
`/preferred-thinking`.
|
|
47
47
|
|
|
@@ -138,6 +138,15 @@ function showHint(ctx: ExtensionContext, modelKey: string): void {
|
|
|
138
138
|
}, HINT_DURATION_MS)
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
function hasExplicitSubagentThinking(): boolean {
|
|
142
|
+
return (
|
|
143
|
+
Boolean(process.env["PI_SUBAGENT_ID"]) &&
|
|
144
|
+
process.argv.some(
|
|
145
|
+
(arg) => arg === "--thinking" || arg.startsWith("--thinking="),
|
|
146
|
+
)
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
141
150
|
function applyPreferredThinking(
|
|
142
151
|
pi: ExtensionAPI,
|
|
143
152
|
ctx: ExtensionContext,
|
|
@@ -210,11 +219,15 @@ export default function (pi: ExtensionAPI): void {
|
|
|
210
219
|
|
|
211
220
|
pi.on("session_start", async (_event, ctx) => {
|
|
212
221
|
nudgedModels.clear()
|
|
213
|
-
if (ctx.model
|
|
222
|
+
if (ctx.model && !hasExplicitSubagentThinking()) {
|
|
223
|
+
applyPreferredThinking(pi, ctx, ctx.model)
|
|
224
|
+
}
|
|
214
225
|
})
|
|
215
226
|
|
|
216
227
|
pi.on("model_select", async (event, ctx) => {
|
|
217
|
-
|
|
228
|
+
if (!hasExplicitSubagentThinking()) {
|
|
229
|
+
applyPreferredThinking(pi, ctx, event.model)
|
|
230
|
+
}
|
|
218
231
|
})
|
|
219
232
|
|
|
220
233
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.30.0] - 2026-08-28
|
|
11
|
+
|
|
12
|
+
### Highlights
|
|
13
|
+
- Other extensions can safely inspect one runtime MCP server without seeing the whole MCP config.
|
|
14
|
+
- OAuth setup works better with providers that publish authorization metadata at a custom URL.
|
|
15
|
+
- MCP tool names are safer for providers, including servers with non-ASCII names.
|
|
16
|
+
- Token CLI commands and Windows request-header cleanup are less fragile in installed packages and long-running sessions.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- Added a fail-closed API for child extensions to inspect one selected runtime MCP server without exporting configured servers or persisting the registration. (#453)
|
|
21
|
+
- Added `oauth.authServerMetadataUrl` for servers whose authorization-server metadata cannot be discovered through MCP protected-resource metadata. Thanks to [@fmoda3](https://github.com/fmoda3) for #458.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- Namespace proxy tool names now use provider-safe characters without making encoded-looking server names collide with non-ASCII server names. Thanks to [@nyankosama](https://github.com/nyankosama) for PR #463.
|
|
26
|
+
- npm-installed token CLI commands now load their credential, config, and utility helpers from the published JavaScript build instead of package-local TypeScript files. Thanks to [@Qhilm](https://github.com/Qhilm) for #456.
|
|
27
|
+
- Server-scoped MCP calls now resolve raw upstream tool names before normalized fallbacks without weakening ambiguity checks. Thanks to [@MikeLP](https://github.com/MikeLP) for #452.
|
|
28
|
+
- Windows request-header command cleanup now treats an already-exited process (`taskkill` exit code 128) as successful cleanup. Thanks to [@peterxcx](https://github.com/peterxcx) for #457.
|
|
29
|
+
|
|
10
30
|
## [2.29.0] - 2026-08-26
|
|
11
31
|
|
|
12
32
|
### Highlights
|
|
@@ -276,6 +276,7 @@ In the configuration examples below, `30000` is illustrative only. If `requestTi
|
|
|
276
276
|
| `oauth.clientName` | Client display name advertised during Dynamic Client Registration fallback |
|
|
277
277
|
| `oauth.clientUri` | Client homepage URI advertised during Dynamic Client Registration fallback. Defaults to `piConfig.clientUri` from the host's manifest when set, and is omitted rather than guessed under a rebranded host |
|
|
278
278
|
| `oauth.logoUri` | Client logo URL advertised during Dynamic Client Registration fallback (RFC 7591 `logo_uri`). Must be an absolute `http(s)` URL — consent screens fetch it server-side, so local paths render nothing. Omitted from the registration request when unset |
|
|
279
|
+
| `oauth.authServerMetadataUrl` | HTTPS URL of an OAuth/OIDC authorization-server metadata document. When set, this document is authoritative instead of MCP protected-resource discovery; its issuer remains validated by default |
|
|
279
280
|
| `oauth.skipIssuerMetadataValidation` | `true` disables the OAuth authorization-server metadata issuer check for this server. This weakens OAuth mix-up protection and should only be used for known-misconfigured internal servers while their metadata is being fixed. |
|
|
280
281
|
| `bearerToken` / `bearerTokenEnv` | Token or env var name; `bearerToken` supports `${VAR}` and `$env:VAR` interpolation. A leading `!` in `bearerToken` runs a command when the HTTP server connects; use `!!` for a literal leading `!`. |
|
|
281
282
|
| `bearerTokenStore` | Set to `true` to read a static bearer token from the adapter-owned OS credential store when `auth` is `"bearer"` and no `bearerToken` or `bearerTokenEnv` is configured. Stored records are keyed only by the server name, bind to the resolved server URL, and are never named by config. Store a token with `pi-mcp-adapter token set <server>`, which reads it from a masked prompt or stdin pipe and never from an argument. `/mcp token status <server>` and `/mcp token remove <server>` manage non-secret state inside Pi; `/mcp token set` stays disabled until Pi exposes masked secret input. |
|
|
@@ -307,6 +308,8 @@ For pre-registered browser OAuth clients, set `oauth.redirectUri` to the exact c
|
|
|
307
308
|
|
|
308
309
|
If an internal authorization server publishes mismatched OAuth metadata and cannot be fixed immediately, set `oauth.skipIssuerMetadataValidation: true` on that server only. This is security-weakening. It disables the RFC 8414 issuer echo check and should not be used for public or untrusted servers.
|
|
309
310
|
|
|
311
|
+
If an MCP server does not publish usable protected-resource metadata, set `oauth.authServerMetadataUrl` to its HTTPS OAuth/OIDC authorization-server metadata document. The configured document is used authoritatively, while issuer validation remains enabled by default. This is trusted configuration; use it only for a metadata endpoint you control or explicitly trust.
|
|
312
|
+
|
|
310
313
|
Secret values in `headers`, `bearerToken`, `oauth.clientSecret`, and stdio `env` may use a leading `!command` to obtain their value at connection or authentication time. The command runs with stdin and stderr suppressed, stdout is limited to 1 MiB and trimmed, and it must finish within 10 seconds with non-empty output; failures stop the connection or authentication flow. Commands are not run during OAuth discovery or while reading, merging, previewing, hashing, or rendering configuration. Use `!!` to escape a literal leading `!`; ordinary and escaped values retain environment interpolation.
|
|
311
314
|
|
|
312
315
|
For local desktop bearer tokens, `bearerTokenStore: true` can opt in to the adapter-owned credential-store namespace. It never falls back to plaintext if the store is unavailable, if the stored record is malformed, or if the stored URL differs from the effective server URL. Literal tokens, command tokens, and environment tokens keep precedence so existing configs do not change. Create or rotate a stored token with `pi-mcp-adapter token set <server>` (masked prompt on a terminal, or piped stdin such as `security find-generic-password -s my-token -w | pi-mcp-adapter token set <server>`); the record binds to the effective configured URL at write time. Token commands need Node 22.18+.
|
|
@@ -202,13 +202,13 @@ async function runInit(argv, log = console.log) {
|
|
|
202
202
|
async function importTokenModules(error) {
|
|
203
203
|
try {
|
|
204
204
|
const [store, config, utils] = await Promise.all([
|
|
205
|
-
import("./mcp-bearer-store.
|
|
206
|
-
import("./config.
|
|
207
|
-
import("./utils.
|
|
205
|
+
import("./dist/mcp-bearer-store.js"),
|
|
206
|
+
import("./dist/config.js"),
|
|
207
|
+
import("./dist/utils.js"),
|
|
208
208
|
]);
|
|
209
209
|
return { store, config, utils };
|
|
210
210
|
} catch (err) {
|
|
211
|
-
error("
|
|
211
|
+
error("Unable to load token command modules.");
|
|
212
212
|
error(`Import failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
213
213
|
return undefined;
|
|
214
214
|
}
|
|
@@ -845,6 +845,7 @@ function extractServers(config: unknown, kind: ImportKind): Record<string, Serve
|
|
|
845
845
|
...(typeof oauth.clientId === "string" ? { clientId: oauth.clientId } : {}),
|
|
846
846
|
...(typeof oauth.clientSecret === "string" ? { clientSecret: oauth.clientSecret } : {}),
|
|
847
847
|
...(typeof oauth.scope === "string" ? { scope: oauth.scope } : {}),
|
|
848
|
+
...(typeof oauth.authServerMetadataUrl === "string" ? { authServerMetadataUrl: oauth.authServerMetadataUrl } : {}),
|
|
848
849
|
...(typeof oauth.skipIssuerMetadataValidation === "boolean"
|
|
849
850
|
? { skipIssuerMetadataValidation: oauth.skipIssuerMetadataValidation }
|
|
850
851
|
: {}),
|
|
@@ -693,6 +693,7 @@ function extractServers(config, kind) {
|
|
|
693
693
|
...(typeof oauth.clientId === "string" ? { clientId: oauth.clientId } : {}),
|
|
694
694
|
...(typeof oauth.clientSecret === "string" ? { clientSecret: oauth.clientSecret } : {}),
|
|
695
695
|
...(typeof oauth.scope === "string" ? { scope: oauth.scope } : {}),
|
|
696
|
+
...(typeof oauth.authServerMetadataUrl === "string" ? { authServerMetadataUrl: oauth.authServerMetadataUrl } : {}),
|
|
696
697
|
...(typeof oauth.skipIssuerMetadataValidation === "boolean"
|
|
697
698
|
? { skipIssuerMetadataValidation: oauth.skipIssuerMetadataValidation }
|
|
698
699
|
: {}),
|