Skip to content

Commit f9f4d44

Browse files
committed
feat: add JSON schema generation from Zod
1 parent 81bc380 commit f9f4d44

File tree

5 files changed

+1688
-1
lines changed

5 files changed

+1688
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"scripts": {
4747
"postinstall": "node scripts/check-old-cli.mjs",
4848
"build": "npm run build:lib && npm run build:cli && npm run build:assets",
49+
"build:schema": "node scripts/generate-schema.mjs && prettier --write schemas/",
4950
"build:lib": "tsc -p tsconfig.build.json",
5051
"build:cli": "node esbuild.config.mjs",
5152
"build:assets": "node scripts/copy-assets.mjs",

schemas/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# JSON Schema
2+
3+
This directory contains the JSON Schema for `agentcore.json`, generated from the Zod schemas in `src/schema/`.
4+
5+
## Updating the schema
6+
7+
```bash
8+
npm run build:lib
9+
npm run build:schema
10+
```
11+
12+
This regenerates `schemas/agentcore.schema.v1.json` from the compiled Zod schemas. Commit the updated file.
13+
14+
## Versioning
15+
16+
- `agentcore.schema.v1.json` — backwards-compatible updates only (new optional fields)
17+
- Create `agentcore.schema.v2.json` only for breaking changes (removed/renamed fields)
18+
19+
### Creating a new major version
20+
21+
1. Update `SCHEMA_VERSION` in `scripts/generate-schema.mjs`
22+
2. Run `npm run build:lib && npm run build:schema`
23+
3. Commit the new schema file — keep the old version for existing projects
24+
25+
## Compatibility
26+
27+
Tag patterns use Unicode property escapes (`\p{L}`, `\p{N}`) which require a JS-based regex engine. This works in VS
28+
Code and other JS-powered validators but may fail in Python, Go, or Java < 9.
29+
30+
## Limitations
31+
32+
The JSON Schema is a best-effort projection of the Zod schemas in `src/schema/`. Zod is the source of truth and is more expressive (e.g. cross-field refinements, custom validators). Passing JSON Schema validation does not guarantee the CLI will accept the config.

0 commit comments

Comments
 (0)