- 将 shangshu-ontology/ 子目录内容移至仓库根一级 - 修复 run.sh 的 REPO_ROOT 计算(扁平化后不再需要 cd ..),ARCHIVE_DIR 正确指向仓库根/archive - 文档(README/PLAN/USAGE/IMPORT/product-intro)移至 docs/,同步更新结构树与导入命令中的旧路径 - 新增根 README.md 索引指向 docs/ - 新增 .gitignore:忽略 bin/、web/node_modules/、web/dist/、server/webroot/、.env、.workbuddy/ 等噪音 - main.go 的 ARCHIVE_DIR fallback 基于可执行文件相邻上级,扁平化后仍正确,无需改动
160 lines
6.0 KiB
Go
160 lines
6.0 KiB
Go
package main
|
||
|
||
import "time"
|
||
|
||
// ============ 本体语义层模型(参考 Palantir Ontology) ============
|
||
|
||
// ObjectType 对象类型:现实世界实体/事件的 Schema 定义。
|
||
type ObjectType struct {
|
||
ID int64 `json:"id"`
|
||
APIName string `json:"api_name"` // 稳定外部标识,如 DataResource
|
||
DisplayName string `json:"display_name"`
|
||
Description string `json:"description"`
|
||
Icon string `json:"icon"` // 前端展示用 emoji 或图标名
|
||
Group string `json:"group"` // 分类分组,便于浏览
|
||
CreatedAt time.Time `json:"created_at"`
|
||
UpdatedAt time.Time `json:"updated_at"`
|
||
Properties []Property `json:"properties,omitempty"`
|
||
}
|
||
|
||
// Property 属性:对象类型的特征字段。
|
||
type Property struct {
|
||
ID int64 `json:"id"`
|
||
ObjectID int64 `json:"object_type_id"`
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
DataType string `json:"data_type"` // string/integer/number/boolean/date/datetime/enum/json/text
|
||
Required bool `json:"required"`
|
||
EnumValues []string `json:"enum_values,omitempty"`
|
||
Description string `json:"description"`
|
||
}
|
||
|
||
// LinkType 链接类型:两个对象类型之间的关系边。
|
||
type LinkType struct {
|
||
ID int64 `json:"id"`
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
SourceType string `json:"source_type"` // 源对象类型 api_name
|
||
TargetType string `json:"target_type"` // 目标对象类型 api_name
|
||
Cardinality string `json:"cardinality"` // one_to_many / many_to_many / one_to_one
|
||
Description string `json:"description"`
|
||
}
|
||
|
||
// ActionType 动作类型(动力层):对对象/属性/链接进行修改的预定义操作。
|
||
type ActionType struct {
|
||
ID int64 `json:"id"`
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
Description string `json:"description"`
|
||
Params string `json:"params"` // JSON 描述参数,如 [{name,type,required}]
|
||
}
|
||
|
||
// Object 对象实例:对象类型的一个具体实体(数字孪生中的一个节点)。
|
||
type Object struct {
|
||
ID int64 `json:"id"`
|
||
ObjectID int64 `json:"object_type_id"`
|
||
TypeAPIName string `json:"type"` // 冗余存储,便于连接器按类型查询
|
||
PK string `json:"pk"` // 该实例在所属类型下的唯一主键
|
||
Properties map[string]interface{} `json:"properties"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
UpdatedAt time.Time `json:"updated_at"`
|
||
}
|
||
|
||
// Link 链接实例:两个对象实例之间的具体关系。
|
||
type Link struct {
|
||
ID int64 `json:"id"`
|
||
LinkType string `json:"type"` // link type api_name
|
||
SourceType string `json:"source_type"`
|
||
SourcePK string `json:"source_pk"`
|
||
TargetType string `json:"target_type"`
|
||
TargetPK string `json:"target_pk"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
}
|
||
|
||
// ============ AI 摄取相关 ============
|
||
|
||
// Ingestion AI 摄取任务记录。
|
||
type Ingestion struct {
|
||
ID int64 `json:"id"`
|
||
Title string `json:"title"`
|
||
RawText string `json:"raw_text"`
|
||
Directive string `json:"directive"` // 用户的更新要求
|
||
Mode string `json:"mode"` // auto(直接应用) / review(仅建议)
|
||
Status string `json:"status"` // pending / applied / failed / reviewed
|
||
Provider string `json:"provider"` // openai / heuristic
|
||
ResultJSON string `json:"result_json"`
|
||
Summary string `json:"summary"`
|
||
CreatedAt time.Time `json:"created_at"`
|
||
AppliedAt *time.Time `json:"applied_at"`
|
||
}
|
||
|
||
// AISuggestion AI 抽取结果结构(与后端抽取提示词对齐)。
|
||
type AISuggestion struct {
|
||
ObjectTypes []AISuggestedType `json:"object_types"`
|
||
LinkTypes []AISuggestedLink `json:"link_types"`
|
||
ActionTypes []AISuggestedAction `json:"action_types"`
|
||
Objects []AISuggestedObject `json:"objects"`
|
||
Links []AISuggestedLinkInst `json:"links"`
|
||
Summary string `json:"summary"`
|
||
}
|
||
|
||
type AISuggestedType struct {
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
Description string `json:"description"`
|
||
Group string `json:"group"`
|
||
Icon string `json:"icon"`
|
||
Properties []AISuggestedProp `json:"properties"`
|
||
}
|
||
type AISuggestedProp struct {
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
DataType string `json:"data_type"`
|
||
Required bool `json:"required"`
|
||
EnumValues []string `json:"enum_values"`
|
||
Description string `json:"description"`
|
||
}
|
||
type AISuggestedLink struct {
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
SourceType string `json:"source_type"`
|
||
TargetType string `json:"target_type"`
|
||
Cardinality string `json:"cardinality"`
|
||
Description string `json:"description"`
|
||
}
|
||
type AISuggestedAction struct {
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
Description string `json:"description"`
|
||
Params string `json:"params"`
|
||
}
|
||
type AISuggestedObject struct {
|
||
Type string `json:"type"`
|
||
PK string `json:"pk"`
|
||
Properties map[string]interface{} `json:"properties"`
|
||
}
|
||
type AISuggestedLinkInst struct {
|
||
Type string `json:"type"`
|
||
SourceType string `json:"source_type"`
|
||
SourcePK string `json:"source_pk"`
|
||
TargetType string `json:"target_type"`
|
||
TargetPK string `json:"target_pk"`
|
||
}
|
||
|
||
// ============ 连接器 / MCP ============
|
||
|
||
// ConnectorObjectType 连接器精简视图:应用只关心类型名+属性。
|
||
type ConnectorObjectType struct {
|
||
APIName string `json:"api_name"`
|
||
DisplayName string `json:"display_name"`
|
||
Description string `json:"description"`
|
||
Properties []Property `json:"properties"`
|
||
}
|
||
|
||
// MCPTool MCP 工具清单中的单个工具描述(供 WorkBuddy 等接入)。
|
||
type MCPTool struct {
|
||
Name string `json:"name"`
|
||
Description string `json:"description"`
|
||
InputSchema map[string]interface{} `json:"inputSchema"`
|
||
}
|