@trim21/personal-pi-extensions 0.0.341 → 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 +1 -1
- package/src/bwrap/runtime.ts +15 -4
package/package.json
CHANGED
package/src/bwrap/runtime.ts
CHANGED
|
@@ -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(
|
|
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:勾选 =
|
|
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> = {};
|