Files
playbook/skills/tsl-api-reference/workflows/api-lookup.md
T

2.4 KiB

API 检索

用于普通函数、具体成员或“有没有某种行为的 API”这类请求。

先查看脚本当前契约:

python <this-skill-dir>/scripts/lookup.py --help

检索顺序

已知名称时直接精确查询:

python <this-skill-dir>/scripts/lookup.py --name argmax
python <this-skill-dir>/scripts/lookup.py --name DemoUnit.Document.Save

只知道行为时必须走两步:

python <this-skill-dir>/scripts/lookup.py --kw 数组 去重
python <this-skill-dir>/scripts/lookup.py --name arrDropDuplicate

--kw 使用字面 AND 语义,搜索名称、签名、tags、summary、scope、module、 qualified_name、owner、kind、binding 和 visibility,并只输出候选摘要。选定候选后, 必须再用 --name 取正文;不得把 summary 当作签名。

已知范围时用当前索引实际提供的 scope 过滤,例如:

python <this-skill-dir>/scripts/lookup.py --scope builtin --name boolToStr
python <this-skill-dir>/scripts/lookup.py --scope dotnet --kw argmax
python <this-skill-dir>/scripts/lookup.py --scope module --name bondAccruedInterest

精确结果判读

  • --name 对简单名称和完全限定名称做大小写不敏感的精确匹配。
  • 简单成员名会返回所有 owner 下的同名 API;完全限定名用于限定 class 或 unit。
  • 重载共享 qualified_name,精确查询会返回该名称的全部重载。
  • 混合页面按唯一 page#anchor 截取目标 H2 或成员子树;每个 H2 的声明类型独立。
  • 同名结果跨 scope 或 module 时,结合当前代码上下文消歧,不能取第一条。
  • 候选中的实例方法显示 function,类方法显示 class function,静态字段和常量 分别显示 static fieldstatic const

脚本可读取必需的 8 列索引;13 列索引额外提供 qualified_name、owner、kind、 binding 和 visibility。使用自定义 --tsv 时,只有索引实际包含的扩展列才能支持对应消歧。

结果与退出码

  • rc=0:查询完成。--name 无匹配和 --kw 零候选也属于查询完成,必须读取正文状态。
  • rc=1:索引缺失、格式错误、为空,或候选指向的正文不可达;这是数据/部署错误。
  • rc=2:参数不合法;按 stderr 和 --help 修正后重跑。

--name 成功输出完整条目正文和来源标记;最终报告按 SKILL.md 的输出约定组织。