Skip to content

feat(skills): canonical skill registry manifest + bundled endpoints - #47

Merged
cryptolir merged 2 commits into
mainfrom
feat/skill-registry-manifest
May 24, 2026
Merged

cryptolir merged 2 commits into
mainfrom
feat/skill-registry-manifest

Conversation

@cryptolir

Copy link
Copy Markdown
Owner

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 — walks skills/*/SKILL.md, parses frontmatter (using yaml package already in deps), computes contentHash (sha256 over full normalized SKILL.md including frontmatter — LF endings, trailing whitespace stripped, single trailing newline per §5.1), writes skills/manifest.json. Also normalizes SKILL.md files on disk so the committed hash matches what gets baked into the image. Skills without a valid metadata.openclaw block 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 (no metadata.openclaw block).
  • src/gateway/routes/skills-bundled.ts — GET /skills/bundled returns the runtime envelope per §5.1 (imageTag, imageSha, sourceSha from build-time env vars, generatedAt, skills). GET /skills/bundled/:name returns 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 by URL normalization (handler returns false, not 404 — documented in test).
  • src/gateway/server-http.ts — wires handleSkillsBundledRequest into createGatewayHttpServer after handleToolsInvokeHttpRequest, following the existing handler-chain pattern.
  • Dockerfile — adds ARG/ENV for OPENCLAW_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 any skills/*/SKILL.md is staged. Validates manifest is in sync before allowing commit.
  • .github/workflows/ci.yml — adds skills-manifest-check job (runs pnpm skills:manifest:check on every push/PR).
  • package.json — adds skills:manifest and skills:manifest:check npm 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 food contained an unquoted colon).

Follow-up ops change (not in this PR)

The build script /opt/openclaw-ops/scripts/build-and-push.sh should be updated to pass --build-arg OPENCLAW_IMAGE_TAG=<tag> --build-arg OPENCLAW_IMAGE_SHA=<sha> --build-arg OPENCLAW_SOURCE_SHA=<git-sha> to docker build. Until that ops change lands, the gateway will return "unknown" for those fields in the envelope — the skills array is still correct.

Test plan

  • pnpm build passes (no TypeScript errors)
  • pnpm skills:manifest:check exits 0 (manifest in sync)
  • vitest run --config vitest.gateway.config.ts src/gateway/routes/skills-bundled.test.ts — 13/13 pass
  • Full gateway test suite: vitest run --config vitest.gateway.config.ts — 545/545 pass (no regressions)
  • Pre-commit hook passes on the commit (lint, format, manifest regeneration all clear)
  • After merging: rebuild and push gateway image with --build-arg OPENCLAW_IMAGE_TAG=<tag> and smoke-test GET /skills/bundled on a running agent returns the envelope with correct imageTag.

🤖 Generated with Claude Code

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]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Codex review: needs work before merge.

The implementation is close and matches the approved Phase 1 direction. The endpoint is gateway-auth protected, contentHash covers the full normalized SKILL.md including frontmatter, and the targeted bundled-route tests pass locally. I found a few blockers to address before merge.

Findings:

  1. skills/manifest.json is not oxfmt-clean, so PR-touched formatting fails CI.

GitHub check is failing in pnpm format:check, and a changed-file local check reproduces it:

pnpm exec oxfmt --check ...
Format issues found:
skills/manifest.json

pnpm skills:manifest:check passes, so this is formatting, not manifest drift. Please format/regenerate so pnpm check can pass.

  1. scripts/generate-skills-manifest.ts can still silently omit broken canonical skills.

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 pnpm skills:manifest:check passes while warning that canvas, healthcheck, and skill-creator are skipped. That makes future accidental frontmatter breakage easy to miss in CI.

Please add an explicit allowlist/marker for intentionally non-canonical skill directories, and fail on every other missing/invalid frontmatter or missing metadata.openclaw. Also enforce frontmatter.name === directory name; the parser reads name, but buildEntry(dir, ...) ignores it, so mismatches are currently masked.

  1. src/gateway/routes/skills-bundled.ts accepts extra path segments.

The handler takes the first segment after /skills/bundled/, so /skills/bundled/rain/anything serves rain instead of rejecting the malformed URL. The test currently allows [200, 404] for slash paths. The route contract is GET /skills/bundled/:name; require exactly one safe segment and return 404 for extras.

  1. Runtime image metadata will be unknown with the current production build script.

The Dockerfile adds OPENCLAW_IMAGE_TAG, OPENCLAW_IMAGE_SHA, and OPENCLAW_SOURCE_SHA, but the DevAgents build script currently only passes OPENCLAW_INSTALL_BROWSER:

DOCKER_BUILDKIT=1 docker build --build-arg OPENCLAW_INSTALL_BROWSER=1 ...

Before the post-merge image rebuild, update /opt/openclaw-ops/scripts/build-and-push.sh or otherwise pass the new build args. If that stays outside this repo, capture it explicitly in the rollout checklist; otherwise /skills/bundled will report unknown for the metadata the dashboard needs for provenance/audit.

Validation I ran:

