Skip to content

fix(fix): assisted Stripe fixes on real repositories - #87

Merged
lucasbraum merged 1 commit into
mainfrom
claude/fix-agent-imports-grouping-tests
Oct 12, 2026
Merged

lucasbraum merged 1 commit into
mainfrom
claude/fix-agent-imports-grouping-tests

Conversation

@lucasbraum

Copy link
Copy Markdown
Collaborator

What and why

On boxyhq/saas-starter-kit at abc9b68, uptide fix stripe --max-cost 3 ended with 5 manual sites, 0 agent fixes, types 4 → 4, and "baseline tests failed", even though npm test passes there. This PR fixes the five causes.

  1. Import guidance. The guide required import { subscriptionPeriod } from "../../../lib/stripe.ts", which fails with TS5097. A new importSpecifier (packs/import-specifier.ts) picks the specifier in this order:

    • a tsconfig paths alias that the file or its neighbours already import through (extends is followed). Here that gives @/lib/stripe, because the file already imports @/lib/env.
    • otherwise an extensionless relative path.
    • .js only when the file's own relative imports use it, or the module resolution (node16/nodenext) requires an extension.
    • .ts only when the file's relative imports use it and allowImportingTsExtensions (or rewriteRelativeImportExtensions) is set.

    The guide now offers this spelling as a suggestion, not a requirement: any specifier that resolves to the module and compiles is accepted. The Stripe API-version follow-up import (clientPins) uses the same function.

  2. Diagnostics across line shifts. newDiagnostics now takes LineMoves, the old line → new line mapping for the lines an edit kept, built from a common head/tail plus an LCS of the middle. A pre-existing error that an added import moves from line 86 to 87 now matches its old self. Lines the edit changed are never remapped, so any error on them still counts as new. Agent acceptance uses this mapping, including the check that a site's own diagnostic is really gone and not just shifted. fix, pin, reverify and the action use it too, via gitLineMoves.

  3. Group sites. Manual sites in the same file with the same rule (or the same change path, when no rule is set) now go to the agent as one task:

    • every member's diagnostic is in sharedDiagnostics, and every enclosing function is in the context;
    • the task is accepted only when all of them are gone;
    • each site keeps its own report entry ("same change in this file as …").

    Also in this item:

    • The Stripe guide's "Patch ONLY the current reported site" and the system prompt now cover the grouped sites.
    • diagnosticFor now breaks ties on the message. Line 117 carries two TS2339 errors (_start and _end), and both sites used to pick the same one.
  4. Baseline tests. The cause was argument order, not sync-stripe.js. Jest reads --testPathIgnorePatterns as an array, so it swallowed the files that followed it, and Jest then failed with "The --findRelatedTests option requires file paths to be specified." Files now come right after --findRelatedTests. When a related-tests run fails before running any test, or finds no related test, the repository's own suite runs instead: its test script (after pretest when relevant), or the unit-test run over the workspace when service tests are excluded. A failing test is never re-run under a wider command. The report says which command failed or found nothing, shows its output (last 40 lines), and names what ran instead.

  5. Version. Reports showed the private engine's 0.1.0. They now show the published CLI version: the value of __UPTIDE_CLI_VERSION__ in the bundle, or packages/cli/package.json when run from source.

How it was verified

  • pnpm lint, pnpm typecheck and pnpm test all pass: core 1203 passed / 28 skipped, CLI 393 passed.

  • New tests:

    • import-specifier.test.ts: alias used by the file, alias used by a neighbour through extends, extensionless, .ts only when allowed, .js, nodenext.
    • Line-shift regression: an assisted edit that adds an import above a pre-existing error it leaves alone is accepted, and the error is still reported, one line down.
    • Grouping: one request for two sites, both enclosing functions shown, both sites accepted.
    • Jest argument order.
    • Fallback when the scoped run fails, when it finds no tests, and when the suite fails too; a failing related test is never retried wider.
  • saas-starter-kit abc9b68 with the built CLI, fix stripe --max-cost 3, no --pr:

    • Tests: ✅ 4 tests passed before and after. The related run found no tests, so the unit suite ran, and the report shows both commands.
    • Report: "Uptide 0.7.4".
    • Guide import for pages/api/webhooks/stripe.ts: @/lib/stripe.
    • Types stayed 4 → 4, only because this environment has no LLM API key. I could not run a real agent here.
  • To exercise the agent path without a key, I ran the real fix pipeline on a copy of the repo with a scripted fixer that edits the way the guide asks:

    • one request covered all four period diagnostics (85, 86, 117 ×2);
    • the edit added import { subscriptionPeriod } from '@/lib/stripe' above the pre-existing errors and was accepted;
    • types after the bump went to 0, and tests passed before and after.

    This shows grouping, line-shift matching and the specifier working together. It does not show what a real model writes. That still needs a run with a key: npx uptide fix stripe --max-cost 3 on that commit.

Checklist

  • Tests added or updated
  • Changeset added (patch)
  • Commits signed off

🤖 Generated with Claude Code

https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi


Generated by Claude Code

Found on boxyhq/saas-starter-kit at abc9b68, where `fix stripe` ended
with 0 agent fixes, types 4 -> 4 and "baseline tests failed".

- Import guidance: the helper's specifier is written the way the file's
  neighbours write imports (a tsconfig `paths` alias they already use,
  else an extensionless relative path; .js/.ts only where the repo does).
  The guide suggests it and no longer requires a spelling; compiling
  decides. The `.ts` it mandated failed TS5097.
- Diagnostics are compared through the edit's line moves, so an import
  added above a pre-existing error no longer makes that error "new".
  Used by agent acceptance and by fix, pin, reverify and the action.
- Sites of the same change in one file go to the agent as one task with
  every enclosing function shown, and are accepted together; each keeps
  its report entry.
- Jest: affected files come before the array-valued
  --testPathIgnorePatterns, which swallowed them. When a related-tests
  run fails before any test, or finds none, the repository's own suite
  runs; the report shows the scoped command and its output.
- Reports print the published CLI version, not the engine's 0.1.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01B2T8GmEVnZwfNrugajEMqi
Signed-off-by: Claude <[email protected]>
@lucasbraum
lucasbraum merged commit 158d68e into main Oct 12, 2026
8 checks passed
@lucasbraum
lucasbraum deleted the claude/fix-agent-imports-grouping-tests branch October 12, 2026 18:00
lucasbraum added a commit that referenced this pull request Oct 12, 2026
#87 fixed the jest argument order and the related-tests fallback on main,
and matches diagnostics across line moves (gitLineMoves). Main's versions
are kept; this branch's duplicate jest fix and its changeset are dropped.
The SDK gate now uses gitLineMoves too, so a task that passes its gate is
judged the same way by the final verdict; newDiagnosticsAcrossShifts is
gone. The incremental typeChecker and the related-tests mode for the SDK
gates are kept on top of main's verify.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Lucas Braum <[email protected]>
@uptide-release uptide-release Bot mentioned this pull request Oct 12, 2026
lucasbraum added a commit that referenced this pull request Oct 13, 2026
…ace (#96)

## What and why

#87 sends manual sites of the same rule in one file to the patch agent
as one task. But the task can edit only the first site's related
declarations.

On alanagoyal/alanagoyal @ 22aa5f1 (React 19),
`components/apps/notes/notes-app.tsx` has two `RefObject<HTMLDivElement
| null>` errors, at lines 91 and 119. Their fixes live in two different
files: the `containerRef` prop types of the mobile presenter and of the
desktop presenter. Grouped, the agent could reach only the mobile one,
and the task is accepted only when both errors are gone. It answered "No
patch submitted" three times, and both sites stayed manual. The default
agent went from 12/12 sites and 3/3 verified before #87 to 10/12 and 0/3
after.

Sites now group only when they share both:
- **the root cause:** the same rule, or the same change path when there
is no rule (as before);
- **the likely fix location:** the same repository declarations behind
their compiler errors, or none.

saas-starter-kit's two period reads (#87's case) link to no repository
declaration, so they still go out as one task. Two prop types in two
files are two tasks.

## Test

`related-declaration.test.ts` reproduces the alanagoyal layout with the
real compiler:
- two presenters' prop files and one call site with two TS2322 errors of
the same rule;
- a fixer that widens whatever prop types its request lets it edit.

It expects two requests (`mobile.ts`, then `desktop.ts`) and both sites
fixed. Against main's `assisted.ts` it fails with three requests, all
limited to `mobile.ts`. #87's grouping test still passes.

`pnpm typecheck`, `pnpm lint` and `pnpm public:check` pass, and `pnpm
test` gives CLI 413 passed and core 1,290 passed. The one core failure
was an assisted test that timed out in the full parallel run, with the
machine at load 15 under another benchmark. It passes alone and with its
file, and it doesn't exercise grouping.

## alanagoyal, default agent, 3 runs

**Pending**, run once the machine is quiet. Target: 12/12 sites, 3/3
verified.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Lucas Braum <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants