Skip to content

build(hooks): format Markdown with dprint instead of prettierd - #139

Merged
furedea merged 2 commits into
mainfrom
build/format-markdown-with-dprint
Nov 10, 2026
Merged

furedea merged 2 commits into
mainfrom
build/format-markdown-with-dprint

Conversation

@furedea-agent

@furedea-agent furedea-agent Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #135

概要

Markdown の lint/format hook を prettierd から dprint(dprint-plugin-markdown 0.29.0, listIndentKind: pythonMarkdown, textWrap: maintain)へ移す.
prettierd は cwd ごとに終了しないデーモンを起動し,worktree ごとに孤児が溜まっていた.dprint は常駐しない.

変更

  • markdown_plan: autocorrect → 既存の dprint_plan(プロジェクトの dprint 設定が優先,prettier 設定があれば policy step)
  • defaults/dprint.json: markdown プラグインと md の include を追加
  • 削除: PRETTIERD_DEFAULT_CONFIG,PERSONAL_PRETTIER_CONFIG_NAME,defaults/prettier.json,command_permissions.json の prettierd
  • 既存バグ修正: 同梱設定へのフォールバック時,--includes-override <相対パス> が設定ディレクトリ基準で解決され,--allow-no-files により何も整形されなかった(JSON/TOML も同様).対象ファイルを位置引数で渡すよう変更

実測

  • ネストリストは 4 スペース,散文の改行は保持される(integration テストで確認)
  • プロジェクトの dprint.json に markdown プラグインが無い場合: エラーなし(exit 0),整形されない(no-op).テストで固定
  • 注意: 残存する ~/.prettierrc はホーム直下の設定として無視する(dotfiles 側の削除までの暫定).Markdown では Biome 設定を競合とみなさない

テスト

uv run pytest: 4541 passed, 1 skipped.ruff format --check / ruff check 通過.

🤖 Generated with Claude Code

prettierd starts a never-exiting daemon per cwd, and orphans piled up
across worktrees. dprint-plugin-markdown (listIndentKind, 0.22.0+) can
now keep 4-space nested lists, so route Markdown through the same
dprint policy as JSON/TOML and drop the prettier plumbing.

Also pass the target as a positional file instead of
--includes-override: with the bundled config the override resolved
against the config directory and silently matched no files.

Closes #135

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T14:50:52.993938Z
We couldn’t complete this review. Comment @codex review to try again.
32d5593 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

Comment thread agents/hooks/lib/formatter_policy.py Outdated
PERSONAL_DPRINT_CONFIG_NAME = "dprint.json"
PERSONAL_PRETTIER_CONFIG_NAME = ".prettierrc"
PERSONAL_CONFIG_NAMES = frozenset({PERSONAL_DPRINT_CONFIG_NAME, PERSONAL_PRETTIER_CONFIG_NAME})
PERSONAL_CONFIG_NAMES = frozenset({PERSONAL_DPRINT_CONFIG_NAME})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — If you drop .prettierrc from PERSONAL_CONFIG_NAMES, project_files will start treating ~/.prettierrc as a real project declaration whenever the walk reaches $HOME. That breaks more than Markdown: dprint_plan runs for JSON and TOML too, so for anyone who still has the ~/.prettierrc that the dotfiles installed, every JSON, TOML or Markdown edit under ~ without a nearer config now returns Lint/format unavailable … takes precedence over dprint and nothing gets formatted. The PR description only mentions Markdown, and the fix depends on a separate dotfiles change (#435) landing first. Consider keeping .prettierrc in the home exclusion set, or at least ignoring it at $HOME, until that change has shipped.

Comment thread agents/hooks/lib/formatter_policy.py Outdated
Step("prettierd format", ("prettierd", filename), writes_stdout=True, mutates=True),
)
"""Fix spacing with autocorrect, then format with dprint under the JSON/TOML policy."""
return (Step("autocorrect format", ("autocorrect", "--fix", str(path)), mutates=True), *dprint_plan(path))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 — Sending Markdown through dprint_plan means it also inherits the OTHER_FORMATTER_CONFIG_NAMES gate, and that gate includes biome.json and biome.jsonc. Biome does not format Markdown. So in any Biome project, every .md edit now gets Lint/format unavailable — Project formatter declaration biome.json takes precedence over dprint, and the file is never formatted. Before this change, prettierd formatted it. For Markdown, only prettier declarations should yield the policy step, or Biome configs should be skipped for md. There's a test for the .prettierrc case but none for biome.json + .md.

@github-actions

Copy link
Copy Markdown

Review summary

No blocking issues. Moving from prettierd to dprint, and passing the target as a positional argument instead of --includes-override, both look correct. The two integration tests cover list indentation, kept wrapping, and the no-op when the project config has no Markdown plugin.

P2 findings (inline):

  • Removing .prettierrc from PERSONAL_CONFIG_NAMES makes a leftover ~/.prettierrc count as a project declaration. That turns off dprint for JSON, TOML and Markdown under $HOME until the dotfiles change (#435) lands, not just Markdown.
  • Markdown now picks up the biome.json gate. Every .md edit in a Biome project gets a policy error, even though Biome doesn't format Markdown. There's no test for this case.

Side note, not a separate finding: a personal ~/dprint.json without the Markdown plugin will silently skip Markdown, the same way the project-config case does.

…ring home .prettierrc

Biome does not format Markdown, so only prettier declarations should
make the Markdown plan defer. A leftover personal ~/.prettierrc must
not shadow dprint for JSON, TOML, or Markdown under $HOME.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@furedea-agent

furedea-agent Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@furedea

furedea commented Nov 10, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions

Copy link
Copy Markdown

Review summary

No blocking findings, and nothing rose above the bar for an inline comment.

What I checked:

  • markdown_plan now runs autocorrect and then dprint_plan(path, PRETTIER_CONFIG_NAMES). A project-level prettier config gives the policy step. Biome is correctly left out of the rivals for Markdown. A leftover ~/.prettierrc is still ignored under $HOME, because PERSONAL_CONFIG_NAMES keeps that name.
  • The fallback-config fix (passing the file as a positional argument instead of --includes-override) looks right. cwd is path.parent and the argument is path.name, or the project root and the relative path when there is a project config. This also fixes the JSON/TOML no-op.
  • No code references the removed PRETTIERD_DEFAULT_CONFIG, PERSONAL_PRETTIER_CONFIG_NAME or prettier.json any more. writes_stdout is still used by other steps, so keeping it is correct.
  • Tests cover the new plan shape, the prettier policy step, ignoring Biome, the leftover ~/.prettierrc, and end-to-end formatting (integration tests, skipped when dprint is not installed).

Behaviour changes to be aware of (intended, not bugs):

  • Projects that have a .prettierrc used to get their Markdown formatted with prettierd. Now they get a "Lint/format unavailable" policy message for .md files.
  • A project dprint.json without the markdown plugin turns Markdown formatting into a silent no-op.

I could not run dprint locally, so I did not check the positional-argument semantics against a real binary.

@furedea
furedea merged commit 68dfcf6 into main Nov 10, 2026
22 of 24 checks passed
@furedea
furedea deleted the build/format-markdown-with-dprint branch November 10, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build(hooks): format Markdown with dprint instead of prettierd

1 participant