@gotgenes/pi-permission-system 18.1.2 → 18.2.0
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 +9 -0
- package/package.json +1 -1
- package/src/extension-config.ts +7 -0
- package/src/forwarded-permissions/permission-forwarder.ts +6 -3
- package/src/handlers/gates/helpers.ts +1 -1
- package/src/handlers/gates/runner.ts +22 -0
- package/src/index.ts +10 -6
- package/src/permission-manager.ts +21 -1
- package/src/permission-prompter.ts +10 -16
- package/src/prompting-gateway.ts +13 -17
- package/src/rule.ts +21 -1
- package/src/status.ts +1 -1
- package/src/yolo-mode.ts +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [18.2.0](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v18.1.2...pi-permission-system-v18.2.0) (2026-07-06)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **pi-permission-system:** add yolo rule origin and ask→allow rewrite helper ([a4bbcc0](https://github.com/gotgenes/pi-packages/commit/a4bbcc0f25d57e31c7658e48ec5bc4465a4c1908))
|
|
14
|
+
* **pi-permission-system:** auto-approve yolo-origin allow in the gate runner ([caf8419](https://github.com/gotgenes/pi-packages/commit/caf8419f835b37693678fccf77373a828f850386))
|
|
15
|
+
* **pi-permission-system:** rewrite ask rules to yolo-origin allow at check time ([cd4e509](https://github.com/gotgenes/pi-packages/commit/cd4e509290aed701928890a6df585b383abbfc2b))
|
|
16
|
+
|
|
8
17
|
## [18.1.2](https://github.com/gotgenes/pi-packages/compare/pi-permission-system-v18.1.1...pi-permission-system-v18.1.2) (2026-07-05)
|
|
9
18
|
|
|
10
19
|
|
package/package.json
CHANGED
package/src/extension-config.ts
CHANGED
|
@@ -66,6 +66,13 @@ export function normalizePermissionSystemConfig(
|
|
|
66
66
|
return result;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
export function isYoloModeEnabled(
|
|
70
|
+
config: PermissionSystemExtensionConfig,
|
|
71
|
+
): boolean {
|
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion -- typed as boolean but may be undefined at runtime (untyped callers); Boolean() guards against that
|
|
73
|
+
return Boolean(config.yoloMode);
|
|
74
|
+
}
|
|
75
|
+
|
|
69
76
|
export function ensurePermissionSystemLogsDirectory(
|
|
70
77
|
logsDir: string,
|
|
71
78
|
): string | undefined {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
type SessionEntryView,
|
|
7
7
|
} from "#src/active-agent";
|
|
8
8
|
import type { ConfigReader } from "#src/config-store";
|
|
9
|
+
import { isYoloModeEnabled } from "#src/extension-config";
|
|
9
10
|
import type {
|
|
10
11
|
PermissionDecisionUi,
|
|
11
12
|
PermissionPromptDecision,
|
|
@@ -31,7 +32,6 @@ import type { DebugReviewLogger } from "#src/session-logger";
|
|
|
31
32
|
import { isSubagentExecutionContext } from "#src/subagent-context";
|
|
32
33
|
import type { SubagentSessionRegistry } from "#src/subagent-registry";
|
|
33
34
|
import { toRecord } from "#src/value-guards";
|
|
34
|
-
import { shouldAutoApprovePermissionState } from "#src/yolo-mode";
|
|
35
35
|
|
|
36
36
|
import {
|
|
37
37
|
cleanupPermissionForwardingLocationIfEmpty,
|
|
@@ -90,7 +90,7 @@ export interface PermissionForwarderDeps {
|
|
|
90
90
|
message: string,
|
|
91
91
|
options?: RequestPermissionOptions,
|
|
92
92
|
) => Promise<PermissionPromptDecision>;
|
|
93
|
-
/** Read current config for
|
|
93
|
+
/** Read current config for the retained forwarded-inbox yolo auto-approve check. */
|
|
94
94
|
config: ConfigReader;
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -506,7 +506,10 @@ export class PermissionForwarder implements ApprovalRequester, InboxProcessor {
|
|
|
506
506
|
approved: false,
|
|
507
507
|
state: "denied",
|
|
508
508
|
};
|
|
509
|
-
|
|
509
|
+
// Last yolo check outside the composed ruleset: dissolves when
|
|
510
|
+
// processInbox is refactored onto evaluate() + Authorizer selection in
|
|
511
|
+
// the Phase 9 spine work.
|
|
512
|
+
if (isYoloModeEnabled(this.config.current())) {
|
|
510
513
|
this.logger.review(
|
|
511
514
|
"forwarded_permission.auto_approved",
|
|
512
515
|
forwardedPermissionLogDetails,
|
|
@@ -62,7 +62,7 @@ export function deriveResolution(
|
|
|
62
62
|
canConfirm: boolean,
|
|
63
63
|
autoApproved = false,
|
|
64
64
|
): PermissionDecisionResolution {
|
|
65
|
-
if (state === "allow") return "policy_allow";
|
|
65
|
+
if (state === "allow") return autoApproved ? "auto_approved" : "policy_allow";
|
|
66
66
|
if (state === "deny") return "policy_deny";
|
|
67
67
|
// state === "ask"
|
|
68
68
|
if (action === "allow") {
|
|
@@ -105,6 +105,28 @@ export class GateRunner {
|
|
|
105
105
|
return { action: "allow" };
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
// 2b. Yolo fast-path — a composition-stage ask→allow rewrite records
|
|
109
|
+
// origin "yolo" on the matched rule. Auto-approve without prompting,
|
|
110
|
+
// preserving today's single auto_approved review entry + decision event
|
|
111
|
+
// so review-log parity holds (#526).
|
|
112
|
+
if (check.state === "allow" && check.origin === "yolo") {
|
|
113
|
+
this.reporter.writeReviewLog("permission_request.auto_approved", {
|
|
114
|
+
...descriptor.logContext,
|
|
115
|
+
agentName,
|
|
116
|
+
resolution: "auto_approved",
|
|
117
|
+
});
|
|
118
|
+
this.reporter.emitDecision(
|
|
119
|
+
buildDecisionEvent(
|
|
120
|
+
descriptor.decision,
|
|
121
|
+
check,
|
|
122
|
+
agentName,
|
|
123
|
+
"allow",
|
|
124
|
+
deriveResolution(check.state, "allow", false, false, true),
|
|
125
|
+
),
|
|
126
|
+
);
|
|
127
|
+
return { action: "allow" };
|
|
128
|
+
}
|
|
129
|
+
|
|
108
130
|
// 3. Apply the deny/ask/allow gate
|
|
109
131
|
const canConfirm = this.prompter.canConfirm();
|
|
110
132
|
|
package/src/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { getGlobalConfigPath } from "./config-paths";
|
|
|
6
6
|
import { ConfigStore } from "./config-store";
|
|
7
7
|
import { DecisionAudit } from "./decision-audit";
|
|
8
8
|
import { GateDecisionReporter } from "./decision-reporter";
|
|
9
|
+
import { isYoloModeEnabled } from "./extension-config";
|
|
9
10
|
import { computeExtensionPaths } from "./extension-paths";
|
|
10
11
|
import {
|
|
11
12
|
PermissionForwarder,
|
|
@@ -46,10 +47,6 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
|
|
|
46
47
|
// session (PathNormalizer) and, later, rule evaluation. Interior modules must
|
|
47
48
|
// not read process.platform (enforced by the eslint guard scoped to src/).
|
|
48
49
|
const hostPlatform = process.platform;
|
|
49
|
-
const permissionManager = new PermissionManager({
|
|
50
|
-
agentDir,
|
|
51
|
-
platform: hostPlatform,
|
|
52
|
-
});
|
|
53
50
|
const sessionRules = new SessionRules();
|
|
54
51
|
const subagentRegistry = getSubagentSessionRegistry();
|
|
55
52
|
const formatterRegistry = new ToolInputFormatterRegistry();
|
|
@@ -65,6 +62,15 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
|
|
|
65
62
|
// eslint-disable-next-line prefer-const -- forward-declared let; `const` requires an initializer
|
|
66
63
|
let session: PermissionSession;
|
|
67
64
|
|
|
65
|
+
// Constructed after the `configStore` forward declaration so the yolo reader
|
|
66
|
+
// can close over it; the closure runs per check(), after configStore is
|
|
67
|
+
// assigned below. yolo becomes a composition-stage ask→allow rewrite (#526).
|
|
68
|
+
const permissionManager = new PermissionManager({
|
|
69
|
+
agentDir,
|
|
70
|
+
platform: hostPlatform,
|
|
71
|
+
isYoloEnabled: () => isYoloModeEnabled(configStore.current()),
|
|
72
|
+
});
|
|
73
|
+
|
|
68
74
|
const logger = new PermissionSessionLogger({
|
|
69
75
|
globalLogsDir: paths.globalLogsDir,
|
|
70
76
|
getConfig: () => configStore.current(),
|
|
@@ -90,14 +96,12 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
|
|
|
90
96
|
const forwarder = new PermissionForwarder(forwardingDeps);
|
|
91
97
|
|
|
92
98
|
const prompter = new PermissionPrompter({
|
|
93
|
-
config: configStore,
|
|
94
99
|
logger,
|
|
95
100
|
events: pi.events,
|
|
96
101
|
forwarder,
|
|
97
102
|
});
|
|
98
103
|
|
|
99
104
|
const gateway = new PromptingGateway({
|
|
100
|
-
config: configStore,
|
|
101
105
|
subagentSessionsDir: paths.subagentSessionsDir,
|
|
102
106
|
platform: hostPlatform,
|
|
103
107
|
registry: subagentRegistry,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
evaluateAnyValue,
|
|
21
21
|
evaluateFirst,
|
|
22
22
|
pathMatchOptions,
|
|
23
|
+
rewriteAsksToYolo,
|
|
23
24
|
} from "./rule";
|
|
24
25
|
import { mergeScopesWithOrigins } from "./scope-merge";
|
|
25
26
|
import {
|
|
@@ -53,6 +54,9 @@ const DEFAULT_UNIVERSAL_FALLBACK: PermissionState = "ask";
|
|
|
53
54
|
/** Promotion predicate matching no token — the no-`path`-rules default (#509). */
|
|
54
55
|
const NO_PROMOTION: PathRuleTokenMatcher = () => false;
|
|
55
56
|
|
|
57
|
+
/** Default yolo reader — yolo disabled unless the composition root injects one. */
|
|
58
|
+
const YOLO_DISABLED = (): boolean => false;
|
|
59
|
+
|
|
56
60
|
type FileCacheEntry<TValue> = {
|
|
57
61
|
stamp: string;
|
|
58
62
|
value: TValue;
|
|
@@ -110,11 +114,20 @@ export interface PermissionManagerOptions extends PolicyLoaderOptions {
|
|
|
110
114
|
* Defaults to a POSIX flavor; production always supplies the real platform.
|
|
111
115
|
*/
|
|
112
116
|
platform?: NodeJS.Platform;
|
|
117
|
+
/**
|
|
118
|
+
* yolo-mode reader, injected from the composition root. When it reports
|
|
119
|
+
* true, {@link PermissionManager.check} rewrites every matched `ask` to a
|
|
120
|
+
* standing `allow` tagged `origin: "yolo"` (recorded authority, #526).
|
|
121
|
+
* Read per check so a mid-session config change takes effect; defaults to
|
|
122
|
+
* yolo disabled.
|
|
123
|
+
*/
|
|
124
|
+
isYoloEnabled?: () => boolean;
|
|
113
125
|
}
|
|
114
126
|
|
|
115
127
|
export class PermissionManager implements ScopedPermissionManager {
|
|
116
128
|
private readonly agentDir: string | undefined;
|
|
117
129
|
private readonly platform: NodeJS.Platform;
|
|
130
|
+
private readonly isYoloEnabled: () => boolean;
|
|
118
131
|
private loader: PolicyLoader;
|
|
119
132
|
private readonly resolvedPermissionsCache = new Map<
|
|
120
133
|
string,
|
|
@@ -124,6 +137,7 @@ export class PermissionManager implements ScopedPermissionManager {
|
|
|
124
137
|
constructor(options: PermissionManagerOptions = {}) {
|
|
125
138
|
this.agentDir = options.agentDir;
|
|
126
139
|
this.platform = options.platform ?? "linux";
|
|
140
|
+
this.isYoloEnabled = options.isYoloEnabled ?? YOLO_DISABLED;
|
|
127
141
|
this.loader =
|
|
128
142
|
options.policyLoader ??
|
|
129
143
|
new FilePolicyLoader(
|
|
@@ -311,9 +325,15 @@ export class PermissionManager implements ScopedPermissionManager {
|
|
|
311
325
|
sessionRules?: Ruleset,
|
|
312
326
|
): PermissionCheckResult {
|
|
313
327
|
const { composedRules } = this.resolvePermissions(intent.agentName);
|
|
314
|
-
const
|
|
328
|
+
const composedWithSession: Ruleset = sessionRules?.length
|
|
315
329
|
? [...composedRules, ...sessionRules]
|
|
316
330
|
: composedRules;
|
|
331
|
+
// Apply the yolo rewrite post-cache so the resolved-permissions cache and
|
|
332
|
+
// the display surfaces (getComposedConfigRules / getToolPermission) stay
|
|
333
|
+
// yolo-free — only the resolution path sees the ask→allow rewrite (#526).
|
|
334
|
+
const fullRules: Ruleset = this.isYoloEnabled()
|
|
335
|
+
? rewriteAsksToYolo(composedWithSession)
|
|
336
|
+
: composedWithSession;
|
|
317
337
|
|
|
318
338
|
if (intent.kind === "path-values") {
|
|
319
339
|
const lookupValues =
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { ConfigReader } from "./config-store";
|
|
3
2
|
import type { ApprovalRequester } from "./forwarded-permissions/permission-forwarder";
|
|
4
3
|
import type { PermissionPromptDecision } from "./permission-dialog";
|
|
5
4
|
import {
|
|
@@ -8,7 +7,6 @@ import {
|
|
|
8
7
|
} from "./permission-events";
|
|
9
8
|
import { buildDirectUiPrompt } from "./permission-ui-prompt";
|
|
10
9
|
import type { ReviewLogger } from "./session-logger";
|
|
11
|
-
import { shouldAutoApprovePermissionState } from "./yolo-mode";
|
|
12
10
|
|
|
13
11
|
export type PermissionReviewSource = "tool_call" | "skill_input" | "skill_read";
|
|
14
12
|
|
|
@@ -40,13 +38,11 @@ export interface PermissionPrompterApi {
|
|
|
40
38
|
/**
|
|
41
39
|
* Dependencies required by PermissionPrompter.
|
|
42
40
|
*
|
|
43
|
-
* Keeps the prompter's external surface narrow: callers provide
|
|
44
|
-
*
|
|
45
|
-
*
|
|
41
|
+
* Keeps the prompter's external surface narrow: callers provide a review
|
|
42
|
+
* logger, the UI-prompt event bus, and the forwarder that owns the
|
|
43
|
+
* UI/subagent-forwarding branching logic.
|
|
46
44
|
*/
|
|
47
45
|
export interface PermissionPrompterDeps {
|
|
48
|
-
/** Read current config for yolo-mode check (called at prompt time). */
|
|
49
|
-
config: ConfigReader;
|
|
50
46
|
/** Write structured entries to the permission review log. */
|
|
51
47
|
logger: ReviewLogger;
|
|
52
48
|
/** Event bus used for UI prompt broadcasts. */
|
|
@@ -57,10 +53,13 @@ export interface PermissionPrompterDeps {
|
|
|
57
53
|
|
|
58
54
|
/**
|
|
59
55
|
* Encapsulates the full permission-prompt flow:
|
|
60
|
-
* 1.
|
|
61
|
-
* 2.
|
|
62
|
-
* 3.
|
|
63
|
-
*
|
|
56
|
+
* 1. Review-log "waiting" entry.
|
|
57
|
+
* 2. UI-present vs. subagent-forwarding branching (via confirmPermission).
|
|
58
|
+
* 3. Review-log "approved" / "denied" entry.
|
|
59
|
+
*
|
|
60
|
+
* Yolo-mode auto-approval happens upstream, at the composition stage
|
|
61
|
+
* (`PermissionManager.check`'s `rewriteAsksToYolo`) — an `ask` never reaches
|
|
62
|
+
* this class under yolo, so this class has no yolo-mode knowledge.
|
|
64
63
|
*
|
|
65
64
|
* Injecting a single PermissionPrompter instance means adding a new prompt
|
|
66
65
|
* parameter (e.g. a future sessionLabel variant) only requires changing
|
|
@@ -73,11 +72,6 @@ export class PermissionPrompter implements PermissionPrompterApi {
|
|
|
73
72
|
ctx: ExtensionContext,
|
|
74
73
|
details: PromptPermissionDetails,
|
|
75
74
|
): Promise<PermissionPromptDecision> {
|
|
76
|
-
if (shouldAutoApprovePermissionState("ask", this.deps.config.current())) {
|
|
77
|
-
this.writeReviewEntry("permission_request.auto_approved", details);
|
|
78
|
-
return { approved: true, state: "approved", autoApproved: true };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
75
|
this.writeReviewEntry("permission_request.waiting", details);
|
|
82
76
|
|
|
83
77
|
// Build the event once. When this session has UI it broadcasts directly;
|
package/src/prompting-gateway.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
|
|
3
|
-
import type { ConfigReader } from "./config-store";
|
|
4
3
|
import type { GatePrompter } from "./gate-prompter";
|
|
5
4
|
import type { PermissionPromptDecision } from "./permission-dialog";
|
|
6
5
|
import type {
|
|
@@ -9,18 +8,15 @@ import type {
|
|
|
9
8
|
} from "./permission-prompter";
|
|
10
9
|
import { isSubagentExecutionContext } from "./subagent-context";
|
|
11
10
|
import type { SubagentSessionRegistry } from "./subagent-registry";
|
|
12
|
-
import { canResolveAskPermissionRequest } from "./yolo-mode";
|
|
13
11
|
|
|
14
12
|
/**
|
|
15
13
|
* Dependencies required by PromptingGateway.
|
|
16
14
|
*
|
|
17
|
-
* All
|
|
18
|
-
* - `
|
|
15
|
+
* All fields are actively consumed:
|
|
16
|
+
* - `subagentSessionsDir` + `registry` drive `canConfirm()`.
|
|
19
17
|
* - `prompter` is called by `prompt()`.
|
|
20
18
|
*/
|
|
21
19
|
export interface PromptingGatewayDeps {
|
|
22
|
-
/** Read current config for the yolo-mode branch of the can-prompt policy. */
|
|
23
|
-
config: ConfigReader;
|
|
24
20
|
/** Static path used to detect a forwarding subagent context. */
|
|
25
21
|
subagentSessionsDir: string;
|
|
26
22
|
/** Host platform, injected from the composition root, for subagent-context path detection. */
|
|
@@ -46,8 +42,8 @@ export interface PromptingGatewayLifecycle {
|
|
|
46
42
|
* Context-owning implementation of the GatePrompter role.
|
|
47
43
|
*
|
|
48
44
|
* Owns the stored ExtensionContext and the "can we prompt?" policy
|
|
49
|
-
* (UI / subagent
|
|
50
|
-
*
|
|
45
|
+
* (UI / subagent), replacing the four twin methods that previously
|
|
46
|
+
* lived on PermissionSession.
|
|
51
47
|
*
|
|
52
48
|
* Lifecycle: PermissionSession drives activate/deactivate so the stored
|
|
53
49
|
* context mirrors the session context without independent call-site changes.
|
|
@@ -72,22 +68,22 @@ export class PromptingGateway
|
|
|
72
68
|
/**
|
|
73
69
|
* Whether an interactive permission prompt can be shown.
|
|
74
70
|
*
|
|
75
|
-
* Returns false when no context is active. Otherwise
|
|
76
|
-
*
|
|
77
|
-
*
|
|
71
|
+
* Returns false when no context is active. Otherwise true when the
|
|
72
|
+
* context has UI or is a forwarding subagent — the two Authorizer-
|
|
73
|
+
* selection predicates the Phase 9 spine will consume. Yolo-mode never
|
|
74
|
+
* reaches this policy: it is resolved upstream at the composition stage.
|
|
78
75
|
*/
|
|
79
76
|
canConfirm(): boolean {
|
|
80
77
|
if (this.context === null) return false;
|
|
81
|
-
return
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
isSubagent: isSubagentExecutionContext(
|
|
78
|
+
return (
|
|
79
|
+
this.context.hasUI ||
|
|
80
|
+
isSubagentExecutionContext(
|
|
85
81
|
this.context,
|
|
86
82
|
this.deps.subagentSessionsDir,
|
|
87
83
|
this.deps.platform,
|
|
88
84
|
this.deps.registry,
|
|
89
|
-
)
|
|
90
|
-
|
|
85
|
+
)
|
|
86
|
+
);
|
|
91
87
|
}
|
|
92
88
|
|
|
93
89
|
/**
|
package/src/rule.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { wildcardMatch } from "./wildcard-matcher";
|
|
|
9
9
|
* Synthesized: "builtin" (universal default / evaluate() fallback),
|
|
10
10
|
* "baseline" (conditional MCP metadata auto-allow).
|
|
11
11
|
* Runtime: "session" (session approvals).
|
|
12
|
+
* Rewrite: "yolo" (composition-stage ask→allow rewrite under yolo mode).
|
|
12
13
|
*/
|
|
13
14
|
export type RuleOrigin =
|
|
14
15
|
| "global"
|
|
@@ -17,7 +18,8 @@ export type RuleOrigin =
|
|
|
17
18
|
| "project-agent"
|
|
18
19
|
| "builtin"
|
|
19
20
|
| "baseline"
|
|
20
|
-
| "session"
|
|
21
|
+
| "session"
|
|
22
|
+
| "yolo";
|
|
21
23
|
|
|
22
24
|
/** A single permission rule — the atomic unit of policy. */
|
|
23
25
|
export interface Rule {
|
|
@@ -41,6 +43,24 @@ export interface Rule {
|
|
|
41
43
|
/** An ordered list of rules. Later rules take priority (last-match-wins). */
|
|
42
44
|
export type Ruleset = Rule[];
|
|
43
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Rewrite every `ask` rule to `allow`, tagged `origin: "yolo"`.
|
|
48
|
+
*
|
|
49
|
+
* The composition-stage expression of yolo mode as recorded authority: when
|
|
50
|
+
* enabled, an `ask` becomes a standing `allow` grant in the ruleset rather than
|
|
51
|
+
* a live prompt-path concern. `deny` and existing `allow` rules pass through
|
|
52
|
+
* untouched, so yolo suppresses prompts but preserves hard denies.
|
|
53
|
+
*
|
|
54
|
+
* Pure and non-mutating — `surface`, `pattern`, and `layer` are preserved so
|
|
55
|
+
* downstream `matchedPattern` / source derivation is unaffected; only `action`
|
|
56
|
+
* and `origin` change.
|
|
57
|
+
*/
|
|
58
|
+
export function rewriteAsksToYolo(rules: Ruleset): Ruleset {
|
|
59
|
+
return rules.map((rule) =>
|
|
60
|
+
rule.action === "ask" ? { ...rule, action: "allow", origin: "yolo" } : rule,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
44
64
|
/**
|
|
45
65
|
* Pure permission evaluation.
|
|
46
66
|
*
|
package/src/status.ts
CHANGED
|
@@ -5,9 +5,9 @@ import type {
|
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
EXTENSION_ID,
|
|
8
|
+
isYoloModeEnabled,
|
|
8
9
|
type PermissionSystemExtensionConfig,
|
|
9
10
|
} from "./extension-config";
|
|
10
|
-
import { isYoloModeEnabled } from "./yolo-mode";
|
|
11
11
|
|
|
12
12
|
export const PERMISSION_SYSTEM_STATUS_KEY = EXTENSION_ID;
|
|
13
13
|
export const PERMISSION_SYSTEM_YOLO_STATUS_VALUE = "yolo";
|
package/src/yolo-mode.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { PermissionSystemExtensionConfig } from "./extension-config";
|
|
2
|
-
import type { PermissionState } from "./types";
|
|
3
|
-
|
|
4
|
-
export interface AskPermissionResolutionOptions {
|
|
5
|
-
config: PermissionSystemExtensionConfig;
|
|
6
|
-
hasUI: boolean;
|
|
7
|
-
isSubagent: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function isYoloModeEnabled(
|
|
11
|
-
config: PermissionSystemExtensionConfig,
|
|
12
|
-
): boolean {
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion -- typed as boolean but may be undefined at runtime (untyped callers); Boolean() guards against that
|
|
14
|
-
return Boolean(config.yoloMode);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function shouldAutoApprovePermissionState(
|
|
18
|
-
state: PermissionState,
|
|
19
|
-
config: PermissionSystemExtensionConfig,
|
|
20
|
-
): boolean {
|
|
21
|
-
return state === "ask" && isYoloModeEnabled(config);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function canResolveAskPermissionRequest(
|
|
25
|
-
options: AskPermissionResolutionOptions,
|
|
26
|
-
): boolean {
|
|
27
|
-
return (
|
|
28
|
-
options.hasUI || options.isSubagent || isYoloModeEnabled(options.config)
|
|
29
|
-
);
|
|
30
|
-
}
|