policy

package
v2.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package policy holds a project's "always allow" rules, evaluated server-side before a human is ever paged.

Rules live in projects.policy_json:

{"allow": [{"tool": "Bash", "prefix": "pytest"}, {"tool": "Edit"}]}

Bash rules match on the command's FIRST TOKEN (or an explicit glob); other tools match wholesale. Token matching, not substring: an auto-approver that substring-matched once denied `terraform version` because it contains "rm ".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BroadenableForSession added in v2.4.0

func BroadenableForSession(toolName string, input map[string]any) bool

BroadenableForSession reports whether "allow for the rest of this session" is a sensible scope for this call. For Bash it is the command's first token; a wrapper, or a path-qualified or empty command, would make that rule far broader than the one command the person saw, so it is refused.

func Matches

func Matches(p Policy, toolName string, input map[string]any) bool

Matches reports whether a policy already permits this call.

Types

type Policy

type Policy struct {
	Allow []Rule `json:"allow"`
}

Policy is a project's rule set.

func AddRule

func AddRule(p Policy, r Rule) Policy

AddRule appends a rule unless an identical one is already present.

func Parse

func Parse(raw string) Policy

Parse decodes policy_json, treating anything unparseable as "no rules".

type Rule

type Rule struct {
	Tool   string `json:"tool"`
	Prefix string `json:"prefix,omitempty"`
	Glob   string `json:"glob,omitempty"`
}

Rule is one always-allow entry.

func PatternFor

func PatternFor(toolName string, input map[string]any) Rule

PatternFor derives the rule an operator means when they say "always allow this".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL