# pi-ask-me

Ask-me extension for **pi-coding-agent**. It provides a structured, tabbed TUI for multi-question decisions, with custom answers and a chat escape hatch.
This extension is unlike many others because it uses pi's `/tree` functionality to create branches for questions where you aren't sure and allows you to chat with the agent in a separate branch. And then you can come back to the original one either with a custom answer, or a summary of your branched chat as the answer, or restart the ask tool completely with new context from the branched chat.

## Install

```bash
pi install npm:pi-ask-me
# or project-local
pi install -l npm:pi-ask-me
```

For local development:

```bash
pi -e ./index.ts
```

## Tool: `ask_me`

The LLM can call this tool to collect decisions:

```json
{
  "title": "Select rollout strategy",
  "overview": "We need to choose a rollout path for the new auth system.",
  "details": "Option A is safer but slower; Option B requires feature flags.",
  "questions": [
    {
      "id": "strategy",
      "label": "Strategy",
      "prompt": "Which rollout strategy should we use?",
      "options": [
        { "value": "A", "label": "Phased rollout", "description": "Safer, gradual" },
        { "value": "B", "label": "Big bang", "description": "Faster, higher risk" }
      ]
    },
    {
      "id": "flags",
      "label": "Flags",
      "prompt": "Do we want feature flags?",
      "options": [
        { "value": "yes", "label": "Yes" },
        { "value": "no", "label": "No" }
      ]
    }
  ]
}
```

### Options per question
- `allowCustom` (default: `true`) — adds a **Custom answer** option.
- `allowChat` (default: `true`) — adds a **Chat with agent** option.

## Command: `/ask-me-resume`

If the user chooses **Chat with agent**, the ask-me flow is paused. Resume it with:

```bash
/ask-me-resume
# or specify a resume id
/ask-me-resume <resumeId>
```

Resume modes:
- Resume unchanged
- Use chat summary as an answer to the original question
- Append chat summary to context and restart ask-me

You can also pass a mode directly:

```bash
/ask-me-resume summary-as-answer
/ask-me-resume summary-as-context-restart
/ask-me-resume unchanged
```

The command uses pi’s tree navigation under the hood and can summarize the chat branch before returning.

---

### Notes
- The extension stores paused ask-me state in session custom entries (`ask_me_state`).
- Works in interactive mode only (TUI required).
