Expand description
Corpus file discovery — a byte-exact port of find_markdown_files
(src/rac/core/fs.py) and the walk seam, per PORT-CONTRACT.d/09 §1.
Landmines reproduced here:
- Extension filter is the literal glob
*.md, case-sensitive on Linux:upper.MD,x.Md,x.markdowndo not match. - Hidden exclusion: any component of the path relative to root that
starts with
.drops the path (hidden dirs at any depth, and hidden files). Equivalent to pruning hidden entries during the walk. - Symlink asymmetry (Python 3.11
rglob): a symlinked file matching*.mdIS yielded; a symlinked directory is NOT descended. - Sort is component-wise (
PurePath._cpartstuple), NOT whole-string:sub/c.mdsorts beforesub-x.md. We sort by the tuple of relative components, each compared by Unicode scalar (== UTF-8 byte order).
Structs§
- Walk
Entry - One discovered markdown file.
Enums§
- Walk
Target - What a command should do with a positional path argument: validate/inspect and friends dispatch a single file directly, a directory through the walk.
Functions§
- dispatch
- Classify a positional path argument for single-file vs directory dispatch.
- find_
markdown_ files - Find
*.mdfiles underdirectory, dropping any path with a dotted component, in component-wise sorted order.recursive=falselooks only at direct children (root.globinstead ofroot.rglob). - is_
directory - True if
pathis a directory (the guardPath(arg).is_dir()used bystats/export/reviewbefore walking). - normalize_
root - Normalize a directory argument the way
str(Path(directory))does (PurePosixPath semantics, PORT-CONTRACT.d/09 §1.6): - py_join
str(Path(root) / a / b / ...)— the normalized root joined with literal relative components (skill/hook install destination paths). Reuses the walk’sjoin_displaysemantics: a bare-.root vanishes, “/” and a preserved “//” prefix avoid doubled slashes.