singularity-forge/docs/extending-pi/20-mode-behavior.md
Lex Christopherson 9f4bf8c452 fix: restore PR files lost during merge conflict resolution
Files added by PR #2008 that were not in main were dropped during
the merge. Restore all src/, docs/, and scripts/ files from the
pre-merge PR head.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-25 22:39:33 -06:00

21 lines
629 B
Markdown

# Mode Behavior
| Mode | UI Methods | Notes |
|------|-----------|-------|
| **Interactive** (default) | Full TUI | Normal operation |
| **RPC** (`--mode rpc`) | JSON protocol | Host handles UI, dialogs work via sub-protocol |
| **JSON** (`--mode json`) | No-op | Event stream to stdout |
| **Print** (`-p`) | No-op | Extensions run but can't prompt users |
**Always check `ctx.hasUI`** before calling dialog methods in extensions that might run in non-interactive modes:
```typescript
if (ctx.hasUI) {
const ok = await ctx.ui.confirm("Delete?", "Sure?");
} else {
// Default behavior for non-interactive mode
}
```
---