@wbline/pi-plan-build 0.0.7 → 0.0.9

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
@@ -4,6 +4,18 @@
4
4
 
5
5
  格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本遵循语义化版本。
6
6
 
7
+ ## [0.0.9] - 2026-10-21
8
+
9
+ ### 修复
10
+
11
+ **`plan_question` 弹窗中文标点前显示方块(□)**:上游模型(agent-gateway / glm 系)偶发在流式 tool_call 参数里夹带 CR 控制符(`\r`)——会话 JSONL 证实同一模型纯文本/thinking 内容零污染,而 toolCall arguments 里有 130+ 处 CR,插在汉字与标点的 token 边界;JetBrains 侧把 CR 渲染成豆腐块。`plan_question` 现在在入口对 question/header/label/description 统一清洗 CR 与零宽字符(U+200B–U+200D、U+FEFF),弹窗选项、无 UI 回退文本、选择结果回传全链路干净;冒烟补 2 个用例。治本需在上游网关对工具参数做同等清洗(覆盖 edit 等其它工具)
12
+
13
+ ## [0.0.8] - 2026-10-21
14
+
15
+ ### 新增
16
+
17
+ - **`plan_question` 自由输入入口**:此前用户只能在 AI 预置的选项里单选,想表达选项之外的想法只能 Esc 取消后打字。现在选择列表末尾自动追加「✏️ 自行输入…」入口,选中后弹输入框自由作答(首尾空白裁剪);输入为空或 Esc 返回选项列表,可改选预置项(镜像官方 question.ts 示例的交互);AI 选项恰好与入口同名时复用为该入口、不重复追加。RPC/ACP 桥接下输入框走 `ui.input` 通道(JetBrains 弹窗 elicitation 表单),与 select 同级可用
18
+
7
19
  ## [0.0.7] - 2026-10-21
8
20
 
9
21
  ### 变更
package/README.md CHANGED
@@ -64,7 +64,7 @@ pi install npm:@wbline/pi-plan-build
64
64
  | `plan_step_complete` | 完成当前进行中的步(摘要必填),立即生效不等待验收;最后一步完成即自动收尾整计划 |
65
65
  | `plan_complete` | 标记整计划完成——仅在全部工作与必需检查通过,或用户明确指示时。收尾时在计划文件文末写入状态块(`> **状态:已完成**(日期)` + 摘要),放弃同理(含原因),历史计划单看文件即可知结局 |
66
66
  | `plan_set_outcome` | 记录未完成结局并保持计划开放:`awaiting_validation`(必填精确的 userAction)/ `blocked` / `waiting_for_input` / `still_working` |
67
- | `plan_question` | 结构化选择题,收集决策;无交互 UI 时自动降级为文本提问 |
67
+ | `plan_question` | 结构化选择题,收集决策;选择列表末尾自动附「✏️ 自行输入…」入口,用户可跳出选项自由作答(空提交/Esc 返回选项);无交互 UI 时自动降级为文本提问 |
68
68
 
69
69
  ## 设置
70
70
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wbline/pi-plan-build",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Plan/Build dual-mode for the Pi coding agent: read-only planning, explicit approval, step-wise execution.",
5
5
  "license": "MIT",
6
6
  "author": "wongbin",
@@ -30,6 +30,8 @@ export interface ToolTexts {
30
30
  questionHeader: string;
31
31
  questionLabel: string;
32
32
  questionDescription: string;
33
+ questionCustom: string;
34
+ questionCustomPrompt: string;
33
35
  }
34
36
 
