Compare commits
10
Commits
b635362171
...
c92fe4db73
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c92fe4db73 | ||
|
|
d301ef5a62 | ||
|
|
023e012eda | ||
|
|
f10b885d1c | ||
|
|
c81bc91e03 | ||
|
|
4ce4466a97 | ||
|
|
b21b974293 | ||
|
|
23fc465701 | ||
|
|
03e8e0391a | ||
|
|
d190ded022 |
No files matched your search
@@ -0,0 +1,20 @@
|
|||||||
|
name: check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [main]
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run check
|
||||||
|
- run: npm test
|
||||||
|
- run: npm run build
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
name: nightly
|
||||||
|
|
||||||
|
# Upstream sync -> regenerate -> validate -> version -> publish -> commit back.
|
||||||
|
# Stops successfully when mattpocock/skills has not moved. Credentials only from secrets.
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "30 3 * * *"
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sync:
|
||||||
|
if: gitea.ref == 'refs/heads/main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- name: Sync upstream snapshot
|
||||||
|
id: sync
|
||||||
|
run: |
|
||||||
|
node scripts/sync-upstream.ts
|
||||||
|
if git diff --quiet -- upstream .opencode/state/upstream.json && git ls-files --error-unmatch upstream/UPSTREAM.json >/dev/null 2>&1 && [ -z "$(git status --porcelain -- upstream .opencode/state/upstream.json)" ]; then
|
||||||
|
echo "changed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Stop when nothing changed
|
||||||
|
if: steps.sync.outputs.changed == 'false'
|
||||||
|
run: echo "upstream unchanged; nothing to do"
|
||||||
|
|
||||||
|
- name: Regenerate OpenCode artifacts
|
||||||
|
if: steps.sync.outputs.changed == 'true'
|
||||||
|
run: node scripts/generate.ts
|
||||||
|
|
||||||
|
- name: Format, typecheck, test, build
|
||||||
|
if: steps.sync.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
npm run format
|
||||||
|
npm run check
|
||||||
|
npm test
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
- name: Prepare changelog + version
|
||||||
|
if: steps.sync.outputs.changed == 'true'
|
||||||
|
run: node scripts/version.ts
|
||||||
|
|
||||||
|
- name: Commit generated changes back
|
||||||
|
if: steps.sync.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
SHA=$(node -p "require('./upstream/UPSTREAM.json').commit.slice(0,9)")
|
||||||
|
git config user.name "gitea-actions[bot]"
|
||||||
|
git config user.email "gitea-actions[bot]@noreply"
|
||||||
|
git remote set-url origin "https://x-access-token:${{ secrets.PACKAGE_TOKEN }}@${GITEA_HOST#https://}"
|
||||||
|
git add upstream skills agents manifest.json docs/skill-mapping.md CHANGELOG.md .opencode/state package-lock.json
|
||||||
|
if git diff --cached --quiet; then
|
||||||
|
echo "no generated changes to commit"
|
||||||
|
else
|
||||||
|
git commit -m "sync: update mattpocock skills to ${SHA} [skip ci]"
|
||||||
|
git push origin main
|
||||||
|
fi
|
||||||
|
env:
|
||||||
|
GITEA_HOST: ${{ gitea.server_url }}
|
||||||
|
|
||||||
|
- name: Publish to Gitea npm registry, tag, link
|
||||||
|
if: steps.sync.outputs.changed == 'true'
|
||||||
|
run: |
|
||||||
|
SHA=$(git rev-parse HEAD)
|
||||||
|
SERVER_URL="$SERVER_URL" REPOSITORY="$REPOSITORY" SHA="$SHA" TOKEN="$TOKEN" node scripts/release.ts
|
||||||
|
env:
|
||||||
|
SERVER_URL: ${{ gitea.server_url }}
|
||||||
|
REPOSITORY: ${{ gitea.repository }}
|
||||||
|
TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name: smoke
|
||||||
|
|
||||||
|
# Runtime smoke against a real opencode v2 server: plugin loads, skills register with correct
|
||||||
|
# autoinvoke flags, agents decode with permissions. No model calls, no tokens. Manual trigger only:
|
||||||
|
# it installs OpenCode via the official installer and is not required for publishing.
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
smoke:
|
||||||
|
if: gitea.ref == 'refs/heads/main'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- name: Install OpenCode
|
||||||
|
run: curl -fsSL https://opencode.ai/install | bash
|
||||||
|
- name: Run smoke
|
||||||
|
run: node scripts/smoke.ts
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
.release/
|
||||||
|
package.tgz
|
||||||
|
*.tgz
|
||||||
@@ -0,0 +1,392 @@
|
|||||||
|
{
|
||||||
|
"$comment": "Per-skill classification driving scripts/generate.ts. Source of truth for docs/skill-mapping.md. Classification enum: skill | agent | agent+skill | orchestrator | plugin | not-convertible. Artifacts: skill:verbatim (vendored + plugin-injected), agent:<name> (generated .md), plugin:<feature>, excluded. status: analyzed | needs-review (new upstream skills land as skill/needs-review).",
|
||||||
|
"upstream_commit": "49dd158d1076134a641b33efb035946536778336",
|
||||||
|
"analyzed_at": "2026-10-14",
|
||||||
|
"agents": {
|
||||||
|
"pocock": "primary orchestrator: ask-matt routing + implement-spec dispatch loop (worktrees, frontier, merges) + user-invoked gating",
|
||||||
|
"pocock-worker": "subagent: one ticket, TDD at spec seams, worktree-locked, never pushes, skill allow-list",
|
||||||
|
"pocock-reviewer": "subagent: read-only code-review axis executor (Standards/Spec), findings returned to caller"
|
||||||
|
},
|
||||||
|
"skills": [
|
||||||
|
{
|
||||||
|
"name": "ask-matt",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Pure router prose over all skills; no execution or isolation. Its routing logic also informs the pocock agent's system prompt."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "code-review",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "agent+skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim", "agent:pocock-reviewer"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Skill stays verbatim (aggregation protocol), but its core mechanic is two parallel isolated axis reviewers with large self-contained prompts -> dedicated read-only pocock-reviewer subagent hosts each axis. Caller (pocock or user) aggregates per the skill."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "codebase-design",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Canonical shared-vocabulary reference consumed by tdd/improve-arch/setup-ts-deep-modules; DESIGN-IT-TWICE parallel subagents run via task tool from the loading agent."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "diagnosing-bugs",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Six-phase procedural discipline run inline; no isolation or special permissions needed."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "domain-modeling",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Interactive writing discipline + bundled format files (GLOSSARY/ADR); must run in the main conversation to challenge user wording - an isolated agent would break it."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "grill-with-docs",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["grilling", "domain-modeling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "7-line composition wrapper; OpenCode skill tool loads the two named skills. Preserve verbatim; orchestrator verifies both load (known upstream wrapper failure mode)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "implement",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["tdd", "code-review"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Thin single-context per-ticket procedure composing tdd + code-review; the pocock-worker agent embodies its discipline for parallel builds."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "implement-spec",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "orchestrator",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim", "agent:pocock", "agent:pocock-worker"],
|
||||||
|
"depends_on": ["tdd", "code-review"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "The repo's clearest orchestrator: task-graph frontier, background implementers in git worktrees, merger, fixer. OpenCode's task tool provides no worktrees, so the pocock agent supplies worktree creation, frontier scheduling from its own merge record, and merges; skill text stays verbatim."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "improve-codebase-architecture",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["codebase-design", "grilling", "domain-modeling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Interactive survey-and-grill; its exploration/design-it-twice subagents are internal delegation via task tool, not its identity."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pr",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Pure PR-body template/reference. Verbatim vendoring preserves required attribution (metadata.credits + CREDITS.md, Dex Horthy's show-me)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "prototype",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Generation procedure with two branch docs (LOGIC/UI); user reacts to artifacts in main conversation."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "research",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "The 12-line skill IS a background-agent brief; OpenCode's built-in general subagent + background:true executes it as written. Dedicated pocock-researcher agent evaluated and REJECTED (D8): the brief is self-contained, a branded agent adds drift risk and no capability."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "retro",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["writing-for-agents"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Analysis over the current session's history - isolating it in a subagent would starve it of the session context it mines."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "setup-matt-pocock-skills",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Interactive per-repo scaffolding + seed assets; it creates the docs/agents/* state that to-spec/to-tickets/triage/implement/implement-spec/code-review/wayfinder hard-depend on. Keep verbatim; README flags it as required first run."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "tdd",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["codebase-design"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "The reusable build discipline; consumed by implement and every pocock-worker via skill allow-list."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "to-spec",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Synthesis + template + publish procedure; explicitly no interview, needs main-conversation context (grilling output)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "to-tickets",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Decomposition with human approval loop; needs the spec conversation in context."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "triage",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["grilling", "domain-modeling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Maintainer-driven interactive state machine; heavy human-in-the-loop design fits a skill. A dedicated triage agent was considered and rejected: every step waits on the maintainer."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wayfinder",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["grilling", "domain-modeling", "research", "prototype"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Stateful planning protocol over the tracker (map/fog/frontier); its research dispatches use the research skill + built-in subagents."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wizard",
|
||||||
|
"bucket": "engineering",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Code generator with bundled template.sh asset; the generated artifact is a human-run script, no harness integration needed."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "grill-me",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": ["grilling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "7-line stateless wrapper around grilling."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "grilling",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "The interview primitive the whole methodology builds on; 100% human interaction in the main conversation - converting to an agent would make it worse (isolated context can't grill the user). Fact-finding subagents dispatch via task tool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "handoff",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Document-generation instructions writing to OS temp dir."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "teach",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Stateful multi-session tutor with bundled format files; workspace state lives in files, so no agent isolation needed. A tutor agent was considered and rejected: continuous human dialogue belongs in the primary conversation."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "to-questionnaire",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Two structured interviews + document template."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wait-what",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "7-line corrective re-pitch instruction, usable mid-any-skill."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "writing-for-agents",
|
||||||
|
"bucket": "productivity",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Pure theory reference; the most instructions-only skill in the repo."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "git-guardrails-claude-code",
|
||||||
|
"bucket": "misc",
|
||||||
|
"classification": "plugin",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim", "plugin:guardrails"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Only skill needing executable integration: a Claude Code PreToolUse hook. OpenCode equivalent = opt-in ctx.tool.hook('execute.before') on shell inside our plugin (D7), default off, porting the bundled block-dangerous-git.sh pattern list. Skill text stays vendored verbatim for reference/fidelity."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "migrate-to-shoehorn",
|
||||||
|
"bucket": "misc",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Mechanical codemod recipe. Frozen misc bucket - vendored as-is."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "scaffold-exercises",
|
||||||
|
"bucket": "misc",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Environment-bound: hard-depends on Matt's private ai-hero-cli, only works in his course repos. Vendored verbatim with caveat noted in mapping doc; no OpenCode artifact can fix an external private tool."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "setup-pre-commit",
|
||||||
|
"bucket": "misc",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": false,
|
||||||
|
"artifacts": ["skill:verbatim"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "Setup recipe, npm ecosystem only. Frozen misc bucket - vendored as-is."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "chief-of-staff",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "orchestrator",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": [],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress beta). Would map to a coordinator persona over background subagents; revisit only if upstream promotes it."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "claude-handoff",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "not-convertible",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["handoff"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 + harness-bound: hard-depends on Claude CLI --bg/agents launcher. OpenCode analogue would need its own background-session mechanism; handoff skill covers the portable half."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "loop-me",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["grilling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress). Grilling + workflows/*.md workspace convention; converts trivially if promoted."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "setup-ts-deep-modules",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["codebase-design"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress). Dependency-cruiser setup with bundled config + prove-it-bites self-check; converts cleanly if promoted."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "writing-beats",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["writing-fragments"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "writing-fragments",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["grilling"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress)."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "writing-shape",
|
||||||
|
"bucket": "in-progress",
|
||||||
|
"classification": "skill",
|
||||||
|
"user_invoked": true,
|
||||||
|
"artifacts": ["excluded"],
|
||||||
|
"depends_on": ["writing-fragments"],
|
||||||
|
"status": "analyzed",
|
||||||
|
"rationale": "EXCLUDED per D6 (in-progress)."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -55,3 +55,16 @@ recorded in `.opencode/state/classification.json` so re-inclusion is a data chan
|
|||||||
The only skill needing executable integration: dangerous-git blocking. Implemented as an opt-in
|
The only skill needing executable integration: dangerous-git blocking. Implemented as an opt-in
|
||||||
plugin hook (`ctx.tool.hook("execute.before")` on shell, options `{ guardrails: true }`, default
|
plugin hook (`ctx.tool.hook("execute.before")` on shell, options `{ guardrails: true }`, default
|
||||||
off) inside our plugin; the skill itself stays vendored verbatim for reference.
|
off) inside our plugin; the skill itself stays vendored verbatim for reference.
|
||||||
|
|
||||||
|
## D8 — 2026-10-14 — Final agent roster: pocock, pocock-worker, pocock-reviewer. No researcher.
|
||||||
|
|
||||||
|
Per-skill analysis (38 skills, `.opencode/state/classification.json`) confirms D5's core pair and
|
||||||
|
the reviewer candidate: `code-review`'s defining mechanic is two parallel isolated axis reviewers
|
||||||
|
with large self-contained prompts → `pocock-reviewer` (subagent, edit-deny, skill allow
|
||||||
|
`code-review` only) is the right primitive; the caller aggregates verbatim per the skill.
|
||||||
|
`pocock-researcher` is REJECTED: the 12-line `research` skill already is a background-agent brief;
|
||||||
|
OpenCode's built-in `general` subagent executes it as written — a branded agent adds drift risk and
|
||||||
|
zero capability. Per-phase agents (spec-writer, ticket-planner, debugger, ...) remain rejected:
|
||||||
|
Matt's phases share one conversation context by design (grilling facts feed to-spec; retro mines the
|
||||||
|
live session); isolating them would make the system worse. `triage` and `teach` agents rejected for
|
||||||
|
the same reason (continuous human dialogue belongs in the primary conversation).
|
||||||
+44
-26
@@ -1,40 +1,58 @@
|
|||||||
# Project status
|
# Project status
|
||||||
|
|
||||||
Updated: 2026-10-14 (phase 0 — analysis)
|
Updated: 2026-10-14 (phase 1 implementation, ~90% done)
|
||||||
|
|
||||||
## Current phase
|
## Current phase
|
||||||
|
|
||||||
Phase 0 (analysis) — nearly complete. Phase 1 (plugin package) not started.
|
Phase 1 (plugin package) — implementation complete and runtime-verified locally. Remaining:
|
||||||
|
first registry release (1.10) + Gitea secret provisioning, then Phase 2.
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
- Repo bootstrapped (was empty; Gitea remote `haylan/mattpocock-skills-opencode` configured, no commits yet).
|
- Phase 0 analysis complete: architecture, 38-skill classification matrix, decisions D1–D8,
|
||||||
- Studied reference repos (cloned to temp, not vendored):
|
verified V2 API surface (docs + `@opencode/plugin@2.0.29` typings + live runtime).
|
||||||
- `fastcrw-opencode-websearch` — V2 plugin shape, Gitea release script/workflows, test style
|
- Package scaffolded: `@haylan/opencode-pocock` (name confirmed by owner), TS ESM, prettier,
|
||||||
(`node --test` on .ts), prettier/tsconfig conventions.
|
`node --test` on .ts, MIT + NOTICE attributions (Matt Pocock, Dex Horthy, mcdays94, fastcrw).
|
||||||
- `mcdays94/pocock-agents` — proven orchestrator/worker agent pair (V1-era, tracks upstream v1.3
|
- `scripts/sync-upstream.ts`: pristine snapshot vendoring @49dd158 (v1.3.1, 38 skills), early exit
|
||||||
`d81f3a1`), drift-check script, Docker smoke test.
|
on no-change, needs-review classification entries for new skills, previous_commit/last_diff in
|
||||||
- `mattpocock/skills` @ `49dd158` (2026-10-09, v1.3.1) — full inventory: engineering 20,
|
state for the changelog generator.
|
||||||
productivity 7, misc 4, in-progress 7 (excluded), deprecated 0.
|
- `scripts/generate.ts`: skills/ tree (verbatim, minus agents/openai.yaml), manifest.json (31
|
||||||
- Verified OpenCode V2 API surface against docs + `anomalyco/opencode@dev` source (see AGENTS.md
|
skills, autoinvoke from upstream DMI), docs/skill-mapping.md matrix between markers.
|
||||||
"Key V2 facts").
|
- Plugin `src/index.ts` (id `haylan.pocock`): injects all manifest skills (frontmatter-stripped
|
||||||
- Wrote: AGENTS.md, state files, TODO.md, docs/architecture.md, docs/skill-mapping.md.
|
content, absolute package paths), opt-in `guardrails` tool hook (upstream pattern list ported),
|
||||||
|
agent missing/stale warning via `.pocock-version` stamp. Fails loudly on bad options.
|
||||||
|
- `src/init.ts` bin: copies agents to project/global agents dir, never clobbers modified files
|
||||||
|
without --force, stamps version.
|
||||||
|
- Agents (V2-native frontmatter only): `pocock` (primary orchestrator, worktree dispatch loop),
|
||||||
|
`pocock-worker` (subagent, skill allow-list tdd/codebase-design/diagnosing-bugs, git/gh denies,
|
||||||
|
no subagents), `pocock-reviewer` (subagent, read-only code-review axis executor).
|
||||||
|
- Release pipeline: `scripts/version.ts` (changelog-driven minor bump, idempotent per upstream
|
||||||
|
SHA) + `scripts/release.ts` (Gitea npm registry publish via HTTP, tag, package link; adapted
|
||||||
|
from fastcrw) + CHANGELOG.md with 0.1.0 prepared.
|
||||||
|
- Workflows: check.yml (PR+push), nightly.yml (sync→generate→format/check/test/build→version→
|
||||||
|
commit-back→publish+tag+link, secrets-only), smoke.yml (dispatch-only, installs opencode).
|
||||||
|
- `scripts/smoke.ts` — PASS on opencode v2.0.29: plugin active, 31 skills registered (16 hidden),
|
||||||
|
agents decoded with full permission arrays. Findings: docs/runtime-checks.md.
|
||||||
|
- Test suite: 32 unit/integration tests green (parser, generator+real-snapshot regression, sync
|
||||||
|
diff, plugin fake-ctx, init, drift gates, release/version helpers).
|
||||||
|
|
||||||
## Known gaps / risks
|
## Known gaps / risks
|
||||||
|
|
||||||
- Unverified at runtime: exact `Skill.Info` field set accepted by `editor.add` (docs show
|
- 1.10 not done: package never published to the Gitea registry yet; npm-name plugin entry
|
||||||
id/name/description/path/content + autoinvoke; confirm against installed `@opencode/plugin`
|
(resolving through `exports`) unverified — local directory entry verified instead.
|
||||||
typings in Phase 1). Same for `permissions` array frontmatter in agent .md — verify with a real
|
- `PACKAGE_TOKEN` Gitea secret must be provisioned by the repo admin before nightly can publish
|
||||||
`opencode serve` smoke.
|
or commit back.
|
||||||
- Background subagents: V1 needed `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true`; V2 status
|
- Nightly runner network access to github.com unverified (fallback: Gitea mirror of upstream).
|
||||||
unknown — orchestrator must work in batch mode either way.
|
- Windows-only smoke quirk: fixture temp dir deletion can lag (EPERM warning, harmless); CI is
|
||||||
- `request.body` overlays are accepted but not sent by the V2 runner yet — don't rely on
|
Linux.
|
||||||
temperature tuning.
|
- Background subagents in V2 (env-gated in V1) not verified; orchestrator text works either way.
|
||||||
- Nightly commit-back to main needs a Gitea token with repo write scope (same `PACKAGE_TOKEN`
|
- `request.body` overlays accepted but not sent by the V2 runner — agents avoid them.
|
||||||
pattern as fastcrw, which used it for tags + package link).
|
|
||||||
|
|
||||||
## Next steps (exact)
|
## Next steps (exact)
|
||||||
|
|
||||||
1. Finish docs/skill-mapping.md classification matrix (subagent analysis of every SKILL.md).
|
1. Run `npm run format`, `npm run check`, `npm test`, `npm run build`; commit workflows/smoke/docs.
|
||||||
2. Commit phase-0 docs: `docs: phase 0 analysis and migration plan`.
|
2. Push to origin; ask owner to add `PACKAGE_TOKEN` secret (write:package + write:repository).
|
||||||
3. Start TODO.md Phase 1.1: scaffold package (package.json, tsconfig, prettier, src/index.ts stub).
|
3. 1.10: `node scripts/release.ts` with SERVER_URL/REPOSITORY/SHA/TOKEN env (or dispatch a manual
|
||||||
|
release workflow) → verify `plugins: ["@haylan/opencode-pocock"]` installs from the registry in
|
||||||
|
a clean fixture; record in docs/runtime-checks.md.
|
||||||
|
4. Phase 2 per TODO.md (2.2 guardrails already implemented in 1.4 — verify mapping note; 2.4–2.7).
|
||||||
@@ -3,6 +3,5 @@
|
|||||||
"commit": "49dd158d1076134a641b33efb035946536778336",
|
"commit": "49dd158d1076134a641b33efb035946536778336",
|
||||||
"commit_date": "2026-10-09T11:56:49+01:00",
|
"commit_date": "2026-10-09T11:56:49+01:00",
|
||||||
"upstream_version": "1.3.1",
|
"upstream_version": "1.3.1",
|
||||||
"synced_at": null,
|
"synced_at": "2026-10-14T09:54:19.512Z"
|
||||||
"note": "HEAD observed during phase-0 analysis; upstream/ snapshot not vendored yet"
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
node_modules/
|
||||||
|
dist/
|
||||||
|
.release/
|
||||||
|
package.tgz
|
||||||
|
upstream/
|
||||||
|
skills/
|
||||||
|
docs/skill-mapping.md
|
||||||
|
CHANGELOG.md
|
||||||
|
package-lock.json
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"semi": false,
|
||||||
|
"printWidth": 100
|
||||||
|
}
|
||||||
@@ -45,14 +45,25 @@ safe intermediate work.
|
|||||||
|
|
||||||
- Plugins: `Plugin.define({ id, setup(ctx) })` from `@opencode/plugin`; config key `plugins`;
|
- Plugins: `Plugin.define({ id, setup(ctx) })` from `@opencode/plugin`; config key `plugins`;
|
||||||
npm package needs `type: module` + `exports["."]`.
|
npm package needs `type: module` + `exports["."]`.
|
||||||
- `ctx.skill.transform(editor)` **can add** skills programmatically (id, name, description, path,
|
- `ctx.skill.transform(editor)` **can add** skills programmatically. `Skill.Info` (verified in
|
||||||
content, autoinvoke, slash). `ctx.agent.transform(editor)` **cannot add** agents — only
|
`@opencode/plugin@2.0.29` typings) = `{ id, name, description?, autoinvoke?, path, content }` —
|
||||||
list/get/update/remove/default. Hence: skills ship via plugin injection, agents via `init` copy.
|
`path` must be absolute (we point it at the bundled SKILL.md so supporting files resolve); there is
|
||||||
|
**no `slash` field** in `Skill.Info` (slash is file-frontmatter only — verify `/name` exposure for
|
||||||
|
injected skills at runtime; fallback: document a `skills: ["<pkg>/skills"]` config entry).
|
||||||
|
`ctx.agent.transform(editor)` **cannot add** agents — only list/get/update/remove/default. Hence:
|
||||||
|
skills ship via plugin injection, agents via `init` copy.
|
||||||
|
- `Agent.Info` (verified): `{ id, name, mode: subagent|primary|all, description?, model?, system?,
|
||||||
|
hidden, color?, steps?, request{settings,headers,body}, permissions[{action,resource,effect}] }`.
|
||||||
- Skills frontmatter honored: `name`, `description`, `slash`, `disable-model-invocation` /
|
- Skills frontmatter honored: `name`, `description`, `slash`, `disable-model-invocation` /
|
||||||
`metadata.opencode/autoinvoke` (hidden from model, still loadable by id/slash).
|
`metadata.opencode/autoinvoke` (hidden from model, still loadable by id/slash).
|
||||||
- Agent files: `.opencode/agents/<name>.md` (project), `~/.config/opencode/agents/` (global);
|
- Agent files: `.opencode/agents/<name>.md` (project), `~/.config/opencode/agents/` (global);
|
||||||
frontmatter = agent config, body = system prompt.
|
frontmatter = agent config, body = system prompt.
|
||||||
- Permission rules are ordered, last match wins; per-agent skill restrictions via
|
- Permission rules are ordered, last match wins; per-agent skill restrictions via
|
||||||
`{action: "skill", resource: "<pattern>", effect: ...}`. Shell action is `shell` in V2.
|
`{action: "skill", resource: "<pattern>", effect: ...}`. V2 actions include `shell`, `edit`,
|
||||||
|
`read`/`glob`/`grep`, `webfetch`, `skill`, `subagent`, `external_directory`; no rule → ask.
|
||||||
|
- Runtime-verified on v2.0.29 (see docs/runtime-checks.md): local plugin entries must be
|
||||||
|
DIRECTORIES (file entries ignored); `/api/skill` omits `autoinvoke` when true; injected skills
|
||||||
|
get no slash commands (file-based only); default rules already allow `external_directory /tmp/*`;
|
||||||
|
injected content must have frontmatter stripped; serve prints its Basic-auth password.
|
||||||
- Agent `steps` replaces `maxSteps`; `temperature`/`top_p` go under `request.body` (not yet sent by
|
- Agent `steps` replaces `maxSteps`; `temperature`/`top_p` go under `request.body` (not yet sent by
|
||||||
the runner — avoid).
|
the runner — avoid).
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to this project are documented in this file. The latest `## [x.y.z]` heading is
|
||||||
|
the release source of truth (scripts/release.ts). Upstream syncs record the mattpocock/skills
|
||||||
|
revision they carry.
|
||||||
|
|
||||||
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); semver, with upstream
|
||||||
|
content changes bumping minor automatically (never major).
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-10-14
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- OpenCode v2 plugin `haylan.pocock` injecting all 31 vendored Matt Pocock skills
|
||||||
|
(mattpocock/skills `49dd158`, v1.3.1) via `ctx.skill.transform`; the 16 user-invoked skills are
|
||||||
|
hidden from model auto-selection (`autoinvoke: false`) and runnable as slash commands.
|
||||||
|
- Generated V2-native agents: `pocock` (primary orchestrator running the grill → spec → tickets →
|
||||||
|
parallel-worktree-build → review → retro flow), `pocock-worker` (worktree-locked test-first
|
||||||
|
implementer with skill allow-list), `pocock-reviewer` (read-only code-review axis executor).
|
||||||
|
- `opencode-pocock init [-g] [--force]` copying agent files into `.opencode/agents/` or
|
||||||
|
`~/.config/opencode/agents/` with a version stamp the plugin checks (missing/stale agents print
|
||||||
|
a one-line fix; no silent repo writes).
|
||||||
|
- Opt-in `guardrails` plugin option porting upstream `git-guardrails-claude-code` to a v2
|
||||||
|
`ctx.tool.hook("execute.before")` shell block (dangerous git patterns, faithful to the upstream
|
||||||
|
script).
|
||||||
|
- Nightly Gitea Actions workflow: upstream sync (early exit on no change), regeneration, format /
|
||||||
|
typecheck / unit / integration / drift tests, changelog-driven minor bump, idempotent publish to
|
||||||
|
the Gitea npm registry with tag + package link, generated changes committed back to main.
|
||||||
|
- Test suite (`node --test` on TypeScript): frontmatter parser, manifest generation, skill/agent
|
||||||
|
drift gates, plugin fake-ctx integration, init behavior, release/version helpers.
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 haylan
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
This package vendors and redistributes third-party material:
|
||||||
|
|
||||||
|
- skills/ (except agents/*.md system prompts written for this package) is a verbatim snapshot of
|
||||||
|
the skills from Matt Pocock's "skills" repository (https://github.com/mattpocock/skills),
|
||||||
|
Copyright (c) Matt Pocock, licensed under the MIT License. The upstream revision is recorded in
|
||||||
|
upstream/UPSTREAM.json and .opencode/state/upstream.json. All engineering discipline in the
|
||||||
|
skills is Matt Pocock's work.
|
||||||
|
|
||||||
|
- The `pr` skill incorporates material from Dex Horthy's "show-me" skill
|
||||||
|
(https://github.com/humanlayer/skills), attributed in the skill's frontmatter
|
||||||
|
(metadata.credits) and CREDITS.md, preserved verbatim.
|
||||||
|
|
||||||
|
- The orchestrator/worker agent design is adapted from mcdays94/pocock-agents
|
||||||
|
(https://github.com/mcdays94/pocock-agents), Copyright (c) mcdays94, MIT License.
|
||||||
|
|
||||||
|
- The Gitea npm registry release scripts are adapted from haylan/fastcrw-opencode-websearch,
|
||||||
|
Apache-2.0.
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
# @haylan/opencode-pocock
|
||||||
|
|
||||||
|
[OpenCode](https://opencode.ai) v2 integration for [Matt Pocock's skills](https://github.com/mattpocock/skills):
|
||||||
|
the upstream skills injected verbatim as OpenCode skills, plus generated agents that run his
|
||||||
|
skill-driven engineering flow — grill an idea, turn it into a spec and tickets, build test-first
|
||||||
|
with parallel workers in isolated git worktrees, review, retro.
|
||||||
|
|
||||||
|
All engineering discipline is Matt Pocock's; this package only supplies the OpenCode v2 wiring.
|
||||||
|
Upstream is synced nightly and the package republished on change (see `CHANGELOG.md` for the
|
||||||
|
upstream revision each release carries).
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
1. Add the plugin (from the Gitea registry, or npm once published there):
|
||||||
|
|
||||||
|
```jsonc
|
||||||
|
// opencode.json
|
||||||
|
{
|
||||||
|
"$schema": "https://opencode.ai/config.json",
|
||||||
|
"plugins": ["@haylan/opencode-pocock"],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The plugin injects all skills at startup — no files copied into your repo.
|
||||||
|
|
||||||
|
2. Install the agents (OpenCode discovers agents only as markdown files, and plugins cannot
|
||||||
|
register them, so this one copy step is required):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @haylan/opencode-pocock init # project: .opencode/agents/
|
||||||
|
npx @haylan/opencode-pocock init -g # or global: ~/.config/opencode/agents/
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Once per repo, run `/setup-matt-pocock-skills` in OpenCode. It configures the issue tracker,
|
||||||
|
triage labels and domain docs that `to-spec`, `to-tickets`, `triage`, `implement`,
|
||||||
|
`implement-spec`, `code-review` and `wayfinder` depend on.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Start OpenCode with the `pocock` agent selected and describe what you want to build:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
opencode --agent pocock
|
||||||
|
```
|
||||||
|
|
||||||
|
| Agent | Role |
|
||||||
|
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
|
| `pocock` | Primary orchestrator. Routes with `ask-matt`, walks grill → spec → tickets → build → review → retro, proposes before each user-invoked step, runs `implement-spec` with one git worktree per ticket and parallel `pocock-worker` subagents. |
|
||||||
|
| `pocock-worker` | Subagent. Builds one ticket test-first (`tdd` at the spec's seams) inside its worktree, merges the integration tip, reports. Never pushes. |
|
||||||
|
| `pocock-reviewer` | Subagent. Read-only executor of one `code-review` axis (Standards or Spec). |
|
||||||
|
|
||||||
|
23 of the 31 vendored skills are user-invoked upstream (`disable-model-invocation: true`);
|
||||||
|
OpenCode v2 honors that natively — they stay out of the model's auto-selection. Note that
|
||||||
|
plugin-injected skills are not exposed as slash commands in v2 (only file-based skills are):
|
||||||
|
the `pocock` agent proposes each user-invoked step and loads it after your yes. If you want
|
||||||
|
`/to-spec` & co. directly, either keep a file-based install of Matt's skills (e.g.
|
||||||
|
`npx skills@latest add mattpocock/skills -a opencode`; id collisions then resolve to your
|
||||||
|
file-based copies) or, for a project-level npm install, add a skills source:
|
||||||
|
`"skills": ["./node_modules/@haylan/opencode-pocock/skills"]`.
|
||||||
|
|
||||||
|
Worktrees live under `/tmp/pocock-workers`. Current OpenCode v2 builds allow `external_directory`
|
||||||
|
for `/tmp/*` by default; if yours asks before a subagent writes there, add a global rule:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{ "permission": { "external_directory": { "/tmp/pocock-workers/*": "allow" } } }
|
||||||
|
```
|
||||||
|
|
||||||
|
## Plugin options
|
||||||
|
|
||||||
|
```jsonc
|
||||||
|
{
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"package": "@haylan/opencode-pocock",
|
||||||
|
// Ports skills/misc/git-guardrails-claude-code to OpenCode: blocks dangerous git
|
||||||
|
// commands (push --force, reset --hard, clean -f, branch -D, ...) before execution.
|
||||||
|
"options": { "guardrails": true },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
- `npm run sync` — update `upstream/` snapshot from mattpocock/skills (script-only; never
|
||||||
|
hand-edit `upstream/` or `skills/`).
|
||||||
|
- `npm run generate` — regenerate `skills/` + `manifest.json` from `upstream/` and
|
||||||
|
`.opencode/state/classification.json`.
|
||||||
|
- `npm test` / `npm run check` / `npm run build` — unit + integration tests (`node --test` on TS),
|
||||||
|
prettier + tsc gate, build.
|
||||||
|
- `npm run smoke` — boots `opencode serve` against a fixture and verifies plugin/skills/agents
|
||||||
|
over the HTTP API (needs a local `opencode` binary; no model calls).
|
||||||
|
|
||||||
|
Design and rationale: [`docs/architecture.md`](docs/architecture.md).
|
||||||
|
Per-skill classification: [`docs/skill-mapping.md`](docs/skill-mapping.md).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
MIT — see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE) for upstream attributions.
|
||||||
@@ -13,33 +13,34 @@ State: `.opencode/state/status.md`. Design: `docs/architecture.md`.
|
|||||||
- [x] Gitea Actions design (§6)
|
- [x] Gitea Actions design (§6)
|
||||||
- [x] Testing strategy (§7)
|
- [x] Testing strategy (§7)
|
||||||
- [x] Phased plan (§9)
|
- [x] Phased plan (§9)
|
||||||
- [ ] Skill inventory + classification matrix → docs/skill-mapping.md (subagent analysis in flight)
|
- [x] Skill inventory + classification matrix → docs/skill-mapping.md +
|
||||||
- [ ] Commit phase-0 docs (`docs: phase 0 analysis and migration plan`)
|
.opencode/state/classification.json (38 skills analyzed from SKILL.md sources)
|
||||||
|
- [x] Commit phase-0 docs
|
||||||
|
|
||||||
## Phase 1 — plugin package
|
## Phase 1 — plugin package
|
||||||
|
|
||||||
- [ ] 1.1 scaffold package (package.json name @haylan/opencode-pocock — CONFIRM scope with repo
|
- [x] 1.1 scaffold package (`@haylan/opencode-pocock` confirmed by owner 2026-10-14)
|
||||||
owner, tsconfig, prettier, .gitignore, MIT LICENSE + upstream attribution, README stub)
|
- [x] 1.2 scripts/sync-upstream.ts + vendor upstream/ @49dd158 + state update
|
||||||
- [ ] 1.2 scripts/sync-upstream.ts + vendor upstream/ @49dd158 + state update
|
- [x] 1.3 scripts/generate.ts: manifest.json + skills/ output + unit tests (parser, manifest)
|
||||||
- [ ] 1.3 scripts/generate.ts: manifest.json + skills/ output + unit tests (parser, manifest)
|
- [x] 1.4 src/index.ts plugin: skill injection (frontmatter-stripped content), options validation,
|
||||||
- [ ] 1.4 src/index.ts plugin: skill injection, options validation, agent-staleness warning +
|
agent-staleness warning + fake-ctx integration tests (Skill.Info verified: cast needed for
|
||||||
fake-ctx integration tests (verify Skill.Info fields against installed @opencode/plugin typings!)
|
effect-branded fields; runtime PASS)
|
||||||
- [ ] 1.5 bin init (copy agents, -g global, no silent overwrite) + tests
|
- [x] 1.5 bin init (copy agents, -g global, no silent overwrite, .pocock-version stamp) + tests
|
||||||
- [ ] 1.6 agent-templates/: port pocock + pocock-worker from pocock-agents to V2-native frontmatter
|
- [x] 1.6 agents/: pocock + pocock-worker + pocock-reviewer, V2-native frontmatter; drift tests
|
||||||
(permissions array, shell action, no legacy keys); generate agents/*.md; drift tests
|
(upstream names, worker skill allow-list, reviewer read-only, no subagent recursion)
|
||||||
- [ ] 1.7 scripts/release.ts + version.ts adapted from fastcrw + unit tests
|
- [x] 1.7 scripts/release.ts + version.ts adapted from fastcrw + unit tests
|
||||||
- [ ] 1.8 .gitea/workflows/: check.yml, nightly.yml, smoke (dispatch); smoke.ts against opencode serve
|
- [x] 1.8 .gitea/workflows/: check.yml, nightly.yml, smoke.yml (dispatch); scripts/smoke.ts —
|
||||||
- [ ] 1.9 local runtime verification (serve + HTTP API: plugin ok, skills visible, autoinvoke flags,
|
PASS on v2.0.29 (plugin active, 31 skills, 16 hidden, agents + permissions decoded)
|
||||||
agents after init, worker denies hold) → docs/runtime-checks.md
|
- [x] 1.9 local runtime verification → docs/runtime-checks.md (findings folded into README/AGENTS)
|
||||||
- [ ] 1.10 manual release 0.1.0 to Gitea registry; verify install-from-registry by package name
|
- [ ] 1.10 manual release 0.1.0 to Gitea registry; verify install-from-registry by package name
|
||||||
- [ ] ask repo admin to add Gitea secret PACKAGE_TOKEN (write:package + write:repository)
|
- [ ] ask repo admin to add Gitea secret PACKAGE_TOKEN (write:package + write:repository)
|
||||||
|
|
||||||
## Phase 2 — conversion
|
## Phase 2 — conversion
|
||||||
|
|
||||||
- [ ] 2.1 deep per-skill analysis → .opencode/state/classification.json + docs/skill-mapping.md
|
- [x] 2.1 deep per-skill analysis → .opencode/state/classification.json + docs/skill-mapping.md
|
||||||
(classification.json becomes generator input; mapping doc generated from it)
|
(done in phase 0; generator must regenerate mapping doc from classification.json — keep in 1.3 scope)
|
||||||
- [ ] 2.2 guardrails plugin hook (opt-in, tool.hook execute.before on shell) + tests
|
- [ ] 2.2 guardrails plugin hook (opt-in, tool.hook execute.before on shell) + tests
|
||||||
- [ ] 2.3 pocock-reviewer: implement or document rejection in decisions.md
|
- [ ] 2.3 pocock-reviewer: CONFIRMED by analysis (D8) — implement template + skill-permission scoping
|
||||||
- [ ] 2.4 orchestrator V2 flow wiring (background-subagent status in V2? batch fallback; worktree
|
- [ ] 2.4 orchestrator V2 flow wiring (background-subagent status in V2? batch fallback; worktree
|
||||||
permission guidance; slash UX for user-invoked skills)
|
permission guidance; slash UX for user-invoked skills)
|
||||||
- [ ] 2.5 per-skill regression checks + manual orchestration smoke (token-spending, documented)
|
- [ ] 2.5 per-skill regression checks + manual orchestration smoke (token-spending, documented)
|
||||||
@@ -48,12 +49,17 @@ State: `.opencode/state/status.md`. Design: `docs/architecture.md`.
|
|||||||
|
|
||||||
## Open questions
|
## Open questions
|
||||||
|
|
||||||
- Exact `Skill.Info`/editor.add field set — check `@opencode/plugin` typings at 1.4.
|
- ~~Exact `Skill.Info`/editor.add field set~~ RESOLVED 2026-10-14 (`@opencode/plugin@2.0.29`):
|
||||||
- V2 background subagents: still env-gated? Affects orchestrator dispatch loop wording (1.6).
|
`{id, name, description?, autoinvoke?, path, content}`; no `slash` in Info.
|
||||||
- Does `slash` need explicit `true` in editor.add to expose `/name` commands? (1.4 runtime check.)
|
- V2 background subagents: still env-gated? Affects orchestrator dispatch loop wording only
|
||||||
- Package name/scope confirmation (1.1).
|
(agent text covers both modes) — low priority, observe at 2.5.
|
||||||
|
- ~~Slash exposure for injected skills~~ RESOLVED: none (runtime check 2026-10-14); README
|
||||||
|
documents file-based alternatives.
|
||||||
|
- Package name/scope: CONFIRMED `@haylan/opencode-pocock` (owner, 2026-10-14).
|
||||||
- Does nightly runner have network access to github.com for upstream fetch? (1.8 — fallback: mirror
|
- Does nightly runner have network access to github.com for upstream fetch? (1.8 — fallback: mirror
|
||||||
upstream to Gitea and sync from the mirror.)
|
upstream to Gitea and sync from the mirror.) Verify on first nightly run.
|
||||||
|
- Install-from-registry by package name (npm-name plugin entry resolving through `exports`) —
|
||||||
|
verify at 1.10; local dir entry verified.
|
||||||
|
|
||||||
## Done log
|
## Done log
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
---
|
||||||
|
description: Read-only executor of one code-review axis (Standards or Spec). Receives a fully-specified review prompt from the orchestrator, reviews the diff since a fixed point, and returns findings for verbatim aggregation. Never edits, never spawns.
|
||||||
|
mode: subagent
|
||||||
|
color: "#34D399"
|
||||||
|
permissions:
|
||||||
|
- { action: read, resource: "*", effect: allow }
|
||||||
|
- { action: glob, resource: "*", effect: allow }
|
||||||
|
- { action: grep, resource: "*", effect: allow }
|
||||||
|
- { action: edit, resource: "*", effect: deny }
|
||||||
|
- { action: subagent, resource: "*", effect: deny }
|
||||||
|
- { action: webfetch, resource: "*", effect: deny }
|
||||||
|
- { action: skill, resource: "*", effect: deny }
|
||||||
|
- { action: skill, resource: "code-review", effect: allow }
|
||||||
|
- { action: shell, resource: "*", effect: deny }
|
||||||
|
- { action: shell, resource: "git diff*", effect: allow }
|
||||||
|
- { action: shell, resource: "git log*", effect: allow }
|
||||||
|
- { action: shell, resource: "git show*", effect: allow }
|
||||||
|
- { action: shell, resource: "git status*", effect: allow }
|
||||||
|
- { action: shell, resource: "git rev-parse*", effect: allow }
|
||||||
|
- { action: shell, resource: "git merge-base*", effect: allow }
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a **Pocock Reviewer**. The pocock orchestrator (or a user running `code-review`) dispatches you for exactly one review axis — **Standards** or **Spec** — with a fully-specified prompt: the fixed point or diff range, and the pasted standards material (for Standards) or spec content (for Spec). You review and return findings. You never fix anything.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Load `code-review` and follow it for your axis only. Your dispatch prompt says which axis you are and contains the material the skill would otherwise gather; don't go looking for a different spec or standards source.
|
||||||
|
2. Pin the diff: run the `git diff`/`git log` commands your prompt gives you (for integration-branch reviews that's `git diff <base>...<branch>` and `git show <branch>:<path>` for file contents at the tip — the checkout you run in may not have the branch checked out).
|
||||||
|
3. Review within your axis:
|
||||||
|
- **Standards axis**: the repo's standards files as pasted (they override the baseline), plus the smell baseline from the skill. Every smell finding is a judgement call — say what it costs and what fixing it buys.
|
||||||
|
- **Spec axis**: behaviour against the spec content as pasted. Missing requirements, contradictions, untested acceptance criteria.
|
||||||
|
4. Return your findings as your whole reply, in severity order, each with file and line reference and a one-line justification. Use the glossary's vocabulary when the repo has one. No preamble, no summary of the diff, no cross-axis findings — the caller aggregates both axes verbatim under `## Standards` / `## Spec`.
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
1. **Read-only.** You cannot edit, run arbitrary commands, fetch the web, or spawn subagents, and you don't try to. If a finding needs verification you can't do with git reads and file reads, mark it "unverified" instead of guessing.
|
||||||
|
2. **Stay in your axis.** A spec violation that is also a smell belongs to the other reviewer; skip it.
|
||||||
|
3. **Findings, not fixes.** Never propose patches longer than a line; the orchestrator sends fixes to a worker in a fresh worktree.
|
||||||
|
4. **Empty is a valid result.** If the axis is clean, return exactly `No <axis> findings.` — don't invent findings to look useful.
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
---
|
||||||
|
description: Implements one ticket test-first in a git worktree prepared by the pocock orchestrator, merges the integration branch tip into its branch, and reports back. Never pushes. Invoked by pocock for parallel ticket work.
|
||||||
|
mode: subagent
|
||||||
|
color: "#818CF8"
|
||||||
|
permissions:
|
||||||
|
- { action: read, resource: "*", effect: allow }
|
||||||
|
- { action: glob, resource: "*", effect: allow }
|
||||||
|
- { action: grep, resource: "*", effect: allow }
|
||||||
|
- { action: edit, resource: "*", effect: allow }
|
||||||
|
- { action: webfetch, resource: "*", effect: allow }
|
||||||
|
- { action: external_directory, resource: "/tmp/pocock-workers/*", effect: allow }
|
||||||
|
- { action: external_directory, resource: "/private/tmp/pocock-workers/*", effect: allow }
|
||||||
|
# Unattended: no spawning, no asking. User-invoked skills need a person and stay denied.
|
||||||
|
# Add project stack skills to the allow-list below (see pocock.md "Stack skills").
|
||||||
|
- { action: subagent, resource: "*", effect: deny }
|
||||||
|
- { action: skill, resource: "*", effect: deny }
|
||||||
|
- { action: skill, resource: "tdd", effect: allow }
|
||||||
|
- { action: skill, resource: "codebase-design", effect: allow }
|
||||||
|
- { action: skill, resource: "diagnosing-bugs", effect: allow }
|
||||||
|
- { action: shell, resource: "*", effect: allow }
|
||||||
|
- { action: shell, resource: "git push*", effect: deny }
|
||||||
|
- { action: shell, resource: "git -C * push*", effect: deny }
|
||||||
|
- { action: shell, resource: "git stash*", effect: deny }
|
||||||
|
- { action: shell, resource: "git -C * stash*", effect: deny }
|
||||||
|
- { action: shell, resource: "git worktree*", effect: deny }
|
||||||
|
- { action: shell, resource: "git -C * worktree*", effect: deny }
|
||||||
|
- { action: shell, resource: "git reset --hard*", effect: deny }
|
||||||
|
- { action: shell, resource: "git -C * reset --hard*", effect: deny }
|
||||||
|
- { action: shell, resource: "git clean*", effect: deny }
|
||||||
|
- { action: shell, resource: "git -C * clean*", effect: deny }
|
||||||
|
- { action: shell, resource: "git switch*", effect: deny }
|
||||||
|
- { action: shell, resource: "git checkout *", effect: deny }
|
||||||
|
- { action: shell, resource: "gh pr create*", effect: deny }
|
||||||
|
- { action: shell, resource: "gh pr merge*", effect: deny }
|
||||||
|
- { action: shell, resource: "gh issue close*", effect: deny }
|
||||||
|
- { action: shell, resource: "glab mr create*", effect: deny }
|
||||||
|
- { action: shell, resource: "glab mr merge*", effect: deny }
|
||||||
|
- { action: shell, resource: "glab issue close*", effect: deny }
|
||||||
|
---
|
||||||
|
|
||||||
|
You are a **Pocock Worker**. The pocock orchestrator gives you one ticket and a git worktree prepared for it. You build that ticket test-first, merge the integration branch into your branch, and report back. Other workers are running in parallel in their own worktrees, so everything you do stays inside yours.
|
||||||
|
|
||||||
|
## Inputs
|
||||||
|
|
||||||
|
The orchestrator's prompt gives you pointers, not copies:
|
||||||
|
|
||||||
|
- **Worktree**: the directory you work in, e.g. `/tmp/pocock-workers/<repo>/<spec>/tickets/<ticket-id>`. Run every command there (use it as the shell's working directory) and never leave it.
|
||||||
|
- **Branch**: already created and checked out, e.g. `ticket/<spec>/<ticket-id>`. Don't create or switch branches.
|
||||||
|
- **Integration branch**: the branch every ticket merges into, e.g. `spec/<spec>`. In PR-per-ticket mode there is none, and the orchestrator will say so.
|
||||||
|
- **Ticket** and **spec**: an issue number, URL or file path. Fetch them the way the repo's issue tracker doc says (the `## Agent skills` block in `AGENTS.md`/`CLAUDE.md` points at it, usually `docs/agents/issue-tracker.md`). A local-markdown ticket lives at `.scratch/<feature>/issues/<NN>-<slug>.md`, next to `.scratch/<feature>/spec.md`.
|
||||||
|
- **Notes**: a directory of exploration notes, if the orchestrator made one. Names it fixes are binding.
|
||||||
|
- **Stack skills** to load, if any.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
### 1. Check the worktree
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status --short # expect: nothing
|
||||||
|
git rev-parse --abbrev-ref HEAD # expect: the branch you were given
|
||||||
|
git merge-base --is-ancestor <integration-branch> HEAD && echo ok # expect: ok
|
||||||
|
```
|
||||||
|
|
||||||
|
If a check fails, stop and report it. Don't repair the worktree yourself; a bad worktree is the orchestrator's bug.
|
||||||
|
|
||||||
|
Worktrees hold only tracked files, so dependencies aren't there yet. Install them the way the project does (`npm ci`, `pnpm install --frozen-lockfile`, `uv sync`, ...).
|
||||||
|
|
||||||
|
### 2. Read
|
||||||
|
|
||||||
|
Read the ticket, then the spec. The spec's **Testing Decisions** name the seams the user agreed to test at; those are your pre-agreed seams. Read the glossary (`GLOSSARY.md`, `GLOSSARY-MAP.md`, or a legacy `CONTEXT.md`) and any ADRs in `docs/adr/` that touch your area, and the notes directory if you got one.
|
||||||
|
|
||||||
|
### 3. Build it test-first
|
||||||
|
|
||||||
|
Load `tdd` and follow it.
|
||||||
|
|
||||||
|
- `tdd` only writes tests at seams agreed in advance, and you can't ask the user. Use the seams from the spec. If the ticket needs a seam the spec doesn't name, pick the highest existing seam that reaches the behaviour and say so in your report.
|
||||||
|
- Red, then green, one vertical slice at a time. Refactoring isn't part of the loop; the review stage handles it.
|
||||||
|
- Typecheck and run single test files often. Run the full suite once, at the end.
|
||||||
|
- Use the glossary's terms in test names, module names and commit messages.
|
||||||
|
- Load `codebase-design` when `tdd` needs it (the shape of an interface is in question), and the stack skills the orchestrator named.
|
||||||
|
- If the ticket is a bug and your first failing test doesn't reproduce it, load `diagnosing-bugs` and follow it. Redact secrets in everything you show.
|
||||||
|
|
||||||
|
### 4. Commit
|
||||||
|
|
||||||
|
Small commits, one per red-green cycle or logical unit. Reference the ticket: `fix(studio): persist deletion in DO state (#42)` on GitHub or GitLab; for a local ticket file, put its path in the commit body. Don't squash.
|
||||||
|
|
||||||
|
### 5. Verify beyond the test suite
|
||||||
|
|
||||||
|
The language test suite (`go test ./...`, `npm test`, etc.) does NOT exercise every file you might touch. Before reporting, verify these separately when relevant:
|
||||||
|
|
||||||
|
- **Dockerfile / Containerfile changes**: run `docker build -t wip-verify .` in the worktree. A passing language build does NOT catch package-name mismatches, layer ordering, or platform-specific failures. Classic trap: Alpine package names differ from Debian/Ubuntu — verify each `apk add` name at pkgs.alpinelinux.org before committing (via `webfetch` when `docker` is unavailable).
|
||||||
|
- **CI workflow files (`.github/workflows/*.yml`, `.gitea/workflows/*.yml`)**: the test suite does not run them. Validate YAML syntax and trace the logic manually; watch shell parameter expansion (`${VAR##*:}` vs `${VAR#*:}`), `sort -V` vs `sort -v:refname`, and tag-matching filters.
|
||||||
|
- **Database migrations**: run against a fresh database, and the rollback too when reversible.
|
||||||
|
- **Package manifests (`package.json`, `go.mod`, `Cargo.toml`, `pyproject.toml`)**: after changes, run a lockfile-respecting install (`npm ci`, `go mod tidy`, ...) to ensure no drift.
|
||||||
|
- **Platform templates / manifests (Kubernetes YAML, Helm charts, XML)**: validate with the right tool (`kubectl apply --dry-run=client`, `helm lint`, `xmllint --noout`).
|
||||||
|
- **Infrastructure-as-code (Terraform, Pulumi, OpenTofu)**: `plan` only, never `apply`; check the plan for unintended destruction.
|
||||||
|
- **Frontend/UI cross-references**: when your code sets a value, triggers a class, routes to a path, or references a DOM id, verify the target actually exists on the other side. Classic trap: setting `select.value = "86400"` with no matching `<option>`. Add assertions on BOTH sides so a refactor can't silently move one.
|
||||||
|
- **Tests that skipped themselves**: a worktree lacks gitignored files (`.env`, local databases, fixtures). Read the runner's skip count; if a test covering your change skipped, say so in your report instead of calling the ticket done.
|
||||||
|
|
||||||
|
If a verification step fails, fix it and commit before reporting. Never report a broken build as done.
|
||||||
|
|
||||||
|
### 6. Merge the integration tip
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git merge --no-edit <integration-branch>
|
||||||
|
```
|
||||||
|
|
||||||
|
Resolve any conflict using the ticket and spec, re-run the tests, and commit the merge. This makes the orchestrator's merge a fast-forward. If the orchestrator resumes you later because another ticket landed first, do this step again. Skip it in PR-per-ticket mode.
|
||||||
|
|
||||||
|
### 7. Report
|
||||||
|
|
||||||
|
Return, in this order:
|
||||||
|
|
||||||
|
- branch and final commit SHA
|
||||||
|
- what you built, in the glossary's terms
|
||||||
|
- tests added or changed, and the seams they sit at
|
||||||
|
- before/after evidence the PR body can quote: the failing then passing test, or command output
|
||||||
|
- anything skipped: tests that didn't run, checks you couldn't do
|
||||||
|
- decisions you made on your own, and follow-ups you noticed but left alone
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
1. **Stay in your worktree.** Don't `cd` out of it, don't switch branches, don't touch `main` or the integration branch directly. Other workers may have those branches checked out.
|
||||||
|
2. **You never push, stash, reset --hard, clean, run `git worktree`, open or merge PRs, or close issues.** Your permissions deny all of these. Pushing and PRs are the orchestrator's job; `refs/stash` is shared by every worktree, so a stash can surface in another worker's tree.
|
||||||
|
3. **One ticket.** Note adjacent problems in your report instead of fixing them.
|
||||||
|
4. **Every behaviour change gets a test.** If the project has no test framework, set one up as your first commit (vitest for Vite projects).
|
||||||
|
5. **Don't report a broken build as done.** Run the project's build and test commands, plus the step 5 checks for files the tests don't cover.
|
||||||
|
6. **Ask nothing.** You're autonomous and cannot spawn subagents. Decide, and record the decision in your report.
|
||||||
|
7. **Report environment anomalies.** If the worktree arrives in an unexpected state (wrong branch, dirty tree, missing files, not based on the integration branch), stop and report it rather than repairing it.
|
||||||
|
8. **Respect the domain docs.** Use the glossary's vocabulary. If your change contradicts an ADR, say so in your report rather than silently overruling it.
|
||||||
|
9. **Your skill list is exhaustive.** `tdd`, `codebase-design`, `diagnosing-bugs` and whatever stack skills your permissions allow. Skills that need a person (grilling, triage, specs, architecture reviews) are the orchestrator's job, and your permissions deny them.
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
description: Runs Matt Pocock's skill-driven engineering flow in OpenCode (grill, spec, tickets, test-first build by parallel workers on an integration branch, review, retro). Dispatches pocock-worker subagents into isolated git worktrees.
|
||||||
|
mode: primary
|
||||||
|
color: "#6366F1"
|
||||||
|
permissions:
|
||||||
|
- { action: read, resource: "*", effect: allow }
|
||||||
|
- { action: glob, resource: "*", effect: allow }
|
||||||
|
- { action: grep, resource: "*", effect: allow }
|
||||||
|
- { action: edit, resource: "*", effect: allow }
|
||||||
|
- { action: webfetch, resource: "*", effect: allow }
|
||||||
|
- { action: skill, resource: "*", effect: allow }
|
||||||
|
- { action: subagent, resource: "*", effect: allow }
|
||||||
|
- { action: external_directory, resource: "/tmp/pocock-workers/*", effect: allow }
|
||||||
|
- { action: external_directory, resource: "/private/tmp/pocock-workers/*", effect: allow }
|
||||||
|
- { action: shell, resource: "*", effect: allow }
|
||||||
|
- { action: shell, resource: "git push --force*", effect: deny }
|
||||||
|
- { action: shell, resource: "git push -f*", effect: deny }
|
||||||
|
- { action: shell, resource: "git reset --hard*", effect: deny }
|
||||||
|
- { action: shell, resource: "git clean -*", effect: deny }
|
||||||
|
- { action: shell, resource: "git branch -D*", effect: deny }
|
||||||
|
---
|
||||||
|
|
||||||
|
You are **Pocock**. You run Matt Pocock's engineering flow in OpenCode: an idea gets grilled, turned into a spec and tickets, built test-first by parallel workers, reviewed, and looked back on.
|
||||||
|
|
||||||
|
Matt's skills hold the discipline. Your job is to pick the next skill, get the user's go-ahead where a person should start it, load it with the `skill` tool, and follow it. What you add is what the skills expect from the tool they run in: git worktrees, subagent dispatch, and the merge loop. Don't restate or improvise a skill's process; load it.
|
||||||
|
|
||||||
|
The skills come from [`mattpocock/skills`](https://github.com/mattpocock/skills), vendored by `@haylan/opencode-pocock` (revision recorded in the package changelog). If a skill named here is missing from the `skill` tool's list, it was probably renamed upstream. Tell the user and point them at the upstream `CHANGELOG.md`; don't guess a replacement.
|
||||||
|
|
||||||
|
Credit: the orchestrator/worker design is adapted from [mcdays94/pocock-agents](https://github.com/mcdays94/pocock-agents) (MIT); all methodology is Matt Pocock's.
|
||||||
|
|
||||||
|
## Session start
|
||||||
|
|
||||||
|
1. **Load `ask-matt`.** It's Matt's router over every skill and flow. On questions of routing it wins over this file. It only reads, so load it without asking. If it isn't installed, carry on with this file and mention that it's missing.
|
||||||
|
2. **Scan the repo.** Read `AGENTS.md` or `CLAUDE.md`, the glossary, `docs/adr/`, and any stack-skill mapping the project defines. Load the stack skills that match and say which ones and why.
|
||||||
|
3. **Find the glossary.** It's `GLOSSARY.md`, or `GLOSSARY-MAP.md` pointing at one glossary per context. Older repos may have `CONTEXT.md`/`CONTEXT-MAP.md` (Matt's name before v1.3) or `UBIQUITOUS_LANGUAGE.md`; read those as the glossary. The upstream skills only look for `GLOSSARY.md`, so the first time the domain docs are about to change, offer `git mv CONTEXT.md GLOSSARY.md`.
|
||||||
|
4. **Check per-repo setup when it's needed.** `setup-matt-pocock-skills` writes an `## Agent skills` block into `AGENTS.md`/`CLAUDE.md` that points at the issue tracker doc and the domain doc, plus a triage label doc when `triage` is installed. The first time a step needs the tracker (`to-spec`, `to-tickets`, `triage`, `wayfinder`, `implement-spec`, `code-review`) and the block is missing, ask the user to run `/setup-matt-pocock-skills`, or offer to run it for them. It edits their instruction file, so wait for a yes.
|
||||||
|
|
||||||
|
## How you invoke skills
|
||||||
|
|
||||||
|
Matt splits his skills in two:
|
||||||
|
|
||||||
|
- **User-invoked** skills are meant to be started by a person: `to-spec`, `to-tickets`, `implement`, `implement-spec`, `triage`, `wayfinder`, `retro`, `improve-codebase-architecture`, `handoff`, `teach`, `to-questionnaire`, `setup-matt-pocock-skills`, and the wrappers `grill-with-docs` and `grill-me`. OpenCode keeps them out of your auto-selection natively, and the user can run any of them as a slash command (`/to-spec`). You still enforce the human gate: propose the step in one line ("Grilling is done. Next I'd run `to-spec` to write the spec. Go ahead?") and load it after the user says yes. A request that already names the step ("write the spec") counts as a yes.
|
||||||
|
- **Model-invoked** skills are yours to load whenever the work calls for them: `grilling`, `domain-modeling`, `tdd`, `codebase-design`, `diagnosing-bugs`, `prototype`, `research`, `code-review`, `pr`, `wizard`, `writing-for-agents`.
|
||||||
|
|
||||||
|
Load one skill per `skill` call. When a wrapper names two skills (`grill-with-docs` = `grilling` + `domain-modeling`), load both yourself and verify both arrived. Matt's docs report that wrappers sometimes fail to load what they name, and the tell is a round of questions with no recommended answers.
|
||||||
|
|
||||||
|
## The main flow
|
||||||
|
|
||||||
|
This is `ask-matt`'s main flow with your part added. Announce each phase as you enter it and say why.
|
||||||
|
|
||||||
|
1. **Grill.** In a repo, load `grilling` and `domain-modeling` (this is what `grill-with-docs` does). With no repo, or when the user wants no docs, load `grilling` alone (`grill-me`). Questions go out in numbered rounds, each with your recommended answer. Facts are yours to find (send an `explore` subagent); decisions are the user's. Move on only when the user confirms you share an understanding. If the idea is too big for one session, propose `wayfinder` instead.
|
||||||
|
2. **Prototype, if needed.** When a question needs running code to settle it (a state model, a UI), load `prototype`.
|
||||||
|
3. **Spec.** Propose `to-spec`. It writes the spec from this conversation without re-interviewing, but it does confirm the test seams with the user. Make sure the seams land in the spec's Testing Decisions: workers test at them and can't ask.
|
||||||
|
4. **Tickets.** Propose `to-tickets`. Keep steps 1 to 4 in one context window; don't suggest compacting before the tickets exist. On GitHub, check afterwards that each ticket is a sub-issue of the spec (`gh issue edit <spec> --add-sub-issue <n>`) with native blocked-by links (the API call is in the tracker doc's wayfinding section), and that the triage labels exist (`gh label create`).
|
||||||
|
5. **Build.** For one small ticket, or when the user wants to drive, propose `implement` and run it here. It commits to the current branch without asking, so get onto a feature branch first. Its closing `code-review` only sees committed work: commit, then review against the branch point. For several tickets, propose `implement-spec` and run it with the dispatch loop below.
|
||||||
|
6. **Review.** `implement-spec` ends with one `code-review` over the integration branch. For work built any other way, run `code-review` against the branch point. The skill runs its two axes as parallel subagents: dispatch one `pocock-reviewer` per axis with the fully-specified prompt the skill describes, then aggregate exactly as the skill says.
|
||||||
|
7. **Retro.** Propose `retro` before the session ends or gets cleared. It turns this session's mistakes into checks and coding standards for the next build.
|
||||||
|
|
||||||
|
## Other entry points
|
||||||
|
|
||||||
|
Route by `ask-matt`. The common ones:
|
||||||
|
|
||||||
|
| Situation | Start with |
|
||||||
|
| ----------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
||||||
|
| Incoming bug reports or feature requests nobody on the team wrote | `triage`, then Build for `ready-for-agent` issues |
|
||||||
|
| A hard bug, flaky test or performance regression | `diagnosing-bugs` |
|
||||||
|
| A huge, foggy effort that won't fit one session | `wayfinder`; when the map clears, continue at step 3 |
|
||||||
|
| A codebase health pass | `improve-codebase-architecture`; a chosen candidate becomes an idea for step 1 |
|
||||||
|
| A question that needs docs, source or specs read | `research` (dispatch it as a background `general` subagent, as the skill says) |
|
||||||
|
| A step only a human can do (dashboards, credentials, CI secrets) | `wizard` |
|
||||||
|
| A decision only someone else can make | `to-questionnaire` |
|
||||||
|
| A finished spec with tickets | step 5 |
|
||||||
|
|
||||||
|
Don't triage tickets that `to-tickets` produced; they're agent-ready already.
|
||||||
|
|
||||||
|
## Phase boundaries
|
||||||
|
|
||||||
|
At the boundary between two phases, follow `ask-matt`'s order. Continue while the next phase needs this context and there's room (models stay sharp up to about 150k tokens). Send tightly scoped work that needs no steering to a subagent. Otherwise suggest the user compacts, with a note on what the next phase needs. You can't clear or compact yourself. Suggest `handoff` only when the work has to move to another tool, directory or person.
|
||||||
|
|
||||||
|
## Running implement-spec in OpenCode
|
||||||
|
|
||||||
|
Load `implement-spec` and follow it. It assumes a tool that gives each subagent its own git worktree; OpenCode's task tool doesn't, so you do that part.
|
||||||
|
|
||||||
|
Everything lives outside the repo, and the main checkout is never touched:
|
||||||
|
|
||||||
|
```
|
||||||
|
WT=/tmp/pocock-workers/<repo>/<spec-slug>
|
||||||
|
$WT/integration worktree on the integration branch spec/<spec-slug>
|
||||||
|
$WT/tickets/<ticket-id> one worktree per ticket, on branch ticket/<spec-slug>/<ticket-id>
|
||||||
|
$WT/notes/ exploration notes every subagent can read
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep ticket branches under `ticket/`: git can't hold a branch `spec/x` and a branch `spec/x/01` at once.
|
||||||
|
|
||||||
|
1. **Read the graph.** Read the spec and every ticket. Write down each ticket's blockers and keep that record current as tickets merge. Compute the frontier from your record, not from the tracker: GitHub only drops a blocked-by edge when the blocker closes, and that happens at the end of the run.
|
||||||
|
2. **Explore (optional).** Send one `general` subagent to explore what the tickets need and write notes to `$WT/notes/`. Have it fix exact names (types, fields, message keys, routes) for anything two tickets both add, because parallel workers otherwise invent different names for the same thing. If two frontier tickets will edit the same file or registry, run them one after the other. Built-in subagents don't inherit your `external_directory` permission for `/tmp/pocock-workers`; without the global rule from the package README, OpenCode asks the user before `general` can write there.
|
||||||
|
3. **Create the integration branch.**
|
||||||
|
```bash
|
||||||
|
git -C <repo> fetch origin
|
||||||
|
git -C <repo> worktree add -b spec/<spec-slug> $WT/integration origin/<default-branch>
|
||||||
|
```
|
||||||
|
With no remote (a local-markdown tracker, offline), branch from the local default branch instead. Install the project's dependencies in `$WT/integration` once; worktrees don't share `node_modules` or virtualenvs.
|
||||||
|
4. **Dispatch the frontier.** For each ticket on the frontier:
|
||||||
|
```bash
|
||||||
|
git -C <repo> worktree add -b ticket/<spec-slug>/<ticket-id> $WT/tickets/<ticket-id> spec/<spec-slug>
|
||||||
|
```
|
||||||
|
Then start one `pocock-worker` per ticket, all in one message so they run in parallel. Give each worker pointers, not summaries: worktree, branch, integration branch, ticket reference, spec reference, notes directory, and the stack skills to load. If your OpenCode runtime supports background subagents, start each new ticket the moment its last blocker merges; otherwise the batch returns together — merge it, recompute the frontier, dispatch the next batch. Worktrees hold only tracked files, so:
|
||||||
|
- With a local-markdown tracker, pass absolute paths into the main checkout (`<repo>/.scratch/<feature>/...`). `.scratch/` is often untracked and then missing from the worktree.
|
||||||
|
- If a ticket's tests need untracked files (fixtures, `.env`, a local database), copy them in when that's safe, and tell the worker, so it reports skipped tests instead of calling them green.
|
||||||
|
5. **Merge each finished ticket.**
|
||||||
|
```bash
|
||||||
|
git -C $WT/integration merge --ff-only ticket/<spec-slug>/<ticket-id>
|
||||||
|
```
|
||||||
|
Workers merge the integration tip into their branch before reporting, so this is normally a fast-forward. When it isn't because another ticket merged first, resume that worker, have it merge the new tip, resolve any conflict and re-run its tests, then retry. It knows its own change best, so it's the merger. Don't merge a ticket whose worker reported failure; decide with the user whether to retry, split or drop it. After each merge, run the tests in `$WT/integration`, update your blocker record, and dispatch whatever is now unblocked.
|
||||||
|
6. **Open a draft PR if one is wanted.** Only when the tracker closes work through PRs, or the user asks. After the first merge, push `spec/<spec-slug>` and open a draft PR that closes the spec and every ticket. Load `pr` for its body.
|
||||||
|
7. **Review once.** When every ticket has merged, load `code-review`. The fixed point is the default branch; since the main checkout isn't on the integration branch, give the reviewers `git diff <default-branch>...spec/<spec-slug>` and `git log <default-branch>..spec/<spec-slug>` instead of `...HEAD`. Worktrees share refs, so the reviewers work from the main checkout and read files at the tip with `git show spec/<spec-slug>:<path>`. Send all findings to one `pocock-worker` in a fresh ticket worktree (`ticket/<spec-slug>/review-fixes`), merge its fix, and stop. A second full review never comes back clean; if the user wants more, check only the fixed findings.
|
||||||
|
8. **Close out.** Mark the draft PR ready, or resolve each ticket the way the tracker closes work. Report the integration branch.
|
||||||
|
9. **Clean up.** Remove every ticket worktree, and `$WT/integration` once the branch is pushed or the user is done with it. Branches stay. Keep a failed worker's worktree until the user has looked at it.
|
||||||
|
```bash
|
||||||
|
git -C <repo> worktree remove --force $WT/tickets/<ticket-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
### PR-per-ticket mode
|
||||||
|
|
||||||
|
Use this only when the user wants every ticket reviewed as its own PR. Branch each ticket worktree from `origin/<default-branch>` instead of the integration branch, and dispatch a ticket only after its blockers' PRs have merged. Tell the worker there's no integration branch. When a worker finishes, push its branch and open the PR yourself (workers never push), with a `pr`-shaped body and a `Closes #<n>` line. Review each PR with `code-review`.
|
||||||
|
|
||||||
|
## Stack skills
|
||||||
|
|
||||||
|
If the project's `AGENTS.md` maps stack skills (signals → skills to load), trust it: load the matching skills up front, before grilling, so every phase benefits, and name them in worker prompts. A worker can only load skills its own permission list in `pocock-worker.md` allows — tell the user to add their stack skills there when they edit the flow. Without a project mapping, load nothing extra.
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
1. **Grill before building.** When the user says "build X", start at step 1, unless they hand you a finished spec, say they've already been grilled, or are reporting bugs.
|
||||||
|
2. **A person starts user-invoked skills.** Propose, then wait for a yes.
|
||||||
|
3. **One phase at a time.** Finish a phase before starting the next. A phase may load the model-invoked skills it names; stack skills and parallel workers are the exceptions.
|
||||||
|
4. **Every worker gets its own worktree.** Never put two workers in one checkout, not even for a quick fix: concurrent checkouts clobber each other's branches.
|
||||||
|
5. **The frontier comes from your merge record.** Never dispatch a ticket whose blockers haven't merged into the integration branch.
|
||||||
|
6. **Read every worker report** before merging or dispatching more. Failures, skipped tests and follow-ups get handled or raised with the user, not buried.
|
||||||
|
7. **Keep artifacts linked.** The spec links its tickets, tickets link their branches, the PR closes the spec and tickets, and ADRs link the decisions they record.
|
||||||
|
8. **Only use skill names from this file or the `skill` tool's list.** If one is missing, say so rather than guessing.
|
||||||
@@ -69,7 +69,7 @@ D6), deprecated 0. Full table with classification + rationale: `docs/skill-mappi
|
|||||||
Verified against V2 (`@opencode/plugin` ^2.x, `Plugin.define`):
|
Verified against V2 (`@opencode/plugin` ^2.x, `Plugin.define`):
|
||||||
|
|
||||||
| Requirement | V2 mechanism |
|
| Requirement | V2 mechanism |
|
||||||
| --- | --- |
|
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Stable identity | `Plugin.define({ id: "haylan.pocock", setup })` |
|
| Stable identity | `Plugin.define({ id: "haylan.pocock", setup })` |
|
||||||
| Inject all skills | `await ctx.skill.transform(editor => editor.add({ id, name, description, path, content, autoinvoke, slash }))` per manifest entry; `path` = absolute SKILL.md location inside the installed package so supporting-file references resolve |
|
| Inject all skills | `await ctx.skill.transform(editor => editor.add({ id, name, description, path, content, autoinvoke, slash }))` per manifest entry; `path` = absolute SKILL.md location inside the installed package so supporting-file references resolve |
|
||||||
| Options | `ctx.options` — validate and fail loudly (fastcrw pattern) |
|
| Options | `ctx.options` — validate and fail loudly (fastcrw pattern) |
|
||||||
@@ -84,7 +84,7 @@ Not needed: custom tools, MCP, websearch, auth. Keep the plugin surface minimal.
|
|||||||
Hierarchy (D5) — two core agents, one likely addition, rest rejected unless the matrix proves value:
|
Hierarchy (D5) — two core agents, one likely addition, rest rejected unless the matrix proves value:
|
||||||
|
|
||||||
| Agent | Mode | Role | Key V2 config |
|
| Agent | Mode | Role | Key V2 config |
|
||||||
| --- | --- | --- | --- |
|
| ----------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||||
| `pocock` | primary | Orchestrator: routes via `ask-matt`, walks grill→spec→tickets→build→review→retro, gates user-invoked skills behind explicit proposals, runs the `implement-spec` dispatch loop (integration branch + one worktree per ticket + frontier scheduling from its own merge record) | `permissions`: edit/shell allow; shell deny for destructive git on the main checkout; `skill` allow `*`; task allow |
|
| `pocock` | primary | Orchestrator: routes via `ask-matt`, walks grill→spec→tickets→build→review→retro, gates user-invoked skills behind explicit proposals, runs the `implement-spec` dispatch loop (integration branch + one worktree per ticket + frontier scheduling from its own merge record) | `permissions`: edit/shell allow; shell deny for destructive git on the main checkout; `skill` allow `*`; task allow |
|
||||||
| `pocock-worker` | subagent | Builds one ticket test-first inside its prepared worktree, merges integration tip into its branch, reports; never pushes/stashes/worktrees/PRs; asks nothing | `permissions`: skill deny `*` + allow-list (tdd, codebase-design, diagnosing-bugs, stack skills); shell deny push/stash/reset --hard/clean/worktree/switch, `gh pr`/`gh issue close`; edit allow |
|
| `pocock-worker` | subagent | Builds one ticket test-first inside its prepared worktree, merges integration tip into its branch, reports; never pushes/stashes/worktrees/PRs; asks nothing | `permissions`: skill deny `*` + allow-list (tdd, codebase-design, diagnosing-bugs, stack skills); shell deny push/stash/reset --hard/clean/worktree/switch, `gh pr`/`gh issue close`; edit allow |
|
||||||
| `pocock-reviewer` (candidate) | subagent | Read-only `code-review` fan-out over the integration branch; findings go back to the orchestrator, fixes run in a fresh worker | `permissions`: edit deny; shell allow git read commands only; skill allow code-review only |
|
| `pocock-reviewer` (candidate) | subagent | Read-only `code-review` fan-out over the integration branch; findings go back to the orchestrator, fixes run in a fresh worker | `permissions`: edit deny; shell allow git read commands only; skill allow code-review only |
|
||||||
@@ -112,7 +112,7 @@ methodology depends on, e.g. grilling facts feeding `to-spec`).
|
|||||||
- Diff old vs new snapshot → added/removed/changed skill list → written into the changelog entry and
|
- Diff old vs new snapshot → added/removed/changed skill list → written into the changelog entry and
|
||||||
`status.md`; changed skills are matched against `classification.json` to flag affected agents
|
`status.md`; changed skills are matched against `classification.json` to flag affected agents
|
||||||
(regeneration is full but cheap and deterministic; "regenerate only what is necessary" is satisfied
|
(regeneration is full but cheap and deterministic; "regenerate only what is necessary" is satisfied
|
||||||
by determinism — unchanged inputs produce byte-identical outputs, so the git diff *is* the
|
by determinism — unchanged inputs produce byte-identical outputs, so the git diff _is_ the
|
||||||
affected-set report).
|
affected-set report).
|
||||||
- New upstream skills appear in the manifest automatically but land unclassified:
|
- New upstream skills appear in the manifest automatically but land unclassified:
|
||||||
`classification.json` defaults them to `skill` + `status: "needs-review"`, and the drift test fails
|
`classification.json` defaults them to `skill` + `status: "needs-review"`, and the drift test fails
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Runtime checks — verified against real OpenCode v2
|
||||||
|
|
||||||
|
Environment: Windows 11, `opencode v2.0.29`, `@opencode/plugin@2.0.29`, 2026-10-14.
|
||||||
|
Method: `scripts/smoke.ts` boots `opencode serve` (private server, Basic auth user `opencode`,
|
||||||
|
password printed on stdout) in a temp fixture and asserts against the HTTP API. Result: **PASS**.
|
||||||
|
|
||||||
|
## Verified
|
||||||
|
|
||||||
|
- **Plugin loads and activates** from a local directory entry (`plugins: ["<abs path>/dist"]`);
|
||||||
|
`GET /api/plugin` shows `haylan.pocock` with `state.status: "active"`.
|
||||||
|
- A **file** entry (`file://.../dist/index.js`) is IGNORED — local plugin entries must be
|
||||||
|
directories with a root `index`/`server` file (confirms fastcrw research). npm-name entries
|
||||||
|
resolve through `exports` (to be re-verified after first registry publish, TODO 1.10).
|
||||||
|
- **Skill injection works**: all 31 manifest skills registered (`GET /api/skill`); the 16
|
||||||
|
user-invoked ones carry `autoinvoke: false`. The API **omits `autoinvoke` when true** (default).
|
||||||
|
- **DMI honored natively**: file-loaded skills with upstream `disable-model-invocation: true`
|
||||||
|
(e.g. a global `~/.agents/skills` install) show `autoinvoke: false` without our plugin.
|
||||||
|
- **ID collisions**: when the same skill id also exists as a file-based skill (global install), the
|
||||||
|
file-based entry is what `/api/skill` reports; plugin injection coexists without errors.
|
||||||
|
(`pr`, absent from the tester's global install, was served from our package path.)
|
||||||
|
- **Injected content must have frontmatter stripped** to match file-based loading
|
||||||
|
(`markdown.content`); the plugin does this since 2026-10-14.
|
||||||
|
- **Agent markdown with V2-native frontmatter decodes correctly** from `.opencode/agents/`:
|
||||||
|
`pocock` (primary), `pocock-worker` / `pocock-reviewer` (subagent), descriptions intact, and the
|
||||||
|
full `permissions` array survived decoding in order — verified on `pocock-worker`:
|
||||||
|
`skill * deny` + `tdd/codebase-design/diagnosing-bugs allow`, `subagent * deny`, and all
|
||||||
|
git/gh/glab shell denies present.
|
||||||
|
- **Default permission floor** (v2.0.29): agents start with `{action:"*",resource:"*",effect:"allow"}`
|
||||||
|
plus specific rules, among them `external_directory /tmp` and `/tmp/*` **allow** — the
|
||||||
|
`/tmp/pocock-workers` worktree root needs no extra user config on this build (README still
|
||||||
|
documents the rule for other setups/subagents).
|
||||||
|
- **Injected skills do NOT become slash commands** (`GET /api/command` shows none for them;
|
||||||
|
`Skill.Info` has no `slash` field). User-invoked steps are started via conversation with `pocock`
|
||||||
|
(propose → yes → load) or by any agent explicitly loading the skill. File-based installs (global
|
||||||
|
`~/.agents/skills`, or a `skills: [...]` directory source) keep slash behavior.
|
||||||
|
- **Server API**: prefix `/api/*`, Basic auth (`opencode` + printed password); SPA HTML answers
|
||||||
|
unknown non-/api paths with 200 — assert JSON, not status. `POST /api/location/reload` exists.
|
||||||
|
Plugin loading is lazy (appears seconds after boot); `/openapi.json` requires auth.
|
||||||
|
|
||||||
|
## Known environment quirks (tester machine, not product issues)
|
||||||
|
|
||||||
|
- Windows: `server.kill()` under `shell:true` only kills `cmd.exe`; smoke uses
|
||||||
|
`taskkill /PID <pid> /T /F`. Temp fixture deletion can lag behind handle release (EPERM warning);
|
||||||
|
harmless, retried on next run.
|
||||||
|
- The user's global `~/.agents/skills` already contains most Matt Pocock skills — smoke assertions
|
||||||
|
are written to tolerate id collisions (presence + flags, not source path).
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
# Skill mapping — mattpocock/skills → OpenCode v2
|
||||||
|
|
||||||
|
Upstream: `mattpocock/skills@49dd158` (v1.3.1, 2026-10-09). Analyzed 2026-10-14.
|
||||||
|
Machine-readable source of truth: `.opencode/state/classification.json` (this doc will be generated
|
||||||
|
from it once `scripts/generate.ts` exists — until then keep both in sync by hand).
|
||||||
|
|
||||||
|
Validation status legend: `pending` = not yet runtime-verified (Phase 1.9); `validated` = loads and
|
||||||
|
behaves correctly in a real OpenCode v2 session.
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
| Classification | Count | Skills |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| skill | 27 | all vendored verbatim; see matrix |
|
||||||
|
| agent+skill | 1 | code-review (+ `pocock-reviewer` subagent) |
|
||||||
|
| orchestrator | 2 | implement-spec (→ `pocock` + `pocock-worker`), chief-of-staff (excluded, in-progress) |
|
||||||
|
| plugin | 1 | git-guardrails-claude-code (→ opt-in guardrails hook) |
|
||||||
|
| not-convertible | 1 | claude-handoff (Claude-CLI-bound, excluded) |
|
||||||
|
| agent (dedicated, no skill) | 0 | research evaluated → rejected as dedicated agent (D8) |
|
||||||
|
|
||||||
|
Vendored: 31 skills (engineering 20, productivity 7, misc 4). Excluded: 7 in-progress + deprecated
|
||||||
|
bucket (empty upstream). 23 of 31 vendored skills are user-invoked upstream
|
||||||
|
(`disable-model-invocation: true`) → manifest sets `autoinvoke: false`; OpenCode v2 honors this
|
||||||
|
natively (hidden from model auto-selection, still loadable via `/name` or explicit id).
|
||||||
|
|
||||||
|
## Generated agents
|
||||||
|
|
||||||
|
| Agent | Mode | Purpose | Key permissions |
|
||||||
|
| --- | --- | --- | --- |
|
||||||
|
| `pocock` | primary | Orchestrator: routes via ask-matt, walks grill→spec→tickets→build→review→retro, gates user-invoked skills behind explicit proposals, runs the implement-spec dispatch loop (integration branch, one worktree per ticket, frontier from own merge record, merges, cleanup) | edit/shell allow; destructive-git denies on main checkout; skill `*` allow; task allow |
|
||||||
|
| `pocock-worker` | subagent | Builds one ticket test-first (tdd at the spec's seams) inside its prepared worktree; merges integration tip; reports; never pushes/PRs/stashes/worktrees; asks nothing | skill deny `*` + allow-list (tdd, codebase-design, diagnosing-bugs + stack skills); shell denies push/stash/reset --hard/clean/worktree/switch, gh pr/issue-close; edit allow |
|
||||||
|
| `pocock-reviewer` | subagent | Read-only executor of one code-review axis (Standards or Spec) with the skill's fully-specified prompt; findings returned to the caller for verbatim aggregation | edit deny; shell allow git-read only; skill allow code-review only |
|
||||||
|
|
||||||
|
Rejected agents (recorded so they are not re-proposed without new evidence): `pocock-researcher`
|
||||||
|
(D8 — built-in `general` + the 12-line research brief is equivalent), per-phase agents
|
||||||
|
(spec-writer/ticket-planner/debugger/... — Matt's phases are conversation steps sharing one context,
|
||||||
|
not roles; splitting them shreds the grilling→spec context the methodology depends on), triage agent
|
||||||
|
(every step waits on the maintainer), teach/tutor agent (continuous human dialogue).
|
||||||
|
|
||||||
|
## Matrix
|
||||||
|
|
||||||
|
DMI = `disable-model-invocation: true` upstream (user-invoked). All vendored skills ship verbatim
|
||||||
|
(D1); "Artifacts" lists everything generated for the skill. Status `analyzed` = classification
|
||||||
|
reviewed by a human; `needs-review` = new upstream skill, drift test fails until reviewed. Runtime
|
||||||
|
validation of every artifact is tracked in `.opencode/state/status.md` (all `pending` until
|
||||||
|
Phase 1.9).
|
||||||
|
|
||||||
|
<!-- matrix:start -->
|
||||||
|
|
||||||
|
| Upstream skill | Bucket | DMI | Classification | Artifacts | Depends on | Status | Rationale |
|
||||||
|
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||||
|
| ask-matt | eng | ✓ | skill | skill:verbatim | | analyzed | Pure router prose over all skills; no execution or isolation. Its routing logic also informs the pocock agent's system prompt. |
|
||||||
|
| code-review | eng | | agent+skill | skill:verbatim, agent:pocock-reviewer | | analyzed | Skill stays verbatim (aggregation protocol), but its core mechanic is two parallel isolated axis reviewers with large self-contained prompts -> dedicated read-only pocock-reviewer subagent hosts each axis. Caller (pocock or user) aggregates per the skill. |
|
||||||
|
| codebase-design | eng | | skill | skill:verbatim | | analyzed | Canonical shared-vocabulary reference consumed by tdd/improve-arch/setup-ts-deep-modules; DESIGN-IT-TWICE parallel subagents run via task tool from the loading agent. |
|
||||||
|
| diagnosing-bugs | eng | | skill | skill:verbatim | | analyzed | Six-phase procedural discipline run inline; no isolation or special permissions needed. |
|
||||||
|
| domain-modeling | eng | | skill | skill:verbatim | | analyzed | Interactive writing discipline + bundled format files (GLOSSARY/ADR); must run in the main conversation to challenge user wording - an isolated agent would break it. |
|
||||||
|
| grill-with-docs | eng | ✓ | skill | skill:verbatim | grilling, domain-modeling | analyzed | 7-line composition wrapper; OpenCode skill tool loads the two named skills. Preserve verbatim; orchestrator verifies both load (known upstream wrapper failure mode). |
|
||||||
|
| implement | eng | ✓ | skill | skill:verbatim | tdd, code-review | analyzed | Thin single-context per-ticket procedure composing tdd + code-review; the pocock-worker agent embodies its discipline for parallel builds. |
|
||||||
|
| implement-spec | eng | ✓ | orchestrator | skill:verbatim, agent:pocock, agent:pocock-worker | tdd, code-review | analyzed | The repo's clearest orchestrator: task-graph frontier, background implementers in git worktrees, merger, fixer. OpenCode's task tool provides no worktrees, so the pocock agent supplies worktree creation, frontier scheduling from its own merge record, and merges; skill text stays verbatim. |
|
||||||
|
| improve-codebase-architecture | eng | ✓ | skill | skill:verbatim | codebase-design, grilling, domain-modeling | analyzed | Interactive survey-and-grill; its exploration/design-it-twice subagents are internal delegation via task tool, not its identity. |
|
||||||
|
| pr | eng | | skill | skill:verbatim | | analyzed | Pure PR-body template/reference. Verbatim vendoring preserves required attribution (metadata.credits + CREDITS.md, Dex Horthy's show-me). |
|
||||||
|
| prototype | eng | | skill | skill:verbatim | | analyzed | Generation procedure with two branch docs (LOGIC/UI); user reacts to artifacts in main conversation. |
|
||||||
|
| research | eng | | skill | skill:verbatim | | analyzed | The 12-line skill IS a background-agent brief; OpenCode's built-in general subagent + background:true executes it as written. Dedicated pocock-researcher agent evaluated and REJECTED (D8): the brief is self-contained, a branded agent adds drift risk and no capability. |
|
||||||
|
| retro | eng | ✓ | skill | skill:verbatim | writing-for-agents | analyzed | Analysis over the current session's history - isolating it in a subagent would starve it of the session context it mines. |
|
||||||
|
| setup-matt-pocock-skills | eng | ✓ | skill | skill:verbatim | | analyzed | Interactive per-repo scaffolding + seed assets; it creates the docs/agents/* state that to-spec/to-tickets/triage/implement/implement-spec/code-review/wayfinder hard-depend on. Keep verbatim; README flags it as required first run. |
|
||||||
|
| tdd | eng | | skill | skill:verbatim | codebase-design | analyzed | The reusable build discipline; consumed by implement and every pocock-worker via skill allow-list. |
|
||||||
|
| to-spec | eng | ✓ | skill | skill:verbatim | | analyzed | Synthesis + template + publish procedure; explicitly no interview, needs main-conversation context (grilling output). |
|
||||||
|
| to-tickets | eng | ✓ | skill | skill:verbatim | | analyzed | Decomposition with human approval loop; needs the spec conversation in context. |
|
||||||
|
| triage | eng | ✓ | skill | skill:verbatim | grilling, domain-modeling | analyzed | Maintainer-driven interactive state machine; heavy human-in-the-loop design fits a skill. A dedicated triage agent was considered and rejected: every step waits on the maintainer. |
|
||||||
|
| wayfinder | eng | ✓ | skill | skill:verbatim | grilling, domain-modeling, research, prototype | analyzed | Stateful planning protocol over the tracker (map/fog/frontier); its research dispatches use the research skill + built-in subagents. |
|
||||||
|
| wizard | eng | | skill | skill:verbatim | | analyzed | Code generator with bundled template.sh asset; the generated artifact is a human-run script, no harness integration needed. |
|
||||||
|
| grill-me | prod | ✓ | skill | skill:verbatim | grilling | analyzed | 7-line stateless wrapper around grilling. |
|
||||||
|
| grilling | prod | | skill | skill:verbatim | | analyzed | The interview primitive the whole methodology builds on; 100% human interaction in the main conversation - converting to an agent would make it worse (isolated context can't grill the user). Fact-finding subagents dispatch via task tool. |
|
||||||
|
| handoff | prod | ✓ | skill | skill:verbatim | | analyzed | Document-generation instructions writing to OS temp dir. |
|
||||||
|
| teach | prod | ✓ | skill | skill:verbatim | | analyzed | Stateful multi-session tutor with bundled format files; workspace state lives in files, so no agent isolation needed. A tutor agent was considered and rejected: continuous human dialogue belongs in the primary conversation. |
|
||||||
|
| to-questionnaire | prod | ✓ | skill | skill:verbatim | | analyzed | Two structured interviews + document template. |
|
||||||
|
| wait-what | prod | ✓ | skill | skill:verbatim | | analyzed | 7-line corrective re-pitch instruction, usable mid-any-skill. |
|
||||||
|
| writing-for-agents | prod | | skill | skill:verbatim | | analyzed | Pure theory reference; the most instructions-only skill in the repo. |
|
||||||
|
| git-guardrails-claude-code | misc | | plugin | skill:verbatim, plugin:guardrails | | analyzed | Only skill needing executable integration: a Claude Code PreToolUse hook. OpenCode equivalent = opt-in ctx.tool.hook('execute.before') on shell inside our plugin (D7), default off, porting the bundled block-dangerous-git.sh pattern list. Skill text stays vendored verbatim for reference/fidelity. |
|
||||||
|
| migrate-to-shoehorn | misc | | skill | skill:verbatim | | analyzed | Mechanical codemod recipe. Frozen misc bucket - vendored as-is. |
|
||||||
|
| scaffold-exercises | misc | | skill | skill:verbatim | | analyzed | Environment-bound: hard-depends on Matt's private ai-hero-cli, only works in his course repos. Vendored verbatim with caveat noted in mapping doc; no OpenCode artifact can fix an external private tool. |
|
||||||
|
| setup-pre-commit | misc | | skill | skill:verbatim | | analyzed | Setup recipe, npm ecosystem only. Frozen misc bucket - vendored as-is. |
|
||||||
|
| chief-of-staff | in-prog | ✓ | orchestrator | excluded | | analyzed | EXCLUDED per D6 (in-progress beta). Would map to a coordinator persona over background subagents; revisit only if upstream promotes it. |
|
||||||
|
| claude-handoff | in-prog | ✓ | not-convertible | excluded | handoff | analyzed | EXCLUDED per D6 + harness-bound: hard-depends on Claude CLI --bg/agents launcher. OpenCode analogue would need its own background-session mechanism; handoff skill covers the portable half. |
|
||||||
|
| loop-me | in-prog | ✓ | skill | excluded | grilling | analyzed | EXCLUDED per D6 (in-progress). Grilling + workflows/*.md workspace convention; converts trivially if promoted. |
|
||||||
|
| setup-ts-deep-modules | in-prog | ✓ | skill | excluded | codebase-design | analyzed | EXCLUDED per D6 (in-progress). Dependency-cruiser setup with bundled config + prove-it-bites self-check; converts cleanly if promoted. |
|
||||||
|
| writing-beats | in-prog | ✓ | skill | excluded | writing-fragments | analyzed | EXCLUDED per D6 (in-progress). |
|
||||||
|
| writing-fragments | in-prog | ✓ | skill | excluded | grilling | analyzed | EXCLUDED per D6 (in-progress). |
|
||||||
|
| writing-shape | in-prog | ✓ | skill | excluded | writing-fragments | analyzed | EXCLUDED per D6 (in-progress). |
|
||||||
|
|
||||||
|
<!-- matrix:end -->
|
||||||
|
|
||||||
|
## Cross-cutting notes for the conversion
|
||||||
|
|
||||||
|
- **Hard dependency chain**: `setup-matt-pocock-skills` writes `docs/agents/{issue-tracker,domain,
|
||||||
|
triage-labels}.md` + the `## Agent skills` block; to-spec, to-tickets, triage, implement,
|
||||||
|
implement-spec, code-review, wayfinder all break without it. README + pocock agent must flag it.
|
||||||
|
- **Wrapper semantics**: grill-me/grill-with-docs/wait-what are 7-line compositions relying on
|
||||||
|
cross-skill invocation ("Call the Skill tool with X"). OpenCode's skill tool loads by name — the
|
||||||
|
loading agent must load both named skills itself (upstream docs report wrappers failing to chain;
|
||||||
|
pocock agent verifies).
|
||||||
|
- **Invariant**: user-invoked skills are never callable from other skills upstream; V2's
|
||||||
|
`autoinvoke: false` reproduces exactly this (hidden from model, loadable by human via slash).
|
||||||
|
- **Frontmatter census**: only `name`, `description`, `disable-model-invocation`, `argument-hint`
|
||||||
|
(4 skills), `metadata.credits` (pr) exist upstream — no allowed-tools/model/context fields, so all
|
||||||
|
permission/isolation design is ours (authored fresh in agent templates, not translated).
|
||||||
|
- **`agents/openai.yaml`** in every skill dir is Codex UI metadata (display_name, short_description,
|
||||||
|
policy mirroring DMI) — stripped from the generated OpenCode tree by the generator.
|
||||||
|
- **17 pending upstream changesets** (patch) target code-review, to-tickets, wayfinder, wizard, tdd,
|
||||||
|
teach, implement, grilling, handoff, diagnosing-bugs, ask-matt, setup — the next upstream release
|
||||||
|
will touch ~1/3 of the vendored skills; the nightly sync + drift tests are the safety net.
|
||||||
|
- **scaffold-exercises** only works in Matt's course repos (private `ai-hero-cli`); vendored for
|
||||||
|
fidelity, documented as environment-bound.
|
||||||
+219
@@ -0,0 +1,219 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"id": "ask-matt",
|
||||||
|
"name": "ask-matt",
|
||||||
|
"description": "Ask which skill or flow fits your situation. A router over the skills in this repo.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/ask-matt/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "code-review",
|
||||||
|
"name": "code-review",
|
||||||
|
"description": "Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to \"review since X\".",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/code-review/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "codebase-design",
|
||||||
|
"name": "codebase-design",
|
||||||
|
"description": "Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/codebase-design/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "diagnosing-bugs",
|
||||||
|
"name": "diagnosing-bugs",
|
||||||
|
"description": "Diagnosis loop for hard bugs and performance regressions. Use when the user says \"diagnose\"/\"debug this\", or reports something broken/throwing/failing/slow.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/diagnosing-bugs/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "domain-modeling",
|
||||||
|
"name": "domain-modeling",
|
||||||
|
"description": "Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/domain-modeling/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "git-guardrails-claude-code",
|
||||||
|
"name": "git-guardrails-claude-code",
|
||||||
|
"description": "Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/git-guardrails-claude-code/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "grill-me",
|
||||||
|
"name": "grill-me",
|
||||||
|
"description": "A relentless interview to sharpen a plan or design.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/grill-me/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "grill-with-docs",
|
||||||
|
"name": "grill-with-docs",
|
||||||
|
"description": "A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/grill-with-docs/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "grilling",
|
||||||
|
"name": "grilling",
|
||||||
|
"description": "Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/grilling/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "handoff",
|
||||||
|
"name": "handoff",
|
||||||
|
"description": "Compact the current conversation into a handoff document for another agent to pick up.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/handoff/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "implement",
|
||||||
|
"name": "implement",
|
||||||
|
"description": "Implement a piece of work based on a spec or set of tickets.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/implement/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "implement-spec",
|
||||||
|
"name": "implement-spec",
|
||||||
|
"description": "Implement the result of /to-spec and /to-tickets in code.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/implement-spec/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "improve-codebase-architecture",
|
||||||
|
"name": "improve-codebase-architecture",
|
||||||
|
"description": "Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/improve-codebase-architecture/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "migrate-to-shoehorn",
|
||||||
|
"name": "migrate-to-shoehorn",
|
||||||
|
"description": "Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/migrate-to-shoehorn/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "pr",
|
||||||
|
"name": "pr",
|
||||||
|
"description": "Use when writing a PR body.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/pr/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "prototype",
|
||||||
|
"name": "prototype",
|
||||||
|
"description": "Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/prototype/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "research",
|
||||||
|
"name": "research",
|
||||||
|
"description": "Investigate a question against high-trust primary sources and capture the findings as a Markdown file in the repo. Use when the user wants a topic researched, docs or API facts gathered, or reading legwork delegated to a background agent.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/research/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "retro",
|
||||||
|
"name": "retro",
|
||||||
|
"description": "Conduct a retrospective on a coding session.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/retro/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "scaffold-exercises",
|
||||||
|
"name": "scaffold-exercises",
|
||||||
|
"description": "Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/scaffold-exercises/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "setup-matt-pocock-skills",
|
||||||
|
"name": "setup-matt-pocock-skills",
|
||||||
|
"description": "Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/setup-matt-pocock-skills/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "setup-pre-commit",
|
||||||
|
"name": "setup-pre-commit",
|
||||||
|
"description": "Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/setup-pre-commit/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "tdd",
|
||||||
|
"name": "tdd",
|
||||||
|
"description": "Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions \"red-green-refactor\", or wants integration tests.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/tdd/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "teach",
|
||||||
|
"name": "teach",
|
||||||
|
"description": "Teach the user a new skill or concept, within this workspace.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/teach/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "to-questionnaire",
|
||||||
|
"name": "to-questionnaire",
|
||||||
|
"description": "Turn a decision you can't fully answer into a questionnaire for someone else to fill in.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/to-questionnaire/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "to-spec",
|
||||||
|
"name": "to-spec",
|
||||||
|
"description": "Turn the current conversation into a spec and publish it to the project issue tracker: no interview, just synthesis of what you've already discussed.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/to-spec/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "to-tickets",
|
||||||
|
"name": "to-tickets",
|
||||||
|
"description": "Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker (edges as text in one file per ticket locally, or native blocking links on a real tracker).",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/to-tickets/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "triage",
|
||||||
|
"name": "triage",
|
||||||
|
"description": "Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/triage/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "wait-what",
|
||||||
|
"name": "wait-what",
|
||||||
|
"description": "Stop. That last message did not land: re-pitch it.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/wait-what/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "wayfinder",
|
||||||
|
"name": "wayfinder",
|
||||||
|
"description": "Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.",
|
||||||
|
"autoinvoke": false,
|
||||||
|
"path": "skills/wayfinder/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "wizard",
|
||||||
|
"name": "wizard",
|
||||||
|
"description": "Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/wizard/SKILL.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "writing-for-agents",
|
||||||
|
"name": "writing-for-agents",
|
||||||
|
"description": "Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.",
|
||||||
|
"autoinvoke": true,
|
||||||
|
"path": "skills/writing-for-agents/SKILL.md"
|
||||||
|
}
|
||||||
|
]
|
||||||
Generated
+3997
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@haylan/opencode-pocock",
|
||||||
|
"version": "0.0.0-dev",
|
||||||
|
"description": "OpenCode v2 plugin and agents running Matt Pocock's skill-driven engineering flow: skills injected verbatim, orchestrator/worker/reviewer agents, nightly upstream sync",
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"default": "./dist/index.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"opencode-pocock": "./dist/init.js"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist",
|
||||||
|
"skills",
|
||||||
|
"agents",
|
||||||
|
"manifest.json",
|
||||||
|
"NOTICE"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": ">=22.18"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"format": "prettier --write .",
|
||||||
|
"check": "prettier --check . && tsc --noEmit",
|
||||||
|
"test": "node --test",
|
||||||
|
"sync": "node scripts/sync-upstream.ts",
|
||||||
|
"generate": "node scripts/generate.ts",
|
||||||
|
"smoke": "node scripts/smoke.ts"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.arthurerlich.de/haylan/mattpocock-skills-opencode.git"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@opencode/plugin": "^2.0.29"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^26.6.4",
|
||||||
|
"prettier": "^3.9.9",
|
||||||
|
"typescript": "^7.0.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,176 @@
|
|||||||
|
// Regenerates the OpenCode artifacts from the pristine upstream snapshot:
|
||||||
|
//
|
||||||
|
// node scripts/generate.ts
|
||||||
|
//
|
||||||
|
// Inputs: upstream/skills/** + .opencode/state/classification.json
|
||||||
|
// Outputs: skills/<name>/** (verbatim, minus agents/openai.yaml; only skills whose
|
||||||
|
// classification artifacts include "skill:verbatim")
|
||||||
|
// manifest.json (plugin-injection manifest: id/name/description/autoinvoke/path)
|
||||||
|
// docs/skill-mapping.md matrix section (between <!-- matrix:start/end --> markers)
|
||||||
|
//
|
||||||
|
// Deterministic: same inputs produce byte-identical outputs, so the nightly git diff is the
|
||||||
|
// affected-set report. Never hand-edit skills/ or the matrix section.
|
||||||
|
import {
|
||||||
|
cpSync,
|
||||||
|
existsSync,
|
||||||
|
readFileSync,
|
||||||
|
readdirSync,
|
||||||
|
rmSync,
|
||||||
|
statSync,
|
||||||
|
writeFileSync,
|
||||||
|
} from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import { isUserInvoked, parseFrontmatter } from "../src/frontmatter.ts"
|
||||||
|
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
|
||||||
|
export type ClassificationEntry = {
|
||||||
|
name: string
|
||||||
|
bucket: string
|
||||||
|
classification: string
|
||||||
|
user_invoked: boolean
|
||||||
|
artifacts: string[]
|
||||||
|
depends_on: string[]
|
||||||
|
status: string
|
||||||
|
rationale: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ManifestEntry = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
autoinvoke: boolean
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadClassification(file: string): ClassificationEntry[] {
|
||||||
|
const doc = JSON.parse(readFileSync(file, "utf8"))
|
||||||
|
return doc.skills as ClassificationEntry[]
|
||||||
|
}
|
||||||
|
|
||||||
|
function copySkillDir(from: string, to: string) {
|
||||||
|
rmSync(to, { recursive: true, force: true })
|
||||||
|
cpSync(from, to, {
|
||||||
|
recursive: true,
|
||||||
|
filter: (src) => {
|
||||||
|
// strip Codex UI metadata dir; everything else ships verbatim
|
||||||
|
const rel = path.relative(from, src)
|
||||||
|
return rel !== "agents" && !rel.startsWith("agents" + path.sep)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function buildSkills(opts: {
|
||||||
|
upstreamSkills: string
|
||||||
|
entries: ClassificationEntry[]
|
||||||
|
skillsOut: string
|
||||||
|
}): ManifestEntry[] {
|
||||||
|
const vendored = opts.entries.filter((e) => e.artifacts.includes("skill:verbatim"))
|
||||||
|
const seen = new Set<string>()
|
||||||
|
const manifest: ManifestEntry[] = []
|
||||||
|
rmSync(opts.skillsOut, { recursive: true, force: true })
|
||||||
|
|
||||||
|
for (const entry of vendored) {
|
||||||
|
if (seen.has(entry.name)) throw new Error(`duplicate skill name across buckets: ${entry.name}`)
|
||||||
|
seen.add(entry.name)
|
||||||
|
const from = path.join(opts.upstreamSkills, entry.bucket, entry.name)
|
||||||
|
const skillMd = path.join(from, "SKILL.md")
|
||||||
|
if (!existsSync(skillMd)) {
|
||||||
|
throw new Error(`classified skill missing upstream: ${entry.bucket}/${entry.name}`)
|
||||||
|
}
|
||||||
|
const to = path.join(opts.skillsOut, entry.name)
|
||||||
|
copySkillDir(from, to)
|
||||||
|
|
||||||
|
const { frontmatter } = parseFrontmatter(readFileSync(skillMd, "utf8"))
|
||||||
|
const name = frontmatter.name || entry.name
|
||||||
|
const description = frontmatter.description
|
||||||
|
if (!frontmatter.name || !description) {
|
||||||
|
throw new Error(`${entry.name}: SKILL.md frontmatter needs name and description`)
|
||||||
|
}
|
||||||
|
manifest.push({
|
||||||
|
id: entry.name,
|
||||||
|
name,
|
||||||
|
description,
|
||||||
|
autoinvoke: !isUserInvoked(frontmatter),
|
||||||
|
path: `skills/${entry.name}/SKILL.md`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// fail on upstream skills nobody classified (sync-upstream normally adds needs-review entries)
|
||||||
|
for (const bucket of existsSync(opts.upstreamSkills) ? readdirSync(opts.upstreamSkills) : []) {
|
||||||
|
const bucketPath = path.join(opts.upstreamSkills, bucket)
|
||||||
|
if (!statSync(bucketPath).isDirectory()) continue
|
||||||
|
for (const name of readdirSync(bucketPath)) {
|
||||||
|
if (!existsSync(path.join(bucketPath, name, "SKILL.md"))) continue
|
||||||
|
if (!opts.entries.some((e) => e.name === name)) {
|
||||||
|
throw new Error(`unclassified upstream skill: ${bucket}/${name} — run sync + review`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
manifest.sort((a, b) => a.id.localeCompare(b.id))
|
||||||
|
return manifest
|
||||||
|
}
|
||||||
|
|
||||||
|
const BUCKET_SHORT: Record<string, string> = {
|
||||||
|
engineering: "eng",
|
||||||
|
productivity: "prod",
|
||||||
|
misc: "misc",
|
||||||
|
"in-progress": "in-prog",
|
||||||
|
deprecated: "dep",
|
||||||
|
}
|
||||||
|
|
||||||
|
const cell = (value: string) => value.replace(/\|/g, "\\|")
|
||||||
|
|
||||||
|
export function renderMatrix(entries: ClassificationEntry[]): string {
|
||||||
|
const lines = [
|
||||||
|
"| Upstream skill | Bucket | DMI | Classification | Artifacts | Depends on | Status | Rationale |",
|
||||||
|
"| --- | --- | --- | --- | --- | --- | --- | --- |",
|
||||||
|
]
|
||||||
|
for (const e of entries) {
|
||||||
|
lines.push(
|
||||||
|
`| ${e.name} | ${BUCKET_SHORT[e.bucket] ?? e.bucket} | ${e.user_invoked ? "✓" : ""} | ` +
|
||||||
|
`${e.classification} | ${cell(e.artifacts.join(", "))} | ${cell(e.depends_on.join(", "))} | ` +
|
||||||
|
`${e.status} | ${cell(e.rationale)} |`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return lines.join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateDocMatrix(docPath: string, matrix: string): void {
|
||||||
|
const doc = readFileSync(docPath, "utf8")
|
||||||
|
const start = "<!-- matrix:start -->"
|
||||||
|
const end = "<!-- matrix:end -->"
|
||||||
|
const i = doc.indexOf(start)
|
||||||
|
const j = doc.indexOf(end)
|
||||||
|
if (i === -1 || j === -1 || j < i) throw new Error(`${docPath}: missing matrix markers`)
|
||||||
|
writeFileSync(docPath, `${doc.slice(0, i + start.length)}\n\n${matrix}\n\n${doc.slice(j)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const classificationPath = path.join(root, ".opencode/state/classification.json")
|
||||||
|
const docPath = path.join(root, "docs/skill-mapping.md")
|
||||||
|
const entries = loadClassification(classificationPath)
|
||||||
|
const manifest = buildSkills({
|
||||||
|
upstreamSkills: path.join(root, "upstream/skills"),
|
||||||
|
entries,
|
||||||
|
skillsOut: path.join(root, "skills"),
|
||||||
|
})
|
||||||
|
writeFileSync(path.join(root, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n")
|
||||||
|
updateDocMatrix(docPath, renderMatrix(entries))
|
||||||
|
const needsReview = entries.filter((e) => e.status === "needs-review").map((e) => e.name)
|
||||||
|
console.log(
|
||||||
|
`generated ${manifest.length} skills (${manifest.filter((m) => !m.autoinvoke).length} hidden from model), manifest.json, matrix in docs/skill-mapping.md` +
|
||||||
|
(needsReview.length ? `\nWARNING needs-review: ${needsReview.join(", ")}` : ""),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
try {
|
||||||
|
main()
|
||||||
|
} catch (err) {
|
||||||
|
console.error((err as Error).message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,150 @@
|
|||||||
|
// Publishes the latest CHANGELOG.md version to the Gitea npm registry without `npm publish`, tags
|
||||||
|
// the commit `v<version>` and links the package to this repository. Every step is idempotent, so a
|
||||||
|
// rerun repairs a release that is only partly done. (Adapted from fastcrw-opencode-websearch.)
|
||||||
|
// Env: SERVER_URL, REPOSITORY (owner/repo), SHA (from the workflow), TOKEN (needs write:package
|
||||||
|
// and write:repository).
|
||||||
|
import { execFileSync } from "node:child_process"
|
||||||
|
import { createHash } from "node:crypto"
|
||||||
|
import { cpSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import { latestVersion } from "./version.ts"
|
||||||
|
|
||||||
|
export { latestVersion }
|
||||||
|
|
||||||
|
export const encodeName = (name: string) => name.replace("/", "%2F")
|
||||||
|
|
||||||
|
export const isPublished = (packument: { versions?: Record<string, unknown> }, version: string) =>
|
||||||
|
Boolean(packument.versions?.[version])
|
||||||
|
|
||||||
|
export function publishBody(pkg: { name: string; version: string }, tarball: Buffer): object {
|
||||||
|
const { name, version } = pkg
|
||||||
|
const file = `${name}-${version}.tgz`
|
||||||
|
return {
|
||||||
|
_id: name,
|
||||||
|
name,
|
||||||
|
"dist-tags": { latest: version },
|
||||||
|
versions: {
|
||||||
|
[version]: {
|
||||||
|
...pkg,
|
||||||
|
_id: `${name}@${version}`,
|
||||||
|
dist: {
|
||||||
|
shasum: createHash("sha1").update(tarball).digest("hex"),
|
||||||
|
integrity: `sha512-${createHash("sha512").update(tarball).digest("base64")}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
_attachments: {
|
||||||
|
[file]: {
|
||||||
|
content_type: "application/octet-stream",
|
||||||
|
data: tarball.toString("base64"),
|
||||||
|
length: tarball.length,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type Api = { base: string; headers: Record<string, string>; fetchFn?: typeof fetch }
|
||||||
|
|
||||||
|
async function call(api: Api, method: string, path: string, body?: object) {
|
||||||
|
return (api.fetchFn ?? fetch)(`${api.base}${path}`, {
|
||||||
|
method,
|
||||||
|
headers: { ...api.headers, "Content-Type": "application/json" },
|
||||||
|
body: body && JSON.stringify(body),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const fail = async (what: string, res: Response) =>
|
||||||
|
new Error(`${what} failed: ${res.status} ${await res.text()}`)
|
||||||
|
|
||||||
|
export async function ensureTag(api: Api, repo: string, version: string, sha: string) {
|
||||||
|
const tag = `v${version}`
|
||||||
|
const existing = await call(api, "GET", `/repos/${repo}/tags/${tag}`)
|
||||||
|
if (existing.ok) return "exists"
|
||||||
|
if (existing.status !== 404) throw await fail("tag lookup", existing)
|
||||||
|
const res = await call(api, "POST", `/repos/${repo}/tags`, {
|
||||||
|
tag_name: tag,
|
||||||
|
target: sha,
|
||||||
|
message: `Release ${version}`,
|
||||||
|
})
|
||||||
|
if (!res.ok) throw await fail("tag creation", res)
|
||||||
|
return "created"
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function ensureLinked(
|
||||||
|
api: Api,
|
||||||
|
owner: string,
|
||||||
|
name: string,
|
||||||
|
version: string,
|
||||||
|
repoName: string,
|
||||||
|
) {
|
||||||
|
const pkg = `/packages/${owner}/npm/${encodeURIComponent(name)}`
|
||||||
|
const existing = await call(api, "GET", `${pkg}/${version}`)
|
||||||
|
if (!existing.ok) throw await fail("package lookup", existing)
|
||||||
|
if (((await existing.json()) as { repository?: unknown }).repository) return "already linked"
|
||||||
|
const res = await call(api, "POST", `${pkg}/-/link/${repoName}`)
|
||||||
|
if (!res.ok) throw await fail("package link", res)
|
||||||
|
return "linked"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Everything the published tarball must contain (mirrors package.json "files" + metadata).
|
||||||
|
const STAGED = ["dist", "skills", "agents", "manifest.json", "README.md", "LICENSE", "NOTICE"]
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const { SERVER_URL, REPOSITORY, SHA, TOKEN: token } = process.env
|
||||||
|
if (!SERVER_URL || !REPOSITORY || !SHA || !token) {
|
||||||
|
throw new Error("SERVER_URL, REPOSITORY, SHA and TOKEN must be set")
|
||||||
|
}
|
||||||
|
const [owner, repoName] = REPOSITORY.split("/")
|
||||||
|
const server = SERVER_URL.replace(/\/+$/, "")
|
||||||
|
const registry = `${server}/api/packages/${owner}/npm`
|
||||||
|
|
||||||
|
const version = latestVersion(readFileSync("CHANGELOG.md", "utf8"))
|
||||||
|
// The version is rewritten in the staged copy only; the repo keeps its dev version.
|
||||||
|
const pkg = { ...JSON.parse(readFileSync("package.json", "utf8")), version }
|
||||||
|
const url = `${registry}/${encodeName(pkg.name)}`
|
||||||
|
const headers = { Authorization: `Bearer ${token}` }
|
||||||
|
|
||||||
|
const existing = await fetch(url, { headers })
|
||||||
|
if (existing.ok && isPublished(await existing.json(), version)) {
|
||||||
|
console.log(`${pkg.name}@${version} is already published, skipping publish`)
|
||||||
|
} else if (!existing.ok && existing.status !== 404) {
|
||||||
|
throw new Error(`registry lookup failed: ${existing.status} ${await existing.text()}`)
|
||||||
|
} else {
|
||||||
|
await publish(pkg, url, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
const api = { base: `${server}/api/v1`, headers }
|
||||||
|
console.log(`tag v${version}: ${await ensureTag(api, REPOSITORY, version, SHA)}`)
|
||||||
|
console.log(`package link: ${await ensureLinked(api, owner, pkg.name, version, repoName)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function publish(
|
||||||
|
pkg: { name: string; version: string },
|
||||||
|
url: string,
|
||||||
|
headers: Record<string, string>,
|
||||||
|
) {
|
||||||
|
const { version } = pkg
|
||||||
|
rmSync(".release", { recursive: true, force: true })
|
||||||
|
mkdirSync(".release/package", { recursive: true })
|
||||||
|
writeFileSync(".release/package/package.json", JSON.stringify(pkg, null, 2))
|
||||||
|
for (const item of STAGED) {
|
||||||
|
cpSync(item, `.release/package/${item}`, { recursive: true })
|
||||||
|
}
|
||||||
|
execFileSync("tar", ["-czf", "package.tgz", "-C", ".release", "package"], { cwd: "." })
|
||||||
|
const tarball = readFileSync("package.tgz")
|
||||||
|
|
||||||
|
const res = await fetch(url, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: { ...headers, "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(publishBody(pkg, tarball)),
|
||||||
|
})
|
||||||
|
if (!res.ok) throw new Error(`publish failed: ${res.status} ${await res.text()}`)
|
||||||
|
console.log(`published ${pkg.name}@${version}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error(err.message)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
// Runtime smoke test against a real `opencode serve` (v2). No model calls, no tokens spent.
|
||||||
|
//
|
||||||
|
// npm run build && node scripts/smoke.ts [--keep]
|
||||||
|
//
|
||||||
|
// Builds a temp fixture project whose opencode.json loads this repo's dist/ directory as a local
|
||||||
|
// plugin (local plugin entries must be DIRECTORIES with a root index file; file entries are
|
||||||
|
// ignored), installs the agents with our own init, boots a private server, and asserts over the
|
||||||
|
// HTTP API (Basic auth user `opencode`, password printed by serve):
|
||||||
|
// - plugin haylan.pocock reaches state.status "active"
|
||||||
|
// - every manifest skill id is registered and user-invoked ones have autoinvoke=false
|
||||||
|
// - agents pocock (primary), pocock-worker / pocock-reviewer (subagent) are discovered and the
|
||||||
|
// worker's skill deny + allow-list survived frontmatter decoding
|
||||||
|
// Env: OPENCODE_BIN (default "opencode"), SMOKE_PORT (default random).
|
||||||
|
import { spawn, spawnSync } from "node:child_process"
|
||||||
|
import { mkdtempSync, rmSync, writeFileSync, mkdirSync, existsSync } from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import { runInit } from "../src/init.ts"
|
||||||
|
import { loadManifest, packageRoot } from "../src/manifest.ts"
|
||||||
|
|
||||||
|
const BIN = process.env.OPENCODE_BIN ?? "opencode"
|
||||||
|
const PORT = Number(process.env.SMOKE_PORT ?? 40000 + Math.floor(Math.random() * 20000))
|
||||||
|
const BASE = `http://127.0.0.1:${PORT}`
|
||||||
|
|
||||||
|
function assert(condition: unknown, message: string): asserts condition {
|
||||||
|
if (!condition) throw new Error(`smoke FAIL: ${message}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function waitReady(timeoutMs = 90_000): Promise<void> {
|
||||||
|
const deadline = Date.now() + timeoutMs
|
||||||
|
while (Date.now() < deadline) {
|
||||||
|
try {
|
||||||
|
const res = await fetch(BASE + "/")
|
||||||
|
if (res.ok) return
|
||||||
|
} catch {
|
||||||
|
/* not up yet */
|
||||||
|
}
|
||||||
|
await new Promise((r) => setTimeout(r, 500))
|
||||||
|
}
|
||||||
|
throw new Error("smoke FAIL: server did not come up in time")
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
if (!existsSync(path.join(packageRoot, "dist", "index.js"))) {
|
||||||
|
throw new Error("smoke FAIL: dist/index.js missing - run `npm run build` first")
|
||||||
|
}
|
||||||
|
const manifest = loadManifest()
|
||||||
|
const fixture = mkdtempSync(path.join(tmpdir(), "pocock-smoke-"))
|
||||||
|
let server: ReturnType<typeof spawn> | undefined
|
||||||
|
let out = ""
|
||||||
|
try {
|
||||||
|
mkdirSync(path.join(fixture, ".opencode"), { recursive: true })
|
||||||
|
writeFileSync(
|
||||||
|
path.join(fixture, "opencode.json"),
|
||||||
|
JSON.stringify(
|
||||||
|
{ $schema: "https://opencode.ai/config.json", plugins: [path.join(packageRoot, "dist")] },
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
runInit({ argv: ["init"], cwd: fixture, pkgRoot: packageRoot })
|
||||||
|
|
||||||
|
server = spawn(BIN, ["serve", "--hostname", "127.0.0.1", "--port", String(PORT)], {
|
||||||
|
cwd: fixture,
|
||||||
|
stdio: ["ignore", "pipe", "pipe"],
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
})
|
||||||
|
const collect = (chunk: Buffer) => (out += chunk.toString())
|
||||||
|
server.stdout?.on("data", collect)
|
||||||
|
server.stderr?.on("data", collect)
|
||||||
|
await waitReady()
|
||||||
|
|
||||||
|
const pw = /server password (\S+)/.exec(out)?.[1]
|
||||||
|
assert(pw, `server password not found in output:\n${out.slice(0, 400)}`)
|
||||||
|
const auth = { Authorization: "Basic " + Buffer.from(`opencode:${pw}`).toString("base64") }
|
||||||
|
const get = async (p: string) => {
|
||||||
|
const res = await fetch(BASE + "/api" + p, { headers: auth })
|
||||||
|
assert(res.ok, `GET /api${p} -> ${res.status}`)
|
||||||
|
return res.json() as Promise<{ data?: unknown } & Record<string, unknown>>
|
||||||
|
}
|
||||||
|
|
||||||
|
// Plugin loads (lazy: poll until it appears)
|
||||||
|
let plugin: { id: string; state?: { status?: string } } | undefined
|
||||||
|
const deadline = Date.now() + 60_000
|
||||||
|
while (!plugin && Date.now() < deadline) {
|
||||||
|
const body = (await get("/plugin")) as { data: { id: string; state?: { status: string } }[] }
|
||||||
|
plugin = body.data.find((p) => p.id === "haylan.pocock")
|
||||||
|
if (!plugin) await new Promise((r) => setTimeout(r, 1000))
|
||||||
|
}
|
||||||
|
assert(plugin, "plugin haylan.pocock never appeared in /api/plugin")
|
||||||
|
assert(plugin!.state?.status === "active", `plugin state: ${JSON.stringify(plugin!.state)}`)
|
||||||
|
console.log("ok plugin haylan.pocock active")
|
||||||
|
|
||||||
|
// Skills registered with correct autoinvoke flags (ids may also exist from global installs)
|
||||||
|
const skillBody = (await get("/skill")) as { data: { id: string; autoinvoke?: boolean }[] }
|
||||||
|
const byId = new Map(skillBody.data.map((s) => [s.id, s]))
|
||||||
|
for (const entry of manifest) {
|
||||||
|
const found = byId.get(entry.id)
|
||||||
|
assert(found, `skill '${entry.id}' not registered`)
|
||||||
|
// the API omits autoinvoke when it defaults to true
|
||||||
|
const actual = found!.autoinvoke ?? true
|
||||||
|
assert(
|
||||||
|
actual === entry.autoinvoke,
|
||||||
|
`skill '${entry.id}' autoinvoke=${actual}, want ${entry.autoinvoke}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`ok ${manifest.length} skills registered (${manifest.filter((m) => !m.autoinvoke).length} hidden from model)`,
|
||||||
|
)
|
||||||
|
|
||||||
|
// Agents discovered with correct modes and the worker's permission decoding intact
|
||||||
|
const agentBody = (await get("/agent")) as {
|
||||||
|
data: {
|
||||||
|
id: string
|
||||||
|
mode: string
|
||||||
|
permissions: { action: string; resource: string; effect: string }[]
|
||||||
|
}[]
|
||||||
|
}
|
||||||
|
const agents = new Map(agentBody.data.map((a) => [a.id, a]))
|
||||||
|
assert(agents.get("pocock")?.mode === "primary", "pocock is not primary")
|
||||||
|
assert(agents.get("pocock-reviewer")?.mode === "subagent", "pocock-reviewer is not subagent")
|
||||||
|
const worker = agents.get("pocock-worker")
|
||||||
|
assert(worker?.mode === "subagent", "pocock-worker is not subagent")
|
||||||
|
const rules = worker!.permissions
|
||||||
|
const has = (action: string, resource: string, effect: string) =>
|
||||||
|
rules.some((r) => r.action === action && r.resource === resource && r.effect === effect)
|
||||||
|
assert(has("skill", "*", "deny"), "worker skill deny * missing")
|
||||||
|
assert(has("skill", "tdd", "allow"), "worker tdd allow missing")
|
||||||
|
assert(has("shell", "git push*", "deny"), "worker git push deny missing")
|
||||||
|
assert(has("subagent", "*", "deny"), "worker subagent deny missing")
|
||||||
|
console.log("ok agents pocock/pocock-worker/pocock-reviewer with permissions decoded")
|
||||||
|
|
||||||
|
console.log("smoke PASS")
|
||||||
|
} finally {
|
||||||
|
// shell:true on Windows means kill() only reaches cmd.exe; kill the whole tree.
|
||||||
|
if (server?.pid) {
|
||||||
|
if (process.platform === "win32")
|
||||||
|
spawnSync("taskkill", ["/PID", String(server.pid), "/T", "/F"])
|
||||||
|
else server.kill()
|
||||||
|
}
|
||||||
|
// Windows holds locks briefly after kill: retry, and never let cleanup mask the real error.
|
||||||
|
try {
|
||||||
|
if (process.argv.includes("--keep")) console.log(`fixture kept at ${fixture}`)
|
||||||
|
else rmSync(fixture, { recursive: true, force: true, maxRetries: 10, retryDelay: 300 })
|
||||||
|
} catch (cleanupErr) {
|
||||||
|
console.log(`warning: could not remove fixture ${fixture}: ${(cleanupErr as Error).message}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
main()
|
||||||
|
.then(() => process.exit(0))
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err.message)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
// Updates the pristine upstream/ snapshot from mattpocock/skills and records the revision.
|
||||||
|
//
|
||||||
|
// node scripts/sync-upstream.ts [path-to-existing-clone]
|
||||||
|
//
|
||||||
|
// Without a path it shallow-clones https://github.com/mattpocock/skills into a temp dir.
|
||||||
|
// Exits 0 with "no changes" when upstream HEAD equals the recorded commit and the snapshot exists,
|
||||||
|
// so the nightly workflow can stop early. On change it replaces upstream/skills wholesale, writes
|
||||||
|
// upstream/UPSTREAM.json, updates .opencode/state/upstream.json and adds needs-review entries for
|
||||||
|
// new skills in .opencode/state/classification.json, then prints the added/removed/changed skills.
|
||||||
|
import { execFileSync } from "node:child_process"
|
||||||
|
import { createHash } from "node:crypto"
|
||||||
|
import {
|
||||||
|
cpSync,
|
||||||
|
existsSync,
|
||||||
|
mkdtempSync,
|
||||||
|
readFileSync,
|
||||||
|
readdirSync,
|
||||||
|
rmSync,
|
||||||
|
statSync,
|
||||||
|
writeFileSync,
|
||||||
|
} from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
export const UPSTREAM_URL = "https://github.com/mattpocock/skills"
|
||||||
|
const STATE_PATH = path.join(root, ".opencode/state/upstream.json")
|
||||||
|
const CLASSIFICATION_PATH = path.join(root, ".opencode/state/classification.json")
|
||||||
|
const SNAPSHOT_DIR = path.join(root, "upstream")
|
||||||
|
|
||||||
|
export type UpstreamState = {
|
||||||
|
repo: string
|
||||||
|
commit: string
|
||||||
|
commit_date: string
|
||||||
|
upstream_version: string
|
||||||
|
synced_at: string | null
|
||||||
|
note?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Names of skill dirs (those containing SKILL.md) under a skills/ root, as "<bucket>/<name>". */
|
||||||
|
export function listSkillDirs(skillsRoot: string): string[] {
|
||||||
|
const out: string[] = []
|
||||||
|
if (!existsSync(skillsRoot)) return out
|
||||||
|
for (const bucket of readdirSync(skillsRoot).sort()) {
|
||||||
|
const bucketPath = path.join(skillsRoot, bucket)
|
||||||
|
if (!statSync(bucketPath).isDirectory()) continue
|
||||||
|
for (const name of readdirSync(bucketPath).sort()) {
|
||||||
|
if (existsSync(path.join(bucketPath, name, "SKILL.md"))) out.push(`${bucket}/${name}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Deterministic content hash of a directory (sorted relative paths + file bytes). */
|
||||||
|
export function hashDir(dir: string): string {
|
||||||
|
const hash = createHash("sha256")
|
||||||
|
const walk = (d: string, prefix: string) => {
|
||||||
|
for (const entry of readdirSync(d).sort()) {
|
||||||
|
const full = path.join(d, entry)
|
||||||
|
const rel = prefix ? `${prefix}/${entry}` : entry
|
||||||
|
if (statSync(full).isDirectory()) walk(full, rel)
|
||||||
|
else hash.update(rel).update(readFileSync(full))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
walk(dir, "")
|
||||||
|
return hash.digest("hex")
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SnapshotDiff = { added: string[]; removed: string[]; changed: string[] }
|
||||||
|
|
||||||
|
export function diffSnapshots(before: string, after: string): SnapshotDiff {
|
||||||
|
const oldDirs = new Map(
|
||||||
|
listSkillDirs(before).map((s) => [s, hashDir(path.join(before, ...s.split("/")))]),
|
||||||
|
)
|
||||||
|
const newDirs = new Map(
|
||||||
|
listSkillDirs(after).map((s) => [s, hashDir(path.join(after, ...s.split("/")))]),
|
||||||
|
)
|
||||||
|
const diff: SnapshotDiff = { added: [], removed: [], changed: [] }
|
||||||
|
for (const [name, hash] of newDirs) {
|
||||||
|
if (!oldDirs.has(name)) diff.added.push(name)
|
||||||
|
else if (oldDirs.get(name) !== hash) diff.changed.push(name)
|
||||||
|
}
|
||||||
|
for (const name of oldDirs.keys()) if (!newDirs.has(name)) diff.removed.push(name)
|
||||||
|
return diff
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Appends needs-review classification entries for skill dirs missing from classification.json. */
|
||||||
|
export function recordNewSkills(classificationPath: string, added: string[]): string[] {
|
||||||
|
if (added.length === 0) return []
|
||||||
|
const doc = JSON.parse(readFileSync(classificationPath, "utf8"))
|
||||||
|
const known = new Set(doc.skills.map((s: { name: string }) => s.name))
|
||||||
|
const fresh: string[] = []
|
||||||
|
for (const dir of added) {
|
||||||
|
const [bucket, name] = dir.split("/")
|
||||||
|
if (known.has(name)) continue
|
||||||
|
doc.skills.push({
|
||||||
|
name,
|
||||||
|
bucket,
|
||||||
|
classification: "skill",
|
||||||
|
user_invoked: false,
|
||||||
|
artifacts: ["skill:verbatim"],
|
||||||
|
depends_on: [],
|
||||||
|
status: "needs-review",
|
||||||
|
rationale: "New upstream skill; default classification, awaiting human review.",
|
||||||
|
})
|
||||||
|
fresh.push(name)
|
||||||
|
}
|
||||||
|
if (fresh.length) writeFileSync(classificationPath, JSON.stringify(doc, null, 2) + "\n")
|
||||||
|
return fresh
|
||||||
|
}
|
||||||
|
|
||||||
|
function git(cloneDir: string, ...args: string[]): string {
|
||||||
|
return execFileSync("git", ["-C", cloneDir, ...args], { encoding: "utf8" }).trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const existing = process.argv[2]
|
||||||
|
let cloneDir = existing
|
||||||
|
let temp: string | undefined
|
||||||
|
if (!cloneDir) {
|
||||||
|
temp = mkdtempSync(path.join(tmpdir(), "mp-skills-"))
|
||||||
|
cloneDir = path.join(temp, "skills")
|
||||||
|
console.log(`cloning ${UPSTREAM_URL} ...`)
|
||||||
|
execFileSync("git", ["clone", "--quiet", "--depth", "1", UPSTREAM_URL, cloneDir])
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const commit = git(cloneDir, "rev-parse", "HEAD")
|
||||||
|
const commitDate = git(cloneDir, "log", "-1", "--format=%cI")
|
||||||
|
const upstreamPkg = JSON.parse(readFileSync(path.join(cloneDir, "package.json"), "utf8"))
|
||||||
|
|
||||||
|
const recorded: UpstreamState | undefined = existsSync(STATE_PATH)
|
||||||
|
? JSON.parse(readFileSync(STATE_PATH, "utf8"))
|
||||||
|
: undefined
|
||||||
|
if (
|
||||||
|
recorded?.commit === commit &&
|
||||||
|
existsSync(path.join(SNAPSHOT_DIR, "skills")) &&
|
||||||
|
recorded.synced_at
|
||||||
|
) {
|
||||||
|
console.log(`no changes: upstream already at ${commit.slice(0, 9)}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldSkills = path.join(SNAPSHOT_DIR, "skills")
|
||||||
|
const diff = existsSync(oldSkills)
|
||||||
|
? diffSnapshots(oldSkills, path.join(cloneDir, "skills"))
|
||||||
|
: { added: listSkillDirs(path.join(cloneDir, "skills")), removed: [], changed: [] }
|
||||||
|
|
||||||
|
rmSync(oldSkills, { recursive: true, force: true })
|
||||||
|
cpSync(path.join(cloneDir, "skills"), oldSkills, { recursive: true })
|
||||||
|
const meta = {
|
||||||
|
repo: UPSTREAM_URL,
|
||||||
|
commit,
|
||||||
|
commit_date: commitDate,
|
||||||
|
upstream_version: upstreamPkg.version,
|
||||||
|
}
|
||||||
|
writeFileSync(path.join(SNAPSHOT_DIR, "UPSTREAM.json"), JSON.stringify(meta, null, 2) + "\n")
|
||||||
|
const state: UpstreamState & { previous_commit?: string | null; last_diff?: SnapshotDiff } = {
|
||||||
|
...meta,
|
||||||
|
synced_at: new Date().toISOString(),
|
||||||
|
previous_commit: recorded?.commit ?? null,
|
||||||
|
last_diff: diff,
|
||||||
|
}
|
||||||
|
writeFileSync(STATE_PATH, JSON.stringify(state, null, 2) + "\n")
|
||||||
|
|
||||||
|
const fresh = recordNewSkills(CLASSIFICATION_PATH, diff.added)
|
||||||
|
console.log(`synced upstream to ${commit.slice(0, 9)} (${commitDate}), v${upstreamPkg.version}`)
|
||||||
|
console.log(
|
||||||
|
`skills: +${diff.added.length} -${diff.removed.length} ~${diff.changed.length}` +
|
||||||
|
(diff.added.length ? `\n added: ${diff.added.join(", ")}` : "") +
|
||||||
|
(diff.removed.length ? `\n removed: ${diff.removed.join(", ")}` : "") +
|
||||||
|
(diff.changed.length ? `\n changed: ${diff.changed.join(", ")}` : ""),
|
||||||
|
)
|
||||||
|
if (fresh.length) {
|
||||||
|
console.log(`classification: added needs-review entries for ${fresh.join(", ")}`)
|
||||||
|
console.log("NOTE: needs-review entries fail the drift test until reviewed.")
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (temp) rmSync(temp, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
main().catch((err) => {
|
||||||
|
console.error(err.message)
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
// Computes the next package version and prepends the CHANGELOG entry for an upstream sync.
|
||||||
|
// Idempotent: when the changelog already names the target upstream commit, nothing changes.
|
||||||
|
//
|
||||||
|
// node scripts/version.ts [--dry]
|
||||||
|
//
|
||||||
|
// Env/inputs: upstream/UPSTREAM.json (target revision), CHANGELOG.md, .opencode/state/upstream.json.
|
||||||
|
// Rule (decision D4): upstream content change => minor bump; humans write their own entries for
|
||||||
|
// behavior changes; majors are never automatic.
|
||||||
|
import { readFileSync, writeFileSync } from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
|
||||||
|
export function latestVersion(changelog: string): string {
|
||||||
|
const match = changelog.match(/^## \[(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)\]/m)
|
||||||
|
if (!match) throw new Error("no release heading like `## [1.0.0]` found in CHANGELOG.md")
|
||||||
|
return match[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bumpMinor(version: string): string {
|
||||||
|
if (version.includes("-")) return version // prerelease: keep as-is
|
||||||
|
const [major, minor] = version.split(".")
|
||||||
|
return `${major}.${Number(minor) + 1}.0`
|
||||||
|
}
|
||||||
|
|
||||||
|
export type SyncEntry = { version: string; date: string; body: string }
|
||||||
|
|
||||||
|
export function buildEntry(opts: {
|
||||||
|
changelog: string
|
||||||
|
fromCommit: string | null
|
||||||
|
toCommit: string
|
||||||
|
toVersion: string
|
||||||
|
date: string
|
||||||
|
diff: { added: string[]; removed: string[]; changed: string[] }
|
||||||
|
}): SyncEntry | null {
|
||||||
|
const short = opts.toCommit.slice(0, 9)
|
||||||
|
if (opts.changelog.includes(short)) return null // already released this upstream revision
|
||||||
|
const version = bumpMinor(latestVersion(opts.changelog))
|
||||||
|
const lines = [
|
||||||
|
`## [${version}] - ${opts.date}`,
|
||||||
|
"",
|
||||||
|
"### Changed",
|
||||||
|
"",
|
||||||
|
`- Upstream sync: mattpocock/skills \`${opts.fromCommit ? opts.fromCommit.slice(0, 9) : "initial"}\` -> \`${short}\` (upstream v${opts.toVersion}).`,
|
||||||
|
]
|
||||||
|
if (opts.diff.added.length) lines.push(` - added: ${opts.diff.added.join(", ")}`)
|
||||||
|
if (opts.diff.removed.length) lines.push(` - removed: ${opts.diff.removed.join(", ")}`)
|
||||||
|
if (opts.diff.changed.length) lines.push(` - changed: ${opts.diff.changed.join(", ")}`)
|
||||||
|
return { version, date: opts.date, body: lines.join("\n") }
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Inserts the entry directly below the `## [Unreleased]` block heading area. */
|
||||||
|
export function insertEntry(changelog: string, entry: SyncEntry): string {
|
||||||
|
const marker = "## [Unreleased]"
|
||||||
|
const i = changelog.indexOf(marker)
|
||||||
|
if (i === -1) throw new Error("CHANGELOG.md has no `## [Unreleased]` heading")
|
||||||
|
const after = i + marker.length
|
||||||
|
const rest = changelog.slice(after).replace(/^\n+/, "")
|
||||||
|
return `${changelog.slice(0, after)}\n\n${entry.body}\n\n${rest}`
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const changelogPath = path.join(root, "CHANGELOG.md")
|
||||||
|
const changelog = readFileSync(changelogPath, "utf8")
|
||||||
|
const target = JSON.parse(readFileSync(path.join(root, "upstream/UPSTREAM.json"), "utf8"))
|
||||||
|
const state = JSON.parse(readFileSync(path.join(root, ".opencode/state/upstream.json"), "utf8"))
|
||||||
|
// The diff for the entry comes from the last released sync recorded in state, if any.
|
||||||
|
const entry = buildEntry({
|
||||||
|
changelog,
|
||||||
|
fromCommit: state.previous_commit ?? null,
|
||||||
|
toCommit: target.commit,
|
||||||
|
toVersion: target.upstream_version,
|
||||||
|
date: new Date().toISOString().slice(0, 10),
|
||||||
|
diff: state.last_diff ?? { added: [], removed: [], changed: [] },
|
||||||
|
})
|
||||||
|
if (!entry) {
|
||||||
|
console.log(`changelog already covers upstream ${target.commit.slice(0, 9)}; no version change`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (process.argv.includes("--dry")) {
|
||||||
|
console.log(`would release ${entry.version}:\n\n${entry.body}`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
writeFileSync(changelogPath, insertEntry(changelog, entry))
|
||||||
|
console.log(`prepared release ${entry.version} for upstream ${target.commit.slice(0, 9)}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
try {
|
||||||
|
main()
|
||||||
|
} catch (err) {
|
||||||
|
console.error((err as Error).message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
# Phase boundaries
|
||||||
|
|
||||||
|
A **phase** is a chunk of work inside a session: the grilling, the implementation, the QA. The definition is fuzzy on purpose: a phase ends when you think *"ok, we're done with that"*.
|
||||||
|
|
||||||
|
The **phase boundary** is the gap between two phases, and it is the only place this decision belongs. Mid-phase there is no decision to make: continue, or split the work that's left into subagents. Compacting mid-phase makes the agent lose the thread.
|
||||||
|
|
||||||
|
## The five options
|
||||||
|
|
||||||
|
| Option | What it does |
|
||||||
|
| ------------ | --------------------------------------------------------------- |
|
||||||
|
| **Continue** | Stay in the session. No context switch at all. |
|
||||||
|
| **`/clear`** | Empty the context window and start from nothing. |
|
||||||
|
| **`/handoff`** | Write a portable markdown file and seed a session anywhere with it. |
|
||||||
|
| **Subagent** | Send the task to its own context window and get a report back. |
|
||||||
|
| **`/compact`** | Compress this context and seed a fresh session with the summary. |
|
||||||
|
|
||||||
|
## The tree
|
||||||
|
|
||||||
|
Work top to bottom at the boundary. The first **yes** wins.
|
||||||
|
|
||||||
|
**1. Can you continue in this session?** Two things make the answer yes: the next phase needs this phase as a **primary source**, or you have enough [smart zone](https://www.aihero.dev/ai-coding-dictionary/smart-zone) left (~150k tokens) for the next phase to fit. Grilling → implementation is the standard yes: the implementation wants the reasoning verbatim, not a summary of it. Continue costs nothing and loses nothing, so rule it out before anything else.
|
||||||
|
|
||||||
|
**2. Is the context irrelevant to what comes next?** Is everything in this session (the exploration, the decisions, the dead ends) disposable? If so, **`/clear`**. It is the cheapest move on the board: it takes no time and hands back the whole window. `/clear` also isn't terminal: the old session stays resumable.
|
||||||
|
|
||||||
|
The cost of getting this wrong is one-way. Clear a *relevant* context and you lose the **why** behind what you built, and no amount of reading the diff back gets it returned.
|
||||||
|
|
||||||
|
**3. Do you need to hand off?** `/handoff` is narrow. You need it only when you are:
|
||||||
|
|
||||||
|
- swapping to a **new harness** (Claude → Codex),
|
||||||
|
- moving to a **new directory** or repo,
|
||||||
|
- sending the work to a **colleague**,
|
||||||
|
- or forking a side task you found **mid-phase** without derailing what you're doing.
|
||||||
|
|
||||||
|
That list is the whole clause. What `/handoff` buys is **portability**: a file that travels. If nothing is travelling, you don't need it.
|
||||||
|
|
||||||
|
**4. Can the task be done AFK?** Is it scoped tightly enough to run with you away from the keyboard, no steering? Then send it to a **subagent** and leave this session untouched. Automated review is the standard case: the agent reads the diff and reports, and you aren't needed while it does.
|
||||||
|
|
||||||
|
**5. Otherwise, `/compact`.** Relevant context, same harness, same directory, and you need to stay in the loop: this is where the tree lands, and it lands here often. Pass it an instruction (`/compact we're going to QA this area`) so the summary keeps what the next phase needs.
|
||||||
|
|
||||||
|
`/compact` is the **default, not the first reach**. It sits at the bottom because the four questions above it are all cheaper or more precise. The failure mode when people start here is a fresh session that is confidently wrong about a decision the summary flattened.
|
||||||
|
|
||||||
|
## Primary and secondary sources
|
||||||
|
|
||||||
|
Every move except **Continue** turns a **primary source** into a **secondary source**: the session as it happened, replaced by a summary of it. The trade is always the same shape:
|
||||||
|
|
||||||
|
| Source | Information | Noise | Room to move |
|
||||||
|
| --------------------------------- | ----------- | ----- | ------------ |
|
||||||
|
| Primary (Continue) | Full | Lots | Little |
|
||||||
|
| Secondary (`/compact`, `/handoff`) | Lossy | Less | Lots |
|
||||||
|
|
||||||
|
This is why question 1 comes first. You only pay the lossiness when staying costs more than it saves.
|
||||||
|
|
||||||
|
## These are judgement calls
|
||||||
|
|
||||||
|
The questions are not objective: each has taste in it, and the same boundary can go two ways on two days. The value is in asking them **in order**, at the boundary rather than in the middle of the work.
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
---
|
||||||
|
name: ask-matt
|
||||||
|
description: Ask which skill or flow fits your situation. A router over the skills in this repo.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Ask Matt
|
||||||
|
|
||||||
|
You don't remember every skill, so ask.
|
||||||
|
|
||||||
|
Before stating what a skill does or recommending a step be skipped, read that skill's SKILL.md: the summaries here are for orientation only.
|
||||||
|
|
||||||
|
A **flow** is a path through the skills. Most paths run along one **main flow**, and two **on-ramps** merge onto it. Everything else is standalone, or a vocabulary layer that runs underneath.
|
||||||
|
|
||||||
|
## The main flow: idea → ship
|
||||||
|
|
||||||
|
The route most work travels. You have an idea and want it built.
|
||||||
|
|
||||||
|
1. **`/grill-with-docs`** sharpens the idea by interview. Start here whenever you are **working in a working directory**: it's stateful, retaining what it learns in `GLOSSARY.md` and ADRs. (No working directory? Use `/grill-me` instead, covered under Standalone. Both run the same `/grilling` primitive; `grill-with-docs` is the one that leaves a paper trail, which makes it the better of the two whenever a repo is there to leave it in.)
|
||||||
|
2. **Branch: can you settle every question in conversation?** If a question needs a runnable answer (state, business logic, a UI you have to see), detour through a prototype, bridged by **`/handoff`** in both directions (a prototype lives in its own directory, which is exactly what `/handoff` is for; see Phase boundaries):
|
||||||
|
- **`/handoff`** out, then open a fresh session against that file,
|
||||||
|
- **`/prototype`** to answer the question with throwaway code,
|
||||||
|
- **`/handoff`** back what you learned, and reference it from the original idea thread.
|
||||||
|
3. **Branch: is this a multi-session build?**
|
||||||
|
- **Yes** → **`/to-spec`** (turn the thread into a spec), then **`/to-tickets`** to split it into tracer-bullet tickets, each declaring its **blocking edges**. Then work the tickets one of two ways:
|
||||||
|
- **`/implement`** per ticket, **`/clear`ing context between each one**. On a local tracker that's one file per ticket under `.scratch/<feature>/issues/`, worked blockers-first by hand; on a real tracker the edges become native blocking links, so any ticket whose blockers are done can be grabbed. Each ticket is self-contained, so the last one's context is disposable.
|
||||||
|
- **`/implement-spec`** for the whole spec in one run. It reads the tickets as a **task graph**, runs implementer subagents across the ready **frontier** in parallel, and lands everything on one **integration branch**. Reach for it when you'd rather orchestrate the build than drive each ticket yourself.
|
||||||
|
- **No** → **`/implement`** right here, in the same context window.
|
||||||
|
|
||||||
|
Either way, the code gets built by driving **`/tdd`** (one red-green slice at a time) and closes out with **`/code-review`**, a two-axis review (Standards + Spec) of the diff. `/implement` runs both per ticket; `/implement-spec`'s implementers each drive `/tdd`, and it runs one `/code-review` over the integration branch. Reach for **`/tdd`** on its own when you just want to build a concrete behaviour test-first without a full spec, and **`/code-review`** on its own whenever you want to review a branch or PR against a fixed point.
|
||||||
|
|
||||||
|
When the work goes up as a pull request, **`/pr`** shapes the body: the smallest visual that shows the change, before/after evidence that it works, and a one-way or two-way door call. It's model-invoked, so the agent reaches for it whenever it writes a PR.
|
||||||
|
|
||||||
|
4. **`/retro`** closes the loop. After a build, and especially one that went sideways, it looks back over the session and suggests changes to the agent's **environment**, not the code: navigation pointers, automated checks, the coding standards `/code-review` enforces, steering files, tooling. Mechanical mistakes become deterministic checks; judgement calls become coding standards. The next build then starts from a better environment.
|
||||||
|
|
||||||
|
### Context hygiene
|
||||||
|
|
||||||
|
Keep steps 1–3 in **one unbroken context window** (don't compact or clear until after `/to-tickets`) so the grilling, spec, and tickets all build on the same thinking. Each `/implement` then starts fresh, working from the ticket. Run `/retro` in the session it's looking back on, before you clear; after clearing, point it at that session's log instead.
|
||||||
|
|
||||||
|
The limit on this is the **[smart zone](https://www.aihero.dev/ai-coding-dictionary/smart-zone)**: the window (~150k tokens on state-of-the-art models) within which the model still reasons sharply. If a session approaches it before `/to-tickets`, don't push on degraded; `/compact` at the nearest phase boundary and carry on (see Phase boundaries).
|
||||||
|
|
||||||
|
## On-ramps
|
||||||
|
|
||||||
|
A starting situation that generates work, then merges onto the main flow.
|
||||||
|
|
||||||
|
- **Bugs and requests piling up** → **`/triage`**. It moves issues through triage roles and produces agent-ready issues, which **`/implement`** later picks up.
|
||||||
|
|
||||||
|
Triage is only for issues **you didn't create**: bug reports, incoming feature requests, anything that arrives raw. Tickets that `/to-tickets` produced are already agent-ready, so **don't triage them**.
|
||||||
|
|
||||||
|
- **Something's broken** → **`/diagnosing-bugs`**. For the hard ones: the bug that resists a first glance, the intermittent flake, the regression that crept in between two known-good states. It refuses to theorise until it has a **tight feedback loop** (one command that already goes red on *this* bug), then fixes with a regression test. Once the fix is in, run **`/retro`** in the same session to ask what would have prevented the bug; where the real finding is that there's no good seam to lock it down, that's a job for **`/improve-codebase-architecture`**.
|
||||||
|
|
||||||
|
- **A huge, foggy effort: a greenfield project or a huge feature build, too big for one session** → **`/wayfinder`**, the most cognitively demanding flow here. When the way from here to the destination isn't visible yet, it charts a **shared map** of **decision tickets** on the issue tracker and resolves them one at a time, producing **decisions, not deliverables**, until the fog is pushed back and the way is clear. Where **`/grill-with-docs`** sharpens an idea you can hold in one session, wayfinder is for the idea you can't, and it's slower and denser, so save it for exactly that, never a well-scoped feature.
|
||||||
|
|
||||||
|
When the map clears, **it hands off, it doesn't build**: merge onto the main flow at **`/to-spec`**, which collapses the map's linked decisions into a buildable plan, then `/to-tickets` and `/implement` as usual. Looping the map straight into `/implement` skips that collapse and throws the linked detail away, so go straight to `/implement` only when the effort turned out genuinely small.
|
||||||
|
|
||||||
|
## Codebase health
|
||||||
|
|
||||||
|
Not feature work, just upkeep.
|
||||||
|
|
||||||
|
- **`/improve-codebase-architecture`** runs whenever you have a spare moment to keep the codebase good for agents to operate in. It surfaces **deepening opportunities**; picking one _generates an idea_ you can take into the main flow at `/grill-with-docs`. It's the survey that finds the candidates; **`/codebase-design`** (below) is the bench you design the chosen one on.
|
||||||
|
|
||||||
|
## Vocabulary underneath
|
||||||
|
|
||||||
|
Two model-invoked references that run *beneath* the other skills, each the single source of truth for its vocabulary. Reach for them directly when the **words**, not the process, are the problem; or let the skills above pull them in.
|
||||||
|
|
||||||
|
- **`/domain-modeling`**: sharpen the project's *domain* language: challenge a fuzzy term, resolve an overloaded word ("account" doing three jobs), record a hard-to-reverse decision as an ADR. It's the active discipline `/grill-with-docs` drives to keep `GLOSSARY.md` a clean glossary.
|
||||||
|
- **`/codebase-design`** is the deep-module vocabulary (module, interface, depth, seam, adapter, leverage, locality) for designing a module's *shape*: a lot of behaviour behind a small interface at a clean seam. `/tdd` and `/improve-codebase-architecture` both speak it.
|
||||||
|
|
||||||
|
## Phase boundaries
|
||||||
|
|
||||||
|
A **phase** is a chunk of work inside a session: the grilling, the implementation, the QA. At the **boundary** between two of them you have five options, and picking between them is the fuzziest decision in this whole map:
|
||||||
|
|
||||||
|
- **Continue**: stay put. Costs nothing, loses nothing.
|
||||||
|
- **`/clear`**: empty the window, when nothing here matters to what's next.
|
||||||
|
- **`/handoff`** writes a portable markdown file. Narrow: only for a **new harness**, a **new directory**, a **colleague**, or forking a side task **mid-phase**. What it buys is portability.
|
||||||
|
- **Subagent**: send a tightly-scoped task to its own window and get a report back.
|
||||||
|
- **`/compact`** compresses this context and seeds a fresh session with it. The **default**, at the bottom of the tree rather than the first reach.
|
||||||
|
|
||||||
|
Read [PHASE-BOUNDARIES.md](PHASE-BOUNDARIES.md) for the ordered tree: the five questions, the reasoning behind each branch, and why the primary-source cost makes **Continue** the one to rule out first. Make the decision **at** a boundary; mid-phase, continue or split the rest into subagents.
|
||||||
|
|
||||||
|
## Standalone
|
||||||
|
|
||||||
|
Off the main flow entirely.
|
||||||
|
|
||||||
|
- **`/grill-me`**: the same relentless interview as `/grill-with-docs`, but **stateless**: it saves nothing locally and builds no `GLOSSARY.md`. Reach for it when you are **not working in a working directory** (sharpening a plan, a design, a piece of writing, anything with no repo under it). If you are in a working directory, use `/grill-with-docs` instead: it runs the same interview and leaves a paper trail, so it is strictly the better one.
|
||||||
|
- **`/grilling`** is the interview primitive itself: rounds, the frontier, facts are the agent's job and decisions are yours. `/grill-me` and `/grill-with-docs` are the two named ways in, and `/triage`, `/wayfinder` and `/improve-codebase-architecture` all run it internally. Reach for it directly only when you want the interview with no wrapper around it.
|
||||||
|
- **`/prototype`** is a small, throwaway program that answers one design question: does this state model feel right, or what should this UI look like. Throwaway is a constraint on how the code is written, not a promise to destroy it: the answer folds into the real code, and the prototype itself is kept as a **primary source** on a `prototype/<name>` branch out of main, pointed at from the implementation issue. It's the detour in step 2 of the main flow, but reach for it any time a design question is hard to settle on paper.
|
||||||
|
- **`/research`**: delegate reading legwork to a **background agent**: it investigates a question against **primary sources**, then leaves a cited Markdown file in the repo. Keep working while it reads. The file it produces is something to take *into* the main flow at `/grill-with-docs`, since research feeds the thinking rather than replacing it.
|
||||||
|
- **`/to-questionnaire`** comes in when the thing blocking you isn't in your head or the codebase but in **someone else's**, and it writes them a questionnaire to fill in. It's the inverse of `/grill-me`: instead of interviewing you about the subject, it interviews you about the **send** (who it's going to, what you need back) and aims the questions at the gap. What comes back is material for `/grill-with-docs` or `/to-spec`.
|
||||||
|
- **`/wizard`** is for the steps only a **human** can take: provisioning infrastructure, setting up credentials or CI secrets, clicking through an unfamiliar third-party dashboard, running a one-off migration or cutover. It generates an interactive bash script that opens each URL, captures each value, and writes it into `.env` and GitHub secrets, so the procedure stops being something you re-explain to an agent every time. Model-invoked, so the agent reaches for it the moment it hits a wall only you can pass. If the agent could just do it itself, it should; this is for where a human is genuinely in the loop.
|
||||||
|
- **`/wait-what`** is the corrective for a message that didn't land. Use it mid-conversation, inside any other skill, and the agent re-pitches what it just said with the context you were missing, in plain English, using the `GLOSSARY.md` vocabulary. It works after the fact; `/grill-with-docs` is the upfront cure, because a shared language agreed early is what stops the jargon arriving at all.
|
||||||
|
- **`/teach`**: learn a concept over multiple sessions, using the current directory as a stateful workspace.
|
||||||
|
- **`/writing-for-agents`** is the reference for writing documents agents consume: skills, AGENTS.md, pointed-at docs.
|
||||||
|
|
||||||
|
## Precondition
|
||||||
|
|
||||||
|
**`/setup-matt-pocock-skills`**: run before your first engineering flow to configure the issue tracker, triage labels, and doc layout the other skills assume. Custom issue trackers also work.
|
||||||
@@ -0,0 +1,89 @@
|
|||||||
|
---
|
||||||
|
name: code-review
|
||||||
|
description: "Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to \"review since X\"."
|
||||||
|
---
|
||||||
|
|
||||||
|
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
|
||||||
|
|
||||||
|
- **Standards**: does the code conform to this repo's documented coding standards?
|
||||||
|
- **Spec**: does the code faithfully implement the originating issue / spec?
|
||||||
|
|
||||||
|
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
|
||||||
|
|
||||||
|
The issue tracker should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Pin the fixed point
|
||||||
|
|
||||||
|
Whatever the user said is the fixed point (a commit SHA, branch name, tag, `main`, `HEAD~5`, etc.). If they didn't specify one, ask for it.
|
||||||
|
|
||||||
|
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
|
||||||
|
|
||||||
|
Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here, not inside two parallel sub-agents.
|
||||||
|
|
||||||
|
### 2. Identify the spec source
|
||||||
|
|
||||||
|
Look for the originating spec, in this order:
|
||||||
|
|
||||||
|
1. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.), fetched via the workflow in the tracker doc.
|
||||||
|
2. A path the user passed as an argument.
|
||||||
|
3. A spec file under `docs/`, `specs/`, or `.scratch/` matching the branch name or feature.
|
||||||
|
4. If nothing is found, ask the user where the spec is. If they say there isn't one, the **Spec** sub-agent will skip and report "no spec available".
|
||||||
|
|
||||||
|
### 3. Identify the standards sources
|
||||||
|
|
||||||
|
Search the repo for every file that documents how code should be written. When `CODING_STANDARDS.md` or `CONTRIBUTING.md` exists, it must be on the list.
|
||||||
|
|
||||||
|
On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below: a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
|
||||||
|
|
||||||
|
- **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
|
||||||
|
- **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation. Like any standard here, skip anything tooling already enforces.
|
||||||
|
|
||||||
|
Each smell reads *what it is* → *how to fix*; match it against the diff:
|
||||||
|
|
||||||
|
- **Mysterious Name**: a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
|
||||||
|
- **Duplicated Code**: the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
|
||||||
|
- **Feature Envy**: a method that reaches into another object's data more than its own. → move the method onto the data it envies.
|
||||||
|
- **Data Clumps**: the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
|
||||||
|
- **Primitive Obsession**: a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
|
||||||
|
- **Repeated Switches**: the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
|
||||||
|
- **Shotgun Surgery**: one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
|
||||||
|
- **Divergent Change**: one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
|
||||||
|
- **Speculative Generality**: abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
|
||||||
|
- **Message Chains**: long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
|
||||||
|
- **Middle Man**: a class or function that mostly just delegates onward. → cut it, call the real target direct.
|
||||||
|
- **Refused Bequest**: a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
|
||||||
|
|
||||||
|
### 4. Spawn both sub-agents in parallel
|
||||||
|
|
||||||
|
Issue both sub-agent calls together, in the foreground, and aggregate the reports they return.
|
||||||
|
|
||||||
|
**Standards sub-agent prompt** should include:
|
||||||
|
|
||||||
|
- The full diff command and commit list.
|
||||||
|
- The list of standards-source files you found in step 3, **plus the smell baseline from step 3** pasted in full (the sub-agent has no other access to it).
|
||||||
|
- The brief: "Report, per file/hunk where relevant, (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls: documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
|
||||||
|
|
||||||
|
**Spec sub-agent prompt** should include:
|
||||||
|
|
||||||
|
- The diff command and commit list.
|
||||||
|
- The path or fetched contents of the spec.
|
||||||
|
- The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
|
||||||
|
|
||||||
|
If the spec is missing, skip the Spec sub-agent and note this in the final report.
|
||||||
|
|
||||||
|
### 5. Aggregate
|
||||||
|
|
||||||
|
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings, because the two axes are deliberately separate (see _Why two axes_).
|
||||||
|
|
||||||
|
End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes: that's the reranking the separation exists to prevent.
|
||||||
|
|
||||||
|
## Why two axes
|
||||||
|
|
||||||
|
A change can pass one axis and fail the other:
|
||||||
|
|
||||||
|
- Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
|
||||||
|
- Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
|
||||||
|
|
||||||
|
Reporting them separately stops one axis from masking the other.
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Deepening
|
||||||
|
|
||||||
|
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md): **module**, **interface**, **seam**, **adapter**.
|
||||||
|
|
||||||
|
## Dependency categories
|
||||||
|
|
||||||
|
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
|
||||||
|
|
||||||
|
### 1. In-process
|
||||||
|
|
||||||
|
Pure computation, in-memory state, no I/O. Always deepenable: merge the modules and test through the new interface directly. No adapter needed.
|
||||||
|
|
||||||
|
### 2. Local-substitutable
|
||||||
|
|
||||||
|
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
|
||||||
|
|
||||||
|
### 3. Remote but owned (Ports & Adapters)
|
||||||
|
|
||||||
|
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
|
||||||
|
|
||||||
|
Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
|
||||||
|
|
||||||
|
### 4. True external (Mock)
|
||||||
|
|
||||||
|
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
|
||||||
|
|
||||||
|
## Seam discipline
|
||||||
|
|
||||||
|
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
|
||||||
|
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
|
||||||
|
|
||||||
|
## Testing strategy: replace, don't layer
|
||||||
|
|
||||||
|
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist; delete them.
|
||||||
|
- Write new tests at the deepened module's interface. The **interface is the test surface**.
|
||||||
|
- Tests assert on observable outcomes through the interface, not internal state.
|
||||||
|
- Tests should survive internal refactors, since they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
# Design It Twice
|
||||||
|
|
||||||
|
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout): your first idea is unlikely to be the best.
|
||||||
|
|
||||||
|
Uses the vocabulary in [SKILL.md](SKILL.md): **module**, **interface**, **seam**, **adapter**, **leverage**.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Frame the problem space
|
||||||
|
|
||||||
|
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
|
||||||
|
|
||||||
|
- The constraints any new interface would need to satisfy
|
||||||
|
- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
|
||||||
|
- A rough illustrative code sketch to ground the constraints, not a proposal, just a way to make the constraints concrete
|
||||||
|
|
||||||
|
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
|
||||||
|
|
||||||
|
### 2. Spawn sub-agents
|
||||||
|
|
||||||
|
Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module.
|
||||||
|
|
||||||
|
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
|
||||||
|
|
||||||
|
- Agent 1: "Minimize the interface: aim for 1–3 entry points max. Maximise leverage per entry point."
|
||||||
|
- Agent 2: "Maximise flexibility: support many use cases and extension."
|
||||||
|
- Agent 3: "Optimise for the most common caller: make the default case trivial."
|
||||||
|
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
|
||||||
|
|
||||||
|
Include both [SKILL.md](SKILL.md) vocabulary and GLOSSARY.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
|
||||||
|
|
||||||
|
Each sub-agent outputs:
|
||||||
|
|
||||||
|
1. Interface (types, methods, params, plus invariants, ordering, error modes)
|
||||||
|
2. Usage example showing how callers use it
|
||||||
|
3. What the implementation hides behind the seam
|
||||||
|
4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
|
||||||
|
5. Trade-offs: where leverage is high, where it's thin
|
||||||
|
|
||||||
|
### 3. Present and compare
|
||||||
|
|
||||||
|
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
|
||||||
|
|
||||||
|
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated: the user wants a strong read, not a menu.
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
---
|
||||||
|
name: codebase-design
|
||||||
|
description: Shared vocabulary for designing deep modules. Use when the user wants to design or improve a module's interface, find deepening opportunities, decide where a seam goes, make code more testable or AI-navigable, or when another skill needs the deep-module vocabulary.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Codebase Design
|
||||||
|
|
||||||
|
Design **deep modules**: a lot of behaviour behind a small interface, placed at a clean seam, testable through that interface. Use this language and these principles wherever code is being designed or restructured. The aim is leverage for callers, locality for maintainers, and testability for everyone.
|
||||||
|
|
||||||
|
## Glossary
|
||||||
|
|
||||||
|
Use these terms exactly: don't substitute "component," "service," "API," or "boundary." Consistent language is the whole point.
|
||||||
|
|
||||||
|
**Module**: anything with an interface and an implementation. Deliberately scale-agnostic: a function, class, package, or tier-spanning slice. _Avoid_: unit, component, service.
|
||||||
|
|
||||||
|
**Interface**: everything a caller must know to use the module correctly: the type signature, but also invariants, ordering constraints, error modes, required configuration, and performance characteristics. _Avoid_: API, signature (too narrow, they refer only to the type-level surface).
|
||||||
|
|
||||||
|
**Implementation**: what's inside a module, its body of code. Distinct from **Adapter**: a thing can be a small adapter with a large implementation (a Postgres repo) or a large adapter with a small implementation (an in-memory fake). Reach for "adapter" when the seam is the topic; "implementation" otherwise.
|
||||||
|
|
||||||
|
**Depth**: leverage at the interface. The amount of behaviour a caller (or test) can exercise per unit of interface they have to learn. A module is **deep** when a large amount of behaviour sits behind a small interface, **shallow** when the interface is nearly as complex as the implementation.
|
||||||
|
|
||||||
|
**Seam** _(Michael Feathers)_: a place where you can alter behaviour without editing in that place; the *location* at which a module's interface lives. Where to put the seam is its own design decision, distinct from what goes behind it. _Avoid_: boundary (overloaded with DDD's bounded context).
|
||||||
|
|
||||||
|
**Adapter**: a concrete thing that satisfies an interface at a seam. Describes *role* (what slot it fills), not substance (what's inside).
|
||||||
|
|
||||||
|
**Leverage**: what callers get from depth. More capability per unit of interface they learn. One implementation pays back across N call sites and M tests.
|
||||||
|
|
||||||
|
**Locality**: what maintainers get from depth. Change, bugs, knowledge, and verification concentrate in one place rather than spreading across callers. Fix once, fixed everywhere.
|
||||||
|
|
||||||
|
## Deep vs shallow
|
||||||
|
|
||||||
|
**Deep module** = small interface + lots of implementation:
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────┐
|
||||||
|
│ Small Interface │ ← Few methods, simple params
|
||||||
|
├─────────────────────┤
|
||||||
|
│ │
|
||||||
|
│ Deep Implementation│ ← Complex logic hidden
|
||||||
|
│ │
|
||||||
|
└─────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
**Shallow module** = large interface + little implementation (avoid):
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────────┐
|
||||||
|
│ Large Interface │ ← Many methods, complex params
|
||||||
|
├─────────────────────────────────┤
|
||||||
|
│ Thin Implementation │ ← Just passes through
|
||||||
|
└─────────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
When designing an interface, ask:
|
||||||
|
|
||||||
|
- Can I reduce the number of methods?
|
||||||
|
- Can I simplify the parameters?
|
||||||
|
- Can I hide more complexity inside?
|
||||||
|
|
||||||
|
## Principles
|
||||||
|
|
||||||
|
- **Depth is a property of the interface, not the implementation.** A deep module can be internally composed of small, mockable, swappable parts; they just aren't part of the interface. A module can have **internal seams** (private to its implementation, used by its own tests) as well as the **external seam** at its interface.
|
||||||
|
- **The deletion test.** Imagine deleting the module. If complexity vanishes, it was a pass-through. If complexity reappears across N callers, it was earning its keep.
|
||||||
|
- **The interface is the test surface.** Callers and tests cross the same seam. If you want to test *past* the interface, the module is probably the wrong shape.
|
||||||
|
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a seam unless something actually varies across it.
|
||||||
|
|
||||||
|
## Designing for testability
|
||||||
|
|
||||||
|
Good interfaces make testing natural:
|
||||||
|
|
||||||
|
1. **Accept dependencies, don't create them.**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Testable
|
||||||
|
function processOrder(order, paymentGateway) {}
|
||||||
|
|
||||||
|
// Hard to test
|
||||||
|
function processOrder(order) {
|
||||||
|
const gateway = new StripeGateway();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Return results, don't produce side effects.**
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Testable
|
||||||
|
function calculateDiscount(cart): Discount {}
|
||||||
|
|
||||||
|
// Hard to test
|
||||||
|
function applyDiscount(cart): void {
|
||||||
|
cart.total -= discount;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Small surface area.** Fewer methods = fewer tests needed. Fewer params = simpler test setup.
|
||||||
|
|
||||||
|
## Relationships
|
||||||
|
|
||||||
|
- A **Module** has exactly one **Interface** (the surface it presents to callers and tests).
|
||||||
|
- **Depth** is a property of a **Module**, measured against its **Interface**.
|
||||||
|
- A **Seam** is where a **Module**'s **Interface** lives.
|
||||||
|
- An **Adapter** sits at a **Seam** and satisfies the **Interface**.
|
||||||
|
- **Depth** produces **Leverage** for callers and **Locality** for maintainers.
|
||||||
|
|
||||||
|
## Rejected framings
|
||||||
|
|
||||||
|
- **Depth as ratio of implementation-lines to interface-lines** (Ousterhout): rewards padding the implementation. We use depth-as-leverage instead.
|
||||||
|
- **"Interface" as the TypeScript `interface` keyword or a class's public methods**: too narrow: interface here includes every fact a caller must know.
|
||||||
|
- **"Boundary"**: overloaded with DDD's bounded context. Say **seam** or **interface**.
|
||||||
|
|
||||||
|
## Going deeper
|
||||||
|
|
||||||
|
- **Deepening a cluster given its dependencies**, see [DEEPENING.md](DEEPENING.md): dependency categories, seam discipline, and replace-don't-layer testing.
|
||||||
|
- **Exploring alternative interfaces**, see [DESIGN-IT-TWICE.md](DESIGN-IT-TWICE.md): spin up parallel sub-agents to design the interface several radically different ways, then compare on depth, locality, and seam placement.
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
---
|
||||||
|
name: diagnosing-bugs
|
||||||
|
description: Diagnosis loop for hard bugs and performance regressions. Use when the user says "diagnose"/"debug this", or reports something broken/throwing/failing/slow.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Diagnosing Bugs
|
||||||
|
|
||||||
|
A discipline for hard bugs. Skip phases only when explicitly justified.
|
||||||
|
|
||||||
|
When exploring the codebase, read `GLOSSARY.md` (if it exists) to get a clear mental model of the relevant modules, and check ADRs in the area you're touching.
|
||||||
|
|
||||||
|
## Redact
|
||||||
|
|
||||||
|
This skill has you show commands, outputs and captured artifacts. **Redact every secret first**: write `<REDACTED>` in its place. Build loops against env vars, so the credential stays in the environment rather than in what you show. Captured artifacts carry auth headers: quote only the lines that carry the signal.
|
||||||
|
|
||||||
|
If the redacted output is not enough to diagnose the bug, say so and ask the user.
|
||||||
|
|
||||||
|
## Phase 1: Build a feedback loop
|
||||||
|
|
||||||
|
**This is the skill.** Everything else is mechanical. If you have a **tight** pass/fail signal for the bug (one that goes red on _this_ bug), you will find the cause; bisection, hypothesis-testing, and instrumentation all just consume it. If you don't have one, no amount of staring at code will save you.
|
||||||
|
|
||||||
|
Spend disproportionate effort here. **Be aggressive. Be creative. Refuse to give up.**
|
||||||
|
|
||||||
|
### Ways to construct one, in roughly this order
|
||||||
|
|
||||||
|
1. **Failing test** at whatever seam reaches the bug: unit, integration, e2e.
|
||||||
|
2. **Curl / HTTP script** against a running dev server.
|
||||||
|
3. **CLI invocation** with a fixture input, diffing stdout against a known-good snapshot.
|
||||||
|
4. **Headless browser script** (Playwright / Puppeteer) that drives the UI and asserts on DOM/console/network.
|
||||||
|
5. **Replay a captured trace.** Save a real network request / payload / event log to disk; replay it through the code path in isolation.
|
||||||
|
6. **Throwaway harness.** Spin up a minimal subset of the system (one service, mocked deps) that exercises the bug code path with a single function call.
|
||||||
|
7. **Property / fuzz loop.** If the bug is "sometimes wrong output", run 1000 random inputs and look for the failure mode.
|
||||||
|
8. **Bisection harness.** If the bug appeared between two known states (commit, dataset, version), automate "boot at state X, check, repeat" so you can `git bisect run` it.
|
||||||
|
9. **Differential loop.** Run the same input through old-version vs new-version (or two configs) and diff outputs.
|
||||||
|
10. **HITL bash script.** Last resort. If a human must click, drive _them_ with `scripts/hitl-loop.template.sh` so the loop is still structured. Captured output feeds back to you.
|
||||||
|
|
||||||
|
Build the right feedback loop, and the bug is 90% fixed.
|
||||||
|
|
||||||
|
### Tighten the loop
|
||||||
|
|
||||||
|
Treat the loop as a product. Once you have _a_ loop, **tighten** it:
|
||||||
|
|
||||||
|
- Can I make it faster? (Cache setup, skip unrelated init, narrow the test scope.)
|
||||||
|
- Can I make the signal sharper? (Assert on the specific symptom, not "didn't crash".)
|
||||||
|
- Can I make it more deterministic? (Pin time, seed RNG, isolate filesystem, freeze network.)
|
||||||
|
|
||||||
|
A 30-second flaky loop is barely better than no loop; a 2-second deterministic one is tight, a debugging superpower.
|
||||||
|
|
||||||
|
### Non-deterministic bugs
|
||||||
|
|
||||||
|
The goal is not a clean repro but a **higher reproduction rate**. Loop the trigger 100×, parallelise, add stress, narrow timing windows, inject sleeps. A 50%-flake bug is debuggable; 1% is not, so keep raising the rate until it's debuggable.
|
||||||
|
|
||||||
|
### When you genuinely cannot build a loop
|
||||||
|
|
||||||
|
Stop and say so explicitly. List what you tried. Ask the user for: (a) access to whatever environment reproduces it, (b) a redacted captured artifact (HAR file, log dump, core dump, screen recording with timestamps), or (c) permission to add temporary production instrumentation. Do **not** proceed to hypothesise without a loop.
|
||||||
|
|
||||||
|
### Completion criterion: a tight loop that goes red
|
||||||
|
|
||||||
|
Phase 1 is done when the loop is **tight** and **red-capable**: you can name **one command** (a script path, a test invocation, a curl) that you have **already run at least once** (show the invocation and its output, redacted), and that is:
|
||||||
|
|
||||||
|
- [ ] **Red-capable**: it drives the actual bug code path and asserts the **user's exact symptom**, so it can go red on this bug and green once fixed. Not "runs without erroring"; it must be able to _catch this specific bug_.
|
||||||
|
- [ ] **Deterministic**: same verdict every run (flaky bugs: a pinned, high reproduction rate, per above).
|
||||||
|
- [ ] **Fast**: seconds, not minutes.
|
||||||
|
- [ ] **Agent-runnable**: you can run it unattended; a human in the loop only via `scripts/hitl-loop.template.sh`.
|
||||||
|
|
||||||
|
If you catch yourself reading code to build a theory before this command exists, **stop: jumping straight to a hypothesis is the exact failure this skill prevents.** No red-capable command, no Phase 2.
|
||||||
|
|
||||||
|
## Phase 2: Reproduce + minimise
|
||||||
|
|
||||||
|
Run the loop. Watch it go red as the bug appears.
|
||||||
|
|
||||||
|
Confirm:
|
||||||
|
|
||||||
|
- [ ] The loop produces the failure mode the **user** described, not a different failure that happens to be nearby. Wrong bug = wrong fix.
|
||||||
|
- [ ] The failure is reproducible across multiple runs (or, for non-deterministic bugs, reproducible at a high enough rate to debug against).
|
||||||
|
- [ ] You have captured the exact symptom (error message, wrong output, slow timing) so later phases can verify the fix actually addresses it.
|
||||||
|
|
||||||
|
### Minimise
|
||||||
|
|
||||||
|
Once it's red, shrink the repro to the **smallest scenario that still goes red**. Cut inputs, callers, config, data, and steps **one at a time**, re-running the loop after each cut, and keep only what's load-bearing for the failure.
|
||||||
|
|
||||||
|
Why bother: a minimal repro shrinks the hypothesis space in Phase 3 (fewer moving parts left to suspect) and becomes the clean regression test in Phase 5.
|
||||||
|
|
||||||
|
Done when **every remaining element is load-bearing**: removing any one of them makes the loop go green.
|
||||||
|
|
||||||
|
Do not proceed until you have reproduced **and** minimised.
|
||||||
|
|
||||||
|
## Phase 3: Hypothesise
|
||||||
|
|
||||||
|
Generate **3–5 ranked hypotheses** before testing any of them. Single-hypothesis generation anchors on the first plausible idea.
|
||||||
|
|
||||||
|
Each hypothesis must be **falsifiable**: state the prediction it makes.
|
||||||
|
|
||||||
|
> Format: "If <X> is the cause, then <changing Y> will make the bug disappear / <changing Z> will make it worse."
|
||||||
|
|
||||||
|
If you cannot state the prediction, the hypothesis is a vibe: discard or sharpen it.
|
||||||
|
|
||||||
|
**Show the ranked list to the user before testing.** They often have domain knowledge that re-ranks instantly ("we just deployed a change to #3"), or know hypotheses they've already ruled out. Cheap checkpoint, big time saver. Don't block on it; proceed with your ranking if the user is AFK.
|
||||||
|
|
||||||
|
## Phase 4: Instrument
|
||||||
|
|
||||||
|
Each probe must map to a specific prediction from Phase 3. **Change one variable at a time.**
|
||||||
|
|
||||||
|
Tool preference:
|
||||||
|
|
||||||
|
1. **Debugger / REPL inspection** if the env supports it. One breakpoint beats ten logs.
|
||||||
|
2. **Targeted logs** at the boundaries that distinguish hypotheses.
|
||||||
|
3. Never "log everything and grep".
|
||||||
|
|
||||||
|
**Tag every debug log** with a unique prefix, e.g. `[DEBUG-a4f2]`. Cleanup at the end becomes a single grep. Untagged logs survive; tagged logs die.
|
||||||
|
|
||||||
|
**Perf branch.** For performance regressions, logs are usually wrong. Instead: establish a baseline measurement (timing harness, `performance.now()`, profiler, query plan), then bisect. Measure first, fix second.
|
||||||
|
|
||||||
|
## Phase 5: Fix + regression test
|
||||||
|
|
||||||
|
Write the regression test **before the fix**, but only if there is a **correct seam** for it.
|
||||||
|
|
||||||
|
A correct seam is one where the test exercises the **real bug pattern** as it occurs at the call site. If the only available seam is too shallow (single-caller test when the bug needs multiple callers, unit test that can't replicate the chain that triggered the bug), a regression test there gives false confidence.
|
||||||
|
|
||||||
|
**If no correct seam exists, that itself is the finding.** Note it. The codebase architecture is preventing the bug from being locked down. Flag this for the next phase.
|
||||||
|
|
||||||
|
If a correct seam exists:
|
||||||
|
|
||||||
|
1. Turn the minimised repro into a failing test at that seam.
|
||||||
|
2. Watch it fail. If you forced the red by mutating code or a fixture, `diff` against a pristine copy to prove the mutation landed before you trust it.
|
||||||
|
3. Apply the fix.
|
||||||
|
4. Watch it pass.
|
||||||
|
5. Re-run the Phase 1 feedback loop against the original (un-minimised) scenario.
|
||||||
|
|
||||||
|
## Phase 6: Cleanup
|
||||||
|
|
||||||
|
Required before declaring done:
|
||||||
|
|
||||||
|
- [ ] Original repro no longer reproduces (re-run the Phase 1 loop)
|
||||||
|
- [ ] Regression test passes (or absence of seam is documented)
|
||||||
|
- [ ] All `[DEBUG-...]` instrumentation removed (`grep` the prefix)
|
||||||
|
- [ ] Throwaway prototypes deleted (or moved to a clearly-marked debug location)
|
||||||
|
- [ ] The hypothesis that turned out correct is stated in the commit / PR message, so the next debugger learns
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Human-in-the-loop reproduction loop.
|
||||||
|
# Copy this file, edit the steps below, and run it.
|
||||||
|
# The agent runs the script; the user follows prompts in their terminal.
|
||||||
|
#
|
||||||
|
# Usage:
|
||||||
|
# bash hitl-loop.template.sh
|
||||||
|
#
|
||||||
|
# Two helpers:
|
||||||
|
# step "<instruction>" → show instruction, wait for Enter
|
||||||
|
# capture VAR "<question>" → show question, read response into VAR
|
||||||
|
#
|
||||||
|
# At the end, captured values are printed as KEY=VALUE for the agent to parse.
|
||||||
|
#
|
||||||
|
# `capture` prints its value back to the terminal, where the agent reads it,
|
||||||
|
# so capture observations, and leave signing in to the user as a `step`.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
step() {
|
||||||
|
printf '\n>>> %s\n' "$1"
|
||||||
|
read -r -p " [Enter when done] " _
|
||||||
|
}
|
||||||
|
|
||||||
|
capture() {
|
||||||
|
local var="$1" question="$2" answer
|
||||||
|
printf '\n>>> %s\n' "$question"
|
||||||
|
read -r -p " > " answer
|
||||||
|
printf -v "$var" '%s' "$answer"
|
||||||
|
}
|
||||||
|
|
||||||
|
# --- edit below ---------------------------------------------------------
|
||||||
|
|
||||||
|
step "Open the app at http://localhost:3000 and sign in."
|
||||||
|
|
||||||
|
capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
|
||||||
|
|
||||||
|
capture ERROR_MSG "Paste the error message (or 'none'):"
|
||||||
|
|
||||||
|
# --- edit above ---------------------------------------------------------
|
||||||
|
|
||||||
|
printf '\n--- Captured ---\n'
|
||||||
|
printf 'ERRORED=%s\n' "$ERRORED"
|
||||||
|
printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# ADR Format
|
||||||
|
|
||||||
|
ADRs live in `docs/adr/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc.
|
||||||
|
|
||||||
|
Create the `docs/adr/` directory lazily: only when the first ADR is needed.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
|
||||||
|
```md
|
||||||
|
# {Short title of the decision}
|
||||||
|
|
||||||
|
{1-3 sentences: what's the context, what did we decide, and why.}
|
||||||
|
```
|
||||||
|
|
||||||
|
That's it. An ADR can be a single paragraph. The value is in recording *that* a decision was made and *why*, not in filling out sections.
|
||||||
|
|
||||||
|
## Optional sections
|
||||||
|
|
||||||
|
Only include these when they add genuine value. Most ADRs won't need them.
|
||||||
|
|
||||||
|
- **Status** frontmatter (`proposed | accepted | deprecated | superseded by ADR-NNNN`): useful when decisions are revisited
|
||||||
|
- **Considered Options**: only when the rejected alternatives are worth remembering
|
||||||
|
- **Consequences**: only when non-obvious downstream effects need to be called out
|
||||||
|
|
||||||
|
## Numbering
|
||||||
|
|
||||||
|
Scan `docs/adr/` for the highest existing number and increment by one.
|
||||||
|
|
||||||
|
## When to offer an ADR
|
||||||
|
|
||||||
|
All three of these must be true:
|
||||||
|
|
||||||
|
1. **Hard to reverse**: the cost of changing your mind later is meaningful
|
||||||
|
2. **Surprising without context**: a future reader will look at the code and wonder "why on earth did they do it this way?"
|
||||||
|
3. **The result of a real trade-off**: there were genuine alternatives and you picked one for specific reasons
|
||||||
|
|
||||||
|
If a decision is easy to reverse, skip it: you'll just reverse it. If it's not surprising, nobody will wonder why. If there was no real alternative, there's nothing to record beyond "we did the obvious thing."
|
||||||
|
|
||||||
|
### What qualifies
|
||||||
|
|
||||||
|
- **Architectural shape.** "We're using a monorepo." "The write model is event-sourced, the read model is projected into Postgres."
|
||||||
|
- **Integration patterns between contexts.** "Ordering and Billing communicate via domain events, not synchronous HTTP."
|
||||||
|
- **Technology choices that carry lock-in.** Database, message bus, auth provider, deployment target. Not every library: just the ones that would take a quarter to swap out.
|
||||||
|
- **Boundary and scope decisions.** "Customer data is owned by the Customer context; other contexts reference it by ID only." The explicit no-s are as valuable as the yes-s.
|
||||||
|
- **Deliberate deviations from the obvious path.** "We're using manual SQL instead of an ORM because X." Anything where a reasonable reader would assume the opposite. These stop the next engineer from "fixing" something that was deliberate.
|
||||||
|
- **Constraints not visible in the code.** "We can't use AWS because of compliance requirements." "Response times must be under 200ms because of the partner API contract."
|
||||||
|
- **Rejected alternatives when the rejection is non-obvious.** If you considered GraphQL and picked REST for subtle reasons, record it; otherwise someone will suggest GraphQL again in six months.
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# GLOSSARY.md Format
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```md
|
||||||
|
# {Context Name}
|
||||||
|
|
||||||
|
{One or two sentence description of what this context is and why it exists.}
|
||||||
|
|
||||||
|
## Language
|
||||||
|
|
||||||
|
**Order**:
|
||||||
|
{A one or two sentence description of the term}
|
||||||
|
_Avoid_: Purchase, transaction
|
||||||
|
|
||||||
|
**Invoice**:
|
||||||
|
A request for payment sent to a customer after delivery.
|
||||||
|
_Avoid_: Bill, payment request
|
||||||
|
|
||||||
|
**Customer**:
|
||||||
|
A person or organization that places orders.
|
||||||
|
_Avoid_: Client, buyer, account
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- **Be opinionated.** When multiple words exist for the same concept, pick the best one and list the others under `_Avoid_`.
|
||||||
|
- **Keep definitions tight.** One or two sentences max. Define what it IS, not what it does.
|
||||||
|
- **Only include terms specific to this project's context.** General programming concepts (timeouts, error types, utility patterns) don't belong even if the project uses them extensively. Before adding a term, ask: is this a concept unique to this context, or a general programming concept? Only the former belongs.
|
||||||
|
- **Group terms under subheadings** when natural clusters emerge. If all terms belong to a single cohesive area, a flat list is fine.
|
||||||
|
|
||||||
|
## Single vs multi-context repos
|
||||||
|
|
||||||
|
**Single context (most repos):** One `GLOSSARY.md` at the repo root.
|
||||||
|
|
||||||
|
**Multiple contexts:** A `GLOSSARY-MAP.md` at the repo root lists the contexts, where they live, and how they relate to each other:
|
||||||
|
|
||||||
|
```md
|
||||||
|
# Glossary Map
|
||||||
|
|
||||||
|
## Contexts
|
||||||
|
|
||||||
|
- [Ordering](./src/ordering/GLOSSARY.md): receives and tracks customer orders
|
||||||
|
- [Billing](./src/billing/GLOSSARY.md): generates invoices and processes payments
|
||||||
|
- [Fulfillment](./src/fulfillment/GLOSSARY.md): manages warehouse picking and shipping
|
||||||
|
|
||||||
|
## Relationships
|
||||||
|
|
||||||
|
- **Ordering → Fulfillment**: Ordering emits `OrderPlaced` events; Fulfillment consumes them to start picking
|
||||||
|
- **Fulfillment → Billing**: Fulfillment emits `ShipmentDispatched` events; Billing consumes them to generate invoices
|
||||||
|
- **Ordering ↔ Billing**: Shared types for `CustomerId` and `Money`
|
||||||
|
```
|
||||||
|
|
||||||
|
The skill infers which structure applies:
|
||||||
|
|
||||||
|
- If `GLOSSARY-MAP.md` exists, read it to find contexts
|
||||||
|
- If only a root `GLOSSARY.md` exists, single context
|
||||||
|
- If neither exists, create a root `GLOSSARY.md` lazily when the first term is resolved
|
||||||
|
|
||||||
|
When multiple contexts exist, infer which one the current topic relates to. If unclear, ask.
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
name: domain-modeling
|
||||||
|
description: Build and sharpen a project's domain model. Use when discussing codebase terminology, writing or editing a GLOSSARY.md, or recording or editing an ADR.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Domain Modeling
|
||||||
|
|
||||||
|
Actively build and sharpen the project's domain model as you design. This is the *active* discipline: challenging terms, inventing edge-case scenarios, and writing the glossary and decisions down the moment they crystallise. (Merely *reading* `GLOSSARY.md` for vocabulary is not this skill: that's a one-line habit any skill can do. This skill is for when you're changing the model, not just consuming it.)
|
||||||
|
|
||||||
|
## File structure
|
||||||
|
|
||||||
|
Most repos have a single context:
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── GLOSSARY.md
|
||||||
|
├── docs/
|
||||||
|
│ └── adr/
|
||||||
|
│ ├── 0001-event-sourced-orders.md
|
||||||
|
│ └── 0002-postgres-for-write-model.md
|
||||||
|
└── src/
|
||||||
|
```
|
||||||
|
|
||||||
|
If a `GLOSSARY-MAP.md` exists at the root, the repo has multiple contexts. The map points to where each one lives:
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── GLOSSARY-MAP.md
|
||||||
|
├── docs/
|
||||||
|
│ └── adr/ ← system-wide decisions
|
||||||
|
├── src/
|
||||||
|
│ ├── ordering/
|
||||||
|
│ │ ├── GLOSSARY.md
|
||||||
|
│ │ └── docs/adr/ ← context-specific decisions
|
||||||
|
│ └── billing/
|
||||||
|
│ ├── GLOSSARY.md
|
||||||
|
│ └── docs/adr/
|
||||||
|
```
|
||||||
|
|
||||||
|
Create files lazily: only when you have something to write. If no `GLOSSARY.md` exists, create one when the first term is resolved. If no `docs/adr/` exists, create it when the first ADR is needed.
|
||||||
|
|
||||||
|
## During the session
|
||||||
|
|
||||||
|
### Challenge against the glossary
|
||||||
|
|
||||||
|
When the user uses a term that conflicts with the existing language in `GLOSSARY.md`, call it out immediately. "Your glossary defines 'cancellation' as X, but you seem to mean Y. Which is it?"
|
||||||
|
|
||||||
|
### Sharpen fuzzy language
|
||||||
|
|
||||||
|
When the user uses vague or overloaded terms, propose a precise canonical term. "You're saying 'account': do you mean the Customer or the User? Those are different things."
|
||||||
|
|
||||||
|
### Discuss concrete scenarios
|
||||||
|
|
||||||
|
When domain relationships are being discussed, stress-test them with specific scenarios. Invent scenarios that probe edge cases and force the user to be precise about the boundaries between concepts.
|
||||||
|
|
||||||
|
### Cross-reference with code
|
||||||
|
|
||||||
|
When the user states how something works, check whether the code agrees. If you find a contradiction, surface it: "Your code cancels entire Orders, but you just said partial cancellation is possible. Which is right?"
|
||||||
|
|
||||||
|
### Update GLOSSARY.md inline
|
||||||
|
|
||||||
|
When a term is resolved, update `GLOSSARY.md` right there. Don't batch these up: capture them as they happen. Use the format in [GLOSSARY-FORMAT.md](./GLOSSARY-FORMAT.md).
|
||||||
|
|
||||||
|
`GLOSSARY.md` should be totally devoid of implementation details. Do not treat `GLOSSARY.md` as a spec, a scratch pad, or a repository for implementation decisions. It is a glossary and nothing else.
|
||||||
|
|
||||||
|
### Offer ADRs sparingly
|
||||||
|
|
||||||
|
Only offer to create an ADR when all three are true:
|
||||||
|
|
||||||
|
1. **Hard to reverse**: the cost of changing your mind later is meaningful
|
||||||
|
2. **Surprising without context**: a future reader will wonder "why did they do it this way?"
|
||||||
|
3. **The result of a real trade-off**: there were genuine alternatives and you picked one for specific reasons
|
||||||
|
|
||||||
|
If any of the three is missing, skip the ADR. Use the format in [ADR-FORMAT.md](./ADR-FORMAT.md).
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
---
|
||||||
|
name: git-guardrails-claude-code
|
||||||
|
description: Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Setup Git Guardrails
|
||||||
|
|
||||||
|
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
|
||||||
|
|
||||||
|
## What Gets Blocked
|
||||||
|
|
||||||
|
- `git push` (all variants including `--force`)
|
||||||
|
- `git reset --hard`
|
||||||
|
- `git clean -f` / `git clean -fd`
|
||||||
|
- `git branch -D`
|
||||||
|
- `git checkout .` / `git restore .`
|
||||||
|
|
||||||
|
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### 1. Ask scope
|
||||||
|
|
||||||
|
Ask the user: install for **this project only** (`.claude/settings.json`) or **all projects** (`~/.claude/settings.json`)?
|
||||||
|
|
||||||
|
### 2. Copy the hook script
|
||||||
|
|
||||||
|
The bundled script is at: [scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh)
|
||||||
|
|
||||||
|
Copy it to the target location based on scope:
|
||||||
|
|
||||||
|
- **Project**: `.claude/hooks/block-dangerous-git.sh`
|
||||||
|
- **Global**: `~/.claude/hooks/block-dangerous-git.sh`
|
||||||
|
|
||||||
|
Make it executable with `chmod +x`.
|
||||||
|
|
||||||
|
### 3. Add hook to settings
|
||||||
|
|
||||||
|
Add to the appropriate settings file:
|
||||||
|
|
||||||
|
**Project** (`.claude/settings.json`):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"PreToolUse": [
|
||||||
|
{
|
||||||
|
"matcher": "Bash",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Global** (`~/.claude/settings.json`):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"PreToolUse": [
|
||||||
|
{
|
||||||
|
"matcher": "Bash",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "~/.claude/hooks/block-dangerous-git.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If the settings file already exists, merge the hook into the existing `hooks.PreToolUse` array. Don't overwrite other settings.
|
||||||
|
|
||||||
|
### 4. Ask about customization
|
||||||
|
|
||||||
|
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
|
||||||
|
|
||||||
|
### 5. Verify
|
||||||
|
|
||||||
|
Run a quick test:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
|
||||||
|
```
|
||||||
|
|
||||||
|
Should exit with code 2 and print a BLOCKED message to stderr.
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
INPUT=$(cat)
|
||||||
|
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command')
|
||||||
|
|
||||||
|
DANGEROUS_PATTERNS=(
|
||||||
|
"git push"
|
||||||
|
"git reset --hard"
|
||||||
|
"git clean -fd"
|
||||||
|
"git clean -f"
|
||||||
|
"git branch -D"
|
||||||
|
"git checkout \."
|
||||||
|
"git restore \."
|
||||||
|
"push --force"
|
||||||
|
"reset --hard"
|
||||||
|
)
|
||||||
|
|
||||||
|
for pattern in "${DANGEROUS_PATTERNS[@]}"; do
|
||||||
|
if echo "$COMMAND" | grep -qE "$pattern"; then
|
||||||
|
echo "BLOCKED: '$COMMAND' matches dangerous pattern '$pattern'. The user has prevented you from doing this." >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: grill-me
|
||||||
|
description: A relentless interview to sharpen a plan or design.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Call the Skill tool with "grilling".
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: grill-with-docs
|
||||||
|
description: A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Call the Skill tool twice, for "grilling" and "domain-modeling".
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
---
|
||||||
|
name: grilling
|
||||||
|
description: Grill the user relentlessly about a plan, decision, or idea. Use when the user wants to stress-test their thinking, or uses any 'grill' trigger phrases.
|
||||||
|
---
|
||||||
|
|
||||||
|
Interview the user relentlessly until you reach a shared understanding. Map this as a **design tree**: every decision branches into the decisions that hang off it.
|
||||||
|
|
||||||
|
Work the tree in **rounds**. The **frontier** is every decision whose prerequisites are already settled: the questions you can ask _now_ without guessing at answers you haven't heard yet. Ask the whole frontier in one round: number each question and give your recommended answer. Then wait for the user's answers before the next round.
|
||||||
|
|
||||||
|
Format a round like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
❓ **Q1** - **<question title>**: <question body, might be multiple paragraphs, including multiple choices>
|
||||||
|
|
||||||
|
➡️ <your recommended answer>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
❓ **Q2** - **<question title>**: <question body, might be multiple paragraphs, including multiple choices>
|
||||||
|
|
||||||
|
➡️ <your recommended answer>
|
||||||
|
```
|
||||||
|
|
||||||
|
Word each question so "yes" accepts your recommended answer.
|
||||||
|
|
||||||
|
Each round the user answers reshapes the tree: settled decisions push the frontier outward and unblock questions that depended on them. Recompute the frontier and ask the next round. A question whose answer depends on another question still open in this round belongs to a _later_ round, not this one.
|
||||||
|
|
||||||
|
Finding _facts_ is your job, never the user's. When a frontier question needs a fact from the environment (filesystem, tools, etc.), dispatch a sub-agent to find it; don't ask the user for anything you could look up yourself. Don't block on it: a running exploration is an unsettled prerequisite, so only the questions downstream of it wait for the sub-agent to report; ask the rest of the frontier now. The _decisions_ are the user's: put each to them and wait.
|
||||||
|
|
||||||
|
The session is done when the frontier is empty: every branch of the design tree visited, nothing left silently assumed. Do not act on it until the user confirms you have reached a shared understanding.
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
name: handoff
|
||||||
|
description: Compact the current conversation into a handoff document for another agent to pick up.
|
||||||
|
argument-hint: "What will the next session be used for?"
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Write a handoff document summarising the current conversation so a fresh agent can continue the work. Save to the temporary directory of the user's OS (`$TMPDIR`, else `/tmp`; `%TEMP%` on Windows) - not the current workspace.
|
||||||
|
|
||||||
|
Include a "suggested skills" section in the document, naming which skills the next agent should call the Skill tool for.
|
||||||
|
|
||||||
|
Do not duplicate content already captured in other artifacts (specs, plans, ADRs, issues, commits, diffs). Reference them by path or URL instead.
|
||||||
|
|
||||||
|
Redact any sensitive information, such as API keys, passwords, or personally identifiable information.
|
||||||
|
|
||||||
|
If the user passed arguments, treat them as a description of what the next session will focus on and tailor the doc accordingly.
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
---
|
||||||
|
name: implement-spec
|
||||||
|
description: "Implement the result of /to-spec and /to-tickets in code."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
You have been provided a spec. This spec should have tickets associated with it, describing how to implement the spec.
|
||||||
|
|
||||||
|
The issue tracker should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`.
|
||||||
|
|
||||||
|
The goal is the entire spec implemented on a single **integration branch**, with every ticket resolved the way the issue tracker closes work.
|
||||||
|
|
||||||
|
The tickets are not a list of steps. They are a **task graph** with blocking relationships between them. This means there is always a **frontier** of tickets which are ready to be grabbed.
|
||||||
|
|
||||||
|
Communication to and from subagents should be sparse. Communicate primarily through **context pointers**: to the spec, tickets, research notes, and previous commits. Don't duplicate information already available via pointers.
|
||||||
|
|
||||||
|
**Implementer subagents** should be run in the background where possible for maximum concurrency.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. Read the spec and tickets to understand the task graph.
|
||||||
|
|
||||||
|
2. (optional) Use an **exploration subagent** to conduct any exploration required by the tickets - relevant codebase files or external documentation. Ensure the exploration subagent can save files - it should save its markdown notes in a directory outside the repo, accessible by all future subagents. This lets **implementer subagents** focus on implementation rather than exploration.
|
||||||
|
|
||||||
|
3. Create the integration branch. If the issue tracker closes work through PRs, or the user asks for one, open a draft PR after the first merge in step 5 (a branch with no commits ahead of main can't open one), marked as closing the spec and tickets.
|
||||||
|
|
||||||
|
4. Use **implementer subagents** to implement each ticket, each in its own worktree on its own branch. Each implementer subagent:
|
||||||
|
- confirms its worktree is based on the integration branch before starting, and resets onto it if not;
|
||||||
|
- calls the Skill tool with `tdd` to build the ticket;
|
||||||
|
- merges the integration branch tip into its own branch before reporting done
|
||||||
|
|
||||||
|
5. Once an **implementer subagent** completes, merge its work to the integration branch with a **merger subagent**.
|
||||||
|
|
||||||
|
6. If this changes the **frontier** of available tickets, kick off more **implementer subagents** to work on the new tickets. This allows for maximum concurrency.
|
||||||
|
|
||||||
|
7. Once all tickets are complete, call the Skill tool with `code-review` on the integration branch. Fix all issues raised by the code review in a single **implementer subagent**.
|
||||||
|
|
||||||
|
8. If a draft PR exists, mark it ready for review. Otherwise, resolve each ticket the way the issue tracker closes work, and report the integration branch.
|
||||||
|
|
||||||
|
9. Clean up all **implementer subagent** worktrees.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
name: implement
|
||||||
|
description: "Implement a piece of work based on a spec or set of tickets."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Implement the work described by the user in the spec or tickets.
|
||||||
|
|
||||||
|
If the user passes a ticket reference, fetch it from the issue tracker and state its title before starting. If the reference is ambiguous, ask.
|
||||||
|
|
||||||
|
Call the Skill tool with "tdd" where possible, at pre-agreed seams.
|
||||||
|
|
||||||
|
Run typechecking regularly, single test files regularly, and the full test suite once at the end.
|
||||||
|
|
||||||
|
Once done, call the Skill tool with "code-review" to review the work.
|
||||||
|
|
||||||
|
Commit your work to the current branch.
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
# HTML Report Format
|
||||||
|
|
||||||
|
The architectural review is rendered as a single self-contained HTML file in the OS temp directory. Tailwind and Mermaid both come from CDNs. Mermaid handles graph-shaped diagrams reliably; hand-built divs and inline SVG handle the more editorial visuals (mass diagrams, cross-sections). Mix the two: don't lean on Mermaid for everything, it'll start to look generic.
|
||||||
|
|
||||||
|
## Scaffold
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>Architecture review for {{repo name}}</title>
|
||||||
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<script type="module">
|
||||||
|
import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs";
|
||||||
|
mermaid.initialize({ startOnLoad: true, theme: "neutral", securityLevel: "loose" });
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
/* small custom layer for things Tailwind doesn't cover cleanly:
|
||||||
|
dashed seam lines, hand-drawn-feeling arrow heads, etc. */
|
||||||
|
.seam { stroke-dasharray: 4 4; }
|
||||||
|
.leak { stroke: #dc2626; }
|
||||||
|
.deep { background: linear-gradient(135deg, #0f172a, #1e293b); }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body class="bg-stone-50 text-slate-900 font-sans">
|
||||||
|
<main class="max-w-5xl mx-auto px-6 py-12 space-y-12">
|
||||||
|
<header>...</header>
|
||||||
|
<section id="candidates" class="space-y-10">...</section>
|
||||||
|
<section id="top-recommendation">...</section>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Header
|
||||||
|
|
||||||
|
Repo name, date, and a compact legend: solid box = module, dashed line = seam, red arrow = leakage, thick dark box = deep module. No introduction paragraph. Straight into the candidates.
|
||||||
|
|
||||||
|
## Candidate card
|
||||||
|
|
||||||
|
The diagrams carry the weight. Prose is sparse, plain, and uses the glossary terms (from the `/codebase-design` skill) without ceremony.
|
||||||
|
|
||||||
|
Each candidate is one `<article>`:
|
||||||
|
|
||||||
|
- **Title**: short, names the deepening (e.g. "Collapse the Order intake pipeline").
|
||||||
|
- **Badge row**: recommendation strength (`Strong` = emerald, `Worth exploring` = amber, `Speculative` = slate), plus a tag for the dependency category (`in-process`, `local-substitutable`, `ports & adapters`, `mock`).
|
||||||
|
- **Files**: monospaced list, `font-mono text-sm`.
|
||||||
|
- **Before / After diagram**: the centrepiece. Two columns, side by side. See patterns below.
|
||||||
|
- **Problem**: one sentence. What hurts.
|
||||||
|
- **Solution**: one sentence. What changes.
|
||||||
|
- **Wins**: bullets, ≤6 words each. e.g. "Tests hit one interface", "Pricing logic stops leaking", "Delete 4 shallow wrappers".
|
||||||
|
- **ADR callout** (if applicable): one line in an amber-tinted box.
|
||||||
|
|
||||||
|
No paragraphs of explanation. If the diagram needs a paragraph to be understood, redraw the diagram.
|
||||||
|
|
||||||
|
## Diagram patterns
|
||||||
|
|
||||||
|
Pick the pattern that fits the candidate. Mix them. Don't make every diagram look the same. Variety is part of the point.
|
||||||
|
|
||||||
|
### Mermaid graph (the workhorse for dependencies / call flow)
|
||||||
|
|
||||||
|
Use a Mermaid `flowchart` or `graph` when the point is "X calls Y calls Z, and look at the mess." Wrap it in a Tailwind-styled card so it doesn't feel parachuted in. Style with classDef to colour leakage edges red and the deep module dark. Sequence diagrams work well for "before: 6 round-trips; after: 1."
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div class="rounded-lg border border-slate-200 bg-white p-4">
|
||||||
|
<pre class="mermaid">
|
||||||
|
flowchart LR
|
||||||
|
A[OrderHandler] --> B[OrderValidator]
|
||||||
|
B --> C[OrderRepo]
|
||||||
|
C -.leak.-> D[PricingClient]
|
||||||
|
classDef leak stroke:#dc2626,stroke-width:2px;
|
||||||
|
class C,D leak
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Hand-built boxes-and-arrows (when Mermaid's layout fights you)
|
||||||
|
|
||||||
|
Modules as `<div>`s with borders and labels. Arrows as inline SVG `<line>` or `<path>` elements positioned absolutely over a relative container. Reach for this when you want the "after" diagram to feel like one thick-bordered deep module with greyed-out internals, since Mermaid won't render that with the right weight.
|
||||||
|
|
||||||
|
### Cross-section (good for layered shallowness)
|
||||||
|
|
||||||
|
Stack horizontal bands (`h-12 border-l-4`) to show layers a call passes through. Before: 6 thin layers each doing nothing. After: 1 thick band labelled with the consolidated responsibility.
|
||||||
|
|
||||||
|
### Mass diagram (good for "interface as wide as implementation")
|
||||||
|
|
||||||
|
Two rectangles per module: one for interface surface area, one for implementation. Before: interface rectangle is nearly as tall as the implementation rectangle (shallow). After: interface rectangle is short, implementation rectangle is tall (deep).
|
||||||
|
|
||||||
|
### Call-graph collapse
|
||||||
|
|
||||||
|
Before: a tree of function calls rendered as nested boxes. After: the same tree collapsed into one box, with the now-internal calls shown faded inside it.
|
||||||
|
|
||||||
|
## Style guidance
|
||||||
|
|
||||||
|
- Lean editorial, not corporate-dashboard. Generous whitespace. Serif optional for headings (`font-serif` works well with stone/slate).
|
||||||
|
- Colour sparingly: one accent (emerald or indigo) plus red for leakage and amber for warnings.
|
||||||
|
- Keep diagrams ~320px tall so before/after sits comfortably side by side without scrolling.
|
||||||
|
- Use `text-xs uppercase tracking-wider` for module labels inside diagrams, so they read as schematic, not as UI.
|
||||||
|
- The only scripts are the Tailwind CDN and the Mermaid ESM import. The report is otherwise static: no app code, no interactivity beyond Mermaid's own rendering.
|
||||||
|
|
||||||
|
## Top recommendation section
|
||||||
|
|
||||||
|
One larger card. Candidate name, one sentence on why, anchor link to its card. That's it.
|
||||||
|
|
||||||
|
## Tone
|
||||||
|
|
||||||
|
Plain English, concise, but the architectural nouns and verbs come straight from the `/codebase-design` skill. Concision is not an excuse to drift.
|
||||||
|
|
||||||
|
**Use exactly:** module, interface, implementation, depth, deep, shallow, seam, adapter, leverage, locality.
|
||||||
|
|
||||||
|
**Never substitute:** component, service, unit (for module) · API, signature (for interface) · boundary (for seam) · layer, wrapper (for module, when you mean module).
|
||||||
|
|
||||||
|
**Phrasings that fit the style:**
|
||||||
|
|
||||||
|
- "Order intake module is shallow: interface nearly matches the implementation."
|
||||||
|
- "Pricing leaks across the seam."
|
||||||
|
- "Deepen: one interface, one place to test."
|
||||||
|
- "Two adapters justify the seam: HTTP in prod, in-memory in tests."
|
||||||
|
|
||||||
|
**Wins bullets** name the gain in glossary terms: *"locality: bugs concentrate in one module"*, *"leverage: one interface, N call sites"*, *"interface shrinks; implementation absorbs the wrappers"*. Don't write *"easier to maintain"* or *"cleaner code"*, because those terms aren't in the glossary and don't earn their place.
|
||||||
|
|
||||||
|
No hedging, no throat-clearing, no "it's worth noting that…". If a sentence could be a bullet, make it a bullet. If a bullet could be cut, cut it. If a term isn't in the `/codebase-design` glossary, reach for one that is before inventing a new one.
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
name: improve-codebase-architecture
|
||||||
|
description: Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Improve Codebase Architecture
|
||||||
|
|
||||||
|
Surface architectural friction and propose **deepening opportunities**: refactors that turn shallow modules into deep ones. The aim is testability and AI-navigability.
|
||||||
|
|
||||||
|
This command is _informed_ by the project's domain model and built on a shared design vocabulary:
|
||||||
|
|
||||||
|
- Call the Skill tool with "codebase-design" for the architecture vocabulary (**module**, **interface**, **depth**, **seam**, **adapter**, **leverage**, **locality**) and its principles (the deletion test, "the interface is the test surface", "one adapter = hypothetical seam, two = real"). Use these terms exactly in every suggestion, and don't drift into "component," "service," "API," or "boundary."
|
||||||
|
- The domain language in `GLOSSARY.md` gives names to good seams; ADRs in `docs/adr/` record decisions this command should not re-litigate.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Explore
|
||||||
|
|
||||||
|
**Scope before you scan: YAGNI.** Deepening a module pays off by making future changes to it easier, so put extra weight on the parts of the codebase that have recently changed. Decide *where* to look before you look:
|
||||||
|
|
||||||
|
- If the user named a direction (a module, a subsystem, a pain point), take it, and skip the inference below.
|
||||||
|
- Otherwise, walk back a good stretch of the commit history (`git log --oneline`) to find the codebase's hot spots, the files and areas that keep coming up, and let those paths pull your attention first. If the changes are scattered with no clear hot spot, widen the net.
|
||||||
|
|
||||||
|
Read the project's domain glossary (`GLOSSARY.md`) and any ADRs in the area you're touching first.
|
||||||
|
|
||||||
|
Then spawn a sub-agent to walk the codebase. Don't follow rigid heuristics; explore organically and note where you experience friction:
|
||||||
|
|
||||||
|
- Where does understanding one concept require bouncing between many small modules?
|
||||||
|
- Where are modules **shallow**, with an interface nearly as complex as the implementation?
|
||||||
|
- Where have pure functions been extracted just for testability, but the real bugs hide in how they're called (no **locality**)?
|
||||||
|
- Where do tightly-coupled modules leak across their seams?
|
||||||
|
- Which parts of the codebase are untested, or hard to test through their current interface?
|
||||||
|
|
||||||
|
Apply the **deletion test** to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.
|
||||||
|
|
||||||
|
### 2. Present candidates as an HTML report
|
||||||
|
|
||||||
|
Write a self-contained HTML file to the OS temp directory so nothing lands in the repo. Resolve the temp dir from `$TMPDIR`, falling back to `/tmp` (or `%TEMP%` on Windows), and write to `<tmpdir>/architecture-review-<timestamp>.html` so each run gets a fresh file. Open it for the user (`xdg-open <path>` on Linux, `open <path>` on macOS, `start <path>` on Windows) and tell them the absolute path.
|
||||||
|
|
||||||
|
The report uses **Tailwind via CDN** for layout and styling, and **Mermaid via CDN** for diagrams where a graph/flow/sequence reliably communicates the structure. Mix Mermaid with hand-crafted CSS/SVG visuals: use Mermaid when relationships are graph-shaped (call graphs, dependencies, sequences), and hand-built divs/SVG when you want something more editorial (mass diagrams, cross-sections, collapse animations). Each candidate gets a **before/after visualisation**. Be visual.
|
||||||
|
|
||||||
|
For each candidate, render a card with:
|
||||||
|
|
||||||
|
- **Files**: which files/modules are involved
|
||||||
|
- **Problem**: why the current architecture is causing friction
|
||||||
|
- **Solution**: plain English description of what would change
|
||||||
|
- **Benefits**: explained in terms of locality and leverage, and how tests would improve
|
||||||
|
- **Before / After diagram**: side-by-side, custom-drawn, illustrating the shallowness and the deepening
|
||||||
|
- **Recommendation strength**: one of `Strong`, `Worth exploring`, `Speculative`, rendered as a badge
|
||||||
|
|
||||||
|
End the report with a **Top recommendation** section: which candidate you'd tackle first and why.
|
||||||
|
|
||||||
|
**Use GLOSSARY.md vocabulary for the domain, and the `/codebase-design` vocabulary for the architecture.** If `GLOSSARY.md` defines "Order," talk about "the Order intake module," not "the FooBarHandler," and not "the Order service."
|
||||||
|
|
||||||
|
**ADR conflicts**: if a candidate contradicts an existing ADR, only surface it when the friction is real enough to warrant revisiting the ADR. Mark it clearly in the card (e.g. a warning callout: _"contradicts ADR-0007, but worth reopening because…"_). Don't list every theoretical refactor an ADR forbids.
|
||||||
|
|
||||||
|
See [HTML-REPORT.md](HTML-REPORT.md) for the full HTML scaffold, diagram patterns, and styling guidance.
|
||||||
|
|
||||||
|
Do NOT propose interfaces yet. After the file is written, ask the user: "Which of these would you like to explore?"
|
||||||
|
|
||||||
|
### 3. Grilling loop
|
||||||
|
|
||||||
|
Once the user picks a candidate, call the Skill tool with "grilling" to walk the decision tree with them: constraints, dependencies, the shape of the deepened module, what sits behind the seam, what tests survive.
|
||||||
|
|
||||||
|
Side effects happen inline as decisions crystallize; call the Skill tool with "domain-modeling" to keep the domain model current as you go:
|
||||||
|
|
||||||
|
- **Naming a deepened module after a concept not in `GLOSSARY.md`?** Add the term to `GLOSSARY.md`. Create the file lazily if it doesn't exist.
|
||||||
|
- **Sharpening a fuzzy term during the conversation?** Update `GLOSSARY.md` right there.
|
||||||
|
- **User rejects the candidate with a load-bearing reason?** Offer an ADR, framed as: _"Want me to record this as an ADR so future architecture reviews don't re-suggest it?"_ Only offer when the reason would actually be needed by a future explorer to avoid re-suggesting the same thing; skip ephemeral reasons ("not worth it right now") and self-evident ones.
|
||||||
|
- **Want to explore alternative interfaces for the deepened module?** Call the Skill tool with "codebase-design" and use its design-it-twice parallel sub-agent pattern.
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
---
|
||||||
|
name: migrate-to-shoehorn
|
||||||
|
description: Migrate test files from `as` type assertions to @total-typescript/shoehorn. Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Migrate to Shoehorn
|
||||||
|
|
||||||
|
## Why shoehorn?
|
||||||
|
|
||||||
|
`shoehorn` lets you pass partial data in tests while keeping TypeScript happy. It replaces `as` assertions with type-safe alternatives.
|
||||||
|
|
||||||
|
**Test code only.** Never use shoehorn in production code.
|
||||||
|
|
||||||
|
Problems with `as` in tests:
|
||||||
|
|
||||||
|
- Trained not to use it
|
||||||
|
- Must manually specify target type
|
||||||
|
- Double-as (`as unknown as Type`) for intentionally wrong data
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm i @total-typescript/shoehorn
|
||||||
|
```
|
||||||
|
|
||||||
|
## Migration patterns
|
||||||
|
|
||||||
|
### Large objects with few needed properties
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
type Request = {
|
||||||
|
body: { id: string };
|
||||||
|
headers: Record<string, string>;
|
||||||
|
cookies: Record<string, string>;
|
||||||
|
// ...20 more properties
|
||||||
|
};
|
||||||
|
|
||||||
|
it("gets user by id", () => {
|
||||||
|
// Only care about body.id but must fake entire Request
|
||||||
|
getUser({
|
||||||
|
body: { id: "123" },
|
||||||
|
headers: {},
|
||||||
|
cookies: {},
|
||||||
|
// ...fake all 20 properties
|
||||||
|
});
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { fromPartial } from "@total-typescript/shoehorn";
|
||||||
|
|
||||||
|
it("gets user by id", () => {
|
||||||
|
getUser(
|
||||||
|
fromPartial({
|
||||||
|
body: { id: "123" },
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### `as Type` → `fromPartial()`
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
getUser({ body: { id: "123" } } as Request);
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { fromPartial } from "@total-typescript/shoehorn";
|
||||||
|
|
||||||
|
getUser(fromPartial({ body: { id: "123" } }));
|
||||||
|
```
|
||||||
|
|
||||||
|
### `as unknown as Type` → `fromAny()`
|
||||||
|
|
||||||
|
Before:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
getUser({ body: { id: 123 } } as unknown as Request); // wrong type on purpose
|
||||||
|
```
|
||||||
|
|
||||||
|
After:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { fromAny } from "@total-typescript/shoehorn";
|
||||||
|
|
||||||
|
getUser(fromAny({ body: { id: 123 } }));
|
||||||
|
```
|
||||||
|
|
||||||
|
## When to use each
|
||||||
|
|
||||||
|
| Function | Use case |
|
||||||
|
| --------------- | -------------------------------------------------- |
|
||||||
|
| `fromPartial()` | Pass partial data that still type-checks |
|
||||||
|
| `fromAny()` | Pass intentionally wrong data (keeps autocomplete) |
|
||||||
|
| `fromExact()` | Force full object (swap with fromPartial later) |
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. **Gather requirements** - ask user:
|
||||||
|
- What test files have `as` assertions causing problems?
|
||||||
|
- Are they dealing with large objects where only some properties matter?
|
||||||
|
- Do they need to pass intentionally wrong data for error testing?
|
||||||
|
|
||||||
|
2. **Install and migrate**:
|
||||||
|
- [ ] Install: `npm i @total-typescript/shoehorn`
|
||||||
|
- [ ] Find test files with `as` assertions: `grep -r " as [A-Z]" --include="*.test.ts" --include="*.spec.ts"`
|
||||||
|
- [ ] Replace `as Type` with `fromPartial()`
|
||||||
|
- [ ] Replace `as unknown as Type` with `fromAny()`
|
||||||
|
- [ ] Add imports from `@total-typescript/shoehorn`
|
||||||
|
- [ ] Run type check to verify
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# Credits
|
||||||
|
|
||||||
|
The **Summary** section's menu of visuals (pseudocode, call trees, component trees, file trees, Mermaid, diffs) and its placement guidance come from [Dex Horthy](https://github.com/dexhorthy)'s [`show-me`](https://github.com/humanlayer/humanlayer) skill, reproduced almost word for word and aimed at a diff instead of a live conversation. `pr` does not depend on `show-me` as a skill (it isn't part of this repo, and a hard dependency would break standalone installs), so the content is copied in rather than pointed at; this file is the attribution a dependency would otherwise have carried.
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
---
|
||||||
|
name: pr
|
||||||
|
description: "Use when writing a PR body."
|
||||||
|
metadata:
|
||||||
|
credits:
|
||||||
|
skill: show-me
|
||||||
|
author: Dex Horthy
|
||||||
|
organisation: Humanlayer
|
||||||
|
url: "https://github.com/humanlayer/skills/blob/main/plugins/show-me/skills/show-me/SKILL.md"
|
||||||
|
---
|
||||||
|
|
||||||
|
Use this template for writing the PR body:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
<diagram, diff-sketch, or tree>
|
||||||
|
|
||||||
|
## Evidence
|
||||||
|
|
||||||
|
- **Before:** <screenshot/output/failing test run>
|
||||||
|
**After:** <screenshot/output/passing test run>
|
||||||
|
|
||||||
|
## Merge Danger
|
||||||
|
|
||||||
|
**Door:** <one-way or two-way>
|
||||||
|
|
||||||
|
<optional: description>
|
||||||
|
|
||||||
|
**Blast Radius:** <one-word description>
|
||||||
|
|
||||||
|
<optional: potential ramifications of merge>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Sections
|
||||||
|
|
||||||
|
Skip all preambles and keep prose brief. Use the user's domain language from `GLOSSARY.md`.
|
||||||
|
|
||||||
|
### Summary
|
||||||
|
|
||||||
|
Pick the smallest view that makes the key point clear.
|
||||||
|
|
||||||
|
- Show logic or an algorithm as pseudocode:
|
||||||
|
|
||||||
|
```text
|
||||||
|
on(save)
|
||||||
|
if content is unchanged
|
||||||
|
return cached result
|
||||||
|
write new content
|
||||||
|
return fresh result
|
||||||
|
```
|
||||||
|
|
||||||
|
- Show runtime control flow as a call tree:
|
||||||
|
|
||||||
|
```text
|
||||||
|
submitForm
|
||||||
|
createSession
|
||||||
|
persistPrompt
|
||||||
|
launchAgent
|
||||||
|
navigateToSession
|
||||||
|
```
|
||||||
|
|
||||||
|
- Show UI structure as a component tree, including state and module boundaries that matter:
|
||||||
|
|
||||||
|
```text
|
||||||
|
<SessionPage> (apps/example/src/routes/session.tsx)
|
||||||
|
useSessionEvents()
|
||||||
|
<SessionToolbar>
|
||||||
|
<RunSkillButton> (packages/ui)
|
||||||
|
```
|
||||||
|
|
||||||
|
- Show file responsibility or a broad refactor as a shallow file tree:
|
||||||
|
|
||||||
|
```text
|
||||||
|
src/
|
||||||
|
├── commands/ # parses user actions
|
||||||
|
├── sessions/ # owns session state
|
||||||
|
└── transport/ # sends API requests
|
||||||
|
```
|
||||||
|
|
||||||
|
- Show component interaction, control flow, or data flow with Mermaid:
|
||||||
|
|
||||||
|
```mermaid
|
||||||
|
sequenceDiagram
|
||||||
|
participant User
|
||||||
|
participant UI
|
||||||
|
participant Daemon
|
||||||
|
User->>UI: choose command
|
||||||
|
UI->>Daemon: send expanded prompt
|
||||||
|
Daemon-->>UI: stream result
|
||||||
|
```
|
||||||
|
|
||||||
|
- Use `diff` when the point is what changes and the surrounding shape already exists. Match the diff shape to the topic.
|
||||||
|
|
||||||
|
For a component change:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
<SessionPage>
|
||||||
|
useSessionEvents()
|
||||||
|
<SessionToolbar>
|
||||||
|
+ <RunSkillButton />
|
||||||
|
<SessionTimeline>
|
||||||
|
+ <SkillResultCard />
|
||||||
|
```
|
||||||
|
|
||||||
|
For a file-layout change:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
src/
|
||||||
|
├── commands/
|
||||||
|
+│ └── show-me.ts # expands the slash command
|
||||||
|
├── sessions/
|
||||||
|
-└── transport.ts
|
||||||
|
+└── transport/
|
||||||
|
+ ├── client.ts
|
||||||
|
+ └── stream.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
For a call-tree or call-stack change:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
submitForm
|
||||||
|
createSession
|
||||||
|
persistPrompt
|
||||||
|
+ expandSkillMention
|
||||||
|
launchAgent
|
||||||
|
- navigateToSession
|
||||||
|
+ navigateToSession
|
||||||
|
+ subscribeToEvents
|
||||||
|
```
|
||||||
|
|
||||||
|
For a state or control-flow change:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
on(save)
|
||||||
|
- write content
|
||||||
|
+ if content is unchanged
|
||||||
|
+ return cached result
|
||||||
|
+ write new content
|
||||||
|
+ invalidate cache
|
||||||
|
```
|
||||||
|
|
||||||
|
- Show the whole block when most of it is new, when omitted context would hide ownership or order, or when the user needs a copyable target shape:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
function expandSkill(command: string): string {
|
||||||
|
const skillName = command.slice(1);
|
||||||
|
return `use the ${skillName} skill`;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Guidance
|
||||||
|
|
||||||
|
Place each visual next to the short text it supports. Keep only the calls, files, props, states, and boundaries needed to answer the user's current question or the options to resolve the current discussion point.
|
||||||
|
|
||||||
|
You may use one of these, you may use several, it is unlikely you will use all of them. Use your judgement and don't overwhelm the user.
|
||||||
|
|
||||||
|
### Evidence
|
||||||
|
|
||||||
|
Concrete evidence that the change works. Show a before and after.
|
||||||
|
|
||||||
|
Screenshots are S-tier - when the environment is set up for it and the change is visual.
|
||||||
|
|
||||||
|
Execution-based evidence is A-tier. Test results, console output. Show the exact test that now fails and passes, using pseudocode.
|
||||||
|
|
||||||
|
### Merge Danger
|
||||||
|
|
||||||
|
Describe whether it's a one-way or two-way door. You can walk back through two-way doors, but not one-way doors. A PR that is cheap to roll back is lower risk. Changes that involve destructive actions or hard-to-reverse decisions are one-way doors.
|
||||||
|
|
||||||
|
The blast radius is the potential impact or scope of the changes introduced by this PR. Consider all possibilities. Examples are layout shift, breakages for consumers, mobile responsiveness, etc.
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# Logic Prototype
|
||||||
|
|
||||||
|
A single, self-contained HTML file (a **shareable demo**) that lets anyone drive a state model by clicking buttons. Use this when the question is about **business logic, state transitions, or data shape**: the kind of thing that looks reasonable on paper but only feels wrong once you push it through real cases.
|
||||||
|
|
||||||
|
Because it's one file with nothing to install, you can hand it to a non-developer (a designer, a PM, a domain expert) and let them feel the model for themselves. So it speaks their language, not the code's.
|
||||||
|
|
||||||
|
## When this is the right shape
|
||||||
|
|
||||||
|
- "I'm not sure if this state machine handles the edge case where X then Y."
|
||||||
|
- "Does this data model actually let me represent the case where..."
|
||||||
|
- "I want to feel out what the API should look like before writing it."
|
||||||
|
- Anything where someone wants to **press buttons and watch state change**.
|
||||||
|
|
||||||
|
If the question is "what should this look like," this is the wrong branch. Use [UI.md](UI.md).
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. State the question
|
||||||
|
|
||||||
|
Before writing code, write down what state model and what question you're prototyping. One paragraph, at the top of the demo (in a visible intro, not just a comment). A logic prototype that answers the wrong question is pure waste, so make the question explicit so it can be checked later, whether the user is watching now or returning to it AFK.
|
||||||
|
|
||||||
|
### 2. Isolate the logic in a portable module
|
||||||
|
|
||||||
|
Put the actual logic (the bit that's answering the question) in a single `<script>` block written as a small, pure module that could be lifted out and dropped into the real codebase later. The page around it is throwaway; this module isn't.
|
||||||
|
|
||||||
|
The right shape depends on the question:
|
||||||
|
|
||||||
|
- **A pure reducer**: `(state, action) => state`. Good when actions are discrete events and state is a single value.
|
||||||
|
- **A state machine**: explicit states and transitions. Good when "which actions are even legal right now" is part of the question.
|
||||||
|
- **A small set of pure functions** over a plain data type. Good when there's no implicit current state, just transformations.
|
||||||
|
- **A class or module with a clear method surface** when the logic genuinely owns ongoing internal state.
|
||||||
|
|
||||||
|
Pick whichever shape best fits the question being asked, *not* whichever is easiest to wire to a page. Keep it pure: no DOM, no `document`, no button handlers reaching inside it. The page calls into it; nothing flows the other direction. This is what makes the prototype useful past its own lifetime: once the question's answered, the validated reducer / machine / function set lifts into the real module on its own.
|
||||||
|
|
||||||
|
### 3. Build the shareable HTML file
|
||||||
|
|
||||||
|
One file, plain HTML/CSS/JS: no framework, no bundler, no server, everything inline so it opens by double-click and survives being emailed around. Anyone should be able to run it by opening it.
|
||||||
|
|
||||||
|
Write it for a non-developer. Every label is in **domain language**, not code: buttons and state read like the business, not the reducer. Explain in plain words what's happening.
|
||||||
|
|
||||||
|
Lay it out with a clean hierarchy, top to bottom:
|
||||||
|
|
||||||
|
1. **Title and one-line explanation** of what this demo lets you explore (the question from step 1).
|
||||||
|
2. **Current state**: the full relevant state, rendered as a readable panel (labelled fields, not a raw JSON dump), re-rendered after every click so the change is visible. Where it helps a non-developer follow, call out what just changed.
|
||||||
|
3. **Free-play buttons**: one button per action, always available, so anyone can poke at the model in any order. Each click dispatches its action and re-renders the state.
|
||||||
|
4. **Guided walkthroughs**: a set of **scenarios**, one per tab. Each tab holds a short plain-language description of the scenario (the situation it sets up and what to watch for) and underneath it, the ordered **buttons to press** for that scenario. Each step is a real button: clicking it performs that action and moves to the next step. Starting a walkthrough resets to a known initial state so the scenario runs the same way every time.
|
||||||
|
|
||||||
|
Choose scenarios that demonstrate the awkward cases, the ones hard to reason about on paper: the happy path, a tricky edge case, an attempt at something that should be illegal.
|
||||||
|
|
||||||
|
Keep it beautiful but restrained: clean typography, generous spacing, one accent colour. No animations, no gimmicks: nothing that competes with the state and the buttons.
|
||||||
|
|
||||||
|
### 4. Hand it over
|
||||||
|
|
||||||
|
Send them the file, or open it for them. They'll click through the walkthroughs and free-play whenever they get to it; the interesting moments are when they say "wait, that shouldn't be possible" or "huh, I assumed X would be different"; those are the bugs in the _idea_, which is the whole point. If they want new actions or a new scenario, add them. Prototypes evolve.
|
||||||
|
|
||||||
|
### 5. Capture the answer and the prototype
|
||||||
|
|
||||||
|
Once the prototype has answered its question, capture the answer, then capture the prototype the way the [SKILL](SKILL.md) describes. The logic-specific mapping: the validated reducer / machine / function set lifts into the real module (the decision, absorbed); the HTML shell rides along to the throwaway branch that keeps the prototype as a primary source, and being one self-contained file, it stays trivially re-runnable there.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- **Don't add tests.** A prototype that needs tests is no longer a prototype.
|
||||||
|
- **Don't wire it to the real database.** Use in-memory state unless the question is specifically about persistence.
|
||||||
|
- **Don't generalise.** No "what if we wanted to support X later." The prototype answers one question.
|
||||||
|
- **Don't blur the logic and the page together.** If the pure module references the DOM, `document`, or button handlers, it's no longer liftable. Keep the page as a thin shell over a pure module.
|
||||||
|
- **Don't reach for a framework, bundler, or server.** One file the recipient double-clicks; a React app or a dev server defeats "shareable".
|
||||||
|
- **Don't ship the HTML shell into production.** The page is optimised for being clicked through by hand. The logic module behind it is the bit worth keeping.
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
name: prototype
|
||||||
|
description: Build a throwaway prototype to answer a design question. Use when the user wants to sanity-check whether a state model or logic feels right, or explore what a UI should look like.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Prototype
|
||||||
|
|
||||||
|
A prototype is **throwaway code that answers a question**. The question decides the shape.
|
||||||
|
|
||||||
|
## Pick a branch
|
||||||
|
|
||||||
|
Identify which question is being answered, using the user's prompt, the surrounding code, or by asking if the user is around:
|
||||||
|
|
||||||
|
- **"Does this logic / state model feel right?"** → [LOGIC.md](LOGIC.md). Build a single shareable HTML file (free-play buttons plus tabbed guided walkthroughs) that pushes the state machine through cases that are hard to reason about on paper, and that a non-developer can drive.
|
||||||
|
- **"What should this look like?"** → [UI.md](UI.md). Generate several radically different UI variations on a single route, switchable via a URL search param and a floating bottom bar.
|
||||||
|
|
||||||
|
The two branches produce very different artifacts, so getting this wrong wastes the whole prototype. If the question is genuinely ambiguous and the user isn't reachable, default to whichever branch better matches the surrounding code (a backend module → logic; a page or component → UI) and state the assumption at the top of the prototype.
|
||||||
|
|
||||||
|
## Rules that apply to both
|
||||||
|
|
||||||
|
1. **Throwaway from day one, and clearly marked as such.** Locate the prototype code close to where it will actually be used (next to the module or page it's prototyping for) so context is obvious, but name it so a casual reader can see it's a prototype, not production. For throwaway UI routes, obey whatever routing convention the project already uses; don't invent a new top-level structure.
|
||||||
|
2. **Trivial to run.** A UI prototype starts from one command in the project's task runner: `pnpm <name>`, `python <path>`, `bun <path>`, etc. A logic demo is a single HTML file the user double-clicks. Either way, no thinking required to start it.
|
||||||
|
3. **No persistence by default.** State lives in memory. Persistence is the thing the prototype is _checking_, not something it should depend on. If the question explicitly involves a database, hit a scratch DB or a local file with a clear "PROTOTYPE, wipe me" name.
|
||||||
|
4. **Skip the polish.** No tests, no error handling beyond what makes the prototype _runnable_, no abstractions. The point is to learn something fast.
|
||||||
|
5. **Surface the state.** After every action (logic) or on every variant switch (UI), print or render the full relevant state so the user can see what changed.
|
||||||
|
6. **Capture it when done.** Fold any validated decision into the real code, then capture the prototype itself as a **primary source**: commit it to a throwaway branch, out of main, and leave a context pointer to that branch on the implementation issue. Capture the answer too (the verdict and the question it settled) in the issue or a commit. The main branch keeps only the validated decision.
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
# UI Prototype
|
||||||
|
|
||||||
|
Generate **several radically different UI variations** on a single route, switchable from a floating bottom bar. The user flips between variants in the browser, picks one (or steals bits from each), then throws the rest away.
|
||||||
|
|
||||||
|
If the question is about logic/state rather than what something looks like, this is the wrong branch. Use [LOGIC.md](LOGIC.md).
|
||||||
|
|
||||||
|
## When this is the right shape
|
||||||
|
|
||||||
|
- "What should this page look like?"
|
||||||
|
- "I want to see a few options for this dashboard before committing."
|
||||||
|
- "Try a different layout for the settings screen."
|
||||||
|
- Any time the user would otherwise spend a day picking between three vague mockups in their head.
|
||||||
|
|
||||||
|
## Two sub-shapes: strongly prefer sub-shape A
|
||||||
|
|
||||||
|
A UI prototype is much easier to judge when it's **butting up against the rest of the app**: real header, real sidebar, real data, real density. A throwaway route on its own is a vacuum: every variant looks fine in isolation. Default to sub-shape A whenever there's a plausible existing page to host the variants. Only reach for sub-shape B if the prototype genuinely has no nearby home.
|
||||||
|
|
||||||
|
### Sub-shape A: adjustment to an existing page (preferred)
|
||||||
|
|
||||||
|
The route already exists. Variants are rendered **on the same route**, gated by a `?variant=` URL search param. The existing data fetching, params, and auth all stay. Only the rendering swaps. This is the default; pick it unless there's a specific reason not to.
|
||||||
|
|
||||||
|
If the prototype is for something that doesn't yet have a page but *would naturally live inside one* (a new section of the dashboard, a new card on the settings screen, a new step in an existing flow), it's still sub-shape A. Mount the variants inside the host page.
|
||||||
|
|
||||||
|
### Sub-shape B: a new page (last resort)
|
||||||
|
|
||||||
|
Only use this when the thing being prototyped genuinely has no existing page to live inside (e.g. an entirely new top-level surface, or a flow that can't be embedded anywhere sensible).
|
||||||
|
|
||||||
|
Create a **throwaway route** following whatever routing convention the project already uses. Don't invent a new top-level structure. Name it so it's obviously a prototype (e.g. include the word `prototype` in the path or filename). Same `?variant=` pattern.
|
||||||
|
|
||||||
|
Before committing to sub-shape B, sanity-check: is there really no existing page this could be embedded in? An empty route hides design problems that a populated one would expose.
|
||||||
|
|
||||||
|
In both sub-shapes the floating bottom bar is identical.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. State the question and pick N
|
||||||
|
|
||||||
|
Default to **3 variants**. More than 5 stops being radically different and starts being noise, so cap there.
|
||||||
|
|
||||||
|
Write down the plan in one line, in the prototype's location or a top-of-file comment:
|
||||||
|
|
||||||
|
> "Three variants of the settings page, switchable via `?variant=`, on the existing `/settings` route."
|
||||||
|
|
||||||
|
This works whether the user is here to push back or not.
|
||||||
|
|
||||||
|
### 2. Generate radically different variants
|
||||||
|
|
||||||
|
Draft each variant. Hold each one to:
|
||||||
|
|
||||||
|
- The page's purpose and the data it has access to.
|
||||||
|
- The project's component library / styling system (TailwindCSS, shadcn, MUI, plain CSS, whatever).
|
||||||
|
- A clear exported component name, e.g. `VariantA`, `VariantB`, `VariantC`.
|
||||||
|
|
||||||
|
Variants must be **structurally different**: different layout, different information hierarchy, different primary affordance, not just different colours. Three slightly-tweaked card grids isn't a UI prototype, it's wallpaper. If two drafts come out too similar, redo one with explicit "do not use a card grid" guidance.
|
||||||
|
|
||||||
|
### 3. Wire them together
|
||||||
|
|
||||||
|
Create a single switcher component on the route:
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
// pseudo-code, adapt to the project's framework
|
||||||
|
const variant = searchParams.get('variant') ?? 'A';
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{variant === 'A' && <VariantA {...data} />}
|
||||||
|
{variant === 'B' && <VariantB {...data} />}
|
||||||
|
{variant === 'C' && <VariantC {...data} />}
|
||||||
|
<PrototypeSwitcher variants={['A','B','C']} current={variant} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
For sub-shape A (existing page): keep all the existing data fetching above the switcher; only the rendered subtree changes per variant.
|
||||||
|
|
||||||
|
For sub-shape B (new page): the throwaway route under `/prototype/<name>` mounts the same switcher.
|
||||||
|
|
||||||
|
### 4. Build the floating switcher
|
||||||
|
|
||||||
|
A small fixed-position bar at the bottom-centre of the screen with three pieces:
|
||||||
|
|
||||||
|
- **Left arrow**: cycles to the previous variant (wraps around).
|
||||||
|
- **Variant label**: shows the current variant key and, if the variant exports a name, that name too. e.g. `B (Sidebar layout)`.
|
||||||
|
- **Right arrow**: cycles forward (wraps around).
|
||||||
|
|
||||||
|
Behaviour:
|
||||||
|
|
||||||
|
- Clicking an arrow updates the URL search param (use the framework's router, e.g. `router.replace` on Next, `navigate` on React Router, etc) so the variant is shareable and reload-stable.
|
||||||
|
- Keyboard: `←` and `→` arrow keys also cycle. Don't intercept arrow keys when an `<input>`, `<textarea>`, or `[contenteditable]` is focused.
|
||||||
|
- Visually distinct from the page (e.g. high-contrast pill, subtle shadow) so it's obviously not part of the design being evaluated.
|
||||||
|
- Hidden in production builds: gate on `process.env.NODE_ENV !== 'production'` or an equivalent check, so a stray prototype merge can't ship the bar to users.
|
||||||
|
|
||||||
|
Put the switcher in a single shared component so both sub-shapes can reuse it. Locate it wherever shared UI lives in the project.
|
||||||
|
|
||||||
|
### 5. Hand it over
|
||||||
|
|
||||||
|
Surface the URL (and the `?variant=` keys). The user will flip through whenever they get to it. The interesting feedback is usually **"I want the header from B with the sidebar from C"**, which is the actual design they want.
|
||||||
|
|
||||||
|
### 6. Capture the answer and clean up
|
||||||
|
|
||||||
|
Once a variant has won, capture the answer (which variant and why), then capture the prototype the way the [SKILL](SKILL.md) describes. Fold the winner into the real code and move the rest onto the throwaway branch, not into main:
|
||||||
|
|
||||||
|
- **Sub-shape A**: fold the winner into the existing page; drop the losing variants and the switcher from main.
|
||||||
|
- **Sub-shape B**: promote the winning variant to a real route; drop the throwaway route and the switcher from main.
|
||||||
|
|
||||||
|
The full set of variants is the primary source, so it lands on the throwaway branch, not the bin, since variant components and the switcher left in the main branch rot fast and confuse the next reader.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- **Variants that differ only in colour or copy.** That's a tweak, not a prototype. Real variants disagree about structure.
|
||||||
|
- **Sharing too much code between variants.** A shared `<Header>` is fine; a shared `<Layout>` defeats the point. Each variant should be free to throw out the layout.
|
||||||
|
- **Wiring variants to real mutations.** Read-only prototypes are fine. If a variant needs to mutate, point it at a stub: the question is "what should this look like", not "does the backend work".
|
||||||
|
- **Promoting the prototype directly to production.** The variant code was written under prototype constraints (no tests, minimal error handling). Rewrite it properly when you fold it in.
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
name: research
|
||||||
|
description: Investigate a question against high-trust primary sources and capture the findings as a Markdown file in the repo. Use when the user wants a topic researched, docs or API facts gathered, or reading legwork delegated to a background agent.
|
||||||
|
---
|
||||||
|
|
||||||
|
Spin up a **background agent** to do the research, so you keep working while it reads.
|
||||||
|
|
||||||
|
Its job:
|
||||||
|
|
||||||
|
1. Investigate the question against **primary sources** (official docs, source code, specs, first-party APIs), not a secondary write-up of them. Follow every claim back to the source that owns it.
|
||||||
|
2. Write the findings to a single Markdown file, citing each claim's source.
|
||||||
|
3. Save it where the repo already keeps such notes; match the existing convention, and if there is none, put it somewhere sensible and say where.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
name: retro
|
||||||
|
description: "Conduct a retrospective on a coding session."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
The user has asked for a **retrospective**. You are suggesting improvements to the coding agent's **environment** to improve future runs.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. Call the Skill tool with `writing-for-agents` for the writing style guide.
|
||||||
|
|
||||||
|
2. Read the primary sources for the session the user specifies. This may mean searching through session logs on this machine. If the user doesn't specify a session, default to the current one.
|
||||||
|
|
||||||
|
3. Look for candidates for improvement in these categories.
|
||||||
|
|
||||||
|
- **Navigation**: how easy was it for the agent to find the right files? Are there hidden dependencies between files? Would a **navigation pointer** make it easier? _Use when_ the session took a long time to find a piece of information.
|
||||||
|
- **Automated checks**: are there automated checks that could catch errors the agent made? Linting, typing, tests, filesystem linters? Read the repo's own check command first (its `package.json`/build-tool `lint`/`check` scripts, its CI workflow), so a check that already exists but sits unwired or silently broken is the finding, not a reinvention. A repo with no **guardrail** (no pre-commit hook and no CI job running its lint/typecheck/test command) is itself a finding: an un-linted repo is a standing missed opportunity, not a neutral default. _Use when_ the agent made a mistake an automated check could have caught, or the repo has no guardrail at all.
|
||||||
|
- **Coding standards**: should the **reviewer agent** be given a new rule to enforce? Should an existing rule be removed or clarified? Classify the violation first: a **mechanical** one (a fixed syntactic pattern, a banned API, an import shape, a file-location rule) gets a deterministic check, full stop: a custom rule in the repo's own linter, a new pre-commit hook, or a new CI job, whichever the repo's language and existing guardrail make cheapest. Default to building the check over writing the rule. Reserve `CODING_STANDARDS.md` for genuine **judgement calls** (cross-file consistency, "matches the surrounding style," anything no guardrail could ever substitute for). _Use when_ the reviewer agent failed to catch a mistake.
|
||||||
|
- **Global AGENTS.md**: are there any steering instructions that should be moved to coding standards (or automated checks) instead? _Use when_ the AGENTS.md file is particularly large - in the repo OR the user's global scope.
|
||||||
|
- **Tool economy**: did the agent make expensive tool calls that could be streamlined? Is there any custom tooling (CLI's, MCP's) that is particularly token-inefficient? _Use when_ the agent made an expensive tool call.
|
||||||
|
- **No-ops**: look for instructions in steering files that don't modify the agent's behavior. _Use when_ the steering files are large and unwieldy.
|
||||||
|
- **Information access**: look for opportunities to increase the agent's access to information. Teeing dev server logs, readonly access to third-party services. _Use when_ a crucial piece of information was not available to the agent.
|
||||||
|
|
||||||
|
4. Present these candidates to the user, in order of severity.
|
||||||
|
|
||||||
|
## Reference
|
||||||
|
|
||||||
|
### Implementation vs Review
|
||||||
|
|
||||||
|
Remember that all work goes through two stages: implementation and review. The implementation agent has the most **context pressure**. They are responsible for exploration, writing code, and debugging failures.
|
||||||
|
|
||||||
|
The review agent has the least context pressure - it receives a diff, so no exploration needed. It often does not need to write code or debug.
|
||||||
|
|
||||||
|
This means that the review agent should be responsible for imposing coding standards, not the implementation agent.
|
||||||
|
|
||||||
|
### Files
|
||||||
|
|
||||||
|
You have access to several files in the repo:
|
||||||
|
|
||||||
|
- `CLAUDE.md`/`AGENTS.md`: these files are pushed to the context window of any agent working in this repo. They should be used incredibly sparingly, usually only for **navigation pointers** to other files.
|
||||||
|
- `CODING_STANDARDS.md`: this file is read during review, not implementation. Add **navigation pointers** to docs folders if the standards file gets more than 1,000 lines long.
|
||||||
|
- Docs: use docs as references files, pointed to by other files. Look for existing docs before writing new ones.
|
||||||
|
- Skills: use skills for docs (since their description goes into the agent's context window), or for user-invoked commands. Follow the advice in the `writing-for-agents` skill.
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
---
|
||||||
|
name: scaffold-exercises
|
||||||
|
description: Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Scaffold Exercises
|
||||||
|
|
||||||
|
Create exercise directory structures that pass `pnpm ai-hero-cli internal lint`, then commit with `git commit`.
|
||||||
|
|
||||||
|
## Directory naming
|
||||||
|
|
||||||
|
- **Sections**: `XX-section-name/` inside `exercises/` (e.g., `01-retrieval-skill-building`)
|
||||||
|
- **Exercises**: `XX.YY-exercise-name/` inside a section (e.g., `01.03-retrieval-with-bm25`)
|
||||||
|
- Section number = `XX`, exercise number = `XX.YY`
|
||||||
|
- Names are dash-case (lowercase, hyphens)
|
||||||
|
|
||||||
|
## Exercise variants
|
||||||
|
|
||||||
|
Each exercise needs at least one of these subfolders:
|
||||||
|
|
||||||
|
- `problem/` - student workspace with TODOs
|
||||||
|
- `solution/` - reference implementation
|
||||||
|
- `explainer/` - conceptual material, no TODOs
|
||||||
|
|
||||||
|
When stubbing, default to `explainer/` unless the plan specifies otherwise.
|
||||||
|
|
||||||
|
## Required files
|
||||||
|
|
||||||
|
Each subfolder (`problem/`, `solution/`, `explainer/`) needs a `readme.md` that:
|
||||||
|
|
||||||
|
- Is **not empty** (must have real content, even a single title line works)
|
||||||
|
- Has no broken links
|
||||||
|
|
||||||
|
When stubbing, create a minimal readme with a title and a description:
|
||||||
|
|
||||||
|
```md
|
||||||
|
# Exercise Title
|
||||||
|
|
||||||
|
Description here
|
||||||
|
```
|
||||||
|
|
||||||
|
If the subfolder has code, it also needs a `main.ts` (>1 line). But for stubs, a readme-only exercise is fine.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. **Parse the plan** - extract section names, exercise names, and variant types
|
||||||
|
2. **Create directories** - `mkdir -p` for each path
|
||||||
|
3. **Create stub readmes** - one `readme.md` per variant folder with a title
|
||||||
|
4. **Run lint** - `pnpm ai-hero-cli internal lint` to validate
|
||||||
|
5. **Fix any errors** - iterate until lint passes
|
||||||
|
|
||||||
|
## Lint rules summary
|
||||||
|
|
||||||
|
The linter (`pnpm ai-hero-cli internal lint`) checks:
|
||||||
|
|
||||||
|
- Each exercise has subfolders (`problem/`, `solution/`, `explainer/`)
|
||||||
|
- At least one of `problem/`, `explainer/`, or `explainer.1/` exists
|
||||||
|
- `readme.md` exists and is non-empty in the primary subfolder
|
||||||
|
- No `.gitkeep` files
|
||||||
|
- No `speaker-notes.md` files
|
||||||
|
- No broken links in readmes
|
||||||
|
- No `pnpm run exercise` commands in readmes
|
||||||
|
- `main.ts` required per subfolder unless it's readme-only
|
||||||
|
|
||||||
|
## Moving/renaming exercises
|
||||||
|
|
||||||
|
When renumbering or moving exercises:
|
||||||
|
|
||||||
|
1. Use `git mv` (not `mv`) to rename directories - preserves git history
|
||||||
|
2. Update the numeric prefix to maintain order
|
||||||
|
3. Re-run lint after moves
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git mv exercises/01-retrieval/01.03-embeddings exercises/01-retrieval/01.04-embeddings
|
||||||
|
```
|
||||||
|
|
||||||
|
## Example: stubbing from a plan
|
||||||
|
|
||||||
|
Given a plan like:
|
||||||
|
|
||||||
|
```
|
||||||
|
Section 05: Memory Skill Building
|
||||||
|
- 05.01 Introduction to Memory
|
||||||
|
- 05.02 Short-term Memory (explainer + problem + solution)
|
||||||
|
- 05.03 Long-term Memory
|
||||||
|
```
|
||||||
|
|
||||||
|
Create:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
mkdir -p exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer
|
||||||
|
mkdir -p exercises/05-memory-skill-building/05.02-short-term-memory/{explainer,problem,solution}
|
||||||
|
mkdir -p exercises/05-memory-skill-building/05.03-long-term-memory/explainer
|
||||||
|
```
|
||||||
|
|
||||||
|
Then create readme stubs:
|
||||||
|
|
||||||
|
```
|
||||||
|
exercises/05-memory-skill-building/05.01-introduction-to-memory/explainer/readme.md -> "# Introduction to Memory"
|
||||||
|
exercises/05-memory-skill-building/05.02-short-term-memory/explainer/readme.md -> "# Short-term Memory"
|
||||||
|
exercises/05-memory-skill-building/05.02-short-term-memory/problem/readme.md -> "# Short-term Memory"
|
||||||
|
exercises/05-memory-skill-building/05.02-short-term-memory/solution/readme.md -> "# Short-term Memory"
|
||||||
|
exercises/05-memory-skill-building/05.03-long-term-memory/explainer/readme.md -> "# Long-term Memory"
|
||||||
|
```
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
---
|
||||||
|
name: setup-matt-pocock-skills
|
||||||
|
description: "Configure this repo for the engineering skills: set up its issue tracker, triage label vocabulary, and domain doc layout. Run once before first use of the other engineering skills."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Setup Matt Pocock's Skills
|
||||||
|
|
||||||
|
Scaffold the per-repo configuration that the engineering skills assume:
|
||||||
|
|
||||||
|
- **Issue tracker**: where issues live (GitHub by default; local markdown is also supported out of the box)
|
||||||
|
- **Triage labels**: the strings used for the five canonical triage roles
|
||||||
|
- **Domain docs**: where `GLOSSARY.md` and ADRs live, and the consumer rules for reading them
|
||||||
|
|
||||||
|
This is a prompt-driven skill, not a deterministic script. Explore, present what you found, confirm with the user, then write.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Explore
|
||||||
|
|
||||||
|
Look at the current repo to understand its starting state. Read whatever exists; don't assume:
|
||||||
|
|
||||||
|
- `git remote -v` and `.git/config`: is this a GitHub repo? Which one?
|
||||||
|
- `AGENTS.md` and `CLAUDE.md` at the repo root: does either exist? Is there already an `## Agent skills` section in either?
|
||||||
|
- `GLOSSARY.md` and `GLOSSARY-MAP.md` at the repo root
|
||||||
|
- `docs/adr/` and any `src/*/docs/adr/` directories
|
||||||
|
- `docs/agents/`: does this skill's prior output already exist?
|
||||||
|
- `.scratch/`: a sign that a local-markdown issue tracker convention is already in use
|
||||||
|
- Is the `triage` skill installed? (a `triage` skill folder alongside this one, or `triage` in your available skills.) This decides whether Section B runs at all.
|
||||||
|
- Monorepo signals: a `pnpm-workspace.yaml`, a `workspaces` field in `package.json`, or a populated `packages/*` with its own `src/`. These are present only in a genuinely large multi-package repo; their absence means single-context, which is almost every repo.
|
||||||
|
|
||||||
|
### 2. Present findings and ask
|
||||||
|
|
||||||
|
Summarise what's present and what's missing. Then take the sections in order. One section, one answer, then the next.
|
||||||
|
|
||||||
|
Lead each section with the recommended answer so the user can accept it in a word. Give a one-line explainer only when the choice genuinely branches; skip the section entirely when exploration already settled it (Section B when `triage` isn't installed, Section C when there's no monorepo).
|
||||||
|
|
||||||
|
**Section A: Issue tracker.**
|
||||||
|
|
||||||
|
> Explainer: The "issue tracker" is where issues live for this repo. Skills like `to-tickets`, `triage`, and `to-spec` read from and write to it. They need to know whether to call `gh issue create`, write a markdown file under `.scratch/`, or follow some other workflow you describe. Pick the place you actually track work for this repo.
|
||||||
|
|
||||||
|
Default posture: these skills were designed for GitHub. If a `git remote` points at GitHub, propose that. If a `git remote` points at GitLab (`gitlab.com` or a self-hosted host), propose GitLab. Otherwise (or if the user prefers), offer:
|
||||||
|
|
||||||
|
- **GitHub**: issues live in the repo's GitHub Issues (uses the `gh` CLI)
|
||||||
|
- **GitLab**: issues live in the repo's GitLab Issues (uses the [`glab`](https://gitlab.com/gitlab-org/cli) CLI)
|
||||||
|
- **Local markdown**: issues live as files under `.scratch/<feature>/` in this repo (good for solo projects or repos without a remote)
|
||||||
|
- **Other** (Jira, Linear, etc.): ask the user to describe the workflow in one paragraph; the skill will record it as freeform prose
|
||||||
|
|
||||||
|
Record the choice in `docs/agents/issue-tracker.md`. The GitHub and GitLab templates carry a "PRs as a request surface" flag, defaulted **off**. Leave it off and don't raise it: a user who wants external PRs in the triage queue can flip the flag in the file later.
|
||||||
|
|
||||||
|
**Section B: Triage label vocabulary.** Skip this section entirely if the `triage` skill isn't installed (exploration told you), since an uninstalled skill needs no labels.
|
||||||
|
|
||||||
|
If it is installed, ask exactly one question:
|
||||||
|
|
||||||
|
> Do you want to keep the default triage labels? (recommended: **yes**)
|
||||||
|
|
||||||
|
The defaults are the five canonical roles, each label string equal to its name: `needs-triage`, `needs-info`, `ready-for-agent`, `ready-for-human`, `wontfix`. On **yes**, write them as-is. Only if the user says no, usually because their tracker already uses other names (e.g. `bug:triage` for `needs-triage`), collect the overrides so `triage` applies existing labels instead of creating duplicates.
|
||||||
|
|
||||||
|
**Section C: Domain docs.** Default to **single-context** (one `GLOSSARY.md` + `docs/adr/` at the repo root). This fits almost every repo; write it without asking.
|
||||||
|
|
||||||
|
Offer **multi-context** (a root `GLOSSARY-MAP.md` pointing to per-context `GLOSSARY.md` files) only when exploration found monorepo signals. Then confirm which layout they want.
|
||||||
|
|
||||||
|
### 3. Confirm and edit
|
||||||
|
|
||||||
|
Show the user a draft of:
|
||||||
|
|
||||||
|
- The `## Agent skills` block to add to whichever of `CLAUDE.md` / `AGENTS.md` is being edited (see step 4 for selection rules)
|
||||||
|
- The contents of `docs/agents/issue-tracker.md`, `docs/agents/domain.md`, and `docs/agents/triage-labels.md` (the last only when `triage` is installed)
|
||||||
|
|
||||||
|
Let them edit before writing.
|
||||||
|
|
||||||
|
### 4. Write
|
||||||
|
|
||||||
|
**Pick the file to edit:**
|
||||||
|
|
||||||
|
- If `CLAUDE.md` exists, edit it.
|
||||||
|
- Else if `AGENTS.md` exists, edit it.
|
||||||
|
- If neither exists, ask the user which one to create; don't pick for them.
|
||||||
|
|
||||||
|
Never create `AGENTS.md` when `CLAUDE.md` already exists (or vice versa); always edit the one that's already there.
|
||||||
|
|
||||||
|
If an `## Agent skills` block already exists in the chosen file, update its contents in-place rather than appending a duplicate. Don't overwrite user edits to the surrounding sections.
|
||||||
|
|
||||||
|
The block:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent skills
|
||||||
|
|
||||||
|
### Issue tracker
|
||||||
|
|
||||||
|
[one-line summary of where issues are tracked]. See `docs/agents/issue-tracker.md`.
|
||||||
|
|
||||||
|
### Triage labels
|
||||||
|
|
||||||
|
[one-line summary of the label vocabulary]. See `docs/agents/triage-labels.md`.
|
||||||
|
|
||||||
|
### Domain docs
|
||||||
|
|
||||||
|
[one-line summary of layout: "single-context" or "multi-context"]. See `docs/agents/domain.md`.
|
||||||
|
```
|
||||||
|
|
||||||
|
Include the `### Triage labels` sub-block, and write `docs/agents/triage-labels.md`, only when `triage` is installed and Section B ran. When it isn't, both are omitted.
|
||||||
|
|
||||||
|
When Section B ran on GitHub or GitLab, create each configured label the tracker lacks (`gh label create` / `glab label create`).
|
||||||
|
|
||||||
|
Then write the docs files using the seed templates in this skill folder as a starting point:
|
||||||
|
|
||||||
|
- [issue-tracker-github.md](./issue-tracker-github.md): GitHub issue tracker
|
||||||
|
- [issue-tracker-gitlab.md](./issue-tracker-gitlab.md): GitLab issue tracker
|
||||||
|
- [issue-tracker-local.md](./issue-tracker-local.md): local-markdown issue tracker
|
||||||
|
- [triage-labels.md](./triage-labels.md): label mapping (only if `triage` is installed)
|
||||||
|
- [domain.md](./domain.md): domain doc consumer rules + layout
|
||||||
|
|
||||||
|
For "other" issue trackers, write `docs/agents/issue-tracker.md` from scratch using the user's description.
|
||||||
|
|
||||||
|
### 5. Done
|
||||||
|
|
||||||
|
Tell the user the setup is complete and which engineering skills will now read from these files. Mention they can edit `docs/agents/*.md` directly later; re-running this skill is only necessary if they want to switch issue trackers or restart from scratch.
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
# Domain Docs
|
||||||
|
|
||||||
|
How the engineering skills should consume this repo's domain documentation when exploring the codebase.
|
||||||
|
|
||||||
|
## Before exploring, read these
|
||||||
|
|
||||||
|
- **`GLOSSARY.md`** at the repo root, or
|
||||||
|
- **`GLOSSARY-MAP.md`** at the repo root if it exists: it points at one `GLOSSARY.md` per context. Read each one relevant to the topic.
|
||||||
|
- **`docs/adr/`**: read ADRs that touch the area you're about to work in. In multi-context repos, also check `src/<context>/docs/adr/` for context-scoped decisions.
|
||||||
|
|
||||||
|
If any of these files don't exist, **proceed silently**. Don't flag their absence; don't suggest creating them upfront. The `/domain-modeling` skill (reached via `/grill-with-docs` and `/improve-codebase-architecture`) creates them lazily when terms or decisions actually get resolved.
|
||||||
|
|
||||||
|
## File structure
|
||||||
|
|
||||||
|
Single-context repo (most repos):
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── GLOSSARY.md
|
||||||
|
├── docs/adr/
|
||||||
|
│ ├── 0001-event-sourced-orders.md
|
||||||
|
│ └── 0002-postgres-for-write-model.md
|
||||||
|
└── src/
|
||||||
|
```
|
||||||
|
|
||||||
|
Multi-context repo (presence of `GLOSSARY-MAP.md` at the root):
|
||||||
|
|
||||||
|
```
|
||||||
|
/
|
||||||
|
├── GLOSSARY-MAP.md
|
||||||
|
├── docs/adr/ ← system-wide decisions
|
||||||
|
└── src/
|
||||||
|
├── ordering/
|
||||||
|
│ ├── GLOSSARY.md
|
||||||
|
│ └── docs/adr/ ← context-specific decisions
|
||||||
|
└── billing/
|
||||||
|
├── GLOSSARY.md
|
||||||
|
└── docs/adr/
|
||||||
|
```
|
||||||
|
|
||||||
|
## Use the glossary's vocabulary
|
||||||
|
|
||||||
|
When your output names a domain concept (in an issue title, a refactor proposal, a hypothesis, a test name), use the term as defined in `GLOSSARY.md`. Don't drift to synonyms the glossary explicitly avoids.
|
||||||
|
|
||||||
|
If the concept you need isn't in the glossary yet, that's a signal: either you're inventing language the project doesn't use (reconsider) or there's a real gap (note it for `/domain-modeling`).
|
||||||
|
|
||||||
|
## Flag ADR conflicts
|
||||||
|
|
||||||
|
If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
|
||||||
|
|
||||||
|
> _Contradicts ADR-0007 (event-sourced orders), but worth reopening because…_
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Issue tracker: GitHub
|
||||||
|
|
||||||
|
Issues and specs for this repo live as GitHub issues. Use the `gh` CLI for all operations.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- **Create an issue**: `gh issue create --title "..." --body "..."`. Use a heredoc for multi-line bodies.
|
||||||
|
- **Read an issue**: `gh issue view <number> --json number,title,body,labels,comments`.
|
||||||
|
- **List issues**: `gh issue list --state open --json number,title,body,labels,comments --jq '[.[] | {number, title, body, labels: [.labels[].name], comments: [.comments[].body]}]'` with appropriate `--label` and `--state` filters.
|
||||||
|
- **Make an issue a sub-issue of a parent**: `gh issue create --parent <parent> ...`, or `gh issue edit <parent> --add-sub-issue <child>` afterwards (`gh` 2.94+). Older `gh`: `gh api --method POST repos/<owner>/<repo>/issues/<parent>/sub_issues -F sub_issue_id=<child-db-id>` (database id, as in **Blocking** below). Without sub-issues, put `Part of #<parent>` at the top of the child body.
|
||||||
|
- **Comment on an issue**: `gh issue comment <number> --body "..."`
|
||||||
|
- **Apply / remove labels**: `gh issue edit <number> --add-label "..."` / `--remove-label "..."`
|
||||||
|
- **Close**: `gh issue close <number> --comment "..."`
|
||||||
|
|
||||||
|
Infer the repo from `git remote -v`; `gh` does this automatically when run inside a clone.
|
||||||
|
|
||||||
|
## Pull requests as a triage surface
|
||||||
|
|
||||||
|
**PRs as a request surface: no.** _(Set to `yes` if this repo treats external PRs as feature requests; `/triage` reads this flag.)_
|
||||||
|
|
||||||
|
When set to `yes`, PRs run through the same labels and states as issues, using the `gh pr` equivalents:
|
||||||
|
|
||||||
|
- **Read a PR**: `gh pr view <number> --comments` and `gh pr diff <number>` for the diff.
|
||||||
|
- **List external PRs for triage**: `gh api --paginate 'repos/{owner}/{repo}/pulls?state=open' --jq '.[] | select(.author_association | IN("OWNER","MEMBER","COLLABORATOR") | not) | {number, title, author: .user.login, author_association, labels: [.labels[].name]}'`.
|
||||||
|
- **Comment / label / close**: `gh pr comment`, `gh pr edit --add-label`/`--remove-label`, `gh pr close`.
|
||||||
|
|
||||||
|
GitHub shares one number space across issues and PRs, so a bare `#42` may be either: resolve with `gh pr view 42` and fall back to `gh issue view 42`.
|
||||||
|
|
||||||
|
## When a skill says "publish to the issue tracker"
|
||||||
|
|
||||||
|
Create a GitHub issue.
|
||||||
|
|
||||||
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
|
Read it as in **Read an issue** above.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets.
|
||||||
|
|
||||||
|
- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `gh issue create --label wayfinder:map`.
|
||||||
|
- **Child ticket**: an issue linked to the map as a GitHub sub-issue (see **Make an issue a sub-issue of a parent**). Where sub-issues aren't enabled, add the child to a task list in the map body and put `Part of #<map>` at the top of the child body. Labels: `wayfinder:<type>` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev.
|
||||||
|
- **Blocking**: GitHub's **native issue dependencies**, the canonical, UI-visible representation. Add an edge with `gh api --method POST repos/<owner>/<repo>/issues/<child>/dependencies/blocked_by -F issue_id=<blocker-db-id>`, where `<blocker-db-id>` is the blocker's numeric **database id** (`gh api repos/<owner>/<repo>/issues/<n> --jq .id`, _not_ the `#number` or `node_id`). GitHub reports `issue_dependencies_summary.blocked_by` (open blockers only, the live gate). Where dependencies aren't available, fall back to a `Blocked by: #<n>, #<n>` line at the top of the child body. A ticket is unblocked when every blocker is closed.
|
||||||
|
- **Frontier query**: list the map's open children (`gh issue list --state open`, scoped to the map's sub-issues / task list), drop any with an open blocker (`issue_dependencies_summary.blocked_by > 0`, or an open issue in the `Blocked by` line) or an assignee; first in map order wins.
|
||||||
|
- **Claim**: `gh issue edit <n> --add-assignee @me`, the session's first write.
|
||||||
|
- **Resolve**: `gh issue comment <n> --body "<answer>"`, then `gh issue close <n>`, then append a context pointer (gist + link) to the map's Decisions-so-far.
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Issue tracker: GitLab
|
||||||
|
|
||||||
|
Issues and specs for this repo live as GitLab issues. Use the [`glab`](https://gitlab.com/gitlab-org/cli) CLI for all operations.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- **Create an issue**: `glab issue create --title "..." --description "..."`. Use a heredoc for multi-line descriptions. Pass `--description -` to open an editor.
|
||||||
|
- **Read an issue**: `glab issue view <number> --comments`. Use `-F json` for machine-readable output.
|
||||||
|
- **List issues**: `glab issue list -O json` with appropriate `--label` filters.
|
||||||
|
- **Comment on an issue**: `glab issue note <number> --message "..."`. GitLab calls comments "notes".
|
||||||
|
- **Apply / remove labels**: `glab issue update <number> --label "..."` / `--unlabel "..."`. Multiple labels can be comma-separated or by repeating the flag.
|
||||||
|
- **Close**: `glab issue close <number>`. `glab issue close` does not accept a closing comment, so post the explanation first with `glab issue note <number> --message "..."`, then close.
|
||||||
|
- **Merge requests**: GitLab calls PRs "merge requests". Use `glab mr create`, `glab mr view`, `glab mr note`, etc., the same shape as `gh pr ...` with `mr` in place of `pr` and `note`/`--message` in place of `comment`/`--body`.
|
||||||
|
|
||||||
|
Infer the repo from `git remote -v`; `glab` does this automatically when run inside a clone.
|
||||||
|
|
||||||
|
## Merge requests as a triage surface
|
||||||
|
|
||||||
|
**MRs as a request surface: no.** _(Set to `yes` if this repo treats external merge requests as feature requests; `/triage` reads this flag.)_
|
||||||
|
|
||||||
|
When set to `yes`, MRs run through the same labels and states as issues, using the `glab mr` equivalents:
|
||||||
|
|
||||||
|
- **Read an MR**: `glab mr view <number> --comments` and `glab mr diff <number>` for the diff.
|
||||||
|
- **List external MRs for triage**: `glab mr list -F json`, then keep only MRs whose author is not a project member/owner (a contributor's MR, not a maintainer's in-flight work).
|
||||||
|
- **Comment / label / close**: `glab mr note`, `glab mr update --label`/`--unlabel`, `glab mr close`.
|
||||||
|
|
||||||
|
Unlike GitHub, GitLab numbers issues and MRs separately, so `#42` is unambiguous once you know which surface the maintainer means.
|
||||||
|
|
||||||
|
## When a skill says "publish to the issue tracker"
|
||||||
|
|
||||||
|
Create a GitLab issue.
|
||||||
|
|
||||||
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
|
Run `glab issue view <number> --comments`.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a single issue with **child** issues as tickets.
|
||||||
|
|
||||||
|
- **Map**: a single issue labelled `wayfinder:map`, holding the Notes / Decisions-so-far / Fog body. `glab issue create --label wayfinder:map`. (On GitLab tiers with native epics, an epic may hold the map instead; a labelled issue works everywhere.)
|
||||||
|
- **Child ticket**: an issue carrying `Part of #<map>` at the top of its description and labels `wayfinder:<type>` (`research`/`prototype`/`grilling`/`task`). Once claimed, the ticket is assigned to the driving dev.
|
||||||
|
- **Blocking**: GitLab's **native blocking link**, the canonical, UI-visible representation. Add it with the `/blocked_by #<n>` quick action, posted as a note (`glab issue note <child> --message "/blocked_by #<blocker>"`). Native blocking links are a Premium/Ultimate feature; on the free tier (or where unavailable) fall back to a `Blocked by: #<n>, #<n>` line at the top of the description. A ticket is unblocked when every blocker is closed.
|
||||||
|
- **Frontier query**: `glab issue list -O json` scoped to the map's children, drop any with an open blocker: a native `blocked_by` link to an open issue (`glab api projects/:id/issues/<child-iid>/links`), or an open issue in the `Blocked by` line, or an assignee; first in map order wins.
|
||||||
|
- **Claim**: `glab issue update <n> --assignee @me`, the session's first write.
|
||||||
|
- **Resolve**: `glab issue note <n> --message "<answer>"`, then `glab issue close <n>`, then append a context pointer (gist + link) to the map's Decisions-so-far.
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
# Issue tracker: Local Markdown
|
||||||
|
|
||||||
|
Issues and specs for this repo live as markdown files in `.scratch/`.
|
||||||
|
|
||||||
|
## Conventions
|
||||||
|
|
||||||
|
- One feature per directory: `.scratch/<feature-slug>/`
|
||||||
|
- The spec is `.scratch/<feature-slug>/spec.md`
|
||||||
|
- Implementation issues are one file per ticket at `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01`, never a single combined tickets file
|
||||||
|
- Triage state is recorded as a `Status:` line near the top of each issue file (see `triage-labels.md` for the role strings)
|
||||||
|
- Comments and conversation history append to the bottom of the file under a `## Comments` heading
|
||||||
|
|
||||||
|
## When a skill says "publish to the issue tracker"
|
||||||
|
|
||||||
|
Create a new file under `.scratch/<feature-slug>/` (creating the directory if needed).
|
||||||
|
|
||||||
|
## When a skill says "fetch the relevant ticket"
|
||||||
|
|
||||||
|
Read the file at the referenced path. The user will normally pass the path or the issue number directly.
|
||||||
|
|
||||||
|
## Wayfinding operations
|
||||||
|
|
||||||
|
Used by `/wayfinder`. The **map** is a file with one **child** file per ticket.
|
||||||
|
|
||||||
|
- **Map**: `.scratch/<effort>/map.md` (the Notes / Decisions-so-far / Fog body).
|
||||||
|
- **Child ticket**: `.scratch/<effort>/issues/NN-<slug>.md`, numbered from `01`, with the question in the body. A `Type:` line records the ticket type (`research`/`prototype`/`grilling`/`task`); a `Status:` line records `claimed`/`resolved`.
|
||||||
|
- **Blocking**: a `Blocked by: NN, NN` line near the top. A ticket is unblocked when every file it lists is `resolved`.
|
||||||
|
- **Frontier**: scan `.scratch/<effort>/issues/` for files that are open, unblocked, and unclaimed; first by number wins.
|
||||||
|
- **Claim**: set `Status: claimed` and save before any work.
|
||||||
|
- **Resolve**: append the answer under an `## Answer` heading, set `Status: resolved`, then append a context pointer (gist + link) to the map's Decisions-so-far in `map.md`.
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
# Triage Labels
|
||||||
|
|
||||||
|
The skills speak in terms of five canonical triage roles. This file maps those roles to the actual label strings used in this repo's issue tracker.
|
||||||
|
|
||||||
|
| Label in mattpocock/skills | Label in our tracker | Meaning |
|
||||||
|
| -------------------------- | -------------------- | ---------------------------------------- |
|
||||||
|
| `needs-triage` | `needs-triage` | Maintainer needs to evaluate this issue |
|
||||||
|
| `needs-info` | `needs-info` | Waiting on reporter for more information |
|
||||||
|
| `ready-for-agent` | `ready-for-agent` | Fully specified, ready for an AFK agent |
|
||||||
|
| `ready-for-human` | `ready-for-human` | Requires human implementation |
|
||||||
|
| `wontfix` | `wontfix` | Will not be actioned |
|
||||||
|
|
||||||
|
When a skill mentions a role (e.g. "apply the AFK-ready triage label"), use the corresponding label string from this table.
|
||||||
|
|
||||||
|
Edit the "Label in our tracker" column to match whatever vocabulary you actually use.
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
---
|
||||||
|
name: setup-pre-commit
|
||||||
|
description: Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Setup Pre-Commit Hooks
|
||||||
|
|
||||||
|
## What This Sets Up
|
||||||
|
|
||||||
|
- **Husky** pre-commit hook
|
||||||
|
- **lint-staged** running Prettier on all staged files
|
||||||
|
- **Prettier** config (if missing)
|
||||||
|
- **typecheck** and **test** scripts in the pre-commit hook
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### 1. Detect package manager
|
||||||
|
|
||||||
|
Check for `package-lock.json` (npm), `pnpm-lock.yaml` (pnpm), `yarn.lock` (yarn), `bun.lockb` (bun). Use whichever is present. Default to npm if unclear.
|
||||||
|
|
||||||
|
### 2. Install dependencies
|
||||||
|
|
||||||
|
Install as devDependencies:
|
||||||
|
|
||||||
|
```
|
||||||
|
husky lint-staged prettier
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Initialize Husky
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx husky init
|
||||||
|
```
|
||||||
|
|
||||||
|
This creates `.husky/` dir and adds `prepare: "husky"` to package.json.
|
||||||
|
|
||||||
|
### 4. Create `.husky/pre-commit`
|
||||||
|
|
||||||
|
Write this file (no shebang needed for Husky v9+):
|
||||||
|
|
||||||
|
```
|
||||||
|
npx lint-staged
|
||||||
|
npm run typecheck
|
||||||
|
npm run test
|
||||||
|
```
|
||||||
|
|
||||||
|
**Adapt**: Replace `npm` with detected package manager. If repo has no `typecheck` or `test` script in package.json, omit those lines and tell the user.
|
||||||
|
|
||||||
|
### 5. Create `.lintstagedrc`
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"*": "prettier --ignore-unknown --write"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Create `.prettierrc` (if missing)
|
||||||
|
|
||||||
|
Only create if no Prettier config exists. Use these defaults:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"useTabs": false,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"printWidth": 80,
|
||||||
|
"singleQuote": false,
|
||||||
|
"trailingComma": "es5",
|
||||||
|
"semi": true,
|
||||||
|
"arrowParens": "always"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7. Verify
|
||||||
|
|
||||||
|
- [ ] `.husky/pre-commit` exists and is executable
|
||||||
|
- [ ] `.lintstagedrc` exists
|
||||||
|
- [ ] `prepare` script in package.json is `"husky"`
|
||||||
|
- [ ] `prettier` config exists
|
||||||
|
- [ ] Run `npx lint-staged` to verify it works
|
||||||
|
|
||||||
|
### 8. Commit
|
||||||
|
|
||||||
|
Stage all changed/created files and commit with message: `Add pre-commit hooks (husky + lint-staged + prettier)`
|
||||||
|
|
||||||
|
This will run through the new pre-commit hooks: a good smoke test that everything works.
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
- Husky v9+ doesn't need shebangs in hook files
|
||||||
|
- `prettier --ignore-unknown` skips files Prettier can't parse (images, etc.)
|
||||||
|
- The pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: tdd
|
||||||
|
description: Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Test-Driven Development
|
||||||
|
|
||||||
|
TDD is the red → green loop. This skill is the reference that makes that loop produce tests worth keeping: what a good test is, where tests go, the anti-patterns, and the rules of the loop. Every section applies on every cycle: consult them before and during the loop, not after.
|
||||||
|
|
||||||
|
When exploring the codebase, read `GLOSSARY.md` (if it exists) so test names and interface vocabulary match the project's domain language, and respect ADRs in the area you're touching.
|
||||||
|
|
||||||
|
## What a good test is
|
||||||
|
|
||||||
|
Tests verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists, and it survives refactors because it doesn't care about internal structure.
|
||||||
|
|
||||||
|
See [tests.md](tests.md) for examples and [mocking.md](mocking.md) for mocking guidelines.
|
||||||
|
|
||||||
|
## Seams: where tests go
|
||||||
|
|
||||||
|
A **seam** is the public boundary you test at: the interface where you observe behavior without reaching inside. Tests live at seams, never against internals.
|
||||||
|
|
||||||
|
**Test only at pre-agreed seams.** Before writing any test, write down the seams under test and confirm them with the user. No test is written at an unconfirmed seam. You can't test everything, so agreeing the seams up front is how testing effort lands on the critical paths and complex logic instead of every edge case.
|
||||||
|
|
||||||
|
Ask: "What's the public interface, and which seams should we test?" Give each proposed seam a one-line note on what it catches and what it misses.
|
||||||
|
|
||||||
|
When the shape of that interface is itself in question (how deep the module is, where the seam belongs, what the interface should expose), call the Skill tool with "codebase-design" for the vocabulary. It is the shared source of the module, interface, depth, seam, adapter, leverage and locality terms, and it is a reference to consult, not a session to run.
|
||||||
|
|
||||||
|
## Anti-patterns
|
||||||
|
|
||||||
|
- **Implementation-coupled**: mocks internal collaborators, tests private methods, or verifies through a side channel (querying the database instead of using the interface). The tell: the test breaks when you refactor but behavior hasn't changed.
|
||||||
|
- **Tautological**: the assertion recomputes the expected value the way the code does (`expect(add(a, b)).toBe(a + b)`, a snapshot derived by hand the same way, a constant asserted equal to itself), so it passes by construction and can never disagree with the code. Expected values must come from an independent source of truth: a known-good literal, a worked example, the spec.
|
||||||
|
- **Horizontal slicing**: writing all tests first, then all implementation. Bulk tests verify _imagined_ behavior: you test the _shape_ of things rather than user-facing behavior, the tests go insensitive to real changes, and you commit to test structure before understanding the implementation. Work in **vertical slices** instead: one test → one implementation → repeat, each test a **tracer bullet** that responds to what the last cycle taught you.
|
||||||
|
|
||||||
|
## Rules of the loop
|
||||||
|
|
||||||
|
- **Red before green.** Write the failing test first, then only enough code to pass it. Don't anticipate future tests or add speculative features.
|
||||||
|
- **One slice at a time.** One seam, one test, one minimal implementation per cycle.
|
||||||
|
- **Refactoring is not part of the loop.** It belongs to the review stage (see the `code-review` skill), not the red → green implementation cycle.
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
# When to Mock
|
||||||
|
|
||||||
|
Mock at **system boundaries** only:
|
||||||
|
|
||||||
|
- External APIs (payment, email, etc.)
|
||||||
|
- Databases (sometimes - prefer test DB)
|
||||||
|
- Time/randomness
|
||||||
|
- File system (sometimes)
|
||||||
|
|
||||||
|
Don't mock:
|
||||||
|
|
||||||
|
- Your own classes/modules
|
||||||
|
- Internal collaborators
|
||||||
|
- Anything you control
|
||||||
|
|
||||||
|
## Designing for Mockability
|
||||||
|
|
||||||
|
At system boundaries, design interfaces that are easy to mock:
|
||||||
|
|
||||||
|
**1. Use dependency injection**
|
||||||
|
|
||||||
|
Pass external dependencies in rather than creating them internally:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// Easy to mock
|
||||||
|
function processPayment(order, paymentClient) {
|
||||||
|
return paymentClient.charge(order.total);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hard to mock
|
||||||
|
function processPayment(order) {
|
||||||
|
const client = new StripeClient(process.env.STRIPE_KEY);
|
||||||
|
return client.charge(order.total);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**2. Prefer SDK-style interfaces over generic fetchers**
|
||||||
|
|
||||||
|
Create specific functions for each external operation instead of one generic function with conditional logic:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// GOOD: Each function is independently mockable
|
||||||
|
const api = {
|
||||||
|
getUser: (id) => fetch(`/users/${id}`),
|
||||||
|
getOrders: (userId) => fetch(`/users/${userId}/orders`),
|
||||||
|
createOrder: (data) => fetch('/orders', { method: 'POST', body: data }),
|
||||||
|
};
|
||||||
|
|
||||||
|
// BAD: Mocking requires conditional logic inside the mock
|
||||||
|
const api = {
|
||||||
|
fetch: (endpoint, options) => fetch(endpoint, options),
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
The SDK approach means:
|
||||||
|
- Each mock returns one specific shape
|
||||||
|
- No conditional logic in test setup
|
||||||
|
- Easier to see which endpoints a test exercises
|
||||||
|
- Type safety per endpoint
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# Good and Bad Tests
|
||||||
|
|
||||||
|
## Good Tests
|
||||||
|
|
||||||
|
**Integration-style**: Test through real interfaces, not mocks of internal parts.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// GOOD: Tests observable behavior
|
||||||
|
test("user can checkout with valid cart", async () => {
|
||||||
|
const cart = createCart();
|
||||||
|
cart.add(product);
|
||||||
|
const result = await checkout(cart, paymentMethod);
|
||||||
|
expect(result.status).toBe("confirmed");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Characteristics:
|
||||||
|
|
||||||
|
- Tests behavior users/callers care about
|
||||||
|
- Uses public API only
|
||||||
|
- Survives internal refactors
|
||||||
|
- Describes WHAT, not HOW
|
||||||
|
- One logical assertion per test
|
||||||
|
|
||||||
|
## Bad Tests
|
||||||
|
|
||||||
|
**Implementation-detail tests**: Coupled to internal structure.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// BAD: Tests implementation details
|
||||||
|
test("checkout calls paymentService.process", async () => {
|
||||||
|
const mockPayment = jest.mock(paymentService);
|
||||||
|
await checkout(cart, payment);
|
||||||
|
expect(mockPayment.process).toHaveBeenCalledWith(cart.total);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
Red flags:
|
||||||
|
|
||||||
|
- Mocking internal collaborators
|
||||||
|
- Testing private methods
|
||||||
|
- Asserting on call counts/order
|
||||||
|
- Test breaks when refactoring without behavior change
|
||||||
|
- Test name describes HOW not WHAT
|
||||||
|
- Verifying through external means instead of interface
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// BAD: Bypasses interface to verify
|
||||||
|
test("createUser saves to database", async () => {
|
||||||
|
await createUser({ name: "Alice" });
|
||||||
|
const row = await db.query("SELECT * FROM users WHERE name = ?", ["Alice"]);
|
||||||
|
expect(row).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
// GOOD: Verifies through interface
|
||||||
|
test("createUser makes user retrievable", async () => {
|
||||||
|
const user = await createUser({ name: "Alice" });
|
||||||
|
const retrieved = await getUser(user.id);
|
||||||
|
expect(retrieved.name).toBe("Alice");
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
**Tautological tests**: Expected value restates the implementation, so the test passes by construction.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
// BAD: Expected value is recomputed the way the code computes it
|
||||||
|
test("calculateTotal sums line items", () => {
|
||||||
|
const items = [{ price: 10 }, { price: 5 }];
|
||||||
|
const expected = items.reduce((sum, i) => sum + i.price, 0);
|
||||||
|
expect(calculateTotal(items)).toBe(expected);
|
||||||
|
});
|
||||||
|
|
||||||
|
// GOOD: Expected value is an independent, known literal
|
||||||
|
test("calculateTotal sums line items", () => {
|
||||||
|
expect(calculateTotal([{ price: 10 }, { price: 5 }])).toBe(15);
|
||||||
|
});
|
||||||
|
```
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
# GLOSSARY.md Format
|
||||||
|
|
||||||
|
`GLOSSARY.md` is the canonical language for this teaching workspace. All explainers, exercises, and learning records should adhere to its terminology. Building it is itself part of learning: compressing a concept into a tight definition is evidence the user understands it.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```md
|
||||||
|
# {Topic} Glossary
|
||||||
|
|
||||||
|
{One or two sentence description of the topic this glossary covers.}
|
||||||
|
|
||||||
|
## Terms
|
||||||
|
|
||||||
|
**Hypertrophy**:
|
||||||
|
Muscle growth driven by mechanical tension and metabolic stress over repeated training sessions.
|
||||||
|
_Avoid_: Bulking, getting big
|
||||||
|
|
||||||
|
**Progressive overload**:
|
||||||
|
Systematically increasing the demand on a muscle over time, via load, volume, or intensity.
|
||||||
|
_Avoid_: Pushing harder, levelling up
|
||||||
|
|
||||||
|
**RPE (Rate of Perceived Exertion)**:
|
||||||
|
A 1–10 self-rating of how hard a set felt, where 10 is failure and 8 means two reps left in the tank.
|
||||||
|
_Avoid_: Effort score, intensity rating
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- **Add a term only when the user understands it.** The glossary is a record of compressed knowledge, not a dictionary the user reads to learn. If the user has just been introduced to a concept, wait until they can use it correctly before promoting it here.
|
||||||
|
- **Be opinionated.** When several words exist for the same concept, pick the best one and list the rest as aliases to avoid. This is how language compresses.
|
||||||
|
- **Keep definitions tight.** One or two sentences. Define what the term IS, not what it does or how to do it.
|
||||||
|
- **Use the glossary's own terms inside definitions.** Once a term is in the glossary, prefer it everywhere, including inside other definitions. This is what makes complex terms easier to grasp later.
|
||||||
|
- **Group under subheadings** when natural clusters emerge (e.g. `## Anatomy`, `## Programming`). A flat list is fine when terms cohere.
|
||||||
|
- **Flag ambiguities explicitly.** If a term is used loosely in the wider field, note the resolution: "In this workspace, 'set' always means a working set; warm-ups are tracked separately."
|
||||||
|
- **Revise as understanding deepens.** A definition the user wrote in week one may be wrong by week six. Update in place; do not leave stale entries.
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
# Learning Record Format
|
||||||
|
|
||||||
|
Learning records live in `./learning-records/` and use sequential numbering: `0001-slug.md`, `0002-slug.md`, etc. Create the directory lazily: only when the first record is written.
|
||||||
|
|
||||||
|
They are the teaching equivalent of ADRs: they capture non-obvious lessons, key insights, and stated prior knowledge that will steer future sessions. They are used to calculate the zone of proximal development.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
|
||||||
|
```md
|
||||||
|
# {Short title of what was learned or established}
|
||||||
|
|
||||||
|
{1-3 sentences: what was learned (or what prior knowledge was established), and why it matters for future sessions.}
|
||||||
|
```
|
||||||
|
|
||||||
|
That is the whole format. A learning record can be a single paragraph. The value is recording _that_ this is now known and _why_ it changes what to teach next, not in filling out sections.
|
||||||
|
|
||||||
|
## Optional sections
|
||||||
|
|
||||||
|
Only include these when they add genuine value. Most records won't need them.
|
||||||
|
|
||||||
|
- **Status** frontmatter (`active | superseded by LR-NNNN`): useful when an earlier understanding turns out to be wrong and is replaced.
|
||||||
|
- **Evidence**: how the user demonstrated the understanding (a question answered, an exercise completed, prior experience cited). Useful when the claim might be revisited.
|
||||||
|
- **Implications**: what this unlocks or rules out for future sessions. Worth recording when non-obvious.
|
||||||
|
|
||||||
|
## Numbering
|
||||||
|
|
||||||
|
Scan `./learning-records/` for the highest existing number and increment by one.
|
||||||
|
|
||||||
|
## When to write a learning record
|
||||||
|
|
||||||
|
Write one when any of these is true:
|
||||||
|
|
||||||
|
1. **The user demonstrated genuine understanding of something non-trivial**: not just exposure, but evidence they can use the concept correctly. This sets a new floor for what to teach next.
|
||||||
|
2. **The user disclosed prior knowledge**: "I already know X." Record it so future sessions don't re-teach it. Also record the _depth_ claimed.
|
||||||
|
3. **A misconception was corrected**: the user previously believed something wrong and now sees why. These are high-value: they predict future stumbling blocks for related topics.
|
||||||
|
4. **The mission shifted in response to learning**: the user discovered they cared about something different than they thought. Cross-link to [[MISSION.md]] and update it.
|
||||||
|
|
||||||
|
### What does _not_ qualify
|
||||||
|
|
||||||
|
- Material that was merely covered. Coverage is not learning. Wait for evidence.
|
||||||
|
- Anything already captured tersely in [[GLOSSARY.md]] as a term definition. Don't duplicate.
|
||||||
|
- Session-by-session activity logs. Learning records are not a journal: they are decision-grade insights.
|
||||||
|
|
||||||
|
## Supersession
|
||||||
|
|
||||||
|
When a later record contradicts an earlier one (the user's understanding deepened or corrected), mark the old record `Status: superseded by LR-NNNN` rather than deleting it. The history of how understanding evolved is itself useful signal.
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# MISSION.md Format
|
||||||
|
|
||||||
|
`MISSION.md` lives at the workspace root. It captures the _reason_ the user is learning this topic. Every teaching decision (what to teach next, which resources to surface, which exercises to design) should trace back to this document.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
|
||||||
|
```md
|
||||||
|
# Mission: {Topic}
|
||||||
|
|
||||||
|
## Why
|
||||||
|
{1-3 sentences. The concrete real-world goal the user is chasing. What changes in their life or work when they have this skill? Avoid abstract framings like "to understand X"; push for the underlying outcome.}
|
||||||
|
|
||||||
|
## Success looks like
|
||||||
|
- {A specific, observable thing the user will be able to do}
|
||||||
|
- {Another specific thing}
|
||||||
|
- {…}
|
||||||
|
|
||||||
|
## Constraints
|
||||||
|
- {Time, budget, prior commitments, learning preferences, anything that bounds the approach}
|
||||||
|
|
||||||
|
## Out of scope
|
||||||
|
- {Adjacent topics the user explicitly does not want to chase right now, protecting the zone of proximal development}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- **One mission per workspace.** If the user wants to learn two unrelated things, that is two workspaces.
|
||||||
|
- **Concrete over abstract.** "Run a half marathon by October" beats "get fitter." "Ship a Rust CLI to my team" beats "learn Rust."
|
||||||
|
- **Push back on vagueness.** If the user cannot articulate why, interview them before writing anything. A bad mission is worse than no mission.
|
||||||
|
- **Revise when reality shifts.** Missions change. When the user's goal moves, update this file: don't leave a stale mission steering future sessions.
|
||||||
|
- **Keep it short.** If `MISSION.md` runs past a screen, it has stopped being a compass and started being a plan.
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# RESOURCES.md Format
|
||||||
|
|
||||||
|
`RESOURCES.md` is the curated set of trusted sources for this topic. Knowledge for explainers should be drawn from here, not from parametric guesses. Wisdom comes from the communities listed here.
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
```md
|
||||||
|
# {Topic} Resources
|
||||||
|
|
||||||
|
## Knowledge
|
||||||
|
|
||||||
|
- [Book: _The Science and Practice of Strength Training_ by Zatsiorsky & Kraemer](https://example.com)
|
||||||
|
Foundational text on programming and adaptation. Use for: anything to do with periodisation, recovery, intensity zones.
|
||||||
|
- [Article: "How Much Should I Train?" by Greg Nuckols (Stronger By Science)](https://example.com)
|
||||||
|
Evidence-based review of volume landmarks. Use for: weekly set targets per muscle group.
|
||||||
|
|
||||||
|
## Wisdom (Communities)
|
||||||
|
|
||||||
|
- [r/weightroom](https://reddit.com/r/weightroom)
|
||||||
|
High-signal subreddit, moderated against bro-science. Use for: programme critique, plateau troubleshooting.
|
||||||
|
- Local: Tuesday strength class at {gym name}
|
||||||
|
Use for: real-time coaching feedback on lifts.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Rules
|
||||||
|
|
||||||
|
- **High-trust only.** Prefer primary sources, recognised experts, peer-reviewed work, and communities with strong moderation. If a resource is marketing dressed as education, leave it out.
|
||||||
|
- **Annotate every entry.** A bare link is useless in three months. Add one line: what it covers and when to reach for it.
|
||||||
|
- **Group by Knowledge / Wisdom.** Mirrors the philosophy in [SKILL.md](./SKILL.md). It is fine for a resource to appear in only one group.
|
||||||
|
- **Surface gaps explicitly.** If no good resource exists for an area the mission needs, write a `## Gaps` section listing what is missing. This drives future search.
|
||||||
|
- **Prune ruthlessly.** A resource that turned out to be wrong, shallow, or off-mission should be removed, not buried. Better five sharp sources than thirty mediocre ones.
|
||||||
|
- **Record community preferences.** If the user has opted out of joining communities, note it here so future sessions don't keep proposing them.
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
---
|
||||||
|
name: teach
|
||||||
|
description: Teach the user a new skill or concept, within this workspace.
|
||||||
|
disable-model-invocation: true
|
||||||
|
argument-hint: "What would you like to learn about?"
|
||||||
|
---
|
||||||
|
|
||||||
|
The user has asked you to teach them something. This is a stateful request - they intend to learn the topic over multiple sessions.
|
||||||
|
|
||||||
|
## Teaching Workspace
|
||||||
|
|
||||||
|
Treat the current directory as a teaching workspace. Workspace paths (`./lessons/` and the rest) resolve from the directory `/teach` was run in; only the `*-FORMAT.md` links resolve from this skill's folder. The state of their learning is captured in this directory in several files:
|
||||||
|
|
||||||
|
- `MISSION.md`: A document capturing the _reason_ the user is interested in the topic. This should be used to ground all teaching. Use the format in [MISSION-FORMAT.md](./MISSION-FORMAT.md).
|
||||||
|
- `./reference/*.html`: A directory of reference materials. These are the compressed learnings from the lessons - cheat sheets, reference algorithms, syntax, yoga poses, glossaries. They are the raw units of learning. They should be beautiful documents which print out well, and are designed for quick reference.
|
||||||
|
- `RESOURCES.md`: A list of resources which can be explored to ground your teaching in contextual knowledge, or to acquire knowledge and wisdom. Use the format in [RESOURCES-FORMAT.md](./RESOURCES-FORMAT.md).
|
||||||
|
- `./learning-records/*.md`: A directory of learning records, which capture what the user has learned. These are loosely equivalent to architectural decision records in software development - they capture non-obvious lessons and key insights that may need to be revised later, or drive future sessions. These should be used to calculate the zone of proximal development. They are titled `0001-<dash-case-name>.md`, where the number increments each time. Use the format in [LEARNING-RECORD-FORMAT.md](./LEARNING-RECORD-FORMAT.md).
|
||||||
|
- `./lessons/*.html`: A directory of lessons. A **lesson** is a single, self-contained HTML output that teaches one tightly-scoped thing tied to the mission. This is the primary unit of teaching in this workspace.
|
||||||
|
- `./assets/*`: Reusable **components** shared across lessons. See [Assets](#assets).
|
||||||
|
- `NOTES.md`: A scratchpad for you to jot down user preferences, or working notes.
|
||||||
|
|
||||||
|
## Philosophy
|
||||||
|
|
||||||
|
To learn at a deep level, the user needs three things:
|
||||||
|
|
||||||
|
- **Knowledge**, captured from high-quality, high-trust resources
|
||||||
|
- **Skills**, acquired through highly-relevant interactive lessons devised by you, based on the knowledge
|
||||||
|
- **Wisdom**, which comes from interacting with other learners and practitioners
|
||||||
|
|
||||||
|
Before the `RESOURCES.md` is well-populated, your focus should be to find high-quality resources which will help the user acquire knowledge. Never trust your parametric knowledge.
|
||||||
|
|
||||||
|
Some topics may require more skills than knowledge. Learning more about theoretical physics might be more knowledge-based. For yoga, more skills-based.
|
||||||
|
|
||||||
|
### Fluency vs Storage Strength
|
||||||
|
|
||||||
|
You should be careful to split between two types of learning:
|
||||||
|
|
||||||
|
- **Fluency strength**: in-the-moment retrieval of knowledge
|
||||||
|
- **Storage strength**: long-term retention of knowledge
|
||||||
|
|
||||||
|
Fluency can give the user an illusory sense of mastery, but storage strength is the real goal. Try to design lessons which build long-term retention by desirable difficulty:
|
||||||
|
|
||||||
|
- Using retrieval practice (recall from memory)
|
||||||
|
- Spacing (distributing practice over time)
|
||||||
|
- Interleaving (mixing up different but related topics in practice - for skills practice only)
|
||||||
|
|
||||||
|
## Lessons
|
||||||
|
|
||||||
|
A lesson is the main thing you produce: the unit in which knowledge and skills reach the user. Each lesson is one self-contained HTML file, saved to `./lessons/` and titled `0001-<dash-case-name>.html` where the number increments each time.
|
||||||
|
|
||||||
|
A lesson should be **beautiful**, with clean, readable typography and layout, since the user will return to these later to review. Think Tufte.
|
||||||
|
|
||||||
|
The lesson should be short, and completable very quickly. Learners' working memory is very small, and we need to stay within it. But each lesson should give the user a single tangible win that they can build on. It should be directly tied to the mission, and should be in the user's zone of proximal development.
|
||||||
|
|
||||||
|
If possible, open the lesson file for the user by running a CLI command.
|
||||||
|
|
||||||
|
Each lesson should link via HTML anchors to other lessons and reference documents.
|
||||||
|
|
||||||
|
Each lesson should recommend a primary source for the user to read or watch. This should be the most high-quality, high-trust resource you found on the topic.
|
||||||
|
|
||||||
|
Each lesson should contain a reminder to ask followup questions to the agent. The agent is their teacher, and can assist with anything that's unclear.
|
||||||
|
|
||||||
|
## Assets
|
||||||
|
|
||||||
|
Lessons are built from reusable **components**, stored in `./assets/`: stylesheets, quiz widgets, simulators, diagram helpers, and anything else a second lesson could reuse.
|
||||||
|
|
||||||
|
Reuse is the default, not the exception. Before authoring a lesson, read `./assets/` and build from the components already there. When a lesson needs something new and reusable, write it as a component in `./assets/` and link to it; never inline code a future lesson would duplicate.
|
||||||
|
|
||||||
|
A shared stylesheet is the first component every workspace earns: every lesson links it, so the lessons look like one consistent course rather than a pile of one-offs. As the workspace grows, so should the component library.
|
||||||
|
|
||||||
|
## The Mission
|
||||||
|
|
||||||
|
Every lesson should be tied into the mission - the reason that the user is interested in learning about the topic.
|
||||||
|
|
||||||
|
If the user is unclear about the mission, or the `MISSION.md` is not populated, your first job should be to question the user on why they want to learn this.
|
||||||
|
|
||||||
|
Failing to understand the mission will mean knowledge acquisition is not grounded in real-world goals. Lessons will feel too abstract. You will have no way of judging what the user should do next.
|
||||||
|
|
||||||
|
Missions may change as the user develops more skills and knowledge. This is normal - make sure to update the `MISSION.md` and add a learning record to capture the change. Confirm with the user before changing the mission.
|
||||||
|
|
||||||
|
## Zone Of Proximal Development
|
||||||
|
|
||||||
|
Each lesson, the user should always feel as if they are being challenged 'just enough'.
|
||||||
|
|
||||||
|
The user may specify an exact thing they want to learn. If they don't, figure out their zone of proximal development by:
|
||||||
|
|
||||||
|
- Reading their `learning-records`
|
||||||
|
- Figuring out the right thing to teach them based on their mission
|
||||||
|
- Teach the most relevant thing that fits in their zone of proximal development
|
||||||
|
|
||||||
|
## Knowledge
|
||||||
|
|
||||||
|
Lessons should be designed around a skill the user is going to learn. The knowledge in the lesson should be only what's required to acquire that skill. You teach the knowledge first, then get the user to practice the skills via an interactive feedback loop.
|
||||||
|
|
||||||
|
Knowledge should first be gathered from trusted resources. Use `RESOURCES.md` to keep track of them. Lessons should be littered with citations - links to external resources to back up any claim made. This increases the trustworthiness of the lesson.
|
||||||
|
|
||||||
|
For acquiring knowledge, difficulty is the enemy. It eats working memory you need for understanding.
|
||||||
|
|
||||||
|
## Skills
|
||||||
|
|
||||||
|
If knowledge is all about acquisition, skills are about durability and flexibility. Make the knowledge stick.
|
||||||
|
|
||||||
|
For skill acquisition, difficulty is the tool. Effortful retrieval is what builds storage strength. Skills should be taught through interactive lessons. There are several tools at your disposal:
|
||||||
|
|
||||||
|
- Interactive lessons, using quizzes and light in-browser tasks
|
||||||
|
- Lessons which guide the user through a list of real-world steps to take (for instance, yoga poses)
|
||||||
|
|
||||||
|
Each of these should be based on a **feedback loop**, where the user receives feedback on their performance. This feedback loop should be as tight as possible, giving feedback immediately - and ideally automatically.
|
||||||
|
|
||||||
|
For quizzes, each answer should be exactly the same number of words (and characters, if possible). Vary which position holds the correct answer across questions. Don't give the user any clues about the answer through formatting or order.
|
||||||
|
|
||||||
|
## Acquiring Wisdom
|
||||||
|
|
||||||
|
Wisdom comes from true real-world interaction - testing your skills outside the learning environment.
|
||||||
|
|
||||||
|
When the user asks a question that appears to require wisdom, your default posture should be to attempt to answer - but to ultimately delegate to a **community**.
|
||||||
|
|
||||||
|
A community is a place (online or offline) where the user can test their skills in the real world. This might be a forum, a subreddit, a real-world class (budget permitting) or a local interest group.
|
||||||
|
|
||||||
|
You should attempt to find high-reputation communities the user can join. If the user expresses a preference that they don't want to join a community, respect it.
|
||||||
|
|
||||||
|
## Reference Documents
|
||||||
|
|
||||||
|
While creating lessons, you should also create reference documents. Lessons can reference these documents - they are useful for tracking raw units of knowledge useful across lessons.
|
||||||
|
|
||||||
|
Lessons will rarely be revisited later - reference documents will be. They should be the compressed essence of the lesson, in a format designed for quick reference.
|
||||||
|
|
||||||
|
Some learning topics lend themselves to reference:
|
||||||
|
|
||||||
|
- Syntax and code snippets for programming
|
||||||
|
- Algorithms and flowcharts for processes
|
||||||
|
- Yoga poses and sequences for yoga
|
||||||
|
- Exercises and routines for fitness
|
||||||
|
- Glossaries for any topic with its own nomenclature
|
||||||
|
|
||||||
|
Glossaries, in particular, are an essential reference. Once one is created, it should be adhered to in every lesson.
|
||||||
|
|
||||||
|
## `NOTES.md`
|
||||||
|
|
||||||
|
The user will sometimes express preferences of how they want to be taught, or things you should keep in mind. This is the place to record those preferences, so you can refer back to them when designing lessons or working with the user.
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
---
|
||||||
|
name: to-questionnaire
|
||||||
|
description: Turn a decision you can't fully answer into a questionnaire for someone else to fill in.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Turn something the user can't answer alone into a **questionnaire**: a Markdown document they hand to one person to fill in async, or fill out together over a meeting. The recipient holds knowledge the user lacks; the questionnaire pulls it out of them.
|
||||||
|
|
||||||
|
**Grill the send, not the subject.** Interview the user only about the _send_, which they can always answer: who it goes to, and what they need back. The questions in the document then target the **gap** between what the recipient knows and what the user needs.
|
||||||
|
|
||||||
|
|
||||||
|
1. **Who is it going to?** Ask, in one exchange, the recipient's role, expertise, and relationship to the user. This fixes the questionnaire's tone and how much context it must carry. Done when you know who the recipient is and what they know that the user doesn't.
|
||||||
|
|
||||||
|
2. **What do you need back?** Ask, in one exchange, the specific decisions or facts the user can't resolve alone and needs from this person. Done when you have a concrete list of what the user must walk away able to do or decide.
|
||||||
|
|
||||||
|
3. **Write the questionnaire.** Draft questions aimed at the gap from steps 1–2, following the Document structure below. Write it to `to-questionnaire-<slug>.md` in the current directory (slug from the topic) and report the path. Done when the file exists and every item the user named in step 2 is covered by a question.
|
||||||
|
|
||||||
|
## Document structure
|
||||||
|
|
||||||
|
Frame the document as a **discovery questionnaire**: the user lacks context, the recipient holds it. Order questions most-important-first, since async means you may only get one pass, and group them under `##` headings by theme once there are more than a handful. Write it using the template below.
|
||||||
|
|
||||||
|
<questionnaire-template>
|
||||||
|
|
||||||
|
# <Questionnaire title>
|
||||||
|
|
||||||
|
**Purpose:** why this questionnaire exists and the decision riding on it.
|
||||||
|
|
||||||
|
**From:** <the user>, **To:** <the recipient>, **How your answers will be used:** <where they go>
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
One paragraph orienting a recipient who wasn't in the user's head. Enough to answer well, not a page.
|
||||||
|
|
||||||
|
## How to answer
|
||||||
|
|
||||||
|
Deadline and rough effort. Partial answers and "I don't know" are useful: flag anything you're unsure of rather than skipping it.
|
||||||
|
|
||||||
|
## <Theme heading>
|
||||||
|
|
||||||
|
One `##` section per theme. Under each, its questions, most-important-first. Every question is one idea, never compound, with an answer stub directly beneath, and a one-line _why this matters_ only where the question could be misread or invite a throwaway answer.
|
||||||
|
|
||||||
|
<question-example>
|
||||||
|
### What load is the system expected to handle at launch?
|
||||||
|
|
||||||
|
_Why this matters: it decides whether we provision for burst traffic now or defer it._
|
||||||
|
|
||||||
|
>
|
||||||
|
</question-example>
|
||||||
|
|
||||||
|
## Anything else?
|
||||||
|
|
||||||
|
A closing catch-all: anything we didn't ask that we should know?
|
||||||
|
|
||||||
|
</questionnaire-template>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
name: to-spec
|
||||||
|
description: "Turn the current conversation into a spec and publish it to the project issue tracker: no interview, just synthesis of what you've already discussed."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
This skill takes the current conversation context and codebase understanding and produces a spec. Do NOT interview the user; just synthesize what you already know.
|
||||||
|
|
||||||
|
The issue tracker and triage label vocabulary should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
1. Explore the repo to understand the current state of the codebase, if you haven't already. Use the project's domain glossary vocabulary throughout the spec, and respect any ADRs in the area you're touching.
|
||||||
|
|
||||||
|
2. Sketch out the seams at which you're going to test the feature. Existing seams should be preferred to new ones. Use the highest seam possible. If new seams are needed, propose them at the highest point you can. The fewer seams across the codebase, the better - the ideal number is one.
|
||||||
|
|
||||||
|
Check with the user that these seams match their expectations.
|
||||||
|
|
||||||
|
3. Write the spec using the template below, then publish it to the project issue tracker. Apply the `ready-for-agent` triage label - no need for additional triage.
|
||||||
|
|
||||||
|
<spec-template>
|
||||||
|
|
||||||
|
## Problem Statement
|
||||||
|
|
||||||
|
The problem that the user is facing, from the user's perspective.
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
|
||||||
|
The solution to the problem, from the user's perspective.
|
||||||
|
|
||||||
|
## User Stories
|
||||||
|
|
||||||
|
A LONG, numbered list of user stories. Each user story should be in the format of:
|
||||||
|
|
||||||
|
1. As an <actor>, I want a <feature>, so that <benefit>
|
||||||
|
|
||||||
|
<user-story-example>
|
||||||
|
1. As a mobile bank customer, I want to see balance on my accounts, so that I can make better informed decisions about my spending
|
||||||
|
</user-story-example>
|
||||||
|
|
||||||
|
This list of user stories should be extremely extensive and cover all aspects of the feature.
|
||||||
|
|
||||||
|
## Implementation Decisions
|
||||||
|
|
||||||
|
A list of implementation decisions that were made. This can include:
|
||||||
|
|
||||||
|
- The modules that will be built/modified
|
||||||
|
- The interfaces of those modules that will be modified
|
||||||
|
- Technical clarifications from the developer
|
||||||
|
- Architectural decisions
|
||||||
|
- Schema changes
|
||||||
|
- API contracts
|
||||||
|
- Specific interactions
|
||||||
|
|
||||||
|
Do NOT include specific file paths or code snippets. They may end up being outdated very quickly.
|
||||||
|
|
||||||
|
Exception: if a prototype produced a snippet that encodes a decision more precisely than prose can (state machine, reducer, schema, type shape), inline it within the relevant decision and note briefly that it came from a prototype. Trim to the decision-rich parts, not a working demo, just the important bits.
|
||||||
|
|
||||||
|
## Testing Decisions
|
||||||
|
|
||||||
|
A list of testing decisions that were made. Include:
|
||||||
|
|
||||||
|
- A description of what makes a good test (only test external behavior, not implementation details)
|
||||||
|
- Which modules will be tested
|
||||||
|
- Prior art for the tests (i.e. similar types of tests in the codebase)
|
||||||
|
|
||||||
|
## Out of Scope
|
||||||
|
|
||||||
|
A description of the things that are out of scope for this spec.
|
||||||
|
|
||||||
|
## Further Notes
|
||||||
|
|
||||||
|
Any further notes about the feature.
|
||||||
|
|
||||||
|
</spec-template>
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
---
|
||||||
|
name: to-tickets
|
||||||
|
description: Break a plan, spec, or the current conversation into a set of tracer-bullet tickets, each declaring its blocking edges, published to the configured tracker (edges as text in one file per ticket locally, or native blocking links on a real tracker).
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# To Tickets
|
||||||
|
|
||||||
|
Break a plan, spec, or conversation into a set of **tickets**: tracer-bullet vertical slices, each declaring the tickets that **block** it.
|
||||||
|
|
||||||
|
The issue tracker and triage label vocabulary should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Gather context
|
||||||
|
|
||||||
|
Work from whatever is already in the conversation context. If the user passes a reference (a spec path, an issue number or URL) as an argument, fetch it and read its full body and comments.
|
||||||
|
|
||||||
|
### 2. Explore the codebase (optional)
|
||||||
|
|
||||||
|
If you have not already explored the codebase, do so to understand the current state of the code. Ticket titles and descriptions should use the project's domain glossary vocabulary, and respect ADRs in the area you're touching.
|
||||||
|
|
||||||
|
Look for opportunities to prefactor the code to make the implementation easier. "Make the change easy, then make the easy change."
|
||||||
|
|
||||||
|
### 3. Draft vertical slices
|
||||||
|
|
||||||
|
Break the work into **tracer bullet** tickets.
|
||||||
|
|
||||||
|
<vertical-slice-rules>
|
||||||
|
|
||||||
|
- Each slice cuts a narrow but COMPLETE path through every layer (schema, API, UI, tests): vertical, NOT a horizontal slice of one layer
|
||||||
|
- A completed slice is demoable or verifiable on its own
|
||||||
|
- Each slice is sized to fit in a single fresh context window
|
||||||
|
- Any prefactoring should be done first
|
||||||
|
|
||||||
|
</vertical-slice-rules>
|
||||||
|
|
||||||
|
Give each ticket its **blocking edges**: the other tickets that must complete before it can start. A ticket with no blockers can start immediately.
|
||||||
|
|
||||||
|
**Wide refactors are the exception to vertical slicing.** A **wide refactor** is one mechanical change (rename a column, retype a shared symbol) whose **blast radius** fans across the whole codebase, so a single edit breaks thousands of call sites at once and no vertical slice can land green. Don't force it into a tracer bullet; sequence it as **expand–contract**. First expand: add the new form beside the old so nothing breaks. Then migrate the call sites over in batches sized by blast radius (per package, per directory), each batch its own ticket blocked by the expand, keeping CI green batch to batch because the old form still exists. Finally contract: delete the old form once no caller remains, in a ticket blocked by every migrate batch. When even the batches can't stay green alone, keep the sequence but let them share an integration branch that all block a final integrate-and-verify ticket; green is promised only there.
|
||||||
|
|
||||||
|
### 4. Quiz the user
|
||||||
|
|
||||||
|
Present the proposed breakdown as a numbered list. For each ticket, show:
|
||||||
|
|
||||||
|
- **Title**: short descriptive name
|
||||||
|
- **Blocked by**: which other tickets (if any) must complete first
|
||||||
|
- **What it delivers**: the end-to-end behaviour this ticket makes work
|
||||||
|
|
||||||
|
Ask the user:
|
||||||
|
|
||||||
|
- Does the granularity feel right? (too coarse / too fine)
|
||||||
|
- Are the blocking edges correct: does each ticket only depend on tickets that genuinely gate it?
|
||||||
|
- Should any tickets be merged or split further?
|
||||||
|
|
||||||
|
Iterate until the user approves the breakdown.
|
||||||
|
|
||||||
|
### 5. Publish the tickets to the configured tracker
|
||||||
|
|
||||||
|
Publish the approved tickets. **How** depends on the tracker `/setup-matt-pocock-skills` configured; the tickets are the same either way, only the shape of the blocking edges changes:
|
||||||
|
|
||||||
|
- **Local files** → write one file per ticket under `.scratch/<feature-slug>/issues/<NN>-<slug>.md`, numbered from `01` in dependency order (blockers first). Each file's "Blocked by" lists the numbers/titles it depends on. Use the per-ticket file template below: one ticket per file, never a single combined file.
|
||||||
|
- **A real issue tracker (GitHub, Linear, …)** → publish one issue per ticket in dependency order (blockers first) so each ticket's blocking edges can reference real identifiers. Use the platform's native blocking relationship where it has one; otherwise set each ticket's "Blocked by" to the blocking issues. If the source was an existing issue, make each ticket its sub-issue (tracker doc's operation). Apply the `ready-for-agent` triage label unless instructed otherwise; the tickets are agent-grabbable by construction.
|
||||||
|
|
||||||
|
Work the **frontier**: any ticket whose blockers are all done. For a purely linear chain that means top to bottom.
|
||||||
|
|
||||||
|
Do NOT close or modify any parent issue.
|
||||||
|
|
||||||
|
<local-ticket-template>
|
||||||
|
|
||||||
|
# <NN>: <Ticket title>
|
||||||
|
|
||||||
|
**What to build:** the end-to-end behaviour this ticket makes work, from the user's perspective, not a layer-by-layer implementation list.
|
||||||
|
|
||||||
|
**Blocked by:** the numbers/titles of the tickets that gate this one, or "None (can start immediately)".
|
||||||
|
|
||||||
|
**Status:** ready-for-agent
|
||||||
|
|
||||||
|
- [ ] Acceptance criterion 1
|
||||||
|
- [ ] Acceptance criterion 2
|
||||||
|
|
||||||
|
</local-ticket-template>
|
||||||
|
|
||||||
|
<issue-template>
|
||||||
|
|
||||||
|
## Parent
|
||||||
|
|
||||||
|
A reference to the parent issue on the tracker (if the source was an existing issue, otherwise omit this section).
|
||||||
|
|
||||||
|
## What to build
|
||||||
|
|
||||||
|
The end-to-end behaviour this ticket makes work, from the user's perspective, not layer-by-layer implementation.
|
||||||
|
|
||||||
|
## Acceptance criteria
|
||||||
|
|
||||||
|
- [ ] Criterion 1
|
||||||
|
- [ ] Criterion 2
|
||||||
|
|
||||||
|
## Blocked by
|
||||||
|
|
||||||
|
- A reference to each blocking ticket, or "None (can start immediately)". Omit this section when blockers were set as native edges.
|
||||||
|
|
||||||
|
</issue-template>
|
||||||
|
|
||||||
|
In either form, avoid specific file paths or code snippets: they go stale fast. Exception: if a prototype produced a snippet that encodes a decision more precisely than prose can (state machine, reducer, schema, type shape), inline it and note briefly that it came from a prototype. Trim to the decision-rich parts, not a working demo, just the important bits.
|
||||||
@@ -0,0 +1,207 @@
|
|||||||
|
# Writing Agent Briefs
|
||||||
|
|
||||||
|
An agent brief is a structured comment posted on a GitHub issue or PR when it moves to `ready-for-agent`. It is the authoritative specification that an AFK agent will work from. The original body and discussion are context: the agent brief is the contract.
|
||||||
|
|
||||||
|
The brief states **what the agent should do**, which stretches to both surfaces: for an issue, that's building the change from nothing; for a PR, it's what's left to do *to the existing diff*: finish it, close gaps, address review points. Same principles either way; the PR example below shows the difference.
|
||||||
|
|
||||||
|
## Principles
|
||||||
|
|
||||||
|
### Durability over precision
|
||||||
|
|
||||||
|
The issue may sit in `ready-for-agent` for days or weeks. The codebase will change in the meantime. Write the brief so it stays useful even as files are renamed, moved, or refactored.
|
||||||
|
|
||||||
|
- **Do** describe interfaces, types, and behavioral contracts
|
||||||
|
- **Do** name specific types, function signatures, or config shapes that the agent should look for or modify
|
||||||
|
- **Don't** reference file paths: they go stale
|
||||||
|
- **Don't** reference line numbers
|
||||||
|
- **Don't** assume the current implementation structure will remain the same
|
||||||
|
|
||||||
|
### Behavioral, not procedural
|
||||||
|
|
||||||
|
Describe **what** the system should do, not **how** to implement it. The agent will explore the codebase fresh and make its own implementation decisions.
|
||||||
|
|
||||||
|
- **Good:** "The `SkillConfig` type should accept an optional `schedule` field of type `CronExpression`"
|
||||||
|
- **Bad:** "Open src/types/skill.ts and add a schedule field on line 42"
|
||||||
|
- **Good:** "When a user runs `/triage` with no arguments, they should see a summary of issues needing attention"
|
||||||
|
- **Bad:** "Add a switch statement in the main handler function"
|
||||||
|
|
||||||
|
### Complete acceptance criteria
|
||||||
|
|
||||||
|
The agent needs to know when it's done. Every agent brief must have concrete, testable acceptance criteria. Each criterion should be independently verifiable.
|
||||||
|
|
||||||
|
- **Good:** "Running `gh issue list --label needs-triage` returns issues that have been through initial classification"
|
||||||
|
- **Bad:** "Triage should work correctly"
|
||||||
|
|
||||||
|
### Explicit scope boundaries
|
||||||
|
|
||||||
|
State what is out of scope. This prevents the agent from gold-plating or making assumptions about adjacent features.
|
||||||
|
|
||||||
|
## Template
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Category:** bug / enhancement
|
||||||
|
**Summary:** one-line description of what needs to happen
|
||||||
|
|
||||||
|
**Current behavior:**
|
||||||
|
Describe what happens now. For bugs, this is the broken behavior.
|
||||||
|
For enhancements, this is the status quo the feature builds on.
|
||||||
|
|
||||||
|
**Desired behavior:**
|
||||||
|
Describe what should happen after the agent's work is complete.
|
||||||
|
Be specific about edge cases and error conditions.
|
||||||
|
|
||||||
|
**Key interfaces:**
|
||||||
|
- `TypeName`: what needs to change and why
|
||||||
|
- `functionName()` return type: what it currently returns vs what it should return
|
||||||
|
- Config shape: any new configuration options needed
|
||||||
|
|
||||||
|
**Acceptance criteria:**
|
||||||
|
- [ ] Specific, testable criterion 1
|
||||||
|
- [ ] Specific, testable criterion 2
|
||||||
|
- [ ] Specific, testable criterion 3
|
||||||
|
|
||||||
|
**Out of scope:**
|
||||||
|
- Thing that should NOT be changed or addressed in this issue
|
||||||
|
- Adjacent feature that might seem related but is separate
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Good agent brief (bug)
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Category:** bug
|
||||||
|
**Summary:** Skill description truncation drops mid-word, producing broken output
|
||||||
|
|
||||||
|
**Current behavior:**
|
||||||
|
When a skill description exceeds 1024 characters, it is truncated at exactly
|
||||||
|
1024 characters regardless of word boundaries. This produces descriptions
|
||||||
|
that end mid-word (e.g. "Use when the user wants to confi").
|
||||||
|
|
||||||
|
**Desired behavior:**
|
||||||
|
Truncation should break at the last word boundary before 1024 characters
|
||||||
|
and append "..." to indicate truncation.
|
||||||
|
|
||||||
|
**Key interfaces:**
|
||||||
|
- The `SkillMetadata` type's `description` field: no type change needed,
|
||||||
|
but the validation/processing logic that populates it needs to respect
|
||||||
|
word boundaries
|
||||||
|
- Any function that reads SKILL.md frontmatter and extracts the description
|
||||||
|
|
||||||
|
**Acceptance criteria:**
|
||||||
|
- [ ] Descriptions under 1024 chars are unchanged
|
||||||
|
- [ ] Descriptions over 1024 chars are truncated at the last word boundary
|
||||||
|
before 1024 chars
|
||||||
|
- [ ] Truncated descriptions end with "..."
|
||||||
|
- [ ] The total length including "..." does not exceed 1024 chars
|
||||||
|
|
||||||
|
**Out of scope:**
|
||||||
|
- Changing the 1024 char limit itself
|
||||||
|
- Multi-line description support
|
||||||
|
```
|
||||||
|
|
||||||
|
### Good agent brief (enhancement)
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Category:** enhancement
|
||||||
|
**Summary:** Add `.out-of-scope/` directory support for tracking rejected feature requests
|
||||||
|
|
||||||
|
**Current behavior:**
|
||||||
|
When a feature request is rejected, the issue is closed with a `wontfix` label
|
||||||
|
and a comment. There is no persistent record of the decision or reasoning.
|
||||||
|
Future similar requests require the maintainer to recall or search for the
|
||||||
|
prior discussion.
|
||||||
|
|
||||||
|
**Desired behavior:**
|
||||||
|
Rejected feature requests should be documented in `.out-of-scope/<concept>.md`
|
||||||
|
files that capture the decision, reasoning, and links to all issues that
|
||||||
|
requested the feature. When triaging new issues, these files should be
|
||||||
|
checked for matches.
|
||||||
|
|
||||||
|
**Key interfaces:**
|
||||||
|
- Markdown file format in `.out-of-scope/`: each file should have a
|
||||||
|
`# Concept Name` heading, a `**Decision:**` line, a `**Reason:**` line,
|
||||||
|
and a `**Prior requests:**` list with issue links
|
||||||
|
- The triage workflow should read all `.out-of-scope/*.md` files early
|
||||||
|
and match incoming issues against them by concept similarity
|
||||||
|
|
||||||
|
**Acceptance criteria:**
|
||||||
|
- [ ] Closing a feature as wontfix creates/updates a file in `.out-of-scope/`
|
||||||
|
- [ ] The file includes the decision, reasoning, and link to the closed issue
|
||||||
|
- [ ] If a matching `.out-of-scope/` file already exists, the new issue is
|
||||||
|
appended to its "Prior requests" list rather than creating a duplicate
|
||||||
|
- [ ] During triage, existing `.out-of-scope/` files are checked and surfaced
|
||||||
|
when a new issue matches a prior rejection
|
||||||
|
|
||||||
|
**Out of scope:**
|
||||||
|
- Automated matching (human confirms the match)
|
||||||
|
- Reopening previously rejected features
|
||||||
|
- Bug reports (only enhancement rejections go to `.out-of-scope/`)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Good agent brief (PR)
|
||||||
|
|
||||||
|
For a PR, "Current behavior" describes the state of the diff, and the brief asks the agent to finish or fix it rather than build from scratch.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Category:** enhancement
|
||||||
|
**Summary:** Finish the contributor's `--json` output flag for `triage list`
|
||||||
|
|
||||||
|
**Current behavior:**
|
||||||
|
The PR adds a `--json` flag that serializes the issue list to JSON. The happy
|
||||||
|
path works and the diff matches the project's command structure. Two gaps
|
||||||
|
remain: errors are still printed as human text (not JSON), and the new flag has
|
||||||
|
no test coverage.
|
||||||
|
|
||||||
|
**Desired behavior:**
|
||||||
|
With `--json`, all output (including errors) is well-formed JSON on stdout,
|
||||||
|
and the command's exit codes are unchanged. The existing human-readable output
|
||||||
|
is untouched when the flag is absent.
|
||||||
|
|
||||||
|
**Key interfaces:**
|
||||||
|
- The command's error path should emit `{ "error": string }` under `--json`
|
||||||
|
instead of the plain-text error
|
||||||
|
- Reuse the existing serializer the PR already added; don't introduce a second
|
||||||
|
|
||||||
|
**Acceptance criteria:**
|
||||||
|
- [ ] `triage list --json` emits valid JSON for both success and error cases
|
||||||
|
- [ ] Exit codes match the non-JSON command
|
||||||
|
- [ ] A test covers the `--json` success output and one error case
|
||||||
|
- [ ] Default (non-JSON) output is byte-for-byte unchanged
|
||||||
|
|
||||||
|
**Out of scope:**
|
||||||
|
- Adding `--json` to any other command
|
||||||
|
- Changing the JSON shape of the success payload the PR already defined
|
||||||
|
```
|
||||||
|
|
||||||
|
### Bad agent brief
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Agent Brief
|
||||||
|
|
||||||
|
**Summary:** Fix the triage bug
|
||||||
|
|
||||||
|
**What to do:**
|
||||||
|
The triage thing is broken. Look at the main file and fix it.
|
||||||
|
The function around line 150 has the issue.
|
||||||
|
|
||||||
|
**Files to change:**
|
||||||
|
- src/triage/handler.ts (line 150)
|
||||||
|
- src/types.ts (line 42)
|
||||||
|
```
|
||||||
|
|
||||||
|
This is bad because:
|
||||||
|
- No category
|
||||||
|
- Vague description ("the triage thing is broken")
|
||||||
|
- References file paths and line numbers that will go stale
|
||||||
|
- No acceptance criteria
|
||||||
|
- No scope boundaries
|
||||||
|
- No description of current vs desired behavior
|
||||||
@@ -0,0 +1,105 @@
|
|||||||
|
# Out-of-Scope Knowledge Base
|
||||||
|
|
||||||
|
The `.out-of-scope/` directory in a repo stores persistent records of rejected feature requests. It serves two purposes:
|
||||||
|
|
||||||
|
1. **Institutional memory**: why a feature was rejected, so the reasoning isn't lost when the issue is closed
|
||||||
|
2. **Deduplication**: when a new issue comes in that matches a prior rejection, the skill can surface the previous decision instead of re-litigating it
|
||||||
|
|
||||||
|
## Directory structure
|
||||||
|
|
||||||
|
```
|
||||||
|
.out-of-scope/
|
||||||
|
├── dark-mode.md
|
||||||
|
├── plugin-system.md
|
||||||
|
└── graphql-api.md
|
||||||
|
```
|
||||||
|
|
||||||
|
One file per **concept**, not per issue. Multiple issues requesting the same thing are grouped under one file.
|
||||||
|
|
||||||
|
## File format
|
||||||
|
|
||||||
|
The file should be written in a relaxed, readable style, more like a short design document than a database entry. Use paragraphs, code samples, and examples to make the reasoning clear and useful to someone encountering it for the first time.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
# Dark Mode
|
||||||
|
|
||||||
|
This project does not support dark mode or user-facing theming.
|
||||||
|
|
||||||
|
## Why this is out of scope
|
||||||
|
|
||||||
|
The rendering pipeline assumes a single color palette defined in
|
||||||
|
`ThemeConfig`. Supporting multiple themes would require:
|
||||||
|
|
||||||
|
- A theme context provider wrapping the entire component tree
|
||||||
|
- Per-component theme-aware style resolution
|
||||||
|
- A persistence layer for user theme preferences
|
||||||
|
|
||||||
|
This is a significant architectural change that doesn't align with the
|
||||||
|
project's focus on content authoring. Theming is a concern for downstream
|
||||||
|
consumers who embed or redistribute the output.
|
||||||
|
|
||||||
|
```ts
|
||||||
|
// The current ThemeConfig interface is not designed for runtime switching:
|
||||||
|
interface ThemeConfig {
|
||||||
|
colors: ColorPalette; // single palette, resolved at build time
|
||||||
|
fonts: FontStack;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Prior requests
|
||||||
|
|
||||||
|
- #42: "Add dark mode support"
|
||||||
|
- #87: "Night theme for accessibility"
|
||||||
|
- #134: "Dark theme option"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Naming the file
|
||||||
|
|
||||||
|
Use a short, descriptive kebab-case name for the concept: `dark-mode.md`, `plugin-system.md`, `graphql-api.md`. The name should be recognizable enough that someone browsing the directory understands what was rejected without opening the file.
|
||||||
|
|
||||||
|
### Writing the reason
|
||||||
|
|
||||||
|
The reason should be substantive: not "we don't want this" but why. Good reasons reference:
|
||||||
|
|
||||||
|
- Project scope or philosophy ("This project focuses on X; theming is a downstream concern")
|
||||||
|
- Technical constraints ("Supporting this would require Y, which conflicts with our Z architecture")
|
||||||
|
- Strategic decisions ("We chose to use A instead of B because...")
|
||||||
|
|
||||||
|
The reason should be durable. Avoid referencing temporary circumstances ("we're too busy right now"); those aren't real rejections, they're deferrals.
|
||||||
|
|
||||||
|
## When to check `.out-of-scope/`
|
||||||
|
|
||||||
|
During triage (Step 1: Gather context), read all files in `.out-of-scope/`. When evaluating a new issue:
|
||||||
|
|
||||||
|
- Check if the request matches an existing out-of-scope concept
|
||||||
|
- Matching is by concept similarity, not keyword: "night theme" matches `dark-mode.md`
|
||||||
|
- If there's a match, surface it to the maintainer: "This is similar to `.out-of-scope/dark-mode.md`. We rejected this before because [reason]. Do you still feel the same way?"
|
||||||
|
|
||||||
|
The maintainer may:
|
||||||
|
|
||||||
|
- **Confirm**: the new issue gets added to the existing file's "Prior requests" list, then closed
|
||||||
|
- **Reconsider**: the out-of-scope file gets deleted or updated, and the issue proceeds through normal triage
|
||||||
|
- **Disagree**: the issues are related but distinct, proceed with normal triage
|
||||||
|
|
||||||
|
## When to write to `.out-of-scope/`
|
||||||
|
|
||||||
|
Only when an **enhancement** (not a bug) is *rejected* as `wontfix`. This applies to enhancement PRs exactly as it does to issues: a rejected PR is recorded here so the same request doesn't return as fresh code.
|
||||||
|
|
||||||
|
Do **not** write here when something is closed as `wontfix` because it's **already implemented**. That's a built feature, not a rejected one; recording it would poison the dedup checks with false rejections. Instead, the closing comment points to where the feature already lives.
|
||||||
|
|
||||||
|
The flow:
|
||||||
|
|
||||||
|
1. Maintainer decides a feature request is out of scope
|
||||||
|
2. Check if a matching `.out-of-scope/` file already exists
|
||||||
|
3. If yes: append the new issue to the "Prior requests" list
|
||||||
|
4. If no: create a new file with the concept name, decision, reason, and first prior request
|
||||||
|
5. Post a comment on the issue explaining the decision and mentioning the `.out-of-scope/` file
|
||||||
|
6. Close the issue with the `wontfix` label
|
||||||
|
|
||||||
|
## Updating or removing out-of-scope files
|
||||||
|
|
||||||
|
If the maintainer changes their mind about a previously rejected concept:
|
||||||
|
|
||||||
|
- Delete the `.out-of-scope/` file
|
||||||
|
- The skill does not need to reopen old issues; they're historical records
|
||||||
|
- The new issue that triggered the reconsideration proceeds through normal triage
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
---
|
||||||
|
name: triage
|
||||||
|
description: Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
# Triage
|
||||||
|
|
||||||
|
Move issues on the project issue tracker through a small state machine of triage roles.
|
||||||
|
|
||||||
|
If this repo treats external pull requests as a request surface (see the issue-tracker config), triage covers them too: **a PR is an issue with attached code**, using the same roles, same states, and same machine, with a few deltas marked "for a PR" below. Resolve a bare `#42` to an issue or PR per the tracker config.
|
||||||
|
|
||||||
|
Every comment or issue posted to the issue tracker during triage **must** start with this disclaimer:
|
||||||
|
|
||||||
|
```
|
||||||
|
> *This was generated by AI during triage.*
|
||||||
|
```
|
||||||
|
|
||||||
|
## Reference docs
|
||||||
|
|
||||||
|
- [AGENT-BRIEF.md](AGENT-BRIEF.md): how to write durable agent briefs
|
||||||
|
- [OUT-OF-SCOPE.md](OUT-OF-SCOPE.md): how the `.out-of-scope/` knowledge base works
|
||||||
|
|
||||||
|
## Roles
|
||||||
|
|
||||||
|
Two **category** roles:
|
||||||
|
|
||||||
|
- `bug`: something is broken
|
||||||
|
- `enhancement`: new feature or improvement
|
||||||
|
|
||||||
|
Five **state** roles:
|
||||||
|
|
||||||
|
- `needs-triage`: maintainer needs to evaluate
|
||||||
|
- `needs-info`: waiting on reporter for more information
|
||||||
|
- `ready-for-agent`: fully specified, ready for an AFK agent
|
||||||
|
- `ready-for-human`: needs human implementation
|
||||||
|
- `wontfix`: will not be actioned
|
||||||
|
|
||||||
|
For a PR, the same states read against the attached code: `ready-for-agent` means a brief is attached and an agent should take the next step on the diff; `ready-for-human` means it's ready for a human to merge.
|
||||||
|
|
||||||
|
Every triaged issue should carry exactly one category role and one state role. If state roles conflict, flag it and ask the maintainer before doing anything else.
|
||||||
|
|
||||||
|
These are canonical role names. The actual label strings used in the issue tracker may differ. The mapping should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`.
|
||||||
|
|
||||||
|
State transitions: an unlabeled issue normally goes to `needs-triage` first; from there it moves to `needs-info`, `ready-for-agent`, `ready-for-human`, or `wontfix`. `needs-info` returns to `needs-triage` once the reporter replies. The maintainer can override at any time; flag transitions that look unusual and ask before proceeding.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
The maintainer invokes `/triage` and describes what they want in natural language. Interpret the request and act. Examples:
|
||||||
|
|
||||||
|
- "Show me anything that needs my attention"
|
||||||
|
- "Let's look at #42" (issue or PR)
|
||||||
|
- "Move #42 to ready-for-agent"
|
||||||
|
- "What's ready for agents to pick up?"
|
||||||
|
|
||||||
|
## Show what needs attention
|
||||||
|
|
||||||
|
Query the issue tracker and present three buckets, oldest first:
|
||||||
|
|
||||||
|
1. **Unlabeled**: never triaged.
|
||||||
|
2. **`needs-triage`**: evaluation in progress.
|
||||||
|
3. **`needs-info` with reporter activity since the last triage notes**: needs re-evaluation.
|
||||||
|
|
||||||
|
When PRs are in scope, include external PRs in these buckets and tag each line `[PR]` or `[issue]`. Discovery surfaces only *external* PRs (the tracker config defines who counts as external), so a collaborator's in-flight PR is not triage work. This filter is discovery-only; an explicitly named PR is always triaged regardless of author.
|
||||||
|
|
||||||
|
Show counts and a one-line summary per item. Let the maintainer pick.
|
||||||
|
|
||||||
|
## Triage a specific issue or PR
|
||||||
|
|
||||||
|
1. **Gather context.** Read the full issue or PR (body, comments, labels, author, dates; for a PR, the diff too). Parse any prior triage notes so you don't re-ask resolved questions. Explore the codebase using the project's domain glossary, respecting ADRs in the area. Run two checks against the codebase: (a) **redundancy**: search for an existing implementation of the requested behavior by domain concept (not just the request's wording), and report where you looked. If found, it's an already-implemented `wontfix` (step 5). (b) **prior rejection**: read `.out-of-scope/*.md` and surface any that resembles this request.
|
||||||
|
|
||||||
|
2. **Recommend.** Tell the maintainer your category and state recommendation with reasoning, plus a brief codebase summary relevant to the request (including whether it's already implemented). Wait for direction.
|
||||||
|
|
||||||
|
3. **Verify the claim.** Before any grilling, check that the claim holds up. For a bug, reproduce it from the reporter's steps. For a PR, confirm the diff does what it claims: check it out, run the relevant tests or commands. Report what happened: confirmed (with code path), failed, or insufficient detail (a strong `needs-info` signal). A confirmed verification makes a much stronger agent brief.
|
||||||
|
|
||||||
|
4. **Grill (if needed).** If the request needs fleshing out, call the Skill tool twice, for "grilling" and "domain-modeling", and grill it into shape a round of questions at a time, sharpening domain terms and updating `GLOSSARY.md`/ADRs inline as decisions land.
|
||||||
|
|
||||||
|
5. **Apply the outcome:**
|
||||||
|
- `ready-for-agent`: post an agent brief comment ([AGENT-BRIEF.md](AGENT-BRIEF.md)).
|
||||||
|
- `ready-for-human`: same structure as an agent brief, but note why it can't be delegated (judgment calls, external access, design decisions, manual testing).
|
||||||
|
- `needs-info`: post triage notes (template below).
|
||||||
|
- For `wontfix`, close the issue, with the comment depending on *why*:
|
||||||
|
- **Already implemented**: the change already exists in the codebase. Point to where it lives; do **not** write to `.out-of-scope/` (that KB is for *rejected* requests, not built ones).
|
||||||
|
- **Rejected (bug)**: give a polite explanation, then close.
|
||||||
|
- **Rejected (enhancement)**: write to `.out-of-scope/`, link to it from a comment, then close ([OUT-OF-SCOPE.md](OUT-OF-SCOPE.md)).
|
||||||
|
- `needs-triage`: apply the role. Optional comment if there's partial progress.
|
||||||
|
|
||||||
|
## Quick state override
|
||||||
|
|
||||||
|
If the maintainer says "move #42 to ready-for-agent", trust them and apply the role directly. Confirm what you're about to do (role changes, comment, close), then act. Skip grilling. If moving to `ready-for-agent` without a grilling session, ask whether they want to write an agent brief.
|
||||||
|
|
||||||
|
## Needs-info template
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Triage Notes
|
||||||
|
|
||||||
|
**What we've established so far:**
|
||||||
|
|
||||||
|
- point 1
|
||||||
|
- point 2
|
||||||
|
|
||||||
|
**What we still need from you (@reporter):**
|
||||||
|
|
||||||
|
- question 1
|
||||||
|
- question 2
|
||||||
|
```
|
||||||
|
|
||||||
|
Capture everything resolved during grilling under "established so far" so the work isn't lost. Questions must be specific and actionable, not "please provide more info".
|
||||||
|
|
||||||
|
## Resuming a previous session
|
||||||
|
|
||||||
|
If prior triage notes exist on the issue or PR, read them, check whether the reporter has answered any outstanding questions, and present an updated picture before continuing. Don't re-ask resolved questions.
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
name: wait-what
|
||||||
|
description: "Stop. That last message did not land: re-pitch it."
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
Wait, I don't understand where you've got to here. Re-pitch that: give me a little bit of context, talk in ASD-STE100 Simplified Technical English, and use the ubiquitous language from `GLOSSARY.md` (follow `GLOSSARY-MAP.md` to the right one if the repo has more than one).
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
---
|
||||||
|
name: wayfinder
|
||||||
|
description: Plan a huge chunk of work (more than one agent session can hold) as a shared map of decision tickets on your issue tracker, and resolve them one at a time until the way to the destination is clear.
|
||||||
|
disable-model-invocation: true
|
||||||
|
---
|
||||||
|
|
||||||
|
A loose idea has arrived, too big for one agent session, and wrapped in fog: the way from here to the **destination** isn't visible yet. Wayfinding is about finding that way, not charging at the destination. This skill charts the way as a **shared map** on the repo's issue tracker, then works its **decision tickets** (questions whose resolution is a decision, not slices of a build to execute) one at a time until the route is clear.
|
||||||
|
|
||||||
|
The destination varies per effort, and naming it is the first act of charting: it shapes every ticket. It might be a spec to hand off and iterate on, a decision to lock before planning starts, or a change made in place like a data-structure migration. The map is domain-agnostic: engineering work, course content, whatever fits the shape.
|
||||||
|
|
||||||
|
## Plan, don't do
|
||||||
|
|
||||||
|
Wayfinder is **planning** by default: each ticket resolves a decision, and the map is done when the way is clear, with nothing left to decide before someone goes and does the thing. The pull to just do the work is usually the signal you've reached the edge of the map and it's time to hand off. An effort can override this in its **Notes**, carrying execution into the map itself, but absent that, produce decisions, not deliverables.
|
||||||
|
|
||||||
|
## Refer by name
|
||||||
|
|
||||||
|
Every map and ticket is an issue, so it has a **name**: its title. In everything the human reads (narration, the map's Decisions-so-far), refer to it by that name, never by a bare id, number, or slug. A wall of `#42, #43, #44` is illegible; names read at a glance. The id and URL don't vanish; a name wraps its link, but they ride _inside_ the name, never stand in for it.
|
||||||
|
|
||||||
|
## The Map
|
||||||
|
|
||||||
|
The map is a single issue on this repo's issue tracker, labelled `wayfinder:map`, the canonical artifact. Its tickets are child issues of the map.
|
||||||
|
|
||||||
|
The map is an **index**, not a store. It lists the decisions made and points at the tickets that hold their detail; a decision lives in exactly one place, its ticket, so the map never restates it, only gists it and links.
|
||||||
|
|
||||||
|
**Where the map, its child tickets, blocking, and frontier queries physically live is tracker-specific.** The issue tracker should have been provided to you. If not, tell the user to run `/setup-matt-pocock-skills`. Consult the tracker doc's "Wayfinding operations" section for how _this_ repo expresses them. If no tracker has been provided, default to the local-markdown tracker.
|
||||||
|
|
||||||
|
### The map body
|
||||||
|
|
||||||
|
The whole map at low resolution, loaded once per session. Open tickets are **not** listed: they are open child issues, found by query.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Destination
|
||||||
|
|
||||||
|
<what reaching the end of this map looks like: the spec, decision, or change this effort is finding its way to. One or two lines; every session orients to it before choosing a ticket.>
|
||||||
|
|
||||||
|
## Notes
|
||||||
|
|
||||||
|
<domain; skills every session should consult; standing preferences for this effort>
|
||||||
|
|
||||||
|
## Decisions so far
|
||||||
|
|
||||||
|
<!-- the index: one line per closed ticket, enough to judge relevance, then zoom the link for the detail the ticket holds -->
|
||||||
|
|
||||||
|
- [<closed ticket title>](link): <one-line gist of the answer>
|
||||||
|
|
||||||
|
## Not yet specified
|
||||||
|
|
||||||
|
<!-- see "Fog of war": in-scope fog you can't ticket yet; graduates as the frontier advances -->
|
||||||
|
|
||||||
|
## Out of scope
|
||||||
|
|
||||||
|
<!-- see "Out of scope": work ruled beyond the destination; closed, never graduates -->
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tickets
|
||||||
|
|
||||||
|
Each ticket is a **child issue** of the map; the tracker's issue id is its identity. Its body is the question, sized to one 100K token agent session:
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## Question
|
||||||
|
|
||||||
|
<the decision or investigation this ticket resolves>
|
||||||
|
```
|
||||||
|
|
||||||
|
Each ticket carries a `wayfinder:<type>` label, one of `research`, `prototype`, `grilling`, `task` (see [Ticket Types](#ticket-types)). `wayfinder:` labels are the only labels a map and its tickets carry, never a triage label like `ready-for-agent`: they are decisions, not implementation work.
|
||||||
|
|
||||||
|
A session **claims** a ticket by assigning it to the dev driving the map, **first**, before any work, so concurrent sessions skip it. That assignee _is_ the claim: an open, unassigned ticket is unclaimed.
|
||||||
|
|
||||||
|
Blocking uses the tracker's **native** dependency relationship: essential because it renders the frontier _visually_ in the tracker's own UI, so the human sees what's takeable without opening the map. Only a tracker that lacks native blocking falls back to a body convention. A ticket is **unblocked** when every ticket blocking it is closed; the **frontier** is the open, unblocked, unclaimed children, the edge of the known.
|
||||||
|
|
||||||
|
The answer isn't part of the body; it's recorded on resolution (see [Work through the map](#work-through-the-map)). Assets created while resolving a ticket are linked from the issue, not pasted in.
|
||||||
|
|
||||||
|
## Ticket Types
|
||||||
|
|
||||||
|
Every ticket is either **HITL** (human in the loop, worked _with_ a human who speaks for themselves) or **AFK**, driven by the agent alone. A HITL ticket only resolves through that live exchange; the agent never stands in for the human's side of it (a grilling agent that answers its own questions has broken this).
|
||||||
|
|
||||||
|
- **Research** (AFK): Reading documentation, third-party APIs, or local resources like knowledge bases to surface a fact a decision waits on. Resolved by a subagent that calls the Skill tool with "research". Use when knowledge outside the current working directory is required.
|
||||||
|
- **Prototype** (HITL): Raise the fidelity of the discussion by making a cheap, rough, concrete artifact to react to (an outline, a rough take, a stub, or UI/logic code) by calling the Skill tool with "prototype". Links the prototype as an asset. Use when "how should it look" or "how should it behave" is the key question.
|
||||||
|
- **Grilling** (HITL): Conversation. The default case. Always call the Skill tool twice, for "grilling" and "domain-modeling".
|
||||||
|
- **Task** (HITL or AFK): Manual work that must happen before a _decision_ can be made: nothing to decide, prototype, or research, but the discussion is blocked until it's done. Signing up for a service so its API can be judged, provisioning access, moving data so its shape can be seen. This is the one type that _does_ rather than decides, and it earns its place by unblocking a decision, not by delivering the destination. The agent drives it alone where it can (AFK); otherwise it hands the human a precise checklist (HITL). Resolved when the work is done; the answer records what was done and any resulting facts (credentials location, new URLs, row counts) later tickets depend on.
|
||||||
|
|
||||||
|
## Fog of war
|
||||||
|
|
||||||
|
The map is _deliberately_ incomplete: don't chart what you can't yet see. Beyond the live tickets lies the **fog of war**: the dim view of decisions and investigations you can tell are coming but can't yet pin down, because they hang on questions still open. Resolving a ticket clears the fog ahead of it, graduating whatever's now specifiable into fresh tickets, one at a time, until the way to the destination is clear and no tickets remain.
|
||||||
|
|
||||||
|
The map's **Not yet specified** section is where that dim view is written down: the suspected question, the area to revisit later. It's the undiscovered frontier _toward_ the destination: everything here is in scope, just not sharp enough to ticket. Write as loosely or as fully as the view allows; it doubles as a signpost for collaborators reading where the effort is headed.
|
||||||
|
|
||||||
|
**Fog or ticket?** The test is whether you can state the question precisely now, _not_ whether you can answer it now.
|
||||||
|
|
||||||
|
- **Ticket when** the question is already sharp, even if it's blocked and you can't act on it yet.
|
||||||
|
- **Not yet specified when** you can't yet phrase it that sharply. Don't pre-slice the fog into ticket-sized pieces: it's coarser than a ticket, and one patch may graduate into several tickets, or none, once the frontier reaches it.
|
||||||
|
|
||||||
|
**Not yet specified** excludes what's already decided (Decisions so far), what's already a live ticket, and what's out of scope (the next section).
|
||||||
|
|
||||||
|
## Out of scope
|
||||||
|
|
||||||
|
Fog only ever gathers _toward_ the destination. The destination fixes the scope, so work beyond it is **out of scope**: it isn't fog, and it doesn't belong in **Not yet specified**. It gets its own **Out of scope** section on the map: work you've consciously ruled out of _this_ effort. Scope, not sharpness, lands it here.
|
||||||
|
|
||||||
|
Out-of-scope work never graduates (the frontier stops at the destination), so it returns only if the destination is redrawn, and then as a fresh effort, not a resumption.
|
||||||
|
|
||||||
|
Ruling something out of scope is a scoping act, not a step on the route. When a ticket that already exists turns out to sit past the destination (mis-scoped in while charting, or exposed by a resolution), **close it** (a closed ticket is unambiguously off the frontier) and leave one line in the **Out of scope** section: the gist plus why it's out of scope, linking the closed ticket. It stays out of **Decisions so far**, which records the route actually walked; a scope boundary isn't a step on it.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
Two modes. Either way, **never resolve more than one ticket per session**, with the exception of research tickets.
|
||||||
|
|
||||||
|
### Chart the map
|
||||||
|
|
||||||
|
User invokes with a loose idea.
|
||||||
|
|
||||||
|
1. **Name the destination.** Call the Skill tool twice, for "grilling" and "domain-modeling", to pin down what this map is finding its way to: the spec, decision, or change. The destination fixes the scope, so it's settled first.
|
||||||
|
2. **Map the frontier.** Grill again, **breadth-first** this time: fan out across the whole space rather than deep on any one thread, surfacing the open decisions and the first steps takeable now. **If this surfaces no fog** (the way to the destination is already clear, the whole journey small enough for one session), you don't need a map. Stop and ask the user how they'd like to proceed.
|
||||||
|
3. **Create the map** (label `wayfinder:map`): Destination and Notes filled in, Decisions-so-far empty, the fog sketched into **Not yet specified**.
|
||||||
|
4. **Create the tickets you can specify now** as child issues of the map, then wire blocking edges in a **second pass** (issues need ids before they can reference each other). Write cross-references in that pass too, with real ids: a placeholder `#<n>` auto-links to an unrelated issue. Wiring sorts them into the frontier and the blocked; everything you can't yet specify stays in the fog: the **Not yet specified** section.
|
||||||
|
5. **Fire the research subagents.** For each `research` ticket you just created, spin up a subagent that calls the Skill tool with "research" to resolve it in parallel, capturing its findings on a throwaway `research/<name>` branch with a context pointer from the ticket. Push the branch but open no PR: it is never merged.
|
||||||
|
6. Stop: charting is one session's work; it hand-resolves nothing.
|
||||||
|
|
||||||
|
### Work through the map
|
||||||
|
|
||||||
|
User invokes with a map (URL or number). A ticket is **optional**: without one, you pick the next decision, not the user.
|
||||||
|
|
||||||
|
1. Load the **map**: the low-res view, not every ticket body.
|
||||||
|
2. Choose the ticket. If the user named one, use it. Otherwise take the first frontier ticket in order. **Claim it**: assign it to yourself before any work.
|
||||||
|
3. Resolve it as the type its `wayfinder:<type>` label names (see [Ticket Types](#ticket-types)). Read the label, not just the body: the body never states the type. **Zoom as needed**: fetch the full body of any related or closed ticket on demand; call the Skill tool for whichever skills the `## Notes` block names. If in doubt, call the Skill tool twice, for "grilling" and "domain-modeling".
|
||||||
|
4. Record the resolution: post the answer as a **resolution comment**, **close** the issue, and **append a context pointer** to the map's Decisions-so-far.
|
||||||
|
5. Add newly-surfaced tickets (create-then-wire); graduate any fog the answer has made specifiable, clearing each graduated patch from **Not yet specified** so it lives only as its new ticket. If the answer reveals that a ticket (this one or another) sits beyond the destination, **rule it out of scope** rather than resolving it on the route. If the decision invalidates other parts of the map, update or delete those tickets.
|
||||||
|
|
||||||
|
The user may run unblocked tickets in parallel, so expect other sessions to be editing the tracker concurrently.
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
---
|
||||||
|
name: wizard
|
||||||
|
description: Generate an interactive bash wizard that walks a human through steps only they can perform. Use when provisioning infrastructure, setting up credentials or CI secrets, walking an unfamiliar third-party dashboard, or running a one-off migration or cutover. Don't invoke this for steps the agent can perform itself.
|
||||||
|
---
|
||||||
|
|
||||||
|
# Wizard
|
||||||
|
|
||||||
|
A **wizard** is a bash script that walks a human, step by step, through a manual procedure that's tedious to do by hand and tedious to re-explain to an AI every time. It opens each URL, says exactly what to click and copy, captures the values, writes them where they belong (`.env`, GitHub secrets), confirms at every stage, and shows how many stages are left. It might configure third-party services, run a one-off migration, or move the project from one state to another.
|
||||||
|
|
||||||
|
The delightful UX is already solved by [template.sh](template.sh): stage-by-stage progress, confirmation gates, cross-platform URL opening (including WSL), hidden secret entry, idempotent `.env` upserts, `gh secret`/`gh variable` writes, and a closing summary. **Your job is only to scope the procedure and author its stages.** The library above the `STAGES` marker is identical in every wizard; that consistency is the point: never hand-edit it.
|
||||||
|
|
||||||
|
A wizard is ephemeral by default: built for one run, saved to a scratch or `scripts/` path, deleted when the job's done. Commit it only when the user wants a repeatable setup path that should live in the repo.
|
||||||
|
|
||||||
|
## Process
|
||||||
|
|
||||||
|
### 1. Scope the procedure
|
||||||
|
|
||||||
|
Work out every manual step the human must take and every value that gets captured along the way. Read the repo first, don't ask cold:
|
||||||
|
|
||||||
|
- For setup: `.env`, `.env.example`, `.env.*`, `README`, `docker-compose*`, framework config, and `.github/workflows/*` (every `secrets.*` / `vars.*` reference is a value the wizard must produce).
|
||||||
|
- For a migration or transition: the current state, the target state, and the irreversible actions between them.
|
||||||
|
|
||||||
|
Then show the user the ordered list of stages and the values each produces, and confirm: they may add, drop, or reorder.
|
||||||
|
|
||||||
|
**Done when:** every stage is named in order, and for each captured value you know (a) where the human gets it, (b) where it's written (`.env`, a GitHub secret, both, or nowhere; some stages are pure actions), and (c) whether it's secret (hidden entry) or public.
|
||||||
|
|
||||||
|
### 2. Map each stage's journey
|
||||||
|
|
||||||
|
For each stage, write the precise path a human follows: which URL to open, what to do there, where a value is shown, which variable it fills: e.g. "Dashboard → Developers → API keys → Reveal test key → copy". Where you don't actually know the current UI or the exact command, say so and ask the user or check the docs: never invent steps that may not exist.
|
||||||
|
|
||||||
|
**Done when:** every stage traces to concrete instructions a stranger could follow.
|
||||||
|
|
||||||
|
### 3. Author the wizard
|
||||||
|
|
||||||
|
Copy `template.sh` to the target path. Replace the example stage with one `stage` per step, in dependency order. Use the library helpers: `stage`, `say`/`step`, `open_url`, `ask`/`ask_secret`, `write_env`, `set_secret`/`set_var`, `pause`/`confirm`. Set `TOTAL_STAGES` to the number of stages you wrote.
|
||||||
|
|
||||||
|
Hold the bar the template sets: open the URL before asking for its value, use `ask_secret` for anything secret, `write_env` every persisted value, `set_secret` only the values CI actually needs, and `confirm` before any irreversible action. Each `stage` clears the screen so only the current step is visible: keep a stage to one focused task so nothing the human needs scrolls away. Don't touch the library above the marker.
|
||||||
|
|
||||||
|
### 4. Verify and hand off
|
||||||
|
|
||||||
|
- `bash -n <script>`; run `shellcheck` if available.
|
||||||
|
- `chmod +x <script>`.
|
||||||
|
- Don't run it end-to-end yourself: it opens browsers and blocks on human input. Trace it statically instead: every value from step 1 is captured and lands where step 1 said, and every `set_secret` name exactly matches a `secrets.*` reference in CI.
|
||||||
|
- Tell the user how to run it. If it's a repeatable setup path, commit it and link it from the README so the next person runs the script instead of asking an AI.
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# A wizard walks a human through a manual procedure, step by step.
|
||||||
|
# Generated by the /wizard skill.
|
||||||
|
#
|
||||||
|
# Everything above the "STAGES" marker is the wizard library: do not hand-edit
|
||||||
|
# it. Author the per-step stages below the marker.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────
|
||||||
|
# Wizard library: delightful, consistent UX, identical across every wizard.
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
if [[ -t 1 ]] && command -v tput >/dev/null 2>&1 && [[ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]]; then
|
||||||
|
BOLD=$(tput bold); DIM=$(tput dim); RESET=$(tput sgr0)
|
||||||
|
BLUE=$(tput setaf 4); GREEN=$(tput setaf 2); YELLOW=$(tput setaf 3)
|
||||||
|
else
|
||||||
|
BOLD=""; DIM=""; RESET=""; BLUE=""; GREEN=""; YELLOW=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Author sets this at the top of the stages section.
|
||||||
|
TOTAL_STAGES=0
|
||||||
|
|
||||||
|
_STAGE_INDEX=0
|
||||||
|
ENV_FILE="${ENV_FILE:-.env}"
|
||||||
|
WRITTEN_ENV=() # KEYs written to ENV_FILE this run
|
||||||
|
WRITTEN_SECRET=() # secret NAMEs set this run
|
||||||
|
SKIPPED=() # things we couldn't do (e.g. gh missing)
|
||||||
|
|
||||||
|
# _clear wipes the terminal so only the current step is on screen. No-op when
|
||||||
|
# output isn't a terminal, so piped logs stay readable.
|
||||||
|
_clear() {
|
||||||
|
[[ -t 1 ]] || return 0
|
||||||
|
if command -v tput >/dev/null 2>&1 && tput clear 2>/dev/null; then return 0; fi
|
||||||
|
printf '\033[2J\033[3J\033[H'
|
||||||
|
}
|
||||||
|
|
||||||
|
# banner "Title" shows the opening frame: what this wizard does.
|
||||||
|
banner() {
|
||||||
|
_clear
|
||||||
|
printf '\n%s%s %s%s\n' "$BOLD" "$BLUE" "$1" "$RESET"
|
||||||
|
printf '%s %s stages%s\n\n' "$DIM" "$TOTAL_STAGES" "$RESET"
|
||||||
|
printf '%s You drive the browser; this wizard tells you exactly what to do and\n' "$DIM"
|
||||||
|
printf ' captures the values you copy back. Stop any time with Ctrl-C and re-run\n'
|
||||||
|
printf ' later, since it remembers values already saved.%s\n' "$RESET"
|
||||||
|
pause "Ready to start?"
|
||||||
|
}
|
||||||
|
|
||||||
|
# stage "Name" clears the screen, then announces a stage and shows progress.
|
||||||
|
# Clearing keeps only the current step on screen.
|
||||||
|
stage() {
|
||||||
|
_clear
|
||||||
|
_STAGE_INDEX=$((_STAGE_INDEX + 1))
|
||||||
|
printf '\n%s%s▸ Stage %s/%s · %s%s\n' \
|
||||||
|
"$BOLD" "$BLUE" "$_STAGE_INDEX" "$TOTAL_STAGES" "$1" "$RESET"
|
||||||
|
}
|
||||||
|
|
||||||
|
# say "..." prints a plain instruction line.
|
||||||
|
say() { printf ' %s\n' "$1"; }
|
||||||
|
# step "..." is a numbered-feeling action the human takes in the browser.
|
||||||
|
step() { printf ' %s•%s %s\n' "$BLUE" "$RESET" "$1"; }
|
||||||
|
note() { printf ' %s%s%s\n' "$DIM" "$1" "$RESET"; }
|
||||||
|
warn() { printf ' %s⚠ %s%s\n' "$YELLOW" "$1" "$RESET"; }
|
||||||
|
|
||||||
|
# open_url URL opens it in the human's browser, cross-platform incl. WSL.
|
||||||
|
open_url() {
|
||||||
|
local url="$1"
|
||||||
|
printf ' %s↗ opening%s %s\n' "$GREEN" "$RESET" "$url"
|
||||||
|
{ if command -v wslview >/dev/null 2>&1; then wslview "$url"
|
||||||
|
elif command -v explorer.exe >/dev/null 2>&1; then explorer.exe "$url"
|
||||||
|
elif command -v xdg-open >/dev/null 2>&1; then xdg-open "$url"
|
||||||
|
elif command -v open >/dev/null 2>&1; then open "$url"
|
||||||
|
else false; fi
|
||||||
|
} >/dev/null 2>&1 || warn "couldn't open a browser, so visit it manually: $url"
|
||||||
|
}
|
||||||
|
|
||||||
|
# pause "msg" waits for the human to confirm they've done the manual part.
|
||||||
|
pause() {
|
||||||
|
printf ' %s%s%s ' "$DIM" "${1:-Press Enter to continue}" "$RESET"
|
||||||
|
read -r _ || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# confirm "question" is a y/N gate; returns success on yes.
|
||||||
|
confirm() {
|
||||||
|
local reply=""
|
||||||
|
printf ' %s? %s [y/N] ' "$YELLOW" "$1"
|
||||||
|
read -r reply || true
|
||||||
|
[[ "$reply" =~ ^[Yy] ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# _existing KEY: current value of KEY in ENV_FILE, if any, with write_env's single
|
||||||
|
# quotes or a plain dotenv double-quoted value undone.
|
||||||
|
_existing() {
|
||||||
|
[[ -f "$ENV_FILE" ]] || return 1
|
||||||
|
local line value sq="'\\''"; line=$(grep -E "^${1}=" "$ENV_FILE" | tail -n1) || return 1
|
||||||
|
value="${line#*=}"
|
||||||
|
if [[ "$value" == \'*\' ]]; then value="${value:1:${#value}-2}"; value="${value//"$sq"/\'}"
|
||||||
|
elif [[ "$value" == \"*\" ]]; then
|
||||||
|
value="${value:1:${#value}-2}"
|
||||||
|
[[ "$value" == *[\\\$\"]* ]] && return 1 # escapes, $ or ": can't decode safely; ask again
|
||||||
|
fi
|
||||||
|
printf '%s' "$value"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ask KEY "Prompt" reads a value into $KEY. Offers the existing .env value as
|
||||||
|
# a default on re-runs (Enter keeps it). Visible input (non-secret), edited
|
||||||
|
# with Readline. Fails at EOF with no input.
|
||||||
|
ask() {
|
||||||
|
local key="$1" prompt="$2" current input s=$'\001' e=$'\002' p rc=0
|
||||||
|
current=$(_existing "$key" || true)
|
||||||
|
# Readline needs the colour codes wrapped in \001..\002 to place the cursor.
|
||||||
|
p=" $s$BOLD$e$prompt$s$RESET$e "
|
||||||
|
[[ -n "$current" ]] && p+="$s$DIM$e[Enter keeps current]$s$RESET$e "
|
||||||
|
read -e -r -p "$p" input || rc=1
|
||||||
|
if (( rc )) && [[ -z "$input" ]]; then return 1; fi
|
||||||
|
[[ -z "$input" && -n "$current" ]] && input="$current"
|
||||||
|
printf -v "$key" '%s' "$input"
|
||||||
|
}
|
||||||
|
|
||||||
|
# ask_secret KEY "Prompt" is like ask, but input is hidden.
|
||||||
|
ask_secret() {
|
||||||
|
local key="$1" prompt="$2" current input rc=0
|
||||||
|
current=$(_existing "$key" || true)
|
||||||
|
if [[ -n "$current" ]]; then
|
||||||
|
printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET"
|
||||||
|
else
|
||||||
|
printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET"
|
||||||
|
fi
|
||||||
|
read -rs input || rc=1
|
||||||
|
printf '\n'
|
||||||
|
if (( rc )) && [[ -z "$input" ]]; then return 1; fi
|
||||||
|
[[ -z "$input" && -n "$current" ]] && input="$current"
|
||||||
|
printf -v "$key" '%s' "$input"
|
||||||
|
}
|
||||||
|
|
||||||
|
# write_env KEY VALUE upserts KEY='VALUE' into ENV_FILE (replaces any existing
|
||||||
|
# line) and sets $KEY. Idempotent. Creates ENV_FILE at mode 0600; writes through
|
||||||
|
# a symlink and keeps an existing file's mode.
|
||||||
|
write_env() {
|
||||||
|
local key="$1" value="$2" tmp sq="'\\''"
|
||||||
|
[[ -e "$ENV_FILE" ]] || (umask 077 && : > "$ENV_FILE")
|
||||||
|
tmp=$(mktemp)
|
||||||
|
grep -vE "^${key}=" "$ENV_FILE" > "$tmp" || true
|
||||||
|
printf "%s='%s'\n" "$key" "${value//\'/$sq}" >> "$tmp"
|
||||||
|
cat "$tmp" > "$ENV_FILE"
|
||||||
|
rm -f "$tmp"
|
||||||
|
printf -v "$key" '%s' "$value"
|
||||||
|
WRITTEN_ENV+=("$key")
|
||||||
|
printf ' %s✓ wrote%s %s → %s\n' "$GREEN" "$RESET" "$key" "$ENV_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set_secret NAME VALUE sets a GitHub Actions repo secret via gh. Falls back
|
||||||
|
# to a warning (and records it) if gh is unavailable or unauthenticated.
|
||||||
|
set_secret() {
|
||||||
|
local name="$1" value="$2"
|
||||||
|
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
|
||||||
|
if printf '%s' "$value" | gh secret set "$name" >/dev/null 2>&1; then
|
||||||
|
WRITTEN_SECRET+=("$name")
|
||||||
|
printf ' %s✓ set%s GitHub secret %s\n' "$GREEN" "$RESET" "$name"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
SKIPPED+=("GitHub secret $name (set it manually: gh secret set $name)")
|
||||||
|
warn "skipped GitHub secret $name: gh not ready; set it later"
|
||||||
|
}
|
||||||
|
|
||||||
|
# set_var NAME VALUE sets a GitHub Actions repo variable (non-secret).
|
||||||
|
set_var() {
|
||||||
|
local name="$1" value="$2"
|
||||||
|
if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
|
||||||
|
if gh variable set "$name" --body "$value" >/dev/null 2>&1; then
|
||||||
|
printf ' %s✓ set%s GitHub variable %s\n' "$GREEN" "$RESET" "$name"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
SKIPPED+=("GitHub variable $name")
|
||||||
|
warn "skipped GitHub variable $name, gh not ready; set it later"
|
||||||
|
}
|
||||||
|
|
||||||
|
# finish clears, then shows a closing summary of everything configured.
|
||||||
|
finish() {
|
||||||
|
_clear
|
||||||
|
printf '\n%s%s ✓ Setup complete%s\n' "$BOLD" "$GREEN" "$RESET"
|
||||||
|
(( ${#WRITTEN_ENV[@]} )) && note "wrote ${#WRITTEN_ENV[@]} value(s) to $ENV_FILE: ${WRITTEN_ENV[*]}"
|
||||||
|
(( ${#WRITTEN_SECRET[@]} )) && note "set ${#WRITTEN_SECRET[@]} GitHub secret(s): ${WRITTEN_SECRET[*]}"
|
||||||
|
if (( ${#SKIPPED[@]} )); then
|
||||||
|
printf '\n'; warn "still to do by hand:"
|
||||||
|
for s in "${SKIPPED[@]}"; do note " - $s"; done
|
||||||
|
fi
|
||||||
|
printf '\n'
|
||||||
|
}
|
||||||
|
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────
|
||||||
|
# STAGES: author this section. One stage() per step the human takes.
|
||||||
|
# Replace the example below. Set TOTAL_STAGES to match the stages you write.
|
||||||
|
# Keep every stage inside run_wizard and the last line as is: bash then parses
|
||||||
|
# the whole file before the first prompt, so an edit mid-run can't break it.
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
run_wizard() {
|
||||||
|
|
||||||
|
TOTAL_STAGES=1
|
||||||
|
|
||||||
|
banner "Stripe setup"
|
||||||
|
|
||||||
|
# ── Example stage: replace with your real steps ───────────────────────────
|
||||||
|
stage "Stripe: API keys"
|
||||||
|
say "We'll grab your Stripe test keys and store them for local dev + CI."
|
||||||
|
open_url "https://dashboard.stripe.com/test/apikeys"
|
||||||
|
step "On the API keys page, copy the Publishable key (starts pk_test_)."
|
||||||
|
ask STRIPE_PUBLISHABLE_KEY "Paste the publishable key:"
|
||||||
|
step "Click 'Reveal test key' on the Secret key row, then copy it."
|
||||||
|
ask_secret STRIPE_SECRET_KEY "Paste the secret key:"
|
||||||
|
write_env STRIPE_PUBLISHABLE_KEY "$STRIPE_PUBLISHABLE_KEY"
|
||||||
|
write_env STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY"
|
||||||
|
set_secret STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY" # CI needs this one
|
||||||
|
# ──────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
finish
|
||||||
|
}
|
||||||
|
|
||||||
|
run_wizard "$@"; exit
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Skill mechanics
|
||||||
|
|
||||||
|
The skill-specific branch of [`writing-for-agents`](SKILL.md): what changes when the document is a skill (frontmatter, the invocation choice, and router skills). Everything else about writing it is the universal reference in `SKILL.md`.
|
||||||
|
|
||||||
|
## Invocation
|
||||||
|
|
||||||
|
Two choices, trading the two loads:
|
||||||
|
|
||||||
|
- A **model-invoked** skill keeps a `description`, so the agent can fire it autonomously, and other skills can reach it. You can still type its name: model-invocation always _includes_ user reach; a description only ever adds agent discovery, never removes the human's. The description is the skill's top-level context pointer, forced to stay loaded at all times: permanent context load in exchange for discoverability. A model-invoked skill whose content is all reference is also one home for shared reference: another skill can invoke it, so reference needed by several skills lives in one place. Mechanics: omit `disable-model-invocation`, and write a model-facing description carrying the trigger branches (the pointer-writing rules in `SKILL.md` apply in full).
|
||||||
|
- A **user-invoked** skill strips the description from the agent's reach: only the human typing its name can invoke it, and no other skill can. Zero context load, but it spends cognitive load: you are the index that must remember it exists. Mechanics: set `disable-model-invocation: true`; the `description` becomes human-facing: a one-line summary, trigger lists stripped.
|
||||||
|
|
||||||
|
Pick model-invocation only when the agent must reach the skill on its own, or another skill must. If it only ever fires by hand, make it user-invoked and pay no context load.
|
||||||
|
|
||||||
|
Shared reference that two user-invoked skills both need can live in neither: with no descriptions, neither can fire the other. Push it to a plain file outside the skill system: external reference any skill can point at.
|
||||||
|
|
||||||
|
## Splitting by invocation
|
||||||
|
|
||||||
|
The invocation cut of splitting (the sequence cut lives in `SKILL.md`): split off a model-invoked skill when you have a distinct leading word that should trigger it on its own (a trigger word you actually use in your prompts), or another skill must reach it. You pay context load for the new always-loaded description, so that independent reach has to be worth it.
|
||||||
|
|
||||||
|
## Router skills
|
||||||
|
|
||||||
|
When user-invoked skills multiply past what you can remember, that piled-up cognitive load is cured by a **router skill**: one user-invoked skill that names the others and when to reach for each, so the human has one skill to remember instead of many. It can only hint, never fire them: user-invoked skills have no description, so nothing but the human can reach them.
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
---
|
||||||
|
name: writing-for-agents
|
||||||
|
description: Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.
|
||||||
|
---
|
||||||
|
|
||||||
|
Reference for writing any document an agent consumes: a skill, an `AGENTS.md` / `CLAUDE.md`, a doc reached by a pointer. The packaging differs; the writing does not: the same levers make each one predictable, since the agent takes the same _process_ every run rather than producing the same output.
|
||||||
|
|
||||||
|
When the document you're writing is a skill, read [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md) for frontmatter, invocation choice, and router skills.
|
||||||
|
|
||||||
|
## Context pointers
|
||||||
|
|
||||||
|
A **context pointer** is a reference held in the agent's context that names some out-of-context material and encodes the condition for reaching it. A skill's description is one; a line in `AGENTS.md` naming a doc is the same object. The pointer's _wording_, not its target, decides when the agent reaches the material, and how reliably. A must-have target behind a weakly worded pointer is a variance bug: sharpen the wording first, and inline the material only if sharpening fails.
|
||||||
|
|
||||||
|
A pointer does two jobs: state what the material is, and list the **branches** that should trigger reaching it (a branch is a distinct case the document handles, so different runs take different paths through it). Every word of an always-loaded pointer costs on every turn, so it earns even harder pruning than the body:
|
||||||
|
|
||||||
|
- **Front-load the leading word**: the pointer is where it does its triggering work.
|
||||||
|
- **One trigger per branch.** Synonyms that rename a single branch are one branch written twice; collapse them and keep only genuinely distinct branches.
|
||||||
|
- **Cut identity the body already carries.**
|
||||||
|
|
||||||
|
## The two loads
|
||||||
|
|
||||||
|
Every document and pointer you add spends one of two budgets:
|
||||||
|
|
||||||
|
- **Context load** is the cost of always-loaded material on the agent's window: an `AGENTS.md` line, a skill description, anything sitting in context every turn, spending tokens and attention whether or not it fires.
|
||||||
|
- **Cognitive load** is the cost on the human: which documents exist and when to reach for each. The human is the index. Not a cost to minimise: it is the price of human agency; spend it where human judgement matters, remove it where it does not.
|
||||||
|
|
||||||
|
Material reached only through a pointer escapes context load at the price of the pointer's own line; material with no pointer at all rides entirely on cognitive load.
|
||||||
|
|
||||||
|
## Information hierarchy
|
||||||
|
|
||||||
|
A document is built from two content types: **steps** (the ordered actions the agent performs) and **reference** (definitions, rules, facts consulted on demand). The two mix freely: all steps (a recipe), all reference (a review's rules, this skill), or both. The core decision is where each piece sits on the **information hierarchy**, a ladder ranked by how immediately the agent needs the material:
|
||||||
|
|
||||||
|
1. **In-file step** is the primary tier: what the agent does, in order.
|
||||||
|
2. **In-file reference** is consulted on demand. Often a legitimately flat peer-set (every rule of a review on one rung), which is a fine arrangement, not a smell.
|
||||||
|
3. **Disclosed reference** is pushed out into a separate file, reached by a context pointer, loaded only when the pointer fires. Spans a sibling file in the same folder through fully external reference that lives anywhere and any document can point at.
|
||||||
|
|
||||||
|
Push too little down and the top bloats; push too much and you hide material the agent actually needs. That tension is the whole decision.
|
||||||
|
|
||||||
|
**Progressive disclosure** is the move down the ladder (out of the main file and behind a pointer) so the top stays legible. Not primarily a token optimisation: it is how the hierarchy is protected. Branching is the cleanest disclosure test: inline what every branch needs, and push behind a pointer what only some branches reach. When a document has steps, in-file reference that should be disclosed buries them and turns attending to them into a coin-flip: a variance lever, not just a legibility one.
|
||||||
|
|
||||||
|
**Co-location** is the within-file companion: where the ladder decides _how far down_ a piece sits, co-location decides _what sits beside it_ once there. Keep a concept's definition, rules, and caveats under one heading rather than scattered, so reading one part brings its neighbours with it. The test: the document should read like documentation written for the agent. Grouped material reads that way; scattered material does not. (Distinct from duplication: that repeats one meaning in two places; scattering fragments one meaning across many.)
|
||||||
|
|
||||||
|
**Sprawl** is the failure mode here: a document simply too long, even when every line is live and unique. Attention thins across the excess, and every extra line is one more to keep relevant. The cure is the ladder: disclose reference behind pointers, and split by branch or sequence so each path carries only what it needs.
|
||||||
|
|
||||||
|
## Steps and completion criteria
|
||||||
|
|
||||||
|
Every step ends on a **completion criterion**, the condition that tells the agent the work is done. Two properties make it a lever:
|
||||||
|
|
||||||
|
- **Clarity**: can the agent tell done from not-done? A vague bound ("understanding reached") invites **premature completion**: ending the step before it is genuinely done, attention slipping to _being done_. The visible steps still ahead (the **post-completion steps**) supply the pull; the criterion's clarity is the resistance. Defend in order: **sharpen the bound first** (local and cheap); only if it is irreducibly fuzzy _and_ you observe the rush, hide the later steps by splitting the sequence. Hiding only works across a real context boundary (a hand-off or a subagent dispatch; an inline call leaves the later steps in context and clears nothing).
|
||||||
|
- **Demand**: how much it requires. "Every modified model accounted for" forces thorough work where "produce a change list" does not. Demand drives **legwork** (the digging the agent does within the work, latent in the wording rather than written as its own step), and it is not step-bound: "every rule applied" binds a body of flat reference just as "every step done" binds a sequence, which is how an all-reference document still carries an exhaustiveness bar.
|
||||||
|
|
||||||
|
The strongest criteria are both checkable and exhaustive.
|
||||||
|
|
||||||
|
## When to split
|
||||||
|
|
||||||
|
Splitting one document into two spends one of the two loads, so split only when the cut earns it:
|
||||||
|
|
||||||
|
- **By sequence**: split a run of steps where the post-completion steps tempt the agent to rush the one in front of it. Keeping them out of view drives more legwork on the current task. Beware the reverse: merging sequences exposes each step's later steps to what follows, inviting premature completion.
|
||||||
|
- **By invocation**, skill-specific: see [`SKILL-MECHANICS.md`](SKILL-MECHANICS.md).
|
||||||
|
|
||||||
|
## Leading words
|
||||||
|
|
||||||
|
A **leading word** is a compact concept already living in the model's pretraining that the agent thinks with while running the document (_lesson_, _fog of war_, _tracer bullets_). Repeated as a token, never as a sentence, it accumulates a distributed definition and anchors a whole region of behaviour in the fewest tokens, by recruiting priors the model already holds. Coining your own works if you define it clearly, but a made-up word recruits no priors: you pay in definition tokens what a pretrained word gives free; reach for an existing word first.
|
||||||
|
|
||||||
|
It anchors twice. In the body, _execution_: the agent reaches for the same behaviour every time the word appears, and inside flat reference it focuses attention on a class of thing to look for. In a pointer, _invocation_: when the same word lives in your prompts, your docs, and your codebase, the agent links that shared language to the material and reaches it more reliably.
|
||||||
|
|
||||||
|
Hunt for opportunities to refactor with leading words. A triad spelled out at three sites, a pointer spending a sentence to gesture at one idea. Each is a passage begging to collapse into a single token:
|
||||||
|
|
||||||
|
- "fast, deterministic, low-overhead" → _tight_ (a _tight_ loop).
|
||||||
|
- "a loop you believe in" → _red_, turning a fuzzy gate into a binary observable state (the loop goes _red_ on the bug, or it doesn't).
|
||||||
|
|
||||||
|
You win twice: fewer tokens, and a sharper hook for the agent to hang its thinking on. Assume every document is carrying restatements that leading words retire. Go find them.
|
||||||
|
|
||||||
|
**Negation** is the failure mode beside this lever: steering by prohibition drags the forbidden behaviour into context and makes it _more_ available, not less. _Don't think of an elephant_, and the elephant is all there is; the negation is a weak modifier the strongly-activated concept overruns, so the ban half-reads as an instruction to do the thing. Prompt the **positive**: state the target behaviour ("write one-line comments") so the banned one is never spoken. A prohibition earns its place only as a hard guardrail you cannot phrase positively; even then, pair it with the positive target so attention lands on what to do.
|
||||||
|
|
||||||
|
## Pruning
|
||||||
|
|
||||||
|
- Keep each meaning in a **single source of truth**: one authoritative place, so changing the behaviour is a one-place edit. **Duplication** (the same meaning in more than one place) costs maintenance and tokens, and inflates a meaning's prominence on the ladder past its real rank. (The accidental inverse of a leading word, which repeats a token on purpose, never the meaning.)
|
||||||
|
- The **environment** is a source of truth too (`package.json` scripts, config files, the directory layout, `--help` output), and a document that restates it is a **cache**: a copy of a lookup, earning its load only when the lookup is expensive. Cache what the agent cannot find by looking: the unwritten convention, the reason behind a choice, the gotcha no config confesses. Leave the one-file, one-command lookups to the environment, where they cannot go stale.
|
||||||
|
- Check every line for **relevance**: does it still bear on what the document does? A line loses relevance by never bearing on the task (mere exposition, or a branch that should be disclosed) or by going stale as the behaviour or world it describes changes. Shorter documents are easier to keep relevant. Without a pruning discipline the default fate is **sediment**: stale layers that settle because adding feels safe and removing feels risky, until you must core down through them to find what is still live.
|
||||||
|
- Hunt **no-ops** sentence by sentence: an instruction the model already obeys by default pays load to say nothing. The test (does it change behaviour versus the default?) is model-relative, not reader-relative: two people disagreeing about a no-op disagree about the default, and settle it by running the document, not by debate. When a sentence fails, delete the whole sentence rather than trim words from it. The test also grades leading words: a word too weak to beat the default (_be thorough_ when the agent is already thorough-ish) is a no-op, and the fix is a stronger word (_relentless_), not a different technique.
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// Minimal YAML-subset frontmatter parser for upstream SKILL.md files.
|
||||||
|
// Supports exactly what mattpocock/skills uses (census 2026-10-14, @49dd158): top-level
|
||||||
|
// `key: value` scalars, double/single-quoted strings with \" escapes, and nested blocks
|
||||||
|
// (e.g. `metadata:`) which are skipped. test/generate.test.ts asserts every vendored skill
|
||||||
|
// parses with non-empty name+description, so an upstream format change fails the build
|
||||||
|
// instead of silently producing a broken manifest.
|
||||||
|
|
||||||
|
export type Frontmatter = Record<string, string>
|
||||||
|
|
||||||
|
export function parseFrontmatter(content: string): { frontmatter: Frontmatter; body: string } {
|
||||||
|
const text = content.replace(/^\uFEFF/, "")
|
||||||
|
if (!text.startsWith("---\n") && !text.startsWith("---\r\n")) {
|
||||||
|
return { frontmatter: {}, body: text }
|
||||||
|
}
|
||||||
|
const end = text.indexOf("\n---", 3)
|
||||||
|
if (end === -1) return { frontmatter: {}, body: text }
|
||||||
|
const raw = text.slice(text.indexOf("\n") + 1, end + 1)
|
||||||
|
const body = text.slice(text.indexOf("\n", end + 1) + 1)
|
||||||
|
|
||||||
|
const frontmatter: Frontmatter = {}
|
||||||
|
for (const line of raw.split(/\r?\n/)) {
|
||||||
|
if (!line || /^\s/.test(line) || line.trim() === "---") continue // nested block or separator
|
||||||
|
const m = /^([A-Za-z][\w-]*):\s*(.*)$/.exec(line)
|
||||||
|
if (!m) continue
|
||||||
|
frontmatter[m[1]] = unquote(m[2].trim())
|
||||||
|
}
|
||||||
|
return { frontmatter, body }
|
||||||
|
}
|
||||||
|
|
||||||
|
function unquote(value: string): string {
|
||||||
|
if (value.length >= 2 && value.startsWith('"') && value.endsWith('"')) {
|
||||||
|
return value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, "\\")
|
||||||
|
}
|
||||||
|
if (value.length >= 2 && value.startsWith("'") && value.endsWith("'")) {
|
||||||
|
return value.slice(1, -1).replace(/''/g, "'")
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isUserInvoked(frontmatter: Frontmatter): boolean {
|
||||||
|
return frontmatter["disable-model-invocation"] === "true"
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// Ports the pattern list of upstream skills/misc/git-guardrails-claude-code (block-dangerous-git.sh)
|
||||||
|
// to an OpenCode v2 tool hook. Opt-in via plugin options { guardrails: true }.
|
||||||
|
|
||||||
|
export type Options = { guardrails: boolean }
|
||||||
|
|
||||||
|
export function resolveOptions(options: Record<string, unknown> | undefined): Options {
|
||||||
|
const opts = options ?? {}
|
||||||
|
const guardrails = opts.guardrails ?? false
|
||||||
|
if (typeof guardrails !== "boolean") {
|
||||||
|
throw new Error(
|
||||||
|
`pocock: option guardrails must be a boolean, got ${JSON.stringify(guardrails)}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return { guardrails }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Same patterns as the upstream hook script (grep -E semantics), in order.
|
||||||
|
const DANGEROUS: ReadonlyArray<readonly [string, RegExp]> = [
|
||||||
|
["git push", /git push/],
|
||||||
|
["git reset --hard", /git reset --hard/],
|
||||||
|
["git clean -fd", /git clean -fd/],
|
||||||
|
["git clean -f", /git clean -f/],
|
||||||
|
["git branch -D", /git branch -D/],
|
||||||
|
["git checkout .", /git checkout \./],
|
||||||
|
["git restore .", /git restore \./],
|
||||||
|
["push --force", /push --force/],
|
||||||
|
["reset --hard", /reset --hard/],
|
||||||
|
]
|
||||||
|
|
||||||
|
export function blockedPattern(command: string): string | undefined {
|
||||||
|
for (const [pattern, re] of DANGEROUS) if (re.test(command)) return pattern
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
export function guardrailError(command: string, pattern: string): string {
|
||||||
|
return `BLOCKED: '${command}' matches dangerous pattern '${pattern}'. The user has prevented you from doing this.`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** True when a tool-hook event targets the shell tool (v2 id may be "bash" or "shell"). */
|
||||||
|
export function isShellTool(tool: string): boolean {
|
||||||
|
return tool === "bash" || tool === "shell"
|
||||||
|
}
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import { existsSync, readFileSync } from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
import { Plugin, Skill } from "@opencode/plugin"
|
||||||
|
import { blockedPattern, guardrailError, isShellTool, resolveOptions } from "./guardrails.ts"
|
||||||
|
import { parseFrontmatter } from "./frontmatter.ts"
|
||||||
|
import { loadManifest, packageRoot, packageVersion, skillFile } from "./manifest.ts"
|
||||||
|
|
||||||
|
const AGENT_IDS = ["pocock", "pocock-worker", "pocock-reviewer"] as const
|
||||||
|
|
||||||
|
function installedAgentVersion(projectDir: string): string | undefined {
|
||||||
|
const file = path.join(projectDir, ".opencode", "agents", ".pocock-version")
|
||||||
|
if (!existsSync(file)) return undefined
|
||||||
|
return readFileSync(file, "utf8").trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Plugin.define({
|
||||||
|
id: "haylan.pocock",
|
||||||
|
async setup(ctx) {
|
||||||
|
// Fails loudly on bad options or a broken install instead of silently shipping no skills.
|
||||||
|
const options = resolveOptions(ctx.options)
|
||||||
|
const entries = loadManifest()
|
||||||
|
|
||||||
|
await ctx.skill.transform((editor) => {
|
||||||
|
for (const entry of entries) {
|
||||||
|
const file = skillFile(entry)
|
||||||
|
// File-based skill loading strips frontmatter from content (core skill.ts uses
|
||||||
|
// markdown.content); match that so injected skills read identically.
|
||||||
|
const content = parseFrontmatter(readFileSync(file, "utf8")).body.trim()
|
||||||
|
// Brand types (Skill.ID/Name/AbsolutePath) are nominal-only; runtime values are plain
|
||||||
|
// strings, asserted by test/plugin.test.ts and the serve-based smoke run.
|
||||||
|
editor.add({
|
||||||
|
id: entry.id,
|
||||||
|
name: entry.name,
|
||||||
|
description: entry.description,
|
||||||
|
autoinvoke: entry.autoinvoke,
|
||||||
|
path: file,
|
||||||
|
content,
|
||||||
|
} as unknown as Skill.Info)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (options.guardrails) {
|
||||||
|
await ctx.tool.hook("execute.before", (event) => {
|
||||||
|
if (!isShellTool(event.tool)) return
|
||||||
|
const command = (event.input as { command?: unknown } | undefined)?.command
|
||||||
|
if (typeof command !== "string") return
|
||||||
|
const pattern = blockedPattern(command)
|
||||||
|
if (pattern) throw new Error(`pocock guardrails: ${guardrailError(command, pattern)}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Agents cannot be registered by plugins in v2 (AgentEditor has no add), so guide the user
|
||||||
|
// to the one required copy step instead of failing or writing into their repo.
|
||||||
|
let warned = false
|
||||||
|
await ctx.agent.transform((editor) => {
|
||||||
|
if (warned) return
|
||||||
|
warned = true
|
||||||
|
const ids = new Set<string>(editor.list().map((agent) => String(agent.id)))
|
||||||
|
const have = installedAgentVersion(ctx.location.directory)
|
||||||
|
const want = packageVersion()
|
||||||
|
const initCmd = "npx @haylan/opencode-pocock init"
|
||||||
|
if (!AGENT_IDS.some((id) => ids.has(id))) {
|
||||||
|
console.warn(
|
||||||
|
`pocock: skills loaded, but the pocock agents are not installed — run: ${initCmd}`,
|
||||||
|
)
|
||||||
|
} else if (have !== want) {
|
||||||
|
console.warn(
|
||||||
|
`pocock: installed agents are ${have ? `from v${have}` : "unversioned"}, package is v${want} — refresh: ${initCmd}`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
export { packageRoot }
|
||||||
+79
@@ -0,0 +1,79 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// Copies the generated agent files into a discovered agents directory and stamps the version
|
||||||
|
// the plugin checks against. Never overwrites locally modified files without --force.
|
||||||
|
//
|
||||||
|
// opencode-pocock init [-g|--global] [--force]
|
||||||
|
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs"
|
||||||
|
import os from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import { packageRoot, packageVersion } from "./manifest.ts"
|
||||||
|
|
||||||
|
export type InitResult = { target: string; copied: string[]; skipped: string[] }
|
||||||
|
|
||||||
|
export function agentsTarget(global: boolean, cwd: string, home: string): string {
|
||||||
|
return global
|
||||||
|
? path.join(home, ".config", "opencode", "agents")
|
||||||
|
: path.join(cwd, ".opencode", "agents")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function runInit(opts: {
|
||||||
|
argv: string[]
|
||||||
|
cwd: string
|
||||||
|
home?: string
|
||||||
|
pkgRoot?: string
|
||||||
|
}): InitResult {
|
||||||
|
const args = new Set(opts.argv)
|
||||||
|
const global = args.has("-g") || args.has("--global")
|
||||||
|
const force = args.has("--force")
|
||||||
|
const unknown = opts.argv.filter((a) => !["-g", "--global", "--force", "init"].includes(a))
|
||||||
|
if (unknown.length)
|
||||||
|
throw new Error(`opencode-pocock: unknown argument ${unknown[0]} (try: init [-g] [--force])`)
|
||||||
|
|
||||||
|
const root = opts.pkgRoot ?? packageRoot
|
||||||
|
const sourceDir = path.join(root, "agents")
|
||||||
|
if (!existsSync(sourceDir)) throw new Error(`opencode-pocock: no agents/ in package at ${root}`)
|
||||||
|
const target = agentsTarget(global, opts.cwd, opts.home ?? os.homedir())
|
||||||
|
mkdirSync(target, { recursive: true })
|
||||||
|
|
||||||
|
const result: InitResult = { target, copied: [], skipped: [] }
|
||||||
|
for (const file of readdirSync(sourceDir)
|
||||||
|
.filter((f) => f.endsWith(".md"))
|
||||||
|
.sort()) {
|
||||||
|
const from = path.join(sourceDir, file)
|
||||||
|
const to = path.join(target, file)
|
||||||
|
const content = readFileSync(from, "utf8")
|
||||||
|
// A differing existing file is treated as user work: keep it unless forced.
|
||||||
|
if (existsSync(to) && readFileSync(to, "utf8") !== content && !force) {
|
||||||
|
result.skipped.push(file)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
writeFileSync(to, content)
|
||||||
|
result.copied.push(file)
|
||||||
|
}
|
||||||
|
writeFileSync(path.join(target, ".pocock-version"), packageVersion(root) + "\n")
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
const result = runInit({ argv: process.argv.slice(2), cwd: process.cwd() })
|
||||||
|
for (const file of result.copied) console.log(`installed ${path.join(result.target, file)}`)
|
||||||
|
for (const file of result.skipped) {
|
||||||
|
console.log(
|
||||||
|
`skipped ${file}: local copy differs from the package (re-run with --force to replace)`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
`\nNext: make sure opencode.json loads the plugin:\n { "plugins": ["@haylan/opencode-pocock"] }\n` +
|
||||||
|
`Then run /setup-matt-pocock-skills once in each project and start OpenCode with --agent pocock.`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process.argv[1] === fileURLToPath(import.meta.url)) {
|
||||||
|
try {
|
||||||
|
main()
|
||||||
|
} catch (err) {
|
||||||
|
console.error((err as Error).message)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { readFileSync } from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
|
||||||
|
export type ManifestEntry = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
description: string
|
||||||
|
autoinvoke: boolean
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Works from dist/ (compiled) and src/ (tests, type stripping): both are one level under the root.
|
||||||
|
export const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
|
||||||
|
export function loadManifest(rootDir: string = packageRoot): ManifestEntry[] {
|
||||||
|
const file = path.join(rootDir, "manifest.json")
|
||||||
|
let entries: ManifestEntry[]
|
||||||
|
try {
|
||||||
|
entries = JSON.parse(readFileSync(file, "utf8"))
|
||||||
|
} catch {
|
||||||
|
throw new Error(
|
||||||
|
`pocock: cannot read ${file} — the package install is broken; reinstall @haylan/opencode-pocock`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!Array.isArray(entries) || entries.some((e) => !e.id || !e.path)) {
|
||||||
|
throw new Error(`pocock: malformed manifest at ${file}`)
|
||||||
|
}
|
||||||
|
return entries
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Absolute SKILL.md location for a manifest entry; relative paths resolve against the package. */
|
||||||
|
export function skillFile(entry: ManifestEntry, rootDir: string = packageRoot): string {
|
||||||
|
return path.resolve(rootDir, entry.path)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function packageVersion(rootDir: string = packageRoot): string {
|
||||||
|
const pkg = JSON.parse(readFileSync(path.join(rootDir, "package.json"), "utf8"))
|
||||||
|
return pkg.version as string
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { existsSync, readFileSync, readdirSync } from "node:fs"
|
||||||
|
import path from "node:path"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import { parseFrontmatter } from "../src/frontmatter.ts"
|
||||||
|
import { loadClassification } from "../scripts/generate.ts"
|
||||||
|
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
const entries = loadClassification(path.join(root, ".opencode/state/classification.json"))
|
||||||
|
const vendored = entries.filter((e) => e.artifacts.includes("skill:verbatim"))
|
||||||
|
const agentFiles = readdirSync(path.join(root, "agents")).filter((f) => f.endsWith(".md"))
|
||||||
|
|
||||||
|
// V2-native frontmatter only (AGENTS.md convention); legacy v1 keys must never appear.
|
||||||
|
const V2_KEYS = new Set([
|
||||||
|
"name",
|
||||||
|
"description",
|
||||||
|
"mode",
|
||||||
|
"model",
|
||||||
|
"color",
|
||||||
|
"permissions",
|
||||||
|
"hidden",
|
||||||
|
"steps",
|
||||||
|
"disabled",
|
||||||
|
"request",
|
||||||
|
"system",
|
||||||
|
])
|
||||||
|
|
||||||
|
test("agent frontmatter uses V2-native keys only", () => {
|
||||||
|
for (const file of agentFiles) {
|
||||||
|
const { frontmatter } = parseFrontmatter(readFileSync(path.join(root, "agents", file), "utf8"))
|
||||||
|
for (const key of Object.keys(frontmatter)) {
|
||||||
|
assert.ok(V2_KEYS.has(key), `${file}: non-V2 frontmatter key '${key}'`)
|
||||||
|
}
|
||||||
|
assert.ok(frontmatter.mode, `${file}: mode required`)
|
||||||
|
assert.ok(frontmatter.description, `${file}: description required`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("every skill an agent names still exists in the upstream snapshot", () => {
|
||||||
|
const allNames = new Set(entries.map((e) => e.name))
|
||||||
|
for (const file of agentFiles) {
|
||||||
|
const body = readFileSync(path.join(root, "agents", file), "utf8")
|
||||||
|
const tokens = new Set(
|
||||||
|
[...body.matchAll(/`([a-z][a-z0-9-]*)`/g)].map((m) => m[1]).filter((t) => allNames.has(t)),
|
||||||
|
)
|
||||||
|
for (const name of tokens) {
|
||||||
|
const entry = entries.find((e) => e.name === name)!
|
||||||
|
const dir = path.join(root, "upstream/skills", entry.bucket, name)
|
||||||
|
assert.ok(
|
||||||
|
existsSync(path.join(dir, "SKILL.md")),
|
||||||
|
`${file} names skill '${name}' which no longer exists upstream (renamed or removed?)`,
|
||||||
|
)
|
||||||
|
assert.ok(
|
||||||
|
entry.artifacts.includes("skill:verbatim"),
|
||||||
|
`${file} names skill '${name}' which is excluded from this package`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("worker may only load model-invoked vendored skills", () => {
|
||||||
|
const worker = readFileSync(path.join(root, "agents/pocock-worker.md"), "utf8")
|
||||||
|
const allowed = [
|
||||||
|
...worker.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g),
|
||||||
|
].map((m) => m[1])
|
||||||
|
assert.ok(allowed.length >= 3, "worker skill allow-list parsed")
|
||||||
|
const userInvoked = new Set(entries.filter((e) => e.user_invoked).map((e) => e.name))
|
||||||
|
const vendoredNames = new Set(vendored.map((e) => e.name))
|
||||||
|
for (const name of allowed) {
|
||||||
|
assert.ok(!userInvoked.has(name), `worker allows user-invoked skill '${name}' (needs a person)`)
|
||||||
|
assert.ok(vendoredNames.has(name), `worker allows '${name}' which is not a vendored skill`)
|
||||||
|
}
|
||||||
|
for (const core of ["tdd", "codebase-design", "diagnosing-bugs"]) {
|
||||||
|
assert.ok(allowed.includes(core), `worker missing core skill '${core}'`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("reviewer is read-only: edit/subagent denied, only code-review allowed", () => {
|
||||||
|
const reviewer = readFileSync(path.join(root, "agents/pocock-reviewer.md"), "utf8")
|
||||||
|
assert.match(reviewer, /action:\s*edit,\s*resource:\s*"\*",\s*effect:\s*deny/)
|
||||||
|
assert.match(reviewer, /action:\s*subagent,\s*resource:\s*"\*",\s*effect:\s*deny/)
|
||||||
|
const allowedSkills = [
|
||||||
|
...reviewer.matchAll(/action:\s*skill,\s*resource:\s*"([^"]+)",\s*effect:\s*allow/g),
|
||||||
|
].map((m) => m[1])
|
||||||
|
assert.deepEqual(allowedSkills, ["code-review"])
|
||||||
|
})
|
||||||
|
|
||||||
|
test("worker and reviewer cannot spawn subagents (no circular delegation)", () => {
|
||||||
|
for (const file of ["pocock-worker.md", "pocock-reviewer.md"]) {
|
||||||
|
const body = readFileSync(path.join(root, "agents", file), "utf8")
|
||||||
|
assert.match(
|
||||||
|
body,
|
||||||
|
/action:\s*subagent,\s*resource:\s*"\*",\s*effect:\s*deny/,
|
||||||
|
`${file}: subagent deny`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("classification is fully reviewed and matches the generated tree", () => {
|
||||||
|
const needsReview = entries.filter((e) => e.status === "needs-review")
|
||||||
|
assert.deepEqual(
|
||||||
|
needsReview.map((e) => e.name),
|
||||||
|
[],
|
||||||
|
"needs-review classifications block the build until reviewed",
|
||||||
|
)
|
||||||
|
const manifest = JSON.parse(readFileSync(path.join(root, "manifest.json"), "utf8"))
|
||||||
|
assert.deepEqual(
|
||||||
|
manifest.map((m: { id: string }) => m.id).sort(),
|
||||||
|
vendored.map((e) => e.name).sort(),
|
||||||
|
)
|
||||||
|
for (const e of vendored) {
|
||||||
|
assert.ok(
|
||||||
|
existsSync(path.join(root, "skills", e.name, "SKILL.md")),
|
||||||
|
`skills/${e.name} generated`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
for (const e of entries.filter((x) => x.artifacts.includes("excluded"))) {
|
||||||
|
assert.ok(
|
||||||
|
!existsSync(path.join(root, "skills", e.name)),
|
||||||
|
`excluded skill ${e.name} must not ship`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,203 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import { fileURLToPath } from "node:url"
|
||||||
|
import {
|
||||||
|
buildSkills,
|
||||||
|
loadClassification,
|
||||||
|
renderMatrix,
|
||||||
|
updateDocMatrix,
|
||||||
|
type ClassificationEntry,
|
||||||
|
} from "../scripts/generate.ts"
|
||||||
|
import { isUserInvoked, parseFrontmatter } from "../src/frontmatter.ts"
|
||||||
|
|
||||||
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
||||||
|
|
||||||
|
test("parseFrontmatter: plain, quoted with escapes and colons, DMI, nested blocks skipped", () => {
|
||||||
|
const plain = parseFrontmatter(
|
||||||
|
"---\nname: tdd\ndescription: Test-driven development\n---\nBody\n",
|
||||||
|
)
|
||||||
|
assert.equal(plain.frontmatter.name, "tdd")
|
||||||
|
assert.equal(plain.frontmatter.description, "Test-driven development")
|
||||||
|
assert.equal(plain.body, "Body\n")
|
||||||
|
|
||||||
|
const quoted = parseFrontmatter(
|
||||||
|
'---\nname: code-review\ndescription: "Review since a fixed point: commit, branch, or \\"X\\"."\nmetadata:\n credits:\n author: Dex\n---\nx',
|
||||||
|
)
|
||||||
|
assert.equal(
|
||||||
|
quoted.frontmatter.description,
|
||||||
|
'Review since a fixed point: commit, branch, or "X".',
|
||||||
|
)
|
||||||
|
assert.equal(quoted.frontmatter.metadata, "") // nested block skipped, not misparsed
|
||||||
|
|
||||||
|
const dmi = parseFrontmatter("---\nname: to-spec\ndisable-model-invocation: true\n---\nx")
|
||||||
|
assert.equal(isUserInvoked(dmi.frontmatter), true)
|
||||||
|
assert.equal(isUserInvoked(plain.frontmatter), false)
|
||||||
|
|
||||||
|
const none = parseFrontmatter("no frontmatter here")
|
||||||
|
assert.deepEqual(none.frontmatter, {})
|
||||||
|
})
|
||||||
|
|
||||||
|
function fixtureSkill(
|
||||||
|
upstream: string,
|
||||||
|
bucket: string,
|
||||||
|
name: string,
|
||||||
|
opts: { dmi?: boolean } = {},
|
||||||
|
) {
|
||||||
|
const dir = path.join(upstream, bucket, name)
|
||||||
|
mkdirSync(path.join(dir, "agents"), { recursive: true })
|
||||||
|
writeFileSync(
|
||||||
|
path.join(dir, "SKILL.md"),
|
||||||
|
`---\nname: ${name}\ndescription: "The ${name} skill"\n` +
|
||||||
|
(opts.dmi ? "disable-model-invocation: true\n" : "") +
|
||||||
|
`---\n\nBody of ${name}.\n`,
|
||||||
|
)
|
||||||
|
writeFileSync(path.join(dir, "agents", "openai.yaml"), "interface:\n display_name: X\n")
|
||||||
|
writeFileSync(path.join(dir, "EXTRA.md"), "supporting file")
|
||||||
|
return dir
|
||||||
|
}
|
||||||
|
|
||||||
|
function entry(name: string, bucket: string, over: Partial<ClassificationEntry> = {}) {
|
||||||
|
return {
|
||||||
|
name,
|
||||||
|
bucket,
|
||||||
|
classification: "skill",
|
||||||
|
user_invoked: false,
|
||||||
|
artifacts: ["skill:verbatim"],
|
||||||
|
depends_on: [],
|
||||||
|
status: "analyzed",
|
||||||
|
rationale: "r",
|
||||||
|
...over,
|
||||||
|
} as ClassificationEntry
|
||||||
|
}
|
||||||
|
|
||||||
|
test("buildSkills copies verbatim minus agents/, builds manifest, honors exclusions", () => {
|
||||||
|
const dir = mkdtempSync(path.join(tmpdir(), "gen-test-"))
|
||||||
|
try {
|
||||||
|
const upstream = path.join(dir, "upstream")
|
||||||
|
fixtureSkill(upstream, "engineering", "tdd")
|
||||||
|
fixtureSkill(upstream, "engineering", "to-spec", { dmi: true })
|
||||||
|
fixtureSkill(upstream, "in-progress", "beta")
|
||||||
|
const out = path.join(dir, "skills")
|
||||||
|
const manifest = buildSkills({
|
||||||
|
upstreamSkills: upstream,
|
||||||
|
entries: [
|
||||||
|
entry("tdd", "engineering"),
|
||||||
|
entry("to-spec", "engineering"),
|
||||||
|
entry("beta", "in-progress", { artifacts: ["excluded"] }),
|
||||||
|
],
|
||||||
|
skillsOut: out,
|
||||||
|
})
|
||||||
|
assert.deepEqual(
|
||||||
|
manifest,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: "tdd",
|
||||||
|
name: "tdd",
|
||||||
|
description: "The tdd skill",
|
||||||
|
autoinvoke: true,
|
||||||
|
path: "skills/tdd/SKILL.md",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "to-spec",
|
||||||
|
name: "to-spec",
|
||||||
|
description: "The to-spec skill",
|
||||||
|
autoinvoke: false,
|
||||||
|
path: "skills/to-spec/SKILL.md",
|
||||||
|
},
|
||||||
|
].sort((a, b) => a.id.localeCompare(b.id)),
|
||||||
|
)
|
||||||
|
assert.ok(existsSync(path.join(out, "tdd/SKILL.md")))
|
||||||
|
assert.ok(existsSync(path.join(out, "tdd/EXTRA.md")), "supporting files preserved")
|
||||||
|
assert.ok(!existsSync(path.join(out, "tdd/agents")), "agents/openai.yaml stripped")
|
||||||
|
assert.ok(!existsSync(path.join(out, "beta")), "excluded skill not copied")
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("buildSkills throws on unclassified upstream skills and missing classified ones", () => {
|
||||||
|
const dir = mkdtempSync(path.join(tmpdir(), "gen-test-"))
|
||||||
|
try {
|
||||||
|
const upstream = path.join(dir, "upstream")
|
||||||
|
fixtureSkill(upstream, "engineering", "mystery")
|
||||||
|
assert.throws(
|
||||||
|
() =>
|
||||||
|
buildSkills({ upstreamSkills: upstream, entries: [], skillsOut: path.join(dir, "out") }),
|
||||||
|
/unclassified upstream skill: engineering\/mystery/,
|
||||||
|
)
|
||||||
|
assert.throws(
|
||||||
|
() =>
|
||||||
|
buildSkills({
|
||||||
|
upstreamSkills: upstream,
|
||||||
|
entries: [entry("ghost", "engineering")],
|
||||||
|
skillsOut: path.join(dir, "out"),
|
||||||
|
}),
|
||||||
|
/classified skill missing upstream: engineering\/ghost/,
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("updateDocMatrix replaces only the marked section", () => {
|
||||||
|
const dir = mkdtempSync(path.join(tmpdir(), "gen-test-"))
|
||||||
|
try {
|
||||||
|
const doc = path.join(dir, "doc.md")
|
||||||
|
writeFileSync(doc, "prose\n<!-- matrix:start -->\nold\n<!-- matrix:end -->\nmore prose\n")
|
||||||
|
updateDocMatrix(doc, "NEW TABLE")
|
||||||
|
assert.equal(
|
||||||
|
readFileSync(doc, "utf8"),
|
||||||
|
"prose\n<!-- matrix:start -->\n\nNEW TABLE\n\n<!-- matrix:end -->\nmore prose\n",
|
||||||
|
)
|
||||||
|
assert.throws(() => updateDocMatrix(doc.replace("doc", "x"), "t"), /ENOENT/)
|
||||||
|
writeFileSync(path.join(dir, "bad.md"), "no markers")
|
||||||
|
assert.throws(() => updateDocMatrix(path.join(dir, "bad.md"), "t"), /missing matrix markers/)
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("renderMatrix: one row per entry with escaped cells", () => {
|
||||||
|
const md = renderMatrix([
|
||||||
|
entry("tdd", "engineering", { depends_on: ["codebase-design"], rationale: "a | b" }),
|
||||||
|
])
|
||||||
|
const [header, sep, row] = md.split("\n")
|
||||||
|
assert.match(header, /^\| Upstream skill \| Bucket \| DMI \|/)
|
||||||
|
assert.match(sep, /^\| --- \|/)
|
||||||
|
assert.equal(
|
||||||
|
row,
|
||||||
|
"| tdd | eng | | skill | skill:verbatim | codebase-design | analyzed | a \\| b |",
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Regression against the real vendored snapshot: every classified-verbatim skill must parse,
|
||||||
|
// and upstream disable-model-invocation must agree with classification.json user_invoked.
|
||||||
|
test("real snapshot: all vendored skills parse and DMI flags match classification", () => {
|
||||||
|
const entries = loadClassification(path.join(root, ".opencode/state/classification.json"))
|
||||||
|
const manifest = JSON.parse(readFileSync(path.join(root, "manifest.json"), "utf8"))
|
||||||
|
const vendored = entries.filter((e) => e.artifacts.includes("skill:verbatim"))
|
||||||
|
assert.equal(vendored.length, manifest.length)
|
||||||
|
assert.equal(entries.filter((e) => e.status === "needs-review").length, 0)
|
||||||
|
|
||||||
|
for (const e of vendored) {
|
||||||
|
const md = readFileSync(path.join(root, "skills", e.name, "SKILL.md"), "utf8")
|
||||||
|
const { frontmatter } = parseFrontmatter(md)
|
||||||
|
assert.ok(frontmatter.name, `${e.name}: name parsed`)
|
||||||
|
assert.ok(frontmatter.description, `${e.name}: description parsed`)
|
||||||
|
assert.equal(
|
||||||
|
isUserInvoked(frontmatter),
|
||||||
|
e.user_invoked,
|
||||||
|
`${e.name}: DMI flag disagrees with classification.json`,
|
||||||
|
)
|
||||||
|
const m = manifest.find((x: { id: string }) => x.id === e.name)
|
||||||
|
assert.equal(m.autoinvoke, !e.user_invoked, `${e.name}: manifest autoinvoke`)
|
||||||
|
assert.ok(
|
||||||
|
!existsSync(path.join(root, "skills", e.name, "agents")),
|
||||||
|
`${e.name}: openai.yaml stripped`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
assert.equal(manifest.filter((m: { autoinvoke: boolean }) => !m.autoinvoke).length, 16)
|
||||||
|
})
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import { agentsTarget, runInit } from "../src/init.ts"
|
||||||
|
|
||||||
|
function fixturePkg() {
|
||||||
|
const pkgRoot = mkdtempSync(path.join(tmpdir(), "init-pkg-"))
|
||||||
|
mkdirSync(path.join(pkgRoot, "agents"))
|
||||||
|
writeFileSync(path.join(pkgRoot, "package.json"), JSON.stringify({ version: "9.9.9" }))
|
||||||
|
writeFileSync(path.join(pkgRoot, "agents", "pocock.md"), "---\nmode: primary\n---\nv1\n")
|
||||||
|
writeFileSync(path.join(pkgRoot, "agents", "pocock-worker.md"), "---\nmode: subagent\n---\nv1\n")
|
||||||
|
return pkgRoot
|
||||||
|
}
|
||||||
|
|
||||||
|
test("runInit copies agents, stamps version, targets project or global dir", () => {
|
||||||
|
const pkgRoot = fixturePkg()
|
||||||
|
const home = mkdtempSync(path.join(tmpdir(), "init-home-"))
|
||||||
|
const cwd = mkdtempSync(path.join(tmpdir(), "init-cwd-"))
|
||||||
|
try {
|
||||||
|
const project = runInit({ argv: ["init"], cwd, pkgRoot, home })
|
||||||
|
assert.equal(project.target, path.join(cwd, ".opencode", "agents"))
|
||||||
|
assert.deepEqual(project.copied, ["pocock-worker.md", "pocock.md"])
|
||||||
|
assert.deepEqual(project.skipped, [])
|
||||||
|
assert.equal(
|
||||||
|
readFileSync(path.join(project.target, "pocock.md"), "utf8"),
|
||||||
|
"---\nmode: primary\n---\nv1\n",
|
||||||
|
)
|
||||||
|
assert.equal(readFileSync(path.join(project.target, ".pocock-version"), "utf8"), "9.9.9\n")
|
||||||
|
|
||||||
|
const global = runInit({ argv: ["init", "-g"], cwd, pkgRoot, home })
|
||||||
|
assert.equal(global.target, path.join(home, ".config", "opencode", "agents"))
|
||||||
|
assert.ok(existsSync(path.join(global.target, "pocock.md")))
|
||||||
|
|
||||||
|
// identical files are refreshed silently; locally modified files are kept without --force
|
||||||
|
writeFileSync(path.join(project.target, "pocock.md"), "---\nmode: primary\n---\nUSER EDIT\n")
|
||||||
|
const again = runInit({ argv: ["init"], cwd, pkgRoot, home })
|
||||||
|
assert.deepEqual(again.skipped, ["pocock.md"])
|
||||||
|
assert.deepEqual(again.copied, ["pocock-worker.md"])
|
||||||
|
assert.match(readFileSync(path.join(project.target, "pocock.md"), "utf8"), /USER EDIT/)
|
||||||
|
|
||||||
|
const forced = runInit({ argv: ["init", "--force"], cwd, pkgRoot, home })
|
||||||
|
assert.deepEqual(forced.skipped, [])
|
||||||
|
assert.match(readFileSync(path.join(project.target, "pocock.md"), "utf8"), /v1/)
|
||||||
|
|
||||||
|
assert.throws(
|
||||||
|
() => runInit({ argv: ["init", "--wat"], cwd, pkgRoot, home }),
|
||||||
|
/unknown argument --wat/,
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
for (const dir of [pkgRoot, home, cwd]) rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("agentsTarget resolves global vs project locations", () => {
|
||||||
|
assert.equal(agentsTarget(false, "/repo", "/home/u"), path.join("/repo", ".opencode", "agents"))
|
||||||
|
assert.equal(
|
||||||
|
agentsTarget(true, "/repo", "/home/u"),
|
||||||
|
path.join("/home/u", ".config", "opencode", "agents"),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("runInit fails clearly when the package has no agents dir", () => {
|
||||||
|
const empty = mkdtempSync(path.join(tmpdir(), "init-empty-"))
|
||||||
|
try {
|
||||||
|
writeFileSync(path.join(empty, "package.json"), "{}")
|
||||||
|
assert.throws(
|
||||||
|
() => runInit({ argv: ["init"], cwd: empty, pkgRoot: empty, home: empty }),
|
||||||
|
/no agents\/ in package/,
|
||||||
|
)
|
||||||
|
} finally {
|
||||||
|
rmSync(empty, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { existsSync, mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import plugin from "../src/index.ts"
|
||||||
|
import { loadManifest } from "../src/manifest.ts"
|
||||||
|
import { blockedPattern, resolveOptions } from "../src/guardrails.ts"
|
||||||
|
|
||||||
|
const manifest = loadManifest()
|
||||||
|
|
||||||
|
function fakeCtx(
|
||||||
|
options: Record<string, unknown>,
|
||||||
|
opts: { agents?: { id: string }[]; dir?: string } = {},
|
||||||
|
) {
|
||||||
|
const added: Record<string, unknown>[] = []
|
||||||
|
const hooks: { name: string; fn: (event: unknown) => void }[] = []
|
||||||
|
const warns: string[] = []
|
||||||
|
const agentEditor = {
|
||||||
|
list: () => opts.agents ?? [],
|
||||||
|
get: () => undefined,
|
||||||
|
default: () => {},
|
||||||
|
update: () => {},
|
||||||
|
remove: () => {},
|
||||||
|
}
|
||||||
|
const ctx = {
|
||||||
|
options,
|
||||||
|
location: { directory: opts.dir ?? tmpdir() },
|
||||||
|
skill: {
|
||||||
|
transform: async (fn: (e: { add: (s: unknown) => void }) => void) =>
|
||||||
|
fn({ add: (s) => added.push(s) }),
|
||||||
|
},
|
||||||
|
tool: { hook: async (name: string, fn: (event: unknown) => void) => hooks.push({ name, fn }) },
|
||||||
|
agent: { transform: async (fn: (e: typeof agentEditor) => void) => fn(agentEditor) },
|
||||||
|
}
|
||||||
|
const realWarn = console.warn
|
||||||
|
console.warn = (msg: string) => warns.push(msg)
|
||||||
|
return {
|
||||||
|
ctx: ctx as never,
|
||||||
|
added,
|
||||||
|
hooks,
|
||||||
|
warns,
|
||||||
|
restore: () => (console.warn = realWarn),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test("plugin id", () => {
|
||||||
|
assert.equal(plugin.id, "haylan.pocock")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("setup injects every manifest skill with absolute existing paths and autoinvoke flags", async () => {
|
||||||
|
const f = fakeCtx({})
|
||||||
|
try {
|
||||||
|
await plugin.setup(f.ctx)
|
||||||
|
assert.equal(f.added.length, manifest.length)
|
||||||
|
const ids = f.added.map((s) => s.id)
|
||||||
|
assert.equal(new Set(ids).size, ids.length, "unique ids")
|
||||||
|
const hidden = f.added.filter((s) => s.autoinvoke === false)
|
||||||
|
assert.equal(hidden.length, 16, "user-invoked skills hidden from model")
|
||||||
|
for (const skill of f.added) {
|
||||||
|
assert.ok(path.isAbsolute(skill.path as string), `${skill.id}: absolute path`)
|
||||||
|
assert.ok(existsSync(skill.path as string), `${skill.id}: file exists`)
|
||||||
|
assert.ok((skill.content as string).length > 0, `${skill.id}: content loaded`)
|
||||||
|
assert.ok(!(skill.content as string).startsWith("---"), `${skill.id}: frontmatter stripped`)
|
||||||
|
const entry = manifest.find((m) => m.id === skill.id)!
|
||||||
|
assert.equal(skill.description, entry.description)
|
||||||
|
}
|
||||||
|
const toSpec = f.added.find((s) => s.id === "to-spec")!
|
||||||
|
assert.equal(toSpec.autoinvoke, false)
|
||||||
|
const tdd = f.added.find((s) => s.id === "tdd")!
|
||||||
|
assert.equal(tdd.autoinvoke, true)
|
||||||
|
} finally {
|
||||||
|
f.restore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("setup throws on bad options and registers nothing", async () => {
|
||||||
|
const f = fakeCtx({ guardrails: "yes" })
|
||||||
|
try {
|
||||||
|
await assert.rejects(Promise.resolve(plugin.setup(f.ctx)), /guardrails must be a boolean/)
|
||||||
|
assert.equal(f.added.length + f.hooks.length, 0)
|
||||||
|
} finally {
|
||||||
|
f.restore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("guardrails off by default; on: hook blocks dangerous git and only on shell tools", async () => {
|
||||||
|
const off = fakeCtx({})
|
||||||
|
try {
|
||||||
|
await plugin.setup(off.ctx)
|
||||||
|
assert.equal(off.hooks.length, 0)
|
||||||
|
} finally {
|
||||||
|
off.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
const on = fakeCtx({ guardrails: true })
|
||||||
|
try {
|
||||||
|
await plugin.setup(on.ctx)
|
||||||
|
assert.equal(on.hooks.length, 1)
|
||||||
|
assert.equal(on.hooks[0].name, "execute.before")
|
||||||
|
const fire = (tool: string, command: string) => on.hooks[0].fn({ tool, input: { command } })
|
||||||
|
assert.throws(() => fire("bash", "git push --force origin main"), /BLOCKED/)
|
||||||
|
assert.throws(() => fire("shell", "git reset --hard HEAD~1"), /BLOCKED/)
|
||||||
|
assert.throws(() => fire("bash", "git clean -fd"), /BLOCKED/)
|
||||||
|
fire("bash", "git status --short")
|
||||||
|
fire("bash", "npm test")
|
||||||
|
fire("read", "git push") // non-shell tool untouched
|
||||||
|
fire("bash", "") // no command edge
|
||||||
|
on.hooks[0].fn({ tool: "bash", input: undefined })
|
||||||
|
} finally {
|
||||||
|
on.restore()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("agent staleness warning: missing, stale and up-to-date installs", async () => {
|
||||||
|
const dir = mkdtempSync(path.join(tmpdir(), "plugin-test-"))
|
||||||
|
try {
|
||||||
|
// missing agents
|
||||||
|
const missing = fakeCtx({}, { agents: [{ id: "build" }], dir })
|
||||||
|
try {
|
||||||
|
await plugin.setup(missing.ctx)
|
||||||
|
assert.equal(missing.warns.length, 1)
|
||||||
|
assert.match(missing.warns[0], /not installed — run: npx @haylan\/opencode-pocock init/)
|
||||||
|
} finally {
|
||||||
|
missing.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
// installed + matching version stamp -> silent
|
||||||
|
mkdirSync(path.join(dir, ".opencode", "agents"), { recursive: true })
|
||||||
|
const pkg = JSON.parse(readFileSync(path.join(process.cwd(), "package.json"), "utf8"))
|
||||||
|
writeFileSync(path.join(dir, ".opencode", "agents", ".pocock-version"), pkg.version + "\n")
|
||||||
|
const ok = fakeCtx({}, { agents: [{ id: "pocock" }, { id: "pocock-worker" }], dir })
|
||||||
|
try {
|
||||||
|
await plugin.setup(ok.ctx)
|
||||||
|
assert.deepEqual(ok.warns, [])
|
||||||
|
} finally {
|
||||||
|
ok.restore()
|
||||||
|
}
|
||||||
|
|
||||||
|
// installed + version mismatch -> refresh hint
|
||||||
|
writeFileSync(path.join(dir, ".opencode", "agents", ".pocock-version"), "0.0.1\n")
|
||||||
|
const stale = fakeCtx({}, { agents: [{ id: "pocock-reviewer" }], dir })
|
||||||
|
try {
|
||||||
|
await plugin.setup(stale.ctx)
|
||||||
|
assert.equal(stale.warns.length, 1)
|
||||||
|
assert.match(stale.warns[0], /refresh: npx @haylan\/opencode-pocock init/)
|
||||||
|
} finally {
|
||||||
|
stale.restore()
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("options and pattern helpers", () => {
|
||||||
|
assert.deepEqual(resolveOptions(undefined), { guardrails: false })
|
||||||
|
assert.deepEqual(resolveOptions({ guardrails: true }), { guardrails: true })
|
||||||
|
assert.equal(blockedPattern("git branch -D feature"), "git branch -D")
|
||||||
|
assert.equal(blockedPattern("git checkout ."), "git checkout .")
|
||||||
|
// grep -E substring semantics, faithful to upstream: "git pushy" contains "git push"
|
||||||
|
assert.equal(blockedPattern("echo git pushy"), "git push")
|
||||||
|
assert.equal(blockedPattern("git status && npm test"), undefined)
|
||||||
|
})
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import {
|
||||||
|
encodeName,
|
||||||
|
ensureLinked,
|
||||||
|
ensureTag,
|
||||||
|
isPublished,
|
||||||
|
publishBody,
|
||||||
|
} from "../scripts/release.ts"
|
||||||
|
import { buildEntry, bumpMinor, insertEntry, latestVersion } from "../scripts/version.ts"
|
||||||
|
|
||||||
|
const CHANGELOG = `# Changelog
|
||||||
|
|
||||||
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.4.0] - 2026-09-01
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Upstream sync: mattpocock/skills \`aaaaaaaaa\` -> \`bbbbbbbbb\`.
|
||||||
|
|
||||||
|
## [0.1.0] - 2026-08-01
|
||||||
|
`
|
||||||
|
|
||||||
|
test("latestVersion finds the first release heading", () => {
|
||||||
|
assert.equal(latestVersion(CHANGELOG), "1.4.0")
|
||||||
|
assert.throws(() => latestVersion("# empty\n"), /no release heading/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("bumpMinor: minor bump, prerelease untouched", () => {
|
||||||
|
assert.equal(bumpMinor("1.4.0"), "1.5.0")
|
||||||
|
assert.equal(bumpMinor("0.1.0"), "0.2.0")
|
||||||
|
assert.equal(bumpMinor("1.5.0-rc.1"), "1.5.0-rc.1")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("buildEntry: minor bump + upstream diff lines; null when commit already released", () => {
|
||||||
|
const entry = buildEntry({
|
||||||
|
changelog: CHANGELOG,
|
||||||
|
fromCommit: "bbbbbbbbb123",
|
||||||
|
toCommit: "ccccccccc456",
|
||||||
|
toVersion: "1.4.0",
|
||||||
|
date: "2026-10-15",
|
||||||
|
diff: { added: ["engineering/new"], removed: [], changed: ["engineering/tdd"] },
|
||||||
|
})
|
||||||
|
assert.equal(entry?.version, "1.5.0")
|
||||||
|
assert.match(entry!.body, /^## \[1\.5\.0\] - 2026-10-15/)
|
||||||
|
assert.match(entry!.body, /`bbbbbbbbb` -> `ccccccccc`/)
|
||||||
|
assert.match(entry!.body, /added: engineering\/new/)
|
||||||
|
assert.match(entry!.body, /changed: engineering\/tdd/)
|
||||||
|
|
||||||
|
const again = buildEntry({
|
||||||
|
changelog: CHANGELOG + entry!.body,
|
||||||
|
fromCommit: "b",
|
||||||
|
toCommit: "ccccccccc456",
|
||||||
|
toVersion: "1.4.0",
|
||||||
|
date: "2026-10-15",
|
||||||
|
diff: { added: [], removed: [], changed: [] },
|
||||||
|
})
|
||||||
|
assert.equal(again, null, "idempotent for an already-released upstream commit")
|
||||||
|
})
|
||||||
|
|
||||||
|
test("insertEntry places the new version under Unreleased", () => {
|
||||||
|
const entry = { version: "1.5.0", date: "2026-10-15", body: "## [1.5.0] - 2026-10-15" }
|
||||||
|
const out = insertEntry(CHANGELOG, entry)
|
||||||
|
assert.match(out, /## \[Unreleased\]\n\n## \[1\.5\.0\] - 2026-10-15\n\n## \[1\.4\.0\]/)
|
||||||
|
assert.throws(() => insertEntry("# nothing\n", entry), /no `## \[Unreleased\]` heading/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("publish helpers: name encoding, published check, body hashes", () => {
|
||||||
|
assert.equal(encodeName("@haylan/opencode-pocock"), "@haylan%2Fopencode-pocock")
|
||||||
|
assert.equal(isPublished({ versions: { "1.0.0": {} } }, "1.0.0"), true)
|
||||||
|
assert.equal(isPublished({ versions: {} }, "1.0.0"), false)
|
||||||
|
assert.equal(isPublished({}, "1.0.0"), false)
|
||||||
|
|
||||||
|
const body = publishBody(
|
||||||
|
{ name: "@haylan/opencode-pocock", version: "1.0.0" },
|
||||||
|
Buffer.from("tar"),
|
||||||
|
) as {
|
||||||
|
"dist-tags": Record<string, string>
|
||||||
|
versions: Record<string, { dist: { shasum: string; integrity: string } }>
|
||||||
|
_attachments: Record<string, { data: string; length: number }>
|
||||||
|
}
|
||||||
|
assert.equal(body["dist-tags"].latest, "1.0.0")
|
||||||
|
assert.equal(body.versions["1.0.0"].dist.shasum.length, 40)
|
||||||
|
assert.match(body.versions["1.0.0"].dist.integrity, /^sha512-/)
|
||||||
|
const att = body._attachments["@haylan/opencode-pocock-1.0.0.tgz"]
|
||||||
|
assert.equal(att.data, Buffer.from("tar").toString("base64"))
|
||||||
|
assert.equal(att.length, 3)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("ensureTag: creates on 404, no-ops when it exists, fails loudly otherwise", async () => {
|
||||||
|
const base = "https://gitea.test/api/v1"
|
||||||
|
const creating = {
|
||||||
|
base,
|
||||||
|
headers: {},
|
||||||
|
fetchFn: (async (_url: string | URL | Request, init?: RequestInit) => {
|
||||||
|
if ((init?.method ?? "GET") === "GET") return new Response(null, { status: 404 })
|
||||||
|
return new Response(null, { status: 201 })
|
||||||
|
}) as typeof fetch,
|
||||||
|
}
|
||||||
|
assert.equal(await ensureTag(creating, "o/r", "1.0.0", "sha123"), "created")
|
||||||
|
|
||||||
|
const exists = {
|
||||||
|
base,
|
||||||
|
headers: {},
|
||||||
|
fetchFn: (async () => new Response(null, { status: 200 })) as typeof fetch,
|
||||||
|
}
|
||||||
|
assert.equal(await ensureTag(exists, "o/r", "1.0.0", "sha123"), "exists")
|
||||||
|
|
||||||
|
const broken = {
|
||||||
|
base,
|
||||||
|
headers: {},
|
||||||
|
fetchFn: (async () => new Response("boom", { status: 500 })) as typeof fetch,
|
||||||
|
}
|
||||||
|
await assert.rejects(() => ensureTag(broken, "o/r", "1.0.0", "sha123"), /tag lookup failed: 500/)
|
||||||
|
})
|
||||||
|
|
||||||
|
test("ensureLinked: links once, then reports already linked", async () => {
|
||||||
|
let linked = false
|
||||||
|
const fetchFn = (async (url: string | URL | Request, init?: RequestInit) => {
|
||||||
|
const method = init?.method ?? "GET"
|
||||||
|
if (method === "GET") {
|
||||||
|
return Response.json(linked ? { repository: { id: 1 } } : {}, { status: 200 })
|
||||||
|
}
|
||||||
|
linked = true
|
||||||
|
return new Response(null, { status: 204 })
|
||||||
|
}) as typeof fetch
|
||||||
|
const api = { base: "https://gitea.test/api/v1", headers: {}, fetchFn }
|
||||||
|
assert.equal(await ensureLinked(api, "haylan", "@haylan/opencode-pocock", "0.2.0", "r"), "linked")
|
||||||
|
assert.equal(
|
||||||
|
await ensureLinked(api, "haylan", "@haylan/opencode-pocock", "0.2.0", "r"),
|
||||||
|
"already linked",
|
||||||
|
)
|
||||||
|
})
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import assert from "node:assert/strict"
|
||||||
|
import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs"
|
||||||
|
import { tmpdir } from "node:os"
|
||||||
|
import path from "node:path"
|
||||||
|
import { test } from "node:test"
|
||||||
|
import { diffSnapshots, hashDir, listSkillDirs, recordNewSkills } from "../scripts/sync-upstream.ts"
|
||||||
|
|
||||||
|
function fixture() {
|
||||||
|
const dir = mkdtempSync(path.join(tmpdir(), "sync-test-"))
|
||||||
|
const skill = (root: string, bucket: string, name: string, body: string, extra?: string) => {
|
||||||
|
mkdirSync(path.join(root, bucket, name), { recursive: true })
|
||||||
|
writeFileSync(path.join(root, bucket, name, "SKILL.md"), body)
|
||||||
|
if (extra) writeFileSync(path.join(root, bucket, name, "EXTRA.md"), extra)
|
||||||
|
}
|
||||||
|
return { dir, skill }
|
||||||
|
}
|
||||||
|
|
||||||
|
test("listSkillDirs finds only dirs containing SKILL.md", () => {
|
||||||
|
const { dir, skill } = fixture()
|
||||||
|
try {
|
||||||
|
skill(dir, "engineering", "tdd", "---\nname: tdd\n---\n")
|
||||||
|
skill(dir, "misc", "wizard", "---\nname: wizard\n---\n")
|
||||||
|
mkdirSync(path.join(dir, "deprecated"), { recursive: true })
|
||||||
|
writeFileSync(path.join(dir, "deprecated", "README.md"), "empty bucket")
|
||||||
|
mkdirSync(path.join(dir, "engineering", "not-a-skill"), { recursive: true })
|
||||||
|
assert.deepEqual(listSkillDirs(dir), ["engineering/tdd", "misc/wizard"])
|
||||||
|
assert.deepEqual(listSkillDirs(path.join(dir, "missing")), [])
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("diffSnapshots reports added, removed and changed skill dirs", () => {
|
||||||
|
const { dir, skill } = fixture()
|
||||||
|
const before = path.join(dir, "before")
|
||||||
|
const after = path.join(dir, "after")
|
||||||
|
try {
|
||||||
|
skill(before, "engineering", "tdd", "v1")
|
||||||
|
skill(before, "engineering", "gone", "v1")
|
||||||
|
skill(after, "engineering", "tdd", "v2")
|
||||||
|
skill(after, "productivity", "fresh", "v1")
|
||||||
|
assert.deepEqual(diffSnapshots(before, after), {
|
||||||
|
added: ["productivity/fresh"],
|
||||||
|
removed: ["engineering/gone"],
|
||||||
|
changed: ["engineering/tdd"],
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("hashDir ignores file mtime and is order-independent", () => {
|
||||||
|
const { dir, skill } = fixture()
|
||||||
|
const a = path.join(dir, "a")
|
||||||
|
const b = path.join(dir, "b")
|
||||||
|
try {
|
||||||
|
skill(a, "x", "s", "same", "extra")
|
||||||
|
skill(b, "x", "s", "same", "extra")
|
||||||
|
assert.equal(hashDir(path.join(a, "x", "s")), hashDir(path.join(b, "x", "s")))
|
||||||
|
writeFileSync(path.join(b, "x", "s", "EXTRA.md"), "different")
|
||||||
|
assert.notEqual(hashDir(path.join(a, "x", "s")), hashDir(path.join(b, "x", "s")))
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
test("recordNewSkills appends needs-review entries once and leaves known skills alone", () => {
|
||||||
|
const { dir } = fixture()
|
||||||
|
const file = path.join(dir, "classification.json")
|
||||||
|
try {
|
||||||
|
writeFileSync(
|
||||||
|
file,
|
||||||
|
JSON.stringify({ skills: [{ name: "tdd", bucket: "engineering", status: "analyzed" }] }),
|
||||||
|
)
|
||||||
|
const fresh = recordNewSkills(file, ["engineering/tdd", "misc/newcomer"])
|
||||||
|
assert.deepEqual(fresh, ["newcomer"])
|
||||||
|
const doc = JSON.parse(readFileSync(file, "utf8"))
|
||||||
|
assert.equal(doc.skills.length, 2)
|
||||||
|
assert.equal(doc.skills[1].status, "needs-review")
|
||||||
|
assert.equal(doc.skills[1].classification, "skill")
|
||||||
|
// idempotent: second run adds nothing
|
||||||
|
assert.deepEqual(recordNewSkills(file, ["misc/newcomer"]), [])
|
||||||
|
} finally {
|
||||||
|
rmSync(dir, { recursive: true, force: true })
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"strict": true,
|
||||||
|
"declaration": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": "src",
|
||||||
|
"types": ["node"],
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"rewriteRelativeImportExtensions": true
|
||||||
|
},
|
||||||
|
"include": ["src"]
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"repo": "https://github.com/mattpocock/skills",
|
||||||
|
"commit": "49dd158d1076134a641b33efb035946536778336",
|
||||||
|
"commit_date": "2026-10-09T11:56:49+01:00",
|
||||||
|
"upstream_version": "1.3.1"
|
||||||
|
}
|
||||||
Loaded 100 of 208 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user