@pi-unipi/unipi 0.1.6 → 0.1.11

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.
Files changed (141) hide show
  1. package/README.md +112 -2
  2. package/package.json +32 -8
  3. package/packages/ask-user/README.md +99 -0
  4. package/packages/ask-user/index.ts +44 -0
  5. package/packages/ask-user/skills/ask-user/SKILL.md +152 -0
  6. package/packages/autocomplete/index.ts +7 -0
  7. package/packages/autocomplete/src/constants.ts +244 -0
  8. package/packages/autocomplete/src/index.ts +31 -0
  9. package/packages/autocomplete/src/provider.ts +326 -0
  10. package/packages/autocomplete/src/settings.ts +84 -0
  11. package/packages/compactor/README.md +86 -0
  12. package/packages/compactor/skills/compactor/SKILL.md +74 -0
  13. package/packages/compactor/skills/compactor-doctor/SKILL.md +74 -0
  14. package/packages/compactor/skills/compactor-ops/SKILL.md +65 -0
  15. package/packages/compactor/skills/compactor-stats/SKILL.md +49 -0
  16. package/packages/compactor/skills/compactor-tools/SKILL.md +120 -0
  17. package/packages/compactor/src/commands/index.ts +248 -0
  18. package/packages/compactor/src/compaction/brief.ts +334 -0
  19. package/packages/compactor/src/compaction/build-sections.ts +77 -0
  20. package/packages/compactor/src/compaction/content.ts +47 -0
  21. package/packages/compactor/src/compaction/cut.ts +80 -0
  22. package/packages/compactor/src/compaction/extract/commits.ts +52 -0
  23. package/packages/compactor/src/compaction/extract/files.ts +58 -0
  24. package/packages/compactor/src/compaction/extract/goals.ts +36 -0
  25. package/packages/compactor/src/compaction/extract/preferences.ts +40 -0
  26. package/packages/compactor/src/compaction/filter-noise.ts +46 -0
  27. package/packages/compactor/src/compaction/format.ts +48 -0
  28. package/packages/compactor/src/compaction/hooks.ts +145 -0
  29. package/packages/compactor/src/compaction/merge.ts +113 -0
  30. package/packages/compactor/src/compaction/normalize.ts +68 -0
  31. package/packages/compactor/src/compaction/recall-scope.ts +32 -0
  32. package/packages/compactor/src/compaction/sanitize.ts +12 -0
  33. package/packages/compactor/src/compaction/search-entries.ts +101 -0
  34. package/packages/compactor/src/compaction/sections.ts +15 -0
  35. package/packages/compactor/src/compaction/summarize.ts +29 -0
  36. package/packages/compactor/src/config/manager.ts +89 -0
  37. package/packages/compactor/src/config/presets.ts +83 -0
  38. package/packages/compactor/src/config/schema.ts +55 -0
  39. package/packages/compactor/src/display/bash-display.ts +28 -0
  40. package/packages/compactor/src/display/diff-presentation.ts +20 -0
  41. package/packages/compactor/src/display/diff-renderer.ts +255 -0
  42. package/packages/compactor/src/display/line-width-safety.ts +16 -0
  43. package/packages/compactor/src/display/pending-diff-preview.ts +51 -0
  44. package/packages/compactor/src/display/render-utils.ts +52 -0
  45. package/packages/compactor/src/display/thinking-label.ts +18 -0
  46. package/packages/compactor/src/display/tool-overrides.ts +136 -0
  47. package/packages/compactor/src/display/user-message-box.ts +16 -0
  48. package/packages/compactor/src/executor/executor.ts +242 -0
  49. package/packages/compactor/src/executor/runtime.ts +125 -0
  50. package/packages/compactor/src/index.ts +211 -0
  51. package/packages/compactor/src/info-screen.ts +60 -0
  52. package/packages/compactor/src/security/evaluator.ts +142 -0
  53. package/packages/compactor/src/security/policy.ts +74 -0
  54. package/packages/compactor/src/security/scanner.ts +65 -0
  55. package/packages/compactor/src/session/db.ts +237 -0
  56. package/packages/compactor/src/session/extract.ts +107 -0
  57. package/packages/compactor/src/session/resume-inject.ts +25 -0
  58. package/packages/compactor/src/session/snapshot.ts +326 -0
  59. package/packages/compactor/src/store/chunking.ts +126 -0
  60. package/packages/compactor/src/store/db-base.ts +79 -0
  61. package/packages/compactor/src/store/index.ts +364 -0
  62. package/packages/compactor/src/tools/compact.ts +20 -0
  63. package/packages/compactor/src/tools/ctx-batch-execute.ts +53 -0
  64. package/packages/compactor/src/tools/ctx-doctor.ts +78 -0
  65. package/packages/compactor/src/tools/ctx-execute-file.ts +26 -0
  66. package/packages/compactor/src/tools/ctx-execute.ts +21 -0
  67. package/packages/compactor/src/tools/ctx-fetch-and-index.ts +37 -0
  68. package/packages/compactor/src/tools/ctx-index.ts +42 -0
  69. package/packages/compactor/src/tools/ctx-search.ts +23 -0
  70. package/packages/compactor/src/tools/ctx-stats.ts +37 -0
  71. package/packages/compactor/src/tools/register.ts +360 -0
  72. package/packages/compactor/src/tools/vcc-recall.ts +64 -0
  73. package/packages/compactor/src/tui/settings-overlay.ts +290 -0
  74. package/packages/compactor/src/types.ts +269 -0
  75. package/packages/kanboard/README.md +137 -0
  76. package/packages/kanboard/index.ts +80 -0
  77. package/packages/kanboard/skills/kanboard-doctor/SKILL.md +71 -0
  78. package/packages/mcp/README.md +109 -0
  79. package/packages/mcp/index.ts +1 -0
  80. package/packages/mcp/skills/mcp/SKILL.md +104 -0
  81. package/packages/mcp/src/bridge/client.ts +365 -0
  82. package/packages/mcp/src/bridge/registry.ts +300 -0
  83. package/packages/mcp/src/bridge/translator.ts +144 -0
  84. package/packages/mcp/src/config/manager.ts +267 -0
  85. package/packages/mcp/src/config/schema.ts +114 -0
  86. package/packages/mcp/src/config/sync.ts +416 -0
  87. package/packages/mcp/src/index.ts +357 -0
  88. package/packages/mcp/src/tui/add-overlay.ts +783 -0
  89. package/packages/mcp/src/tui/settings-overlay.ts +364 -0
  90. package/packages/mcp/src/types.ts +162 -0
  91. package/packages/memory/index.ts +36 -7
  92. package/packages/milestone/README.md +123 -0
  93. package/packages/milestone/index.ts +72 -0
  94. package/packages/milestone/skills/milestone-onboard/SKILL.md +114 -0
  95. package/packages/milestone/skills/milestone-update/SKILL.md +109 -0
  96. package/packages/notify/README.md +103 -0
  97. package/packages/notify/index.ts +57 -0
  98. package/packages/notify/skills/configure-notify/SKILL.md +134 -0
  99. package/packages/notify/skills/notify/SKILL.md +56 -0
  100. package/packages/subagents/src/agent-manager.ts +12 -1
  101. package/packages/subagents/src/agent-runner.ts +23 -8
  102. package/packages/subagents/src/conversation-viewer.ts +299 -0
  103. package/packages/subagents/src/index.ts +411 -49
  104. package/packages/subagents/src/types.ts +49 -0
  105. package/packages/subagents/src/widget.ts +332 -72
  106. package/packages/unipi/index.ts +14 -0
  107. package/packages/utility/README.md +165 -0
  108. package/packages/utility/index.ts +1 -0
  109. package/packages/utility/skills/utility/SKILL.md +70 -0
  110. package/packages/utility/src/analytics/collector.ts +293 -0
  111. package/packages/utility/src/cache/ttl-cache.ts +311 -0
  112. package/packages/utility/src/commands.ts +250 -0
  113. package/packages/utility/src/diagnostics/engine.ts +298 -0
  114. package/packages/utility/src/display/capabilities.ts +200 -0
  115. package/packages/utility/src/display/width.ts +226 -0
  116. package/packages/utility/src/index.ts +283 -0
  117. package/packages/utility/src/info-screen.ts +80 -0
  118. package/packages/utility/src/lifecycle/cleanup.ts +332 -0
  119. package/packages/utility/src/lifecycle/process.ts +162 -0
  120. package/packages/utility/src/tools/batch.ts +229 -0
  121. package/packages/utility/src/tools/env.ts +134 -0
  122. package/packages/utility/src/tui/badge-settings.ts +103 -0
  123. package/packages/utility/src/tui/name-badge-state.ts +299 -0
  124. package/packages/utility/src/tui/name-badge.ts +117 -0
  125. package/packages/utility/src/tui/settings-inspector.ts +303 -0
  126. package/packages/utility/src/types.ts +257 -0
  127. package/packages/web-api/src/tools.ts +7 -0
  128. package/packages/workflow/README.md +47 -5
  129. package/packages/workflow/skills/auto/SKILL.md +465 -0
  130. package/packages/workflow/skills/chore-create/SKILL.md +313 -0
  131. package/packages/workflow/skills/chore-execute/SKILL.md +312 -0
  132. package/packages/workflow/skills/debug/SKILL.md +224 -0
  133. package/packages/workflow/skills/fix/SKILL.md +210 -0
  134. package/packages/workflow/skills/plan/SKILL.md +25 -9
  135. package/packages/workflow/skills/quick-fix/SKILL.md +133 -0
  136. package/packages/workflow/skills/quick-work/SKILL.md +3 -3
  137. package/packages/workflow/skills/research/SKILL.md +251 -0
  138. package/packages/workflow/skills/review-work/SKILL.md +22 -2
  139. package/packages/workflow/skills/scan-issues/SKILL.md +14 -2
  140. package/packages/workflow/skills/work/SKILL.md +38 -24
  141. package/packages/workflow/skills/worktree-merge/SKILL.md +2 -0
