@howaboua/pi-ask 0.0.13 → 0.0.15

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @howaboua/pi-ask
2
2
 
3
+ ## 0.0.15
4
+
5
+ - Use consistent tool discovery across native, Code and Notebook modes, with compact help in PCC GPT prompt mode.
6
+
7
+ ## 0.0.14
8
+
9
+ - Ask now separates exact choice labels from descriptions in forwarded questions.
10
+
3
11
  ## 0.0.13
4
12
 
5
13
  - Ask now accepts supervisor replies through Shepherdr's `reply` action. Update and reload Ask and Shepherdr together on controllers and workers.
package/README.md CHANGED
@@ -14,7 +14,7 @@ Try it for one session:
14
14
  pi -e npm:@howaboua/pi-ask
15
15
  ```
16
16
 
17
- When [Pi Codex](https://www.npmjs.com/package/@howaboua/pi-codex-conversion) 3.0.25 or newer is installed too, `ask` is available inside Code and Notebook Mode as `await tools.ask({ prompts, delivery?, handoff? })`.
17
+ When [Pi Codex](https://www.npmjs.com/package/@howaboua/pi-codex-conversion) 3.0.52 or newer is installed too, `ask` is available inside Code and Notebook Mode as `await tools.ask({ prompts, delivery?, handoff? })`.
18
18
 
19
19
  ## How it behaves
20
20
 
@@ -21,7 +21,7 @@ function questionText(request: AskRequest): string {
21
21
  `Choose ${prompt.multiple ? "one or more" : "one"}:`,
22
22
  ...prompt.choices.map(
23
23
  (choice) =>
24
- `- ${choice.label}${choice.description ? `: ${choice.description}` : ""}`,
24
+ `- ${JSON.stringify(choice.label)}${choice.description ? `\n ${choice.description}` : ""}`,
25
25
  ),
26
26
  ]
27
27
  : ["Free-text answer"]),
package/ask/tool.ts CHANGED
@@ -29,6 +29,7 @@ type OnBlockedChange = (state: BlockedState) => void;
29
29
 
30
30
  interface AskToolOptions extends AskCoordinatorOptions {
31
31
  onBlockedChange?: OnBlockedChange;
32
+ isGpt?(): boolean;
32
33
  }
33
34
 
34
35
  export function createAskRuntime({
@@ -37,6 +38,7 @@ export function createAskRuntime({
37
38
  onBlockedChange,
38
39
  onPendingChange,
39
40
  onRequestChange,
41
+ isGpt = () => false,
40
42
  }: AskToolOptions = {}) {
41
43
  const coordinator = createAskCoordinator({
42
44
  ...(askInComposer ? { askInComposer } : {}),
@@ -48,7 +50,7 @@ export function createAskRuntime({
48
50
  const tool = defineTool({
49
51
  name: "ask",
50
52
  label: "Ask",
51
- description: "Request user input or action; {} for help",
53
+ description: "Request user input or action",
52
54
  parameters: AskParameters,
53
55
  executionMode: "sequential",
54
56
  prepareArguments(input) {
@@ -64,13 +66,22 @@ export function createAskRuntime({
64
66
  return {
65
67
  content: [
66
68
  textContent(
67
- [
68
- "ask({}) or ask({ help: true }) returns help",
69
- 'ask({ prompts: [{ title, body?, multiple?, choices?: [{ label, description? }] }], delivery?: "wait"|"steer", handoff? })',
70
- "Omit delivery to wait; steer only while reversible work can continue. Handoffs wait for user action; state the completion signal",
71
- "For reviews, make each finding a prompt with disposition choices; do not report first",
72
- "Other/rephrase is automatic; omit choices for free text. Blank Other/rephrase means rephrase or follow up",
73
- ].join("\n"),
69
+ (isGpt()
70
+ ? [
71
+ "ask({}) / ask({help:true}): usage",
72
+ 'ask({prompts:[{title,body?,multiple?,choices?:[{label,description?}]}],delivery?:"wait"|"steer",handoff?})',
73
+ "Default wait; steer only with reversible work to continue. Handoffs wait for user action: state completion signal",
74
+ "Reviews: each finding = prompt + disposition choices; do not report first",
75
+ "Automatic Other/rephrase; no choices = free text. Blank Other/rephrase = rephrase/follow up",
76
+ ]
77
+ : [
78
+ "ask({}) or ask({ help: true }) returns usage",
79
+ 'ask({ prompts: [{ title, body?, multiple?, choices?: [{ label, description? }] }], delivery?: "wait"|"steer", handoff? })',
80
+ "Omit delivery to wait; steer only while reversible work can continue. Handoffs wait for user action; state the completion signal",
81
+ "For reviews, make each finding a prompt with disposition choices; do not report first",
82
+ "Other/rephrase is automatic; omit choices for free text. Blank Other/rephrase means rephrase or follow up",
83
+ ]
84
+ ).join("\n"),
74
85
  ),
75
86
  ],
76
87
  details: { kind: "help" },
package/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.5.10/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
3
3
  "vcs": {
4
4
  "enabled": true,
5
5
  "clientKind": "git",
package/index.ts CHANGED
@@ -30,7 +30,9 @@ const DEVELOPER_MESSAGES_MODULE = `${CODE_MODE_PACKAGE}/developer-messages`;
30
30
  export default async function humanInTheLoop(pi: ExtensionAPI): Promise<void> {
31
31
  registerPackageChangelog(pi);
32
32
  const trySendCodexDeveloperMessage = await loadCodexDeveloperMessageSender();
33
+ let gpt = false;
33
34
  const askRuntime = createAskRuntime({
35
+ isGpt: () => gpt,
34
36
  onRequestChange: (change) => publishAskRequest(pi, change),
35
37
  deliverSteer: createSteerDelivery(pi, trySendCodexDeveloperMessage),
36
38
  onBlockedChange: (state) => {
@@ -57,6 +59,28 @@ export default async function humanInTheLoop(pi: ExtensionAPI): Promise<void> {
57
59
  );
58
60
  };
59
61
  pi.registerTool(ask);
62
+ try {
63
+ const { registerGptPromptMode } = await import(
64
+ "@howaboua/pi-codex-conversion/prompt-mode"
65
+ );
66
+ registerGptPromptMode(pi, (active) => {
67
+ gpt = active;
68
+ return [ask];
69
+ });
70
+ } catch (error) {
71
+ if (
72
+ !(error instanceof Error) ||
73
+ !("code" in error) ||
74
+ ![
75
+ "ERR_MODULE_NOT_FOUND",
76
+ "MODULE_NOT_FOUND",
77
+ "ERR_PACKAGE_PATH_NOT_EXPORTED",
78
+ ].includes(String(error.code)) ||
79
+ !error.message.includes(CODE_MODE_PACKAGE)
80
+ )
81
+ throw error;
82
+ }
83
+
60
84
  await registerAskInCodeMode(pi, ask);
61
85
  pi.on("session_start", (_event, ctx) => restorePending(ctx));
62
86
  pi.on("session_tree", (_event, ctx) => restorePending(ctx));
@@ -101,7 +125,7 @@ async function registerAskInCodeMode(
101
125
  adaptToolForCodeMode(ask, {
102
126
  blocking: (input) =>
103
127
  !isAskHelpInput(input) && !isSteeringAskInput(input),
104
- usage: "await tools.ask() // help",
128
+ discovery: "help",
105
129
  }),
106
130
  ]);
107
131
  pi.on("session_shutdown", () => registration.unregister());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-ask",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "Interactive decisions, review triage, and human handoffs for Pi.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  ]
46
46
  },
47
47
  "peerDependencies": {
48
- "@howaboua/pi-codex-conversion": ">=3.0.50",
48
+ "@howaboua/pi-codex-conversion": ">=4.0.2",
49
49
  "@earendil-works/pi-ai": ">=1.0.0",
50
50
  "@earendil-works/pi-coding-agent": ">=1.0.0",
51
51
  "@earendil-works/pi-tui": ">=1.0.0",
@@ -57,12 +57,12 @@
57
57
  }
58
58
  },
59
59
  "devDependencies": {
60
- "@howaboua/pi-codex-conversion": "3.0.50",
61
- "@biomejs/biome": "^2.5.10",
62
- "@earendil-works/pi-ai": "1.1.0",
63
- "@earendil-works/pi-coding-agent": "1.1.0",
64
- "@earendil-works/pi-tui": "1.1.0",
65
- "typebox": "1.3.18",
60
+ "@howaboua/pi-codex-conversion": "4.0.2",
61
+ "@biomejs/biome": "^2.5.15",
62
+ "@earendil-works/pi-ai": "1.3.0",
63
+ "@earendil-works/pi-coding-agent": "1.3.0",
64
+ "@earendil-works/pi-tui": "1.3.0",
65
+ "typebox": "1.3.37",
66
66
  "typescript": "^7.0.2"
67
67
  },
68
68
  "scripts": {