-
Notifications
You must be signed in to change notification settings - Fork 7
Add redirect checker to block PRs with deleted pages missing redirects #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Adds a GitHub Action and local script that compares the branch to main, detects deleted markdown files, and ensures each has a corresponding redirect entry in next.config.ts. Prevents broken bookmarks and SEO issues. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…t checker Content moves: - Move guides/agent-frameworks/* to get-started/agent-frameworks/* - Move guides/tool-calling/mcp-clients/* to get-started/mcp-clients/* - Add wildcard redirects for moved content - Fix stale _meta.tsx references Redirect checker enhancements: - Interactive mode prompts for redirect destinations - Validates existing redirects for placeholder text (REPLACE_WITH, TODO, FIXME) - Catches circular redirects (source == destination) - Verifies destination pages exist - Detects both deletes and renames Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fail with error when base branch is unavailable instead of silent success - Fix root page URL path handling (app/en/page.mdx -> /:locale) - Only check page.md/mdx files (skip non-routable markdown like README.md) - Use cut with tab delimiter instead of awk to handle filenames with spaces Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Adjusted the script to use cut for field extraction, improving handling of deleted and renamed page files. - Updated informational messages to redirect stderr, ensuring clarity in user prompts. This improves the user experience when managing redirects in the Arcade platform.
Companion to check-redirects.sh - this script reads redirect mappings from next.config.ts and updates any internal links in MDX/TSX files that point to old (redirected) paths. Usage: ./scripts/update-internal-links.sh [--dry-run] Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update internal links and redirect destinations that were incorrectly pointing to /guides/ paths when the actual pages are under /get-started/: - /guides/agent-frameworks/* -> /get-started/agent-frameworks/* - /guides/tool-calling/mcp-clients/* -> /get-started/mcp-clients/* - /home/quickstart -> /get-started/quickstarts/call-tool-agent - /home/hosting-overview -> /guides/deployment-hosting Files updated across MDX docs, TSX components, and next.config.ts redirects. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Changes to check-redirects.sh: - Add --auto-fix flag that automatically inserts redirect entries into next.config.ts when pages are deleted - Uses placeholder destinations that must be replaced before merge Changes to pre-commit hook: - When page files are deleted, runs check-redirects.sh --auto-fix - Auto-adds redirect entries and stages next.config.ts - Blocks commit until placeholder destinations are replaced - When next.config.ts is staged, runs update-internal-links.sh to fix internal links pointing to redirected paths Workflow: 1. Delete page -> commit blocked, redirect entry auto-added 2. Update placeholder destination in next.config.ts 3. Commit again -> internal links auto-fixed, commit succeeds Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The perl -pe approach failed because redirect entry strings contain special characters (colons, slashes, quotes) that broke perl syntax. Switch to awk with a temp file approach which handles arbitrary content safely. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When a redirect points to a destination that itself has a redirect (a chain like A → B → C), the script now: 1. Detects the chain during validation 2. In --auto-fix mode, automatically collapses it (A → C) 3. Updates next.config.ts with the collapsed redirect This handles the case where an old redirect (e.g., from a previous migration) points to a page that is now being deleted/moved. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Pre-commit hook now shows appropriate message based on error type: - Placeholder message only when REPLACE_WITH_NEW_PATH exists - Generic "fix issues shown above" for other errors - Invalid redirect errors now include step-by-step fix instructions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Accept main's llms.txt (auto-generated) - Include workflow fix (set -o pipefail) - Include new Copilot Studio MCP client docs - Include LLM setup guide Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style Review
Found 3 style suggestion(s).
Powered by Vale + Claude
app/en/get-started/agent-frameworks/crewai/use-arcade-tools/page.mdx
Outdated
Show resolved
Hide resolved
app/en/get-started/agent-frameworks/google-adk/overview/page.mdx
Outdated
Show resolved
Hide resolved
app/en/get-started/agent-frameworks/mastra/use-arcade-tools/page.mdx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Style Review
Found 3 style suggestion(s).
Powered by Vale + Claude
app/en/get-started/agent-frameworks/crewai/use-arcade-tools/page.mdx
Outdated
Show resolved
Hide resolved
app/en/get-started/agent-frameworks/google-adk/overview/page.mdx
Outdated
Show resolved
Hide resolved
app/en/get-started/agent-frameworks/mastra/use-arcade-tools/page.mdx
Outdated
Show resolved
Hide resolved
…ge.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…ge.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
evantahler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question: Why are your new scripts bash? pnpm run check-redirects seems ok since we are already in TS, and that would allow the use of the node file utilities + glob which would make those scripts much smaller and easier to read
Great question! I vibecoded this so had 0 opinion! IS this a blocker or a follow up, @evantahler ? |
|
Yes, I think this would be a blocker because it's adding something that's very hard for the team that normally works on docs to maintain. We will want to adjust and understand these scripts in the future. You can split this PR into 2 - merge in the found redirecet problems now, and work on the script out-of-band? |
|
@evantahler Nah, I'll do it now. We need to move both forward fast. I've tasked @torresmateo to check that it works, then I'll ping you for another look |
- Rewrite check-redirects.sh as check-redirects.ts - Rewrite update-internal-links.sh as update-internal-links.ts - Add folder rename detection (R status) to pre-commit hook - Update GitHub Actions workflow to use TypeScript scripts - Add pnpm scripts: check-redirects, update-links Benefits of TypeScript: - Consistent with rest of codebase - Uses fast-glob instead of bash find - Easier to read and maintain - Better error handling - Properly parses next.config.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Refactor regex matching to avoid assignment in expressions - Extract magic numbers to named constants - Rename variables to avoid shadowing - Replace increment operators with += 1 - Collapse nested if statements - Fix formatting issues Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add --staged-only flag to check-redirects script - When --staged-only is set, use git diff --cached instead of git diff HEAD - Update pre-commit hook to pass --staged-only - Fix chain collapse to follow entire chain to final destination (previously only resolved one hop) Fixes: - Script no longer flags file deletions in working directory that haven't been staged for commit - Redirect chains like A→B→C→D are now fully collapsed to A→D in a single run Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Component is at get-started/mcp-clients/, not guides/tool-calling/mcp-clients/ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
String replacement patterns like $1, $2, $& in paths would be incorrectly expanded by the regex engine. Using replacer functions ensures the new path is inserted literally. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
| # Stage any files that were modified | ||
| UPDATED_FILES=$(git diff --name-only -- 'app/**/*.mdx' 'app/**/*.tsx' 'app/**/*.md' 2>/dev/null || true) | ||
| if [ -n "$UPDATED_FILES" ]; then | ||
| echo "$UPDATED_FILES" | xargs git add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-commit hook stages unintended working directory changes
Medium Severity
After running pnpm update-links, the hook uses git diff --name-only to find modified files and stages them. However, this command returns ALL files differing between the working directory and the index, not just files modified by update-links. If a user has other mdx/tsx/md files modified in their working directory but intentionally not staged (perhaps saving changes for a future commit), those files get auto-staged by xargs git add, causing unintended changes to be included in the commit.
evantahler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's try it!
I got sick of broken links being reported, so I made this to ensure all deleted/moved markdown files are accounted for with redirects. The workflow does a lot of the heavy lifting of chain collapsing and updating internal links.
Summary
Adds automated redirect management when pages are deleted or moved. This ensures URL stability for bookmarks and SEO.
What's New
1. Pre-commit Hook Integration
When you delete a page file and try to commit:
.mdx/.mdpage filesnext.config.tswith placeholder destinations2. Redirect Chain Collapsing
When an old redirect points to a page you're deleting:
old-path → deleted-path → new-path)3. Internal Link Auto-Update
When
next.config.tsis staged with new redirects:Workflow
Deleting/Moving a Page
First commit attempt:
Update the placeholder in
next.config.ts:Second commit attempt:
Scripts Added/Modified
scripts/update-internal-links.shscripts/check-redirects.sh--auto-fixflag for auto-adding redirects.husky/pre-commitTest Plan
🤖 Generated with Claude Code
Note
Introduces automated redirect enforcement and link maintenance for documentation.
check-redirects.ymlto detect deleted/renamed markdown pages lacking redirects, comment on PRs with details, and fail the check.husky/pre-committo auto-add missing redirects (with placeholders), block commits until resolved, and auto-update/stage internal links whennext.config.tschangesscripts/check-redirects.ts(validates/auto-fixes redirects, collapses redirect chains) andscripts/update-internal-links.ts(rewrites links to new destinations); wired viapackage.json(check-redirects,update-links)next.config.tswith comprehensive redirects (notably movingguides/agent-frameworksandguides/tool-calling/mcp-clientstoget-started/...) to preserve URLsToolFooter, multiplepage.mdxfiles) to newget-startedstructure; minor copy edits and meta cleanuppublic/llms.txtWritten by Cursor Bugbot for commit f552b84. This will update automatically on new commits. Configure here.