feat: add counterfact.yaml config file support with --config option#1723
Merged
pmcelhaney merged 8 commits intomainfrom Apr 9, 2026
Merged
feat: add counterfact.yaml config file support with --config option#1723pmcelhaney merged 8 commits intomainfrom
pmcelhaney merged 8 commits intomainfrom
Conversation
Closed
Copilot
AI
changed the title
[WIP] Add support for counterfact.yaml configuration file
feat: add counterfact.yaml config file support with --config option
Apr 8, 2026
pmcelhaney
requested changes
Apr 8, 2026
Collaborator
pmcelhaney
left a comment
There was a problem hiding this comment.
Use usingTemporaryFiles() for the test.
Contributor
Author
Done in 4f14c8f — replaced the manual |
pmcelhaney
approved these changes
Apr 8, 2026
pmcelhaney
requested changes
Apr 9, 2026
Collaborator
pmcelhaney
left a comment
There was a problem hiding this comment.
Add documentation in usage.md
Agent-Logs-Url: https://github.com/counterfact/api-simulator/sessions/06e4d189-e8a0-4d82-88ba-b3c2cd8c4a01 Co-authored-by: pmcelhaney <51504+pmcelhaney@users.noreply.github.com>
Contributor
Author
Done in 746b53e — added |
pmcelhaney
approved these changes
Apr 9, 2026
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
CLI options were becoming unwieldy to pass on every invocation. This adds a
counterfact.yamlconfig file as an alternative — any CLI option can now be set there, with command-line flags always winning on conflict.Use
--config <path>to point at a non-default location.Original Prompt
The options in the command line are getting unwieldy. It's time to support a counterfact.yaml file as an alternative way to set configuration.
Follow common conventions, e.g. --config to set an alternate config file path; when there's a conflict, command line settings override config file settings
Manual acceptance tests
counterfact.yamlin the current directory starts the server using config values (e.g.port: 8080overrides the default 3100)--port 9000) overrides the same key set incounterfact.yaml--config ./path/to/other.yamlloads options from the specified file instead ofcounterfact.yaml--config ./nonexistent.yamlexits with a clear "Config file not found" errorcounterfact.yamlpresent and no--configflag → startup proceeds normally with CLI/default valuesproxy-url,always-fake-optionals) are recognised correctlyTasks
src/util/load-config-file.ts: reads and parses YAML, normalises kebab-case keys to camelCase, returns{}when default file is absent, throws when a required file is missingbin/counterfact.js: importsloadConfigFile, adds--config <path>Commander option, merges file config into options before buildingConfigusingprogram.getOptionValueSource()to detect explicit CLI flagstest/util/load-config-file.test.tsusingusingTemporaryFiles()per project conventionREADME.mdandbin/README.mdwith the new option and example configdocs/usage.md: added--configto the CLI reference block and a new "Using a counterfact.yaml config file"<details>section covering the example YAML, kebab-case key normalisation, custom config path, and missing-file behaviour