world/skill/SKILL.md

55 lines
2.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
name: world
description: world 模块技能文档——世界定义与管理(根模块,平台入口域)。提供 world 表 CRUD、列表查询接口、创建自动编码通过 load_world() 挂载。
---
# world 模块
## 概述
世界定义与管理,是平台的根模块/入口域,无业务依赖,最先开发。依赖 appbaseappcodes 字典、rbac权限
## 数据模型
### 表 `world`models/world.json
| 字段 | 类型 | 说明 |
|------|------|------|
| id | str(32) | 主键 |
| name | str(255) | 世界名称 |
| code | str(64) | 世界编码(唯一) |
| description | text | 描述 |
| world_type | str(16) | 世界类型appcodes world_type默认 '0' |
| status | str(16) | 状态appcodes world_status默认 '0' |
| config_json | text | 世界配置 JSON |
| created_at | timestamp | 创建时间 |
| updated_at | timestamp | 更新时间 |
- 主键:`["id"]`
- 唯一索引:`idx_world_code(code)`
- 字典world_type → appcodes_kv(parentid='world_type')、status → appcodes_kv(parentid='world_status')
## 关键接口
### ServerEnv 注册函数load_world() 挂载)
- `list_worlds(params)``[{value:id, text:name}]`
- `get_world({id})` → 单条
- `create_world(ns)` → 自动生成 id/code、写 created_at
- `update_world(ns)` → 写 updated_at、剔除 `_text` 后缀
- `delete_world({id})`
### wwwroot/api/*.dspy
- `list_worlds.dspy`:世界列表(下拉/菜单)
- `create_world.dspy`:创建
- `world_update.dspy`:更新
- `world_delete.dspy`:删除
- `get_search_world_type.dspy` / `get_search_status.dspy`:字典下拉
## 陷阱
- 库名禁止硬编码,统一 `ServerEnv().get_module_dbname("world")`.py/ `get_module_dbname("world")`.dspy
- dspy 无 importjson/get_sor_context/debug 均为预加载全局)
- `create_world` 必须设置 `created_at = curDateString()`,否则 sor.C 静默丢记录
- `update_world` 需剔除 Tabular 传来的 `_text` 后缀字段
- CRUD json 的 `new_data_url` 指向自定义 `api/create_world.dspy`
## 依赖
- appbaseappcodes 字典、rbac权限