Skip to content

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

Merged
furedea merged 3 commits into
mainfrom
build/replace-prettierd-with-dprint-for-markdown
Nov 10, 2026
Merged

furedea merged 3 commits into
mainfrom
build/replace-prettierd-with-dprint-for-markdown

Conversation

@furedea-agent

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

Copy link
Copy Markdown
Contributor

Closes #435

概要

Markdown の formatter を prettierd から dprint(listIndentKind: pythonMarkdown, textWrap: maintain)へ戻し,prettierd を削除する.

変更

  • dprint/dprint.json に markdown プラグイン(hash 固定)と md の includes を追加.lefthook の glob も md を含める
  • nvim(conform)の markdown を autocorrect → dprint に変更し,prettierd の override を削除
  • prettierd,prettier/.prettierrc,~/.prettierrc リンクと関連 TODO を削除
  • tests/esa/format.bats を dprint fmt --stdin に移行し,散文の改行保持とネストリスト 4 スペースを検証
  • README の formatter の説明を更新
  • 既存 Markdown を再整形(ADR 3 件,SKILL.md,README.リスト項目の折り返し行インデント 2→4 のみ)
  • agent-config input を 68dfcf6 に更新(hook が dprint を使う版)

確認

  • bats tests,autocorrect --lint,stylua --check,nixfmt --check,nix flake check が通過

ユーザー作業

darwin-rebuild switch 後,Markdown を hook と nvim で整形し,pgrep prettierd が空であることを確認する.

レビュー指摘への対応

  • Claude review の P2(~ 外の絶対パスで ~/dprint.json が効かない懸念)は,dprint 0.64.3 での実測により否定された.dprint fmt --config <dir>/dprint.json --stdin /other/abs/post.md は rc=0 で整形され(ネストリストは 4 スペース),相対名と同じ結果になる.tests/esa/format.bats に回帰テストを追加した(8fb462d).なお eb75105 の --config フォールバックは,プロジェクト設定が無いバッファ向けの保険として残す.
  • Codex review は usage limit により失敗(既知).

🤖 Generated with Claude Code

