rig-migrate

GitHub

协助将 Rig 代码库从旧版本迁移至新版本,自动检测当前版本并对比最新发行版。提供审计、规划及执行迁移工作流,涵盖废弃 API 替换、WasmCompat 适配及错误类型重构,确保升级后的代码兼容性。

data/skills-md/0xplaygrounds/rig/rig-migrate/SKILL.md NeverSight/learn-skills.dev

Trigger Scenarios

升级 rig-core 或相关 crate 时 需要处理 Breaking Changes 或更新已弃用的 API 时

Install

npx skills add NeverSight/learn-skills.dev --skill rig-migrate -g -y
More Options

Non-standard path

npx skills add https://github.com/NeverSight/learn-skills.dev/tree/main/data/skills-md/0xplaygrounds/rig/rig-migrate -g -y

Use without installing

npx skills use NeverSight/learn-skills.dev@rig-migrate

指定 Agent (Claude Code)

npx skills add NeverSight/learn-skills.dev --skill rig-migrate -a claude-code -g -y

安装 repo 全部 skill

npx skills add NeverSight/learn-skills.dev --all -g -y

预览 repo 内 skill

npx skills add NeverSight/learn-skills.dev --list

SKILL.md

Frontmatter
{
    "name": "rig-migrate",
    "description": "Help migrate Rig code between versions. Use when upgrading rig-core or companion crates, resolving breaking changes, or updating deprecated APIs. Detects the current version from Cargo.toml automatically.\n",
    "allowed-tools": [
        "Read",
        "Glob",
        "Grep",
        "Edit",
        "Write",
        "Bash"
    ],
    "argument-hint": "[target-version]"
}

Rig Migration Assistant

Current project Rig version (auto-detected):

!`grep -E '^rig-core|^rig ' Cargo.toml 2>/dev/null || grep -rE 'rig-core\s*=' Cargo.toml */Cargo.toml 2>/dev/null | head -5 || echo "rig-core version not found in Cargo.toml"`

Latest Rig release:

!`cargo search rig-core --limit 1 2>/dev/null || echo "Could not fetch latest version. Check https://crates.io/crates/rig-core"`

Migration Workflow

  1. Detect: Compare current version against target version.
  2. Audit: Search for deprecated patterns and breaking API usages.
  3. Plan: List all files and changes required.
  4. Migrate: Apply changes systematically.
  5. Validate: Run cargo fmt, cargo clippy --all-targets --all-features, cargo test.

Common Migration Patterns

Send/Sync to WasmCompat (introduced in 0.5+)

All trait bounds must use WASM-compatible variants:

// Before
pub trait MyTrait: Send + Sync {
    fn method(&self) -> impl Future<Output = ()> + Send;
}

// After
use rig::{WasmCompatSend, WasmCompatSync};

pub trait MyTrait: WasmCompatSend + WasmCompatSync {
    fn method(&self) -> impl Future<Output = ()> + WasmCompatSend;
}

Search pattern: grep -rn ': Send\b\|+ Send\b\|: Sync\b\|+ Sync\b' --include='*.rs'

String Error Types to Proper Enums

// Before
fn process() -> Result<(), String> { ... }

// After
#[derive(Debug, thiserror::Error)]
enum ProcessError {
    #[error("Parse failed: {0}")]
    Parse(#[from] serde_json::Error),
}

fn process() -> Result<(), ProcessError> { ... }

Search pattern: grep -rn 'Result<.*,\s*String>' --include='*.rs' (results should be manually verified to avoid false positives)

Provider API Updates

When providers update their APIs, Rig's type definitions change. Check the CHANGELOG for specific field additions/removals.

Typical changes:

  • New fields added to request/response structs
  • Model constant renames (e.g., GPT_4 -> GPT_4O)
  • New capability declarations

CompletionRequest Model Override (new)

CompletionRequest now has an optional model field:

// When constructing CompletionRequest manually, include the field:
let request = CompletionRequest {
    model: None,  // or Some("model-override".to_string())
    preamble: None,
    chat_history: OneOrMany::one("Hello".into()),
    // ... rest of fields
};

Migration Checklist

Use this checklist when migrating:

