Thanks to visit codestin.com
Credit goes to github.com

Skip to content

new hook fix-broken-links#2027

Draft
jhauga wants to merge 2 commits into
github:stagedfrom
jhauga:hook-fix-broken-links
Draft

new hook fix-broken-links#2027
jhauga wants to merge 2 commits into
github:stagedfrom
jhauga:hook-fix-broken-links

Conversation

@jhauga

@jhauga jhauga commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, workflow, or canvas extension file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, workflow, or canvas extension with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.
  • I am targeting the staged branch for this pull request.

Description

For full test results ctrl + click support-repo.

  • Agent: Copilot CLI
  • Model: Claude Sonnet 4.5
  • Number of Prompts: 1
  • Post Edits: None

Prompt

Context

Two links were broken:

And one could use SEO and/or better link text:

Write a brief blog article referencing about ai research techniques, and organizing research in such a way that it can easliy be kept up-to-date with ai changes; and incorporating research findings in order to build ai skills. Update @index.html as HTML with the final data.

**References:**

- [ai-research](https://www.microsoft.com/en-us/research/group/ai-for-good-research-lab/)
- [azure ai](https://learn.microsoft.com/en-us/azure/well-architected/ai/get-started)
- [ai skills](https://www.microsoft.com/en-us/corporate-responsibility/ai-skils-resources)
  - [design-methodology](https://learn.microsoft.com/en-us/azure/well-architected/ai/desgn-methodology)
  - [principles](https://learn.microsoft.com/en-us/azure/well-architected/ai/design-principles)

Results

Links fixed. I'm not entirely sure it was the hook, but ran copilot, pasted prompt, and results were as expected. To confirm ran:

pwsh .github/hooks/fix-broken-links/link-fix.ps1 index.html

  Checking 5 link(s) in index.html ...

  No broken links found.

Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
    • Hook
  • New canvas extension.
  • Update to existing instruction, prompt, agent, plugin, skill, workflow, or canvas extension.
  • Other (please specify):

By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.

@jhauga jhauga requested a review from aaronpowell as a code owner June 17, 2026 04:34
Copilot AI review requested due to automatic review settings June 17, 2026 04:34
@github-actions github-actions Bot added hooks PR touches hooks new-submission PR adds at least one new contribution labels Jun 17, 2026
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

🔒 PR Risk Scan Results

Scanned 6 changed file(s).

Severity Count
🔴 High 0
🟠 Medium 1
ℹ️ Info 0
Severity Rule File Line Match
🟠 unpinned-version-indicator .codespellrc 21 # categor - TypeScript template literal in website/src/scripts/pages/skills.ts:70 (categor${...length > 1 ? "ies" : "y"})

This is an automated soft-gate report. Findings indicate review targets and do not block merge by themselves.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a “Fix Broken Links” Copilot hook that scans recently changed web-related files for http(s) links, reports non-200 URLs, offers interactive fixes (replace/remove/skip), and flags generic SEO anchor text.

Changes:

  • Introduces Bash and PowerShell implementations for scanning/checking links and offering interactive remediation.
  • Adds hook configuration (hooks.json) to run after tool usage.
  • Documents the hook and lists it in the repository hooks index.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
hooks/fix-broken-links/link-fix.sh Bash hook to discover changed files, extract URLs, check status, suggest alternatives, and interactively apply fixes.
hooks/fix-broken-links/link-fix.ps1 PowerShell 7+ port of the hook with equivalent behavior using .NET web requests/regex.
hooks/fix-broken-links/hooks.json Registers the hook command(s) for Copilot hook execution.
hooks/fix-broken-links/README.md Installation/usage documentation for the new hook.
docs/README.hooks.md Adds the new hook entry to the hooks catalog table.

Comment on lines +209 to +214
# Replace a literal URL everywhere in a file (pure bash, no regex).
replace_url() {
local file="$1" old="$2" new="$3" content
read_file content "$file"
printf '%s' "${content//"$old"/"$new"}" > "$file"
}
Comment on lines +228 to +230
while [[ $content =~ $re ]]; do
content="${content//"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}"
done
# --data-urlencode keeps the URL's own ?query&params from corrupting our request.
wayback_lookup() {
local url="$1"
curl -s -G --max-time 8 "http://archive.org/wayback/available" \
param([string]$Url)
try {
$enc = [uri]::EscapeDataString($Url)
$r = Invoke-RestMethod -Uri "http://archive.org/wayback/available?url=$enc" `
Comment on lines +9 to +11
Scans recently-changed web files for broken hyperlinks after each GitHub Copilot
tool use. For each broken URL the hook tries common spelling variations, queries
DuckDuckGo for a replacement, and presents an interactive fix menu. Generic

## Configuration

The hook is configured in `hooks.json` to run on the `userPromptSubmitted` event:
{
"version": 1,
"hooks": {
"userPromptSubmitted": [
@jhauga jhauga marked this pull request as draft June 17, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hooks PR touches hooks new-submission PR adds at least one new contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants