@geoqiao/pi-ask 1.1.0

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 (59) hide show
  1. package/CHANGELOG.md +194 -0
  2. package/LICENSE +22 -0
  3. package/README.md +282 -0
  4. package/docs/README.md +33 -0
  5. package/docs/configuration.md +406 -0
  6. package/docs/contract.md +309 -0
  7. package/docs/remote-events.md +187 -0
  8. package/package.json +130 -0
  9. package/skills/ask-user/SKILL.md +110 -0
  10. package/src/answer-commands.ts +361 -0
  11. package/src/answer-extraction.ts +354 -0
  12. package/src/ask-payload-store.ts +86 -0
  13. package/src/ask-settings-command.ts +14 -0
  14. package/src/ask-tool-helpers.ts +172 -0
  15. package/src/ask-tool.ts +84 -0
  16. package/src/config/defaults.ts +216 -0
  17. package/src/config/migrate.ts +70 -0
  18. package/src/config/migrations/index.ts +139 -0
  19. package/src/config/migrations/types.ts +10 -0
  20. package/src/config/schema.ts +287 -0
  21. package/src/config/store.ts +227 -0
  22. package/src/constants/keymaps.ts +721 -0
  23. package/src/constants/text.ts +12 -0
  24. package/src/constants/ui.ts +22 -0
  25. package/src/index.ts +30 -0
  26. package/src/math.ts +3 -0
  27. package/src/notifications.ts +119 -0
  28. package/src/remote-ask.ts +563 -0
  29. package/src/result-format.ts +157 -0
  30. package/src/result.ts +23 -0
  31. package/src/schema.ts +74 -0
  32. package/src/state/answers.ts +251 -0
  33. package/src/state/create.ts +18 -0
  34. package/src/state/editor.ts +70 -0
  35. package/src/state/navigation.ts +86 -0
  36. package/src/state/normalize.ts +326 -0
  37. package/src/state/question-type.ts +128 -0
  38. package/src/state/result.ts +263 -0
  39. package/src/state/selectors.ts +135 -0
  40. package/src/state/transitions.ts +330 -0
  41. package/src/state/view.ts +28 -0
  42. package/src/text.ts +98 -0
  43. package/src/types.ts +169 -0
  44. package/src/ui/auto-submit.ts +36 -0
  45. package/src/ui/autocomplete.ts +52 -0
  46. package/src/ui/controller.ts +645 -0
  47. package/src/ui/dismiss-guard.ts +26 -0
  48. package/src/ui/input.ts +160 -0
  49. package/src/ui/render-frame.ts +235 -0
  50. package/src/ui/render-helpers.ts +385 -0
  51. package/src/ui/render-question.ts +288 -0
  52. package/src/ui/render-submit.ts +168 -0
  53. package/src/ui/render-types.ts +33 -0
  54. package/src/ui/render.ts +53 -0
  55. package/src/ui/review-shortcuts.ts +43 -0
  56. package/src/ui/settings-list.ts +461 -0
  57. package/src/ui/show-settings.ts +37 -0
  58. package/src/ui/view-models/question.ts +203 -0
  59. package/src/ui/view-models/review.ts +100 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,194 @@
