capability

package
v0.18.1 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: AGPL-3.0 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 capability is komando's command tree as data: every command of the v2.7 grammar (TYPE PROVIDER [AREA] VERB, or NOUN [KIND] VERB) with its options, tier rows and the facts the safety checks need. The cobra tree, `komando schema`, help and the person's questions are built from it. It imports no cobra and no komando state, so tests and tools can read it whole.

Until the v0.18.0 cut internal/cli reads only TodayKeys from it, the keys of its safety tables; the fields marked "pre-cut" tie today's command IDs to their v2.7 home and go in the cut.

Index

Constants

View Source
const (
	UserArea       = "user"
	UserAdd        = "add"
	UserEdit       = "edit"
	UserCredential = "credential"
	UserFromHost   = "from-host"
)

The words of the user leaves, spelled here alone: the code, the hints and the error catalog read them, so a rename is one edit (and the docs).

Variables

This section is empty.

Functions

func Children

func Children(path ...string) []string

Children returns the distinct next words under path, in table order: the types at the top, the providers of a type, and so on.

func CobraOwn

func CobraOwn() []string

CobraOwn are command IDs cobra makes itself; they stay outside the table.

func DatabaseExample

func DatabaseExample(provider string) (entry, url, read string, ok bool)

DatabaseExample is what a provider's examples use: the name of a saved database, its URL and a read in the provider's language. ok is false for a word that is no database provider.

func Groups

func Groups() []string

Groups are command IDs of today that only hold other commands (db.user): their fate is their children's. Each keeps a key in todayOnlyKeys.

func QueueExample

func QueueExample(provider string) (entry, url, topic string, ok bool)

QueueExample is a broker's sample conn name, address and topic, for the examples and the help of the queue commands.

func TodayKeys

func TodayKeys() map[string]TodayKey

TodayKeys returns the safety key of every command ID of today: the key of the leaf that keeps the ID under its own key (Leaf.Today), else the key todayOnlyKeys gives it. The map is new on each call.

func UserLine

func UserLine(provider, verb, conn, user string) string

UserLine is the command line of database PROVIDER user VERB for the conn CONN and the user USER, as a hint names it.

func VpnGroupShort

func VpnGroupShort(provider string) string

VpnGroupShort is the text of the group of a provider (vpn wireguard).

Types

type Arg

type Arg struct {
	Name     string // NAME, ITEM, NEW, ...
	Selector bool   // takes @group, tag:x, label:k=v, all
	Many     bool
	Optional bool
	Dash     bool // typed after `--`: words for another program
}

Arg is one positional argument.

type Cond

type Cond struct {
	Flags []string // all of these options are given
	Value string   // ... and the first one has this value ("false")
	Not   bool     // the row applies when the flags are NOT given
	Words []string // or one of these arguments is given ("0")
}

Cond is when a row applies. Every flag it names is an Option of every leaf the row reaches, so a renamed flag cannot silently stop a row.

type Gone

type Gone struct {
	Today string // command ID of v0.17, as in testdata/v0_17_ids.txt (deleted after the v0.18.0 release)
	Why   string // the decision
	Lost  string // the function that goes on purpose, "" when none
}

Gone is a command of today that no leaf carries.

func Gones

func Gones() []Gone

Gones returns the commands of today that no leaf carries.

type Internal

type Internal struct {
	Today string
	For   Key
}

Internal is a hidden command of today that komando runs itself, and the leaf it serves. A Key with an empty Provider means every provider.

func Internals

func Internals() []Internal

Internals returns today's hidden commands and the leaf each serves.

type Key

type Key struct{ Type, Provider, Area, Verb string }

Key names one leaf. Type is "" for a top-level action (list, copy, ...); Provider is "" for komando's own nouns; Area is "" when the verb sits on the provider or noun. For komando's nouns a credential kind or a config part (vault, skill, recording) is the Area.

func (Key) Path

func (k Key) Path() []string

Path is the words a person types, without NAME and flags.

func (Key) String

func (k Key) String() string

type Leaf

type Leaf struct {
	Key
	Args       []Arg
	Options    []Option
	Short      string
	Example    string
	State      State
	Output     Output
	LocalRead  bool     // runs when the store cannot be written
	LeavesHome bool     // run as root it never touches ~/.komando
	Synonyms   []string // plain words people type for the verb (ls)
	Stops      []string // the in-command stops it runs, by function name

	// Today (pre-cut) are today's command IDs whose safety key (cmdKeys in internal/cli) is
	// this leaf's (type, area, verb). Carries (pre-cut) are today's IDs
	// whose job this leaf does under another key: exec, raw or query in
	// place of a removed command, or one ID that splits into kinds.
	Today   []string
	Carries []string
}

Leaf is one command a person or an agent can run.

func All

func All() []Leaf

All returns every leaf. The slice is a copy; the slices inside each leaf are shared with the table, so callers must not change them.

func Find

func Find(k Key) (Leaf, bool)

Find returns the leaf with this key. Its slices are shared with the table, as in All.

func (Leaf) Option

func (l Leaf) Option(name string) (Option, bool)

Option returns the leaf's option with this name.

type OptKind

type OptKind uint8

OptKind is how an option's value is read.

const (
	String OptKind = iota
	Bool
	Int
	Duration
	Bytes
	Enum
	Credential // the name of a credential
	Entry      // the name of an entry in komando's list
	File       // a path on this computer
)

type Option

type Option struct {
	Name      string
	Short     string // the one-letter form (-n)
	Kind      OptKind
	Enum      []string
	Default   string
	Required  bool
	Repeat    bool
	Pairs     bool     // each value is KEY=VALUE
	List      bool     // the values may be given comma-separated, one flag or many
	Sensitive bool     // never echoed, never in the audit text
	Generated bool     // komando makes the value at 256 bits; a person never types it
	Pattern   string   // the value must match before any use
	Needs     []string // options this one works only with
	Conflicts []string // options it cannot be used with
	Help      string
	Ask       string // the question a person sees when it is missing
}

Option is one flag of a leaf. Global flags (-o, --dry-run, --yes, ...) are not here.

type Output

type Output uint8

Output says whose data a leaf prints. TargetData is read from a server or resource: secrets and personal data in it are hidden from AI agents.

const (
	OwnData Output = iota
	TargetData
)

type Replaced

type Replaced struct {
	Today     string
	Rows      []Key    // v2.7 tier rows, by their key, that reach the carrying leaf
	Rules     []string // internal/policy rule IDs
	SQLRules  []string // rule IDs of the SQL classifier (internal/driver SQLRules)
	EveryRule bool     // every policy rule checks the text, as today's command did
	Tests     []string // the tests that pin the rules or the rating, by function name
	Stops     []string // in-command stops, by function name
	NoRule    string   // why no policy rule carries it ("" when one does)
	Lost      string   // what goes on purpose, in the plan's words
}

Replaced is a command of today that exec, query or raw does after the cut (a Leaf.Carries entry), with what keeps its protection: the cut plan's "Carried by" column, sections 1.4 to 1.6 and 1.8. Pre-cut: it goes with the other fates at the cut.

func Replacements

func Replacements() []Replaced

Replacements returns today's commands that exec, query or raw does now.

type State

type State uint8

State says whether a leaf is built. A New leaf is in the plan only: the builder leaves it out of the cobra tree, help and schema.

const (
	Built State = iota
	New
)

type Tier

type Tier uint8

Tier is how much a command needs before it runs (the same order as today's tiers in internal/cli/risk.go).

const (
	Read      Tier = iota // looks only
	Change                // reversible, or only komando's own list
	Protected             // decided by the target's protection
	Dangerous             // cannot be undone, or an outage
	Safety                // weakens komando's own checks
	Person                // only a person at a terminal
)

func Base

func Base(k Key) Tier

Base is the tier a leaf has when no condition of a row is met: the highest row with no condition that reaches it, else its floor. Only such a row can put a leaf below its floor (a backup that only reads).

func Floor

func Floor(k Key) Tier

Floor is the tier a leaf has with no row: read for a verb that only looks, else change.

func Highest

func Highest(k Key) Tier

Highest is the highest tier k can have: its base, or the highest row that reaches it, whatever the row's condition.

type TierRow

type TierRow struct {
	Key
	Tier    Tier
	When    Cond   // zero: always
	What    string // "deletes the keys": the person reads "This deletes the keys."
	Dynamic string // set: the tier holds only when this is so; the command decides
	Bulk    string // set: a bulk confirm the command keeps
	// Today (pre-cut): internal/cli's riskRows uses this row now, in place
	// of today's row for the same key, tier and condition. The other rows
	// wait for the cut, when their leaf's path is live.
	Today bool
}

TierRow is one row of the v2.7 tier table. It reaches every leaf with the same type, area and verb; a row with a Provider reaches only that provider (a provider adds a row only where it differs).

func Rows

func Rows(k Key) []TierRow

Rows returns the tier rows that reach k.

func TierRows

func TierRows() []TierRow

TierRows returns every row. The slice is a copy.

func (TierRow) Reaches

func (r TierRow) Reaches(k Key) bool

Reaches reports whether r applies to leaf k.

type TodayKey

type TodayKey struct{ Type, Area, Verb string }

TodayKey is the safety key of one command of today (pre-cut): where it sits in the v2.7 grammar without its provider. internal/cli keys its safety tables (tier rows, kinds, TARGET kinds) by it until the cut.

type TodayRow

type TodayRow struct {
	Key  TodayKey
	When string // a named condition internal/cli reads ("flag:delete"); "" always
	Cond string // When, in words for `komando schema`
	Tier Tier
	What string // "deletes the keys": the person reads "This deletes the keys."
	// Dynamic set: the tier holds only when this is so; the command decides
	Dynamic string
	Bulk    string // set: a bulk confirm the command keeps
	// Typed and Items: a change row for which a person at the terminal also
	// types the name of what goes; Items says what those are
	Typed, Items string
}

TodayRow (pre-cut) is one row of today's rule table (internal/cli risk.go), keyed by today's safety key. Until the cut, internal/cli builds its riskRows from these rows; the cut deletes them with the commands they are for (cut PR D).

func TodayRows

func TodayRows() []TodayRow

TodayRows returns today's rows. The slice is a copy.

type Verb

type Verb struct {
	Name    string
	Class   string // inventory, target, check, run, data, life, setup, settings, about
	Meaning string
}

Verb is one word of the closed vocabulary: one word, one meaning.

func Verbs

func Verbs() []Verb

Verbs returns the closed vocabulary. The slice is a copy.

Jump to

Keyboard shortcuts

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