← XeFM crftwr/xefm on GitHub · craftware

Stable API plan — API_VERSION 1

Status: implemented (#713). Settled in conversation on 2026-10-23. One change while implementing: DISPLAY_PREFIX and get_display_title() turned out to be read nowhere in XeFM, so they are Preview rather than stable overrides (§3.1).

The per-API Preview mechanism from #632 (xefm/preview.py, @preview, PREVIEW_APIS, the STABLE test in test/test_user_task_api.py) is already in place, and today every public API but ActionContext.api_version is still Preview. Shipping a stable API means four things:

  1. Remove the mark from the APIs we are confident in.
  2. Settle the APIs whose boundary is unclear today: XeFM’s Path, PathImpl subclassing, and the names config.py imports.
  3. Set API_VERSION = 1.
  4. Make the docs, the log notices and xefm ext check say the same thing, and tell extension authors which Preview APIs they use (§4.1).
  5. Make future changes to the API impossible to miss (§7).

The rule for what stays Preview: mark it Preview if it is new, has an open design question, has planned work that would reshape it, or exposes a type we do not own.


1. Classification

Stable

API Notes
config.ACTIONS, manifest.contributes.actions Oldest surface (2026-08-22). The context key accepts only 'filer'; viewer contexts would be an addition later.
config.SORT_KEYS, manifest.contributes.sort_keys 2026-09-05
config.FILTERS, manifest.contributes.filters 2026-09-05
manifest.contributes.key_suggestions Plain data
EntryInfo All of it except the constructor’s name= (§2.4). from_attrs becomes _from_attrs.
PaneApi All of it except open_list
ActionContext.pane / other / left / right  
ActionContext.invoke Built-in action names already keep resolving after a rename (Action.aliases). That becomes a stated promise.
ActionContext.run_program  
ActionContext.message  
ActionContext.action_names() Without its context parameter (§2.3)
ActionContext.api_version Already stable
Path, as reached through EntryInfo.path, PaneApi.path and cd() The stable member set in §2.1
xefm_tool, xefm_python, is_desktop_mode §2.5
PATH_SCHEMES, manifest.contributes.path_schemes The stable parts of the table in §3.3
ReadOnlyPathImpl, UriStatResult The members in tiers A, C and B-high of §3.1

Preview

API Why
PaneApi.open_list Renamed once (show_list), and its semantics are intricate
ActionContext.input / choose / confirm Whether the callback shape is livable is still open (CUSTOMIZATION_API_IMPLEMENTATION §8)
ActionContext.run_task, TaskJob, TaskOutcome 2026-10-22; item_progress arrived the same week
ActionContext.show_markdown / copy_text, md_code_block, md_escape 2026-10-22
extension(), manifest.settings 2026-10-22, when it replaced ctx.extension
config.EVENT_HOOKS, HookEvent, manifest.contributes.event_hooks The (ctx, event) shape is from 2026-10-22. Whether directory_changed fires on virtual panes is open.
config.MENU_ITEMS, manifest.contributes.menus Viewer-specific menus are planned
config.IMAGE_DECODERS, manifest.contributes.image_decoders The contract names PuiKit’s RasterImage, and the thumbnail view (#638) is likely to touch it
config.LEXERS, manifest.contributes.lexers Markdown fences need a PuiKit hook, and a hand check is still owed
manifest.contributes.themes, manifest.requires, manifest.extension.updates New
UriPathImpl Newly published, as Preview (§3.2)
PATH_SCHEMES "override": True; ReadOnlyPathImpl members in tier B-low/mid §3

Not public

These are neither Stable nor Preview:


2. The caller side

2.1 Path — the stable member set

Path reaches stable signatures, but it is not importable (xefm.path is internal). What a stable API promises is therefore its member set:

Stated in the docs:

The API snapshot (§7.1) fixes the public dir(Path) to this list, so a new public member has to be classified on purpose. Path’s docstring lists the set.

2.2 Path methods that leave the class

Seven methods move from Path methods to module functions in xefm.path (path.copy_to(dest) becomes copy_to(path, dest)). Extensions cannot import xefm.path, so the existing import rule in ext check enforces this with no new heuristics.

Method Why not public
copy_to, move_to Two failure channels (False and exceptions). overwrite replaces a file but silently merges a directory. Copying behaves differently per storage. Bypasses XeFM’s file operations (conflict dialog, job queue, progress, archive owners #516). Diverges from Python 3.14’s pathlib.Path.copy / move. If extensions need copy or move, that gets designed as a separate Preview ctx API that goes through file operations.
listdir_attrs Returns the internal dir_scan record (alloc, ok, cmp_name, …)
concurrency Internal tuning
forget_cached_metadata Exposes a cache detail
get_display_title UI string whose format may change
get_extended_metadata Shaped for the info dialog (format_hint); #635 will change it

The PathImpl hooks of the same names stay where they are (§3.1, tier B).

Documented limit: dynamic access (getattr(p, "_x")) is beyond any static check. “Names starting with _ and functions in xefm.path are not API. The check helps you keep to that; it does not guarantee it.”

2.3 action_names()

Remove the context parameter. It exposes nine internal context names (isearch, filter_list, search, …), yet invoke() runs only filer actions. The no-argument form is the stable one.

2.4 Constructors

2.5 xefm_tool, xefm_python, is_desktop_mode

PROGRAMS depends on these, and nothing else does their job. They become Stable.


3. The implementer side (PATH_SCHEMES)

3.1 Tiers for a ReadOnlyPathImpl subclass

A. Required. SCHEME, exists(), is_dir(), iterdir(), stat(), open()

B. May override. Each has a default.

Member Confidence Status
READ_ONLY_MESSAGE, IS_REMOTE high Stable
target() (default None) high Stable
DISPLAY_PREFIX, get_display_title() — nothing in XeFM reads them (found while implementing), so there is no behaviour to promise Preview
parse_uri(uri) / root_prefix() (the URI parsing hooks) mid Preview
CAPABILITIES, SEARCH_STRATEGY low: the vocabulary mixes in search tuning Preview
listdir_attrs() low: internal record shape Preview
get_extended_metadata() low: #635 Preview
forget_cached_metadata(), CONCURRENCY / READ_CONCURRENCY / WRITE_CONCURRENCY low: implementation detail Preview

C. Helpers a backend calls. child(name), at(key), key, UriStatResult. Stable.

D. Do not override. Everything else: path arithmetic, __eq__ / __hash__, the write refusals, supports, …

Renames, free while Preview. They take the contract off private names.

Today After
_child(name) child(name)
_at(key) at(key)
_key key (read-only property)
_parse(uri) parse_uri(uri)
_root_prefix() root_prefix()

These live on UriPathImpl. Path does not delegate them, so they do not leak into §2.1. Update doc/VIRTUAL_FOLDERS_FEATURE.md, the skill references and the tests that use _child.

What XeFM promises the backend:

The @preview mark moves from the class to the individual Preview members. The API snapshot (§7.1) fixes the tiers, as it does for Path. test_published_base.py keeps guarding that no new abstract method reaches ReadOnlyPathImpl.

3.2 UriPathImpl → Preview, PathImpl → unsupported

3.3 The PATH_SCHEMES table

Item Status
Key: a scheme name (lowercase, starts with a letter, may contain + - .) Stable
Value: a ReadOnlyPathImpl subclass, or {"class": cls} Stable
{"impl": cls}, an undocumented alias Removed
"override": True (replacing s3://, ssh://, archive://) Preview
A class not based on ReadOnlyPathImpl Outside the promise. UriPathImpl is Preview; PathImpl gets the warning above.
The same key from two sources Stable, as it behaves today (below)

How a key from two sources resolves today, in extensions._apply, for every table: config.py wins over an extension. Between two extensions, the one loaded first wins, and extensions load in ascending order of their package directory name. Bug to fix: when one extension loses to another, its warning says “is also in config.py”. It should name the extension that won.


4. Version, notices, check

Without this, the Stable / Preview split exists only in docstrings and docs. Nothing in the workflow (write → xefm ext check → xefm try → install) would tell an author that they rely on Preview. It ships with API_VERSION 1.

Static: xefm ext check reports every Preview use.

Target How it is found Confidence
Manifest sections (contributes.menus, [settings], [requires], [extension] updates, …) The manifest itself exact
Preview names from xefm.user_api / xefm.path_base (TaskJob, md_escape, extension, UriPathImpl, …) The existing lint already binds these modules and resolves names exact
A ReadOnlyPathImpl subclass defining a Preview tier-B member (listdir_attrs, CAPABILITIES, parse_uri, …) Class bodies whose bases resolve to path_base classes exact
A PATH_SCHEMES entry with "override": True in a manifest-referenced table The table entry exact
ctx.<member> / ctx.pane.<member> where the member is Preview (run_task, show_markdown, copy_text, input, choose, confirm, open_list) Attribute access whose receiver is the first parameter of a function, or a name ctx (entry points take ctx first; so do on_done callbacks), matched against the Preview member names of ActionContext / PaneApi near-exact

The member and name lists come from PREVIEW_APIS at check time, so the check never needs a hand-kept list.

Runtime: one log line the first time a Preview API is used.

5. Docs and skill

6. Tests to touch

7. Detecting API changes in future development

Today, STABLE in test_user_task_api.py catches only an unclassified new name. test_published_base.py pins only the abstract-method set. Nothing catches a signature change, a member removed from PaneApi / EntryInfo, a config-table or manifest schema change, or a behavioral test whose expectation was quietly edited. There is no CI, so all of the following runs under local pytest and at the release pre-tag check.

7.1 API snapshot

7.2 Contract tests

7.3 Real extensions and the release check

8. After release

9. Deprecation — how a stable API goes away

Added after the first release of this plan (discussion #469 asked for “how deprecation works” as part of the compatibility promise).

  1. Deprecate first. @deprecated("use … instead") in xefm/preview.py marks a stable function, method, property getter or class. A config.py table or a manifest section goes into DEPRECATED_APIS by name. The API keeps working. Its docstring opens with “Deprecated — …”, it is listed in xefm.user_api.DEPRECATED_APIS with what replaces it, its first use from outside XeFM logs a warning naming the caller, and xefm ext check reports each use as a warning (deprecated_uses, part of check_manifest). The snapshot records it as deprecated, which is not a breaking change.
  2. Keep it for at least one minor release. The release that deprecates it says so in its notes, with the replacement.
  3. Then remove it, and bump API_VERSION. Removing a deprecated API is a breaking change, so make api-snapshot refuses it without the bump. Removing a stable API that was never deprecated is refused the same way, and the message asks for deprecation first. A bump overrides it for the rare case that cannot wait (a security problem), and the release notes must say why.

Preview APIs need none of this: they change or go in any release.

10. Operations from the API — dedicated calls, one shape (#716)

Added with ctx.copy / ctx.move. An action reaches a built-in operation through a dedicated call, added where one is needed, not through a general way to run any action with its inputs given up front.

10.1 The shape every dedicated call follows

10.2 Set aside: invoke() with inputs

ctx.invoke(name, operands=..., args=...) would have made every action callable with its inputs: operands the panes’ state (this / other / left / right, each a dir, selected and focused, as dataclasses), and args the values an action prompts for today (a name, a pattern). It was set aside because:

invoke() stays as it is.

10.3 Future idea: args

If a dedicated call ever needs the values a built-in prompts for, the shape considered was a per-action dataclass (CreateDirectoryArgs(name="build")), declared in the action’s metadata (#718) so the snapshot covers it. A value given skips its prompt; one not given is still asked for. Safety confirmations are not args and are never skipped by them. Nothing needs this yet.

10.4 ctx.trash / ctx.delete (#782)

Two calls, mirroring the two built-ins rather than one call that follows DELETE_TO_TRASH: the setting is the user’s choice for a key, and an action that asks for the trash should get it, or be told why not.