my-pi 0.1.36 → 0.1.38
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 +14 -6
- package/dist/api.d.ts +14 -1
- package/dist/api.js +13 -3
- package/dist/api.js.map +1 -1
- package/dist/{builtin-registry-CoOUEeqx.js → builtin-registry-1hIf07ru.js} +16 -3
- package/dist/{builtin-registry-CoOUEeqx.js.map → builtin-registry-1hIf07ru.js.map} +1 -1
- package/dist/{hooks-resolution-DKAposPY.js → hooks-resolution-D89Ewkyw.js} +46 -7
- package/dist/hooks-resolution-D89Ewkyw.js.map +1 -0
- package/dist/index.js +1 -1
- package/package.json +15 -12
- package/dist/hooks-resolution-DKAposPY.js.map +0 -1
package/README.md
CHANGED
|
@@ -519,12 +519,15 @@ restore, save, and load reusable MCP server sets.
|
|
|
519
519
|
### Hooks
|
|
520
520
|
|
|
521
521
|
Claude-style hooks are discovered from `.claude/settings.json`,
|
|
522
|
-
`.rulesync/hooks.json`, and `.pi/hooks.json`.
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
522
|
+
`.rulesync/hooks.json`, and `.pi/hooks.json`. `PreToolUse` hooks run
|
|
523
|
+
before a tool executes and can block by exiting with code `2` or by
|
|
524
|
+
printing JSON like `{ "decision": "block", "reason": "..." }`.
|
|
525
|
+
`PostToolUse` and `PostToolUseFailure` hooks run after tool execution.
|
|
526
|
+
Because hook commands run through `bash -lc`, project hook config is
|
|
527
|
+
untrusted by default. Interactive sessions show the hook source files
|
|
528
|
+
and commands before allowing execution; headless sessions skip hooks
|
|
529
|
+
unless `MY_PI_HOOKS_CONFIG=allow` or `MY_PI_HOOKS_CONFIG=trust` is
|
|
530
|
+
set. Trusted hook approvals are remembered per project directory and
|
|
528
531
|
hook-config hash.
|
|
529
532
|
|
|
530
533
|
Hook commands receive a restricted child-process environment by
|
|
@@ -752,6 +755,7 @@ pi install npm:@spences10/pi-recall
|
|
|
752
755
|
pi install npm:@spences10/pi-nopeek
|
|
753
756
|
pi install npm:@spences10/pi-omnisearch
|
|
754
757
|
pi install npm:@spences10/pi-sqlite-tools
|
|
758
|
+
pi install npm:@spences10/pi-svelte-guardrails
|
|
755
759
|
pi install npm:@spences10/pi-team-mode
|
|
756
760
|
pi install npm:@spences10/pi-themes
|
|
757
761
|
```
|
|
@@ -779,6 +783,9 @@ pi install npm:@spences10/pi-themes
|
|
|
779
783
|
mcp-omnisearch reminder for verified web research
|
|
780
784
|
- [`@spences10/pi-sqlite-tools`](./packages/pi-sqlite-tools/README.md)
|
|
781
785
|
— mcp-sqlite-tools reminder for safer SQLite database work
|
|
786
|
+
- [`@spences10/pi-svelte-guardrails`](./packages/pi-svelte-guardrails/README.md)
|
|
787
|
+
— Svelte pattern guardrails that block discouraged writes like
|
|
788
|
+
`$effect`
|
|
782
789
|
- [`@spences10/pi-team-mode`](./packages/pi-team-mode/README.md) —
|
|
783
790
|
local orchestrator/team mode with RPC teammates, tasks, and
|
|
784
791
|
mailboxes
|
|
@@ -819,6 +826,7 @@ packages/
|
|
|
819
826
|
pi-mcp/ Installable Pi package for MCP integration
|
|
820
827
|
pi-lsp/ Installable Pi package for LSP tools
|
|
821
828
|
pi-confirm-destructive/ Installable Pi package for destructive action confirmations
|
|
829
|
+
pi-svelte-guardrails/ Installable Pi package for Svelte pattern guardrails
|
|
822
830
|
pi-skills/ Installable Pi package for skill management
|
|
823
831
|
pi-recall/ Installable Pi package for pirecall reminders
|
|
824
832
|
pi-nopeek/ Installable Pi package for nopeek reminders
|
package/dist/api.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import * as _$_spences10_pi_nopeek0 from "@spences10/pi-nopeek";
|
|
|
10
10
|
import * as _$_spences10_pi_omnisearch0 from "@spences10/pi-omnisearch";
|
|
11
11
|
import * as _$_spences10_pi_sqlite_tools0 from "@spences10/pi-sqlite-tools";
|
|
12
12
|
import * as _$_spences10_pi_confirm_destructive0 from "@spences10/pi-confirm-destructive";
|
|
13
|
+
import * as _$_spences10_pi_svelte_guardrails0 from "@spences10/pi-svelte-guardrails";
|
|
13
14
|
import * as _$_spences10_pi_team_mode0 from "@spences10/pi-team-mode";
|
|
14
15
|
|
|
15
16
|
//#region src/extensions/startup-screen/index.d.ts
|
|
@@ -190,7 +191,7 @@ declare const BUILTIN_EXTENSION_REGISTRY: readonly [{
|
|
|
190
191
|
readonly key: "hooks-resolution";
|
|
191
192
|
readonly label: "Hooks resolution";
|
|
192
193
|
readonly docs_label: "Hooks resolution";
|
|
193
|
-
readonly description: "Claude Code style PostToolUse hook compatibility from .claude, .rulesync, and .pi configs";
|
|
194
|
+
readonly description: "Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs";
|
|
194
195
|
readonly default_enabled: true;
|
|
195
196
|
readonly option_name: "hooks_resolution";
|
|
196
197
|
readonly cli_arg: "no-hooks";
|
|
@@ -198,6 +199,18 @@ declare const BUILTIN_EXTENSION_REGISTRY: readonly [{
|
|
|
198
199
|
readonly cli_description: "Disable Claude-style hook execution";
|
|
199
200
|
readonly aliases: readonly ["hooks-resolution", "hooks"];
|
|
200
201
|
readonly load: () => Promise<ExtensionFactory$1>;
|
|
202
|
+
}, {
|
|
203
|
+
readonly key: "svelte-guardrails";
|
|
204
|
+
readonly label: "Svelte guardrails";
|
|
205
|
+
readonly docs_label: "Svelte guardrails";
|
|
206
|
+
readonly description: "Blocks discouraged Svelte patterns like $effect before agents write them";
|
|
207
|
+
readonly default_enabled: true;
|
|
208
|
+
readonly option_name: "svelte_guardrails";
|
|
209
|
+
readonly cli_arg: "no-svelte-guardrails";
|
|
210
|
+
readonly cli_flag: "--no-svelte-guardrails";
|
|
211
|
+
readonly cli_description: "Disable Svelte guardrails";
|
|
212
|
+
readonly aliases: readonly ["svelte-guardrails", "svelte"];
|
|
213
|
+
readonly load: () => Promise<typeof _$_spences10_pi_svelte_guardrails0.default>;
|
|
201
214
|
}, {
|
|
202
215
|
readonly key: "team-mode";
|
|
203
216
|
readonly label: "Team mode";
|
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-1hIf07ru.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -339,10 +339,18 @@ function get_force_disabled_builtins(options) {
|
|
|
339
339
|
}
|
|
340
340
|
return force_disabled;
|
|
341
341
|
}
|
|
342
|
+
function warn_builtin_extension_unavailable(key, error) {
|
|
343
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
344
|
+
process.emitWarning(`Built-in extension "${key}" is unavailable and was skipped: ${reason}`, { code: "MY_PI_BUILTIN_EXTENSION_UNAVAILABLE" });
|
|
345
|
+
}
|
|
342
346
|
function create_lazy_builtin_extension_factory(key, load_extension, force_disabled) {
|
|
343
347
|
return async (pi) => {
|
|
344
348
|
if (!is_builtin_extension_active(load_builtin_extensions_config(), key, force_disabled)) return;
|
|
345
|
-
|
|
349
|
+
try {
|
|
350
|
+
await (await load_extension())(pi);
|
|
351
|
+
} catch (error) {
|
|
352
|
+
warn_builtin_extension_unavailable(key, error);
|
|
353
|
+
}
|
|
346
354
|
};
|
|
347
355
|
}
|
|
348
356
|
function create_lazy_telemetry_extension(options) {
|
|
@@ -387,7 +395,9 @@ async function create_my_pi(options = {}) {
|
|
|
387
395
|
...options,
|
|
388
396
|
runtime_mode
|
|
389
397
|
});
|
|
390
|
-
const skills_package = is_builtin_extension_active(load_builtin_extensions_config(), "skills", force_disabled) ? await import("@spences10/pi-skills")
|
|
398
|
+
const skills_package = is_builtin_extension_active(load_builtin_extensions_config(), "skills", force_disabled) ? await import("@spences10/pi-skills").catch((error) => {
|
|
399
|
+
warn_builtin_extension_unavailable("skills", error);
|
|
400
|
+
}) : void 0;
|
|
391
401
|
const managed_extension_factories = [
|
|
392
402
|
create_lazy_telemetry_extension({
|
|
393
403
|
enabled: telemetry,
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../src/extensions/manager/config.ts","../src/extensions/manager/index.ts","../src/api.ts"],"sourcesContent":["import {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\trenameSync,\n\twriteFileSync,\n} from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionInfo,\n\ttype BuiltinExtensionKey,\n} from '../builtin-registry.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\nconst DEFAULT_CONFIG: BuiltinExtensionsConfig = {\n\tversion: 1,\n\tenabled: {},\n};\n\nexport function get_builtin_extensions_config_path(): string {\n\tconst xdg =\n\t\tprocess.env.XDG_CONFIG_HOME || join(homedir(), '.config');\n\treturn join(xdg, 'my-pi', 'extensions.json');\n}\n\nexport function load_builtin_extensions_config(): BuiltinExtensionsConfig {\n\tconst path = get_builtin_extensions_config_path();\n\tif (!existsSync(path)) return { ...DEFAULT_CONFIG };\n\n\ttry {\n\t\tconst raw = readFileSync(path, 'utf-8');\n\t\tconst parsed = JSON.parse(\n\t\t\traw,\n\t\t) as Partial<BuiltinExtensionsConfig>;\n\t\tconst enabled: BuiltinExtensionsConfig['enabled'] = {};\n\t\tfor (const extension of BUILTIN_EXTENSIONS) {\n\t\t\tconst value = parsed.enabled?.[extension.key];\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\tenabled[extension.key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tversion: parsed.version ?? 1,\n\t\t\tenabled,\n\t\t};\n\t} catch {\n\t\treturn { ...DEFAULT_CONFIG };\n\t}\n}\n\nexport function save_builtin_extensions_config(\n\tconfig: BuiltinExtensionsConfig,\n): void {\n\tconst path = get_builtin_extensions_config_path();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n\n\tconst tmp = `${path}.tmp-${Date.now()}`;\n\twriteFileSync(tmp, JSON.stringify(config, null, '\\t') + '\\n', {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\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\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// Extension loading patterns inspired by pi-vs-claude-code\n\nimport {\n\tclampThinkingLevel,\n\ttype Api,\n\ttype Model,\n} from '@earendil-works/pi-ai';\nimport {\n\tInteractiveMode,\n\tSessionManager,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tgetAgentDir,\n\trunPrintMode,\n\trunRpcMode,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype ExtensionFactory,\n\ttype LoadExtensionsResult,\n} from '@earendil-works/pi-coding-agent';\nimport { apply_project_trust_untrusted_defaults } from '@spences10/pi-project-trust';\nimport { createRequire } from 'node:module';\nimport { dirname, resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSION_REGISTRY,\n\ttype BuiltinExtensionKey,\n\ttype BuiltinExtensionOptionName,\n} 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 MyPiRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\nexport type MyPiThinkingLevel = NonNullable<\n\tCreateAgentSessionFromServicesOptions['thinkingLevel']\n>;\n\ntype BuiltinExtensionOptions = Partial<\n\tRecord<BuiltinExtensionOptionName, boolean>\n>;\n\nexport interface CreateMyPiOptions extends BuiltinExtensionOptions {\n\tcwd?: string;\n\tagent_dir?: string;\n\textensions?: string[];\n\textensionFactories?: ExtensionFactory[];\n\truntime_mode?: MyPiRuntimeMode;\n\ttelemetry?: boolean;\n\ttelemetry_db_path?: string;\n\tmodel?: string;\n\tthinking?: MyPiThinkingLevel;\n\tselected_tools?: string[];\n\tselected_skills?: string[];\n\tsession_dir?: string;\n\tsystem_prompt?: string;\n\tappend_system_prompt?: string;\n\tuntrusted_repo?: boolean;\n}\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nconst require = createRequire(import.meta.url);\nconst PACKAGE_THEME_DIR = resolve(\n\tdirname(require.resolve('@spences10/pi-themes/package.json')),\n\t'themes',\n);\nconst PI_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst MY_PI_RUNTIME_MODE_ENV = 'MY_PI_RUNTIME_MODE';\n\ntype EnvSnapshot = Map<string, string | undefined>;\n\nfunction 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\nfunction 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\nfunction 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\nfunction is_resource_enabled(value: string | undefined): 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\nfunction resolve_agent_dir(cwd: string, agent_dir?: string): string {\n\treturn agent_dir ? resolve(cwd, agent_dir) : getAgentDir();\n}\n\ninterface ModelRegistryLike {\n\tgetAll(): Model<Api>[];\n}\n\nexport function resolve_model_reference(\n\tmodel_reference: string | undefined,\n\tmodel_registry: ModelRegistryLike,\n): Model<Api> | undefined {\n\tif (!model_reference) return undefined;\n\tconst models = model_registry.getAll();\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\nexport function get_force_disabled_builtins(\n\toptions: Pick<CreateMyPiOptions, 'runtime_mode'> &\n\t\tBuiltinExtensionOptions,\n): ReadonlySet<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\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\tconst extension = await load_extension();\n\t\tawait extension(pi);\n\t};\n}\n\nfunction create_lazy_telemetry_extension(options: {\n\tenabled?: boolean;\n\tdb_path?: string;\n\tcwd?: string;\n}): ExtensionFactory {\n\treturn async (pi) => {\n\t\tconst { create_telemetry_extension } =\n\t\t\tawait import('@spences10/pi-telemetry');\n\t\tawait create_telemetry_extension(options)(pi);\n\t};\n}\n\nfunction 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\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\tselected_skills,\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\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')\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?: unknown;\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: (base: any) => {\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: any) => {\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} as any,\n\t\t});\n\n\t\tconst requested_model = resolve_model_reference(\n\t\t\tmodel,\n\t\t\tservices.modelRegistry,\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: sessionStartEvent as any,\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})),\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: SessionManager.create(\n\t\t\t\t\tcwd,\n\t\t\t\t\tsession_dir ? resolve(cwd, session_dir) : undefined,\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,MAAM,iBAA0C;CAC/C,SAAS;CACT,SAAS,EAAE;CACX;AAED,SAAgB,qCAA6C;AAG5D,QAAO,KADN,QAAQ,IAAI,mBAAmB,KAAK,SAAS,EAAE,UAAU,EACzC,SAAS,kBAAkB;;AAG7C,SAAgB,iCAA0D;CACzE,MAAM,OAAO,oCAAoC;AACjD,KAAI,CAAC,WAAW,KAAK,CAAE,QAAO,EAAE,GAAG,gBAAgB;AAEnD,KAAI;EACH,MAAM,MAAM,aAAa,MAAM,QAAQ;EACvC,MAAM,SAAS,KAAK,MACnB,IACA;EACD,MAAM,UAA8C,EAAE;AACtD,OAAK,MAAM,aAAa,oBAAoB;GAC3C,MAAM,QAAQ,OAAO,UAAU,UAAU;AACzC,OAAI,OAAO,UAAU,UACpB,SAAQ,UAAU,OAAO;;AAI3B,SAAO;GACN,SAAS,OAAO,WAAW;GAC3B;GACA;SACM;AACP,SAAO,EAAE,GAAG,gBAAgB;;;AAI9B,SAAgB,+BACf,QACO;CACP,MAAM,OAAO,oCAAoC;CACjD,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AAgB,GAAG,WAAW,mBAAmB;GACpJ,CAAC;AAGH,SAAO;GACN,GAAI,MAAM,+BAA+B;IACxC;IACA;IACmB;IACnB,GAAI,kBAAkB,EAAE,OAAO,iBAAiB,GAAG,EAAE;IACrD,GAAI,qBACD,EAAE,eAAe,oBAAoB,GACrC,EAAE;IACL,GAAI,gBAAgB,SAAS,EAAE,OAAO,gBAAgB,GAAG,EAAE;IAC3D,CAAC;GACF;GACA,aAAa,SAAS;GACtB;;AAGF,KAAI;AACH,SAAO,yBACN,MAAM,0BAA0B,gBAAgB;GAC/C;GACA,UAAU;GACV,gBAAgB,eAAe,OAC9B,KACA,cAAc,QAAQ,KAAK,YAAY,GAAG,KAAA,EAC1C;GACD,CAAC,EACF,oBACA;UACO,OAAO;AACf,uBAAqB;AACrB,QAAM"}
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../src/extensions/manager/config.ts","../src/extensions/manager/index.ts","../src/api.ts"],"sourcesContent":["import {\n\texistsSync,\n\tmkdirSync,\n\treadFileSync,\n\trenameSync,\n\twriteFileSync,\n} from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport {\n\tBUILTIN_EXTENSIONS,\n\ttype BuiltinExtensionInfo,\n\ttype BuiltinExtensionKey,\n} from '../builtin-registry.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\nconst DEFAULT_CONFIG: BuiltinExtensionsConfig = {\n\tversion: 1,\n\tenabled: {},\n};\n\nexport function get_builtin_extensions_config_path(): string {\n\tconst xdg =\n\t\tprocess.env.XDG_CONFIG_HOME || join(homedir(), '.config');\n\treturn join(xdg, 'my-pi', 'extensions.json');\n}\n\nexport function load_builtin_extensions_config(): BuiltinExtensionsConfig {\n\tconst path = get_builtin_extensions_config_path();\n\tif (!existsSync(path)) return { ...DEFAULT_CONFIG };\n\n\ttry {\n\t\tconst raw = readFileSync(path, 'utf-8');\n\t\tconst parsed = JSON.parse(\n\t\t\traw,\n\t\t) as Partial<BuiltinExtensionsConfig>;\n\t\tconst enabled: BuiltinExtensionsConfig['enabled'] = {};\n\t\tfor (const extension of BUILTIN_EXTENSIONS) {\n\t\t\tconst value = parsed.enabled?.[extension.key];\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\tenabled[extension.key] = value;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tversion: parsed.version ?? 1,\n\t\t\tenabled,\n\t\t};\n\t} catch {\n\t\treturn { ...DEFAULT_CONFIG };\n\t}\n}\n\nexport function save_builtin_extensions_config(\n\tconfig: BuiltinExtensionsConfig,\n): void {\n\tconst path = get_builtin_extensions_config_path();\n\tconst dir = dirname(path);\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n\n\tconst tmp = `${path}.tmp-${Date.now()}`;\n\twriteFileSync(tmp, JSON.stringify(config, null, '\\t') + '\\n', {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\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\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// Extension loading patterns inspired by pi-vs-claude-code\n\nimport {\n\tclampThinkingLevel,\n\ttype Api,\n\ttype Model,\n} from '@earendil-works/pi-ai';\nimport {\n\tInteractiveMode,\n\tSessionManager,\n\tcreateAgentSessionFromServices,\n\tcreateAgentSessionRuntime,\n\tcreateAgentSessionServices,\n\tgetAgentDir,\n\trunPrintMode,\n\trunRpcMode,\n\ttype CreateAgentSessionFromServicesOptions,\n\ttype ExtensionFactory,\n\ttype LoadExtensionsResult,\n} from '@earendil-works/pi-coding-agent';\nimport { apply_project_trust_untrusted_defaults } from '@spences10/pi-project-trust';\nimport { createRequire } from 'node:module';\nimport { dirname, resolve } from 'node:path';\nimport {\n\tBUILTIN_EXTENSION_REGISTRY,\n\ttype BuiltinExtensionKey,\n\ttype BuiltinExtensionOptionName,\n} 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 MyPiRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\nexport type MyPiThinkingLevel = NonNullable<\n\tCreateAgentSessionFromServicesOptions['thinkingLevel']\n>;\n\ntype BuiltinExtensionOptions = Partial<\n\tRecord<BuiltinExtensionOptionName, boolean>\n>;\n\nexport interface CreateMyPiOptions extends BuiltinExtensionOptions {\n\tcwd?: string;\n\tagent_dir?: string;\n\textensions?: string[];\n\textensionFactories?: ExtensionFactory[];\n\truntime_mode?: MyPiRuntimeMode;\n\ttelemetry?: boolean;\n\ttelemetry_db_path?: string;\n\tmodel?: string;\n\tthinking?: MyPiThinkingLevel;\n\tselected_tools?: string[];\n\tselected_skills?: string[];\n\tsession_dir?: string;\n\tsystem_prompt?: string;\n\tappend_system_prompt?: string;\n\tuntrusted_repo?: boolean;\n}\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nconst require = createRequire(import.meta.url);\nconst PACKAGE_THEME_DIR = resolve(\n\tdirname(require.resolve('@spences10/pi-themes/package.json')),\n\t'themes',\n);\nconst PI_AGENT_DIR_ENV = 'PI_CODING_AGENT_DIR';\nconst MY_PI_RUNTIME_MODE_ENV = 'MY_PI_RUNTIME_MODE';\n\ntype EnvSnapshot = Map<string, string | undefined>;\n\nfunction 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\nfunction 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\nfunction 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\nfunction is_resource_enabled(value: string | undefined): 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\nfunction resolve_agent_dir(cwd: string, agent_dir?: string): string {\n\treturn agent_dir ? resolve(cwd, agent_dir) : getAgentDir();\n}\n\ninterface ModelRegistryLike {\n\tgetAll(): Model<Api>[];\n}\n\nexport function resolve_model_reference(\n\tmodel_reference: string | undefined,\n\tmodel_registry: ModelRegistryLike,\n): Model<Api> | undefined {\n\tif (!model_reference) return undefined;\n\tconst models = model_registry.getAll();\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\nexport function get_force_disabled_builtins(\n\toptions: Pick<CreateMyPiOptions, 'runtime_mode'> &\n\t\tBuiltinExtensionOptions,\n): ReadonlySet<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 warn_builtin_extension_unavailable(\n\tkey: BuiltinExtensionKey,\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\nfunction create_lazy_telemetry_extension(options: {\n\tenabled?: boolean;\n\tdb_path?: string;\n\tcwd?: string;\n}): ExtensionFactory {\n\treturn async (pi) => {\n\t\tconst { create_telemetry_extension } =\n\t\t\tawait import('@spences10/pi-telemetry');\n\t\tawait create_telemetry_extension(options)(pi);\n\t};\n}\n\nfunction 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\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\tselected_skills,\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\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?: unknown;\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: (base: any) => {\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: any) => {\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} as any,\n\t\t});\n\n\t\tconst requested_model = resolve_model_reference(\n\t\t\tmodel,\n\t\t\tservices.modelRegistry,\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: sessionStartEvent as any,\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})),\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: SessionManager.create(\n\t\t\t\t\tcwd,\n\t\t\t\t\tsession_dir ? resolve(cwd, session_dir) : undefined,\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/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ACtB;;AAGF,KAAI;AACH,SAAO,yBACN,MAAM,0BAA0B,gBAAgB;GAC/C;GACA,UAAU;GACV,gBAAgB,eAAe,OAC9B,KACA,cAAc,QAAQ,KAAK,YAAY,GAAG,KAAA,EAC1C;GACD,CAAC,EACF,oBACA;UACO,OAAO;AACf,uBAAqB;AACrB,QAAM"}
|
|
@@ -226,14 +226,27 @@ const BUILTIN_EXTENSION_REGISTRY = [
|
|
|
226
226
|
key: "hooks-resolution",
|
|
227
227
|
label: "Hooks resolution",
|
|
228
228
|
docs_label: "Hooks resolution",
|
|
229
|
-
description: "Claude Code style PostToolUse hook compatibility from .claude, .rulesync, and .pi configs",
|
|
229
|
+
description: "Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs",
|
|
230
230
|
default_enabled: true,
|
|
231
231
|
option_name: "hooks_resolution",
|
|
232
232
|
cli_arg: "no-hooks",
|
|
233
233
|
cli_flag: "--no-hooks",
|
|
234
234
|
cli_description: "Disable Claude-style hook execution",
|
|
235
235
|
aliases: ["hooks-resolution", "hooks"],
|
|
236
|
-
load: async () => (await import("./hooks-resolution-
|
|
236
|
+
load: async () => (await import("./hooks-resolution-D89Ewkyw.js")).default
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
key: "svelte-guardrails",
|
|
240
|
+
label: "Svelte guardrails",
|
|
241
|
+
docs_label: "Svelte guardrails",
|
|
242
|
+
description: "Blocks discouraged Svelte patterns like $effect before agents write them",
|
|
243
|
+
default_enabled: true,
|
|
244
|
+
option_name: "svelte_guardrails",
|
|
245
|
+
cli_arg: "no-svelte-guardrails",
|
|
246
|
+
cli_flag: "--no-svelte-guardrails",
|
|
247
|
+
cli_description: "Disable Svelte guardrails",
|
|
248
|
+
aliases: ["svelte-guardrails", "svelte"],
|
|
249
|
+
load: async () => (await import("@spences10/pi-svelte-guardrails")).default
|
|
237
250
|
},
|
|
238
251
|
{
|
|
239
252
|
key: "team-mode",
|
|
@@ -257,4 +270,4 @@ const BUILTIN_EXTENSIONS = BUILTIN_EXTENSION_REGISTRY.map(({ load: _load, ...ext
|
|
|
257
270
|
//#endregion
|
|
258
271
|
export { BUILTIN_EXTENSION_REGISTRY as n, BUILTIN_EXTENSIONS as t };
|
|
259
272
|
|
|
260
|
-
//# sourceMappingURL=builtin-registry-
|
|
273
|
+
//# sourceMappingURL=builtin-registry-1hIf07ru.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-registry-CoOUEeqx.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\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\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\tload: async () => (await import('@spences10/pi-mcp')).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\tload: async () => (await import('@spences10/pi-skills')).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\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\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\tload: async () => (await import('@spences10/pi-nopeek')).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\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\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: '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\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\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 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: 'team-mode',\n\t\tlabel: 'Team mode',\n\t\tdocs_label: 'Team mode',\n\t\tdescription:\n\t\t\t'Experimental orchestrator/team mode with RPC teammates, tasks, and 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 experimental team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\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":";AA4BA,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;GAAU;EAClD,MAAM,aAAa,MAAM,OAAO,0BAA0B;EAC1D;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,MAAM;EAChB,MAAM,aAAa,MAAM,OAAO,sBAAsB;EACtD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,UAAU,QAAQ;EAC5B,MAAM,aAAa,MAAM,OAAO,yBAAyB;EACzD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GACR;GACA;GACA;GACA;GACA;GACA;GACA;EACD,MAAM,aAAa,MAAM,OAAO,yBAAyB;EACzD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,UAAU,WAAW;EAC/B,MAAM,aAAa,MAAM,OAAO,yBAAyB;EACzD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;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AAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAgB;GAAW;GAAY;EACjD,kBAAkB;GACjB,aAAa;IAAC;IAAS;IAAQ;IAAM;GACrC,QACC;GACD;EACD,MAAM,aACJ,MAAM,OAAO,+BAA4B;EAC3C;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,uBAAuB,UAAU;EAC3C,MAAM,aACJ,MAAM,OAAO,sCAAsC;EACrD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,oBAAoB,QAAQ;EACtC,MAAM,aACJ,MAAM,OAAO,mCAAgC;EAC/C;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAa;GAAQ;GAAY;EAC3C,MAAM,aACJ,MAAM,OAAO,4BAA4B;EAC3C;CACD;AAgBD,MAAa,qBACZ,2BAA2B,KACzB,EAAE,MAAM,OAAO,GAAG,gBAAgB,UACnC"}
|
|
1
|
+
{"version":3,"file":"builtin-registry-1hIf07ru.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\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\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\tload: async () => (await import('@spences10/pi-mcp')).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\tload: async () => (await import('@spences10/pi-skills')).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\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\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\tload: async () => (await import('@spences10/pi-nopeek')).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\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\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: '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\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\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\tload: async () =>\n\t\t\t(await import('@spences10/pi-svelte-guardrails')).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'Experimental orchestrator/team mode with RPC teammates, tasks, and 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 experimental team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\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":";AA4BA,MAAa,6BAA6B;CACzC;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,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C,MAAM,aACJ,MAAM,OAAO,sCAAsC;EACrD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,oBAAoB,QAAQ;EACtC,MAAM,aACJ,MAAM,OAAO,mCAAgC;EAC/C;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,qBAAqB,SAAS;EACxC,MAAM,aACJ,MAAM,OAAO,oCAAoC;EACnD;CACD;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAa;GAAQ;GAAY;EAC3C,MAAM,aACJ,MAAM,OAAO,4BAA4B;EAC3C;CACD;AAgBD,MAAa,qBACZ,2BAA2B,KACzB,EAAE,MAAM,OAAO,GAAG,gBAAgB,UACnC"}
|
|
@@ -108,7 +108,7 @@ function create_hook(event_name, matcher_text, command, source, project_dir) {
|
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
function get_hook_entries(hooks_record, event_name) {
|
|
111
|
-
const keys = event_name === "PostToolUse" ? ["PostToolUse", "postToolUse"] : ["PostToolUseFailure", "postToolUseFailure"];
|
|
111
|
+
const keys = event_name === "PreToolUse" ? ["PreToolUse", "preToolUse"] : event_name === "PostToolUse" ? ["PostToolUse", "postToolUse"] : ["PostToolUseFailure", "postToolUseFailure"];
|
|
112
112
|
for (const key of keys) {
|
|
113
113
|
const value = hooks_record[key];
|
|
114
114
|
if (Array.isArray(value)) return value;
|
|
@@ -120,7 +120,11 @@ function parse_claude_settings_hooks(config, source, project_dir) {
|
|
|
120
120
|
const hooks_root = root ? as_record(root.hooks) : void 0;
|
|
121
121
|
if (!hooks_root) return [];
|
|
122
122
|
const hooks = [];
|
|
123
|
-
for (const event_name of [
|
|
123
|
+
for (const event_name of [
|
|
124
|
+
"PreToolUse",
|
|
125
|
+
"PostToolUse",
|
|
126
|
+
"PostToolUseFailure"
|
|
127
|
+
]) {
|
|
124
128
|
const entries = get_hook_entries(hooks_root, event_name);
|
|
125
129
|
for (const entry of entries) {
|
|
126
130
|
const entry_record = as_record(entry);
|
|
@@ -143,7 +147,11 @@ function parse_simple_hooks_file(config, source, project_dir) {
|
|
|
143
147
|
const hooks_root = root ? as_record(root.hooks) : void 0;
|
|
144
148
|
if (!hooks_root) return [];
|
|
145
149
|
const hooks = [];
|
|
146
|
-
for (const event_name of [
|
|
150
|
+
for (const event_name of [
|
|
151
|
+
"PreToolUse",
|
|
152
|
+
"PostToolUse",
|
|
153
|
+
"PostToolUseFailure"
|
|
154
|
+
]) {
|
|
147
155
|
const entries = get_hook_entries(hooks_root, event_name);
|
|
148
156
|
for (const entry of entries) {
|
|
149
157
|
const entry_record = as_record(entry);
|
|
@@ -247,16 +255,17 @@ function build_tool_response(event, normalized_input) {
|
|
|
247
255
|
}
|
|
248
256
|
function build_hook_payload(event, event_name, ctx, project_dir) {
|
|
249
257
|
const normalized_input = normalize_tool_input(event.input);
|
|
250
|
-
|
|
258
|
+
const payload = {
|
|
251
259
|
session_id: ctx.sessionManager.getSessionFile() ?? "ephemeral",
|
|
252
260
|
cwd: ctx.cwd,
|
|
253
261
|
claude_project_dir: project_dir,
|
|
254
262
|
hook_event_name: event_name,
|
|
255
263
|
tool_name: to_claude_tool_name(event.toolName),
|
|
256
264
|
tool_call_id: event.toolCallId,
|
|
257
|
-
tool_input: normalized_input
|
|
258
|
-
tool_response: build_tool_response(event, normalized_input)
|
|
265
|
+
tool_input: normalized_input
|
|
259
266
|
};
|
|
267
|
+
if ("content" in event) payload.tool_response = build_tool_response(event, normalized_input);
|
|
268
|
+
return payload;
|
|
260
269
|
}
|
|
261
270
|
async function run_command_hook(command, cwd, payload) {
|
|
262
271
|
return await new Promise((resolve) => {
|
|
@@ -319,6 +328,20 @@ async function run_command_hook(command, cwd, payload) {
|
|
|
319
328
|
function hook_event_name_for_result(event) {
|
|
320
329
|
return event.isError ? "PostToolUseFailure" : "PostToolUse";
|
|
321
330
|
}
|
|
331
|
+
function hook_block_reason(result) {
|
|
332
|
+
const parse_json = (text) => {
|
|
333
|
+
const trimmed = text.trim();
|
|
334
|
+
if (!trimmed) return void 0;
|
|
335
|
+
try {
|
|
336
|
+
return as_record(JSON.parse(trimmed));
|
|
337
|
+
} catch {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const json = parse_json(result.stdout) ?? parse_json(result.stderr);
|
|
342
|
+
if (json?.decision === "block") return typeof json.reason === "string" ? json.reason : "Blocked by hook";
|
|
343
|
+
if (result.code === 2) return result.stderr.trim() || result.stdout.trim() || "Blocked by hook";
|
|
344
|
+
}
|
|
322
345
|
function format_duration(elapsed_ms) {
|
|
323
346
|
if (elapsed_ms < 1e3) return `${elapsed_ms}ms`;
|
|
324
347
|
return `${(elapsed_ms / 1e3).toFixed(1)}s`;
|
|
@@ -390,6 +413,22 @@ function create_hooks_resolution_extension(options = {}) {
|
|
|
390
413
|
pi.on("session_start", async (_event, ctx) => {
|
|
391
414
|
await refresh_hooks(ctx.cwd, ctx);
|
|
392
415
|
});
|
|
416
|
+
pi.on("tool_call", async (event, ctx) => {
|
|
417
|
+
if (state.hooks.length === 0) return;
|
|
418
|
+
const matching_hooks = state.hooks.filter((hook) => hook.event_name === "PreToolUse" && matches_hook(hook, event.toolName));
|
|
419
|
+
if (matching_hooks.length === 0) return;
|
|
420
|
+
const payload = build_hook_payload(event, "PreToolUse", ctx, state.project_dir);
|
|
421
|
+
const executed_commands = /* @__PURE__ */ new Set();
|
|
422
|
+
for (const hook of matching_hooks) {
|
|
423
|
+
if (executed_commands.has(hook.command)) continue;
|
|
424
|
+
executed_commands.add(hook.command);
|
|
425
|
+
const reason = hook_block_reason(await run_command_hook_impl(hook.command, state.project_dir, payload));
|
|
426
|
+
if (reason) return {
|
|
427
|
+
block: true,
|
|
428
|
+
reason
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
});
|
|
393
432
|
pi.on("tool_result", async (event, ctx) => {
|
|
394
433
|
if (state.hooks.length === 0) return;
|
|
395
434
|
const event_name = hook_event_name_for_result(event);
|
|
@@ -416,4 +455,4 @@ var hooks_resolution_default = create_hooks_resolution_extension();
|
|
|
416
455
|
//#endregion
|
|
417
456
|
export { hooks_resolution_default as default };
|
|
418
457
|
|
|
419
|
-
//# sourceMappingURL=hooks-resolution-
|
|
458
|
+
//# sourceMappingURL=hooks-resolution-D89Ewkyw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks-resolution-D89Ewkyw.js","names":["create_child_process_env","create_shared_child_process_env","HOOKS_CONFIG_ENV","create_child_process_env"],"sources":["../src/extensions/hooks-resolution/env.ts","../src/extensions/hooks-resolution/trust.ts","../src/extensions/hooks-resolution/index.ts"],"sourcesContent":["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 { 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","// Hooks resolution — Claude Code style hook compatibility\n\nimport type {\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolCallEvent,\n\tToolCallEventResult,\n\tToolResultEvent,\n} from '@earendil-works/pi-coding-agent';\nimport {\n\tresolve_project_trust,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\nimport { spawn } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { create_child_process_env } from './env.js';\nimport {\n\tdefault_hooks_trust_store_path,\n\tis_hooks_config_trusted,\n} from './trust.js';\n\nconst HOOK_TIMEOUT_MS = 10 * 60 * 1000;\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\ntype JsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| JsonValue[]\n\t| { [key: string]: JsonValue };\n\nexport type HookEventName =\n\t| 'PreToolUse'\n\t| 'PostToolUse'\n\t| 'PostToolUseFailure';\n\nexport interface ResolvedCommandHook {\n\tevent_name: HookEventName;\n\tmatcher?: RegExp;\n\tmatcher_text?: string;\n\tcommand: string;\n\tsource: string;\n}\n\nexport interface HookState {\n\tproject_dir: string;\n\thooks: ResolvedCommandHook[];\n}\n\nexport interface HooksConfigInfo {\n\tproject_dir: string;\n\thash: string;\n\tsources: string[];\n\thooks: Array<{\n\t\tevent_name: HookEventName;\n\t\tmatcher_text?: string;\n\t\tcommand: string;\n\t\tsource: string;\n\t}>;\n}\n\nexport interface CommandRunResult {\n\tcode: number;\n\tstdout: string;\n\tstderr: string;\n\telapsed_ms: number;\n\ttimed_out: boolean;\n}\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\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\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\nfunction 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\nasync 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\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":";;;;;;;;AAEA,SAAgBA,2BACf,eAAuC,EAAE,EACzC,aAAgC,QAAQ,KACpB;AACpB,QAAOC,yBAAgC;EACtC,SAAS;EACT;EACA;EACA,CAAC;;;;ACDH,MAAMC,qBAAmB;AAEzB,SAAgB,iCAAyC;AACxD,QAAO,KAAK,aAAa,EAAE,qBAAqB;;AAGjD,SAAgB,kCACf,aACA,MACsB;AACtB,QAAO;EACN,MAAM;EACN,IAAI;EACJ,WAAW;EACX;EACA,SAASA;EACT,cACC;EACD;;AAGF,SAAgB,wBACf,aACA,MACA,mBAAmB,gCAAgC,EACzC;AAKV,KAAI,2BAJY,kCACf,aACA,KAEqC,EAAE,i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AM,MAAM,WAAW,EAAG;GAE9B,MAAM,aAAa,2BAA2B,MAAM;GACpD,MAAM,iBAAiB,MAAM,MAAM,QACjC,SACA,KAAK,eAAe,cACpB,aAAa,MAAM,MAAM,SAAS,CACnC;AACD,OAAI,eAAe,WAAW,EAAG;GAEjC,MAAM,UAAU,mBACf,OACA,YACA,KACA,MAAM,YACN;GACD,MAAM,oCAAoB,IAAI,KAAa;AAE3C,QAAK,MAAM,QAAQ,gBAAgB;AAClC,QAAI,kBAAkB,IAAI,KAAK,QAAQ,CAAE;AACzC,sBAAkB,IAAI,KAAK,QAAQ;IAEnC,MAAM,SAAS,MAAM,sBACpB,KAAK,SACL,MAAM,aACN,QACA;IACD,MAAM,OAAO,UAAU,KAAK,QAAQ;IACpC,MAAM,WAAW,gBAAgB,OAAO,WAAW;AAEnD,QAAI,IAAI,MACP,KAAI,OAAO,SAAS,EACnB,KAAI,GAAG,OACN,UAAU,KAAK,UAAU,SAAS,IAClC,OACA;SACK;KACN,MAAM,aACL,OAAO,OAAO,MAAM,IACpB,OAAO,OAAO,MAAM,IACpB,aAAa,OAAO;AACrB,SAAI,GAAG,OACN,UAAU,KAAK,aAAa,SAAS,KAAK,cAC1C,UACA;;;IAIH;;;AAIJ,IAAA,2BAAe,mCAAmC"}
|
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-1hIf07ru.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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"description": "Composable pi coding agent with MCP, LSP, prompt presets, and local eval telemetry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -47,30 +47,33 @@
|
|
|
47
47
|
"@earendil-works/pi-coding-agent": "^0.74.0",
|
|
48
48
|
"@earendil-works/pi-tui": "^0.74.0",
|
|
49
49
|
"citty": "^0.2.2",
|
|
50
|
-
"typebox": "^1.1.38"
|
|
50
|
+
"typebox": "^1.1.38"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@changesets/cli": "^2.31.0",
|
|
54
|
+
"@types/node": "^25.6.1",
|
|
55
|
+
"vite-plus": "^0.1.20",
|
|
56
|
+
"vitest": "^4.1.5"
|
|
57
|
+
},
|
|
58
|
+
"optionalDependencies": {
|
|
51
59
|
"@spences10/pi-child-env": "0.1.4",
|
|
60
|
+
"@spences10/pi-confirm-destructive": "0.0.8",
|
|
52
61
|
"@spences10/pi-context": "0.0.10",
|
|
53
62
|
"@spences10/pi-lsp": "0.0.17",
|
|
54
63
|
"@spences10/pi-mcp": "0.0.20",
|
|
55
|
-
"@spences10/pi-confirm-destructive": "0.0.8",
|
|
56
64
|
"@spences10/pi-nopeek": "0.0.6",
|
|
57
|
-
"@spences10/pi-project-trust": "0.0.6",
|
|
58
65
|
"@spences10/pi-omnisearch": "0.0.6",
|
|
66
|
+
"@spences10/pi-project-trust": "0.0.6",
|
|
59
67
|
"@spences10/pi-recall": "0.0.6",
|
|
68
|
+
"@spences10/pi-skills": "0.0.14",
|
|
60
69
|
"@spences10/pi-redact": "0.0.6",
|
|
61
70
|
"@spences10/pi-sqlite-tools": "0.0.6",
|
|
62
|
-
"@spences10/pi-
|
|
71
|
+
"@spences10/pi-svelte-guardrails": "0.0.2",
|
|
72
|
+
"@spences10/pi-team-mode": "0.0.16",
|
|
63
73
|
"@spences10/pi-telemetry": "0.0.9",
|
|
64
74
|
"@spences10/pi-themes": "0.0.4",
|
|
65
|
-
"@spences10/pi-team-mode": "0.0.16",
|
|
66
75
|
"@spences10/pi-tui-modal": "0.0.9"
|
|
67
76
|
},
|
|
68
|
-
"devDependencies": {
|
|
69
|
-
"@changesets/cli": "^2.31.0",
|
|
70
|
-
"@types/node": "^25.6.1",
|
|
71
|
-
"vite-plus": "^0.1.20",
|
|
72
|
-
"vitest": "^4.1.5"
|
|
73
|
-
},
|
|
74
77
|
"engines": {
|
|
75
78
|
"node": ">=24.15.0"
|
|
76
79
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-resolution-DKAposPY.js","names":["create_child_process_env","create_shared_child_process_env","HOOKS_CONFIG_ENV","create_child_process_env"],"sources":["../src/extensions/hooks-resolution/env.ts","../src/extensions/hooks-resolution/trust.ts","../src/extensions/hooks-resolution/index.ts"],"sourcesContent":["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 { 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","// Hooks resolution — Claude Code style hook compatibility\n\nimport type {\n\tExtensionAPI,\n\tExtensionContext,\n\tExtensionFactory,\n\tToolResultEvent,\n} from '@earendil-works/pi-coding-agent';\nimport {\n\tresolve_project_trust,\n\ttype ProjectTrustSubject,\n} from '@spences10/pi-project-trust';\nimport { spawn } from 'node:child_process';\nimport { createHash } from 'node:crypto';\nimport { existsSync, readFileSync, statSync } from 'node:fs';\nimport { basename, dirname, join, resolve } from 'node:path';\nimport { create_child_process_env } from './env.js';\nimport {\n\tdefault_hooks_trust_store_path,\n\tis_hooks_config_trusted,\n} from './trust.js';\n\nconst HOOK_TIMEOUT_MS = 10 * 60 * 1000;\nconst HOOKS_CONFIG_ENV = 'MY_PI_HOOKS_CONFIG';\n\ntype JsonValue =\n\t| string\n\t| number\n\t| boolean\n\t| null\n\t| JsonValue[]\n\t| { [key: string]: JsonValue };\n\nexport type HookEventName = 'PostToolUse' | 'PostToolUseFailure';\n\nexport interface ResolvedCommandHook {\n\tevent_name: HookEventName;\n\tmatcher?: RegExp;\n\tmatcher_text?: string;\n\tcommand: string;\n\tsource: string;\n}\n\nexport interface HookState {\n\tproject_dir: string;\n\thooks: ResolvedCommandHook[];\n}\n\nexport interface HooksConfigInfo {\n\tproject_dir: string;\n\thash: string;\n\tsources: string[];\n\thooks: Array<{\n\t\tevent_name: HookEventName;\n\t\tmatcher_text?: string;\n\t\tcommand: string;\n\t\tsource: string;\n\t}>;\n}\n\nexport interface CommandRunResult {\n\tcode: number;\n\tstdout: string;\n\tstderr: string;\n\telapsed_ms: number;\n\ttimed_out: boolean;\n}\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 === 'PostToolUse'\n\t\t\t? ['PostToolUse', 'postToolUse']\n\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'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'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\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: 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\n\treturn {\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\ttool_response: build_tool_response(event, normalized_input),\n\t};\n}\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 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\nfunction 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\nasync 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\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('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":";;;;;;;;AAEA,SAAgBA,2BACf,eAAuC,EAAE,EACzC,aAAgC,QAAQ,KACpB;AACpB,QAAOC,yBAAgC;EACtC,SAAS;EACT;EACA;EACA,CAAC;;;;ACDH,MAAMC,qBAAmB;AAEzB,SAAgB,iCAAyC;AACxD,QAAO,KAAK,aAAa,EAAE,qBAAqB;;AAGjD,SAAgB,kCACf,aACA,MACsB;AACtB,QAAO;EACN,MAAM;EACN,IAAI;EACJ,WAAW;EACX;EACA,SAASA;EACT,cACC;EACD;;AAGF,SAAgB,wBACf,aACA,MACA,mBAAmB,gCAAgC,EACzC;AAKV,KAAI,2BAJY,kCACf,aACA,KAEqC,EAAE,iBAAiB,CACxD,QAAO;CAER,MAAM,eAAe,yBAAyB,iBAAiB,CAC9D;AAED,QACC,cAAc,gBAAgB,eAC9B,aAAa,SAAS;;;;ACzBxB,MAAM,kBAAkB,MAAU;AAClC,MAAM,mBAAmB;AA6CzB,SAAgB,QAAQ,MAAuB;AAC9C,KAAI;AACH,SAAO,SAAS,KAAK,CAAC,QAAQ;SACvB;AACP,SAAO;;;AAIT,SAAgB,UACf,OACsC;AACtC,KAAI,OAAO,UAAU,YAAY,UAAU,KAAM,QAAO,KAAA;AACxD,QAAO;;AAGR,SAAgB,oBACf,WACA,UACW;CACX,MAAM,cAAwB,EAAE;CAChC,MAAM,eAAe,aAAa,KAAA;CAClC,IAAI,UAAU,QAAQ,U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