feat: skills as branches, channels as forks

Replace the custom skills engine with standard git operations.
Feature skills are now git branches (on upstream or channel forks)
applied via `git merge`. Channels are separate fork repos.

- Remove skills-engine/ (6,300+ lines), apply/uninstall/rebase scripts
- Remove old skill format (add/, modify/, manifest.yaml) from all skills
- Remove old CI (skill-drift.yml, skill-pr.yml)
- Add merge-forward CI for upstream skill branches
- Add fork notification (repository_dispatch to channel forks)
- Add marketplace config (.claude/settings.json)
- Add /update-skills operational skill
- Update /setup and /customize for marketplace plugin install
- Add docs/skills-as-branches.md architecture doc

Channel forks created: nanoclaw-whatsapp (with 5 skill branches),
nanoclaw-telegram, nanoclaw-discord, nanoclaw-slack, nanoclaw-gmail.

Upstream retains: skill/ollama-tool, skill/apple-container, skill/compact.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
gavrielc
2026-03-10 00:18:25 +02:00
parent e7852a45a5
commit 5118239cea
182 changed files with 1065 additions and 36205 deletions

View File

@@ -0,0 +1,158 @@
name: Merge-forward skill branches
on:
push:
branches: [main]
permissions:
contents: write
issues: write
jobs:
merge-forward:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Merge main into each skill branch
id: merge
run: |
FAILED=""
SUCCEEDED=""
# List all remote skill branches
SKILL_BRANCHES=$(git branch -r --list 'origin/skill/*' | sed 's|origin/||' | xargs)
if [ -z "$SKILL_BRANCHES" ]; then
echo "No skill branches found."
exit 0
fi
for BRANCH in $SKILL_BRANCHES; do
SKILL_NAME=$(echo "$BRANCH" | sed 's|skill/||')
echo ""
echo "=== Processing $BRANCH ==="
# Checkout the skill branch
git checkout -B "$BRANCH" "origin/$BRANCH"
# Attempt merge
if ! git merge main --no-edit; then
echo "::warning::Merge conflict in $BRANCH"
git merge --abort
FAILED="$FAILED $SKILL_NAME"
continue
fi
# Check if there's anything new to push
if git diff --quiet "origin/$BRANCH"; then
echo "$BRANCH is already up to date with main."
SUCCEEDED="$SUCCEEDED $SKILL_NAME"
continue
fi
# Install deps and validate
npm ci
if ! npm run build; then
echo "::warning::Build failed for $BRANCH"
git reset --hard "origin/$BRANCH"
FAILED="$FAILED $SKILL_NAME"
continue
fi
if ! npm test 2>/dev/null; then
echo "::warning::Tests failed for $BRANCH"
git reset --hard "origin/$BRANCH"
FAILED="$FAILED $SKILL_NAME"
continue
fi
# Push the updated branch
git push origin "$BRANCH"
SUCCEEDED="$SUCCEEDED $SKILL_NAME"
echo "$BRANCH merged and pushed successfully."
done
echo ""
echo "=== Results ==="
echo "Succeeded: $SUCCEEDED"
echo "Failed: $FAILED"
# Export for issue creation
echo "failed=$FAILED" >> "$GITHUB_OUTPUT"
echo "succeeded=$SUCCEEDED" >> "$GITHUB_OUTPUT"
- name: Open issue for failed merges
if: steps.merge.outputs.failed != ''
uses: actions/github-script@v7
with:
script: |
const failed = '${{ steps.merge.outputs.failed }}'.trim().split(/\s+/);
const sha = context.sha.substring(0, 7);
const body = [
`The merge-forward workflow failed to merge \`main\` (${sha}) into the following skill branches:`,
'',
...failed.map(s => `- \`skill/${s}\`: merge conflict, build failure, or test failure`),
'',
'Please resolve manually:',
'```bash',
...failed.map(s => [
`git checkout skill/${s}`,
`git merge main`,
`# resolve conflicts, then: git push`,
''
]).flat(),
'```',
'',
`Triggered by push to main: ${context.sha}`
].join('\n');
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Merge-forward failed for ${failed.length} skill branch(es) after ${sha}`,
body,
labels: ['skill-maintenance']
});
- name: Notify channel forks
if: always()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.FORK_DISPATCH_TOKEN || secrets.GITHUB_TOKEN }}
script: |
const forks = [
'nanoclaw-whatsapp',
'nanoclaw-telegram',
'nanoclaw-discord',
'nanoclaw-slack',
'nanoclaw-gmail',
];
const sha = context.sha.substring(0, 7);
for (const repo of forks) {
try {
await github.rest.repos.createDispatchEvent({
owner: 'qwibitai',
repo,
event_type: 'upstream-main-updated',
client_payload: { sha: context.sha },
});
console.log(`Notified ${repo}`);
} catch (e) {
console.log(`Failed to notify ${repo}: ${e.message}`);
}
}

View File

@@ -1,102 +0,0 @@
name: Skill Drift Detection
# Runs after every push to main that touches source files.
# Validates every skill can still be cleanly applied, type-checked, and tested.
# If a skill drifts, attempts auto-fix via three-way merge of modify/ files,
# then opens a PR with the result (auto-fixed or with conflict markers).
on:
push:
branches: [main]
paths:
- 'src/**'
- 'container/**'
- 'package.json'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
# ── Step 1: Check all skills against current main ─────────────────────
validate:
runs-on: ubuntu-latest
outputs:
drifted: ${{ steps.check.outputs.drifted }}
drifted_skills: ${{ steps.check.outputs.drifted_skills }}
results: ${{ steps.check.outputs.results }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Validate all skills against main
id: check
run: npx tsx scripts/validate-all-skills.ts
continue-on-error: true
# ── Step 2: Auto-fix and create PR ────────────────────────────────────
fix-drift:
needs: validate
if: needs.validate.outputs.drifted == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
token: ${{ steps.app-token.outputs.token }}
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Attempt auto-fix via three-way merge
id: fix
run: |
SKILLS=$(echo '${{ needs.validate.outputs.drifted_skills }}' | jq -r '.[]')
npx tsx scripts/fix-skill-drift.ts $SKILLS
- name: Create pull request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ steps.app-token.outputs.token }}
branch: ci/fix-skill-drift
delete-branch: true
title: 'fix(skills): auto-update drifted skills'
body: |
## Skill Drift Detected
A push to `main` (${{ github.sha }}) changed source files that caused
the following skills to fail validation:
**Drifted:** ${{ needs.validate.outputs.drifted_skills }}
### Auto-fix results
${{ steps.fix.outputs.summary }}
### What to do
1. Review the changes to `.claude/skills/*/modify/` files
2. If there are conflict markers (`<<<<<<<`), resolve them
3. CI will run typecheck + tests on this PR automatically
4. Merge when green
---
*Auto-generated by [skill-drift CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})*
labels: skill-drift,automated
commit-message: 'fix(skills): auto-update drifted skill modify/ files'

View File

@@ -1,151 +0,0 @@
name: Skill PR Validation
on:
pull_request:
branches: [main]
paths:
- '.claude/skills/**'
- 'skills-engine/**'
jobs:
# ── Job 1: Policy gate ────────────────────────────────────────────────
# Block PRs that add NEW skill files while also modifying source code.
# Skill PRs should contain instructions for Claude, not raw source edits.
policy-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for mixed skill + source changes
run: |
ADDED_SKILLS=$(git diff --name-only --diff-filter=A origin/main...HEAD \
| grep '^\\.claude/skills/' || true)
CHANGED=$(git diff --name-only origin/main...HEAD)
SOURCE=$(echo "$CHANGED" \
| grep -E '^src/|^container/|^package\.json|^package-lock\.json' || true)
if [ -n "$ADDED_SKILLS" ] && [ -n "$SOURCE" ]; then
echo "::error::PRs that add new skills should not modify source files."
echo ""
echo "New skill files:"
echo "$ADDED_SKILLS"
echo ""
echo "Source files:"
echo "$SOURCE"
echo ""
echo "Please split into separate PRs. See CONTRIBUTING.md."
exit 1
fi
- name: Comment on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `This PR adds a skill while also modifying source code. A skill PR should not change source files—the skill should contain **instructions** for Claude to follow.
If you're fixing a bug or simplifying code, please submit that as a separate PR.
See [CONTRIBUTING.md](https://github.com/${context.repo.owner}/${context.repo.repo}/blob/main/CONTRIBUTING.md) for details.`
})
# ── Job 2: Detect which skills changed ────────────────────────────────
detect-changed:
runs-on: ubuntu-latest
outputs:
skills: ${{ steps.detect.outputs.skills }}
has_skills: ${{ steps.detect.outputs.has_skills }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed skills
id: detect
run: |
CHANGED_SKILLS=$(git diff --name-only origin/main...HEAD \
| grep '^\\.claude/skills/' \
| sed 's|^\.claude/skills/||' \
| cut -d/ -f1 \
| sort -u \
| jq -R . | jq -s .)
echo "skills=$CHANGED_SKILLS" >> "$GITHUB_OUTPUT"
if [ "$CHANGED_SKILLS" = "[]" ]; then
echo "has_skills=false" >> "$GITHUB_OUTPUT"
else
echo "has_skills=true" >> "$GITHUB_OUTPUT"
fi
echo "Changed skills: $CHANGED_SKILLS"
# ── Job 3: Validate each changed skill in isolation ───────────────────
validate-skills:
needs: detect-changed
if: needs.detect-changed.outputs.has_skills == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
skill: ${{ fromJson(needs.detect-changed.outputs.skills) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- run: npm ci
- name: Initialize skills system
run: >-
npx tsx -e
"import { initNanoclawDir } from './skills-engine/index'; initNanoclawDir();"
- name: Apply skill
run: npx tsx scripts/apply-skill.ts ".claude/skills/${{ matrix.skill }}"
- name: Typecheck after apply
run: npx tsc --noEmit
- name: Run skill tests
run: |
TEST_CMD=$(npx tsx -e "
import { parse } from 'yaml';
import fs from 'fs';
const m = parse(fs.readFileSync('.claude/skills/${{ matrix.skill }}/manifest.yaml', 'utf-8'));
if (m.test) console.log(m.test);
")
if [ -n "$TEST_CMD" ]; then
echo "Running: $TEST_CMD"
eval "$TEST_CMD"
else
echo "No test command defined, skipping"
fi
# ── Summary gate for branch protection ────────────────────────────────
skill-validation-summary:
needs:
- policy-check
- detect-changed
- validate-skills
if: always()
runs-on: ubuntu-latest
steps:
- name: Check results
run: |
echo "policy-check: ${{ needs.policy-check.result }}"
echo "validate-skills: ${{ needs.validate-skills.result }}"
if [ "${{ needs.policy-check.result }}" = "failure" ]; then
echo "::error::Policy check failed"
exit 1
fi
if [ "${{ needs.validate-skills.result }}" = "failure" ]; then
echo "::error::Skill validation failed"
exit 1
fi
echo "All skill checks passed"