@howaboua/pi-ask 0.0.11 → 0.0.12

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,10 @@
1
1
  # @howaboua/pi-ask
2
2
 
3
+ ## 0.0.12
4
+
5
+ - ### Improvements
6
+ - Ask returns help when called without arguments, including an empty structured object. Explicit help remains supported.
7
+
3
8
  ## 0.0.11
4
9
 
5
10
  - Parents can receive and answer asynchronous questions through Shepherdr while workers continue.
package/ask/contracts.ts CHANGED
@@ -16,8 +16,9 @@ const PromptSchema = Type.Object({
16
16
  });
17
17
 
18
18
  export const AskParameters = Type.Object({
19
+ help: Type.Optional(Type.Literal(true)),
19
20
  handoff: Type.Optional(Type.Boolean()),
20
- prompts: Type.Array(PromptSchema),
21
+ prompts: Type.Optional(Type.Array(PromptSchema)),
21
22
  delivery: Type.Optional(StringEnum(ASK_DELIVERIES)),
22
23
  });
23
24
 
package/ask/normalize.ts CHANGED
@@ -52,6 +52,13 @@ export function isSteeringAskInput(input: unknown): boolean {
52
52
  );
53
53
  }
54
54
 
55
+ export function isAskHelpInput(input: unknown): boolean {
56
+ if (input === undefined) return true;
57
+ if (!isRecord(input) || Array.isArray(input)) return false;
58
+ const keys = Object.keys(input);
59
+ return keys.length === 0 || (keys.length === 1 && input["help"] === true);
60
+ }
61
+
55
62
  export function normalizeAskInput(params: unknown): {
56
63
  delivery: "wait" | "steer";
57
64
  handoff: boolean;
package/ask/tool.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  createAskCoordinator,
7
7
  } from "./coordinator.js";
8
8
  import {
9
+ isAskHelpInput,
9
10
  isSteeringAskInput,
10
11
  normalizeAskInput,
11
12
  normalizeResponses,
@@ -45,15 +46,26 @@ export function createAskRuntime({
45
46
  const tool = defineTool({
46
47
  name: "ask",
47
48
  label: "Ask",
48
- description: "Request user input or action",
49
+ description: "Request user input or action; {} for help",
49
50
  parameters: AskParameters,
50
- promptGuidelines: [
51
- "ask: Omit delivery to wait; steer only while reversible work can continue. Handoffs wait for user action; state the completion signal",
52
- "ask: For reviews, make each finding a prompt with disposition choices; do not report first.",
53
- "ask: Other/rephrase is automatic; omit choices for free text",
54
- ],
55
51
  executionMode: "sequential",
56
52
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
53
+ if (isAskHelpInput(params)) {
54
+ return {
55
+ content: [
56
+ textContent(
57
+ [
58
+ "ask({}) or ask({ help: true }) returns help",
59
+ 'ask({ prompts: [{ title, body?, multiple?, choices?: [{ label, description? }] }], delivery?: "wait"|"steer", handoff? })',
60
+ "Omit delivery to wait; steer only while reversible work can continue. Handoffs wait for user action; state the completion signal",
61
+ "For reviews, make each finding a prompt with disposition choices; do not report first",
62
+ "Other/rephrase is automatic; omit choices for free text. Blank Other/rephrase means rephrase or follow up",
63
+ ].join("\n"),
64
+ ),
65
+ ],
66
+ details: { kind: "help" },
67
+ };
68
+ }
57
69
  const { delivery, handoff, prompts } = normalizeAskInput(params);
58
70
  if (prompts.length === 0) {
59
71
  throw new Error(
@@ -115,6 +127,8 @@ export function createAskRuntime({
115
127
  };
116
128
  },
117
129
  renderCall(args, theme, context) {
130
+ if (isAskHelpInput(args))
131
+ return new Text(theme.fg("toolTitle", theme.bold("ask help")), 0, 0);
118
132
  const count = Array.isArray(args.prompts) ? args.prompts.length : 0;
119
133
  const label =
120
134
  args.handoff === true
package/index.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  createSteerDelivery,
10
10
  type TryCodexDeveloperMessage,
11
11
  } from "./ask/delivery.js";
12
- import { isSteeringAskInput } from "./ask/normalize.js";
12
+ import { isAskHelpInput, isSteeringAskInput } from "./ask/normalize.js";
13
13
  import { PENDING_ASK_ENTRY_TYPE, readPendingAsks } from "./ask/pending.js";
14
14
  import { createAskRuntime, createAskTool } from "./ask/tool.js";
15
15
  import registerPackageChangelog from "./changelog.js";
@@ -127,9 +127,9 @@ async function registerAskInCodeMode(
127
127
  await import("@howaboua/pi-codex-conversion/code-mode");
128
128
  const registration = registerCodeModeExtensionTools(pi, () => [
129
129
  adaptToolForCodeMode(ask, {
130
- blocking: (input) => !isSteeringAskInput(input),
131
- usage:
132
- 'await tools.ask({ prompts: [{ title, body?, multiple?, choices?: [{ label, description? }] }], delivery?: "wait"|"steer", handoff? })',
130
+ blocking: (input) =>
131
+ !isAskHelpInput(input) && !isSteeringAskInput(input),
132
+ usage: "await tools.ask() // help",
133
133
  }),
134
134
  ]);
135
135
  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.11",
3
+ "version": "0.0.12",
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.46",
48
+ "@howaboua/pi-codex-conversion": ">=3.0.48",
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,18 +57,17 @@
57
57
  }
58
58
  },
59
59
  "devDependencies": {
60
- "@howaboua/pi-codex-conversion": "3.0.46",
60
+ "@howaboua/pi-codex-conversion": "3.0.48",
61
61
  "@biomejs/biome": "^2.5.10",
62
- "@earendil-works/pi-ai": "1.0.4",
63
- "@earendil-works/pi-coding-agent": "1.0.4",
64
- "@earendil-works/pi-tui": "1.0.4",
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
65
  "typebox": "1.3.18",
66
66
  "typescript": "^7.0.2"
67
67
  },
68
68
  "scripts": {
69
- "check": "bun run lint && bun run typecheck && bun run test",
69
+ "check": "bun run lint && bun run typecheck",
70
70
  "prepack": "bun run check",
71
- "test": "bun test",
72
71
  "typecheck": "tsgo --noEmit",
73
72
  "lint": "biome check .",
74
73
  "format": "biome check --write .",