{"_id":"@d3ara1n/pi-command-palette-core","name":"@d3ara1n/pi-command-palette-core","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@d3ara1n/pi-command-palette-core","version":"0.1.0","type":"module","description":"Shared types and singleton registry for pi-command-palette — let any extension register native palette entries with direct callbacks","main":"src/index.ts","types":"src/index.ts","peerDependencies":{"@earendil-works/pi-coding-agent":"*"},"peerDependenciesMeta":{"@earendil-works/pi-coding-agent":{"optional":true}},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/d3ara1n/pi-extensions.git","directory":"packages/pi-command-palette-core"},"gitHead":"a62bdbc69529456b830a11b2e6f39088157c2a43","_id":"@d3ara1n/pi-command-palette-core@0.1.0","bugs":{"url":"https://github.com/d3ara1n/pi-extensions/issues"},"homepage":"https://github.com/d3ara1n/pi-extensions#readme","_nodeVersion":"26.8.1","_npmVersion":"12.0.2","dist":{"integrity":"sha512-teSpceN1UXyF79r4Efrc4bHs3L5ZPikUmt2dF3mrXpmMbInYhwy0hGjX6bum4NnhbQNYqDe8It+bTWPTCbONrQ==","shasum":"364e7af81f928b0779c421914185ab5361ca8591","tarball":"https://registry.npmjs.org/@d3ara1n/pi-command-palette-core/-/pi-command-palette-core-0.1.0.tgz","fileCount":4,"unpackedSize":10387,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIB8JwhvddnSxsYFIkPPR8QvZDWuDVyKbo3SCLizg4qZsAiEAg1c0X2X8zzt0jkaekw60zWKC17DI/Q9Nx4QaVyLa9DY="}]},"_npmUser":{"name":"d3ara1n","email":"d3ara1n@outlook.com"},"directories":{},"maintainers":[{"name":"d3ara1n","email":"d3ara1n@outlook.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pi-command-palette-core_0.1.0_1789050641853_0.20441997394856948"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-10T14:30:41.692Z","0.1.0":"2026-09-10T14:30:41.992Z","modified":"2026-09-10T14:30:42.190Z"},"maintainers":[{"name":"d3ara1n","email":"d3ara1n@outlook.com"}],"description":"Shared types and singleton registry for pi-command-palette — let any extension register native palette entries with direct callbacks","homepage":"https://github.com/d3ara1n/pi-extensions#readme","repository":{"type":"git","url":"git+https://github.com/d3ara1n/pi-extensions.git","directory":"packages/pi-command-palette-core"},"bugs":{"url":"https://github.com/d3ara1n/pi-extensions/issues"},"license":"MIT","readme":"# @d3ara1n/pi-command-palette-core\n\n[![npm version](https://img.shields.io/npm/v/@d3ara1n/pi-command-palette-core)](https://www.npmjs.com/package/@d3ara1n/pi-command-palette-core) [![npm downloads](https://img.shields.io/npm/dm/@d3ara1n/pi-command-palette-core)](https://www.npmjs.com/package/@d3ara1n/pi-command-palette-core) [![license](https://img.shields.io/npm/l/@d3ara1n/pi-command-palette-core)](https://www.npmjs.com/package/@d3ara1n/pi-command-palette-core)\n\nShared types and singleton registry for [pi-command-palette](../pi-command-palette) — let any extension add **native** palette entries that run a callback directly.\n\nPi slash commands only run when the editor is empty, and the palette's `/command` entries work by filling the editor — both clobber whatever the user was typing. A native entry instead invokes your callback immediately: no editor round-trip, no text saved or restored, works mid-draft.\n\n## Dependencies\n\nNone.\n\n## Installation\n\n```bash\nnpm install @d3ara1n/pi-command-palette-core\n```\n\n> This package is a **library**, not a standalone pi extension. It is installed automatically when used by another plugin; install it directly only when building against its API. Entries registered here only appear in the UI when [`@d3ara1n/pi-command-palette`](../pi-command-palette) is installed and loaded.\n\n## Registering a palette command\n\nFrom your extension's factory body (re-runs on every load/reload, overwriting by id):\n\n```ts\nimport type { ExtensionAPI } from \"@earendil-works/pi-coding-agent\";\nimport { paletteCommandRegistry } from \"@d3ara1n/pi-command-palette-core\";\n\nexport default function myExtension(pi: ExtensionAPI) {\n  paletteCommandRegistry.register({\n    id: \"my-plugin:do-thing\",\n    label: \"My Plugin: Do the Thing\",\n    description: \"Runs immediately, without touching the editor\",\n    run: (pi, ctx) => ctx.ui.notify(\"Done\", \"info\"),\n  });\n}\n```\n\nNative entries appear in the palette after the built-in actions and above the `/command` entries, and are re-read every time the palette opens — register and unregister at any time. Rejections from `run` are caught by the palette and surfaced as an error notification.\n\n## Types\n\n### `PaletteCommand`\n\n```ts\ninterface PaletteCommand {\n  id: string;          // unique; namespaced ids (\"plugin:action\") avoid collisions\n  label: string;       // shown in the palette; prefix with the plugin name\n  description?: string; // one line, shown under the label\n  run(pi: ExtensionAPI, ctx: ExtensionContext): void | Promise<void>;\n}\n```\n\n`run` receives the palette extension's live `ExtensionAPI` and the shortcut handler's `ExtensionContext` (the palette is opened via keyboard shortcut, so `ctx` is an `ExtensionContext`, not an `ExtensionCommandContext` — session-control methods like `newSession`/`fork`/`reload` are not on it).\n\n## Registry\n\n`paletteCommandRegistry` is a global singleton shared across all extensions via `globalThis`:\n\n```ts\nimport { paletteCommandRegistry } from \"@d3ara1n/pi-command-palette-core\";\n\npaletteCommandRegistry.register(command: PaletteCommand): void; // overwrites if id exists\npaletteCommandRegistry.unregister(id: string): void;\npaletteCommandRegistry.get(id: string): PaletteCommand | undefined;\npaletteCommandRegistry.getAll(): PaletteCommand[];               // registration order\npaletteCommandRegistry.size: number;\n```\n\n## Why a separate package?\n\nPi extensions can load the same package under distinct module identities. Storing this registry on `globalThis` keeps registrants and the palette connected across those identities and reloads.\n","readmeFilename":"README.md","_rev":"1-a6338955a553d45a19b756f679144009"}