# [READY] wk-files — File-backed work items ## Introduction A devtree project accumulates planning material as plain markdown. Task notes sit at the project root as `TASK-.md`, idea notes and bug reports as `IDEA-.md` and `BUG-.md`, handoff documents as `HANDOFF-.md`, and larger pieces of work live in spec directories seeded and moved by `manage-spec`, each holding a `DISCOVERY.md`, a `SPEC.md`, and one `EXPLO-.md` per exploration topic. A date segment in a capture name, as in `TASK-20261001T1110-fix-parser.md`, is the legacy form that older files still carry; the timestamp now lives in the file's frontmatter. Every one of those files declares what it is in its filename and where it stands in the first line of its H1 heading. Nothing reads those declarations. Answering "what is ready in this project" or "which specs are still claimed" means listing directory entries and reading headings by hand, and an agent asked to pick up the next piece of work does the same thing with less patience. The harness already has a frontend for the other half of the problem: `wk` wraps `bd`, so beads issues are listable, filterable, and addressable from a command line. File-backed artefacts have no equivalent surface. `wk-files` is that surface. It is invoked as `wkf`. It manages artefacts that already exist: it enumerates them, filters them by the state they are in, shows where each one lives, and applies the small set of transitions the conventions already describe. It never creates files, scaffolds templates, chooses names, or invents titles. Starting work stays the act of writing a file, by hand or by a skill that knows the template. The two backends stay separate on purpose. `wk` keeps wrapping `bd` and stays unaware of this addition, so file-backed management ships as a command of its own instead of a namespace inside the beads frontend. A unified surface over both stores is a plausible future, and deliberately not this spec. Scope is one project at a time: the tree of the project reachable from the current directory. A listing starts where the caller stands and widens to the project root on request, while an id names its item from anywhere in the project. Cross-devtree listing, and any synchronisation between the two stores, are out of scope. ## Naming & IDs The kinds are `task`, `handoff`, `idea`, `bug`, `spec`, and `explo`. An id names one item: `[kind]:[name]` or `[kind]:[name]:[part]`. The walk is the scan an item comes from: it starts at the nearest git root and descends recursively. Placement / Scope defines exactly what it skips. | Kind | Artefact | Id | |------|----------|-----| | `task` | `TASK-.md` anywhere under the walk | `task:fix-parser` | | `handoff` | `HANDOFF-.md` anywhere under the walk | `handoff:beads-shared-server` | | `idea` | `IDEA-.md` anywhere under the walk | `idea:ask-for-each-mode` | | `bug` | `BUG-.md` anywhere under the walk | `bug:parser-drops-eof` | | `spec` | `SPEC-DRAFT-/`, `SPEC-READY-/`, `SPEC-KO-/`, or legacy `_SPECS//` | `spec:wk-files` | | `spec` | that spec's `EXPLO-BRIEF.md` | `spec:wk-files:explo` | | `explo` | a standalone `EXPLO-.md` outside any spec directory | `explo:devtree-hook` | The name drops three things: the kind prefix, an optional leading date or timestamp token, and the `.md` suffix. `TASK-fix-parser.md` is `task:fix-parser`, and so is the legacy `TASK-20261001T1110-fix-parser.md`: the kind token already carries the type, and a date is metadata rather than identity. The timestamp comes from the `created-at` field of the frontmatter block a capture opens with, falling back to a leading date token in a legacy name. Parse `20261001T1110` and `20260920` down to the calendar day, discard the time, and expose it on `show`. When a legacy name and a block disagree, the block wins; the filename token is read only when the block is absent. The timestamp orders rows, but never decides a status or a section: rows sort by status, then by directory, then by `created-at` newest first, then by name. An item with neither a block nor a date token sorts after the others in its directory, keeping name order among its peers. A spec id is its slug and survives everything the lifecycle does to it — the `DISCOVERY.md` to `SPEC.md` carrier change, and the directory moves between the draft, ready, and retired prefixes. Path, carrier, and status change; the id does not. Arguments resolve against the filesystem, not against syntax. An argument is a path when it points at an existing file inside the walk, and an id when it matches exactly one discovered item; either form is accepted by every verb that takes an item. ```pseudocode resolve(arg): path_hit = arg is an existing file inside the walk id_hit = arg matches exactly one discovered item dups = more than one item of the same kind reduces to the same slug if path_hit and id_hit and different items -> ambiguous error, naming both if path_hit -> that item if dups -> duplicate-slug error, naming every colliding path if id_hit -> that item if ":" in arg -> unknown id error else -> file not found error ``` An argument outside the walk is never an item, however it is spelled. An id is portable within one project: it means the same item from any directory of that project, because a slug belongs to exactly one item of its kind there. Across projects it means nothing — two repos can each own `task:fix-parser`, and a command run in the wrong project resolves the wrong item or none at all. Slug uniqueness is a corpus invariant, not a lookup strategy: within one kind, no two items share a slug, wherever they sit in the tree. `wkf` never creates files, so it cannot enforce the invariant at the source; what it can do is refuse to paper over a violation, which is why a duplicate is an error rather than something the id syntax works around. A duplicate reaches the user as an error naming every colliding path, and the repair is a rename by hand — e.g. two `SPEC-/` directories, or a slug present in both `_SPECS//` and `SPEC-DRAFT-/`, which `manage-spec migrate` resolves. It is fatal only where it can affect the answer. A `--type` filter that excludes the colliding kind, or a query that never names those items, runs normally; an unfiltered listing, or any id resolving to the shared slug, fails instead of returning an answer it cannot name honestly. So a listing never prints two rows under one id, and a corpus with a duplicate stays usable everywhere the duplicate is irrelevant. ## Interface / How to use `wkf` exposes the listing verbs and the item verbs at the top level, and every mutation under `do`. The listings answer different questions: `status` curates and groups, `ls` lists everything outside the archive. ```console $ wkf --help Usage: wkf [options] COMMANDS: status grouped listing, the default view ls flat listing, archived excluded draft|ready|claimed|done|abandoned list one status group (status --filter sugar) show report one item do apply a mutation OPTIONS: --by-dir group by directory first (status default) --by-status group by status first (status only) --filter draft, ready, claimed, done, abandoned, archived; prefix `+` to add --type comma-separated: task, handoff, idea, bug, spec, explo --all list from the project root instead of the current directory --json machine-readable output (any command) actions: claim, finish, abandon, undo, reset, archive ``` Both listings show the invocation directory and everything below it, and `--all` widens that to the whole project. The item commands ignore the current directory, so an id or a path names the same item from anywhere in the project. Scope is a listing concern; see Placement / Scope for the tree itself. ### `status` Bare `wkf status` answers "what is where": it groups by directory, and each directory holds its items under status headings. Both levels always print, even when a directory holds a single group, so a heading never hides the shape of the answer. Every heading names its axis, `Dir: