@trim21/personal-pi-extensions 0.0.244 → 0.0.245

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trim21/personal-pi-extensions",
3
- "version": "0.0.244",
3
+ "version": "0.0.245",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
@@ -182,31 +182,37 @@ export class BwrapRuntime {
182
182
  const policy = resolveEscalation({ hasUI: ctx.hasUI });
183
183
  if (policy.kind === "deny") throw new Error(policy.reason);
184
184
  const description = `Allow this command to run without sandbox?\n---\n\nReason: ${escapeHtml(reason ?? "(No reason provided by model)")}\n---\n${fenceCodeBlock(command)}`;
185
- while (true) {
186
- const result = await selectWithOptionalInput(
187
- description,
188
- [
189
- { label: "Approve once" },
190
- { label: "Block" },
191
- { label: "Block with reason", inputPrompt: "Why was this denied?" },
192
- ],
193
- ctx.ui,
194
- { signal: ctx.signal },
195
- );
196
- if (result === undefined) {
197
- ctx.abort();
198
- throw new Error("User denied the command execution.");
199
- }
200
- if (result.label === "Approve once") return;
201
- if (result.label === "Block") throw new Error("User denied unsandboxed execution.");
202
- // "Block with reason":取消输入则重新询问;空输入同样拒绝(不带反馈文本)
203
- if (result.input === undefined) continue;
204
- throw new Error(
205
- result.input
206
- ? `User denied unsandboxed execution: ${result.input}`
207
- : "User denied unsandboxed execution.",
208
- );
185
+
186
+ // 单选 1:允许还是拦截(关闭对话框 = 中断并拒绝)
187
+ const verdict = await selectWithOptionalInput(
188
+ description,
189
+ [{ label: "Approve once" }, { label: "Block" }],
190
+ ctx.ui,
191
+ { signal: ctx.signal },
192
+ );
193
+ if (verdict === undefined) {
194
+ ctx.abort();
195
+ throw new Error("User denied the command execution.");
209
196
  }
197
+ if (verdict.label === "Approve once") return;
198
+
199
+ // 单选 2 + input 组合:直接拦截还是附带理由;选 "Block with reason"
200
+ // 自动弹输入框。关闭对话框/取消输入/空白都按无理由拒绝,不循环重问。
201
+ const style = await selectWithOptionalInput(
202
+ "Block this command?",
203
+ [{ label: "Block" }, { label: "Block with reason", inputPrompt: "Why was this denied?" }],
204
+ ctx.ui,
205
+ { signal: ctx.signal },
206
+ );
207
+ if (style === undefined || style.label === "Block") {
208
+ throw new Error("User denied unsandboxed execution.");
209
+ }
210
+ const feedback = style.input?.trim() ?? "";
211
+ throw new Error(
212
+ feedback
213
+ ? `User denied unsandboxed execution: ${feedback}`
214
+ : "User denied unsandboxed execution.",
215
+ );
210
216
  }
211
217
 
212
218
  private registerCommands(pi: ExtensionAPI): void {