Skip to content

Commit 32c56c2

Browse files
committed
docs(agents): document changelog sync rule
1 parent 793efeb commit 32c56c2

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ subagents, skills, web/visualization UIs, and multi-provider LLM authentication.
3737
commit status is `success`, not `pending`/`failure` or absent — and read the review summary and
3838
any "Actionable comments posted: N" findings. Do not merge while CodeRabbit is still reviewing or
3939
on an unreviewed commit; surface unresolved actionable findings instead of merging past them.
40+
- **Do not manually edit auto-synced changelog files.** `docs/en/release-notes/changelog.md` is
41+
generated from the root `CHANGELOG.md`; edit `CHANGELOG.md` and run `npm run sync` from `docs/`
42+
instead of hand-editing the generated docs changelog.
4043
- **When working on a PR or GitHub Actions failure, investigate and identify the root cause first.**
4144
Provide the best-practice, most robust design solution; never provide fast fixes or workarounds.
4245
This is a hard constraint.

scripts/release.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@
2929
REVIEW_PYPROJECT = REPO_ROOT / "packages" / "pythinker-review" / "pyproject.toml"
3030
SDK_PYPROJECT = REPO_ROOT / "sdks" / "pythinker-sdk" / "pyproject.toml"
3131

32-
# Single source for the three hand-authored changelog files. validate() asserts
33-
# the `## Unreleased` anchor in ALL of them before any write, and rewrite()
34-
# promotes the SAME list — defined once so the two can never drift (atomic
35-
# Phase-2 guarantee: no partial-write if a docs file is missing its anchor).
32+
# Hand-authored changelog files. The docs changelog is intentionally excluded:
33+
# docs/en/release-notes/changelog.md is auto-synced from the root CHANGELOG.md
34+
# by docs/scripts/sync-changelog.mjs and must not be edited directly.
3635
CHANGELOG_FILES = (
3736
REPO_ROOT / "CHANGELOG.md",
38-
REPO_ROOT / "docs" / "en" / "release-notes" / "changelog.md",
3937
REPO_ROOT / "docs" / "en" / "release-notes" / "breaking-changes.md",
4038
)
39+
DOCS_CHANGELOG_SCRIPT = REPO_ROOT / "docs" / "scripts" / "sync-changelog.mjs"
4140

4241
SEMVER_RE = re.compile(r"^(\d+)\.(\d+)\.(\d+)$")
4342
_DEP_PIN_RE = re.compile(
@@ -157,6 +156,10 @@ def rewrite_version_in_files(paths: list[Path], *, old: str, new: str) -> None:
157156
path.write_text(rewrite_version_strings(original, old=old, new=new), encoding="utf-8")
158157

159158

159+
def sync_docs_changelog() -> None:
160+
subprocess.run(["node", str(DOCS_CHANGELOG_SCRIPT)], cwd=REPO_ROOT / "docs", check=True)
161+
162+
160163
def _run(cmd: list[str], *, dry_run: bool, check: bool = True) -> subprocess.CompletedProcess[str]:
161164
if dry_run:
162165
print(f"[dry-run] {' '.join(cmd)}")
@@ -185,8 +188,9 @@ def validate(target: str) -> None:
185188
if head != remote:
186189
raise ReleaseError("current HEAD is not origin/main; switch to main before release prep")
187190
assert_monotonic(current=read_project_version(ROOT_PYPROJECT), target=target)
188-
# Assert the `## Unreleased` anchor in ALL changelog files BEFORE any write
189-
# (same list rewrite() promotes) so Phase 2 cannot partially rewrite the tree.
191+
# Assert the `## Unreleased` anchor in ALL hand-authored changelog files BEFORE
192+
# any write (same list rewrite() promotes) so Phase 2 cannot partially rewrite
193+
# the tree.
190194
for changelog in CHANGELOG_FILES:
191195
if _UNRELEASED_RE.search(changelog.read_text(encoding="utf-8")) is None:
192196
raise ReleaseError(f"{changelog} has no `## Unreleased` section")
@@ -214,6 +218,7 @@ def rewrite(target: str, *, bump_core: str | None, bump_host: str | None) -> Non
214218
today = date.today().isoformat()
215219
for changelog in CHANGELOG_FILES:
216220
promote_changelog(changelog, target, release_date=today)
221+
sync_docs_changelog()
217222
rewrite_version_in_files(
218223
[
219224
REPO_ROOT / "README.md",

0 commit comments

Comments
 (0)