63 lines
2.9 KiB
Markdown
63 lines
2.9 KiB
Markdown
# API 检索
|
|
|
|
用于普通函数、具体成员、“有没有某种行为的 API”或“某个 API 的参数可以填什么”这类请求。
|
|
|
|
先查看脚本当前契约:
|
|
|
|
```bash
|
|
python <this-skill-dir>/scripts/lookup.py --help
|
|
```
|
|
|
|
## 检索顺序
|
|
|
|
已知名称时直接精确查询:
|
|
|
|
```bash
|
|
python <this-skill-dir>/scripts/lookup.py --name argmax
|
|
python <this-skill-dir>/scripts/lookup.py --name DemoUnit.Document.Save
|
|
```
|
|
|
|
只知道行为时必须走两步:
|
|
|
|
```bash
|
|
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;如果关键词命中参数取值域,结果会
|
|
在对应 API 候选下附上参数名、值/名称、绑定关系和来源。它仍只输出候选摘要,选定候选后
|
|
必须再用 `--name` 取正文;不得把 summary 或参数域样例当作签名。
|
|
|
|
已知范围时用当前索引实际提供的 scope 过滤,例如:
|
|
|
|
```bash
|
|
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 field`、`static const`。
|
|
|
|
脚本可读取必需的 8 列索引;13 列索引额外提供 `qualified_name`、owner、kind、
|
|
binding 和 visibility。使用自定义 `--tsv` 时,只有索引实际包含的扩展列才能支持对应消歧。
|
|
|
|
## 结果与退出码
|
|
|
|
- rc=0:查询完成。`--name` 无匹配和 `--kw` 零候选也属于查询完成,必须读取正文状态。
|
|
- rc=1:索引缺失、格式错误、为空,或候选指向的正文不可达;这是数据/部署错误。
|
|
- rc=2:参数不合法;按 stderr 和 `--help` 修正后重跑。
|
|
|
|
`--name` 成功输出完整条目正文和来源标记;若 API 绑定参数取值域,还会显示域模式、
|
|
完整性、快照和系统/用户运行时解析器。完整的封闭枚举或值模式会直接列出;不完整的版本
|
|
目录和运行时目录只显示已记录数量,用 `dictionary_lookup.py --query` 按域 ID、名称、代码
|
|
或模式取回。最终报告按 `SKILL.md` 的输出约定组织。
|