Skip to content

Conversation

@seefeldb
Copy link
Contributor

@seefeldb seefeldb commented Jun 3, 2025

Summary by cubic

Replaced most uses of the any type with unknown and added isRecord and isObject type guards for stricter type safety across builder, runner, js-runtime, and memory packages.

  • Refactors
    • Updated function signatures and internal checks to use unknown instead of any.
    • Replaced manual object checks with isRecord and isObject utilities.
    • Adjusted type assertions and generics to match stricter typing.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves type safety by replacing many uses of any with unknown or stricter types, introducing generics for utility functions, and swapping ad-hoc typeof value === "object" checks for the new isRecord/isObject predicates.

  • Replace any and broad object checks with unknown, isRecord, and type parameters.
  • Add JSONValue imports and type annotations to core functions.
  • Introduce generics to mergeObjects and other utilities to enable stronger typing.

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/toolshed/routes/ai/spell/handlers/fulfill.ts Swap raw object checks for isRecord in sanitization
packages/runner/test/utils.test.ts Update test schema literals with as const and add generics to mergeObjects
packages/runner/src/utils.ts Strengthen extractDefaultValues and mergeObjects signatures and replace object checks
packages/runner/src/storage.ts Replace deep typeof checks with isRecord in storage serialization
packages/runner/src/schema.ts Add stricter types and use isRecord for JSON schema validation
packages/runner/src/runner.ts Introduce generics and tighten types in runner logic
packages/runner/src/query-result-proxy.ts Use isRecord in proxy guards
packages/runner/src/doc.ts Harden isDoc check with isRecord
packages/runner/src/doc-map.ts Use isRecord when traversing document maps
packages/runner/src/cell.ts Switch to isRecord and isObject for cell updates
packages/memory/traverse.ts Cast to JSONValue and narrow types in traversers
packages/js-runtime/interface.ts Narrow runtime interface methods to unknown args/returns
packages/js-runtime/deno.json Expand Deno permissions for environment variables
packages/builder/src/utils.ts Use isRecord in value traversal
packages/builder/src/types.ts Replace any with unknown in core builder types
packages/builder/src/recipe.ts Use isRecord when naming recipe outputs
packages/builder/src/opaque-ref.ts Guard external value mapping with isRecord
packages/builder/src/built-in.ts Narrow LLM error fields to unknown

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 16 issues across 17 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

cubic found 16 issues across 17 files. Review them in cubic.dev

React with 👍 or 👎 to teach cubic. Tag @cubic-dev-ai to give specific feedback.

Copy link
Contributor

@ubik2 ubik2 left a comment

Choose a reason for hiding this comment

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

A few places where I agree with cubic, but otherwise, lgtm. Would also be ok to merge as is.

seefeldb and others added 3 commits June 6, 2025 13:41
Replace `any` types with `unknown` throughout builder, js-runtime, memory, and runner packages to improve type safety and maintainability. Add proper type guards and assertions where needed.

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

Co-Authored-By: Claude <noreply@anthropic.com>
- tightened deepCopy and mergeObjects
@seefeldb seefeldb force-pushed the claude-type-improvements branch from 402eff2 to e76bcc6 Compare June 6, 2025 20:41
@seefeldb seefeldb merged commit 3287c17 into main Jun 6, 2025
6 checks passed
@seefeldb seefeldb deleted the claude-type-improvements branch June 6, 2025 20:58
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.

4 participants