35
37
  const ZH: ToolTexts = {
@@ -64,11 +66,13 @@ const ZH: ToolTexts = {
64
66
  "awaiting_validation 必填:用户要执行的精确验证步骤(多项检查每项一个简短要点)",
65
67
  outcomeReason: "blocked/waiting_for_input/still_working 必填:原因",
66
68
  question:
67
- "向用户提出结构化选择题,收集决策/澄清歧义;推荐选项放第一个并在 label 尾部加「(推荐)」。无交互 UI 时自动降级为文本提问。",
69
+ "向用户提出结构化选择题,收集决策/澄清歧义;推荐选项放第一个并在 label 尾部加「(推荐)」。选择列表末尾自动附自由输入入口,用户可跳出选项作答。无交互 UI 时自动降级为文本提问。",
68
70
  questionPrompt: "问题",
69
71
  questionHeader: "短标题(≤12 字符)",
70
72
  questionLabel: "选项显示文本",
71
73
  questionDescription: "选项说明",
74
+ questionCustom: "✏️ 自行输入…",
75
+ questionCustomPrompt: "输入你的想法(空提交或 Esc 返回选项)",
72
76
  };
73
77
 
74
78
  const EN: ToolTexts = {
@@ -106,11 +110,14 @@ const EN: ToolTexts = {
106
110
  outcomeReason:
107
111
  "required for blocked/waiting_for_input/still_working: the reason",
108
112
  question:
109
- 'Ask the user structured multiple-choice questions to settle decisions or clarify ambiguity; put the recommended option first and append "(recommended)" to its label. Falls back to a text question without interactive UI.',
113
+ 'Ask the user structured multiple-choice questions to settle decisions or clarify ambiguity; put the recommended option first and append "(recommended)" to its label. A custom-input entry is appended to the choice list so the user can answer in free text. Falls back to a text question without interactive UI.',
110
114
  questionPrompt: "The question",
111
115
  questionHeader: "Short header (≤12 chars)",
112
116
  questionLabel: "Option display text",
113
117
  questionDescription: "Option description",
118
+ questionCustom: "✏️ Type something…",
119
+ questionCustomPrompt:
120
+ "Type your answer (empty submit or Esc goes back to options)",
114
121
  };
115
122
 
116
123
  export function toolTexts(lang: Lang): ToolTexts {
@@ -1,4 +1,4 @@
1
- /** question:结构化提问工具(精简自官方 question.ts 模式)。 */
1
+ /** question:结构化提问工具(精简自官方 question.ts 模式,选项自带自由输入入口)。 */
2
2
 
3
3
  import type {
4
4
  ExtensionAPI,
@@ -8,6 +8,10 @@ import { Type } from "typebox";
8
8
  import type { Lang } from "../core/prompts.ts";
9
9
  import { toolTexts } from "./descriptions.ts";
10
10
 
11
+ /** 上游模型偶发在流式工具参数里夹带控制符(CR 会被 IDE 渲染成方块、零宽字符不可见),UI 文本一律清洗。 */
12
+ const stripControlNoise = (s: string): string =>
13
+ s.replace(/[\r\u200b-\u200d\ufeff]/g, "");
14
+
11
15
  export function registerQuestion(pi: ExtensionAPI, lang: Lang): void {
12
16
  const T = toolTexts(lang);
13
17
  const QuestionT = Type.Object({
@@ -34,8 +38,19 @@ export function registerQuestion(pi: ExtensionAPI, lang: Lang): void {
34
38
  description: T.question,
35
39
  parameters: Params,
36
40
  async execute(_id, params, _signal, _onUpdate, ctx: ExtensionToolContext) {
41
+ const questions = params.questions.map((q) => ({
42
+ question: stripControlNoise(q.question),
43
+ header: stripControlNoise(q.header),
44
+ options: q.options.map((o) => ({
45
+ ...o,
46
+ label: stripControlNoise(o.label),
47
+ ...(o.description
48
+ ? { description: stripControlNoise(o.description) }
49
+ : {}),
50
+ })),
51
+ }));
37
52
  if (!ctx.hasUI) {
38
- const rendered = params.questions
53
+ const rendered = questions
39
54
  .map(
40
55
  (q, i) =>
41
56
  `${i + 1}. ${q.question}\n${q.options.map((o) => ` - ${o.label}${o.description ? `:${o.description}` : ""}`).join("\n")}`,
@@ -52,23 +67,38 @@ export function registerQuestion(pi: ExtensionAPI, lang: Lang): void {
52
67
  };
53
68
  }
54
69
  const answers: string[] = [];
55
- for (const q of params.questions) {
56
- const choice = await ctx.ui.select(
57
- q.question,
58
- q.options.map((o) => o.label),
59
- );
60
- if (choice === undefined) {
61
- return {
62
- content: [
63
- {
64
- type: "text" as const,
65
- text: "用户取消了提问。请根据上下文继续,不要重复询问。",
66
- },
67
- ],
68
- details: undefined,
69
- };
70
+ for (const q of questions) {
71
+ // 自由输入入口追加在选项末尾;AI 选项恰好同名时复用为该入口,不重复追加
72
+ const custom = T.questionCustom;
73
+ const labels = q.options.map((o) => o.label);
74
+ const options = labels.includes(custom) ? labels : [...labels, custom];
75
+ // 输入为空或取消 → 回到选项列表(镜像官方示例:编辑器 Esc 返回选项)
76
+ while (true) {
77
+ const choice = await ctx.ui.select(q.question, options);
78
+ if (choice === undefined) {
79
+ return {
80
+ content: [
81
+ {
82
+ type: "text" as const,
83
+ text: "用户取消了提问。请根据上下文继续,不要重复询问。",
84
+ },
85
+ ],
86
+ details: undefined,
87
+ };
88
+ }
89
+ if (choice !== custom) {
90
+ answers.push(`${q.header}: ${choice}`);
91
+ break;
92
+ }
93
+ const customAnswer = await ctx.ui.input(
94
+ q.question,
95
+ T.questionCustomPrompt,
96
+ );
97
+ if (customAnswer?.trim()) {
98
+ answers.push(`${q.header}: ${customAnswer.trim()}`);
99
+ break;
100
+ }
70
101
  }
71
- answers.push(`${q.header}: ${choice}`);
72
102
  }
73
103
  return {
74
104
  content: [