Skip to content

chant init lexicon

Scaffold a new lexicon plugin project with compilable stubs for all required LexiconPlugin lifecycle methods.

chant init lexicon <name> [path] [flags]
ArgumentDescription
<name>Lexicon name (e.g. k8s, gcp). Used to derive package name, variable names, and rule prefix.
[path]Target directory (default: ./lexicons/<name>)
FlagDescription
--forceInitialize even if the target directory is not empty

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.

From the provided name, the command derives:

Derived valueFormulaExample (k8s)
Plugin variablecamelCase(name) + "Plugin"k8sPlugin
Serializer variablecamelCase(name) + "Serializer"k8sSerializer
Rule prefixname.toUpperCase() (first 3 alphanumeric chars)K8S
Package name@intentius/chant-lexicon-<name>@intentius/chant-lexicon-k8s

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.

FilePurpose
src/plugin.tsLexiconPlugin with all 4 required lifecycle methods
src/index.tsRe-exports plugin and serializer; the package entry point
src/serializer.tsStub Serializer producing minimal JSON
src/codegen/generate.tsCalls core generatePipeline with TODO callbacks
src/codegen/generate-cli.tstsx entry point for just generate
src/codegen/docs-cli.tstsx entry point for just docs
src/codegen/naming.tsNamingStrategy with empty data tables
src/codegen/package.tsCalls core packagePipeline
src/codegen/docs.tsCalls core docsPipeline
src/spec/fetch.tsfetchWithCache stub with TODO URL
src/spec/parse.tsparseSchema stub with ParseResult type
src/lint/rules/sample.tsExample LintRule using derived prefix
src/lint/rules/index.tsRe-export for lint rules
src/lsp/completions.ts, src/lsp/hover.tsStubs using core lexiconCompletions / lexiconHover
src/lsp/completions.test.ts, src/lsp/hover.test.tsTests for the LSP providers
src/plugin.test.ts, src/serializer.test.tsThe two tests chant dev check-lexicon requires by name
src/validate.tsStub validation checks
src/validate-cli.tstsx entry point for just validate
src/package-cli.tstsx entry point for npm run bundle, chained into prepack; writes src/generated/ and dist/
src/generated/.gitkeepPlaceholder for the generation output directory
package.jsonPackage config with a * dev dependency on @intentius/chant
tsconfig.json, tsconfig.build.jsonExtends root TypeScript config; build config with bundler resolution
justfilegenerate, validate, docs, docs-build, package recipes
.gitignoreIgnores snapshots, dist, cache
README.mdGetting 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
Terminal window
# Scaffold a new lexicon
chant init lexicon k8s
# Scaffold at a custom path
chant init lexicon gcp ./my-gcp-lexicon
# Overwrite an existing directory
chant init lexicon k8s --force

After scaffolding:

  1. cd lexicons/<name>
  2. npm install
  3. Edit src/spec/fetch.ts — point at your upstream schema source
  4. Edit src/spec/parse.ts — parse your schema format
  5. chant dev generate to generate types
  6. chant dev publish to package for distribution
  7. chant dev onboard <name> to wire into CI, Docker, and npm publish

See the full authoring workflow for details on each step.

CodeMeaning
0Lexicon project created successfully
1Error (missing name, target directory not empty without --force)