Kanshō/Policy editor

Policy editor

Ordered rule list for agent approval policies. Each rule pairs an action, a scope glob, and a decision — and because matching is first-match-wins, the order of the list is itself part of the policy.

Included in the single kansho full pack. Components are not offered as separate installs.

With rules

Drag to reorder · click to cycle · edit scope inline

Each rule specifies an action (click to cycle: any / write_file / run_command), an inline-editable scope glob, and a decision (allow / ask / deny). The editor holds its own working copy and surfaces an unsaved-changes bar the moment anything differs from the last save.

Approval rules · first match wins
  • 1
  • 2
  • 3
  • 4
  • 5

Precedence — first match wins

Order is meaning

The leading number on each row is its precedence. The agent walks the list top to bottom and stops at the first rule that matches, so a broad rule above a narrow one can hide it entirely.

Below, rule 2 denies writes to src/secrets/** — but rule 1 already allows all of src/** and sits above it, so the deny never fires. Drag rule 2 above rule 1 (or use the move controls) to give the deny precedence and watch the policy change meaning.

Approval rules · first match wins
  • 1
  • 2

Delete, tombstone, undo

Deletion is reversible until you save

Deleting a rule does not remove it outright — it leaves a quiet tombstone in place with an Undo button. Undo restores the rule at its original position; Save clears the tombstones and persists what remains; Discard brings every deleted rule back. Nothing is lost until you choose Save, which keeps a mis-click from silently loosening a policy.

Approval rules · first match wins
  • 1
  • 2
  • 3
  • 4
  • 5

Keyboard reorder

No pointer required

Reordering works entirely from the keyboard. Tab to a row’s drag handle, then:

  • Spacelifts the rule
  • move it up or down
  • Spacedrops it in place
  • Esccancels and returns the rule to its start

The move-up / move-down arrows beside each row do the same thing in a single click, and are disabled at the ends of the list.

Accessibility

Announced, not just visual

Every mutation is narrated to screen readers. A polite live region announces cycling (“Decision: deny”), deletion (“Rule 3 deleted. Undo available.”), restoration, and discards. Drag-and-drop routes through dnd-kit’s announcement channel, reading the rule summary and its new position (“moved to position 1 of 5”). Decision is never carried by colour alone — the chip always spells out allow / ask / deny, and each row’s accessible label mirrors its visible ordinal.

Empty state

Static preview: this empty specimen does not persist Save
Approval rules · first match wins
No rules defined. All actions will require approval.

Component documentation

Policy Editor

components/control-plane/policy-editor.tsx

Purpose

Maintains a working copy of ordered approval-policy rules with add, edit, reorder, delete, undo, and save controls.

Appropriate use

Use for controlled policy editing when the host can persist the complete rule array and show save results.

Example

components/control-plane/policy-editor.tsx has a representative live example in the "With rules" section on /components/policy-editor.

States

Decisions are allow, ask, and deny; actions are write_file and run_command; rules may be live, added, modified, deleted, reordered, saving, or clean.

API and props

PolicyEditor accepts rules, onSave, optional onChange, saving, and className; PolicyRule supplies id, optional action, optional scopeGlob, and decision.

Dependencies

Direct imports are React, Lucide icons, dnd-kit core/sortable/utilities, ScopeChip, Button, IconButton, and cn.

Accessibility

Rules form a labelled list; fields and action controls are named, keyboard move controls accompany drag, deletion can be undone, and save state is a polite live region.

Limitations

It supports only two actions, does not validate glob syntax or permissions, and the host owns persistence, concurrency, and save errors.

Source

Source: components/control-plane/policy-editor.tsx.

Full pack

components/control-plane/policy-editor.tsx is documented at /components/policy-editor and installs only through the single Kansho full pack; no individual component install is offered.