Skip to content

Commit 3c79468

Browse files
committed
feat: reorganize schemas into schemas/ directory with shared refs and registry loading
- Create schemas/_shared.json with common $defs (status, priority, assessment, wikilink, title, content, summary, baseNodeProps, ostEntityProps) - Create schemas/general.json referencing shared defs via ost-tools:// URIs - Remove top-level schema.json (superseded by schemas/general.json) - Add space-level schema field to SpaceConfig and config schema validation - resolveSchema now checks CLI arg > space schema > global schema > default - Default schema path updated from schema.json to schemas/general.json - createValidator uses AJV registry: all peer schemas in schemas/ are registered so cross-file $refs resolve transitively without custom bundling - loadSchema bundles for template-sync (one-level merge + ref rewrite); full registry-aware traversal deferred to #15 alongside strict_ost schema work
1 parent dcfccdc commit 3c79468

13 files changed

Lines changed: 327 additions & 235 deletions

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Before starting new work, review [docs/concepts.md](docs/concepts.md) for canoni
2424
## Key Files
2525

2626
- `config.json` — Space registry (alias → absolute path)
27-
- `schema.json`Entity type definitions and validation rules
27+
- `schemas/`Schema files; composable
2828

2929
## Testing
3030

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,33 +39,32 @@ bun run src/index.ts validate personal
3939
"miroFrameId": "3458764123456789"
4040
}
4141
],
42-
"schema": "/path/to/custom/schema.json",
42+
"schema": "/path/to/custom/schemas/my-schema.json",
4343
"templateDir": "/path/to/Templates"
4444
}
4545
```
4646

4747
- `miroBoardId` / `miroFrameId` — required for `miro-sync` (frame ID is auto-saved after `--new-frame`)
48-
- `schema` — overrides default schema path (`schema.json`). CLI `--schema` takes precedence
48+
- `schema` — overrides schema path
4949
- `templateDir` — default template directory for `template-sync` (can omit the CLI argument)
5050

5151
## Usage
5252

5353
### Validate OST nodes
5454

5555
```bash
56-
bun run src/index.ts validate <space-or-dir> [--schema path/to/schema.json]
56+
bun run src/index.ts validate <space-or-dir> [--schema path/to/my-schema.json]
5757
```
5858

5959
Validates markdown files against the OST JSON schema:
6060
- Extracts YAML frontmatter from each `.md` file
6161
- Skips files without frontmatter or without a `type` field
62-
- Validates against the resolved schema (CLI `--schema` > `config.schema` > `schema.json`)
6362
- Reports validation results with counts and per-file errors
6463

6564
### Generate Mermaid diagram
6665

6766
```bash
68-
bun run src/index.ts diagram <space-or-dir> [--output path/to/output.mmd] [--schema path/to/schema.json]
67+
bun run src/index.ts diagram <space-or-dir> [--output path/to/output.mmd] [--schema path/to/my-schema.json]
6968
```
7069

7170
Generates Mermaid `graph TD` diagram from validated OST nodes:
@@ -93,7 +92,7 @@ Sync is one-way (OST → Miro) and scoped to a single frame. Only cards and conn
9392
### Sync templates with schema
9493

9594
```bash
96-
bun run src/index.ts template-sync [template-dir] [--schema path/to/schema.json] [--dry-run]
95+
bun run src/index.ts template-sync [template-dir] [--schema path/to/my-schema.json] [--dry-run]
9796
```
9897

9998
Keeps Obsidian template files in sync with schema examples:
@@ -124,7 +123,9 @@ bun run test:all
124123

125124
## Schema
126125

127-
The `schema.json` file contains the OST JSON Schema definition for validating node frontmatter.
126+
Schema files and composable parts of schemas live in `schemas/`. Additional schemas can be added and selected per-space or globally via `config.json`.
127+
128+
Schema resolution order: (CLI `--schema` argument > space config `schema` > global config `schema` > `schemas/general.json` default)
128129

129130
## License
130131

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ost-tools",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"module": "src/index.ts",
55
"type": "module",
66
"private": true,

schema.json

Lines changed: 0 additions & 198 deletions
This file was deleted.

schemas/_shared.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "ost-tools://_shared",
4+
"description": "Shared definitions referenced by OST schema files",
5+
"$defs": {
6+
"title": {
7+
"type": "string",
8+
"description": "Title of the node (derived from filename at validation time)"
9+
},
10+
"content": {
11+
"type": "string",
12+
"description": "Body content of the document (excluding frontmatter)"
13+
},
14+
"summary": {
15+
"type": "string",
16+
"description": "Short summary of the node"
17+
},
18+
"status": {
19+
"type": "string",
20+
"enum": ["identified", "wondering", "exploring", "active", "paused", "completed", "archived"]
21+
},
22+
"priority": {
23+
"type": "string",
24+
"enum": ["p1", "p2", "p3", "p4"]
25+
},
26+
"assessment": {
27+
"type": "integer",
28+
"minimum": 1,
29+
"maximum": 5,
30+
"description": "Assessment score from 1-5"
31+
},
32+
"wikilink": {
33+
"type": "string",
34+
"pattern": "^\\[\\[.+\\]\\]$",
35+
"description": "An Obsidian wikilink, e.g. [[Parent Node]]"
36+
},
37+
"baseNodeProps": {
38+
"type": "object",
39+
"properties": {
40+
"title": { "$ref": "#/$defs/title" },
41+
"content": { "$ref": "#/$defs/content" },
42+
"tags": {
43+
"type": "array",
44+
"items": { "type": "string" },
45+
"description": "Categorization tags"
46+
}
47+
},
48+
"required": ["title"]
49+
},
50+
"ostEntityProps": {
51+
"type": "object",
52+
"properties": {
53+
"status": { "$ref": "#/$defs/status" },
54+
"summary": { "$ref": "#/$defs/summary" },
55+
"status_tweet": {
56+
"type": "string",
57+
"description": "Succinct free-text status summary"
58+
}
59+
},
60+
"required": ["status"]
61+
}
62+
}
63+
}

0 commit comments

Comments
 (0)