♻️ refactor(tsl-api-reference): split lookup workflows and maintenance tooling

This commit is contained in:
csh
2026-08-20 17:47:48 +08:00
parent 9b95bf2682
commit cd0405d64b
18 changed files with 707 additions and 374 deletions
@@ -0,0 +1,58 @@
# 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,并只输出候选摘要。选定候选后,
必须再用 `--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` 成功输出完整条目正文和来源标记;最终报告按 `SKILL.md` 的输出约定组织。
@@ -0,0 +1,57 @@
# Class 与 Framework 查询
用于 class 摘要、成员分类、子类实现、回调重写和生命周期协议。公开入口只有
`class_lookup.py`Framework Profile 是 class 查询的附加层,不单独调用另一个 CLI。
先查看脚本当前契约:
```bash
python <this-skill-dir>/scripts/class_lookup.py --help
```
## 查询
```bash
python <this-skill-dir>/scripts/class_lookup.py --list
python <this-skill-dir>/scripts/class_lookup.py --class TStringList
python <this-skill-dir>/scripts/class_lookup.py --class TSBackTesting
python <this-skill-dir>/scripts/class_lookup.py \
--class TSBackTesting --config FGroupType=1 --format json
```
- 查询或使用任意 class 时,先取类摘要;需要具体成员正文时,再按返回的
`qualified_name` 运行 `lookup.py --name`
- `class_lookup.py` 自动覆盖 `function_index.tsv``kind=class` 的条目,不要求普通
对象类维护人工 Profile。
- 只有 `kind=framework` 且有证据化生命周期的类才叠加 Framework Profile。不得因目标
是 class 就推断它是框架。
- 同名 class 的 `status=ambiguous` 时,使用 `--scope``--module` 或完全限定名消歧。
## 状态判读
- `status=resolved`:类查询已解析;`status=not_found`:索引中无该 class
`status=ambiguous`:存在多个候选。
- `profile_status=not_profiled`:普通 class,只使用自动成员视图,不是错误,也不表示数据
不完整;成员查询可以继续。若当前请求依赖生命周期、配置或回调,则表示没有已验证的
framework 契约,必须停止该部分,不能假设空的 Framework Profile。
- `profile_status=resolved`:返回了 Framework Profile。
- `scaffold_status=resolved` 只表示生命周期和成员引用完整。
- `contract_status` 不是 `resolved` 时,必须按 `diagnostics` 补齐模式与返回 schema 证据,
并停止生成回调字段。
Framework Profile 只描述 API 协议,不定义 TSL 语法或代码结构。解析后的 Framework
Contract Packet 仅作为已验证的 API 事实输出。
只有返回的 Profile 本身带有生命周期、配置、回调、执行入口或结果查询证据时,才使用
这些协议;`not_profiled` 时不能从 class 名称或成员列表推断 framework。
使用自定义 `--tsv` 时默认不加载 Framework Profile,普通 class 仍可查询;该索引确有
curated Profile 时必须同时显式传入 `--profiles`
## 退出码
- rc=0:查询或校验完成;`not_found``ambiguous` 通过输出状态表达。
- rc=1:索引/Profile 数据缺失、损坏或引用校验失败。
- rc=2:参数不合法。
`--check` 属维护动作,普通编码查询不需要运行。
@@ -0,0 +1,39 @@
# 数据字典查询
用于按中文业务含义查询天软数据字典中的表、数据源或字段。它们不是可调用 API,
不进入 `function_index.tsv`
先查看脚本当前契约:
```bash
python <this-skill-dir>/scripts/dictionary_lookup.py --help
```
## 查询
```bash
python <this-skill-dir>/scripts/dictionary_lookup.py \
--query "股票现金流指标销售现金比率"
python <this-skill-dir>/scripts/dictionary_lookup.py --query "市值" --scope fund
python <this-skill-dir>/scripts/dictionary_lookup.py --query "买一量" --table TradeTable
python <this-skill-dir>/scripts/dictionary_lookup.py --query "9900700" --field 销售现金比率
```
结果包含表或数据源名称、表 ID、字段名称、字段 ID、类型、单位、提取方式、访问代码、
对应 API 和字典页面。
## 状态判读
- `status: ok`:最高分候选唯一。
- `status: ambiguous`:存在多个同分候选;列出候选并请用户补充 scope、表或数据源范围,
不能默认选第一条。
- `status: no_match`:数据字典无匹配,不能改述为 API 的 `not found`
标识符匹配保留下划线;同义词只来自 `dictionary_lexicon.json` 的受控映射。
`MarketTable``TradeTable` 是 TS-SQL 数据源,不是函数。
## 退出码
- rc=0:查询完成,实际结果由 `status` 判定,包括 `ambiguous``no_match`
- rc=1:字典索引或词表缺失、损坏、格式错误。
- rc=2:参数不合法。