# TargApps JSON Schemas

Machine-readable JSON Schema (draft 2020-12) for TargApps application and workspace formats.

## Catalog

Browse the manifest at [`/schemas/index.json`](/schemas/index.json).

| Directory | Scope |
|-----------|-------|
| `chroma/` | Chroma engine and CLI JSON (`chroma.json`, `chroma-fs.json`, `pkg/package.json`, `jsconfig.json`) |
| `chroma-plugins/` | First-party `@chroma/*` plugin contracts and router manifests |
| `targ-apps/` | Targ-Apps-Finance data, app-level Chroma manifests, marketing site config, workspace stage registry |

## Validate with AJV CLI

From the workspace root:

```bash
cd targ-apps-docs/public/schemas

# Recommended: Ajv 2020 with all schemas preloaded (handles $ref)
TMP=$(mktemp -d) && cd "$TMP" && npm init -y && npm install ajv@8 ajv-formats@3
node --input-type=module -e "
import Ajv2020 from 'ajv/dist/2020.js';
import addFormats from 'ajv-formats';
import fs from 'fs';
import path from 'path';
const root = '$(pwd)/../..'; // adjust if running from repo root
const ajv = new Ajv2020({ allErrors: true, strict: false });
addFormats(ajv);
for (const dir of ['targ-apps','chroma','chroma-plugins']) {
  for (const f of fs.readdirSync(path.join(root, dir)).filter(x => x.endsWith('.json')))
    ajv.addSchema(JSON.parse(fs.readFileSync(path.join(root, dir, f), 'utf8')));
}
const v = ajv.getSchema('https://docs.targapps.xyz/schemas/targ-apps/finance-backup.schema.json');
console.log(v(JSON.parse(fs.readFileSync(path.join(root,'targ-apps/examples/finance-backup-sample.json'),'utf8'))));
"
```

For single-file checks without cross-references, `npx ajv-cli@5 validate -s <schema> -d <data> --spec=draft2020` works.

## Source of truth

Schemas are derived from:

- `Targ-Apps-Finance/logic/persist.js`, `export.js`, `import.js`, `settings.js`, `models.js`, `auth.js`
- `Targ-Apps-Finance/chroma-fs.json`, `chroma.json`, `plugins/*/chroma.plugin.json`
- `targ-apps/components.json` (and deploy mirror `targ-apps-page-vmaspad/components.json`)
- `STAGE.md` machine-readable block (`scripts/commit-stage.sh`)
