@devries-cameron20 / t3code Mirror · read-only / commits / e00ebb6e26
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 22, 12:00 UTC

fix(pi): explain when an untrusted folder makes Pi skip project resources (#27539)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: GPT 6.1 Sol <codex@openai.com>

Wout Stiens committed Oct 30, 2026 at 17:11 UTC e00ebb6e2641a2681d7612bccc5d8810403d99b8
3 files changed +55 -7
docs/user/providers-pi.md
+10 -5
@@ -47,9 +47,10 @@ reporting while a response streams and after it settles.
47 Pi skills appear in the composer's `$` menu. This includes user skills and project skills that Pi
48 loads for the current workspace; selecting one uses Pi's native skill expansion.
49
50 -Pi loads its normal user and project extensions. Blocking `select`, `confirm`, `input`, and `editor`
51 -dialogs work in T3 Code. Notifications appear in the work log. Pi terminal decoration such as
52 -titles, status lines, and widgets does not have a T3 Code equivalent.
50 +Pi loads its normal user extensions, and project extensions once the folder is trusted in Pi.
51 +Blocking `select`, `confirm`, `input`, and `editor` dialogs work in T3 Code. Notifications appear in
52 +the work log. Pi terminal decoration such as titles, status lines, and widgets does not have a T3
53 +Code equivalent.
54
55 ## Permission Modes
56
@@ -79,7 +80,11 @@ threads.
80 - If no models appear, open Pi directly and confirm its authentication and model configuration.
81 - If discovery cannot complete, T3 Code keeps Pi available with the `Pi default` model. Start a
82 thread to let the interactive Pi session handle any startup prompt.
82 -- If a project extension is missing, approve the project in Pi, then start a fresh provider session.
83 -- If a project skill is missing from the `$` menu, approve the project in Pi and refresh the provider.
83 +- If Pi skips project settings, extensions, skills, prompts, MCP servers, or system prompt files
84 + because the folder is not trusted, the thread shows a notice on the first turn of the Pi session.
85 + Run the configured Pi binary in that folder on the server machine, using the same provider
86 + environment, including `PI_CODING_AGENT_DIR` if set. Trust the folder or its parent with `/trust`,
87 + then start a new thread using that same worktree. Launch arguments with `--no-approve` keep
88 + project files off without the notice.
89 - The context meter appears once Pi reports usage for the thread. Some model providers only
90 report usage when a response completes, so the meter can wait for the first reply.
packages/provider-pi/src/server/mcpExtensionSource.test.ts
+31 -2
@@ -25,7 +25,10 @@ type InputHook = (
25 ctx: { ui: { notify: (message: string, level: string) => void } },
26 ) => Promise<{ action: string; text: string; images?: ReadonlyArray<unknown> } | undefined>;
27
28 -async function loadHooks(commands: ReadonlyArray<SkillCommand> = []) {
28 +async function loadHooks(
29 + commands: ReadonlyArray<SkillCommand> = [],
30 + argv: ReadonlyArray<string> = [],
31 +) {
32 const handlers = new Map<string, unknown>();
33 const source = NodeModule.stripTypeScriptTypes(
34 PI_T3_MCP_EXTENSION_SOURCE.replace(/^import .*;$/gm, "").replace(
@@ -34,7 +37,7 @@ async function loadHooks(commands: ReadonlyArray<SkillCommand> = []) {
37 ),
38 );
39 await NodeVM.runInNewContext(`${source}\nt3McpExtension(pi)`, {
37 - process: { env: {} },
40 + process: { env: {}, argv },
41 NodeFSP,
42 NodePath,
43 stripFrontmatter: (content: string) => content,
@@ -77,6 +80,32 @@ describe("Pi orchestration prompt section", () => {
80 });
81 });
82
83 +describe("Pi project trust", () => {
84 + it.each([
85 + { name: "a trusted folder", trusted: true, argv: [], notices: 0 },
86 + { name: "an untrusted folder", trusted: false, argv: [], notices: 1 },
87 + { name: "--no-approve", trusted: false, argv: ["--approve", "-na"], notices: 0 },
88 + ])("sends $notices trust notice per session for $name", async ({ trusted, argv, notices }) => {
89 + const sent: string[] = [];
90 + const ctx = {
91 + cwd: "/repo",
92 + isProjectTrusted: () => trusted,
93 + ui: { notify: (message: string) => sent.push(message) },
94 + };
95 + // Pi reruns extension factories on session replacement without asking about trust again.
96 + for (const _session of [1, 2]) {
97 + const handlers = (await loadHooks([], ["node", "pi", ...argv])) as Map<
98 + string,
99 + (event: unknown, ctx: unknown) => unknown
100 + >;
101 + for (const _turn of [1, 2]) await handlers.get("before_agent_start")!({}, ctx);
102 + }
103 + assert.equal(sent.length, notices * 2);
104 + for (const message of sent)
105 + assert.include(message, "for /repo because the folder is not trusted");
106 + });
107 +});
108 +
109 describe("Pi MCP tool results", () => {
110 it("returns mixed screenshot blocks and typed script output without repeating structured text", async () => {
111 const content = [
packages/provider-pi/src/server/mcpExtensionSource.ts
+14
@@ -241,6 +241,20 @@ function createMcpClient(endpoint: string, token: string) {
241 }
242
243 export default async function t3McpExtension(pi: ExtensionAPI) {
244 + // RPC has no trust prompt, so Pi skips an untrusted folder's protected resources. Session
245 + // replacement reruns this factory without project_trust, and T3 drops notices outside a turn,
246 + // so check each session's first turn. An explicit --no-approve is deliberate and stays quiet.
247 + let projectTrustChecked = false;
248 + pi.on("before_agent_start", (_event, ctx) => {
249 + if (projectTrustChecked) return;
250 + projectTrustChecked = true;
251 + if (ctx.isProjectTrusted() || process.argv.some((arg) => arg === "--no-approve" || arg === "-na")) return;
252 + ctx.ui.notify(
253 + \`Pi did not load project settings, extensions, skills, prompts, MCP servers or system prompt files for \${ctx.cwd} because the folder is not trusted. To load them, run the configured Pi binary there with the same PI_CODING_AGENT_DIR (if set), trust the folder or its parent with /trust, then start a new thread in that same worktree. To trust every project, add --approve to Pi's launch arguments in T3 Code settings; to keep them off without this notice, add --no-approve.\`,
254 + "warning",
255 + );
256 + });
257 +
258 // Keep skill chips in the request. Pi expands only one leading /skill:
259 // command, so use its own frontmatter loader for every selected chip here.
260 pi.on("input", async (event, ctx) => {