my-pi 0.1.115 → 0.1.117
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 +51 -8
- package/dist/api.d.ts +4 -3
- package/dist/api.js +33 -18
- package/dist/api.js.map +1 -1
- package/dist/{builtin-registry-aGnFiwEg.js → builtin-registry-DC8RlCfd.js} +2 -2
- package/dist/{builtin-registry-aGnFiwEg.js.map → builtin-registry-DC8RlCfd.js.map} +1 -1
- package/dist/{hooks-resolution-Ct3OPm5A.js → hooks-resolution-Ci98WDjn.js} +11 -7
- package/dist/hooks-resolution-Ci98WDjn.js.map +1 -0
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/package.json +32 -29
- package/dist/hooks-resolution-Ct3OPm5A.js.map +0 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ SDK. Use the full distribution directly, or install individual
|
|
|
18
18
|
## Quick start
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
pnpx my-pi@latest
|
|
21
|
+
pnpx --allow-build=@google/genai --allow-build=protobufjs my-pi@latest
|
|
22
22
|
# or: npx my-pi@latest / bunx my-pi@latest
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -29,7 +29,7 @@ pnpx my-pi@latest
|
|
|
29
29
|
Use `my-pi` if you want the complete, opinionated setup:
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
|
-
pnpx my-pi@latest
|
|
32
|
+
pnpx --allow-build=@google/genai --allow-build=protobufjs my-pi@latest
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
This is its own CLI wrapper around Pi. Do not install the root package
|
|
@@ -49,6 +49,32 @@ Use this path if you already have your own Pi setup and only want
|
|
|
49
49
|
selected features. Package READMEs are the source of truth for install
|
|
50
50
|
instructions, commands, configuration, and runtime behavior.
|
|
51
51
|
|
|
52
|
+
### Programmatic use
|
|
53
|
+
|
|
54
|
+
`create_my_pi()` accepts upstream `InlineExtension` values, including
|
|
55
|
+
named wrappers that keep startup extension paths descriptive. Bare
|
|
56
|
+
factory functions remain supported.
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { create_my_pi, type InlineExtension } from 'my-pi';
|
|
60
|
+
|
|
61
|
+
const audit_extension: InlineExtension = {
|
|
62
|
+
name: 'audit-events',
|
|
63
|
+
factory(pi) {
|
|
64
|
+
pi.on('agent_start', () => console.log('agent started'));
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const runtime = await create_my_pi({
|
|
69
|
+
extensionFactories: [audit_extension],
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The wrapper above appears as `<inline:audit-events>` in Pi's startup
|
|
74
|
+
Extensions list. Names beginning with `my-pi-` are reserved for the
|
|
75
|
+
managed distribution extensions; `create_my_pi()` rejects consumer
|
|
76
|
+
wrappers using that prefix before loading any extensions.
|
|
77
|
+
|
|
52
78
|
## What you get
|
|
53
79
|
|
|
54
80
|
- **Pi-native CLI + SDK wrapper** — interactive TUI, print mode, JSON
|
|
@@ -90,6 +116,22 @@ observability packages. The CLI suppresses Node's expected
|
|
|
90
116
|
`node:sqlite` `ExperimentalWarning`; standalone package/API consumers
|
|
91
117
|
own their process warning policy until Node marks it stable.
|
|
92
118
|
|
|
119
|
+
### pnpm 11 first-run build approval
|
|
120
|
+
|
|
121
|
+
pnpm 11 asks for interactive approval before running the transitive
|
|
122
|
+
`@google/genai` preinstall and `protobufjs` postinstall hooks. Neither
|
|
123
|
+
hook builds runtime artifacts: the first prints a no-op message and
|
|
124
|
+
the second only checks dependency version syntax. Declining them does
|
|
125
|
+
not degrade `my-pi` functionality.
|
|
126
|
+
|
|
127
|
+
For a deterministic first run, or after accidentally selecting `No`,
|
|
128
|
+
rerun the Quick start command with both `--allow-build` flags. It
|
|
129
|
+
allows those two known hooks without the two-stage selection and
|
|
130
|
+
confirmation prompt. The package does not publish a `pnpm` settings
|
|
131
|
+
block because pnpm 11 ignores package-level build policy. The
|
|
132
|
+
`node-domexception` deprecation notice is also transitive and does not
|
|
133
|
+
affect runtime behavior.
|
|
134
|
+
|
|
93
135
|
## Common usage
|
|
94
136
|
|
|
95
137
|
```bash
|
|
@@ -167,12 +209,13 @@ Full package list here:
|
|
|
167
209
|
| [`@spences10/pi-themes`](./packages/pi-themes/README.md) | Bundled theme pack for Pi |
|
|
168
210
|
|
|
169
211
|
Shared helper packages such as `@spences10/pi-child-env`,
|
|
170
|
-
`@spences10/pi-footer`, `@spences10/pi-
|
|
171
|
-
`@spences10/pi-
|
|
172
|
-
`@spences10/pi-
|
|
173
|
-
published as dependencies and are not
|
|
174
|
-
`pi install`. See
|
|
175
|
-
the authoritative
|
|
212
|
+
`@spences10/pi-footer`, `@spences10/pi-git-remote`,
|
|
213
|
+
`@spences10/pi-project-trust`, `@spences10/pi-settings`,
|
|
214
|
+
`@spences10/pi-skill-importer`, `@spences10/pi-sqlite-core`, and
|
|
215
|
+
`@spences10/pi-tui-modal` are published as dependencies and are not
|
|
216
|
+
packages to install via `pi install`. See
|
|
217
|
+
[`docs/package-map.md`](./docs/package-map.md) for the authoritative
|
|
218
|
+
classification.
|
|
176
219
|
|
|
177
220
|
Maintainers publish from GitHub Actions with npm trusted publishing;
|
|
178
221
|
see [`docs/releases.md`](./docs/releases.md) for the workflow and the
|
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AgentSessionRuntime, CreateAgentSessionFromServicesOptions, ExtensionAPI, ExtensionFactory, ExtensionFactory as ExtensionFactory$1, InteractiveMode, InteractiveModeOptions, PrintModeOptions, runPrintMode, runRpcMode } from "@earendil-works/pi-coding-agent";
|
|
1
|
+
import { AgentSessionRuntime, CreateAgentSessionFromServicesOptions, ExtensionAPI, ExtensionFactory, ExtensionFactory as ExtensionFactory$1, InlineExtension, InlineExtension as InlineExtension$1, InteractiveMode, InteractiveModeOptions, PrintModeOptions, runPrintMode, runRpcMode } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { Api, Model } from "@earendil-works/pi-ai";
|
|
3
3
|
//#region src/extensions/startup-screen/index.d.ts
|
|
4
4
|
declare function startup_screen_extension(pi: ExtensionAPI): void;
|
|
@@ -384,7 +384,8 @@ interface CreateMyPiOptions extends BuiltinExtensionOptions {
|
|
|
384
384
|
cwd?: string;
|
|
385
385
|
agent_dir?: string;
|
|
386
386
|
extensions?: string[];
|
|
387
|
-
|
|
387
|
+
/** Named wrappers must not use the reserved `my-pi-` prefix. */
|
|
388
|
+
extensionFactories?: InlineExtension$1[];
|
|
388
389
|
runtime_mode?: MyPiRuntimeMode;
|
|
389
390
|
telemetry?: boolean;
|
|
390
391
|
telemetry_db_path?: string;
|
|
@@ -421,5 +422,5 @@ declare function resolve_effective_thinking_level(model: Model<Api> | undefined,
|
|
|
421
422
|
//#region src/api.d.ts
|
|
422
423
|
declare function create_my_pi(options?: CreateMyPiOptions): Promise<import("@earendil-works/pi-coding-agent").AgentSessionRuntime>;
|
|
423
424
|
//#endregion
|
|
424
|
-
export { type AgentSessionRuntime, type CreateMyPiOptions, type ExtensionFactory, InteractiveMode, type InteractiveModeOptions, type MyPiRuntimeMode, type MyPiThinkingLevel, type PrintModeOptions, apply_untrusted_repo_defaults, create_lazy_builtin_extension_factory, create_my_pi, get_externally_installed_builtin_extensions, get_force_disabled_builtins, resolve_effective_thinking_level, resolve_model_reference, runPrintMode, runRpcMode };
|
|
425
|
+
export { type AgentSessionRuntime, type CreateMyPiOptions, type ExtensionFactory, type InlineExtension, InteractiveMode, type InteractiveModeOptions, type MyPiRuntimeMode, type MyPiThinkingLevel, type PrintModeOptions, apply_untrusted_repo_defaults, create_lazy_builtin_extension_factory, create_my_pi, get_externally_installed_builtin_extensions, get_force_disabled_builtins, resolve_effective_thinking_level, resolve_model_reference, runPrintMode, runRpcMode };
|
|
425
426
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as BUILTIN_EXTENSION_REGISTRY, t as BUILTIN_EXTENSIONS } from "./builtin-registry-
|
|
1
|
+
import { n as BUILTIN_EXTENSION_REGISTRY, t as BUILTIN_EXTENSIONS } from "./builtin-registry-DC8RlCfd.js";
|
|
2
2
|
import { n as save_settings, t as load_settings } from "./settings-CTk0ws43.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, readdirSync } from "node:fs";
|
|
@@ -58,6 +58,10 @@ function find_builtin_extension(query) {
|
|
|
58
58
|
].some((value) => value.toLowerCase() === normalized));
|
|
59
59
|
}
|
|
60
60
|
const PACKAGE_THEME_DIR = resolve(dirname(createRequire(import.meta.url).resolve("@spences10/pi-themes/package.json")), "themes");
|
|
61
|
+
const MANAGED_INLINE_EXTENSION_NAME_PREFIX = "my-pi-";
|
|
62
|
+
function assert_unreserved_inline_extension_names(extensions) {
|
|
63
|
+
for (const extension of extensions) if (typeof extension !== "function" && extension.name.startsWith("my-pi-")) throw new Error(`Inline extension name "${extension.name}" is reserved for my-pi managed extensions; choose a name that does not start with "${MANAGED_INLINE_EXTENSION_NAME_PREFIX}".`);
|
|
64
|
+
}
|
|
61
65
|
function get_force_disabled_builtins(options) {
|
|
62
66
|
const force_disabled = /* @__PURE__ */ new Set();
|
|
63
67
|
for (const extension of BUILTIN_EXTENSION_REGISTRY) {
|
|
@@ -102,15 +106,16 @@ function create_lazy_telemetry_extension(options) {
|
|
|
102
106
|
}
|
|
103
107
|
};
|
|
104
108
|
}
|
|
105
|
-
function create_extensions_override(
|
|
106
|
-
const managed_paths = new Set(managed_inline_paths);
|
|
109
|
+
function create_extensions_override(managed_extension_paths) {
|
|
107
110
|
return (base) => {
|
|
108
|
-
const
|
|
109
|
-
const ordered_managed =
|
|
110
|
-
|
|
111
|
+
const remaining = [...base.extensions];
|
|
112
|
+
const ordered_managed = managed_extension_paths.flatMap((path) => {
|
|
113
|
+
const index = remaining.findIndex((extension) => extension.path === path);
|
|
114
|
+
return index === -1 ? [] : remaining.splice(index, 1);
|
|
115
|
+
});
|
|
111
116
|
return {
|
|
112
117
|
...base,
|
|
113
|
-
extensions: [...ordered_managed, ...
|
|
118
|
+
extensions: [...ordered_managed, ...remaining]
|
|
114
119
|
};
|
|
115
120
|
};
|
|
116
121
|
}
|
|
@@ -397,6 +402,7 @@ create_extensions_extension();
|
|
|
397
402
|
//#region src/api.ts
|
|
398
403
|
async function create_my_pi(options = {}) {
|
|
399
404
|
const { cwd = process.cwd(), agent_dir, extensions = [], extensionFactories: user_factories = [], runtime_mode = "interactive", telemetry, telemetry_db_path, model, thinking, selected_tools, excluded_tools, selected_skills, session, session_id, startup_session_name, session_dir, system_prompt, append_system_prompt, untrusted_repo = false } = options;
|
|
405
|
+
assert_unreserved_inline_extension_names(user_factories);
|
|
400
406
|
const env_keys_to_restore = /* @__PURE__ */ new Set([MY_PI_RUNTIME_MODE_ENV]);
|
|
401
407
|
if (agent_dir) env_keys_to_restore.add(PI_AGENT_DIR_ENV);
|
|
402
408
|
const env_snapshot = snapshot_env(process.env, env_keys_to_restore);
|
|
@@ -424,16 +430,25 @@ async function create_my_pi(options = {}) {
|
|
|
424
430
|
const skills_package = skills_builtin_enabled ? await import("@spences10/pi-skills").catch((error) => {
|
|
425
431
|
warn_builtin_extension_unavailable("skills", error);
|
|
426
432
|
}) : void 0;
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
const managed_inline_extensions = [
|
|
434
|
+
{
|
|
435
|
+
name: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}telemetry`,
|
|
436
|
+
factory: create_lazy_telemetry_extension({
|
|
437
|
+
enabled: telemetry,
|
|
438
|
+
db_path: telemetry_db_path,
|
|
439
|
+
cwd
|
|
440
|
+
})
|
|
441
|
+
},
|
|
442
|
+
{
|
|
443
|
+
name: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}extensions-manager`,
|
|
444
|
+
factory: create_extensions_extension({ force_disabled })
|
|
445
|
+
},
|
|
446
|
+
...BUILTIN_EXTENSION_REGISTRY.map((extension) => ({
|
|
447
|
+
name: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}${extension.key}`,
|
|
448
|
+
factory: create_lazy_builtin_extension_factory(extension.key, extension.load, force_disabled)
|
|
449
|
+
}))
|
|
435
450
|
];
|
|
436
|
-
const
|
|
451
|
+
const managed_extension_paths = managed_inline_extensions.map((extension) => `<inline:${extension.name}>`);
|
|
437
452
|
const create_runtime = async ({ cwd: runtime_cwd, sessionManager, sessionStartEvent }) => {
|
|
438
453
|
const runtime_skills_manager = skills_package?.create_skills_manager({
|
|
439
454
|
cwd: runtime_cwd,
|
|
@@ -449,8 +464,8 @@ async function create_my_pi(options = {}) {
|
|
|
449
464
|
...append_system_prompt !== void 0 ? { appendSystemPromptOverride: (base) => [...base, append_system_prompt] } : {},
|
|
450
465
|
additionalExtensionPaths: [...resolved_extensions],
|
|
451
466
|
...runtime_mode === "interactive" ? { additionalThemePaths: [PACKAGE_THEME_DIR] } : {},
|
|
452
|
-
extensionFactories: [...
|
|
453
|
-
extensionsOverride: create_extensions_override(
|
|
467
|
+
extensionFactories: [...managed_inline_extensions, ...user_factories],
|
|
468
|
+
extensionsOverride: create_extensions_override(managed_extension_paths),
|
|
454
469
|
skillsOverride: (base) => {
|
|
455
470
|
if (!skills_builtin_enabled) return {
|
|
456
471
|
...base,
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../src/extensions/manager/config.ts","../src/api/builtin-extensions.ts","../src/api/env.ts","../src/api/models.ts","../src/api/session.ts","../src/extensions/manager/index.ts","../src/api.ts"],"sourcesContent":["import {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionInfo,\n\ttype BuiltinExtensionKey,\n} from '../builtin-registry.js';\nimport {\n\tget_settings_path,\n\tload_settings,\n\tsave_settings,\n} from '../../settings/index.js';\n\nexport { BUILTIN_EXTENSIONS };\nexport type { BuiltinExtensionInfo, BuiltinExtensionKey };\n\nexport interface BuiltinExtensionsConfig {\n\tversion: number;\n\tenabled: Partial<Record<BuiltinExtensionKey, boolean>>;\n}\n\nexport interface BuiltinExtensionState extends BuiltinExtensionInfo {\n\tsaved_enabled: boolean;\n\teffective_enabled: boolean;\n\tforced_disabled: boolean;\n}\n\nexport function get_builtin_extensions_config_path(): string {\n\treturn get_settings_path();\n}\n\nexport function load_builtin_extensions_config(): BuiltinExtensionsConfig {\n\tconst settings = load_settings();\n\tconst enabled: BuiltinExtensionsConfig['enabled'] = {};\n\tfor (const extension of BUILTIN_EXTENSIONS) {\n\t\tconst value = settings.extensions.enabled[extension.key];\n\t\tif (typeof value === 'boolean') enabled[extension.key] = value;\n\t}\n\treturn { version: 1, enabled };\n}\n\nexport function save_builtin_extensions_config(\n\tconfig: BuiltinExtensionsConfig,\n): void {\n\tconst settings = load_settings();\n\tsave_settings({\n\t\t...settings,\n\t\textensions: {\n\t\t\t...settings.extensions,\n\t\t\tenabled: config.enabled,\n\t\t},\n\t});\n}\n\nexport function is_builtin_extension_enabled(\n\tconfig: BuiltinExtensionsConfig,\n\tkey: BuiltinExtensionKey,\n): boolean {\n\treturn config.enabled[key] ?? true;\n}\n\nexport function is_builtin_extension_active(\n\tconfig: BuiltinExtensionsConfig,\n\tkey: BuiltinExtensionKey,\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey> = new Set(),\n): boolean {\n\treturn (\n\t\tis_builtin_extension_enabled(config, key) &&\n\t\t!force_disabled.has(key)\n\t);\n}\n\nexport function resolve_builtin_extension_states(\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey> = new Set(),\n\tconfig: BuiltinExtensionsConfig = load_builtin_extensions_config(),\n): BuiltinExtensionState[] {\n\treturn BUILTIN_EXTENSIONS.map((extension) => {\n\t\tconst saved_enabled = is_builtin_extension_enabled(\n\t\t\tconfig,\n\t\t\textension.key,\n\t\t);\n\t\tconst forced = force_disabled.has(extension.key);\n\t\treturn {\n\t\t\t...extension,\n\t\t\tsaved_enabled,\n\t\t\teffective_enabled: saved_enabled && !forced,\n\t\t\tforced_disabled: forced,\n\t\t};\n\t});\n}\n\nexport function find_builtin_extension(\n\tquery: string,\n): BuiltinExtensionInfo | undefined {\n\tconst normalized = query.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\n\treturn BUILTIN_EXTENSIONS.find((extension) =>\n\t\t[extension.key, extension.label, ...extension.aliases].some(\n\t\t\t(value) => value.toLowerCase() === normalized,\n\t\t),\n\t);\n}\n","import type {\n\tExtensionFactory,\n\tLoadExtensionsResult,\n} from '@earendil-works/pi-coding-agent';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSION_REGISTRY,\n\ttype BuiltinExtensionKey,\n} from '../extensions/builtin-registry.js';\nimport {\n\tis_builtin_extension_active,\n\tload_builtin_extensions_config,\n} from '../extensions/manager/config.js';\nimport type {\n\tBuiltinExtensionOptions,\n\tCreateMyPiOptions,\n\tMyPiRuntimeMode,\n} from './options.js';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nconst require = createRequire(import.meta.url);\nexport const PACKAGE_THEME_DIR = resolve(\n\tdirname(require.resolve('@spences10/pi-themes/package.json')),\n\t'themes',\n);\n\nexport function get_force_disabled_builtins(\n\toptions: Pick<CreateMyPiOptions, 'runtime_mode'> &\n\t\tBuiltinExtensionOptions,\n): Set<BuiltinExtensionKey> {\n\tconst force_disabled = new Set<BuiltinExtensionKey>();\n\tfor (const extension of BUILTIN_EXTENSION_REGISTRY) {\n\t\tconst enabled =\n\t\t\toptions[extension.option_name] ?? extension.default_enabled;\n\t\tif (!enabled) force_disabled.add(extension.key);\n\t\tconst disabled_in =\n\t\t\t'mode_constraints' in extension\n\t\t\t\t? extension.mode_constraints.disabled_in\n\t\t\t\t: undefined;\n\t\tif (\n\t\t\toptions.runtime_mode &&\n\t\t\t(\n\t\t\t\tdisabled_in as readonly MyPiRuntimeMode[] | undefined\n\t\t\t)?.includes(options.runtime_mode)\n\t\t) {\n\t\t\tforce_disabled.add(extension.key);\n\t\t}\n\t}\n\treturn force_disabled;\n}\n\nfunction is_agent_dir_package_installed(\n\tagent_dir: string,\n\tpackage_name: string,\n): boolean {\n\treturn existsSync(\n\t\tjoin(agent_dir, 'npm', 'node_modules', package_name),\n\t);\n}\n\nexport function get_externally_installed_builtin_extensions(\n\tagent_dir: string,\n): Set<BuiltinExtensionKey> {\n\tconst installed = new Set<BuiltinExtensionKey>();\n\tfor (const extension of BUILTIN_EXTENSION_REGISTRY) {\n\t\tconst external_package_name = (\n\t\t\textension as { external_package_name?: string }\n\t\t).external_package_name;\n\t\tif (\n\t\t\texternal_package_name &&\n\t\t\tis_agent_dir_package_installed(agent_dir, external_package_name)\n\t\t) {\n\t\t\tinstalled.add(extension.key);\n\t\t}\n\t}\n\treturn installed;\n}\n\nexport function warn_builtin_extension_unavailable(\n\tkey: BuiltinExtensionKey | 'telemetry',\n\terror: unknown,\n): void {\n\tconst reason =\n\t\terror instanceof Error ? error.message : String(error);\n\tprocess.emitWarning(\n\t\t`Built-in extension \"${key}\" is unavailable and was skipped: ${reason}`,\n\t\t{ code: 'MY_PI_BUILTIN_EXTENSION_UNAVAILABLE' },\n\t);\n}\n\nexport function create_lazy_builtin_extension_factory(\n\tkey: BuiltinExtensionKey,\n\tload_extension: BuiltinExtensionLoader,\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey>,\n): ExtensionFactory {\n\treturn async (pi) => {\n\t\tconst config = load_builtin_extensions_config();\n\t\tif (!is_builtin_extension_active(config, key, force_disabled)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst extension = await load_extension();\n\t\t\tawait extension(pi);\n\t\t} catch (error) {\n\t\t\twarn_builtin_extension_unavailable(key, error);\n\t\t}\n\t};\n}\n\nexport function create_lazy_telemetry_extension(options: {\n\tenabled?: boolean;\n\tdb_path?: string;\n\tcwd?: string;\n}): ExtensionFactory {\n\treturn async (pi) => {\n\t\ttry {\n\t\t\tconst { create_telemetry_extension } =\n\t\t\t\tawait import('@spences10/pi-telemetry');\n\t\t\tawait create_telemetry_extension(options)(pi);\n\t\t} catch (error) {\n\t\t\twarn_builtin_extension_unavailable('telemetry', error);\n\t\t}\n\t};\n}\n\nexport function create_extensions_override(\n\tmanaged_inline_paths: string[],\n): (base: LoadExtensionsResult) => LoadExtensionsResult {\n\tconst managed_paths = new Set(managed_inline_paths);\n\treturn (base) => {\n\t\tconst managed = new Map(\n\t\t\tbase.extensions.map((extension) => [extension.path, extension]),\n\t\t);\n\t\tconst ordered_managed = managed_inline_paths\n\t\t\t.map((path) => managed.get(path))\n\t\t\t.filter(\n\t\t\t\t(\n\t\t\t\t\textension,\n\t\t\t\t): extension is LoadExtensionsResult['extensions'][number] =>\n\t\t\t\t\tBoolean(extension),\n\t\t\t);\n\t\tconst others = base.extensions.filter(\n\t\t\t(extension) => !managed_paths.has(extension.path),\n\t\t);\n\t\treturn {\n\t\t\t...base,\n\t\t\textensions: [...ordered_managed, ...others],\n\t\t};\n\t};\n}\n","import { getAgentDir } from '@earendil-works/pi-coding-agent';\nimport { apply_project_trust_untrusted_defaults } from '@spences10/pi-project-trust';\nimport { resolve } from 'node:path';\n\nexport const PI_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nexport const MY_PI_RUNTIME_MODE_ENV = 'MY_PI_RUNTIME_MODE';\n\ntype EnvSnapshot = Map<string, string | undefined>;\n\nexport function snapshot_env(\n\tenv: NodeJS.ProcessEnv,\n\tkeys: Iterable<string>,\n): EnvSnapshot {\n\treturn new Map(Array.from(keys, (key) => [key, env[key]]));\n}\n\nexport function restore_env(\n\tenv: NodeJS.ProcessEnv,\n\tsnapshot: EnvSnapshot,\n): void {\n\tfor (const [key, value] of snapshot) {\n\t\tif (value === undefined) delete env[key];\n\t\telse env[key] = value;\n\t}\n}\n\nexport function wrap_runtime_env_restore<\n\tT extends { dispose(): Promise<void> },\n>(runtime: T, restore: () => void): T {\n\tconst dispose = runtime.dispose.bind(runtime);\n\tlet restored = false;\n\tconst restore_once = () => {\n\t\tif (restored) return;\n\t\trestored = true;\n\t\trestore();\n\t};\n\n\truntime.dispose = (async () => {\n\t\ttry {\n\t\t\tawait dispose();\n\t\t} finally {\n\t\t\trestore_once();\n\t\t}\n\t}) as T['dispose'];\n\n\treturn runtime;\n}\n\nconst UNTRUSTED_CHILD_ENV_DEFAULTS: Record<string, string> = {\n\tMY_PI_CHILD_ENV_ALLOWLIST: '',\n\tMY_PI_MCP_ENV_ALLOWLIST: '',\n\tMY_PI_LSP_ENV_ALLOWLIST: '',\n\tMY_PI_HOOKS_ENV_ALLOWLIST: '',\n\tMY_PI_TEAM_MODE_ENV_ALLOWLIST: '',\n};\n\nexport function apply_untrusted_repo_defaults(\n\tenv: NodeJS.ProcessEnv = process.env,\n): string[] {\n\tconst applied = apply_project_trust_untrusted_defaults(env);\n\tfor (const [key, value] of Object.entries(\n\t\tUNTRUSTED_CHILD_ENV_DEFAULTS,\n\t)) {\n\t\tif (env[key] !== undefined) continue;\n\t\tenv[key] = value;\n\t\tapplied.push(key);\n\t}\n\treturn applied;\n}\n\nexport function is_resource_enabled(\n\tvalue: string | undefined,\n): boolean {\n\tconst normalized = value?.trim().toLowerCase();\n\tif (!normalized) return true;\n\tif (['0', 'false', 'no', 'skip', 'disable'].includes(normalized)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport function resolve_agent_dir(\n\tcwd: string,\n\tagent_dir?: string,\n): string {\n\treturn agent_dir ? resolve(cwd, agent_dir) : getAgentDir();\n}\n","import {\n\tclampThinkingLevel,\n\ttype Api,\n\ttype Model,\n} from '@earendil-works/pi-ai';\nimport type { MyPiThinkingLevel } from './options.js';\n\ninterface ModelsLike {\n\tgetModels(): readonly Model<Api>[];\n}\n\nexport function resolve_model_reference(\n\tmodel_reference: string | undefined,\n\tmodels_runtime: ModelsLike,\n): Model<Api> | undefined {\n\tif (!model_reference) return undefined;\n\tconst models = models_runtime.getModels();\n\tconst lower_reference = model_reference.toLowerCase();\n\tconst slash_index = model_reference.indexOf('/');\n\n\tif (slash_index !== -1) {\n\t\tconst maybe_provider = model_reference.slice(0, slash_index);\n\t\tconst model_id = model_reference.slice(slash_index + 1);\n\t\tconst provider = models.find(\n\t\t\t(model) =>\n\t\t\t\tmodel.provider.toLowerCase() === maybe_provider.toLowerCase(),\n\t\t)?.provider;\n\n\t\tif (provider) {\n\t\t\tconst provider_match = models.find(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.provider === provider &&\n\t\t\t\t\tmodel.id.toLowerCase() === model_id.toLowerCase(),\n\t\t\t);\n\t\t\tif (provider_match) return provider_match;\n\t\t}\n\t}\n\n\treturn models.find((model) => {\n\t\tconst id = model.id.toLowerCase();\n\t\tconst full_id = `${model.provider}/${model.id}`.toLowerCase();\n\t\treturn id === lower_reference || full_id === lower_reference;\n\t});\n}\n\nexport function resolve_effective_thinking_level(\n\tmodel: Model<Api> | undefined,\n\tthinking: MyPiThinkingLevel | undefined,\n): MyPiThinkingLevel | undefined {\n\tif (!thinking || !model) return thinking;\n\treturn clampThinkingLevel(model, thinking);\n}\n","import { SessionManager } from '@earendil-works/pi-coding-agent';\nimport { existsSync, readdirSync } from 'node:fs';\nimport { basename, isAbsolute, join, resolve } from 'node:path';\n\nfunction resolve_session_file(\n\tcwd: string,\n\tsession_dir: string | undefined,\n\tsession_ref: string | undefined,\n): string | undefined {\n\tif (!session_ref) return undefined;\n\tconst explicit_path = isAbsolute(session_ref)\n\t\t? session_ref\n\t\t: resolve(cwd, session_ref);\n\tif (existsSync(explicit_path)) return explicit_path;\n\tif (session_ref.endsWith('.jsonl')) return explicit_path;\n\n\tconst dir = session_dir ? resolve(cwd, session_dir) : undefined;\n\tif (!dir || !existsSync(dir)) return undefined;\n\tconst matches = readdirSync(dir)\n\t\t.filter(\n\t\t\t(file) =>\n\t\t\t\tfile.endsWith('.jsonl') &&\n\t\t\t\t(basename(file, '.jsonl').endsWith(session_ref) ||\n\t\t\t\t\tfile.includes(session_ref)),\n\t\t)\n\t\t.sort();\n\tconst match = matches.at(-1);\n\treturn match ? join(dir, match) : undefined;\n}\n\nexport function create_session_manager(options: {\n\tcwd: string;\n\tsession_dir?: string;\n\tsession?: string;\n\tsession_id?: string;\n\tstartup_session_name?: string;\n}): SessionManager {\n\tconst resolved_session_dir = options.session_dir\n\t\t? resolve(options.cwd, options.session_dir)\n\t\t: SessionManager.create(options.cwd).getSessionDir();\n\tconst session_ref = options.session ?? options.session_id;\n\tconst session_file = resolve_session_file(\n\t\toptions.cwd,\n\t\tresolved_session_dir,\n\t\tsession_ref,\n\t);\n\tconst session_manager = session_file\n\t\t? SessionManager.open(\n\t\t\t\tsession_file,\n\t\t\t\tresolved_session_dir,\n\t\t\t\toptions.cwd,\n\t\t\t)\n\t\t: SessionManager.create(\n\t\t\t\toptions.cwd,\n\t\t\t\tresolved_session_dir,\n\t\t\t\toptions.session_id ? { id: options.session_id } : {},\n\t\t\t);\n\tif (\n\t\toptions.startup_session_name &&\n\t\tsession_manager.getSessionName() !== options.startup_session_name\n\t) {\n\t\tsession_manager.appendSessionInfo(options.startup_session_name);\n\t}\n\treturn session_manager;\n}\n","import type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n} from '@earendil-works/pi-coding-agent';\nimport { type SettingItem } from '@earendil-works/pi-tui';\nimport { show_settings_modal } from '@spences10/pi-tui-modal';\nimport {\n\tBUILTIN_EXTENSIONS,\n\tfind_builtin_extension,\n\tload_builtin_extensions_config,\n\tresolve_builtin_extension_states,\n\tsave_builtin_extensions_config,\n\ttype BuiltinExtensionKey,\n\ttype BuiltinExtensionState,\n} from './config.js';\n\nconst ENABLED = '● enabled';\nconst DISABLED = '○ disabled';\n\nexport interface ExtensionsManagerOptions {\n\tforce_disabled?: Iterable<BuiltinExtensionKey>;\n}\n\nfunction to_force_disabled_set(\n\tforce_disabled?: Iterable<BuiltinExtensionKey>,\n): ReadonlySet<BuiltinExtensionKey> {\n\treturn new Set(force_disabled ?? []);\n}\n\nfunction format_effective_state(\n\tstate: BuiltinExtensionState,\n): string {\n\tif (state.effective_enabled) {\n\t\treturn 'enabled';\n\t}\n\tif (state.forced_disabled) {\n\t\treturn `disabled in this process by ${state.cli_flag}`;\n\t}\n\treturn 'disabled';\n}\n\nfunction format_extension_lines(\n\tstates: BuiltinExtensionState[],\n\toptions?: { heading?: string },\n): string {\n\tconst lines: string[] = [];\n\tif (options?.heading) {\n\t\tlines.push(options.heading, '');\n\t}\n\n\tconst enabled_now = states.filter(\n\t\t(state) => state.effective_enabled,\n\t).length;\n\tconst disabled_now = states.length - enabled_now;\n\tlines.push(\n\t\t`${states.length} built-in extensions (${enabled_now} enabled now, ${disabled_now} disabled now)`,\n\t\t'',\n\t);\n\n\tfor (const state of states) {\n\t\tlines.push(\n\t\t\t`${state.saved_enabled ? ENABLED : DISABLED} ${state.label}`,\n\t\t);\n\t\tlines.push(` key: ${state.key}`);\n\t\tlines.push(\n\t\t\t` saved config: ${state.saved_enabled ? 'enabled' : 'disabled'}`,\n\t\t);\n\t\tlines.push(\n\t\t\t` current process: ${format_effective_state(state)}`,\n\t\t);\n\t\tlines.push(` ${state.description}`);\n\t}\n\n\treturn lines.join('\\n');\n}\n\nfunction to_setting_item(state: BuiltinExtensionState): SettingItem {\n\tconst detail_lines = [\n\t\tstate.key,\n\t\tstate.description,\n\t\t`current process: ${format_effective_state(state)}`,\n\t\t`startup override: ${state.cli_flag}`,\n\t];\n\n\treturn {\n\t\tid: state.key,\n\t\tlabel: state.label,\n\t\tdescription: detail_lines.join('\\n'),\n\t\tcurrentValue: state.saved_enabled ? ENABLED : DISABLED,\n\t\tvalues: [ENABLED, DISABLED],\n\t};\n}\n\nfunction sets_equal(\n\ta: ReadonlySet<string>,\n\tb: ReadonlySet<string>,\n): boolean {\n\tif (a.size !== b.size) return false;\n\tfor (const value of a) {\n\t\tif (!b.has(value)) return false;\n\t}\n\treturn true;\n}\n\nfunction search_states(\n\tstates: BuiltinExtensionState[],\n\tquery: string,\n): BuiltinExtensionState[] {\n\tconst normalized = query.trim().toLowerCase();\n\tif (!normalized) return states;\n\n\treturn states.filter((state) =>\n\t\t[\n\t\t\tstate.key,\n\t\t\tstate.label,\n\t\t\tstate.description,\n\t\t\t...state.aliases,\n\t\t].some((value) => value.toLowerCase().includes(normalized)),\n\t);\n}\n\nfunction save_extension_enabled(\n\tkey: BuiltinExtensionKey,\n\tenabled: boolean,\n): void {\n\tconst config = load_builtin_extensions_config();\n\tconfig.enabled[key] = enabled;\n\tsave_builtin_extensions_config(config);\n}\n\nexport function create_extensions_extension(\n\toptions: ExtensionsManagerOptions = {},\n) {\n\tconst force_disabled = to_force_disabled_set(\n\t\toptions.force_disabled,\n\t);\n\n\tasync function show_manager(\n\t\tctx: ExtensionCommandContext,\n\t): Promise<boolean> {\n\t\tif (!ctx.hasUI) return false;\n\n\t\tconst states = resolve_builtin_extension_states(force_disabled);\n\t\tconst initial_enabled = new Set(\n\t\t\tstates\n\t\t\t\t.filter((state) => state.saved_enabled)\n\t\t\t\t.map((state) => state.key),\n\t\t);\n\t\tconst current_enabled = new Set(initial_enabled);\n\n\t\tconst items = states.map(to_setting_item);\n\t\tawait show_settings_modal(ctx, {\n\t\t\ttitle: 'Built-in extensions',\n\t\t\tsubtitle: () => {\n\t\t\t\tconst saved_enabled = current_enabled.size;\n\t\t\t\tconst saved_disabled = states.length - saved_enabled;\n\t\t\t\tconst enabled_now = [...current_enabled].filter(\n\t\t\t\t\t(key) => !force_disabled.has(key as BuiltinExtensionKey),\n\t\t\t\t).length;\n\t\t\t\tconst disabled_now = states.length - enabled_now;\n\t\t\t\treturn `${saved_enabled} saved enabled • ${saved_disabled} saved disabled • ${enabled_now} enabled now • ${disabled_now} disabled now`;\n\t\t\t},\n\t\t\titems,\n\t\t\tenable_search: true,\n\t\t\tfooter:\n\t\t\t\t'esc close • search filters • changes save immediately • CLI --no-* flags still win in this process',\n\t\t\ton_change: (id, new_value) => {\n\t\t\t\tconst key = id as BuiltinExtensionKey;\n\t\t\t\tconst enabled = new_value === ENABLED;\n\t\t\t\tif (enabled) {\n\t\t\t\t\tcurrent_enabled.add(key);\n\t\t\t\t} else {\n\t\t\t\t\tcurrent_enabled.delete(key);\n\t\t\t\t}\n\t\t\t\tsave_extension_enabled(key, enabled);\n\t\t\t},\n\t\t});\n\n\t\tif (!sets_equal(initial_enabled, current_enabled)) {\n\t\t\tctx.ui.notify(\n\t\t\t\tforce_disabled.size > 0\n\t\t\t\t\t? 'Reloading to apply updated built-in extensions. CLI --no-* flags still force-disable some extensions in this process.'\n\t\t\t\t\t: 'Reloading to apply updated built-in extensions...',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tawait ctx.reload();\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn async function extensions(pi: ExtensionAPI) {\n\t\tconst subs = ['list', 'enable', 'disable', 'toggle', 'search'];\n\n\t\tpi.registerCommand('extensions', {\n\t\t\tdescription: 'Manage built-in my-pi extensions',\n\t\t\tgetArgumentCompletions: (prefix) => {\n\t\t\t\tconst parts = prefix.trim().split(/\\s+/);\n\t\t\t\tif (parts.length <= 1) {\n\t\t\t\t\treturn subs\n\t\t\t\t\t\t.filter((sub) => sub.startsWith(parts[0] || ''))\n\t\t\t\t\t\t.map((sub) => ({ value: sub, label: sub }));\n\t\t\t\t}\n\n\t\t\t\tif (['enable', 'disable', 'toggle'].includes(parts[0])) {\n\t\t\t\t\tconst q = parts.slice(1).join(' ').toLowerCase();\n\t\t\t\t\treturn resolve_builtin_extension_states(force_disabled)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(state) =>\n\t\t\t\t\t\t\t\tstate.key.toLowerCase().includes(q) ||\n\t\t\t\t\t\t\t\tstate.label.toLowerCase().includes(q),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.slice(0, 20)\n\t\t\t\t\t\t.map((state) => ({\n\t\t\t\t\t\t\tvalue: `${parts[0]} ${state.key}`,\n\t\t\t\t\t\t\tlabel: `${state.key} ${state.saved_enabled ? ENABLED : DISABLED}`,\n\t\t\t\t\t\t}));\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\thandler: async (args, ctx) => {\n\t\t\t\tconst trimmed = args.trim();\n\n\t\t\t\tif (!trimmed) {\n\t\t\t\t\tif (await show_manager(ctx)) return;\n\t\t\t\t}\n\n\t\t\t\tconst [sub, ...rest] = (trimmed || 'list').split(/\\s+/);\n\t\t\t\tconst arg = rest.join(' ');\n\t\t\t\tconst states =\n\t\t\t\t\tresolve_builtin_extension_states(force_disabled);\n\n\t\t\t\tswitch (sub) {\n\t\t\t\t\tcase 'list': {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tformat_extension_lines(states, {\n\t\t\t\t\t\t\t\theading: 'Built-in extensions',\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'enable':\n\t\t\t\t\tcase 'disable':\n\t\t\t\t\tcase 'toggle': {\n\t\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\t\tif (await show_manager(ctx)) return;\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Usage: /extensions ${sub} <key>`,\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst extension = find_builtin_extension(arg);\n\t\t\t\t\t\tif (!extension) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Unknown extension: ${arg}. Use: ${BUILTIN_EXTENSIONS.map((item) => item.key).join(', ')}`,\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst current_state = states.find(\n\t\t\t\t\t\t\t(state) => state.key === extension.key,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst next_enabled =\n\t\t\t\t\t\t\tsub === 'enable'\n\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t: sub === 'disable'\n\t\t\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t\t\t: !current_state?.saved_enabled;\n\t\t\t\t\t\tsave_extension_enabled(extension.key, next_enabled);\n\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tnext_enabled && force_disabled.has(extension.key)\n\t\t\t\t\t\t\t\t? `Enabled ${extension.key} in saved config. Still disabled in this process by ${extension.cli_flag}. /reload or restart without that flag to apply.`\n\t\t\t\t\t\t\t\t: `${extension.key} ${next_enabled ? 'enabled' : 'disabled'}. /reload to apply.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'search': {\n\t\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t'Usage: /extensions search <query>',\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst results = search_states(states, arg);\n\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`No built-in extensions matching \"${arg}\"`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tformat_extension_lines(results, {\n\t\t\t\t\t\t\t\theading: `Built-in extensions matching \"${arg}\"`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Unknown: ${sub}. Use: ${subs.join(', ')}`,\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n}\n\nexport default create_extensions_extension();\n","// Composable programmatic API for my-pi\n\nimport {\n\tInteractiveMode,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\trunPrintMode,\n\trunRpcMode,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\ttype ExtensionFactory,\n\ttype SessionManager,\n} from '@earendil-works/pi-coding-agent';\nimport { resolve } from 'node:path';\nimport {\n\tPACKAGE_THEME_DIR,\n\tcreate_extensions_override,\n\tcreate_lazy_builtin_extension_factory,\n\tcreate_lazy_telemetry_extension,\n\tget_externally_installed_builtin_extensions,\n\tget_force_disabled_builtins,\n\twarn_builtin_extension_unavailable,\n} from './api/builtin-extensions.js';\nimport {\n\tMY_PI_RUNTIME_MODE_ENV,\n\tPI_AGENT_DIR_ENV,\n\tapply_untrusted_repo_defaults,\n\tis_resource_enabled,\n\tresolve_agent_dir,\n\trestore_env,\n\tsnapshot_env,\n\twrap_runtime_env_restore,\n} from './api/env.js';\nimport {\n\tresolve_effective_thinking_level,\n\tresolve_model_reference,\n} from './api/models.js';\nimport type { CreateMyPiOptions } from './api/options.js';\nimport { create_session_manager } from './api/session.js';\nimport { BUILTIN_EXTENSION_REGISTRY } from './extensions/builtin-registry.js';\nimport {\n\tis_builtin_extension_active,\n\tload_builtin_extensions_config,\n} from './extensions/manager/config.js';\nimport { create_extensions_extension } from './extensions/manager/index.js';\n\nexport type {\n\tCreateMyPiOptions,\n\tMyPiRuntimeMode,\n\tMyPiThinkingLevel,\n} from './api/options.js';\nexport {\n\tapply_untrusted_repo_defaults,\n\tcreate_lazy_builtin_extension_factory,\n\tget_externally_installed_builtin_extensions,\n\tget_force_disabled_builtins,\n\tresolve_effective_thinking_level,\n\tresolve_model_reference,\n};\n\nexport async function create_my_pi(options: CreateMyPiOptions = {}) {\n\tconst {\n\t\tcwd = process.cwd(),\n\t\tagent_dir,\n\t\textensions = [],\n\t\textensionFactories: user_factories = [],\n\t\truntime_mode = 'interactive',\n\t\ttelemetry,\n\t\ttelemetry_db_path,\n\t\tmodel,\n\t\tthinking,\n\t\tselected_tools,\n\t\texcluded_tools,\n\t\tselected_skills,\n\t\tsession,\n\t\tsession_id,\n\t\tstartup_session_name,\n\t\tsession_dir,\n\t\tsystem_prompt,\n\t\tappend_system_prompt,\n\t\tuntrusted_repo = false,\n\t} = options;\n\n\tconst env_keys_to_restore = new Set<string>([\n\t\tMY_PI_RUNTIME_MODE_ENV,\n\t]);\n\tif (agent_dir) env_keys_to_restore.add(PI_AGENT_DIR_ENV);\n\tconst env_snapshot = snapshot_env(process.env, env_keys_to_restore);\n\tlet restore_runtime_env = () =>\n\t\trestore_env(process.env, env_snapshot);\n\n\tif (untrusted_repo) {\n\t\tconst applied = apply_untrusted_repo_defaults();\n\t\tif (applied.length) {\n\t\t\tconst restore_previous = restore_runtime_env;\n\t\t\trestore_runtime_env = () => {\n\t\t\t\tfor (const key of applied) delete process.env[key];\n\t\t\t\trestore_previous();\n\t\t\t};\n\t\t}\n\t}\n\n\tconst effective_agent_dir = resolve_agent_dir(cwd, agent_dir);\n\tif (agent_dir) {\n\t\tprocess.env[PI_AGENT_DIR_ENV] = effective_agent_dir;\n\t}\n\tprocess.env[MY_PI_RUNTIME_MODE_ENV] = runtime_mode;\n\n\tconst resolved_extensions = extensions.map((p) => resolve(cwd, p));\n\tconst force_disabled = get_force_disabled_builtins({\n\t\t...options,\n\t\truntime_mode,\n\t});\n\tfor (const key of get_externally_installed_builtin_extensions(\n\t\teffective_agent_dir,\n\t)) {\n\t\tforce_disabled.add(key);\n\t}\n\tconst builtins_config = load_builtin_extensions_config();\n\tconst skills_builtin_enabled = is_builtin_extension_active(\n\t\tbuiltins_config,\n\t\t'skills',\n\t\tforce_disabled,\n\t);\n\tconst skills_package = skills_builtin_enabled\n\t\t? await import('@spences10/pi-skills').catch((error) => {\n\t\t\t\twarn_builtin_extension_unavailable('skills', error);\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t: undefined;\n\n\tconst managed_extension_factories: ExtensionFactory[] = [\n\t\tcreate_lazy_telemetry_extension({\n\t\t\tenabled: telemetry,\n\t\t\tdb_path: telemetry_db_path,\n\t\t\tcwd,\n\t\t}),\n\t\tcreate_extensions_extension({ force_disabled }),\n\t\t...BUILTIN_EXTENSION_REGISTRY.map((extension) =>\n\t\t\tcreate_lazy_builtin_extension_factory(\n\t\t\t\textension.key,\n\t\t\t\textension.load,\n\t\t\t\tforce_disabled,\n\t\t\t),\n\t\t),\n\t];\n\tconst managed_inline_paths = managed_extension_factories.map(\n\t\t(_, index) => `<inline:${index + 1}>`,\n\t);\n\n\tconst create_runtime = async ({\n\t\tcwd: runtime_cwd,\n\t\tsessionManager,\n\t\tsessionStartEvent,\n\t}: {\n\t\tcwd: string;\n\t\tsessionManager: SessionManager;\n\t\tsessionStartEvent?: CreateAgentSessionFromServicesOptions['sessionStartEvent'];\n\t}) => {\n\t\t// Keep skill filtering reloadable so profile changes made by\n\t\t// /skills are reflected without restarting the process.\n\t\tconst runtime_skills_manager =\n\t\t\tskills_package?.create_skills_manager({\n\t\t\t\tcwd: runtime_cwd,\n\t\t\t\tproject_skills_enabled: is_resource_enabled(\n\t\t\t\t\tprocess.env.MY_PI_PROJECT_SKILLS,\n\t\t\t\t),\n\t\t\t});\n\t\tconst additional_skill_paths =\n\t\t\truntime_skills_manager?.get_enabled_skill_paths() ?? [];\n\n\t\tconst services = await createAgentSessionServices({\n\t\t\tcwd: runtime_cwd,\n\t\t\tagentDir: effective_agent_dir,\n\t\t\tresourceLoaderOptions: {\n\t\t\t\t...(additional_skill_paths.length\n\t\t\t\t\t? { additionalSkillPaths: additional_skill_paths }\n\t\t\t\t\t: {}),\n\t\t\t\t...(system_prompt !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsystemPromptOverride: () => system_prompt,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(append_system_prompt !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tappendSystemPromptOverride: (base: string[]) => [\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t\tappend_system_prompt,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tadditionalExtensionPaths: [...resolved_extensions],\n\t\t\t\t...(runtime_mode === 'interactive'\n\t\t\t\t\t? { additionalThemePaths: [PACKAGE_THEME_DIR] }\n\t\t\t\t\t: {}),\n\t\t\t\textensionFactories: [\n\t\t\t\t\t...managed_extension_factories,\n\t\t\t\t\t...user_factories,\n\t\t\t\t],\n\t\t\t\textensionsOverride: create_extensions_override(\n\t\t\t\t\tmanaged_inline_paths,\n\t\t\t\t),\n\t\t\t\tskillsOverride: (\n\t\t\t\t\tbase: Parameters<\n\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\t\tCreateAgentSessionServicesOptions['resourceLoaderOptions']\n\t\t\t\t\t\t\t>['skillsOverride']\n\t\t\t\t\t\t>\n\t\t\t\t\t>[0],\n\t\t\t\t) => {\n\t\t\t\t\tif (!skills_builtin_enabled) return { ...base, skills: [] };\n\t\t\t\t\tif (!runtime_skills_manager) return base;\n\t\t\t\t\truntime_skills_manager.refresh();\n\n\t\t\t\t\tconst selected_skill_names = selected_skills?.length\n\t\t\t\t\t\t? new Set(selected_skills)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...base,\n\t\t\t\t\t\tskills: base.skills.filter((skill) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tselected_skill_names &&\n\t\t\t\t\t\t\t\t!selected_skill_names.has(skill.name)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn runtime_skills_manager.is_enabled_by_skill(\n\t\t\t\t\t\t\t\tskill.name,\n\t\t\t\t\t\t\t\tskill.filePath,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t} satisfies CreateAgentSessionServicesOptions['resourceLoaderOptions'],\n\t\t});\n\n\t\tconst requested_model = resolve_model_reference(\n\t\t\tmodel,\n\t\t\tservices.modelRuntime,\n\t\t);\n\t\tconst effective_thinking = resolve_effective_thinking_level(\n\t\t\trequested_model,\n\t\t\tthinking,\n\t\t);\n\t\tif (\n\t\t\trequested_model &&\n\t\t\tthinking &&\n\t\t\teffective_thinking &&\n\t\t\teffective_thinking !== thinking\n\t\t) {\n\t\t\tservices.diagnostics.push({\n\t\t\t\ttype: 'warning',\n\t\t\t\tmessage: `Requested thinking level \"${thinking}\" is not supported by ${requested_model.provider}/${requested_model.id}; using \"${effective_thinking}\".`,\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\t...(await createAgentSessionFromServices({\n\t\t\t\tservices,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent,\n\t\t\t\t...(requested_model ? { model: requested_model } : {}),\n\t\t\t\t...(effective_thinking\n\t\t\t\t\t? { thinkingLevel: effective_thinking }\n\t\t\t\t\t: {}),\n\t\t\t\t...(selected_tools?.length ? { tools: selected_tools } : {}),\n\t\t\t\t...(excluded_tools?.length\n\t\t\t\t\t? { excludeTools: excluded_tools }\n\t\t\t\t\t: {}),\n\t\t\t})),\n\t\t\tservices,\n\t\t\tdiagnostics: services.diagnostics,\n\t\t};\n\t};\n\n\ttry {\n\t\treturn wrap_runtime_env_restore(\n\t\t\tawait createAgentSessionRuntime(create_runtime, {\n\t\t\t\tcwd,\n\t\t\t\tagentDir: effective_agent_dir,\n\t\t\t\tsessionManager: create_session_manager({\n\t\t\t\t\tcwd,\n\t\t\t\t\tsession_dir,\n\t\t\t\t\tsession,\n\t\t\t\t\tsession_id,\n\t\t\t\t\tstartup_session_name,\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trestore_runtime_env,\n\t\t);\n\t} catch (error) {\n\t\trestore_runtime_env();\n\t\tthrow error;\n\t}\n}\n\nexport { InteractiveMode, runPrintMode, runRpcMode };\n\nexport type {\n\tAgentSessionRuntime,\n\tExtensionFactory,\n\tInteractiveModeOptions,\n\tPrintModeOptions,\n} from '@earendil-works/pi-coding-agent';\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,iCAA0D;CACzE,MAAM,WAAW,cAAc;CAC/B,MAAM,UAA8C,CAAC;CACrD,KAAK,MAAM,aAAa,oBAAoB;EAC3C,MAAM,QAAQ,SAAS,WAAW,QAAQ,UAAU;EACpD,IAAI,OAAO,UAAU,WAAW,QAAQ,UAAU,OAAO;CAC1D;CACA,OAAO;EAAE,SAAS;EAAG;CAAQ;AAC9B;AAEA,SAAgB,+BACf,QACO;CACP,MAAM,WAAW,cAAc;CAC/B,cAAc;EACb,GAAG;EACH,YAAY;GACX,GAAG,SAAS;GACZ,SAAS,OAAO;EACjB;CACD,CAAC;AACF;AAEA,SAAgB,6BACf,QACA,KACU;CACV,OAAO,OAAO,QAAQ,QAAQ;AAC/B;AAEA,SAAgB,4BACf,QACA,KACA,iCAAmD,IAAI,IAAI,GACjD;CACV,OACC,6BAA6B,QAAQ,GAAG,KACxC,CAAC,eAAe,IAAI,GAAG;AAEzB;AAEA,SAAgB,iCACf,iCAAmD,IAAI,IAAI,GAC3D,SAAkC,+BAA+B,GACvC;CAC1B,OAAO,mBAAmB,KAAK,cAAc;EAC5C,MAAM,gBAAgB,6BACrB,QACA,UAAU,GACX;EACA,MAAM,SAAS,eAAe,IAAI,UAAU,GAAG;EAC/C,OAAO;GACN,GAAG;GACH;GACA,mBAAmB,iBAAiB,CAAC;GACrC,iBAAiB;EAClB;CACD,CAAC;AACF;AAEA,SAAgB,uBACf,OACmC;CACnC,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,YAAY;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ACF;IACD;GACD;EACD,CAAC;EAED,MAAM,kBAAkB,wBACvB,OACA,SAAS,YACV;EACA,MAAM,qBAAqB,iCAC1B,iBACA,QACD;EACA,IACC,mBACA,YACA,sBACA,uBAAuB,UAEvB,SAAS,YAAY,KAAK;GACzB,MAAM;GACN,SAAS,6BAA6B,SAAS,wBAAwB,gBAAgB,SAAS,GAAG,gBAAgB,GAAG,WAAW,mBAAmB;EACrJ,CAAC;EAGF,OAAO;GACN,GAAI,MAAM,+BAA+B;IACxC;IACA;IACA;IACA,GAAI,kBAAkB,EAAE,OAAO,gBAAgB,IAAI,CAAC;IACpD,GAAI,qBACD,EAAE,eAAe,mBAAmB,IACpC,CAAC;IACJ,GAAI,gBAAgB,SAAS,EAAE,OAAO,eAAe,IAAI,CAAC;IAC1D,GAAI,gBAAgB,SACjB,EAAE,cAAc,eAAe,IAC/B,CAAC;GACL,CAAC;GACD;GACA,aAAa,SAAS;EACvB;CACD;CAEA,IAAI;EACH,OAAO,yBACN,MAAM,0BAA0B,gBAAgB;GAC/C;GACA,UAAU;GACV,gBAAgB,uBAAuB;IACtC;IACA;IACA;IACA;IACA;GACD,CAAC;EACF,CAAC,GACD,mBACD;CACD,SAAS,OAAO;EACf,oBAAoB;EACpB,MAAM;CACP;AACD"}
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../src/extensions/manager/config.ts","../src/api/builtin-extensions.ts","../src/api/env.ts","../src/api/models.ts","../src/api/session.ts","../src/extensions/manager/index.ts","../src/api.ts"],"sourcesContent":["import {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionInfo,\n\ttype BuiltinExtensionKey,\n} from '../builtin-registry.js';\nimport {\n\tget_settings_path,\n\tload_settings,\n\tsave_settings,\n} from '../../settings/index.js';\n\nexport { BUILTIN_EXTENSIONS };\nexport type { BuiltinExtensionInfo, BuiltinExtensionKey };\n\nexport interface BuiltinExtensionsConfig {\n\tversion: number;\n\tenabled: Partial<Record<BuiltinExtensionKey, boolean>>;\n}\n\nexport interface BuiltinExtensionState extends BuiltinExtensionInfo {\n\tsaved_enabled: boolean;\n\teffective_enabled: boolean;\n\tforced_disabled: boolean;\n}\n\nexport function get_builtin_extensions_config_path(): string {\n\treturn get_settings_path();\n}\n\nexport function load_builtin_extensions_config(): BuiltinExtensionsConfig {\n\tconst settings = load_settings();\n\tconst enabled: BuiltinExtensionsConfig['enabled'] = {};\n\tfor (const extension of BUILTIN_EXTENSIONS) {\n\t\tconst value = settings.extensions.enabled[extension.key];\n\t\tif (typeof value === 'boolean') enabled[extension.key] = value;\n\t}\n\treturn { version: 1, enabled };\n}\n\nexport function save_builtin_extensions_config(\n\tconfig: BuiltinExtensionsConfig,\n): void {\n\tconst settings = load_settings();\n\tsave_settings({\n\t\t...settings,\n\t\textensions: {\n\t\t\t...settings.extensions,\n\t\t\tenabled: config.enabled,\n\t\t},\n\t});\n}\n\nexport function is_builtin_extension_enabled(\n\tconfig: BuiltinExtensionsConfig,\n\tkey: BuiltinExtensionKey,\n): boolean {\n\treturn config.enabled[key] ?? true;\n}\n\nexport function is_builtin_extension_active(\n\tconfig: BuiltinExtensionsConfig,\n\tkey: BuiltinExtensionKey,\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey> = new Set(),\n): boolean {\n\treturn (\n\t\tis_builtin_extension_enabled(config, key) &&\n\t\t!force_disabled.has(key)\n\t);\n}\n\nexport function resolve_builtin_extension_states(\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey> = new Set(),\n\tconfig: BuiltinExtensionsConfig = load_builtin_extensions_config(),\n): BuiltinExtensionState[] {\n\treturn BUILTIN_EXTENSIONS.map((extension) => {\n\t\tconst saved_enabled = is_builtin_extension_enabled(\n\t\t\tconfig,\n\t\t\textension.key,\n\t\t);\n\t\tconst forced = force_disabled.has(extension.key);\n\t\treturn {\n\t\t\t...extension,\n\t\t\tsaved_enabled,\n\t\t\teffective_enabled: saved_enabled && !forced,\n\t\t\tforced_disabled: forced,\n\t\t};\n\t});\n}\n\nexport function find_builtin_extension(\n\tquery: string,\n): BuiltinExtensionInfo | undefined {\n\tconst normalized = query.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\n\treturn BUILTIN_EXTENSIONS.find((extension) =>\n\t\t[extension.key, extension.label, ...extension.aliases].some(\n\t\t\t(value) => value.toLowerCase() === normalized,\n\t\t),\n\t);\n}\n","import type {\n\tExtensionFactory,\n\tInlineExtension,\n\tLoadExtensionsResult,\n} from '@earendil-works/pi-coding-agent';\nimport { existsSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSION_REGISTRY,\n\ttype BuiltinExtensionKey,\n} from '../extensions/builtin-registry.js';\nimport {\n\tis_builtin_extension_active,\n\tload_builtin_extensions_config,\n} from '../extensions/manager/config.js';\nimport type {\n\tBuiltinExtensionOptions,\n\tCreateMyPiOptions,\n\tMyPiRuntimeMode,\n} from './options.js';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nconst require = createRequire(import.meta.url);\nexport const PACKAGE_THEME_DIR = resolve(\n\tdirname(require.resolve('@spences10/pi-themes/package.json')),\n\t'themes',\n);\n\nexport const MANAGED_INLINE_EXTENSION_NAME_PREFIX = 'my-pi-';\n\nexport function assert_unreserved_inline_extension_names(\n\textensions: readonly InlineExtension[],\n): void {\n\tfor (const extension of extensions) {\n\t\tif (\n\t\t\ttypeof extension !== 'function' &&\n\t\t\textension.name.startsWith(MANAGED_INLINE_EXTENSION_NAME_PREFIX)\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Inline extension name \"${extension.name}\" is reserved for my-pi managed extensions; choose a name that does not start with \"${MANAGED_INLINE_EXTENSION_NAME_PREFIX}\".`,\n\t\t\t);\n\t\t}\n\t}\n}\n\nexport function get_force_disabled_builtins(\n\toptions: Pick<CreateMyPiOptions, 'runtime_mode'> &\n\t\tBuiltinExtensionOptions,\n): Set<BuiltinExtensionKey> {\n\tconst force_disabled = new Set<BuiltinExtensionKey>();\n\tfor (const extension of BUILTIN_EXTENSION_REGISTRY) {\n\t\tconst enabled =\n\t\t\toptions[extension.option_name] ?? extension.default_enabled;\n\t\tif (!enabled) force_disabled.add(extension.key);\n\t\tconst disabled_in =\n\t\t\t'mode_constraints' in extension\n\t\t\t\t? extension.mode_constraints.disabled_in\n\t\t\t\t: undefined;\n\t\tif (\n\t\t\toptions.runtime_mode &&\n\t\t\t(\n\t\t\t\tdisabled_in as readonly MyPiRuntimeMode[] | undefined\n\t\t\t)?.includes(options.runtime_mode)\n\t\t) {\n\t\t\tforce_disabled.add(extension.key);\n\t\t}\n\t}\n\treturn force_disabled;\n}\n\nfunction is_agent_dir_package_installed(\n\tagent_dir: string,\n\tpackage_name: string,\n): boolean {\n\treturn existsSync(\n\t\tjoin(agent_dir, 'npm', 'node_modules', package_name),\n\t);\n}\n\nexport function get_externally_installed_builtin_extensions(\n\tagent_dir: string,\n): Set<BuiltinExtensionKey> {\n\tconst installed = new Set<BuiltinExtensionKey>();\n\tfor (const extension of BUILTIN_EXTENSION_REGISTRY) {\n\t\tconst external_package_name = (\n\t\t\textension as { external_package_name?: string }\n\t\t).external_package_name;\n\t\tif (\n\t\t\texternal_package_name &&\n\t\t\tis_agent_dir_package_installed(agent_dir, external_package_name)\n\t\t) {\n\t\t\tinstalled.add(extension.key);\n\t\t}\n\t}\n\treturn installed;\n}\n\nexport function warn_builtin_extension_unavailable(\n\tkey: BuiltinExtensionKey | 'telemetry',\n\terror: unknown,\n): void {\n\tconst reason =\n\t\terror instanceof Error ? error.message : String(error);\n\tprocess.emitWarning(\n\t\t`Built-in extension \"${key}\" is unavailable and was skipped: ${reason}`,\n\t\t{ code: 'MY_PI_BUILTIN_EXTENSION_UNAVAILABLE' },\n\t);\n}\n\nexport function create_lazy_builtin_extension_factory(\n\tkey: BuiltinExtensionKey,\n\tload_extension: BuiltinExtensionLoader,\n\tforce_disabled: ReadonlySet<BuiltinExtensionKey>,\n): ExtensionFactory {\n\treturn async (pi) => {\n\t\tconst config = load_builtin_extensions_config();\n\t\tif (!is_builtin_extension_active(config, key, force_disabled)) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tconst extension = await load_extension();\n\t\t\tawait extension(pi);\n\t\t} catch (error) {\n\t\t\twarn_builtin_extension_unavailable(key, error);\n\t\t}\n\t};\n}\n\nexport function create_lazy_telemetry_extension(options: {\n\tenabled?: boolean;\n\tdb_path?: string;\n\tcwd?: string;\n}): ExtensionFactory {\n\treturn async (pi) => {\n\t\ttry {\n\t\t\tconst { create_telemetry_extension } =\n\t\t\t\tawait import('@spences10/pi-telemetry');\n\t\t\tawait create_telemetry_extension(options)(pi);\n\t\t} catch (error) {\n\t\t\twarn_builtin_extension_unavailable('telemetry', error);\n\t\t}\n\t};\n}\n\nexport function create_extensions_override(\n\tmanaged_extension_paths: readonly string[],\n): (base: LoadExtensionsResult) => LoadExtensionsResult {\n\treturn (base) => {\n\t\t// Pi names inline extensions but still loads discovered paths first.\n\t\t// Move only the first matching managed instance to preserve precedence.\n\t\tconst remaining = [...base.extensions];\n\t\tconst ordered_managed = managed_extension_paths.flatMap(\n\t\t\t(path) => {\n\t\t\t\tconst index = remaining.findIndex(\n\t\t\t\t\t(extension) => extension.path === path,\n\t\t\t\t);\n\t\t\t\treturn index === -1 ? [] : remaining.splice(index, 1);\n\t\t\t},\n\t\t);\n\t\treturn {\n\t\t\t...base,\n\t\t\textensions: [...ordered_managed, ...remaining],\n\t\t};\n\t};\n}\n","import { getAgentDir } from '@earendil-works/pi-coding-agent';\nimport { apply_project_trust_untrusted_defaults } from '@spences10/pi-project-trust';\nimport { resolve } from 'node:path';\n\nexport const PI_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nexport const MY_PI_RUNTIME_MODE_ENV = 'MY_PI_RUNTIME_MODE';\n\ntype EnvSnapshot = Map<string, string | undefined>;\n\nexport function snapshot_env(\n\tenv: NodeJS.ProcessEnv,\n\tkeys: Iterable<string>,\n): EnvSnapshot {\n\treturn new Map(Array.from(keys, (key) => [key, env[key]]));\n}\n\nexport function restore_env(\n\tenv: NodeJS.ProcessEnv,\n\tsnapshot: EnvSnapshot,\n): void {\n\tfor (const [key, value] of snapshot) {\n\t\tif (value === undefined) delete env[key];\n\t\telse env[key] = value;\n\t}\n}\n\nexport function wrap_runtime_env_restore<\n\tT extends { dispose(): Promise<void> },\n>(runtime: T, restore: () => void): T {\n\tconst dispose = runtime.dispose.bind(runtime);\n\tlet restored = false;\n\tconst restore_once = () => {\n\t\tif (restored) return;\n\t\trestored = true;\n\t\trestore();\n\t};\n\n\truntime.dispose = (async () => {\n\t\ttry {\n\t\t\tawait dispose();\n\t\t} finally {\n\t\t\trestore_once();\n\t\t}\n\t}) as T['dispose'];\n\n\treturn runtime;\n}\n\nconst UNTRUSTED_CHILD_ENV_DEFAULTS: Record<string, string> = {\n\tMY_PI_CHILD_ENV_ALLOWLIST: '',\n\tMY_PI_MCP_ENV_ALLOWLIST: '',\n\tMY_PI_LSP_ENV_ALLOWLIST: '',\n\tMY_PI_HOOKS_ENV_ALLOWLIST: '',\n\tMY_PI_TEAM_MODE_ENV_ALLOWLIST: '',\n};\n\nexport function apply_untrusted_repo_defaults(\n\tenv: NodeJS.ProcessEnv = process.env,\n): string[] {\n\tconst applied = apply_project_trust_untrusted_defaults(env);\n\tfor (const [key, value] of Object.entries(\n\t\tUNTRUSTED_CHILD_ENV_DEFAULTS,\n\t)) {\n\t\tif (env[key] !== undefined) continue;\n\t\tenv[key] = value;\n\t\tapplied.push(key);\n\t}\n\treturn applied;\n}\n\nexport function is_resource_enabled(\n\tvalue: string | undefined,\n): boolean {\n\tconst normalized = value?.trim().toLowerCase();\n\tif (!normalized) return true;\n\tif (['0', 'false', 'no', 'skip', 'disable'].includes(normalized)) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\nexport function resolve_agent_dir(\n\tcwd: string,\n\tagent_dir?: string,\n): string {\n\treturn agent_dir ? resolve(cwd, agent_dir) : getAgentDir();\n}\n","import {\n\tclampThinkingLevel,\n\ttype Api,\n\ttype Model,\n} from '@earendil-works/pi-ai';\nimport type { MyPiThinkingLevel } from './options.js';\n\ninterface ModelsLike {\n\tgetModels(): readonly Model<Api>[];\n}\n\nexport function resolve_model_reference(\n\tmodel_reference: string | undefined,\n\tmodels_runtime: ModelsLike,\n): Model<Api> | undefined {\n\tif (!model_reference) return undefined;\n\tconst models = models_runtime.getModels();\n\tconst lower_reference = model_reference.toLowerCase();\n\tconst slash_index = model_reference.indexOf('/');\n\n\tif (slash_index !== -1) {\n\t\tconst maybe_provider = model_reference.slice(0, slash_index);\n\t\tconst model_id = model_reference.slice(slash_index + 1);\n\t\tconst provider = models.find(\n\t\t\t(model) =>\n\t\t\t\tmodel.provider.toLowerCase() === maybe_provider.toLowerCase(),\n\t\t)?.provider;\n\n\t\tif (provider) {\n\t\t\tconst provider_match = models.find(\n\t\t\t\t(model) =>\n\t\t\t\t\tmodel.provider === provider &&\n\t\t\t\t\tmodel.id.toLowerCase() === model_id.toLowerCase(),\n\t\t\t);\n\t\t\tif (provider_match) return provider_match;\n\t\t}\n\t}\n\n\treturn models.find((model) => {\n\t\tconst id = model.id.toLowerCase();\n\t\tconst full_id = `${model.provider}/${model.id}`.toLowerCase();\n\t\treturn id === lower_reference || full_id === lower_reference;\n\t});\n}\n\nexport function resolve_effective_thinking_level(\n\tmodel: Model<Api> | undefined,\n\tthinking: MyPiThinkingLevel | undefined,\n): MyPiThinkingLevel | undefined {\n\tif (!thinking || !model) return thinking;\n\treturn clampThinkingLevel(model, thinking);\n}\n","import { SessionManager } from '@earendil-works/pi-coding-agent';\nimport { existsSync, readdirSync } from 'node:fs';\nimport { basename, isAbsolute, join, resolve } from 'node:path';\n\nfunction resolve_session_file(\n\tcwd: string,\n\tsession_dir: string | undefined,\n\tsession_ref: string | undefined,\n): string | undefined {\n\tif (!session_ref) return undefined;\n\tconst explicit_path = isAbsolute(session_ref)\n\t\t? session_ref\n\t\t: resolve(cwd, session_ref);\n\tif (existsSync(explicit_path)) return explicit_path;\n\tif (session_ref.endsWith('.jsonl')) return explicit_path;\n\n\tconst dir = session_dir ? resolve(cwd, session_dir) : undefined;\n\tif (!dir || !existsSync(dir)) return undefined;\n\tconst matches = readdirSync(dir)\n\t\t.filter(\n\t\t\t(file) =>\n\t\t\t\tfile.endsWith('.jsonl') &&\n\t\t\t\t(basename(file, '.jsonl').endsWith(session_ref) ||\n\t\t\t\t\tfile.includes(session_ref)),\n\t\t)\n\t\t.sort();\n\tconst match = matches.at(-1);\n\treturn match ? join(dir, match) : undefined;\n}\n\nexport function create_session_manager(options: {\n\tcwd: string;\n\tsession_dir?: string;\n\tsession?: string;\n\tsession_id?: string;\n\tstartup_session_name?: string;\n}): SessionManager {\n\tconst resolved_session_dir = options.session_dir\n\t\t? resolve(options.cwd, options.session_dir)\n\t\t: SessionManager.create(options.cwd).getSessionDir();\n\tconst session_ref = options.session ?? options.session_id;\n\tconst session_file = resolve_session_file(\n\t\toptions.cwd,\n\t\tresolved_session_dir,\n\t\tsession_ref,\n\t);\n\tconst session_manager = session_file\n\t\t? SessionManager.open(\n\t\t\t\tsession_file,\n\t\t\t\tresolved_session_dir,\n\t\t\t\toptions.cwd,\n\t\t\t)\n\t\t: SessionManager.create(\n\t\t\t\toptions.cwd,\n\t\t\t\tresolved_session_dir,\n\t\t\t\toptions.session_id ? { id: options.session_id } : {},\n\t\t\t);\n\tif (\n\t\toptions.startup_session_name &&\n\t\tsession_manager.getSessionName() !== options.startup_session_name\n\t) {\n\t\tsession_manager.appendSessionInfo(options.startup_session_name);\n\t}\n\treturn session_manager;\n}\n","import type {\n\tExtensionAPI,\n\tExtensionCommandContext,\n} from '@earendil-works/pi-coding-agent';\nimport { type SettingItem } from '@earendil-works/pi-tui';\nimport { show_settings_modal } from '@spences10/pi-tui-modal';\nimport {\n\tBUILTIN_EXTENSIONS,\n\tfind_builtin_extension,\n\tload_builtin_extensions_config,\n\tresolve_builtin_extension_states,\n\tsave_builtin_extensions_config,\n\ttype BuiltinExtensionKey,\n\ttype BuiltinExtensionState,\n} from './config.js';\n\nconst ENABLED = '● enabled';\nconst DISABLED = '○ disabled';\n\nexport interface ExtensionsManagerOptions {\n\tforce_disabled?: Iterable<BuiltinExtensionKey>;\n}\n\nfunction to_force_disabled_set(\n\tforce_disabled?: Iterable<BuiltinExtensionKey>,\n): ReadonlySet<BuiltinExtensionKey> {\n\treturn new Set(force_disabled ?? []);\n}\n\nfunction format_effective_state(\n\tstate: BuiltinExtensionState,\n): string {\n\tif (state.effective_enabled) {\n\t\treturn 'enabled';\n\t}\n\tif (state.forced_disabled) {\n\t\treturn `disabled in this process by ${state.cli_flag}`;\n\t}\n\treturn 'disabled';\n}\n\nfunction format_extension_lines(\n\tstates: BuiltinExtensionState[],\n\toptions?: { heading?: string },\n): string {\n\tconst lines: string[] = [];\n\tif (options?.heading) {\n\t\tlines.push(options.heading, '');\n\t}\n\n\tconst enabled_now = states.filter(\n\t\t(state) => state.effective_enabled,\n\t).length;\n\tconst disabled_now = states.length - enabled_now;\n\tlines.push(\n\t\t`${states.length} built-in extensions (${enabled_now} enabled now, ${disabled_now} disabled now)`,\n\t\t'',\n\t);\n\n\tfor (const state of states) {\n\t\tlines.push(\n\t\t\t`${state.saved_enabled ? ENABLED : DISABLED} ${state.label}`,\n\t\t);\n\t\tlines.push(` key: ${state.key}`);\n\t\tlines.push(\n\t\t\t` saved config: ${state.saved_enabled ? 'enabled' : 'disabled'}`,\n\t\t);\n\t\tlines.push(\n\t\t\t` current process: ${format_effective_state(state)}`,\n\t\t);\n\t\tlines.push(` ${state.description}`);\n\t}\n\n\treturn lines.join('\\n');\n}\n\nfunction to_setting_item(state: BuiltinExtensionState): SettingItem {\n\tconst detail_lines = [\n\t\tstate.key,\n\t\tstate.description,\n\t\t`current process: ${format_effective_state(state)}`,\n\t\t`startup override: ${state.cli_flag}`,\n\t];\n\n\treturn {\n\t\tid: state.key,\n\t\tlabel: state.label,\n\t\tdescription: detail_lines.join('\\n'),\n\t\tcurrentValue: state.saved_enabled ? ENABLED : DISABLED,\n\t\tvalues: [ENABLED, DISABLED],\n\t};\n}\n\nfunction sets_equal(\n\ta: ReadonlySet<string>,\n\tb: ReadonlySet<string>,\n): boolean {\n\tif (a.size !== b.size) return false;\n\tfor (const value of a) {\n\t\tif (!b.has(value)) return false;\n\t}\n\treturn true;\n}\n\nfunction search_states(\n\tstates: BuiltinExtensionState[],\n\tquery: string,\n): BuiltinExtensionState[] {\n\tconst normalized = query.trim().toLowerCase();\n\tif (!normalized) return states;\n\n\treturn states.filter((state) =>\n\t\t[\n\t\t\tstate.key,\n\t\t\tstate.label,\n\t\t\tstate.description,\n\t\t\t...state.aliases,\n\t\t].some((value) => value.toLowerCase().includes(normalized)),\n\t);\n}\n\nfunction save_extension_enabled(\n\tkey: BuiltinExtensionKey,\n\tenabled: boolean,\n): void {\n\tconst config = load_builtin_extensions_config();\n\tconfig.enabled[key] = enabled;\n\tsave_builtin_extensions_config(config);\n}\n\nexport function create_extensions_extension(\n\toptions: ExtensionsManagerOptions = {},\n) {\n\tconst force_disabled = to_force_disabled_set(\n\t\toptions.force_disabled,\n\t);\n\n\tasync function show_manager(\n\t\tctx: ExtensionCommandContext,\n\t): Promise<boolean> {\n\t\tif (!ctx.hasUI) return false;\n\n\t\tconst states = resolve_builtin_extension_states(force_disabled);\n\t\tconst initial_enabled = new Set(\n\t\t\tstates\n\t\t\t\t.filter((state) => state.saved_enabled)\n\t\t\t\t.map((state) => state.key),\n\t\t);\n\t\tconst current_enabled = new Set(initial_enabled);\n\n\t\tconst items = states.map(to_setting_item);\n\t\tawait show_settings_modal(ctx, {\n\t\t\ttitle: 'Built-in extensions',\n\t\t\tsubtitle: () => {\n\t\t\t\tconst saved_enabled = current_enabled.size;\n\t\t\t\tconst saved_disabled = states.length - saved_enabled;\n\t\t\t\tconst enabled_now = [...current_enabled].filter(\n\t\t\t\t\t(key) => !force_disabled.has(key as BuiltinExtensionKey),\n\t\t\t\t).length;\n\t\t\t\tconst disabled_now = states.length - enabled_now;\n\t\t\t\treturn `${saved_enabled} saved enabled • ${saved_disabled} saved disabled • ${enabled_now} enabled now • ${disabled_now} disabled now`;\n\t\t\t},\n\t\t\titems,\n\t\t\tenable_search: true,\n\t\t\tfooter:\n\t\t\t\t'esc close • search filters • changes save immediately • CLI --no-* flags still win in this process',\n\t\t\ton_change: (id, new_value) => {\n\t\t\t\tconst key = id as BuiltinExtensionKey;\n\t\t\t\tconst enabled = new_value === ENABLED;\n\t\t\t\tif (enabled) {\n\t\t\t\t\tcurrent_enabled.add(key);\n\t\t\t\t} else {\n\t\t\t\t\tcurrent_enabled.delete(key);\n\t\t\t\t}\n\t\t\t\tsave_extension_enabled(key, enabled);\n\t\t\t},\n\t\t});\n\n\t\tif (!sets_equal(initial_enabled, current_enabled)) {\n\t\t\tctx.ui.notify(\n\t\t\t\tforce_disabled.size > 0\n\t\t\t\t\t? 'Reloading to apply updated built-in extensions. CLI --no-* flags still force-disable some extensions in this process.'\n\t\t\t\t\t: 'Reloading to apply updated built-in extensions...',\n\t\t\t\t'info',\n\t\t\t);\n\t\t\tawait ctx.reload();\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn async function extensions(pi: ExtensionAPI) {\n\t\tconst subs = ['list', 'enable', 'disable', 'toggle', 'search'];\n\n\t\tpi.registerCommand('extensions', {\n\t\t\tdescription: 'Manage built-in my-pi extensions',\n\t\t\tgetArgumentCompletions: (prefix) => {\n\t\t\t\tconst parts = prefix.trim().split(/\\s+/);\n\t\t\t\tif (parts.length <= 1) {\n\t\t\t\t\treturn subs\n\t\t\t\t\t\t.filter((sub) => sub.startsWith(parts[0] || ''))\n\t\t\t\t\t\t.map((sub) => ({ value: sub, label: sub }));\n\t\t\t\t}\n\n\t\t\t\tif (['enable', 'disable', 'toggle'].includes(parts[0])) {\n\t\t\t\t\tconst q = parts.slice(1).join(' ').toLowerCase();\n\t\t\t\t\treturn resolve_builtin_extension_states(force_disabled)\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(state) =>\n\t\t\t\t\t\t\t\tstate.key.toLowerCase().includes(q) ||\n\t\t\t\t\t\t\t\tstate.label.toLowerCase().includes(q),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.slice(0, 20)\n\t\t\t\t\t\t.map((state) => ({\n\t\t\t\t\t\t\tvalue: `${parts[0]} ${state.key}`,\n\t\t\t\t\t\t\tlabel: `${state.key} ${state.saved_enabled ? ENABLED : DISABLED}`,\n\t\t\t\t\t\t}));\n\t\t\t\t}\n\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\thandler: async (args, ctx) => {\n\t\t\t\tconst trimmed = args.trim();\n\n\t\t\t\tif (!trimmed) {\n\t\t\t\t\tif (await show_manager(ctx)) return;\n\t\t\t\t}\n\n\t\t\t\tconst [sub, ...rest] = (trimmed || 'list').split(/\\s+/);\n\t\t\t\tconst arg = rest.join(' ');\n\t\t\t\tconst states =\n\t\t\t\t\tresolve_builtin_extension_states(force_disabled);\n\n\t\t\t\tswitch (sub) {\n\t\t\t\t\tcase 'list': {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tformat_extension_lines(states, {\n\t\t\t\t\t\t\t\theading: 'Built-in extensions',\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'enable':\n\t\t\t\t\tcase 'disable':\n\t\t\t\t\tcase 'toggle': {\n\t\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\t\tif (await show_manager(ctx)) return;\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Usage: /extensions ${sub} <key>`,\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst extension = find_builtin_extension(arg);\n\t\t\t\t\t\tif (!extension) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`Unknown extension: ${arg}. Use: ${BUILTIN_EXTENSIONS.map((item) => item.key).join(', ')}`,\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst current_state = states.find(\n\t\t\t\t\t\t\t(state) => state.key === extension.key,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst next_enabled =\n\t\t\t\t\t\t\tsub === 'enable'\n\t\t\t\t\t\t\t\t? true\n\t\t\t\t\t\t\t\t: sub === 'disable'\n\t\t\t\t\t\t\t\t\t? false\n\t\t\t\t\t\t\t\t\t: !current_state?.saved_enabled;\n\t\t\t\t\t\tsave_extension_enabled(extension.key, next_enabled);\n\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tnext_enabled && force_disabled.has(extension.key)\n\t\t\t\t\t\t\t\t? `Enabled ${extension.key} in saved config. Still disabled in this process by ${extension.cli_flag}. /reload or restart without that flag to apply.`\n\t\t\t\t\t\t\t\t: `${extension.key} ${next_enabled ? 'enabled' : 'disabled'}. /reload to apply.`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase 'search': {\n\t\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t'Usage: /extensions search <query>',\n\t\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst results = search_states(states, arg);\n\t\t\t\t\t\tif (results.length === 0) {\n\t\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t\t`No built-in extensions matching \"${arg}\"`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\tformat_extension_lines(results, {\n\t\t\t\t\t\t\t\theading: `Built-in extensions matching \"${arg}\"`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Unknown: ${sub}. Use: ${subs.join(', ')}`,\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t};\n}\n\nexport default create_extensions_extension();\n","// Composable programmatic API for my-pi\n\nimport {\n\tInteractiveMode,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\trunPrintMode,\n\trunRpcMode,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype CreateAgentSessionServicesOptions,\n\ttype InlineExtension,\n\ttype SessionManager,\n} from '@earendil-works/pi-coding-agent';\nimport { resolve } from 'node:path';\nimport {\n\tMANAGED_INLINE_EXTENSION_NAME_PREFIX,\n\tPACKAGE_THEME_DIR,\n\tassert_unreserved_inline_extension_names,\n\tcreate_extensions_override,\n\tcreate_lazy_builtin_extension_factory,\n\tcreate_lazy_telemetry_extension,\n\tget_externally_installed_builtin_extensions,\n\tget_force_disabled_builtins,\n\twarn_builtin_extension_unavailable,\n} from './api/builtin-extensions.js';\nimport {\n\tMY_PI_RUNTIME_MODE_ENV,\n\tPI_AGENT_DIR_ENV,\n\tapply_untrusted_repo_defaults,\n\tis_resource_enabled,\n\tresolve_agent_dir,\n\trestore_env,\n\tsnapshot_env,\n\twrap_runtime_env_restore,\n} from './api/env.js';\nimport {\n\tresolve_effective_thinking_level,\n\tresolve_model_reference,\n} from './api/models.js';\nimport type { CreateMyPiOptions } from './api/options.js';\nimport { create_session_manager } from './api/session.js';\nimport { BUILTIN_EXTENSION_REGISTRY } from './extensions/builtin-registry.js';\nimport {\n\tis_builtin_extension_active,\n\tload_builtin_extensions_config,\n} from './extensions/manager/config.js';\nimport { create_extensions_extension } from './extensions/manager/index.js';\n\nexport type {\n\tCreateMyPiOptions,\n\tMyPiRuntimeMode,\n\tMyPiThinkingLevel,\n} from './api/options.js';\nexport {\n\tapply_untrusted_repo_defaults,\n\tcreate_lazy_builtin_extension_factory,\n\tget_externally_installed_builtin_extensions,\n\tget_force_disabled_builtins,\n\tresolve_effective_thinking_level,\n\tresolve_model_reference,\n};\n\nexport async function create_my_pi(options: CreateMyPiOptions = {}) {\n\tconst {\n\t\tcwd = process.cwd(),\n\t\tagent_dir,\n\t\textensions = [],\n\t\textensionFactories: user_factories = [],\n\t\truntime_mode = 'interactive',\n\t\ttelemetry,\n\t\ttelemetry_db_path,\n\t\tmodel,\n\t\tthinking,\n\t\tselected_tools,\n\t\texcluded_tools,\n\t\tselected_skills,\n\t\tsession,\n\t\tsession_id,\n\t\tstartup_session_name,\n\t\tsession_dir,\n\t\tsystem_prompt,\n\t\tappend_system_prompt,\n\t\tuntrusted_repo = false,\n\t} = options;\n\n\tassert_unreserved_inline_extension_names(user_factories);\n\n\tconst env_keys_to_restore = new Set<string>([\n\t\tMY_PI_RUNTIME_MODE_ENV,\n\t]);\n\tif (agent_dir) env_keys_to_restore.add(PI_AGENT_DIR_ENV);\n\tconst env_snapshot = snapshot_env(process.env, env_keys_to_restore);\n\tlet restore_runtime_env = () =>\n\t\trestore_env(process.env, env_snapshot);\n\n\tif (untrusted_repo) {\n\t\tconst applied = apply_untrusted_repo_defaults();\n\t\tif (applied.length) {\n\t\t\tconst restore_previous = restore_runtime_env;\n\t\t\trestore_runtime_env = () => {\n\t\t\t\tfor (const key of applied) delete process.env[key];\n\t\t\t\trestore_previous();\n\t\t\t};\n\t\t}\n\t}\n\n\tconst effective_agent_dir = resolve_agent_dir(cwd, agent_dir);\n\tif (agent_dir) {\n\t\tprocess.env[PI_AGENT_DIR_ENV] = effective_agent_dir;\n\t}\n\tprocess.env[MY_PI_RUNTIME_MODE_ENV] = runtime_mode;\n\n\tconst resolved_extensions = extensions.map((p) => resolve(cwd, p));\n\tconst force_disabled = get_force_disabled_builtins({\n\t\t...options,\n\t\truntime_mode,\n\t});\n\tfor (const key of get_externally_installed_builtin_extensions(\n\t\teffective_agent_dir,\n\t)) {\n\t\tforce_disabled.add(key);\n\t}\n\tconst builtins_config = load_builtin_extensions_config();\n\tconst skills_builtin_enabled = is_builtin_extension_active(\n\t\tbuiltins_config,\n\t\t'skills',\n\t\tforce_disabled,\n\t);\n\tconst skills_package = skills_builtin_enabled\n\t\t? await import('@spences10/pi-skills').catch((error) => {\n\t\t\t\twarn_builtin_extension_unavailable('skills', error);\n\t\t\t\treturn undefined;\n\t\t\t})\n\t\t: undefined;\n\n\tconst managed_inline_extensions = [\n\t\t{\n\t\t\tname: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}telemetry`,\n\t\t\tfactory: create_lazy_telemetry_extension({\n\t\t\t\tenabled: telemetry,\n\t\t\t\tdb_path: telemetry_db_path,\n\t\t\t\tcwd,\n\t\t\t}),\n\t\t},\n\t\t{\n\t\t\tname: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}extensions-manager`,\n\t\t\tfactory: create_extensions_extension({ force_disabled }),\n\t\t},\n\t\t...BUILTIN_EXTENSION_REGISTRY.map((extension) => ({\n\t\t\tname: `${MANAGED_INLINE_EXTENSION_NAME_PREFIX}${extension.key}`,\n\t\t\tfactory: create_lazy_builtin_extension_factory(\n\t\t\t\textension.key,\n\t\t\t\textension.load,\n\t\t\t\tforce_disabled,\n\t\t\t),\n\t\t})),\n\t] satisfies InlineExtension[];\n\tconst managed_extension_paths = managed_inline_extensions.map(\n\t\t(extension) => `<inline:${extension.name}>`,\n\t);\n\n\tconst create_runtime = async ({\n\t\tcwd: runtime_cwd,\n\t\tsessionManager,\n\t\tsessionStartEvent,\n\t}: {\n\t\tcwd: string;\n\t\tsessionManager: SessionManager;\n\t\tsessionStartEvent?: CreateAgentSessionFromServicesOptions['sessionStartEvent'];\n\t}) => {\n\t\t// Keep skill filtering reloadable so profile changes made by\n\t\t// /skills are reflected without restarting the process.\n\t\tconst runtime_skills_manager =\n\t\t\tskills_package?.create_skills_manager({\n\t\t\t\tcwd: runtime_cwd,\n\t\t\t\tproject_skills_enabled: is_resource_enabled(\n\t\t\t\t\tprocess.env.MY_PI_PROJECT_SKILLS,\n\t\t\t\t),\n\t\t\t});\n\t\tconst additional_skill_paths =\n\t\t\truntime_skills_manager?.get_enabled_skill_paths() ?? [];\n\n\t\tconst services = await createAgentSessionServices({\n\t\t\tcwd: runtime_cwd,\n\t\t\tagentDir: effective_agent_dir,\n\t\t\tresourceLoaderOptions: {\n\t\t\t\t...(additional_skill_paths.length\n\t\t\t\t\t? { additionalSkillPaths: additional_skill_paths }\n\t\t\t\t\t: {}),\n\t\t\t\t...(system_prompt !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tsystemPromptOverride: () => system_prompt,\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\t...(append_system_prompt !== undefined\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tappendSystemPromptOverride: (base: string[]) => [\n\t\t\t\t\t\t\t\t...base,\n\t\t\t\t\t\t\t\tappend_system_prompt,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t\tadditionalExtensionPaths: [...resolved_extensions],\n\t\t\t\t...(runtime_mode === 'interactive'\n\t\t\t\t\t? { additionalThemePaths: [PACKAGE_THEME_DIR] }\n\t\t\t\t\t: {}),\n\t\t\t\textensionFactories: [\n\t\t\t\t\t...managed_inline_extensions,\n\t\t\t\t\t...user_factories,\n\t\t\t\t],\n\t\t\t\textensionsOverride: create_extensions_override(\n\t\t\t\t\tmanaged_extension_paths,\n\t\t\t\t),\n\t\t\t\tskillsOverride: (\n\t\t\t\t\tbase: Parameters<\n\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\tNonNullable<\n\t\t\t\t\t\t\t\tCreateAgentSessionServicesOptions['resourceLoaderOptions']\n\t\t\t\t\t\t\t>['skillsOverride']\n\t\t\t\t\t\t>\n\t\t\t\t\t>[0],\n\t\t\t\t) => {\n\t\t\t\t\tif (!skills_builtin_enabled) return { ...base, skills: [] };\n\t\t\t\t\tif (!runtime_skills_manager) return base;\n\t\t\t\t\truntime_skills_manager.refresh();\n\n\t\t\t\t\tconst selected_skill_names = selected_skills?.length\n\t\t\t\t\t\t? new Set(selected_skills)\n\t\t\t\t\t\t: undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...base,\n\t\t\t\t\t\tskills: base.skills.filter((skill) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tselected_skill_names &&\n\t\t\t\t\t\t\t\t!selected_skill_names.has(skill.name)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn runtime_skills_manager.is_enabled_by_skill(\n\t\t\t\t\t\t\t\tskill.name,\n\t\t\t\t\t\t\t\tskill.filePath,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t} satisfies CreateAgentSessionServicesOptions['resourceLoaderOptions'],\n\t\t});\n\n\t\tconst requested_model = resolve_model_reference(\n\t\t\tmodel,\n\t\t\tservices.modelRuntime,\n\t\t);\n\t\tconst effective_thinking = resolve_effective_thinking_level(\n\t\t\trequested_model,\n\t\t\tthinking,\n\t\t);\n\t\tif (\n\t\t\trequested_model &&\n\t\t\tthinking &&\n\t\t\teffective_thinking &&\n\t\t\teffective_thinking !== thinking\n\t\t) {\n\t\t\tservices.diagnostics.push({\n\t\t\t\ttype: 'warning',\n\t\t\t\tmessage: `Requested thinking level \"${thinking}\" is not supported by ${requested_model.provider}/${requested_model.id}; using \"${effective_thinking}\".`,\n\t\t\t});\n\t\t}\n\n\t\treturn {\n\t\t\t...(await createAgentSessionFromServices({\n\t\t\t\tservices,\n\t\t\t\tsessionManager,\n\t\t\t\tsessionStartEvent,\n\t\t\t\t...(requested_model ? { model: requested_model } : {}),\n\t\t\t\t...(effective_thinking\n\t\t\t\t\t? { thinkingLevel: effective_thinking }\n\t\t\t\t\t: {}),\n\t\t\t\t...(selected_tools?.length ? { tools: selected_tools } : {}),\n\t\t\t\t...(excluded_tools?.length\n\t\t\t\t\t? { excludeTools: excluded_tools }\n\t\t\t\t\t: {}),\n\t\t\t})),\n\t\t\tservices,\n\t\t\tdiagnostics: services.diagnostics,\n\t\t};\n\t};\n\n\ttry {\n\t\treturn wrap_runtime_env_restore(\n\t\t\tawait createAgentSessionRuntime(create_runtime, {\n\t\t\t\tcwd,\n\t\t\t\tagentDir: effective_agent_dir,\n\t\t\t\tsessionManager: create_session_manager({\n\t\t\t\t\tcwd,\n\t\t\t\t\tsession_dir,\n\t\t\t\t\tsession,\n\t\t\t\t\tsession_id,\n\t\t\t\t\tstartup_session_name,\n\t\t\t\t}),\n\t\t\t}),\n\t\t\trestore_runtime_env,\n\t\t);\n\t} catch (error) {\n\t\trestore_runtime_env();\n\t\tthrow error;\n\t}\n}\n\nexport { InteractiveMode, runPrintMode, runRpcMode };\n\nexport type {\n\tAgentSessionRuntime,\n\tExtensionFactory,\n\tInlineExtension,\n\tInteractiveModeOptions,\n\tPrintModeOptions,\n} from '@earendil-works/pi-coding-agent';\n"],"mappings":";;;;;;;;;;AA6BA,SAAgB,iCAA0D;CACzE,MAAM,WAAW,cAAc;CAC/B,MAAM,UAA8C,CAAC;CACrD,KAAK,MAAM,aAAa,oBAAoB;EAC3C,MAAM,QAAQ,SAAS,WAAW,QAAQ,UAAU;EACpD,IAAI,OAAO,UAAU,WAAW,QAAQ,UAAU,OAAO;CAC1D;CACA,OAAO;EAAE,SAAS;EAAG;CAAQ;AAC9B;AAEA,SAAgB,+BACf,QACO;CACP,MAAM,WAAW,cAAc;CAC/B,cAAc;EACb,GAAG;EACH,YAAY;GACX,GAAG,SAAS;GACZ,SAAS,OAAO;EACjB;CACD,CAAC;AACF;AAEA,SAAgB,6BAC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,eAAe,IAAI,CAAC;IAC1D,GAAI,gBAAgB,SACjB,EAAE,cAAc,eAAe,IAC/B,CAAC;GACL,CAAC;GACD;GACA,aAAa,SAAS;EACvB;CACD;CAEA,IAAI;EACH,OAAO,yBACN,MAAM,0BAA0B,gBAAgB;GAC/C;GACA,UAAU;GACV,gBAAgB,uBAAuB;IACtC;IACA;IACA;IACA;IACA;GACD,CAAC;EACF,CAAC,GACD,mBACD;CACD,SAAS,OAAO;EACf,oBAAoB;EACpB,MAAM;CACP;AACD"}
|
|
@@ -403,7 +403,7 @@ const BUILTIN_EXTENSION_REGISTRY = [
|
|
|
403
403
|
cli_flag: "--no-hooks",
|
|
404
404
|
cli_description: "Disable Claude-style hook execution",
|
|
405
405
|
aliases: ["hooks-resolution", "hooks"],
|
|
406
|
-
load: async () => (await import("./hooks-resolution-
|
|
406
|
+
load: async () => (await import("./hooks-resolution-Ci98WDjn.js")).default
|
|
407
407
|
},
|
|
408
408
|
{
|
|
409
409
|
key: "svelte-guardrails",
|
|
@@ -473,4 +473,4 @@ const BUILTIN_EXTENSIONS = BUILTIN_EXTENSION_REGISTRY.map(({ load: _load, ...ext
|
|
|
473
473
|
//#endregion
|
|
474
474
|
export { BUILTIN_EXTENSION_REGISTRY as n, BUILTIN_EXTENSIONS as t };
|
|
475
475
|
|
|
476
|
-
//# sourceMappingURL=builtin-registry-
|
|
476
|
+
//# sourceMappingURL=builtin-registry-DC8RlCfd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-registry-aGnFiwEg.js","names":[],"sources":["../src/extensions/builtin-registry.ts"],"sourcesContent":["import type { ExtensionFactory } from '@earendil-works/pi-coding-agent';\n\nexport type BuiltinExtensionRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nexport interface BuiltinExtensionManifestEntry {\n\tkey: string;\n\tlabel: string;\n\tdocs_label: string;\n\tdescription: string;\n\tdefault_enabled: boolean;\n\toption_name: string;\n\tcli_arg: string;\n\tcli_flag: `--${string}`;\n\tcli_description: string;\n\taliases: readonly string[];\n\tmode_constraints?: {\n\t\tdisabled_in: readonly BuiltinExtensionRuntimeMode[];\n\t\treason: string;\n\t};\n\texternal_package_name?: string;\n\tload: BuiltinExtensionLoader;\n}\n\nexport const BUILTIN_EXTENSION_REGISTRY = [\n\t{\n\t\tkey: 'context-sidecar',\n\t\tlabel: 'Context sidecar',\n\t\tdocs_label: 'SQLite context sidecar',\n\t\tdescription: 'Local SQLite FTS sidecar for oversized tool output',\n\t\tdefault_enabled: true,\n\t\toption_name: 'context_sidecar',\n\t\tcli_arg: 'no-context-sidecar',\n\t\tcli_flag: '--no-context-sidecar',\n\t\tcli_description:\n\t\t\t'Disable SQLite context sidecar for large tool output',\n\t\taliases: ['context-sidecar', 'context', 'sidecar'],\n\t\texternal_package_name: '@spences10/pi-context',\n\t\tload: async () => (await import('@spences10/pi-context')).default,\n\t},\n\t{\n\t\tkey: 'mcp',\n\t\tlabel: 'MCP',\n\t\tdocs_label: 'MCP',\n\t\tdescription: 'MCP server integration and /mcp command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'mcp',\n\t\tcli_arg: 'no-mcp',\n\t\tcli_flag: '--no-mcp',\n\t\tcli_description: 'Disable built-in MCP extension',\n\t\taliases: ['mcp'],\n\t\texternal_package_name: '@spences10/pi-mcp',\n\t\tload: async () => (await import('@spences10/pi-mcp')).default,\n\t},\n\t{\n\t\tkey: 'openrouter-fusion-config',\n\t\tlabel: 'OpenRouter Fusion config',\n\t\tdocs_label: 'OpenRouter Fusion config guard',\n\t\tdescription:\n\t\t\t'Keeps OpenRouter Fusion off Anthropic by injecting a non-Anthropic panel and judge',\n\t\tdefault_enabled: true,\n\t\toption_name: 'openrouter_fusion_config',\n\t\tcli_arg: 'no-openrouter-fusion-config',\n\t\tcli_flag: '--no-openrouter-fusion-config',\n\t\tcli_description: 'Disable OpenRouter Fusion non-Anthropic config',\n\t\taliases: ['openrouter-fusion-config', 'fusion-budget'],\n\t\tload: async () =>\n\t\t\t(await import('./openrouter-fusion-config/index.js')).default,\n\t},\n\t{\n\t\tkey: 'umans-provider',\n\t\tlabel: 'Umans provider',\n\t\tdocs_label: 'Umans provider',\n\t\tdescription:\n\t\t\t'Umans.ai Anthropic Messages provider with API key login support',\n\t\tdefault_enabled: true,\n\t\toption_name: 'umans_provider',\n\t\tcli_arg: 'no-umans-provider',\n\t\tcli_flag: '--no-umans-provider',\n\t\tcli_description: 'Disable built-in Umans provider',\n\t\taliases: ['umans-provider', 'umans'],\n\t\tload: async () =>\n\t\t\t(await import('./umans-provider/index.js')).default,\n\t},\n\t{\n\t\tkey: 'footer',\n\t\tlabel: 'Footer',\n\t\tdocs_label: 'Footer',\n\t\tdescription: 'Configurable interactive footer/statusline',\n\t\tdefault_enabled: true,\n\t\toption_name: 'footer',\n\t\tcli_arg: 'no-footer',\n\t\tcli_flag: '--no-footer',\n\t\tcli_description: 'Disable custom footer/statusline',\n\t\taliases: ['footer', 'statusline', 'status-line'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Footer only renders in the interactive TUI',\n\t\t},\n\t\tload: async () => (await import('./footer/index.js')).default,\n\t},\n\t{\n\t\tkey: 'codex-usage',\n\t\tlabel: 'Codex usage',\n\t\tdocs_label: 'Codex usage status',\n\t\tdescription: 'OpenAI Codex usage status for the footer',\n\t\tdefault_enabled: true,\n\t\toption_name: 'codex_usage',\n\t\tcli_arg: 'no-codex-usage',\n\t\tcli_flag: '--no-codex-usage',\n\t\tcli_description: 'Disable Codex usage footer status',\n\t\taliases: ['codex-usage', 'codex-status'],\n\t\texternal_package_name: '@spences10/pi-codex-usage',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-codex-usage')).default,\n\t},\n\t{\n\t\tkey: 'harness',\n\t\tlabel: 'Harness',\n\t\tdocs_label: 'Task harness runtime',\n\t\tdescription:\n\t\t\t'Ephemeral /tmp task harness runtime with tools, enforcement, and bundled skills',\n\t\tdefault_enabled: true,\n\t\toption_name: 'harness',\n\t\tcli_arg: 'no-harness',\n\t\tcli_flag: '--no-harness',\n\t\tcli_description: 'Disable task harness runtime',\n\t\taliases: ['harness', 'task-harness'],\n\t\texternal_package_name: '@spences10/pi-harness',\n\t\tload: async () => (await import('@spences10/pi-harness')).default,\n\t},\n\t{\n\t\tkey: 'factory',\n\t\tlabel: 'Software factory',\n\t\tdocs_label: 'Software-factory control plane',\n\t\tdescription:\n\t\t\t'Versioned workflow dispatch, execution feedback, review, approval, recovery, and metrics',\n\t\tdefault_enabled: true,\n\t\toption_name: 'factory',\n\t\tcli_arg: 'no-factory',\n\t\tcli_flag: '--no-factory',\n\t\tcli_description: 'Disable software-factory control plane',\n\t\taliases: ['factory', 'software-factory', 'control-plane'],\n\t\texternal_package_name: '@spences10/pi-factory',\n\t\tload: async () => (await import('@spences10/pi-factory')).default,\n\t},\n\t{\n\t\tkey: 'skills',\n\t\tlabel: 'Skills',\n\t\tdocs_label: 'Skills',\n\t\tdescription: 'Managed pi-native skills and /skills command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skills',\n\t\tcli_arg: 'no-skills',\n\t\tcli_flag: '--no-skills',\n\t\tcli_description: 'Disable built-in skills extension',\n\t\taliases: ['skills', 'skill'],\n\t\texternal_package_name: '@spences10/pi-skills',\n\t\tload: async () => (await import('@spences10/pi-skills')).default,\n\t},\n\t{\n\t\tkey: 'skill-importer',\n\t\tlabel: 'Skill importer',\n\t\tdocs_label: 'Skill importer',\n\t\tdescription:\n\t\t\t'Import external Claude/plugin skills into Pi-native storage',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skill_importer',\n\t\tcli_arg: 'no-skill-importer',\n\t\tcli_flag: '--no-skill-importer',\n\t\tcli_description: 'Disable external skill importer extension',\n\t\taliases: ['skill-importer', 'import-skills', 'skill-import'],\n\t\texternal_package_name: '@spences10/pi-skill-importer',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-skill-importer')).default,\n\t},\n\t{\n\t\tkey: 'filter-output',\n\t\tlabel: 'Secret redaction',\n\t\tdocs_label: 'Secret redaction',\n\t\tdescription:\n\t\t\t'Redacts secrets from tool output before the model sees them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'filter_output',\n\t\tcli_arg: 'no-filter',\n\t\tcli_flag: '--no-filter',\n\t\tcli_description: 'Disable secret redaction in tool output',\n\t\taliases: [\n\t\t\t'filter-output',\n\t\t\t'filter_output',\n\t\t\t'filter',\n\t\t\t'redaction',\n\t\t\t'secret-redaction',\n\t\t\t'output-redaction',\n\t\t],\n\t\texternal_package_name: '@spences10/pi-redact',\n\t\tload: async () => (await import('@spences10/pi-redact')).default,\n\t},\n\t{\n\t\tkey: 'recall',\n\t\tlabel: 'Recall',\n\t\tdocs_label: 'Recall',\n\t\tdescription: 'pirecall reminder and background session sync',\n\t\tdefault_enabled: true,\n\t\toption_name: 'recall',\n\t\tcli_arg: 'no-recall',\n\t\tcli_flag: '--no-recall',\n\t\tcli_description: 'Disable recall extension',\n\t\taliases: ['recall', 'pirecall'],\n\t\texternal_package_name: '@spences10/pi-recall',\n\t\tload: async () => (await import('@spences10/pi-recall')).default,\n\t},\n\t{\n\t\tkey: 'nopeek',\n\t\tlabel: 'Nopeek',\n\t\tdocs_label: 'Nopeek',\n\t\tdescription:\n\t\t\t'nopeek reminder for secret-safe environment loading',\n\t\tdefault_enabled: true,\n\t\toption_name: 'nopeek',\n\t\tcli_arg: 'no-nopeek',\n\t\tcli_flag: '--no-nopeek',\n\t\tcli_description: 'Disable nopeek reminder extension',\n\t\taliases: ['nopeek', 'secrets', 'secret-loading'],\n\t\texternal_package_name: '@spences10/pi-nopeek',\n\t\tload: async () => (await import('@spences10/pi-nopeek')).default,\n\t},\n\t{\n\t\tkey: 'observability',\n\t\tlabel: 'Observability',\n\t\tdocs_label: 'Live observability',\n\t\tdescription:\n\t\t\t'Optional live event stream and local browser dashboard',\n\t\tdefault_enabled: true,\n\t\toption_name: 'observability',\n\t\tcli_arg: 'no-observability',\n\t\tcli_flag: '--no-observability',\n\t\tcli_description: 'Disable live observability extension',\n\t\taliases: ['observability', 'obs', 'live-events'],\n\t\texternal_package_name: '@spences10/pi-observability',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-observability')).default,\n\t},\n\t{\n\t\tkey: 'omnisearch',\n\t\tlabel: 'Omnisearch',\n\t\tdocs_label: 'Omnisearch',\n\t\tdescription: 'mcp-omnisearch reminder for verified web research',\n\t\tdefault_enabled: true,\n\t\toption_name: 'omnisearch',\n\t\tcli_arg: 'no-omnisearch',\n\t\tcli_flag: '--no-omnisearch',\n\t\tcli_description: 'Disable mcp-omnisearch reminder extension',\n\t\taliases: ['omnisearch', 'search', 'web-search', 'research'],\n\t\texternal_package_name: '@spences10/pi-omnisearch',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-omnisearch')).default,\n\t},\n\t{\n\t\tkey: 'sqlite-tools',\n\t\tlabel: 'SQLite tools',\n\t\tdocs_label: 'SQLite tools',\n\t\tdescription:\n\t\t\t'mcp-sqlite-tools reminder for safer SQLite database work',\n\t\tdefault_enabled: true,\n\t\toption_name: 'sqlite_tools',\n\t\tcli_arg: 'no-sqlite-tools',\n\t\tcli_flag: '--no-sqlite-tools',\n\t\tcli_description: 'Disable mcp-sqlite-tools reminder extension',\n\t\taliases: ['sqlite-tools', 'sqlite', 'mcp-sqlite-tools'],\n\t\texternal_package_name: '@spences10/pi-sqlite-tools',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-sqlite-tools')).default,\n\t},\n\t{\n\t\tkey: 'startup-screen',\n\t\tlabel: 'Startup screen',\n\t\tdocs_label: 'Startup screen',\n\t\tdescription:\n\t\t\t'Pixel-art gradient startup header for interactive sessions',\n\t\tdefault_enabled: true,\n\t\toption_name: 'startup_screen',\n\t\tcli_arg: 'no-startup-screen',\n\t\tcli_flag: '--no-startup-screen',\n\t\tcli_description: 'Disable the custom startup screen',\n\t\taliases: ['startup-screen', 'startup', 'header', 'splash'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Startup screen only renders in the interactive TUI',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./startup-screen/index.js')).default,\n\t},\n\t{\n\t\tkey: 'prompt-presets',\n\t\tlabel: 'Prompt presets',\n\t\tdocs_label: 'Prompt presets',\n\t\tdescription:\n\t\t\t'Runtime prompt preset selection and /prompt-preset command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'prompt_presets',\n\t\tcli_arg: 'no-prompt-presets',\n\t\tcli_flag: '--no-prompt-presets',\n\t\tcli_description: 'Disable prompt presets extension',\n\t\taliases: ['prompt-preset', 'preset', 'presets'],\n\t\tload: async () =>\n\t\t\t(await import('./prompt-presets/index.js')).default,\n\t},\n\t{\n\t\tkey: 'git-ui',\n\t\tlabel: 'Git UI',\n\t\tdocs_label: 'Git staging UI',\n\t\tdescription: 'Interactive source control staging panel',\n\t\tdefault_enabled: true,\n\t\toption_name: 'git_ui',\n\t\tcli_arg: 'no-git-ui',\n\t\tcli_flag: '--no-git-ui',\n\t\tcli_description: 'Disable built-in Git staging UI',\n\t\taliases: ['git-ui', 'git', 'source-control', 'scm'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Git UI is only useful in interactive mode',\n\t\t},\n\t\texternal_package_name: '@spences10/pi-git-ui',\n\t\tload: async () => (await import('@spences10/pi-git-ui')).default,\n\t},\n\t{\n\t\tkey: 'lsp',\n\t\tlabel: 'LSP',\n\t\tdocs_label: 'LSP',\n\t\tdescription:\n\t\t\t'Language Server Protocol tools (diagnostics, hover, definition, references)',\n\t\tdefault_enabled: true,\n\t\toption_name: 'lsp',\n\t\tcli_arg: 'no-lsp',\n\t\tcli_flag: '--no-lsp',\n\t\tcli_description: 'Disable LSP extension',\n\t\taliases: ['lsp', 'language-server'],\n\t\texternal_package_name: '@spences10/pi-lsp',\n\t\tload: async () => (await import('@spences10/pi-lsp')).default,\n\t},\n\t{\n\t\tkey: 'session-name',\n\t\tlabel: 'Session name',\n\t\tdocs_label: 'Session auto-naming',\n\t\tdescription:\n\t\t\t'AI-powered session auto-naming and /session-name command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'session_name',\n\t\tcli_arg: 'no-session-name',\n\t\tcli_flag: '--no-session-name',\n\t\tcli_description: 'Disable session name extension',\n\t\taliases: ['session-name', 'session', 'auto-name'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason:\n\t\t\t\t'UI-only session naming is only useful in interactive mode',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./session-name/index.js')).default,\n\t},\n\t{\n\t\tkey: 'confirm-destructive',\n\t\tlabel: 'Confirm destructive',\n\t\tdocs_label: 'Destructive action confirmation',\n\t\tdescription:\n\t\t\t'Prompt before destructive tool calls like file deletes, overwrites, and hard resets',\n\t\tdefault_enabled: true,\n\t\toption_name: 'confirm_destructive',\n\t\tcli_arg: 'no-confirm-destructive',\n\t\tcli_flag: '--no-confirm-destructive',\n\t\tcli_description: 'Disable destructive action confirmations',\n\t\taliases: ['confirm-destructive', 'confirm'],\n\t\texternal_package_name: '@spences10/pi-confirm-destructive',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-confirm-destructive')).default,\n\t},\n\t{\n\t\tkey: 'hooks-resolution',\n\t\tlabel: 'Hooks resolution',\n\t\tdocs_label: 'Hooks resolution',\n\t\tdescription:\n\t\t\t'Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs',\n\t\tdefault_enabled: true,\n\t\toption_name: 'hooks_resolution',\n\t\tcli_arg: 'no-hooks',\n\t\tcli_flag: '--no-hooks',\n\t\tcli_description: 'Disable Claude-style hook execution',\n\t\taliases: ['hooks-resolution', 'hooks'],\n\t\tload: async () =>\n\t\t\t(await import('./hooks-resolution/index.js')).default,\n\t},\n\t{\n\t\tkey: 'svelte-guardrails',\n\t\tlabel: 'Svelte guardrails',\n\t\tdocs_label: 'Svelte guardrails',\n\t\tdescription:\n\t\t\t'Blocks discouraged Svelte patterns like $effect before agents write them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'svelte_guardrails',\n\t\tcli_arg: 'no-svelte-guardrails',\n\t\tcli_flag: '--no-svelte-guardrails',\n\t\tcli_description: 'Disable Svelte guardrails',\n\t\taliases: ['svelte-guardrails', 'svelte'],\n\t\texternal_package_name: '@spences10/pi-svelte-guardrails',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-svelte-guardrails')).default,\n\t},\n\t{\n\t\tkey: 'coding-preferences',\n\t\tlabel: 'Coding preferences',\n\t\tdocs_label: 'Coding preferences',\n\t\tdescription:\n\t\t\t'Blocks configured coding workflow anti-patterns from JSON preferences',\n\t\tdefault_enabled: true,\n\t\toption_name: 'coding_preferences',\n\t\tcli_arg: 'no-coding-preferences',\n\t\tcli_flag: '--no-coding-preferences',\n\t\tcli_description: 'Disable coding preferences guardrails',\n\t\taliases: ['coding-preferences', 'preferences', 'prefs'],\n\t\texternal_package_name: '@spences10/pi-coding-preferences',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-coding-preferences')).default,\n\t},\n\t{\n\t\tkey: 'handoff',\n\t\tlabel: 'Handoff',\n\t\tdocs_label: 'Handoff',\n\t\tdescription:\n\t\t\t'Help command for Pi continuation primitives like /fork, /tree, /export, /import, and /share',\n\t\tdefault_enabled: true,\n\t\toption_name: 'handoff',\n\t\tcli_arg: 'no-handoff',\n\t\tcli_flag: '--no-handoff',\n\t\tcli_description: 'Disable handoff helper command',\n\t\taliases: ['handoff', 'continuation'],\n\t\tload: async () => (await import('./handoff/index.js')).default,\n\t},\n\t{\n\t\tkey: 'team-mode',\n\t\tlabel: 'Team mode',\n\t\tdocs_label: 'Team mode',\n\t\tdescription:\n\t\t\t'Peer coordination between independently opened Pi sessions with groups, artifacts, and durable mailboxes',\n\t\tdefault_enabled: true,\n\t\toption_name: 'team_mode',\n\t\tcli_arg: 'no-team-mode',\n\t\tcli_flag: '--no-team-mode',\n\t\tcli_description: 'Disable peer-session team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\n\t\texternal_package_name: '@spences10/pi-team-mode',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-team-mode')).default,\n\t},\n] as const satisfies readonly BuiltinExtensionManifestEntry[];\n\nexport type BuiltinExtensionKey =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['key'];\n\nexport type BuiltinExtensionOptionName =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['option_name'];\n\nexport type BuiltinExtensionInfo = Omit<\n\tBuiltinExtensionManifestEntry,\n\t'load'\n> & {\n\tkey: BuiltinExtensionKey;\n\toption_name: BuiltinExtensionOptionName;\n};\n\nexport const BUILTIN_EXTENSIONS: BuiltinExtensionInfo[] =\n\tBUILTIN_EXTENSION_REGISTRY.map(\n\t\t({ load: _load, ...extension }) => extension,\n\t);\n"],"mappings":";AA6BA,MAAa,6BAA6B;CACzC;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBACC;EACD,SAAS;GAAC;GAAmB;GAAW;EAAS;EACjD,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,yBAAA,CAA0B;CAC3D;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,KAAK;EACf,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,qBAAA,CAAsB;CACvD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,4BAA4B,e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C;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,WAAW,cAAc;EACnC,MAAM,aAAa,MAAM,OAAO,yBAAA,CAAuB;CACxD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAa;GAAQ;EAAW;EAC1C,uBAAuB;EACvB,MAAM,aACJ,MAAM,OAAO,2BAAA,CAA4B;CAC5C;AACD;AAgBA,MAAa,qBACZ,2BAA2B,KACzB,EAAE,MAAM,OAAO,GAAG,gBAAgB,SACpC"}
|
|
1
|
+
{"version":3,"file":"builtin-registry-DC8RlCfd.js","names":[],"sources":["../src/extensions/builtin-registry.ts"],"sourcesContent":["import type { ExtensionFactory } from '@earendil-works/pi-coding-agent';\n\nexport type BuiltinExtensionRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nexport interface BuiltinExtensionManifestEntry {\n\tkey: string;\n\tlabel: string;\n\tdocs_label: string;\n\tdescription: string;\n\tdefault_enabled: boolean;\n\toption_name: string;\n\tcli_arg: string;\n\tcli_flag: `--${string}`;\n\tcli_description: string;\n\taliases: readonly string[];\n\tmode_constraints?: {\n\t\tdisabled_in: readonly BuiltinExtensionRuntimeMode[];\n\t\treason: string;\n\t};\n\texternal_package_name?: string;\n\tload: BuiltinExtensionLoader;\n}\n\nexport const BUILTIN_EXTENSION_REGISTRY = [\n\t{\n\t\tkey: 'context-sidecar',\n\t\tlabel: 'Context sidecar',\n\t\tdocs_label: 'SQLite context sidecar',\n\t\tdescription: 'Local SQLite FTS sidecar for oversized tool output',\n\t\tdefault_enabled: true,\n\t\toption_name: 'context_sidecar',\n\t\tcli_arg: 'no-context-sidecar',\n\t\tcli_flag: '--no-context-sidecar',\n\t\tcli_description:\n\t\t\t'Disable SQLite context sidecar for large tool output',\n\t\taliases: ['context-sidecar', 'context', 'sidecar'],\n\t\texternal_package_name: '@spences10/pi-context',\n\t\tload: async () => (await import('@spences10/pi-context')).default,\n\t},\n\t{\n\t\tkey: 'mcp',\n\t\tlabel: 'MCP',\n\t\tdocs_label: 'MCP',\n\t\tdescription: 'MCP server integration and /mcp command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'mcp',\n\t\tcli_arg: 'no-mcp',\n\t\tcli_flag: '--no-mcp',\n\t\tcli_description: 'Disable built-in MCP extension',\n\t\taliases: ['mcp'],\n\t\texternal_package_name: '@spences10/pi-mcp',\n\t\tload: async () => (await import('@spences10/pi-mcp')).default,\n\t},\n\t{\n\t\tkey: 'openrouter-fusion-config',\n\t\tlabel: 'OpenRouter Fusion config',\n\t\tdocs_label: 'OpenRouter Fusion config guard',\n\t\tdescription:\n\t\t\t'Keeps OpenRouter Fusion off Anthropic by injecting a non-Anthropic panel and judge',\n\t\tdefault_enabled: true,\n\t\toption_name: 'openrouter_fusion_config',\n\t\tcli_arg: 'no-openrouter-fusion-config',\n\t\tcli_flag: '--no-openrouter-fusion-config',\n\t\tcli_description: 'Disable OpenRouter Fusion non-Anthropic config',\n\t\taliases: ['openrouter-fusion-config', 'fusion-budget'],\n\t\tload: async () =>\n\t\t\t(await import('./openrouter-fusion-config/index.js')).default,\n\t},\n\t{\n\t\tkey: 'umans-provider',\n\t\tlabel: 'Umans provider',\n\t\tdocs_label: 'Umans provider',\n\t\tdescription:\n\t\t\t'Umans.ai Anthropic Messages provider with API key login support',\n\t\tdefault_enabled: true,\n\t\toption_name: 'umans_provider',\n\t\tcli_arg: 'no-umans-provider',\n\t\tcli_flag: '--no-umans-provider',\n\t\tcli_description: 'Disable built-in Umans provider',\n\t\taliases: ['umans-provider', 'umans'],\n\t\tload: async () =>\n\t\t\t(await import('./umans-provider/index.js')).default,\n\t},\n\t{\n\t\tkey: 'footer',\n\t\tlabel: 'Footer',\n\t\tdocs_label: 'Footer',\n\t\tdescription: 'Configurable interactive footer/statusline',\n\t\tdefault_enabled: true,\n\t\toption_name: 'footer',\n\t\tcli_arg: 'no-footer',\n\t\tcli_flag: '--no-footer',\n\t\tcli_description: 'Disable custom footer/statusline',\n\t\taliases: ['footer', 'statusline', 'status-line'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Footer only renders in the interactive TUI',\n\t\t},\n\t\tload: async () => (await import('./footer/index.js')).default,\n\t},\n\t{\n\t\tkey: 'codex-usage',\n\t\tlabel: 'Codex usage',\n\t\tdocs_label: 'Codex usage status',\n\t\tdescription: 'OpenAI Codex usage status for the footer',\n\t\tdefault_enabled: true,\n\t\toption_name: 'codex_usage',\n\t\tcli_arg: 'no-codex-usage',\n\t\tcli_flag: '--no-codex-usage',\n\t\tcli_description: 'Disable Codex usage footer status',\n\t\taliases: ['codex-usage', 'codex-status'],\n\t\texternal_package_name: '@spences10/pi-codex-usage',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-codex-usage')).default,\n\t},\n\t{\n\t\tkey: 'harness',\n\t\tlabel: 'Harness',\n\t\tdocs_label: 'Task harness runtime',\n\t\tdescription:\n\t\t\t'Ephemeral /tmp task harness runtime with tools, enforcement, and bundled skills',\n\t\tdefault_enabled: true,\n\t\toption_name: 'harness',\n\t\tcli_arg: 'no-harness',\n\t\tcli_flag: '--no-harness',\n\t\tcli_description: 'Disable task harness runtime',\n\t\taliases: ['harness', 'task-harness'],\n\t\texternal_package_name: '@spences10/pi-harness',\n\t\tload: async () => (await import('@spences10/pi-harness')).default,\n\t},\n\t{\n\t\tkey: 'factory',\n\t\tlabel: 'Software factory',\n\t\tdocs_label: 'Software-factory control plane',\n\t\tdescription:\n\t\t\t'Versioned workflow dispatch, execution feedback, review, approval, recovery, and metrics',\n\t\tdefault_enabled: true,\n\t\toption_name: 'factory',\n\t\tcli_arg: 'no-factory',\n\t\tcli_flag: '--no-factory',\n\t\tcli_description: 'Disable software-factory control plane',\n\t\taliases: ['factory', 'software-factory', 'control-plane'],\n\t\texternal_package_name: '@spences10/pi-factory',\n\t\tload: async () => (await import('@spences10/pi-factory')).default,\n\t},\n\t{\n\t\tkey: 'skills',\n\t\tlabel: 'Skills',\n\t\tdocs_label: 'Skills',\n\t\tdescription: 'Managed pi-native skills and /skills command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skills',\n\t\tcli_arg: 'no-skills',\n\t\tcli_flag: '--no-skills',\n\t\tcli_description: 'Disable built-in skills extension',\n\t\taliases: ['skills', 'skill'],\n\t\texternal_package_name: '@spences10/pi-skills',\n\t\tload: async () => (await import('@spences10/pi-skills')).default,\n\t},\n\t{\n\t\tkey: 'skill-importer',\n\t\tlabel: 'Skill importer',\n\t\tdocs_label: 'Skill importer',\n\t\tdescription:\n\t\t\t'Import external Claude/plugin skills into Pi-native storage',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skill_importer',\n\t\tcli_arg: 'no-skill-importer',\n\t\tcli_flag: '--no-skill-importer',\n\t\tcli_description: 'Disable external skill importer extension',\n\t\taliases: ['skill-importer', 'import-skills', 'skill-import'],\n\t\texternal_package_name: '@spences10/pi-skill-importer',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-skill-importer')).default,\n\t},\n\t{\n\t\tkey: 'filter-output',\n\t\tlabel: 'Secret redaction',\n\t\tdocs_label: 'Secret redaction',\n\t\tdescription:\n\t\t\t'Redacts secrets from tool output before the model sees them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'filter_output',\n\t\tcli_arg: 'no-filter',\n\t\tcli_flag: '--no-filter',\n\t\tcli_description: 'Disable secret redaction in tool output',\n\t\taliases: [\n\t\t\t'filter-output',\n\t\t\t'filter_output',\n\t\t\t'filter',\n\t\t\t'redaction',\n\t\t\t'secret-redaction',\n\t\t\t'output-redaction',\n\t\t],\n\t\texternal_package_name: '@spences10/pi-redact',\n\t\tload: async () => (await import('@spences10/pi-redact')).default,\n\t},\n\t{\n\t\tkey: 'recall',\n\t\tlabel: 'Recall',\n\t\tdocs_label: 'Recall',\n\t\tdescription: 'pirecall reminder and background session sync',\n\t\tdefault_enabled: true,\n\t\toption_name: 'recall',\n\t\tcli_arg: 'no-recall',\n\t\tcli_flag: '--no-recall',\n\t\tcli_description: 'Disable recall extension',\n\t\taliases: ['recall', 'pirecall'],\n\t\texternal_package_name: '@spences10/pi-recall',\n\t\tload: async () => (await import('@spences10/pi-recall')).default,\n\t},\n\t{\n\t\tkey: 'nopeek',\n\t\tlabel: 'Nopeek',\n\t\tdocs_label: 'Nopeek',\n\t\tdescription:\n\t\t\t'nopeek reminder for secret-safe environment loading',\n\t\tdefault_enabled: true,\n\t\toption_name: 'nopeek',\n\t\tcli_arg: 'no-nopeek',\n\t\tcli_flag: '--no-nopeek',\n\t\tcli_description: 'Disable nopeek reminder extension',\n\t\taliases: ['nopeek', 'secrets', 'secret-loading'],\n\t\texternal_package_name: '@spences10/pi-nopeek',\n\t\tload: async () => (await import('@spences10/pi-nopeek')).default,\n\t},\n\t{\n\t\tkey: 'observability',\n\t\tlabel: 'Observability',\n\t\tdocs_label: 'Live observability',\n\t\tdescription:\n\t\t\t'Optional live event stream and local browser dashboard',\n\t\tdefault_enabled: true,\n\t\toption_name: 'observability',\n\t\tcli_arg: 'no-observability',\n\t\tcli_flag: '--no-observability',\n\t\tcli_description: 'Disable live observability extension',\n\t\taliases: ['observability', 'obs', 'live-events'],\n\t\texternal_package_name: '@spences10/pi-observability',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-observability')).default,\n\t},\n\t{\n\t\tkey: 'omnisearch',\n\t\tlabel: 'Omnisearch',\n\t\tdocs_label: 'Omnisearch',\n\t\tdescription: 'mcp-omnisearch reminder for verified web research',\n\t\tdefault_enabled: true,\n\t\toption_name: 'omnisearch',\n\t\tcli_arg: 'no-omnisearch',\n\t\tcli_flag: '--no-omnisearch',\n\t\tcli_description: 'Disable mcp-omnisearch reminder extension',\n\t\taliases: ['omnisearch', 'search', 'web-search', 'research'],\n\t\texternal_package_name: '@spences10/pi-omnisearch',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-omnisearch')).default,\n\t},\n\t{\n\t\tkey: 'sqlite-tools',\n\t\tlabel: 'SQLite tools',\n\t\tdocs_label: 'SQLite tools',\n\t\tdescription:\n\t\t\t'mcp-sqlite-tools reminder for safer SQLite database work',\n\t\tdefault_enabled: true,\n\t\toption_name: 'sqlite_tools',\n\t\tcli_arg: 'no-sqlite-tools',\n\t\tcli_flag: '--no-sqlite-tools',\n\t\tcli_description: 'Disable mcp-sqlite-tools reminder extension',\n\t\taliases: ['sqlite-tools', 'sqlite', 'mcp-sqlite-tools'],\n\t\texternal_package_name: '@spences10/pi-sqlite-tools',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-sqlite-tools')).default,\n\t},\n\t{\n\t\tkey: 'startup-screen',\n\t\tlabel: 'Startup screen',\n\t\tdocs_label: 'Startup screen',\n\t\tdescription:\n\t\t\t'Pixel-art gradient startup header for interactive sessions',\n\t\tdefault_enabled: true,\n\t\toption_name: 'startup_screen',\n\t\tcli_arg: 'no-startup-screen',\n\t\tcli_flag: '--no-startup-screen',\n\t\tcli_description: 'Disable the custom startup screen',\n\t\taliases: ['startup-screen', 'startup', 'header', 'splash'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Startup screen only renders in the interactive TUI',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./startup-screen/index.js')).default,\n\t},\n\t{\n\t\tkey: 'prompt-presets',\n\t\tlabel: 'Prompt presets',\n\t\tdocs_label: 'Prompt presets',\n\t\tdescription:\n\t\t\t'Runtime prompt preset selection and /prompt-preset command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'prompt_presets',\n\t\tcli_arg: 'no-prompt-presets',\n\t\tcli_flag: '--no-prompt-presets',\n\t\tcli_description: 'Disable prompt presets extension',\n\t\taliases: ['prompt-preset', 'preset', 'presets'],\n\t\tload: async () =>\n\t\t\t(await import('./prompt-presets/index.js')).default,\n\t},\n\t{\n\t\tkey: 'git-ui',\n\t\tlabel: 'Git UI',\n\t\tdocs_label: 'Git staging UI',\n\t\tdescription: 'Interactive source control staging panel',\n\t\tdefault_enabled: true,\n\t\toption_name: 'git_ui',\n\t\tcli_arg: 'no-git-ui',\n\t\tcli_flag: '--no-git-ui',\n\t\tcli_description: 'Disable built-in Git staging UI',\n\t\taliases: ['git-ui', 'git', 'source-control', 'scm'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Git UI is only useful in interactive mode',\n\t\t},\n\t\texternal_package_name: '@spences10/pi-git-ui',\n\t\tload: async () => (await import('@spences10/pi-git-ui')).default,\n\t},\n\t{\n\t\tkey: 'lsp',\n\t\tlabel: 'LSP',\n\t\tdocs_label: 'LSP',\n\t\tdescription:\n\t\t\t'Language Server Protocol tools (diagnostics, hover, definition, references)',\n\t\tdefault_enabled: true,\n\t\toption_name: 'lsp',\n\t\tcli_arg: 'no-lsp',\n\t\tcli_flag: '--no-lsp',\n\t\tcli_description: 'Disable LSP extension',\n\t\taliases: ['lsp', 'language-server'],\n\t\texternal_package_name: '@spences10/pi-lsp',\n\t\tload: async () => (await import('@spences10/pi-lsp')).default,\n\t},\n\t{\n\t\tkey: 'session-name',\n\t\tlabel: 'Session name',\n\t\tdocs_label: 'Session auto-naming',\n\t\tdescription:\n\t\t\t'AI-powered session auto-naming and /session-name command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'session_name',\n\t\tcli_arg: 'no-session-name',\n\t\tcli_flag: '--no-session-name',\n\t\tcli_description: 'Disable session name extension',\n\t\taliases: ['session-name', 'session', 'auto-name'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason:\n\t\t\t\t'UI-only session naming is only useful in interactive mode',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./session-name/index.js')).default,\n\t},\n\t{\n\t\tkey: 'confirm-destructive',\n\t\tlabel: 'Confirm destructive',\n\t\tdocs_label: 'Destructive action confirmation',\n\t\tdescription:\n\t\t\t'Prompt before destructive tool calls like file deletes, overwrites, and hard resets',\n\t\tdefault_enabled: true,\n\t\toption_name: 'confirm_destructive',\n\t\tcli_arg: 'no-confirm-destructive',\n\t\tcli_flag: '--no-confirm-destructive',\n\t\tcli_description: 'Disable destructive action confirmations',\n\t\taliases: ['confirm-destructive', 'confirm'],\n\t\texternal_package_name: '@spences10/pi-confirm-destructive',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-confirm-destructive')).default,\n\t},\n\t{\n\t\tkey: 'hooks-resolution',\n\t\tlabel: 'Hooks resolution',\n\t\tdocs_label: 'Hooks resolution',\n\t\tdescription:\n\t\t\t'Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs',\n\t\tdefault_enabled: true,\n\t\toption_name: 'hooks_resolution',\n\t\tcli_arg: 'no-hooks',\n\t\tcli_flag: '--no-hooks',\n\t\tcli_description: 'Disable Claude-style hook execution',\n\t\taliases: ['hooks-resolution', 'hooks'],\n\t\tload: async () =>\n\t\t\t(await import('./hooks-resolution/index.js')).default,\n\t},\n\t{\n\t\tkey: 'svelte-guardrails',\n\t\tlabel: 'Svelte guardrails',\n\t\tdocs_label: 'Svelte guardrails',\n\t\tdescription:\n\t\t\t'Blocks discouraged Svelte patterns like $effect before agents write them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'svelte_guardrails',\n\t\tcli_arg: 'no-svelte-guardrails',\n\t\tcli_flag: '--no-svelte-guardrails',\n\t\tcli_description: 'Disable Svelte guardrails',\n\t\taliases: ['svelte-guardrails', 'svelte'],\n\t\texternal_package_name: '@spences10/pi-svelte-guardrails',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-svelte-guardrails')).default,\n\t},\n\t{\n\t\tkey: 'coding-preferences',\n\t\tlabel: 'Coding preferences',\n\t\tdocs_label: 'Coding preferences',\n\t\tdescription:\n\t\t\t'Blocks configured coding workflow anti-patterns from JSON preferences',\n\t\tdefault_enabled: true,\n\t\toption_name: 'coding_preferences',\n\t\tcli_arg: 'no-coding-preferences',\n\t\tcli_flag: '--no-coding-preferences',\n\t\tcli_description: 'Disable coding preferences guardrails',\n\t\taliases: ['coding-preferences', 'preferences', 'prefs'],\n\t\texternal_package_name: '@spences10/pi-coding-preferences',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-coding-preferences')).default,\n\t},\n\t{\n\t\tkey: 'handoff',\n\t\tlabel: 'Handoff',\n\t\tdocs_label: 'Handoff',\n\t\tdescription:\n\t\t\t'Help command for Pi continuation primitives like /fork, /tree, /export, /import, and /share',\n\t\tdefault_enabled: true,\n\t\toption_name: 'handoff',\n\t\tcli_arg: 'no-handoff',\n\t\tcli_flag: '--no-handoff',\n\t\tcli_description: 'Disable handoff helper command',\n\t\taliases: ['handoff', 'continuation'],\n\t\tload: async () => (await import('./handoff/index.js')).default,\n\t},\n\t{\n\t\tkey: 'team-mode',\n\t\tlabel: 'Team mode',\n\t\tdocs_label: 'Team mode',\n\t\tdescription:\n\t\t\t'Peer coordination between independently opened Pi sessions with groups, artifacts, and durable mailboxes',\n\t\tdefault_enabled: true,\n\t\toption_name: 'team_mode',\n\t\tcli_arg: 'no-team-mode',\n\t\tcli_flag: '--no-team-mode',\n\t\tcli_description: 'Disable peer-session team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\n\t\texternal_package_name: '@spences10/pi-team-mode',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-team-mode')).default,\n\t},\n] as const satisfies readonly BuiltinExtensionManifestEntry[];\n\nexport type BuiltinExtensionKey =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['key'];\n\nexport type BuiltinExtensionOptionName =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['option_name'];\n\nexport type BuiltinExtensionInfo = Omit<\n\tBuiltinExtensionManifestEntry,\n\t'load'\n> & {\n\tkey: BuiltinExtensionKey;\n\toption_name: BuiltinExtensionOptionName;\n};\n\nexport const BUILTIN_EXTENSIONS: BuiltinExtensionInfo[] =\n\tBUILTIN_EXTENSION_REGISTRY.map(\n\t\t({ load: _load, ...extension }) => extension,\n\t);\n"],"mappings":";AA6BA,MAAa,6BAA6B;CACzC;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBACC;EACD,SAAS;GAAC;GAAmB;GAAW;EAAS;EACjD,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,yBAAA,CAA0B;CAC3D;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,KAAK;EACf,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,qBAAA,CAAsB;CACvD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,4BAA4B,eAAe;EACrD,MAAM,aACJ,MAAM,OAAO,0CAAA,CAAwC;CACxD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,kBAAkB,OAAO;EACnC,MAAM,aACJ,MAAM,OAAO,gCAAA,CAA8B;CAC9C;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAU;GAAc;EAAa;EAC/C,kBAAkB;GACjB,aAAa;IAAC;IAAS;IAAQ;GAAK;GACpC,QAAQ;EACT;EACA,MAAM,aAAa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Sync, readFileSync, statSync } from "node:fs";
|
|
2
2
|
import { basename, dirname, join, resolve } from "node:path";
|
|
3
|
-
import {
|
|
4
|
-
import { is_project_subject_trusted, read_project_trust_store, resolve_project_trust } from "@spences10/pi-project-trust";
|
|
3
|
+
import { create_project_trust_wrapper, resolve_project_trust } from "@spences10/pi-project-trust";
|
|
5
4
|
import { createHash } from "node:crypto";
|
|
6
5
|
import { spawn } from "node:child_process";
|
|
7
6
|
import { create_child_process_env } from "@spences10/pi-child-env";
|
|
@@ -336,8 +335,15 @@ function hook_name(command) {
|
|
|
336
335
|
//#endregion
|
|
337
336
|
//#region src/extensions/hooks-resolution/trust.ts
|
|
338
337
|
const HOOKS_CONFIG_ENV$1 = "MY_PI_HOOKS_CONFIG";
|
|
338
|
+
const hooks_config_trust = create_project_trust_wrapper({
|
|
339
|
+
store_filename: "trusted-hooks.json",
|
|
340
|
+
legacy_matcher: (entry, subject) => {
|
|
341
|
+
const legacy_entry = entry;
|
|
342
|
+
return legacy_entry?.project_dir === subject.id && legacy_entry.hash === subject.hash;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
339
345
|
function default_hooks_trust_store_path() {
|
|
340
|
-
return
|
|
346
|
+
return hooks_config_trust.default_trust_store_path();
|
|
341
347
|
}
|
|
342
348
|
function create_hooks_config_trust_subject(project_dir, hash) {
|
|
343
349
|
return {
|
|
@@ -350,9 +356,7 @@ function create_hooks_config_trust_subject(project_dir, hash) {
|
|
|
350
356
|
};
|
|
351
357
|
}
|
|
352
358
|
function is_hooks_config_trusted(project_dir, hash, trust_store_path = default_hooks_trust_store_path()) {
|
|
353
|
-
|
|
354
|
-
const legacy_entry = read_project_trust_store(trust_store_path)[project_dir];
|
|
355
|
-
return legacy_entry?.project_dir === project_dir && legacy_entry.hash === hash;
|
|
359
|
+
return hooks_config_trust.is_trusted(create_hooks_config_trust_subject(project_dir, hash), trust_store_path);
|
|
356
360
|
}
|
|
357
361
|
//#endregion
|
|
358
362
|
//#region src/extensions/hooks-resolution/trust-gate.ts
|
|
@@ -463,4 +467,4 @@ var hooks_resolution_default = create_hooks_resolution_extension();
|
|
|
463
467
|
//#endregion
|
|
464
468
|
export { hooks_resolution_default as default };
|
|
465
469
|
|
|
466
|
-
//# sourceMappingURL=hooks-resolution-
|
|
470
|
+
//# sourceMappingURL=hooks-resolution-Ci98WDjn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-resolution-Ci98WDjn.js","names":["create_child_process_env","create_shared_child_process_env","create_child_process_env","HOOKS_CONFIG_ENV"],"sources":["../src/extensions/hooks-resolution/config.ts","../src/extensions/hooks-resolution/payload.ts","../src/extensions/hooks-resolution/env.ts","../src/extensions/hooks-resolution/runner.ts","../src/extensions/hooks-resolution/trust.ts","../src/extensions/hooks-resolution/trust-gate.ts","../src/extensions/hooks-resolution/index.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type {\n\tHookEventName,\n\tHooksConfigInfo,\n\tHookState,\n\tJsonValue,\n\tResolvedCommandHook,\n} from './types.js';\n\nexport function is_file(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isFile();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function as_record(\n\tvalue: unknown,\n): Record<string, unknown> | undefined {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\treturn value as Record<string, unknown>;\n}\n\nexport function walk_up_directories(\n\tstart_dir: string,\n\tstop_dir?: string,\n): string[] {\n\tconst directories: string[] = [];\n\tconst has_stop_dir = stop_dir !== undefined;\n\tlet current = resolve(start_dir);\n\tlet parent = dirname(current);\n\tlet reached_stop_dir = has_stop_dir && current === stop_dir;\n\tlet reached_filesystem_root = parent === current;\n\n\tdirectories.push(current);\n\twhile (!reached_stop_dir && !reached_filesystem_root) {\n\t\tcurrent = parent;\n\t\tparent = dirname(current);\n\t\treached_stop_dir = has_stop_dir && current === stop_dir;\n\t\treached_filesystem_root = parent === current;\n\t\tdirectories.push(current);\n\t}\n\n\treturn directories;\n}\n\nexport function find_nearest_git_root(\n\tstart_dir: string,\n): string | undefined {\n\tfor (const directory of walk_up_directories(start_dir)) {\n\t\tif (existsSync(join(directory, '.git'))) {\n\t\t\treturn directory;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function has_hooks_config(directory: string): boolean {\n\treturn (\n\t\tis_file(join(directory, '.claude', 'settings.json')) ||\n\t\tis_file(join(directory, '.rulesync', 'hooks.json')) ||\n\t\tis_file(join(directory, '.pi', 'hooks.json'))\n\t);\n}\n\nexport function find_project_dir(cwd: string): string {\n\tconst git_root = find_nearest_git_root(cwd);\n\tfor (const directory of walk_up_directories(cwd, git_root)) {\n\t\tif (has_hooks_config(directory)) {\n\t\t\treturn directory;\n\t\t}\n\t}\n\treturn git_root ?? resolve(cwd);\n}\n\nexport function read_json_file(path: string): JsonValue | undefined {\n\tif (!is_file(path)) return undefined;\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8')) as JsonValue;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function resolve_hook_command(\n\tcommand: string,\n\tproject_dir: string,\n): string {\n\treturn command.replace(/\\$CLAUDE_PROJECT_DIR\\b/g, project_dir);\n}\n\nexport function compile_matcher(\n\tmatcher_text: string | undefined,\n): RegExp | undefined {\n\tif (matcher_text === undefined) return undefined;\n\ttry {\n\t\treturn new RegExp(matcher_text);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function create_hook(\n\tevent_name: HookEventName,\n\tmatcher_text: string | undefined,\n\tcommand: string,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook | undefined {\n\tconst matcher = compile_matcher(matcher_text);\n\tif (matcher_text !== undefined && matcher === undefined)\n\t\treturn undefined;\n\treturn {\n\t\tevent_name,\n\t\tmatcher,\n\t\tmatcher_text,\n\t\tcommand: resolve_hook_command(command, project_dir),\n\t\tsource,\n\t};\n}\n\nexport function get_hook_entries(\n\thooks_record: Record<string, unknown>,\n\tevent_name: HookEventName,\n): unknown[] {\n\tconst keys =\n\t\tevent_name === 'PreToolUse'\n\t\t\t? ['PreToolUse', 'preToolUse']\n\t\t\t: event_name === 'PostToolUse'\n\t\t\t\t? ['PostToolUse', 'postToolUse']\n\t\t\t\t: ['PostToolUseFailure', 'postToolUseFailure'];\n\n\tfor (const key of keys) {\n\t\tconst value = hooks_record[key];\n\t\tif (Array.isArray(value)) return value;\n\t}\n\treturn [];\n}\n\nexport function parse_claude_settings_hooks(\n\tconfig: unknown,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst root = as_record(config);\n\tconst hooks_root = root ? as_record(root.hooks) : undefined;\n\tif (!hooks_root) return [];\n\n\tconst hooks: ResolvedCommandHook[] = [];\n\tconst events: HookEventName[] = [\n\t\t'PreToolUse',\n\t\t'PostToolUse',\n\t\t'PostToolUseFailure',\n\t];\n\n\tfor (const event_name of events) {\n\t\tconst entries = get_hook_entries(hooks_root, event_name);\n\t\tfor (const entry of entries) {\n\t\t\tconst entry_record = as_record(entry);\n\t\t\tif (!entry_record || !Array.isArray(entry_record.hooks))\n\t\t\t\tcontinue;\n\n\t\t\tconst matcher_text =\n\t\t\t\ttypeof entry_record.matcher === 'string'\n\t\t\t\t\t? entry_record.matcher\n\t\t\t\t\t: undefined;\n\t\t\tfor (const nested_hook of entry_record.hooks) {\n\t\t\t\tconst nested_record = as_record(nested_hook);\n\t\t\t\tif (!nested_record) continue;\n\t\t\t\tif (nested_record.type !== 'command') continue;\n\t\t\t\tif (typeof nested_record.command !== 'string') continue;\n\n\t\t\t\tconst hook = create_hook(\n\t\t\t\t\tevent_name,\n\t\t\t\t\tmatcher_text,\n\t\t\t\t\tnested_record.command,\n\t\t\t\t\tsource,\n\t\t\t\t\tproject_dir,\n\t\t\t\t);\n\t\t\t\tif (hook) hooks.push(hook);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hooks;\n}\n\nexport function parse_simple_hooks_file(\n\tconfig: unknown,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst root = as_record(config);\n\tconst hooks_root = root ? as_record(root.hooks) : undefined;\n\tif (!hooks_root) return [];\n\n\tconst hooks: ResolvedCommandHook[] = [];\n\tconst events: HookEventName[] = [\n\t\t'PreToolUse',\n\t\t'PostToolUse',\n\t\t'PostToolUseFailure',\n\t];\n\n\tfor (const event_name of events) {\n\t\tconst entries = get_hook_entries(hooks_root, event_name);\n\t\tfor (const entry of entries) {\n\t\t\tconst entry_record = as_record(entry);\n\t\t\tif (!entry_record || typeof entry_record.command !== 'string') {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst matcher_text =\n\t\t\t\ttypeof entry_record.matcher === 'string'\n\t\t\t\t\t? entry_record.matcher\n\t\t\t\t\t: undefined;\n\t\t\tconst hook = create_hook(\n\t\t\t\tevent_name,\n\t\t\t\tmatcher_text,\n\t\t\t\tentry_record.command,\n\t\t\t\tsource,\n\t\t\t\tproject_dir,\n\t\t\t);\n\t\t\tif (hook) hooks.push(hook);\n\t\t}\n\t}\n\n\treturn hooks;\n}\n\nfunction hook_config_paths(project_dir: string): string[] {\n\treturn [\n\t\tjoin(project_dir, '.claude', 'settings.json'),\n\t\tjoin(project_dir, '.rulesync', 'hooks.json'),\n\t\tjoin(project_dir, '.pi', 'hooks.json'),\n\t];\n}\n\nfunction parse_hooks_config_file(\n\tpath: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst config = read_json_file(path);\n\tif (config === undefined) return [];\n\tif (path.endsWith(join('.claude', 'settings.json'))) {\n\t\treturn parse_claude_settings_hooks(config, path, project_dir);\n\t}\n\treturn parse_simple_hooks_file(config, path, project_dir);\n}\n\nexport function load_hooks(cwd: string): HookState {\n\tconst project_dir = find_project_dir(cwd);\n\tconst hooks = hook_config_paths(project_dir).flatMap((path) =>\n\t\tparse_hooks_config_file(path, project_dir),\n\t);\n\n\treturn { project_dir, hooks };\n}\n\nexport function get_hooks_config_info(\n\tcwd: string,\n): HooksConfigInfo | undefined {\n\tconst project_dir = find_project_dir(cwd);\n\tconst sources = hook_config_paths(project_dir).filter(is_file);\n\tif (sources.length === 0) return undefined;\n\n\tconst hash = createHash('sha256');\n\tfor (const source of sources) {\n\t\thash.update(source);\n\t\thash.update('\\0');\n\t\thash.update(readFileSync(source, 'utf8'));\n\t\thash.update('\\0');\n\t}\n\n\tconst hooks = sources\n\t\t.flatMap((source) => parse_hooks_config_file(source, project_dir))\n\t\t.map((hook) => ({\n\t\t\tevent_name: hook.event_name,\n\t\t\tmatcher_text: hook.matcher_text,\n\t\t\tcommand: hook.command,\n\t\t\tsource: hook.source,\n\t\t}));\n\n\treturn {\n\t\tproject_dir,\n\t\thash: hash.digest('hex'),\n\t\tsources,\n\t\thooks,\n\t};\n}\n","import type {\n\tExtensionContext,\n\tToolCallEvent,\n\tToolResultEvent,\n} from '@earendil-works/pi-coding-agent';\nimport type { HookEventName, ResolvedCommandHook } from './types.js';\n\nexport function to_claude_tool_name(tool_name: string): string {\n\tif (tool_name === 'ls') return 'LS';\n\tif (tool_name.length === 0) return tool_name;\n\treturn tool_name[0].toUpperCase() + tool_name.slice(1);\n}\n\nexport function matches_hook(\n\thook: ResolvedCommandHook,\n\ttool_name: string,\n): boolean {\n\tif (!hook.matcher) return true;\n\n\tconst claude_tool_name = to_claude_tool_name(tool_name);\n\thook.matcher.lastIndex = 0;\n\tif (hook.matcher.test(tool_name)) return true;\n\n\thook.matcher.lastIndex = 0;\n\treturn hook.matcher.test(claude_tool_name);\n}\n\nexport function extract_text_content(content: unknown): string {\n\tif (!Array.isArray(content)) return '';\n\n\tconst parts: string[] = [];\n\tfor (const item of content) {\n\t\tif (!item || typeof item !== 'object') continue;\n\t\tconst item_record = item as Record<string, unknown>;\n\t\tif (\n\t\t\titem_record.type === 'text' &&\n\t\t\ttypeof item_record.text === 'string'\n\t\t) {\n\t\t\tparts.push(item_record.text);\n\t\t}\n\t}\n\n\treturn parts.join('\\n');\n}\n\nexport function normalize_tool_input(\n\tinput: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst normalized: Record<string, unknown> = { ...input };\n\tconst path_value =\n\t\ttypeof input.path === 'string' ? input.path : undefined;\n\tif (path_value !== undefined) {\n\t\tnormalized.file_path = path_value;\n\t\tnormalized.filePath = path_value;\n\t}\n\treturn normalized;\n}\n\nexport function build_tool_response(\n\tevent: ToolResultEvent,\n\tnormalized_input: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst response: Record<string, unknown> = {\n\t\tis_error: event.isError,\n\t\tisError: event.isError,\n\t\tcontent: event.content,\n\t\ttext: extract_text_content(event.content),\n\t\tdetails: event.details ?? null,\n\t};\n\n\tconst file_path =\n\t\ttypeof normalized_input.file_path === 'string'\n\t\t\t? normalized_input.file_path\n\t\t\t: undefined;\n\tif (file_path !== undefined) {\n\t\tresponse.file_path = file_path;\n\t\tresponse.filePath = file_path;\n\t}\n\n\treturn response;\n}\n\nexport function build_hook_payload(\n\tevent: ToolCallEvent | ToolResultEvent,\n\tevent_name: HookEventName,\n\tctx: ExtensionContext,\n\tproject_dir: string,\n): Record<string, unknown> {\n\tconst normalized_input = normalize_tool_input(\n\t\tevent.input as Record<string, unknown>,\n\t);\n\tconst session_id =\n\t\tctx.sessionManager.getSessionFile() ?? 'ephemeral';\n\tconst payload: Record<string, unknown> = {\n\t\tsession_id,\n\t\tcwd: ctx.cwd,\n\t\tclaude_project_dir: project_dir,\n\t\thook_event_name: event_name,\n\t\ttool_name: to_claude_tool_name(event.toolName),\n\t\ttool_call_id: event.toolCallId,\n\t\ttool_input: normalized_input,\n\t};\n\n\tif ('content' in event) {\n\t\tpayload.tool_response = build_tool_response(\n\t\t\tevent,\n\t\t\tnormalized_input,\n\t\t);\n\t}\n\n\treturn payload;\n}\n","import { create_child_process_env as create_shared_child_process_env } from '@spences10/pi-child-env';\n\nexport function create_child_process_env(\n\texplicit_env: Record<string, string> = {},\n\tsource_env: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\treturn create_shared_child_process_env({\n\t\tprofile: 'hooks',\n\t\texplicit_env,\n\t\tsource_env,\n\t});\n}\n","import type { ToolResultEvent } from '@earendil-works/pi-coding-agent';\nimport { spawn } from 'node:child_process';\nimport { basename } from 'node:path';\nimport { as_record } from './config.js';\nimport { create_child_process_env } from './env.js';\nimport type { CommandRunResult, HookEventName } from './types.js';\n\nconst HOOK_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport async function run_command_hook(\n\tcommand: string,\n\tcwd: string,\n\tpayload: Record<string, unknown>,\n): Promise<CommandRunResult> {\n\treturn await new Promise((resolve) => {\n\t\tconst started_at = Date.now();\n\t\tconst child = spawn('bash', ['-lc', command], {\n\t\t\tcwd,\n\t\t\tenv: create_child_process_env({ CLAUDE_PROJECT_DIR: cwd }),\n\t\t\tstdio: ['pipe', 'pipe', 'pipe'],\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\t\tlet timed_out = false;\n\t\tlet resolved = false;\n\n\t\tconst finish = (code: number) => {\n\t\t\tif (resolved) return;\n\t\t\tresolved = true;\n\t\t\tresolve({\n\t\t\t\tcode,\n\t\t\t\tstdout,\n\t\t\t\tstderr,\n\t\t\t\telapsed_ms: Date.now() - started_at,\n\t\t\t\ttimed_out,\n\t\t\t});\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\ttimed_out = true;\n\t\t\tchild.kill('SIGTERM');\n\t\t\tconst kill_timer = setTimeout(() => {\n\t\t\t\tchild.kill('SIGKILL');\n\t\t\t}, 1000);\n\t\t\t(\n\t\t\t\tkill_timer as NodeJS.Timeout & { unref?: () => void }\n\t\t\t).unref?.();\n\t\t}, HOOK_TIMEOUT_MS);\n\t\t(timeout as NodeJS.Timeout & { unref?: () => void }).unref?.();\n\n\t\tchild.stdout.on('data', (chunk: Buffer) => {\n\t\t\tstdout += chunk.toString('utf8');\n\t\t});\n\t\tchild.stderr.on('data', (chunk: Buffer) => {\n\t\t\tstderr += chunk.toString('utf8');\n\t\t});\n\n\t\tchild.on('error', (error) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tstderr += `${error.message}\\n`;\n\t\t\tfinish(-1);\n\t\t});\n\n\t\tchild.on('close', (code) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tfinish(code ?? -1);\n\t\t});\n\n\t\ttry {\n\t\t\tchild.stdin.write(JSON.stringify(payload));\n\t\t\tchild.stdin.end();\n\t\t} catch (error) {\n\t\t\tstderr += `${error instanceof Error ? error.message : String(error)}\\n`;\n\t\t}\n\t});\n}\n\nexport function hook_event_name_for_result(\n\tevent: ToolResultEvent,\n): HookEventName {\n\treturn event.isError ? 'PostToolUseFailure' : 'PostToolUse';\n}\n\nexport function hook_block_reason(\n\tresult: CommandRunResult,\n): string | undefined {\n\tconst parse_json = (\n\t\ttext: string,\n\t): Record<string, unknown> | undefined => {\n\t\tconst trimmed = text.trim();\n\t\tif (!trimmed) return undefined;\n\t\ttry {\n\t\t\treturn as_record(JSON.parse(trimmed));\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\tconst json = parse_json(result.stdout) ?? parse_json(result.stderr);\n\tif (json?.decision === 'block') {\n\t\treturn typeof json.reason === 'string'\n\t\t\t? json.reason\n\t\t\t: 'Blocked by hook';\n\t}\n\tif (result.code === 2) {\n\t\treturn (\n\t\t\tresult.stderr.trim() ||\n\t\t\tresult.stdout.trim() ||\n\t\t\t'Blocked by hook'\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function format_duration(elapsed_ms: number): string {\n\tif (elapsed_ms < 1000) return `${elapsed_ms}ms`;\n\treturn `${(elapsed_ms / 1000).toFixed(1)}s`;\n}\n\nexport function hook_name(command: string): string {\n\tconst sh_path_match = command.match(/[^\\s|;&]+\\.sh\\b/);\n\tif (sh_path_match) return basename(sh_path_match[0]);\n\tconst first_token = command.trim().split(/\\s+/)[0] ?? 'hook';\n\treturn basename(first_token);\n}\n","import {\n\tcreate_project_trust_wrapper,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\n\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\nconst hooks_config_trust = create_project_trust_wrapper({\n\tstore_filename: 'trusted-hooks.json',\n\tlegacy_matcher: (entry, subject) => {\n\t\tconst legacy_entry = entry as\n\t\t\t| { project_dir?: unknown; hash?: unknown }\n\t\t\t| undefined;\n\t\treturn (\n\t\t\tlegacy_entry?.project_dir === subject.id &&\n\t\t\tlegacy_entry.hash === subject.hash\n\t\t);\n\t},\n});\n\nexport function default_hooks_trust_store_path(): string {\n\treturn hooks_config_trust.default_trust_store_path();\n}\n\nexport function create_hooks_config_trust_subject(\n\tproject_dir: string,\n\thash: string,\n): ProjectTrustSubject {\n\treturn {\n\t\tkind: 'hooks-config',\n\t\tid: project_dir,\n\t\tstore_key: project_dir,\n\t\thash,\n\t\tenv_key: HOOKS_CONFIG_ENV,\n\t\tprompt_title:\n\t\t\t'Project hook config can execute shell commands after tool use. Trust these hooks?',\n\t};\n}\n\nexport function is_hooks_config_trusted(\n\tproject_dir: string,\n\thash: string,\n\ttrust_store_path = default_hooks_trust_store_path(),\n): boolean {\n\treturn hooks_config_trust.is_trusted(\n\t\tcreate_hooks_config_trust_subject(project_dir, hash),\n\t\ttrust_store_path,\n\t);\n}\n\nexport function trust_hooks_config(\n\tproject_dir: string,\n\thash: string,\n\ttrust_store_path = default_hooks_trust_store_path(),\n): void {\n\thooks_config_trust.trust(\n\t\tcreate_hooks_config_trust_subject(project_dir, hash),\n\t\ttrust_store_path,\n\t);\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport {\n\tresolve_project_trust,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\nimport { get_hooks_config_info } from './config.js';\nimport {\n\tdefault_hooks_trust_store_path,\n\tis_hooks_config_trusted,\n} from './trust.js';\nimport type { HooksConfigInfo } from './types.js';\n\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\nexport function create_hooks_trust_subject(\n\tinfo: HooksConfigInfo,\n): ProjectTrustSubject {\n\tconst source_lines = info.sources.map((source) => `- ${source}`);\n\tconst hook_lines =\n\t\tinfo.hooks.length === 0\n\t\t\t? ['- no valid command hooks detected']\n\t\t\t: info.hooks.map((hook) => {\n\t\t\t\t\tconst matcher = hook.matcher_text\n\t\t\t\t\t\t? ` matcher=${hook.matcher_text}`\n\t\t\t\t\t\t: '';\n\t\t\t\t\treturn `- ${hook.event_name}${matcher}: ${hook.command}`;\n\t\t\t\t});\n\treturn {\n\t\tkind: 'hooks-config',\n\t\tid: info.project_dir,\n\t\tstore_key: info.project_dir,\n\t\thash: info.hash,\n\t\tenv_key: HOOKS_CONFIG_ENV,\n\t\tprompt_title:\n\t\t\t'Project hook config can execute shell commands after tool use. Trust these hooks?',\n\t\tsummary_lines: [\n\t\t\t'Sources:',\n\t\t\t...source_lines,\n\t\t\t'Commands:',\n\t\t\t...hook_lines,\n\t\t],\n\t\tchoices: {\n\t\t\tallow_once: 'Allow once for this session',\n\t\t\ttrust: 'Trust this repo until hook config changes',\n\t\t\tskip: 'Skip project hooks',\n\t\t},\n\t\theadless_warning: `Skipping untrusted hook config in ${info.project_dir}. Set ${HOOKS_CONFIG_ENV}=allow to enable hooks for this run.`,\n\t};\n}\n\nexport async function should_load_hooks_config(\n\tcwd: string,\n\tctx?: ExtensionContext,\n): Promise<boolean> {\n\tconst info = get_hooks_config_info(cwd);\n\tif (!info) return true;\n\tif (is_hooks_config_trusted(info.project_dir, info.hash))\n\t\treturn true;\n\n\tconst decision = await resolve_project_trust(\n\t\tcreate_hooks_trust_subject(info),\n\t\t{\n\t\t\thas_ui: ctx?.hasUI,\n\t\t\tselect: ctx?.hasUI\n\t\t\t\t? async (\n\t\t\t\t\t\tmessage: string,\n\t\t\t\t\t\tchoices: string[],\n\t\t\t\t\t): Promise<string> => {\n\t\t\t\t\t\tconst selected = await ctx.ui.select(message, choices);\n\t\t\t\t\t\treturn selected ?? '';\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t\tenv: process.env,\n\t\t\ttrust_store_path: default_hooks_trust_store_path(),\n\t\t},\n\t);\n\treturn (\n\t\tdecision.action === 'allow-once' ||\n\t\tdecision.action === 'trust-persisted'\n\t);\n}\n","// Hooks resolution — Claude Code style hook compatibility\n\nimport type {\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolCallEventResult,\n} from '@earendil-works/pi-coding-agent';\nimport { load_hooks } from './config.js';\nimport { build_hook_payload, matches_hook } from './payload.js';\nimport {\n\tformat_duration,\n\thook_block_reason,\n\thook_event_name_for_result,\n\thook_name,\n\trun_command_hook,\n} from './runner.js';\nimport { should_load_hooks_config } from './trust-gate.js';\nimport type { CommandRunResult, HookState } from './types.js';\n\nexport {\n\tas_record,\n\tcompile_matcher,\n\tcreate_hook,\n\tfind_nearest_git_root,\n\tfind_project_dir,\n\tget_hook_entries,\n\tget_hooks_config_info,\n\thas_hooks_config,\n\tis_file,\n\tload_hooks,\n\tparse_claude_settings_hooks,\n\tparse_simple_hooks_file,\n\tread_json_file,\n\tresolve_hook_command,\n\twalk_up_directories,\n} from './config.js';\nexport {\n\tbuild_hook_payload,\n\tbuild_tool_response,\n\textract_text_content,\n\tmatches_hook,\n\tnormalize_tool_input,\n\tto_claude_tool_name,\n} from './payload.js';\nexport {\n\tformat_duration,\n\thook_block_reason,\n\thook_event_name_for_result,\n\thook_name,\n\trun_command_hook,\n} from './runner.js';\nexport type {\n\tCommandRunResult,\n\tHookEventName,\n\tHooksConfigInfo,\n\tHookState,\n\tResolvedCommandHook,\n} from './types.js';\nexport interface HooksResolutionOptions {\n\tload_hooks?: (cwd: string) => HookState;\n\trun_command_hook?: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\tpayload: Record<string, unknown>,\n\t) => Promise<CommandRunResult>;\n}\n\nexport function create_hooks_resolution_extension(\n\toptions: HooksResolutionOptions = {},\n): ExtensionFactory {\n\tconst load_hooks_impl = options.load_hooks ?? load_hooks;\n\tconst run_command_hook_impl =\n\t\toptions.run_command_hook ?? run_command_hook;\n\n\treturn async function hooks_resolution(pi: ExtensionAPI) {\n\t\tlet state: HookState = {\n\t\t\tproject_dir: process.cwd(),\n\t\t\thooks: [],\n\t\t};\n\n\t\tconst refresh_hooks = async (\n\t\t\tcwd: string,\n\t\t\tctx?: ExtensionContext,\n\t\t) => {\n\t\t\tif (!(await should_load_hooks_config(cwd, ctx))) {\n\t\t\t\tstate = { project_dir: cwd, hooks: [] };\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstate = load_hooks_impl(cwd);\n\t\t};\n\n\t\tpi.on('session_start', async (_event, ctx) => {\n\t\t\tawait refresh_hooks(ctx.cwd, ctx);\n\t\t});\n\n\t\tpi.on(\n\t\t\t'tool_call',\n\t\t\tasync (\n\t\t\t\tevent,\n\t\t\t\tctx,\n\t\t\t): Promise<ToolCallEventResult | undefined> => {\n\t\t\t\tif (state.hooks.length === 0) return;\n\n\t\t\t\tconst matching_hooks = state.hooks.filter(\n\t\t\t\t\t(hook) =>\n\t\t\t\t\t\thook.event_name === 'PreToolUse' &&\n\t\t\t\t\t\tmatches_hook(hook, event.toolName),\n\t\t\t\t);\n\t\t\t\tif (matching_hooks.length === 0) return;\n\n\t\t\t\tconst payload = build_hook_payload(\n\t\t\t\t\tevent,\n\t\t\t\t\t'PreToolUse',\n\t\t\t\t\tctx,\n\t\t\t\t\tstate.project_dir,\n\t\t\t\t);\n\t\t\t\tconst executed_commands = new Set<string>();\n\n\t\t\t\tfor (const hook of matching_hooks) {\n\t\t\t\t\tif (executed_commands.has(hook.command)) continue;\n\t\t\t\t\texecuted_commands.add(hook.command);\n\n\t\t\t\t\tconst result = await run_command_hook_impl(\n\t\t\t\t\t\thook.command,\n\t\t\t\t\t\tstate.project_dir,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t);\n\t\t\t\t\tconst reason = hook_block_reason(result);\n\t\t\t\t\tif (reason) return { block: true, reason };\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tpi.on('tool_result', async (event, ctx) => {\n\t\t\tif (state.hooks.length === 0) return;\n\n\t\t\tconst event_name = hook_event_name_for_result(event);\n\t\t\tconst matching_hooks = state.hooks.filter(\n\t\t\t\t(hook) =>\n\t\t\t\t\thook.event_name === event_name &&\n\t\t\t\t\tmatches_hook(hook, event.toolName),\n\t\t\t);\n\t\t\tif (matching_hooks.length === 0) return;\n\n\t\t\tconst payload = build_hook_payload(\n\t\t\t\tevent,\n\t\t\t\tevent_name,\n\t\t\t\tctx,\n\t\t\t\tstate.project_dir,\n\t\t\t);\n\t\t\tconst executed_commands = new Set<string>();\n\n\t\t\tfor (const hook of matching_hooks) {\n\t\t\t\tif (executed_commands.has(hook.command)) continue;\n\t\t\t\texecuted_commands.add(hook.command);\n\n\t\t\t\tconst result = await run_command_hook_impl(\n\t\t\t\t\thook.command,\n\t\t\t\t\tstate.project_dir,\n\t\t\t\t\tpayload,\n\t\t\t\t);\n\t\t\t\tconst name = hook_name(hook.command);\n\t\t\t\tconst duration = format_duration(result.elapsed_ms);\n\n\t\t\t\tif (ctx.hasUI) {\n\t\t\t\t\tif (result.code === 0) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Hook \\`${name}\\` ran (${duration})`,\n\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst error_line =\n\t\t\t\t\t\t\tresult.stderr.trim() ||\n\t\t\t\t\t\t\tresult.stdout.trim() ||\n\t\t\t\t\t\t\t`exit code ${result.code}`;\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Hook \\`${name}\\` failed (${duration}): ${error_line}`,\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default create_hooks_resolution_extension();\n"],"mappings":";;;;;;;AAWA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,MAAM,aACN,OACD;IACA,MAAM,OAAO,UAAU,KAAK,OAAO;IACnC,MAAM,WAAW,gBAAgB,OAAO,UAAU;IAElD,IAAI,IAAI,OACP,IAAI,OAAO,SAAS,GACnB,IAAI,GAAG,OACN,UAAU,KAAK,UAAU,SAAS,IAClC,MACD;SACM;KACN,MAAM,aACL,OAAO,OAAO,KAAK,KACnB,OAAO,OAAO,KAAK,KACnB,aAAa,OAAO;KACrB,IAAI,GAAG,OACN,UAAU,KAAK,aAAa,SAAS,KAAK,cAC1C,SACD;IACD;GAEF;EACD,CAAC;CACF;AACD;AAEA,IAAA,2BAAe,kCAAkC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as BUILTIN_EXTENSIONS } from "./builtin-registry-
|
|
2
|
+
import { t as BUILTIN_EXTENSIONS } from "./builtin-registry-DC8RlCfd.js";
|
|
3
3
|
import { defineCommand, renderUsage, runMain } from "citty";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -75,6 +75,32 @@ function parse_thinking_level(value) {
|
|
|
75
75
|
return normalized;
|
|
76
76
|
}
|
|
77
77
|
//#endregion
|
|
78
|
+
//#region src/runtime-preflight.ts
|
|
79
|
+
const MINIMUM_NODE_VERSION = "24.15.0";
|
|
80
|
+
function parse_node_version(version) {
|
|
81
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(version);
|
|
82
|
+
if (!match) return void 0;
|
|
83
|
+
return [
|
|
84
|
+
Number(match[1]),
|
|
85
|
+
Number(match[2]),
|
|
86
|
+
Number(match[3])
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
function is_supported_node_version(version) {
|
|
90
|
+
const current = parse_node_version(version);
|
|
91
|
+
const minimum = parse_node_version(MINIMUM_NODE_VERSION);
|
|
92
|
+
if (!current || !minimum) return false;
|
|
93
|
+
for (let index = 0; index < current.length; index++) {
|
|
94
|
+
if (current[index] > minimum[index]) return true;
|
|
95
|
+
if (current[index] < minimum[index]) return false;
|
|
96
|
+
}
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
function get_node_preflight_error(current_version = process.versions.node) {
|
|
100
|
+
if (is_supported_node_version(current_version)) return void 0;
|
|
101
|
+
return `my-pi requires Node >=${MINIMUM_NODE_VERSION}; current version is ${current_version}. Upgrade Node and retry.`;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
78
104
|
//#region src/warnings.ts
|
|
79
105
|
const SQLITE_EXPERIMENTAL_WARNING = "SQLite is an experimental feature";
|
|
80
106
|
const FILTER_INSTALLED = Symbol.for("my-pi.sqlite-warning-filter-installed");
|
|
@@ -99,6 +125,11 @@ function install_sqlite_warning_filter(process_like = process) {
|
|
|
99
125
|
}
|
|
100
126
|
//#endregion
|
|
101
127
|
//#region src/index.ts
|
|
128
|
+
const node_preflight_error = get_node_preflight_error();
|
|
129
|
+
if (node_preflight_error) {
|
|
130
|
+
console.error(node_preflight_error);
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
102
133
|
install_sqlite_warning_filter();
|
|
103
134
|
const package_root = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
104
135
|
const pkg = JSON.parse(readFileSync(join(package_root, "package.json"), "utf-8"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/cli-args.ts","../src/warnings.ts","../src/index.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionOptionName,\n} from './extensions/builtin-registry.js';\n\nconst THINKING_LEVELS = new Set([\n\t'off',\n\t'minimal',\n\t'low',\n\t'medium',\n\t'high',\n\t'xhigh',\n]);\n\nexport type CliThinkingLevel =\n\t| 'off'\n\t| 'minimal'\n\t| 'low'\n\t| 'medium'\n\t| 'high'\n\t| 'xhigh';\n\nexport type BuiltinDisableCliArgs = Record<\n\tstring,\n\t{\n\t\ttype: 'boolean';\n\t\tdescription: string;\n\t\tdefault: false;\n\t}\n>;\n\nexport function create_builtin_disable_cli_args(): BuiltinDisableCliArgs {\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.cli_arg,\n\t\t\t{\n\t\t\t\ttype: 'boolean' as const,\n\t\t\t\tdescription: extension.cli_description,\n\t\t\t\tdefault: false as const,\n\t\t\t},\n\t\t]),\n\t);\n}\n\nfunction is_citty_no_flag_set(\n\targs: Record<string, unknown>,\n\tcli_arg: string,\n): boolean {\n\tif (args[cli_arg]) return true;\n\n\tconst positive_kebab = cli_arg.replace(/^no-/, '');\n\tconst positive_camel = positive_kebab.replace(\n\t\t/-([a-z])/g,\n\t\t(_, char) => String(char).toUpperCase(),\n\t);\n\treturn (\n\t\targs[positive_kebab] === false || args[positive_camel] === false\n\t);\n}\n\nexport function resolve_builtin_extension_options(\n\targs: Record<string, unknown>,\n): Partial<Record<BuiltinExtensionOptionName, boolean>> {\n\tconst no_builtin = is_citty_no_flag_set(args, 'no-builtin');\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.option_name,\n\t\t\t!no_builtin && !is_citty_no_flag_set(args, extension.cli_arg),\n\t\t]),\n\t) as Partial<Record<BuiltinExtensionOptionName, boolean>>;\n}\n\nexport function collect_flag_values(\n\targv: string[],\n\tflags: readonly string[],\n): string[] {\n\tconst values: string[] = [];\n\tconst flag_set = new Set(flags);\n\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i];\n\t\tif (!arg) continue;\n\n\t\tconst equals_index = arg.indexOf('=');\n\t\tif (equals_index !== -1) {\n\t\t\tconst name = arg.slice(0, equals_index);\n\t\t\tif (flag_set.has(name)) {\n\t\t\t\tvalues.push(arg.slice(equals_index + 1));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (flag_set.has(arg) && i + 1 < argv.length) {\n\t\t\tconst next = argv[i + 1];\n\t\t\tif (next !== undefined) {\n\t\t\t\tvalues.push(next);\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn values;\n}\n\nexport function parse_extension_paths(\n\targv: string[],\n\tcwd = process.cwd(),\n): string[] {\n\treturn collect_flag_values(argv, ['-e', '--extension'])\n\t\t.map((path) => path.trim())\n\t\t.filter(Boolean)\n\t\t.map((path) => resolve(cwd, path));\n}\n\nfunction parse_comma_list_flags(\n\targv: string[],\n\tflags: readonly string[],\n): string[] | undefined {\n\tconst values = collect_flag_values(argv, flags)\n\t\t.flatMap((value) => value.split(','))\n\t\t.map((value) => value.trim())\n\t\t.filter(Boolean);\n\treturn values.length ? [...new Set(values)] : undefined;\n}\n\nexport function parse_tool_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--tools', '-t']);\n}\n\nexport function parse_tool_excludelist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--exclude-tools', '-xt']);\n}\n\nexport function parse_skill_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--skill']);\n}\n\nexport function parse_thinking_level(\n\tvalue: string | undefined,\n): CliThinkingLevel | undefined {\n\tconst normalized = value?.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\tif (!THINKING_LEVELS.has(normalized)) {\n\t\tthrow new Error(\n\t\t\t'--thinking must be one of: off, minimal, low, medium, high, xhigh.',\n\t\t);\n\t}\n\treturn normalized as CliThinkingLevel;\n}\n","const SQLITE_EXPERIMENTAL_WARNING =\n\t'SQLite is an experimental feature';\nconst FILTER_INSTALLED = Symbol.for(\n\t'my-pi.sqlite-warning-filter-installed',\n);\nconst ORIGINAL_EMIT_WARNING = Symbol.for(\n\t'my-pi.original-emit-warning',\n);\n\ntype WarningEmitter = Pick<typeof process, 'emitWarning'> & {\n\t[FILTER_INSTALLED]?: boolean;\n\t[ORIGINAL_EMIT_WARNING]?: typeof process.emitWarning;\n};\n\nexport function should_suppress_warning(warning: Error): boolean {\n\treturn (\n\t\twarning.name === 'ExperimentalWarning' &&\n\t\twarning.message.includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nfunction should_suppress_emit_warning_args(args: unknown[]): boolean {\n\tconst [warning, options_or_type] = args;\n\tif (warning instanceof Error)\n\t\treturn should_suppress_warning(warning);\n\tconst warning_type =\n\t\ttypeof options_or_type === 'string'\n\t\t\t? options_or_type\n\t\t\t: options_or_type && typeof options_or_type === 'object'\n\t\t\t\t? (options_or_type as { type?: unknown }).type\n\t\t\t\t: undefined;\n\treturn (\n\t\twarning_type === 'ExperimentalWarning' &&\n\t\tString(warning).includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nexport function install_sqlite_warning_filter(\n\tprocess_like: WarningEmitter = process,\n): void {\n\tif (process_like[FILTER_INSTALLED]) return;\n\tprocess_like[FILTER_INSTALLED] = true;\n\n\tconst original_emit_warning =\n\t\tprocess_like[ORIGINAL_EMIT_WARNING] ?? process_like.emitWarning;\n\tprocess_like[ORIGINAL_EMIT_WARNING] = original_emit_warning;\n\n\tprocess_like.emitWarning = function emit_filtered_warning(\n\t\tthis: WarningEmitter,\n\t\t...args: unknown[]\n\t) {\n\t\tif (should_suppress_emit_warning_args(args)) return;\n\t\treturn (\n\t\t\toriginal_emit_warning as (...args: unknown[]) => void\n\t\t).apply(this, args);\n\t} as typeof process.emitWarning;\n}\n","#!/usr/bin/env node\n\nimport {\n\tdefineCommand,\n\trenderUsage,\n\trunMain,\n\ttype ArgsDef,\n\ttype CommandDef,\n} from 'citty';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n\tcreate_builtin_disable_cli_args,\n\tparse_extension_paths,\n\tparse_skill_allowlist,\n\tparse_thinking_level,\n\tparse_tool_allowlist,\n\tparse_tool_excludelist,\n\tresolve_builtin_extension_options,\n} from './cli-args.js';\nimport { install_sqlite_warning_filter } from './warnings.js';\n\ninstall_sqlite_warning_filter();\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst package_root = join(__dirname, '..');\nconst pkg = JSON.parse(\n\treadFileSync(join(package_root, 'package.json'), 'utf-8'),\n);\n\n// my-pi is a wrapper around Pi; upstream Pi update banners are useful in\n// this repo, but confusing for installed wrapper users.\nif (!existsSync(join(package_root, '.git'))) {\n\tprocess.env.PI_SKIP_VERSION_CHECK ??= '1';\n}\n\nasync function read_stdin(): Promise<string> {\n\tconst chunks: Buffer[] = [];\n\tfor await (const chunk of process.stdin) {\n\t\tchunks.push(chunk as Buffer);\n\t}\n\treturn Buffer.concat(chunks).toString('utf-8').trim();\n}\n\ntype MyPiRuntime = Awaited<\n\tReturnType<(typeof import('./api.js'))['create_my_pi']>\n>;\ntype InteractiveModeConstructor =\n\t(typeof import('@earendil-works/pi-coding-agent'))['InteractiveMode'];\n\nasync function run_interactive_mode(\n\truntime: MyPiRuntime,\n\tInteractiveModeClass: InteractiveModeConstructor,\n): Promise<void> {\n\tconst original_write = process.stdout.write.bind(process.stdout);\n\tprocess.stdout.write = ((\n\t\tchunk: string | Uint8Array,\n\t\t...args: Parameters<typeof original_write>\n\t) => {\n\t\tif (typeof chunk === 'string') {\n\t\t\tconst escape = String.fromCharCode(27);\n\t\t\tconst styled_hint = new RegExp(\n\t\t\t\t`(To resume this session:${escape}\\\\[[\\\\d;]*m )pi( --session )`,\n\t\t\t\t'g',\n\t\t\t);\n\t\t\tchunk = chunk.replace(styled_hint, '$1my-pi$2');\n\t\t\tchunk = chunk.replace(\n\t\t\t\t/(To resume this session: )pi( --session )/g,\n\t\t\t\t'$1my-pi$2',\n\t\t\t);\n\t\t}\n\t\treturn Reflect.apply(original_write, process.stdout, [\n\t\t\tchunk,\n\t\t\t...args,\n\t\t]);\n\t}) as typeof process.stdout.write;\n\ttry {\n\t\tconst mode = new InteractiveModeClass(runtime, {\n\t\t\tmigratedProviders: [],\n\t\t\tmodelFallbackMessage: undefined,\n\t\t\tinitialMessage: undefined,\n\t\t\tinitialImages: [],\n\t\t\tinitialMessages: [],\n\t\t});\n\t\tawait mode.run();\n\t} finally {\n\t\tprocess.stdout.write =\n\t\t\toriginal_write as typeof process.stdout.write;\n\t}\n}\n\nconst HELP_APPENDIX = `\nMODES\n\n my-pi\n Interactive TUI with slash commands, editor, and session UI.\n\n my-pi \"prompt\"\n my-pi -P \"prompt\"\n One-shot print mode with plain text output.\n\n my-pi --json \"prompt\"\n Non-interactive NDJSON mode for scripts, evals, and other agents.\n\n my-pi --mode rpc\n RPC mode over stdin/stdout JSONL for orchestrators and teammate sessions.\n\nNOTES\n\n - In non-interactive modes, my-pi keeps headless-capable built-ins like\n MCP, LSP, prompt presets, recall, nopeek, Omnisearch, SQLite tools, hooks, and secret redaction.\n - UI-only built-ins like session auto-naming are skipped.\n - Repeat -e / --extension to compose multiple extensions.\n\nNESTED RUNS\n\n - Child runs inherit cwd and environment unless you isolate them explicitly.\n - Use --agent-dir to isolate auth, config, sessions, and telemetry state.\n - For safer evals or unknown repos, use --untrusted plus an explicit\n --system-prompt.\n\nEXAMPLES\n\n my-pi\n my-pi \"fix the failing test\"\n my-pi -P \"summarize this repo\"\n my-pi --json \"list all TODO comments\"\n echo \"plan a login page\" | my-pi --json\n my-pi --telemetry --json \"run eval case\"\n my-pi --telemetry --telemetry-db ./tmp/evals.db --json \"run case\"\n my-pi observability\n my-pi --untrusted --agent-dir /tmp/pi-agent --json \"run case\"\n my-pi -e ./my-ext.ts -e ./other-ext.ts \"hello\"\n my-pi -m claude-haiku-4-5-20241022 \"explain this file\"\n XIAOMI_API_KEY=... my-pi -m xiaomi/mimo-v2.5-pro \"summarize this repo\"\n my-pi -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast \"explain this file\"\n my-pi --preset terse,no-purple-prose \"summarize this repo\"\n my-pi --system-prompt \"You are a JSON classifier. Return only JSON.\" --json \"classify this\"\n\nPROMPT PRESETS\n\n Interactive commands:\n /prompt-preset help\n /prompt-preset export-defaults\n /prompt-preset edit-global terse\n /prompt-preset base detailed\n /prompt-preset enable bullets\n\n Short alias: /preset\n\n Editable preset files:\n ~/.pi/agent/presets/*.md\n .pi/presets/*.md\n`;\n\nasync function render_rich_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<string> {\n\treturn `${await renderUsage(cmd, parent)}\\n${HELP_APPENDIX}`;\n}\n\nasync function print_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<void> {\n\tconsole.log(await render_rich_usage(cmd, parent));\n}\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'my-pi',\n\t\tversion: pkg.version,\n\t\tdescription:\n\t\t\t'Composable pi coding agent with MCP, LSP, presets, and local eval telemetry',\n\t},\n\targs: {\n\t\tprint: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'P',\n\t\t\tdescription: 'Print mode (non-interactive, one-shot)',\n\t\t\tdefault: false,\n\t\t},\n\t\t'agent-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi auth/config/session directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi session storage directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'j',\n\t\t\tdescription: 'Output NDJSON events (for agent consumption)',\n\t\t\tdefault: false,\n\t\t},\n\t\tmode: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Runtime mode: interactive, print, json, or rpc',\n\t\t\trequired: false,\n\t\t},\n\t\textension: {\n\t\t\ttype: 'string',\n\t\t\talias: 'e',\n\t\t\tdescription:\n\t\t\t\t'Extension path to load; repeatable via argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'no-builtin': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable all built-in extensions',\n\t\t\tdefault: false,\n\t\t},\n\t\tuntrusted: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription:\n\t\t\t\t'Safe mode for unknown repos: skip project MCP, hooks, project prompt presets, project skills, and project LSP binaries unless explicitly re-enabled',\n\t\t\tdefault: false,\n\t\t},\n\t\t...create_builtin_disable_cli_args(),\n\t\ttelemetry: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Enable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'no-telemetry': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'telemetry-db': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override telemetry database path for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tmodel: {\n\t\t\ttype: 'string',\n\t\t\talias: 'm',\n\t\t\tdescription:\n\t\t\t\t'Model to use (e.g. claude-sonnet-4-5-20241022, gpt-5.4, cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast)',\n\t\t},\n\t\tthinking: {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Thinking level: off, minimal, low, medium, high, or xhigh',\n\t\t\trequired: false,\n\t\t},\n\t\ttools: {\n\t\t\ttype: 'string',\n\t\t\talias: 't',\n\t\t\tdescription:\n\t\t\t\t'Comma-separated allowlist of tool names to enable',\n\t\t\trequired: false,\n\t\t},\n\t\t'exclude-tools': {\n\t\t\ttype: 'string',\n\t\t\talias: 'xt',\n\t\t\tdescription: 'Comma-separated list of tool names to disable',\n\t\t\trequired: false,\n\t\t},\n\t\tsession: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Resume a specific session file or session ID',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-id': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Create or resume an exact project-local session ID',\n\t\t\trequired: false,\n\t\t},\n\t\tname: {\n\t\t\ttype: 'string',\n\t\t\talias: 'n',\n\t\t\tdescription: 'Set the session display name at startup',\n\t\t\trequired: false,\n\t\t},\n\t\tskill: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Skill name to allow; repeatable in argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Replace the base system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\t'append-system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Append one-off instructions to the system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: 'string',\n\t\t\talias: 'p',\n\t\t\tdescription: 'Prompt text (alternative to positional argument)',\n\t\t\trequired: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst cwd = process.cwd();\n\t\tconst extension_paths = parse_extension_paths(process.argv, cwd);\n\t\tconst selected_tools = parse_tool_allowlist(process.argv);\n\t\tconst excluded_tools = parse_tool_excludelist(process.argv);\n\t\tconst selected_skills = parse_skill_allowlist(process.argv);\n\t\tlet selected_thinking;\n\t\ttry {\n\t\t\tselected_thinking = parse_thinking_level(args.thinking);\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet runtime_mode: 'interactive' | 'print' | 'json' | 'rpc' =\n\t\t\t'interactive';\n\t\tif (args.mode) {\n\t\t\tconst requested = String(args.mode).trim().toLowerCase();\n\t\t\tif (\n\t\t\t\t!['interactive', 'print', 'json', 'rpc'].includes(requested)\n\t\t\t) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Error: --mode must be one of interactive, print, json, rpc.',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\truntime_mode = requested as\n\t\t\t\t| 'interactive'\n\t\t\t\t| 'print'\n\t\t\t\t| 'json'\n\t\t\t\t| 'rpc';\n\t\t}\n\t\tif (args.json) runtime_mode = 'json';\n\t\telse if (args.print) runtime_mode = 'print';\n\n\t\tconst positionals = args._;\n\t\tif (positionals?.[0] === 'observability') {\n\t\t\tconst { start_observability_server } =\n\t\t\t\tawait import('@spences10/pi-observability/server');\n\t\t\tstart_observability_server();\n\t\t\treturn;\n\t\t}\n\n\t\t// Resolve prompt: named --prompt flag > positional > stdin\n\t\tlet prompt = args.prompt;\n\t\tif (!prompt && positionals && positionals.length > 0) {\n\t\t\tprompt = positionals[0];\n\t\t}\n\t\tif (!prompt && !process.stdin.isTTY && runtime_mode !== 'rpc') {\n\t\t\tprompt = await read_stdin();\n\t\t}\n\t\tif (prompt && runtime_mode === 'interactive')\n\t\t\truntime_mode = 'print';\n\n\t\tif (\n\t\t\t!args.print &&\n\t\t\t!args.json &&\n\t\t\truntime_mode !== 'rpc' &&\n\t\t\t!prompt &&\n\t\t\t!process.stdout.isTTY\n\t\t) {\n\t\t\tawait print_usage(main);\n\t\t\treturn;\n\t\t}\n\n\t\t// Startup feedback so silence = broken (issue #3)\n\t\tif (runtime_mode !== 'interactive') {\n\t\t\tprocess.stderr.write(\n\t\t\t\t`my-pi: connecting to ${args.model || 'default model'}...\\n`,\n\t\t\t);\n\t\t}\n\n\t\tif (args.telemetry && args['no-telemetry']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --telemetry and --no-telemetry cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (args.session && args['session-id']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --session and --session-id cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet telemetry_override: boolean | undefined;\n\t\tif (args.telemetry) {\n\t\t\ttelemetry_override = true;\n\t\t} else if (args['no-telemetry']) {\n\t\t\ttelemetry_override = false;\n\t\t}\n\n\t\tconst [\n\t\t\t{ create_my_pi },\n\t\t\t{ InteractiveMode, runPrintMode, runRpcMode },\n\t\t] = await Promise.all([\n\t\t\timport('./api.js'),\n\t\t\timport('@earendil-works/pi-coding-agent'),\n\t\t]);\n\n\t\tconst runtime = await create_my_pi({\n\t\t\tcwd,\n\t\t\tagent_dir: args['agent-dir'],\n\t\t\tsession_dir: args['session-dir'],\n\t\t\textensions: extension_paths,\n\t\t\truntime_mode,\n\t\t\t...resolve_builtin_extension_options(args),\n\t\t\ttelemetry: telemetry_override,\n\t\t\ttelemetry_db_path: args['telemetry-db'],\n\t\t\tmodel: args.model,\n\t\t\tthinking: selected_thinking,\n\t\t\tselected_tools,\n\t\t\texcluded_tools,\n\t\t\tselected_skills,\n\t\t\tsession: args.session,\n\t\t\tsession_id: args['session-id'],\n\t\t\tstartup_session_name: args.name,\n\t\t\tsystem_prompt: args['system-prompt'],\n\t\t\tappend_system_prompt: args['append-system-prompt'],\n\t\t\tuntrusted_repo: args.untrusted,\n\t\t});\n\n\t\tif (runtime_mode === 'rpc') {\n\t\t\tawait runRpcMode(runtime);\n\t\t} else if (args.print || args.json || prompt) {\n\t\t\tlet output_mode: 'json' | 'text' = 'text';\n\t\t\tif (args.json) {\n\t\t\t\toutput_mode = 'json';\n\t\t\t}\n\t\t\tconst code = await runPrintMode(runtime, {\n\t\t\t\tmode: output_mode,\n\t\t\t\tinitialMessage: prompt || '',\n\t\t\t\tinitialImages: [],\n\t\t\t\tmessages: [],\n\t\t\t});\n\t\t\tprocess.exit(code);\n\t\t} else if (!process.stdout.isTTY) {\n\t\t\tawait print_usage(main);\n\t\t} else {\n\t\t\tawait run_interactive_mode(runtime, InteractiveMode);\n\t\t}\n\t},\n});\n\nvoid runMain(main, {\n\tshowUsage: async (cmd, parent) => {\n\t\tawait print_usage(cmd, parent);\n\t},\n});\n"],"mappings":";;;;;;;AAMA,MAAM,kCAAkB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAmBD,SAA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gB,KAAA;GAChB,eAAe,CAAC;GAChB,iBAAiB,CAAC;EACnB,CACS,CAAC,CAAC,IAAI;CAChB,UAAU;EACT,QAAQ,OAAO,QACd;CACF;AACD;AAEA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEtB,eAAe,kBACd,KACA,QACkB;CAClB,OAAO,GAAG,MAAM,YAAY,KAAK,MAAM,EAAE,IAAI;AAC9C;AAEA,eAAe,YACd,KACA,QACgB;CAChB,QAAQ,IAAI,MAAM,kBAAkB,KAAK,MAAM,CAAC;AACjD;AAEA,MAAM,OAAO,cAAc;CAC1B,MAAM;EACL,MAAM;EACN,SAAS,IAAI;EACb,aACC;CACF;CACA,MAAM;EACL,OAAO;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,aAAa;GACZ,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,eAAe;GACd,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,MAAM;GACL,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,MAAM;GACL,MAAM;GACN,aAAa;GACb,UAAU;EACX;EACA,WAAW;GACV,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EACX;EACA,cAAc;GACb,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,WAAW;GACV,MAAM;GACN,aACC;GACD,SAAS;EACV;EACA,GAAG,gCAAgC;EACnC,WAAW;GACV,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;EACF;EACA,UAAU;GACT,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EACX;EACA,iBAAiB;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AI,cAA+B;GACnC,IAAI,KAAK,MACR,cAAc;GAEf,MAAM,OAAO,MAAM,aAAa,SAAS;IACxC,MAAM;IACN,gBAAgB,UAAU;IAC1B,eAAe,CAAC;IAChB,UAAU,CAAC;GACZ,CAAC;GACD,QAAQ,KAAK,IAAI;EAClB,OAAO,IAAI,CAAC,QAAQ,OAAO,OAC1B,MAAM,YAAY,IAAI;OAEtB,MAAM,qBAAqB,SAAS,eAAe;CAErD;AACD,CAAC;AAEI,QAAQ,MAAM,EAClB,WAAW,OAAO,KAAK,WAAW;CACjC,MAAM,YAAY,KAAK,MAAM;AAC9B,EACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/cli-args.ts","../src/runtime-preflight.ts","../src/warnings.ts","../src/index.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionOptionName,\n} from './extensions/builtin-registry.js';\n\nconst THINKING_LEVELS = new Set([\n\t'off',\n\t'minimal',\n\t'low',\n\t'medium',\n\t'high',\n\t'xhigh',\n]);\n\nexport type CliThinkingLevel =\n\t| 'off'\n\t| 'minimal'\n\t| 'low'\n\t| 'medium'\n\t| 'high'\n\t| 'xhigh';\n\nexport type BuiltinDisableCliArgs = Record<\n\tstring,\n\t{\n\t\ttype: 'boolean';\n\t\tdescription: string;\n\t\tdefault: false;\n\t}\n>;\n\nexport function create_builtin_disable_cli_args(): BuiltinDisableCliArgs {\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.cli_arg,\n\t\t\t{\n\t\t\t\ttype: 'boolean' as const,\n\t\t\t\tdescription: extension.cli_description,\n\t\t\t\tdefault: false as const,\n\t\t\t},\n\t\t]),\n\t);\n}\n\nfunction is_citty_no_flag_set(\n\targs: Record<string, unknown>,\n\tcli_arg: string,\n): boolean {\n\tif (args[cli_arg]) return true;\n\n\tconst positive_kebab = cli_arg.replace(/^no-/, '');\n\tconst positive_camel = positive_kebab.replace(\n\t\t/-([a-z])/g,\n\t\t(_, char) => String(char).toUpperCase(),\n\t);\n\treturn (\n\t\targs[positive_kebab] === false || args[positive_camel] === false\n\t);\n}\n\nexport function resolve_builtin_extension_options(\n\targs: Record<string, unknown>,\n): Partial<Record<BuiltinExtensionOptionName, boolean>> {\n\tconst no_builtin = is_citty_no_flag_set(args, 'no-builtin');\n\treturn Object.fromEntries(\n\t\tBUILTIN_EXTENSIONS.map((extension) => [\n\t\t\textension.option_name,\n\t\t\t!no_builtin && !is_citty_no_flag_set(args, extension.cli_arg),\n\t\t]),\n\t) as Partial<Record<BuiltinExtensionOptionName, boolean>>;\n}\n\nexport function collect_flag_values(\n\targv: string[],\n\tflags: readonly string[],\n): string[] {\n\tconst values: string[] = [];\n\tconst flag_set = new Set(flags);\n\n\tfor (let i = 0; i < argv.length; i++) {\n\t\tconst arg = argv[i];\n\t\tif (!arg) continue;\n\n\t\tconst equals_index = arg.indexOf('=');\n\t\tif (equals_index !== -1) {\n\t\t\tconst name = arg.slice(0, equals_index);\n\t\t\tif (flag_set.has(name)) {\n\t\t\t\tvalues.push(arg.slice(equals_index + 1));\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (flag_set.has(arg) && i + 1 < argv.length) {\n\t\t\tconst next = argv[i + 1];\n\t\t\tif (next !== undefined) {\n\t\t\t\tvalues.push(next);\n\t\t\t\ti += 1;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn values;\n}\n\nexport function parse_extension_paths(\n\targv: string[],\n\tcwd = process.cwd(),\n): string[] {\n\treturn collect_flag_values(argv, ['-e', '--extension'])\n\t\t.map((path) => path.trim())\n\t\t.filter(Boolean)\n\t\t.map((path) => resolve(cwd, path));\n}\n\nfunction parse_comma_list_flags(\n\targv: string[],\n\tflags: readonly string[],\n): string[] | undefined {\n\tconst values = collect_flag_values(argv, flags)\n\t\t.flatMap((value) => value.split(','))\n\t\t.map((value) => value.trim())\n\t\t.filter(Boolean);\n\treturn values.length ? [...new Set(values)] : undefined;\n}\n\nexport function parse_tool_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--tools', '-t']);\n}\n\nexport function parse_tool_excludelist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--exclude-tools', '-xt']);\n}\n\nexport function parse_skill_allowlist(\n\targv: string[],\n): string[] | undefined {\n\treturn parse_comma_list_flags(argv, ['--skill']);\n}\n\nexport function parse_thinking_level(\n\tvalue: string | undefined,\n): CliThinkingLevel | undefined {\n\tconst normalized = value?.trim().toLowerCase();\n\tif (!normalized) return undefined;\n\tif (!THINKING_LEVELS.has(normalized)) {\n\t\tthrow new Error(\n\t\t\t'--thinking must be one of: off, minimal, low, medium, high, xhigh.',\n\t\t);\n\t}\n\treturn normalized as CliThinkingLevel;\n}\n","export const MINIMUM_NODE_VERSION = '24.15.0';\n\nfunction parse_node_version(\n\tversion: string,\n): [number, number, number] | undefined {\n\tconst match = /^v?(\\d+)\\.(\\d+)\\.(\\d+)(?:[-+].*)?$/.exec(version);\n\tif (!match) return undefined;\n\treturn [Number(match[1]), Number(match[2]), Number(match[3])];\n}\n\nexport function is_supported_node_version(version: string): boolean {\n\tconst current = parse_node_version(version);\n\tconst minimum = parse_node_version(MINIMUM_NODE_VERSION);\n\tif (!current || !minimum) return false;\n\n\tfor (let index = 0; index < current.length; index++) {\n\t\tif (current[index] > minimum[index]) return true;\n\t\tif (current[index] < minimum[index]) return false;\n\t}\n\treturn true;\n}\n\nexport function get_node_preflight_error(\n\tcurrent_version = process.versions.node,\n): string | undefined {\n\tif (is_supported_node_version(current_version)) return undefined;\n\treturn `my-pi requires Node >=${MINIMUM_NODE_VERSION}; current version is ${current_version}. Upgrade Node and retry.`;\n}\n","const SQLITE_EXPERIMENTAL_WARNING =\n\t'SQLite is an experimental feature';\nconst FILTER_INSTALLED = Symbol.for(\n\t'my-pi.sqlite-warning-filter-installed',\n);\nconst ORIGINAL_EMIT_WARNING = Symbol.for(\n\t'my-pi.original-emit-warning',\n);\n\ntype WarningEmitter = Pick<typeof process, 'emitWarning'> & {\n\t[FILTER_INSTALLED]?: boolean;\n\t[ORIGINAL_EMIT_WARNING]?: typeof process.emitWarning;\n};\n\nexport function should_suppress_warning(warning: Error): boolean {\n\treturn (\n\t\twarning.name === 'ExperimentalWarning' &&\n\t\twarning.message.includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nfunction should_suppress_emit_warning_args(args: unknown[]): boolean {\n\tconst [warning, options_or_type] = args;\n\tif (warning instanceof Error)\n\t\treturn should_suppress_warning(warning);\n\tconst warning_type =\n\t\ttypeof options_or_type === 'string'\n\t\t\t? options_or_type\n\t\t\t: options_or_type && typeof options_or_type === 'object'\n\t\t\t\t? (options_or_type as { type?: unknown }).type\n\t\t\t\t: undefined;\n\treturn (\n\t\twarning_type === 'ExperimentalWarning' &&\n\t\tString(warning).includes(SQLITE_EXPERIMENTAL_WARNING)\n\t);\n}\n\nexport function install_sqlite_warning_filter(\n\tprocess_like: WarningEmitter = process,\n): void {\n\tif (process_like[FILTER_INSTALLED]) return;\n\tprocess_like[FILTER_INSTALLED] = true;\n\n\tconst original_emit_warning =\n\t\tprocess_like[ORIGINAL_EMIT_WARNING] ?? process_like.emitWarning;\n\tprocess_like[ORIGINAL_EMIT_WARNING] = original_emit_warning;\n\n\tprocess_like.emitWarning = function emit_filtered_warning(\n\t\tthis: WarningEmitter,\n\t\t...args: unknown[]\n\t) {\n\t\tif (should_suppress_emit_warning_args(args)) return;\n\t\treturn (\n\t\t\toriginal_emit_warning as (...args: unknown[]) => void\n\t\t).apply(this, args);\n\t} as typeof process.emitWarning;\n}\n","#!/usr/bin/env node\n\nimport {\n\tdefineCommand,\n\trenderUsage,\n\trunMain,\n\ttype ArgsDef,\n\ttype CommandDef,\n} from 'citty';\nimport { existsSync, readFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport {\n\tcreate_builtin_disable_cli_args,\n\tparse_extension_paths,\n\tparse_skill_allowlist,\n\tparse_thinking_level,\n\tparse_tool_allowlist,\n\tparse_tool_excludelist,\n\tresolve_builtin_extension_options,\n} from './cli-args.js';\nimport { get_node_preflight_error } from './runtime-preflight.js';\nimport { install_sqlite_warning_filter } from './warnings.js';\n\nconst node_preflight_error = get_node_preflight_error();\nif (node_preflight_error) {\n\tconsole.error(node_preflight_error);\n\tprocess.exit(1);\n}\n\ninstall_sqlite_warning_filter();\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\nconst package_root = join(__dirname, '..');\nconst pkg = JSON.parse(\n\treadFileSync(join(package_root, 'package.json'), 'utf-8'),\n);\n\n// my-pi is a wrapper around Pi; upstream Pi update banners are useful in\n// this repo, but confusing for installed wrapper users.\nif (!existsSync(join(package_root, '.git'))) {\n\tprocess.env.PI_SKIP_VERSION_CHECK ??= '1';\n}\n\nasync function read_stdin(): Promise<string> {\n\tconst chunks: Buffer[] = [];\n\tfor await (const chunk of process.stdin) {\n\t\tchunks.push(chunk as Buffer);\n\t}\n\treturn Buffer.concat(chunks).toString('utf-8').trim();\n}\n\ntype MyPiRuntime = Awaited<\n\tReturnType<(typeof import('./api.js'))['create_my_pi']>\n>;\ntype InteractiveModeConstructor =\n\t(typeof import('@earendil-works/pi-coding-agent'))['InteractiveMode'];\n\nasync function run_interactive_mode(\n\truntime: MyPiRuntime,\n\tInteractiveModeClass: InteractiveModeConstructor,\n): Promise<void> {\n\tconst original_write = process.stdout.write.bind(process.stdout);\n\tprocess.stdout.write = ((\n\t\tchunk: string | Uint8Array,\n\t\t...args: Parameters<typeof original_write>\n\t) => {\n\t\tif (typeof chunk === 'string') {\n\t\t\tconst escape = String.fromCharCode(27);\n\t\t\tconst styled_hint = new RegExp(\n\t\t\t\t`(To resume this session:${escape}\\\\[[\\\\d;]*m )pi( --session )`,\n\t\t\t\t'g',\n\t\t\t);\n\t\t\tchunk = chunk.replace(styled_hint, '$1my-pi$2');\n\t\t\tchunk = chunk.replace(\n\t\t\t\t/(To resume this session: )pi( --session )/g,\n\t\t\t\t'$1my-pi$2',\n\t\t\t);\n\t\t}\n\t\treturn Reflect.apply(original_write, process.stdout, [\n\t\t\tchunk,\n\t\t\t...args,\n\t\t]);\n\t}) as typeof process.stdout.write;\n\ttry {\n\t\tconst mode = new InteractiveModeClass(runtime, {\n\t\t\tmigratedProviders: [],\n\t\t\tmodelFallbackMessage: undefined,\n\t\t\tinitialMessage: undefined,\n\t\t\tinitialImages: [],\n\t\t\tinitialMessages: [],\n\t\t});\n\t\tawait mode.run();\n\t} finally {\n\t\tprocess.stdout.write =\n\t\t\toriginal_write as typeof process.stdout.write;\n\t}\n}\n\nconst HELP_APPENDIX = `\nMODES\n\n my-pi\n Interactive TUI with slash commands, editor, and session UI.\n\n my-pi \"prompt\"\n my-pi -P \"prompt\"\n One-shot print mode with plain text output.\n\n my-pi --json \"prompt\"\n Non-interactive NDJSON mode for scripts, evals, and other agents.\n\n my-pi --mode rpc\n RPC mode over stdin/stdout JSONL for orchestrators and teammate sessions.\n\nNOTES\n\n - In non-interactive modes, my-pi keeps headless-capable built-ins like\n MCP, LSP, prompt presets, recall, nopeek, Omnisearch, SQLite tools, hooks, and secret redaction.\n - UI-only built-ins like session auto-naming are skipped.\n - Repeat -e / --extension to compose multiple extensions.\n\nNESTED RUNS\n\n - Child runs inherit cwd and environment unless you isolate them explicitly.\n - Use --agent-dir to isolate auth, config, sessions, and telemetry state.\n - For safer evals or unknown repos, use --untrusted plus an explicit\n --system-prompt.\n\nEXAMPLES\n\n my-pi\n my-pi \"fix the failing test\"\n my-pi -P \"summarize this repo\"\n my-pi --json \"list all TODO comments\"\n echo \"plan a login page\" | my-pi --json\n my-pi --telemetry --json \"run eval case\"\n my-pi --telemetry --telemetry-db ./tmp/evals.db --json \"run case\"\n my-pi observability\n my-pi --untrusted --agent-dir /tmp/pi-agent --json \"run case\"\n my-pi -e ./my-ext.ts -e ./other-ext.ts \"hello\"\n my-pi -m claude-haiku-4-5-20241022 \"explain this file\"\n XIAOMI_API_KEY=... my-pi -m xiaomi/mimo-v2.5-pro \"summarize this repo\"\n my-pi -m cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast \"explain this file\"\n my-pi --preset terse,no-purple-prose \"summarize this repo\"\n my-pi --system-prompt \"You are a JSON classifier. Return only JSON.\" --json \"classify this\"\n\nPROMPT PRESETS\n\n Interactive commands:\n /prompt-preset help\n /prompt-preset export-defaults\n /prompt-preset edit-global terse\n /prompt-preset base detailed\n /prompt-preset enable bullets\n\n Short alias: /preset\n\n Editable preset files:\n ~/.pi/agent/presets/*.md\n .pi/presets/*.md\n`;\n\nasync function render_rich_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<string> {\n\treturn `${await renderUsage(cmd, parent)}\\n${HELP_APPENDIX}`;\n}\n\nasync function print_usage<T extends ArgsDef>(\n\tcmd: CommandDef<T>,\n\tparent?: CommandDef<T>,\n): Promise<void> {\n\tconsole.log(await render_rich_usage(cmd, parent));\n}\n\nconst main = defineCommand({\n\tmeta: {\n\t\tname: 'my-pi',\n\t\tversion: pkg.version,\n\t\tdescription:\n\t\t\t'Composable pi coding agent with MCP, LSP, presets, and local eval telemetry',\n\t},\n\targs: {\n\t\tprint: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'P',\n\t\t\tdescription: 'Print mode (non-interactive, one-shot)',\n\t\t\tdefault: false,\n\t\t},\n\t\t'agent-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi auth/config/session directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-dir': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override Pi session storage directory for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tjson: {\n\t\t\ttype: 'boolean',\n\t\t\talias: 'j',\n\t\t\tdescription: 'Output NDJSON events (for agent consumption)',\n\t\t\tdefault: false,\n\t\t},\n\t\tmode: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Runtime mode: interactive, print, json, or rpc',\n\t\t\trequired: false,\n\t\t},\n\t\textension: {\n\t\t\ttype: 'string',\n\t\t\talias: 'e',\n\t\t\tdescription:\n\t\t\t\t'Extension path to load; repeatable via argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'no-builtin': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable all built-in extensions',\n\t\t\tdefault: false,\n\t\t},\n\t\tuntrusted: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription:\n\t\t\t\t'Safe mode for unknown repos: skip project MCP, hooks, project prompt presets, project skills, and project LSP binaries unless explicitly re-enabled',\n\t\t\tdefault: false,\n\t\t},\n\t\t...create_builtin_disable_cli_args(),\n\t\ttelemetry: {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Enable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'no-telemetry': {\n\t\t\ttype: 'boolean',\n\t\t\tdescription: 'Disable local SQLite telemetry for this process',\n\t\t\tdefault: false,\n\t\t},\n\t\t'telemetry-db': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Override telemetry database path for this process',\n\t\t\trequired: false,\n\t\t},\n\t\tmodel: {\n\t\t\ttype: 'string',\n\t\t\talias: 'm',\n\t\t\tdescription:\n\t\t\t\t'Model to use (e.g. claude-sonnet-4-5-20241022, gpt-5.4, cloudflare-workers-ai/@cf/meta/llama-3.3-70b-instruct-fp8-fast)',\n\t\t},\n\t\tthinking: {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Thinking level: off, minimal, low, medium, high, or xhigh',\n\t\t\trequired: false,\n\t\t},\n\t\ttools: {\n\t\t\ttype: 'string',\n\t\t\talias: 't',\n\t\t\tdescription:\n\t\t\t\t'Comma-separated allowlist of tool names to enable',\n\t\t\trequired: false,\n\t\t},\n\t\t'exclude-tools': {\n\t\t\ttype: 'string',\n\t\t\talias: 'xt',\n\t\t\tdescription: 'Comma-separated list of tool names to disable',\n\t\t\trequired: false,\n\t\t},\n\t\tsession: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Resume a specific session file or session ID',\n\t\t\trequired: false,\n\t\t},\n\t\t'session-id': {\n\t\t\ttype: 'string',\n\t\t\tdescription:\n\t\t\t\t'Create or resume an exact project-local session ID',\n\t\t\trequired: false,\n\t\t},\n\t\tname: {\n\t\t\ttype: 'string',\n\t\t\talias: 'n',\n\t\t\tdescription: 'Set the session display name at startup',\n\t\t\trequired: false,\n\t\t},\n\t\tskill: {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Skill name to allow; repeatable in argv parsing',\n\t\t\trequired: false,\n\t\t},\n\t\t'system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Replace the base system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\t'append-system-prompt': {\n\t\t\ttype: 'string',\n\t\t\tdescription: 'Append one-off instructions to the system prompt',\n\t\t\trequired: false,\n\t\t},\n\t\tprompt: {\n\t\t\ttype: 'string',\n\t\t\talias: 'p',\n\t\t\tdescription: 'Prompt text (alternative to positional argument)',\n\t\t\trequired: false,\n\t\t},\n\t},\n\tasync run({ args }) {\n\t\tconst cwd = process.cwd();\n\t\tconst extension_paths = parse_extension_paths(process.argv, cwd);\n\t\tconst selected_tools = parse_tool_allowlist(process.argv);\n\t\tconst excluded_tools = parse_tool_excludelist(process.argv);\n\t\tconst selected_skills = parse_skill_allowlist(process.argv);\n\t\tlet selected_thinking;\n\t\ttry {\n\t\t\tselected_thinking = parse_thinking_level(args.thinking);\n\t\t} catch (error) {\n\t\t\tconsole.error(\n\t\t\t\terror instanceof Error ? error.message : String(error),\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet runtime_mode: 'interactive' | 'print' | 'json' | 'rpc' =\n\t\t\t'interactive';\n\t\tif (args.mode) {\n\t\t\tconst requested = String(args.mode).trim().toLowerCase();\n\t\t\tif (\n\t\t\t\t!['interactive', 'print', 'json', 'rpc'].includes(requested)\n\t\t\t) {\n\t\t\t\tconsole.error(\n\t\t\t\t\t'Error: --mode must be one of interactive, print, json, rpc.',\n\t\t\t\t);\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\t\t\truntime_mode = requested as\n\t\t\t\t| 'interactive'\n\t\t\t\t| 'print'\n\t\t\t\t| 'json'\n\t\t\t\t| 'rpc';\n\t\t}\n\t\tif (args.json) runtime_mode = 'json';\n\t\telse if (args.print) runtime_mode = 'print';\n\n\t\tconst positionals = args._;\n\t\tif (positionals?.[0] === 'observability') {\n\t\t\tconst { start_observability_server } =\n\t\t\t\tawait import('@spences10/pi-observability/server');\n\t\t\tstart_observability_server();\n\t\t\treturn;\n\t\t}\n\n\t\t// Resolve prompt: named --prompt flag > positional > stdin\n\t\tlet prompt = args.prompt;\n\t\tif (!prompt && positionals && positionals.length > 0) {\n\t\t\tprompt = positionals[0];\n\t\t}\n\t\tif (!prompt && !process.stdin.isTTY && runtime_mode !== 'rpc') {\n\t\t\tprompt = await read_stdin();\n\t\t}\n\t\tif (prompt && runtime_mode === 'interactive')\n\t\t\truntime_mode = 'print';\n\n\t\tif (\n\t\t\t!args.print &&\n\t\t\t!args.json &&\n\t\t\truntime_mode !== 'rpc' &&\n\t\t\t!prompt &&\n\t\t\t!process.stdout.isTTY\n\t\t) {\n\t\t\tawait print_usage(main);\n\t\t\treturn;\n\t\t}\n\n\t\t// Startup feedback so silence = broken (issue #3)\n\t\tif (runtime_mode !== 'interactive') {\n\t\t\tprocess.stderr.write(\n\t\t\t\t`my-pi: connecting to ${args.model || 'default model'}...\\n`,\n\t\t\t);\n\t\t}\n\n\t\tif (args.telemetry && args['no-telemetry']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --telemetry and --no-telemetry cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\t\tif (args.session && args['session-id']) {\n\t\t\tconsole.error(\n\t\t\t\t'Error: --session and --session-id cannot be used together.',\n\t\t\t);\n\t\t\tprocess.exit(1);\n\t\t}\n\n\t\tlet telemetry_override: boolean | undefined;\n\t\tif (args.telemetry) {\n\t\t\ttelemetry_override = true;\n\t\t} else if (args['no-telemetry']) {\n\t\t\ttelemetry_override = false;\n\t\t}\n\n\t\tconst [\n\t\t\t{ create_my_pi },\n\t\t\t{ InteractiveMode, runPrintMode, runRpcMode },\n\t\t] = await Promise.all([\n\t\t\timport('./api.js'),\n\t\t\timport('@earendil-works/pi-coding-agent'),\n\t\t]);\n\n\t\tconst runtime = await create_my_pi({\n\t\t\tcwd,\n\t\t\tagent_dir: args['agent-dir'],\n\t\t\tsession_dir: args['session-dir'],\n\t\t\textensions: extension_paths,\n\t\t\truntime_mode,\n\t\t\t...resolve_builtin_extension_options(args),\n\t\t\ttelemetry: telemetry_override,\n\t\t\ttelemetry_db_path: args['telemetry-db'],\n\t\t\tmodel: args.model,\n\t\t\tthinking: selected_thinking,\n\t\t\tselected_tools,\n\t\t\texcluded_tools,\n\t\t\tselected_skills,\n\t\t\tsession: args.session,\n\t\t\tsession_id: args['session-id'],\n\t\t\tstartup_session_name: args.name,\n\t\t\tsystem_prompt: args['system-prompt'],\n\t\t\tappend_system_prompt: args['append-system-prompt'],\n\t\t\tuntrusted_repo: args.untrusted,\n\t\t});\n\n\t\tif (runtime_mode === 'rpc') {\n\t\t\tawait runRpcMode(runtime);\n\t\t} else if (args.print || args.json || prompt) {\n\t\t\tlet output_mode: 'json' | 'text' = 'text';\n\t\t\tif (args.json) {\n\t\t\t\toutput_mode = 'json';\n\t\t\t}\n\t\t\tconst code = await runPrintMode(runtime, {\n\t\t\t\tmode: output_mode,\n\t\t\t\tinitialMessage: prompt || '',\n\t\t\t\tinitialImages: [],\n\t\t\t\tmessages: [],\n\t\t\t});\n\t\t\tprocess.exit(code);\n\t\t} else if (!process.stdout.isTTY) {\n\t\t\tawait print_usage(main);\n\t\t} else {\n\t\t\tawait run_interactive_mode(runtime, InteractiveMode);\n\t\t}\n\t},\n});\n\nvoid runMain(main, {\n\tshowUsage: async (cmd, parent) => {\n\t\tawait print_usage(cmd, parent);\n\t},\n});\n"],"mappings":";;;;;;;AAMA,MAAM,kCAAkB,IAAI,IAAI;CAC/B;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;AAmBD,SAAgB,kCAAyD;CACxE,OAAO,OAAO,YACb,mBAAmB,KAAK,cAAc,CACrC,UAAU,SACV;EACC,MAAM;EACN,aAAa,UAAU;EACvB,SAAS;CACV,CACD,CAAC,CACF;AACD;AAEA,SAAS,qBACR,MACA,SACU;CACV,IAAI,KAAK,UAAU,OAAO;CAE1B,MAAM,iBAAiB,QAAQ,QAAQ,QAAQ,EAAE;CACjD,MAAM,iBAAiB,eAAe,QACrC,cACC,GAAG,SAAS,OAAO,IAAI,CAAC,CAAC,YAAY,CACvC;CACA,OACC,KAAK,oBAAoB,SAAS,KAAK,oBAAoB;AAE7D;AAEA,SAAgB,kCACf,MACuD;CACvD,MAAM,aAAa,qBAAqB,MAAM,YAAY;CAC1D,OAAO,OAAO,YACb,mBAAmB,KAAK,cAAc,CACrC,UAAU,aACV,CAAC,cAAc,CAAC,qBAAqB,MAAM,UAAU,OAAO,CAC7D,CAAC,CACF;AACD;AAEA,SAAgB,oBACf,MACA,OACW;CACX,MAAM,SAAmB,CAAC;CAC1B,MAAM,WAAW,IAAI,IAAI,KAAK;CAE9B,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;EACrC,MAAM,MAAM,KAAK;EACjB,IAAI,CAAC,KAAK;EAEV,MAAM,eAAe,IAAI,QAAQ,GAAG;EACpC,IAAI,iBAAiB,IAAI;GACxB,MAAM,OAAO,IAAI,MAAM,GAAG,YAAY;GACtC,IAAI,SAAS,IAAI,IAAI,GACpB,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC,CAAC;GAExC;EACD;EAEA,IAAI,SAAS,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,QA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kBACd,KACA,QACkB;CAClB,OAAO,GAAG,MAAM,YAAY,KAAK,MAAM,EAAE,IAAI;AAC9C;AAEA,eAAe,YACd,KACA,QACgB;CAChB,QAAQ,IAAI,MAAM,kBAAkB,KAAK,MAAM,CAAC;AACjD;AAEA,MAAM,OAAO,cAAc;CAC1B,MAAM;EACL,MAAM;EACN,SAAS,IAAI;EACb,aACC;CACF;CACA,MAAM;EACL,OAAO;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,aAAa;GACZ,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,eAAe;GACd,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,MAAM;GACL,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS;EACV;EACA,MAAM;GACL,MAAM;GACN,aAAa;GACb,UAAU;EACX;EACA,WAAW;GACV,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EACX;EACA,cAAc;GACb,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,WAAW;GACV,MAAM;GACN,aACC;GACD,SAAS;EACV;EACA,GAAG,gCAAgC;EACnC,WAAW;GACV,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aAAa;GACb,SAAS;EACV;EACA,gBAAgB;GACf,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;EACF;EACA,UAAU;GACT,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,OAAO;GACP,aACC;GACD,UAAU;EACX;EACA,iBAAiB;GAChB,MAAM;GACN,OAAO;GACP,aAAa;GACb,UAAU;EACX;EACA,SAAS;GACR,MAAM;GACN,aAAa;GACb,UAAU;EACX;EACA,cAAc;GACb,MAAM;GACN,aACC;GACD,UAAU;EACX;EACA,MAAM;GACL,MAAM;GACN,OAAO;GACP,aAAa;GACb,UAAU;EACX;EACA,OAAO;GACN,MAAM;GACN,a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YAAY,IAAI;OAEtB,MAAM,qBAAqB,SAAS,eAAe;CAErD;AACD,CAAC;AAEI,QAAQ,MAAM,EAClB,WAAW,OAAO,KAAK,WAAW;CACjC,MAAM,YAAY,KAAK,MAAM;AAC9B,EACD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.117",
|
|
4
4
|
"description": "Composable pi coding agent with MCP, LSP, prompt presets, and local eval telemetry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@earendil-works/pi-ai": "0.80.
|
|
47
|
-
"@earendil-works/pi-coding-agent": "0.80.
|
|
48
|
-
"@earendil-works/pi-tui": "0.80.
|
|
46
|
+
"@earendil-works/pi-ai": "0.80.10",
|
|
47
|
+
"@earendil-works/pi-coding-agent": "0.80.10",
|
|
48
|
+
"@earendil-works/pi-tui": "0.80.10",
|
|
49
49
|
"citty": "^0.2.2",
|
|
50
|
-
"@spences10/pi-
|
|
51
|
-
"@spences10/pi-project-trust": "0.0.16",
|
|
50
|
+
"@spences10/pi-project-trust": "0.0.18",
|
|
52
51
|
"@spences10/pi-settings": "0.0.2",
|
|
53
|
-
"@spences10/pi-tui-modal": "0.0.
|
|
52
|
+
"@spences10/pi-tui-modal": "0.0.24",
|
|
53
|
+
"@spences10/pi-themes": "0.0.10"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@changesets/cli": "^2.31.0",
|
|
@@ -61,28 +61,28 @@
|
|
|
61
61
|
"vitest": "4.1.10"
|
|
62
62
|
},
|
|
63
63
|
"optionalDependencies": {
|
|
64
|
-
"@spences10/pi-child-env": "0.1.
|
|
65
|
-
"@spences10/pi-coding-preferences": "0.0.13",
|
|
64
|
+
"@spences10/pi-child-env": "0.1.9",
|
|
66
65
|
"@spences10/pi-codex-usage": "0.0.1",
|
|
67
|
-
"@spences10/pi-
|
|
68
|
-
"@spences10/pi-
|
|
69
|
-
"@spences10/pi-
|
|
70
|
-
"@spences10/pi-
|
|
71
|
-
"@spences10/pi-
|
|
72
|
-
"@spences10/pi-harness": "0.0.
|
|
73
|
-
"@spences10/pi-
|
|
74
|
-
"@spences10/pi-mcp": "0.0.
|
|
75
|
-
"@spences10/pi-
|
|
76
|
-
"@spences10/pi-
|
|
77
|
-
"@spences10/pi-observability": "0.0.
|
|
78
|
-
"@spences10/pi-
|
|
79
|
-
"@spences10/pi-
|
|
80
|
-
"@spences10/pi-
|
|
81
|
-
"@spences10/pi-
|
|
82
|
-
"@spences10/pi-
|
|
83
|
-
"@spences10/pi-
|
|
84
|
-
"@spences10/pi-
|
|
85
|
-
"@spences10/pi-team-mode": "0.0.
|
|
66
|
+
"@spences10/pi-confirm-destructive": "0.0.20",
|
|
67
|
+
"@spences10/pi-context": "0.1.11",
|
|
68
|
+
"@spences10/pi-coding-preferences": "0.0.14",
|
|
69
|
+
"@spences10/pi-factory": "0.0.7",
|
|
70
|
+
"@spences10/pi-footer": "0.0.14",
|
|
71
|
+
"@spences10/pi-harness": "0.0.7",
|
|
72
|
+
"@spences10/pi-git-ui": "0.0.16",
|
|
73
|
+
"@spences10/pi-mcp": "0.0.53",
|
|
74
|
+
"@spences10/pi-lsp": "0.0.41",
|
|
75
|
+
"@spences10/pi-nopeek": "0.0.15",
|
|
76
|
+
"@spences10/pi-observability": "0.0.21",
|
|
77
|
+
"@spences10/pi-omnisearch": "0.0.15",
|
|
78
|
+
"@spences10/pi-recall": "0.0.16",
|
|
79
|
+
"@spences10/pi-redact": "0.0.14",
|
|
80
|
+
"@spences10/pi-skill-importer": "0.0.13",
|
|
81
|
+
"@spences10/pi-skills": "0.0.35",
|
|
82
|
+
"@spences10/pi-sqlite-tools": "0.0.15",
|
|
83
|
+
"@spences10/pi-svelte-guardrails": "0.0.15",
|
|
84
|
+
"@spences10/pi-team-mode": "0.0.52",
|
|
85
|
+
"@spences10/pi-telemetry": "0.0.31"
|
|
86
86
|
},
|
|
87
87
|
"engines": {
|
|
88
88
|
"node": ">=24.15.0"
|
|
@@ -91,7 +91,10 @@
|
|
|
91
91
|
"build": "pnpm --filter \"./packages/*\" run build:self && vp pack",
|
|
92
92
|
"dev": "vp pack --watch",
|
|
93
93
|
"start": "node ./dist/index.js",
|
|
94
|
-
"
|
|
94
|
+
"docs:sync": "node tools/sync-package-readmes.ts --write",
|
|
95
|
+
"docs:links": "node tools/check-markdown-links.ts",
|
|
96
|
+
"docs:check": "node tools/sync-package-readmes.ts && pnpm run docs:links",
|
|
97
|
+
"check": "pnpm run docs:check && pnpm --filter \"./packages/*\" run build:self && vp check && pnpm run check:boundaries && pnpm --filter \"./packages/*\" run check:self",
|
|
95
98
|
"check:boundaries": "node tools/check-boundaries.ts",
|
|
96
99
|
"check:fix": "vp check --fix",
|
|
97
100
|
"format": "vp check --fix",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-resolution-Ct3OPm5A.js","names":["create_child_process_env","create_shared_child_process_env","create_child_process_env","HOOKS_CONFIG_ENV"],"sources":["../src/extensions/hooks-resolution/config.ts","../src/extensions/hooks-resolution/payload.ts","../src/extensions/hooks-resolution/env.ts","../src/extensions/hooks-resolution/runner.ts","../src/extensions/hooks-resolution/trust.ts","../src/extensions/hooks-resolution/trust-gate.ts","../src/extensions/hooks-resolution/index.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { dirname, join, resolve } from 'node:path';\nimport type {\n\tHookEventName,\n\tHooksConfigInfo,\n\tHookState,\n\tJsonValue,\n\tResolvedCommandHook,\n} from './types.js';\n\nexport function is_file(path: string): boolean {\n\ttry {\n\t\treturn statSync(path).isFile();\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function as_record(\n\tvalue: unknown,\n): Record<string, unknown> | undefined {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\treturn value as Record<string, unknown>;\n}\n\nexport function walk_up_directories(\n\tstart_dir: string,\n\tstop_dir?: string,\n): string[] {\n\tconst directories: string[] = [];\n\tconst has_stop_dir = stop_dir !== undefined;\n\tlet current = resolve(start_dir);\n\tlet parent = dirname(current);\n\tlet reached_stop_dir = has_stop_dir && current === stop_dir;\n\tlet reached_filesystem_root = parent === current;\n\n\tdirectories.push(current);\n\twhile (!reached_stop_dir && !reached_filesystem_root) {\n\t\tcurrent = parent;\n\t\tparent = dirname(current);\n\t\treached_stop_dir = has_stop_dir && current === stop_dir;\n\t\treached_filesystem_root = parent === current;\n\t\tdirectories.push(current);\n\t}\n\n\treturn directories;\n}\n\nexport function find_nearest_git_root(\n\tstart_dir: string,\n): string | undefined {\n\tfor (const directory of walk_up_directories(start_dir)) {\n\t\tif (existsSync(join(directory, '.git'))) {\n\t\t\treturn directory;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function has_hooks_config(directory: string): boolean {\n\treturn (\n\t\tis_file(join(directory, '.claude', 'settings.json')) ||\n\t\tis_file(join(directory, '.rulesync', 'hooks.json')) ||\n\t\tis_file(join(directory, '.pi', 'hooks.json'))\n\t);\n}\n\nexport function find_project_dir(cwd: string): string {\n\tconst git_root = find_nearest_git_root(cwd);\n\tfor (const directory of walk_up_directories(cwd, git_root)) {\n\t\tif (has_hooks_config(directory)) {\n\t\t\treturn directory;\n\t\t}\n\t}\n\treturn git_root ?? resolve(cwd);\n}\n\nexport function read_json_file(path: string): JsonValue | undefined {\n\tif (!is_file(path)) return undefined;\n\ttry {\n\t\treturn JSON.parse(readFileSync(path, 'utf8')) as JsonValue;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function resolve_hook_command(\n\tcommand: string,\n\tproject_dir: string,\n): string {\n\treturn command.replace(/\\$CLAUDE_PROJECT_DIR\\b/g, project_dir);\n}\n\nexport function compile_matcher(\n\tmatcher_text: string | undefined,\n): RegExp | undefined {\n\tif (matcher_text === undefined) return undefined;\n\ttry {\n\t\treturn new RegExp(matcher_text);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function create_hook(\n\tevent_name: HookEventName,\n\tmatcher_text: string | undefined,\n\tcommand: string,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook | undefined {\n\tconst matcher = compile_matcher(matcher_text);\n\tif (matcher_text !== undefined && matcher === undefined)\n\t\treturn undefined;\n\treturn {\n\t\tevent_name,\n\t\tmatcher,\n\t\tmatcher_text,\n\t\tcommand: resolve_hook_command(command, project_dir),\n\t\tsource,\n\t};\n}\n\nexport function get_hook_entries(\n\thooks_record: Record<string, unknown>,\n\tevent_name: HookEventName,\n): unknown[] {\n\tconst keys =\n\t\tevent_name === 'PreToolUse'\n\t\t\t? ['PreToolUse', 'preToolUse']\n\t\t\t: event_name === 'PostToolUse'\n\t\t\t\t? ['PostToolUse', 'postToolUse']\n\t\t\t\t: ['PostToolUseFailure', 'postToolUseFailure'];\n\n\tfor (const key of keys) {\n\t\tconst value = hooks_record[key];\n\t\tif (Array.isArray(value)) return value;\n\t}\n\treturn [];\n}\n\nexport function parse_claude_settings_hooks(\n\tconfig: unknown,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst root = as_record(config);\n\tconst hooks_root = root ? as_record(root.hooks) : undefined;\n\tif (!hooks_root) return [];\n\n\tconst hooks: ResolvedCommandHook[] = [];\n\tconst events: HookEventName[] = [\n\t\t'PreToolUse',\n\t\t'PostToolUse',\n\t\t'PostToolUseFailure',\n\t];\n\n\tfor (const event_name of events) {\n\t\tconst entries = get_hook_entries(hooks_root, event_name);\n\t\tfor (const entry of entries) {\n\t\t\tconst entry_record = as_record(entry);\n\t\t\tif (!entry_record || !Array.isArray(entry_record.hooks))\n\t\t\t\tcontinue;\n\n\t\t\tconst matcher_text =\n\t\t\t\ttypeof entry_record.matcher === 'string'\n\t\t\t\t\t? entry_record.matcher\n\t\t\t\t\t: undefined;\n\t\t\tfor (const nested_hook of entry_record.hooks) {\n\t\t\t\tconst nested_record = as_record(nested_hook);\n\t\t\t\tif (!nested_record) continue;\n\t\t\t\tif (nested_record.type !== 'command') continue;\n\t\t\t\tif (typeof nested_record.command !== 'string') continue;\n\n\t\t\t\tconst hook = create_hook(\n\t\t\t\t\tevent_name,\n\t\t\t\t\tmatcher_text,\n\t\t\t\t\tnested_record.command,\n\t\t\t\t\tsource,\n\t\t\t\t\tproject_dir,\n\t\t\t\t);\n\t\t\t\tif (hook) hooks.push(hook);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn hooks;\n}\n\nexport function parse_simple_hooks_file(\n\tconfig: unknown,\n\tsource: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst root = as_record(config);\n\tconst hooks_root = root ? as_record(root.hooks) : undefined;\n\tif (!hooks_root) return [];\n\n\tconst hooks: ResolvedCommandHook[] = [];\n\tconst events: HookEventName[] = [\n\t\t'PreToolUse',\n\t\t'PostToolUse',\n\t\t'PostToolUseFailure',\n\t];\n\n\tfor (const event_name of events) {\n\t\tconst entries = get_hook_entries(hooks_root, event_name);\n\t\tfor (const entry of entries) {\n\t\t\tconst entry_record = as_record(entry);\n\t\t\tif (!entry_record || typeof entry_record.command !== 'string') {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst matcher_text =\n\t\t\t\ttypeof entry_record.matcher === 'string'\n\t\t\t\t\t? entry_record.matcher\n\t\t\t\t\t: undefined;\n\t\t\tconst hook = create_hook(\n\t\t\t\tevent_name,\n\t\t\t\tmatcher_text,\n\t\t\t\tentry_record.command,\n\t\t\t\tsource,\n\t\t\t\tproject_dir,\n\t\t\t);\n\t\t\tif (hook) hooks.push(hook);\n\t\t}\n\t}\n\n\treturn hooks;\n}\n\nfunction hook_config_paths(project_dir: string): string[] {\n\treturn [\n\t\tjoin(project_dir, '.claude', 'settings.json'),\n\t\tjoin(project_dir, '.rulesync', 'hooks.json'),\n\t\tjoin(project_dir, '.pi', 'hooks.json'),\n\t];\n}\n\nfunction parse_hooks_config_file(\n\tpath: string,\n\tproject_dir: string,\n): ResolvedCommandHook[] {\n\tconst config = read_json_file(path);\n\tif (config === undefined) return [];\n\tif (path.endsWith(join('.claude', 'settings.json'))) {\n\t\treturn parse_claude_settings_hooks(config, path, project_dir);\n\t}\n\treturn parse_simple_hooks_file(config, path, project_dir);\n}\n\nexport function load_hooks(cwd: string): HookState {\n\tconst project_dir = find_project_dir(cwd);\n\tconst hooks = hook_config_paths(project_dir).flatMap((path) =>\n\t\tparse_hooks_config_file(path, project_dir),\n\t);\n\n\treturn { project_dir, hooks };\n}\n\nexport function get_hooks_config_info(\n\tcwd: string,\n): HooksConfigInfo | undefined {\n\tconst project_dir = find_project_dir(cwd);\n\tconst sources = hook_config_paths(project_dir).filter(is_file);\n\tif (sources.length === 0) return undefined;\n\n\tconst hash = createHash('sha256');\n\tfor (const source of sources) {\n\t\thash.update(source);\n\t\thash.update('\\0');\n\t\thash.update(readFileSync(source, 'utf8'));\n\t\thash.update('\\0');\n\t}\n\n\tconst hooks = sources\n\t\t.flatMap((source) => parse_hooks_config_file(source, project_dir))\n\t\t.map((hook) => ({\n\t\t\tevent_name: hook.event_name,\n\t\t\tmatcher_text: hook.matcher_text,\n\t\t\tcommand: hook.command,\n\t\t\tsource: hook.source,\n\t\t}));\n\n\treturn {\n\t\tproject_dir,\n\t\thash: hash.digest('hex'),\n\t\tsources,\n\t\thooks,\n\t};\n}\n","import type {\n\tExtensionContext,\n\tToolCallEvent,\n\tToolResultEvent,\n} from '@earendil-works/pi-coding-agent';\nimport type { HookEventName, ResolvedCommandHook } from './types.js';\n\nexport function to_claude_tool_name(tool_name: string): string {\n\tif (tool_name === 'ls') return 'LS';\n\tif (tool_name.length === 0) return tool_name;\n\treturn tool_name[0].toUpperCase() + tool_name.slice(1);\n}\n\nexport function matches_hook(\n\thook: ResolvedCommandHook,\n\ttool_name: string,\n): boolean {\n\tif (!hook.matcher) return true;\n\n\tconst claude_tool_name = to_claude_tool_name(tool_name);\n\thook.matcher.lastIndex = 0;\n\tif (hook.matcher.test(tool_name)) return true;\n\n\thook.matcher.lastIndex = 0;\n\treturn hook.matcher.test(claude_tool_name);\n}\n\nexport function extract_text_content(content: unknown): string {\n\tif (!Array.isArray(content)) return '';\n\n\tconst parts: string[] = [];\n\tfor (const item of content) {\n\t\tif (!item || typeof item !== 'object') continue;\n\t\tconst item_record = item as Record<string, unknown>;\n\t\tif (\n\t\t\titem_record.type === 'text' &&\n\t\t\ttypeof item_record.text === 'string'\n\t\t) {\n\t\t\tparts.push(item_record.text);\n\t\t}\n\t}\n\n\treturn parts.join('\\n');\n}\n\nexport function normalize_tool_input(\n\tinput: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst normalized: Record<string, unknown> = { ...input };\n\tconst path_value =\n\t\ttypeof input.path === 'string' ? input.path : undefined;\n\tif (path_value !== undefined) {\n\t\tnormalized.file_path = path_value;\n\t\tnormalized.filePath = path_value;\n\t}\n\treturn normalized;\n}\n\nexport function build_tool_response(\n\tevent: ToolResultEvent,\n\tnormalized_input: Record<string, unknown>,\n): Record<string, unknown> {\n\tconst response: Record<string, unknown> = {\n\t\tis_error: event.isError,\n\t\tisError: event.isError,\n\t\tcontent: event.content,\n\t\ttext: extract_text_content(event.content),\n\t\tdetails: event.details ?? null,\n\t};\n\n\tconst file_path =\n\t\ttypeof normalized_input.file_path === 'string'\n\t\t\t? normalized_input.file_path\n\t\t\t: undefined;\n\tif (file_path !== undefined) {\n\t\tresponse.file_path = file_path;\n\t\tresponse.filePath = file_path;\n\t}\n\n\treturn response;\n}\n\nexport function build_hook_payload(\n\tevent: ToolCallEvent | ToolResultEvent,\n\tevent_name: HookEventName,\n\tctx: ExtensionContext,\n\tproject_dir: string,\n): Record<string, unknown> {\n\tconst normalized_input = normalize_tool_input(\n\t\tevent.input as Record<string, unknown>,\n\t);\n\tconst session_id =\n\t\tctx.sessionManager.getSessionFile() ?? 'ephemeral';\n\tconst payload: Record<string, unknown> = {\n\t\tsession_id,\n\t\tcwd: ctx.cwd,\n\t\tclaude_project_dir: project_dir,\n\t\thook_event_name: event_name,\n\t\ttool_name: to_claude_tool_name(event.toolName),\n\t\ttool_call_id: event.toolCallId,\n\t\ttool_input: normalized_input,\n\t};\n\n\tif ('content' in event) {\n\t\tpayload.tool_response = build_tool_response(\n\t\t\tevent,\n\t\t\tnormalized_input,\n\t\t);\n\t}\n\n\treturn payload;\n}\n","import { create_child_process_env as create_shared_child_process_env } from '@spences10/pi-child-env';\n\nexport function create_child_process_env(\n\texplicit_env: Record<string, string> = {},\n\tsource_env: NodeJS.ProcessEnv = process.env,\n): NodeJS.ProcessEnv {\n\treturn create_shared_child_process_env({\n\t\tprofile: 'hooks',\n\t\texplicit_env,\n\t\tsource_env,\n\t});\n}\n","import type { ToolResultEvent } from '@earendil-works/pi-coding-agent';\nimport { spawn } from 'node:child_process';\nimport { basename } from 'node:path';\nimport { as_record } from './config.js';\nimport { create_child_process_env } from './env.js';\nimport type { CommandRunResult, HookEventName } from './types.js';\n\nconst HOOK_TIMEOUT_MS = 10 * 60 * 1000;\n\nexport async function run_command_hook(\n\tcommand: string,\n\tcwd: string,\n\tpayload: Record<string, unknown>,\n): Promise<CommandRunResult> {\n\treturn await new Promise((resolve) => {\n\t\tconst started_at = Date.now();\n\t\tconst child = spawn('bash', ['-lc', command], {\n\t\t\tcwd,\n\t\t\tenv: create_child_process_env({ CLAUDE_PROJECT_DIR: cwd }),\n\t\t\tstdio: ['pipe', 'pipe', 'pipe'],\n\t\t});\n\n\t\tlet stdout = '';\n\t\tlet stderr = '';\n\t\tlet timed_out = false;\n\t\tlet resolved = false;\n\n\t\tconst finish = (code: number) => {\n\t\t\tif (resolved) return;\n\t\t\tresolved = true;\n\t\t\tresolve({\n\t\t\t\tcode,\n\t\t\t\tstdout,\n\t\t\t\tstderr,\n\t\t\t\telapsed_ms: Date.now() - started_at,\n\t\t\t\ttimed_out,\n\t\t\t});\n\t\t};\n\n\t\tconst timeout = setTimeout(() => {\n\t\t\ttimed_out = true;\n\t\t\tchild.kill('SIGTERM');\n\t\t\tconst kill_timer = setTimeout(() => {\n\t\t\t\tchild.kill('SIGKILL');\n\t\t\t}, 1000);\n\t\t\t(\n\t\t\t\tkill_timer as NodeJS.Timeout & { unref?: () => void }\n\t\t\t).unref?.();\n\t\t}, HOOK_TIMEOUT_MS);\n\t\t(timeout as NodeJS.Timeout & { unref?: () => void }).unref?.();\n\n\t\tchild.stdout.on('data', (chunk: Buffer) => {\n\t\t\tstdout += chunk.toString('utf8');\n\t\t});\n\t\tchild.stderr.on('data', (chunk: Buffer) => {\n\t\t\tstderr += chunk.toString('utf8');\n\t\t});\n\n\t\tchild.on('error', (error) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tstderr += `${error.message}\\n`;\n\t\t\tfinish(-1);\n\t\t});\n\n\t\tchild.on('close', (code) => {\n\t\t\tclearTimeout(timeout);\n\t\t\tfinish(code ?? -1);\n\t\t});\n\n\t\ttry {\n\t\t\tchild.stdin.write(JSON.stringify(payload));\n\t\t\tchild.stdin.end();\n\t\t} catch (error) {\n\t\t\tstderr += `${error instanceof Error ? error.message : String(error)}\\n`;\n\t\t}\n\t});\n}\n\nexport function hook_event_name_for_result(\n\tevent: ToolResultEvent,\n): HookEventName {\n\treturn event.isError ? 'PostToolUseFailure' : 'PostToolUse';\n}\n\nexport function hook_block_reason(\n\tresult: CommandRunResult,\n): string | undefined {\n\tconst parse_json = (\n\t\ttext: string,\n\t): Record<string, unknown> | undefined => {\n\t\tconst trimmed = text.trim();\n\t\tif (!trimmed) return undefined;\n\t\ttry {\n\t\t\treturn as_record(JSON.parse(trimmed));\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t};\n\n\tconst json = parse_json(result.stdout) ?? parse_json(result.stderr);\n\tif (json?.decision === 'block') {\n\t\treturn typeof json.reason === 'string'\n\t\t\t? json.reason\n\t\t\t: 'Blocked by hook';\n\t}\n\tif (result.code === 2) {\n\t\treturn (\n\t\t\tresult.stderr.trim() ||\n\t\t\tresult.stdout.trim() ||\n\t\t\t'Blocked by hook'\n\t\t);\n\t}\n\treturn undefined;\n}\n\nexport function format_duration(elapsed_ms: number): string {\n\tif (elapsed_ms < 1000) return `${elapsed_ms}ms`;\n\treturn `${(elapsed_ms / 1000).toFixed(1)}s`;\n}\n\nexport function hook_name(command: string): string {\n\tconst sh_path_match = command.match(/[^\\s|;&]+\\.sh\\b/);\n\tif (sh_path_match) return basename(sh_path_match[0]);\n\tconst first_token = command.trim().split(/\\s+/)[0] ?? 'hook';\n\treturn basename(first_token);\n}\n","import { getAgentDir } from '@earendil-works/pi-coding-agent';\nimport {\n\tis_project_subject_trusted,\n\tread_project_trust_store,\n\ttrust_project_subject,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\nimport { join } from 'node:path';\n\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\nexport function default_hooks_trust_store_path(): string {\n\treturn join(getAgentDir(), 'trusted-hooks.json');\n}\n\nexport function create_hooks_config_trust_subject(\n\tproject_dir: string,\n\thash: string,\n): ProjectTrustSubject {\n\treturn {\n\t\tkind: 'hooks-config',\n\t\tid: project_dir,\n\t\tstore_key: project_dir,\n\t\thash,\n\t\tenv_key: HOOKS_CONFIG_ENV,\n\t\tprompt_title:\n\t\t\t'Project hook config can execute shell commands after tool use. Trust these hooks?',\n\t};\n}\n\nexport function is_hooks_config_trusted(\n\tproject_dir: string,\n\thash: string,\n\ttrust_store_path = default_hooks_trust_store_path(),\n): boolean {\n\tconst subject = create_hooks_config_trust_subject(\n\t\tproject_dir,\n\t\thash,\n\t);\n\tif (is_project_subject_trusted(subject, trust_store_path))\n\t\treturn true;\n\n\tconst legacy_entry = read_project_trust_store(trust_store_path)[\n\t\tproject_dir\n\t] as { project_dir?: unknown; hash?: unknown } | undefined;\n\treturn (\n\t\tlegacy_entry?.project_dir === project_dir &&\n\t\tlegacy_entry.hash === hash\n\t);\n}\n\nexport function trust_hooks_config(\n\tproject_dir: string,\n\thash: string,\n\ttrust_store_path = default_hooks_trust_store_path(),\n): void {\n\ttrust_project_subject(\n\t\tcreate_hooks_config_trust_subject(project_dir, hash),\n\t\ttrust_store_path,\n\t);\n}\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\nimport {\n\tresolve_project_trust,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\nimport { get_hooks_config_info } from './config.js';\nimport {\n\tdefault_hooks_trust_store_path,\n\tis_hooks_config_trusted,\n} from './trust.js';\nimport type { HooksConfigInfo } from './types.js';\n\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\nexport function create_hooks_trust_subject(\n\tinfo: HooksConfigInfo,\n): ProjectTrustSubject {\n\tconst source_lines = info.sources.map((source) => `- ${source}`);\n\tconst hook_lines =\n\t\tinfo.hooks.length === 0\n\t\t\t? ['- no valid command hooks detected']\n\t\t\t: info.hooks.map((hook) => {\n\t\t\t\t\tconst matcher = hook.matcher_text\n\t\t\t\t\t\t? ` matcher=${hook.matcher_text}`\n\t\t\t\t\t\t: '';\n\t\t\t\t\treturn `- ${hook.event_name}${matcher}: ${hook.command}`;\n\t\t\t\t});\n\treturn {\n\t\tkind: 'hooks-config',\n\t\tid: info.project_dir,\n\t\tstore_key: info.project_dir,\n\t\thash: info.hash,\n\t\tenv_key: HOOKS_CONFIG_ENV,\n\t\tprompt_title:\n\t\t\t'Project hook config can execute shell commands after tool use. Trust these hooks?',\n\t\tsummary_lines: [\n\t\t\t'Sources:',\n\t\t\t...source_lines,\n\t\t\t'Commands:',\n\t\t\t...hook_lines,\n\t\t],\n\t\tchoices: {\n\t\t\tallow_once: 'Allow once for this session',\n\t\t\ttrust: 'Trust this repo until hook config changes',\n\t\t\tskip: 'Skip project hooks',\n\t\t},\n\t\theadless_warning: `Skipping untrusted hook config in ${info.project_dir}. Set ${HOOKS_CONFIG_ENV}=allow to enable hooks for this run.`,\n\t};\n}\n\nexport async function should_load_hooks_config(\n\tcwd: string,\n\tctx?: ExtensionContext,\n): Promise<boolean> {\n\tconst info = get_hooks_config_info(cwd);\n\tif (!info) return true;\n\tif (is_hooks_config_trusted(info.project_dir, info.hash))\n\t\treturn true;\n\n\tconst decision = await resolve_project_trust(\n\t\tcreate_hooks_trust_subject(info),\n\t\t{\n\t\t\thas_ui: ctx?.hasUI,\n\t\t\tselect: ctx?.hasUI\n\t\t\t\t? async (\n\t\t\t\t\t\tmessage: string,\n\t\t\t\t\t\tchoices: string[],\n\t\t\t\t\t): Promise<string> => {\n\t\t\t\t\t\tconst selected = await ctx.ui.select(message, choices);\n\t\t\t\t\t\treturn selected ?? '';\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t\tenv: process.env,\n\t\t\ttrust_store_path: default_hooks_trust_store_path(),\n\t\t},\n\t);\n\treturn (\n\t\tdecision.action === 'allow-once' ||\n\t\tdecision.action === 'trust-persisted'\n\t);\n}\n","// Hooks resolution — Claude Code style hook compatibility\n\nimport type {\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolCallEventResult,\n} from '@earendil-works/pi-coding-agent';\nimport { load_hooks } from './config.js';\nimport { build_hook_payload, matches_hook } from './payload.js';\nimport {\n\tformat_duration,\n\thook_block_reason,\n\thook_event_name_for_result,\n\thook_name,\n\trun_command_hook,\n} from './runner.js';\nimport { should_load_hooks_config } from './trust-gate.js';\nimport type { CommandRunResult, HookState } from './types.js';\n\nexport {\n\tas_record,\n\tcompile_matcher,\n\tcreate_hook,\n\tfind_nearest_git_root,\n\tfind_project_dir,\n\tget_hook_entries,\n\tget_hooks_config_info,\n\thas_hooks_config,\n\tis_file,\n\tload_hooks,\n\tparse_claude_settings_hooks,\n\tparse_simple_hooks_file,\n\tread_json_file,\n\tresolve_hook_command,\n\twalk_up_directories,\n} from './config.js';\nexport {\n\tbuild_hook_payload,\n\tbuild_tool_response,\n\textract_text_content,\n\tmatches_hook,\n\tnormalize_tool_input,\n\tto_claude_tool_name,\n} from './payload.js';\nexport {\n\tformat_duration,\n\thook_block_reason,\n\thook_event_name_for_result,\n\thook_name,\n\trun_command_hook,\n} from './runner.js';\nexport type {\n\tCommandRunResult,\n\tHookEventName,\n\tHooksConfigInfo,\n\tHookState,\n\tResolvedCommandHook,\n} from './types.js';\nexport interface HooksResolutionOptions {\n\tload_hooks?: (cwd: string) => HookState;\n\trun_command_hook?: (\n\t\tcommand: string,\n\t\tcwd: string,\n\t\tpayload: Record<string, unknown>,\n\t) => Promise<CommandRunResult>;\n}\n\nexport function create_hooks_resolution_extension(\n\toptions: HooksResolutionOptions = {},\n): ExtensionFactory {\n\tconst load_hooks_impl = options.load_hooks ?? load_hooks;\n\tconst run_command_hook_impl =\n\t\toptions.run_command_hook ?? run_command_hook;\n\n\treturn async function hooks_resolution(pi: ExtensionAPI) {\n\t\tlet state: HookState = {\n\t\t\tproject_dir: process.cwd(),\n\t\t\thooks: [],\n\t\t};\n\n\t\tconst refresh_hooks = async (\n\t\t\tcwd: string,\n\t\t\tctx?: ExtensionContext,\n\t\t) => {\n\t\t\tif (!(await should_load_hooks_config(cwd, ctx))) {\n\t\t\t\tstate = { project_dir: cwd, hooks: [] };\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tstate = load_hooks_impl(cwd);\n\t\t};\n\n\t\tpi.on('session_start', async (_event, ctx) => {\n\t\t\tawait refresh_hooks(ctx.cwd, ctx);\n\t\t});\n\n\t\tpi.on(\n\t\t\t'tool_call',\n\t\t\tasync (\n\t\t\t\tevent,\n\t\t\t\tctx,\n\t\t\t): Promise<ToolCallEventResult | undefined> => {\n\t\t\t\tif (state.hooks.length === 0) return;\n\n\t\t\t\tconst matching_hooks = state.hooks.filter(\n\t\t\t\t\t(hook) =>\n\t\t\t\t\t\thook.event_name === 'PreToolUse' &&\n\t\t\t\t\t\tmatches_hook(hook, event.toolName),\n\t\t\t\t);\n\t\t\t\tif (matching_hooks.length === 0) return;\n\n\t\t\t\tconst payload = build_hook_payload(\n\t\t\t\t\tevent,\n\t\t\t\t\t'PreToolUse',\n\t\t\t\t\tctx,\n\t\t\t\t\tstate.project_dir,\n\t\t\t\t);\n\t\t\t\tconst executed_commands = new Set<string>();\n\n\t\t\t\tfor (const hook of matching_hooks) {\n\t\t\t\t\tif (executed_commands.has(hook.command)) continue;\n\t\t\t\t\texecuted_commands.add(hook.command);\n\n\t\t\t\t\tconst result = await run_command_hook_impl(\n\t\t\t\t\t\thook.command,\n\t\t\t\t\t\tstate.project_dir,\n\t\t\t\t\t\tpayload,\n\t\t\t\t\t);\n\t\t\t\t\tconst reason = hook_block_reason(result);\n\t\t\t\t\tif (reason) return { block: true, reason };\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tpi.on('tool_result', async (event, ctx) => {\n\t\t\tif (state.hooks.length === 0) return;\n\n\t\t\tconst event_name = hook_event_name_for_result(event);\n\t\t\tconst matching_hooks = state.hooks.filter(\n\t\t\t\t(hook) =>\n\t\t\t\t\thook.event_name === event_name &&\n\t\t\t\t\tmatches_hook(hook, event.toolName),\n\t\t\t);\n\t\t\tif (matching_hooks.length === 0) return;\n\n\t\t\tconst payload = build_hook_payload(\n\t\t\t\tevent,\n\t\t\t\tevent_name,\n\t\t\t\tctx,\n\t\t\t\tstate.project_dir,\n\t\t\t);\n\t\t\tconst executed_commands = new Set<string>();\n\n\t\t\tfor (const hook of matching_hooks) {\n\t\t\t\tif (executed_commands.has(hook.command)) continue;\n\t\t\t\texecuted_commands.add(hook.command);\n\n\t\t\t\tconst result = await run_command_hook_impl(\n\t\t\t\t\thook.command,\n\t\t\t\t\tstate.project_dir,\n\t\t\t\t\tpayload,\n\t\t\t\t);\n\t\t\t\tconst name = hook_name(hook.command);\n\t\t\t\tconst duration = format_duration(result.elapsed_ms);\n\n\t\t\t\tif (ctx.hasUI) {\n\t\t\t\t\tif (result.code === 0) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Hook \\`${name}\\` ran (${duration})`,\n\t\t\t\t\t\t\t'info',\n\t\t\t\t\t\t);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst error_line =\n\t\t\t\t\t\t\tresult.stderr.trim() ||\n\t\t\t\t\t\t\tresult.stdout.trim() ||\n\t\t\t\t\t\t\t`exit code ${result.code}`;\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t`Hook \\`${name}\\` failed (${duration}): ${error_line}`,\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t};\n}\n\nexport default create_hooks_resolution_extension();\n"],"mappings":";;;;;;;;AAWA,SAAgB,QAAQ,MAAuB;CAC9C,IAAI;EACH,OAAO,SAAS,IAAI,CAAC,CAAC,OAAO;CAC9B,QAAQ;EACP,OAAO;CACR;AACD;AAEA,SAAgB,UACf,OACsC;CACtC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;CACxD,OAAO;AACR;AAEA,SAAgB,oBACf,WACA,UACW;CACX,MAAM,cAAwB,CAAC;CAC/B,MAAM,eAAe,aAAa,KAAA;CAClC,IAAI,UAAU,QAAQ,SAAS;CAC/B,IAAI,SAAS,QAAQ,OAAO;CAC5B,IAAI,mBAAmB,gBAAgB,YAAY;CACnD,IAAI,0BAA0B,WAAW;CAEzC,YAAY,KAAK,OAAO;CACxB,OAAO,CAAC,oBAAoB,CAAC,yBAAyB;EACrD,UAAU;EACV,SAAS,QAAQ,OAAO;EACxB,mBAAmB,gBAAgB,YAAY;EAC/C,0BAA0B,WAAW;EACrC,YAAY,KAAK,OAAO;CACzB;CAEA,OAAO;AACR;AAEA,SAAgB,sBACf,WACqB;CACrB,KAAK,MAAM,aAAa,oBAAoB,SAAS,GACpD,IAAI,WAAW,KAAK,WAAW,MAAM,CAAC,GACrC,OAAO;AAIV;AAEA,SAAgB,iBAAiB,WAA4B;CAC5D,OACC,QAAQ,KAAK,WAAW,WA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