Skip to content

feat: add Zod schema validation and JSON Schema for skills.json autocompletion#12

Merged
SoonIter merged 2 commits intomainfrom
feat/zod-json-schema
Apr 9, 2026
Merged

feat: add Zod schema validation and JSON Schema for skills.json autocompletion#12
SoonIter merged 2 commits intomainfrom
feat/zod-json-schema

Conversation

@SoonIter
Copy link
Copy Markdown
Owner

@SoonIter SoonIter commented Apr 9, 2026

Summary

This PR adds Zod-based schema validation and JSON Schema generation for skills.json, enabling:

  1. Runtime validation - Invalid manifests now produce clear error messages instead of silent failures
  2. Editor autocompletion - Users can add $schema pointing to unpkg for IDE support
  3. Single source of truth - Zod schema drives both TypeScript types and JSON Schema

Key changes:

  • New skillsManifestSchema in src/config/schema.ts using Zod
  • readSkillsManifest() now validates with helpful validation error messages
  • pnpm generate:schema generates JSON Schema from Zod
  • Auto-injects $schema field in new manifests pointing to unpkg

Related Links

None

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings April 9, 2026 19:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Zod-driven schema for skills.json with runtime validation and generates/publishes a JSON Schema to enable editor autocompletion via $schema.

Changes:

  • Introduce skillsManifestSchema (Zod) and validate skills.json at read time with improved errors.
  • Add generate:schema script to generate skills.schema.json from the Zod schema and publish it with the package.
  • Auto-inject a $schema URL into newly written/initialized manifests; update fixtures/tests accordingly.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
skills.schema.json New root JSON Schema artifact (generated) for reference/autocomplete.
skills.json Adds $schema pointer for editor autocompletion in the repo sample manifest.
scripts/generate-schema.ts New generator script converting Zod schema to JSON Schema and writing outputs.
package.json Adds generate:schema script and tsx dev dependency.
pnpm-lock.yaml Locks new dependencies (tsx, zod, zod-to-json-schema and transitive deps).
packages/skills-package-manager/src/config/schema.ts Adds Zod schema as source of truth for manifest structure.
packages/skills-package-manager/src/config/types.ts Switches SkillsManifest type to be inferred from Zod schema.
packages/skills-package-manager/src/config/readSkillsManifest.ts Adds Zod validation + validation error reporting for invalid manifests.
packages/skills-package-manager/src/config/writeSkillsManifest.ts Injects $schema when writing manifests and retains defaults.
packages/skills-package-manager/src/commands/init.ts Ensures initialized manifests include $schema.
packages/skills-package-manager/skills.schema.json New package-published JSON Schema artifact (generated).
packages/skills-package-manager/package.json Publishes skills.schema.json and adds Zod-related dependencies.
packages/skills-package-manager/test/manifest.test.ts Adds schema validation tests and updates expected manifest output.
packages/skills-package-manager/test/init.test.ts Updates init tests to assert $schema is present.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

package.json:17

  • generate:schema relies on zod-to-json-schema, but it isn't declared in the root devDependencies, so pnpm generate:schema may fail to resolve it. Add it to the root devDependencies (or move the script under the workspace package and run it via pnpm --filter ...).
  "scripts": {
    "prepare": "simple-git-hooks && pnpm run build",
    "build": "pnpm -r --filter=!website build",
    "build:website": "pnpm --filter website build",
    "generate:schema": "tsx scripts/generate-schema.ts",
    "bump": "bumpp -r --no-tag --no-push",
    "test": "rstest run",
    "lint": "biome lint",
    "format": "biome format --write",
    "check": "biome check",
    "check:write": "biome check --write"
  },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ompletion

- Add Zod schema as single source of truth for skills.json structure
- Implement runtime validation in readSkillsManifest with helpful error messages
- Generate JSON Schema from Zod for editor autocompletion via unpkg
- Add pnpm generate:schema script for schema regeneration
- Auto-inject $schema field when writing new manifests
- Add validation tests for the schema layer
@SoonIter SoonIter force-pushed the feat/zod-json-schema branch from fe6203a to ae915b0 Compare April 9, 2026 19:21
…ills.json validation

- Add new error code EMANIFESTVAL for manifest validation errors
- Use ManifestError instead of SkillError for validation failures
- Add helpful error message pointing to JSON Schema reference
@SoonIter SoonIter force-pushed the feat/zod-json-schema branch from ae915b0 to 8957453 Compare April 9, 2026 19:30
@SoonIter SoonIter merged commit 96493a6 into main Apr 9, 2026
2 checks passed
@SoonIter SoonIter deleted the feat/zod-json-schema branch April 9, 2026 19:32
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.

2 participants