Skip to main content

@svatah/yam-compiler

Compiler tiers, validation, lint and plan writer

Exports

ExportKindSignature
CaseResultinterfaceexport interface CaseResult
checkSigilsfunctionexport function checkSigils(The first retired form in a sentence, as a diagnostic.
clearTiersfunctionexport function clearTiers(): void
comparablefunctionexport function comparable(step: Step): Record<string, unknown>The part of a step two compilers must agree on to have compiled the same
compilefunctionexport function compile(options: CompileOptions): CompileResult
CompileOptionsinterfaceexport interface CompileOptions
CompileResultinterfaceexport interface CompileResult
compileSentencefunctionexport function compileSentence(One sentence through the tiers.
compileWithModelTiersfunctionexport async function compileWithModelTiers(Compile, asking the registered model tiers about the residue (REQ-COMP-1, 3, 4).
DEFAULT_LONG_SLEEP_SECONDSvariableDEFAULT_LONG_SLEEP_SECONDS = 5
EvalReportinterfaceexport interface EvalReport
GOLDEN_PROVENANCEvariableGOLDEN_PROVENANCE A stand-in provenance for a model tier's entry (REQ-STD-4).
GoldenEntrytypealiasexport type GoldenEntry = z.infer<typeof goldenEntrySchema>;
goldenEntrySchemavariablegoldenEntrySchema = z
hasModelTiersfunctionexport function hasModelTiers(): booleanWhether any model-backed tier is available, for --tier2 / --tier3 checks.
LintOptionsinterfaceexport interface LintOptions
lintPlanfunctionexport function lintPlan(plan: Plan, options: LintOptions = {}): Diagnostic[]The warnings that need the whole plan.
LowerContextinterfaceexport interface LowerContext
lowerStepfunctionexport function lowerStep(The IR step for one parsed sentence.
lowerValuefunctionexport function lowerValue(raw: RawValue, secrets: ReadonlySet<string>): ValueRefA raw reference to a ValueRef, marking a secret data path as one.
materialisefunctionexport function materialise(entry: GoldenEntry, storyName = "Golden", line = 1): StepBuild the full Step a compiler would emit for an entry.
ModelSteptypealiasexport type ModelStep = z.infer<typeof modelStepSchema>;
modelStepSchemavariablemodelStepSchema = zOne step, as a model may describe it.
ModelTierinterfaceexport interface ModelTierA tier that a model backs. Registered by the CLI; absent by default.
ModelTierAnswerinterfaceexport interface ModelTierAnswerWhat a model-backed tier answers with.
ModelTierOptionsinterfaceexport interface ModelTierOptions
ModelValuetypealiasexport type ModelValue = z.infer<typeof rawValueSchema>;
parseGuardfunctionexport function parseGuard(Parse a guard written on its own line, which the reader has already split off.
parseSentencefunctionexport function parseSentence(text: string, where: { file: string; line: number }): Tier1ResultParse one sentence.
RawPredicateinterfaceexport interface RawPredicate
RawStepinterfaceexport interface RawStep
RawTargetinterfaceexport interface RawTarget
RawValuetypealiasexport type RawValue A value the grammar read, before it knows whether the path is secret.
rawValueSchemavariablerawValueSchema = zA value the model may name.
readGoldenfunctionexport function readGolden(path: string): GoldenEntry[]Read and parse a golden.jsonl file. Throws with the line number on bad input.
referencesOffunctionexport function referencesOf(step: Step): ValueRef[]Every ValueRef a step reads, wherever it sits.
registerTierfunctionexport function registerTier(tier: ModelTier): voidRegister a model-backed tier. Module (b)'s CLI does this when configured.
renderPlanfunctionexport function renderPlan(plan: Plan): stringplan.json's bytes: canonical, so two compiles of one input are identical.
RETIRED_FORMSvariableRETIRED_FORMS: readonly Form[] = [The retired forms, from the migration table.
scoreCasefunctionexport function scoreCase(entry: GoldenEntry, actual: Step | undefined, error?: string): CaseResultScore one measured step against the golden entry it was measured for.
SentenceContextinterfaceexport interface SentenceContextWhere a sentence the grammar refused was written.
sentenceKeyfunctionexport function sentenceKey(file: string, line: number, text: string): stringHow a sentence is keyed in modelAnswers.
SIDE_EFFECT_WORDSvariableSIDE_EFFECT_WORDS = [Target phrases that make a step side-effecting (REQ-AUTO-8).
STABLE_TIMESTAMPvariableSTABLE_TIMESTAMP = "1970-01-01T00:00:00.000Z"The timestamp --stable uses: fixed, and obviously so.
StepIdentityinterfaceexport interface StepIdentityEverything a step needs that the grammar does not decide.
summarisefunctionexport function summarise(Roll a list of case results into per-tier and overall rates.
Tier1Resultinterfaceexport interface Tier1Result
tierForfunctionexport function tierFor(level: 2 | 3): ModelTier | undefined
toRawStepfunctionexport function toRawStep(step: ModelStep): RawStepA model's answer, as the raw step the grammar would have produced.
ValidateContextinterfaceexport interface ValidateContext
validateStoryfunctionexport function validateStory(Validate one story's steps.