@ftrdotdev/pi-inquiry 0.7.0 → 0.9.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/CHANGELOG.md +268 -0
- package/README.md +24 -4
- package/package.json +18 -16
- package/src/core/domain.test.ts +198 -9
- package/src/core/domain.ts +75 -24
- package/src/core/editor.test.ts +87 -42
- package/src/core/flow.test.ts +22 -3
- package/src/core/flow.ts +7 -3
- package/src/core/keyboard.test.ts +3 -3
- package/src/core/keyboard.ts +1 -1
- package/src/core/machine.test.ts +25 -2
- package/src/core/machine.ts +30 -22
- package/src/core/purity.test.ts +118 -0
- package/src/core/scene.test.ts +75 -20
- package/src/core/scene.ts +78 -42
- package/src/core/services.ts +6 -5
- package/src/core/text.test.ts +44 -15
- package/src/core/text.ts +7 -0
- package/src/harness-policy.test.ts +27 -0
- package/src/sdk/box-parity.test.ts +2 -7
- package/src/sdk/keys.test.ts +24 -1
- package/src/sdk/painter.ts +3 -3
- package/src/sdk/pi-ui.test.ts +56 -12
- package/src/sdk/pi-ui.ts +118 -93
- package/src/sdk/schema.test.ts +31 -1
- package/src/tool/question.test.ts +136 -6
- package/src/tool/question.ts +11 -12
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# @ftrdotdev/pi-inquiry
|
|
2
|
+
|
|
3
|
+
## 0.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9b1fcd6: Standardize the `@effect/tsgo` setup and clear every lint finding.
|
|
8
|
+
|
|
9
|
+
- The toolchain moves to `@effect/tsgo` 0.73.4, `oxlint` 1.94.0, and
|
|
10
|
+
`oxlint-tsgolint` 7.0.2008.
|
|
11
|
+
- The root `tsconfig.json` now carries the compiler options and the
|
|
12
|
+
`@effect/language-service` plugin, and every package extends it. Stricter
|
|
13
|
+
flags join it: `noUnusedLocals`, `noUnusedParameters`, `noImplicitReturns`,
|
|
14
|
+
`noUncheckedSideEffectImports`, and `exactOptionalPropertyTypes`. Effect
|
|
15
|
+
diagnostics come from oxlint alone: the 13 `recommended` errors fail the
|
|
16
|
+
lint run, and the remaining rules report as warnings.
|
|
17
|
+
- `oxlint` is the only owner of the Effect diagnostics. `tsconfig.json` sets
|
|
18
|
+
the language-service plugin's `diagnostics` to `false`, so `tsc` no longer
|
|
19
|
+
repeats what oxlint reports. The root `oxlint.config.ts` extends the Effect
|
|
20
|
+
`style`, `correctness`, `antipattern` and `recommended` presets in that order;
|
|
21
|
+
oxlint finds it by walking up from each package, so the per-package configs
|
|
22
|
+
are gone.
|
|
23
|
+
- `Schema.Class`, `Schema.TaggedClass`, and `Schema.TaggedError` declarations
|
|
24
|
+
now carry the nominal brand type argument. **Type-level breaking change** for
|
|
25
|
+
code that assigned plain object literals to these types; construct them with
|
|
26
|
+
`.make()` or `new`.
|
|
27
|
+
- `@ftrdotdev/pi-inquiry`: `Keyboard`'s `nextKey` is
|
|
28
|
+
`readonly nextKey: Effect.Effect<KeyEvent>` instead of a zero-argument
|
|
29
|
+
method. **Breaking for code that implements `Keyboard["Service"]`**; callers
|
|
30
|
+
drop the `()`.
|
|
31
|
+
- `@ftrdotdev/pi-tui`: new `withStatus` and `withCounts` helpers replace
|
|
32
|
+
class-instance spreads when a status or count record needs one field
|
|
33
|
+
replaced. The config schema now uses `Schema.Finite` where `Schema.Number`
|
|
34
|
+
accepted `NaN` and infinities.
|
|
35
|
+
- `@ftrdotdev/pi-qrspi`: `readGitMetadata` omits unknown frontmatter fields
|
|
36
|
+
instead of setting them to `undefined`.
|
|
37
|
+
|
|
38
|
+
- 32d0e80: Report blocked program status while the `question` tool waits for an answer.
|
|
39
|
+
|
|
40
|
+
The tool now passes `blocked: { kind: "question", message }` to
|
|
41
|
+
`ctx.ui.custom()`. Terminals and dashboards that support the Program Status
|
|
42
|
+
Protocol (OSC 7501) show pi as blocked instead of working. The message is
|
|
43
|
+
fixed text: `Answer the question` for one question and `Answer N questions`
|
|
44
|
+
for several. It never contains the question prompt or other model output.
|
|
45
|
+
|
|
46
|
+
Requires pi 1.5.0 or newer, the first release with the `blocked` option.
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- 891568b: Ship `CHANGELOG.md` in the package tarballs.
|
|
51
|
+
|
|
52
|
+
- Pi reads a package changelog after an update and lists the new entries under
|
|
53
|
+
"Extension Updates" on the next fresh launch. It reads the file from the
|
|
54
|
+
installed package.
|
|
55
|
+
- The `files` whitelist in each `package.json` left the changelog out, so the
|
|
56
|
+
published tarballs carried no release notes.
|
|
57
|
+
- The README release section now records the requirement.
|
|
58
|
+
|
|
59
|
+
- 81c4a61: Move the Pi packages to `1.5.0` and build tool parameter schemas with
|
|
60
|
+
`@earendil-works/pi-schema`.
|
|
61
|
+
|
|
62
|
+
- `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, and
|
|
63
|
+
`@earendil-works/pi-tui` move from `1.4.0` to `1.5.0`. Pi 1.5.0 validates
|
|
64
|
+
tool arguments with `@earendil-works/pi-schema`.
|
|
65
|
+
- `pi-tracker` and `pi-tui` build `parameters` with pi-schema builders and
|
|
66
|
+
derive the parameter types from pi-schema's `Static`. The `typebox` peer
|
|
67
|
+
dependency is removed.
|
|
68
|
+
- `pi-inquiry` drops its TypeBox type import. Its Effect-generated JSON Schema
|
|
69
|
+
passes to Pi unchanged.
|
|
70
|
+
- Tool validation errors now use pi-schema messages, such as
|
|
71
|
+
`recommended: expected boolean, got string`.
|
|
72
|
+
|
|
73
|
+
- f8094f4: Show the interface in each package README, and point `homepage` at that package
|
|
74
|
+
README instead of the monorepo root.
|
|
75
|
+
- 305cdb7: Move the tui session state behind Effect services and one composition layer.
|
|
76
|
+
|
|
77
|
+
- Add `SessionLifecycleService`, `ActivityService`, `TurnTelemetryService`,
|
|
78
|
+
`UsageTotalsService` and `RuntimeInfoService`. The chrome port builder, the
|
|
79
|
+
extension entry and the tracker widget read them instead of module-level
|
|
80
|
+
cells, so a session start resets every store from one counter.
|
|
81
|
+
- Build the per-program graph in `src/layers.ts`. The runtime probe goes through
|
|
82
|
+
`FileSystem`, `Path` and `ChildProcessSpawner`, with the home directory and a
|
|
83
|
+
live environment read injected at the entry point.
|
|
84
|
+
- Compose the tracker's tool graph in `makeTrackerRuntime`, leaving `src/index.ts`
|
|
85
|
+
as the bridge that injects `appendEntry`.
|
|
86
|
+
- Guard the inquiry core: no `@earendil-works`, `@effect/platform` or `node:`
|
|
87
|
+
import outside the box-frame carve-out, and no `Layer` construction.
|
|
88
|
+
|
|
89
|
+
Rendered output is unchanged: the frozen footer and header frames stay
|
|
90
|
+
byte-identical at 30/40/60/80/100/120.
|
|
91
|
+
|
|
92
|
+
- Updated dependencies [891568b]
|
|
93
|
+
- Updated dependencies [9b1fcd6]
|
|
94
|
+
- Updated dependencies [eeb018a]
|
|
95
|
+
- Updated dependencies [81c4a61]
|
|
96
|
+
- Updated dependencies [f8094f4]
|
|
97
|
+
- Updated dependencies [305cdb7]
|
|
98
|
+
- Updated dependencies [36e53c0]
|
|
99
|
+
- @ftrdotdev/pi-tui@0.9.0
|
|
100
|
+
|
|
101
|
+
## 0.8.0
|
|
102
|
+
|
|
103
|
+
### Minor Changes
|
|
104
|
+
|
|
105
|
+
- 9e0dd29: Add an optional per-option `recommended` flag to the `question` tool. The tool
|
|
106
|
+
shows a `✓` marker in a reserved column left of the option label.
|
|
107
|
+
|
|
108
|
+
- `options[].recommended` (default `false`) marks the option the model suggests.
|
|
109
|
+
On a multi-select question (`multiple: true`), the model can recommend any
|
|
110
|
+
number of options. On a single-choice question, the tool rejects two or more
|
|
111
|
+
recommendations as invalid parameters. The tool does not trim the
|
|
112
|
+
recommendations.
|
|
113
|
+
- This release changes the layout. Every option-block row now reserves a two-cell
|
|
114
|
+
marker column. Option labels, the multi-select checkbox, and the
|
|
115
|
+
"Add your own answer" row move two columns right. Option descriptions and the
|
|
116
|
+
"Current answer" subtitle move two columns right too. Their offset from the
|
|
117
|
+
label is unchanged.
|
|
118
|
+
- The tool description, the `recommended` field description, and the five prompt
|
|
119
|
+
guidelines use short imperative sentences. The model reads the same rules and
|
|
120
|
+
defaults as before.
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- c294fe5: Bump the Effect packages to `4.1.1`, `@effect/tsgo` to `0.63.0`, `vitest` to
|
|
125
|
+
`5.0.5`, and the Pi packages to `1.4.0`.
|
|
126
|
+
|
|
127
|
+
- `effect`, `@effect/platform-node`, `@effect/platform-node-shared`, and
|
|
128
|
+
`@effect/vitest` move from `4.0.0` to `4.1.1`; `@effect/tsgo` moves from
|
|
129
|
+
`0.47.2` to `0.63.0`.
|
|
130
|
+
- `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, and
|
|
131
|
+
`@earendil-works/pi-tui` move from `1.1.0` to `1.4.0`. No extension API
|
|
132
|
+
changes were needed.
|
|
133
|
+
- `vitest` moves from the 4.1 line to `5.0.5`, the range that
|
|
134
|
+
`@effect/vitest` declares as its peer. `oxlint` moves to `1.90.0` and
|
|
135
|
+
`oxlint-tsgolint` to `7.0.2005`, the pair that `@effect/tsgo` 0.63.0 supports.
|
|
136
|
+
- Effect 4.1.1 marks `effect/FileSystem`, `effect/Path`, `effect/PlatformError`,
|
|
137
|
+
`effect/Graph`, `@effect/platform-node*`, and `@effect/vitest` as unstable.
|
|
138
|
+
Each package `tsconfig.json` now lists them in the language-service plugin
|
|
139
|
+
option `allowedUnstableApis`, so typecheck stays green without per-file
|
|
140
|
+
`@effect-diagnostics` directives.
|
|
141
|
+
- The internal `TuiConfig` schema in `pi-tui` is now a `Schema.Struct` with a type
|
|
142
|
+
alias instead of a `Schema.Class`. The class was only ever used as plain data,
|
|
143
|
+
and the 4.1.1 `schemaClassObjectLiteral` rule flagged every literal and spread.
|
|
144
|
+
`TuiConfig` is not part of the package exports, so no consumer code changes.
|
|
145
|
+
|
|
146
|
+
- Updated dependencies [c294fe5]
|
|
147
|
+
- @ftrdotdev/pi-tui@0.8.0
|
|
148
|
+
|
|
149
|
+
## 0.7.0
|
|
150
|
+
|
|
151
|
+
### Patch Changes
|
|
152
|
+
|
|
153
|
+
- Updated dependencies [edb419d]
|
|
154
|
+
- Updated dependencies [f4213db]
|
|
155
|
+
- @ftrdotdev/pi-tui@0.7.0
|
|
156
|
+
|
|
157
|
+
## 0.6.0
|
|
158
|
+
|
|
159
|
+
### Minor Changes
|
|
160
|
+
|
|
161
|
+
- 3803293: Add mouse-wheel navigation, clipboard copy, and new theme helpers.
|
|
162
|
+
|
|
163
|
+
- The footer lists every runtime that matches the working directory, in table order, and joins them with a dim `·`. Previously it showed the first match only. An empty result stays an empty segment.
|
|
164
|
+
- The editor's top border shows pi's working status indicator during a run: spinner and message when they fit, spinner alone on narrow widths. The mode glyph and the scroll hint move behind it in the label slot.
|
|
165
|
+
- `makeBorderedBox` takes a theme background token for `bg` instead of a caller-supplied function. Pass `"customMessageBg"` where the code passed `(s) => theme.bg("customMessageBg", s)`. The border, the embedded label, and the body now paint the same background.
|
|
166
|
+
- `@ftrdotdev/pi-tui` exports derived theme colors: `mixThemeTokens`, `recede`, `emphasize`, and `isDark`. Use them for shades that are not theme tokens, such as a dimmed border or a selected row. `recede` and `emphasize` follow `theme.appearance`, so a light theme needs no special case.
|
|
167
|
+
- The `/tracker` overlay moves the cursor with the mouse wheel and wraps at either end. `[c]` copies the selected list or item and reports `Copied ...` in the overlay.
|
|
168
|
+
- The selected row in the `/tracker` overlay uses the `selectedBg` token.
|
|
169
|
+
- The inquiry questionnaire moves the cursor with the mouse wheel and copies the open question and its options with `ctrl+y`.
|
|
170
|
+
- The header clears the visible screen once per process, on the first regular-mode mount, and never again. Fullscreen owns the alternate screen, where the clear only flickered. A re-mount (`reload`, `new`, `fork`, `/resume`, settings toggle) no longer clears: that write went outside pi-tui and desynced its differential redraw, which left the space for an extension widget blank until the next full repaint.
|
|
171
|
+
|
|
172
|
+
### Patch Changes
|
|
173
|
+
|
|
174
|
+
- Updated dependencies [3803293]
|
|
175
|
+
- Updated dependencies [6876f36]
|
|
176
|
+
- @ftrdotdev/pi-tui@0.6.0
|
|
177
|
+
|
|
178
|
+
## 0.5.2
|
|
179
|
+
|
|
180
|
+
### Patch Changes
|
|
181
|
+
|
|
182
|
+
- a860f5b: Move the Effect packages to the stable `4.0.0` release and the Pi packages to `1.0.0`.
|
|
183
|
+
|
|
184
|
+
- Bump `effect`, `@effect/platform-node`, `@effect/platform-node-shared`, and `@effect/vitest` to `4.0.0`, and `@effect/tsgo` to `0.47.2`.
|
|
185
|
+
- Bump `@earendil-works/pi-ai`, `@earendil-works/pi-coding-agent`, and `@earendil-works/pi-tui` to `1.0.0`.
|
|
186
|
+
- Follow the rc.118 module move: `effect/unstable/process` becomes `effect/process`.
|
|
187
|
+
- Follow the Pi 0.99.0 tool API: tool execution contexts are now `ExtensionToolContext`.
|
|
188
|
+
- `pi-inquiry` gains a `typecheck` script; its two latent type errors are fixed.
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [a860f5b]
|
|
191
|
+
- @ftrdotdev/pi-tui@0.5.2
|
|
192
|
+
|
|
193
|
+
## 0.5.1
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- 4e101f0: Pin `@effect/platform-node-shared` and move the Effect packages to `4.0.0-rc.116`.
|
|
198
|
+
|
|
199
|
+
The 0.5.0 packages pinned `effect` and `@effect/platform-node` to `4.0.0-rc.108`. `@effect/platform-node` depends on `@effect/platform-node-shared` with a caret range. Every `4.0.0-rc.*` release shares the `4.0.0` base, so that range resolved to a newer `@effect/platform-node-shared` that imports `effect/ByteSize`. The pinned `effect` has no `ByteSize` module, so loading an extension failed with `Cannot find module '.../effect/dist/ByteSize.js'`.
|
|
200
|
+
|
|
201
|
+
- Move `effect`, `@effect/platform-node`, and `@effect/vitest` to `4.0.0-rc.116`.
|
|
202
|
+
- Add `@effect/platform-node-shared` to the `effect` catalog at an exact version, and depend on it directly from `pi-tui` and `pi-tracker`. This stops the transitive range from floating to a release that needs a newer `effect`.
|
|
203
|
+
|
|
204
|
+
- Updated dependencies [4e101f0]
|
|
205
|
+
- @ftrdotdev/pi-tui@0.5.1
|
|
206
|
+
|
|
207
|
+
## 0.5.0
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- @ftrdotdev/pi-tui@0.5.0
|
|
212
|
+
|
|
213
|
+
## 0.4.0
|
|
214
|
+
|
|
215
|
+
### Patch Changes
|
|
216
|
+
|
|
217
|
+
- Fix terminal-width crashes from emoji and strip model marker emoji from question text.
|
|
218
|
+
|
|
219
|
+
- Measure visible widths per grapheme with pi-tui's emoji rule (`RGI_Emoji`, flags, CJK fallback). The old per-code-point table counted `➡️` (U+27A1 + VS16) as one column while pi's crash guard counts two, so a model-written prompt continuation that exactly filled a line overflowed by one column and pi exited hard ("Rendered line exceeds terminal width"). Widths, truncation, and wrapping now match pi-tui's `visibleWidth` exactly.
|
|
220
|
+
- Strip leading marker emoji (`❓`, `➡️`, `⚠️`, …) from question prompts, labels, and option labels/descriptions: the UI already provides selection affordances, so the markers are pure noise (`❓ Q7 — …` renders as `Q7 — …`). Bare text-presentation glyphs (`→`, `•`, `✔`) are left alone.
|
|
221
|
+
- Clamp framed body rows to the content width so a future measurement mismatch can never push a rail past the terminal again.
|
|
222
|
+
|
|
223
|
+
- 483f6f4: Tighten the agent-facing tool guidance.
|
|
224
|
+
|
|
225
|
+
- Rewrite the `question` tool description and prompt guidelines: split long sentences, use the imperative, and make the "cancelled question" guidance concrete.
|
|
226
|
+
- Update the `tracker` tool description so the working-state claim is concrete instead of "live".
|
|
227
|
+
|
|
228
|
+
- Updated dependencies [c89b1a6]
|
|
229
|
+
- Updated dependencies [2d3c636]
|
|
230
|
+
- Updated dependencies [a113d38]
|
|
231
|
+
- @ftrdotdev/pi-tui@0.4.0
|
|
232
|
+
|
|
233
|
+
## 0.3.0
|
|
234
|
+
|
|
235
|
+
### Minor Changes
|
|
236
|
+
|
|
237
|
+
- Add multi-select questions so one question can collect several answers.
|
|
238
|
+
|
|
239
|
+
- New `multiple` question parameter (default `false`). When `true` the
|
|
240
|
+
question renders as checkboxes and the user picks several options: Space
|
|
241
|
+
toggles a box on or off, Enter confirms the selection and moves on.
|
|
242
|
+
- `allowOther` still applies to multi-select questions: the user can add
|
|
243
|
+
custom alternatives one at a time through the "Add your own answer" entry.
|
|
244
|
+
- A multi-select question contributes one `Answer` per chosen option or typed
|
|
245
|
+
alternative in the result, all sharing the question's `id`; the tool groups
|
|
246
|
+
them together in its output.
|
|
247
|
+
|
|
248
|
+
### Patch Changes
|
|
249
|
+
|
|
250
|
+
- @ftrdotdev/pi-tui@0.3.0
|
|
251
|
+
|
|
252
|
+
## 0.2.1
|
|
253
|
+
|
|
254
|
+
### Patch Changes
|
|
255
|
+
|
|
256
|
+
- Updated dependencies
|
|
257
|
+
- @ftrdotdev/pi-tui@0.2.1
|
|
258
|
+
|
|
259
|
+
## 0.2.0
|
|
260
|
+
|
|
261
|
+
### Minor Changes
|
|
262
|
+
|
|
263
|
+
- fe0ac01: Solidify initial tooling, visuals, and configurability between packages
|
|
264
|
+
|
|
265
|
+
### Patch Changes
|
|
266
|
+
|
|
267
|
+
- Updated dependencies [fe0ac01]
|
|
268
|
+
- @ftrdotdev/pi-tui@0.2.0
|
package/README.md
CHANGED
|
@@ -8,6 +8,11 @@ so the user can type a custom answer when the listed options do not fit.
|
|
|
8
8
|
|
|
9
9
|
Package: `@ftrdotdev/pi-inquiry` · [MIT](LICENSE)
|
|
10
10
|
|
|
11
|
+
<img src="https://raw.githubusercontent.com/felixnorden/pi-mono/main/docs/images/pi-inquiry.png" width="880" alt="A question prompt in a pi session: the question text, three numbered options with the first marked recommended and selected, each with a one-line description, and the keys line below">
|
|
12
|
+
|
|
13
|
+
The `question` tool in a live session: numbered options, a description per
|
|
14
|
+
option, the recommended option marked, and the free-text path one key away.
|
|
15
|
+
|
|
11
16
|
## What it is
|
|
12
17
|
|
|
13
18
|
`inquiry` is a pi extension. It is a package named `@ftrdotdev/pi-inquiry` and
|
|
@@ -21,7 +26,9 @@ plain text — the model guidance is contributed through `promptSnippet` and
|
|
|
21
26
|
and how to present questions.
|
|
22
27
|
|
|
23
28
|
The tool renders in pi's TUI. Outside TUI mode it returns an error instead of
|
|
24
|
-
showing a question.
|
|
29
|
+
showing a question. While the questionnaire waits, it reports blocked program
|
|
30
|
+
status (OSC 7501), so supporting terminals and dashboards show pi as waiting
|
|
31
|
+
for an answer. This needs pi 1.5.0 or newer.
|
|
25
32
|
|
|
26
33
|
## Installation
|
|
27
34
|
|
|
@@ -71,7 +78,13 @@ pick between options, or confirm a decision. Ask all open questions in one
|
|
|
71
78
|
"questions": [
|
|
72
79
|
{
|
|
73
80
|
"prompt": "The full question text to display",
|
|
74
|
-
"options": [
|
|
81
|
+
"options": [
|
|
82
|
+
{
|
|
83
|
+
"label": "Short label",
|
|
84
|
+
"description": "Optional one-line description",
|
|
85
|
+
"recommended": true // the UI shows ✓ beside the option. Defaults to false.
|
|
86
|
+
}
|
|
87
|
+
],
|
|
75
88
|
"id": "optional-unique-id", // defaults to q1, q2, ...
|
|
76
89
|
"label": "Scope", // short tab-bar label, defaults to Q1, Q2
|
|
77
90
|
"allowOther": true, // defaults to true; false forces the listed options
|
|
@@ -83,8 +96,13 @@ pick between options, or confirm a decision. Ask all open questions in one
|
|
|
83
96
|
|
|
84
97
|
- `questions` — one or more questions. A single question shows a simple
|
|
85
98
|
option list; multiple questions show a tabbed interface with a submit tab.
|
|
86
|
-
- `options` — 2–5
|
|
87
|
-
one-line `description
|
|
99
|
+
- `options` — 2–5 options per question, each a `label`, an optional
|
|
100
|
+
one-line `description`, and an optional `recommended` flag.
|
|
101
|
+
- `recommended` — set this flag to `true` on the option you recommend to the user.
|
|
102
|
+
The UI shows `✓` in a two-cell marker column left of the label. The flag defaults
|
|
103
|
+
to `false`. On a single-choice question, recommend at most one option. The tool
|
|
104
|
+
rejects two or more recommendations as invalid parameters. On a multi-select
|
|
105
|
+
question, recommend any number of options.
|
|
88
106
|
- `allowOther` — when `true` (default), the user can also type a free-text
|
|
89
107
|
answer ("Type something."). Set it to `false` only when one of the listed
|
|
90
108
|
options is required.
|
|
@@ -105,6 +123,8 @@ the type mode (Space does too). In the result, a multi-select question
|
|
|
105
123
|
contributes one `Answer` per chosen option or typed alternative, all sharing
|
|
106
124
|
the question's `id`.
|
|
107
125
|
|
|
126
|
+
On a multi-select question, recommend any number of options with `recommended: true`.
|
|
127
|
+
|
|
108
128
|
### Result
|
|
109
129
|
|
|
110
130
|
The tool returns its answers both as human-readable content and in
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ftrdotdev/pi-inquiry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Interactive questions for the pi coding agent: a single `question` tool renders option lists, tabbed forms, and free-text answers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"question",
|
|
13
13
|
"tui"
|
|
14
14
|
],
|
|
15
|
-
"homepage": "https://github.com/felixnorden/pi-mono
|
|
15
|
+
"homepage": "https://github.com/felixnorden/pi-mono/blob/main/packages/inquiry/README.md",
|
|
16
16
|
"bugs": {
|
|
17
17
|
"url": "https://github.com/felixnorden/pi-mono/issues"
|
|
18
18
|
},
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"directory": "packages/inquiry"
|
|
25
25
|
},
|
|
26
26
|
"files": [
|
|
27
|
+
"CHANGELOG.md",
|
|
27
28
|
"index.ts",
|
|
28
29
|
"src",
|
|
29
30
|
"README.md",
|
|
@@ -37,29 +38,30 @@
|
|
|
37
38
|
"test": "vitest run",
|
|
38
39
|
"test:watch": "vitest",
|
|
39
40
|
"typecheck": "tsc --noEmit",
|
|
40
|
-
"lint": "oxlint
|
|
41
|
+
"lint": "oxlint",
|
|
41
42
|
"lint:fix": "oxlint --fix",
|
|
42
|
-
"fmt": "oxfmt"
|
|
43
|
+
"fmt": "oxfmt",
|
|
44
|
+
"fmt:check": "oxfmt --check"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@ftrdotdev/pi-tui": "^0.
|
|
46
|
-
"effect": "4.
|
|
47
|
+
"@ftrdotdev/pi-tui": "^0.9.0",
|
|
48
|
+
"effect": "4.1.5"
|
|
47
49
|
},
|
|
48
50
|
"devDependencies": {
|
|
49
|
-
"@earendil-works/pi-ai": "1.
|
|
50
|
-
"@effect/tsgo": "0.
|
|
51
|
-
"@effect/vitest": "4.
|
|
51
|
+
"@earendil-works/pi-ai": "1.6.0",
|
|
52
|
+
"@effect/tsgo": "0.73.4",
|
|
53
|
+
"@effect/vitest": "4.1.5",
|
|
54
|
+
"@ftrdotdev/pi-test-kit": "0.0.0",
|
|
52
55
|
"@types/bun": "latest",
|
|
53
|
-
"oxfmt": "
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
56
|
+
"oxfmt": "0.80.0",
|
|
57
|
+
"oxlint": "1.94.0",
|
|
58
|
+
"oxlint-tsgolint": "7.0.2008",
|
|
56
59
|
"typescript": "7.0.2",
|
|
57
|
-
"vitest": "^
|
|
60
|
+
"vitest": "^5.1.0"
|
|
58
61
|
},
|
|
59
62
|
"peerDependencies": {
|
|
60
|
-
"@earendil-works/pi-coding-agent": "
|
|
61
|
-
"@earendil-works/pi-tui": "*"
|
|
62
|
-
"typebox": "*"
|
|
63
|
+
"@earendil-works/pi-coding-agent": ">=1.5.0",
|
|
64
|
+
"@earendil-works/pi-tui": "*"
|
|
63
65
|
},
|
|
64
66
|
"pi": {
|
|
65
67
|
"extensions": [
|
package/src/core/domain.test.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
1
|
+
import { assert, describe, expect, it } from "@effect/vitest";
|
|
2
|
+
import { PROPERTY_RUNS } from "@ftrdotdev/pi-test-kit";
|
|
2
3
|
import { Schema } from "effect";
|
|
4
|
+
import { questionParamsArbitrary } from "../../test-support/generators.ts";
|
|
3
5
|
import {
|
|
6
|
+
Option,
|
|
4
7
|
QuestionListParamsJsonSchema,
|
|
5
8
|
decodeParams,
|
|
6
9
|
normalizeQuestions,
|
|
@@ -8,6 +11,16 @@ import {
|
|
|
8
11
|
} from "./domain.ts";
|
|
9
12
|
|
|
10
13
|
describe("decodeParams", () => {
|
|
14
|
+
/** Message of the `SchemaError` the decoder throws, for wording pins. */
|
|
15
|
+
const decodeError = (input: unknown): string => {
|
|
16
|
+
try {
|
|
17
|
+
decodeParams(input);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return (error as Error).message;
|
|
20
|
+
}
|
|
21
|
+
throw new Error("expected decodeParams to throw");
|
|
22
|
+
};
|
|
23
|
+
|
|
11
24
|
it("decodes valid params", () => {
|
|
12
25
|
const params = decodeParams({
|
|
13
26
|
questions: [{ prompt: "Pick one?", options: [{ label: "Yes" }] }],
|
|
@@ -36,6 +49,15 @@ describe("decodeParams", () => {
|
|
|
36
49
|
expect(params.questions[0]?.options[0]?.description).toBe("Go ahead");
|
|
37
50
|
});
|
|
38
51
|
|
|
52
|
+
it("decodes the optional recommended flag on an option", () => {
|
|
53
|
+
const params = decodeParams({
|
|
54
|
+
questions: [{ prompt: "p", options: [{ label: "a", recommended: true }, { label: "b" }] }],
|
|
55
|
+
});
|
|
56
|
+
const options = params.questions[0]?.options as readonly { recommended?: boolean }[];
|
|
57
|
+
expect(options[0]?.recommended).toBe(true);
|
|
58
|
+
expect(options[1]?.recommended).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
|
|
39
61
|
it("rejects invalid input with a SchemaError", () => {
|
|
40
62
|
expect(() => decodeParams({ questions: [{ prompt: "p", options: [{ label: 42 }] }] })).toThrow(
|
|
41
63
|
Schema.SchemaError,
|
|
@@ -52,6 +74,106 @@ describe("decodeParams", () => {
|
|
|
52
74
|
});
|
|
53
75
|
expect(params.questions[0]?.options[0]?.label).toBe("Yes");
|
|
54
76
|
});
|
|
77
|
+
|
|
78
|
+
it("rejects two recommendations when multiple is absent", () => {
|
|
79
|
+
const params = {
|
|
80
|
+
questions: [
|
|
81
|
+
{
|
|
82
|
+
label: "Scope",
|
|
83
|
+
prompt: "p",
|
|
84
|
+
options: [
|
|
85
|
+
{ label: "a", recommended: true },
|
|
86
|
+
{ label: "b", recommended: true },
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
};
|
|
91
|
+
expect(() => decodeParams(params)).toThrow(Schema.SchemaError);
|
|
92
|
+
const message = decodeError(params);
|
|
93
|
+
expect(message).toContain('question "Scope" is single-choice but has 2 recommended options');
|
|
94
|
+
expect(message).toContain("keep at most one recommended option, or set multiple: true");
|
|
95
|
+
expect(message).toContain('at ["questions"][0]["options"][1]');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it("rejects two recommendations when multiple is false", () => {
|
|
99
|
+
const params = {
|
|
100
|
+
questions: [
|
|
101
|
+
{
|
|
102
|
+
label: "Scope",
|
|
103
|
+
prompt: "p",
|
|
104
|
+
multiple: false,
|
|
105
|
+
options: [
|
|
106
|
+
{ label: "a", recommended: true },
|
|
107
|
+
{ label: "b", recommended: true },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
};
|
|
112
|
+
expect(() => decodeParams(params)).toThrow(Schema.SchemaError);
|
|
113
|
+
expect(decodeError(params)).toContain('at ["questions"][0]["options"][1]');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("counts three recommendations", () => {
|
|
117
|
+
const params = {
|
|
118
|
+
questions: [
|
|
119
|
+
{
|
|
120
|
+
prompt: "p",
|
|
121
|
+
options: [
|
|
122
|
+
{ label: "a", recommended: true },
|
|
123
|
+
{ label: "b", recommended: true },
|
|
124
|
+
{ label: "c", recommended: true },
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
const message = decodeError(params);
|
|
130
|
+
expect(message).toContain("has 3 recommended options");
|
|
131
|
+
expect(message.startsWith("this question is single-choice")).toBe(true);
|
|
132
|
+
expect(message).toContain('at ["questions"][0]["options"][1]');
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("names the second question's pointer when it is invalid", () => {
|
|
136
|
+
const params = {
|
|
137
|
+
questions: [
|
|
138
|
+
{ prompt: "ok", options: [{ label: "a", recommended: true }] },
|
|
139
|
+
{
|
|
140
|
+
prompt: "bad",
|
|
141
|
+
options: [
|
|
142
|
+
{ label: "b", recommended: true },
|
|
143
|
+
{ label: "c", recommended: true },
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
};
|
|
148
|
+
expect(decodeError(params)).toContain('at ["questions"][1]["options"][1]');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("accepts two recommendations when multiple is true", () => {
|
|
152
|
+
const params = decodeParams({
|
|
153
|
+
questions: [
|
|
154
|
+
{
|
|
155
|
+
prompt: "p",
|
|
156
|
+
multiple: true,
|
|
157
|
+
options: [
|
|
158
|
+
{ label: "a", recommended: true },
|
|
159
|
+
{ label: "b", recommended: true },
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
],
|
|
163
|
+
});
|
|
164
|
+
expect(params.questions[0]?.options.map((o) => o.recommended)).toEqual([true, true]);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("rejects a legacy-shaped call with two recommendations", () => {
|
|
168
|
+
const prepared = prepareQuestionArgs({
|
|
169
|
+
question: "Pick one?",
|
|
170
|
+
options: [
|
|
171
|
+
{ label: "a", recommended: true },
|
|
172
|
+
{ label: "b", recommended: true },
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
expect(decodeError(prepared)).toContain('at ["questions"][0]["options"][1]');
|
|
176
|
+
});
|
|
55
177
|
});
|
|
56
178
|
|
|
57
179
|
describe("prepareQuestionArgs", () => {
|
|
@@ -94,6 +216,19 @@ describe("QuestionListParamsJsonSchema", () => {
|
|
|
94
216
|
const option = question.properties.options.items;
|
|
95
217
|
expect(option.additionalProperties).toBe(true);
|
|
96
218
|
expect(option.required).toEqual(["label"]);
|
|
219
|
+
expect(Object.keys(option.properties)).toEqual(["label", "description", "recommended"]);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it("does not project the recommendation rule", () => {
|
|
223
|
+
const question = schema.properties.questions.items;
|
|
224
|
+
const option = question.properties.options.items;
|
|
225
|
+
expect(option.required).toEqual(["label"]);
|
|
226
|
+
expect(option.additionalProperties).toBe(true);
|
|
227
|
+
for (const node of [option, question]) {
|
|
228
|
+
for (const artifact of ["allOf", "anyOf", "oneOf", "not", "minItems"]) {
|
|
229
|
+
expect(node).not.toHaveProperty(artifact);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
97
232
|
});
|
|
98
233
|
|
|
99
234
|
it("carries the field descriptions the LLM sees", () => {
|
|
@@ -106,6 +241,11 @@ describe("QuestionListParamsJsonSchema", () => {
|
|
|
106
241
|
expect(q.label.description).toContain("Short contextual label for tab bar");
|
|
107
242
|
expect(q.allowOther.description).toContain("default: true");
|
|
108
243
|
expect(q.options.items.properties.label.description).toBe("Display label for the option");
|
|
244
|
+
expect(q.options.items.properties.recommended).toEqual({
|
|
245
|
+
type: "boolean",
|
|
246
|
+
description:
|
|
247
|
+
"Recommend this option to the user (default: false). On a single-choice question, recommend at most one option. Set multiple: true to recommend more than one option.",
|
|
248
|
+
});
|
|
109
249
|
});
|
|
110
250
|
});
|
|
111
251
|
|
|
@@ -161,14 +301,6 @@ describe("normalizeQuestions", () => {
|
|
|
161
301
|
expect(questions[0]?.multiple).toBe(false);
|
|
162
302
|
});
|
|
163
303
|
|
|
164
|
-
it("maps option labels and descriptions", () => {
|
|
165
|
-
const questions = normalizeQuestions(
|
|
166
|
-
decodeParams({ questions: [{ prompt: "p", options: [{ label: "a", description: "d" }] }] }),
|
|
167
|
-
);
|
|
168
|
-
expect(questions[0]?.options[0]?.label).toBe("a");
|
|
169
|
-
expect(questions[0]?.options[0]?.description).toBe("d");
|
|
170
|
-
});
|
|
171
|
-
|
|
172
304
|
it("strips leading marker emoji from prompt, label and options", () => {
|
|
173
305
|
const questions = normalizeQuestions(
|
|
174
306
|
decodeParams({
|
|
@@ -202,6 +334,26 @@ describe("normalizeQuestions", () => {
|
|
|
202
334
|
expect(q.options[1]?.label).toBe("One-shot warning log");
|
|
203
335
|
});
|
|
204
336
|
|
|
337
|
+
it("collapses the wire recommendation to a concrete boolean", () => {
|
|
338
|
+
const questions = normalizeQuestions(
|
|
339
|
+
decodeParams({
|
|
340
|
+
questions: [{ prompt: "p", options: [{ label: "a", recommended: true }, { label: "b" }] }],
|
|
341
|
+
}),
|
|
342
|
+
);
|
|
343
|
+
expect(questions[0]?.options[0]?.recommended).toBe(true);
|
|
344
|
+
expect(questions[0]?.options[1]?.recommended).toBe(false);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("strips label emoji without touching the recommendation", () => {
|
|
348
|
+
const questions = normalizeQuestions(
|
|
349
|
+
decodeParams({
|
|
350
|
+
questions: [{ prompt: "p", options: [{ label: "✅ Document-only", recommended: true }] }],
|
|
351
|
+
}),
|
|
352
|
+
);
|
|
353
|
+
expect(questions[0]?.options[0]?.label).toBe("Document-only");
|
|
354
|
+
expect(questions[0]?.options[0]?.recommended).toBe(true);
|
|
355
|
+
});
|
|
356
|
+
|
|
205
357
|
it("drops option descriptions that strip to empty", () => {
|
|
206
358
|
const questions = normalizeQuestions(
|
|
207
359
|
decodeParams({ questions: [{ prompt: "p", options: [{ label: "a", description: "➡️" }] }] }),
|
|
@@ -209,3 +361,40 @@ describe("normalizeQuestions", () => {
|
|
|
209
361
|
expect(questions[0]?.options[0]?.description).toBeUndefined();
|
|
210
362
|
});
|
|
211
363
|
});
|
|
364
|
+
|
|
365
|
+
describe("Option", () => {
|
|
366
|
+
it("defaults recommended to false when constructed without it", () => {
|
|
367
|
+
expect(Option.make({ label: "Yes" }).recommended).toBe(false);
|
|
368
|
+
expect(Option.make({ label: "Yes", recommended: true }).recommended).toBe(true);
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
it.prop(
|
|
373
|
+
"normalization preserves each question's id and options",
|
|
374
|
+
{ params: questionParamsArbitrary },
|
|
375
|
+
({ params }) => {
|
|
376
|
+
const normalized = normalizeQuestions(decodeParams(params));
|
|
377
|
+
assert.strictEqual(normalized.length, params.questions.length);
|
|
378
|
+
params.questions.forEach((wire, index) => {
|
|
379
|
+
const question = normalized[index]!;
|
|
380
|
+
assert.strictEqual(question.id, wire.id ?? `q${index + 1}`);
|
|
381
|
+
assert.deepStrictEqual(
|
|
382
|
+
question.options.map((option) => [option.label, option.description]),
|
|
383
|
+
wire.options.map((option) => [option.label, option.description]),
|
|
384
|
+
);
|
|
385
|
+
});
|
|
386
|
+
},
|
|
387
|
+
{ arbitrary: { runs: PROPERTY_RUNS } },
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
it.prop(
|
|
391
|
+
"normalization keeps at most one recommendation per single-choice question",
|
|
392
|
+
{ params: questionParamsArbitrary },
|
|
393
|
+
({ params }) => {
|
|
394
|
+
for (const question of normalizeQuestions(decodeParams(params))) {
|
|
395
|
+
if (question.multiple) continue;
|
|
396
|
+
assert.isAtMost(question.options.filter((option) => option.recommended).length, 1);
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
{ arbitrary: { runs: PROPERTY_RUNS } },
|
|
400
|
+
);
|