Skip to content

Schema

@kjanat/dreamcli/schema is the package's published definition-schema export.
It resolves to the same schema referenced by generateSchema() output, with a package-target specific mapping:

  • npm/package export (package.json): ./schema -> dreamcli.schema.json
  • Deno/JSR export (deno.json): ./schema -> src/schema.ts (which re-exports the same schema)

Its bytes are identical to the canonical hosted copy at https://dreamcli.kjanat.dev/schemas/definition/v1.schema.json, so use it when you want local or offline validation of dreamcli definition metadata without a network lookup.

Importing The Schema

ts
import schema from '@kjanat/dreamcli/schema';

schema.$schema;
schema.$defs.command;

In TypeScript, this works with resolveJsonModule.
Runtime loading behavior depends on the host runtime export target (see notes above). For Node on the npm/package target, import with with { type: 'json' }.

Common Uses

  • Validate the output of generateSchema(myCli.schema) in tests or tooling.
  • Ship an offline $schema target in repos that do not want network lookups.
  • Feed the schema into JSON Schema tooling such as Ajv or IDE integrations.

Pairing With generateSchema()

ts
import schema from '@kjanat/dreamcli/schema';
import {
  cli,
  command,
  generateSchema,
} from '@kjanat/dreamcli';

const app = cli('mycli').command(command('deploy'));
const definition = generateSchema(app.schema);

definition.$schema;
schema.$id;

definition.$schema points at the canonical hosted URL. Its v1 segment is the definition format version, matching the document's schemaVersion. The package export gives you the same schema locally from the installed package.

Released under the MIT License.