Repository navigation
Harden the plugin code with types and contract checks - #7
Merged
Merged
Conversation
Make wrong code fail in CI before review: - Fix a race: two listings raised together share one tools decision. Each decision goes to session memory before the write, so later reads in the same dispatch see it. - Keep the /loadout words in one COMMANDS record. The command switch ends with `satisfies never`, and the listing test runs each word. - Write code per listing kind as a Record<Kind, ...> map or as an exhaustive switch. - Use Object.hasOwn in statusOf, so a group named like an object key is not read as kept. - Rename the effort atom to effortState, because its shape changed. - Add tests/contract.check.mjs: module state, kind branches, casts in tests, option reads and the command doc. CI runs it. - Type-check only against the engine types in .claude-plugin/types/, which git does not track. CI cannot run tsc: it has no login. - Add tests/kit.ts with typed builders for hook inputs. - Raise the version to 0.6.4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
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
This PR adds types and checks so that wrong plugin code fails before review.
/loadoutwords.COMMANDSinhooks/scope.tsholds every word. Thecommand.runswitch ends insatisfies never, and the listing test runs each word. The command description, the usage text andcommands/loadout.mdcome from this list.Record<Kind, ...>map or a switch withdefault: return kind satisfies never.statusOfusesObject.hasOwn. Thus a group namedconstructoror__proto__is not read as a built-in object key.effortatom is noweffortState, because its shape changed.tests/contract.check.mjs. It checks these rules, and CI runs it:as constreadOptions(raw)commands/loadout.mdshows the words ofCOMMANDSTraceLinetests/kit.ts. It has typed builders for hook inputs and fake replies.The type check still runs only on a contributor's machine, against
.claude-plugin/types/. CI cannot make these types without a login, and the repo does not store a copy.Test plan
claude plugin validate .passes, with the CLAUDE.md warning only.claude plugin test .: 57 pass. This includes a new test for the race. It fails without the fix.node tests/docs.check.mjspasses.npx -p typescript@7.0.2 tsc -p tsconfig.jsonpasses.node tests/contract.check.mjspasses. Its self-test shows that each rule catches a bad example and accepts a good one.node tests/smoke.e2e.mjs: all 8 checks pass./verifyin real Claude Code:/loadout,list,keep,unkeep, a barekeepand an unknown word give the correct output.effort offandeffort onwork.🤖 Generated with Claude Code