chant init lexicon
Scaffold a new lexicon plugin project with compilable stubs for all required LexiconPlugin lifecycle methods.
Synopsis
Section titled “Synopsis”chant init lexicon <name> [path] [flags]Arguments
Section titled “Arguments”| Argument | Description |
|---|---|
<name> | Lexicon name (e.g. k8s, gcp). Used to derive package name, variable names, and rule prefix. |
[path] | Target directory (default: ./lexicons/<name>) |
| Flag | Description |
|---|---|
--force | Initialize even if the target directory is not empty |
Description
Section titled “Description”chant init lexicon creates a complete lexicon plugin project with stubs for every required lifecycle method. The generated code compiles out of the box, imports from @intentius/chant, and mirrors the structure of the AWS lexicon.
Name derivations
Section titled “Name derivations”From the provided name, the command derives:
| Derived value | Formula | Example (k8s) |
|---|---|---|
| Plugin variable | camelCase(name) + "Plugin" | k8sPlugin |
| Serializer variable | camelCase(name) + "Serializer" | k8sSerializer |
| Rule prefix | name.toUpperCase() (first 3 alphanumeric chars) | K8S |
| Package name | @intentius/chant-lexicon-<name> | @intentius/chant-lexicon-k8s |
Generated files
Section titled “Generated files”36 files, as initLexiconCommand writes them (packages/core/src/cli/commands/init-lexicon.ts). Neither dist/ nor src/generated/* is scaffolded; generation and packaging write those later.
| File | Purpose |
|---|---|
src/plugin.ts | LexiconPlugin with all 4 required lifecycle methods |
src/index.ts | Re-exports plugin and serializer; the package entry point |
src/serializer.ts | Stub Serializer producing minimal JSON |
src/codegen/generate.ts | Calls core generatePipeline with TODO callbacks |
src/codegen/generate-cli.ts | tsx entry point for just generate |
src/codegen/docs-cli.ts | tsx entry point for just docs |
src/codegen/naming.ts | NamingStrategy with empty data tables |
src/codegen/package.ts | Calls core packagePipeline |
src/codegen/docs.ts | Calls core docsPipeline |
src/spec/fetch.ts | fetchWithCache stub with TODO URL |
src/spec/parse.ts | parseSchema stub with ParseResult type |
src/lint/rules/sample.ts | Example LintRule using derived prefix |
src/lint/rules/index.ts | Re-export for lint rules |
src/lsp/completions.ts, src/lsp/hover.ts | Stubs using core lexiconCompletions / lexiconHover |
src/lsp/completions.test.ts, src/lsp/hover.test.ts | Tests for the LSP providers |
src/plugin.test.ts, src/serializer.test.ts | The two tests chant dev check-lexicon requires by name |
src/validate.ts | Stub validation checks |
src/validate-cli.ts | tsx entry point for just validate |
src/package-cli.ts | tsx entry point for npm run bundle, chained into prepack; writes src/generated/ and dist/ |
src/generated/.gitkeep | Placeholder for the generation output directory |
package.json | Package config with a * dev dependency on @intentius/chant |
tsconfig.json, tsconfig.build.json | Extends root TypeScript config; build config with bundler resolution |
justfile | generate, validate, docs, docs-build, package recipes |
.gitignore | Ignores snapshots, dist, cache |
README.md | Getting started guide |
docs/ | Starlight site: package.json, tsconfig.json, astro.config.mjs, src/content.config.ts, src/content/docs/index.mdx, pages/getting-started.mdx |
examples/getting-started/ | One example project: package.json, src/infra.ts |
# Scaffold a new lexiconchant init lexicon k8s
# Scaffold at a custom pathchant init lexicon gcp ./my-gcp-lexicon
# Overwrite an existing directorychant init lexicon k8s --forceNext steps
Section titled “Next steps”After scaffolding:
cd lexicons/<name>npm install- Edit
src/spec/fetch.ts— point at your upstream schema source - Edit
src/spec/parse.ts— parse your schema format chant dev generateto generate typeschant dev publishto package for distributionchant dev onboard <name>to wire into CI, Docker, and npm publish
See the full authoring workflow for details on each step.
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
| 0 | Lexicon project created successfully |
| 1 | Error (missing name, target directory not empty without --force) |