@pi-unipi/unipi 0.1.6 → 0.1.9
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/README.md +83 -2
- package/package.json +26 -8
- package/packages/ask-user/README.md +99 -0
- package/packages/ask-user/index.ts +44 -0
- package/packages/ask-user/skills/ask-user/SKILL.md +100 -0
- package/packages/autocomplete/index.ts +7 -0
- package/packages/autocomplete/src/constants.ts +214 -0
- package/packages/autocomplete/src/index.ts +31 -0
- package/packages/autocomplete/src/provider.ts +307 -0
- package/packages/autocomplete/src/settings.ts +84 -0
- package/packages/compactor/README.md +86 -0
- package/packages/compactor/skills/compactor/SKILL.md +74 -0
- package/packages/compactor/skills/compactor-doctor/SKILL.md +74 -0
- package/packages/compactor/skills/compactor-ops/SKILL.md +65 -0
- package/packages/compactor/skills/compactor-stats/SKILL.md +49 -0
- package/packages/compactor/skills/compactor-tools/SKILL.md +120 -0
- package/packages/compactor/src/commands/index.ts +248 -0
- package/packages/compactor/src/compaction/brief.ts +334 -0
- package/packages/compactor/src/compaction/build-sections.ts +77 -0
- package/packages/compactor/src/compaction/content.ts +47 -0
- package/packages/compactor/src/compaction/cut.ts +80 -0
- package/packages/compactor/src/compaction/extract/commits.ts +52 -0
- package/packages/compactor/src/compaction/extract/files.ts +58 -0
- package/packages/compactor/src/compaction/extract/goals.ts +36 -0
- package/packages/compactor/src/compaction/extract/preferences.ts +40 -0
- package/packages/compactor/src/compaction/filter-noise.ts +46 -0
- package/packages/compactor/src/compaction/format.ts +48 -0
- package/packages/compactor/src/compaction/hooks.ts +145 -0
- package/packages/compactor/src/compaction/merge.ts +113 -0
- package/packages/compactor/src/compaction/normalize.ts +68 -0
- package/packages/compactor/src/compaction/recall-scope.ts +32 -0
- package/packages/compactor/src/compaction/sanitize.ts +12 -0
- package/packages/compactor/src/compaction/search-entries.ts +101 -0
- package/packages/compactor/src/compaction/sections.ts +15 -0
- package/packages/compactor/src/compaction/summarize.ts +29 -0
- package/packages/compactor/src/config/manager.ts +89 -0
- package/packages/compactor/src/config/presets.ts +83 -0
- package/packages/compactor/src/config/schema.ts +55 -0
- package/packages/compactor/src/display/bash-display.ts +28 -0
- package/packages/compactor/src/display/diff-presentation.ts +20 -0
- package/packages/compactor/src/display/diff-renderer.ts +255 -0
- package/packages/compactor/src/display/line-width-safety.ts +16 -0
- package/packages/compactor/src/display/pending-diff-preview.ts +51 -0
- package/packages/compactor/src/display/render-utils.ts +52 -0
- package/packages/compactor/src/display/thinking-label.ts +18 -0
- package/packages/compactor/src/display/tool-overrides.ts +136 -0
- package/packages/compactor/src/display/user-message-box.ts +16 -0
- package/packages/compactor/src/executor/executor.ts +242 -0
- package/packages/compactor/src/executor/runtime.ts +125 -0
- package/packages/compactor/src/index.ts +211 -0
- package/packages/compactor/src/info-screen.ts +60 -0
- package/packages/compactor/src/security/evaluator.ts +142 -0
- package/packages/compactor/src/security/policy.ts +74 -0
- package/packages/compactor/src/security/scanner.ts +65 -0
- package/packages/compactor/src/session/db.ts +237 -0
- package/packages/compactor/src/session/extract.ts +107 -0
- package/packages/compactor/src/session/resume-inject.ts +25 -0
- package/packages/compactor/src/session/snapshot.ts +326 -0
- package/packages/compactor/src/store/chunking.ts +126 -0
- package/packages/compactor/src/store/db-base.ts +79 -0
- package/packages/compactor/src/store/index.ts +364 -0
- package/packages/compactor/src/tools/compact.ts +20 -0
- package/packages/compactor/src/tools/ctx-batch-execute.ts +53 -0
- package/packages/compactor/src/tools/ctx-doctor.ts +78 -0
- package/packages/compactor/src/tools/ctx-execute-file.ts +26 -0
- package/packages/compactor/src/tools/ctx-execute.ts +21 -0
- package/packages/compactor/src/tools/ctx-fetch-and-index.ts +37 -0
- package/packages/compactor/src/tools/ctx-index.ts +42 -0
- package/packages/compactor/src/tools/ctx-search.ts +23 -0
- package/packages/compactor/src/tools/ctx-stats.ts +37 -0
- package/packages/compactor/src/tools/register.ts +360 -0
- package/packages/compactor/src/tools/vcc-recall.ts +64 -0
- package/packages/compactor/src/tui/settings-overlay.ts +290 -0
- package/packages/compactor/src/types.ts +269 -0
- package/packages/mcp/README.md +109 -0
- package/packages/mcp/index.ts +1 -0
- package/packages/mcp/skills/mcp/SKILL.md +104 -0
- package/packages/mcp/src/bridge/client.ts +365 -0
- package/packages/mcp/src/bridge/registry.ts +300 -0
- package/packages/mcp/src/bridge/translator.ts +144 -0
- package/packages/mcp/src/config/manager.ts +267 -0
- package/packages/mcp/src/config/schema.ts +114 -0
- package/packages/mcp/src/config/sync.ts +416 -0
- package/packages/mcp/src/index.ts +357 -0
- package/packages/mcp/src/tui/add-overlay.ts +783 -0
- package/packages/mcp/src/tui/settings-overlay.ts +364 -0
- package/packages/mcp/src/types.ts +162 -0
- package/packages/memory/index.ts +30 -7
- package/packages/notify/README.md +103 -0
- package/packages/notify/index.ts +57 -0
- package/packages/notify/skills/configure-notify/SKILL.md +134 -0
- package/packages/notify/skills/notify/SKILL.md +56 -0
- package/packages/unipi/index.ts +10 -0
- package/packages/utility/README.md +151 -0
- package/packages/utility/index.ts +1 -0
- package/packages/utility/skills/utility/SKILL.md +70 -0
- package/packages/utility/src/analytics/collector.ts +293 -0
- package/packages/utility/src/cache/ttl-cache.ts +311 -0
- package/packages/utility/src/commands.ts +186 -0
- package/packages/utility/src/diagnostics/engine.ts +298 -0
- package/packages/utility/src/display/capabilities.ts +200 -0
- package/packages/utility/src/display/width.ts +226 -0
- package/packages/utility/src/index.ts +172 -0
- package/packages/utility/src/info-screen.ts +80 -0
- package/packages/utility/src/lifecycle/cleanup.ts +332 -0
- package/packages/utility/src/lifecycle/process.ts +162 -0
- package/packages/utility/src/tools/batch.ts +229 -0
- package/packages/utility/src/tools/env.ts +134 -0
- package/packages/utility/src/tui/settings-inspector.ts +303 -0
- package/packages/utility/src/types.ts +257 -0
- package/packages/web-api/src/tools.ts +7 -0
- package/packages/workflow/README.md +47 -5
- package/packages/workflow/skills/auto/SKILL.md +465 -0
- package/packages/workflow/skills/chore-create/SKILL.md +313 -0
- package/packages/workflow/skills/chore-execute/SKILL.md +312 -0
- package/packages/workflow/skills/debug/SKILL.md +224 -0
- package/packages/workflow/skills/fix/SKILL.md +210 -0
- package/packages/workflow/skills/plan/SKILL.md +25 -9
- package/packages/workflow/skills/quick-fix/SKILL.md +133 -0
- package/packages/workflow/skills/quick-work/SKILL.md +3 -3
- package/packages/workflow/skills/research/SKILL.md +251 -0
- package/packages/workflow/skills/review-work/SKILL.md +22 -2
- package/packages/workflow/skills/scan-issues/SKILL.md +14 -2
- package/packages/workflow/skills/work/SKILL.md +38 -24
- package/packages/workflow/skills/worktree-merge/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -19,6 +19,11 @@ pi install npm:@pi-unipi/info-screen
|
|
|
19
19
|
pi install npm:@pi-unipi/subagents
|
|
20
20
|
pi install npm:@pi-unipi/btw
|
|
21
21
|
pi install npm:@pi-unipi/web-api
|
|
22
|
+
pi install npm:@pi-unipi/compactor
|
|
23
|
+
pi install npm:@pi-unipi/notify
|
|
24
|
+
pi install npm:@pi-unipi/utility
|
|
25
|
+
pi install npm:@pi-unipi/mcp
|
|
26
|
+
pi install npm:@pi-unipi/ask-user
|
|
22
27
|
```
|
|
23
28
|
|
|
24
29
|
## Packages
|
|
@@ -26,13 +31,18 @@ pi install npm:@pi-unipi/web-api
|
|
|
26
31
|
| Package | Description |
|
|
27
32
|
|---------|-------------|
|
|
28
33
|
| `@pi-unipi/core` | Shared utilities, event types, constants |
|
|
29
|
-
| `@pi-unipi/workflow` |
|
|
34
|
+
| `@pi-unipi/workflow` | 20 structured development workflow commands |
|
|
30
35
|
| `@pi-unipi/ralph` | Long-running iterative development loops |
|
|
31
36
|
| `@pi-unipi/memory` | Persistent cross-session memory with vector search |
|
|
32
37
|
| `@pi-unipi/info-screen` | Dashboard and module registry overlay |
|
|
33
38
|
| `@pi-unipi/subagents` | Parallel sub-agent execution with file locking |
|
|
34
39
|
| `@pi-unipi/btw` | Parallel side conversations with `/btw` |
|
|
35
40
|
| `@pi-unipi/web-api` | Web search, read, and summarize with provider selection |
|
|
41
|
+
| `@pi-unipi/compactor` | Session compaction, context management, batch execution |
|
|
42
|
+
| `@pi-unipi/notify` | Cross-platform notifications (native, Gotify, Telegram) |
|
|
43
|
+
| `@pi-unipi/utility` | Environment info, diagnostics, settings inspector, cleanup |
|
|
44
|
+
| `@pi-unipi/mcp` | MCP server discovery, connection, and tool integration |
|
|
45
|
+
| `@pi-unipi/ask-user` | Structured user input with options and freeform text |
|
|
36
46
|
|
|
37
47
|
## Commands
|
|
38
48
|
|
|
@@ -45,6 +55,7 @@ pi install npm:@pi-unipi/web-api
|
|
|
45
55
|
| `/unipi:work` | Execute plan in worktree |
|
|
46
56
|
| `/unipi:review-work` | Review what was built |
|
|
47
57
|
| `/unipi:consolidate` | Merge findings, update docs |
|
|
58
|
+
| `/unipi:auto` | Full pipeline — brainstorm → plan → work → review → merge |
|
|
48
59
|
| `/unipi:worktree-create` | Create git worktree |
|
|
49
60
|
| `/unipi:worktree-list` | List all worktrees |
|
|
50
61
|
| `/unipi:worktree-merge` | Merge worktree back |
|
|
@@ -53,6 +64,12 @@ pi install npm:@pi-unipi/web-api
|
|
|
53
64
|
| `/unipi:gather-context` | Research codebase |
|
|
54
65
|
| `/unipi:document` | Generate documentation |
|
|
55
66
|
| `/unipi:scan-issues` | Find bugs, anti-patterns |
|
|
67
|
+
| `/unipi:debug` | Active bug investigation — reproduce, diagnose, root-cause |
|
|
68
|
+
| `/unipi:fix` | Fix bugs using debug reports |
|
|
69
|
+
| `/unipi:quick-fix` | Fast one-shot fix for clear bugs |
|
|
70
|
+
| `/unipi:research` | Deep codebase investigation and documentation review |
|
|
71
|
+
| `/unipi:chore-create` | Create reusable chore (deploy, publish, etc.) |
|
|
72
|
+
| `/unipi:chore-execute` | Run a saved chore |
|
|
56
73
|
|
|
57
74
|
### Ralph (`/unipi:ralph`)
|
|
58
75
|
|
|
@@ -103,6 +120,49 @@ pi install npm:@pi-unipi/web-api
|
|
|
103
120
|
| `/unipi:web-settings` | Configure providers and API keys |
|
|
104
121
|
| `/unipi:web-cache-clear` | Clear all cached web content |
|
|
105
122
|
|
|
123
|
+
### Compactor (`/unipi:compact*`)
|
|
124
|
+
|
|
125
|
+
| Command | Description |
|
|
126
|
+
|---------|-------------|
|
|
127
|
+
| `/unipi:compact` | Compact session into brief |
|
|
128
|
+
| `/unipi:compact-recall` | Recall from compacted sessions |
|
|
129
|
+
| `/unipi:compact-stats` | Show compaction statistics |
|
|
130
|
+
| `/unipi:compact-doctor` | Diagnose compactor issues |
|
|
131
|
+
| `/unipi:compact-settings` | Configure compactor |
|
|
132
|
+
| `/unipi:compact-preset` | Apply compaction presets |
|
|
133
|
+
| `/unipi:compact-index` | Index context for search |
|
|
134
|
+
| `/unipi:compact-search` | Search indexed context |
|
|
135
|
+
| `/unipi:compact-purge` | Purge old compacted data |
|
|
136
|
+
|
|
137
|
+
### Notify (`/unipi:notify-*`)
|
|
138
|
+
|
|
139
|
+
| Command | Description |
|
|
140
|
+
|---------|-------------|
|
|
141
|
+
| `/unipi:notify-settings` | Configure notification platforms |
|
|
142
|
+
| `/unipi:notify-set-gotify` | Set Gotify server config |
|
|
143
|
+
| `/unipi:notify-set-tg` | Set Telegram bot config |
|
|
144
|
+
| `/unipi:notify-test` | Test notification delivery |
|
|
145
|
+
|
|
146
|
+
### Utility (`/unipi:*`)
|
|
147
|
+
|
|
148
|
+
| Command | Description |
|
|
149
|
+
|---------|-------------|
|
|
150
|
+
| `/unipi:env` | Show environment info |
|
|
151
|
+
| `/unipi:doctor` | Run diagnostics |
|
|
152
|
+
| `/unipi:status` | Show module status |
|
|
153
|
+
| `/unipi:cleanup` | Clean stale temp files |
|
|
154
|
+
| `/unipi:reload` | Reload extensions |
|
|
155
|
+
|
|
156
|
+
### MCP (`/unipi:mcp-*`)
|
|
157
|
+
|
|
158
|
+
| Command | Description |
|
|
159
|
+
|---------|-------------|
|
|
160
|
+
| `/unipi:mcp-add` | Add MCP server |
|
|
161
|
+
| `/unipi:mcp-settings` | Configure MCP servers |
|
|
162
|
+
| `/unipi:mcp-sync` | Sync MCP tools |
|
|
163
|
+
| `/unipi:mcp-status` | Show MCP connection status |
|
|
164
|
+
| `/unipi:mcp-reload` | Reload MCP connections |
|
|
165
|
+
|
|
106
166
|
### Tools
|
|
107
167
|
|
|
108
168
|
| Tool | Package | Description |
|
|
@@ -120,12 +180,23 @@ pi install npm:@pi-unipi/web-api
|
|
|
120
180
|
| `web_search` | web-api | Search the web via provider |
|
|
121
181
|
| `web_read` | web-api | Extract content from URL |
|
|
122
182
|
| `web_llm_summarize` | web-api | Summarize web content via LLM |
|
|
183
|
+
| `notify_user` | notify | Send cross-platform notifications |
|
|
184
|
+
| `ask_user` | ask-user | Structured user input with options |
|
|
185
|
+
| `compact` | compactor | Compact session context |
|
|
186
|
+
| `vcc_recall` | compactor | Recall from compacted sessions |
|
|
187
|
+
| `ctx_execute` | compactor | Execute with context management |
|
|
188
|
+
| `ctx_batch_execute` | compactor | Batch execute with rollback |
|
|
189
|
+
| `ctx_index` | compactor | Index context for search |
|
|
190
|
+
| `ctx_search` | compactor | Search indexed context |
|
|
191
|
+
| `ctx_fetch_and_index` | compactor | Fetch and index web content |
|
|
192
|
+
| `ctx_stats` | compactor | Show compaction statistics |
|
|
193
|
+
| `ctx_doctor` | compactor | Diagnose compactor issues |
|
|
123
194
|
|
|
124
195
|
## How It Works
|
|
125
196
|
|
|
126
197
|
**Core** provides shared infrastructure — event types, constants, utilities — so modules discover each other without tight coupling.
|
|
127
198
|
|
|
128
|
-
**Workflow** provides
|
|
199
|
+
**Workflow** provides 20 commands guiding work from idea to completion: brainstorm → plan → work → review → consolidate, plus quick-fix, debug, research, chore, and more.
|
|
129
200
|
|
|
130
201
|
**Ralph** enables long-running iterative tasks. Start a loop, the agent works through iterations, reflects periodically, and completes when done.
|
|
131
202
|
|
|
@@ -139,6 +210,16 @@ pi install npm:@pi-unipi/web-api
|
|
|
139
210
|
|
|
140
211
|
**Web API** provides web search, page reading, and LLM summarization through a ranked provider system. DuckDuckGo and Jina work out of the box; paid providers (SerpAPI, Tavily, Firecrawl, Perplexity) are configured via `/unipi:web-settings`.
|
|
141
212
|
|
|
213
|
+
**Compactor** manages session context with compaction, indexing, search, and batch execution. Keep context lean without losing important information.
|
|
214
|
+
|
|
215
|
+
**Notify** sends notifications across platforms — native OS, Gotify, and Telegram. Configure once, get alerts everywhere.
|
|
216
|
+
|
|
217
|
+
**Utility** provides environment info, diagnostics, settings inspection, and cleanup tools for maintaining your development environment.
|
|
218
|
+
|
|
219
|
+
**MCP** integrates Model Context Protocol servers — discover, connect, and use external tool servers seamlessly.
|
|
220
|
+
|
|
221
|
+
**Ask User** provides structured user input with multiple-choice, multi-select, and freeform text options.
|
|
222
|
+
|
|
142
223
|
## Module Discovery
|
|
143
224
|
|
|
144
225
|
Modules announce presence via `pi.events`. When `@pi-unipi/workflow` detects `@pi-unipi/ralph`, it enables loop integration. Each module works standalone.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pi-unipi/unipi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "All-in-one extension suite for Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,13 +42,24 @@
|
|
|
42
42
|
"node_modules/@pi-unipi/info-screen/index.ts",
|
|
43
43
|
"node_modules/@pi-unipi/subagents/src/index.ts",
|
|
44
44
|
"node_modules/@pi-unipi/btw/extensions/btw.ts",
|
|
45
|
-
"node_modules/@pi-unipi/web-api/src/index.ts"
|
|
45
|
+
"node_modules/@pi-unipi/web-api/src/index.ts",
|
|
46
|
+
"node_modules/@pi-unipi/utility/src/index.ts",
|
|
47
|
+
"node_modules/@pi-unipi/ask-user/index.ts",
|
|
48
|
+
"node_modules/@pi-unipi/mcp/src/index.ts",
|
|
49
|
+
"node_modules/@pi-unipi/compactor/src/index.ts",
|
|
50
|
+
"node_modules/@pi-unipi/notify/index.ts",
|
|
51
|
+
"node_modules/@pi-unipi/command-enchantment/src/index.ts"
|
|
46
52
|
],
|
|
47
53
|
"skills": [
|
|
48
54
|
"node_modules/@pi-unipi/workflow/skills",
|
|
49
55
|
"node_modules/@pi-unipi/ralph/SKILL.md",
|
|
50
56
|
"node_modules/@pi-unipi/memory/skills",
|
|
51
|
-
"node_modules/@pi-unipi/btw/skills"
|
|
57
|
+
"node_modules/@pi-unipi/btw/skills",
|
|
58
|
+
"node_modules/@pi-unipi/ask-user/skills",
|
|
59
|
+
"node_modules/@pi-unipi/mcp/skills",
|
|
60
|
+
"node_modules/@pi-unipi/utility/skills",
|
|
61
|
+
"node_modules/@pi-unipi/compactor/skills",
|
|
62
|
+
"node_modules/@pi-unipi/notify/skills"
|
|
52
63
|
]
|
|
53
64
|
},
|
|
54
65
|
"peerDependencies": {
|
|
@@ -58,17 +69,24 @@
|
|
|
58
69
|
"@sinclair/typebox": "*"
|
|
59
70
|
},
|
|
60
71
|
"dependencies": {
|
|
72
|
+
"@pi-unipi/ask-user": "*",
|
|
73
|
+
"@pi-unipi/btw": "*",
|
|
74
|
+
"@pi-unipi/compactor": "*",
|
|
75
|
+
"@pi-unipi/notify": "*",
|
|
76
|
+
"@pi-unipi/command-enchantment": "*",
|
|
61
77
|
"@pi-unipi/core": "*",
|
|
62
|
-
"@pi-unipi/workflow": "*",
|
|
63
|
-
"@pi-unipi/ralph": "*",
|
|
64
|
-
"@pi-unipi/memory": "*",
|
|
65
78
|
"@pi-unipi/info-screen": "*",
|
|
79
|
+
"@pi-unipi/mcp": "*",
|
|
80
|
+
"@pi-unipi/memory": "*",
|
|
81
|
+
"@pi-unipi/ralph": "*",
|
|
66
82
|
"@pi-unipi/subagents": "*",
|
|
67
|
-
"@pi-unipi/
|
|
68
|
-
"@pi-unipi/web-api": "*"
|
|
83
|
+
"@pi-unipi/utility": "*",
|
|
84
|
+
"@pi-unipi/web-api": "*",
|
|
85
|
+
"@pi-unipi/workflow": "*"
|
|
69
86
|
},
|
|
70
87
|
"devDependencies": {
|
|
71
88
|
"@types/node": "^25.6.0",
|
|
89
|
+
"tsx": "^4.21.0",
|
|
72
90
|
"typescript": "^6.0.0"
|
|
73
91
|
}
|
|
74
92
|
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# @pi-unipi/ask-user
|
|
2
|
+
|
|
3
|
+
Structured user input tool for the Pi coding agent — part of the Unipi suite.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
### `ask_user` Tool
|
|
8
|
+
|
|
9
|
+
Ask the user a question with structured options. Supports three modes:
|
|
10
|
+
|
|
11
|
+
- **Single-select** — Pick one option from a list
|
|
12
|
+
- **Multi-select** — Toggle multiple options, then submit
|
|
13
|
+
- **Freeform** — Type a custom answer
|
|
14
|
+
|
|
15
|
+
### Usage
|
|
16
|
+
|
|
17
|
+
The agent calls the tool when it needs user input:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
ask_user({
|
|
21
|
+
question: "Which database should we use?",
|
|
22
|
+
options: [
|
|
23
|
+
{ label: "PostgreSQL", description: "Reliable, feature-rich" },
|
|
24
|
+
{ label: "SQLite", description: "Simple, serverless" },
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Parameters
|
|
30
|
+
|
|
31
|
+
| Parameter | Type | Default | Description |
|
|
32
|
+
|-----------|------|---------|-------------|
|
|
33
|
+
| `question` | string | required | The question to ask |
|
|
34
|
+
| `context` | string? | — | Additional context shown before question |
|
|
35
|
+
| `options` | array? | [] | Multiple-choice options |
|
|
36
|
+
| `allowMultiple` | boolean? | false | Enable multi-select mode |
|
|
37
|
+
| `allowFreeform` | boolean? | true | Allow freeform text input |
|
|
38
|
+
| `timeout` | number? | — | Auto-dismiss after N ms |
|
|
39
|
+
|
|
40
|
+
### Keyboard Controls
|
|
41
|
+
|
|
42
|
+
| Mode | Keys |
|
|
43
|
+
|------|------|
|
|
44
|
+
| Single-select | ↑↓ navigate, Enter select, Esc cancel |
|
|
45
|
+
| Multi-select | ↑↓ navigate, Space toggle, Enter submit, Esc cancel |
|
|
46
|
+
| Freeform | Type text, Enter submit, Esc back |
|
|
47
|
+
|
|
48
|
+
### TUI Display
|
|
49
|
+
|
|
50
|
+
**Single-select:**
|
|
51
|
+
```
|
|
52
|
+
─────────────────────────────
|
|
53
|
+
Which approach should we use?
|
|
54
|
+
─────────────────────────────
|
|
55
|
+
> Option A
|
|
56
|
+
Option B
|
|
57
|
+
Option C
|
|
58
|
+
Type something...
|
|
59
|
+
|
|
60
|
+
↑↓ navigate • Enter select • Esc cancel
|
|
61
|
+
─────────────────────────────
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**Multi-select:**
|
|
65
|
+
```
|
|
66
|
+
─────────────────────────────
|
|
67
|
+
Which features to enable?
|
|
68
|
+
─────────────────────────────
|
|
69
|
+
> [✓] Logging
|
|
70
|
+
[ ] Metrics
|
|
71
|
+
[✓] Tracing
|
|
72
|
+
[ ] Type something...
|
|
73
|
+
|
|
74
|
+
↑↓ navigate • Space toggle • Enter submit • Esc cancel
|
|
75
|
+
─────────────────────────────
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pi install npm:@pi-unipi/ask-user
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or install the full Unipi suite:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
pi install npm:@pi-unipi/unipi
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Bundled Skill
|
|
91
|
+
|
|
92
|
+
The package includes a skill that guides the agent to use `ask_user` for high-stakes decisions. The skill is automatically discovered when the extension loads.
|
|
93
|
+
|
|
94
|
+
## Dependencies
|
|
95
|
+
|
|
96
|
+
- `@pi-unipi/core` — Shared constants and utilities
|
|
97
|
+
- `@mariozechner/pi-coding-agent` — Pi extension API
|
|
98
|
+
- `@mariozechner/pi-tui` — TUI components
|
|
99
|
+
- `@sinclair/typebox` — Schema validation
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pi-unipi/ask-user — Extension entry
|
|
3
|
+
*
|
|
4
|
+
* Provides ask_user tool for structured user input with single-select,
|
|
5
|
+
* multi-select, and freeform modes. Includes bundled skill for agent guidance.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
|
+
import {
|
|
10
|
+
UNIPI_EVENTS,
|
|
11
|
+
MODULES,
|
|
12
|
+
ASK_USER_TOOLS,
|
|
13
|
+
emitEvent,
|
|
14
|
+
getPackageVersion,
|
|
15
|
+
} from "@pi-unipi/core";
|
|
16
|
+
import { registerAskUserTools } from "./tools.js";
|
|
17
|
+
import { registerAskUserCommands } from "./commands.js";
|
|
18
|
+
|
|
19
|
+
/** Package version */
|
|
20
|
+
const VERSION = getPackageVersion(new URL(".", import.meta.url).pathname);
|
|
21
|
+
|
|
22
|
+
export default function (pi: ExtensionAPI) {
|
|
23
|
+
// Register skills directory
|
|
24
|
+
const skillsDir = new URL("./skills", import.meta.url).pathname;
|
|
25
|
+
pi.on("resources_discover", async () => {
|
|
26
|
+
return {
|
|
27
|
+
skillPaths: [skillsDir],
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Register tools and commands
|
|
32
|
+
registerAskUserTools(pi);
|
|
33
|
+
registerAskUserCommands(pi);
|
|
34
|
+
|
|
35
|
+
// Session lifecycle — announce module
|
|
36
|
+
pi.on("session_start", async () => {
|
|
37
|
+
emitEvent(pi, UNIPI_EVENTS.MODULE_READY, {
|
|
38
|
+
name: MODULES.ASK_USER,
|
|
39
|
+
version: VERSION,
|
|
40
|
+
commands: ["unipi:ask-user-settings"],
|
|
41
|
+
tools: [ASK_USER_TOOLS.ASK],
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ask-user
|
|
3
|
+
description: >
|
|
4
|
+
Interactive decision-gating tool for structured user input.
|
|
5
|
+
Use ask_user when you need user confirmation, preferences, or decisions
|
|
6
|
+
before proceeding with high-impact or ambiguous choices.
|
|
7
|
+
allowed-tools:
|
|
8
|
+
- ask_user
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Ask User
|
|
12
|
+
|
|
13
|
+
Use the `ask_user` tool to collect structured input from the user.
|
|
14
|
+
|
|
15
|
+
## When to use ask_user
|
|
16
|
+
|
|
17
|
+
- Architectural trade-offs with high impact
|
|
18
|
+
- Requirements are ambiguous or conflicting
|
|
19
|
+
- Assumptions would materially change implementation
|
|
20
|
+
- User preferences needed (style, approach, priority)
|
|
21
|
+
- Confirming before destructive operations
|
|
22
|
+
|
|
23
|
+
## Decision Handshake Flow
|
|
24
|
+
|
|
25
|
+
1. Gather evidence and summarize context
|
|
26
|
+
2. Ask ONE focused question via `ask_user`
|
|
27
|
+
3. Wait for explicit user choice
|
|
28
|
+
4. Confirm the decision, then proceed
|
|
29
|
+
|
|
30
|
+
## Parameters
|
|
31
|
+
|
|
32
|
+
| Parameter | Type | Default | Description |
|
|
33
|
+
|-----------|------|---------|-------------|
|
|
34
|
+
| `question` | string | required | The question to ask |
|
|
35
|
+
| `context` | string? | — | Additional context shown before question |
|
|
36
|
+
| `options` | array? | [] | Multiple-choice options with labels, descriptions, values |
|
|
37
|
+
| `allowMultiple` | boolean? | false | Enable multi-select |
|
|
38
|
+
| `allowFreeform` | boolean? | true | Add "Custom response" checkable option |
|
|
39
|
+
| `timeout` | number? | — | Auto-dismiss after N ms |
|
|
40
|
+
|
|
41
|
+
## Examples
|
|
42
|
+
|
|
43
|
+
Single choice:
|
|
44
|
+
```
|
|
45
|
+
ask_user({
|
|
46
|
+
question: "Which database should we use?",
|
|
47
|
+
options: [
|
|
48
|
+
{ label: "PostgreSQL", description: "Reliable, feature-rich" },
|
|
49
|
+
{ label: "SQLite", description: "Simple, serverless" }
|
|
50
|
+
]
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Multi-select:
|
|
55
|
+
```
|
|
56
|
+
ask_user({
|
|
57
|
+
question: "Which features to implement?",
|
|
58
|
+
options: [
|
|
59
|
+
{ label: "Auth", value: "auth" },
|
|
60
|
+
{ label: "Cache", value: "cache" },
|
|
61
|
+
{ label: "Logging", value: "logging" }
|
|
62
|
+
],
|
|
63
|
+
allowMultiple: true
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
With context:
|
|
68
|
+
```
|
|
69
|
+
ask_user({
|
|
70
|
+
question: "Which approach?",
|
|
71
|
+
context: "Current bottleneck: network I/O. Goal: reduce latency.",
|
|
72
|
+
options: [
|
|
73
|
+
{ label: "Cache-first" },
|
|
74
|
+
{ label: "DB-first" }
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Freeform only:
|
|
80
|
+
```
|
|
81
|
+
ask_user({
|
|
82
|
+
question: "What should we name this module?",
|
|
83
|
+
options: [],
|
|
84
|
+
allowFreeform: true
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Combined (multi-select + freeform):
|
|
89
|
+
```
|
|
90
|
+
ask_user({
|
|
91
|
+
question: "Which features and what custom feature?",
|
|
92
|
+
options: [
|
|
93
|
+
{ label: "Auth", value: "auth" },
|
|
94
|
+
{ label: "Cache", value: "cache" }
|
|
95
|
+
],
|
|
96
|
+
allowMultiple: true,
|
|
97
|
+
allowFreeform: true
|
|
98
|
+
})
|
|
99
|
+
```
|
|
100
|
+
User can check "Auth", "Cache", and "Custom response" to type additional features.
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @pi-unipi/command-enchantment — Constants
|
|
3
|
+
*
|
|
4
|
+
* Static mappings for the command registry, package ordering, and package colors.
|
|
5
|
+
* These drive the enhanced autocomplete display for /unipi:* commands.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// ─── ANSI Color Helpers ──────────────────────────────────────────────
|
|
9
|
+
const ESC = "\x1b";
|
|
10
|
+
const RESET = `${ESC}[0m`;
|
|
11
|
+
|
|
12
|
+
/** Wrap text in an ANSI color code */
|
|
13
|
+
export function colorize(ansiCode: string, text: string): string {
|
|
14
|
+
return `${ansiCode}${text}${RESET}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// ─── Package Order ───────────────────────────────────────────────────
|
|
18
|
+
/** Packages sorted by display priority (top-to-bottom in autocomplete) */
|
|
19
|
+
export const PACKAGE_ORDER: string[] = [
|
|
20
|
+
"workflow",
|
|
21
|
+
"ralph",
|
|
22
|
+
"memory",
|
|
23
|
+
"mcp",
|
|
24
|
+
"utility",
|
|
25
|
+
"ask-user",
|
|
26
|
+
"info",
|
|
27
|
+
"web-api",
|
|
28
|
+
"compact",
|
|
29
|
+
"notify",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
// ─── Package Colors ──────────────────────────────────────────────────
|
|
33
|
+
/** ANSI bright-color codes per package */
|
|
34
|
+
export const PACKAGE_COLORS: Record<string, string> = {
|
|
35
|
+
workflow: `${ESC}[91m`, // Bright Red
|
|
36
|
+
ralph: `${ESC}[33m`, // Yellow/Orange
|
|
37
|
+
memory: `${ESC}[93m`, // Bright Yellow
|
|
38
|
+
mcp: `${ESC}[32m`, // Green
|
|
39
|
+
utility: `${ESC}[36m`, // Cyan
|
|
40
|
+
"ask-user": `${ESC}[94m`, // Bright Blue
|
|
41
|
+
info: `${ESC}[35m`, // Magenta
|
|
42
|
+
"web-api": `${ESC}[95m`, // Bright Magenta
|
|
43
|
+
compact: `${ESC}[37m`, // White
|
|
44
|
+
notify: `${ESC}[96m`, // Bright Cyan
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ─── Command Registry ────────────────────────────────────────────────
|
|
48
|
+
/** Mapping of full command name → package name (58 verified commands) */
|
|
49
|
+
export const COMMAND_REGISTRY: Record<string, string> = {
|
|
50
|
+
// workflow (20 commands)
|
|
51
|
+
"unipi:brainstorm": "workflow",
|
|
52
|
+
"unipi:plan": "workflow",
|
|
53
|
+
"unipi:work": "workflow",
|
|
54
|
+
"unipi:review-work": "workflow",
|
|
55
|
+
"unipi:consolidate": "workflow",
|
|
56
|
+
"unipi:worktree-create": "workflow",
|
|
57
|
+
"unipi:worktree-list": "workflow",
|
|
58
|
+
"unipi:worktree-merge": "workflow",
|
|
59
|
+
"unipi:consultant": "workflow",
|
|
60
|
+
"unipi:quick-work": "workflow",
|
|
61
|
+
"unipi:gather-context": "workflow",
|
|
62
|
+
"unipi:document": "workflow",
|
|
63
|
+
"unipi:scan-issues": "workflow",
|
|
64
|
+
"unipi:auto": "workflow",
|
|
65
|
+
"unipi:debug": "workflow",
|
|
66
|
+
"unipi:fix": "workflow",
|
|
67
|
+
"unipi:quick-fix": "workflow",
|
|
68
|
+
"unipi:research": "workflow",
|
|
69
|
+
"unipi:chore-create": "workflow",
|
|
70
|
+
"unipi:chore-execute": "workflow",
|
|
71
|
+
|
|
72
|
+
// ralph (2 commands)
|
|
73
|
+
"unipi:ralph": "ralph",
|
|
74
|
+
"unipi:ralph-stop": "ralph",
|
|
75
|
+
|
|
76
|
+
// memory (7 commands)
|
|
77
|
+
"unipi:memory-process": "memory",
|
|
78
|
+
"unipi:memory-search": "memory",
|
|
79
|
+
"unipi:memory-consolidate": "memory",
|
|
80
|
+
"unipi:memory-forget": "memory",
|
|
81
|
+
"unipi:global-memory-search": "memory",
|
|
82
|
+
"unipi:global-memory-list": "memory",
|
|
83
|
+
"unipi:memory-settings": "memory",
|
|
84
|
+
|
|
85
|
+
// mcp (5 commands)
|
|
86
|
+
"unipi:mcp-status": "mcp",
|
|
87
|
+
"unipi:mcp-sync": "mcp",
|
|
88
|
+
"unipi:mcp-add": "mcp",
|
|
89
|
+
"unipi:mcp-settings": "mcp",
|
|
90
|
+
"unipi:mcp-reload": "mcp",
|
|
91
|
+
|
|
92
|
+
// utility (6 commands)
|
|
93
|
+
"unipi:continue": "utility",
|
|
94
|
+
"unipi:reload": "utility",
|
|
95
|
+
"unipi:status": "utility",
|
|
96
|
+
"unipi:cleanup": "utility",
|
|
97
|
+
"unipi:env": "utility",
|
|
98
|
+
"unipi:doctor": "utility",
|
|
99
|
+
|
|
100
|
+
// ask-user (1 command)
|
|
101
|
+
"unipi:ask-user-settings": "ask-user",
|
|
102
|
+
|
|
103
|
+
// info (2 commands)
|
|
104
|
+
"unipi:info": "info",
|
|
105
|
+
"unipi:info-settings": "info",
|
|
106
|
+
|
|
107
|
+
// web-api (2 commands)
|
|
108
|
+
"unipi:web-settings": "web-api",
|
|
109
|
+
"unipi:web-cache-clear": "web-api",
|
|
110
|
+
|
|
111
|
+
// compact (9 commands)
|
|
112
|
+
"unipi:compact": "compact",
|
|
113
|
+
"unipi:compact-recall": "compact",
|
|
114
|
+
"unipi:compact-stats": "compact",
|
|
115
|
+
"unipi:compact-doctor": "compact",
|
|
116
|
+
"unipi:compact-settings": "compact",
|
|
117
|
+
"unipi:compact-preset": "compact",
|
|
118
|
+
"unipi:compact-index": "compact",
|
|
119
|
+
"unipi:compact-search": "compact",
|
|
120
|
+
"unipi:compact-purge": "compact",
|
|
121
|
+
|
|
122
|
+
// notify (4 commands)
|
|
123
|
+
"unipi:notify-settings": "notify",
|
|
124
|
+
"unipi:notify-set-gotify": "notify",
|
|
125
|
+
"unipi:notify-set-tg": "notify",
|
|
126
|
+
"unipi:notify-test": "notify",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// ─── Description Map ─────────────────────────────────────────────────
|
|
130
|
+
/** Short descriptions for each command (used when base suggestions lack them) */
|
|
131
|
+
export const COMMAND_DESCRIPTIONS: Record<string, string> = {
|
|
132
|
+
"unipi:brainstorm": "Collaborative discovery — explore problem space",
|
|
133
|
+
"unipi:plan": "Strategic planning — tasks, dependencies",
|
|
134
|
+
"unipi:work": "Execute plan — implement tasks, test, commit",
|
|
135
|
+
"unipi:review-work": "Review work — check task completion, run lint",
|
|
136
|
+
"unipi:consolidate": "Save learnings to memory, craft skills",
|
|
137
|
+
"unipi:worktree-create": "Create git worktree for parallel work",
|
|
138
|
+
"unipi:worktree-list": "List all unipi worktrees",
|
|
139
|
+
"unipi:worktree-merge": "Merge worktree branches back to main",
|
|
140
|
+
"unipi:consultant": "Expert consultation — advisory analysis",
|
|
141
|
+
"unipi:quick-work": "Fast single-task execution — one shot",
|
|
142
|
+
"unipi:gather-context": "Research codebase — surface patterns",
|
|
143
|
+
"unipi:document": "Generate documentation — README, API docs",
|
|
144
|
+
"unipi:scan-issues": "Deep investigation — find bugs, issues",
|
|
145
|
+
"unipi:auto": "Full pipeline — brainstorm → plan → work → review",
|
|
146
|
+
"unipi:debug": "Active bug investigation — reproduce, diagnose",
|
|
147
|
+
"unipi:fix": "Fix bugs using debug reports",
|
|
148
|
+
"unipi:quick-fix": "Fast bug fix without debug report",
|
|
149
|
+
"unipi:research": "Read-only research with bash access",
|
|
150
|
+
"unipi:chore-create": "Create reusable chore definition",
|
|
151
|
+
"unipi:chore-execute": "Execute a saved chore",
|
|
152
|
+
|
|
153
|
+
"unipi:ralph": "Ralph loop — start/resume coding session",
|
|
154
|
+
"unipi:ralph-stop": "Stop the active ralph loop",
|
|
155
|
+
|
|
156
|
+
"unipi:memory-process": "Process and store conversation learnings",
|
|
157
|
+
"unipi:memory-search": "Search project memory for past context",
|
|
158
|
+
"unipi:memory-consolidate": "Consolidate memory entries",
|
|
159
|
+
"unipi:memory-forget": "Remove memory entries",
|
|
160
|
+
"unipi:global-memory-search": "Search across all project memories",
|
|
161
|
+
"unipi:global-memory-list": "List all project memories",
|
|
162
|
+
"unipi:memory-settings": "Configure memory settings",
|
|
163
|
+
|
|
164
|
+
"unipi:mcp-status": "Show MCP server status",
|
|
165
|
+
"unipi:mcp-sync": "Sync MCP server connections",
|
|
166
|
+
"unipi:mcp-add": "Add a new MCP server",
|
|
167
|
+
"unipi:mcp-settings": "Configure MCP settings",
|
|
168
|
+
"unipi:mcp-reload": "Reload MCP connections",
|
|
169
|
+
|
|
170
|
+
"unipi:continue": "Continue the last conversation",
|
|
171
|
+
"unipi:reload": "Reload extensions and settings",
|
|
172
|
+
"unipi:status": "Show system status",
|
|
173
|
+
"unipi:cleanup": "Clean up old sessions and cache",
|
|
174
|
+
"unipi:env": "Show environment info",
|
|
175
|
+
"unipi:doctor": "Run diagnostics",
|
|
176
|
+
|
|
177
|
+
"unipi:ask-user-settings": "Configure ask-user settings",
|
|
178
|
+
|
|
179
|
+
"unipi:info": "Show system information",
|
|
180
|
+
"unipi:info-settings": "Configure info display",
|
|
181
|
+
|
|
182
|
+
"unipi:web-settings": "Configure web search settings",
|
|
183
|
+
"unipi:web-cache-clear": "Clear web search cache",
|
|
184
|
+
|
|
185
|
+
"unipi:compact": "Compact context window",
|
|
186
|
+
"unipi:compact-recall": "Recall a compacted session",
|
|
187
|
+
"unipi:compact-stats": "Show compaction statistics",
|
|
188
|
+
"unipi:compact-doctor": "Diagnose compaction issues",
|
|
189
|
+
"unipi:compact-settings": "Configure compaction settings",
|
|
190
|
+
"unipi:compact-preset": "Manage compaction presets",
|
|
191
|
+
"unipi:compact-index": "Show compaction index",
|
|
192
|
+
"unipi:compact-search": "Search compacted sessions",
|
|
193
|
+
"unipi:compact-purge": "Purge old compacted sessions",
|
|
194
|
+
|
|
195
|
+
"unipi:notify-settings": "Configure notification platforms and events",
|
|
196
|
+
"unipi:notify-set-gotify": "Set up Gotify push notifications",
|
|
197
|
+
"unipi:notify-set-tg": "Set up Telegram bot notifications",
|
|
198
|
+
"unipi:notify-test": "Test all enabled notification platforms",
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// ─── Package Display Names ───────────────────────────────────────────
|
|
202
|
+
/** Pretty names for package tags in autocomplete items */
|
|
203
|
+
export const PACKAGE_LABELS: Record<string, string> = {
|
|
204
|
+
workflow: "workflow",
|
|
205
|
+
ralph: "ralph",
|
|
206
|
+
memory: "memory",
|
|
207
|
+
mcp: "mcp",
|
|
208
|
+
utility: "utility",
|
|
209
|
+
"ask-user": "ask-user",
|
|
210
|
+
info: "info",
|
|
211
|
+
"web-api": "web-api",
|
|
212
|
+
compact: "compact",
|
|
213
|
+
notify: "notify",
|
|
214
|
+
};
|