feat(tsl-syntax-reference): harden retrieval and restructure pages

- flag weak candidates (no intent/heading/identifier/tag hit) and exit 2
  when every candidate is weak: mis-hits used to be indistinguishable
  from real hits, so the retry-with-better-terms loop never fired
- accept multiple ids per --section for batch fetch, failing atomically
  on any unknown id so a partial fetch cannot pass as complete
- move query synonyms and page intent aliases to data/lexicon.json and
  enforce alias/page correspondence in --check; curation data no longer
  lives in the engine
- document the weak-hit rule, batch fetch and prelude-once guidance in
  SKILL.md, with curation discipline in data/README.md
- drop 11_pitfalls.md, renumber the trailing pages and spread retrieval
  tags across topics; lexicon keys are page filenames, so the renumbering
  and the new --check rule cannot land in separate commits
This commit is contained in:
csh
2026-07-29 15:45:47 +08:00
parent 37a3bf4b0c
commit 40a9885eb4
28 changed files with 1048 additions and 773 deletions
@@ -6,18 +6,6 @@
回答“`setSysParam` / `getSysParam` 怎样用、`sysParams[...]` 是什么、块环境 `with *, values do` / `with **, values do` 怎样写、`#Func() with array(...)` 这种后缀环境调用怎样写,网格调用怎样取回结果,以及全局缓存最小读写规则是什么”。
## 智能体运行时上下文判断流程
1. 先判断要操作系统参数、运行时上下文对象、块环境 `with` 语句、`with` 后缀调用、`#` 网格调用、`timeout` 后缀,还是全局缓存函数。
2. 系统参数优先用本页明确的 `setSysParam` / `getSysParam` / `sysParams[...]` 形态。
3. `#Func() with array(...)` 只作为运行时环境调用写法,不要套到普通本地函数。
4. 网格调用返回的不是最终值;需要最终结果时继续写 `dupvalue(...)`
5. 全局缓存读写要成对出现,并明确键和值的生命周期。
6. 普通函数调用的事实见 [05_functions_and_calls.md](05_functions_and_calls.md),不要把运行时服务写成普通语法糖;缓存值参与 `select` 时,查询语法事实见 [14_ts_sql.md](14_ts_sql.md)。
7. 内置运行时对象本身的事实见 [21_builtin_runtime_objects.md](21_builtin_runtime_objects.md)。
8. 本地函数后缀 `with` 属于反例时不要照写。
9. 没有对应代码块时不要发明运行时上下文/运行时服务/全局缓存写法。
## 核心规则
本页示例只说明运行时上下文语法中的调用位置和源码外形。API 的精确签名、参数、返回行为、平台 scope、目标环境或解释器可用性必须使用 `tsl-api-reference` skill 重新核对,不能由本页示例反推。
@@ -47,6 +35,8 @@
### `setSysParam` / `getSysParam` / `sysParams[...]` 基础读写
<!-- tags: 系统参数, 读写运行参数, 环境设置, 全局设置项 -->
直接设置和读取系统参数:
代码块身份:可直接照写示例
@@ -88,6 +78,8 @@ writeLn(getSysParam("a"));
### 块环境 `with *`
<!-- tags: 临时改参数, 局部生效, 一段代码内有效, 块内覆盖 -->
代码块身份:可直接照写示例
```tsl
@@ -139,6 +131,8 @@ end
### 块环境 `with **`
<!-- tags: 嵌套覆盖, 深层块环境, 多层 with -->
代码块身份:可直接照写示例
```tsl
@@ -164,6 +158,8 @@ writeLn(getSysParam("b"));
### 后缀 `with array(...)`:网格调用的临时覆盖
<!-- tags: 调用时临时改参数, 单次覆盖, 调用完恢复 -->
`#Func(...) with array(...)` 在一次网格调用里临时覆盖系统参数,调用结束后恢复外层原值。下面用一个 `TestDo.tsf` 演示覆盖边界:
代码块身份:配置片段 / 概念骨架
@@ -216,6 +212,8 @@ writeLn(getSysParam("b") = nil);
### `#` 网格调用与 `dupvalue`
<!-- tags: 网格调用, 分布式执行, 井号调用, 取回结果 -->
网格调用函数:
代码块身份:可直接照写示例
@@ -265,6 +263,8 @@ array(2,4,6,8,10)
### 网格调用的 `timeout`
<!-- tags: 超时, 限制执行时间, 多久不返回就断 -->
代码块身份:可直接照写示例
```tsl
@@ -283,6 +283,8 @@ end;
### `setGlobalCache`、`getGlobalCache` 与 `ifCache`
<!-- tags: 全局缓存, 缓存数据, 跨脚本共享, 存起来下次用 -->
代码块身份:可直接照写示例
```tsl
@@ -308,6 +310,8 @@ writeLn(cached_data[0], ',', cached_data[1], ',', cached_data[2]);
### `checkGlobalCacheExpired`
<!-- tags: 缓存过期, 缓存失效判断, 什么时候要重算 -->
代码块身份:可直接照写示例
```tsl
@@ -325,6 +329,8 @@ writeLn(checkGlobalCacheExpired(cache_ref));
### 缓存值本地写入后会实例化
<!-- tags: 改缓存内容, 缓存副本, 写回不影响原缓存 -->
代码块身份:可直接照写示例
```tsl
@@ -344,6 +350,8 @@ writeLn(local_copy[0], ',', local_copy[1], ',', local_copy[2]);
### 全局缓存参与 `select`
<!-- tags: 对缓存做查询, 缓存当表查 -->
代码块身份:可直接照写示例
```tsl