vouchington-tooling 0.59.0 → 0.61.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/README.md +108 -0
- package/dist/cli/commands/hook.d.mts +2 -0
- package/dist/cli/commands/hook.mjs +19 -0
- package/dist/cli/commands/sandbox-command-audit.d.mts +7 -0
- package/dist/cli/commands/sandbox-command-audit.mjs +27 -0
- package/dist/cli/index.mjs +8 -0
- package/dist/cli/parse-forwarded-commands.d.mts +9 -0
- package/dist/cli/parse-forwarded-commands.mjs +6 -0
- package/dist/cli/parse.d.mts +9 -0
- package/dist/cli/usage-text.d.mts +1 -0
- package/dist/cli/usage-text.mjs +179 -0
- package/dist/cli/usage.d.mts +2 -1
- package/dist/cli/usage.mjs +2 -156
- package/dist/command-policy/engine.d.mts +7 -0
- package/dist/command-policy/engine.mjs +58 -0
- package/dist/command-policy/git-patterns.d.mts +20 -0
- package/dist/command-policy/git-patterns.mjs +82 -0
- package/dist/command-policy/git-process.d.mts +4 -0
- package/dist/command-policy/git-process.mjs +54 -0
- package/dist/command-policy/github-checkout-owners.d.mts +22 -0
- package/dist/command-policy/github-checkout-owners.mjs +122 -0
- package/dist/command-policy/github-command-context.d.mts +6 -0
- package/dist/command-policy/github-command-context.mjs +19 -0
- package/dist/command-policy/github-command-cwd.d.mts +8 -0
- package/dist/command-policy/github-command-cwd.mjs +130 -0
- package/dist/command-policy/github-command-position.d.mts +7 -0
- package/dist/command-policy/github-command-position.mjs +12 -0
- package/dist/command-policy/github-configured-base.d.mts +25 -0
- package/dist/command-policy/github-configured-base.mjs +59 -0
- package/dist/command-policy/github-invocation.d.mts +9 -0
- package/dist/command-policy/github-invocation.mjs +80 -0
- package/dist/command-policy/github-merge-authority.d.mts +21 -0
- package/dist/command-policy/github-merge-authority.mjs +86 -0
- package/dist/command-policy/github-option-flags.d.mts +3 -0
- package/dist/command-policy/github-option-flags.mjs +67 -0
- package/dist/command-policy/github-options.d.mts +12 -0
- package/dist/command-policy/github-options.mjs +73 -0
- package/dist/command-policy/github-stack-workflow.d.mts +9 -0
- package/dist/command-policy/github-stack-workflow.mjs +94 -0
- package/dist/command-policy/github-workflow.d.mts +7 -0
- package/dist/command-policy/github-workflow.mjs +50 -0
- package/dist/command-policy/hook/args.d.mts +11 -0
- package/dist/command-policy/hook/args.mjs +49 -0
- package/dist/command-policy/hook/harness.d.mts +26 -0
- package/dist/command-policy/hook/harness.mjs +119 -0
- package/dist/command-policy/hook/policy-module.d.mts +7 -0
- package/dist/command-policy/hook/policy-module.mjs +48 -0
- package/dist/command-policy/hook/post-tool-use.d.mts +9 -0
- package/dist/command-policy/hook/post-tool-use.mjs +51 -0
- package/dist/command-policy/hook/pre-tool-use.d.mts +21 -0
- package/dist/command-policy/hook/pre-tool-use.mjs +45 -0
- package/dist/command-policy/hook/run.d.mts +17 -0
- package/dist/command-policy/hook/run.mjs +69 -0
- package/dist/command-policy/hook/types.d.mts +33 -0
- package/dist/command-policy/hook/types.mjs +5 -0
- package/dist/command-policy/index.d.mts +29 -0
- package/dist/command-policy/index.mjs +23 -0
- package/dist/command-policy/path-references.d.mts +14 -0
- package/dist/command-policy/path-references.mjs +68 -0
- package/dist/command-policy/path-rules.d.mts +11 -0
- package/dist/command-policy/path-rules.mjs +37 -0
- package/dist/command-policy/payload.d.mts +8 -0
- package/dist/command-policy/payload.mjs +54 -0
- package/dist/command-policy/types.d.mts +77 -0
- package/dist/command-policy/types.mjs +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/sandbox-command-audit/args.d.mts +20 -0
- package/dist/sandbox-command-audit/args.mjs +64 -0
- package/dist/sandbox-command-audit/classify-prefixes.d.mts +23 -0
- package/dist/sandbox-command-audit/classify-prefixes.mjs +50 -0
- package/dist/sandbox-command-audit/classify.d.mts +46 -0
- package/dist/sandbox-command-audit/classify.mjs +74 -0
- package/dist/sandbox-command-audit/claude-extract.d.mts +23 -0
- package/dist/sandbox-command-audit/claude-extract.mjs +76 -0
- package/dist/sandbox-command-audit/claude-tool-uses.d.mts +15 -0
- package/dist/sandbox-command-audit/claude-tool-uses.mjs +53 -0
- package/dist/sandbox-command-audit/codex-extract.d.mts +21 -0
- package/dist/sandbox-command-audit/codex-extract.mjs +77 -0
- package/dist/sandbox-command-audit/codex-scan.d.mts +11 -0
- package/dist/sandbox-command-audit/codex-scan.mjs +98 -0
- package/dist/sandbox-command-audit/codex-spool.d.mts +14 -0
- package/dist/sandbox-command-audit/codex-spool.mjs +46 -0
- package/dist/sandbox-command-audit/discover-files.d.mts +44 -0
- package/dist/sandbox-command-audit/discover-files.mjs +85 -0
- package/dist/sandbox-command-audit/failure-text.d.mts +7 -0
- package/dist/sandbox-command-audit/failure-text.mjs +34 -0
- package/dist/sandbox-command-audit/fixtures.test-helpers.d.mts +34 -0
- package/dist/sandbox-command-audit/fixtures.test-helpers.mjs +41 -0
- package/dist/sandbox-command-audit/index.d.mts +26 -0
- package/dist/sandbox-command-audit/index.mjs +15 -0
- package/dist/sandbox-command-audit/json-record.d.mts +6 -0
- package/dist/sandbox-command-audit/json-record.mjs +16 -0
- package/dist/sandbox-command-audit/limits.d.mts +30 -0
- package/dist/sandbox-command-audit/limits.mjs +66 -0
- package/dist/sandbox-command-audit/repo-scope.d.mts +25 -0
- package/dist/sandbox-command-audit/repo-scope.mjs +79 -0
- package/dist/sandbox-command-audit/report-raw.d.mts +16 -0
- package/dist/sandbox-command-audit/report-raw.mjs +55 -0
- package/dist/sandbox-command-audit/report.d.mts +10 -0
- package/dist/sandbox-command-audit/report.mjs +61 -0
- package/dist/sandbox-command-audit/run.d.mts +36 -0
- package/dist/sandbox-command-audit/run.mjs +70 -0
- package/dist/sandbox-command-audit/scan.d.mts +10 -0
- package/dist/sandbox-command-audit/scan.mjs +79 -0
- package/dist/sandbox-command-audit/transcript-cwd.d.mts +14 -0
- package/dist/sandbox-command-audit/transcript-cwd.mjs +153 -0
- package/dist/sandbox-command-audit/types.d.mts +59 -0
- package/dist/sandbox-command-audit/types.mjs +23 -0
- package/dist/tmux/cli-shared.d.mts +18 -0
- package/dist/tmux/cli-shared.mjs +8 -0
- package/dist/tmux/cli.d.mts +3 -0
- package/dist/tmux/cli.mjs +34 -0
- package/dist/tmux/config.d.mts +24 -0
- package/dist/tmux/config.mjs +91 -0
- package/dist/tmux/fake-tmux.test-helpers.d.mts +46 -0
- package/dist/tmux/fake-tmux.test-helpers.mjs +105 -0
- package/dist/tmux/hook-payload.d.mts +8 -0
- package/dist/tmux/hook-payload.mjs +39 -0
- package/dist/tmux/index.d.mts +9 -0
- package/dist/tmux/index.mjs +7 -0
- package/dist/tmux/launcher.d.mts +11 -0
- package/dist/tmux/launcher.mjs +127 -0
- package/dist/tmux/reminder-post-tool.d.mts +21 -0
- package/dist/tmux/reminder-post-tool.mjs +88 -0
- package/dist/tmux/runner.d.mts +11 -0
- package/dist/tmux/runner.mjs +26 -0
- package/dist/tmux/session-name.d.mts +5 -0
- package/dist/tmux/session-name.mjs +10 -0
- package/dist/tmux/shell-quote.d.mts +9 -0
- package/dist/tmux/shell-quote.mjs +16 -0
- package/dist/tmux/up.d.mts +2 -0
- package/dist/tmux/up.mjs +73 -0
- package/dist/tmux/windows.d.mts +18 -0
- package/dist/tmux/windows.mjs +50 -0
- package/package.json +16 -1
- package/scripts/__pycache__/run_bounded_process.cpython-312.pyc +0 -0
- package/scripts/tmux/tmux-agent-reminder.sh +68 -0
- package/scripts/tmux/tmux-name.sh +34 -0
- package/scripts/tmux/tmux-read-title.sh +13 -0
- package/scripts/tmux/tmux-target.sh +130 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { CommandPolicy, HookPayload } from '../types.mts';
|
|
2
|
+
export declare const HOOK_HARNESSES: readonly ["claude", "codex", "cursor", "grok"];
|
|
3
|
+
export type HookHarness = (typeof HOOK_HARNESSES)[number];
|
|
4
|
+
export type HookContext = {
|
|
5
|
+
harness: HookHarness;
|
|
6
|
+
payload: HookPayload;
|
|
7
|
+
env: NodeJS.ProcessEnv;
|
|
8
|
+
/** Repository root: `--root`, else the hook process's working directory. */
|
|
9
|
+
root: string;
|
|
10
|
+
};
|
|
11
|
+
export type PostToolUseWarning = {
|
|
12
|
+
level: 'warn' | 'error';
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
/** A file check run after an Edit/Write. `filePath` is as the tool reported it. */
|
|
16
|
+
export type PostToolUseChecker = {
|
|
17
|
+
matches: (filePath: string, root: string) => boolean;
|
|
18
|
+
check: (filePath: string, root: string) => PostToolUseWarning[];
|
|
19
|
+
};
|
|
20
|
+
/** What a `--policy <module>` exports, as its default export or a function returning it. */
|
|
21
|
+
export type HookPolicy = {
|
|
22
|
+
/** Rule table for `pre-tool-use`. Without it the hook has no opinion. */
|
|
23
|
+
command?: CommandPolicy;
|
|
24
|
+
/** File checks for `post-tool-use`. */
|
|
25
|
+
checkers?: readonly PostToolUseChecker[];
|
|
26
|
+
/** Extra context for the model after a tool call, or nothing. Must not throw to matter. */
|
|
27
|
+
reminder?: (context: HookContext) => string | null | undefined | Promise<string | null | undefined>;
|
|
28
|
+
/** Runs first on both events, for example to persist the harness session id. */
|
|
29
|
+
onPayload?: (context: HookContext) => void | Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
export type HookPolicyExport = HookPolicy | ((context: HookContext) => HookPolicy | Promise<HookPolicy>);
|
|
32
|
+
/** Identity helper that types a policy module's default export. */
|
|
33
|
+
export declare function defineHookPolicy<T extends HookPolicyExport>(policy: T): T;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { evaluateCommandPolicy } from './engine.mts';
|
|
2
|
+
export { parseHookArgs } from './hook/args.mts';
|
|
3
|
+
export { isAttendedClaudeSession, isAutomationContext, normalizeCursorShellPayload, parseHookPayload, resolveHarness, } from './hook/harness.mts';
|
|
4
|
+
export { loadHookPolicy } from './hook/policy-module.mts';
|
|
5
|
+
export { checkFile, postToolUseOutput } from './hook/post-tool-use.mts';
|
|
6
|
+
export { preToolUseOutput } from './hook/pre-tool-use.mts';
|
|
7
|
+
export type { PreToolUseOptions, PreToolUseResult } from './hook/pre-tool-use.mts';
|
|
8
|
+
export { runHook } from './hook/run.mts';
|
|
9
|
+
export type { HookIo } from './hook/run.mts';
|
|
10
|
+
export { HOOK_HARNESSES, defineHookPolicy } from './hook/types.mts';
|
|
11
|
+
export type { HookContext, HookHarness, HookPolicy, HookPolicyExport, PostToolUseChecker, PostToolUseWarning, } from './hook/types.mts';
|
|
12
|
+
export { PLAIN_FORCE_PUSH_REASON, findBlockedPatternReason, standardGitPatterns, } from './git-patterns.mts';
|
|
13
|
+
export { defaultGitProbe } from './git-process.mts';
|
|
14
|
+
export { checkoutOwner, checkoutOwners, githubOwner, ownerOfRepoSelector, sessionHomeOwners, } from './github-checkout-owners.mts';
|
|
15
|
+
export { commandsToInspectForGitHubPolicy } from './github-command-context.mts';
|
|
16
|
+
export { commandCwd } from './github-command-cwd.mts';
|
|
17
|
+
export { commandPrefixAt, commandSegmentStart } from './github-command-position.mts';
|
|
18
|
+
export { configuredPullRequestBase, findHandRolledStackBaseBlock, } from './github-configured-base.mts';
|
|
19
|
+
export { parseGhInvocation, parseGhOrGhStackInvocation } from './github-invocation.mts';
|
|
20
|
+
export type { GhInvocation } from './github-invocation.mts';
|
|
21
|
+
export { findAutomationMergeBlock, findInteractiveMergeConfirm, isLoneMergeCommand, } from './github-merge-authority.mts';
|
|
22
|
+
export { hasNamedFlag, hasNumericPrSelector, lastNamedOption } from './github-option-flags.mts';
|
|
23
|
+
export { isGhCommandSeparator, parseGhOptions } from './github-options.mts';
|
|
24
|
+
export type { GhOptions } from './github-options.mts';
|
|
25
|
+
export { findGitHubStackWorkflowBlock } from './github-stack-workflow.mts';
|
|
26
|
+
export { findGitHubWorkflowBlock } from './github-workflow.mts';
|
|
27
|
+
export { extractToolCommand, hookCwd, hookFilePath, hookSessionId, hookToolInput, hookToolName, } from './payload.mts';
|
|
28
|
+
export { findPathTypo, protectedPathMatch, referencesProtectedPath } from './path-rules.mts';
|
|
29
|
+
export type { BlockDecision, CommandPolicy, EvaluateOptions, GitProbe, HookPayload, PathTypoRule, PatternRule, ProtectedPaths, StackPolicy, } from './types.mts';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { evaluateCommandPolicy } from "./engine.mjs";
|
|
2
|
+
export { parseHookArgs } from "./hook/args.mjs";
|
|
3
|
+
export { isAttendedClaudeSession, isAutomationContext, normalizeCursorShellPayload, parseHookPayload, resolveHarness, } from "./hook/harness.mjs";
|
|
4
|
+
export { loadHookPolicy } from "./hook/policy-module.mjs";
|
|
5
|
+
export { checkFile, postToolUseOutput } from "./hook/post-tool-use.mjs";
|
|
6
|
+
export { preToolUseOutput } from "./hook/pre-tool-use.mjs";
|
|
7
|
+
export { runHook } from "./hook/run.mjs";
|
|
8
|
+
export { HOOK_HARNESSES, defineHookPolicy } from "./hook/types.mjs";
|
|
9
|
+
export { PLAIN_FORCE_PUSH_REASON, findBlockedPatternReason, standardGitPatterns, } from "./git-patterns.mjs";
|
|
10
|
+
export { defaultGitProbe } from "./git-process.mjs";
|
|
11
|
+
export { checkoutOwner, checkoutOwners, githubOwner, ownerOfRepoSelector, sessionHomeOwners, } from "./github-checkout-owners.mjs";
|
|
12
|
+
export { commandsToInspectForGitHubPolicy } from "./github-command-context.mjs";
|
|
13
|
+
export { commandCwd } from "./github-command-cwd.mjs";
|
|
14
|
+
export { commandPrefixAt, commandSegmentStart } from "./github-command-position.mjs";
|
|
15
|
+
export { configuredPullRequestBase, findHandRolledStackBaseBlock, } from "./github-configured-base.mjs";
|
|
16
|
+
export { parseGhInvocation, parseGhOrGhStackInvocation } from "./github-invocation.mjs";
|
|
17
|
+
export { findAutomationMergeBlock, findInteractiveMergeConfirm, isLoneMergeCommand, } from "./github-merge-authority.mjs";
|
|
18
|
+
export { hasNamedFlag, hasNumericPrSelector, lastNamedOption } from "./github-option-flags.mjs";
|
|
19
|
+
export { isGhCommandSeparator, parseGhOptions } from "./github-options.mjs";
|
|
20
|
+
export { findGitHubStackWorkflowBlock } from "./github-stack-workflow.mjs";
|
|
21
|
+
export { findGitHubWorkflowBlock } from "./github-workflow.mjs";
|
|
22
|
+
export { extractToolCommand, hookCwd, hookFilePath, hookSessionId, hookToolInput, hookToolName, } from "./payload.mjs";
|
|
23
|
+
export { findPathTypo, protectedPathMatch, referencesProtectedPath } from "./path-rules.mjs";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HookPayload } from './types.mts';
|
|
2
|
+
/**
|
|
3
|
+
* The files an apply_patch leaves behind: added files and move destinations, plus updated files
|
|
4
|
+
* that are not moved. Deleted files and the pre-move side of a move are gone afterwards.
|
|
5
|
+
*/
|
|
6
|
+
export declare function patchResultPaths(patch: string): string[];
|
|
7
|
+
/**
|
|
8
|
+
* Whether a path-shaped reference in the payload or the command satisfies `matches`: the payload's
|
|
9
|
+
* path-like string fields, an apply_patch's header lines, and the command's shell words. The
|
|
10
|
+
* command's own `command` field is read as shell text, never as a field value.
|
|
11
|
+
*/
|
|
12
|
+
export declare function referencesPath(payload: HookPayload, command: string, matches: (token: string) => boolean, options?: {
|
|
13
|
+
splitRedirections?: boolean;
|
|
14
|
+
}): boolean;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { tokenizeShellWords } from "../shell-parse/index.mjs";
|
|
2
|
+
import { commandsToInspectForGitHubPolicy } from "./github-command-context.mjs";
|
|
3
|
+
import { isRecord } from "./payload.mjs";
|
|
4
|
+
const PATCH_BEGIN = '*** Begin Patch';
|
|
5
|
+
const PATCH_HEADER_PREFIX = /^(?:\*\*\* (?:Add|Delete|Update) File:|\*\*\* Move to:)\s+/;
|
|
6
|
+
const KEY_PATH_LIKE_RE = /(?:^|_)(?:cwd|file|filename|path|workdir|workspace)(?:_|$)/i;
|
|
7
|
+
function keyLooksPathLike(key) {
|
|
8
|
+
const snake = key.replaceAll(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
|
|
9
|
+
return KEY_PATH_LIKE_RE.test(snake);
|
|
10
|
+
}
|
|
11
|
+
/** Header lines name the files an apply_patch touches; body text that mentions a path does not. */
|
|
12
|
+
function patchHeaderPaths(patch) {
|
|
13
|
+
return patch
|
|
14
|
+
.split('\n')
|
|
15
|
+
.filter((line) => PATCH_HEADER_PREFIX.test(line))
|
|
16
|
+
.map((line) => line.replace(PATCH_HEADER_PREFIX, ''));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The files an apply_patch leaves behind: added files and move destinations, plus updated files
|
|
20
|
+
* that are not moved. Deleted files and the pre-move side of a move are gone afterwards.
|
|
21
|
+
*/
|
|
22
|
+
export function patchResultPaths(patch) {
|
|
23
|
+
const lines = patch.split('\n').filter((line) => PATCH_HEADER_PREFIX.test(line));
|
|
24
|
+
return lines.flatMap((line, index) => {
|
|
25
|
+
const path = line.replace(PATCH_HEADER_PREFIX, '');
|
|
26
|
+
if (line.startsWith('*** Delete File:'))
|
|
27
|
+
return [];
|
|
28
|
+
const moved = lines[index + 1]?.startsWith('*** Move to:') === true;
|
|
29
|
+
return line.startsWith('*** Update File:') && moved ? [] : [path];
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Whether a path-shaped reference in the payload or the command satisfies `matches`: the payload's
|
|
34
|
+
* path-like string fields, an apply_patch's header lines, and the command's shell words. The
|
|
35
|
+
* command's own `command` field is read as shell text, never as a field value.
|
|
36
|
+
*/
|
|
37
|
+
export function referencesPath(payload, command, matches, options = {}) {
|
|
38
|
+
return valueReferences(payload, matches) || commandReferences(command, matches, options);
|
|
39
|
+
}
|
|
40
|
+
function commandReferences(command, matches, options) {
|
|
41
|
+
if (command.trimStart().startsWith(PATCH_BEGIN)) {
|
|
42
|
+
return patchHeaderPaths(command).some(matches);
|
|
43
|
+
}
|
|
44
|
+
// `apply_patch <<'EOF'` carries its patch in a data heredoc that shell scanning blanks out.
|
|
45
|
+
if (command.includes(PATCH_BEGIN) &&
|
|
46
|
+
tokenizeShellWords(command, { splitRedirections: true }).includes('apply_patch') &&
|
|
47
|
+
patchHeaderPaths(command).some(matches)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
// Without splitRedirections a no-space redirect like `>dir/file` stays fused to its operator.
|
|
51
|
+
// Nested scripts (`sh -c`, substitutions, heredoc shell bodies) are read like the outer command.
|
|
52
|
+
return commandsToInspectForGitHubPolicy(command).some((script) => tokenizeShellWords(script, options).some(matches));
|
|
53
|
+
}
|
|
54
|
+
function valueReferences(value, matches, key) {
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
if (value.startsWith(PATCH_BEGIN)) {
|
|
57
|
+
return patchHeaderPaths(value).some(matches);
|
|
58
|
+
}
|
|
59
|
+
return key !== undefined && keyLooksPathLike(key) && matches(value);
|
|
60
|
+
}
|
|
61
|
+
if (Array.isArray(value)) {
|
|
62
|
+
return value.some((nested) => valueReferences(nested, matches, key));
|
|
63
|
+
}
|
|
64
|
+
if (!isRecord(value)) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return Object.entries(value).some(([nestedKey, nested]) => nestedKey !== 'command' && valueReferences(nested, matches, nestedKey));
|
|
68
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HookPayload, PathTypoRule, ProtectedPaths } from './types.mts';
|
|
2
|
+
/** The first typo rule the payload or command references, or undefined. */
|
|
3
|
+
export declare function findPathTypo(payload: HookPayload, command: string, rules: readonly PathTypoRule[]): PathTypoRule | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* Whether `rawToken` names a protected file or directory. Dot segments collapse
|
|
6
|
+
* (`dir/./hooks/x` -> `dir/hooks/x`) so redundant path noise cannot hide a literal match. The match
|
|
7
|
+
* is deliberately not resolved against the command's cwd, so a `cd` plus a relative path is the
|
|
8
|
+
* indirection this check does not catch.
|
|
9
|
+
*/
|
|
10
|
+
export declare function protectedPathMatch(rawToken: string, protectedPaths: ProtectedPaths): boolean;
|
|
11
|
+
export declare function referencesProtectedPath(payload: HookPayload, command: string, protectedPaths: ProtectedPaths): boolean;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { referencesPath } from "./path-references.mjs";
|
|
3
|
+
/** True when `token` is the segment, or has it as a leading, trailing, or interior path segment. */
|
|
4
|
+
function tokenReferencesSegment(token, segment) {
|
|
5
|
+
return (token === segment ||
|
|
6
|
+
token.startsWith(`${segment}/`) ||
|
|
7
|
+
token.endsWith(`/${segment}`) ||
|
|
8
|
+
token.includes(`/${segment}/`));
|
|
9
|
+
}
|
|
10
|
+
/** The first typo rule the payload or command references, or undefined. */
|
|
11
|
+
export function findPathTypo(payload, command, rules) {
|
|
12
|
+
return rules.find((rule) => referencesPath(payload, command, (token) => tokenReferencesSegment(token, rule.segment)));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Whether `rawToken` names a protected file or directory. Dot segments collapse
|
|
16
|
+
* (`dir/./hooks/x` -> `dir/hooks/x`) so redundant path noise cannot hide a literal match. The match
|
|
17
|
+
* is deliberately not resolved against the command's cwd, so a `cd` plus a relative path is the
|
|
18
|
+
* indirection this check does not catch.
|
|
19
|
+
*/
|
|
20
|
+
export function protectedPathMatch(rawToken, protectedPaths) {
|
|
21
|
+
const token = rawToken === '' ? rawToken : posix.normalize(rawToken);
|
|
22
|
+
if (protectedPaths.exactFiles.some((file) => token === file || token.endsWith(`/${file}`))) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return protectedPaths.dirPrefixes.some((prefix) => {
|
|
26
|
+
const bareDir = prefix.slice(0, -1);
|
|
27
|
+
return (token === bareDir ||
|
|
28
|
+
token.startsWith(prefix) ||
|
|
29
|
+
token.endsWith(`/${bareDir}`) ||
|
|
30
|
+
token.includes(`/${prefix}`));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function referencesProtectedPath(payload, command, protectedPaths) {
|
|
34
|
+
return referencesPath(payload, command, (token) => protectedPathMatch(token, protectedPaths), {
|
|
35
|
+
splitRedirections: true,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HookPayload } from './types.mts';
|
|
2
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
|
+
export declare function hookToolInput(payload: HookPayload): Record<string, unknown> | undefined;
|
|
4
|
+
export declare function extractToolCommand(payload: HookPayload): string;
|
|
5
|
+
export declare function hookToolName(payload: HookPayload): string;
|
|
6
|
+
export declare function hookSessionId(payload: HookPayload): string;
|
|
7
|
+
export declare function hookFilePath(payload: HookPayload): string;
|
|
8
|
+
export declare function hookCwd(payload: HookPayload, fallback?: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export function isRecord(value) {
|
|
2
|
+
return typeof value === 'object' && value !== null;
|
|
3
|
+
}
|
|
4
|
+
export function hookToolInput(payload) {
|
|
5
|
+
if (isRecord(payload.tool_input))
|
|
6
|
+
return payload.tool_input;
|
|
7
|
+
if (isRecord(payload.toolInput))
|
|
8
|
+
return payload.toolInput;
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
export function extractToolCommand(payload) {
|
|
12
|
+
const toolInput = hookToolInput(payload);
|
|
13
|
+
if (toolInput && typeof toolInput.command === 'string')
|
|
14
|
+
return toolInput.command;
|
|
15
|
+
if (typeof payload.command === 'string')
|
|
16
|
+
return payload.command;
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
function firstString(values) {
|
|
20
|
+
for (const value of values) {
|
|
21
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
22
|
+
return value.trim();
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
export function hookToolName(payload) {
|
|
27
|
+
return firstString([payload.tool_name, payload.toolName]);
|
|
28
|
+
}
|
|
29
|
+
export function hookSessionId(payload) {
|
|
30
|
+
return firstString([payload.session_id, payload.sessionId, payload.conversation_id]);
|
|
31
|
+
}
|
|
32
|
+
export function hookFilePath(payload) {
|
|
33
|
+
if (typeof payload.file_path === 'string' && payload.file_path !== '')
|
|
34
|
+
return payload.file_path;
|
|
35
|
+
if (typeof payload.filePath === 'string' && payload.filePath !== '')
|
|
36
|
+
return payload.filePath;
|
|
37
|
+
const toolInput = hookToolInput(payload);
|
|
38
|
+
if (!toolInput)
|
|
39
|
+
return '';
|
|
40
|
+
for (const key of ['file_path', 'filePath', 'path']) {
|
|
41
|
+
const value = toolInput[key];
|
|
42
|
+
if (typeof value === 'string' && value !== '')
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
export function hookCwd(payload, fallback = process.cwd()) {
|
|
48
|
+
const toolInput = hookToolInput(payload);
|
|
49
|
+
for (const value of [toolInput?.cwd, toolInput?.workdir, payload.cwd, payload.workspaceRoot]) {
|
|
50
|
+
if (typeof value === 'string' && value !== '')
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
return fallback;
|
|
54
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type HookPayload = {
|
|
2
|
+
tool_input?: unknown;
|
|
3
|
+
toolInput?: unknown;
|
|
4
|
+
session_id?: unknown;
|
|
5
|
+
sessionId?: unknown;
|
|
6
|
+
conversation_id?: unknown;
|
|
7
|
+
tool_name?: unknown;
|
|
8
|
+
toolName?: unknown;
|
|
9
|
+
command?: unknown;
|
|
10
|
+
cwd?: unknown;
|
|
11
|
+
workspaceRoot?: unknown;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export type BlockDecision = {
|
|
15
|
+
reason: string;
|
|
16
|
+
/**
|
|
17
|
+
* 'block' (the default when omitted) rejects the tool call outright. 'confirm' marks an
|
|
18
|
+
* interactive lone merge, which a caller may render as a silent allow in an attended session.
|
|
19
|
+
* Only `findInteractiveMergeConfirm` produces 'confirm', and the engine consults it after every
|
|
20
|
+
* block, so a block anywhere in the command always wins.
|
|
21
|
+
*/
|
|
22
|
+
disposition?: 'block' | 'confirm';
|
|
23
|
+
};
|
|
24
|
+
export type PatternRule = {
|
|
25
|
+
pattern: RegExp;
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
28
|
+
/** Paths that automation must not write. Directory prefixes end in `/`. */
|
|
29
|
+
export type ProtectedPaths = {
|
|
30
|
+
dirPrefixes: readonly string[];
|
|
31
|
+
exactFiles: readonly string[];
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
/** A mistyped path segment (for example a misspelled dot-directory) and the reason to refuse it. */
|
|
35
|
+
export type PathTypoRule = {
|
|
36
|
+
segment: string;
|
|
37
|
+
reason: string;
|
|
38
|
+
};
|
|
39
|
+
/** Read-only git probes; every one returns undefined when git cannot answer. */
|
|
40
|
+
export type GitProbe = {
|
|
41
|
+
currentBranch(cwd: string): string | undefined;
|
|
42
|
+
configValue(cwd: string, key: string): string | undefined;
|
|
43
|
+
isAncestor(cwd: string, ancestor: string, descendant: string): boolean | undefined;
|
|
44
|
+
resolveRef(cwd: string, ref: string): string | undefined;
|
|
45
|
+
};
|
|
46
|
+
export type StackPolicy = {
|
|
47
|
+
/** Branch a stack must root on and a PR must target. Defaults to `main`. */
|
|
48
|
+
baseBranch?: string;
|
|
49
|
+
/** Remote whose `<remote>/<baseBranch>` HEAD must descend from. Defaults to `origin`. */
|
|
50
|
+
remote?: string;
|
|
51
|
+
/** Appended to stack reasons, for example a pointer to the repository's stacking skill. */
|
|
52
|
+
guidance?: string;
|
|
53
|
+
/** What to do after a draft PR opens, for example the description tool to call. */
|
|
54
|
+
draftFollowUp?: string;
|
|
55
|
+
/** Probe override for tests and sandboxes. */
|
|
56
|
+
git?: GitProbe;
|
|
57
|
+
};
|
|
58
|
+
export type CommandPolicy = {
|
|
59
|
+
typoPaths?: readonly PathTypoRule[];
|
|
60
|
+
protectedPaths?: ProtectedPaths;
|
|
61
|
+
/** Tested against every command and nested script, before the git rules. */
|
|
62
|
+
commandPatterns?: readonly PatternRule[];
|
|
63
|
+
/** Tested against nested scripts, only when the command mentions git. */
|
|
64
|
+
gitPatterns?: readonly PatternRule[];
|
|
65
|
+
/** Reason for an interactive `git rebase --continue`; omit to allow it. */
|
|
66
|
+
rebaseContinueReason?: string;
|
|
67
|
+
/** Appended to merge reasons, for example a pointer to the merge-authority document. */
|
|
68
|
+
mergeGuidance?: string;
|
|
69
|
+
/** GitHub stack rules apply only when this is present. */
|
|
70
|
+
stack?: StackPolicy;
|
|
71
|
+
};
|
|
72
|
+
export type EvaluateOptions = {
|
|
73
|
+
/** Whether the call runs in unattended automation. Defaults to true, the strict choice. */
|
|
74
|
+
automationContext?: boolean;
|
|
75
|
+
/** Directory the call runs in. Defaults to the payload's own, else `process.cwd()`. */
|
|
76
|
+
cwd?: string;
|
|
77
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.mts
CHANGED
|
@@ -111,3 +111,5 @@ export { countDiffLineChanges, DEFAULT_LARGE_DIFF_THRESHOLDS, exceedsLargeDiffTh
|
|
|
111
111
|
export type { DiffLineChanges, LargeDiffThresholds } from './pull-request-diff/index.mts';
|
|
112
112
|
export { tokenizeShellWords, tokenizeShellWordsDetailed } from './shell-parse/index.mts';
|
|
113
113
|
export type { ShellWord } from './shell-parse/index.mts';
|
|
114
|
+
export { evaluateCommandPolicy } from './command-policy/index.mts';
|
|
115
|
+
export type { BlockDecision, CommandPolicy } from './command-policy/index.mts';
|
package/dist/index.mjs
CHANGED
|
@@ -60,3 +60,4 @@ export { assertHeadPushed, buildGhPrCreateArgs, createPullRequest, DetachedHeadE
|
|
|
60
60
|
export { formatReferenceKey, hasClosingIssueReference, parseClosingIssueReferences, parseNonClosingRefs, } from "./gh-cli/index.mjs";
|
|
61
61
|
export { countDiffLineChanges, DEFAULT_LARGE_DIFF_THRESHOLDS, exceedsLargeDiffThreshold, } from "./pull-request-diff/index.mjs";
|
|
62
62
|
export { tokenizeShellWords, tokenizeShellWordsDetailed } from "./shell-parse/index.mjs";
|
|
63
|
+
export { evaluateCommandPolicy } from "./command-policy/index.mjs";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type AuditArgs = {
|
|
2
|
+
rules: string;
|
|
3
|
+
projectsDir: string;
|
|
4
|
+
codexSessionsDir: string;
|
|
5
|
+
settingsPath?: string;
|
|
6
|
+
maxFilesPerRoot: number;
|
|
7
|
+
sinceDays?: number;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
json: boolean;
|
|
10
|
+
raw: boolean;
|
|
11
|
+
/** Undefined resolves the roots from git. */
|
|
12
|
+
repoRoots?: string[];
|
|
13
|
+
worktreeGlobs: string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Parses the `sandbox-command-audit` flags. Transcript roots default to the harnesses' own
|
|
17
|
+
* (`CLAUDE_CONFIG_DIR` / `CODEX_HOME`, else the home directory), matching transcript resolution.
|
|
18
|
+
* Throws an Error whose message names the first problem.
|
|
19
|
+
*/
|
|
20
|
+
export declare function parseAuditArgs(argv: readonly string[], env: NodeJS.ProcessEnv): AuditArgs;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { parseArgs } from 'node:util';
|
|
4
|
+
import { SESSION_ID } from "../retrospective-transcript/resolve-transcript-file.mjs";
|
|
5
|
+
const DEFAULT_LIMIT = 50;
|
|
6
|
+
function positiveInteger(raw, flag) {
|
|
7
|
+
const parsed = Number(raw);
|
|
8
|
+
if (!Number.isSafeInteger(parsed) || parsed <= 0)
|
|
9
|
+
throw new Error(`${flag} requires a positive integer`);
|
|
10
|
+
return parsed;
|
|
11
|
+
}
|
|
12
|
+
function value(raw, flag) {
|
|
13
|
+
if (raw.length === 0 || raw.startsWith('-'))
|
|
14
|
+
throw new Error(`${flag} requires a value`);
|
|
15
|
+
return raw;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Parses the `sandbox-command-audit` flags. Transcript roots default to the harnesses' own
|
|
19
|
+
* (`CLAUDE_CONFIG_DIR` / `CODEX_HOME`, else the home directory), matching transcript resolution.
|
|
20
|
+
* Throws an Error whose message names the first problem.
|
|
21
|
+
*/
|
|
22
|
+
export function parseAuditArgs(argv, env) {
|
|
23
|
+
const { values } = parseArgs({
|
|
24
|
+
args: [...argv],
|
|
25
|
+
strict: true,
|
|
26
|
+
options: {
|
|
27
|
+
rules: { type: 'string' },
|
|
28
|
+
json: { type: 'boolean' },
|
|
29
|
+
raw: { type: 'boolean' },
|
|
30
|
+
limit: { type: 'string' },
|
|
31
|
+
since: { type: 'string' },
|
|
32
|
+
'session-id': { type: 'string' },
|
|
33
|
+
'projects-dir': { type: 'string' },
|
|
34
|
+
'codex-sessions-dir': { type: 'string' },
|
|
35
|
+
'settings-path': { type: 'string' },
|
|
36
|
+
'repo-root': { type: 'string', multiple: true },
|
|
37
|
+
'worktree-glob': { type: 'string', multiple: true },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
if (values.rules === undefined)
|
|
41
|
+
throw new Error('--rules <module> is required');
|
|
42
|
+
const home = homedir();
|
|
43
|
+
const sessionId = values['session-id'];
|
|
44
|
+
if (sessionId !== undefined && !SESSION_ID.test(sessionId)) {
|
|
45
|
+
throw new Error(`--session-id has an invalid format: ${sessionId}`);
|
|
46
|
+
}
|
|
47
|
+
const many = (flag) => values[flag]?.map((entry) => value(entry, `--${flag}`));
|
|
48
|
+
const since = values.since;
|
|
49
|
+
return {
|
|
50
|
+
rules: value(values.rules, '--rules'),
|
|
51
|
+
projectsDir: value(values['projects-dir'] ?? join(env.CLAUDE_CONFIG_DIR || join(home, '.claude'), 'projects'), '--projects-dir'),
|
|
52
|
+
codexSessionsDir: value(values['codex-sessions-dir'] ?? join(env.CODEX_HOME || join(home, '.codex'), 'sessions'), '--codex-sessions-dir'),
|
|
53
|
+
maxFilesPerRoot: values.limit === undefined ? DEFAULT_LIMIT : positiveInteger(values.limit, '--limit'),
|
|
54
|
+
json: values.json === true,
|
|
55
|
+
raw: values.raw === true,
|
|
56
|
+
worktreeGlobs: many('worktree-glob') ?? [],
|
|
57
|
+
...(values['settings-path'] === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: { settingsPath: value(values['settings-path'], '--settings-path') }),
|
|
60
|
+
...(since === undefined ? {} : { sinceDays: positiveInteger(since, '--since') }),
|
|
61
|
+
...(sessionId === undefined ? {} : { sessionId: sessionId.toLowerCase() }),
|
|
62
|
+
...(many('repo-root') === undefined ? {} : { repoRoots: many('repo-root') }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type PrefixCount = {
|
|
2
|
+
prefix: string;
|
|
3
|
+
count: number;
|
|
4
|
+
};
|
|
5
|
+
/** Which list of an injected policy a command is checked against. */
|
|
6
|
+
export type CoverageList = 'allow' | 'deny' | 'excluded';
|
|
7
|
+
/**
|
|
8
|
+
* The repository's own answer to "is this already handled": the caller loads its settings from
|
|
9
|
+
* wherever and in whatever format it keeps them, and exposes only this question. `allow` and
|
|
10
|
+
* `excluded` receive a normalized prefix; `deny` receives each raw command.
|
|
11
|
+
*/
|
|
12
|
+
export type CoveragePolicy = {
|
|
13
|
+
covers: (list: CoverageList, commandOrPrefix: string) => boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function groupByPrefix(commands: Array<string | undefined>): Map<string, number>;
|
|
16
|
+
export declare function toSortedPrefixCounts(counts: Map<string, number>): PrefixCount[];
|
|
17
|
+
export declare function unresolvedCount(counts: Map<string, number>): number;
|
|
18
|
+
export declare function coverageByPrefix(commands: Array<string | undefined>, list: CoverageList, policy: CoveragePolicy): Map<string, boolean>;
|
|
19
|
+
export declare function splitByCoverage(counts: Map<string, number>, list: CoverageList, policy: CoveragePolicy): {
|
|
20
|
+
covered: PrefixCount[];
|
|
21
|
+
uncovered: PrefixCount[];
|
|
22
|
+
unresolvedCount: number;
|
|
23
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { normalizeCommandPrefix } from "../retrospective-transcript/index.mjs";
|
|
2
|
+
// A command that could not be normalized (uncorrelated, or no command text) is still counted so
|
|
3
|
+
// it is never a silent drop; it just cannot anchor a per-prefix row.
|
|
4
|
+
const UNRESOLVED_PREFIX = '';
|
|
5
|
+
export function groupByPrefix(commands) {
|
|
6
|
+
const counts = new Map();
|
|
7
|
+
for (const command of commands) {
|
|
8
|
+
const prefix = command ? normalizeCommandPrefix(command) : UNRESOLVED_PREFIX;
|
|
9
|
+
counts.set(prefix, (counts.get(prefix) ?? 0) + 1);
|
|
10
|
+
}
|
|
11
|
+
return counts;
|
|
12
|
+
}
|
|
13
|
+
export function toSortedPrefixCounts(counts) {
|
|
14
|
+
const entries = [];
|
|
15
|
+
for (const [prefix, count] of counts) {
|
|
16
|
+
if (prefix !== UNRESOLVED_PREFIX)
|
|
17
|
+
entries.push({ prefix, count });
|
|
18
|
+
}
|
|
19
|
+
return entries.toSorted((a, b) => b.count - a.count || a.prefix.localeCompare(b.prefix));
|
|
20
|
+
}
|
|
21
|
+
export function unresolvedCount(counts) {
|
|
22
|
+
return counts.get(UNRESOLVED_PREFIX) ?? 0;
|
|
23
|
+
}
|
|
24
|
+
// Checked per raw command, because deny rules can run deeper than the two-token prefix depth. A
|
|
25
|
+
// prefix group is "covered" only when every command in it is: one uncovered instance leaves the
|
|
26
|
+
// group for human review.
|
|
27
|
+
export function coverageByPrefix(commands, list, policy) {
|
|
28
|
+
const coverage = new Map();
|
|
29
|
+
for (const command of commands) {
|
|
30
|
+
if (!command)
|
|
31
|
+
continue;
|
|
32
|
+
const prefix = normalizeCommandPrefix(command);
|
|
33
|
+
coverage.set(prefix, (coverage.get(prefix) ?? true) && policy.covers(list, command));
|
|
34
|
+
}
|
|
35
|
+
return coverage;
|
|
36
|
+
}
|
|
37
|
+
export function splitByCoverage(counts, list, policy) {
|
|
38
|
+
const covered = new Map();
|
|
39
|
+
const uncovered = new Map();
|
|
40
|
+
for (const [prefix, count] of counts) {
|
|
41
|
+
if (prefix === UNRESOLVED_PREFIX)
|
|
42
|
+
continue;
|
|
43
|
+
(policy.covers(list, prefix) ? covered : uncovered).set(prefix, count);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
covered: toSortedPrefixCounts(covered),
|
|
47
|
+
uncovered: toSortedPrefixCounts(uncovered),
|
|
48
|
+
unresolvedCount: unresolvedCount(counts),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type CoveragePolicy, type PrefixCount } from './classify-prefixes.mts';
|
|
2
|
+
import type { ScanResult, SkipCounts } from './types.mts';
|
|
3
|
+
export type { CoverageList, CoveragePolicy, PrefixCount } from './classify-prefixes.mts';
|
|
4
|
+
export type GenuineBypassCandidate = PrefixCount & {
|
|
5
|
+
alreadyInAllowList: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type BlockCandidate = PrefixCount & {
|
|
8
|
+
alreadyDenied: boolean;
|
|
9
|
+
};
|
|
10
|
+
export type KindCount = {
|
|
11
|
+
kind: string;
|
|
12
|
+
count: number;
|
|
13
|
+
};
|
|
14
|
+
export type EscalationPressure = {
|
|
15
|
+
claudeCovered: PrefixCount[];
|
|
16
|
+
claudeUncovered: PrefixCount[];
|
|
17
|
+
claudeUnresolvedCount: number;
|
|
18
|
+
e2bigCount: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The privacy boundary: this is what `--json` serializes, so it carries only normalized prefixes
|
|
22
|
+
* and counts. Read-error paths and failure text exist only on `ScanResult`, as counts here.
|
|
23
|
+
*/
|
|
24
|
+
export type CategorizedAudit = {
|
|
25
|
+
genuineBypassCandidates: GenuineBypassCandidate[];
|
|
26
|
+
genuineBypassUnresolvedCount: number;
|
|
27
|
+
blockCandidates: BlockCandidate[];
|
|
28
|
+
blockCandidateUnresolvedCount: number;
|
|
29
|
+
escalationPressure: EscalationPressure;
|
|
30
|
+
policyBlockCount: number;
|
|
31
|
+
/** Failures a caller rule put in its own bucket, by kind. Never counted as bypass candidates. */
|
|
32
|
+
otherFailures: KindCount[];
|
|
33
|
+
claudeFilesScanned: number;
|
|
34
|
+
codexFilesScanned: number;
|
|
35
|
+
readErrorCount: number;
|
|
36
|
+
repoRoots: string[];
|
|
37
|
+
skippedOtherRepo: SkipCounts;
|
|
38
|
+
skippedUnknownCwd: SkipCounts;
|
|
39
|
+
rawRetention: ScanResult['rawRetention'];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Sorts a scan into report buckets against the caller's policy. Bypass candidates come from
|
|
43
|
+
* Claude's real permission failures; Codex escalations are not scanned here because Codex agents
|
|
44
|
+
* journal them separately.
|
|
45
|
+
*/
|
|
46
|
+
export declare function classifyAudit(scan: ScanResult, policy: CoveragePolicy): CategorizedAudit;
|