Skip to content

Conversation

@gagik
Copy link
Collaborator

@gagik gagik commented Oct 31, 2025

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.

gagik added 8 commits October 31, 2025 11:01
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.
@gagik gagik requested a review from a team as a code owner October 31, 2025 12:16
@gagik gagik force-pushed the gagik/schema-default branch from 3da9497 to c98c875 Compare October 31, 2025 12:18
Base automatically changed from gagik/readme-generate to main October 31, 2025 13:17
Copilot AI review requested due to automatic review settings October 31, 2025 13:19
Copy link
Contributor

Copilot AI left a 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 defaultUserConfig object 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

@coveralls
Copy link
Collaborator

coveralls commented Oct 31, 2025

Pull Request Test Coverage Report for Build 18973895821

Details

  • 212 of 220 (96.36%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 80.045%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/common/config.ts 55 56 98.21%
src/common/configUtils.ts 53 60 88.33%
Totals Coverage Status
Change from base Build 18973742580: 0.08%
Covered Lines: 6440
Relevant Lines: 7920

💛 - Coveralls

@gagik gagik merged commit f56f772 into main Oct 31, 2025
19 checks passed
@gagik gagik deleted the gagik/schema-default branch October 31, 2025 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants