@agnishc/edb-ask-user 0.1.0 → 0.4.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 +7 -2
- package/package.json +24 -7
- package/src/component.ts +9 -2
- package/src/index.ts +5 -3
- package/src/schemas.ts +10 -7
- package/src/types.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [
|
|
3
|
+
## [0.2.0] - 2026-04-29
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Replaced question-level `allowOther` with option-level `isOther` boolean on `QuestionOption`
|
|
7
|
+
- Free-text input is always guaranteed for choice questions: if no option is marked `isOther: true`, a default "Type something." option is auto-appended; if an option is marked `isOther: true`, it replaces the default (eliminating redundant options)
|
|
8
|
+
- Updated prompt guidelines to document the `isOther` field
|
|
4
9
|
|
|
5
10
|
### Added
|
|
6
11
|
- Initial release: `ask_user` tool with text and choice question types
|
|
7
12
|
- Single-question focused UI and multi-question tabbed wizard
|
|
8
|
-
- `
|
|
13
|
+
- `isOther` / inline editor for choice questions
|
|
9
14
|
- Submit review tab showing all answers before submission
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agnishc/edb-ask-user",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Pi extension: ask_user tool for structured questions — text, choice, and multi-step wizard",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi-extension",
|
|
8
|
+
"edb"
|
|
9
|
+
],
|
|
6
10
|
"type": "module",
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "Agnish Chakraborty",
|
|
@@ -12,12 +16,25 @@
|
|
|
12
16
|
"directory": "packages/edb-ask-user"
|
|
13
17
|
},
|
|
14
18
|
"homepage": "https://github.com/agnishcc/pi-extention-monorepo/tree/main/packages/edb-ask-user#readme",
|
|
15
|
-
"bugs": {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/agnishcc/pi-extention-monorepo/issues"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "vitest run"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"src",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"CHANGELOG.md"
|
|
33
|
+
],
|
|
19
34
|
"pi": {
|
|
20
|
-
"extensions": [
|
|
35
|
+
"extensions": [
|
|
36
|
+
"./src/index.ts"
|
|
37
|
+
]
|
|
21
38
|
},
|
|
22
39
|
"peerDependencies": {
|
|
23
40
|
"@mariozechner/pi-ai": "*",
|
package/src/component.ts
CHANGED
|
@@ -56,8 +56,15 @@ export function createAskUserComponent(
|
|
|
56
56
|
function currentOptions(): RenderOption[] {
|
|
57
57
|
const q = currentQuestion();
|
|
58
58
|
if (!q || q.type !== "choice") return [];
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
const rawOpts = q.options ?? [];
|
|
60
|
+
const opts: RenderOption[] = rawOpts.map((o) => ({
|
|
61
|
+
...o,
|
|
62
|
+
isOther: o.isOther === true ? true : undefined,
|
|
63
|
+
}));
|
|
64
|
+
// If no option is already marked as free-text (isOther), auto-append "Type something."
|
|
65
|
+
if (!opts.some((o) => o.isOther)) {
|
|
66
|
+
opts.push({ value: "__other__", label: "Type something.", isOther: true });
|
|
67
|
+
}
|
|
61
68
|
return opts;
|
|
62
69
|
}
|
|
63
70
|
|
package/src/index.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Supports three question modes (freely mixed in one call):
|
|
8
8
|
* - text : free-form text input via inline editor
|
|
9
|
-
* - choice : pick from a numbered option list (+
|
|
9
|
+
* - choice : pick from a numbered option list (+ always-available free-text)
|
|
10
10
|
*
|
|
11
11
|
* Single question → focused UI, no tab bar, immediate return
|
|
12
12
|
* Multiple questions → tab-based wizard with a Submit tab
|
|
@@ -36,7 +36,10 @@ export default function askUserExtension(pi: ExtensionAPI): void {
|
|
|
36
36
|
"For a single free-form question set type to 'text'. " +
|
|
37
37
|
"For a multiple-choice question set type to 'choice' and provide options. " +
|
|
38
38
|
"Pass several questions together for a multi-step flow.",
|
|
39
|
-
"
|
|
39
|
+
"A free-text option is always available for choice questions. " +
|
|
40
|
+
"By default, a 'Type something.' option is auto-appended. " +
|
|
41
|
+
"If you want to provide your own free-text option (e.g. 'Other', 'Custom'), " +
|
|
42
|
+
"mark it with isOther: true — this replaces the default and avoids redundancy.",
|
|
40
43
|
],
|
|
41
44
|
parameters: AskUserParams,
|
|
42
45
|
|
|
@@ -72,7 +75,6 @@ export default function askUserExtension(pi: ExtensionAPI): void {
|
|
|
72
75
|
const questions: AskQuestion[] = params.questions.map((q, i) => ({
|
|
73
76
|
...q,
|
|
74
77
|
label: q.label || `Q${i + 1}`,
|
|
75
|
-
allowOther: true,
|
|
76
78
|
}));
|
|
77
79
|
|
|
78
80
|
// ── Build & show the custom TUI ───────────────────────────────────
|
package/src/schemas.ts
CHANGED
|
@@ -15,6 +15,16 @@ export const OptionSchema = Type.Object({
|
|
|
15
15
|
description: "Optional sub-label shown below the option (e.g. a clarifying note)",
|
|
16
16
|
}),
|
|
17
17
|
),
|
|
18
|
+
isOther: Type.Optional(
|
|
19
|
+
Type.Boolean({
|
|
20
|
+
description:
|
|
21
|
+
"Mark this option as a free-text option. When selected, opens an inline editor " +
|
|
22
|
+
"instead of returning the option value. Use this when you want to provide your own " +
|
|
23
|
+
"label for the free-text option (e.g. 'Other', 'Custom'). " +
|
|
24
|
+
"If no option is marked isOther, a default 'Type something.' option is auto-appended. " +
|
|
25
|
+
"Only one option should be marked isOther per question.",
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
18
28
|
});
|
|
19
29
|
|
|
20
30
|
export const QuestionSchema = Type.Object({
|
|
@@ -47,13 +57,6 @@ export const QuestionSchema = Type.Object({
|
|
|
47
57
|
"(e.g. 'Enter your API key…'). Purely informational.",
|
|
48
58
|
}),
|
|
49
59
|
),
|
|
50
|
-
allowOther: Type.Optional(
|
|
51
|
-
Type.Boolean({
|
|
52
|
-
description:
|
|
53
|
-
"For choice questions: whether to append a 'Type something' option " +
|
|
54
|
-
"that opens a free-text editor. Defaults to true.",
|
|
55
|
-
}),
|
|
56
|
-
),
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
export const AskUserParams = Type.Object({
|
package/src/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface QuestionOption {
|
|
|
4
4
|
value: string;
|
|
5
5
|
label: string;
|
|
6
6
|
description?: string;
|
|
7
|
+
isOther?: boolean;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export type RenderOption = QuestionOption & { isOther?: boolean };
|
|
@@ -14,7 +15,6 @@ export interface AskQuestion {
|
|
|
14
15
|
type: "text" | "choice";
|
|
15
16
|
options?: QuestionOption[];
|
|
16
17
|
placeholder?: string;
|
|
17
|
-
allowOther?: boolean;
|
|
18
18
|
label?: string;
|
|
19
19
|
}
|
|
20
20
|
|