Repository navigation
feat(skills): canonical skill registry manifest + bundled endpoints - #47
Conversation
Implements §6.1 of the canonical skill registry plan (PR #46, SHA 8686c48). - scripts/generate-skills-manifest.ts: walks skills/*/SKILL.md, parses frontmatter, computes sha256 contentHash over the full normalized SKILL.md (LF endings, trailing whitespace stripped per line, single trailing newline), writes skills/manifest.json. Also normalizes SKILL.md files on disk so the committed hash matches what is baked into the image. Skips skills without a valid metadata.openclaw block (canvas, healthcheck, skill-creator) with logged warnings. - skills/manifest.json: committed initial snapshot — 53 canonical skills, deterministic (sorted by name, keys sorted within each object). - src/gateway/routes/skills-bundled.ts: GET /skills/bundled returns the runtime envelope (manifest + imageTag/imageSha/sourceSha from build-time env vars OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, OPENCLAW_SOURCE_SHA). GET /skills/bundled/:name returns the SKILL.md body. Both routes require gateway bearer auth. No filesystem traversal outside /app/skills/. - src/gateway/routes/skills-bundled.test.ts: 13 tests covering envelope shape, manifest-file consistency, contentHash verification, body-matches-disk, auth required, and unknown-name 404. - src/gateway/server-http.ts: wire skills-bundled handler into createGatewayHttpServer. - Dockerfile: add OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, OPENCLAW_SOURCE_SHA ARG+ENV pairs for build-time provenance injection. - git-hooks/pre-commit: regenerate and validate manifest when any SKILL.md is staged. - .github/workflows/ci.yml: add skills-manifest-check job (pnpm skills:manifest:check). - package.json: add skills:manifest and skills:manifest:check npm scripts. - docs/skills-manifest.md: schema documentation. - skills/food-order/SKILL.md: quote description field to fix YAML parse error (unquoted colon in "Triggers: order food"). Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
Codex review: needs work before merge. The implementation is close and matches the approved Phase 1 direction. The endpoint is gateway-auth protected, Findings:
GitHub
The food-order fix was necessary because bad YAML caused a silent skip, but the generator still treats parse/metadata failures as warnings and exits 0. Today Please add an explicit allowlist/marker for intentionally non-canonical skill directories, and fail on every other missing/invalid frontmatter or missing
The handler takes the first segment after
The Dockerfile adds Before the post-merge image rebuild, update Validation I ran: CI note: the |
Three blockers from #47: 1. skills/manifest.json now oxfmt-clean. Generator runs `pnpm exec oxfmt skills/manifest.json` as a post-step on write, so future regenerations stay format-compliant. --check mode writes to a tempfile, oxfmts it, and compares against committed (catches both content drift and formatter drift in one shot). 2. Generator now strict by default. Three non-canonical skill directories (canvas, healthcheck, skill-creator) are explicitly allowlisted; any OTHER directory that fails frontmatter parse or lacks metadata.openclaw is a hard error (exit 1). Also enforces `frontmatter.name === directory name` — a mismatch is an error for canonical entries (verified by temporarily editing rain SKILL.md's name field and observing exit 1). 3. /skills/bundled/:name now rejects extra path segments. Previously /skills/bundled/rain/anything served `rain`; now it returns 404 like /skills/bundled/foo/bar. Test (e) tightened to assert 404 across {trailing slash, extra segment, deep extras, extras with unknown leading name}. Validation: - pnpm skills:manifest → writes + oxfmts cleanly - pnpm skills:manifest:check → passes (53 skills, 3 allowlisted) - pnpm exec oxfmt --check skills/manifest.json → clean - pnpm test src/gateway/routes/skills-bundled.test.ts → 13/13 pass - strict mode confirmed: temporarily breaking rain SKILL.md name causes exit 1 with a clear error. Codex's finding #4 (build-and-push.sh ops change) is captured as a follow-up in the PR description — that script lives outside this repo, so it ships as a separate ops change before the post-merge image rebuild. Co-Authored-By: Claude Opus 4.7 <[email protected]>
|
Thanks for the review — all three code blockers fixed in commit 4622c6f. Fixes1.
|
|
Codex re-review of v2 ( Confirmed fixes:
Validation run on DevAgents in a disposable clone at
Ops sequencing answer: merge this PR now is acceptable from the code-review side once maintainers are comfortable with the unrelated CI failures, but do not run the first post-merge gateway image rebuild/deploy until One nuance for that follow-up: No remaining code review findings from PR #47. |
PR #47 introduced `OPENCLAW_IMAGE_TAG` / `OPENCLAW_IMAGE_SHA` / `OPENCLAW_SOURCE_SHA` build args, but used `?? "unknown"` for the runtime read. The Dockerfile declares these as `ARG ... = ""`, so an unset --build-arg comes through at runtime as an empty string (not undefined) — and `??` only triggers on null/undefined, leaving the gateway envelope with `"imageTag": ""` etc. Adds a `buildEnvOr(name, fallback)` helper that treats undefined, null, and "" as missing, and uses it for all three fields. Also adds test (a2) asserting empty-string env vars produce "unknown" in the envelope. Also documents (inline comment + STATUS.md note) why `imageSha` specifically will remain "unknown" until Phase 3 of the canonical skill registry plan — the Artifact Registry digest isn't known inside a single-pass `docker build`, so we can't bake it in via --build-arg. Release-record join (plan §8) will populate it post-push. STATUS.md records the corresponding ops change applied on DevAgents to /opt/openclaw-ops/scripts/build-and-push.sh — it now passes the new build args (TAG + SOURCE_SHA), with backup file alongside. Co-Authored-By: Claude Opus 4.7 <[email protected]>
…#48) PR #47 introduced `OPENCLAW_IMAGE_TAG` / `OPENCLAW_IMAGE_SHA` / `OPENCLAW_SOURCE_SHA` build args, but used `?? "unknown"` for the runtime read. The Dockerfile declares these as `ARG ... = ""`, so an unset --build-arg comes through at runtime as an empty string (not undefined) — and `??` only triggers on null/undefined, leaving the gateway envelope with `"imageTag": ""` etc. Adds a `buildEnvOr(name, fallback)` helper that treats undefined, null, and "" as missing, and uses it for all three fields. Also adds test (a2) asserting empty-string env vars produce "unknown" in the envelope. Also documents (inline comment + STATUS.md note) why `imageSha` specifically will remain "unknown" until Phase 3 of the canonical skill registry plan — the Artifact Registry digest isn't known inside a single-pass `docker build`, so we can't bake it in via --build-arg. Release-record join (plan §8) will populate it post-push. STATUS.md records the corresponding ops change applied on DevAgents to /opt/openclaw-ops/scripts/build-and-push.sh — it now passes the new build args (TAG + SOURCE_SHA), with backup file alongside. Co-authored-by: Liran Peretz <[email protected]> Co-authored-by: Claude Opus 4.7 <[email protected]>
Summary
Phase 1 worker side of the canonical skill registry, per plan PR #46 (merged at SHA
8686c48df). Implements §6.1 only. Dashboard side (feat/skill-registry-install-ui) is a separate PR/session.scripts/generate-skills-manifest.ts— walksskills/*/SKILL.md, parses frontmatter (usingyamlpackage already in deps), computescontentHash(sha256 over full normalized SKILL.md including frontmatter — LF endings, trailing whitespace stripped, single trailing newline per §5.1), writesskills/manifest.json. Also normalizes SKILL.md files on disk so the committed hash matches what gets baked into the image. Skills without a validmetadata.openclawblock are skipped with a logged warning.skills/manifest.json— committed initial snapshot: 53 canonical skills, deterministic output (sorted by name, stable key order within each object). Skipped:canvas(no frontmatter),healthcheck,skill-creator(nometadata.openclawblock).src/gateway/routes/skills-bundled.ts—GET /skills/bundledreturns the runtime envelope per §5.1 (imageTag,imageSha,sourceShafrom build-time env vars,generatedAt,skills).GET /skills/bundled/:namereturns the SKILL.md body. Both require gateway bearer auth (authorizeGatewayBearerRequestOrReply). Manifest cached at module init. No filesystem traversal outside/app/skills/.src/gateway/routes/skills-bundled.test.ts— 13 tests covering (a) envelope shape, (b) manifest entries match committed file + contentHash verification, (c) per-skill body matches disk, (d) auth required (401), (e) unknown skill name returns 404. Path-traversal via../is neutralized byURLnormalization (handler returnsfalse, not 404 — documented in test).src/gateway/server-http.ts— wireshandleSkillsBundledRequestintocreateGatewayHttpServerafterhandleToolsInvokeHttpRequest, following the existing handler-chain pattern.Dockerfile— addsARG/ENVforOPENCLAW_IMAGE_TAG,OPENCLAW_IMAGE_SHA,OPENCLAW_SOURCE_SHA. Injected at build time by--build-arg.git-hooks/pre-commit— regenerates manifest + normalizes staged SKILL.md files when anyskills/*/SKILL.mdis staged. Validates manifest is in sync before allowing commit..github/workflows/ci.yml— addsskills-manifest-checkjob (runspnpm skills:manifest:checkon every push/PR).package.json— addsskills:manifestandskills:manifest:checknpm scripts.docs/skills-manifest.md— schema documentation (§5.1 layout, normalization rules, API spec, frontmatter requirements, tooling table, provenance overview).skills/food-order/SKILL.md— fix: quote description field to resolve YAML parse error (Triggers: order foodcontained an unquoted colon).Follow-up ops change (not in this PR)
The build script
/opt/openclaw-ops/scripts/build-and-push.shshould be updated to pass--build-arg OPENCLAW_IMAGE_TAG=<tag> --build-arg OPENCLAW_IMAGE_SHA=<sha> --build-arg OPENCLAW_SOURCE_SHA=<git-sha>todocker build. Until that ops change lands, the gateway will return"unknown"for those fields in the envelope — theskillsarray is still correct.Test plan
pnpm buildpasses (no TypeScript errors)pnpm skills:manifest:checkexits 0 (manifest in sync)vitest run --config vitest.gateway.config.ts src/gateway/routes/skills-bundled.test.ts— 13/13 passvitest run --config vitest.gateway.config.ts— 545/545 pass (no regressions)--build-arg OPENCLAW_IMAGE_TAG=<tag>and smoke-testGET /skills/bundledon a running agent returns the envelope with correctimageTag.🤖 Generated with Claude Code