feat(cli): add --strict-config flag to reject unknown config keys#671
feat(cli): add --strict-config flag to reject unknown config keys#671grandmaster451 wants to merge 1 commit into
Conversation
Adds a `--strict-config` CLI option that propagates through the SDK and agent core so that `config.toml` is parsed with a strict Zod schema. Unknown keys at the top level and inside stable nested sections (permission, services, loop_control, background, thinking) are rejected with a clear config.invalid error. Provider and model alias tables remain open for custom fields. - Parse `KimiConfigStrictSchema` when `strictConfig` is enabled. - Keep strictness sticky across config reloads (getKimiConfig, setKimiConfig, removeKimiProvider, provider manager reload). - Add CLI flag and forward it through `createKimiHarness` / `KimiCore`. - Add unit tests for CLI parsing and strict config validation.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e58d9e179b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const transformed = transformTomlData(data); | ||
| transformed['raw'] = raw; | ||
|
|
||
| const schema = options.strict ? KimiConfigStrictSchema : KimiConfigSchema; |
There was a problem hiding this comment.
Reject unknown top-level tables in strict config
When --strict-config is used, this parses the already-transformed object, but transformTomlData drops any unrecognized top-level table because object-valued keys only get copied for known sections. As a result, a config like [typo]\nkey = "value" is silently accepted even though the flag is meant to reject unknown top-level keys; validate the raw top-level keys or carry unknown table sections through before applying the strict schema.
Useful? React with 👍 / 👎.
Adds a
--strict-configCLI option that propagates through the SDK and agent core so thatconfig.tomlis parsed with a strict Zod schema.Unknown keys at the top level and inside stable nested sections (permission, services, loop_control, background, thinking) are rejected with a clear
config.invaliderror. Provider and model alias tables remain open for custom fields.Changes
KimiConfigStrictSchemawhenstrictConfigis enabled.getKimiConfig,setKimiConfig,removeKimiProvider, provider manager reload).createKimiHarness/KimiCore.Testing
pnpm vitest run packages/agent-core/test/config/configs.test.tspnpm vitest run apps/kimi-code/test/cli/options.test.tspnpm run typecheckinpackages/agent-core,packages/node-sdk, andapps/kimi-code