Files
headroom/scripts/verify-versions.py
66e1467682 feat(plugins): headroom skill for Claude Code, Codex, Copilot and skills.sh (#4533)
## Description

In the unbranded sandbox run the agent never searched and wrote a
300-line trimmer by hand; nothing in its environment said Headroom
exists. An Agent Skill is the one artifact that fires on the job words
(cut input tokens, trim tool outputs, fit a context window) with zero
fetches. Four unofficial "headroom" skills already exist on skills.sh;
there is no official one.

Depends on #4529 for the `/docs/fastapi` link in the skill body.

## Type of Change

- [x] New feature (non-breaking change that adds functionality)

## Changes Made

- `skills/headroom/SKILL.md`: job-language description; body is the
no-key `compress()` path, the zero-network check, `model_limit` /
`protect_recent`, the TypeScript proxy caveat, the coding-agent path,
and a short do-not list (no savings claims, no `CompressionMiddleware`
for apps that call a provider, no `[all]` unless asked).
- `plugins/headroom-skill/`: the same SKILL.md under `skills/`,
`.claude-plugin/plugin.json` and `.github/plugin/plugin.json`
(identical), README with install lines for Claude Code, Copilot CLI and
`npx skills add`.
- Both marketplace manifests: `headroom-skill` entry, inserted after the
hooks plugin so `plugins[0]` stays as the existing tests expect.
- `scripts/version-sync.py` and `scripts/verify-versions.py`: the two
new manifests, so the next release PR passes the version gate.
`scripts/tests/test_version_sync.py` fixture and assertion extended;
`tests/test_release_workflows.py` gate list extended.
- `tests/test_plugin_manifests.py`: the two SKILL.md copies must be
byte-identical (the repo has no symlinks, for Windows checkouts),
frontmatter has `name: headroom`; the skill plugin's two manifests match
each other and the marketplace entry.

## Testing

- [x] Unit tests pass: `tests/test_plugin_manifests.py
scripts/tests/test_version_sync.py tests/test_release_workflows.py -k
"manifest or version or skill or sync"`: 30 passed
- [x] `ruff check` / `ruff format --check` on the touched Python
- [x] `python scripts/verify-versions.py`: "All versions aligned at
0.42.0"
- [x] Manual testing performed

### Test Output

```text
pytest tests/test_plugin_manifests.py scripts/tests/test_version_sync.py tests/test_release_workflows.py -k "manifest or version or skill or sync": 30 passed
python scripts/verify-versions.py: All versions aligned at 0.42.0
claude plugin validate .: ✔ Validation passed
```

## Real Behavior Proof

- Environment: macOS arm64, Claude Code CLI.
- Exact command / steps: `claude plugin validate .` at the repo root of
this branch.
- Observed result: `✔ Validation passed`. The only warning is
pre-existing and about `plugins/headroom-agent-hooks/README.md` lacking
a marketplace install line.
- Not tested: installing the plugin from the marketplace into a fresh
Claude Code or Copilot CLI session and triggering the skill on a real
task; skills.sh indexing (happens on their side once this is on `main`).

## Runtime Rollout Safety

- Rollout-managed feature(s): none; documentation and metadata only, no
runtime code path changes
- Minimum rollout channel: n/a
- Stable/default behavior changed: no
- Kill switch / disable path: n/a (revert the PR)
- Unsafe override required: no
- Qualification impact: none
- Rollback path: revert the commit

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Co-authored-by: JD Davis <mxjerrett@gmail.com>
2026-11-03 23:43:21 -06:00

77 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Verify all package manifest versions are in sync before publishing."""
import json
from pathlib import Path
try:
import tomllib
except ImportError: # pragma: no cover - Python 3.10 fallback
import tomli as tomllib
ROOT = Path(__file__).parent.parent
def _read_json_version(path: Path) -> str:
with open(path, encoding="utf-8") as f:
return str(json.load(f)["version"])
def _read_marketplace_versions(path: Path) -> dict[str, str]:
with open(path, encoding="utf-8") as f:
payload = json.load(f)
versions: dict[str, str] = {}
metadata = payload.get("metadata")
if isinstance(metadata, dict):
versions[f"{path}:metadata"] = str(metadata.get("version"))
plugins = payload.get("plugins")
if isinstance(plugins, list):
for index, plugin in enumerate(plugins):
if isinstance(plugin, dict):
versions[f"{path}:plugins[{index}]"] = str(plugin.get("version"))
return versions
def main() -> None:
with open(ROOT / "pyproject.toml", "rb") as f:
py_ver = tomllib.load(f)["project"]["version"]
versions = {
"pyproject.toml": py_ver,
"plugins/openclaw/package.json": _read_json_version(ROOT / "plugins/openclaw/package.json"),
"plugins/opencode/package.json": _read_json_version(ROOT / "plugins/opencode/package.json"),
"sdk/typescript/package.json": _read_json_version(ROOT / "sdk/typescript/package.json"),
"plugins/headroom-agent-hooks/.claude-plugin/plugin.json": _read_json_version(
ROOT / "plugins/headroom-agent-hooks/.claude-plugin/plugin.json"
),
"plugins/headroom-snip/.claude-plugin/plugin.json": _read_json_version(
ROOT / "plugins/headroom-snip/.claude-plugin/plugin.json"
),
"plugins/headroom-agent-hooks/.github/plugin/plugin.json": _read_json_version(
ROOT / "plugins/headroom-agent-hooks/.github/plugin/plugin.json"
),
"plugins/headroom-skill/.claude-plugin/plugin.json": _read_json_version(
ROOT / "plugins/headroom-skill/.claude-plugin/plugin.json"
),
"plugins/headroom-skill/.github/plugin/plugin.json": _read_json_version(
ROOT / "plugins/headroom-skill/.github/plugin/plugin.json"
),
}
versions.update(_read_marketplace_versions(ROOT / ".claude-plugin/marketplace.json"))
versions.update(_read_marketplace_versions(ROOT / ".github/plugin/marketplace.json"))
if not all(v == py_ver for v in versions.values()):
print("Version mismatch detected:")
for file, ver in versions.items():
print(f" {file}: {ver}")
print(f"Expected all to be: {py_ver}")
raise SystemExit(1)
print(f"All versions aligned at {py_ver}")
print("Packages:", ", ".join(versions.keys()))
if __name__ == "__main__":
main()