T0000 — Repository scaffold

Part of the roadmap. Phase 0 · wave 0 · size M.

Goal

A working pnpm monorepo where every later task can add code and tests without touching the tooling.

Scope

  • Root workspace:

    • package.json: private, packageManager pinned to the current pnpm major, engines.node >= 22
    • scripts: build, test, test:watch, typecheck, lint, format, check (lint + typecheck + test + build + package checks) and changeset
    • pnpm-workspace.yaml (packages/*, tools/*), .node-version (24), .editorconfig, .gitignore
    • a LICENSE file (MIT); the README says MIT, but the file is missing
  • TypeScript 7: tsconfig.base.json with the flags from build and packaging (strict, exactOptionalPropertyTypes, noUncheckedIndexedAccess, verbatimModuleSyntax, isolatedDeclarations), per-package tsconfig.json, typecheck with tsc --noEmit.

  • Build: tsdown in packages/core, producing ESM dist/index.js and dist/index.d.ts. Pin the tsdown version (it is still 0.x).

  • Tests: Vitest with projects (one per package), a smoke test in core, and coverage (@vitest/coverage-v8) configured but not enforced.

  • Lint/format: Biome with biome.json. biome ci runs in CI.

  • Package checks:

    • publint
    • @arethetypeswrong/cli
    • a script that fails if @callis/core has any dependencies
    • a script that reports the gzip size of @callis/core
  • Versioning: Changesets (.changeset/config.json, independent versions, access: public).

  • CI: .github/workflows/ci.yml runs on push and pull request:

    • pnpm install --frozen-lockfile
    • biome ci
    • typecheck
    • tests on Node 22, 24 and 26
    • build
    • package checks

    Concurrent runs on the same ref are cancelled.

  • packages/core (@callis/core):

    • package.json with version: 0.0.0, type: module, an exports map, files, sideEffects: false, engines, license, repository and keywords
    • src/index.ts with an empty public API
    • an internal src/errors/ skeleton: the FhirPathError hierarchy, SourceSpan, the ErrorCode union and format() from errors and diagnostics. Every wave-1 task needs this module, so it is created here to avoid merge conflicts.
  • Contributor docs: CONTRIBUTING.md and AGENTS.md already describe the workflow and conventions. Fill in their Commands sections: install, pnpm check and its parts, running a single test file, and adding a changeset.

  • PR-title check: a CI job that checks PR titles against the rules in CONTRIBUTING.md: allowed types and scopes, exactly one scope (optional only for docs, build, ci and chore), a summary that starts with a lowercase letter and has no trailing period, and at most 72 characters. The rules live in scripts/pr-title.ts with tests, and pnpm check:title runs them locally. Generic actions such as amannn/action-semantic-pull-request cannot express all of these rules.

  • Biome rules that enforce the code style guide where Biome supports it (for example no default exports).

Out of scope

Any FHIRPath functionality; the release workflow (T0025).

Design notes

Errors and diagnostics

ts
class FhirPathError extends Error {
readonly code: ErrorCode; // stable string, e.g. 'syntax/unexpected-token'
readonly span?: SourceSpan;
readonly expression?: string;
format(): string; // message plus source excerpt with a caret
}
class FhirPathSyntaxError extends FhirPathError {}
class FhirPathSemanticError extends FhirPathError { readonly diagnostics: readonly Diagnostic[] }
class FhirPathEvaluationError extends FhirPathError {}
interface SourceSpan { start: number; end: number; line: number; column: number } // offsets in UTF-16 units; line/column 1-based

Error codes are stable strings grouped by stage, for example:

  • syntax: syntax/unexpected-token, syntax/unexpected-character, syntax/unterminated-string, syntax/unterminated-comment, syntax/invalid-escape, syntax/invalid-date-literal
  • semantic: semantic/unknown-function, semantic/wrong-arity, semantic/unknown-element, semantic/unknown-type
  • evaluation: eval/singleton-expected, eval/type-mismatch, eval/undefined-variable, eval/invalid-literal, eval/invalid-argument, eval/async-in-sync, eval/aborted, eval/limit-exceeded, eval/datetime-out-of-range, eval/invalid-calendar-unit

A formatted error looks like this:

text
FhirPathSyntaxError [syntax/unexpected-token]: Expected ')' but found end of input
Patient.name.where(use = 'official'
^

When the spec says evaluation "will end and signal an error to the calling environment", Callis throws. When it says the result is empty, Callis returns []; division by zero is one example.

Build, packaging and runtime targets

TopicDecision
Module formatESM only ("type": "module", an exports map with types + default, "sideEffects": false). Node ≥ 20.19 / 22.12 can require() ESM. See ADR-0009 (owner decision: no CommonJS build for now).
Language targetES2022 output. BigInt is the only feature newer than ES2017 that is essential.
Platform independenceThe core imports no node: modules and uses no Buffer, process or DOM types. lib is ES2022 only. Host APIs that appear in the public API are typed with small structural interfaces defined and exported by the core, for example CancellationSignal instead of AbortSignal (T0021: sync and async), so consumers need no extra ambient typings.
RuntimesNode.js 22, 24 and 26 (current LTS lines); evergreen browsers; Deno, Bun and edge workers on a best-effort basis. engines.node: ">=22".
TypeScriptTypeScript 7 (native compiler) with strict, exactOptionalPropertyTypes, noUncheckedIndexedAccess, verbatimModuleSyntax and isolatedDeclarations. The last one forces explicit types on the public API and enables fast .d.ts generation.
Buildtsdown (Rolldown-based; tsup is no longer maintained and points users to tsdown). Outputs ESM plus .d.ts.
Lint and formatBiome: one tool, fast, minimal config. Type checking is a separate tsc --noEmit step.
TestsVitest, with one project per package.
VersioningChangesets, independent versions per package. Model and UCUM packages have a peer dependency on @callis/core.
Package checkspublint and @arethetypeswrong/cli in CI. A script fails the build if @callis/core gains any dependencies. Bundle size is tracked, with an initial budget of 40 kB gzip for the core.
CI (GitHub Actions)Install (pnpm, frozen lockfile), biome ci, typecheck, unit tests (Node matrix), build, package checks, conformance report (job summary + artifact). A release workflow based on changesets comes with the first release.

Acceptance criteria

  • On a clean clone, pnpm install && pnpm check passes on Node 22, 24 and 26.
  • CI runs on every PR and is green. Breaking lint, types or tests turns it red (checked once, by hand).
  • pnpm --filter @callis/core build emits ESM + .d.ts. publint and attw report no problems.
  • Adding a dependency to @callis/core makes the no-dependency check fail (checked once, by hand).
  • pnpm changeset works.
  • The Commands sections in CONTRIBUTING.md and AGENTS.md list working commands.
  • A PR with a non-conforming title fails the PR-title check (checked once, by hand).