@earendil-works/pi-coding-agent 0.78.0 → 0.78.1
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/CHANGELOG.md +35 -0
- package/README.md +5 -2
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +3 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +3 -1
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +7 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -3
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +3 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +9 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/export-html/template.js +19 -6
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -2
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +13 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +7 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/footer-data-provider.d.ts +2 -0
- package/dist/core/footer-data-provider.d.ts.map +1 -1
- package/dist/core/footer-data-provider.js +29 -1
- package/dist/core/footer-data-provider.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +3 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/package-manager.d.ts +2 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +22 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/provider-attribution.d.ts +4 -0
- package/dist/core/provider-attribution.d.ts.map +1 -0
- package/dist/core/provider-attribution.js +72 -0
- package/dist/core/provider-attribution.js.map +1 -0
- package/dist/core/provider-display-names.d.ts.map +1 -1
- package/dist/core/provider-display-names.js +3 -0
- package/dist/core/provider-display-names.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +7 -33
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +92 -68
- package/dist/core/session-manager.js.map +1 -1
- package/dist/modes/interactive/components/login-dialog.d.ts +0 -1
- package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
- package/dist/modes/interactive/components/login-dialog.js +3 -12
- package/dist/modes/interactive/components/login-dialog.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +22 -0
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +2 -0
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/print-mode.d.ts.map +1 -1
- package/dist/modes/print-mode.js +1 -0
- package/dist/modes/print-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +1 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +54 -22
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/open-browser.d.ts +9 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +22 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/docs/containerization.md +111 -0
- package/docs/docs.json +4 -0
- package/docs/extensions.md +36 -11
- package/docs/index.md +1 -0
- package/docs/providers.md +5 -0
- package/docs/rpc.md +1 -1
- package/docs/tui.md +10 -1
- package/docs/usage.md +1 -1
- package/examples/extensions/README.md +1 -0
- package/examples/extensions/custom-header.ts +1 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/gondolin/index.ts +531 -0
- package/examples/extensions/gondolin/package-lock.json +185 -0
- package/examples/extensions/gondolin/package.json +19 -0
- package/examples/extensions/handoff.ts +1 -1
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/overlay-qa-tests.ts +152 -81
- package/examples/extensions/qna.ts +1 -1
- package/examples/extensions/question.ts +1 -1
- package/examples/extensions/questionnaire.ts +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/summarize.ts +1 -1
- package/examples/extensions/tic-tac-toe.ts +1 -1
- package/examples/extensions/todo.ts +1 -1
- package/examples/extensions/tools.ts +5 -0
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +5 -4
package/dist/utils/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/utils/git.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAoB5C,SAAS,QAAQ,CAAC,GAAW,EAAkC;IAC9D,MAAM,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IACrD,IAAI,YAAY,EAAE,CAAC;QAClB,MAAM,gBAAgB,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,gBAAgB,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MAAM,CAC9G,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAC1C,CAAC;IACF,KAAK,MAAM,SAAS,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC9C,SAAS;YACV,CAAC;YACD,OAAO;gBACN,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,WAAW,KAAK,CAAC,IAAI,EAAE;gBAC7B,IAAI,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE;gBACvB,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC1D,GAAG,EAAE,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,IAAI,SAAS;gBAC9C,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC,GAAG,CAAC;aAC7C,CAAC;QACH,CAAC;IACF,CAAC;IAED,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;AAAA,CAC/B","sourcesContent":["import hostedGitInfo from \"hosted-git-info\";\n\n/**\n * Parsed git URL information.\n */\nexport type GitSource = {\n\t/** Always \"git\" for git sources */\n\ttype: \"git\";\n\t/** Clone URL (always valid for git clone, without ref suffix) */\n\trepo: string;\n\t/** Git host domain (e.g., \"github.com\") */\n\thost: string;\n\t/** Repository path (e.g., \"user/repo\") */\n\tpath: string;\n\t/** Git ref (branch, tag, commit) if specified */\n\tref?: string;\n\t/** True if ref was specified (package won't be auto-updated) */\n\tpinned: boolean;\n};\n\nfunction splitRef(url: string): { repo: string; ref?: string } {\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\tif (refSeparator < 0) return { repo: url };\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\tif (!repoPath || !ref) return { repo: url };\n\t\treturn {\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\n\t\t\tref,\n\t\t};\n\t}\n\n\tif (url.includes(\"://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(url);\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\t\tif (refSeparator < 0) return { repo: url };\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\t\tif (!repoPath || !ref) return { repo: url };\n\t\t\tparsed.pathname = `/${repoPath}`;\n\t\t\treturn {\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\n\t\t\t\tref,\n\t\t\t};\n\t\t} catch {\n\t\t\treturn { repo: url };\n\t\t}\n\t}\n\n\tconst slashIndex = url.indexOf(\"/\");\n\tif (slashIndex < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst host = url.slice(0, slashIndex);\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\tif (refSeparator < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\tif (!repoPath || !ref) {\n\t\treturn { repo: url };\n\t}\n\treturn {\n\t\trepo: `${host}/${repoPath}`,\n\t\tref,\n\t};\n}\n\nfunction parseGenericGitUrl(url: string): GitSource | null {\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\n\tlet repo = repoWithoutRef;\n\tlet host = \"\";\n\tlet path = \"\";\n\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\thost = scpLikeMatch[1] ?? \"\";\n\t\tpath = scpLikeMatch[2] ?? \"\";\n\t} else if (\n\t\trepoWithoutRef.startsWith(\"https://\") ||\n\t\trepoWithoutRef.startsWith(\"http://\") ||\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\n\t\trepoWithoutRef.startsWith(\"git://\")\n\t) {\n\t\ttry {\n\t\t\tconst parsed = new URL(repoWithoutRef);\n\t\t\thost = parsed.hostname;\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else {\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\n\t\tif (slashIndex < 0) {\n\t\t\treturn null;\n\t\t}\n\t\thost = repoWithoutRef.slice(0, slashIndex);\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\n\t\t\treturn null;\n\t\t}\n\t\trepo = `https://${repoWithoutRef}`;\n\t}\n\n\tconst normalizedPath = path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\n\tif (!host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"git\",\n\t\trepo,\n\t\thost,\n\t\tpath: normalizedPath,\n\t\tref,\n\t\tpinned: Boolean(ref),\n\t};\n}\n\n/**\n * Parse git source into a GitSource.\n *\n * Rules:\n * - With git: prefix, accept all historical shorthand forms.\n * - Without git: prefix, only accept explicit protocol URLs.\n */\nexport function parseGitUrl(source: string): GitSource | null {\n\tconst trimmed = source.trim();\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\n\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\n\t\treturn null;\n\t}\n\n\tconst split = splitRef(url);\n\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of hostedCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst useHttpsPrefix =\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\n\t\t\t\t!split.repo.startsWith(\"git@\");\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\t\t}\n\t}\n\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of httpsCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\ttype: \"git\",\n\t\t\t\trepo: `https://${split.repo}`,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`.replace(/\\.git$/, \"\"),\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t\tpinned: Boolean(info.committish || split.ref),\n\t\t\t};\n\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-info\";\n\n/**\n * Parsed git URL information.\n */\nexport type GitSource = {\n\t/** Always \"git\" for git sources */\n\ttype: \"git\";\n\t/** Clone URL (always valid for git clone, without ref suffix) */\n\trepo: string;\n\t/** Git host domain (e.g., \"github.com\") */\n\thost: string;\n\t/** Repository path (e.g., \"user/repo\") */\n\tpath: string;\n\t/** Git ref (branch, tag, commit) if specified */\n\tref?: string;\n\t/** True if ref was specified (package won't be auto-updated) */\n\tpinned: boolean;\n};\n\nfunction splitRef(url: string): { repo: string; ref?: string } {\n\tconst scpLikeMatch = url.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\tconst pathWithMaybeRef = scpLikeMatch[2] ?? \"\";\n\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\tif (refSeparator < 0) return { repo: url };\n\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\tif (!repoPath || !ref) return { repo: url };\n\t\treturn {\n\t\t\trepo: `git@${scpLikeMatch[1] ?? \"\"}:${repoPath}`,\n\t\t\tref,\n\t\t};\n\t}\n\n\tif (url.includes(\"://\")) {\n\t\ttry {\n\t\t\tconst parsed = new URL(url);\n\t\t\tconst pathWithMaybeRef = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\t\t\tif (refSeparator < 0) return { repo: url };\n\t\t\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\t\t\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\t\t\tif (!repoPath || !ref) return { repo: url };\n\t\t\tparsed.pathname = `/${repoPath}`;\n\t\t\treturn {\n\t\t\t\trepo: parsed.toString().replace(/\\/$/, \"\"),\n\t\t\t\tref,\n\t\t\t};\n\t\t} catch {\n\t\t\treturn { repo: url };\n\t\t}\n\t}\n\n\tconst slashIndex = url.indexOf(\"/\");\n\tif (slashIndex < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst host = url.slice(0, slashIndex);\n\tconst pathWithMaybeRef = url.slice(slashIndex + 1);\n\tconst refSeparator = pathWithMaybeRef.indexOf(\"@\");\n\tif (refSeparator < 0) {\n\t\treturn { repo: url };\n\t}\n\tconst repoPath = pathWithMaybeRef.slice(0, refSeparator);\n\tconst ref = pathWithMaybeRef.slice(refSeparator + 1);\n\tif (!repoPath || !ref) {\n\t\treturn { repo: url };\n\t}\n\treturn {\n\t\trepo: `${host}/${repoPath}`,\n\t\tref,\n\t};\n}\n\nfunction decodeForValidation(value: string): string | null {\n\ttry {\n\t\treturn decodeURIComponent(value);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction hasUnsafeGitInstallPart(value: string, allowSlash: boolean): boolean {\n\tconst decoded = decodeForValidation(value);\n\tif (decoded === null) {\n\t\treturn true;\n\t}\n\tconst candidates = [value, decoded];\n\tfor (const candidate of candidates) {\n\t\tif (candidate.includes(\"\\0\") || candidate.includes(\"\\\\\") || candidate.startsWith(\"/\")) {\n\t\t\treturn true;\n\t\t}\n\t\tif (!allowSlash && candidate.includes(\"/\")) {\n\t\t\treturn true;\n\t\t}\n\t\tif (candidate.split(\"/\").includes(\"..\")) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nfunction buildGitSource(args: { repo: string; host: string; path: string; ref?: string }): GitSource | null {\n\tif (args.path.startsWith(\"/\")) {\n\t\treturn null;\n\t}\n\tconst normalizedPath = args.path.replace(/\\.git$/, \"\").replace(/^\\/+/, \"\");\n\tif (!args.host || !normalizedPath || normalizedPath.split(\"/\").length < 2) {\n\t\treturn null;\n\t}\n\tif (hasUnsafeGitInstallPart(args.host, false) || hasUnsafeGitInstallPart(normalizedPath, true)) {\n\t\treturn null;\n\t}\n\n\treturn {\n\t\ttype: \"git\",\n\t\trepo: args.repo,\n\t\thost: args.host,\n\t\tpath: normalizedPath,\n\t\tref: args.ref,\n\t\tpinned: Boolean(args.ref),\n\t};\n}\n\nfunction parseGenericGitUrl(url: string): GitSource | null {\n\tconst { repo: repoWithoutRef, ref } = splitRef(url);\n\tlet repo = repoWithoutRef;\n\tlet host = \"\";\n\tlet path = \"\";\n\n\tconst scpLikeMatch = repoWithoutRef.match(/^git@([^:]+):(.+)$/);\n\tif (scpLikeMatch) {\n\t\thost = scpLikeMatch[1] ?? \"\";\n\t\tpath = scpLikeMatch[2] ?? \"\";\n\t} else if (\n\t\trepoWithoutRef.startsWith(\"https://\") ||\n\t\trepoWithoutRef.startsWith(\"http://\") ||\n\t\trepoWithoutRef.startsWith(\"ssh://\") ||\n\t\trepoWithoutRef.startsWith(\"git://\")\n\t) {\n\t\ttry {\n\t\t\tconst parsed = new URL(repoWithoutRef);\n\t\t\thost = parsed.hostname;\n\t\t\tpath = parsed.pathname.replace(/^\\/+/, \"\");\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t} else {\n\t\tconst slashIndex = repoWithoutRef.indexOf(\"/\");\n\t\tif (slashIndex < 0) {\n\t\t\treturn null;\n\t\t}\n\t\thost = repoWithoutRef.slice(0, slashIndex);\n\t\tpath = repoWithoutRef.slice(slashIndex + 1);\n\t\tif (!host.includes(\".\") && host !== \"localhost\") {\n\t\t\treturn null;\n\t\t}\n\t\trepo = `https://${repoWithoutRef}`;\n\t}\n\n\treturn buildGitSource({ repo, host, path, ref });\n}\n\n/**\n * Parse git source into a GitSource.\n *\n * Rules:\n * - With git: prefix, accept all historical shorthand forms.\n * - Without git: prefix, only accept explicit protocol URLs.\n */\nexport function parseGitUrl(source: string): GitSource | null {\n\tconst trimmed = source.trim();\n\tconst hasGitPrefix = trimmed.startsWith(\"git:\");\n\tconst url = hasGitPrefix ? trimmed.slice(4).trim() : trimmed;\n\n\tif (!hasGitPrefix && !/^(https?|ssh|git):\\/\\//i.test(url)) {\n\t\treturn null;\n\t}\n\n\tconst split = splitRef(url);\n\n\tconst hostedCandidates = [split.ref ? `${split.repo}#${split.ref}` : undefined, url].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of hostedCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst useHttpsPrefix =\n\t\t\t\t!split.repo.startsWith(\"http://\") &&\n\t\t\t\t!split.repo.startsWith(\"https://\") &&\n\t\t\t\t!split.repo.startsWith(\"ssh://\") &&\n\t\t\t\t!split.repo.startsWith(\"git://\") &&\n\t\t\t\t!split.repo.startsWith(\"git@\");\n\t\t\treturn buildGitSource({\n\t\t\t\trepo: useHttpsPrefix ? `https://${split.repo}` : split.repo,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`,\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\tconst httpsCandidates = [split.ref ? `https://${split.repo}#${split.ref}` : undefined, `https://${url}`].filter(\n\t\t(value): value is string => Boolean(value),\n\t);\n\tfor (const candidate of httpsCandidates) {\n\t\tconst info = hostedGitInfo.fromUrl(candidate);\n\t\tif (info) {\n\t\t\tif (split.ref && info.project?.includes(\"@\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\treturn buildGitSource({\n\t\t\t\trepo: `https://${split.repo}`,\n\t\t\t\thost: info.domain || \"\",\n\t\t\t\tpath: `${info.user}/${info.project}`,\n\t\t\t\tref: info.committish || split.ref || undefined,\n\t\t\t});\n\t\t}\n\t}\n\n\treturn parseGenericGitUrl(url);\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open a URL or file in the platform browser/default handler.
|
|
3
|
+
*
|
|
4
|
+
* This intentionally never invokes a shell. On Windows, do not use
|
|
5
|
+
* `cmd /c start`: cmd.exe re-parses metacharacters (&, |, ^, ...) before
|
|
6
|
+
* `start` runs, which would make attacker-controlled URLs injectable.
|
|
7
|
+
*/
|
|
8
|
+
export declare function openBrowser(target: string): void;
|
|
9
|
+
//# sourceMappingURL=open-browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-browser.d.ts","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAchD","sourcesContent":["import { spawn } from \"node:child_process\";\n\n/**\n * Open a URL or file in the platform browser/default handler.\n *\n * This intentionally never invokes a shell. On Windows, do not use\n * `cmd /c start`: cmd.exe re-parses metacharacters (&, |, ^, ...) before\n * `start` runs, which would make attacker-controlled URLs injectable.\n */\nexport function openBrowser(target: string): void {\n\tconst [cmd, args]: [string, string[]] =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"open\", [target]]\n\t\t\t: process.platform === \"win32\"\n\t\t\t\t? [\"rundll32\", [\"url.dll,FileProtocolHandler\", target]]\n\t\t\t\t: [\"xdg-open\", [target]];\n\n\t// spawn reports launcher failures (for example, missing xdg-open) via an\n\t// error event. Browser launch is best-effort: callers still present the target\n\t// to the user, so keep the launcher failure from becoming a process crash.\n\tspawn(cmd, args, { stdio: \"ignore\", detached: true })\n\t\t.on(\"error\", () => {})\n\t\t.unref();\n}\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* Open a URL or file in the platform browser/default handler.
|
|
4
|
+
*
|
|
5
|
+
* This intentionally never invokes a shell. On Windows, do not use
|
|
6
|
+
* `cmd /c start`: cmd.exe re-parses metacharacters (&, |, ^, ...) before
|
|
7
|
+
* `start` runs, which would make attacker-controlled URLs injectable.
|
|
8
|
+
*/
|
|
9
|
+
export function openBrowser(target) {
|
|
10
|
+
const [cmd, args] = process.platform === "darwin"
|
|
11
|
+
? ["open", [target]]
|
|
12
|
+
: process.platform === "win32"
|
|
13
|
+
? ["rundll32", ["url.dll,FileProtocolHandler", target]]
|
|
14
|
+
: ["xdg-open", [target]];
|
|
15
|
+
// spawn reports launcher failures (for example, missing xdg-open) via an
|
|
16
|
+
// error event. Browser launch is best-effort: callers still present the target
|
|
17
|
+
// to the user, so keep the launcher failure from becoming a process crash.
|
|
18
|
+
spawn(cmd, args, { stdio: "ignore", detached: true })
|
|
19
|
+
.on("error", () => { })
|
|
20
|
+
.unref();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=open-browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"open-browser.js","sourceRoot":"","sources":["../../src/utils/open-browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc,EAAQ;IACjD,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,GAChB,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAC5B,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC,CAAC,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC7B,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC,UAAU,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5B,yEAAyE;IACzE,+EAA+E;IAC/E,2EAA2E;IAC3E,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;SACnD,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;SACrB,KAAK,EAAE,CAAC;AAAA,CACV","sourcesContent":["import { spawn } from \"node:child_process\";\n\n/**\n * Open a URL or file in the platform browser/default handler.\n *\n * This intentionally never invokes a shell. On Windows, do not use\n * `cmd /c start`: cmd.exe re-parses metacharacters (&, |, ^, ...) before\n * `start` runs, which would make attacker-controlled URLs injectable.\n */\nexport function openBrowser(target: string): void {\n\tconst [cmd, args]: [string, string[]] =\n\t\tprocess.platform === \"darwin\"\n\t\t\t? [\"open\", [target]]\n\t\t\t: process.platform === \"win32\"\n\t\t\t\t? [\"rundll32\", [\"url.dll,FileProtocolHandler\", target]]\n\t\t\t\t: [\"xdg-open\", [target]];\n\n\t// spawn reports launcher failures (for example, missing xdg-open) via an\n\t// error event. Browser launch is best-effort: callers still present the target\n\t// to the user, so keep the launcher failure from becoming a process crash.\n\tspawn(cmd, args, { stdio: \"ignore\", detached: true })\n\t\t.on(\"error\", () => {})\n\t\t.unref();\n}\n"]}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Containerization
|
|
2
|
+
|
|
3
|
+
Pi runs with all permissions by default, but in some cases, you will want to have more control over what directories Pi can write to and which accesses it has.
|
|
4
|
+
|
|
5
|
+
There are two general options. You can either
|
|
6
|
+
1. run the whole `pi` process inside an isolated environment, or
|
|
7
|
+
2. run `pi` on the host and route tool execution into an isolated environment.
|
|
8
|
+
|
|
9
|
+
## Choose a pattern
|
|
10
|
+
|
|
11
|
+
| Pattern | What is isolated | Best for | Notes |
|
|
12
|
+
| --- | --- | --- | --- |
|
|
13
|
+
| OpenShell | Whole `pi` process in a policy-controlled sandbox | Local or remote managed sandbox | Requires an OpenShell gateway |
|
|
14
|
+
| Gondolin extension | Built-in tools and `!` commands | Local micro-VM isolation while keeping auth on host | See [`examples/extensions/gondolin/`](../examples/extensions/gondolin/). |
|
|
15
|
+
| Plain Docker | Whole `pi` process in a local container | Simple local isolation | Provider API keys enter the container. |
|
|
16
|
+
|
|
17
|
+
Extensions run wherever the `pi` process runs. If you run host `pi` with a tool-routing extension, other custom extension tools still run on the host unless they also delegate their operations.
|
|
18
|
+
|
|
19
|
+
## OpenShell
|
|
20
|
+
|
|
21
|
+
Use [NVIDIA OpenShell](https://docs.nvidia.com/openshell/about/overview) when you want a policy-controlled sandbox with filesystem, process, network, credential, and inference controls.
|
|
22
|
+
OpenShell can run sandboxes through a local gateway backed by Docker, Podman, or a VM runtime, or through a remote Kubernetes gateway.
|
|
23
|
+
|
|
24
|
+
Every sandbox requires an active gateway.
|
|
25
|
+
Register and select one before creating a sandbox:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
openshell gateway add <gateway-url> --name <name>
|
|
29
|
+
openshell gateway select <name>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Launch `pi` inside an OpenShell sandbox:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
openshell sandbox create --name pi-sandbox --from pi -- pi
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
In this pattern, the whole `pi` process runs inside the sandbox.
|
|
39
|
+
Built-in tools, `!` commands, and extension tools execute inside the OpenShell boundary.
|
|
40
|
+
|
|
41
|
+
If the gateway is remote, project files are not bind-mounted from the host, meaning writes in the sandbox are not reflected on your machine.
|
|
42
|
+
Clone the repository inside the sandbox or use OpenShell file transfer commands:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
openshell sandbox upload pi-sandbox ./repo /workspace
|
|
46
|
+
openshell sandbox download pi-sandbox /workspace/repo ./repo-out
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
OpenShell providers can keep raw model API keys outside the sandbox.
|
|
50
|
+
When inference routing is configured, code inside the sandbox can call `https://inference.local`, and the gateway injects the configured provider credentials upstream.
|
|
51
|
+
Configure Pi to use the corresponding OpenAI-compatible or Anthropic-compatible endpoint if you want model traffic to use this route.
|
|
52
|
+
|
|
53
|
+
## Gondolin
|
|
54
|
+
|
|
55
|
+
[Gondolin](https://github.com/earendil-works/gondolin) is a local Linux micro-VM.
|
|
56
|
+
Use the [example extension](../examples/extensions/gondolin) when you want `pi` on the host but all built-in tools routed into the VM.
|
|
57
|
+
|
|
58
|
+
Setup:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
cp -R packages/coding-agent/examples/extensions/gondolin ~/.pi/agent/extensions/gondolin
|
|
62
|
+
cd ~/.pi/agent/extensions/gondolin
|
|
63
|
+
npm install --ignore-scripts
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Run from the project you want mounted:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
cd /path/to/project
|
|
70
|
+
pi -e ~/.pi/agent/extensions/gondolin
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The extension mounts the host cwd at `/workspace` in the VM and overrides `read`, `write`, `edit`, `bash`, `grep`, `find`, and `ls`.
|
|
74
|
+
User `!` commands are routed into the VM, as well.
|
|
75
|
+
File changes under `/workspace` write through to the host.
|
|
76
|
+
|
|
77
|
+
Requirements: Node.js >= 23.6.0 for `@earendil-works/gondolin`, plus QEMU (requires installation through your package manager).
|
|
78
|
+
|
|
79
|
+
## Plain Docker
|
|
80
|
+
|
|
81
|
+
Run the whole `pi` process in Docker when you want the simplest local container boundary.
|
|
82
|
+
|
|
83
|
+
`Dockerfile.pi`:
|
|
84
|
+
|
|
85
|
+
```dockerfile
|
|
86
|
+
FROM node:24-bookworm-slim
|
|
87
|
+
|
|
88
|
+
RUN apt-get update \
|
|
89
|
+
&& apt-get install -y --no-install-recommends bash ca-certificates git ripgrep \
|
|
90
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
91
|
+
RUN npm install -g --ignore-scripts @earendil-works/pi-coding-agent
|
|
92
|
+
|
|
93
|
+
WORKDIR /workspace
|
|
94
|
+
ENTRYPOINT ["pi"]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Build and run:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
docker build -t pi-sandbox -f Dockerfile.pi .
|
|
101
|
+
|
|
102
|
+
docker run --rm -it \
|
|
103
|
+
-e ANTHROPIC_API_KEY \
|
|
104
|
+
-v "$PWD:/workspace" \
|
|
105
|
+
-v pi-agent-home:/root/.pi/agent \
|
|
106
|
+
pi-sandbox
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `-v "$PWD:/workspace"` mounts your current directory into the container at /workspace such that reads and writes in `/workspace` inside Docker directly affect your host files, like in the Gondolin example.
|
|
110
|
+
|
|
111
|
+
Use a named volume for `/root/.pi/agent` if you want container-local settings and sessions. Mounting your host `~/.pi/agent` exposes host auth and session files to the container.
|
package/docs/docs.json
CHANGED
package/docs/extensions.md
CHANGED
|
@@ -860,9 +860,13 @@ All handlers receive `ctx: ExtensionContext`.
|
|
|
860
860
|
|
|
861
861
|
UI methods for user interaction. See [Custom UI](#custom-ui) for full details.
|
|
862
862
|
|
|
863
|
+
### ctx.mode
|
|
864
|
+
|
|
865
|
+
Current run mode: `"tui"`, `"rpc"`, `"json"`, or `"print"`. Use `ctx.mode === "tui"` to guard terminal-only features such as `custom()`, component factories, terminal input, and direct TUI rendering.
|
|
866
|
+
|
|
863
867
|
### ctx.hasUI
|
|
864
868
|
|
|
865
|
-
`false` in print mode (`-p`) and JSON mode.
|
|
869
|
+
`true` in TUI and RPC modes. `false` in print mode (`-p`) and JSON mode. Use this to guard dialog methods (`select`, `confirm`, `input`, `editor`) and fire-and-forget methods (`notify`, `setStatus`, `setWidget`, `setTitle`, `setEditorText`) that work in both TUI and RPC modes. In RPC mode, some TUI-specific methods are no-ops or return defaults (see [rpc.md](rpc.md#extension-ui-protocol)).
|
|
866
870
|
|
|
867
871
|
### ctx.cwd
|
|
868
872
|
|
|
@@ -978,6 +982,19 @@ pi.on("before_agent_start", (event, ctx) => {
|
|
|
978
982
|
|
|
979
983
|
Command handlers receive `ExtensionCommandContext`, which extends `ExtensionContext` with session control methods. These are only available in commands because they can deadlock if called from event handlers.
|
|
980
984
|
|
|
985
|
+
### ctx.getSystemPromptOptions()
|
|
986
|
+
|
|
987
|
+
Returns the base inputs Pi currently uses to build the system prompt.
|
|
988
|
+
|
|
989
|
+
```typescript
|
|
990
|
+
const options = ctx.getSystemPromptOptions();
|
|
991
|
+
const contextPaths = options.contextFiles?.map((file) => file.path) ?? [];
|
|
992
|
+
```
|
|
993
|
+
|
|
994
|
+
This has the same shape and mutability as `before_agent_start` `event.systemPromptOptions`: custom prompt, active tools, tool snippets, prompt guidelines, appended system prompt text, cwd, loaded context files, and loaded skills. It may include full context file contents, so treat it as sensitive extension-local data and avoid exposing it through command lists, logs, or autocomplete metadata.
|
|
995
|
+
|
|
996
|
+
This reports the current base prompt inputs. It does not include per-turn `before_agent_start` chained system-prompt changes, later `context` event message mutations, or `before_provider_request` payload rewrites.
|
|
997
|
+
|
|
981
998
|
### ctx.waitForIdle()
|
|
982
999
|
|
|
983
1000
|
Wait for the agent to finish streaming:
|
|
@@ -2371,7 +2388,7 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
2371
2388
|
);
|
|
2372
2389
|
```
|
|
2373
2390
|
|
|
2374
|
-
For advanced positioning (anchors, margins, percentages, responsive visibility), pass `overlayOptions`. Use `onHandle` to control visibility programmatically:
|
|
2391
|
+
For advanced positioning (anchors, margins, percentages, responsive visibility), pass `overlayOptions`. Use `onHandle` to control focus or visibility programmatically:
|
|
2375
2392
|
|
|
2376
2393
|
```typescript
|
|
2377
2394
|
const result = await ctx.ui.custom<string | null>(
|
|
@@ -2379,12 +2396,19 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
2379
2396
|
{
|
|
2380
2397
|
overlay: true,
|
|
2381
2398
|
overlayOptions: { anchor: "top-right", width: "50%", margin: 2 },
|
|
2382
|
-
onHandle: (handle) => {
|
|
2399
|
+
onHandle: (handle) => {
|
|
2400
|
+
handle.focus(); // focus this overlay and bring it to the visual front
|
|
2401
|
+
// handle.unfocus({ target: editorComponent }); // release input to a specific component
|
|
2402
|
+
// handle.setHidden(true/false); // toggle visibility
|
|
2403
|
+
// handle.hide(); // permanently remove
|
|
2404
|
+
}
|
|
2383
2405
|
}
|
|
2384
2406
|
);
|
|
2385
2407
|
```
|
|
2386
2408
|
|
|
2387
|
-
|
|
2409
|
+
A focused visible overlay can reclaim input after temporary non-overlay custom UI closes. If you intentionally want another component to keep input while the overlay stays visible, call `handle.unfocus({ target })`. Passing `{ target: null }` releases the overlay without focusing another component.
|
|
2410
|
+
|
|
2411
|
+
See [tui.md](tui.md) for the full `OverlayOptions` and `OverlayHandle` API and [overlay-qa-tests.ts](../examples/extensions/overlay-qa-tests.ts) for examples.
|
|
2388
2412
|
|
|
2389
2413
|
### Custom Editor
|
|
2390
2414
|
|
|
@@ -2509,14 +2533,14 @@ const highlighted = highlightCode(code, lang, theme);
|
|
|
2509
2533
|
|
|
2510
2534
|
## Mode Behavior
|
|
2511
2535
|
|
|
2512
|
-
| Mode |
|
|
2513
|
-
|
|
2514
|
-
| Interactive | Full TUI
|
|
2515
|
-
| RPC (`--mode rpc`) | JSON protocol
|
|
2516
|
-
| JSON (`--mode json`) |
|
|
2517
|
-
| Print (`-p`) |
|
|
2536
|
+
| Mode | `ctx.mode` | `ctx.hasUI` | Notes |
|
|
2537
|
+
|------|------------|-------------|-------|
|
|
2538
|
+
| Interactive | `"tui"` | `true` | Full TUI with terminal rendering |
|
|
2539
|
+
| RPC (`--mode rpc`) | `"rpc"` | `true` | Dialogs and notifications via JSON protocol; `custom()` returns `undefined`. See [rpc.md](rpc.md) |
|
|
2540
|
+
| JSON (`--mode json`) | `"json"` | `false` | Event stream to stdout; UI methods are no-ops |
|
|
2541
|
+
| Print (`-p`) | `"print"` | `false` | Extensions run but can't prompt |
|
|
2518
2542
|
|
|
2519
|
-
|
|
2543
|
+
Use `ctx.mode === "tui"` before TUI-specific features (`custom()`, component factories, terminal input). Use `ctx.hasUI` before dialog and notification methods that work in both TUI and RPC modes.
|
|
2520
2544
|
|
|
2521
2545
|
## Examples Reference
|
|
2522
2546
|
|
|
@@ -2582,6 +2606,7 @@ All examples in [examples/extensions/](../examples/extensions/).
|
|
|
2582
2606
|
| `ssh.ts` | SSH remote execution | `registerFlag`, `on("user_bash")`, `on("before_agent_start")`, tool operations |
|
|
2583
2607
|
| `interactive-shell.ts` | Persistent shell session | `on("user_bash")` |
|
|
2584
2608
|
| `sandbox/` | Sandboxed tool execution | Tool operations |
|
|
2609
|
+
| `gondolin/` | Route built-in tools and `!` commands into a Gondolin micro-VM | Tool operations, built-in tool overrides, `on("user_bash")` |
|
|
2585
2610
|
| `subagent/` | Spawn sub-agents | `registerTool`, `exec` |
|
|
2586
2611
|
| **Games** |||
|
|
2587
2612
|
| `snake.ts` | Snake game | `registerCommand`, `ui.custom`, keyboard handling |
|
package/docs/index.md
CHANGED
|
@@ -41,6 +41,7 @@ For the full first-run flow, see [Quickstart](quickstart.md).
|
|
|
41
41
|
- [Quickstart](quickstart.md) - install, authenticate, and run a first session.
|
|
42
42
|
- [Using Pi](usage.md) - interactive mode, slash commands, context files, and CLI reference.
|
|
43
43
|
- [Providers](providers.md) - subscription and API-key setup for built-in providers.
|
|
44
|
+
- [Containerization](containerization.md) - sandbox pi with OpenShell, Gondolin, or Docker.
|
|
44
45
|
- [Settings](settings.md) - global and project settings.
|
|
45
46
|
- [Keybindings](keybindings.md) - default shortcuts and custom keybindings.
|
|
46
47
|
- [Sessions](sessions.md) - session management, branching, and tree navigation.
|
package/docs/providers.md
CHANGED
|
@@ -49,9 +49,11 @@ pi
|
|
|
49
49
|
| Provider | Environment Variable | `auth.json` key |
|
|
50
50
|
|----------|----------------------|------------------|
|
|
51
51
|
| Anthropic | `ANTHROPIC_API_KEY` | `anthropic` |
|
|
52
|
+
| Ant Ling | `ANT_LING_API_KEY` | `ant-ling` |
|
|
52
53
|
| Azure OpenAI Responses | `AZURE_OPENAI_API_KEY` | `azure-openai-responses` |
|
|
53
54
|
| OpenAI | `OPENAI_API_KEY` | `openai` |
|
|
54
55
|
| DeepSeek | `DEEPSEEK_API_KEY` | `deepseek` |
|
|
56
|
+
| NVIDIA NIM | `NVIDIA_API_KEY` | `nvidia` |
|
|
55
57
|
| Google Gemini | `GEMINI_API_KEY` | `google` |
|
|
56
58
|
| Mistral | `MISTRAL_API_KEY` | `mistral` |
|
|
57
59
|
| Groq | `GROQ_API_KEY` | `groq` |
|
|
@@ -62,6 +64,7 @@ pi
|
|
|
62
64
|
| OpenRouter | `OPENROUTER_API_KEY` | `openrouter` |
|
|
63
65
|
| Vercel AI Gateway | `AI_GATEWAY_API_KEY` | `vercel-ai-gateway` |
|
|
64
66
|
| ZAI | `ZAI_API_KEY` | `zai` |
|
|
67
|
+
| ZAI Coding Plan (China) | `ZAI_CODING_CN_API_KEY` | `zai-coding-cn` |
|
|
65
68
|
| OpenCode Zen | `OPENCODE_API_KEY` | `opencode` |
|
|
66
69
|
| OpenCode Go | `OPENCODE_API_KEY` | `opencode-go` |
|
|
67
70
|
| Hugging Face | `HF_TOKEN` | `huggingface` |
|
|
@@ -84,8 +87,10 @@ Store credentials in `~/.pi/agent/auth.json`:
|
|
|
84
87
|
```json
|
|
85
88
|
{
|
|
86
89
|
"anthropic": { "type": "api_key", "key": "sk-ant-..." },
|
|
90
|
+
"ant-ling": { "type": "api_key", "key": "..." },
|
|
87
91
|
"openai": { "type": "api_key", "key": "sk-..." },
|
|
88
92
|
"deepseek": { "type": "api_key", "key": "sk-..." },
|
|
93
|
+
"nvidia": { "type": "api_key", "key": "nvapi-..." },
|
|
89
94
|
"google": { "type": "api_key", "key": "..." },
|
|
90
95
|
"opencode": { "type": "api_key", "key": "..." },
|
|
91
96
|
"opencode-go": { "type": "api_key", "key": "..." },
|
package/docs/rpc.md
CHANGED
|
@@ -1003,7 +1003,7 @@ Some `ExtensionUIContext` methods are not supported or degraded in RPC mode beca
|
|
|
1003
1003
|
- `getTheme()` returns `undefined`
|
|
1004
1004
|
- `setTheme()` returns `{ success: false, error: "..." }`
|
|
1005
1005
|
|
|
1006
|
-
Note: `ctx.hasUI` is `true` in RPC mode because the dialog and fire-and-forget methods are functional via the extension UI sub-protocol.
|
|
1006
|
+
Note: `ctx.mode` is `"rpc"` and `ctx.hasUI` is `true` in RPC mode because the dialog and fire-and-forget methods are functional via the extension UI sub-protocol. Use `ctx.mode === "tui"` to guard TUI-specific features like `custom()` that require a real terminal.
|
|
1007
1007
|
|
|
1008
1008
|
### Extension UI Requests (stdout)
|
|
1009
1009
|
|
package/docs/tui.md
CHANGED
|
@@ -145,8 +145,11 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
145
145
|
// Responsive: hide on narrow terminals
|
|
146
146
|
visible: (termWidth, termHeight) => termWidth >= 80,
|
|
147
147
|
},
|
|
148
|
-
// Get handle for programmatic visibility control
|
|
148
|
+
// Get handle for programmatic focus and visibility control
|
|
149
149
|
onHandle: (handle) => {
|
|
150
|
+
// handle.focus() - focus this overlay and bring it to the visual front
|
|
151
|
+
// handle.unfocus() - release input to normal fallback
|
|
152
|
+
// handle.unfocus({ target }) - release input to a specific component or null
|
|
150
153
|
// handle.setHidden(true/false) - toggle visibility
|
|
151
154
|
// handle.hide() - permanently remove
|
|
152
155
|
},
|
|
@@ -154,6 +157,12 @@ const result = await ctx.ui.custom<string | null>(
|
|
|
154
157
|
);
|
|
155
158
|
```
|
|
156
159
|
|
|
160
|
+
### Overlay Focus
|
|
161
|
+
|
|
162
|
+
A focused visible overlay keeps input ownership across temporary non-overlay UI. If an overlay opens another `ctx.ui.custom()` component without `{ overlay: true }`, that replacement UI receives input while it is active; when it closes, the focused overlay can reclaim input.
|
|
163
|
+
|
|
164
|
+
Use `handle.unfocus()` when a visible overlay should stop owning input and let TUI fall back to another visible capturing overlay or the previous focus target. Use `handle.unfocus({ target })` when a specific component should receive input while the overlay stays visible. Passing `{ target: null }` intentionally leaves no focused component until focus is set again.
|
|
165
|
+
|
|
157
166
|
### Overlay Lifecycle
|
|
158
167
|
|
|
159
168
|
Overlay components are disposed when closed. Don't reuse references - create fresh instances:
|
package/docs/usage.md
CHANGED
|
@@ -275,7 +275,7 @@ pi --exclude-tools ask_question
|
|
|
275
275
|
| `PI_PACKAGE_DIR` | Override package directory, useful for Nix/Guix store paths |
|
|
276
276
|
| `PI_OFFLINE` | Disable startup network operations, including update checks, package update checks, and install/update telemetry |
|
|
277
277
|
| `PI_SKIP_VERSION_CHECK` | Skip the Pi version update check at startup. This prevents the `pi.dev` latest-version request |
|
|
278
|
-
| `PI_TELEMETRY` | Override install/update telemetry: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
|
|
278
|
+
| `PI_TELEMETRY` | Override install/update telemetry and provider attribution headers: `1`/`true`/`yes` or `0`/`false`/`no`. This does not disable update checks |
|
|
279
279
|
| `PI_CACHE_RETENTION` | Set to `long` for extended prompt cache where supported |
|
|
280
280
|
| `VISUAL`, `EDITOR` | External editor for Ctrl+G |
|
|
281
281
|
|
|
@@ -23,6 +23,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|
|
23
23
|
| `confirm-destructive.ts` | Confirms before destructive session actions (clear, switch, fork) |
|
|
24
24
|
| `dirty-repo-guard.ts` | Prevents session changes with uncommitted git changes |
|
|
25
25
|
| `sandbox/` | OS-level sandboxing using `@anthropic-ai/sandbox-runtime` with per-project config |
|
|
26
|
+
| `gondolin/` | Route built-in tools and `!` commands into a Gondolin micro-VM |
|
|
26
27
|
|
|
27
28
|
### Custom Tools
|
|
28
29
|
|
|
@@ -47,7 +47,7 @@ function getPiMascot(theme: Theme): string[] {
|
|
|
47
47
|
export default function (pi: ExtensionAPI) {
|
|
48
48
|
// Set custom header immediately on load (if UI is available)
|
|
49
49
|
pi.on("session_start", async (_event, ctx) => {
|
|
50
|
-
if (ctx.
|
|
50
|
+
if (ctx.mode === "tui") {
|
|
51
51
|
ctx.ui.setHeader((_tui, theme) => {
|
|
52
52
|
return {
|
|
53
53
|
render(_width: number): string[] {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-extension-custom-provider",
|
|
3
|
-
"version": "0.78.
|
|
3
|
+
"version": "0.78.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pi-extension-custom-provider",
|
|
9
|
-
"version": "0.78.
|
|
9
|
+
"version": "0.78.1",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@anthropic-ai/sdk": "^0.52.0"
|
|
12
12
|
}
|
|
@@ -23,7 +23,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
23
23
|
description: "Play DOOM as an overlay. Q to pause and exit.",
|
|
24
24
|
|
|
25
25
|
handler: async (args, ctx) => {
|
|
26
|
-
if (
|
|
26
|
+
if (ctx.mode !== "tui") {
|
|
27
27
|
ctx.ui.notify("DOOM requires interactive mode", "error");
|
|
28
28
|
return;
|
|
29
29
|
}
|