@luxass/pi-questions 0.1.0 → 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,6 +10,8 @@ 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. 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
+
13
15
  ## Use
14
16
 
15
17
  The model can use `ask_questions` without an explicit request. Its instructions tell it to clarify unclear goals, scope, and constraints before implementing a new system or substantial feature. It skips questions you already answered and routine implementation details. You can also ask it to use the tool explicitly.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxass/pi-questions",
3
- "version": "0.1.0",
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": "*",
@@ -35,8 +38,8 @@
35
38
  ]
36
39
  },
37
40
  "scripts": {
38
- "lint": "oxlint --deny-warnings .",
39
- "lint:fix": "oxlint --fix --deny-warnings .",
41
+ "lint": "oxlint .",
42
+ "lint:fix": "oxlint --fix .",
40
43
  "fmt": "oxfmt .",
41
44
  "fmt:check": "oxfmt --check .",
42
45
  "typecheck": "tsc -p tsconfig.json"
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 {
@@ -20,6 +21,8 @@ const TOOL_NAME = "ask_questions";
20
21
  let inlineInUse = false;
21
22
 
22
23
  async function showQuestions(
24
+ pi: ExtensionAPI,
25
+ blocked: HerdrBlockedReporter,
23
26
  params: Questions,
24
27
  ctx: ExtensionContext,
25
28
  signal?: AbortSignal,
@@ -57,7 +60,10 @@ async function showQuestions(
57
60
  );
58
61
  let ownsInlineSlot = !inlineInUse;
59
62
  if (ownsInlineSlot) inlineInUse = true;
63
+ const releaseLabel = blocked.block("Waiting for answers");
60
64
  try {
65
+ // Herdr's optional Pi integration owns state reporting and counts overlapping blockers.
66
+ pi.events.emit("herdr:blocked", { active: true, label: "Waiting for answers" });
61
67
  if (ownsInlineSlot) {
62
68
  const result = await mount(false);
63
69
  if (result) return result;
@@ -69,9 +75,17 @@ async function showQuestions(
69
75
  } finally {
70
76
  if (ownsInlineSlot) inlineInUse = false;
71
77
  signal?.removeEventListener("abort", abort);
78
+ pi.events.emit("herdr:blocked", { active: false });
79
+ await releaseLabel();
72
80
  }
73
81
  }
74
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());
75
89
  pi.registerTool<typeof QuestionsSchema, QuestionResult>({
76
90
  name: TOOL_NAME,
77
91
  label: "Ask user",
@@ -97,7 +111,7 @@ export default function askQuestions(pi: ExtensionAPI) {
97
111
  openWorldHint: false,
98
112
  },
99
113
  async execute(_id, params, signal, _update, ctx) {
100
- const result = await showQuestions(params, ctx, signal);
114
+ const result = await showQuestions(pi, blocked, params, ctx, signal);
101
115
  const prefix =
102
116
  result.message ??
103
117
  (result.cancelled