@luxass/pi-questions 0.1.1 → 0.1.2

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 CHANGED
@@ -10,7 +10,7 @@ pi install npm:@luxass/pi-questions
10
10
 
11
11
  Requires interactive Pi. RPC, JSON, and print modes are not supported. There are no commands or configuration files.
12
12
 
13
- With Herdr's Pi integration installed and loaded, Herdr marks the agent as blocked while a questionnaire is open. Submission, cancellation, an abort, or an error clears this questionnaire's blocked state. Without the integration, questionnaires work as usual.
13
+ With Herdr's Pi integration installed and loaded, Herdr marks the agent as blocked while a questionnaire is open. The bundled `@luxass/herdr-agent-shared` library adds the sidebar label `Waiting for answers`. Include `state_text` in Herdr's agent sidebar rows to display it. No extra Pi extension is needed. Submission, cancellation, an abort, or an error clears this questionnaire's state and label. Without Herdr, questionnaires work as usual.
14
14
 
15
15
  ## Use
16
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/pi-questions",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Ask structured questions in Pi with tabs, choices, notes, and Markdown previews.",
5
5
  "keywords": [
6
6
  "pi",
@@ -23,6 +23,9 @@
23
23
  "publishConfig": {
24
24
  "access": "public"
25
25
  },
26
+ "dependencies": {
27
+ "@luxass/herdr-agent-shared": "^0.1.0"
28
+ },
26
29
  "peerDependencies": {
27
30
  "@earendil-works/pi-coding-agent": "*",
28
31
  "@earendil-works/pi-tui": "*",
package/src/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
2
  import { stripTerminalSequences, Text } from "@earendil-works/pi-tui";
3
+ import { HerdrBlockedReporter } from "@luxass/herdr-agent-shared";
3
4
 
4
5
  import { QuestionDialog } from "./dialog.ts";
5
6
  import {
@@ -21,6 +22,7 @@ let inlineInUse = false;
21
22
 
22
23
  async function showQuestions(
23
24
  pi: ExtensionAPI,
25
+ blocked: HerdrBlockedReporter,
24
26
  params: Questions,
25
27
  ctx: ExtensionContext,
26
28
  signal?: AbortSignal,
@@ -58,6 +60,7 @@ async function showQuestions(
58
60
  );
59
61
  let ownsInlineSlot = !inlineInUse;
60
62
  if (ownsInlineSlot) inlineInUse = true;
63
+ const releaseLabel = blocked.block("Waiting for answers");
61
64
  try {
62
65
  // Herdr's optional Pi integration owns state reporting and counts overlapping blockers.
63
66
  pi.events.emit("herdr:blocked", { active: true, label: "Waiting for answers" });
@@ -73,9 +76,16 @@ async function showQuestions(
73
76
  if (ownsInlineSlot) inlineInUse = false;
74
77
  signal?.removeEventListener("abort", abort);
75
78
  pi.events.emit("herdr:blocked", { active: false });
79
+ await releaseLabel();
76
80
  }
77
81
  }
78
82
  export default function askQuestions(pi: ExtensionAPI) {
83
+ const blocked = new HerdrBlockedReporter({
84
+ source: "pi-questions:blocked",
85
+ agent: "pi",
86
+ appliesToSource: "herdr:pi",
87
+ });
88
+ pi.on("session_shutdown", () => blocked.clear());
79
89
  pi.registerTool<typeof QuestionsSchema, QuestionResult>({
80
90
  name: TOOL_NAME,
81
91
  label: "Ask user",
@@ -101,7 +111,7 @@ export default function askQuestions(pi: ExtensionAPI) {
101
111
  openWorldHint: false,
102
112
  },
103
113
  async execute(_id, params, signal, _update, ctx) {
104
- const result = await showQuestions(pi, params, ctx, signal);
114
+ const result = await showQuestions(pi, blocked, params, ctx, signal);
105
115
  const prefix =
106
116
  result.message ??
107
117
  (result.cancelled