Skip to content

npm run format mass-reformats ~125 files: no Prettier config, unpinned major range resolves to 3.9.6 #445

Closed

Description

@ranxianglei

来源: #442 (#442) 分析时发现(PR #443 实现过程中触发)

Repro: on pristine master, npm ci && npx prettier --check . fails on ~125 files. Running npm run format rewrites package.json (4→2 space indent), regenerates package-lock.json, and wraps/reindents virtually every src/ and tests/ file.

Cause:

  • No Prettier config file exists in the repo, so Prettier runs on defaults (printWidth 80) that do not match the committed style.
  • devDependency is prettier ^3.3.0, which now resolves to 3.9.6 — the committed style predates the current major's defaults.
  • CI (.github/workflows/ci.yml runs: npm ci, typecheck, test, build, check-pr.sh) does not run format:check, so the drift is invisible to CI and only explodes locally.

Impact: AGENTS.md lists npm run format / npm run format:check as standard build commands, but running them today produces a 125-file churn diff that buries any real change and defeats the PR diff-cleanliness gate (§7.5). Any agent following the documented commands hits this (hit during PR #443 implementation; the mass reformat was reverted and formatting was skipped instead).

Suggested fix (owner decision): either (a) add a .prettierrc matching the committed style AND pin prettier to an exact tested version, then re-run format once deliberately; or (b) remove format/format:check from AGENTS.md build commands until a config exists. Option (a) restores the documented workflow; option (b) is lower-risk but leaves the command broken-by-omission.

Activity

  1. ranxianglei commented on Sep 26, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷 Reproduced + root-caused — recommending option (a); your call before I push

    Repro confirmed on pristine master (476d440): npm ci resolves prettier ^3.3.0 → 3.9.6; npx prettier --check . fails on 125 files. No .prettierrc, .editorconfig, or .prettierignore exists in the repo.

    Key finding — the committed style was never prettier-formatted. I tested printWidth 80/100/120/140 against Prettier defaults: no config makes pristine master pass (best case = 125 files at width 80). The code mixes three habits: long single-line signatures up to ~120 cols (e.g. src/nudge-text.ts:19), manually-wrapped ~80-col blocks, and hand-packed multi-field object lines (src/nudge-text.ts:83) that Prettier would never produce. So "match the committed style" can only be approximate — option (a)'s deliberate one-time reformat is unavoidable under any width. (Sibling check: opencode-acp has a .prettierrc but its no-semicolons style contradicts acp-kernel's committed semicolon style — not transferable. Everything else in the committed style already equals Prettier v3 defaults: semi, double quotes, 2-space, trailing commas → printWidth is the only real knob.)

    Measured churn of the one-time run:

    printWidth files changed lines what it does
    80 125 ~29.5K wraps most long signatures into multi-line param lists
    120 161 +10,556 / −12,503 unwraps manual ~80-col wraps; keeps long signatures as written

    Recommendation: option (a), concretely:

    1. .prettierrc = { "printWidth": 120 } — matches how new code is actually written (recent PRs use long single-line signatures); fewer total changed lines than 80.
    2. Pin devDep "prettier": "^3.3.0" → "3.9.6" exact (= current lockfile resolution = the version tested here). Kills silent future re-drift.
    3. New .prettierignore: dist/, coverage/, tmp/, .tmp/, package-lock.json (npm-owned — Prettier would rewrite it), *.tgz, .acp-*.json. Without this, format would mangle build output and the lockfile.
    4. One isolated, clearly-labeled mass-format commit (161 files, pure whitespace/wrapping, zero semantic change).

    Verified on the formatted tree: prettier --check clean · typecheck clean · 1122/1122 tests pass · build OK. Branch is fully staged locally (2 commits: config+pin, then the labeled reformat) — push + PR happens the moment you say go.

    One extra decision for you: CI never runs format:check — that's why this drift stayed invisible for months. I recommend adding it to the ci.yml test job as a third labeled commit. ⚠️ Behavior change: unformatted PRs will start failing CI (that's the point). Say if you want it out of scope.

    Decision requested: (a) as above [my recommendation] or (b) strip the commands from AGENTS.md? And yes/no on the CI gate?

    中文摘要:已复现并定位根因——仓库从未用 Prettier 格式化过(任何宽度都无法让 master 通过 check,提交风格本身混用长签名与手工换行)。建议方案 (a):加 .prettierrc(printWidth 120)+ 精确锁定 prettier 3.9.6 + 新增 .prettierignore(排除 dist/lockfile 等生成物),一次性重排 161 文件(纯空白、零语义变更,已验证 format:check/typecheck/1122 项测试/build 全绿);另建议在 CI 增加 format:check 防止再次静默漂移(行为变更:未格式化 PR 将失败 CI)。请拍板 (a)/(b) 及是否加 CI 门禁。

  2. ranxianglei commented on Sep 26, 2026

    @ranxianglei
    OwnerAuthor

    🤖 Powered by ework · qwen3.8-27b

    [bot] 🏷 Correction: this is a duplicate of PR #438 — closing here, relaying one open item there

    Duplicate screening (per repo policy, before implementing) turned up prior work covering this issue's full scope, opened ~9h before this issue was filed:

    PR #438 — chore: prettier baseline — config, CI format gate, tree reformat (Closes #435), branch 2026-09-26_prettier-baseline @ 9654f8b, based directly on current master 476d440:

    • .prettierrc: explicit pin of Prettier defaults (printWidth 80 + all other defaults written out, so a future major's default change can't silently re-drift the tree)
    • .prettierignore: dist/, node_modules/, .tmp/, package-lock.json
    • ci.yml: new standalone format job running npm run format:check on PRs + pushes to master
    • Deliberate one-time whole-tree reformat: 124 files, layout only (+15,940/−9,290)
    • CI all green at that head; independent agent review verdict: mergeable, with a char-level zero-semantics proof in its thread

    Related threads for completeness: #361 (same scope, older base, superseded by #438 — closure candidate) and #418 (fixes the prettier two-pass non-idempotence quirk in src/hide-consumed.ts that #438 documents but leaves in place — recommended small follow-up after #438 lands).

    Why this issue still got filed: during PR #443 implementation (on master, where #438 was still unmerged) the working agent hit the broken npm run format, reverted the churn, and filed this without linking #438. Root cause is identical — missing Prettier config (+ caret range) → mass reformat — so per the one-issue-per-root-cause policy I'm closing #445 as a duplicate rather than starting parallel work. My own staged width-120 variant stays local, unpushed.

    Independent measurements from my analysis (for the record, feeding #438's open choices):

    printWidth failing files changed lines
    80 (#438's pick) 125 ~+15.9K/−9.3K (excl. lockfile)
    120 162 +10.6K/−12.5K

    80 touches fewer files (its stated rationale holds); 120 changes fewer total lines and keeps long single-line signatures as-written. Also confirmed: no prettier config can make pristine master pass — the committed style was never prettier-formatted (it mixes long single-line signatures, manual ~80-col wraps, and hand-packed object lines), so the one-time reformat is unavoidable under option (a) at any width.

    Open item relayed to #438: this issue's cause section independently supports the optional exact pin from #438's PR body — "prettier": "3.9.6" instead of ^3.3.0. The caret range is what let 3.9.6 float in silently; lockfile + npm ci make resolution deterministic today, but the pin costs one line and removes the last drift vector. Comment posted in #438's thread.

    Closing #445 as duplicate of #438 (labeling 重复). If you'd rather keep the (a)-vs-(b) question open as a fresh decision independent of #438, say so and I'll reopen — but note the substantive choice is exactly #438's merge gate.

    中文摘要:查重发现本 issue 与已开放且 CI 全绿、独立评审可合并的 PR #438 同根因(缺 Prettier 配置+caret 版本漂移→批量重排;#438 已实现方案 (a):显式 .prettierrc(printWidth 80)+ .prettierignore + CI format 门禁 + 一次性全树重排 124 文件)。按「一根因一 issue」原则以重复关闭本 issue 并转链 #438/#361/#418;本 issue 独立支持精确锁定 prettier 3.9.6(一行改动,#438 正文已提议),该建议已转达至 #438 线程。如需保留 (a)/(b) 作为独立决策可说明后重开。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions