Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 9 additions & 27 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
# CI: shared assets in sync, plugin and marketplace validation, unit tests.
# Actions are pinned to commit SHAs (the version is in the comment).
# Runs this repo's checks (scripts/ci.sh: plugin icon copies match assets/icon.png), Claude Code
# validation, the plugin's unit tests and, on main, the badges.
# The steps live in rjstone/plugin-ci (reusable workflow, called at @main).
name: check
on: [push, pull_request]
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
- name: Plugin icons match assets/icon.png
run: |
# assets/icon.png is the one to edit; each plugin folder carries a copy (an install only
# fetches the plugin folder, so plugin.json can't point outside it).
copies=$(find . -name icon.png -not -path './assets/*' -not -path './.git/*')
[ -n "$copies" ] || { echo "no plugin icon copies found"; exit 1; }
status=0
for f in $copies; do
if cmp -s assets/icon.png "$f"; then echo "ok: $f"; else echo "::error file=$f::differs from assets/icon.png (copy it again)"; status=1; fi
done
exit $status
- name: Validate the marketplace and plugin
run: npx -y @anthropic-ai/claude-code@2.1.332 plugin validate .
- name: Validate the plugin against the plugin directory's checks
run: npx -y @anthropic-ai/claude-code@2.1.332 plugin validate claude-code/custom-compaction --profile directory
- name: Unit tests
run: npx -y @anthropic-ai/claude-code@2.1.332 plugin test claude-code/custom-compaction
permissions:
contents: write # for the nested badges job; the nested check job lowers it to read
uses: rjstone/plugin-ci/.github/workflows/check.yml@main
with:
plugin-path: claude-code/custom-compaction
plugin-tests: true
71 changes: 10 additions & 61 deletions .github/workflows/notify-marketplace.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# Starts rjstone/plugin-marketplace's update workflow so a new release is listed within minutes
# instead of at the marketplace's next daily run. Copied from that repo's
# docs/plugin-repo-release-workflow.yml, plus a manual trigger.
#
# Runs on a release tag push (vX.Y.Z or X.Y.Z), or by hand (Actions > notify-marketplace > Run
# workflow) for a tag pushed before this workflow existed. The marketplace resolves the latest
# release tag itself; the tag sent here only labels its run.
#
# Setup in THIS repo (Settings -> Secrets and variables -> Actions):
# - variable MARKETPLACE_APP_CLIENT_ID: the GitHub App's Client ID (App settings page, "Iv...")
# - secret MARKETPLACE_APP_PRIVATE_KEY: a private key (.pem) generated for that App
# The App needs only "Actions: Read and write" and is installed on the marketplace repo.
# Actions are pinned to commit SHAs (the version is in the comment).
# Starts rjstone/plugin-marketplace's update workflow when a release tag is pushed, or by hand.
# The steps live in rjstone/plugin-ci (reusable workflow, called at @main).
# Setup in this repo: variable MARKETPLACE_APP_CLIENT_ID and secret MARKETPLACE_APP_PRIVATE_KEY
# (the GitHub App needs only "Actions: Read and write" on the marketplace repo).
name: notify-marketplace
on:
push:
Expand All @@ -21,55 +12,13 @@ on:
description: Release tag to report (empty = the latest vX.Y.Z tag)
required: false
type: string

permissions:
contents: read

env:
MARKETPLACE_OWNER: rjstone
MARKETPLACE_REPO: plugin-marketplace

jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Find the tag
id: tag
env:
GH_TOKEN: ${{ github.token }}
EVENT: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
INPUT_TAG: ${{ inputs.tag }}
REPO: ${{ github.repository }}
run: |
if [ "$EVENT" = push ]; then
tag="$REF_NAME"
elif [ -n "$INPUT_TAG" ]; then
tag="$INPUT_TAG"
else
tag=$(gh api "repos/$REPO/tags" --paginate --jq '.[].name' \
| grep -E '^v?[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -1)
fi
# Only a plain release tag goes on (no shell or output injection through a tag name).
if ! printf '%s' "$tag" | grep -Eqx 'v?[0-9]+\.[0-9]+\.[0-9]+'; then
echo "not a release tag: '$tag'"; exit 1
fi
echo "tag=$tag" >> "$GITHUB_OUTPUT"
echo "reporting $tag"
- uses: actions/create-github-app-token@f418cff399f7aef4c2f0ad47e25ca7a6abbdd6fc # v3.4.0
id: token
with:
client-id: ${{ vars.MARKETPLACE_APP_CLIENT_ID }}
private-key: ${{ secrets.MARKETPLACE_APP_PRIVATE_KEY }}
owner: ${{ env.MARKETPLACE_OWNER }}
repositories: ${{ env.MARKETPLACE_REPO }}
- name: Start the marketplace update workflow
env:
GH_TOKEN: ${{ steps.token.outputs.token }}
REPO: ${{ github.repository }}
TAG: ${{ steps.tag.outputs.tag }}
run: |
gh api -X POST "repos/$MARKETPLACE_OWNER/$MARKETPLACE_REPO/actions/workflows/update.yml/dispatches" \
-f ref=main \
-f "inputs[repo]=$REPO" \
-f "inputs[tag]=$TAG"
uses: rjstone/plugin-ci/.github/workflows/notify-marketplace.yml@main
with:
tag: ${{ inputs.tag }}
client-id: ${{ vars.MARKETPLACE_APP_CLIENT_ID }}
secrets:
private-key: ${{ secrets.MARKETPLACE_APP_PRIVATE_KEY }}
25 changes: 5 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
# On a release tag (vX.Y.Z): build that release's notes with git-cliff (cliff.toml) and publish
# a GitHub Release. The tag itself is created by the maintainer (see AGENTS.md, "Releases").
# Actions are pinned to commit SHAs (the version is in the comment).
# Publishes a GitHub Release with git-cliff notes when a vX.Y.Z tag is pushed.
# The steps live in rjstone/plugin-ci (reusable workflow, called at @main).
name: release
on:
push:
tags: ['v[0-9]+.[0-9]+.[0-9]+']
permissions: {}
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Release notes
uses: orhun/git-cliff-action@a9a95522b26fe6403f7bb24031f21fb573d0f5ff # v4.9.1
with:
config: cliff.toml
args: --latest --strip header
env:
OUTPUT: RELEASE_NOTES.md
- name: Publish the release
uses: softprops/action-gh-release@8a0cd651e5b2365bd640854a3fa5dfc70e4875f3 # v3.0.4
with:
body_path: RELEASE_NOTES.md
uses: rjstone/plugin-ci/.github/workflows/release.yml@main
with:
plugin-path: claude-code/custom-compaction
12 changes: 11 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ in `docs/`, tooling in `tools/`.
- **Shared icon:** `assets/icon.png` (square PNG, 512-2048 px, under 2 MB; no SVG or WebP) is the one to
edit. Each plugin folder carries an identical copy (for Claude Code: `.claude-plugin/icon.png`, found there
with no `"icon"` key in `plugin.json`: the claude.ai marketplace sync warns about that key as unknown), because an install only fetches the plugin folder. After changing the icon,
copy it to every plugin folder; CI (`.github/workflows/check.yml`) fails if a copy differs.
copy it to every plugin folder; `scripts/ci.sh` (run by CI) fails if a copy differs.
- Keep docs in sync: a behaviour change updates the plugin README, and a new finding or test
result goes in `docs/` with the date and the harness version tested.

Expand Down Expand Up @@ -61,6 +61,16 @@ Releasing `vX.Y.Z`:
Tags must be `vX.Y.Z` (the marketplace ignores other forms, including `claude plugin tag`'s
`name--vX.Y.Z`).

## CI

`.github/workflows/` holds three thin callers of the reusable workflows in
[rjstone/plugin-ci](https://github.com/rjstone/plugin-ci) (`check`, `release`,
`notify-marketplace`); its README documents the inputs. `check` runs `bash scripts/ci.sh` (this
repo's own check: every plugin `icon.png` equals `assets/icon.png`), then `claude plugin
validate` in both profiles and `claude plugin test claude-code/custom-compaction`. Don't add
`claude plugin validate` or `claude plugin test` to `scripts/ci.sh`: the shared workflow runs
them. On pushes to `main` it also renders the README badges onto the orphan `badges` branch.

## Live tests

`tools/live-test/` drives headless sessions; see its README. Live tests cost model tokens: use a
Expand Down
4 changes: 3 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
`reference.md` and `types/claude-code.d.ts` (search for `'session.compact'`,
`SessionCompactInput`, `SessionMessage`, `ModelCompleteRequest`). Once a mod is loaded, the
engine also writes editor types to `<plugin>/.claude-plugin/types/`.
- Before committing a plugin change, run both and keep them clean:
- Before committing a plugin change, run these and keep them clean:
- `bash scripts/ci.sh` (the repo's own checks: plugin icon copies match `assets/icon.png`)
- `claude plugin validate .` (reads the marketplace, manifests and modules)
- `claude plugin validate claude-code/custom-compaction --profile directory`
- `claude plugin test claude-code/custom-compaction` (unit tests; a test's hooks stand in for
the engine, and a stand-in for a `$` call answers `{ value }`)
- Try a change in a session with `claude --plugin-dir claude-code/custom-compaction`.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# custom-compaction-plugin

[![check](https://raw.githubusercontent.com/rjstone/custom-compaction-plugin/badges/check.svg)](https://github.com/rjstone/custom-compaction-plugin/actions/workflows/check.yml)
![tests](https://raw.githubusercontent.com/rjstone/custom-compaction-plugin/badges/tests.svg)
[![version](https://raw.githubusercontent.com/rjstone/custom-compaction-plugin/badges/version.svg)](https://github.com/rjstone/custom-compaction-plugin/releases)
![license](https://raw.githubusercontent.com/rjstone/custom-compaction-plugin/badges/license.svg)

Customizable conversation compaction for coding-agent harnesses. Instead of the harness's
built-in "summarize and replace" step, you choose the summarizer (the session's own model or
any OpenAI- or Anthropic-format endpoint), the summary prompt, and how much recent
Expand Down
3 changes: 3 additions & 0 deletions claude-code/custom-compaction/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
"author": {
"name": "rjstone"
},
"homepage": "https://github.com/rjstone/custom-compaction-plugin",
"repository": "https://github.com/rjstone/custom-compaction-plugin",
"license": "MIT",
"userConfig": {
"mode": {
"type": "string",
Expand Down
15 changes: 15 additions & 0 deletions scripts/ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# This repo's own checks. The shared check workflow (rjstone/plugin-ci) runs it in CI; run it
# by hand before committing. Claude Code validation is separate (see CLAUDE.md).
set -euo pipefail
cd "$(dirname "$0")/.."

# Plugin icons match assets/icon.png. assets/icon.png is the one to edit; each plugin folder
# carries a copy (an install only fetches the plugin folder, so plugin.json can't point outside it).
copies=$(find . -name icon.png -not -path './assets/*' -not -path './.git/*')
[ -n "$copies" ] || { echo "no plugin icon copies found"; exit 1; }
status=0
for f in $copies; do
if cmp -s assets/icon.png "$f"; then echo "ok: $f"; else echo "::error file=$f::differs from assets/icon.png (copy it again)"; status=1; fi
done
exit $status