Skip to content

fix(init): restore CONTEXTCRAWLER.md filename + legacy migration + regression-pinning test - #21

Merged
thehoff merged 2 commits into
developfrom
fix/codex-md-filename-regression
May 18, 2026
Merged

thehoff merged 2 commits into
developfrom
fix/codex-md-filename-regression

Conversation

@thehoff

@thehoff thehoff commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Restores the downstream rebrand of the slim instructions file to CONTEXTCRAWLER.md (commit bcddd06 silently flipped it back to RTK.md during the upstream-rebase merge) and adds the never-do-it-again insurance.

Functional fixes

  • RTK_MD / RTK_MD_REF constants restored to "CONTEXTCRAWLER.md" / "@CONTEXTCRAWLER.md"
  • patch_claude_md's write paths now interpolate RTK_MD_REF (was hardcoded @RTK.md literal — meaning the contains-check would miss its own writes and re-append every run)
  • patch_claude_md also migrates pre-existing legacy @RTK.md lines to the canonical form before the contains-check (codex P2)
  • uninstall_codex_at cleans up both canonical AND LEGACY_RTK_MD_FILES entries — file + relative + absolute @-refs (codex P2)
  • show_codex_config surfaces legacy artifacts with a [!!] marker and includes legacy refs in the has_rtk_reference probe (codex P2)

Auto-migration for upgrading users

cleanup_legacy_codex_files() runs as part of run_codex_mode. Any user with a stale ~/.codex/RTK.md + @RTK.md line gets:

  • Orphan file removed
  • Stale @-reference stripped from AGENTS.md
  • Surrounding blank lines collapsed so the file stays tidy

Idempotent — safe to re-run when nothing legacy is present. Future renames just add filenames to LEGACY_RTK_MD_FILES.

Reviewed by Codex

  • P2: CLAUDE.md duplicate-ref → fixed (legacy @-ref migration before contains-check)
  • P2: uninstall/status didn't recognise legacy → fixed (both extended to iterate LEGACY_RTK_MD_FILES)

Regression insurance

#[test]
fn test_rtk_md_constant_pinned_to_contextcrawler_filename() {
    // REGRESSION GUARD (issue #19). ...
    assert_eq!(RTK_MD, "CONTEXTCRAWLER.md", "filename regression: see issue #19");
    assert_eq!(RTK_MD_REF, "@CONTEXTCRAWLER.md", "filename regression: see issue #19");
}

The next person who tries to revert this gets a failing test pointing at the issue. The "never do it again" requirement is enforced by the test suite, not just by reviewer attention.

Cosmetic follow-up

#20 tracks the remaining ~30 hardcoded RTK.md/@RTK.md literals in print strings and doc comments (non-functional, just misleading labels). Kept out of this PR so the regression fix stays reviewable.

Test plan

  • cargo test --bin contextcrawler — 2026 passed, 0 failed (+8 new across both commits)
  • Pinning test catches a hypothetical revert
  • Legacy file + @-ref auto-cleanup verified
  • CLAUDE.md legacy ref migration verified + idempotent
  • uninstall + show recognise legacy installs

Closes #19