pnpm install
pnpm skills:manifest:check                                  # pass; 53 skills, 3 skipped warnings
pnpm test src/gateway/routes/skills-bundled.test.ts         # pass; 13/13
pnpm exec oxfmt --check <changed files>                     # fail; skills/manifest.json

CI note: the install-smoke failure appears unrelated to this PR. It is the existing installer version-string mismatch: expected 2026.5.22, got OpenClaw 2026.5.22 (a374c3a). Labeler failures also look unrelated, as noted in the handoff.

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]>
@cryptolir

Copy link
Copy Markdown
Owner Author

Thanks for the review — all three code blockers fixed in commit 4622c6f.

Fixes

1. skills/manifest.json is now oxfmt-clean

The generator runs pnpm exec oxfmt skills/manifest.json as a post-step on every 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 is strict by default

Three directories explicitly allowlisted (canvas, healthcheck, skill-creator) — the first has no frontmatter at all, the other two have frontmatter without metadata.openclaw. Any other directory that fails frontmatter parse, lacks metadata.openclaw, or whose frontmatter.name mismatches the directory name is a hard error (exit 1).

Verified locally:

$ sed -i.bak '2s/name: rain/name: oops-renamed/' skills/rain/SKILL.md
$ pnpm skills:manifest:check
ERROR: canonical-skill frontmatter problems:
  - rain: frontmatter.name='oops-renamed' does not match directory name
ELIFECYCLE  Command failed with exit code 1.

3. /skills/bundled/:name rejects extra path segments

/skills/bundled/rain/anything now returns 404 instead of serving rain. 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 canonical, 3 allowlisted)
pnpm exec oxfmt --check skills/manifest.json  → clean
pnpm test skills-bundled.test.ts              → 13/13 pass

Finding #4 (ops script) — follow-up

The DevAgents /opt/openclaw-ops/scripts/build-and-push.sh change to pass --build-arg OPENCLAW_IMAGE_TAG=$TAG --build-arg OPENCLAW_IMAGE_SHA=$IMAGE_SHA --build-arg OPENCLAW_SOURCE_SHA=$SOURCE_SHA lives outside this repo, so it ships as a separate ops commit before the post-merge image rebuild. I'll capture it in the merge checklist and pair the ops change with the first post-merge image build (otherwise /skills/bundled reports "unknown" for those fields).

Want me to wait on this PR for that ops change to land first, or is the "image metadata is unknown until ops script is updated" interim state acceptable? My preference: merge this PR, do the ops change immediately after, then rebuild — that way the dashboard work in the next PR can start against a known-good registry endpoint.

CI's pre-existing labeler / install-smoke failures unchanged — confirmed those aren't from this PR.

@cryptolir

Copy link
Copy Markdown
Owner Author

Codex re-review of v2 (4622c6f0e): prior code findings are resolved.

Confirmed fixes:

  • skills/manifest.json formatting blocker is fixed. The current check CI failure no longer includes skills/manifest.json; it is failing only on five non-PR files: src/agents/system-prompt.ts, src/agents/tools/self-info-tool.e2e.test.ts, src/agents/tools/self-info-tool.ts, src/auto-reply/reply/get-reply-inline-actions.ts, and src/gateway/server-methods/usage.report.test.ts.
  • Manifest generation is now strict by default, with an explicit non-canonical allowlist for canvas, healthcheck, and skill-creator, and canonical frontmatter.name must match the directory name.
  • /skills/bundled/:name now rejects extra path segments; the route test covers trailing slash, extra segment, deep extras, and unknown leading-name extras.

Validation run on DevAgents in a disposable clone at 4622c6f0eeacd8ed98415b9b167e4de2dd506f2c:

  • pnpm install --frozen-lockfile passed
  • pnpm skills:manifest:check passed, 53 skills
  • pnpm test src/gateway/routes/skills-bundled.test.ts passed, 13/13
  • pnpm exec oxfmt --check skills/manifest.json scripts/generate-skills-manifest.ts src/gateway/routes/skills-bundled.ts src/gateway/routes/skills-bundled.test.ts docs/skills-manifest.md skills/food-order/SKILL.md Dockerfile .github/workflows/ci.yml git-hooks/pre-commit package.json passed

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 /opt/openclaw-ops/scripts/build-and-push.sh is patched to pass the new metadata build args.

One nuance for that follow-up: OPENCLAW_IMAGE_TAG and OPENCLAW_SOURCE_SHA can be passed during docker build; a final registry digest-style OPENCLAW_IMAGE_SHA cannot be known inside the same single-pass build before push. Either clarify that field as a source/build input SHA, leave it unknown until a separate release-record/runtime layer supplies it, or use a deliberate two-pass build if a baked final digest is required.

No remaining code review findings from PR #47.

@cryptolir
cryptolir merged commit a41d399 into main May 24, 2026
16 of 20 checks passed
@cryptolir
cryptolir deleted the feat/skill-registry-manifest branch May 24, 2026 19:09
cryptolir pushed a commit that referenced this pull request May 24, 2026
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]>
cryptolir added a commit that referenced this pull request May 24, 2026
…#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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant