AgentSkillsCN

Verify Package Types

通过检查本地安装的 node_modules,验证 TypeScript 类型与包 API 的正确性。

SKILL.md
--- frontmatter
name: Verify Package Types
description: Instructions for verifying TypeScript types and package APIs by inspecting locally installed node_modules.

Verify Package Types

Use this skill when:

  • You encounter a TypeScript error (e.g., "Property 'x' does not exist on type 'y'") for a third-party package.
  • You are unsure if a specific feature or configuration option is supported by the installed version of a package.
  • You suspect a version mismatch between your training data (docs) and the actual installed package.

Strategy

Do not guess package capabilities. The source of truth is the code sitting on the disk in node_modules.

Application Rules

  1. Locate the Entry Point:

    • Check package.json to see the installed version.
    • Look at node_modules/<package_name>/package.json to find the types or typings field.
    • If no types field, look for index.d.ts in the root or dist folder.
  2. Inspect Definition Files:

    • Use view_file to read the .d.ts file.
    • Search for the specific function, class, or interface you are trying to use.
    • Check the function signature, accepted parameters, and their types.
    • Look for exported types that might match what you need.
  3. Check for "maxSteps" and "Stream" Usage (Common Issues):

    • For Vercel AI SDK (ai), streamText and generateText options change frequently between versions.
    • Always verify if maxSteps, maxToolRoundtrips, or similar properties exist in the Settings interface.
  4. Resolve Discrepancies:

    • If the feature you want to use is missing from the types:
      • logic: It probably doesn't exist in this version. Do not use @ts-ignore unless you have verified via grep that the runtime code actually supports it but the types are missing (rare).
      • Action: Use an alternative API that is present in the type definition, or suggest upgrading the package to the user.

Example Workflow

User Request: "Fix the error: maxSteps does not exist in streamText"

  1. Check Package Version: view_file package.json -> see "ai": "^3.0.0"
  2. Locate Types: find_by_name node_modules/ai -e d.ts -> found dist/index.d.ts
  3. Read Definitions: view_file node_modules/ai/dist/index.d.ts
  4. Search: Grep for maxSteps.
    • Result: Not found.
  5. Alternative Search: Grep for maxRetries or roundtrips to see what is supported.
  6. Conclusion: "The installed version 3.0.0 does not support maxSteps. We must use maxToolRoundtrips instead, or upgrade to version 3.1+."