pi-ask-user-x 0.1.0 → 0.1.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 +41 -7
- package/package.json +1 -1
- package/src/index.ts +5 -5
- package/src/ui/renderer.ts +1 -1
package/README.md
CHANGED
|
@@ -4,18 +4,18 @@ Bilingual structured questionnaire extension for the Pi coding agent (`@earendil
|
|
|
4
4
|
|
|
5
5
|
## Overview & Architecture
|
|
6
6
|
|
|
7
|
-
`pi-ask-user-x` provides the `
|
|
7
|
+
`pi-ask-user-x` provides the `ask_user` tool for interactive user questionnaires, preference elicitation, and architectural decision trees.
|
|
8
8
|
|
|
9
|
-
- **Non-Interception & Tool Separation**: The
|
|
9
|
+
- **Non-Interception & Tool Separation**: The separate `ask_user_question` plugin is **not intercepted**, patched, or monkey-patched. Models invoke `ask_user` directly to ask structured questions with single or multiple choices, or open freeform input, without global state mutations.
|
|
10
10
|
- **Dual Execution Modes**:
|
|
11
|
-
- **Co-operative with `pi-translate-x`**: When `pi-translate-x` (>=0.1.3) is active and enabled, question headers, prompts, descriptions, and predefined options are dynamically translated into the user's target language via the versioned translation service (`TranslationService`, protocol v1 over `pi.events`). Custom user prose and notes are reverse-translated back to English for the LLM.
|
|
11
|
+
- **Co-operative with `pi-translate-x`**: When `pi-translate-x` (>=0.1.3) is active and enabled, question headers, prompts, descriptions, and predefined options are dynamically translated into the user's target language via the versioned translation service (`TranslationService`, protocol v1 over `pi.events`). Custom user prose and notes are reverse-translated back to English for the LLM. Translation is a presentation implementation detail—the model tool name, label, and description remain clean and neutral.
|
|
12
12
|
- **Standalone Mode**: When `pi-translate-x` is absent or disabled at launch, `pi-ask-user-x` operates standalone in canonical English without failure. When an active translation service is detected but incompatible, malformed, or fails rediscovery/retry, users are presented with an explicit recovery choice (Retry discovery, Continue in English, or Cancel questionnaire) rather than silently degrading. Once an enabled service is discovered, answer translation obligation is pinned: custom user prose and notes are never submitted raw to the LLM without translation or explicit user recovery choice.
|
|
13
13
|
- **English-Canonical Contract & Stable IDs**: Predefined choices resolve strictly by stable, immutable string identifiers (`id`), completely independent of translated display text or duplicate localized labels. Predefined option choices are never back-translated. The model-facing tool arguments and return results remain strictly canonical English.
|
|
14
14
|
- **Submit-Only Privacy & Persistence**: Only confirmed, submitted questionnaire answers and their durable bilingual display snapshot are persisted to the session transcript (as context-excluded custom entries of type `pi-ask-user-x:questionnaire`). In-progress drafts, uncommitted answers, and cancelled questionnaire sessions are discarded from memory and never written to transcript storage. Persisted records are static; changing translator settings later does not re-translate or mutate session history. Durable transcript records are rendered visually for the human user but excluded from LLM context injection.
|
|
15
15
|
|
|
16
16
|
## Question Types and Configuration
|
|
17
17
|
|
|
18
|
-
The `
|
|
18
|
+
The `ask_user` tool supports 1 to 8 structured questions per invocation:
|
|
19
19
|
|
|
20
20
|
| Question Type | Behavior & Fields |
|
|
21
21
|
|---|---|
|
|
@@ -49,17 +49,43 @@ The TUI component (`QuestionnaireTUIComponent`) provides an accessible, fully re
|
|
|
49
49
|
|
|
50
50
|
When running headless or via RPC (`ctx.mode === "rpc"`), interactive terminal components degrade gracefully to standard dialog methods (`ui.select`, `ui.input`, `ui.confirm`). Rich Markdown previews degrade to text label and description hints.
|
|
51
51
|
|
|
52
|
-
##
|
|
52
|
+
## Installation & Usage
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
### Installing Published Packages
|
|
55
55
|
|
|
56
|
+
Install the companion questionnaire package directly from npm:
|
|
57
|
+
```sh
|
|
58
|
+
pi install npm:pi-ask-user-x
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
When using alongside `pi-translate-x` for bilingual translation support, ensure `pi-translate-x` is at least version `0.1.3`:
|
|
62
|
+
```sh
|
|
63
|
+
pi install npm:pi-translate-x
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Source Checkout, Migration, and Release Status
|
|
67
|
+
|
|
68
|
+
- **Tool Name Migration**:
|
|
69
|
+
- In `pi-ask-user-x@0.1.0` (published on npm): The tool was named `bilingual_questionnaire`.
|
|
70
|
+
- In `pi-ask-user-x@0.1.1` (prepared in checkout): The tool is renamed to `ask_user` with label `Ask User` and a neutral model description (`structured questions / choices / freeform`).
|
|
71
|
+
- **Published Tarball vs Source**: Version `0.1.0` of `pi-ask-user-x` is verified public latest on npm (integrity `sha512-MYTZ9F1Ll7DKmyeUtq5iAzBF/r6vwomizfeR2WUjr25KK+si36iHINRgMon5WzUcNkxzjnc/mGeWtnG/d1Mdiw==`, owner `carmelocampos`). Because npm enforces package immutability, version 0.1.0 cannot and will not be republished. Version `0.1.1` is prepared in this repository workspace.
|
|
72
|
+
- **Future Automated Releases**: Subsequent releases will be automated via GitHub Actions workflow `.github/workflows/publish-ask-user.yml` triggered exclusively by published GitHub Releases (`GHrelease.published`) with tag `pi-ask-user-x-v<packageversion>`.
|
|
73
|
+
- **npm Trusted Publisher Configuration**:
|
|
74
|
+
- GitHub repository: `dogalyir/pi-translate-x`
|
|
75
|
+
- Workflow name: `publish-ask-user.yml`
|
|
76
|
+
- Environment name: `npm`
|
|
77
|
+
*(Do not configure the trusted publisher in the npm owner UI until confirmed.)*
|
|
78
|
+
|
|
79
|
+
### Local Development from Checkout
|
|
80
|
+
|
|
81
|
+
To run or test both extensions locally from this checkout without loading duplicate extensions:
|
|
56
82
|
```sh
|
|
57
83
|
pi --no-extensions --extension ./src/index.ts --extension ./packages/ask-user/src/index.ts
|
|
58
84
|
```
|
|
59
85
|
|
|
60
86
|
## Runnable Schema Example
|
|
61
87
|
|
|
62
|
-
Below is a complete, runnable invocation of `
|
|
88
|
+
Below is a complete, runnable invocation of `ask_user` demonstrating `single`, `multi`, and `text` question types, markdown previews, supplemental custom text, notes, and selection bounds:
|
|
63
89
|
|
|
64
90
|
```json
|
|
65
91
|
{
|
|
@@ -129,6 +155,14 @@ Below is a complete, runnable invocation of `bilingual_questionnaire` demonstrat
|
|
|
129
155
|
|
|
130
156
|
Automated test suites pass deterministically using headless Vitest assertions, mock terminal renderers, and simulated event busses. **No manual assistive technology (AT), hardware cursor, screen-reader, or live terminal/provider verification is claimed.** Manual terminal inspection remains required for physical terminal emulator quirks.
|
|
131
157
|
|
|
158
|
+
## Documentation & Monorepo Links
|
|
159
|
+
|
|
160
|
+
For additional architectural details and guides, see the repository documentation:
|
|
161
|
+
- [Questionnaire Guide](https://github.com/dogalyir/pi-translate-x/blob/main/docs/questionnaire.md)
|
|
162
|
+
- [Translation Pipeline Guide](https://github.com/dogalyir/pi-translate-x/blob/main/docs/translation.md)
|
|
163
|
+
- [Release Operations & Verification](https://github.com/dogalyir/pi-translate-x/blob/main/docs/releases.md)
|
|
164
|
+
- [Monorepo Documentation Index](https://github.com/dogalyir/pi-translate-x/blob/main/docs/index.md)
|
|
165
|
+
|
|
132
166
|
## License
|
|
133
167
|
|
|
134
168
|
MIT
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -96,12 +96,12 @@ export default function register(pi: ExtensionAPI): void {
|
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// 2. Register tool
|
|
99
|
+
// 2. Register tool ask_user
|
|
100
100
|
pi.registerTool({
|
|
101
|
-
name: "
|
|
102
|
-
label: "
|
|
101
|
+
name: "ask_user",
|
|
102
|
+
label: "Ask User",
|
|
103
103
|
description:
|
|
104
|
-
"
|
|
104
|
+
"Ask the user structured questions with single or multiple choices, or open freeform input, to collect preferences, requirements, and decisions.",
|
|
105
105
|
exposure: "model-only",
|
|
106
106
|
parameters: BilingualQuestionnaireParamsSchema,
|
|
107
107
|
execute: async (toolCallId, params: BilingualQuestionnaireParams, signal, _onUpdate, ctx) => {
|
|
@@ -927,7 +927,7 @@ function makeUnsupportedResult(params: BilingualQuestionnaireParams, reason: str
|
|
|
927
927
|
content: [
|
|
928
928
|
{
|
|
929
929
|
type: "text" as const,
|
|
930
|
-
text: "Error:
|
|
930
|
+
text: "Error: ask_user requires interactive UI mode (TUI or RPC). Headless execution is not supported.",
|
|
931
931
|
},
|
|
932
932
|
],
|
|
933
933
|
isError: true,
|
package/src/ui/renderer.ts
CHANGED
|
@@ -19,7 +19,7 @@ export function renderQuestionnaireEntry(
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const record: DurableQuestionnaireRecord = entry.data;
|
|
22
|
-
const title = record.canonical.title ?? "
|
|
22
|
+
const title = record.canonical.title ?? "Ask User";
|
|
23
23
|
const dateStr = new Date(record.createdAt).toLocaleTimeString();
|
|
24
24
|
const langBadge = record.display?.language ? `[${record.display.language.toUpperCase()}]` : "";
|
|
25
25
|
|