ISSUE-354: Resolve declarative settings doctor checks from the project scope - #357
Merged
Merged
Conversation
- hookEventExists and settingsKeyEquals now read project settings.local.json before global settings.json, so project-scoped packs are verified against the file their artifacts were actually written to - Report settings files that exist but cannot be parsed instead of discarding the error and falling through silently - Warn from mcs pack validate when a check declares scope on a type that ignores it
- Newer SwiftFormat releases wrap single-line `if x { return y }` bodies,
which this codebase writes inline throughout — a clean main fails
`swiftformat --lint --strict .` on 20 files under 0.62.1
- Declares the existing style in config rather than pinning the tool version,
so the check is stable across SwiftFormat upgrades
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
The declarative
hookEventExistsandsettingsKeyEqualsdoctor checks read the global~/.claude/settings.jsonunconditionally. Project-scoped sync writes hook entries and settings keys to the project'ssettings.local.json, so for any project-scoped pack these checks were pointed at a file their artifacts were never written to — passing when the global file happened to hold the event or key, failing when the pack had installed correctly. Both directions were silent.Also carries a one-line formatting-config fix, because a clean
maincurrently fails the lint job and this PR would otherwise be red for reasons unrelated to it.Closes #354
Changes
settings.local.jsonbefore the globalsettings.json. That order matches Claude Code's own precedence, so the check reports on the configuration actually in effect; doctor output names the file that answered.mcs pack validatewarns when a pack declaresscopeon a check type that ignores it.scopeselects the base directory for an author-suppliedpath, so it only ever applied to the four path-based check types — the schema docs advertised it as universal, which is how two types came to accept and quietly discard it.wrapIfStatementBodiesSwiftFormat rule. Newer releases wrap single-lineif x { return y }bodies, which this codebase writes inline throughout, so a cleanmainfailsswiftformat --lint --strict .on 20 files, 109 violations, all from that one rule. The lint job installs SwiftFormat unpinned, so this is a moving target; declaring the existing style in config keeps the check stable across upgrades, where pinning the tool version would freeze the repo on an old release and still leave localswiftformatruns rewriting unrelated lines.Test plan
swift testpasses locallyswiftformat --lint .andswiftlintpass without violations —0/138 files require formatting(was 20 onmain), SwiftLint0 violationsmcs pack validatewas run against a real pack and emits the new warning.mcs sync/mcs doctorcould not be exercised safely:Environmentresolves the home directory viaNSHomeDirectory(), which ignoresHOME, so a sandboxed CLI run would read and write the real~/.mcsand~/.claude. Covered instead by integration tests that drive the runner with an injected sandbox environment, asserting both a pass when the event exists only in the project file and a failure when it exists nowhere.To verify manually in a scratch project: sync a pack whose check is
hookEventExists, confirm the hook lands in<project>/.claude/settings.local.jsonand not in~/.claude/settings.json, then runmcs doctor→ expect a pass readingregistered in settings.local.json(this fails before the change). Move the event to the global file → expect a pass readingregistered in settings.json. Corrupt the project file → expect a warning naming it as unreadable.Checklist for engine changes
LifecycleIntegrationTestsorDoctorRunnerIntegrationTests)CLAUDE.md,docs/,techpack.yamlschema inExternalPackManifest.swift)