Skip to content

fix(agents,prompts): upgrade oxlint/oxfmt and resolve all lint errors#78

Open
zrosenbauer wants to merge 5 commits intomainfrom
fix/agents-lint-warnings
Open

fix(agents,prompts): upgrade oxlint/oxfmt and resolve all lint errors#78
zrosenbauer wants to merge 5 commits intomainfrom
fix/agents-lint-warnings

Conversation

@zrosenbauer
Copy link
Copy Markdown
Member

@zrosenbauer zrosenbauer commented Apr 8, 2026

Summary

  • Upgrade oxlint 1.57.01.59.0 and oxfmt 0.42.00.44.0
  • Fix all 173 new require-mock-type-parameters errors — added type params to every vi.fn() call
  • Fix prefer-import-meta-properties — use import.meta.dirname instead of dirname(fileURLToPath(...))
  • Fix prefer-called-exactly-once-with — combine assertion pairs
  • Fix multiline-blocks — expand single-line JSDoc
  • Fix prefer-lowercase-title and prefer-describe-function-title (pre-existing warnings)

Changes

  • 20 files changed across @funkai/agents and @funkai/prompts
  • package.json + lockfile updated for version bumps

Test plan

  • pnpm exec oxlint — 0 warnings, 0 errors
  • pnpm typecheck — passes
  • pnpm test --filter=@funkai/agents — 665 tests pass
  • pnpm test --filter=@funkai/prompts — 35 tests pass
  • pnpm format:check — all files formatted

- Lowercase `describe` title for StepFinishEvent to satisfy prefer-lowercase-title
- Append `()` to function-named describe titles to avoid prefer-describe-function-title

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
funkai Ready Ready Preview, Comment Apr 10, 2026 11:17pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

🦋 Changeset detected

Latest commit: f994b47

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: a71ee96b-ecd3-4390-b53f-588aa12d8d1e

📥 Commits

Reviewing files that changed from the base of the PR and between 53c2924 and f994b47.

📒 Files selected for processing (1)
  • packages/agents/src/lib/middleware.test.ts

📝 Walkthrough

Walkthrough

Many test files had Vitest mocks tightened with explicit TypeScript generics; three type-test suite labels were renamed; PARTIALS_DIR now uses import.meta.dirname; minor JSDoc formatting was updated. No exported/public API signatures or runtime behavior were changed.

Changes

