Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 16d0c66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Coverage Report
📁 File Coverage (20 files)
|
tuler
force-pushed
the
claude/define-config-function-7hq2t0
branch
from
October 14, 2026 02:17
0471fc9 to
447fc8a
Compare
Member
|
@tuler, Probably due to the base, but can you rebase? |
tuler
force-pushed
the
claude/define-config-function-7hq2t0
branch
from
October 19, 2026 14:26
447fc8a to
ce0c0da
Compare
Replace `cartesi.toml` with a `cartesi.config.ts` file that exports its configuration through `defineConfig`, imported from `@cartesi/cli/config`. The helper does nothing at runtime, and exists so the configuration is type checked and completed by the editor, without any annotation. A configuration file may also export a function, which receives the command being run and the mode, so a project can configure itself differently for `build` and `run`. TypeScript configuration files are imported by the runtime itself, so there is no build step and no extra dependency: the standalone binaries run on bun, and node strips the types from the version this package requires. Applications not written in TypeScript or JavaScript describe the same configuration as plain data, in a `cartesi.config.json`, `cartesi.config.yaml` or `cartesi.config` file, the last one read as YAML so it accepts JSON too. Those are not type checked, so `config/normalize.ts` validates every value, and, as the TOML parser does, rejects a key no section reads, which turns a misspelled option into an error instead of silence. `$schema` is allowed, so a JSON or YAML file can point an editor at a schema. The configuration gained a `run` section with the project defaults of the local development environment, so they do not have to be repeated on every `cartesi run`. Command line options take precedence over it, which is why the commander defaults were moved into `run` itself. `cartesi.toml` keeps working, and is read when a project has no other configuration file, but is deprecated and prints a warning. The configuration modules the new formats share with the deprecated one grew to fit: the errors and the size parsing now take a value from any format rather than a TOML one, the size parsing moves to `config/size.ts` beside `splitSize`, and the top-level TOML parse moves to `config/toml/parse.ts` so `config.ts` is only a barrel and nothing imports it in a cycle. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BHFyMTf1k57qtDwcbwVjrs
tuler
force-pushed
the
claude/define-config-function-7hq2t0
branch
from
November 3, 2026 16:07
ce0c0da to
16d0c66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces
cartesi.tomlwith acartesi.config.tsfile that exports its configuration throughdefineConfig, in the style of rolldown and tsdown, so an application can be configured without reaching for the programmatic API.defineConfigdoes nothing at runtime: it exists so the configuration is type checked and completed by the editor, without any annotation. A configuration file may also export a function, which receives the command being run and the mode, so a project can configure itself differently forbuildandrun:Based on #512, which it builds directly on top of.
Key Changes
defineConfigand the input types (config/user.ts), exported from a new@cartesi/cli/configsubpath so a configuration file does not pull in the rest of the CLI. Also re-exported from the main entrypoint.Applications not written in TypeScript describe the very same configuration as plain data. The configuration file of a project is the first of these that exists:
cartesi.config.ts,.mts,.cts,.js,.mjs,.cjsdefineConfig({ ... })cartesi.config.jsoncartesi.config.yaml,cartesi.config.ymlcartesi.configcartesi.tomlconfig/load.tsfinds and reads it;config/normalize.tsvalidates it. Those formats are not type checked, so every value is checked there and, as the TOML parser does, a key no section reads is an error rather than silence — a misspelledramLenghtis reported with the keysmachineaccepts.$schemais allowed, so a JSON or YAML file can point an editor at a schema.runsection: project level defaults of the local development environment (epochLength,services,blockTime,forkUrl,projectName, ...), so they do not have to be repeated on everycartesi run. Command line options take precedence, which is why the commander defaults moved intorunitself; the layering is a pureresolveRunOptionsfunction.cartesi.tomlkeeps working, and is read when a project has no other configuration file, but is deprecated and prints a warning.The shared configuration modules grew to fit two kinds of input: the errors and the size parsing now take a value from any format rather than a TOML one,
parseSize/parseBytesmove toconfig/size.tsbesidesplitSize, and the top-level TOML parse moves toconfig/toml/parse.tssoconfig.tsis only a barrel and nothing imports it in a cycle.CLAUDE.mdis updated to match.Notable Implementation Details
path.extnamereads a file with no format in its name, such ascartesi.config, as.config, which is handled as YAML.Configis a validUserConfig, so it can be given straight back toresolveConfig, and normalizing it again is idempotent. Keys are camelCase, as the resolved configuration already is; thewithdrawalkeys keep the names thecartesi-rollups-cliexpects.runshell relies on.Behavior Changes
resolveConfigis now asynchronous, since a configuration file has to be imported, and itsconfigoption accepts a configuration written inline, in the same shape acartesi.config.tsfile exports.getProjectSdkand the withdrawal resolution inrun()became asynchronous with it;getProjectSdkkeeps reporting an invalid configuration rather than falling back to the default image.-c/--configdefaults to looking the configuration file of the project up, rather than tocartesi.toml. An explicitly given file that does not exist is an error, as before.--default-blockwarning moved from theruncommand intorun(), where the resolved value is known, and is silenced along with the rest of the progress output.Testing
Linting, type checking and 467 unit tests pass. The 383 tests of the base branch all still pass; the other 84 are new, covering
defineConfig, normalization and validation of every section (drives, nvrams, the accounts drive,withdrawal,run), unknown keys, size parsing, file discovery and precedence, loading each supported format, merging a list of files, and the layering of therunoptions.The base's
should parse every key of full.tomlexpectation gainsrun: {}, which is the check working as its comment intends: the deprecated format has no[run]section, so it always defaults.End to end, against the built artifacts rather than the sources: a TypeScript configuration exporting a function was loaded through
dist/lib.jswith nvrams, an accounts drive andwithdrawaloverrides resolving correctly, and the compiledlinux-x64binary read the TypeScript, JSON (with$schema), YAML, barecartesi.configand deprecated TOML files, reporting an unknown key and an invalid nvram size as a single line each. Docker was not available in the development environment, so the build itself was only exercised up to the point where it shells out.One note for the maintainer, not introduced here: the messages of
InvalidWithdrawalConfigErrorandInvalidAccountsDriveErrorname the TOML spellings (accounts_drive = true), which read oddly for acartesi.config.ts. They are left as they are because the base branch's tests assert the exact strings.Also still easy to add later: a generated JSON Schema for
$schemadriven completion in the data formats, and the application templates, which live in another repository.🤖 Generated with Claude Code
https://claude.ai/code/session_01BHFyMTf1k57qtDwcbwVjrs