User commands: commands.toml, API version 1 and trust #245

closed cmc opened this on 2026-11-27 06:00 UTC · feature · milestone 8 Automation and extension

Discussion

cmc 2026-11-27 06:00 UTC

Phase 1 of the user-commands plan in docs/plans/2026-11-27-user-commands.md (#173). This is the user-visible feature.

  • commands.toml in the configuration folder (api = 1, [[command]] with name, title, file, function, optional when and timeout) and code in commands/*.js. Read without running code; problems reported by file and key like the other configuration files. Mac: through ConfigSync, reloaded on change. iOS: through MobileModel.readConfig and the FolderPresenter; a script iCloud hasn't downloaded is reported and its download started.
  • UserCommand: OrgCommand in OrgCore with id user.<name>; applies(in:) from when through KeyContext.holds; run(in:) returns .external(.userCommand(...)).
  • DocumentSession runs it on the #244 host, validates the returned edits (in range, non-overlapping) and commits them as one EditResult at the base revision: one undo step, refused if the buffer changed.
  • API version 1, all asynchronous: org.text(), org.selection(), org.heading(at?), org.outline(), org.file(), org.settings(), org.prompt({...}) through the existing closure-based prompt UI, org.message(), org.fail(). Return value {edits, selection, message, copy} in UTF-16 offsets.
  • Registration: EditorCommands.all (as namedMacros), the palette and CommandUsage, keymap.toml validation, MobileEditor.offered, the iOS Commands list and [key-bar].
  • Trust: first run of a command from a file asks (Run Once, Always, Don't Run); Always stores a hash of the file and every module it imports in TrustStore. Any change asks again, including one from sync.
  • Refused in a buffer holding decrypted entries.
  • Cancel Running Task also cancels a user command.
  • Import from Emacs lists bindings to the user's own defuns as skipped, pointing to user commands.
  • Manual: a new chapter (files, API, limits, what is absent compared with Emacs Lisp, a porting table), 13-configuration.org file table, 03-keys.org. German strings.

Tests: manifest problems; a command's edits apply as one undo step; an edit made while the command ran refuses its result; overlapping or out-of-range edits are refused; a changed script asks for trust again; when hides the command where it doesn't apply.

Open questions for the owner before starting: orgstar+ or free; default timeout.

Platforms: Mac (download and Mac App Store builds), iOS. Depends on: #244.

cmc 2026-11-27 06:03 UTC

Decision (owner, 2026-11-27): user commands are free (not behind orgstar+). Timeouts 2 s default, 30 s maximum are fine.

closed by cmc in commit 61025559a3: User commands: commands.toml, API version 1 and trust

2026-11-27 09:07 UTC
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form