From b578c3e32e5dc5e097c14fa0e547170186b3b01f Mon Sep 17 00:00:00 2001 From: deathpie <10750179+deathpie@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:29:01 -0500 Subject: [PATCH] chore: conform to repository standard Add the MIT license, the required check workflow, Dependabot config with grouped updates, a native auto-merge workflow for Dependabot minor and patch updates, an agent-files validator, and exception rows for the recipes that a docs-only repository cannot run. --- .github/dependabot.yml | 29 +++++ .github/workflows/checks.yml | 38 ++++++ .github/workflows/dependabot-automerge.yml | 84 +++++++++++++ AGENTS.md | 11 +- LICENSE | 21 ++++ docs/exceptions.md | 10 ++ justfile | 11 +- mise.toml | 3 + scripts/agent-files.ts | 140 +++++++++++++++++++++ 9 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/checks.yml create mode 100644 .github/workflows/dependabot-automerge.yml create mode 100644 LICENSE create mode 100644 docs/exceptions.md create mode 100644 scripts/agent-files.ts diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..922eb17 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,29 @@ +# Dependabot keeps the pinned workflow actions current. Updates are grouped and +# weekly to limit noise. Minor and patch updates merge automatically once every +# check passes; major updates get their own pull request and wait for review +# (see .github/workflows/dependabot-automerge.yml). +version: 2 + +updates: + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + day: monday + time: "06:00" + timezone: Etc/UTC + cooldown: + default-days: 14 + semver-patch-days: 3 + semver-minor-days: 7 + semver-major-days: 14 + groups: + github-actions: + patterns: ["*"] + update-types: ["minor", "patch"] + github-actions-major: + patterns: ["*"] + update-types: ["major"] + labels: ["dependencies"] + commit-message: + prefix: "chore(actions)" diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..d2f222a --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,38 @@ +name: check + +# One job, named `check`, so the ruleset can require one context. The job runs +# `just check`, which is the same gate a local run uses. The full suite runs on +# every push to main and weekly, so a pull request cannot hide a slow failure. +on: + push: + branches: [main] + pull_request: + schedule: + - cron: "0 6 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: check-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + check: + name: check + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install pinned tools from mise.toml + uses: jdx/mise-action@9b200bcecbfd6303e69a4a261b2e09e3757440a7 # v5.2.0 + with: + cache: true + + - name: Run the repository gate + run: just check diff --git a/.github/workflows/dependabot-automerge.yml b/.github/workflows/dependabot-automerge.yml new file mode 100644 index 0000000..a37bfb1 --- /dev/null +++ b/.github/workflows/dependabot-automerge.yml @@ -0,0 +1,84 @@ +name: Dependabot automerge + +# Public repositories on this account allow native auto-merge, so this workflow +# only classifies a Dependabot pull request and arms it. GitHub merges it once +# every required check on the head commit passes. +# +# Minor and patch updates get the `automerge` label and native auto-merge. +# Major updates get `major-update` and one review comment, and are never merged +# unattended. Nothing here checks out or runs pull request code, which is why +# `pull_request_target` is safe here: the only action reads Dependabot metadata. +on: + pull_request_target: # zizmor: ignore[dangerous-triggers] + types: [opened, reopened, synchronize, ready_for_review] + +permissions: + contents: write + pull-requests: write + issues: write + +concurrency: + group: dependabot-automerge-${{ github.event.pull_request.number }} + cancel-in-progress: false + +jobs: + arm: + name: Arm native auto-merge + if: github.event.pull_request.user.login == 'dependabot[bot]' + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Fetch Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@25dd0e34f4fe68f24cc83900b1fe3fe149efef98 # v3.1.0 + with: + github-token: ${{ github.token }} + + - name: Hold majors and arm minor or patch updates + shell: bash + env: + GH_TOKEN: ${{ github.token }} + REPO: ${{ github.repository }} + PR: ${{ github.event.pull_request.number }} + UPDATE_TYPE: ${{ steps.metadata.outputs.update-type }} + UPDATED_DEPENDENCIES: ${{ steps.metadata.outputs.updated-dependencies-json }} + run: | + set -euo pipefail + say() { printf '%s\n' "$*"; } + + # fetch-metadata's update-type is already the highest semver level in + # the pull request. Re-check every dependency so a group that contains + # any major update is still held if that roll-up ever changes. + major=$(jq -r \ + '[.[] | select(.updateType == "version-update:semver-major")] | length' \ + <<<"$UPDATED_DEPENDENCIES") + + gh label create major-update -R "$REPO" \ + --description "Dependabot major update; owner review required" \ + --color B60205 --force >/dev/null + + if [[ "$UPDATE_TYPE" == "version-update:semver-major" || "$major" -gt 0 ]]; then + gh api -X POST "repos/$REPO/issues/$PR/labels" \ + -f labels[]=major-update >/dev/null + gh api -X DELETE "repos/$REPO/issues/$PR/labels/automerge" \ + >/dev/null 2>&1 || true + + marker="" + existing=$(gh api --paginate --slurp \ + "repos/$REPO/issues/$PR/comments" \ + --jq 'add | map(select(.body | contains(""))) | length') + if [[ "$existing" -eq 0 ]]; then + gh pr comment "$PR" -R "$REPO" --body "$marker + This is a major Dependabot update, so it is **not** auto-merged. It needs owner review. Minor and patch updates still merge automatically once every check passes." + fi + say "Major update held for owner review; auto-merge not armed." + exit 0 + fi + + gh api -X POST "repos/$REPO/issues/$PR/labels" \ + -f labels[]=automerge >/dev/null + gh api -X DELETE "repos/$REPO/issues/$PR/labels/major-update" \ + >/dev/null 2>&1 || true + + gh pr merge "$PR" -R "$REPO" --auto --squash + say "Minor or patch update; native auto-merge armed." diff --git a/AGENTS.md b/AGENTS.md index 9894e1c..1c7462f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,15 +11,22 @@ that applies to the account. - `standards/core.md`: the shared core standard. Byte-identical in five owner repositories. - `standards/owner.md`: the rules for this account on top of the core. - `scripts/core-drift.ts`: compares the five copies of `core.md`. +- `scripts/agent-files.ts`: validates the skill files and their `.claude` symlinks. +- `.github/workflows/checks.yml`: the required `check` job, which runs `just check`. +- `.github/workflows/dependabot-automerge.yml`: arms native auto-merge for Dependabot minor and + patch updates and holds majors. +- `docs/exceptions.md`: rules this repository cannot meet, with reasons and revisit dates. - `favicon.svg`: the T3 Code project icon. ## Commands - `just` lists the recipes. - `just fmt` formats the repository; `just fmt-check` reports files that need it. -- `just check` is the gate: `fmt-check`. +- `just lint` runs `actionlint` and `zizmor` over the workflows. +- `just agent-files` checks `.agents/skills` against `.claude/skills`. +- `just check` is the gate: `fmt-check`, `lint` and `agent-files`. - `just core-drift` compares `standards/core.md` with the other four owners. It needs `gh` logged - in as both `deathpie` and `simpsonm09`, so it runs locally only. + in as both `deathpie` and `simpsonm09`, so it runs locally only and is not a required check. ## Invariants diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b4c80e4 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 deathpie + +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. diff --git a/docs/exceptions.md b/docs/exceptions.md new file mode 100644 index 0000000..a3bbec8 --- /dev/null +++ b/docs/exceptions.md @@ -0,0 +1,10 @@ +# Exceptions + +Rules from [`standards/core.md`](../standards/core.md) and +[`standards/owner.md`](../standards/owner.md) that this repository cannot meet, with the reason +and the date to revisit. + +| Rule | Reason | Revisit | +| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | +| C7.5 | `install`, `typecheck`, `test` and `hooks` have nothing to run: this repository is documentation and community defaults only. `fmt`, `fmt-check`, `lint`, `check` and `agent-files` exist. | 2027-02-23 | +| C5.1 | Fewer than 20 pull request runs exist, so there is no median to report. The `check` job is one short job; the median is recorded once 20 runs exist. | 2027-02-23 | diff --git a/justfile b/justfile index b6010e9..0d48b83 100644 --- a/justfile +++ b/justfile @@ -16,5 +16,14 @@ fmt: fmt-check: bun fmt --check +# Lint the workflows: actionlint for syntax, zizmor for security. +lint: + actionlint + zizmor .github/workflows + +# Check the agent skill files: frontmatter, recipes and the .claude symlinks. +agent-files: + bun scripts/agent-files.ts + # Everything a pull request in this repository must pass. -check: fmt-check +check: fmt-check lint agent-files diff --git a/mise.toml b/mise.toml index e364149..99199f9 100644 --- a/mise.toml +++ b/mise.toml @@ -4,3 +4,6 @@ [tools] just = "1.59.0" bun = "1.4.5" +actionlint = "1.7.12" +shellcheck = "0.11.0" +zizmor = "1.30.1" diff --git a/scripts/agent-files.ts b/scripts/agent-files.ts new file mode 100644 index 0000000..28f07e3 --- /dev/null +++ b/scripts/agent-files.ts @@ -0,0 +1,140 @@ +#!/usr/bin/env bun +// Validate the agent skill files: the canonical copies live in +// `.agents/skills//SKILL.md`, and `.claude/skills/` is a relative +// symlink to each of them (C8.2, C8.3). +// +// Fails when: +// - a SKILL.md has no `name` or `description` frontmatter, +// - a skill names a `just` recipe that the justfile does not define, +// - the two skill directories differ, +// - a `.claude/skills` entry is not a symlink (a Windows clone without +// `core.symlinks=true` turns links into text files), +// - a symlink is broken or points somewhere other than the canonical copy. + +import { + existsSync, + lstatSync, + readdirSync, + readFileSync, + realpathSync, +} from "node:fs"; +import { join, relative } from "node:path"; + +const root = process.cwd(); +const canonicalDir = join(root, ".agents", "skills"); +const linkDir = join(root, ".claude", "skills"); +const errors: string[] = []; + +function entries(path: string): string[] { + if (!existsSync(path)) return []; + return readdirSync(path) + .filter((name) => !name.startsWith(".")) + .sort(); +} + +function readFrontmatter(file: string): string | undefined { + const text = readFileSync(file, "utf8"); + const match = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text); + return match?.[1]; +} + +function field(frontmatter: string, key: string): string | undefined { + const match = new RegExp(`^${key}:\\s*(.+)$`, "m").exec(frontmatter); + const value = match?.[1]?.trim(); + if (!value) return undefined; + return value.replace(/^["']|["']$/g, ""); +} + +function recipes(): Set { + const file = join(root, "justfile"); + if (!existsSync(file)) return new Set(); + const names = new Set(); + for (const line of readFileSync(file, "utf8").split(/\r?\n/)) { + if ( + !line || + /^\s/.test(line) || + line.startsWith("#") || + line.startsWith("set ") + ) { + continue; + } + const match = /^@?([A-Za-z0-9_-]+)(?:\s[^:]*)?:/.exec(line); + if (match) names.add(match[1]); + } + return names; +} + +const canonical = entries(canonicalDir); +const linked = entries(linkDir); +const known = recipes(); + +for (const name of canonical) { + const skillFile = join(canonicalDir, name, "SKILL.md"); + if (!existsSync(skillFile)) { + errors.push(`.agents/skills/${name}: missing SKILL.md`); + continue; + } + const frontmatter = readFrontmatter(skillFile); + if (!frontmatter) { + errors.push(`.agents/skills/${name}/SKILL.md: missing --- frontmatter`); + continue; + } + if (!field(frontmatter, "name")) { + errors.push(`.agents/skills/${name}/SKILL.md: frontmatter has no name`); + } + if (!field(frontmatter, "description")) { + errors.push( + `.agents/skills/${name}/SKILL.md: frontmatter has no description`, + ); + } + const body = readFileSync(skillFile, "utf8"); + for (const match of body.matchAll(/`just ([a-z0-9][a-z0-9-]*)`/g)) { + if (!known.has(match[1])) { + errors.push( + `.agents/skills/${name}/SKILL.md: names unknown recipe "just ${match[1]}"`, + ); + } + } +} + +for (const name of linked) { + if (!canonical.includes(name)) { + errors.push(`.claude/skills/${name}: no matching .agents/skills/${name}`); + continue; + } + const link = join(linkDir, name); + const stat = lstatSync(link); + if (!stat.isSymbolicLink()) { + errors.push( + `.claude/skills/${name}: not a symlink (Windows clone needs core.symlinks=true)`, + ); + continue; + } + if (!existsSync(link)) { + errors.push(`.claude/skills/${name}: broken symlink`); + continue; + } + const expected = realpathSync(join(canonicalDir, name)); + if (realpathSync(link) !== expected) { + errors.push( + `.claude/skills/${name}: points at ${relative(linkDir, realpathSync(link))}`, + ); + } +} + +for (const name of canonical) { + if (!linked.includes(name)) { + errors.push( + `.agents/skills/${name}: missing symlink .claude/skills/${name}`, + ); + } +} + +if (errors.length > 0) { + for (const error of errors) console.error(error); + process.exit(1); +} + +console.log( + `agent files OK: ${canonical.length} skill(s)${canonical.length ? ` (${canonical.join(", ")})` : ""}`, +);