my-pi 0.1.108 → 0.1.110
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/dist/api.js +1 -1
- package/dist/{builtin-registry-BGqWuqdp.js → builtin-registry-CvuaboQf.js} +2 -2
- package/dist/{builtin-registry-BGqWuqdp.js.map → builtin-registry-CvuaboQf.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/{prompt-presets-BlCoIFYT.js → prompt-presets-Lb8mMDHY.js} +3 -2
- package/dist/prompt-presets-Lb8mMDHY.js.map +1 -0
- package/package.json +17 -18
- package/dist/prompt-presets-BlCoIFYT.js.map +0 -1
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-CvuaboQf.js";
|
|
2
2
|
import { n as save_settings, t as load_settings } from "./settings-CTk0ws43.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { existsSync, readdirSync } from "node:fs";
|
|
@@ -292,7 +292,7 @@ const BUILTIN_EXTENSION_REGISTRY = [
|
|
|
292
292
|
"preset",
|
|
293
293
|
"presets"
|
|
294
294
|
],
|
|
295
|
-
load: async () => (await import("./prompt-presets-
|
|
295
|
+
load: async () => (await import("./prompt-presets-Lb8mMDHY.js")).default
|
|
296
296
|
},
|
|
297
297
|
{
|
|
298
298
|
key: "git-ui",
|
|
@@ -455,4 +455,4 @@ const BUILTIN_EXTENSIONS = BUILTIN_EXTENSION_REGISTRY.map(({ load: _load, ...ext
|
|
|
455
455
|
//#endregion
|
|
456
456
|
export { BUILTIN_EXTENSION_REGISTRY as n, BUILTIN_EXTENSIONS as t };
|
|
457
457
|
|
|
458
|
-
//# sourceMappingURL=builtin-registry-
|
|
458
|
+
//# sourceMappingURL=builtin-registry-CvuaboQf.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtin-registry-BGqWuqdp.js","names":[],"sources":["../src/extensions/builtin-registry.ts"],"sourcesContent":["import type { ExtensionFactory } from '@earendil-works/pi-coding-agent';\n\nexport type BuiltinExtensionRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nexport interface BuiltinExtensionManifestEntry {\n\tkey: string;\n\tlabel: string;\n\tdocs_label: string;\n\tdescription: string;\n\tdefault_enabled: boolean;\n\toption_name: string;\n\tcli_arg: string;\n\tcli_flag: `--${string}`;\n\tcli_description: string;\n\taliases: readonly string[];\n\tmode_constraints?: {\n\t\tdisabled_in: readonly BuiltinExtensionRuntimeMode[];\n\t\treason: string;\n\t};\n\texternal_package_name?: string;\n\tload: BuiltinExtensionLoader;\n}\n\nexport const BUILTIN_EXTENSION_REGISTRY = [\n\t{\n\t\tkey: 'context-sidecar',\n\t\tlabel: 'Context sidecar',\n\t\tdocs_label: 'SQLite context sidecar',\n\t\tdescription: 'Local SQLite FTS sidecar for oversized tool output',\n\t\tdefault_enabled: true,\n\t\toption_name: 'context_sidecar',\n\t\tcli_arg: 'no-context-sidecar',\n\t\tcli_flag: '--no-context-sidecar',\n\t\tcli_description:\n\t\t\t'Disable SQLite context sidecar for large tool output',\n\t\taliases: ['context-sidecar', 'context', 'sidecar'],\n\t\texternal_package_name: '@spences10/pi-context',\n\t\tload: async () => (await import('@spences10/pi-context')).default,\n\t},\n\t{\n\t\tkey: 'mcp',\n\t\tlabel: 'MCP',\n\t\tdocs_label: 'MCP',\n\t\tdescription: 'MCP server integration and /mcp command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'mcp',\n\t\tcli_arg: 'no-mcp',\n\t\tcli_flag: '--no-mcp',\n\t\tcli_description: 'Disable built-in MCP extension',\n\t\taliases: ['mcp'],\n\t\texternal_package_name: '@spences10/pi-mcp',\n\t\tload: async () => (await import('@spences10/pi-mcp')).default,\n\t},\n\t{\n\t\tkey: 'openrouter-fusion-config',\n\t\tlabel: 'OpenRouter Fusion config',\n\t\tdocs_label: 'OpenRouter Fusion config guard',\n\t\tdescription:\n\t\t\t'Keeps OpenRouter Fusion off Anthropic by injecting a non-Anthropic panel and judge',\n\t\tdefault_enabled: true,\n\t\toption_name: 'openrouter_fusion_config',\n\t\tcli_arg: 'no-openrouter-fusion-config',\n\t\tcli_flag: '--no-openrouter-fusion-config',\n\t\tcli_description: 'Disable OpenRouter Fusion non-Anthropic config',\n\t\taliases: ['openrouter-fusion-config', 'fusion-budget'],\n\t\tload: async () =>\n\t\t\t(await import('./openrouter-fusion-config/index.js')).default,\n\t},\n\t{\n\t\tkey: 'umans-provider',\n\t\tlabel: 'Umans provider',\n\t\tdocs_label: 'Umans provider',\n\t\tdescription:\n\t\t\t'Umans.ai Anthropic Messages provider with API key login support',\n\t\tdefault_enabled: true,\n\t\toption_name: 'umans_provider',\n\t\tcli_arg: 'no-umans-provider',\n\t\tcli_flag: '--no-umans-provider',\n\t\tcli_description: 'Disable built-in Umans provider',\n\t\taliases: ['umans-provider', 'umans'],\n\t\tload: async () =>\n\t\t\t(await import('./umans-provider/index.js')).default,\n\t},\n\t{\n\t\tkey: 'footer',\n\t\tlabel: 'Footer',\n\t\tdocs_label: 'Footer',\n\t\tdescription: 'Configurable interactive footer/statusline',\n\t\tdefault_enabled: true,\n\t\toption_name: 'footer',\n\t\tcli_arg: 'no-footer',\n\t\tcli_flag: '--no-footer',\n\t\tcli_description: 'Disable custom footer/statusline',\n\t\taliases: ['footer', 'statusline', 'status-line'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Footer only renders in the interactive TUI',\n\t\t},\n\t\tload: async () => (await import('./footer/index.js')).default,\n\t},\n\t{\n\t\tkey: 'codex-usage',\n\t\tlabel: 'Codex usage',\n\t\tdocs_label: 'Codex usage status',\n\t\tdescription: 'OpenAI Codex usage status for the footer',\n\t\tdefault_enabled: true,\n\t\toption_name: 'codex_usage',\n\t\tcli_arg: 'no-codex-usage',\n\t\tcli_flag: '--no-codex-usage',\n\t\tcli_description: 'Disable Codex usage footer status',\n\t\taliases: ['codex-usage', 'codex-status'],\n\t\texternal_package_name: '@spences10/pi-codex-usage',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-codex-usage')).default,\n\t},\n\t{\n\t\tkey: 'harness',\n\t\tlabel: 'Harness',\n\t\tdocs_label: 'Task harness runtime',\n\t\tdescription:\n\t\t\t'Ephemeral /tmp task harness runtime with tools, enforcement, and bundled skills',\n\t\tdefault_enabled: true,\n\t\toption_name: 'harness',\n\t\tcli_arg: 'no-harness',\n\t\tcli_flag: '--no-harness',\n\t\tcli_description: 'Disable task harness runtime',\n\t\taliases: ['harness', 'task-harness'],\n\t\texternal_package_name: '@spences10/pi-harness',\n\t\tload: async () => (await import('@spences10/pi-harness')).default,\n\t},\n\t{\n\t\tkey: 'skills',\n\t\tlabel: 'Skills',\n\t\tdocs_label: 'Skills',\n\t\tdescription: 'Managed pi-native skills and /skills command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skills',\n\t\tcli_arg: 'no-skills',\n\t\tcli_flag: '--no-skills',\n\t\tcli_description: 'Disable built-in skills extension',\n\t\taliases: ['skills', 'skill'],\n\t\texternal_package_name: '@spences10/pi-skills',\n\t\tload: async () => (await import('@spences10/pi-skills')).default,\n\t},\n\t{\n\t\tkey: 'skill-importer',\n\t\tlabel: 'Skill importer',\n\t\tdocs_label: 'Skill importer',\n\t\tdescription:\n\t\t\t'Import external Claude/plugin skills into Pi-native storage',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skill_importer',\n\t\tcli_arg: 'no-skill-importer',\n\t\tcli_flag: '--no-skill-importer',\n\t\tcli_description: 'Disable external skill importer extension',\n\t\taliases: ['skill-importer', 'import-skills', 'skill-import'],\n\t\texternal_package_name: '@spences10/pi-skill-importer',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-skill-importer')).default,\n\t},\n\t{\n\t\tkey: 'filter-output',\n\t\tlabel: 'Secret redaction',\n\t\tdocs_label: 'Secret redaction',\n\t\tdescription:\n\t\t\t'Redacts secrets from tool output before the model sees them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'filter_output',\n\t\tcli_arg: 'no-filter',\n\t\tcli_flag: '--no-filter',\n\t\tcli_description: 'Disable secret redaction in tool output',\n\t\taliases: [\n\t\t\t'filter-output',\n\t\t\t'filter_output',\n\t\t\t'filter',\n\t\t\t'redaction',\n\t\t\t'secret-redaction',\n\t\t\t'output-redaction',\n\t\t],\n\t\texternal_package_name: '@spences10/pi-redact',\n\t\tload: async () => (await import('@spences10/pi-redact')).default,\n\t},\n\t{\n\t\tkey: 'recall',\n\t\tlabel: 'Recall',\n\t\tdocs_label: 'Recall',\n\t\tdescription: 'pirecall reminder and background session sync',\n\t\tdefault_enabled: true,\n\t\toption_name: 'recall',\n\t\tcli_arg: 'no-recall',\n\t\tcli_flag: '--no-recall',\n\t\tcli_description: 'Disable recall extension',\n\t\taliases: ['recall', 'pirecall'],\n\t\texternal_package_name: '@spences10/pi-recall',\n\t\tload: async () => (await import('@spences10/pi-recall')).default,\n\t},\n\t{\n\t\tkey: 'nopeek',\n\t\tlabel: 'Nopeek',\n\t\tdocs_label: 'Nopeek',\n\t\tdescription:\n\t\t\t'nopeek reminder for secret-safe environment loading',\n\t\tdefault_enabled: true,\n\t\toption_name: 'nopeek',\n\t\tcli_arg: 'no-nopeek',\n\t\tcli_flag: '--no-nopeek',\n\t\tcli_description: 'Disable nopeek reminder extension',\n\t\taliases: ['nopeek', 'secrets', 'secret-loading'],\n\t\texternal_package_name: '@spences10/pi-nopeek',\n\t\tload: async () => (await import('@spences10/pi-nopeek')).default,\n\t},\n\t{\n\t\tkey: 'observability',\n\t\tlabel: 'Observability',\n\t\tdocs_label: 'Live observability',\n\t\tdescription:\n\t\t\t'Optional live event stream and local browser dashboard',\n\t\tdefault_enabled: true,\n\t\toption_name: 'observability',\n\t\tcli_arg: 'no-observability',\n\t\tcli_flag: '--no-observability',\n\t\tcli_description: 'Disable live observability extension',\n\t\taliases: ['observability', 'obs', 'live-events'],\n\t\texternal_package_name: '@spences10/pi-observability',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-observability')).default,\n\t},\n\t{\n\t\tkey: 'omnisearch',\n\t\tlabel: 'Omnisearch',\n\t\tdocs_label: 'Omnisearch',\n\t\tdescription: 'mcp-omnisearch reminder for verified web research',\n\t\tdefault_enabled: true,\n\t\toption_name: 'omnisearch',\n\t\tcli_arg: 'no-omnisearch',\n\t\tcli_flag: '--no-omnisearch',\n\t\tcli_description: 'Disable mcp-omnisearch reminder extension',\n\t\taliases: ['omnisearch', 'search', 'web-search', 'research'],\n\t\texternal_package_name: '@spences10/pi-omnisearch',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-omnisearch')).default,\n\t},\n\t{\n\t\tkey: 'sqlite-tools',\n\t\tlabel: 'SQLite tools',\n\t\tdocs_label: 'SQLite tools',\n\t\tdescription:\n\t\t\t'mcp-sqlite-tools reminder for safer SQLite database work',\n\t\tdefault_enabled: true,\n\t\toption_name: 'sqlite_tools',\n\t\tcli_arg: 'no-sqlite-tools',\n\t\tcli_flag: '--no-sqlite-tools',\n\t\tcli_description: 'Disable mcp-sqlite-tools reminder extension',\n\t\taliases: ['sqlite-tools', 'sqlite', 'mcp-sqlite-tools'],\n\t\texternal_package_name: '@spences10/pi-sqlite-tools',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-sqlite-tools')).default,\n\t},\n\t{\n\t\tkey: 'startup-screen',\n\t\tlabel: 'Startup screen',\n\t\tdocs_label: 'Startup screen',\n\t\tdescription:\n\t\t\t'Pixel-art gradient startup header for interactive sessions',\n\t\tdefault_enabled: true,\n\t\toption_name: 'startup_screen',\n\t\tcli_arg: 'no-startup-screen',\n\t\tcli_flag: '--no-startup-screen',\n\t\tcli_description: 'Disable the custom startup screen',\n\t\taliases: ['startup-screen', 'startup', 'header', 'splash'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Startup screen only renders in the interactive TUI',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./startup-screen/index.js')).default,\n\t},\n\t{\n\t\tkey: 'prompt-presets',\n\t\tlabel: 'Prompt presets',\n\t\tdocs_label: 'Prompt presets',\n\t\tdescription:\n\t\t\t'Runtime prompt preset selection and /prompt-preset command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'prompt_presets',\n\t\tcli_arg: 'no-prompt-presets',\n\t\tcli_flag: '--no-prompt-presets',\n\t\tcli_description: 'Disable prompt presets extension',\n\t\taliases: ['prompt-preset', 'preset', 'presets'],\n\t\tload: async () =>\n\t\t\t(await import('./prompt-presets/index.js')).default,\n\t},\n\t{\n\t\tkey: 'git-ui',\n\t\tlabel: 'Git UI',\n\t\tdocs_label: 'Git staging UI',\n\t\tdescription: 'Interactive source control staging panel',\n\t\tdefault_enabled: true,\n\t\toption_name: 'git_ui',\n\t\tcli_arg: 'no-git-ui',\n\t\tcli_flag: '--no-git-ui',\n\t\tcli_description: 'Disable built-in Git staging UI',\n\t\taliases: ['git-ui', 'git', 'source-control', 'scm'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Git UI is only useful in interactive mode',\n\t\t},\n\t\texternal_package_name: '@spences10/pi-git-ui',\n\t\tload: async () => (await import('@spences10/pi-git-ui')).default,\n\t},\n\t{\n\t\tkey: 'lsp',\n\t\tlabel: 'LSP',\n\t\tdocs_label: 'LSP',\n\t\tdescription:\n\t\t\t'Language Server Protocol tools (diagnostics, hover, definition, references)',\n\t\tdefault_enabled: true,\n\t\toption_name: 'lsp',\n\t\tcli_arg: 'no-lsp',\n\t\tcli_flag: '--no-lsp',\n\t\tcli_description: 'Disable LSP extension',\n\t\taliases: ['lsp', 'language-server'],\n\t\texternal_package_name: '@spences10/pi-lsp',\n\t\tload: async () => (await import('@spences10/pi-lsp')).default,\n\t},\n\t{\n\t\tkey: 'session-name',\n\t\tlabel: 'Session name',\n\t\tdocs_label: 'Session auto-naming',\n\t\tdescription:\n\t\t\t'AI-powered session auto-naming and /session-name command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'session_name',\n\t\tcli_arg: 'no-session-name',\n\t\tcli_flag: '--no-session-name',\n\t\tcli_description: 'Disable session name extension',\n\t\taliases: ['session-name', 'session', 'auto-name'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason:\n\t\t\t\t'UI-only session naming is only useful in interactive mode',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./session-name/index.js')).default,\n\t},\n\t{\n\t\tkey: 'confirm-destructive',\n\t\tlabel: 'Confirm destructive',\n\t\tdocs_label: 'Destructive action confirmation',\n\t\tdescription:\n\t\t\t'Prompt before destructive tool calls like file deletes, overwrites, and hard resets',\n\t\tdefault_enabled: true,\n\t\toption_name: 'confirm_destructive',\n\t\tcli_arg: 'no-confirm-destructive',\n\t\tcli_flag: '--no-confirm-destructive',\n\t\tcli_description: 'Disable destructive action confirmations',\n\t\taliases: ['confirm-destructive', 'confirm'],\n\t\texternal_package_name: '@spences10/pi-confirm-destructive',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-confirm-destructive')).default,\n\t},\n\t{\n\t\tkey: 'hooks-resolution',\n\t\tlabel: 'Hooks resolution',\n\t\tdocs_label: 'Hooks resolution',\n\t\tdescription:\n\t\t\t'Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs',\n\t\tdefault_enabled: true,\n\t\toption_name: 'hooks_resolution',\n\t\tcli_arg: 'no-hooks',\n\t\tcli_flag: '--no-hooks',\n\t\tcli_description: 'Disable Claude-style hook execution',\n\t\taliases: ['hooks-resolution', 'hooks'],\n\t\tload: async () =>\n\t\t\t(await import('./hooks-resolution/index.js')).default,\n\t},\n\t{\n\t\tkey: 'svelte-guardrails',\n\t\tlabel: 'Svelte guardrails',\n\t\tdocs_label: 'Svelte guardrails',\n\t\tdescription:\n\t\t\t'Blocks discouraged Svelte patterns like $effect before agents write them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'svelte_guardrails',\n\t\tcli_arg: 'no-svelte-guardrails',\n\t\tcli_flag: '--no-svelte-guardrails',\n\t\tcli_description: 'Disable Svelte guardrails',\n\t\taliases: ['svelte-guardrails', 'svelte'],\n\t\texternal_package_name: '@spences10/pi-svelte-guardrails',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-svelte-guardrails')).default,\n\t},\n\t{\n\t\tkey: 'coding-preferences',\n\t\tlabel: 'Coding preferences',\n\t\tdocs_label: 'Coding preferences',\n\t\tdescription:\n\t\t\t'Blocks configured coding workflow anti-patterns from JSON preferences',\n\t\tdefault_enabled: true,\n\t\toption_name: 'coding_preferences',\n\t\tcli_arg: 'no-coding-preferences',\n\t\tcli_flag: '--no-coding-preferences',\n\t\tcli_description: 'Disable coding preferences guardrails',\n\t\taliases: ['coding-preferences', 'preferences', 'prefs'],\n\t\texternal_package_name: '@spences10/pi-coding-preferences',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-coding-preferences')).default,\n\t},\n\t{\n\t\tkey: 'handoff',\n\t\tlabel: 'Handoff',\n\t\tdocs_label: 'Handoff',\n\t\tdescription:\n\t\t\t'Help command for Pi continuation primitives like /fork, /tree, /export, /import, and /share',\n\t\tdefault_enabled: true,\n\t\toption_name: 'handoff',\n\t\tcli_arg: 'no-handoff',\n\t\tcli_flag: '--no-handoff',\n\t\tcli_description: 'Disable handoff helper command',\n\t\taliases: ['handoff', 'continuation'],\n\t\tload: async () => (await import('./handoff/index.js')).default,\n\t},\n\t{\n\t\tkey: 'team-mode',\n\t\tlabel: 'Team mode',\n\t\tdocs_label: 'Team mode',\n\t\tdescription:\n\t\t\t'Peer coordination between independently opened Pi sessions with groups, artifacts, and durable mailboxes',\n\t\tdefault_enabled: true,\n\t\toption_name: 'team_mode',\n\t\tcli_arg: 'no-team-mode',\n\t\tcli_flag: '--no-team-mode',\n\t\tcli_description: 'Disable peer-session team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\n\t\texternal_package_name: '@spences10/pi-team-mode',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-team-mode')).default,\n\t},\n] as const satisfies readonly BuiltinExtensionManifestEntry[];\n\nexport type BuiltinExtensionKey =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['key'];\n\nexport type BuiltinExtensionOptionName =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['option_name'];\n\nexport type BuiltinExtensionInfo = Omit<\n\tBuiltinExtensionManifestEntry,\n\t'load'\n> & {\n\tkey: BuiltinExtensionKey;\n\toption_name: BuiltinExtensionOptionName;\n};\n\nexport const BUILTIN_EXTENSIONS: BuiltinExtensionInfo[] =\n\tBUILTIN_EXTENSION_REGISTRY.map(\n\t\t({ load: _load, ...extension }) => extension,\n\t);\n"],"mappings":";AA6BA,MAAa,6BAA6B;CACzC;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBACC;EACD,SAAS;GAAC;GAAmB;GAAW;EAAS;EACjD,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,yBAAA,CAA0B;CAC3D;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,KAAK;EACf,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,qBAAA,CAAsB;CACvD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,4BAA4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B,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAa;GAAQ;EAAW;EAC1C,uBAAuB;EACvB,MAAM,aACJ,MAAM,OAAO,2BAAA,CAA4B;CAC5C;AACD;AAgBA,MAAa,qBACZ,2BAA2B,KACzB,EAAE,MAAM,OAAO,GAAG,gBAAgB,SACpC"}
|
|
1
|
+
{"version":3,"file":"builtin-registry-CvuaboQf.js","names":[],"sources":["../src/extensions/builtin-registry.ts"],"sourcesContent":["import type { ExtensionFactory } from '@earendil-works/pi-coding-agent';\n\nexport type BuiltinExtensionRuntimeMode =\n\t| 'interactive'\n\t| 'print'\n\t| 'json'\n\t| 'rpc';\n\ntype BuiltinExtensionLoader = () => Promise<ExtensionFactory>;\n\nexport interface BuiltinExtensionManifestEntry {\n\tkey: string;\n\tlabel: string;\n\tdocs_label: string;\n\tdescription: string;\n\tdefault_enabled: boolean;\n\toption_name: string;\n\tcli_arg: string;\n\tcli_flag: `--${string}`;\n\tcli_description: string;\n\taliases: readonly string[];\n\tmode_constraints?: {\n\t\tdisabled_in: readonly BuiltinExtensionRuntimeMode[];\n\t\treason: string;\n\t};\n\texternal_package_name?: string;\n\tload: BuiltinExtensionLoader;\n}\n\nexport const BUILTIN_EXTENSION_REGISTRY = [\n\t{\n\t\tkey: 'context-sidecar',\n\t\tlabel: 'Context sidecar',\n\t\tdocs_label: 'SQLite context sidecar',\n\t\tdescription: 'Local SQLite FTS sidecar for oversized tool output',\n\t\tdefault_enabled: true,\n\t\toption_name: 'context_sidecar',\n\t\tcli_arg: 'no-context-sidecar',\n\t\tcli_flag: '--no-context-sidecar',\n\t\tcli_description:\n\t\t\t'Disable SQLite context sidecar for large tool output',\n\t\taliases: ['context-sidecar', 'context', 'sidecar'],\n\t\texternal_package_name: '@spences10/pi-context',\n\t\tload: async () => (await import('@spences10/pi-context')).default,\n\t},\n\t{\n\t\tkey: 'mcp',\n\t\tlabel: 'MCP',\n\t\tdocs_label: 'MCP',\n\t\tdescription: 'MCP server integration and /mcp command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'mcp',\n\t\tcli_arg: 'no-mcp',\n\t\tcli_flag: '--no-mcp',\n\t\tcli_description: 'Disable built-in MCP extension',\n\t\taliases: ['mcp'],\n\t\texternal_package_name: '@spences10/pi-mcp',\n\t\tload: async () => (await import('@spences10/pi-mcp')).default,\n\t},\n\t{\n\t\tkey: 'openrouter-fusion-config',\n\t\tlabel: 'OpenRouter Fusion config',\n\t\tdocs_label: 'OpenRouter Fusion config guard',\n\t\tdescription:\n\t\t\t'Keeps OpenRouter Fusion off Anthropic by injecting a non-Anthropic panel and judge',\n\t\tdefault_enabled: true,\n\t\toption_name: 'openrouter_fusion_config',\n\t\tcli_arg: 'no-openrouter-fusion-config',\n\t\tcli_flag: '--no-openrouter-fusion-config',\n\t\tcli_description: 'Disable OpenRouter Fusion non-Anthropic config',\n\t\taliases: ['openrouter-fusion-config', 'fusion-budget'],\n\t\tload: async () =>\n\t\t\t(await import('./openrouter-fusion-config/index.js')).default,\n\t},\n\t{\n\t\tkey: 'umans-provider',\n\t\tlabel: 'Umans provider',\n\t\tdocs_label: 'Umans provider',\n\t\tdescription:\n\t\t\t'Umans.ai Anthropic Messages provider with API key login support',\n\t\tdefault_enabled: true,\n\t\toption_name: 'umans_provider',\n\t\tcli_arg: 'no-umans-provider',\n\t\tcli_flag: '--no-umans-provider',\n\t\tcli_description: 'Disable built-in Umans provider',\n\t\taliases: ['umans-provider', 'umans'],\n\t\tload: async () =>\n\t\t\t(await import('./umans-provider/index.js')).default,\n\t},\n\t{\n\t\tkey: 'footer',\n\t\tlabel: 'Footer',\n\t\tdocs_label: 'Footer',\n\t\tdescription: 'Configurable interactive footer/statusline',\n\t\tdefault_enabled: true,\n\t\toption_name: 'footer',\n\t\tcli_arg: 'no-footer',\n\t\tcli_flag: '--no-footer',\n\t\tcli_description: 'Disable custom footer/statusline',\n\t\taliases: ['footer', 'statusline', 'status-line'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Footer only renders in the interactive TUI',\n\t\t},\n\t\tload: async () => (await import('./footer/index.js')).default,\n\t},\n\t{\n\t\tkey: 'codex-usage',\n\t\tlabel: 'Codex usage',\n\t\tdocs_label: 'Codex usage status',\n\t\tdescription: 'OpenAI Codex usage status for the footer',\n\t\tdefault_enabled: true,\n\t\toption_name: 'codex_usage',\n\t\tcli_arg: 'no-codex-usage',\n\t\tcli_flag: '--no-codex-usage',\n\t\tcli_description: 'Disable Codex usage footer status',\n\t\taliases: ['codex-usage', 'codex-status'],\n\t\texternal_package_name: '@spences10/pi-codex-usage',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-codex-usage')).default,\n\t},\n\t{\n\t\tkey: 'harness',\n\t\tlabel: 'Harness',\n\t\tdocs_label: 'Task harness runtime',\n\t\tdescription:\n\t\t\t'Ephemeral /tmp task harness runtime with tools, enforcement, and bundled skills',\n\t\tdefault_enabled: true,\n\t\toption_name: 'harness',\n\t\tcli_arg: 'no-harness',\n\t\tcli_flag: '--no-harness',\n\t\tcli_description: 'Disable task harness runtime',\n\t\taliases: ['harness', 'task-harness'],\n\t\texternal_package_name: '@spences10/pi-harness',\n\t\tload: async () => (await import('@spences10/pi-harness')).default,\n\t},\n\t{\n\t\tkey: 'skills',\n\t\tlabel: 'Skills',\n\t\tdocs_label: 'Skills',\n\t\tdescription: 'Managed pi-native skills and /skills command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skills',\n\t\tcli_arg: 'no-skills',\n\t\tcli_flag: '--no-skills',\n\t\tcli_description: 'Disable built-in skills extension',\n\t\taliases: ['skills', 'skill'],\n\t\texternal_package_name: '@spences10/pi-skills',\n\t\tload: async () => (await import('@spences10/pi-skills')).default,\n\t},\n\t{\n\t\tkey: 'skill-importer',\n\t\tlabel: 'Skill importer',\n\t\tdocs_label: 'Skill importer',\n\t\tdescription:\n\t\t\t'Import external Claude/plugin skills into Pi-native storage',\n\t\tdefault_enabled: true,\n\t\toption_name: 'skill_importer',\n\t\tcli_arg: 'no-skill-importer',\n\t\tcli_flag: '--no-skill-importer',\n\t\tcli_description: 'Disable external skill importer extension',\n\t\taliases: ['skill-importer', 'import-skills', 'skill-import'],\n\t\texternal_package_name: '@spences10/pi-skill-importer',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-skill-importer')).default,\n\t},\n\t{\n\t\tkey: 'filter-output',\n\t\tlabel: 'Secret redaction',\n\t\tdocs_label: 'Secret redaction',\n\t\tdescription:\n\t\t\t'Redacts secrets from tool output before the model sees them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'filter_output',\n\t\tcli_arg: 'no-filter',\n\t\tcli_flag: '--no-filter',\n\t\tcli_description: 'Disable secret redaction in tool output',\n\t\taliases: [\n\t\t\t'filter-output',\n\t\t\t'filter_output',\n\t\t\t'filter',\n\t\t\t'redaction',\n\t\t\t'secret-redaction',\n\t\t\t'output-redaction',\n\t\t],\n\t\texternal_package_name: '@spences10/pi-redact',\n\t\tload: async () => (await import('@spences10/pi-redact')).default,\n\t},\n\t{\n\t\tkey: 'recall',\n\t\tlabel: 'Recall',\n\t\tdocs_label: 'Recall',\n\t\tdescription: 'pirecall reminder and background session sync',\n\t\tdefault_enabled: true,\n\t\toption_name: 'recall',\n\t\tcli_arg: 'no-recall',\n\t\tcli_flag: '--no-recall',\n\t\tcli_description: 'Disable recall extension',\n\t\taliases: ['recall', 'pirecall'],\n\t\texternal_package_name: '@spences10/pi-recall',\n\t\tload: async () => (await import('@spences10/pi-recall')).default,\n\t},\n\t{\n\t\tkey: 'nopeek',\n\t\tlabel: 'Nopeek',\n\t\tdocs_label: 'Nopeek',\n\t\tdescription:\n\t\t\t'nopeek reminder for secret-safe environment loading',\n\t\tdefault_enabled: true,\n\t\toption_name: 'nopeek',\n\t\tcli_arg: 'no-nopeek',\n\t\tcli_flag: '--no-nopeek',\n\t\tcli_description: 'Disable nopeek reminder extension',\n\t\taliases: ['nopeek', 'secrets', 'secret-loading'],\n\t\texternal_package_name: '@spences10/pi-nopeek',\n\t\tload: async () => (await import('@spences10/pi-nopeek')).default,\n\t},\n\t{\n\t\tkey: 'observability',\n\t\tlabel: 'Observability',\n\t\tdocs_label: 'Live observability',\n\t\tdescription:\n\t\t\t'Optional live event stream and local browser dashboard',\n\t\tdefault_enabled: true,\n\t\toption_name: 'observability',\n\t\tcli_arg: 'no-observability',\n\t\tcli_flag: '--no-observability',\n\t\tcli_description: 'Disable live observability extension',\n\t\taliases: ['observability', 'obs', 'live-events'],\n\t\texternal_package_name: '@spences10/pi-observability',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-observability')).default,\n\t},\n\t{\n\t\tkey: 'omnisearch',\n\t\tlabel: 'Omnisearch',\n\t\tdocs_label: 'Omnisearch',\n\t\tdescription: 'mcp-omnisearch reminder for verified web research',\n\t\tdefault_enabled: true,\n\t\toption_name: 'omnisearch',\n\t\tcli_arg: 'no-omnisearch',\n\t\tcli_flag: '--no-omnisearch',\n\t\tcli_description: 'Disable mcp-omnisearch reminder extension',\n\t\taliases: ['omnisearch', 'search', 'web-search', 'research'],\n\t\texternal_package_name: '@spences10/pi-omnisearch',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-omnisearch')).default,\n\t},\n\t{\n\t\tkey: 'sqlite-tools',\n\t\tlabel: 'SQLite tools',\n\t\tdocs_label: 'SQLite tools',\n\t\tdescription:\n\t\t\t'mcp-sqlite-tools reminder for safer SQLite database work',\n\t\tdefault_enabled: true,\n\t\toption_name: 'sqlite_tools',\n\t\tcli_arg: 'no-sqlite-tools',\n\t\tcli_flag: '--no-sqlite-tools',\n\t\tcli_description: 'Disable mcp-sqlite-tools reminder extension',\n\t\taliases: ['sqlite-tools', 'sqlite', 'mcp-sqlite-tools'],\n\t\texternal_package_name: '@spences10/pi-sqlite-tools',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-sqlite-tools')).default,\n\t},\n\t{\n\t\tkey: 'startup-screen',\n\t\tlabel: 'Startup screen',\n\t\tdocs_label: 'Startup screen',\n\t\tdescription:\n\t\t\t'Pixel-art gradient startup header for interactive sessions',\n\t\tdefault_enabled: true,\n\t\toption_name: 'startup_screen',\n\t\tcli_arg: 'no-startup-screen',\n\t\tcli_flag: '--no-startup-screen',\n\t\tcli_description: 'Disable the custom startup screen',\n\t\taliases: ['startup-screen', 'startup', 'header', 'splash'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Startup screen only renders in the interactive TUI',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./startup-screen/index.js')).default,\n\t},\n\t{\n\t\tkey: 'prompt-presets',\n\t\tlabel: 'Prompt presets',\n\t\tdocs_label: 'Prompt presets',\n\t\tdescription:\n\t\t\t'Runtime prompt preset selection and /prompt-preset command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'prompt_presets',\n\t\tcli_arg: 'no-prompt-presets',\n\t\tcli_flag: '--no-prompt-presets',\n\t\tcli_description: 'Disable prompt presets extension',\n\t\taliases: ['prompt-preset', 'preset', 'presets'],\n\t\tload: async () =>\n\t\t\t(await import('./prompt-presets/index.js')).default,\n\t},\n\t{\n\t\tkey: 'git-ui',\n\t\tlabel: 'Git UI',\n\t\tdocs_label: 'Git staging UI',\n\t\tdescription: 'Interactive source control staging panel',\n\t\tdefault_enabled: true,\n\t\toption_name: 'git_ui',\n\t\tcli_arg: 'no-git-ui',\n\t\tcli_flag: '--no-git-ui',\n\t\tcli_description: 'Disable built-in Git staging UI',\n\t\taliases: ['git-ui', 'git', 'source-control', 'scm'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason: 'Git UI is only useful in interactive mode',\n\t\t},\n\t\texternal_package_name: '@spences10/pi-git-ui',\n\t\tload: async () => (await import('@spences10/pi-git-ui')).default,\n\t},\n\t{\n\t\tkey: 'lsp',\n\t\tlabel: 'LSP',\n\t\tdocs_label: 'LSP',\n\t\tdescription:\n\t\t\t'Language Server Protocol tools (diagnostics, hover, definition, references)',\n\t\tdefault_enabled: true,\n\t\toption_name: 'lsp',\n\t\tcli_arg: 'no-lsp',\n\t\tcli_flag: '--no-lsp',\n\t\tcli_description: 'Disable LSP extension',\n\t\taliases: ['lsp', 'language-server'],\n\t\texternal_package_name: '@spences10/pi-lsp',\n\t\tload: async () => (await import('@spences10/pi-lsp')).default,\n\t},\n\t{\n\t\tkey: 'session-name',\n\t\tlabel: 'Session name',\n\t\tdocs_label: 'Session auto-naming',\n\t\tdescription:\n\t\t\t'AI-powered session auto-naming and /session-name command',\n\t\tdefault_enabled: true,\n\t\toption_name: 'session_name',\n\t\tcli_arg: 'no-session-name',\n\t\tcli_flag: '--no-session-name',\n\t\tcli_description: 'Disable session name extension',\n\t\taliases: ['session-name', 'session', 'auto-name'],\n\t\tmode_constraints: {\n\t\t\tdisabled_in: ['print', 'json', 'rpc'],\n\t\t\treason:\n\t\t\t\t'UI-only session naming is only useful in interactive mode',\n\t\t},\n\t\tload: async () =>\n\t\t\t(await import('./session-name/index.js')).default,\n\t},\n\t{\n\t\tkey: 'confirm-destructive',\n\t\tlabel: 'Confirm destructive',\n\t\tdocs_label: 'Destructive action confirmation',\n\t\tdescription:\n\t\t\t'Prompt before destructive tool calls like file deletes, overwrites, and hard resets',\n\t\tdefault_enabled: true,\n\t\toption_name: 'confirm_destructive',\n\t\tcli_arg: 'no-confirm-destructive',\n\t\tcli_flag: '--no-confirm-destructive',\n\t\tcli_description: 'Disable destructive action confirmations',\n\t\taliases: ['confirm-destructive', 'confirm'],\n\t\texternal_package_name: '@spences10/pi-confirm-destructive',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-confirm-destructive')).default,\n\t},\n\t{\n\t\tkey: 'hooks-resolution',\n\t\tlabel: 'Hooks resolution',\n\t\tdocs_label: 'Hooks resolution',\n\t\tdescription:\n\t\t\t'Claude Code style PreToolUse and PostToolUse hook compatibility from .claude, .rulesync, and .pi configs',\n\t\tdefault_enabled: true,\n\t\toption_name: 'hooks_resolution',\n\t\tcli_arg: 'no-hooks',\n\t\tcli_flag: '--no-hooks',\n\t\tcli_description: 'Disable Claude-style hook execution',\n\t\taliases: ['hooks-resolution', 'hooks'],\n\t\tload: async () =>\n\t\t\t(await import('./hooks-resolution/index.js')).default,\n\t},\n\t{\n\t\tkey: 'svelte-guardrails',\n\t\tlabel: 'Svelte guardrails',\n\t\tdocs_label: 'Svelte guardrails',\n\t\tdescription:\n\t\t\t'Blocks discouraged Svelte patterns like $effect before agents write them',\n\t\tdefault_enabled: true,\n\t\toption_name: 'svelte_guardrails',\n\t\tcli_arg: 'no-svelte-guardrails',\n\t\tcli_flag: '--no-svelte-guardrails',\n\t\tcli_description: 'Disable Svelte guardrails',\n\t\taliases: ['svelte-guardrails', 'svelte'],\n\t\texternal_package_name: '@spences10/pi-svelte-guardrails',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-svelte-guardrails')).default,\n\t},\n\t{\n\t\tkey: 'coding-preferences',\n\t\tlabel: 'Coding preferences',\n\t\tdocs_label: 'Coding preferences',\n\t\tdescription:\n\t\t\t'Blocks configured coding workflow anti-patterns from JSON preferences',\n\t\tdefault_enabled: true,\n\t\toption_name: 'coding_preferences',\n\t\tcli_arg: 'no-coding-preferences',\n\t\tcli_flag: '--no-coding-preferences',\n\t\tcli_description: 'Disable coding preferences guardrails',\n\t\taliases: ['coding-preferences', 'preferences', 'prefs'],\n\t\texternal_package_name: '@spences10/pi-coding-preferences',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-coding-preferences')).default,\n\t},\n\t{\n\t\tkey: 'handoff',\n\t\tlabel: 'Handoff',\n\t\tdocs_label: 'Handoff',\n\t\tdescription:\n\t\t\t'Help command for Pi continuation primitives like /fork, /tree, /export, /import, and /share',\n\t\tdefault_enabled: true,\n\t\toption_name: 'handoff',\n\t\tcli_arg: 'no-handoff',\n\t\tcli_flag: '--no-handoff',\n\t\tcli_description: 'Disable handoff helper command',\n\t\taliases: ['handoff', 'continuation'],\n\t\tload: async () => (await import('./handoff/index.js')).default,\n\t},\n\t{\n\t\tkey: 'team-mode',\n\t\tlabel: 'Team mode',\n\t\tdocs_label: 'Team mode',\n\t\tdescription:\n\t\t\t'Peer coordination between independently opened Pi sessions with groups, artifacts, and durable mailboxes',\n\t\tdefault_enabled: true,\n\t\toption_name: 'team_mode',\n\t\tcli_arg: 'no-team-mode',\n\t\tcli_flag: '--no-team-mode',\n\t\tcli_description: 'Disable peer-session team mode extension',\n\t\taliases: ['team-mode', 'team', 'teammates'],\n\t\texternal_package_name: '@spences10/pi-team-mode',\n\t\tload: async () =>\n\t\t\t(await import('@spences10/pi-team-mode')).default,\n\t},\n] as const satisfies readonly BuiltinExtensionManifestEntry[];\n\nexport type BuiltinExtensionKey =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['key'];\n\nexport type BuiltinExtensionOptionName =\n\t(typeof BUILTIN_EXTENSION_REGISTRY)[number]['option_name'];\n\nexport type BuiltinExtensionInfo = Omit<\n\tBuiltinExtensionManifestEntry,\n\t'load'\n> & {\n\tkey: BuiltinExtensionKey;\n\toption_name: BuiltinExtensionOptionName;\n};\n\nexport const BUILTIN_EXTENSIONS: BuiltinExtensionInfo[] =\n\tBUILTIN_EXTENSION_REGISTRY.map(\n\t\t({ load: _load, ...extension }) => extension,\n\t);\n"],"mappings":";AA6BA,MAAa,6BAA6B;CACzC;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBACC;EACD,SAAS;GAAC;GAAmB;GAAW;EAAS;EACjD,uBAAuB;EACvB,MAAM,aAAa,MAAM,OAAO,yBAAA,CAA0B;CAC3D;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aAAa;EACb,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,KAAK;EACf,uB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B,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS,CAAC,WAAW,cAAc;EACnC,MAAM,aAAa,MAAM,OAAO,yBAAA,CAAuB;CACxD;CACA;EACC,KAAK;EACL,OAAO;EACP,YAAY;EACZ,aACC;EACD,iBAAiB;EACjB,aAAa;EACb,SAAS;EACT,UAAU;EACV,iBAAiB;EACjB,SAAS;GAAC;GAAa;GAAQ;EAAW;EAC1C,uBAAuB;EACvB,MAAM,aACJ,MAAM,OAAO,2BAAA,CAA4B;CAC5C;AACD;AAgBA,MAAa,qBACZ,2BAA2B,KACzB,EAAE,MAAM,OAAO,GAAG,gBAAgB,SACpC"}
|
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-CvuaboQf.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";
|
|
@@ -123,7 +123,8 @@ const DEFAULT_PROMPT_PRESET_FILES = {
|
|
|
123
123
|
bullets: "---\nkind: layer\ndescription: Prefer short bullets when useful\n---\n\nWhen presenting options, findings, or steps, prefer short bullet lists\nover long paragraphs.\n",
|
|
124
124
|
"clarify-first": "---\nkind: layer\ndescription:\n Ask brief clarifying questions when requirements are ambiguous\n---\n\nIf the request is materially ambiguous, ask the minimum clarifying\nquestion(s) needed before proceeding. Do not ask unnecessary\nquestions.\n",
|
|
125
125
|
"include-risks": "---\nkind: layer\ndescription: Call out notable risks or tradeoffs\n---\n\nWhen making a recommendation or implementation plan, briefly mention\nthe key risk, tradeoff, or caveat if one materially matters.\n",
|
|
126
|
-
karpathy: "---\nkind: layer\ndescription: Bias toward simple, surgical, verified code changes\n---\n\nBefore coding, state assumptions when unclear and surface meaningful\ntradeoffs. Prefer the minimum code that solves the request; avoid\nspeculative abstractions, flexibility, and unrelated cleanup. Make\nsurgical changes: touch only lines directly tied to the task, match\nexisting style, and mention unrelated issues instead of fixing them.\nFor multi-step work, use brief success criteria and verify with\nfocused checks before reporting.\n"
|
|
126
|
+
karpathy: "---\nkind: layer\ndescription: Bias toward simple, surgical, verified code changes\n---\n\nBefore coding, state assumptions when unclear and surface meaningful\ntradeoffs. Prefer the minimum code that solves the request; avoid\nspeculative abstractions, flexibility, and unrelated cleanup. Make\nsurgical changes: touch only lines directly tied to the task, match\nexisting style, and mention unrelated issues instead of fixing them.\nFor multi-step work, use brief success criteria and verify with\nfocused checks before reporting.\n",
|
|
127
|
+
spence: "---\nkind: layer\ndescription:\n Discuss critically, then execute the agreed outcome autonomously\n---\n\nMatch the user's working mode. When they are exploring, asking what\nyou think, or requesting discussion or research, investigate and\nrespond critically before making changes. Challenge weak assumptions,\nconsider the wider outcome, and do not agree merely to be agreeable.\n\nOnce the user authorises implementation, treat the agreed requirements\nand decisions as the work contract. Complete that outcome and validate\nit without stopping at a plan, an arbitrary partial slice, or repeated\npermission checks. Keep the implementation focused, but never shrink\nthe requested outcome merely to keep the change small.\n\nRespect explicit review and approval boundaries.\n"
|
|
127
128
|
};
|
|
128
129
|
function parse_default_prompt_preset(content) {
|
|
129
130
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
@@ -996,4 +997,4 @@ async function prompt_presets(pi) {
|
|
|
996
997
|
//#endregion
|
|
997
998
|
export { prompt_presets as default };
|
|
998
999
|
|
|
999
|
-
//# sourceMappingURL=prompt-presets-
|
|
1000
|
+
//# sourceMappingURL=prompt-presets-Lb8mMDHY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-presets-Lb8mMDHY.js","names":["no_purple_prose","clarify_first","include_risks"],"sources":["../src/extensions/prompt-presets/catalog.ts","../src/extensions/prompt-presets/completions.ts","../src/extensions/prompt-presets/defaults/bullets.md","../src/extensions/prompt-presets/defaults/clarify-first.md","../src/extensions/prompt-presets/defaults/detailed.md","../src/extensions/prompt-presets/defaults/include-risks.md","../src/extensions/prompt-presets/defaults/karpathy.md","../src/extensions/prompt-presets/defaults/no-purple-prose.md","../src/extensions/prompt-presets/defaults/spence.md","../src/extensions/prompt-presets/defaults/standard.md","../src/extensions/prompt-presets/defaults/terse.md","../src/extensions/prompt-presets/defaults.ts","../src/extensions/prompt-presets/footer.ts","../src/extensions/prompt-presets/help.ts","../src/extensions/prompt-presets/prompt-blocks.ts","../src/extensions/prompt-presets/storage.ts","../src/extensions/prompt-presets/state.ts","../src/extensions/prompt-presets/manager.ts","../src/extensions/prompt-presets/index.ts"],"sourcesContent":["import type {\n\tLoadedPromptPreset,\n\tPromptPresetSource,\n} from './types.js';\n\nexport function get_prompt_source_label(\n\tsource: PromptPresetSource,\n): string {\n\tswitch (source) {\n\t\tcase 'builtin':\n\t\t\treturn 'built-in';\n\t\tcase 'user':\n\t\t\treturn 'user';\n\t\tcase 'project':\n\t\t\treturn 'project';\n\t}\n}\n\nexport function list_base_presets(\n\tpresets: Record<string, LoadedPromptPreset>,\n): LoadedPromptPreset[] {\n\treturn Object.values(presets)\n\t\t.filter((preset) => preset.kind === 'base')\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function list_layer_presets(\n\tpresets: Record<string, LoadedPromptPreset>,\n): LoadedPromptPreset[] {\n\treturn Object.values(presets)\n\t\t.filter((preset) => preset.kind === 'layer')\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function format_summary(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n\tpresets: Record<string, LoadedPromptPreset>,\n): string {\n\tconst lines = [`Base: ${active_base_name ?? '(none)'}`];\n\n\tconst layer_names = [...active_layers].sort();\n\tif (layer_names.length === 0) {\n\t\tlines.push('Layers: (none)');\n\t} else {\n\t\tlines.push('Layers:');\n\t\tfor (const name of layer_names) {\n\t\t\tconst preset = presets[name];\n\t\t\tconst description = preset?.description\n\t\t\t\t? ` — ${preset.description}`\n\t\t\t\t: '';\n\t\t\tlines.push(`- ${name}${description}`);\n\t\t}\n\t}\n\n\treturn lines.join('\\n');\n}\n\nexport function format_active_details(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n\tpresets: Record<string, LoadedPromptPreset>,\n): string {\n\tconst parts: string[] = [];\n\n\tif (active_base_name) {\n\t\tconst base = presets[active_base_name];\n\t\tif (base) {\n\t\t\tparts.push(`Base: ${base.name}`);\n\t\t\tif (base.description)\n\t\t\t\tparts.push(`Description: ${base.description}`);\n\t\t\tparts.push(`Source: ${get_prompt_source_label(base.source)}`);\n\t\t\tparts.push('', base.instructions.trim());\n\t\t}\n\t}\n\n\tconst layer_names = [...active_layers].sort();\n\tif (layer_names.length > 0) {\n\t\tif (parts.length > 0) parts.push('', '---', '');\n\t\tparts.push('Layers:');\n\t\tfor (const name of layer_names) {\n\t\t\tconst layer = presets[name];\n\t\t\tif (!layer) continue;\n\t\t\tparts.push(\n\t\t\t\t`- ${layer.name} (${get_prompt_source_label(layer.source)})`,\n\t\t\t);\n\t\t\tif (layer.description) parts.push(` ${layer.description}`);\n\t\t}\n\t}\n\n\treturn parts.join('\\n') || 'No preset or layers active';\n}\n","import { list_base_presets, list_layer_presets } from './catalog.js';\nimport type { LoadedPromptPreset } from './types.js';\n\nconst SUBCOMMANDS = [\n\t'help',\n\t'list',\n\t'show',\n\t'clear',\n\t'edit',\n\t'edit-global',\n\t'export-defaults',\n\t'delete',\n\t'reset',\n\t'reload',\n\t'base',\n\t'enable',\n\t'disable',\n\t'toggle',\n];\n\nexport function get_prompt_preset_completions(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tprefix: string,\n): Array<{ value: string; label: string }> | null {\n\tconst trimmed = prefix.trim();\n\tconst parts = trimmed ? trimmed.split(/\\s+/) : [];\n\tconst base_names = list_base_presets(presets).map(\n\t\t(preset) => preset.name,\n\t);\n\tconst layer_names = list_layer_presets(presets).map(\n\t\t(preset) => preset.name,\n\t);\n\tconst all_names = [...base_names, ...layer_names];\n\n\tif (parts.length <= 1) {\n\t\tconst query = parts[0] ?? '';\n\t\treturn [\n\t\t\t...SUBCOMMANDS.filter((item) => item.startsWith(query)).map(\n\t\t\t\t(item) => ({ value: item, label: item }),\n\t\t\t),\n\t\t\t...all_names\n\t\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t\t.map((item) => ({ value: item, label: item })),\n\t\t];\n\t}\n\n\tconst command = parts[0];\n\tconst query = parts.slice(1).join(' ');\n\tif (command === 'base') {\n\t\treturn base_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({ value: `base ${item}`, label: item }));\n\t}\n\tif (['enable', 'disable', 'toggle'].includes(command)) {\n\t\treturn layer_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\tif (command === 'edit' || command === 'edit-global') {\n\t\treturn all_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\tif (['delete', 'reset'].includes(command)) {\n\t\treturn all_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\treturn null;\n}\n","\"---\\nkind: layer\\ndescription: Prefer short bullets when useful\\n---\\n\\nWhen presenting options, findings, or steps, prefer short bullet lists\\nover long paragraphs.\\n\"","\"---\\nkind: layer\\ndescription:\\n Ask brief clarifying questions when requirements are ambiguous\\n---\\n\\nIf the request is materially ambiguous, ask the minimum clarifying\\nquestion(s) needed before proceeding. Do not ask unnecessary\\nquestions.\\n\"","\"---\\nkind: base\\ndescription: More explanation when nuance matters\\n---\\n\\nBe thorough when the task is complex or tradeoffs matter, but stay\\npractical. Explain only the details that help the user decide, verify,\\nor implement. Avoid purple prose and unnecessary scene-setting.\\n\"","\"---\\nkind: layer\\ndescription: Call out notable risks or tradeoffs\\n---\\n\\nWhen making a recommendation or implementation plan, briefly mention\\nthe key risk, tradeoff, or caveat if one materially matters.\\n\"","\"---\\nkind: layer\\ndescription: Bias toward simple, surgical, verified code changes\\n---\\n\\nBefore coding, state assumptions when unclear and surface meaningful\\ntradeoffs. Prefer the minimum code that solves the request; avoid\\nspeculative abstractions, flexibility, and unrelated cleanup. Make\\nsurgical changes: touch only lines directly tied to the task, match\\nexisting style, and mention unrelated issues instead of fixing them.\\nFor multi-step work, use brief success criteria and verify with\\nfocused checks before reporting.\\n\"","\"---\\nkind: layer\\ndescription: Strip out ornamental language\\n---\\n\\nDo not use purple prose, flourish, motivational filler, or theatrical\\ntransitions. Prefer plain language and concrete statements.\\n\"","\"---\\nkind: layer\\ndescription:\\n Discuss critically, then execute the agreed outcome autonomously\\n---\\n\\nMatch the user's working mode. When they are exploring, asking what\\nyou think, or requesting discussion or research, investigate and\\nrespond critically before making changes. Challenge weak assumptions,\\nconsider the wider outcome, and do not agree merely to be agreeable.\\n\\nOnce the user authorises implementation, treat the agreed requirements\\nand decisions as the work contract. Complete that outcome and validate\\nit without stopping at a plan, an arbitrary partial slice, or repeated\\npermission checks. Keep the implementation focused, but never shrink\\nthe requested outcome merely to keep the change small.\\n\\nRespect explicit review and approval boundaries.\\n\"","\"---\\nkind: base\\ndescription: Clear and concise with key context\\n---\\n\\nBe clear, direct, and concise. Include only the reasoning and\\nimplementation details that matter. Avoid filler, grandstanding, and\\nornamental language. Use bullets when they improve scanability.\\n\"","\"---\\nkind: base\\ndescription: Short, direct, no fluff\\n---\\n\\nBe concise and direct. Default to the shortest response that fully\\nsolves the user's request. Use at most one short paragraph or 3\\nbullets unless the user explicitly asks for detail. For implementation\\nreports, include only what changed, validation, and the next step if\\nrelevant. No purple prose, no filler, no repetitive caveats.\\n\"","import { parseFrontmatter } from '@earendil-works/pi-coding-agent';\nimport type { PromptPreset, PromptPresetMap } from './types.js';\n\nimport bullets from './defaults/bullets.md';\nimport clarify_first from './defaults/clarify-first.md';\nimport detailed from './defaults/detailed.md';\nimport include_risks from './defaults/include-risks.md';\nimport karpathy from './defaults/karpathy.md';\nimport no_purple_prose from './defaults/no-purple-prose.md';\nimport spence from './defaults/spence.md';\nimport standard from './defaults/standard.md';\nimport terse from './defaults/terse.md';\n\nexport const DEFAULT_BASE_PROMPT_PRESET_NAME = 'terse';\n\nconst DEFAULT_PROMPT_PRESET_FILES = {\n\tterse,\n\tstandard,\n\tdetailed,\n\t'no-purple-prose': no_purple_prose,\n\tbullets,\n\t'clarify-first': clarify_first,\n\t'include-risks': include_risks,\n\tkarpathy,\n\tspence,\n} satisfies Record<string, string>;\n\nfunction parse_default_prompt_preset(content: string): PromptPreset {\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\treturn {\n\t\tkind: frontmatter.kind === 'layer' ? 'layer' : 'base',\n\t\tinstructions: body.trim(),\n\t\t...(typeof frontmatter.description === 'string' &&\n\t\tfrontmatter.description.trim()\n\t\t\t? { description: frontmatter.description.trim() }\n\t\t\t: {}),\n\t};\n}\n\nexport const DEFAULT_PROMPT_PRESETS: PromptPresetMap =\n\tObject.fromEntries(\n\t\tObject.entries(DEFAULT_PROMPT_PRESET_FILES).map(\n\t\t\t([name, content]) => [\n\t\t\t\tname,\n\t\t\t\tparse_default_prompt_preset(content),\n\t\t\t],\n\t\t),\n\t);\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nfunction get_footer_prompt_status(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): string | undefined {\n\tif (!active_base_name && active_layers.size === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst label = active_base_name ?? 'none';\n\tconst layer_suffix =\n\t\tactive_layers.size > 0 ? ` +${active_layers.size}` : '';\n\treturn `prompt:${label}${layer_suffix}`;\n}\n\nexport function set_status(\n\tctx: ExtensionContext,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): void {\n\tctx.ui.setStatus(\n\t\t'preset',\n\t\tget_footer_prompt_status(active_base_name, active_layers),\n\t);\n}\n","export function is_subcommand(command: string): boolean {\n\treturn [\n\t\t'help',\n\t\t'list',\n\t\t'show',\n\t\t'clear',\n\t\t'edit',\n\t\t'edit-global',\n\t\t'export-defaults',\n\t\t'delete',\n\t\t'reset',\n\t\t'reload',\n\t\t'base',\n\t\t'enable',\n\t\t'disable',\n\t\t'toggle',\n\t].includes(command);\n}\n\nexport function format_prompt_preset_help(): string {\n\treturn `Prompt presets append instructions to the system prompt.\n\nCommands:\n- /prompt-preset Open the preset picker\n- /prompt-preset show Show the active base and layers\n- /prompt-preset <name> Activate a base preset or toggle a layer\n- /prompt-preset base <name> Activate a base preset\n- /prompt-preset enable <layer> Enable a layer\n- /prompt-preset disable <layer> Disable a layer\n- /prompt-preset edit <name> Edit/create .pi/presets/<name>.md\n- /prompt-preset edit-global <name> Edit/create ~/.pi/agent/presets/<name>.md\n- /prompt-preset export-defaults Export built-ins to ~/.pi/agent/presets/*.md\n- /prompt-preset export-defaults project Export built-ins to .pi/presets/*.md\n- /prompt-preset reload Reload presets after manual file edits\n- /prompt-preset clear Clear active base and layers\n\nExamples:\n- /prompt-preset export-defaults\n- /prompt-preset edit-global terse\n- /prompt-preset base detailed\n- /prompt-preset enable bullets\n- /prompt-preset show\n\nAlias: /preset`;\n}\n","import type { LoadedPromptPreset } from './types.js';\n\nexport function build_active_prompt_blocks(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): string[] {\n\tconst blocks: string[] = [];\n\tconst base = active_base_name\n\t\t? presets[active_base_name]\n\t\t: undefined;\n\tif (base?.instructions.trim()) {\n\t\tblocks.push(\n\t\t\t`## Active Base Prompt: ${base.name}\\n${base.instructions.trim()}`,\n\t\t);\n\t}\n\n\tconst layer_blocks = [...active_layers]\n\t\t.sort()\n\t\t.map((name) => presets[name])\n\t\t.filter((preset): preset is LoadedPromptPreset =>\n\t\t\tBoolean(preset?.instructions.trim()),\n\t\t)\n\t\t.map(\n\t\t\t(preset) => `### ${preset.name}\\n${preset.instructions.trim()}`,\n\t\t);\n\tif (layer_blocks.length > 0) {\n\t\tblocks.push(\n\t\t\t`## Active Prompt Layers\\n\\n${layer_blocks.join('\\n\\n')}`,\n\t\t);\n\t}\n\n\treturn blocks;\n}\n","import {\n\tgetAgentDir,\n\tparseFrontmatter,\n} from '@earendil-works/pi-coding-agent';\nimport {\n\tread_settings,\n\twrite_settings,\n} from '@spences10/pi-settings';\nimport {\n\texistsSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { DEFAULT_PROMPT_PRESETS } from './defaults.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPreset,\n\tPromptPresetMap,\n\tPromptPresetSource,\n\tPromptPresetState,\n} from './types.js';\n\nconst PROJECT_PROMPT_PRESETS_ENV = 'MY_PI_PROMPT_PRESETS_PROJECT';\n\ninterface PersistedPromptPresetStates {\n\tversion: number;\n\tprojects: Record<string, PromptPresetState>;\n}\n\nexport function normalize_prompt_presets(\n\tinput: unknown,\n): PromptPresetMap {\n\tif (!input || typeof input !== 'object') return {};\n\n\tconst normalized: PromptPresetMap = {};\n\tfor (const [raw_name, raw_value] of Object.entries(input)) {\n\t\tconst name = raw_name.trim();\n\t\tif (!name) continue;\n\n\t\tif (typeof raw_value === 'string') {\n\t\t\tnormalized[name] = {\n\t\t\t\tkind: 'base',\n\t\t\t\tinstructions: raw_value,\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!raw_value || typeof raw_value !== 'object') continue;\n\t\tconst candidate = raw_value as {\n\t\t\tkind?: unknown;\n\t\t\tdescription?: unknown;\n\t\t\tinstructions?: unknown;\n\t\t};\n\t\tif (typeof candidate.instructions !== 'string') continue;\n\n\t\tnormalized[name] = {\n\t\t\tinstructions: candidate.instructions,\n\t\t\t...(candidate.kind === 'layer'\n\t\t\t\t? { kind: 'layer' as const }\n\t\t\t\t: {}),\n\t\t\t...(typeof candidate.description === 'string'\n\t\t\t\t? { description: candidate.description }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\treturn normalized;\n}\n\nexport function merge_prompt_presets(\n\t...sources: PromptPresetMap[]\n): PromptPresetMap {\n\treturn Object.assign({}, ...sources);\n}\n\nfunction to_loaded_prompt_presets(\n\tpresets: PromptPresetMap,\n\tsource: PromptPresetSource,\n): Record<string, LoadedPromptPreset> {\n\treturn Object.fromEntries(\n\t\tObject.entries(presets).map(([name, preset]) => [\n\t\t\tname,\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\tkind: preset.kind === 'layer' ? 'layer' : 'base',\n\t\t\t\tsource,\n\t\t\t\t...preset,\n\t\t\t},\n\t\t]),\n\t);\n}\n\nfunction get_global_presets_path(): string {\n\treturn join(getAgentDir(), 'presets.json');\n}\n\nfunction get_project_presets_path(cwd: string): string {\n\treturn join(cwd, '.pi', 'presets.json');\n}\n\nexport function get_global_presets_dir(): string {\n\treturn join(getAgentDir(), 'presets');\n}\n\nexport function get_project_presets_dir(cwd: string): string {\n\treturn join(cwd, '.pi', 'presets');\n}\n\nfunction sanitize_prompt_preset_file_name(name: string): string {\n\tconst sanitized = name\n\t\t.trim()\n\t\t.replace(/[\\\\/:*?\"<>|]/g, '-')\n\t\t.replace(/^\\.+$/, '')\n\t\t.replace(/^\\.+/, '')\n\t\t.replace(/\\.+$/, '');\n\tif (!sanitized) {\n\t\tthrow new Error(\n\t\t\t'Prompt preset name must contain a file-safe character',\n\t\t);\n\t}\n\treturn sanitized;\n}\n\nexport function get_prompt_preset_file_path(\n\tdir: string,\n\tname: string,\n): string {\n\treturn join(dir, `${sanitize_prompt_preset_file_name(name)}.md`);\n}\n\nfunction get_persisted_prompt_state_path(): string {\n\treturn join(getAgentDir(), 'prompt-preset-state.json');\n}\n\nfunction read_prompt_presets_file(path: string): PromptPresetMap {\n\ttry {\n\t\tif (path === get_global_presets_path()) {\n\t\t\treturn normalize_prompt_presets(\n\t\t\t\tread_settings().promptPresets?.global ?? {},\n\t\t\t);\n\t\t}\n\t\tif (!existsSync(path)) return {};\n\t\treturn normalize_prompt_presets(\n\t\t\tJSON.parse(readFileSync(path, 'utf-8')),\n\t\t);\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport function parse_prompt_preset_markdown(content: string): {\n\tmetadata: Record<string, unknown>;\n\tbody: string;\n} {\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\treturn { metadata: frontmatter, body: body.trim() };\n}\n\nexport function read_prompt_presets_dir(\n\tpath: string,\n): PromptPresetMap {\n\tif (!existsSync(path)) return {};\n\n\ttry {\n\t\tconst presets: PromptPresetMap = {};\n\t\tfor (const entry of readdirSync(path, { withFileTypes: true })\n\t\t\t.filter((item) => item.isFile() && item.name.endsWith('.md'))\n\t\t\t.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\t\tconst name = entry.name.slice(0, -3).trim();\n\t\t\tif (!name) continue;\n\t\t\tconst { metadata, body } = parse_prompt_preset_markdown(\n\t\t\t\treadFileSync(join(path, entry.name), 'utf-8'),\n\t\t\t);\n\t\t\tif (!body) continue;\n\t\t\tpresets[name] = {\n\t\t\t\tkind: metadata.kind === 'layer' ? 'layer' : 'base',\n\t\t\t\tinstructions: body,\n\t\t\t\t...(typeof metadata.description === 'string' &&\n\t\t\t\tmetadata.description.trim()\n\t\t\t\t\t? { description: metadata.description }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t\treturn presets;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport function format_prompt_preset_markdown(\n\tpreset: PromptPreset,\n): string {\n\tconst lines = [\n\t\t'---',\n\t\t`kind: ${preset.kind === 'layer' ? 'layer' : 'base'}`,\n\t];\n\tif (preset.description?.trim()) {\n\t\tlines.push(\n\t\t\t`description: ${JSON.stringify(preset.description.trim())}`,\n\t\t);\n\t}\n\tlines.push('---', '', preset.instructions.trim(), '');\n\treturn lines.join('\\n');\n}\n\nexport function save_prompt_preset_file(\n\tdir: string,\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n\n\tconst path = get_prompt_preset_file_path(dir, name);\n\tconst tmp = `${path}.tmp-${Date.now()}`;\n\twriteFileSync(tmp, format_prompt_preset_markdown(preset), {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\n\treturn path;\n}\n\nexport function save_project_prompt_preset_file(\n\tcwd: string,\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\treturn save_prompt_preset_file(\n\t\tget_project_presets_dir(cwd),\n\t\tname,\n\t\tpreset,\n\t);\n}\n\nexport function save_global_prompt_preset_file(\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\treturn save_prompt_preset_file(\n\t\tget_global_presets_dir(),\n\t\tname,\n\t\tpreset,\n\t);\n}\n\nfunction should_load_project_prompt_presets(): boolean {\n\tconst normalized = process.env[PROJECT_PROMPT_PRESETS_ENV]\n\t\t?.trim()\n\t\t.toLowerCase();\n\treturn !['0', 'false', 'no', 'skip', 'disable'].includes(\n\t\tnormalized ?? '',\n\t);\n}\n\nexport function load_prompt_presets(\n\tcwd: string,\n): Record<string, LoadedPromptPreset> {\n\treturn Object.assign(\n\t\t{},\n\t\tto_loaded_prompt_presets(DEFAULT_PROMPT_PRESETS, 'builtin'),\n\t\tto_loaded_prompt_presets(\n\t\t\tread_prompt_presets_file(get_global_presets_path()),\n\t\t\t'user',\n\t\t),\n\t\tto_loaded_prompt_presets(\n\t\t\tread_prompt_presets_dir(get_global_presets_dir()),\n\t\t\t'user',\n\t\t),\n\t\t...(should_load_project_prompt_presets()\n\t\t\t? [\n\t\t\t\t\tto_loaded_prompt_presets(\n\t\t\t\t\t\tread_prompt_presets_file(get_project_presets_path(cwd)),\n\t\t\t\t\t\t'project',\n\t\t\t\t\t),\n\t\t\t\t\tto_loaded_prompt_presets(\n\t\t\t\t\t\tread_prompt_presets_dir(get_project_presets_dir(cwd)),\n\t\t\t\t\t\t'project',\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t);\n}\n\nfunction sort_prompt_presets(\n\tpresets: PromptPresetMap,\n): PromptPresetMap {\n\treturn Object.fromEntries(\n\t\tObject.entries(presets).sort(([a], [b]) => a.localeCompare(b)),\n\t);\n}\n\nexport function save_project_prompt_presets(\n\tcwd: string,\n\tpresets: PromptPresetMap,\n): string {\n\tconst path = get_project_presets_path(cwd);\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(\n\t\ttmp,\n\t\tJSON.stringify(sort_prompt_presets(presets), null, '\\t') + '\\n',\n\t\t{ mode: 0o600 },\n\t);\n\trenameSync(tmp, path);\n\treturn path;\n}\n\nexport function remove_project_prompt_preset(\n\tcwd: string,\n\tname: string,\n): {\n\tremoved: boolean;\n\tpath: string;\n\tremaining: number;\n} {\n\tconst json_path = get_project_presets_path(cwd);\n\tconst project_presets = read_prompt_presets_file(json_path);\n\tlet removed = false;\n\tlet removed_path = json_path;\n\n\tif (name in project_presets) {\n\t\tdelete project_presets[name];\n\t\tremoved = true;\n\t\tremoved_path = json_path;\n\t\tif (Object.keys(project_presets).length === 0) {\n\t\t\tif (existsSync(json_path)) {\n\t\t\t\tunlinkSync(json_path);\n\t\t\t}\n\t\t} else {\n\t\t\tsave_project_prompt_presets(cwd, project_presets);\n\t\t}\n\t}\n\n\tconst file_path = get_prompt_preset_file_path(\n\t\tget_project_presets_dir(cwd),\n\t\tname,\n\t);\n\tif (existsSync(file_path)) {\n\t\tunlinkSync(file_path);\n\t\tremoved = true;\n\t\tremoved_path = file_path;\n\t}\n\n\tconst remaining =\n\t\tObject.keys(read_prompt_presets_file(json_path)).length +\n\t\tObject.keys(read_prompt_presets_dir(get_project_presets_dir(cwd)))\n\t\t\t.length;\n\n\treturn { removed, path: removed_path, remaining };\n}\n\nfunction normalize_prompt_preset_state(\n\tinput: unknown,\n): PromptPresetState | undefined {\n\tif (!input || typeof input !== 'object') return undefined;\n\n\tconst candidate = input as {\n\t\tbase_name?: unknown;\n\t\tlayer_names?: unknown;\n\t};\n\tconst base_name =\n\t\ttypeof candidate.base_name === 'string' &&\n\t\tcandidate.base_name.trim()\n\t\t\t? candidate.base_name.trim()\n\t\t\t: null;\n\tconst layer_names = Array.isArray(candidate.layer_names)\n\t\t? [\n\t\t\t\t...new Set(\n\t\t\t\t\tcandidate.layer_names\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(value): value is string =>\n\t\t\t\t\t\t\t\ttypeof value === 'string' && value.trim().length > 0,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((value) => value.trim()),\n\t\t\t\t),\n\t\t\t].sort()\n\t\t: [];\n\n\treturn {\n\t\tbase_name,\n\t\tlayer_names,\n\t};\n}\n\nfunction read_persisted_prompt_states(\n\tpath = get_persisted_prompt_state_path(),\n): PersistedPromptPresetStates {\n\ttry {\n\t\tconst parsed = (\n\t\t\tpath === get_persisted_prompt_state_path()\n\t\t\t\t? (read_settings().promptPresets?.state ?? {})\n\t\t\t\t: existsSync(path)\n\t\t\t\t\t? JSON.parse(readFileSync(path, 'utf-8'))\n\t\t\t\t\t: {}\n\t\t) as {\n\t\t\tversion?: unknown;\n\t\t\tprojects?: unknown;\n\t\t};\n\t\tconst raw_projects =\n\t\t\tparsed.projects && typeof parsed.projects === 'object'\n\t\t\t\t? parsed.projects\n\t\t\t\t: {};\n\t\tconst projects: Record<string, PromptPresetState> = {};\n\t\tfor (const [cwd, value] of Object.entries(raw_projects)) {\n\t\t\tconst normalized = normalize_prompt_preset_state(value);\n\t\t\tif (!normalized) continue;\n\t\t\tprojects[cwd] = normalized;\n\t\t}\n\t\treturn {\n\t\t\tversion:\n\t\t\t\ttypeof parsed.version === 'number' ? parsed.version : 1,\n\t\t\tprojects,\n\t\t};\n\t} catch {\n\t\treturn { version: 1, projects: {} };\n\t}\n}\n\nexport function load_persisted_prompt_state(\n\tcwd: string,\n\tpath = get_persisted_prompt_state_path(),\n): PromptPresetState | undefined {\n\treturn read_persisted_prompt_states(path).projects[cwd];\n}\n\nexport function save_persisted_prompt_state(\n\tcwd: string,\n\tstate: PromptPresetState,\n\tpath = get_persisted_prompt_state_path(),\n): string {\n\tconst persisted = read_persisted_prompt_states(path);\n\tpersisted.projects[cwd] = normalize_prompt_preset_state(state) ?? {\n\t\tbase_name: null,\n\t\tlayer_names: [],\n\t};\n\n\tconst next = {\n\t\tversion: 1,\n\t\tprojects: Object.fromEntries(\n\t\t\tObject.entries(persisted.projects).sort(([a], [b]) =>\n\t\t\t\ta.localeCompare(b),\n\t\t\t),\n\t\t),\n\t};\n\tif (path === get_persisted_prompt_state_path()) {\n\t\tconst settings = read_settings();\n\t\twrite_settings({\n\t\t\t...settings,\n\t\t\tpromptPresets: { ...settings.promptPresets, state: next },\n\t\t});\n\t\treturn path;\n\t}\n\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(next, null, '\\t') + '\\n', {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\n\treturn path;\n}\n","import type {\n\tExtensionAPI,\n\tExtensionContext,\n} from '@earendil-works/pi-coding-agent';\nimport { save_persisted_prompt_state } from './storage.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPresetState,\n} from './types.js';\n\nexport const PRESET_STATE_TYPE = 'prompt-preset-state';\nexport const ENABLED = '● enabled';\nexport const DISABLED = '○ disabled';\nexport const SELECTED = '● selected';\nexport const UNSELECTED = '○';\nexport const NONE_BASE_ID = '__base_none__';\n\nexport function get_last_preset_state(\n\tctx: ExtensionContext,\n): PromptPresetState | undefined {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i] as {\n\t\t\ttype?: string;\n\t\t\tcustomType?: string;\n\t\t\tdata?: PromptPresetState;\n\t\t};\n\t\tif (\n\t\t\tentry.type === 'custom' &&\n\t\t\tentry.customType === PRESET_STATE_TYPE &&\n\t\t\tentry.data\n\t\t) {\n\t\t\treturn entry.data;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function 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\nexport function persist_state(\n\tpi: ExtensionAPI,\n\tctx: ExtensionContext,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): void {\n\tconst state = {\n\t\tbase_name: active_base_name ?? null,\n\t\tlayer_names: [...active_layers].sort(),\n\t};\n\tpi.appendEntry(PRESET_STATE_TYPE, state);\n\tsave_persisted_prompt_state(ctx.cwd, state);\n}\n\nexport function normalize_active_state(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): {\n\tactive_base_name: string | undefined;\n\tactive_layers: Set<string>;\n} {\n\tconst next_base_name =\n\t\tactive_base_name && presets[active_base_name]?.kind === 'base'\n\t\t\t? active_base_name\n\t\t\t: undefined;\n\tconst next_layers = new Set(\n\t\t[...active_layers].filter(\n\t\t\t(name) => presets[name]?.kind === 'layer',\n\t\t),\n\t);\n\treturn {\n\t\tactive_base_name: next_base_name,\n\t\tactive_layers: next_layers,\n\t};\n}\n\nexport function parse_preset_flag(flag: string): string[] {\n\treturn flag\n\t\t.split(',')\n\t\t.map((item) => item.trim())\n\t\t.filter(Boolean);\n}\n","import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';\nimport {\n\tKey,\n\tmatchesKey,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n\ttype Component,\n} from '@earendil-works/pi-tui';\nimport { show_modal, type ModalTheme } from '@spences10/pi-tui-modal';\nimport {\n\tget_prompt_source_label,\n\tlist_base_presets,\n\tlist_layer_presets,\n} from './catalog.js';\nimport { build_active_prompt_blocks } from './prompt-blocks.js';\nimport { NONE_BASE_ID, sets_equal } from './state.js';\nimport type { LoadedPromptPreset } from './types.js';\n\nexport interface PromptPresetManagerState {\n\tpresets: Record<string, LoadedPromptPreset>;\n\tactive_base_name: string | undefined;\n\tactive_layers: ReadonlySet<string>;\n}\n\nexport type PromptPresetManagerResult =\n\t| {\n\t\t\taction: 'apply';\n\t\t\tbase_name: string | undefined;\n\t\t\tlayers: ReadonlySet<string>;\n\t }\n\t| { action: 'edit'; name: string; scope: 'project' | 'global' };\n\ntype PresetRow =\n\t| { type: 'header'; id: string; label: string }\n\t| { type: 'base-none'; id: typeof NONE_BASE_ID; label: string }\n\t| { type: 'preset'; id: string; preset: LoadedPromptPreset };\n\nexport async function show_prompt_preset_manager(\n\tctx: ExtensionCommandContext,\n\tstate: PromptPresetManagerState,\n\ton_change: (\n\t\tbase_name: string | undefined,\n\t\tlayers: ReadonlySet<string>,\n\t) => void,\n\ton_edit?: (\n\t\tname: string,\n\t\tscope: 'project' | 'global',\n\t) => Promise<void>,\n): Promise<void> {\n\tconst base_presets = list_base_presets(state.presets);\n\tconst layer_presets = list_layer_presets(state.presets);\n\tif (base_presets.length === 0 && layer_presets.length === 0) {\n\t\tctx.ui.notify('No prompt presets available', 'warning');\n\t\treturn;\n\t}\n\n\tconst result = await show_modal<\n\t\tPromptPresetManagerResult | undefined\n\t>(\n\t\tctx,\n\t\t{\n\t\t\ttitle: 'Prompt preset inspector',\n\t\t\tsubtitle: () =>\n\t\t\t\t`base: ${state.active_base_name ?? '(none)'} • ${state.active_layers.size} layer(s) currently active`,\n\t\t\tfooter:\n\t\t\t\t'↑↓ navigate • space toggle/select • tab preview • e edit project • E edit global • enter apply • esc cancel',\n\t\t\toverlay_options: {\n\t\t\t\twidth: '92%',\n\t\t\t\tminWidth: 72,\n\t\t\t\tmaxHeight: '88%',\n\t\t\t},\n\t\t},\n\t\t({ done }, theme, layout) =>\n\t\t\tnew PromptPresetInspectorBody(\n\t\t\t\tstate,\n\t\t\t\ttheme,\n\t\t\t\t() => layout.get_max_body_lines(),\n\t\t\t\tdone,\n\t\t\t),\n\t);\n\n\tif (!result) return;\n\tif (result.action === 'edit') {\n\t\tawait on_edit?.(result.name, result.scope);\n\t\treturn;\n\t}\n\tif (\n\t\tresult.base_name !== state.active_base_name ||\n\t\t!sets_equal(new Set(state.active_layers), result.layers)\n\t) {\n\t\ton_change(result.base_name, result.layers);\n\t}\n}\n\nclass PromptPresetInspectorBody implements Component {\n\tprivate readonly rows: PresetRow[];\n\tprivate selected_index = 1;\n\tprivate selected_base: string | undefined;\n\tprivate readonly enabled_layers: Set<string>;\n\tprivate preview_mode: 'item' | 'effective' = 'item';\n\tprivate preview_offset = 0;\n\tprivate preview_lines: string[] = [];\n\n\tconstructor(\n\t\tprivate readonly state: PromptPresetManagerState,\n\t\tprivate readonly theme: ModalTheme,\n\t\tprivate readonly get_max_lines: () => number,\n\t\tprivate readonly done: (\n\t\t\tresult: PromptPresetManagerResult | undefined,\n\t\t) => void,\n\t) {\n\t\tconst base_presets = list_base_presets(state.presets);\n\t\tconst layer_presets = list_layer_presets(state.presets);\n\t\tthis.rows = [\n\t\t\t{\n\t\t\t\ttype: 'header',\n\t\t\t\tid: '__base_header__',\n\t\t\t\tlabel: `Base presets (${base_presets.length + 1})`,\n\t\t\t},\n\t\t\t{ type: 'base-none', id: NONE_BASE_ID, label: '(none)' },\n\t\t\t...base_presets.map((preset) => ({\n\t\t\t\ttype: 'preset' as const,\n\t\t\t\tid: preset.name,\n\t\t\t\tpreset,\n\t\t\t})),\n\t\t\t{\n\t\t\t\ttype: 'header',\n\t\t\t\tid: '__layer_header__',\n\t\t\t\tlabel: `Prompt layers (${layer_presets.length})`,\n\t\t\t},\n\t\t\t...layer_presets.map((preset) => ({\n\t\t\t\ttype: 'preset' as const,\n\t\t\t\tid: preset.name,\n\t\t\t\tpreset,\n\t\t\t})),\n\t\t];\n\t\tthis.selected_base = state.active_base_name;\n\t\tthis.enabled_layers = new Set(state.active_layers);\n\t\tthis.skip_header(1);\n\t}\n\n\trender(width: number): string[] {\n\t\tconst body_lines = Math.max(8, this.get_max_lines());\n\t\tif (width < 80) return this.render_stacked(width, body_lines);\n\n\t\tconst list_width = Math.min(\n\t\t\t38,\n\t\t\tMath.max(28, Math.floor(width * 0.38)),\n\t\t);\n\t\tconst preview_width = width - list_width - 3;\n\t\tconst list = this.render_list(list_width, body_lines);\n\t\tconst preview = this.render_preview(preview_width, body_lines);\n\t\tconst lines: string[] = [];\n\t\tfor (let i = 0; i < body_lines; i++) {\n\t\t\tlines.push(\n\t\t\t\t`${this.pad_line(list[i] ?? '', list_width)} ${this.theme.fg('dim', '│')} ${preview[i] ?? ''}`,\n\t\t\t);\n\t\t}\n\t\treturn lines.map((line) => truncateToWidth(line, width));\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached rendering.\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (matchesKey(data, Key.up) || data === 'k') {\n\t\t\tthis.move(-1);\n\t\t} else if (matchesKey(data, Key.down) || data === 'j') {\n\t\t\tthis.move(1);\n\t\t} else if (data === ' ' || matchesKey(data, Key.enter)) {\n\t\t\tif (matchesKey(data, Key.enter)) {\n\t\t\t\tthis.done({\n\t\t\t\t\taction: 'apply',\n\t\t\t\t\tbase_name: this.selected_base,\n\t\t\t\t\tlayers: new Set(this.enabled_layers),\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.toggle_selected();\n\t\t} else if (data === '\\t') {\n\t\t\tthis.preview_mode =\n\t\t\t\tthis.preview_mode === 'item' ? 'effective' : 'item';\n\t\t\tthis.preview_offset = 0;\n\t\t} else if (data === 'c') {\n\t\t\tthis.selected_base = undefined;\n\t\t\tthis.enabled_layers.clear();\n\t\t\tthis.preview_mode = 'effective';\n\t\t\tthis.preview_offset = 0;\n\t\t} else if (data === 'a') {\n\t\t\tthis.done({\n\t\t\t\taction: 'apply',\n\t\t\t\tbase_name: this.selected_base,\n\t\t\t\tlayers: new Set(this.enabled_layers),\n\t\t\t});\n\t\t} else if (data === 'e' || data === 'E') {\n\t\t\tconst row = this.rows[this.selected_index];\n\t\t\tif (row?.type === 'preset') {\n\t\t\t\tthis.done({\n\t\t\t\t\taction: 'edit',\n\t\t\t\t\tname: row.preset.name,\n\t\t\t\t\tscope: data === 'E' ? 'global' : 'project',\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (matchesKey(data, Key.escape) || data === 'q') {\n\t\t\tthis.done(undefined);\n\t\t} else if (data === 'J') {\n\t\t\tthis.scroll_preview(1);\n\t\t} else if (data === 'K') {\n\t\t\tthis.scroll_preview(-1);\n\t\t}\n\t}\n\n\tprivate render_stacked(\n\t\twidth: number,\n\t\tbody_lines: number,\n\t): string[] {\n\t\tconst list_lines = Math.max(5, Math.floor(body_lines / 2));\n\t\treturn [\n\t\t\t...this.render_list(width, list_lines),\n\t\t\tthis.theme.fg('dim', '─'.repeat(Math.min(width, 80))),\n\t\t\t...this.render_preview(width, body_lines - list_lines - 1),\n\t\t];\n\t}\n\n\tprivate render_list(width: number, max_lines: number): string[] {\n\t\tconst lines = [\n\t\t\tthis.theme.fg(\n\t\t\t\t'accent',\n\t\t\t\t`Draft selection: ${this.selected_base ?? '(none)'} + ${this.enabled_layers.size} layer(s)`,\n\t\t\t),\n\t\t\t'',\n\t\t];\n\t\tconst visible_rows = Math.max(1, max_lines - lines.length);\n\t\tconst start = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selected_index - Math.floor(visible_rows / 2),\n\t\t\t\tthis.rows.length - visible_rows,\n\t\t\t),\n\t\t);\n\t\tconst end = Math.min(start + visible_rows, this.rows.length);\n\t\tfor (let index = start; index < end; index++) {\n\t\t\tlines.push(this.render_row(this.rows[index], index, width));\n\t\t}\n\t\treturn lines.map((line) => truncateToWidth(line, width));\n\t}\n\n\tprivate render_preview(width: number, max_lines: number): string[] {\n\t\tconst heading =\n\t\t\tthis.preview_mode === 'effective'\n\t\t\t\t? 'Effective prompt contribution'\n\t\t\t\t: 'Selected preset';\n\t\tconst text =\n\t\t\tthis.preview_mode === 'effective'\n\t\t\t\t? this.get_effective_prompt_text()\n\t\t\t\t: this.get_selected_prompt_text();\n\t\tconst content_width = Math.max(10, width);\n\t\tthis.preview_lines = text\n\t\t\t.split('\\n')\n\t\t\t.flatMap((line) =>\n\t\t\t\tline.trim().length === 0\n\t\t\t\t\t? ['']\n\t\t\t\t\t: wrapTextWithAnsi(line, content_width),\n\t\t\t);\n\t\tconst available = Math.max(1, max_lines - 2);\n\t\tconst max_offset = Math.max(\n\t\t\t0,\n\t\t\tthis.preview_lines.length - available,\n\t\t);\n\t\tthis.preview_offset = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.preview_offset, max_offset),\n\t\t);\n\t\tconst end = Math.min(\n\t\t\tthis.preview_offset + available,\n\t\t\tthis.preview_lines.length,\n\t\t);\n\t\tconst range =\n\t\t\tthis.preview_lines.length > available\n\t\t\t\t? ` (${this.preview_offset + 1}-${end}/${this.preview_lines.length})`\n\t\t\t\t: '';\n\t\treturn [\n\t\t\tthis.theme.fg('accent', this.theme.bold(`${heading}${range}`)),\n\t\t\t'',\n\t\t\t...this.preview_lines\n\t\t\t\t.slice(this.preview_offset, end)\n\t\t\t\t.map((line) => truncateToWidth(line, width)),\n\t\t];\n\t}\n\n\tprivate render_row(\n\t\trow: PresetRow,\n\t\tindex: number,\n\t\twidth: number,\n\t): string {\n\t\tif (row.type === 'header') {\n\t\t\treturn this.theme.fg('muted', ` ${row.label}`);\n\t\t}\n\t\tconst selected = index === this.selected_index;\n\t\tconst cursor = selected ? this.theme.fg('accent', '› ') : ' ';\n\t\tconst marker = this.get_marker(row);\n\t\tconst label =\n\t\t\trow.type === 'base-none' ? row.label : row.preset.name;\n\t\tconst suffix =\n\t\t\trow.type === 'preset'\n\t\t\t\t? ` ${this.theme.fg('dim', get_prompt_source_label(row.preset.source))}`\n\t\t\t\t: '';\n\t\treturn truncateToWidth(\n\t\t\t`${cursor}${marker} ${this.pad(label, 18)}${suffix}`,\n\t\t\twidth,\n\t\t);\n\t}\n\n\tprivate get_marker(row: PresetRow): string {\n\t\tif (row.type === 'header') return ' ';\n\t\tif (row.type === 'base-none') {\n\t\t\treturn this.selected_base ? '○' : '●';\n\t\t}\n\t\tif (row.preset.kind === 'base') {\n\t\t\treturn this.selected_base === row.preset.name ? '●' : '○';\n\t\t}\n\t\treturn this.enabled_layers.has(row.preset.name) ? '☑' : '☐';\n\t}\n\n\tprivate get_selected_prompt_text(): string {\n\t\tconst row = this.rows[this.selected_index];\n\t\tif (!row || row.type === 'header') return '';\n\t\tif (row.type === 'base-none') {\n\t\t\treturn 'No active base preset. Only enabled prompt layers will be appended.';\n\t\t}\n\t\tconst preset = row.preset;\n\t\treturn [\n\t\t\t`# ${preset.name}`,\n\t\t\t'',\n\t\t\t`Kind: ${preset.kind}`,\n\t\t\t`Source: ${get_prompt_source_label(preset.source)}`,\n\t\t\tpreset.description\n\t\t\t\t? `Description: ${preset.description}`\n\t\t\t\t: undefined,\n\t\t\t'',\n\t\t\tpreset.instructions.trim() || '(empty preset)',\n\t\t]\n\t\t\t.filter((line): line is string => line !== undefined)\n\t\t\t.join('\\n');\n\t}\n\n\tprivate get_effective_prompt_text(): string {\n\t\tconst blocks = build_active_prompt_blocks(\n\t\t\tthis.state.presets,\n\t\t\tthis.selected_base,\n\t\t\tthis.enabled_layers,\n\t\t);\n\t\treturn blocks.length > 0\n\t\t\t? blocks.join('\\n\\n')\n\t\t\t: '(No prompt preset text will be appended.)';\n\t}\n\n\tprivate toggle_selected(): void {\n\t\tconst row = this.rows[this.selected_index];\n\t\tif (!row || row.type === 'header') return;\n\t\tif (row.type === 'base-none') {\n\t\t\tthis.selected_base = undefined;\n\t\t} else if (row.preset.kind === 'base') {\n\t\t\tthis.selected_base = row.preset.name;\n\t\t} else if (this.enabled_layers.has(row.preset.name)) {\n\t\t\tthis.enabled_layers.delete(row.preset.name);\n\t\t} else {\n\t\t\tthis.enabled_layers.add(row.preset.name);\n\t\t}\n\t\tthis.preview_mode = 'effective';\n\t\tthis.preview_offset = 0;\n\t}\n\n\tprivate move(delta: number): void {\n\t\tlet next = this.selected_index;\n\t\tdo {\n\t\t\tnext = (next + delta + this.rows.length) % this.rows.length;\n\t\t} while (this.rows[next]?.type === 'header');\n\t\tthis.selected_index = next;\n\t\tthis.preview_offset = 0;\n\t}\n\n\tprivate skip_header(fallback: number): void {\n\t\tif (this.rows[this.selected_index]?.type !== 'header') return;\n\t\tthis.selected_index = fallback;\n\t}\n\n\tprivate scroll_preview(delta: number): void {\n\t\tconst max_offset = Math.max(0, this.preview_lines.length - 1);\n\t\tthis.preview_offset = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.preview_offset + delta, max_offset),\n\t\t);\n\t}\n\n\tprivate pad(text: string, width: number): string {\n\t\tconst visible = visibleWidth(text);\n\t\treturn text + ' '.repeat(Math.max(0, width - visible));\n\t}\n\n\tprivate pad_line(text: string, width: number): string {\n\t\tconst truncated = truncateToWidth(text, width);\n\t\treturn (\n\t\t\ttruncated +\n\t\t\t' '.repeat(Math.max(0, width - visibleWidth(truncated)))\n\t\t);\n\t}\n}\n","import {\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n} from '@earendil-works/pi-coding-agent';\nimport { existsSync, readFileSync } from 'node:fs';\nimport {\n\tformat_active_details,\n\tformat_summary,\n\tget_prompt_source_label,\n} from './catalog.js';\nimport { get_prompt_preset_completions } from './completions.js';\nimport {\n\tDEFAULT_BASE_PROMPT_PRESET_NAME,\n\tDEFAULT_PROMPT_PRESETS,\n} from './defaults.js';\nimport { set_status } from './footer.js';\nimport { format_prompt_preset_help, is_subcommand } from './help.js';\nimport { show_prompt_preset_manager } from './manager.js';\nimport { build_active_prompt_blocks } from './prompt-blocks.js';\nimport {\n\tget_last_preset_state,\n\tnormalize_active_state,\n\tparse_preset_flag,\n\tpersist_state,\n} from './state.js';\nimport {\n\tformat_prompt_preset_markdown,\n\tget_global_presets_dir,\n\tget_project_presets_dir,\n\tget_prompt_preset_file_path,\n\tload_persisted_prompt_state,\n\tload_prompt_presets,\n\tparse_prompt_preset_markdown,\n\tremove_project_prompt_preset,\n\tsave_global_prompt_preset_file,\n\tsave_project_prompt_preset_file,\n\tsave_prompt_preset_file,\n} from './storage.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPresetKind,\n} from './types.js';\n\nexport {\n\tget_current_thinking_level,\n\tget_default_footer_thinking_level,\n\trender_footer_status_line,\n} from '@spences10/pi-footer';\nexport {\n\tDEFAULT_BASE_PROMPT_PRESET_NAME,\n\tDEFAULT_PROMPT_PRESETS,\n} from './defaults.js';\nexport {\n\tload_persisted_prompt_state,\n\tload_prompt_presets,\n\tmerge_prompt_presets,\n\tnormalize_prompt_presets,\n\tread_prompt_presets_dir,\n\tremove_project_prompt_preset,\n\tsave_persisted_prompt_state,\n\tsave_project_prompt_presets,\n\tsave_prompt_preset_file,\n} from './storage.js';\nexport type {\n\tLoadedPromptPreset,\n\tPromptPreset,\n\tPromptPresetKind,\n\tPromptPresetMap,\n\tPromptPresetSource,\n\tPromptPresetState,\n} from './types.js';\n\nexport default async function prompt_presets(pi: ExtensionAPI) {\n\tlet presets: Record<string, LoadedPromptPreset> = {};\n\tlet active_base_name: string | undefined;\n\tlet active_layers = new Set<string>();\n\n\tfunction get_base(\n\t\tname: string | undefined,\n\t): LoadedPromptPreset | undefined {\n\t\treturn name ? presets[name] : undefined;\n\t}\n\n\tfunction get_layer(name: string): LoadedPromptPreset | undefined {\n\t\tconst preset = presets[name];\n\t\treturn preset?.kind === 'layer' ? preset : undefined;\n\t}\n\n\tfunction commit_state(\n\t\tctx: ExtensionContext,\n\t\tnext_base_name: string | undefined,\n\t\tnext_layers: ReadonlySet<string>,\n\t\toptions?: { persist?: boolean; notify?: string },\n\t): void {\n\t\tactive_base_name = next_base_name;\n\t\tactive_layers = new Set(next_layers);\n\t\tset_status(ctx, active_base_name, active_layers);\n\t\tif (options?.persist !== false) {\n\t\t\tpersist_state(pi, ctx, active_base_name, active_layers);\n\t\t}\n\t\tif (options?.notify) {\n\t\t\tctx.ui.notify(options.notify, 'info');\n\t\t}\n\t}\n\n\tfunction activate_base(\n\t\tname: string | undefined,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\tif (!name) {\n\t\t\tcommit_state(ctx, undefined, active_layers, {\n\t\t\t\tpersist: options?.persist,\n\t\t\t\tnotify: 'Base preset cleared',\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\n\t\tconst preset = get_base(name);\n\t\tif (!preset) {\n\t\t\tctx.ui.notify(`Unknown base preset: ${name}`, 'warning');\n\t\t\treturn false;\n\t\t}\n\n\t\tcommit_state(ctx, preset.name, active_layers, {\n\t\t\tpersist: options?.persist,\n\t\t\tnotify: `Base preset \"${preset.name}\" activated`,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction set_layer_enabled(\n\t\tname: string,\n\t\tenabled: boolean,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\tconst preset = get_layer(name);\n\t\tif (!preset) {\n\t\t\tctx.ui.notify(`Unknown prompt layer: ${name}`, 'warning');\n\t\t\treturn false;\n\t\t}\n\n\t\tconst next_layers = new Set(active_layers);\n\t\tif (enabled) {\n\t\t\tnext_layers.add(preset.name);\n\t\t} else {\n\t\t\tnext_layers.delete(preset.name);\n\t\t}\n\n\t\tcommit_state(ctx, active_base_name, next_layers, {\n\t\t\tpersist: options?.persist,\n\t\t\tnotify: enabled\n\t\t\t\t? `Layer \"${preset.name}\" enabled`\n\t\t\t\t: `Layer \"${preset.name}\" disabled`,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction toggle_layer(\n\t\tname: string,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\treturn set_layer_enabled(\n\t\t\tname,\n\t\t\t!active_layers.has(name),\n\t\t\tctx,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync function edit_preset(\n\t\tname: string,\n\t\tctx: ExtensionCommandContext,\n\t\tscope: 'project' | 'global' = 'project',\n\t): Promise<void> {\n\t\tconst existing = presets[name];\n\t\tconst dir =\n\t\t\tscope === 'global'\n\t\t\t\t? get_global_presets_dir()\n\t\t\t\t: get_project_presets_dir(ctx.cwd);\n\t\tconst path = get_prompt_preset_file_path(dir, name);\n\t\tconst initial_markdown = existsSync(path)\n\t\t\t? readFileSync(path, 'utf-8')\n\t\t\t: format_prompt_preset_markdown({\n\t\t\t\t\tkind: existing?.kind ?? 'layer',\n\t\t\t\t\tinstructions: existing?.instructions ?? '',\n\t\t\t\t\t...(existing?.description\n\t\t\t\t\t\t? { description: existing.description }\n\t\t\t\t\t\t: {}),\n\t\t\t\t});\n\n\t\tconst edited = await ctx.ui.editor(\n\t\t\t`Edit ${scope} preset markdown: ${name}`,\n\t\t\tinitial_markdown,\n\t\t);\n\t\tif (edited === undefined) return;\n\n\t\tconst { metadata, body } = parse_prompt_preset_markdown(edited);\n\t\tif (!body.trim()) {\n\t\t\tctx.ui.notify('Preset instructions cannot be empty', 'warning');\n\t\t\treturn;\n\t\t}\n\t\tconst kind: PromptPresetKind =\n\t\t\tmetadata.kind === 'base' ? 'base' : 'layer';\n\t\tconst preset = {\n\t\t\tkind,\n\t\t\tinstructions: body,\n\t\t\t...(typeof metadata.description === 'string' &&\n\t\t\tmetadata.description.trim()\n\t\t\t\t? { description: metadata.description.trim() }\n\t\t\t\t: {}),\n\t\t};\n\n\t\tconst saved_path =\n\t\t\tscope === 'global'\n\t\t\t\t? save_global_prompt_preset_file(name, preset)\n\t\t\t\t: save_project_prompt_preset_file(ctx.cwd, name, preset);\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\n\t\tif (kind === 'base') {\n\t\t\tactivate_base(name, ctx);\n\t\t} else {\n\t\t\tset_layer_enabled(name, true, ctx);\n\t\t}\n\t\tctx.ui.notify(`Saved preset \"${name}\" to ${saved_path}`, 'info');\n\t}\n\n\tfunction export_default_presets(\n\t\tctx: ExtensionCommandContext,\n\t\tscope: 'project' | 'global',\n\t): void {\n\t\tconst dir =\n\t\t\tscope === 'global'\n\t\t\t\t? get_global_presets_dir()\n\t\t\t\t: get_project_presets_dir(ctx.cwd);\n\t\tlet written = 0;\n\t\tlet skipped = 0;\n\t\tfor (const [name, preset] of Object.entries(\n\t\t\tDEFAULT_PROMPT_PRESETS,\n\t\t)) {\n\t\t\tconst path = get_prompt_preset_file_path(dir, name);\n\t\t\tif (existsSync(path)) {\n\t\t\t\tskipped += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsave_prompt_preset_file(dir, name, preset);\n\t\t\twritten += 1;\n\t\t}\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\n\t\tctx.ui.notify(\n\t\t\t`Exported ${written} built-in preset file(s) to ${dir}${skipped ? ` (${skipped} already existed)` : ''}`,\n\t\t\t'info',\n\t\t);\n\t}\n\n\tfunction remove_custom_preset(\n\t\tname: string,\n\t\tctx: ExtensionCommandContext,\n\t\tmode: 'delete' | 'reset',\n\t): void {\n\t\tconst result = remove_project_prompt_preset(ctx.cwd, name);\n\t\tif (!result.removed) {\n\t\t\tctx.ui.notify(\n\t\t\t\t`No project-local preset named \"${name}\" to ${mode}`,\n\t\t\t\t'warning',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\t\tpersist_state(pi, ctx, active_base_name, active_layers);\n\n\t\tconst fallback = presets[name];\n\t\tif (mode === 'reset' && fallback) {\n\t\t\tctx.ui.notify(\n\t\t\t\t`Reset \"${name}\" to ${get_prompt_source_label(fallback.source)} preset`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tctx.ui.notify(\n\t\t\tresult.remaining === 0\n\t\t\t\t? `Removed \"${name}\" and deleted ${result.path}`\n\t\t\t\t: `Removed \"${name}\" from ${result.path}`,\n\t\t\t'info',\n\t\t);\n\t}\n\n\tasync function show_manager(\n\t\tctx: ExtensionCommandContext,\n\t): Promise<void> {\n\t\tawait show_prompt_preset_manager(\n\t\t\tctx,\n\t\t\t{ presets, active_base_name, active_layers },\n\t\t\t(selected_base, enabled_layers) => {\n\t\t\t\tcommit_state(ctx, selected_base, enabled_layers, {\n\t\t\t\t\tnotify: 'Updated prompt preset selection',\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync (name, scope) => {\n\t\t\t\tawait edit_preset(name, ctx, scope);\n\t\t\t},\n\t\t);\n\t}\n\n\tpi.registerFlag('preset', {\n\t\tdescription:\n\t\t\t'Activate prompt config on startup. Accepts a base preset or comma-separated preset/layer names.',\n\t\ttype: 'string',\n\t});\n\n\tconst prompt_preset_command: Parameters<\n\t\tExtensionAPI['registerCommand']\n\t>[1] = {\n\t\tdescription:\n\t\t\t'Manage prompt presets and layers. Try: /prompt-preset help, /prompt-preset export-defaults, /prompt-preset edit-global terse',\n\t\tgetArgumentCompletions: (prefix) =>\n\t\t\tget_prompt_preset_completions(presets, prefix),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst trimmed = args.trim();\n\t\t\tif (!trimmed) {\n\t\t\t\tif (ctx.hasUI) {\n\t\t\t\t\tawait show_manager(ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\tformat_summary(active_base_name, active_layers, presets),\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [first, ...rest] = trimmed.split(/\\s+/);\n\t\t\tconst arg = rest.join(' ').trim();\n\n\t\t\tswitch (first) {\n\t\t\t\tcase 'help':\n\t\t\t\t\tctx.ui.notify(format_prompt_preset_help(), 'info');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'list':\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\tformat_summary(active_base_name, active_layers, presets),\n\t\t\t\t\t\t'info',\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'show':\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\tformat_active_details(\n\t\t\t\t\t\t\tactive_base_name,\n\t\t\t\t\t\t\tactive_layers,\n\t\t\t\t\t\t\tpresets,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'info',\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'clear':\n\t\t\t\t\tcommit_state(ctx, undefined, new Set(), {\n\t\t\t\t\t\tnotify: 'Cleared base preset and prompt layers',\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\tcase 'reload': {\n\t\t\t\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\t\t\t\tconst normalized = normalize_active_state(\n\t\t\t\t\t\tpresets,\n\t\t\t\t\t\tactive_base_name,\n\t\t\t\t\t\tactive_layers,\n\t\t\t\t\t);\n\t\t\t\t\tactive_base_name = normalized.active_base_name;\n\t\t\t\t\tactive_layers = normalized.active_layers;\n\t\t\t\t\tset_status(ctx, active_base_name, active_layers);\n\t\t\t\t\tctx.ui.notify('Reloaded prompt presets', 'info');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'base':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset base <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactivate_base(arg, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'enable':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset enable <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tset_layer_enabled(arg, true, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'disable':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset disable <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tset_layer_enabled(arg, false, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'toggle':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset toggle <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttoggle_layer(arg, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'edit': {\n\t\t\t\t\tlet scope: 'project' | 'global' = 'project';\n\t\t\t\t\tlet name = arg;\n\t\t\t\t\tif (arg.startsWith('--global ')) {\n\t\t\t\t\t\tscope = 'global';\n\t\t\t\t\t\tname = arg.slice('--global '.length).trim();\n\t\t\t\t\t} else if (arg.startsWith('--project ')) {\n\t\t\t\t\t\tname = arg.slice('--project '.length).trim();\n\t\t\t\t\t}\n\t\t\t\t\tif (!name) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset edit [--global|--project] <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait edit_preset(name, ctx, scope);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'edit-global':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset edit-global <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait edit_preset(arg, ctx, 'global');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'export-defaults': {\n\t\t\t\t\tconst scope = arg || 'global';\n\t\t\t\t\tif (scope !== 'global' && scope !== 'project') {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset export-defaults [global|project] (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\texport_default_presets(ctx, scope);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'delete':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset delete <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tremove_custom_preset(arg, ctx, 'delete');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'reset':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset reset <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tremove_custom_preset(arg, ctx, 'reset');\n\t\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (is_subcommand(first)) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Unsupported preset command: ${first}`,\n\t\t\t\t\t'warning',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst preset = presets[trimmed];\n\t\t\tif (!preset) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Unknown preset or layer: ${trimmed}. Try /prompt-preset help.`,\n\t\t\t\t\t'warning',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (preset.kind === 'base') {\n\t\t\t\tactivate_base(preset.name, ctx);\n\t\t\t} else {\n\t\t\t\ttoggle_layer(preset.name, ctx);\n\t\t\t}\n\t\t},\n\t};\n\n\tfor (const command_name of ['prompt-preset', 'preset']) {\n\t\tpi.registerCommand(command_name, prompt_preset_command);\n\t}\n\n\tpi.on('session_start', async (_event, ctx) => {\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tactive_base_name = undefined;\n\t\tactive_layers = new Set();\n\n\t\tconst preset_flag = pi.getFlag('preset');\n\t\tif (typeof preset_flag === 'string' && preset_flag.trim()) {\n\t\t\tfor (const name of parse_preset_flag(preset_flag)) {\n\t\t\t\tconst preset = presets[name];\n\t\t\t\tif (!preset) continue;\n\t\t\t\tif (preset.kind === 'base') {\n\t\t\t\t\tactive_base_name = name;\n\t\t\t\t} else {\n\t\t\t\t\tactive_layers.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst normalized = normalize_active_state(\n\t\t\t\tpresets,\n\t\t\t\tactive_base_name,\n\t\t\t\tactive_layers,\n\t\t\t);\n\t\t\tactive_base_name = normalized.active_base_name;\n\t\t\tactive_layers = normalized.active_layers;\n\t\t\tset_status(ctx, active_base_name, active_layers);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restored = get_last_preset_state(ctx) ??\n\t\t\tload_persisted_prompt_state(ctx.cwd) ?? {\n\t\t\t\tbase_name: DEFAULT_BASE_PROMPT_PRESET_NAME,\n\t\t\t\tlayer_names: [],\n\t\t\t};\n\t\tactive_base_name = restored.base_name ?? undefined;\n\t\tactive_layers = new Set(restored.layer_names ?? []);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\t});\n\n\tpi.on('before_agent_start', async (event) => {\n\t\tconst blocks = build_active_prompt_blocks(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tif (blocks.length === 0) return;\n\t\treturn {\n\t\t\tsystemPrompt: `${event.systemPrompt}\\n\\n${blocks.join('\\n\\n')}`,\n\t\t};\n\t});\n\n\tpi.on('session_shutdown', async (_event, ctx) => {\n\t\tctx.ui.setStatus('preset', undefined);\n\t});\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,wBACf,QACS;CACT,QAAQ,QAAR;EACC,KAAK,WACJ,OAAO;EACR,KAAK,QACJ,OAAO;EACR,KAAK,WACJ,OAAO;CACT;AACD;AAEA,SAAgB,kBACf,SACuB;CACvB,OAAO,OAAO,OAAO,OAAO,CAAC,CAC3B,QAAQ,WAAW,OAAO,SAAS,MAAM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C5C,MAAM,SAAS,2BACd,SACA,kBACA,aACD;EACA,IAAI,OAAO,WAAW,GAAG;EACzB,OAAO,EACN,cAAc,GAAG,MAAM,aAAa,MAAM,OAAO,KAAK,MAAM,IAC7D;CACD,CAAC;CAED,GAAG,GAAG,oBAAoB,OAAO,QAAQ,QAAQ;EAChD,IAAI,GAAG,UAAU,UAAU,KAAA,CAAS;CACrC,CAAC;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.110",
|
|
4
4
|
"description": "Composable pi coding agent with MCP, LSP, prompt presets, and local eval telemetry",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -47,11 +47,10 @@
|
|
|
47
47
|
"@earendil-works/pi-coding-agent": "0.80.6",
|
|
48
48
|
"@earendil-works/pi-tui": "0.80.6",
|
|
49
49
|
"citty": "^0.2.2",
|
|
50
|
-
"
|
|
51
|
-
"@spences10/pi-themes": "0.0.8",
|
|
50
|
+
"@spences10/pi-project-trust": "0.0.16",
|
|
52
51
|
"@spences10/pi-settings": "0.0.2",
|
|
53
|
-
"@spences10/pi-
|
|
54
|
-
"@spences10/pi-tui-modal": "0.0.
|
|
52
|
+
"@spences10/pi-themes": "0.0.8",
|
|
53
|
+
"@spences10/pi-tui-modal": "0.0.21"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
56
|
"@changesets/cli": "^2.31.0",
|
|
@@ -63,26 +62,26 @@
|
|
|
63
62
|
},
|
|
64
63
|
"optionalDependencies": {
|
|
65
64
|
"@spences10/pi-child-env": "0.1.8",
|
|
66
|
-
"@spences10/pi-
|
|
67
|
-
"@spences10/pi-confirm-destructive": "0.0.17",
|
|
68
|
-
"@spences10/pi-context": "0.1.6",
|
|
69
|
-
"@spences10/pi-footer": "0.0.9",
|
|
65
|
+
"@spences10/pi-context": "0.1.7",
|
|
70
66
|
"@spences10/pi-coding-preferences": "0.0.12",
|
|
71
|
-
"@spences10/pi-
|
|
72
|
-
"@spences10/pi-
|
|
73
|
-
"@spences10/pi-
|
|
67
|
+
"@spences10/pi-confirm-destructive": "0.0.17",
|
|
68
|
+
"@spences10/pi-footer": "0.0.10",
|
|
69
|
+
"@spences10/pi-git-ui": "0.0.13",
|
|
70
|
+
"@spences10/pi-codex-usage": "0.0.1",
|
|
71
|
+
"@spences10/pi-harness": "0.0.5",
|
|
72
|
+
"@spences10/pi-lsp": "0.0.38",
|
|
73
|
+
"@spences10/pi-mcp": "0.0.49",
|
|
74
74
|
"@spences10/pi-nopeek": "0.0.13",
|
|
75
|
-
"@spences10/pi-mcp": "0.0.47",
|
|
76
75
|
"@spences10/pi-omnisearch": "0.0.13",
|
|
77
|
-
"@spences10/pi-observability": "0.0.
|
|
76
|
+
"@spences10/pi-observability": "0.0.17",
|
|
78
77
|
"@spences10/pi-recall": "0.0.13",
|
|
79
78
|
"@spences10/pi-redact": "0.0.12",
|
|
80
|
-
"@spences10/pi-
|
|
81
|
-
"@spences10/pi-
|
|
79
|
+
"@spences10/pi-skills": "0.0.31",
|
|
80
|
+
"@spences10/pi-skill-importer": "0.0.9",
|
|
82
81
|
"@spences10/pi-sqlite-tools": "0.0.13",
|
|
83
82
|
"@spences10/pi-svelte-guardrails": "0.0.13",
|
|
84
|
-
"@spences10/pi-
|
|
85
|
-
"@spences10/pi-
|
|
83
|
+
"@spences10/pi-team-mode": "0.0.49",
|
|
84
|
+
"@spences10/pi-telemetry": "0.0.28"
|
|
86
85
|
},
|
|
87
86
|
"engines": {
|
|
88
87
|
"node": ">=24.15.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-presets-BlCoIFYT.js","names":["no_purple_prose","clarify_first","include_risks"],"sources":["../src/extensions/prompt-presets/catalog.ts","../src/extensions/prompt-presets/completions.ts","../src/extensions/prompt-presets/defaults/bullets.md","../src/extensions/prompt-presets/defaults/clarify-first.md","../src/extensions/prompt-presets/defaults/detailed.md","../src/extensions/prompt-presets/defaults/include-risks.md","../src/extensions/prompt-presets/defaults/karpathy.md","../src/extensions/prompt-presets/defaults/no-purple-prose.md","../src/extensions/prompt-presets/defaults/standard.md","../src/extensions/prompt-presets/defaults/terse.md","../src/extensions/prompt-presets/defaults.ts","../src/extensions/prompt-presets/footer.ts","../src/extensions/prompt-presets/help.ts","../src/extensions/prompt-presets/prompt-blocks.ts","../src/extensions/prompt-presets/storage.ts","../src/extensions/prompt-presets/state.ts","../src/extensions/prompt-presets/manager.ts","../src/extensions/prompt-presets/index.ts"],"sourcesContent":["import type {\n\tLoadedPromptPreset,\n\tPromptPresetSource,\n} from './types.js';\n\nexport function get_prompt_source_label(\n\tsource: PromptPresetSource,\n): string {\n\tswitch (source) {\n\t\tcase 'builtin':\n\t\t\treturn 'built-in';\n\t\tcase 'user':\n\t\t\treturn 'user';\n\t\tcase 'project':\n\t\t\treturn 'project';\n\t}\n}\n\nexport function list_base_presets(\n\tpresets: Record<string, LoadedPromptPreset>,\n): LoadedPromptPreset[] {\n\treturn Object.values(presets)\n\t\t.filter((preset) => preset.kind === 'base')\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function list_layer_presets(\n\tpresets: Record<string, LoadedPromptPreset>,\n): LoadedPromptPreset[] {\n\treturn Object.values(presets)\n\t\t.filter((preset) => preset.kind === 'layer')\n\t\t.sort((a, b) => a.name.localeCompare(b.name));\n}\n\nexport function format_summary(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n\tpresets: Record<string, LoadedPromptPreset>,\n): string {\n\tconst lines = [`Base: ${active_base_name ?? '(none)'}`];\n\n\tconst layer_names = [...active_layers].sort();\n\tif (layer_names.length === 0) {\n\t\tlines.push('Layers: (none)');\n\t} else {\n\t\tlines.push('Layers:');\n\t\tfor (const name of layer_names) {\n\t\t\tconst preset = presets[name];\n\t\t\tconst description = preset?.description\n\t\t\t\t? ` — ${preset.description}`\n\t\t\t\t: '';\n\t\t\tlines.push(`- ${name}${description}`);\n\t\t}\n\t}\n\n\treturn lines.join('\\n');\n}\n\nexport function format_active_details(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n\tpresets: Record<string, LoadedPromptPreset>,\n): string {\n\tconst parts: string[] = [];\n\n\tif (active_base_name) {\n\t\tconst base = presets[active_base_name];\n\t\tif (base) {\n\t\t\tparts.push(`Base: ${base.name}`);\n\t\t\tif (base.description)\n\t\t\t\tparts.push(`Description: ${base.description}`);\n\t\t\tparts.push(`Source: ${get_prompt_source_label(base.source)}`);\n\t\t\tparts.push('', base.instructions.trim());\n\t\t}\n\t}\n\n\tconst layer_names = [...active_layers].sort();\n\tif (layer_names.length > 0) {\n\t\tif (parts.length > 0) parts.push('', '---', '');\n\t\tparts.push('Layers:');\n\t\tfor (const name of layer_names) {\n\t\t\tconst layer = presets[name];\n\t\t\tif (!layer) continue;\n\t\t\tparts.push(\n\t\t\t\t`- ${layer.name} (${get_prompt_source_label(layer.source)})`,\n\t\t\t);\n\t\t\tif (layer.description) parts.push(` ${layer.description}`);\n\t\t}\n\t}\n\n\treturn parts.join('\\n') || 'No preset or layers active';\n}\n","import { list_base_presets, list_layer_presets } from './catalog.js';\nimport type { LoadedPromptPreset } from './types.js';\n\nconst SUBCOMMANDS = [\n\t'help',\n\t'list',\n\t'show',\n\t'clear',\n\t'edit',\n\t'edit-global',\n\t'export-defaults',\n\t'delete',\n\t'reset',\n\t'reload',\n\t'base',\n\t'enable',\n\t'disable',\n\t'toggle',\n];\n\nexport function get_prompt_preset_completions(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tprefix: string,\n): Array<{ value: string; label: string }> | null {\n\tconst trimmed = prefix.trim();\n\tconst parts = trimmed ? trimmed.split(/\\s+/) : [];\n\tconst base_names = list_base_presets(presets).map(\n\t\t(preset) => preset.name,\n\t);\n\tconst layer_names = list_layer_presets(presets).map(\n\t\t(preset) => preset.name,\n\t);\n\tconst all_names = [...base_names, ...layer_names];\n\n\tif (parts.length <= 1) {\n\t\tconst query = parts[0] ?? '';\n\t\treturn [\n\t\t\t...SUBCOMMANDS.filter((item) => item.startsWith(query)).map(\n\t\t\t\t(item) => ({ value: item, label: item }),\n\t\t\t),\n\t\t\t...all_names\n\t\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t\t.map((item) => ({ value: item, label: item })),\n\t\t];\n\t}\n\n\tconst command = parts[0];\n\tconst query = parts.slice(1).join(' ');\n\tif (command === 'base') {\n\t\treturn base_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({ value: `base ${item}`, label: item }));\n\t}\n\tif (['enable', 'disable', 'toggle'].includes(command)) {\n\t\treturn layer_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\tif (command === 'edit' || command === 'edit-global') {\n\t\treturn all_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\tif (['delete', 'reset'].includes(command)) {\n\t\treturn all_names\n\t\t\t.filter((item) => item.startsWith(query))\n\t\t\t.map((item) => ({\n\t\t\t\tvalue: `${command} ${item}`,\n\t\t\t\tlabel: item,\n\t\t\t}));\n\t}\n\treturn null;\n}\n","\"---\\nkind: layer\\ndescription: Prefer short bullets when useful\\n---\\n\\nWhen presenting options, findings, or steps, prefer short bullet lists\\nover long paragraphs.\\n\"","\"---\\nkind: layer\\ndescription:\\n Ask brief clarifying questions when requirements are ambiguous\\n---\\n\\nIf the request is materially ambiguous, ask the minimum clarifying\\nquestion(s) needed before proceeding. Do not ask unnecessary\\nquestions.\\n\"","\"---\\nkind: base\\ndescription: More explanation when nuance matters\\n---\\n\\nBe thorough when the task is complex or tradeoffs matter, but stay\\npractical. Explain only the details that help the user decide, verify,\\nor implement. Avoid purple prose and unnecessary scene-setting.\\n\"","\"---\\nkind: layer\\ndescription: Call out notable risks or tradeoffs\\n---\\n\\nWhen making a recommendation or implementation plan, briefly mention\\nthe key risk, tradeoff, or caveat if one materially matters.\\n\"","\"---\\nkind: layer\\ndescription: Bias toward simple, surgical, verified code changes\\n---\\n\\nBefore coding, state assumptions when unclear and surface meaningful\\ntradeoffs. Prefer the minimum code that solves the request; avoid\\nspeculative abstractions, flexibility, and unrelated cleanup. Make\\nsurgical changes: touch only lines directly tied to the task, match\\nexisting style, and mention unrelated issues instead of fixing them.\\nFor multi-step work, use brief success criteria and verify with\\nfocused checks before reporting.\\n\"","\"---\\nkind: layer\\ndescription: Strip out ornamental language\\n---\\n\\nDo not use purple prose, flourish, motivational filler, or theatrical\\ntransitions. Prefer plain language and concrete statements.\\n\"","\"---\\nkind: base\\ndescription: Clear and concise with key context\\n---\\n\\nBe clear, direct, and concise. Include only the reasoning and\\nimplementation details that matter. Avoid filler, grandstanding, and\\nornamental language. Use bullets when they improve scanability.\\n\"","\"---\\nkind: base\\ndescription: Short, direct, no fluff\\n---\\n\\nBe concise and direct. Default to the shortest response that fully\\nsolves the user's request. Use at most one short paragraph or 3\\nbullets unless the user explicitly asks for detail. For implementation\\nreports, include only what changed, validation, and the next step if\\nrelevant. No purple prose, no filler, no repetitive caveats.\\n\"","import { parseFrontmatter } from '@earendil-works/pi-coding-agent';\nimport type { PromptPreset, PromptPresetMap } from './types.js';\n\nimport bullets from './defaults/bullets.md';\nimport clarify_first from './defaults/clarify-first.md';\nimport detailed from './defaults/detailed.md';\nimport include_risks from './defaults/include-risks.md';\nimport karpathy from './defaults/karpathy.md';\nimport no_purple_prose from './defaults/no-purple-prose.md';\nimport standard from './defaults/standard.md';\nimport terse from './defaults/terse.md';\n\nexport const DEFAULT_BASE_PROMPT_PRESET_NAME = 'terse';\n\nconst DEFAULT_PROMPT_PRESET_FILES = {\n\tterse,\n\tstandard,\n\tdetailed,\n\t'no-purple-prose': no_purple_prose,\n\tbullets,\n\t'clarify-first': clarify_first,\n\t'include-risks': include_risks,\n\tkarpathy,\n} satisfies Record<string, string>;\n\nfunction parse_default_prompt_preset(content: string): PromptPreset {\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\treturn {\n\t\tkind: frontmatter.kind === 'layer' ? 'layer' : 'base',\n\t\tinstructions: body.trim(),\n\t\t...(typeof frontmatter.description === 'string' &&\n\t\tfrontmatter.description.trim()\n\t\t\t? { description: frontmatter.description.trim() }\n\t\t\t: {}),\n\t};\n}\n\nexport const DEFAULT_PROMPT_PRESETS: PromptPresetMap =\n\tObject.fromEntries(\n\t\tObject.entries(DEFAULT_PROMPT_PRESET_FILES).map(\n\t\t\t([name, content]) => [\n\t\t\t\tname,\n\t\t\t\tparse_default_prompt_preset(content),\n\t\t\t],\n\t\t),\n\t);\n","import type { ExtensionContext } from '@earendil-works/pi-coding-agent';\n\nfunction get_footer_prompt_status(\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): string | undefined {\n\tif (!active_base_name && active_layers.size === 0) {\n\t\treturn undefined;\n\t}\n\n\tconst label = active_base_name ?? 'none';\n\tconst layer_suffix =\n\t\tactive_layers.size > 0 ? ` +${active_layers.size}` : '';\n\treturn `prompt:${label}${layer_suffix}`;\n}\n\nexport function set_status(\n\tctx: ExtensionContext,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): void {\n\tctx.ui.setStatus(\n\t\t'preset',\n\t\tget_footer_prompt_status(active_base_name, active_layers),\n\t);\n}\n","export function is_subcommand(command: string): boolean {\n\treturn [\n\t\t'help',\n\t\t'list',\n\t\t'show',\n\t\t'clear',\n\t\t'edit',\n\t\t'edit-global',\n\t\t'export-defaults',\n\t\t'delete',\n\t\t'reset',\n\t\t'reload',\n\t\t'base',\n\t\t'enable',\n\t\t'disable',\n\t\t'toggle',\n\t].includes(command);\n}\n\nexport function format_prompt_preset_help(): string {\n\treturn `Prompt presets append instructions to the system prompt.\n\nCommands:\n- /prompt-preset Open the preset picker\n- /prompt-preset show Show the active base and layers\n- /prompt-preset <name> Activate a base preset or toggle a layer\n- /prompt-preset base <name> Activate a base preset\n- /prompt-preset enable <layer> Enable a layer\n- /prompt-preset disable <layer> Disable a layer\n- /prompt-preset edit <name> Edit/create .pi/presets/<name>.md\n- /prompt-preset edit-global <name> Edit/create ~/.pi/agent/presets/<name>.md\n- /prompt-preset export-defaults Export built-ins to ~/.pi/agent/presets/*.md\n- /prompt-preset export-defaults project Export built-ins to .pi/presets/*.md\n- /prompt-preset reload Reload presets after manual file edits\n- /prompt-preset clear Clear active base and layers\n\nExamples:\n- /prompt-preset export-defaults\n- /prompt-preset edit-global terse\n- /prompt-preset base detailed\n- /prompt-preset enable bullets\n- /prompt-preset show\n\nAlias: /preset`;\n}\n","import type { LoadedPromptPreset } from './types.js';\n\nexport function build_active_prompt_blocks(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): string[] {\n\tconst blocks: string[] = [];\n\tconst base = active_base_name\n\t\t? presets[active_base_name]\n\t\t: undefined;\n\tif (base?.instructions.trim()) {\n\t\tblocks.push(\n\t\t\t`## Active Base Prompt: ${base.name}\\n${base.instructions.trim()}`,\n\t\t);\n\t}\n\n\tconst layer_blocks = [...active_layers]\n\t\t.sort()\n\t\t.map((name) => presets[name])\n\t\t.filter((preset): preset is LoadedPromptPreset =>\n\t\t\tBoolean(preset?.instructions.trim()),\n\t\t)\n\t\t.map(\n\t\t\t(preset) => `### ${preset.name}\\n${preset.instructions.trim()}`,\n\t\t);\n\tif (layer_blocks.length > 0) {\n\t\tblocks.push(\n\t\t\t`## Active Prompt Layers\\n\\n${layer_blocks.join('\\n\\n')}`,\n\t\t);\n\t}\n\n\treturn blocks;\n}\n","import {\n\tgetAgentDir,\n\tparseFrontmatter,\n} from '@earendil-works/pi-coding-agent';\nimport {\n\tread_settings,\n\twrite_settings,\n} from '@spences10/pi-settings';\nimport {\n\texistsSync,\n\tmkdirSync,\n\treaddirSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n\twriteFileSync,\n} from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { DEFAULT_PROMPT_PRESETS } from './defaults.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPreset,\n\tPromptPresetMap,\n\tPromptPresetSource,\n\tPromptPresetState,\n} from './types.js';\n\nconst PROJECT_PROMPT_PRESETS_ENV = 'MY_PI_PROMPT_PRESETS_PROJECT';\n\ninterface PersistedPromptPresetStates {\n\tversion: number;\n\tprojects: Record<string, PromptPresetState>;\n}\n\nexport function normalize_prompt_presets(\n\tinput: unknown,\n): PromptPresetMap {\n\tif (!input || typeof input !== 'object') return {};\n\n\tconst normalized: PromptPresetMap = {};\n\tfor (const [raw_name, raw_value] of Object.entries(input)) {\n\t\tconst name = raw_name.trim();\n\t\tif (!name) continue;\n\n\t\tif (typeof raw_value === 'string') {\n\t\t\tnormalized[name] = {\n\t\t\t\tkind: 'base',\n\t\t\t\tinstructions: raw_value,\n\t\t\t};\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!raw_value || typeof raw_value !== 'object') continue;\n\t\tconst candidate = raw_value as {\n\t\t\tkind?: unknown;\n\t\t\tdescription?: unknown;\n\t\t\tinstructions?: unknown;\n\t\t};\n\t\tif (typeof candidate.instructions !== 'string') continue;\n\n\t\tnormalized[name] = {\n\t\t\tinstructions: candidate.instructions,\n\t\t\t...(candidate.kind === 'layer'\n\t\t\t\t? { kind: 'layer' as const }\n\t\t\t\t: {}),\n\t\t\t...(typeof candidate.description === 'string'\n\t\t\t\t? { description: candidate.description }\n\t\t\t\t: {}),\n\t\t};\n\t}\n\n\treturn normalized;\n}\n\nexport function merge_prompt_presets(\n\t...sources: PromptPresetMap[]\n): PromptPresetMap {\n\treturn Object.assign({}, ...sources);\n}\n\nfunction to_loaded_prompt_presets(\n\tpresets: PromptPresetMap,\n\tsource: PromptPresetSource,\n): Record<string, LoadedPromptPreset> {\n\treturn Object.fromEntries(\n\t\tObject.entries(presets).map(([name, preset]) => [\n\t\t\tname,\n\t\t\t{\n\t\t\t\tname,\n\t\t\t\tkind: preset.kind === 'layer' ? 'layer' : 'base',\n\t\t\t\tsource,\n\t\t\t\t...preset,\n\t\t\t},\n\t\t]),\n\t);\n}\n\nfunction get_global_presets_path(): string {\n\treturn join(getAgentDir(), 'presets.json');\n}\n\nfunction get_project_presets_path(cwd: string): string {\n\treturn join(cwd, '.pi', 'presets.json');\n}\n\nexport function get_global_presets_dir(): string {\n\treturn join(getAgentDir(), 'presets');\n}\n\nexport function get_project_presets_dir(cwd: string): string {\n\treturn join(cwd, '.pi', 'presets');\n}\n\nfunction sanitize_prompt_preset_file_name(name: string): string {\n\tconst sanitized = name\n\t\t.trim()\n\t\t.replace(/[\\\\/:*?\"<>|]/g, '-')\n\t\t.replace(/^\\.+$/, '')\n\t\t.replace(/^\\.+/, '')\n\t\t.replace(/\\.+$/, '');\n\tif (!sanitized) {\n\t\tthrow new Error(\n\t\t\t'Prompt preset name must contain a file-safe character',\n\t\t);\n\t}\n\treturn sanitized;\n}\n\nexport function get_prompt_preset_file_path(\n\tdir: string,\n\tname: string,\n): string {\n\treturn join(dir, `${sanitize_prompt_preset_file_name(name)}.md`);\n}\n\nfunction get_persisted_prompt_state_path(): string {\n\treturn join(getAgentDir(), 'prompt-preset-state.json');\n}\n\nfunction read_prompt_presets_file(path: string): PromptPresetMap {\n\ttry {\n\t\tif (path === get_global_presets_path()) {\n\t\t\treturn normalize_prompt_presets(\n\t\t\t\tread_settings().promptPresets?.global ?? {},\n\t\t\t);\n\t\t}\n\t\tif (!existsSync(path)) return {};\n\t\treturn normalize_prompt_presets(\n\t\t\tJSON.parse(readFileSync(path, 'utf-8')),\n\t\t);\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport function parse_prompt_preset_markdown(content: string): {\n\tmetadata: Record<string, unknown>;\n\tbody: string;\n} {\n\tconst { frontmatter, body } = parseFrontmatter(content);\n\treturn { metadata: frontmatter, body: body.trim() };\n}\n\nexport function read_prompt_presets_dir(\n\tpath: string,\n): PromptPresetMap {\n\tif (!existsSync(path)) return {};\n\n\ttry {\n\t\tconst presets: PromptPresetMap = {};\n\t\tfor (const entry of readdirSync(path, { withFileTypes: true })\n\t\t\t.filter((item) => item.isFile() && item.name.endsWith('.md'))\n\t\t\t.sort((a, b) => a.name.localeCompare(b.name))) {\n\t\t\tconst name = entry.name.slice(0, -3).trim();\n\t\t\tif (!name) continue;\n\t\t\tconst { metadata, body } = parse_prompt_preset_markdown(\n\t\t\t\treadFileSync(join(path, entry.name), 'utf-8'),\n\t\t\t);\n\t\t\tif (!body) continue;\n\t\t\tpresets[name] = {\n\t\t\t\tkind: metadata.kind === 'layer' ? 'layer' : 'base',\n\t\t\t\tinstructions: body,\n\t\t\t\t...(typeof metadata.description === 'string' &&\n\t\t\t\tmetadata.description.trim()\n\t\t\t\t\t? { description: metadata.description }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t\treturn presets;\n\t} catch {\n\t\treturn {};\n\t}\n}\n\nexport function format_prompt_preset_markdown(\n\tpreset: PromptPreset,\n): string {\n\tconst lines = [\n\t\t'---',\n\t\t`kind: ${preset.kind === 'layer' ? 'layer' : 'base'}`,\n\t];\n\tif (preset.description?.trim()) {\n\t\tlines.push(\n\t\t\t`description: ${JSON.stringify(preset.description.trim())}`,\n\t\t);\n\t}\n\tlines.push('---', '', preset.instructions.trim(), '');\n\treturn lines.join('\\n');\n}\n\nexport function save_prompt_preset_file(\n\tdir: string,\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\tif (!existsSync(dir)) {\n\t\tmkdirSync(dir, { recursive: true, mode: 0o700 });\n\t}\n\n\tconst path = get_prompt_preset_file_path(dir, name);\n\tconst tmp = `${path}.tmp-${Date.now()}`;\n\twriteFileSync(tmp, format_prompt_preset_markdown(preset), {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\n\treturn path;\n}\n\nexport function save_project_prompt_preset_file(\n\tcwd: string,\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\treturn save_prompt_preset_file(\n\t\tget_project_presets_dir(cwd),\n\t\tname,\n\t\tpreset,\n\t);\n}\n\nexport function save_global_prompt_preset_file(\n\tname: string,\n\tpreset: PromptPreset,\n): string {\n\treturn save_prompt_preset_file(\n\t\tget_global_presets_dir(),\n\t\tname,\n\t\tpreset,\n\t);\n}\n\nfunction should_load_project_prompt_presets(): boolean {\n\tconst normalized = process.env[PROJECT_PROMPT_PRESETS_ENV]\n\t\t?.trim()\n\t\t.toLowerCase();\n\treturn !['0', 'false', 'no', 'skip', 'disable'].includes(\n\t\tnormalized ?? '',\n\t);\n}\n\nexport function load_prompt_presets(\n\tcwd: string,\n): Record<string, LoadedPromptPreset> {\n\treturn Object.assign(\n\t\t{},\n\t\tto_loaded_prompt_presets(DEFAULT_PROMPT_PRESETS, 'builtin'),\n\t\tto_loaded_prompt_presets(\n\t\t\tread_prompt_presets_file(get_global_presets_path()),\n\t\t\t'user',\n\t\t),\n\t\tto_loaded_prompt_presets(\n\t\t\tread_prompt_presets_dir(get_global_presets_dir()),\n\t\t\t'user',\n\t\t),\n\t\t...(should_load_project_prompt_presets()\n\t\t\t? [\n\t\t\t\t\tto_loaded_prompt_presets(\n\t\t\t\t\t\tread_prompt_presets_file(get_project_presets_path(cwd)),\n\t\t\t\t\t\t'project',\n\t\t\t\t\t),\n\t\t\t\t\tto_loaded_prompt_presets(\n\t\t\t\t\t\tread_prompt_presets_dir(get_project_presets_dir(cwd)),\n\t\t\t\t\t\t'project',\n\t\t\t\t\t),\n\t\t\t\t]\n\t\t\t: []),\n\t);\n}\n\nfunction sort_prompt_presets(\n\tpresets: PromptPresetMap,\n): PromptPresetMap {\n\treturn Object.fromEntries(\n\t\tObject.entries(presets).sort(([a], [b]) => a.localeCompare(b)),\n\t);\n}\n\nexport function save_project_prompt_presets(\n\tcwd: string,\n\tpresets: PromptPresetMap,\n): string {\n\tconst path = get_project_presets_path(cwd);\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(\n\t\ttmp,\n\t\tJSON.stringify(sort_prompt_presets(presets), null, '\\t') + '\\n',\n\t\t{ mode: 0o600 },\n\t);\n\trenameSync(tmp, path);\n\treturn path;\n}\n\nexport function remove_project_prompt_preset(\n\tcwd: string,\n\tname: string,\n): {\n\tremoved: boolean;\n\tpath: string;\n\tremaining: number;\n} {\n\tconst json_path = get_project_presets_path(cwd);\n\tconst project_presets = read_prompt_presets_file(json_path);\n\tlet removed = false;\n\tlet removed_path = json_path;\n\n\tif (name in project_presets) {\n\t\tdelete project_presets[name];\n\t\tremoved = true;\n\t\tremoved_path = json_path;\n\t\tif (Object.keys(project_presets).length === 0) {\n\t\t\tif (existsSync(json_path)) {\n\t\t\t\tunlinkSync(json_path);\n\t\t\t}\n\t\t} else {\n\t\t\tsave_project_prompt_presets(cwd, project_presets);\n\t\t}\n\t}\n\n\tconst file_path = get_prompt_preset_file_path(\n\t\tget_project_presets_dir(cwd),\n\t\tname,\n\t);\n\tif (existsSync(file_path)) {\n\t\tunlinkSync(file_path);\n\t\tremoved = true;\n\t\tremoved_path = file_path;\n\t}\n\n\tconst remaining =\n\t\tObject.keys(read_prompt_presets_file(json_path)).length +\n\t\tObject.keys(read_prompt_presets_dir(get_project_presets_dir(cwd)))\n\t\t\t.length;\n\n\treturn { removed, path: removed_path, remaining };\n}\n\nfunction normalize_prompt_preset_state(\n\tinput: unknown,\n): PromptPresetState | undefined {\n\tif (!input || typeof input !== 'object') return undefined;\n\n\tconst candidate = input as {\n\t\tbase_name?: unknown;\n\t\tlayer_names?: unknown;\n\t};\n\tconst base_name =\n\t\ttypeof candidate.base_name === 'string' &&\n\t\tcandidate.base_name.trim()\n\t\t\t? candidate.base_name.trim()\n\t\t\t: null;\n\tconst layer_names = Array.isArray(candidate.layer_names)\n\t\t? [\n\t\t\t\t...new Set(\n\t\t\t\t\tcandidate.layer_names\n\t\t\t\t\t\t.filter(\n\t\t\t\t\t\t\t(value): value is string =>\n\t\t\t\t\t\t\t\ttypeof value === 'string' && value.trim().length > 0,\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.map((value) => value.trim()),\n\t\t\t\t),\n\t\t\t].sort()\n\t\t: [];\n\n\treturn {\n\t\tbase_name,\n\t\tlayer_names,\n\t};\n}\n\nfunction read_persisted_prompt_states(\n\tpath = get_persisted_prompt_state_path(),\n): PersistedPromptPresetStates {\n\ttry {\n\t\tconst parsed = (\n\t\t\tpath === get_persisted_prompt_state_path()\n\t\t\t\t? (read_settings().promptPresets?.state ?? {})\n\t\t\t\t: existsSync(path)\n\t\t\t\t\t? JSON.parse(readFileSync(path, 'utf-8'))\n\t\t\t\t\t: {}\n\t\t) as {\n\t\t\tversion?: unknown;\n\t\t\tprojects?: unknown;\n\t\t};\n\t\tconst raw_projects =\n\t\t\tparsed.projects && typeof parsed.projects === 'object'\n\t\t\t\t? parsed.projects\n\t\t\t\t: {};\n\t\tconst projects: Record<string, PromptPresetState> = {};\n\t\tfor (const [cwd, value] of Object.entries(raw_projects)) {\n\t\t\tconst normalized = normalize_prompt_preset_state(value);\n\t\t\tif (!normalized) continue;\n\t\t\tprojects[cwd] = normalized;\n\t\t}\n\t\treturn {\n\t\t\tversion:\n\t\t\t\ttypeof parsed.version === 'number' ? parsed.version : 1,\n\t\t\tprojects,\n\t\t};\n\t} catch {\n\t\treturn { version: 1, projects: {} };\n\t}\n}\n\nexport function load_persisted_prompt_state(\n\tcwd: string,\n\tpath = get_persisted_prompt_state_path(),\n): PromptPresetState | undefined {\n\treturn read_persisted_prompt_states(path).projects[cwd];\n}\n\nexport function save_persisted_prompt_state(\n\tcwd: string,\n\tstate: PromptPresetState,\n\tpath = get_persisted_prompt_state_path(),\n): string {\n\tconst persisted = read_persisted_prompt_states(path);\n\tpersisted.projects[cwd] = normalize_prompt_preset_state(state) ?? {\n\t\tbase_name: null,\n\t\tlayer_names: [],\n\t};\n\n\tconst next = {\n\t\tversion: 1,\n\t\tprojects: Object.fromEntries(\n\t\t\tObject.entries(persisted.projects).sort(([a], [b]) =>\n\t\t\t\ta.localeCompare(b),\n\t\t\t),\n\t\t),\n\t};\n\tif (path === get_persisted_prompt_state_path()) {\n\t\tconst settings = read_settings();\n\t\twrite_settings({\n\t\t\t...settings,\n\t\t\tpromptPresets: { ...settings.promptPresets, state: next },\n\t\t});\n\t\treturn path;\n\t}\n\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(next, null, '\\t') + '\\n', {\n\t\tmode: 0o600,\n\t});\n\trenameSync(tmp, path);\n\treturn path;\n}\n","import type {\n\tExtensionAPI,\n\tExtensionContext,\n} from '@earendil-works/pi-coding-agent';\nimport { save_persisted_prompt_state } from './storage.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPresetState,\n} from './types.js';\n\nexport const PRESET_STATE_TYPE = 'prompt-preset-state';\nexport const ENABLED = '● enabled';\nexport const DISABLED = '○ disabled';\nexport const SELECTED = '● selected';\nexport const UNSELECTED = '○';\nexport const NONE_BASE_ID = '__base_none__';\n\nexport function get_last_preset_state(\n\tctx: ExtensionContext,\n): PromptPresetState | undefined {\n\tconst entries = ctx.sessionManager.getEntries();\n\tfor (let i = entries.length - 1; i >= 0; i--) {\n\t\tconst entry = entries[i] as {\n\t\t\ttype?: string;\n\t\t\tcustomType?: string;\n\t\t\tdata?: PromptPresetState;\n\t\t};\n\t\tif (\n\t\t\tentry.type === 'custom' &&\n\t\t\tentry.customType === PRESET_STATE_TYPE &&\n\t\t\tentry.data\n\t\t) {\n\t\t\treturn entry.data;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function 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\nexport function persist_state(\n\tpi: ExtensionAPI,\n\tctx: ExtensionContext,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): void {\n\tconst state = {\n\t\tbase_name: active_base_name ?? null,\n\t\tlayer_names: [...active_layers].sort(),\n\t};\n\tpi.appendEntry(PRESET_STATE_TYPE, state);\n\tsave_persisted_prompt_state(ctx.cwd, state);\n}\n\nexport function normalize_active_state(\n\tpresets: Record<string, LoadedPromptPreset>,\n\tactive_base_name: string | undefined,\n\tactive_layers: ReadonlySet<string>,\n): {\n\tactive_base_name: string | undefined;\n\tactive_layers: Set<string>;\n} {\n\tconst next_base_name =\n\t\tactive_base_name && presets[active_base_name]?.kind === 'base'\n\t\t\t? active_base_name\n\t\t\t: undefined;\n\tconst next_layers = new Set(\n\t\t[...active_layers].filter(\n\t\t\t(name) => presets[name]?.kind === 'layer',\n\t\t),\n\t);\n\treturn {\n\t\tactive_base_name: next_base_name,\n\t\tactive_layers: next_layers,\n\t};\n}\n\nexport function parse_preset_flag(flag: string): string[] {\n\treturn flag\n\t\t.split(',')\n\t\t.map((item) => item.trim())\n\t\t.filter(Boolean);\n}\n","import type { ExtensionCommandContext } from '@earendil-works/pi-coding-agent';\nimport {\n\tKey,\n\tmatchesKey,\n\ttruncateToWidth,\n\tvisibleWidth,\n\twrapTextWithAnsi,\n\ttype Component,\n} from '@earendil-works/pi-tui';\nimport { show_modal, type ModalTheme } from '@spences10/pi-tui-modal';\nimport {\n\tget_prompt_source_label,\n\tlist_base_presets,\n\tlist_layer_presets,\n} from './catalog.js';\nimport { build_active_prompt_blocks } from './prompt-blocks.js';\nimport { NONE_BASE_ID, sets_equal } from './state.js';\nimport type { LoadedPromptPreset } from './types.js';\n\nexport interface PromptPresetManagerState {\n\tpresets: Record<string, LoadedPromptPreset>;\n\tactive_base_name: string | undefined;\n\tactive_layers: ReadonlySet<string>;\n}\n\nexport type PromptPresetManagerResult =\n\t| {\n\t\t\taction: 'apply';\n\t\t\tbase_name: string | undefined;\n\t\t\tlayers: ReadonlySet<string>;\n\t }\n\t| { action: 'edit'; name: string; scope: 'project' | 'global' };\n\ntype PresetRow =\n\t| { type: 'header'; id: string; label: string }\n\t| { type: 'base-none'; id: typeof NONE_BASE_ID; label: string }\n\t| { type: 'preset'; id: string; preset: LoadedPromptPreset };\n\nexport async function show_prompt_preset_manager(\n\tctx: ExtensionCommandContext,\n\tstate: PromptPresetManagerState,\n\ton_change: (\n\t\tbase_name: string | undefined,\n\t\tlayers: ReadonlySet<string>,\n\t) => void,\n\ton_edit?: (\n\t\tname: string,\n\t\tscope: 'project' | 'global',\n\t) => Promise<void>,\n): Promise<void> {\n\tconst base_presets = list_base_presets(state.presets);\n\tconst layer_presets = list_layer_presets(state.presets);\n\tif (base_presets.length === 0 && layer_presets.length === 0) {\n\t\tctx.ui.notify('No prompt presets available', 'warning');\n\t\treturn;\n\t}\n\n\tconst result = await show_modal<\n\t\tPromptPresetManagerResult | undefined\n\t>(\n\t\tctx,\n\t\t{\n\t\t\ttitle: 'Prompt preset inspector',\n\t\t\tsubtitle: () =>\n\t\t\t\t`base: ${state.active_base_name ?? '(none)'} • ${state.active_layers.size} layer(s) currently active`,\n\t\t\tfooter:\n\t\t\t\t'↑↓ navigate • space toggle/select • tab preview • e edit project • E edit global • enter apply • esc cancel',\n\t\t\toverlay_options: {\n\t\t\t\twidth: '92%',\n\t\t\t\tminWidth: 72,\n\t\t\t\tmaxHeight: '88%',\n\t\t\t},\n\t\t},\n\t\t({ done }, theme, layout) =>\n\t\t\tnew PromptPresetInspectorBody(\n\t\t\t\tstate,\n\t\t\t\ttheme,\n\t\t\t\t() => layout.get_max_body_lines(),\n\t\t\t\tdone,\n\t\t\t),\n\t);\n\n\tif (!result) return;\n\tif (result.action === 'edit') {\n\t\tawait on_edit?.(result.name, result.scope);\n\t\treturn;\n\t}\n\tif (\n\t\tresult.base_name !== state.active_base_name ||\n\t\t!sets_equal(new Set(state.active_layers), result.layers)\n\t) {\n\t\ton_change(result.base_name, result.layers);\n\t}\n}\n\nclass PromptPresetInspectorBody implements Component {\n\tprivate readonly rows: PresetRow[];\n\tprivate selected_index = 1;\n\tprivate selected_base: string | undefined;\n\tprivate readonly enabled_layers: Set<string>;\n\tprivate preview_mode: 'item' | 'effective' = 'item';\n\tprivate preview_offset = 0;\n\tprivate preview_lines: string[] = [];\n\n\tconstructor(\n\t\tprivate readonly state: PromptPresetManagerState,\n\t\tprivate readonly theme: ModalTheme,\n\t\tprivate readonly get_max_lines: () => number,\n\t\tprivate readonly done: (\n\t\t\tresult: PromptPresetManagerResult | undefined,\n\t\t) => void,\n\t) {\n\t\tconst base_presets = list_base_presets(state.presets);\n\t\tconst layer_presets = list_layer_presets(state.presets);\n\t\tthis.rows = [\n\t\t\t{\n\t\t\t\ttype: 'header',\n\t\t\t\tid: '__base_header__',\n\t\t\t\tlabel: `Base presets (${base_presets.length + 1})`,\n\t\t\t},\n\t\t\t{ type: 'base-none', id: NONE_BASE_ID, label: '(none)' },\n\t\t\t...base_presets.map((preset) => ({\n\t\t\t\ttype: 'preset' as const,\n\t\t\t\tid: preset.name,\n\t\t\t\tpreset,\n\t\t\t})),\n\t\t\t{\n\t\t\t\ttype: 'header',\n\t\t\t\tid: '__layer_header__',\n\t\t\t\tlabel: `Prompt layers (${layer_presets.length})`,\n\t\t\t},\n\t\t\t...layer_presets.map((preset) => ({\n\t\t\t\ttype: 'preset' as const,\n\t\t\t\tid: preset.name,\n\t\t\t\tpreset,\n\t\t\t})),\n\t\t];\n\t\tthis.selected_base = state.active_base_name;\n\t\tthis.enabled_layers = new Set(state.active_layers);\n\t\tthis.skip_header(1);\n\t}\n\n\trender(width: number): string[] {\n\t\tconst body_lines = Math.max(8, this.get_max_lines());\n\t\tif (width < 80) return this.render_stacked(width, body_lines);\n\n\t\tconst list_width = Math.min(\n\t\t\t38,\n\t\t\tMath.max(28, Math.floor(width * 0.38)),\n\t\t);\n\t\tconst preview_width = width - list_width - 3;\n\t\tconst list = this.render_list(list_width, body_lines);\n\t\tconst preview = this.render_preview(preview_width, body_lines);\n\t\tconst lines: string[] = [];\n\t\tfor (let i = 0; i < body_lines; i++) {\n\t\t\tlines.push(\n\t\t\t\t`${this.pad_line(list[i] ?? '', list_width)} ${this.theme.fg('dim', '│')} ${preview[i] ?? ''}`,\n\t\t\t);\n\t\t}\n\t\treturn lines.map((line) => truncateToWidth(line, width));\n\t}\n\n\tinvalidate(): void {\n\t\t// No cached rendering.\n\t}\n\n\thandleInput(data: string): void {\n\t\tif (matchesKey(data, Key.up) || data === 'k') {\n\t\t\tthis.move(-1);\n\t\t} else if (matchesKey(data, Key.down) || data === 'j') {\n\t\t\tthis.move(1);\n\t\t} else if (data === ' ' || matchesKey(data, Key.enter)) {\n\t\t\tif (matchesKey(data, Key.enter)) {\n\t\t\t\tthis.done({\n\t\t\t\t\taction: 'apply',\n\t\t\t\t\tbase_name: this.selected_base,\n\t\t\t\t\tlayers: new Set(this.enabled_layers),\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.toggle_selected();\n\t\t} else if (data === '\\t') {\n\t\t\tthis.preview_mode =\n\t\t\t\tthis.preview_mode === 'item' ? 'effective' : 'item';\n\t\t\tthis.preview_offset = 0;\n\t\t} else if (data === 'c') {\n\t\t\tthis.selected_base = undefined;\n\t\t\tthis.enabled_layers.clear();\n\t\t\tthis.preview_mode = 'effective';\n\t\t\tthis.preview_offset = 0;\n\t\t} else if (data === 'a') {\n\t\t\tthis.done({\n\t\t\t\taction: 'apply',\n\t\t\t\tbase_name: this.selected_base,\n\t\t\t\tlayers: new Set(this.enabled_layers),\n\t\t\t});\n\t\t} else if (data === 'e' || data === 'E') {\n\t\t\tconst row = this.rows[this.selected_index];\n\t\t\tif (row?.type === 'preset') {\n\t\t\t\tthis.done({\n\t\t\t\t\taction: 'edit',\n\t\t\t\t\tname: row.preset.name,\n\t\t\t\t\tscope: data === 'E' ? 'global' : 'project',\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (matchesKey(data, Key.escape) || data === 'q') {\n\t\t\tthis.done(undefined);\n\t\t} else if (data === 'J') {\n\t\t\tthis.scroll_preview(1);\n\t\t} else if (data === 'K') {\n\t\t\tthis.scroll_preview(-1);\n\t\t}\n\t}\n\n\tprivate render_stacked(\n\t\twidth: number,\n\t\tbody_lines: number,\n\t): string[] {\n\t\tconst list_lines = Math.max(5, Math.floor(body_lines / 2));\n\t\treturn [\n\t\t\t...this.render_list(width, list_lines),\n\t\t\tthis.theme.fg('dim', '─'.repeat(Math.min(width, 80))),\n\t\t\t...this.render_preview(width, body_lines - list_lines - 1),\n\t\t];\n\t}\n\n\tprivate render_list(width: number, max_lines: number): string[] {\n\t\tconst lines = [\n\t\t\tthis.theme.fg(\n\t\t\t\t'accent',\n\t\t\t\t`Draft selection: ${this.selected_base ?? '(none)'} + ${this.enabled_layers.size} layer(s)`,\n\t\t\t),\n\t\t\t'',\n\t\t];\n\t\tconst visible_rows = Math.max(1, max_lines - lines.length);\n\t\tconst start = Math.max(\n\t\t\t0,\n\t\t\tMath.min(\n\t\t\t\tthis.selected_index - Math.floor(visible_rows / 2),\n\t\t\t\tthis.rows.length - visible_rows,\n\t\t\t),\n\t\t);\n\t\tconst end = Math.min(start + visible_rows, this.rows.length);\n\t\tfor (let index = start; index < end; index++) {\n\t\t\tlines.push(this.render_row(this.rows[index], index, width));\n\t\t}\n\t\treturn lines.map((line) => truncateToWidth(line, width));\n\t}\n\n\tprivate render_preview(width: number, max_lines: number): string[] {\n\t\tconst heading =\n\t\t\tthis.preview_mode === 'effective'\n\t\t\t\t? 'Effective prompt contribution'\n\t\t\t\t: 'Selected preset';\n\t\tconst text =\n\t\t\tthis.preview_mode === 'effective'\n\t\t\t\t? this.get_effective_prompt_text()\n\t\t\t\t: this.get_selected_prompt_text();\n\t\tconst content_width = Math.max(10, width);\n\t\tthis.preview_lines = text\n\t\t\t.split('\\n')\n\t\t\t.flatMap((line) =>\n\t\t\t\tline.trim().length === 0\n\t\t\t\t\t? ['']\n\t\t\t\t\t: wrapTextWithAnsi(line, content_width),\n\t\t\t);\n\t\tconst available = Math.max(1, max_lines - 2);\n\t\tconst max_offset = Math.max(\n\t\t\t0,\n\t\t\tthis.preview_lines.length - available,\n\t\t);\n\t\tthis.preview_offset = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.preview_offset, max_offset),\n\t\t);\n\t\tconst end = Math.min(\n\t\t\tthis.preview_offset + available,\n\t\t\tthis.preview_lines.length,\n\t\t);\n\t\tconst range =\n\t\t\tthis.preview_lines.length > available\n\t\t\t\t? ` (${this.preview_offset + 1}-${end}/${this.preview_lines.length})`\n\t\t\t\t: '';\n\t\treturn [\n\t\t\tthis.theme.fg('accent', this.theme.bold(`${heading}${range}`)),\n\t\t\t'',\n\t\t\t...this.preview_lines\n\t\t\t\t.slice(this.preview_offset, end)\n\t\t\t\t.map((line) => truncateToWidth(line, width)),\n\t\t];\n\t}\n\n\tprivate render_row(\n\t\trow: PresetRow,\n\t\tindex: number,\n\t\twidth: number,\n\t): string {\n\t\tif (row.type === 'header') {\n\t\t\treturn this.theme.fg('muted', ` ${row.label}`);\n\t\t}\n\t\tconst selected = index === this.selected_index;\n\t\tconst cursor = selected ? this.theme.fg('accent', '› ') : ' ';\n\t\tconst marker = this.get_marker(row);\n\t\tconst label =\n\t\t\trow.type === 'base-none' ? row.label : row.preset.name;\n\t\tconst suffix =\n\t\t\trow.type === 'preset'\n\t\t\t\t? ` ${this.theme.fg('dim', get_prompt_source_label(row.preset.source))}`\n\t\t\t\t: '';\n\t\treturn truncateToWidth(\n\t\t\t`${cursor}${marker} ${this.pad(label, 18)}${suffix}`,\n\t\t\twidth,\n\t\t);\n\t}\n\n\tprivate get_marker(row: PresetRow): string {\n\t\tif (row.type === 'header') return ' ';\n\t\tif (row.type === 'base-none') {\n\t\t\treturn this.selected_base ? '○' : '●';\n\t\t}\n\t\tif (row.preset.kind === 'base') {\n\t\t\treturn this.selected_base === row.preset.name ? '●' : '○';\n\t\t}\n\t\treturn this.enabled_layers.has(row.preset.name) ? '☑' : '☐';\n\t}\n\n\tprivate get_selected_prompt_text(): string {\n\t\tconst row = this.rows[this.selected_index];\n\t\tif (!row || row.type === 'header') return '';\n\t\tif (row.type === 'base-none') {\n\t\t\treturn 'No active base preset. Only enabled prompt layers will be appended.';\n\t\t}\n\t\tconst preset = row.preset;\n\t\treturn [\n\t\t\t`# ${preset.name}`,\n\t\t\t'',\n\t\t\t`Kind: ${preset.kind}`,\n\t\t\t`Source: ${get_prompt_source_label(preset.source)}`,\n\t\t\tpreset.description\n\t\t\t\t? `Description: ${preset.description}`\n\t\t\t\t: undefined,\n\t\t\t'',\n\t\t\tpreset.instructions.trim() || '(empty preset)',\n\t\t]\n\t\t\t.filter((line): line is string => line !== undefined)\n\t\t\t.join('\\n');\n\t}\n\n\tprivate get_effective_prompt_text(): string {\n\t\tconst blocks = build_active_prompt_blocks(\n\t\t\tthis.state.presets,\n\t\t\tthis.selected_base,\n\t\t\tthis.enabled_layers,\n\t\t);\n\t\treturn blocks.length > 0\n\t\t\t? blocks.join('\\n\\n')\n\t\t\t: '(No prompt preset text will be appended.)';\n\t}\n\n\tprivate toggle_selected(): void {\n\t\tconst row = this.rows[this.selected_index];\n\t\tif (!row || row.type === 'header') return;\n\t\tif (row.type === 'base-none') {\n\t\t\tthis.selected_base = undefined;\n\t\t} else if (row.preset.kind === 'base') {\n\t\t\tthis.selected_base = row.preset.name;\n\t\t} else if (this.enabled_layers.has(row.preset.name)) {\n\t\t\tthis.enabled_layers.delete(row.preset.name);\n\t\t} else {\n\t\t\tthis.enabled_layers.add(row.preset.name);\n\t\t}\n\t\tthis.preview_mode = 'effective';\n\t\tthis.preview_offset = 0;\n\t}\n\n\tprivate move(delta: number): void {\n\t\tlet next = this.selected_index;\n\t\tdo {\n\t\t\tnext = (next + delta + this.rows.length) % this.rows.length;\n\t\t} while (this.rows[next]?.type === 'header');\n\t\tthis.selected_index = next;\n\t\tthis.preview_offset = 0;\n\t}\n\n\tprivate skip_header(fallback: number): void {\n\t\tif (this.rows[this.selected_index]?.type !== 'header') return;\n\t\tthis.selected_index = fallback;\n\t}\n\n\tprivate scroll_preview(delta: number): void {\n\t\tconst max_offset = Math.max(0, this.preview_lines.length - 1);\n\t\tthis.preview_offset = Math.max(\n\t\t\t0,\n\t\t\tMath.min(this.preview_offset + delta, max_offset),\n\t\t);\n\t}\n\n\tprivate pad(text: string, width: number): string {\n\t\tconst visible = visibleWidth(text);\n\t\treturn text + ' '.repeat(Math.max(0, width - visible));\n\t}\n\n\tprivate pad_line(text: string, width: number): string {\n\t\tconst truncated = truncateToWidth(text, width);\n\t\treturn (\n\t\t\ttruncated +\n\t\t\t' '.repeat(Math.max(0, width - visibleWidth(truncated)))\n\t\t);\n\t}\n}\n","import {\n\ttype ExtensionAPI,\n\ttype ExtensionCommandContext,\n\ttype ExtensionContext,\n} from '@earendil-works/pi-coding-agent';\nimport { existsSync, readFileSync } from 'node:fs';\nimport {\n\tformat_active_details,\n\tformat_summary,\n\tget_prompt_source_label,\n} from './catalog.js';\nimport { get_prompt_preset_completions } from './completions.js';\nimport {\n\tDEFAULT_BASE_PROMPT_PRESET_NAME,\n\tDEFAULT_PROMPT_PRESETS,\n} from './defaults.js';\nimport { set_status } from './footer.js';\nimport { format_prompt_preset_help, is_subcommand } from './help.js';\nimport { show_prompt_preset_manager } from './manager.js';\nimport { build_active_prompt_blocks } from './prompt-blocks.js';\nimport {\n\tget_last_preset_state,\n\tnormalize_active_state,\n\tparse_preset_flag,\n\tpersist_state,\n} from './state.js';\nimport {\n\tformat_prompt_preset_markdown,\n\tget_global_presets_dir,\n\tget_project_presets_dir,\n\tget_prompt_preset_file_path,\n\tload_persisted_prompt_state,\n\tload_prompt_presets,\n\tparse_prompt_preset_markdown,\n\tremove_project_prompt_preset,\n\tsave_global_prompt_preset_file,\n\tsave_project_prompt_preset_file,\n\tsave_prompt_preset_file,\n} from './storage.js';\nimport type {\n\tLoadedPromptPreset,\n\tPromptPresetKind,\n} from './types.js';\n\nexport {\n\tget_current_thinking_level,\n\tget_default_footer_thinking_level,\n\trender_footer_status_line,\n} from '@spences10/pi-footer';\nexport {\n\tDEFAULT_BASE_PROMPT_PRESET_NAME,\n\tDEFAULT_PROMPT_PRESETS,\n} from './defaults.js';\nexport {\n\tload_persisted_prompt_state,\n\tload_prompt_presets,\n\tmerge_prompt_presets,\n\tnormalize_prompt_presets,\n\tread_prompt_presets_dir,\n\tremove_project_prompt_preset,\n\tsave_persisted_prompt_state,\n\tsave_project_prompt_presets,\n\tsave_prompt_preset_file,\n} from './storage.js';\nexport type {\n\tLoadedPromptPreset,\n\tPromptPreset,\n\tPromptPresetKind,\n\tPromptPresetMap,\n\tPromptPresetSource,\n\tPromptPresetState,\n} from './types.js';\n\nexport default async function prompt_presets(pi: ExtensionAPI) {\n\tlet presets: Record<string, LoadedPromptPreset> = {};\n\tlet active_base_name: string | undefined;\n\tlet active_layers = new Set<string>();\n\n\tfunction get_base(\n\t\tname: string | undefined,\n\t): LoadedPromptPreset | undefined {\n\t\treturn name ? presets[name] : undefined;\n\t}\n\n\tfunction get_layer(name: string): LoadedPromptPreset | undefined {\n\t\tconst preset = presets[name];\n\t\treturn preset?.kind === 'layer' ? preset : undefined;\n\t}\n\n\tfunction commit_state(\n\t\tctx: ExtensionContext,\n\t\tnext_base_name: string | undefined,\n\t\tnext_layers: ReadonlySet<string>,\n\t\toptions?: { persist?: boolean; notify?: string },\n\t): void {\n\t\tactive_base_name = next_base_name;\n\t\tactive_layers = new Set(next_layers);\n\t\tset_status(ctx, active_base_name, active_layers);\n\t\tif (options?.persist !== false) {\n\t\t\tpersist_state(pi, ctx, active_base_name, active_layers);\n\t\t}\n\t\tif (options?.notify) {\n\t\t\tctx.ui.notify(options.notify, 'info');\n\t\t}\n\t}\n\n\tfunction activate_base(\n\t\tname: string | undefined,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\tif (!name) {\n\t\t\tcommit_state(ctx, undefined, active_layers, {\n\t\t\t\tpersist: options?.persist,\n\t\t\t\tnotify: 'Base preset cleared',\n\t\t\t});\n\t\t\treturn true;\n\t\t}\n\n\t\tconst preset = get_base(name);\n\t\tif (!preset) {\n\t\t\tctx.ui.notify(`Unknown base preset: ${name}`, 'warning');\n\t\t\treturn false;\n\t\t}\n\n\t\tcommit_state(ctx, preset.name, active_layers, {\n\t\t\tpersist: options?.persist,\n\t\t\tnotify: `Base preset \"${preset.name}\" activated`,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction set_layer_enabled(\n\t\tname: string,\n\t\tenabled: boolean,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\tconst preset = get_layer(name);\n\t\tif (!preset) {\n\t\t\tctx.ui.notify(`Unknown prompt layer: ${name}`, 'warning');\n\t\t\treturn false;\n\t\t}\n\n\t\tconst next_layers = new Set(active_layers);\n\t\tif (enabled) {\n\t\t\tnext_layers.add(preset.name);\n\t\t} else {\n\t\t\tnext_layers.delete(preset.name);\n\t\t}\n\n\t\tcommit_state(ctx, active_base_name, next_layers, {\n\t\t\tpersist: options?.persist,\n\t\t\tnotify: enabled\n\t\t\t\t? `Layer \"${preset.name}\" enabled`\n\t\t\t\t: `Layer \"${preset.name}\" disabled`,\n\t\t});\n\t\treturn true;\n\t}\n\n\tfunction toggle_layer(\n\t\tname: string,\n\t\tctx: ExtensionContext,\n\t\toptions?: { persist?: boolean },\n\t): boolean {\n\t\treturn set_layer_enabled(\n\t\t\tname,\n\t\t\t!active_layers.has(name),\n\t\t\tctx,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tasync function edit_preset(\n\t\tname: string,\n\t\tctx: ExtensionCommandContext,\n\t\tscope: 'project' | 'global' = 'project',\n\t): Promise<void> {\n\t\tconst existing = presets[name];\n\t\tconst dir =\n\t\t\tscope === 'global'\n\t\t\t\t? get_global_presets_dir()\n\t\t\t\t: get_project_presets_dir(ctx.cwd);\n\t\tconst path = get_prompt_preset_file_path(dir, name);\n\t\tconst initial_markdown = existsSync(path)\n\t\t\t? readFileSync(path, 'utf-8')\n\t\t\t: format_prompt_preset_markdown({\n\t\t\t\t\tkind: existing?.kind ?? 'layer',\n\t\t\t\t\tinstructions: existing?.instructions ?? '',\n\t\t\t\t\t...(existing?.description\n\t\t\t\t\t\t? { description: existing.description }\n\t\t\t\t\t\t: {}),\n\t\t\t\t});\n\n\t\tconst edited = await ctx.ui.editor(\n\t\t\t`Edit ${scope} preset markdown: ${name}`,\n\t\t\tinitial_markdown,\n\t\t);\n\t\tif (edited === undefined) return;\n\n\t\tconst { metadata, body } = parse_prompt_preset_markdown(edited);\n\t\tif (!body.trim()) {\n\t\t\tctx.ui.notify('Preset instructions cannot be empty', 'warning');\n\t\t\treturn;\n\t\t}\n\t\tconst kind: PromptPresetKind =\n\t\t\tmetadata.kind === 'base' ? 'base' : 'layer';\n\t\tconst preset = {\n\t\t\tkind,\n\t\t\tinstructions: body,\n\t\t\t...(typeof metadata.description === 'string' &&\n\t\t\tmetadata.description.trim()\n\t\t\t\t? { description: metadata.description.trim() }\n\t\t\t\t: {}),\n\t\t};\n\n\t\tconst saved_path =\n\t\t\tscope === 'global'\n\t\t\t\t? save_global_prompt_preset_file(name, preset)\n\t\t\t\t: save_project_prompt_preset_file(ctx.cwd, name, preset);\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\n\t\tif (kind === 'base') {\n\t\t\tactivate_base(name, ctx);\n\t\t} else {\n\t\t\tset_layer_enabled(name, true, ctx);\n\t\t}\n\t\tctx.ui.notify(`Saved preset \"${name}\" to ${saved_path}`, 'info');\n\t}\n\n\tfunction export_default_presets(\n\t\tctx: ExtensionCommandContext,\n\t\tscope: 'project' | 'global',\n\t): void {\n\t\tconst dir =\n\t\t\tscope === 'global'\n\t\t\t\t? get_global_presets_dir()\n\t\t\t\t: get_project_presets_dir(ctx.cwd);\n\t\tlet written = 0;\n\t\tlet skipped = 0;\n\t\tfor (const [name, preset] of Object.entries(\n\t\t\tDEFAULT_PROMPT_PRESETS,\n\t\t)) {\n\t\t\tconst path = get_prompt_preset_file_path(dir, name);\n\t\t\tif (existsSync(path)) {\n\t\t\t\tskipped += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsave_prompt_preset_file(dir, name, preset);\n\t\t\twritten += 1;\n\t\t}\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\n\t\tctx.ui.notify(\n\t\t\t`Exported ${written} built-in preset file(s) to ${dir}${skipped ? ` (${skipped} already existed)` : ''}`,\n\t\t\t'info',\n\t\t);\n\t}\n\n\tfunction remove_custom_preset(\n\t\tname: string,\n\t\tctx: ExtensionCommandContext,\n\t\tmode: 'delete' | 'reset',\n\t): void {\n\t\tconst result = remove_project_prompt_preset(ctx.cwd, name);\n\t\tif (!result.removed) {\n\t\t\tctx.ui.notify(\n\t\t\t\t`No project-local preset named \"${name}\" to ${mode}`,\n\t\t\t\t'warning',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\t\tpersist_state(pi, ctx, active_base_name, active_layers);\n\n\t\tconst fallback = presets[name];\n\t\tif (mode === 'reset' && fallback) {\n\t\t\tctx.ui.notify(\n\t\t\t\t`Reset \"${name}\" to ${get_prompt_source_label(fallback.source)} preset`,\n\t\t\t\t'info',\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\tctx.ui.notify(\n\t\t\tresult.remaining === 0\n\t\t\t\t? `Removed \"${name}\" and deleted ${result.path}`\n\t\t\t\t: `Removed \"${name}\" from ${result.path}`,\n\t\t\t'info',\n\t\t);\n\t}\n\n\tasync function show_manager(\n\t\tctx: ExtensionCommandContext,\n\t): Promise<void> {\n\t\tawait show_prompt_preset_manager(\n\t\t\tctx,\n\t\t\t{ presets, active_base_name, active_layers },\n\t\t\t(selected_base, enabled_layers) => {\n\t\t\t\tcommit_state(ctx, selected_base, enabled_layers, {\n\t\t\t\t\tnotify: 'Updated prompt preset selection',\n\t\t\t\t});\n\t\t\t},\n\t\t\tasync (name, scope) => {\n\t\t\t\tawait edit_preset(name, ctx, scope);\n\t\t\t},\n\t\t);\n\t}\n\n\tpi.registerFlag('preset', {\n\t\tdescription:\n\t\t\t'Activate prompt config on startup. Accepts a base preset or comma-separated preset/layer names.',\n\t\ttype: 'string',\n\t});\n\n\tconst prompt_preset_command: Parameters<\n\t\tExtensionAPI['registerCommand']\n\t>[1] = {\n\t\tdescription:\n\t\t\t'Manage prompt presets and layers. Try: /prompt-preset help, /prompt-preset export-defaults, /prompt-preset edit-global terse',\n\t\tgetArgumentCompletions: (prefix) =>\n\t\t\tget_prompt_preset_completions(presets, prefix),\n\t\thandler: async (args, ctx) => {\n\t\t\tconst trimmed = args.trim();\n\t\t\tif (!trimmed) {\n\t\t\t\tif (ctx.hasUI) {\n\t\t\t\t\tawait show_manager(ctx);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\tformat_summary(active_base_name, active_layers, presets),\n\t\t\t\t\t'info',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst [first, ...rest] = trimmed.split(/\\s+/);\n\t\t\tconst arg = rest.join(' ').trim();\n\n\t\t\tswitch (first) {\n\t\t\t\tcase 'help':\n\t\t\t\t\tctx.ui.notify(format_prompt_preset_help(), 'info');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'list':\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\tformat_summary(active_base_name, active_layers, presets),\n\t\t\t\t\t\t'info',\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'show':\n\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\tformat_active_details(\n\t\t\t\t\t\t\tactive_base_name,\n\t\t\t\t\t\t\tactive_layers,\n\t\t\t\t\t\t\tpresets,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'info',\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'clear':\n\t\t\t\t\tcommit_state(ctx, undefined, new Set(), {\n\t\t\t\t\t\tnotify: 'Cleared base preset and prompt layers',\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\tcase 'reload': {\n\t\t\t\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\t\t\t\tconst normalized = normalize_active_state(\n\t\t\t\t\t\tpresets,\n\t\t\t\t\t\tactive_base_name,\n\t\t\t\t\t\tactive_layers,\n\t\t\t\t\t);\n\t\t\t\t\tactive_base_name = normalized.active_base_name;\n\t\t\t\t\tactive_layers = normalized.active_layers;\n\t\t\t\t\tset_status(ctx, active_base_name, active_layers);\n\t\t\t\t\tctx.ui.notify('Reloaded prompt presets', 'info');\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'base':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset base <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tactivate_base(arg, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'enable':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset enable <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tset_layer_enabled(arg, true, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'disable':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset disable <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tset_layer_enabled(arg, false, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'toggle':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset toggle <layer> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\ttoggle_layer(arg, ctx);\n\t\t\t\t\treturn;\n\t\t\t\tcase 'edit': {\n\t\t\t\t\tlet scope: 'project' | 'global' = 'project';\n\t\t\t\t\tlet name = arg;\n\t\t\t\t\tif (arg.startsWith('--global ')) {\n\t\t\t\t\t\tscope = 'global';\n\t\t\t\t\t\tname = arg.slice('--global '.length).trim();\n\t\t\t\t\t} else if (arg.startsWith('--project ')) {\n\t\t\t\t\t\tname = arg.slice('--project '.length).trim();\n\t\t\t\t\t}\n\t\t\t\t\tif (!name) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset edit [--global|--project] <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait edit_preset(name, ctx, scope);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'edit-global':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset edit-global <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tawait edit_preset(arg, ctx, 'global');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'export-defaults': {\n\t\t\t\t\tconst scope = arg || 'global';\n\t\t\t\t\tif (scope !== 'global' && scope !== 'project') {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset export-defaults [global|project] (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\texport_default_presets(ctx, scope);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tcase 'delete':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset delete <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tremove_custom_preset(arg, ctx, 'delete');\n\t\t\t\t\treturn;\n\t\t\t\tcase 'reset':\n\t\t\t\t\tif (!arg) {\n\t\t\t\t\t\tctx.ui.notify(\n\t\t\t\t\t\t\t'Usage: /prompt-preset reset <name> (alias: /preset)',\n\t\t\t\t\t\t\t'warning',\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tremove_custom_preset(arg, ctx, 'reset');\n\t\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (is_subcommand(first)) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Unsupported preset command: ${first}`,\n\t\t\t\t\t'warning',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst preset = presets[trimmed];\n\t\t\tif (!preset) {\n\t\t\t\tctx.ui.notify(\n\t\t\t\t\t`Unknown preset or layer: ${trimmed}. Try /prompt-preset help.`,\n\t\t\t\t\t'warning',\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (preset.kind === 'base') {\n\t\t\t\tactivate_base(preset.name, ctx);\n\t\t\t} else {\n\t\t\t\ttoggle_layer(preset.name, ctx);\n\t\t\t}\n\t\t},\n\t};\n\n\tfor (const command_name of ['prompt-preset', 'preset']) {\n\t\tpi.registerCommand(command_name, prompt_preset_command);\n\t}\n\n\tpi.on('session_start', async (_event, ctx) => {\n\t\tpresets = load_prompt_presets(ctx.cwd);\n\t\tactive_base_name = undefined;\n\t\tactive_layers = new Set();\n\n\t\tconst preset_flag = pi.getFlag('preset');\n\t\tif (typeof preset_flag === 'string' && preset_flag.trim()) {\n\t\t\tfor (const name of parse_preset_flag(preset_flag)) {\n\t\t\t\tconst preset = presets[name];\n\t\t\t\tif (!preset) continue;\n\t\t\t\tif (preset.kind === 'base') {\n\t\t\t\t\tactive_base_name = name;\n\t\t\t\t} else {\n\t\t\t\t\tactive_layers.add(name);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst normalized = normalize_active_state(\n\t\t\t\tpresets,\n\t\t\t\tactive_base_name,\n\t\t\t\tactive_layers,\n\t\t\t);\n\t\t\tactive_base_name = normalized.active_base_name;\n\t\t\tactive_layers = normalized.active_layers;\n\t\t\tset_status(ctx, active_base_name, active_layers);\n\t\t\treturn;\n\t\t}\n\n\t\tconst restored = get_last_preset_state(ctx) ??\n\t\t\tload_persisted_prompt_state(ctx.cwd) ?? {\n\t\t\t\tbase_name: DEFAULT_BASE_PROMPT_PRESET_NAME,\n\t\t\t\tlayer_names: [],\n\t\t\t};\n\t\tactive_base_name = restored.base_name ?? undefined;\n\t\tactive_layers = new Set(restored.layer_names ?? []);\n\t\tconst normalized = normalize_active_state(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tactive_base_name = normalized.active_base_name;\n\t\tactive_layers = normalized.active_layers;\n\t\tset_status(ctx, active_base_name, active_layers);\n\t});\n\n\tpi.on('before_agent_start', async (event) => {\n\t\tconst blocks = build_active_prompt_blocks(\n\t\t\tpresets,\n\t\t\tactive_base_name,\n\t\t\tactive_layers,\n\t\t);\n\t\tif (blocks.length === 0) return;\n\t\treturn {\n\t\t\tsystemPrompt: `${event.systemPrompt}\\n\\n${blocks.join('\\n\\n')}`,\n\t\t};\n\t});\n\n\tpi.on('session_shutdown', async (_event, ctx) => {\n\t\tctx.ui.setStatus('preset', undefined);\n\t});\n}\n"],"mappings":";;;;;;;;AAKA,SAAgB,wBACf,QACS;CACT,QAAQ,QAAR;EACC,KAAK,WACJ,OAAO;EACR,KAAK,QACJ,OAAO;EACR,KAAK,WACJ,OAAO;CACT;AACD;AAEA,SAAgB,kBACf,SACuB;CACvB,OAAO,OAAO,OAAO,OAAO,CAAC,CAC3B,QAAQ,WAAW,OAAO,SAAS,MAAM,CAAC,CAC1C,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC9C;AAEA,SAAgB,mBACf,SACuB;CACvB,OAAO,OAAO,OAAO,OAAO,CAAC,CAC3B,QAAQ,WAAW,OAAO,SAAS,OAAO,CAAC,CAC3C,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC;AAC9C;AAEA,SAAgB,eACf,kBACA,eACA,SACS;CACT,MAAM,QAAQ,CAAC,SAAS,oBAAoB,UAAU;CAEtD,MAAM,cAAc,CAAC,GAAG,aAAa,CAAC,CAAC,KAAK;CAC5C,IAAI,YAAY,WAAW,GAC1B,MAAM,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