@ftrdotdev/pi-inquiry 0.8.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 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftrdotdev/pi-inquiry",
3
- "version": "0.8.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#readme",
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 && oxlint --type-aware -A all -D typescript/unbound-method",
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.8.0",
46
- "effect": "4.1.1"
47
+ "@ftrdotdev/pi-tui": "^0.9.0",
48
+ "effect": "4.1.5"
47
49
  },
48
50
  "devDependencies": {
49
- "@earendil-works/pi-ai": "1.4.0",
50
- "@effect/tsgo": "0.63.0",
51
- "@effect/vitest": "4.1.1",
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": "^0.63.0",
54
- "oxlint": "1.90.0",
55
- "oxlint-tsgolint": "7.0.2005",
56
+ "oxfmt": "0.80.0",
57
+ "oxlint": "1.94.0",
58
+ "oxlint-tsgolint": "7.0.2008",
56
59
  "typescript": "7.0.2",
57
- "vitest": "^5.0.5"
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": [
@@ -1,5 +1,7 @@
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 {
4
6
  Option,
5
7
  QuestionListParamsJsonSchema,
@@ -299,14 +301,6 @@ describe("normalizeQuestions", () => {
299
301
  expect(questions[0]?.multiple).toBe(false);
300
302
  });
301
303
 
302
- it("maps option labels and descriptions", () => {
303
- const questions = normalizeQuestions(
304
- decodeParams({ questions: [{ prompt: "p", options: [{ label: "a", description: "d" }] }] }),
305
- );
306
- expect(questions[0]?.options[0]?.label).toBe("a");
307
- expect(questions[0]?.options[0]?.description).toBe("d");
308
- });
309
-
310
304
  it("strips leading marker emoji from prompt, label and options", () => {
311
305
  const questions = normalizeQuestions(
312
306
  decodeParams({
@@ -370,7 +364,37 @@ describe("normalizeQuestions", () => {
370
364
 
371
365
  describe("Option", () => {
372
366
  it("defaults recommended to false when constructed without it", () => {
373
- expect(new Option({ label: "Yes" }).recommended).toBe(false);
374
- expect(new Option({ label: "Yes", recommended: true }).recommended).toBe(true);
367
+ expect(Option.make({ label: "Yes" }).recommended).toBe(false);
368
+ expect(Option.make({ label: "Yes", recommended: true }).recommended).toBe(true);
375
369
  });
376
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
+ );
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import { Effect, Schema } from "effect";
10
- import { stripLeadingEmoji } from "./text.ts";
10
+ import { isNonEmptyString, stripLeadingEmoji } from "./text.ts";
11
11
 
12
12
  // ---------------------------------------------------------------------------
13
13
  // Wire schemas (tool parameters) — the single source of truth. The tool's
@@ -69,9 +69,9 @@ export type QuestionParams = typeof QuestionParamsStruct.Type;
69
69
  * appends the pointer.
70
70
  */
71
71
  const atMostOneRecommendation = Schema.makeFilter((q: QuestionParams): Schema.FilterOutput => {
72
- if (q.multiple === true) return undefined;
72
+ if (q.multiple ?? false) return undefined;
73
73
  const recommended = q.options.flatMap((option, index) =>
74
- option.recommended === true ? [index] : [],
74
+ (option.recommended ?? false) ? [index] : [],
75
75
  );
76
76
  if (recommended.length <= 1) return undefined;
77
77
  const name = q.label ?? q.id;
@@ -97,7 +97,7 @@ export type QuestionListParams = typeof QuestionListParamsSchema.Type;
97
97
 
98
98
  /**
99
99
  * JSON Schema form of the wire params, passed to pi as the tool's
100
- * `parameters`. `onExcessProperty: "ignore"` mirrors the legacy typebox
100
+ * `parameters`. `onExcessProperty: "ignore"` mirrors the legacy tool
101
101
  * contract (unknown keys such as the old `value` field are tolerated) and
102
102
  * matches Effect's own struct decoding, which ignores unknown keys.
103
103
  */
@@ -117,7 +117,7 @@ export const decodeParams = (input: unknown): QuestionListParams =>
117
117
  * the tool's `prepareArguments` before schema validation.
118
118
  */
119
119
  export const prepareQuestionArgs = (args: unknown): unknown => {
120
- if (args && typeof args === "object") {
120
+ if (typeof args === "object" && args !== null) {
121
121
  const legacy = args as { question?: unknown; options?: unknown; questions?: unknown };
122
122
  if (!Array.isArray(legacy.questions) && typeof legacy.question === "string") {
123
123
  return {
@@ -147,13 +147,17 @@ const optionRecommended = Schema.Boolean.pipe(
147
147
  Schema.withConstructorDefault(Effect.succeed(false)),
148
148
  );
149
149
 
150
- export class Option extends Schema.Class<Option>("inquiry/core/domain/Option")({
150
+ export class Option extends Schema.Class<Option, { readonly brand: unique symbol }>(
151
+ "inquiry/core/domain/Option",
152
+ )({
151
153
  label: Schema.String,
152
154
  description: Schema.optionalKey(Schema.String),
153
155
  recommended: optionRecommended,
154
156
  }) {}
155
157
 
156
- export class Question extends Schema.Class<Question>("inquiry/core/domain/Question")({
158
+ export class Question extends Schema.Class<Question, { readonly brand: unique symbol }>(
159
+ "inquiry/core/domain/Question",
160
+ )({
157
161
  id: Schema.String,
158
162
  label: Schema.String,
159
163
  prompt: Schema.String,
@@ -162,14 +166,16 @@ export class Question extends Schema.Class<Question>("inquiry/core/domain/Questi
162
166
  multiple: Schema.Boolean,
163
167
  }) {}
164
168
 
165
- export class Answer extends Schema.Class<Answer>("inquiry/core/domain/Answer")({
169
+ export class Answer extends Schema.Class<Answer, { readonly brand: unique symbol }>(
170
+ "inquiry/core/domain/Answer",
171
+ )({
166
172
  id: Schema.String,
167
173
  label: Schema.String,
168
174
  wasCustom: Schema.Boolean,
169
175
  index: Schema.optionalKey(Schema.Int),
170
176
  }) {}
171
177
 
172
- export class QuestionResult extends Schema.Class<QuestionResult>(
178
+ export class QuestionResult extends Schema.Class<QuestionResult, { readonly brand: unique symbol }>(
173
179
  "inquiry/core/domain/QuestionResult",
174
180
  )({
175
181
  questions: Schema.Array(Question),
@@ -187,22 +193,21 @@ export class QuestionResult extends Schema.Class<QuestionResult>(
187
193
  * markers duplicate.
188
194
  */
189
195
  export const normalizeQuestions = (params: QuestionListParams): readonly Question[] =>
190
- params.questions.map(
191
- (q, i) =>
192
- new Question({
193
- id: q.id ?? `q${i + 1}`,
194
- label: stripLeadingEmoji(q.label ?? `Q${i + 1}`),
195
- prompt: stripLeadingEmoji(q.prompt),
196
- options: q.options.map((o) => {
197
- const label = stripLeadingEmoji(o.label);
198
- const description =
199
- o.description === undefined ? undefined : stripLeadingEmoji(o.description);
200
- const recommended = o.recommended === true;
201
- return description
202
- ? new Option({ label, description, recommended })
203
- : new Option({ label, recommended });
204
- }),
205
- allowOther: q.allowOther !== false,
206
- multiple: q.multiple === true,
196
+ params.questions.map((q, i) =>
197
+ Question.make({
198
+ id: q.id ?? `q${i + 1}`,
199
+ label: stripLeadingEmoji(q.label ?? `Q${i + 1}`),
200
+ prompt: stripLeadingEmoji(q.prompt),
201
+ options: q.options.map((o) => {
202
+ const label = stripLeadingEmoji(o.label);
203
+ const description =
204
+ o.description === undefined ? undefined : stripLeadingEmoji(o.description);
205
+ const recommended = o.recommended ?? false;
206
+ return isNonEmptyString(description)
207
+ ? Option.make({ label, description, recommended })
208
+ : Option.make({ label, recommended });
207
209
  }),
210
+ allowOther: q.allowOther !== false,
211
+ multiple: q.multiple ?? false,
212
+ }),
208
213
  );