package/README.md CHANGED
@@ -19,6 +19,13 @@ 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
27
+ pi install npm:@pi-unipi/milestone
28
+ pi install npm:@pi-unipi/kanboard
22
29
  ```
23
30
 
24
31
  ## Packages
@@ -26,13 +33,20 @@ pi install npm:@pi-unipi/web-api
26
33
  | Package | Description |
27
34
  |---------|-------------|
28
35
  | `@pi-unipi/core` | Shared utilities, event types, constants |
29
- | `@pi-unipi/workflow` | 13 structured development workflow commands |
36
+ | `@pi-unipi/workflow` | 20 structured development workflow commands |
30
37
  | `@pi-unipi/ralph` | Long-running iterative development loops |
31
38
  | `@pi-unipi/memory` | Persistent cross-session memory with vector search |
32
39
  | `@pi-unipi/info-screen` | Dashboard and module registry overlay |
33
40
  | `@pi-unipi/subagents` | Parallel sub-agent execution with file locking |
34
41
  | `@pi-unipi/btw` | Parallel side conversations with `/btw` |
35
42
  | `@pi-unipi/web-api` | Web search, read, and summarize with provider selection |
43
+ | `@pi-unipi/compactor` | Session compaction, context management, batch execution |
44
+ | `@pi-unipi/notify` | Cross-platform notifications (native, Gotify, Telegram) |
45
+ | `@pi-unipi/utility` | Environment info, diagnostics, settings inspector, cleanup |
46
+ | `@pi-unipi/mcp` | MCP server discovery, connection, and tool integration |
47
+ | `@pi-unipi/ask-user` | Structured user input with options and freeform text |
48
+ | `@pi-unipi/milestone` | Milestone tracking and project progress management |
49
+ | `@pi-unipi/kanboard` | Kanboard visualization server with TUI overlay |
36
50
 
37
51
  ## Commands
38
52
 
@@ -45,6 +59,7 @@ pi install npm:@pi-unipi/web-api
45
59
  | `/unipi:work` | Execute plan in worktree |
46
60
  | `/unipi:review-work` | Review what was built |
47
61
  | `/unipi:consolidate` | Merge findings, update docs |
62
+ | `/unipi:auto` | Full pipeline — brainstorm → plan → work → review → merge |
48
63
  | `/unipi:worktree-create` | Create git worktree |
49
64
  | `/unipi:worktree-list` | List all worktrees |
50
65
  | `/unipi:worktree-merge` | Merge worktree back |
@@ -53,6 +68,12 @@ pi install npm:@pi-unipi/web-api
53
68
  | `/unipi:gather-context` | Research codebase |
54
69
  | `/unipi:document` | Generate documentation |
55
70
  | `/unipi:scan-issues` | Find bugs, anti-patterns |
71
+ | `/unipi:debug` | Active bug investigation — reproduce, diagnose, root-cause |
72
+ | `/unipi:fix` | Fix bugs using debug reports |
73
+ | `/unipi:quick-fix` | Fast one-shot fix for clear bugs |
74
+ | `/unipi:research` | Deep codebase investigation and documentation review |
75
+ | `/unipi:chore-create` | Create reusable chore (deploy, publish, etc.) |
76
+ | `/unipi:chore-execute` | Run a saved chore |
56
77
 
57
78
  ### Ralph (`/unipi:ralph`)
58
79
 
@@ -103,6 +124,52 @@ pi install npm:@pi-unipi/web-api
103
124
  | `/unipi:web-settings` | Configure providers and API keys |
104
125
  | `/unipi:web-cache-clear` | Clear all cached web content |
105
126
 
127
+ ### Compactor (`/unipi:compact*`)
128
+
129
+ | Command | Description |
130
+ |---------|-------------|
131
+ | `/unipi:compact` | Compact session into brief |
132
+ | `/unipi:compact-recall` | Recall from compacted sessions |
133
+ | `/unipi:compact-stats` | Show compaction statistics |
134
+ | `/unipi:compact-doctor` | Diagnose compactor issues |
135
+ | `/unipi:compact-settings` | Configure compactor |
136
+ | `/unipi:compact-preset` | Apply compaction presets |
137
+ | `/unipi:compact-index` | Index context for search |
138
+ | `/unipi:compact-search` | Search indexed context |
139
+ | `/unipi:compact-purge` | Purge old compacted data |
140
+
141
+ ### Notify (`/unipi:notify-*`)
142
+
143
+ | Command | Description |
144
+ |---------|-------------|
145
+ | `/unipi:notify-settings` | Configure notification platforms |
146
+ | `/unipi:notify-set-gotify` | Set Gotify server config |
147
+ | `/unipi:notify-set-tg` | Set Telegram bot config |
148
+ | `/unipi:notify-test` | Test notification delivery |
149
+
150
+ ### Utility (`/unipi:*`)
151
+
152
+ | Command | Description |
153
+ |---------|-------------|
154
+ | `/unipi:env` | Show environment info |
155
+ | `/unipi:doctor` | Run diagnostics |
156
+ | `/unipi:status` | Show module status |
157
+ | `/unipi:cleanup` | Clean stale temp files |
158
+ | `/unipi:reload` | Reload extensions |
159
+ | `/unipi:name-badge` | Toggle session name badge overlay |
160
+ | `/unipi:badge-gen` | Generate session name via background agent |
161
+ | `/unipi:badge-toggle` | Configure badge settings |
162
+
163
+ ### MCP (`/unipi:mcp-*`)
164
+
165
+ | Command | Description |
166
+ |---------|-------------|
167
+ | `/unipi:mcp-add` | Add MCP server |
168
+ | `/unipi:mcp-settings` | Configure MCP servers |
169
+ | `/unipi:mcp-sync` | Sync MCP tools |
170
+ | `/unipi:mcp-status` | Show MCP connection status |
171
+ | `/unipi:mcp-reload` | Reload MCP connections |
172
+
106
173
  ### Tools
107
174
 
108
175
  | Tool | Package | Description |
@@ -120,12 +187,41 @@ pi install npm:@pi-unipi/web-api
120
187
  | `web_search` | web-api | Search the web via provider |
121
188
  | `web_read` | web-api | Extract content from URL |
122
189
  | `web_llm_summarize` | web-api | Summarize web content via LLM |
190
+ | `notify_user` | notify | Send cross-platform notifications |
191
+ | `ask_user` | ask-user | Structured user input with options |
192
+ | `compact` | compactor | Compact session context |
193
+ | `vcc_recall` | compactor | Recall from compacted sessions |
194
+ | `ctx_execute` | compactor | Execute with context management |
195
+ | `ctx_batch_execute` | compactor | Batch execute with rollback |
196
+ | `ctx_index` | compactor | Index context for search |
197
+ | `ctx_search` | compactor | Search indexed context |
198
+ | `ctx_fetch_and_index` | compactor | Fetch and index web content |
199
+ | `ctx_stats` | compactor | Show compaction statistics |
200
+ | `ctx_doctor` | compactor | Diagnose compactor issues |
201
+ | `set_session_name` | utility | Set session name for badge display |
202
+ | `ctx_batch` | utility | Atomic batch execution with rollback |
203
+ | `ctx_env` | utility | Show environment information |
204
+
205
+ ### Milestone (`/unipi:milestone-*`)
206
+
207
+ | Command | Description |
208
+ |---------|-------------|
209
+ | `/unipi:milestone-onboard` | Create MILESTONES.md from existing workflow docs |
210
+ | `/unipi:milestone-update` | Sync MILESTONES.md with completed work |
211
+
212
+ ### Kanboard (`/unipi:kanboard*`)
213
+
214
+ | Command | Description |
215
+ |---------|-------------|
216
+ | `/unipi:kanboard` | Toggle kanboard visualization server |
217
+ | `/unipi:kanboard-doctor` | Diagnose and fix kanboard parser issues |
218
+ | `/unipi:name-gen` | Generate session name badge via background agent |
123
219
 
124
220
  ## How It Works
125
221
 
126
222
  **Core** provides shared infrastructure — event types, constants, utilities — so modules discover each other without tight coupling.
127
223
 
128
- **Workflow** provides 13 commands guiding work from idea to completion via brainstorm → plan → work → review → consolidate.
224
+ **Workflow** provides 20 commands guiding work from idea to completion: brainstorm → plan → work → review → consolidate, plus quick-fix, debug, research, chore, and more.
129
225
 
130
226
  **Ralph** enables long-running iterative tasks. Start a loop, the agent works through iterations, reflects periodically, and completes when done.
131
227
 
@@ -139,6 +235,20 @@ pi install npm:@pi-unipi/web-api
139
235
 
140
236
  **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
237
 
238
+ **Compactor** manages session context with compaction, indexing, search, and batch execution. Keep context lean without losing important information.
239
+
240
+ **Notify** sends notifications across platforms — native OS, Gotify, and Telegram. Configure once, get alerts everywhere.
241
+
242
+ **Utility** provides environment info, diagnostics, settings inspection, and cleanup tools for maintaining your development environment.
243
+
244
+ **MCP** integrates Model Context Protocol servers — discover, connect, and use external tool servers seamlessly.
245
+
246
+ **Ask User** provides structured user input with multiple-choice, multi-select, and freeform text options.
247
+
248
+ **Milestone** tracks project progress with MILESTONES.md — onboards existing work and syncs with completed tasks.
249
+
250
+ **Kanboard** provides a visualization server with htmx + Alpine.js UI for kanban boards, workflow timelines, and milestone progress. Includes a TUI overlay for quick access.
251
+
142
252
  ## Module Discovery
143
253
 
144
254
  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.6",
3
+ "version": "0.1.11",
4
4
  "description": "All-in-one extension suite for Pi coding agent",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,13 +42,28 @@
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/milestone/index.ts",
52
+ "node_modules/@pi-unipi/kanboard/index.ts",
53
+ "node_modules/@pi-unipi/command-enchantment/src/index.ts"
46
54
  ],
47
55
  "skills": [
48
56
  "node_modules/@pi-unipi/workflow/skills",
49
57
  "node_modules/@pi-unipi/ralph/SKILL.md",
50
58
  "node_modules/@pi-unipi/memory/skills",
51
- "node_modules/@pi-unipi/btw/skills"
59
+ "node_modules/@pi-unipi/btw/skills",
60
+ "node_modules/@pi-unipi/ask-user/skills",
61
+ "node_modules/@pi-unipi/mcp/skills",
62
+ "node_modules/@pi-unipi/utility/skills",
63
+ "node_modules/@pi-unipi/compactor/skills",
64
+ "node_modules/@pi-unipi/notify/skills",
65
+ "node_modules/@pi-unipi/milestone/skills",
66
+ "node_modules/@pi-unipi/kanboard/skills"
52
67
  ]
53
68
  },
54
69
  "peerDependencies": {
@@ -58,17 +73,26 @@
58
73
  "@sinclair/typebox": "*"
59
74
  },
60
75
  "dependencies": {
76
+ "@pi-unipi/ask-user": "*",
77
+ "@pi-unipi/btw": "*",
78
+ "@pi-unipi/compactor": "*",
79
+ "@pi-unipi/notify": "*",
80
+ "@pi-unipi/command-enchantment": "*",
61
81
  "@pi-unipi/core": "*",
62
- "@pi-unipi/workflow": "*",
63
- "@pi-unipi/ralph": "*",
64
- "@pi-unipi/memory": "*",
65
82
  "@pi-unipi/info-screen": "*",
83
+ "@pi-unipi/mcp": "*",
84
+ "@pi-unipi/memory": "*",
85
+ "@pi-unipi/ralph": "*",
66
86
  "@pi-unipi/subagents": "*",
67
- "@pi-unipi/btw": "*",
68
- "@pi-unipi/web-api": "*"
87
+ "@pi-unipi/utility": "*",
88
+ "@pi-unipi/milestone": "*",
89
+ "@pi-unipi/kanboard": "*",
90
+ "@pi-unipi/web-api": "*",
91
+ "@pi-unipi/workflow": "*"
69
92
  },
70
93
  "devDependencies": {
71
94
  "@types/node": "^25.6.0",
95
+ "tsx": "^4.21.0",
72
96
  "typescript": "^6.0.0"
73
97
  }
74
98
  }
@@ -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,152 @@
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
+ ### Option Properties
42
+
43
+ | Property | Type | Default | Description |
44
+ |----------|------|---------|-------------|
45
+ | `label` | string | required | Display label |
46
+ | `description` | string? | — | Description shown below label |
47
+ | `value` | string? | label | Value returned when selected |
48
+ | `allowCustom` | boolean? | false | Allow user to add custom text for this option (shorthand for `action: "input"`) |
49
+ | `action` | string? | "select" | Special action: `"select"`, `"input"`, `"end_turn"`, `"new_session"` |
50
+ | `prefill` | string? | — | Prefill message for `"new_session"` action |
51
+
52
+ ### Action Types
53
+
54
+ | Action | Behavior |
55
+ |--------|----------|
56
+ | `"select"` | Normal selection (default). Returns immediately. |
57
+ | `"input"` | Enters text input mode. Returns `combined` response with selection + text. |
58
+ | `"end_turn"` | Signals end of agent turn. Returns `end_turn` response kind. |
59
+ | `"new_session"` | Starts a new session. Returns `new_session` response kind with optional `prefill`. |
60
+
61
+ ## Examples
62
+
63
+ Single choice:
64
+ ```
65
+ ask_user({
66
+ question: "Which database should we use?",
67
+ options: [
68
+ { label: "PostgreSQL", description: "Reliable, feature-rich" },
69
+ { label: "SQLite", description: "Simple, serverless" }
70
+ ]
71
+ })
72
+ ```
73
+
74
+ Multi-select:
75
+ ```
76
+ ask_user({
77
+ question: "Which features to implement?",
78
+ options: [
79
+ { label: "Auth", value: "auth" },
80
+ { label: "Cache", value: "cache" },
81
+ { label: "Logging", value: "logging" }
82
+ ],
83
+ allowMultiple: true
84
+ })
85
+ ```
86
+
87
+ With context:
88
+ ```
89
+ ask_user({
90
+ question: "Which approach?",
91
+ context: "Current bottleneck: network I/O. Goal: reduce latency.",
92
+ options: [
93
+ { label: "Cache-first" },
94
+ { label: "DB-first" }
95
+ ]
96
+ })
97
+ ```
98
+
99
+ Freeform only:
100
+ ```
101
+ ask_user({
102
+ question: "What should we name this module?",
103
+ options: [],
104
+ allowFreeform: true
105
+ })
106
+ ```
107
+
108
+ Combined (multi-select + freeform):
109
+ ```
110
+ ask_user({
111
+ question: "Which features and what custom feature?",
112
+ options: [
113
+ { label: "Auth", value: "auth" },
114
+ { label: "Cache", value: "cache" }
115
+ ],
116
+ allowMultiple: true,
117
+ allowFreeform: true
118
+ })
119
+ ```
120
+ User can check "Auth", "Cache", and "Custom response" to type additional features.
121
+
122
+ With per-option custom text:
123
+ ```
124
+ ask_user({
125
+ question: "Does this look right?",
126
+ options: [
127
+ { label: "Yes", value: "yes" },
128
+ { label: "Partially", value: "partial", allowCustom: true },
129
+ { label: "No", value: "no", allowCustom: true }
130
+ ],
131
+ allowFreeform: false
132
+ })
133
+ ```
134
+ Selecting "Partially" or "No" enters text input so the user can explain what needs to change.
135
+
136
+ With end_turn and new_session actions:
137
+ ```
138
+ ask_user({
139
+ question: "How would you like to proceed?",
140
+ options: [
141
+ { label: "Looks good, proceed", value: "proceed" },
142
+ { label: "I want changes", value: "changes", action: "input" },
143
+ { label: "Done for now", value: "done", action: "end_turn" },
144
+ { label: "Start fresh", value: "new", action: "new_session", prefill: "Let's redesign the..." }
145
+ ],
146
+ allowFreeform: false
147
+ })
148
+ ```
149
+ - "Looks good" returns immediately with selection
150
+ - "I want changes" enters text input mode for the user to explain
151
+ - "Done for now" signals the agent to end its turn
152
+ - "Start fresh" starts a new session with the prefill message
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @pi-unipi/command-enchantment — Re-export
3
+ *
4
+ * Re-exports from src/ for module resolution.
5
+ */
6
+
7
+ export { default } from "./src/index.js";