-
Notifications
You must be signed in to change notification settings - Fork 154
chore: get default user config from schema #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This removes a lot of boilerplate validation code and makes the UserConfigSchema the main entry point for our parsing. There's actually a couple more follow-ups I want to do with i.e. storing secrets but don't want to make this too big.
3da9497 to
c98c875
Compare
…gagik/schema-default
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the configuration system to use the UserConfigSchema as the single source of truth for default values and validation, eliminating boilerplate validation code previously done manually. The schema now handles parsing, validation, and default value generation through Zod, streamlining the configuration setup process.
Key Changes:
- Replaced the hardcoded
defaultUserConfigobject with schema-based defaults - Added preprocessing and validation directly to the Zod schema
- Consolidated configuration utilities into separate modules for better organization
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/common/config.ts |
Removed defaultUserConfig object and manual validation logic; now uses UserConfigSchema.safeParse() for all validation |
src/common/schemas.ts |
New file containing shared type definitions for PreviewFeature and Similarity |
src/common/configUtils.ts |
New file extracting utility functions from config.ts including path getters and validation helpers |
src/common/argsParserOptions.ts |
New file extracting argument parser options from config.ts |
tests/unit/common/config.test.ts |
Updated tests to use UserConfigSchema.parse({}) instead of defaultUserConfig; added test to verify schema defaults |
tests/unit/common/roles.test.ts |
Updated to use UserConfigSchema.parse({}) for default config |
tests/unit/toolBase.test.ts |
Updated import to use PreviewFeature from schemas.ts |
src/tools/tool.ts |
Updated import to use PreviewFeature from schemas.ts |
src/tools/mongodb/create/createIndex.ts |
Updated to use similarityValues from schemas.ts instead of similarityEnum |
src/common/search/vectorSearchEmbeddingsManager.ts |
Removed similarityEnum definition, now using type from schemas.ts |
src/lib.ts |
Removed exports of defaultUserConfig and configurableProperties |
scripts/generateArguments.ts |
Updated to generate defaults from schema instead of defaultUserConfig |
tests/integration/build.test.ts |
Removed defaultUserConfig from expected exports |
eslint-rules/enforce-zod-v4.js |
Added schemas.ts to allowed Zod v4 imports |
Pull Request Test Coverage Report for Build 18973895821Details
💛 - Coveralls |
This removes a lot of boilerplate validation code and makes the UserConfigSchema the main source of truth for our parsing. The only part which is still "unsafe" is arguments we haven't defined in the schema which are part of arg-parser options. But those are also the args we don't use directly.
There's actually a couple more follow-ups I want to do with i.e. storing secrets but don't want to make this too big.