okf dirs
The shape of the bundle: one row per directory.
When to use it
- As the first read on a bundle you do not know. One row per directory stays small whether the bundle holds thirty concepts or three thousand, so it orients you before you open anything.
- To find where the mass sits before a consume or a refine pass:
--diradds a subtree count, so you can see which branch carries the weight. - To plan a descent. Name the branch here, then open it with
okf index --dir. The skill leads withokf dirsfor exactly this reason:dirsemits one row per directory whereindexemits one row per concept, so the two scale with different things.
How it works
okf dirs <dir|@slug> lists every directory in the bundle with the number of concepts living directly in it, root first and the total last. The count is direct, never a rollup, so a directory holding nothing but sub-directories reads 0 rather than a hidden sum, and the column adds up to the bundle's concept count exactly. Every directory the tree has appears, including the empty intermediates that exist only to connect one branch to another, because each is still a directory you can address. JSON shape: { bundle, total, count, dirs: [{ dir, count, subdirs }] }.
Three flags shape the view:
--dir PATH(repeatable) narrows to one directory and everything below it, and adds asubtreecount per row: the concepts at or below that directory. The subtree number is defined as exactly what--dir PATHitself returns, so the count and the flag can never disagree. A concept matches when its directory is the path or sits below it, so--dir platformreachesplatform/services/api.rootis the unquoted spelling of., the bundle root alone; since 1.13.0 a bundle that actually has aroot/directory keeps it addressable, because the real directory wins over the alias. Matching folds case, and a trailing slash on the label the views print is accepted.--depth Nkeeps only that many directory levels below the starting point, where the starting point is the--dirwhen one is given and the bundle root otherwise. It is relative, not absolute, so--dir a/b --depth 1reads "a/b and one level under it" with no need to know how deepa/balready is.--depth 0is the starting point alone. Anything but a whole number is a usage error (exit2).--fields/--exceptproject the JSON down to the properties you want, over the row shape above.
With --dir, the chain of ancestors up to the root is shown by default so the branch is never adrift of the context that names it; --no-ancestors drops it. Ascent and descent are separate axes, so --depth never bounds that chain.
Try it
okf dirs docs/
Dirs — docs
Dir Concepts
(root) 3
cli 15
skill 9
guides 3
4 dirs · 30 concepts
Find where the weight sits, with subtree counts:
okf dirs docs/ --dir cli --depth 1
The subtree column then reads the concepts at or below each row, and the deprecated first-segment rollup never enters it. To walk a large tree a level at a time, raise --depth one step at a time; to project the JSON, add --fields dir,count,subtree.
Pitfalls
- The count is direct, not a subtree. A parent directory's row counts only the concepts directly in it, which is why the column sums to the total. When you want "how much is at or below here", reach for
--dirand read thesubtreecount. - Empty intermediate directories read
0, not nothing. A directory that holds only sub-directories still appears, because it is still one--dircan address. That is information, not noise. --depthis relative to the starting point.--dir a/b --depth 1is "a/b and one level under it", not "the second level of the whole tree". Ascent to the root is a separate axis and is not bounded by--depth.dirsspeaks the full path. The rowplatform/servicesis the whole directory, not a first segment. The deprecated--area/--by areaonly ever saw the first segment; the full-path world is--dirandstats'sby_dir.