@yss123/cage-ontology 0.3.2 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -45
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,62 +1,28 @@
|
|
|
1
1
|
# @yss123/cage-ontology
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
从当前注册表生成服务端运行本体,按主体能力检索聚合、命令、查询和审批摘要,供 AI 工具发现和受控能力目录使用。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 服务端发现
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
```powershell
|
|
10
|
-
pnpm add @yss123/cage-ontology @yss123/cage-kernel
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
普通应用启用 `@yss123/cage-ai` 时由运行时使用本包,无需再创建另一套本体服务。开发期间查源码、图谱、路径或影响范围,使用 `@yss123/cage-cli` 的 `cage context/graph`。
|
|
14
|
-
|
|
15
|
-
## 服务端检索示例
|
|
16
|
-
|
|
17
|
-
下面是服务端集成函数;`registry` 必须来自当前应用,`ctx` 来自已认证且实时解析授权的身份。不要从浏览器输入构造权限上下文。
|
|
7
|
+
安装 pnpm add @yss123/cage-ontology @yss123/cage-kernel,使用同版本框架和 Node.js 24+:
|
|
18
8
|
|
|
19
9
|
```ts
|
|
20
|
-
|
|
21
|
-
import { type Ctx, type Registry } from '@yss123/cage-kernel';
|
|
10
|
+
import type { Ctx, Registry } from '@yss123/cage-kernel';
|
|
22
11
|
import { ontologyCatalog, runtimeOntology } from '@yss123/cage-ontology';
|
|
23
12
|
|
|
24
|
-
/**
|
|
25
|
-
* 为受信任服务端调用方检索当前身份可发现的节点。
|
|
26
|
-
* @param registry 当前运行的领域注册表。
|
|
27
|
-
* @param ctx 认证层提供的身份和能力;行级范围由实际读取另行落实。
|
|
28
|
-
* @param query 中文说明、标识或字段关键词。
|
|
29
|
-
* @returns 有界摘要页;nextOffset 非空表示还存在后续结果。
|
|
30
|
-
*/
|
|
13
|
+
/** 从已认证上下文发现声明;业务行范围仍由实际读取与执行层检查。 */
|
|
31
14
|
export function discover(registry: Registry, ctx: Ctx, query: string) {
|
|
32
|
-
const
|
|
33
|
-
const catalog = ontologyCatalog(ontology);
|
|
15
|
+
const catalog = ontologyCatalog(runtimeOntology(registry));
|
|
34
16
|
return catalog.search(ctx, { query, offset: 0, limit: 10 });
|
|
35
17
|
}
|
|
36
18
|
```
|
|
37
19
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
## 主要入口与结果
|
|
41
|
-
|
|
42
|
-
| 入口 | 作用 |
|
|
43
|
-
| --- | --- |
|
|
44
|
-
| `runtimeOntology(registry)` | 提取公开字段、状态、输入、调用身份、规则名称与审批步骤 |
|
|
45
|
-
| `ontologyCatalog(ontology)`、`OntologyCatalog` | 为稳定本体建立检索与关联索引 |
|
|
46
|
-
| `catalog.search(ctx, input)` | 返回摘要、total、nextOffset、truncated;每页最多 20 项 |
|
|
47
|
-
| `catalog.describe(ctx, key, section)` | 按 overview、fields、input、related 展开详情;字段和关系支持分页 |
|
|
48
|
-
| `catalog.node(ctx, key)` | 读取一个授权可见节点;不存在和无权限均返回 NOT_FOUND |
|
|
49
|
-
| `nodeKey(node)` | 得到 `aggregate:Note`、`command:Note.create` 等稳定键 |
|
|
50
|
-
| `visibleNodes`、`searchOntology` | 直接过滤及简单关键词召回;大目录优先使用分页 catalog |
|
|
51
|
-
|
|
52
|
-
运行本体不包含 handler 函数体、SQL、隐藏字段或密钥。命令可发现性按命令能力判断,其他节点要求其读依赖的 read 能力;可发现不等于可以访问任意业务记录或立即执行命令。状态、版本、数据范围与硬约束仍在实际读写阶段判断。
|
|
20
|
+
registry 来自当前应用,ctx 来自可信认证和授权解析;浏览器不能自行构造权限。启用 cage-ai 后运行时自动使用这些能力,应用通常无需另建本体服务。
|
|
53
21
|
|
|
54
|
-
|
|
22
|
+
## 区分声明与数据
|
|
55
23
|
|
|
56
|
-
|
|
24
|
+
本体描述字段、输入、规则名称与关系,不查询业务数据、不执行命令,也不导出 handler 或 SQL 源码。发现节点仍需调用相应授权工具才能读取记录或执行动作。
|
|
57
25
|
|
|
58
|
-
|
|
59
|
-
- [开发时的本体查询与源码定位](https://github.com/shunshunyue/cage/blob/main/docs/development/tools/ontology-context.md)
|
|
60
|
-
- [能力发现与诊断](https://github.com/shunshunyue/cage/blob/main/docs/development/tools/diagnostics.md)
|
|
26
|
+
检索基于确定性关键词并支持分页,不是向量数据库。开发阶段的源码图谱和影响分析由 CLI context/graph 提供,和这里的运行时目录不同。
|
|
61
27
|
|
|
62
|
-
|
|
28
|
+
[运行时工具参考](https://github.com/shunshunyue/cage/blob/main/docs/development/reference/intelligence.md) · [开发本体工具](https://github.com/shunshunyue/cage/blob/main/docs/development/tools/ontology-context.md)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yss123/cage-ontology",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Cage 运行时本体与受控能力发现",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"zod": "^4.1.5",
|
|
19
|
-
"@yss123/cage-kernel": "0.
|
|
19
|
+
"@yss123/cage-kernel": "0.4.1"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"engines": {
|