Cohort / File(s) Summary
Test mock typings (agents & hooks)
packages/agents/src/core/.../*.test.ts, packages/agents/src/core/agents/.../*.test.ts, packages/agents/src/core/agents/flow/steps/*/*.test.ts, packages/agents/src/lib/*.test.ts, packages/agents/src/integration/lifecycle.test.ts, packages/agents/src/testing/logger.ts
Replaced many untyped vi.fn() usages with explicitly typed vi.fn<...>() generics for hooks, agent methods, middleware, stream helpers, logger spies, and other test doubles. A few assertions were adjusted (non-null assertions or consolidated call-count checks). Runtime behaviour unchanged.
Type test labels
packages/agents/src/core/types.test-d.ts
Renamed three Vitest describe(...) labels: StepFinishEventstepFinishEvent, createAgentStepFinishEventcreateAgentStepFinishEvent(), createFlowStepFinishEventcreateFlowStepFinishEvent(). No test bodies changed.
Prompts partials path
packages/prompts/src/partials-dir.ts
Switched PARTIALS_DIR computation from resolve(dirname(fileURLToPath(import.meta.url)), "../prompts") to resolve(import.meta.dirname, "../prompts"); export/signature unchanged.
JSDoc formatting
packages/agents/src/core/types.ts
Converted single-line JSDoc on AgentChainEntry.id to a multi-line doc block. Type and signature unchanged.
Misc (changeset & package devDeps)
.changeset/chubby-bars-pump.md, package.json
Added an empty changeset file; bumped devDependency versions for oxfmt and oxlint. No behavioral changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 28.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: upgrading oxlint/oxfmt and resolving all resulting lint errors across the codebase.
Description check ✅ Passed The description is directly related to the changeset, detailing the dependency upgrades, specific lint errors fixed, affected files, and comprehensive test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

- Upgrade oxlint 1.57.0 → 1.59.0, oxfmt 0.42.0 → 0.44.0
- Add type parameters to all vi.fn() calls (require-mock-type-parameters)
- Replace dirname(fileURLToPath()) with import.meta.dirname (prefer-import-meta-properties)
- Combine toHaveBeenCalledOnce + toHaveBeenCalledWith into toHaveBeenCalledExactlyOnceWith
- Expand single-line JSDoc to multiline (multiline-blocks)
- Fix describe title casing and function name matching

Co-Authored-By: Claude <noreply@anthropic.com>
@zrosenbauer zrosenbauer changed the title fix(agents): resolve oxlint warnings in type tests fix(agents,prompts): upgrade oxlint/oxfmt and resolve all lint errors Apr 10, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/agents/src/core/agents/base/agent.test.ts`:
- Around line 11-14: Replace the explicit any types and lint suppressions on the
top-level mocks: change the vi.fn generic signatures for mockGenerateText and
mockStreamText from vi.fn<(...args: any[]) => any>() to vi.fn<(...args:
unknown[]) => unknown>() and remove the corresponding eslint-disable comments;
this matches the pattern used in evolve.test.ts and preserves compatibility with
mockResolvedValue, mockImplementation and mockReturnValue.

In `@packages/agents/src/core/agents/flow/steps/all.test.ts`:
- Line 202: The mocks onError and onDone declared as vi.fn<() => void>() do not
match the callbacks' actual signatures (they receive event objects); update
those mocks in all.test.ts to include the event parameter in the generic, e.g.
change vi.fn<() => void>() for onError to vi.fn<(event:
<appropriateErrorEventType>) => void>() and for onDone to vi.fn<(event:
<appropriateDoneEventType>) => void>(), importing the correct event types from
the module that defines the flow event interfaces so the test enforces the real
callback contracts.

In `@packages/agents/src/core/agents/flow/steps/map.test.ts`:
- Line 190: The mocks onError and onFinish are typed as vi.fn<() => void>() but
the tests call them with event objects; update their typings so the mock
signatures match the hook contracts: change onError to vi.fn<(event: { id:
string; error: Error }) => void>() and onFinish to vi.fn<(event: { id: string;
result: unknown[]; duration: number }) => void>() (or use the concrete R type if
available) so TypeScript will enforce the correct payload shape in the tests
referencing onError and onFinish.

In `@packages/agents/src/core/agents/flow/steps/race.test.ts`:
- Line 170: The mocks for onError and onFinish are currently typed as vi.fn<()
=> void>() which loses the event payload typings; update the mocks to use the
actual event types used by the race step tests (for example, change onError to
vi.fn<(e: RaceStepErrorEvent) => void>() and onFinish to vi.fn<(e:
RaceStepFinishEvent) => void>()), importing those event type symbols from the
module that defines the race step hooks so assertions in the test are
type-checked against the real event shapes.

In `@packages/agents/src/core/agents/flow/steps/step.test.ts`:
- Line 169: The tests currently declare mock callbacks with no-arg signatures
(e.g., parentFinish, onFinish, onError) which strips the event payload types;
update each vi.fn declaration to accept the correct payload shape: type
parentFinish as (evt: StepFinishEvent) => void where StepFinishEvent includes
stepId, output, duration, etc.; type onFinish as (payload: { id: string; result:
unknown; duration: number }) => void; and type onError as (payload: { id:
string; error: Error }) => void; replace the nullary vi.fn<() => void>() calls
with vi.fn<typeof callbackSignature>() or vi.fn<(payload: PayloadType) =>
void>() so the compiler preserves the payload contracts used by the assertions.

In `@packages/agents/src/core/agents/flow/steps/while.test.ts`:
- Line 45: Mocks use nullary signatures but must match the actual typed
callbacks; update the Vitest mock generics and their implementations for
executeSpy, onError, and onFinish to the correct parameterized signatures: set
executeSpy as vi.fn< (params: { index: number; $: StepBuilder }) =>
Promise<string> >(async ({ index, $ }) => "value"), set onError as vi.fn<
(event: { id: string; error: Error }) => void | Promise<void> >(event =>
{/*...*/}) and set onFinish as vi.fn< (event: { id: string; result: string |
undefined; duration: number }) => void >(event => {/*...*/}); ensure each mock
implementation accepts and (if used) references the incoming parameter names so
the test types line up with while.execute, onError, and onFinish signatures.

In `@packages/agents/src/lib/middleware.test.ts`:
- Around line 13-14: The mocks doGenerate and doStream are typed as () =>
Promise<never>, which strips required parameters and true return types; update
these mocks to use the actual middleware/model hook signatures instead (import
and use the real hook types used in production tests—e.g., the Generate/Stream
hook types or the exported types for the middleware functions) and apply them to
vi.fn (for example vi.fn<GenerateHook>() / vi.fn<StreamHook>() or vi.fn<(args:
Parameters<GenerateHook>[0]) => ReturnType<GenerateHook>>), and make the same
change for the other occurrences at lines noted so the mocks preserve parameters
and return contracts for doGenerate and doStream.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: c9091344-d344-4366-be3c-0cfc15d66d68

