canhelp

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Given a canister ID or name in
$ARGUMENTS
, fetch and summarize its Candid interface.
获取
$ARGUMENTS
中给定的 canister ID 或名称,并汇总其 Candid 接口。

Steps

步骤

  1. Resolve the canister ID by running the resolve script from the skill's base directory:
    bash
    ./scripts/resolve-canister-id.sh "$ARGUMENTS"
    If
    $ARGUMENTS
    is already a valid principal, the script echoes it back. Otherwise, it queries the IC Dashboard API and outputs matches as
    <canister-id>  <name>
    (one per line).
    • If there is a single result, clearly display the resolved canister ID and use it directly.
    • If there are multiple results, present the list to the user and ask them to pick one before continuing.
  2. Fetch the Candid interface using the resolved canister ID:
    bash
    ./scripts/fetch-candid.sh <resolved-canister-id>
    The script outputs the path to the downloaded
    .did
    file.
  3. Read the file using the
    Read
    tool.
  4. Present the output as a readable summary with the following structure:
    Canister
    <canister-id>
    Query methods:
    • method_name(arg1: type1, arg2: type2) → return_type
      — one-line description if inferable from the name
    Update methods:
    • method_name(arg1: type1) → return_type
    Types:
    • List any custom record/variant types defined in the interface, with their fields
  1. 运行 skill 基础目录中的 resolve 脚本,解析 canister ID:
    bash
    ./scripts/resolve-canister-id.sh "$ARGUMENTS"
    如果
    $ARGUMENTS
    已经是有效的 principal,脚本会直接回显该值。 否则,脚本将查询 IC Dashboard API,并以
    <canister-id>  <name>
    的格式输出匹配结果(每行一个)。
    • 如果只有一个结果,应清晰展示解析出的 canister ID,并直接使用该 ID。
    • 如果有多个结果,则向用户展示列表,并要求用户选择一个后再继续。
  2. 使用解析出的 canister ID 获取 Candid 接口:
    bash
    ./scripts/fetch-candid.sh <resolved-canister-id>
    该脚本会输出已下载的
    .did
    文件路径。
  3. 使用
    Read
    工具读取该文件。
  4. 按以下结构以易读形式呈现结果:
    Canister
    <canister-id>
    Query methods:
    • method_name(arg1: type1, arg2: type2) → return_type
      — 如果可以根据名称推断,则提供一句话说明
    Update methods:
    • method_name(arg1: type1) → return_type
    Types:
    • 列出接口中定义的所有自定义 record/variant 类型及其字段

Guidelines

指南

  • Group methods by query vs update
  • Sort methods alphabetically within each group
  • For complex nested types, show the top-level structure and note nesting
  • If the candid is very large (>100 methods), show a summary count and list only the most important-looking methods, offering to show the full list on request
  • If the fetch succeeds, but the Candid interface is empty,explain that the canister is not exposing its Candid interface in the wasm metadata
  • If the fetch fails, suggest the user verify the canister ID and that
    icp
    is installed
  • 按 query 和 update 对方法进行分组
  • 在每组内部按字母顺序排列方法
  • 对于复杂的嵌套类型,展示顶层结构并注明嵌套关系
  • 如果 Candid 接口非常大(超过 100 个方法),则显示汇总数量,仅列出看起来最重要的方法,并主动询问是否需要展示完整列表
  • 如果获取成功,但 Candid 接口为空,应说明该 canister 未在 wasm metadata 中公开其 Candid 接口
  • 如果获取失败,应建议用户检查 canister ID,并确认已安装
    icp