@k3_2o/pi-ask-user-question 0.0.0-stage → 0.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.
- package/LICENSE +21 -0
- package/README.md +53 -2
- package/index.ts +8 -0
- package/package.json +53 -5
- package/src/dialog.ts +676 -0
- package/src/normalize.ts +148 -0
- package/src/respond.ts +46 -0
- package/src/result-interpretation.ts +20 -0
- package/src/schema.ts +31 -0
- package/src/text-layout.ts +76 -0
- package/src/tool.ts +173 -0
- package/src/transcript.ts +305 -0
- package/src/types.ts +41 -0
- package/src/validate.ts +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 k3-2o
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-ask-user-question
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A pi extension that pauses the agent and interviews the user in the terminal.
|
|
4
|
+
|
|
5
|
+
## What you get
|
|
6
|
+
|
|
7
|
+
- Batched questions in one tool call, answered one at a time (`Tab`/`→` next, `←` previous, `↑`/`↓` move, `Enter` select) — navigation loops, so Tab from the last face wraps to the first
|
|
8
|
+
- Radio selection with per-option descriptions, a `(Recommended)` badge, and a `Type your own answer` escape hatch that is always appended — scroll onto it and just type; the row itself becomes the input (Enter still works to focus it)
|
|
9
|
+
- Multi-select mode (`multi: true`): `Space` toggles options, shown with checkboxes
|
|
10
|
+
- One canonical `questions[]` contract, answers correlated by `id`
|
|
11
|
+
- The answer is painted in place: after the ask completes, the transcript row redraws as the menu with the picked option radio-filled (`◉`) and no separate answer line. Cancelled and skipped asks get a single dim footnote. HTML export renders each renderer once, so exported sessions keep the call-plus-answer layout
|
|
12
|
+
- Batched asks finish on a Submit review page listing every question with its chosen answer; `←` from it re-opens any question to reselect before committing
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pi install .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or point the extensions dir at this repo's `index.ts`. Loads as a pi package via the `pi.extensions` field.
|
|
21
|
+
|
|
22
|
+
## Tool use
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"questions": [
|
|
27
|
+
{
|
|
28
|
+
"id": "storage",
|
|
29
|
+
"question": "Which database should we use?",
|
|
30
|
+
"header": "Architecture Decision",
|
|
31
|
+
"options": [
|
|
32
|
+
{ "label": "SQLite", "description": "Zero-ops, single file" },
|
|
33
|
+
{ "label": "Postgres", "description": "Heavier but production-grade" }
|
|
34
|
+
],
|
|
35
|
+
"recommended": 0
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Never include the custom-instruction option yourself; the dialog always appends it. Multi-select is opt-in via `multi: true`; without it, one choice per question. Options are `{ label, description? }` only; a `Recommended` suffix in a label is rejected so the badge cannot be spoofed.
|
|
42
|
+
|
|
43
|
+
## Development
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
bun install
|
|
47
|
+
bun test # behavior tests, stub-driven dialog
|
|
48
|
+
bun test --coverage # coverage report
|
|
49
|
+
bun run typecheck # tsc --noEmit
|
|
50
|
+
bun run lint # oxlint
|
|
51
|
+
bun run fmt # oxfmt --write
|
|
52
|
+
bun run fmt:check # oxfmt --check
|
|
53
|
+
bun run knip # unused exports / dependencies
|
|
54
|
+
```
|
package/index.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { createAskUserQuestionDefinition } from './src/tool';
|
|
3
|
+
|
|
4
|
+
export { createAskUserQuestionDefinition };
|
|
5
|
+
|
|
6
|
+
export default function askUserQuestion(pi: ExtensionAPI) {
|
|
7
|
+
pi.registerTool(createAskUserQuestionDefinition());
|
|
8
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@k3_2o/pi-ask-user-question",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Pause execution and ask the user a question: radio options, notes, custom input, timeout auto-select.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ask",
|
|
7
|
+
"interactive",
|
|
8
|
+
"pi",
|
|
9
|
+
"pi-package",
|
|
10
|
+
"question"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"author": "k3-2o",
|
|
14
|
+
"files": [
|
|
15
|
+
"index.ts",
|
|
16
|
+
"src/",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"type": "module",
|
|
21
|
+
"exports": "./index.ts",
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "bun test",
|
|
27
|
+
"typecheck": "bunx tsrs --noEmit",
|
|
28
|
+
"lint": "bunx oxlint",
|
|
29
|
+
"fmt": "bunx oxfmt --write",
|
|
30
|
+
"fmt:check": "bunx oxfmt --check",
|
|
31
|
+
"knip": "bunx knip",
|
|
32
|
+
"prepublishOnly": "bun test && bun run typecheck && bun run lint && bun run fmt:check && bun run knip"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {},
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@earendil-works/pi-coding-agent": "^1.0.0",
|
|
37
|
+
"@earendil-works/pi-tui": "^1.0.0",
|
|
38
|
+
"typebox": "^1.3.36"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"bun": ">=1.2"
|
|
42
|
+
},
|
|
43
|
+
"knip": {
|
|
44
|
+
"project": [
|
|
45
|
+
"src/**/*.ts",
|
|
46
|
+
"test/**/*.ts"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"pi": {
|
|
50
|
+
"extensions": [
|
|
51
|
+
"./index.ts"
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|