Skip to content

Commit da0ae54

Browse files
nearestnaborsclaudegithub-actions[bot]
authored
Add redirect checker to block PRs with deleted pages missing redirects (#666)
* Add redirect checker to block PRs with deleted pages missing redirects 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 <[email protected]> * Move agent-frameworks and mcp-clients to get-started, enhance redirect 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 <[email protected]> * 🤖 Regenerate LLMs.txt * 🤖 Regenerate LLMs.txt * Fix bugbot issues in redirect checker script - 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 <[email protected]> * Enhance redirect checker script for better file handling - 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. * fixes * Add script to auto-update internal links from redirects 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 <[email protected]> * Fix internal links to use correct /get-started/ paths 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 <[email protected]> * Add auto-fix mode for redirect checker and integrate into pre-commit 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 <[email protected]> * Fix auto-fix insertion using awk instead of perl 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 <[email protected]> * Add redirect chain detection and auto-collapsing 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 <[email protected]> * Improve error messages for redirect validation - 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 <[email protected]> * Merge main into feature/redirect-checker - 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 <[email protected]> * Merge main to resolve conflicts * Move setup-arcade-with-your-llm-python to correct location - Move page from guides/ to get-started/agent-frameworks/ (correct location) - Update internal links in Next Steps section Co-Authored-By: Claude Opus 4.5 <[email protected]> * Remove duplicate page and add redirect - Remove page from guides/ (merged from main) since it was moved to get-started/ - Add redirect from old guides/ path to new get-started/ path Co-Authored-By: Claude Opus 4.5 <[email protected]> * 🤖 Regenerate LLMs.txt * 🤖 Regenerate LLMs.txt * Update app/en/get-started/agent-frameworks/crewai/use-arcade-tools/page.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update app/en/get-started/agent-frameworks/google-adk/overview/page.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update app/en/get-started/agent-frameworks/mastra/use-arcade-tools/page.mdx Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Rewrite redirect scripts in TypeScript - 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 <[email protected]> * Fix linter errors in TypeScript redirect scripts - 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 <[email protected]> * Fix redirect checker to only check staged changes in pre-commit - 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 <[email protected]> * Fix MCPClientGrid import path in call-tool-client quickstart Component is at get-started/mcp-clients/, not guides/tool-calling/mcp-clients/ Co-Authored-By: Claude Opus 4.5 <[email protected]> * Use replacer functions in regex replace to avoid pattern expansion 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 <[email protected]> --------- Co-authored-by: Rachel Lee Nabors <[email protected]> Co-authored-by: Claude Opus 4.5 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 9c57848 commit da0ae54

File tree

46 files changed

+1220
-82
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1220
-82
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: Check Redirects for Deleted Pages
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- "app/**/*.md"
8+
- "app/**/*.mdx"
9+
- "next.config.ts"
10+
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
15+
jobs:
16+
check-redirects:
17+
name: Verify Deleted Pages Have Redirects
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0 # Full history needed for branch comparison
25+
26+
- name: Fetch base branch
27+
run: git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: "20"
33+
34+
- name: Install dependencies
35+
run: npm install -g pnpm && pnpm install
36+
37+
- name: Check for missing redirects
38+
id: check
39+
run: |
40+
set -o pipefail
41+
pnpm check-redirects ${{ github.base_ref }} 2>&1 | tee redirect-check-output.txt
42+
continue-on-error: true
43+
44+
- name: Comment on PR if redirects are missing
45+
if: steps.check.outcome == 'failure'
46+
uses: actions/github-script@v7
47+
with:
48+
script: |
49+
const fs = require('fs');
50+
const output = fs.readFileSync('redirect-check-output.txt', 'utf8');
51+
52+
// Extract the missing redirects and suggestions from output
53+
const body = `## 🔗 Missing Redirects Detected
54+
55+
This PR deletes markdown files that don't have corresponding redirects in \`next.config.ts\`.
56+
57+
When you delete a page, you must add a redirect to prevent broken links for users who have bookmarked the old URL.
58+
59+
<details>
60+
<summary>📋 View Details</summary>
61+
62+
\`\`\`
63+
${output}
64+
\`\`\`
65+
66+
</details>
67+
68+
### How to fix
69+
70+
1. Open \`next.config.ts\`
71+
2. Find the \`redirects()\` function
72+
3. Add redirect entries for each deleted file (see suggestions above)
73+
4. Push the changes
74+
75+
---
76+
*This check ensures we maintain URL stability for our documentation.*`;
77+
78+
// Check if we already commented
79+
const { data: comments } = await github.rest.issues.listComments({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
issue_number: context.issue.number,
83+
});
84+
85+
const botComment = comments.find(comment =>
86+
comment.user.type === 'Bot' &&
87+
comment.body.includes('Missing Redirects Detected')
88+
);
89+
90+
if (botComment) {
91+
await github.rest.issues.updateComment({
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
comment_id: botComment.id,
95+
body: body
96+
});
97+
} else {
98+
await github.rest.issues.createComment({
99+
owner: context.repo.owner,
100+
repo: context.repo.repo,
101+
issue_number: context.issue.number,
102+
body: body
103+
});
104+
}
105+
106+
- name: Remove outdated comment if check passes
107+
if: steps.check.outcome == 'success'
108+
uses: actions/github-script@v7
109+
with:
110+
script: |
111+
const { data: comments } = await github.rest.issues.listComments({
112+
owner: context.repo.owner,
113+
repo: context.repo.repo,
114+
issue_number: context.issue.number,
115+
});
116+
117+
const botComment = comments.find(comment =>
118+
comment.user.type === 'Bot' &&
119+
comment.body.includes('Missing Redirects Detected')
120+
);
121+
122+
if (botComment) {
123+
await github.rest.issues.deleteComment({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
comment_id: botComment.id,
127+
});
128+
}
129+
130+
- name: Fail if redirects are missing
131+
if: steps.check.outcome == 'failure'
132+
run: |
133+
echo "❌ Missing redirects for deleted pages. See PR comment for details."
134+
exit 1

.husky/pre-commit

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,51 @@ if [ -n "$STAGED_DOCS" ]; then
2929
fi
3030
fi
3131

32+
# --- Check Redirects (when markdown pages are deleted or renamed) ---
33+
# Detect deleted pages (D status) and renamed pages (R status - old path needs redirect)
34+
DELETED_PAGES=$(git diff --cached --name-status | grep -E "^D.*page\.(md|mdx)$" | cut -f2 || true)
35+
RENAMED_PAGES=$(git diff --cached --name-status | grep -E "^R.*page\.(md|mdx)$" | cut -f2 || true)
36+
37+
if [ -n "$DELETED_PAGES" ] || [ -n "$RENAMED_PAGES" ]; then
38+
echo "🔗 Detected deleted/renamed page(s), checking for redirects..."
39+
40+
# Run the TypeScript redirect checker with auto-fix (only checks staged changes)
41+
# This will add redirect entries to next.config.ts if missing
42+
if ! pnpm check-redirects --auto-fix --staged-only 2>&1; then
43+
# Stage next.config.ts if it was modified
44+
if git diff --name-only next.config.ts 2>/dev/null | grep -q "next.config.ts"; then
45+
git add next.config.ts
46+
echo ""
47+
echo "📝 Redirect entries added to next.config.ts and staged."
48+
fi
49+
echo ""
50+
# Check if there are placeholders vs other errors
51+
if grep -q "REPLACE_WITH_NEW_PATH" next.config.ts 2>/dev/null; then
52+
echo "❌ Commit blocked: Please update the placeholder destinations in next.config.ts"
53+
echo " Search for 'REPLACE_WITH_NEW_PATH' and provide actual redirect paths."
54+
else
55+
echo "❌ Commit blocked: Please fix the redirect issues shown above."
56+
fi
57+
exit 1
58+
fi
59+
fi
60+
61+
# --- Update Internal Links (when redirects are added) ---
62+
# If next.config.ts is staged, update any internal links pointing to redirected paths
63+
if git diff --cached --name-only | grep -q "next.config.ts"; then
64+
echo "🔗 Updating internal links for new redirects..."
65+
66+
# Run the TypeScript update script
67+
if pnpm update-links 2>/dev/null; then
68+
# Stage any files that were modified
69+
UPDATED_FILES=$(git diff --name-only -- 'app/**/*.mdx' 'app/**/*.tsx' 'app/**/*.md' 2>/dev/null || true)
70+
if [ -n "$UPDATED_FILES" ]; then
71+
echo "$UPDATED_FILES" | xargs git add
72+
echo "✅ Internal links updated and staged"
73+
fi
74+
fi
75+
fi
76+
3277
# --- Lint Staged (formatting) ---
3378
pnpm dlx lint-staged
3479

app/_components/tool-footer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const ToolFooter: React.FC<ToolFooterProps> = ({ pipPackageName }) => (
1515
<div className="mt-16 grid gap-8 md:grid-cols-2">
1616
<QuickStartCard
1717
description="Arcade tools are hosted by our cloud platform and ready to be used in your agents. Learn how."
18-
href="/home/quickstart"
18+
href="/get-started/quickstarts/call-tool-agent"
1919
icon={Cloud}
2020
title="Use tools hosted on Arcade Cloud"
2121
/>
@@ -24,7 +24,7 @@ const ToolFooter: React.FC<ToolFooterProps> = ({ pipPackageName }) => (
2424
description={
2525
"Arcade tools can be self-hosted on your own infrastructure. Learn more about self-hosting."
2626
}
27-
href="/home/hosting-overview"
27+
href="/guides/deployment-hosting"
2828
icon={Puzzle}
2929
title="Self Host Arcade tools"
3030
/>
File renamed without changes.
File renamed without changes.

app/en/guides/agent-frameworks/crewai/custom-auth-flow/page.mdx renamed to app/en/get-started/agent-frameworks/crewai/custom-auth-flow/page.mdx

app/en/guides/agent-frameworks/crewai/use-arcade-tools/page.mdx renamed to app/en/get-started/agent-frameworks/crewai/use-arcade-tools/page.mdx

Lines changed: 2 additions & 2 deletions

app/en/guides/agent-frameworks/google-adk/_meta.tsx renamed to app/en/get-started/agent-frameworks/google-adk/_meta.tsx

File renamed without changes.

app/en/guides/agent-frameworks/google-adk/overview/page.mdx renamed to app/en/get-started/agent-frameworks/google-adk/overview/page.mdx

Lines changed: 2 additions & 2 deletions

app/en/guides/agent-frameworks/google-adk/use-arcade-tools/page.mdx renamed to app/en/get-started/agent-frameworks/google-adk/use-arcade-tools/page.mdx

0 commit comments

Comments
 (0)