prettierd starts a never-exiting daemon per cwd and leaves orphans.
dprint-plugin-markdown now supports listIndentKind (#176), so use it
with pythonMarkdown for four-space nested lists.

- add the markdown plugin and md includes to dprint.json and lefthook
- use dprint for markdown in conform.nvim
- remove prettierd, ~/.prettierrc and prettier/
- migrate tests/esa/format.bats to dprint
- reformat tracked Markdown (list continuation indent 2 -> 4)
- update agent-config to pick up the dprint-based hook

Closes #435

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-10T16:31:18.092225Z
We couldn’t complete this review. Comment @codex review to try again.
8fb462d 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.

formatters_by_ft = {
-- Text files: CJK spacing then structure formatting
markdown = { "autocorrect", "prettierd" },
markdown = { "autocorrect", "dprint" },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The removed prettierd override was there so that files outside ~ still got the global config. esa edit creates its buffers under tempfile.mkdtemp() ($TMPDIR/esa-edit.*/post.md, see zsh/esa.py:101). conform runs dprint fmt --stdin $FILENAME with cwd set to the nearest dprint.json. For a file in $TMPDIR no dprint.json is found. Even if dprint falls back to ~/dprint.json, the absolute path /var/folders/.../post.md is outside that config's base, so the **/*.{json,toml,md} includes probably won't match. dprint then returns the input unchanged, or errors. I didn't run this, so please confirm it. If it holds, esa articles would quietly stop being formatted.

The new bats test passes the relative name article.md with an explicit --config, so it doesn't cover this path. Possible fixes: pass --config ~/dprint.json through a formatters.dprint override, or add a test that formats a file under $BATS_TEST_TMPDIR using the nvim/conform path.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

I found nothing blocking (no P0 or P1). The dprint config, the lefthook glob, the Nix cleanup, and the Markdown reformat all look consistent. The reformat only changes continuation-line indentation, so the rendered output stays the same.

  • P2 (nvim/lua/plugins/format.lua): removing prettierd also removed the handling for files outside ~. With conform's default dprint invocation, esa edit buffers in $TMPDIR may not pick up ~/dprint.json or match its includes, so they could go unformatted without any error. I didn't run this, so please confirm it. The new bats test uses a relative filename and an explicit --config, so it doesn't cover this path.

Also, tests/esa/format.bats isn't in the CI Bats job's file list. That was already true before this PR, but it means the new nested-list test only runs locally.

I couldn't check that markdown-0.29.0 accepts listIndentKind (no network in the review sandbox). I'm relying on the reported local bats run for that.

@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.

if has_project_config then
return { "fmt", "--stdin", "$FILENAME" }
end
return { "fmt", "--config", vim.fn.expand("~/dprint.json"), "--stdin", "$FILENAME" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: The $TMPDIR fallback may silently leave the file unformatted. Conform passes $FILENAME as an absolute path. For example, the esa editor uses tempfile.mkdtemp(prefix="esa-edit.")/post.md (zsh/esa.py:101), which on macOS is under /var/folders/.... I believe that when dprint fmt --stdin gets a full path, it checks it against the config's includes/excludes. Those patterns (**/*.{json,toml,md}) are resolved relative to the config's directory (~). If so, a file outside ~ does not match, and dprint returns the input unchanged with exit 0. esa posts would then get no structure formatting, which prettierd did provide before. I could not run dprint here to confirm this.

The new bats test calls --stdin article.md with a bare filename, which skips that check, so it does not exercise this path. Two possible fixes: pass only the basename (e.g. vim.fn.fnamemodify(ctx.filename, ":t")) in the fallback branch, or add a test that formats an absolute path outside $REPO_ROOT.

@github-actions

Copy link
Copy Markdown
Contributor

Review summary

I found no P0 or P1 issues. The dprint config, lefthook glob, CI coverage of Markdown, prettierd removal and Markdown reformatting look consistent.

  • P2 nvim/lua/plugins/format.lua: with the ~/dprint.json fallback, conform passes an absolute $FILENAME. dprint may check that path against includes, which are relative to ~, and return files under $TMPDIR unchanged. That would include the esa editor's post.md. The bats test uses a bare filename, so it would not catch this. I could not run dprint to confirm it.

Blocking findings: 0

furedea
furedea previously approved these changes Nov 10, 2026
@furedea-agent

furedea-agent Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Re P2 (nvim ~/dprint.json fallback for files outside ~): refuted by measurement. With dprint 0.64.3 and this PR's dprint/dprint.json, dprint fmt --config <dir>/dprint.json --stdin /other/abs/post.md exits 0 and formats the file (nested list becomes 4 spaces), the same as a bare filename. The absolute path outside the config directory is therefore not a problem. Pinned by a new bats case in 8fb462d. The explicit --config fallback added in eb75105 stays as a safeguard only for buffers with no project config.

@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
Contributor

Review summary (read-only): no findings.

Checked: dprint markdown plugin config (hash-pinned, pythonMarkdown + textWrap: maintain), the lefthook and CI dprint check coverage of md, the conform dprint args override (it keeps conform's default cwd root detection and falls back to --config ~/dprint.json only when no project config is found), complete removal of prettierd and .prettierrc (no references left), and the updated Bats tests, which cover line-break preservation, 4-space nested lists, and the absolute-path-outside-config case. The re-formatted Markdown only changes continuation indentation.

Blocking findings (P0/P1): 0

🤖 Generated with Claude Code

@furedea
furedea merged commit 20cbddc into main Nov 10, 2026
19 of 21 checks passed
@furedea
furedea deleted the build/replace-prettierd-with-dprint-for-markdown branch November 10, 2026 16:39
furedea added a commit that referenced this pull request Nov 10, 2026
## 概要

CI の `bats-tests` ジョブが bats ファイルを 3 件だけ列挙していたため,残りが CI
で走っていなかった.探索ベースに変更し,新しい bats ファイルが黙って漏れないようにする.

## 設計

- CI(ubuntu): `bats --recursive --filter-tags '!macos' tests`
- Mac(ローカル): 従来どおり `bats --recursive tests` で全件
- macOS 専用テストは別ファイルに分け,先頭に `# macOS only: <理由>` と `# bats
file_tags=macos`(bats 1.12 のファイルタグ)を置く.混在ファイルは `<name>_macos.bats`
に分割する(`tests/zsh/startup.bats` の 1 件を `startup_macos.bats` へ)
- 印の付け忘れは Linux CI で落ちるため,macOS 専用かどうかの判断が強制される
- テストごとの `require_macos` ヘルパーは採用しない(印が散らばるため)
- macOS ランナーの追加はこの PR の範囲外(必要になったら別 Issue で実測してから判断する)

## 変更

- `.github/workflows/ci.yml`: `bats-tests` を探索実行 + `--filter-tags
'!macos'` に変更
- macOS 専用ファイルにタグと理由を追加.`tests/zsh/startup.bats` から macOS 専用の 1 件を
`startup_macos.bats` に分割.`tests/zsh/ssh_agent.bats` は `.zshrc` が
`OSTYPE=darwin` でのみ動くため,全件が Linux では空振りになるのでファイル全体を macos タグにした
- `tests/ssh-agent/load_identity.bats`: BSD 専用の `stat -f` を `find -perm
0700` に置き換え,Linux でも実行
- `tests/esa/nvim.bats`: リポジトリの `nvim` を `runtimepath`
に追加(`~/.config/nvim` が無い環境でも動く).dev shell に `neovim` を追加
- README: `macos` タグの意味と CI での除外を追記

#438 はマージ済みで,`tests/esa/format.bats` は dprint で Linux 上で実行される.

## 分類(19 ファイル + 分割 1 件)

| ファイル | 分類 | 根拠 |
|---|---|---|
| tests/codex/update_codex.bats | linux | モックのみ |
| tests/esa/format.bats | linux | dprint(dev shell 提供) |
| tests/esa/nvim.bats | linux | headless nvim と esa モック |
| tests/esa/zsh.bats | linux | モックのみ |
| tests/herdr/herdr_command.bats | macos | aarch64-darwin の Home Manager
をビルド |
| tests/hister/server_launcher.bats | linux | モックのみ |
| tests/moshi/lifecycle.bats | linux | モックのみ |
| tests/moshi/update_moshi_hook.bats | linux | モックのみ |
| tests/nix/agent_hook.bats | macos | darwin の activationPackage をビルド |
| tests/nix/codex_notification.bats | macos | darwin 向け codex パッケージをビルド
|
| tests/nix/configuration.bats | macos | `checks.aarch64-darwin` をビルド |
| tests/nvim/lspmux.bats | linux | headless nvim |
| tests/ssh-agent/load_identity.bats | linux | `find -perm` に置き換えて Linux
対応 |
| tests/ssh-agent/sign_ssh.bats | linux | モックのみ |
| tests/terminal-browser/terminal_browser.bats | macos | darwin-arm64
バイナリを実行 |
| tests/zsh/cache.bats | linux | モックのみ |
| tests/zsh/repository_search.bats | linux | モックのみ |
| tests/zsh/ssh_agent.bats | macos | `OSTYPE=darwin` 限定のロジックで,Linux
では全件が空振りになる |
| tests/zsh/startup.bats | linux | 10 件 |
| tests/zsh/startup_macos.bats(新規) | macos | darwin の Home Manager をビルド
1 件 |

ローカル(`bats --count`): 全 90 件,`--filter-tags '!macos'` で 72 件,macOS 専用 18
件.

Closes #440

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: furedea <[email protected]>
Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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(format): replace prettierd with dprint for Markdown

1 participant