1
+ # [1.1.0](https://github.com/eko24ive/pi-ask/compare/v1.0.2...v1.1.0) (2026-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * refresh pi dependency compatibility ([d6db94a](https://github.com/eko24ive/pi-ask/commit/d6db94a39d37fda632d53147592af8f53aa50e4b))
7
+
8
+
9
+ ### Features
10
+
11
+ * add remote ask event contract ([69e8bab](https://github.com/eko24ive/pi-ask/commit/69e8bab6efbc0394aecb9ce416eea27da755a5df)), closes [#6](https://github.com/eko24ive/pi-ask/issues/6)
12
+
13
+ ## [1.0.2](https://github.com/eko24ive/pi-ask/compare/v1.0.1...v1.0.2) (2026-05-31)
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * avoid destructive ask config writes ([fa89c15](https://github.com/eko24ive/pi-ask/commit/fa89c1551a509690dee767165124450aac322c58))
19
+
20
+ ## [1.0.1](https://github.com/eko24ive/pi-ask/compare/v1.0.0...v1.0.1) (2026-05-22)
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * avoid config docs supply-chain false positive ([5d12c2f](https://github.com/eko24ive/pi-ask/commit/5d12c2fb8da82ca538999be65f58595c8aa54dde))
26
+ * clarify ask_user prompt guidelines ([4afbe62](https://github.com/eko24ive/pi-ask/commit/4afbe62a42c80b13b8c77112a25cc68ab18ea3fa))
27
+
28
+ # [1.0.0](https://github.com/eko24ive/pi-ask/compare/v0.9.0...v1.0.0) (2026-05-22)
29
+
30
+
31
+ * feat!: migrate to latest pi packages ([a987406](https://github.com/eko24ive/pi-ask/commit/a9874062a50d4073a5379667620e1f2e457148a2))
32
+
33
+
34
+ ### BREAKING CHANGES
35
+
36
+ * pi dependencies moved from @mariozechner/* to @earendil-works/*.
37
+
38
+ Consumers must use the latest pi package scope.
39
+
40
+ # [0.9.0](https://github.com/eko24ive/pi-ask/compare/v0.8.1...v0.9.0) (2026-05-06)
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * remove footer navigation hints ([45d8302](https://github.com/eko24ive/pi-ask/commit/45d8302e0a2e1527f0129bbb53fec38927a722ac))
46
+
47
+
48
+ ### Features
49
+
50
+ * add ask notifications ([43cee4c](https://github.com/eko24ive/pi-ask/commit/43cee4c0f0cbbaf9673b67ca300ff5b05117819c))
51
+ * add context-aware ask keymaps ([808b62c](https://github.com/eko24ive/pi-ask/commit/808b62cc77ee23093f2f672679ada1c34ec1a978))
52
+ * add guarded config reset ([b218b8b](https://github.com/eko24ive/pi-ask/commit/b218b8b1889b163e5bd21fcb5083250921404a02))
53
+ * add question type presentation controls ([f1a0a5d](https://github.com/eko24ive/pi-ask/commit/f1a0a5d5e5eb3591b90200921e88660517830dec))
54
+
55
+ ## [0.8.1](https://github.com/eko24ive/pi-ask/compare/v0.8.0...v0.8.1) (2026-05-03)
56
+
57
+
58
+ ### Bug Fixes
59
+
60
+ * multi-select custom answer toggling ([780aac2](https://github.com/eko24ive/pi-ask/commit/780aac24cf58e144a8ab3ba6a29a75cf6fbf2656))
61
+ * refine ask tool context typing ([cbabd44](https://github.com/eko24ive/pi-ask/commit/cbabd44acc0fadd4959602e8aa73c1c106856aad))
62
+
63
+ # [0.8.0](https://github.com/eko24ive/pi-ask/compare/v0.7.0...v0.8.0) (2026-05-02)
64
+
65
+
66
+ ### Bug Fixes
67
+
68
+ * rename settings modal title ([4feeec9](https://github.com/eko24ive/pi-ask/commit/4feeec9f0f535b4a129c8ce5d0f310f1365c6010))
69
+
70
+
71
+ ### Features
72
+
73
+ * add answer extraction replay commands ([5b70eca](https://github.com/eko24ive/pi-ask/commit/5b70eca306e15335e0a24754280c1ea6d9787bbf))
74
+ * **config:** add migration framework ([288caf4](https://github.com/eko24ive/pi-ask/commit/288caf49de4a78e35845187f736b9685f732c5cc))
75
+
76
+ # [0.7.0](https://github.com/eko24ive/pi-ask/compare/v0.6.1...v0.7.0) (2026-04-29)
77
+
78
+
79
+ ### Bug Fixes
80
+
81
+ * **package:** declare bundled skills in pi manifest ([3c26bfa](https://github.com/eko24ive/pi-ask/commit/3c26bfa7c995fd4fb22d391db784ceaf76594e4c))
82
+ * pass custom answers through elaborate output ([85962d9](https://github.com/eko24ive/pi-ask/commit/85962d985d7a8064093f8643f4706d8d98888050))
83
+
84
+
85
+ ### Features
86
+
87
+ * add ask settings modal shell ([5c0d896](https://github.com/eko24ive/pi-ask/commit/5c0d8964fba099e85472c42ab442bd5b86480de1))
88
+ * add config-backed ask keymaps ([e8a36b7](https://github.com/eko24ive/pi-ask/commit/e8a36b72eff4f43f8d3944846dbe58bb605210a9))
89
+ * add dirty-dismiss and footer hint settings ([18120e8](https://github.com/eko24ive/pi-ask/commit/18120e880119cff23e2fdc2cf49cdf3fbb512829))
90
+ * add review shortcut confirmation setting ([67891d1](https://github.com/eko24ive/pi-ask/commit/67891d147f4bde4bb84edc1e8eca4d91786c1056))
91
+ * bootstrap ask config on first use ([2bf85b3](https://github.com/eko24ive/pi-ask/commit/2bf85b3f6f19a71972df8b989ccc6670397c4e38))
92
+ * **ui:** add ask keymap help modal ([c9930b4](https://github.com/eko24ive/pi-ask/commit/c9930b494f89320498db9b9828415f331605c3ff))
93
+
94
+ ## [0.6.1](https://github.com/eko24ive/pi-ask/compare/v0.6.0...v0.6.1) (2026-04-27)
95
+
96
+
97
+ ### Bug Fixes
98
+
99
+ * remove automatic lefthook install ([4f1c598](https://github.com/eko24ive/pi-ask/commit/4f1c59818137cbcd335d5153c835e3f420aab575))
100
+
101
+ # [0.6.0](https://github.com/eko24ive/pi-ask/compare/v0.5.1...v0.6.0) (2026-04-25)
102
+
103
+
104
+ ### Bug Fixes
105
+
106
+ * **ui:** tighten ask layout rendering ([3515098](https://github.com/eko24ive/pi-ask/commit/351509838cd14ad251ca4b152c0bb4577c9d7b79))
107
+
108
+
109
+ ### Features
110
+
111
+ * **ui:** improve narrow-screen tab and footer rendering ([1ce7210](https://github.com/eko24ive/pi-ask/commit/1ce721094c21faf6180098a7244b6f2abd13623e))
112
+ * **ui:** split submit tab into actions and review ([b59c967](https://github.com/eko24ive/pi-ask/commit/b59c967d985a6f62dc32da3b4f2c5767d01608a9))
113
+ * **ui:** support custom answers in preview questions ([7cca5eb](https://github.com/eko24ive/pi-ask/commit/7cca5eb54d1964d19ce17ebb45507f1939960b8b))
114
+
115
+ ## [0.5.1](https://github.com/eko24ive/pi-ask/compare/v0.5.0...v0.5.1) (2026-04-25)
116
+
117
+
118
+ ### Bug Fixes
119
+
120
+ * **skills:** align bundled skill name with folder ([005151f](https://github.com/eko24ive/pi-ask/commit/005151f79ba562c08e0fe9b5bccf59e964c02a32))
121
+
122
+ # [0.5.0](https://github.com/eko24ive/pi-ask/compare/v0.4.0...v0.5.0) (2026-04-24)
123
+
124
+
125
+ ### Features
126
+
127
+ * add submit screen number hotkeys ([c10c61f](https://github.com/eko24ive/pi-ask/commit/c10c61f1ebb061dab1daf7404089ce6b57c8917c))
128
+ * **skill:** add ask-user decision gate profile ([6d9cb5b](https://github.com/eko24ive/pi-ask/commit/6d9cb5b7bfde54c7522f8e8321046161af296dad))
129
+
130
+ # [0.4.0](https://github.com/eko24ive/pi-ask/compare/v0.3.0...v0.4.0) (2026-04-24)
131
+
132
+
133
+ ### Features
134
+
135
+ * improve ask flow elaboration and validation ([b7c7301](https://github.com/eko24ive/pi-ask/commit/b7c7301f974c81eb82070810304a9267f62d7699))
136
+
137
+ # [0.3.0](https://github.com/eko24ive/pi-ask/compare/v0.2.0...v0.3.0) (2026-04-23)
138
+
139
+
140
+ ### Bug Fixes
141
+
142
+ * allow empty editor navigation shortcuts ([5d7ccc8](https://github.com/eko24ive/pi-ask/commit/5d7ccc8ce2e45c70a36932f048a90419dcb59304))
143
+
144
+
145
+ ### Features
146
+
147
+ * harden ask tool validation and fallback ([050e880](https://github.com/eko24ive/pi-ask/commit/050e8800cdcd97be635bb95d9500a309d207f7f8))
148
+
149
+ # [0.2.0](https://github.com/eko24ive/pi-ask/compare/v0.1.1...v0.2.0) (2026-04-19)
150
+
151
+
152
+ ### Bug Fixes
153
+
154
+ * improve custom input editor rendering ([bc92712](https://github.com/eko24ive/pi-ask/commit/bc9271205335bb9e610f8cd0c6e86bea5ce22f4b))
155
+ * keep arrow keys and tab inside editor mode ([cdea90b](https://github.com/eko24ive/pi-ask/commit/cdea90bbfe726f4edca131513cf96e81a5307782))
156
+ * polish ask note spacing and styling ([e0e2b04](https://github.com/eko24ive/pi-ask/commit/e0e2b046883b9d07745a6178c49cfef25e771424))
157
+ * preserve multi-select choices with custom answers ([8d8e7b6](https://github.com/eko24ive/pi-ask/commit/8d8e7b67c97e796de0e44b8935960a8d39b55360))
158
+
159
+
160
+ ### Features
161
+
162
+ * refine ask submit screen layout ([d5ca38e](https://github.com/eko24ive/pi-ask/commit/d5ca38e621f701af466a9b67005708ebd176bbf0))
163
+ * sharpen ask_user tool guidance ([4a131f7](https://github.com/eko24ive/pi-ask/commit/4a131f7752f17f2f91fd6669e45a74888240d86e))
164
+ * simplify ask UI copy and note shortcuts ([9ab368a](https://github.com/eko24ive/pi-ask/commit/9ab368ad6bebdf26d8a4be7de71ac415eea06285))
165
+ * support @ file autocomplete in ask editor ([0386239](https://github.com/eko24ive/pi-ask/commit/0386239f5e4165281b40db540d129d86c8af63d4))
166
+ * support ctrl+c dismissal in ask flow ([fcd1f1b](https://github.com/eko24ive/pi-ask/commit/fcd1f1bce5120af07c7d6499591295e4bccf6a55))
167
+
168
+ ## [0.1.1](https://github.com/eko24ive/pi-ask/compare/v0.1.0...v0.1.1) (2026-04-19)
169
+
170
+
171
+ ### Bug Fixes
172
+
173
+ * relax toolchain pinning for release workflow ([549c2c2](https://github.com/eko24ive/pi-ask/commit/549c2c26f04f5c2d6b7b3f6487a7a72303f998bb))
174
+ * remove toolchain pinning from repo ([5b10568](https://github.com/eko24ive/pi-ask/commit/5b105683c35dc02df1e1e0fc6132a46283c25d1b))
175
+ * specify pnpm version in workflows ([08e053f](https://github.com/eko24ive/pi-ask/commit/08e053f095ed5ccc68a367f03c07a30b31683b3c))
176
+
177
+ # [0.1.0](https://github.com/eko24ive/pi-ask/compare/v0.0.0...v0.1.0) (2026-04-19)
178
+
179
+
180
+ ### Bug Fixes
181
+
182
+ * skip git hooks during release commits ([32c2ae7](https://github.com/eko24ive/pi-ask/commit/32c2ae785c16ab2482f9f2a09d19c8eeed8cae8e))
183
+ * update release tooling for trusted publishing ([85f4ec5](https://github.com/eko24ive/pi-ask/commit/85f4ec5128ba4554412e3409d9f353fb66981f35))
184
+
185
+
186
+ ### Features
187
+
188
+ * bootstrap first public release ([552959f](https://github.com/eko24ive/pi-ask/commit/552959f7ad3b40a9f3f8443d301a2c6f2340477d))
189
+
190
+ # Changelog
191
+
192
+ All notable changes to this project will be documented in this file.
193
+
194
+ The format is driven by semantic-release.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 eko24ive
4
+ Copyright (c) 2026 geoqiao
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,282 @@
1
+ ![pi-ask main image](docs/media/pi-ask-main.png)
2
+
3
+ # @geoqiao/pi-ask
4
+
5
+ [![npm downloads](https://badgen.net/npm/dm/@geoqiao/pi-ask)](https://www.npmjs.com/package/@geoqiao/pi-ask)
6
+ [![last commit](https://badgen.net/github/last-commit/geoqiao/pi-ask)](https://github.com/geoqiao/pi-ask/commits/main)
7
+ [![stars](https://badgen.net/github/stars/geoqiao/pi-ask)](https://github.com/geoqiao/pi-ask/stargazers)
8
+
9
+ `@geoqiao/pi-ask` is an independently maintained continuation of [`eko24ive/pi-ask`](https://github.com/eko24ive/pi-ask). It is an ask tool that cares about your answers.
10
+
11
+ It lets an agent pause, ask structured questions in a terminal UI, and continue with normalized answers instead of guessing.
12
+
13
+ ![pi-ask demo](docs/media/pi-ask-demo.gif)
14
+
15
+ High-quality video: [demo.mp4](https://github.com/user-attachments/assets/a8503ca9-afcb-4c31-9edc-353b985a0209)
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pi install npm:@geoqiao/pi-ask
21
+ ```
22
+
23
+ You can also install from git:
24
+
25
+ ```bash
26
+ pi install git:github.com/geoqiao/pi-ask
27
+ ```
28
+
29
+ Or try it without installing (load once for the current run):
30
+
31
+ ```bash
32
+ pi -e npm:@geoqiao/pi-ask
33
+ ```
34
+
35
+ ## Features
36
+
37
+ Once installed, this package gives the agent a native way to ask for clarification instead of guessing.
38
+
39
+ - 🧭 Familiar ask-style interface: tabbed questions, single/multi select, and preview mode
40
+ - ✍️ Inline free-form `Type your own` answers
41
+ - 📎 Native pi-style `@` file references inside answer and note editors
42
+ - 📝 Question-level and option-level notes
43
+ - 👀 Review tab with `Submit`, `Elaborate`, and `Cancel`
44
+ - 💬 Elaboration flow to capture note-based clarification before final submission
45
+ - ⌨️ Context-aware customizable keymaps with aliases for main flow, editors, and settings
46
+ - ⚙️ Ask settings with persisted behaviour, notifications, keymaps, and `/answer` extraction config
47
+ - 🔔 Optional external notifications when an ask flow is waiting for input
48
+ - 🔁 Slash commands for fallback/replay:
49
+ - `/answer` extracts questions from the latest assistant message into an ask flow
50
+ - `/answer:again` reopens the latest `/answer` form on the current branch
51
+ - `/ask:replay` replays the latest real `ask_user` form on the current branch
52
+ - 🗣️ You can talk to your agent to configure pi-ask; it will read the bundled configuration guide and tailor the config for you
53
+
54
+ ## Feature walkthrough
55
+
56
+ ### Native `@` file references
57
+ Use pi-style `@` file path autocomplete inside free-form answers and note editors.
58
+
59
+ ![Native pi-style @ file references inside the ask flow](docs/media/feature-at-file-mentions.png)
60
+
61
+ ### Option and question notes
62
+ Attach clarification notes to a specific option (`n`) or add broader question-level context (`Shift+N`).
63
+
64
+ | Option notes | Question notes |
65
+ |---|---|
66
+ | ![Option note editor with note text for selected option](docs/media/feature-option-note.png) | ![Question-level note editor with saved note](docs/media/feature-question-note.png) |
67
+
68
+ ### Review tab — Elaborate and Submit
69
+ Ask the agent to elaborate on notes before finalizing choices, or review all answers before returning them to the agent.
70
+
71
+ | Elaborate | Submit |
72
+ |---|---|
73
+ | ![Review tab with Elaborate action and expanded note preview](docs/media/feature-review-elaborate.png) | ![Review tab with Submit action highlighted](docs/media/feature-review-submit.png) |
74
+
75
+ ### Single-select and multi-select questions
76
+ Pick one option when answers are mutually exclusive, or choose multiple options when several answers apply.
77
+
78
+ | Single-select | Multi-select |
79
+ |---|---|
80
+ | ![Single-select question with one selected option](docs/media/feature-single-select.png) | ![Multi-select question with multiple selected options](docs/media/feature-multi-select.png) |
81
+
82
+ ### Preview mode
83
+ Use a dedicated preview pane when options need richer detail.
84
+
85
+ ![Preview question showing a dedicated preview pane](docs/media/feature-preview-pane.png)
86
+
87
+ ### Custom answer (`Type your own`)
88
+ Capture free-form input inline without leaving the flow.
89
+
90
+ ![Inline custom answer input for Type your own option](docs/media/feature-custom-answer-input.png)
91
+
92
+ ## Default key bindings
93
+
94
+ Open ask settings with `?` during the ask flow, or with the `/ask-settings` command from pi.
95
+
96
+ Keymaps are context-aware and configurable in `~/.pi/agent/extensions/eko24ive-pi-ask.json`.
97
+ Each action accepts a key string or an array of aliases.
98
+
99
+ Default contexts:
100
+
101
+ - `global`: `dismiss` (`Ctrl+C`) and `settings` (`?`)
102
+ - `main`: confirm/cancel/toggle, tab navigation, option navigation, and note shortcuts
103
+ - `editor`: custom answer submit/close and empty-editor navigation
104
+ - `noteEditor`: note save/close and empty-editor navigation
105
+ - `settingsModal`: close, next/previous setting, and toggle
106
+
107
+ Fixed bindings:
108
+
109
+ | Key | Context | Effect |
110
+ |---|---|---|
111
+ | `1..9` | Options list | Select or toggle matching option |
112
+ | `1` `2` `3` | Review tab | Trigger `Submit` / `Elaborate` / `Cancel` |
113
+ | `@` | Editors | File-reference affordance |
114
+ | Arrow keys / `Tab` | Non-empty editor | Stay in editor for cursor movement |
115
+
116
+ Review-tab shortcuts can optionally require the same number key twice via `behaviour.doublePressReviewShortcuts`. `behaviour.presentSingleAsMulti` can render future single-select questions as multi-select while preserving the requested type in results; use `main.changeQuestionType` (`t` by default) to change the active question type live.
117
+
118
+ You can edit the config file yourself, ask pi to edit it for you, or use `/ask-settings` to find the exact config path, toggle behaviour/notification settings, or reset config to defaults with a guarded double press. pi-ask treats the config file as user-owned: load-time migrations and invalid files are handled in memory without rewriting or backing up the file, and read-only/externally managed configs fail gracefully with a manual-edit message.
119
+
120
+ ```json
121
+ {
122
+ "schemaVersion": 5,
123
+ "answer": {
124
+ "extractionModels": [
125
+ { "provider": "openai-codex", "id": "gpt-5.4-mini" },
126
+ { "provider": "github-copilot", "id": "gpt-5.4-mini" },
127
+ { "provider": "anthropic", "id": "claude-haiku-4-5" }
128
+ ],
129
+ "extractionTimeoutMs": 30000,
130
+ "extractionRetries": 1
131
+ },
132
+ "behaviour": {
133
+ "autoSubmitWhenAnsweredWithoutNotes": false,
134
+ "confirmDismissWhenDirty": true,
135
+ "doublePressReviewShortcuts": true,
136
+ "presentSingleAsMulti": false,
137
+ "showFooterHints": true
138
+ },
139
+ "keymaps": {
140
+ "global": { "dismiss": ["ctrl+c"], "settings": ["?"] },
141
+ "main": {
142
+ "confirm": ["enter"],
143
+ "cancel": ["esc"],
144
+ "toggle": ["space"],
145
+ "changeQuestionType": ["t"],
146
+ "nextTab": ["tab", "right"],
147
+ "previousTab": ["shift+tab", "left"],
148
+ "nextOption": ["down"],
149
+ "previousOption": ["up"],
150
+ "optionNote": ["n"],
151
+ "questionNote": ["shift+n"]
152
+ },
153
+ "editor": {
154
+ "submit": ["enter"],
155
+ "close": ["esc"],
156
+ "nextTabWhenEmpty": ["tab", "right"],
157
+ "previousTabWhenEmpty": ["shift+tab", "left"],
158
+ "nextOptionWhenEmpty": ["down"],
159
+ "previousOptionWhenEmpty": ["up"]
160
+ },
161
+ "noteEditor": {
162
+ "save": ["enter"],
163
+ "close": ["esc"],
164
+ "nextTabWhenEmpty": ["tab", "right"],
165
+ "previousTabWhenEmpty": ["shift+tab", "left"],
166
+ "nextOptionWhenEmpty": ["down"],
167
+ "previousOptionWhenEmpty": ["up"]
168
+ },
169
+ "settingsModal": {
170
+ "close": ["esc", "ctrl+c", "?"],
171
+ "nextOption": ["down"],
172
+ "previousOption": ["up"],
173
+ "toggle": ["enter", "space"]
174
+ }
175
+ },
176
+ "notifications": {
177
+ "enabled": true,
178
+ "channels": ["bell"]
179
+ }
180
+ }
181
+ ```
182
+
183
+ Accepted notation follows pi-tui key ids. Common aliases are normalized, for example `escape` → `esc`, `return` → `enter`, `control+c` → `ctrl+c`, and `Shift+N` → `shift+n`.
184
+
185
+ ## Use
186
+
187
+ After installation, the extension registers the `ask_user` tool plus `/ask-settings`, `/answer`, `/answer:again`, and `/ask:replay` commands.
188
+
189
+ Agents can auto-discover and call `ask_user` when they need clarification instead of guessing. In interactive sessions, it opens a terminal UI flow for structured answers, supports native pi-style `@` file references while typing answers or notes, and returns normalized answers back to the agent. Ask settings are available both from `?` in the ask flow and from the `/ask-settings` command. Behaviour and notification settings are binary `on`/`off` toggles that save immediately when the config file is writable; save failures revert the toggle and show a manual-edit message. The settings overlay includes a guarded double-press reset-to-defaults action; keymaps, notification channels, and extraction settings are changed by editing the shown config file path.
190
+
191
+ ### Answer and replay commands
192
+
193
+ `/answer` is useful when the agent asked questions in plain text instead of using `ask_user`. It extracts questions from the latest completed assistant message and opens the same ask UI.
194
+
195
+ Replay commands are branch-aware. They read persisted entries from the current pi session branch, so they work naturally with `/resume`, `/tree`, and conversation branching:
196
+
197
+ - `/answer:again` reopens the latest form created by `/answer` on this branch
198
+ - `/ask:replay` reopens the latest real `ask_user` form on this branch
199
+
200
+ Cancellation is local to the UI: closing a replayed form does not start a new agent turn. Submitted answers are sent back as a normal user follow-up message.
201
+
202
+ Kudos to [@k0valik](https://github.com/k0valik) for the `/answer` idea.
203
+
204
+ You can also talk to pi to configure this extension. When asked to customize pi-ask settings, keymaps, notifications, or extraction behavior, the agent is instructed to read the bundled `docs/configuration.md` guide first and then edit the config file accordingly.
205
+
206
+ This package also bundles the `ask-user` skill profile from `skills/ask-user/SKILL.md`. It reinforces when to use the tool, is enabled by default when installed, and can be disabled via `pi config`. The skill was inspired by https://github.com/edlsh/pi-ask-user.
207
+
208
+ You can still add your own agent instruction if you want to further reinforce usage.
209
+
210
+ For exact input/output and UX guarantees, see [`docs/contract.md`](docs/contract.md).
211
+
212
+ ## Local development
213
+
214
+ ### Run locally in pi
215
+
216
+ ```bash
217
+ pi -e ./src/index.ts
218
+ ```
219
+
220
+ ### Run in isolated test mode (extension + bundled skill only)
221
+
222
+ ```bash
223
+ pnpm dev
224
+ pnpm dev ../test
225
+ ```
226
+
227
+ `pnpm dev [path]` runs pi with `--no-extensions --no-skills --no-prompt-templates --no-themes --no-context-files`, loads this repo’s extension and `skills/ask-user`, and starts pi from `[path]` by changing directories before launch (defaults to `.`).
228
+
229
+ ### Install dependencies
230
+
231
+ ```bash
232
+ pnpm install
233
+ ```
234
+
235
+ ### Install git hooks (contributors)
236
+
237
+ `lefthook` is not installed automatically. If you want the local commit hooks used by this repo, run:
238
+
239
+ ```bash
240
+ pnpm exec lefthook install
241
+ ```
242
+
243
+ ### Development commands
244
+
245
+ ```bash
246
+ pnpm format
247
+ pnpm lint
248
+ pnpm check
249
+ pnpm typecheck
250
+ pnpm test
251
+ ```
252
+
253
+ ### Commit workflow
254
+
255
+ This repo uses `lefthook`, Commitizen, conventional commitlint, and semantic-release.
256
+
257
+ If you want local hooks, install them once after `pnpm install`:
258
+
259
+ ```bash
260
+ pnpm exec lefthook install
261
+ ```
262
+
263
+ Recommended flow:
264
+
265
+ ```bash
266
+ pnpm commit
267
+ ```
268
+
269
+ ## Project layout
270
+
271
+ - `src/` — TypeScript extension implementation
272
+ - `tests/` — behavior-focused tests
273
+ - `docs/` — small docs set for contract and architecture
274
+ - `docs/media/` — repository-only README media assets
275
+
276
+ ## Documentation
277
+
278
+ Docs stay intentionally small:
279
+
280
+ - `docs/README.md` — index
281
+ - `docs/contract.md` — external behavior
282
+ - `docs/architecture.md` — module boundaries and invariants
package/docs/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Docs
2
+
3
+ This folder keeps only the documentation needed to understand and maintain the extension without turning docs into a second copy of the code.
4
+
5
+ ## Files
6
+
7
+ - `configuration.md` — source of truth for configuring pi-ask keymaps, behaviour, and `/answer` extraction
8
+ - `contract.md` — external behavior, tool payload/result details, and UX guarantees
9
+ - `remote-events.md` — local inter-extension event contract, bridge examples, and smoke-test steps
10
+ - `architecture.md` — module boundaries and invariants
11
+ - `../skills/ask-user/SKILL.md` — auto-bundled agent-side decision-gate guidance; enabled by default, but can be disabled via `pi config`; inspired by https://github.com/edlsh/pi-ask-user
12
+
13
+ ## Reading order
14
+
15
+ - start with `configuration.md` for config-editing rules
16
+ - read `contract.md` for behavior
17
+ - read `remote-events.md` for local bridge/event integration
18
+ - read `architecture.md` for code layout
19
+
20
+ ## Local test run
21
+
22
+ From repo root, run:
23
+
24
+ ```bash
25
+ pnpm dev
26
+ pnpm dev ../some-target-folder
27
+ ```
28
+
29
+ This starts pi in isolated mode, loads only this extension and bundled `ask-user` skill, and uses the optional folder as `--cd` target.
30
+
31
+ ## Rule of thumb
32
+
33
+ If a detail is about implementation mechanics, it should usually live in `src/` or `tests/`, not here.