mirror of
https://github.com/github/awesome-copilot.git
synced 2026-02-20 02:15:12 +00:00
Merge pull request #750 from github/plugin-migration
refactor: migrate plugins to Claude Code spec format
This commit is contained in:
4
.github/workflows/check-line-endings.yml
vendored
4
.github/workflows/check-line-endings.yml
vendored
@@ -2,9 +2,9 @@ name: Check Line Endings
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [staged]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [staged]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
129
.github/workflows/check-plugin-structure.yml
vendored
Normal file
129
.github/workflows/check-plugin-structure.yml
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
name: Check Plugin Structure
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [staged]
|
||||
paths:
|
||||
- "plugins/**"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check-materialized-files:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Check for materialized files in plugin directories
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const { execSync } = require('child_process');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const pluginsDir = 'plugins';
|
||||
const errors = [];
|
||||
|
||||
if (!fs.existsSync(pluginsDir)) {
|
||||
console.log('No plugins directory found');
|
||||
return;
|
||||
}
|
||||
|
||||
const pluginDirs = fs.readdirSync(pluginsDir, { withFileTypes: true })
|
||||
.filter(d => d.isDirectory())
|
||||
.map(d => d.name);
|
||||
|
||||
for (const plugin of pluginDirs) {
|
||||
const pluginPath = path.join(pluginsDir, plugin);
|
||||
|
||||
// Check for materialized agent/command/skill files
|
||||
for (const subdir of ['agents', 'commands', 'skills']) {
|
||||
const subdirPath = path.join(pluginPath, subdir);
|
||||
if (!fs.existsSync(subdirPath)) continue;
|
||||
|
||||
const stat = fs.lstatSync(subdirPath);
|
||||
if (stat.isSymbolicLink()) {
|
||||
errors.push(`${pluginPath}/${subdir} is a symlink — symlinks should not exist in plugin directories`);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const files = fs.readdirSync(subdirPath);
|
||||
if (files.length > 0) {
|
||||
errors.push(
|
||||
`${pluginPath}/${subdir}/ contains ${files.length} file(s): ${files.join(', ')}. ` +
|
||||
`Plugin directories on staged should only contain .github/plugin/plugin.json and README.md. ` +
|
||||
`Agent, command, and skill files are materialized automatically during publish to main.`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for symlinks anywhere in the plugin directory
|
||||
try {
|
||||
const allFiles = execSync(`find "${pluginPath}" -type l`, { encoding: 'utf-8' }).trim();
|
||||
if (allFiles) {
|
||||
errors.push(`${pluginPath} contains symlinks:\n${allFiles}`);
|
||||
}
|
||||
} catch (e) {
|
||||
// find returns non-zero if no matches, ignore
|
||||
}
|
||||
}
|
||||
|
||||
if (errors.length > 0) {
|
||||
const prBranch = context.payload.pull_request.head.ref;
|
||||
const prRepo = context.payload.pull_request.head.repo.full_name;
|
||||
const isFork = context.payload.pull_request.head.repo.fork;
|
||||
|
||||
const body = [
|
||||
'⚠️ **Materialized files or symlinks detected in plugin directories**',
|
||||
'',
|
||||
'Plugin directories on the `staged` branch should only contain:',
|
||||
'- `.github/plugin/plugin.json` (metadata)',
|
||||
'- `README.md`',
|
||||
'',
|
||||
'Agent, command, and skill files are copied in automatically when publishing to `main`.',
|
||||
'',
|
||||
'**Issues found:**',
|
||||
...errors.map(e => `- ${e}`),
|
||||
'',
|
||||
'---',
|
||||
'',
|
||||
'### How to fix',
|
||||
'',
|
||||
'It looks like your branch may be based on `main` (which contains materialized files). Here are two options:',
|
||||
'',
|
||||
'**Option 1: Rebase onto `staged`** (recommended if you have few commits)',
|
||||
'```bash',
|
||||
`git fetch origin staged`,
|
||||
`git rebase --onto origin/staged origin/main ${prBranch}`,
|
||||
`git push --force-with-lease`,
|
||||
'```',
|
||||
'',
|
||||
'**Option 2: Remove the extra files manually**',
|
||||
'```bash',
|
||||
'# Remove materialized files from plugin directories',
|
||||
'find plugins/ -mindepth 2 -maxdepth 2 -type d \\( -name agents -o -name commands -o -name skills \\) -exec rm -rf {} +',
|
||||
'# Remove any symlinks',
|
||||
'find plugins/ -type l -delete',
|
||||
'git add -A && git commit -m "fix: remove materialized plugin files"',
|
||||
'git push',
|
||||
'```',
|
||||
].join('\n');
|
||||
|
||||
await github.rest.pulls.createReview({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
event: 'REQUEST_CHANGES',
|
||||
body
|
||||
});
|
||||
|
||||
core.setFailed('Plugin directories contain materialized files or symlinks that should not be on staged');
|
||||
} else {
|
||||
console.log('✅ All plugin directories are clean');
|
||||
}
|
||||
35
.github/workflows/check-pr-target.yml
vendored
Normal file
35
.github/workflows/check-pr-target.yml
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
name: Check PR Target Branch
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [main]
|
||||
types: [opened]
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
check-target:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Reject PR targeting main
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const body = [
|
||||
'⚠️ **This PR targets `main`, but PRs should target `staged`.**',
|
||||
'',
|
||||
'The `main` branch is auto-published from `staged` and should not receive direct PRs.',
|
||||
'Please close this PR and re-open it against the `staged` branch.',
|
||||
'',
|
||||
'You can change the base branch using the **Edit** button at the top of this PR,',
|
||||
'or run: `gh pr edit ${{ github.event.pull_request.number }} --base staged`'
|
||||
].join('\n');
|
||||
|
||||
await github.rest.pulls.createReview({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: context.issue.number,
|
||||
event: 'REQUEST_CHANGES',
|
||||
body
|
||||
});
|
||||
4
.github/workflows/codespell.yml
vendored
4
.github/workflows/codespell.yml
vendored
@@ -2,9 +2,9 @@ name: Check Spelling
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
branches: [staged]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
branches: [staged]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
53
.github/workflows/publish.yml
vendored
Normal file
53
.github/workflows/publish.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: Publish to main
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [staged]
|
||||
|
||||
concurrency:
|
||||
group: publish-to-main
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout staged branch
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: staged
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Extract Node version from package.json
|
||||
id: node-version
|
||||
run: |
|
||||
NODE_VERSION=$(jq -r '.engines.node // "22"' package.json)
|
||||
echo "version=${NODE_VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ steps.node-version.outputs.version }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Materialize plugin files
|
||||
run: node eng/materialize-plugins.mjs
|
||||
|
||||
- name: Build generated files
|
||||
run: npm run build
|
||||
|
||||
- name: Fix line endings
|
||||
run: bash scripts/fix-line-endings.sh
|
||||
|
||||
- name: Publish to main
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add -A
|
||||
git commit -m "chore: publish from staged [skip ci]" --allow-empty
|
||||
git push origin HEAD:main --force
|
||||
1
.github/workflows/validate-readme.yml
vendored
1
.github/workflows/validate-readme.yml
vendored
@@ -2,6 +2,7 @@ name: Validate README.md
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [staged]
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- "instructions/**"
|
||||
|
||||
Reference in New Issue
Block a user