📥 Commits

Reviewing files that changed from the base of the PR and between ce07596 and 465b814.

📒 Files selected for processing (20)
  • packages/agents/src/core/agents/base/agent.test.ts
  • packages/agents/src/core/agents/base/utils.test.ts
  • packages/agents/src/core/agents/evolve.test.ts
  • packages/agents/src/core/agents/flow/engine.test.ts
  • packages/agents/src/core/agents/flow/flow-agent.test.ts
  • packages/agents/src/core/agents/flow/steps/agent.test.ts
  • packages/agents/src/core/agents/flow/steps/all.test.ts
  • packages/agents/src/core/agents/flow/steps/each.test.ts
  • packages/agents/src/core/agents/flow/steps/factory.test.ts
  • packages/agents/src/core/agents/flow/steps/map.test.ts
  • packages/agents/src/core/agents/flow/steps/race.test.ts
  • packages/agents/src/core/agents/flow/steps/reduce.test.ts
  • packages/agents/src/core/agents/flow/steps/step.test.ts
  • packages/agents/src/core/agents/flow/steps/while.test.ts
  • packages/agents/src/core/types.ts
  • packages/agents/src/integration/lifecycle.test.ts
  • packages/agents/src/lib/hooks.test.ts
  • packages/agents/src/lib/middleware.test.ts
  • packages/agents/src/testing/logger.ts
  • packages/prompts/src/partials-dir.ts

- Use event parameter types on onError/onFinish/parentFinish mocks
- Use NonNullable<LanguageModelMiddleware["wrapGenerate"]> for middleware mocks
- Keep any-typed top-level mocks with oxlint-disable comments where unknown breaks mockImplementation

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (3)
packages/agents/src/lib/middleware.test.ts (1)

54-54: ⚠️ Potential issue | 🟠 Major

Fix OXFmt violations blocking CI

Line 54 and Lines 70-71 are the formatting offenders causing oxfmt --check to fail in this file.

Proposed fix
-    const middleware = createStubMiddleware({ wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>() });
+    const middleware = createStubMiddleware({
+      wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>(),
+    });
@@
-    const mw1 = createStubMiddleware({ wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>() });
-    const mw2 = createStubMiddleware({ wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>() });
+    const mw1 = createStubMiddleware({
+      wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>(),
+    });
+    const mw2 = createStubMiddleware({
+      wrapGenerate: vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>(),
+    });

As per coding guidelines: "Use OXFmt for code formatting across the project."

Also applies to: 70-71

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/agents/src/lib/middleware.test.ts` at line 54, Replace the
OXFmt-breaking generic vi.fn usage with a casted call: instead of
vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>(), call vi.fn() as
NonNullable<LanguageModelMiddleware["wrapGenerate"]> in the createStubMiddleware
invocation (and the other occurrences on lines 70-71); this keeps the same typed
value but uses formatting that satisfies OXFmt and preserves the reference to
LanguageModelMiddleware["wrapGenerate"] and createStubMiddleware.
packages/agents/src/core/agents/base/agent.test.ts (1)

11-14: ⚠️ Potential issue | 🟠 Major

Remove explicit any from top-level mock signatures.
vi.fn<(...args: any[]) => any>() violates the repo’s no-any rule and weakens type guarantees in the rest of the test file.

Proposed fix
-// oxlint-disable-next-line `@typescript-eslint/no-explicit-any` -- top-level mock needs flexible signature for mockImplementation compatibility
-const mockGenerateText = vi.fn<(...args: any[]) => any>();
-// oxlint-disable-next-line `@typescript-eslint/no-explicit-any` -- top-level mock needs flexible signature for mockImplementation compatibility
-const mockStreamText = vi.fn<(...args: any[]) => any>();
+const mockGenerateText = vi.fn<(...args: unknown[]) => unknown>();
+const mockStreamText = vi.fn<(...args: unknown[]) => unknown>();
#!/bin/bash
rg -nP 'vi\.fn<\(\.\.\.args:\s*any\[\]\)\s*=>\s*any>\(\)' packages/agents/src/core/agents/base/agent.test.ts

As per coding guidelines, **/*.{ts,tsx}: “Do not use the any type — use unknown and narrow appropriately.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/agents/src/core/agents/base/agent.test.ts` around lines 11 - 14, The
top-level mocks mockGenerateText and mockStreamText use vi.fn with explicit any
types; replace those generics with unknown (e.g., vi.fn<(...args: unknown[]) =>
unknown>()) to satisfy the no-any rule and then narrow types where the mock is
used (provide typed mockImplementation or type assertions at call sites) so
callers get correct argument/return types; update usages of mockGenerateText and
mockStreamText in the test to cast or implement with the specific expected
parameter and return shapes rather than relying on any.
packages/agents/src/core/agents/flow/steps/step.test.ts (1)