thehoff and others added 2 commits May 18, 2026 15:48
…ession-pinning test (#19)

Commit bcddd06 ("fix(hooks): rename hardcoded \`rtk hook\` commands + RTK.md
deployment") silently flipped the downstream rebrand constants from
"CONTEXTCRAWLER.md" / "@CONTEXTCRAWLER.md" back to upstream's "RTK.md" /
"@RTK.md" during the upstream-rebase merge. The rebrand sweep
(c0349b2, 540413e) missed it. The result:

- `contextcrawler init -g --codex` wrote `~/.codex/RTK.md` instead of
  `~/.codex/CONTEXTCRAWLER.md`
- AGENTS.md ended up with BOTH a stale `@CONTEXTCRAWLER.md` (from the
  previous install) and a fresh `@RTK.md` (from the new init), with the
  CONTEXTCRAWLER.md file left orphaned on disk
- `patch_claude_md` wrote a hardcoded `@RTK.md\n` literal while the
  presence check used `RTK_MD_REF` (= "@CONTEXTCRAWLER.md") — meaning
  every run would re-append the same line, never detecting it was
  already present

Fix:

1. **Constants restored** to "CONTEXTCRAWLER.md" / "@CONTEXTCRAWLER.md".

2. **Pinning regression test** (`test_rtk_md_constant_pinned_to_contextcrawler_filename`)
   makes any future revert blow up the test suite with a comment
   pointing back to issue #19. The "never do it again" insurance.

3. **`patch_claude_md` write paths** now use `RTK_MD_REF` interpolation
   instead of hardcoded `@RTK.md` literal — fixes the silent
   never-idempotent bug noted above.

4. **`cleanup_legacy_codex_files()`** runs as part of `run_codex_mode`
   so users upgrading from a regressed install get their orphan
   `~/.codex/RTK.md` removed and the stale `@RTK.md` reference
   stripped from AGENTS.md automatically. Idempotent — safe to run when
   nothing legacy is present. Future renames just add filenames to
   `LEGACY_RTK_MD_FILES` and old users get clean upgrades.

5. **`strip_at_reference_line()` helper** removes a matching `@<name>`
   line and collapses the surrounding blank lines so AGENTS.md doesn't
   accumulate extra vertical space across repeated cleanups.

6. **6 existing tests** that hardcoded "RTK.md"/"@RTK.md" updated to
   use the `RTK_MD` / `RTK_MD_REF` constants — they now track the
   constant value automatically.

Cosmetic follow-up (separate issue): ~30 print/eprintln/doc-comment
occurrences still hardcode "RTK.md"/"@RTK.md" labels. Non-functional
but misleading; tracked separately so this PR stays reviewable.

Tests: 5 new (pinning, 3 cleanup scenarios, blank-line collapse).
All 2024 binary tests pass.

Closes #19
Two P2 gaps raised by `codex review` on the initial fix:

1. **CLAUDE.md migration was incomplete.** On an upgraded install,
   `CLAUDE.md` may still contain `@RTK.md` from the regressed era.
   `content.contains(RTK_MD_REF)` only matched the new
   `@CONTEXTCRAWLER.md`, so the contains-check fell through and the
   appender added a second line, leaving both references in place.

   Fix: in `patch_claude_md`, scan for any whole-line `@<legacy>` from
   `LEGACY_RTK_MD_FILES` and rewrite each to `RTK_MD_REF` before the
   contains-check runs. Whole-line match avoids corrupting prose that
   incidentally mentions the legacy name.

2. **`uninstall_codex_at` and `show_codex_config` ignored legacy
   artifacts.** Both only looked for the new `RTK_MD` value, so a
   regressed install that had `~/.codex/RTK.md` / `@RTK.md` would be
   reported as unconfigured by `init --show` and would be left behind
   by `uninstall --codex`.

   Fix: extend `uninstall_codex_at` to iterate over the canonical name
   *and* every entry in `LEGACY_RTK_MD_FILES`, both as on-disk files
   and as @-references (relative + absolute forms). Extend
   `show_codex_config` to surface legacy artifacts with a `[!!]`
   marker hinting at the cleanup-on-next-init behaviour, and to
   include all legacy @-ref forms in the has_rtk_reference probe so
   the global/local AGENTS.md checks recognise a regressed install
   as configured-but-stale rather than unconfigured.

Two new tests (`test_patch_claude_md_migrates_legacy_at_ref_in_place`,
`test_uninstall_codex_at_removes_legacy_rtk_md_file_and_ref`) pin both
codepaths so the next person who touches this can't quietly regress
the upgrade path. All 2026 binary tests pass.

Co-Authored-By: Codex review <noreply@openai.com>
@thehoff
thehoff merged commit d352c13 into develop May 18, 2026
3 checks passed
@thehoff
thehoff deleted the fix/codex-md-filename-regression branch May 18, 2026 05:53
noogalabs pushed a commit to noogalabs/contextcrawler that referenced this pull request Jun 4, 2026
… branding-lint extension

**Version bump 0.39.0 → 0.1.7.** The upstream rebase pulled in rtk's
`0.39.0` version; restoring the downstream `0.1.x` numbering line per
the maintainer's call. `.release-please-manifest.json` updated to
match. Last downstream tag was `v0.1.6` (2026-05-15); this is the
next in the sequence.

**release-please-config.json `package-name: "rtk"` → "contextcrawler".**
Caught by manual audit during release prep. Same regression-family as
thehoff#19 / thehoff#20 / thehoff#22: a rebrand gap the prior branding-lint (src/-scoped)
didn't catch because release-please-config.json lives at repo root.
Without this fix, release-please would have produced `rtk-vX.Y.Z`
tags and release-PR titles.

**Cargo.toml `extended-description` rebrand.** Line 77 still read
"rtk filters and compresses..." — same upstream-leak family. Fixed.

**Extended `tests/branding_lint.rs`** with a third test —
`branding_lint_config_files_pin_canonical_package_name` — that:
- Parses Cargo.toml and asserts `[package].name == "contextcrawler"`
- Parses release-please-config.json and asserts
  `packages["."]["package-name"] == "contextcrawler"`

This closes the gap that let release-please-config.json silently drift
to `"rtk"` post-rebase. Any future rebase that re-introduces an
upstream package-name fails `cargo test --test branding_lint` with an
explicit error pointing at issues thehoff#19/thehoff#20/thehoff#22 history.

**CHANGELOG.md** entry for v0.1.7 added, summarizing all PRs merged
today (thehoff#10 thehoff#15 thehoff#16 thehoff#21 thehoff#24 thehoff#25 thehoff#30) plus the deferred follow-ups
(thehoff#26 thehoff#27 thehoff#28 thehoff#29).

Tests: 2027 bin + 3 branding-lint (1 new) + 1 harness = all pass.
Verified: `contextcrawler --version` now prints `contextcrawler 0.1.7`.

Refs thehoff#19 thehoff#20 thehoff#22 thehoff#29
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.

bug: regression — init --codex writes RTK.md instead of CONTEXTCRAWLER.md (incomplete rebrand)

1 participant