WORK-657
ID:WORK-657Status:ready

refrakt format re-indents nested block tags, with a check mode and editor formatting

Once WORK-645 allows indentation, SPEC-170 D5 sets the rule for when to indent: a block tag's content is indented only when it contains another block tag. A rule nobody can apply mechanically drifts, and no existing tool applies this one:

Priority:highComplexity:moderateMilestone:v0.42.0Source:SPEC-170
claude/v0-42-0-planning-ata7nd View source

Criteria completion

Criteria completion: 0 of 10 (0%) checked; tracking started on Oct 22, no incremental history yet0%25%50%75%100%Oct 22Oct 28

Tracking started Oct 22 — check back for trends.

Branches 3
History 1
  1. f7f9792
    Created (ready)by bjornolofandersson

Acceptance Criteria

  • refrakt format [paths] re-indents .md files by SPEC-170 D5: one tab per level of block-tag nesting, applied only inside a block tag that contains another block tag; inline tags do not count
  • It changes only the leading whitespace of lines inside block tags; every other byte is unchanged, asserted on fixtures that include lists, tables, emphasis and long tag openings
  • A fenced code block keeps its internal relative indentation and is shifted as a whole
  • It writes a file only when the AST parsed with the shared parse is unchanged; otherwise it reports the file and line and leaves the file alone
  • Formatting is idempotent: a second run changes nothing, asserted on every fixture
  • refrakt format --check exits non-zero and names each file that would change; CI runs it beside npm run format:check (.github/workflows/format.yml)
  • The language server provides document formatting with the same function, so editors can format on save
  • Every file under plan/ is unchanged by a run, asserted once in the resolution
  • The MCP server exposes it, or the resolution records why not
  • The composed-runes guide and the content-authoring docs state the rule and the command

Approach

  • Use the tokenizer to find each block tag's opening and closing lines. Work out each line's nesting depth, and rewrite the leading whitespace only. Do not reprint from the AST.
  • Lines inside fences, and continuation lines of list items, need care. The AST-equality guard is what makes a mistake there harmless: a wrong rewrite is refused, not written.
  • The CI check starts with the paths the rule is enforced on (site/content/, the composed fixtures, plan/), and widens as WORK-658 migrates them.

Blocked by

  • WORK-645: the shared parse with allowIndentation.

References

  • SPEC-170: D3 (round trips), D5 (the rule).