# @ramarivera/pi-prompt-maestro

Prompt Maestro is a Pi coding-agent extension for prompt-box ergonomics: draft capture, sent prompt history, reusable snippets, and a fuzzy picker for inserting prompts back into the editor.

## What it does

- Captures prompt-box drafts on terminal input into a global store.
- Converts the active draft to a `confirmed` prompt when the text is submitted.
- Stores manual reusable prompts as `snippet` records.
- Tracks source folder, session file, timestamps, tags, soft-delete state, and snippet lineage.
- Opens a floating fuzzy picker with `/pm`, `/pm ls`, `/pm search`, or `/prompt-maestro`.
- Supports inline markers like `before </pm ls f:21st> after` and replaces only the marker on submit.
- Creates snippets with `/pm new <content>` or `/pm def[:name] <content>`.
- Keeps records global, not folder-bound, while still showing the source folder in picker/detail UIs.

Prompt records live at:

```text
~/.pi/agent/prompt-maestro/prompts.json
```

## Commands

```text
/pm
/pm ls [t:draft|t:confirmed|t:snippet] [f:<regex-or-fuzzy-query>]
/pm search [same filters]
/pm new[:optional-name] <prompt content>
/pm def[:optional-name] <prompt content>
/pm del [filters]
/prompt-maestro [same as /pm]
```

Inline marker form:

```text
Write tests for </pm ls s f:node runner> and keep it concise.
```

Short type filters also work:

```text
/pm ls d f:rough
/pm ls c f:deploy
/pm ls s f:21st
```

## Picker keys

- `Enter` inserts the selected prompt at the current editor cursor.
- `Shift+Enter` replaces the editor with the selected prompt.
- `Ctrl+Enter` / `Cmd+Enter` / `Meta+Enter` sends the selected prompt immediately when the terminal can report that chord.
- `/` or `Alt+Enter` opens the action menu for the selected prompt.
- `Esc` closes the current UI.

The action menu currently supports insert, replace, send, save as snippet, rename, tags, view, and soft delete.

## Record model

A prompt has:

- `id`
- `name` (optional; nameless prompts display a content preview)
- `content`
- `type`: `draft`, `confirmed`, or `snippet`
- `active`: soft-delete/default visibility flag
- `snippetId`: lineage link when a draft/confirmed prompt is saved as a snippet
- `sourceCwd`
- `sessionFile`
- `createdAt`, `updatedAt`, `lastDraftAt`, `confirmedAt`
- `tags`

Saving a draft as a snippet sets the draft `active = false` and links `snippetId`. Saving a confirmed prompt as a snippet links `snippetId` but keeps the confirmed prompt active.

## Install

```sh
pi install npm:@ramarivera/pi-prompt-maestro@0.0.3
```

## Local development

This checkout is live-enabled for Pi through:

```text
.pi/extensions/prompt-maestro/index.ts
```

That shim imports the package entrypoint in `src/index.ts`, which imports the extension factory from `src/extension.ts`. Tests use the same symbol so local behavior, package behavior, and manual Pi behavior do not drift.

```sh
npm install
npm run check
npm test
npm run test:e2e
npm pack --dry-run
```

## Publishing

Publishing uses GitHub Actions trusted publishing in `.github/workflows/publish.yml`.

Before the first publish, configure npm trusted publishing:

- owner/repo: `ramarivera/pi-prompt-maestro`
- workflow: `.github/workflows/publish.yml`
- environment: blank unless the workflow is changed to require one

No `NPM_TOKEN` is required for trusted publishing.