  • Update rig-core version in all Cargo.toml files
  • Update companion crate versions (rig-mongodb, rig-lancedb, etc.)
  • Search for deprecated API patterns
  • Replace Send/Sync with WasmCompatSend/WasmCompatSync
  • Replace String error types with proper error enums
  • Remove .unwrap() / .expect() on fallible operations
  • Update model constants if renamed
  • Run cargo fmt && cargo clippy --all-targets --all-features && cargo test
  • Verify examples still compile

Version History

  • e0220ca Current 2026-07-05 20:36

Same Skill Collection

data/skills-md/00prabalk00/claude-skills/knowledge-base-gap-finder/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-agile/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-auth/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-issues/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-project-management/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-projects/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-safe/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-search/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-spaces/SKILL.md
data/skills-md/01000001-01001110/agent-jira-skills/jira-transitions/SKILL.md
data/skills-md/0731coderlee-sudo/wechat-publisher/wechat-publisher/SKILL.md
data/skills-md/0froq/skills/conventionalcommits/SKILL.md
data/skills-md/0froq/skills/nuxt/SKILL.md
data/skills-md/0froq/skills/oq/SKILL.md
data/skills-md/0froq/skills/pinia/SKILL.md
data/skills-md/0froq/skills/pnpm/SKILL.md
data/skills-md/0froq/skills/slidev/SKILL.md
data/skills-md/0froq/skills/tsdown/SKILL.md
data/skills-md/0froq/skills/turborepo/SKILL.md
data/skills-md/0froq/skills/unocss/SKILL.md
data/skills-md/0froq/skills/vitepress/SKILL.md
data/skills-md/0froq/skills/vitest/SKILL.md
data/skills-md/0froq/skills/vue-best-practices/SKILL.md
data/skills-md/0froq/skills/vue-router-best-practices/SKILL.md
data/skills-md/0froq/skills/vue-testing-best-practices/SKILL.md
data/skills-md/0froq/skills/vue/SKILL.md
data/skills-md/0froq/skills/vueuse-functions/SKILL.md
data/skills-md/0froq/skills/web-design-guidelines/SKILL.md
data/skills-md/0juano/agent-skills/bondterminal-x402/SKILL.md
data/skills-md/0juano/agent-skills/edgeone-pages-deploy/SKILL.md
data/skills-md/0juano/agent-skills/ley-ar/SKILL.md
data/skills-md/0juano/agent-skills/ticktick/SKILL.md
data/skills-md/0juano/agent-skills/x-image-cards/SKILL.md
data/skills-md/0juano/x-image-cards/x-image-cards/SKILL.md
data/skills-md/0x0funky/agent-sprite-forge/generate2dsprite/SKILL.md
data/skills-md/0x0funky/agent-sprite-forge/video2dsprite/SKILL.md
data/skills-md/0x2e/superpowers/brainstorming/SKILL.md
data/skills-md/0x2e/superpowers/dispatching-parallel-agents/SKILL.md
data/skills-md/0x2e/superpowers/executing-plans/SKILL.md
data/skills-md/0x2e/superpowers/finishing-a-development-branch/SKILL.md
data/skills-md/0x2e/superpowers/receiving-code-review/SKILL.md
data/skills-md/0x2e/superpowers/requesting-code-review/SKILL.md
data/skills-md/0x2e/superpowers/subagent-driven-development/SKILL.md
data/skills-md/0x2e/superpowers/systematic-debugging/SKILL.md
data/skills-md/0x2e/superpowers/test-driven-development/SKILL.md
data/skills-md/0x2e/superpowers/using-git-worktrees/SKILL.md
data/skills-md/0x2e/superpowers/using-superpowers/SKILL.md
data/skills-md/0x2e/superpowers/verification-before-completion/SKILL.md
data/skills-md/0x2e/superpowers/writing-plans/SKILL.md
data/skills-md/0x2e/superpowers/writing-skills/SKILL.md

Metadata

Files
0
Version
e4a0f95
Hash
a00ef294
Indexed
2026-07-05 20:36

- 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-05 18:29
浙ICP备14020137号-1 $방문자$