@trim21/personal-pi-extensions 0.0.340 → 0.0.342

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.340",
3
+ "version": "0.0.342",
4
4
  "type": "module",
5
5
  "description": "Custom pi coding-agent extensions: bwrap sandbox, workspace guard, opencode edit, and more",
6
6
  "keywords": [
package/src/aft/tools.ts CHANGED
@@ -231,7 +231,6 @@ export function registerZoomTool(pi: ExtensionAPI, ctx: AftToolContext): void {
231
231
  output: text,
232
232
  truncated,
233
233
  }),
234
- expanded: true,
235
234
  } satisfies ToolPendant,
236
235
  },
237
236
  };
@@ -448,7 +448,11 @@ export class BwrapRuntime {
448
448
  lines.push("", outcome.suggestion.text, "---");
449
449
  }
450
450
  if (patterns.length > 0) {
451
- lines.push("", "勾选规则将永久允许(allow forever),未勾选规则仅本次放行:", "---");
451
+ lines.push(
452
+ "",
453
+ "勾选规则将持久化为允许规则(后续同模式命令自动放行),未勾选规则仅本次处理:",
454
+ "---",
455
+ );
452
456
  }
453
457
  lines.push(fenceCodeBlock(command));
454
458
  // workdir 存在时展示实际执行目录(ctx.cwd 已被 bash 工具解析为绝对路径)
@@ -490,8 +494,9 @@ export class BwrapRuntime {
490
494
  }
491
495
  }
492
496
 
493
- // 每个识别到的 pattern 一个 checkbox:勾选 = 该规则 allow forever。
494
- // Allow once = 执行本次并持久化勾选的规则;Deny 系列不持久化任何规则。
497
+ // 每个识别到的 pattern 一个 checkbox:勾选 = 持久化为 allow 规则。
498
+ // Allow once = 执行本次并持久化勾选的规则;Deny 系列 = 拒绝本次,
499
+ // 勾选的规则仍持久化(用户确认该模式可信,只是本次命令不执行)。
495
500
  const actions = [
496
501
  { action: "allow-once", label: ALLOW_ONCE },
497
502
  { action: "deny", label: DENY },
@@ -521,9 +526,15 @@ export class BwrapRuntime {
521
526
  return;
522
527
  }
523
528
  case "deny": {
529
+ if (verdict.selected.length > 0) {
530
+ await this.persistAllowRule(ctx, command, verdict.selected);
531
+ }
524
532
  throw new Error("User denied unsandboxed execution.");
525
533
  }
526
534
  case "deny-with-reason": {
535
+ if (verdict.selected.length > 0) {
536
+ await this.persistAllowRule(ctx, command, verdict.selected);
537
+ }
527
538
  const feedback = verdict.input?.trim() ?? "";
528
539
  throw new Error(
529
540
  feedback
@@ -541,7 +552,7 @@ export class BwrapRuntime {
541
552
  patterns?: string[],
542
553
  ): Promise<void> {
543
554
  const rulePatterns = patterns ?? (await commandPatternsFor(command));
544
- if (rulePatterns.length === 0) return; // 解析失败:本次放行,不写规则
555
+ if (rulePatterns.length === 0) return; // 解析失败:本次处理,不写规则
545
556
  const newRules: ApprovalRule[] = rulePatterns.map((pattern) => ({ action: "allow", pattern }));
546
557
  const { project } = getBwrapConfigPaths(ctx.cwd);
547
558
  let config: Record<string, unknown> = {};