Skip to content

[Tools > Definition API]: Simplify tool definitions and add migration guidance - #6

Merged
rendotdev merged 2 commits into
mainfrom
work/tool-api-v2-migration
Jul 15, 2026
Merged

rendotdev merged 2 commits into
mainfrom
work/tool-api-v2-migration

Conversation

@rendotdev

@rendotdev rendotdev commented Jul 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

At the moment, Rig tool definitions repeat their folder name, command inference depends on the verbose rig.defineCommand form, generated runtime types have drifted from the source SDK, and Rig updates do not provide agents with an exact migration prompt when the tool API changes.

This PR introduces a compatibility-safe tool API v2 with folder-derived names and a bound command builder that infers command input, output, environment, and collection types. Existing v1 tool definitions remain supported so tools can migrate incrementally.

Implementation

  • Add commands: (command) => ({ ... }) as the concise v2 definition shape.
  • Derive optional tool names from their containing folder.
  • Add explicit // rig:tool-api-version 2 source markers.
  • Add rig migrate and rig migrate --json compatibility reports.
  • Surface unresolved migration guidance through rig init, rig doctor, and generated agent instructions.
  • Preserve existing callback and rig.defineCommand definitions through SDK normalization.
  • Align generated runtime types with typed environment and collection contexts.
  • Update scaffolding, help topics, README guidance, agent instructions, fixtures, and tests.

Local migration validation

  • Ran the built PR artifact against the active Google Drive registry containing 14 real v1 tools.
  • Detected all 14 migrations with no unsupported versions and no changes to tool source checksums.
  • Typechecked and loaded all 14 existing tools under the v2-generated runtime.
  • Executed LanguageTool, Hue status, Apple Music status, and CleanShot dry-run commands successfully.
  • Reproduced the web.fetch connectivity failure under installed Rig 0.0.40 and direct curl; the machine could not resolve example.com, so this is environmental.
  • Migrated isolated copies of hue, cleanshots, and video to cover inline commands, reusable command helpers, and predeclared commands.
  • Confirmed the migrated copies typecheck, report ready: true, and execute representative Hue and CleanShot commands.
  • Expanded the migration prompt with explicit guidance for predeclared commands and reusable command factories.

Validation

  • vp run ci
  • 197 unit tests
  • 30 end-to-end tests
  • 100% statement, branch, function, and line coverage
  • Formatting, linting, type checking, build, smoke testing, and package dry run

@rendotdev
rendotdev marked this pull request as ready for review July 15, 2026 13:48
@rendotdev
rendotdev merged commit c6c6526 into main Jul 15, 2026
1 check passed
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