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
- func Children(path ...string) []string
- func CobraOwn() []string
- func DatabaseExample(provider string) (entry, url, read string, ok bool)
- func Groups() []string
- func QueueExample(provider string) (entry, url, topic string, ok bool)
- func TodayKeys() map[string]TodayKey
- func UserLine(provider, verb, conn, user string) string
- func VpnGroupShort(provider string) string
- type Arg
- type Cond
- type Gone
- type Internal
- type Key
- type Leaf
- type OptKind
- type Option
- type Output
- type Replaced
- type State
- type Tier
- type TierRow
- type TodayKey
- type TodayRow
- type Verb
Constants ¶
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 ¶
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 ¶
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 ¶
QueueExample is a broker's sample conn name, address and topic, for the examples and the help of the queue commands.
func TodayKeys ¶
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 ¶
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 ¶
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.
type Internal ¶
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.
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.
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.
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.
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.
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).
func Base ¶
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).
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).
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).