fix: add a typecheck gate and fix the 14 errors it found - #168
Merged
Conversation
Nothing in this repo runs `tsc`. tsup transpiles through esbuild without typechecking, lint is oxlint and format is dprint, so type errors have been accumulating unnoticed. `tsc --noEmit` reports 14 of them, identical under TypeScript 6.0.3 and 7.0.2 - none are upgrade fallout. Two are real bugs: - tools/browser/browserClickTool.ts: puppeteer calls the option `count`, not `clickCount`. The unknown key was silently dropped, so the tool's clickCount parameter never worked and every request single-clicked. - agent/runAgentForOnePass.ts: `stream.state._maxTurns` is `number | null` upstream, but `trackedState.maxTurns` is `number` and feeds the `currentTurn + 1 >= maxTurns` guard. A null would have made that guard fire immediately and abort the run. Now falls back to the configured limit, and the change-detection comparison uses the same normalized value so it can't get stuck dirty. The rest are correctness-neutral: - ink/components/BlinkingTextInput.tsx used `wrap="end"`, which is not a valid Ink wrap value. Ink matches "wrap", "hard", and anything starting with "truncate", so "end" fell through every branch and the text was passed through untouched. Changed to `truncate-end`, which is what the name was reaching for. **This is a real behavior change** - that text is now truncated to the box width instead of overflowing it. Flagging it for review; if the intent was to leave the text alone, `wrap="wrap"` would preserve today's rendering more closely. - tools/files/applyPatchTool.ts threaded a bare `string` where getHarperSkillTool accepts a union of skill names. Now derives `HarperSkillName` from the exported list, with no casts. - The four configurationWizard test files omitted required props (`defaultValue`, and `onExit` for ProviderStep). Passing `""` matches the undefined they were effectively getting, so behavior is unchanged - the tests pass identically before and after. Adds `npm run typecheck` and a Typecheck job to Verify PR so this stays at zero. Verified: typecheck, lint, format, build, and 53 files / 345 tests all pass.
There was a problem hiding this comment.
Code Review
This pull request introduces several fixes and improvements, including correct handling of nullish _maxTurns in the agent runner, updating text wrapping to "truncate-end" in BlinkingTextInput, adding a "typecheck" script, and refining TypeScript types in applyPatchTool. It also updates various wizard component tests to include missing props. However, a critical issue was identified in browserClickTool.ts where changing the Puppeteer click option from clickCount to count is incorrect and will cause multi-click requests to fail.
|
🎉 This PR is included in version 0.16.53 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
1 task
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.
Nothing in this repo runs
tsctsup transpiles through esbuild without typechecking, lint is oxlint, format is dprint. So type errors have been accumulating unnoticed.
tsc --noEmitreports 14.They are identical under TypeScript 6.0.3 and 7.0.2 — I diffed the two runs, zero difference either way. None of this is TS 7 fallout; it's just never been checked.
Two are real bugs
tools/browser/browserClickTool.ts:14— puppeteer calls the optioncount, notclickCount:The tool exposes a
clickCountparameter to the model and describes it as "The number of times to click." Puppeteer ignored the unknown key, so every request single-clicked — double-click has never worked.agent/runAgentForOnePass.ts:219,321—stream.state._maxTurnsisnumber | nullupstream, whiletrackedState.maxTurnsisnumberand feeds this guard:A null would make
currentTurn + 1 >= nulltrue immediately and abort on the first turn. Now falls back to the configured limit, and the change-detection comparison uses the same normalized value so it can't get stuck permanently dirty.One is a behavior change — please look at this one
ink/components/BlinkingTextInput.tsxusedwrap="end", which is not a valid Ink wrap value. Ink'swrapTextmatches"wrap","hard", andstartsWith("truncate")—"end"falls through all three, so the text was passed through untouched, neither wrapped nor truncated.I changed it to
truncate-end, which is what the name was reaching for (Ink's own truncate default isposition: 'end'). That means the text is now truncated to the box width instead of overflowing it. There are no tests for this component, so it's worth an eyeball. If the intent was genuinely "leave the text alone",wrap="wrap"is closer to today's rendering.The rest are correctness-neutral
tools/files/applyPatchTool.tsthreaded a barestringwheregetHarperSkillToolaccepts a union of skill names. Now derivesHarperSkillNamefrom the exported list — no casts, noany.configurationWizardtest files omitted required props (defaultValue, plusonExitforProviderStep). Passing""matches theundefinedthey were effectively getting, so rendering is unchanged — the tests pass identically before and after.The gate
Adds
npm run typecheckand aTypecheckjob to Verify PR, so this stays at zero.Verification
🤖 Generated with Claude Code