feat: add permissions status script (#681)

This commit is contained in:
jnjpng
2026-01-26 11:20:21 -08:00
committed by GitHub
parent abb98d7571
commit d950db3afd
4 changed files with 97 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
// src/hooks/index.ts
// Main hooks module - provides high-level API for running hooks
import { sessionPermissions } from "../permissions/session";
import { executeHooks, executeHooksParallel } from "./executor";
import { getHooksForEvent, hasHooksForEvent, loadHooks } from "./loader";
import type {
@@ -120,6 +121,7 @@ export async function runPermissionRequestHooks(
type: permissionType,
scope,
},
session_permissions: sessionPermissions.getRules(),
};
// Run sequentially - first hook that returns 0 or 2 determines outcome

View File

@@ -194,6 +194,12 @@ export interface PermissionRequestHookInput extends HookInputBase {
type: "allow" | "deny" | "ask";
scope?: "session" | "project" | "user";
};
/** Current session permissions (in-memory only, cleared on exit) */
session_permissions?: {
allow?: string[];
deny?: string[];
ask?: string[];
};
}
/**

View File

@@ -403,11 +403,16 @@ export async function checkToolPermission(
matchedRule?: string;
reason?: string;
}> {
const { checkPermission } = await import("../permissions/checker");
const { checkPermissionWithHooks } = await import("../permissions/checker");
const { loadPermissions } = await import("../permissions/loader");
const permissions = await loadPermissions(workingDirectory);
return checkPermission(toolName, toolArgs, permissions, workingDirectory);
return checkPermissionWithHooks(
toolName,
toolArgs,
permissions,
workingDirectory,
);
}
/**