@juicesharp/rpiv-ask-user-question 0.1.3 → 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 juicesharp
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
@@ -4,7 +4,7 @@ Pi extension that registers the `ask_user_question` tool — a structured option
4
4
  selector (with free-text "Other" fallback) the model can use to ask you a
5
5
  clarifying question instead of guessing.
6
6
 
7
- ![Structured question prompt](https://raw.githubusercontent.com/juicesharp/rpiv-ask-user-question/main/docs/prompt.jpg)
7
+ ![Structured question prompt](https://raw.githubusercontent.com/juicesharp/rpiv-mono/main/packages/rpiv-ask-user-question/docs/prompt.jpg)
8
8
 
9
9
  ## Installation
10
10
 
@@ -1,11 +1,7 @@
1
- import { type ExtensionAPI, DynamicBorder, type Theme } from "@mariozechner/pi-coding-agent";
2
- import { Container, Spacer, Text, getKeybindings } from "@mariozechner/pi-tui";
1
+ import { DynamicBorder, type ExtensionAPI, type Theme } from "@mariozechner/pi-coding-agent";
2
+ import { Container, getKeybindings, Spacer, Text } from "@mariozechner/pi-tui";
3
3
  import { Type } from "@sinclair/typebox";
4
- import {
5
- WrappingSelect,
6
- type WrappingSelectItem,
7
- type WrappingSelectTheme,
8
- } from "./wrapping-select.js";
4
+ import { WrappingSelect, type WrappingSelectItem, type WrappingSelectTheme } from "./wrapping-select.js";
9
5
 
10
6
  const MAX_VISIBLE_ROWS = 10;
11
7
 
@@ -74,7 +70,8 @@ export function registerAskUserQuestionTool(pi: ExtensionAPI): void {
74
70
 
75
71
  async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
76
72
  if (!ctx.hasUI) return buildToolResult(ERROR_NO_UI, { question: params.question, answer: null });
77
- if (params.options.length === 0) return buildToolResult(ERROR_NO_OPTIONS, { question: params.question, answer: null });
73
+ if (params.options.length === 0)
74
+ return buildToolResult(ERROR_NO_OPTIONS, { question: params.question, answer: null });
78
75
 
79
76
  const mainItems = buildMainItems(params.options);
80
77
  const chatItems: WrappingSelectItem[] = [{ label: CHAT_ABOUT_THIS_LABEL, isChat: true }];
@@ -87,12 +84,9 @@ export function registerAskUserQuestionTool(pi: ExtensionAPI): void {
87
84
  scrollInfo: (t) => theme.fg("dim", t),
88
85
  };
89
86
 
90
- const mainList = new WrappingSelect(
91
- mainItems,
92
- Math.min(mainItems.length, MAX_VISIBLE_ROWS),
93
- selectTheme,
94
- { totalItemsForNumbering: totalCount },
95
- );
87
+ const mainList = new WrappingSelect(mainItems, Math.min(mainItems.length, MAX_VISIBLE_ROWS), selectTheme, {
88
+ totalItemsForNumbering: totalCount,
89
+ });
96
90
  const chatList = new WrappingSelect(chatItems, 1, selectTheme, {
97
91
  numberStartOffset: mainItems.length,
98
92
  totalItemsForNumbering: totalCount,
@@ -215,10 +209,11 @@ function buildResponse(choice: WrappingSelectItem | null, params: QuestionParams
215
209
  }
216
210
  if (choice.isOther) {
217
211
  const customAnswer = choice.label.length > 0 ? choice.label : null;
218
- return buildToolResult(
219
- `User answered: ${customAnswer ?? NO_INPUT_PLACEHOLDER}`,
220
- { question: params.question, answer: customAnswer, wasCustom: true },
221
- );
212
+ return buildToolResult(`User answered: ${customAnswer ?? NO_INPUT_PLACEHOLDER}`, {
213
+ question: params.question,
214
+ answer: customAnswer,
215
+ wasCustom: true,
216
+ });
222
217
  }
223
218
  if (choice.isChat) {
224
219
  return buildToolResult(CHAT_CONTINUATION_MESSAGE, {
package/index.ts CHANGED
@@ -12,5 +12,5 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
12
12
  import { registerAskUserQuestionTool } from "./ask-user-question.js";
13
13
 
14
14
  export default function (pi: ExtensionAPI) {
15
- registerAskUserQuestionTool(pi);
15
+ registerAskUserQuestionTool(pi);
16
16
  }
package/package.json CHANGED
@@ -1,24 +1,38 @@
1
1
  {
2
2
  "name": "@juicesharp/rpiv-ask-user-question",
3
- "version": "0.1.3",
3
+ "version": "0.6.1",
4
4
  "description": "Pi extension: lets the model ask you a clarifying question with structured options instead of guessing",
5
- "keywords": ["pi-package", "pi-extension", "rpiv"],
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "rpiv"
9
+ ],
6
10
  "type": "module",
7
11
  "license": "MIT",
8
12
  "author": "juicesharp",
9
13
  "repository": {
10
14
  "type": "git",
11
- "url": "git+https://github.com/juicesharp/rpiv-ask-user-question.git"
15
+ "url": "git+https://github.com/juicesharp/rpiv-mono.git",
16
+ "directory": "packages/rpiv-ask-user-question"
12
17
  },
13
- "homepage": "https://github.com/juicesharp/rpiv-ask-user-question#readme",
18
+ "homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-ask-user-question#readme",
14
19
  "bugs": {
15
- "url": "https://github.com/juicesharp/rpiv-ask-user-question/issues"
20
+ "url": "https://github.com/juicesharp/rpiv-mono/issues"
16
21
  },
17
22
  "publishConfig": {
18
23
  "access": "public"
19
24
  },
25
+ "files": [
26
+ "index.ts",
27
+ "ask-user-question.ts",
28
+ "wrapping-select.ts",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
20
32
  "pi": {
21
- "extensions": ["./index.ts"]
33
+ "extensions": [
34
+ "./index.ts"
35
+ ]
22
36
  },
23
37
  "peerDependencies": {
24
38
  "@mariozechner/pi-coding-agent": "*",
@@ -1,5 +1,5 @@
1
- import { visibleWidth, wrapTextWithAnsi } from "@mariozechner/pi-tui";
2
1
  import type { Component } from "@mariozechner/pi-tui";
2
+ import { visibleWidth, wrapTextWithAnsi } from "@mariozechner/pi-tui";
3
3
 
4
4
  export interface WrappingSelectItem {
5
5
  label: string;
@@ -106,10 +106,7 @@ export class WrappingSelect implements Component {
106
106
 
107
107
  private computeVisibleWindow(): { startIndex: number; endIndex: number } {
108
108
  const half = Math.floor(this.maxVisible / 2);
109
- const startIndex = Math.max(
110
- 0,
111
- Math.min(this.selectedIndex - half, this.items.length - this.maxVisible),
112
- );
109
+ const startIndex = Math.max(0, Math.min(this.selectedIndex - half, this.items.length - this.maxVisible));
113
110
  const endIndex = Math.min(startIndex + this.maxVisible, this.items.length);
114
111
  return { startIndex, endIndex };
115
112
  }
@@ -180,6 +177,8 @@ export class WrappingSelect implements Component {
180
177
  }
181
178
 
182
179
  private stripControlChars(text: string): string {
183
- return Array.from(text).filter((c) => c >= " ").join("");
180
+ return Array.from(text)
181
+ .filter((c) => c >= " ")
182
+ .join("");
184
183
  }
185
184
  }
package/docs/prompt.jpg DELETED
Binary file