feat: add rulesync doctor command for config diagnostics - #2491
Merged
Conversation
Adds a read-only 'rulesync doctor' command that diagnoses the configuration files (rulesync.jsonc / rulesync.local.jsonc) and reports problems grouped by severity. This is the first slice of #2446, covering the config-file checks: - JSONC parse errors with line/column - Unknown or misspelled top-level keys with did-you-mean suggestions (the config schema is non-strict, so these are otherwise silently ignored) - Unknown tool targets and features with nearest-name suggestions - Deprecated 'ignore' feature warning - Object-form targets combined with features, including conflicts that only appear after merging base and local config files - Conflicting target pairs - $schema presence and currency - Structural schema violations via ConfigFileSchema - sources[].tokenEnv pointing at an unset environment variable - inputRoot pointing at a nonexistent directory Exit code is 1 when errors are present (or warnings with --strict); the global --json flag emits structured diagnostics. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Scope test-fixture typo words to doctor.test.ts via cspell:ignore instead of the global cspell dictionary - Add CLI-level e2e spec (e2e-doctor.spec.ts): clean-config exit 0, missing config, misspelled-key exit 1, --strict, --json success and failure documents - Reuse GITIGNORE_DESTINATION_KEY exported from config.ts instead of hard-coding the per-feature extra key - Derive deprecated-feature diagnostics from a new DEPRECATED_FEATURE_REPLACEMENTS map in features.ts - Simplify collectMergedConfigDiagnostics: drop the unreachable assertTargetsFeaturesExclusive round-trip - Read each config file once and share the content between per-file and merge checks - Strip control characters from config-derived strings before terminal output - Skip per-diagnostic logging in JSON mode so the error document keeps its DOCTOR_FAILED code Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
In JSON mode a failing doctor run previously kept only the summary string in error.message, dropping the structured diagnostics that CI and editors need most when something is wrong. CLIError now carries an optional structured details payload that JsonLogger.error propagates into error.details, and doctorCommand attaches the diagnostics and severity summary to the DOCTOR_FAILED error. The e2e failure-path test now pins the propagation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
Author
|
@dyoshikawa Thank you! |
This was referenced Jul 30, 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
First slice of #2446: adds a read-only
rulesync doctorcommand that diagnoses the configuration files (rulesync.jsonc/rulesync.local.jsonc) and reports problems grouped by severity (error/warning/info).Closes #2446 (config-file check group; input-tree and workspace check groups are follow-ups as noted in the issue).
Why
Today the only feedback channel for a broken setup is
rulesync generate. BecauseConfigFileSchemais non-strict, a misspelled key such as"target"instead of"targets"is silently swallowed and generation quietly falls back to defaults.doctorgives a single, fast, read-only answer to "is my configuration correct?" — usable both as a first troubleshooting step and as a CI guard.What it checks
ConfigFileSchema(no hard-coded key list)ignorefeature (warning)targetscombined withfeatures, including the case where the conflict only appears after merging base and local config filesCONFLICTING_TARGET_PAIRS)$schemapresence (info) and currency (warning)ConfigFileSchema.safeParsesources[].tokenEnvnaming an unset environment variable (warning)inputRootpointing at a nonexistent directory (error)UX
1when any error is present;--strictmakes warnings fatal for CI-j, --jsonflag (diagnostics + severity summary as structured data)-c, --config,-V, --verbose,-s, --silentwired like other commandsExample
Tests
--strict,--config, JSON capture, base+local merge conflictpnpm cicheckpasses🤖 Generated with Claude Code