169-169: ⚠️ Potential issue | 🟡 Minor

Type parentFinish as StepFinishEvent instead of unknown.
Using unknown here drops the callback payload contract this PR is trying to enforce.

Proposed fix
 import { describe, expect, it, vi } from "vitest";
 
 import { createStepBuilder } from "@/core/agents/flow/steps/factory.js";
+import type { StepFinishEvent } from "@/core/types.js";
 import { createMockCtx } from "@/testing/index.js";
@@
-    const parentFinish = vi.fn<(event: unknown) => void>();
+    const parentFinish = vi.fn<(event: StepFinishEvent) => void>();
#!/bin/bash
rg -nP 'const parentFinish = vi\.fn<\(event:\s*unknown\)\s*=>\s*void>\(\);' packages/agents/src/core/agents/flow/steps/step.test.ts -C2
rg -nP 'onStepFinish\?:' packages/agents/src/core/agents/flow/steps/step.ts -C3
rg -nP 'export type StepFinishEvent' packages/agents/src/core/types.ts -C3

As per coding guidelines, **/*.ts: “Follow type-driven design … Make illegal states unrepresentable.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/agents/src/core/agents/flow/steps/step.test.ts` at line 169, The
test's mock callback is currently typed as vi.fn<(event: unknown) => void>()
which loses the StepFinishEvent payload contract; update the mock to
vi.fn<(event: StepFinishEvent) => void>() and (if missing) import the
StepFinishEvent type from the module that exports it so the test enforces the
correct payload shape for parentFinish (which corresponds to the onStepFinish?
handler used by Step/step.ts).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/agents/src/core/agents/base/agent.test.ts`:
- Around line 11-14: The top-level mocks mockGenerateText and mockStreamText use
vi.fn with explicit any types; replace those generics with unknown (e.g.,
vi.fn<(...args: unknown[]) => unknown>()) to satisfy the no-any rule and then
narrow types where the mock is used (provide typed mockImplementation or type
assertions at call sites) so callers get correct argument/return types; update
usages of mockGenerateText and mockStreamText in the test to cast or implement
with the specific expected parameter and return shapes rather than relying on
any.

In `@packages/agents/src/core/agents/flow/steps/step.test.ts`:
- Line 169: The test's mock callback is currently typed as vi.fn<(event:
unknown) => void>() which loses the StepFinishEvent payload contract; update the
mock to vi.fn<(event: StepFinishEvent) => void>() and (if missing) import the
StepFinishEvent type from the module that exports it so the test enforces the
correct payload shape for parentFinish (which corresponds to the onStepFinish?
handler used by Step/step.ts).

In `@packages/agents/src/lib/middleware.test.ts`:
- Line 54: Replace the OXFmt-breaking generic vi.fn usage with a casted call:
instead of vi.fn<NonNullable<LanguageModelMiddleware["wrapGenerate"]>>(), call
vi.fn() as NonNullable<LanguageModelMiddleware["wrapGenerate"]> in the
createStubMiddleware invocation (and the other occurrences on lines 70-71); this
keeps the same typed value but uses formatting that satisfies OXFmt and
preserves the reference to LanguageModelMiddleware["wrapGenerate"] and
createStubMiddleware.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 933ef4dc-ca31-4078-9a76-715c1d88f7b5

📥 Commits

Reviewing files that changed from the base of the PR and between 465b814 and 670f449.

📒 Files selected for processing (7)
  • packages/agents/src/core/agents/base/agent.test.ts
  • packages/agents/src/core/agents/flow/steps/all.test.ts
  • packages/agents/src/core/agents/flow/steps/map.test.ts
  • packages/agents/src/core/agents/flow/steps/race.test.ts
  • packages/agents/src/core/agents/flow/steps/step.test.ts
  • packages/agents/src/core/agents/flow/steps/while.test.ts
  • packages/agents/src/lib/middleware.test.ts

zrosenbauer and others added 2 commits April 10, 2026 19:13
- Pin oxlint ≥1.59.0, oxfmt ≥0.44.0 in package.json
- Update lockfile so CI installs correct versions
- Add empty changeset (no publishable package changes)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant