pi-ask-user 0.1.1 → 0.2.1
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
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
A Pi package that adds an interactive `ask_user` tool for collecting user decisions during an agent run.
|
|
4
4
|
|
|
5
|
+
## Demo
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
High-quality video: [ask-user-demo.mp4](./media/ask-user-demo.mp4)
|
|
10
|
+
|
|
5
11
|
## Features
|
|
6
12
|
|
|
7
13
|
- Single-select option lists
|
|
@@ -9,6 +15,24 @@ A Pi package that adds an interactive `ask_user` tool for collecting user decisi
|
|
|
9
15
|
- Optional freeform responses
|
|
10
16
|
- Context display support
|
|
11
17
|
- Graceful fallback when interactive UI is unavailable
|
|
18
|
+
- Bundled `ask-user` skill for mandatory decision-gating in high-stakes or ambiguous tasks
|
|
19
|
+
|
|
20
|
+
## Bundled skill: `ask-user`
|
|
21
|
+
|
|
22
|
+
This package now ships a skill at `skills/ask-user/SKILL.md` that nudges/mandates the agent to use `ask_user` when:
|
|
23
|
+
|
|
24
|
+
- architectural trade-offs are high impact
|
|
25
|
+
- requirements are ambiguous or conflicting
|
|
26
|
+
- assumptions would materially change implementation
|
|
27
|
+
|
|
28
|
+
The skill follows a "decision handshake" flow:
|
|
29
|
+
|
|
30
|
+
1. Gather evidence and summarize context
|
|
31
|
+
2. Ask one focused question via `ask_user`
|
|
32
|
+
3. Wait for explicit user choice
|
|
33
|
+
4. Confirm the decision, then proceed
|
|
34
|
+
|
|
35
|
+
See: `skills/ask-user/references/ask-user-skill-extension-spec.md`.
|
|
12
36
|
|
|
13
37
|
## Install
|
|
14
38
|
|
|
@@ -36,28 +60,3 @@ The registered tool name is:
|
|
|
36
60
|
"allowFreeform": true
|
|
37
61
|
}
|
|
38
62
|
```
|
|
39
|
-
|
|
40
|
-
## Local development
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
pi -e ./index.ts
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Release workflow
|
|
47
|
-
|
|
48
|
-
### One-time setup
|
|
49
|
-
|
|
50
|
-
1. Add `NPM_TOKEN` in GitHub repo secrets.
|
|
51
|
-
2. Keep `package.json` version in sync with release tag.
|
|
52
|
-
|
|
53
|
-
### Publish with provenance (recommended)
|
|
54
|
-
|
|
55
|
-
- Create tag: `vX.Y.Z`
|
|
56
|
-
- Create a GitHub Release for that tag
|
|
57
|
-
- The `publish.yml` workflow publishes to npm with `--provenance`
|
|
58
|
-
|
|
59
|
-
You can also trigger the publish workflow manually from GitHub Actions.
|
|
60
|
-
|
|
61
|
-
## License
|
|
62
|
-
|
|
63
|
-
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-ask-user",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Interactive ask_user tool for pi-coding-agent with multi-select and freeform input UI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -28,10 +28,14 @@
|
|
|
28
28
|
"pi": {
|
|
29
29
|
"extensions": [
|
|
30
30
|
"./index.ts"
|
|
31
|
+
],
|
|
32
|
+
"skills": [
|
|
33
|
+
"./skills"
|
|
31
34
|
]
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"index.ts",
|
|
38
|
+
"skills",
|
|
35
39
|
"README.md",
|
|
36
40
|
"LICENSE"
|
|
37
41
|
],
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ask-user
|
|
3
|
+
description: "You MUST use this before high-stakes architectural decisions, irreversible changes, or when requirements are ambiguous. Runs a decision handshake with the ask_user tool: summarize context, present structured options, collect explicit user choice, then proceed."
|
|
4
|
+
metadata:
|
|
5
|
+
short-description: Decision gate for ambiguity and high-stakes choices
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Ask User Decision Gate
|
|
9
|
+
|
|
10
|
+
Use this skill to force explicit user alignment before consequential decisions.
|
|
11
|
+
|
|
12
|
+
This skill is about **decision control**, not general chit-chat.
|
|
13
|
+
|
|
14
|
+
## Non-negotiable rule
|
|
15
|
+
|
|
16
|
+
Invoke `ask_user` before proceeding when **any** of the following is true:
|
|
17
|
+
|
|
18
|
+
1. The next step changes architecture, schema, API contracts, deployment strategy, or security posture.
|
|
19
|
+
2. The work is costly to undo (large refactor, migration, destructive edit, production-facing behavior change).
|
|
20
|
+
3. Requirements, constraints, or success criteria are unclear, conflicting, or missing.
|
|
21
|
+
4. Multiple valid options exist and the trade-off is preference-dependent.
|
|
22
|
+
5. You are about to assume something that can materially change implementation.
|
|
23
|
+
|
|
24
|
+
Do **not** skip this gate unless the user has already provided a clear, explicit decision for the exact trade-off.
|
|
25
|
+
|
|
26
|
+
## Agent Protocol Handshake (required)
|
|
27
|
+
|
|
28
|
+
Follow this handshake in order.
|
|
29
|
+
|
|
30
|
+
### 1) Detect boundary
|
|
31
|
+
Classify the current step as:
|
|
32
|
+
- `high_stakes`
|
|
33
|
+
- `ambiguous`
|
|
34
|
+
- `both`
|
|
35
|
+
- `clear` (no gate needed)
|
|
36
|
+
|
|
37
|
+
If classification is not `clear`, continue.
|
|
38
|
+
|
|
39
|
+
### 2) Gather evidence first
|
|
40
|
+
Before asking, gather context from available tools (`read`, `bash`, `exa`, `ref`, etc.).
|
|
41
|
+
Do not ask the user to decide blind.
|
|
42
|
+
|
|
43
|
+
### 3) Synthesize context
|
|
44
|
+
Prepare a short neutral summary (3-7 bullets or short paragraph) covering:
|
|
45
|
+
- current state
|
|
46
|
+
- key constraints
|
|
47
|
+
- trade-offs
|
|
48
|
+
- recommendation (if any)
|
|
49
|
+
|
|
50
|
+
### 4) Ask one focused question
|
|
51
|
+
Call `ask_user` with one decision at a time:
|
|
52
|
+
- `question`: concrete decision prompt
|
|
53
|
+
- `context`: synthesized summary
|
|
54
|
+
- `options`: 2-5 clear choices when possible
|
|
55
|
+
- `allowMultiple`: `false` unless independent selections are genuinely needed
|
|
56
|
+
- `allowFreeform`: usually `true`
|
|
57
|
+
|
|
58
|
+
### 5) Commit the decision
|
|
59
|
+
After response:
|
|
60
|
+
- restate the decision in plain language
|
|
61
|
+
- state what will be done next
|
|
62
|
+
- proceed with implementation
|
|
63
|
+
|
|
64
|
+
### 6) Re-open only on new ambiguity
|
|
65
|
+
Ask again only if materially new uncertainty appears.
|
|
66
|
+
Avoid repetitive confirmation loops.
|
|
67
|
+
|
|
68
|
+
## Anti-overasking guardrails (required)
|
|
69
|
+
|
|
70
|
+
Apply a strict question budget per decision boundary:
|
|
71
|
+
|
|
72
|
+
- **Max 1** `ask_user` call per decision boundary in normal cases.
|
|
73
|
+
- **Max 2** `ask_user` calls for the same boundary when first response is unclear/cancelled.
|
|
74
|
+
- Never ask the same trade-off again without new evidence.
|
|
75
|
+
|
|
76
|
+
Escalation ladder:
|
|
77
|
+
|
|
78
|
+
1. **Attempt 1:** structured options + concise context.
|
|
79
|
+
2. **Attempt 2 (only if needed):** narrower question with agent recommendation and explicit choices:
|
|
80
|
+
- `Proceed with recommended option`
|
|
81
|
+
- `Choose another option` (freeform)
|
|
82
|
+
- `Stop for now`
|
|
83
|
+
|
|
84
|
+
After attempt 2:
|
|
85
|
+
|
|
86
|
+
- If boundary is `high_stakes` or `both`: **stop and mark blocked**. Do not keep asking.
|
|
87
|
+
- If boundary is `ambiguous` only and user says “your call” or equivalent: proceed with the most reversible default and state assumptions explicitly.
|
|
88
|
+
|
|
89
|
+
## `ask_user` payload quality standard
|
|
90
|
+
|
|
91
|
+
### Question quality
|
|
92
|
+
Use:
|
|
93
|
+
- “Which option should we adopt for X?”
|
|
94
|
+
- “Do you want A (fast) or B (safer) for Y?”
|
|
95
|
+
|
|
96
|
+
Avoid:
|
|
97
|
+
- broad/open prompts with no decision boundary
|
|
98
|
+
- multiple unrelated decisions in one question
|
|
99
|
+
- questions that should be answered by reading code/docs first
|
|
100
|
+
|
|
101
|
+
### Option quality
|
|
102
|
+
Options must be:
|
|
103
|
+
- mutually understandable
|
|
104
|
+
- short and outcome-oriented
|
|
105
|
+
- explicit on trade-offs
|
|
106
|
+
|
|
107
|
+
Good options include a short description when trade-offs are non-obvious.
|
|
108
|
+
|
|
109
|
+
## Recommended patterns
|
|
110
|
+
|
|
111
|
+
### Single-select architecture decision
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"question": "Which caching strategy should we use for the first release?",
|
|
116
|
+
"context": "Current API has p95 latency issues. Redis is fastest but adds infra complexity; in-memory cache is simpler but not shared across instances.",
|
|
117
|
+
"options": [
|
|
118
|
+
{ "title": "In-memory cache", "description": "Simpler rollout, weaker horizontal consistency" },
|
|
119
|
+
{ "title": "Redis cache", "description": "Better consistency and scalability, more ops overhead" }
|
|
120
|
+
],
|
|
121
|
+
"allowMultiple": false,
|
|
122
|
+
"allowFreeform": true
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Multi-select when decisions are independent
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"question": "Select the first-wave hardening items to implement now.",
|
|
131
|
+
"context": "We can ship quickly with baseline controls, then add targeted hardening. Budget is limited to 1-2 days.",
|
|
132
|
+
"options": [
|
|
133
|
+
"Rate limiting",
|
|
134
|
+
"Audit logging",
|
|
135
|
+
"Input schema validation",
|
|
136
|
+
"Secrets rotation"
|
|
137
|
+
],
|
|
138
|
+
"allowMultiple": true,
|
|
139
|
+
"allowFreeform": true
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Anti-patterns
|
|
144
|
+
|
|
145
|
+
- Asking `ask_user` without first gathering context
|
|
146
|
+
- Using it for trivial formatting choices
|
|
147
|
+
- Forcing options when freeform is clearly better
|
|
148
|
+
- Asking the same question repeatedly without new information
|
|
149
|
+
- Proceeding with high-stakes implementation after unclear/cancelled answer
|
|
150
|
+
|
|
151
|
+
## If user cancels or answer is unclear
|
|
152
|
+
|
|
153
|
+
Pause execution and explain what is blocked.
|
|
154
|
+
Use at most one narrower follow-up `ask_user` question (attempt 2).
|
|
155
|
+
After that, do not continue asking in a loop:
|
|
156
|
+
- for high-stakes decisions: remain blocked until explicit decision
|
|
157
|
+
- for ambiguity-only decisions: proceed only if user delegated the choice ("your call")
|
|
158
|
+
|
|
159
|
+
## Additional reference
|
|
160
|
+
|
|
161
|
+
For full trigger matrix, UX conventions, and extension interaction details, read:
|
|
162
|
+
- `references/ask-user-skill-extension-spec.md`
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Ask User Skill × Extension Interaction Spec
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
This document defines a minimal decision-gating protocol for using the `ask-user` skill with the `ask_user` tool.
|
|
6
|
+
|
|
7
|
+
Goal: require explicit user decisions at high-impact or ambiguous boundaries before implementation continues.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## 1) Trigger Matrix (When to Call `ask_user`)
|
|
12
|
+
|
|
13
|
+
| Scenario | Must Ask? | Why |
|
|
14
|
+
|---|---:|---|
|
|
15
|
+
| Architecture trade-off (e.g., queue vs cron, SQL vs KV) | Yes | Preference-sensitive, high blast radius |
|
|
16
|
+
| Data schema / migration path selection | Yes | Costly to reverse |
|
|
17
|
+
| Security/compliance posture trade-off | Yes | Risk ownership is human |
|
|
18
|
+
| Requirements conflict or ambiguity | Yes | Need explicit intent |
|
|
19
|
+
| Non-trivial scope cut/prioritization | Yes | Product decision, not purely technical |
|
|
20
|
+
| Purely local refactor with identical behavior | Usually no | No policy-level decision |
|
|
21
|
+
| Formatting-only edits | No | Trivial |
|
|
22
|
+
| User already gave explicit choice for exact trade-off | No (unless new ambiguity) | Decision already captured |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## 2) Decision Handshake
|
|
27
|
+
|
|
28
|
+
Use this protocol whenever the trigger matrix says to ask.
|
|
29
|
+
|
|
30
|
+
1. **Detect boundary**
|
|
31
|
+
- classify as `high_stakes`, `ambiguous`, `both`, or `clear`
|
|
32
|
+
2. **Gather evidence**
|
|
33
|
+
- read code/docs/logs first; do not ask blindly
|
|
34
|
+
3. **Summarize context**
|
|
35
|
+
- prepare concise trade-off context (3–7 bullets or short paragraph)
|
|
36
|
+
4. **Ask one focused question**
|
|
37
|
+
- call `ask_user` for one decision at a time
|
|
38
|
+
5. **Commit and proceed**
|
|
39
|
+
- restate chosen option and implement accordingly
|
|
40
|
+
|
|
41
|
+
### Retry/cancel policy
|
|
42
|
+
|
|
43
|
+
- Max **2** `ask_user` attempts for the same decision boundary.
|
|
44
|
+
- Attempt 1: normal structured question.
|
|
45
|
+
- Attempt 2: narrower question with recommendation and explicit options.
|
|
46
|
+
- After attempt 2:
|
|
47
|
+
- `high_stakes` / `both`: stop and report blocked.
|
|
48
|
+
- `ambiguous` only: proceed only if user delegates (e.g., “your call”), using the most reversible default.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## 3) Example Payloads
|
|
53
|
+
|
|
54
|
+
### Architecture decision
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"question": "Which implementation path should we use for v1?",
|
|
59
|
+
"context": "Path A is faster to ship but less extensible. Path B takes longer but supports plugin-style growth. Existing deadline is 2 weeks.",
|
|
60
|
+
"options": [
|
|
61
|
+
{ "title": "Path A (ship fast)", "description": "Lowest scope, revisit architecture later" },
|
|
62
|
+
{ "title": "Path B (extensible)", "description": "Higher initial effort, cleaner long-term composition" }
|
|
63
|
+
],
|
|
64
|
+
"allowMultiple": false,
|
|
65
|
+
"allowFreeform": true
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Requirement-priority decision
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"question": "Which requirement should be prioritized first?",
|
|
74
|
+
"context": "Current request mixes performance tuning and UI redesign. Doing both now risks delaying delivery.",
|
|
75
|
+
"options": [
|
|
76
|
+
"Performance first",
|
|
77
|
+
"UI redesign first",
|
|
78
|
+
"Do a minimal pass on both"
|
|
79
|
+
],
|
|
80
|
+
"allowMultiple": false,
|
|
81
|
+
"allowFreeform": true
|
|
82
|
+
}
|
|
83
|
+
```
|