从当前文档或指定文本中提取业务实体。当用户要求识别、提取或分析业务实体、其数据结构及领域模型关系时调用。
识别并结构化文本中的核心业务对象,为领域驱动设计 (DDD)、数据库建模或系统集成提供基础依据。
提取结果将自动保存到:
data/business_entities.db(如果安装了 better-sqlite3)data/entities/{source_hash}.json(备选方案)save-extraction.mjs 脚本保存结果到数据库或文件。提取完成后,调用存储脚本保存结果:
node save-extraction.mjs --source "<source_file>" --output "<output_file>"
CREATE TABLE business_entities (
id INTEGER PRIMARY KEY AUTOINCREMENT,
entity_name TEXT NOT NULL,
source_file TEXT,
source_hash TEXT,
business_description TEXT,
attributes TEXT, -- JSON
lifecycle TEXT, -- JSON
relationships TEXT, -- JSON
data_flow TEXT, -- JSON
related_systems TEXT, -- JSON
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE entity_relationships (
id INTEGER PRIMARY KEY AUTOINCREMENT,
source_entity TEXT NOT NULL,
target_entity TEXT NOT NULL,
relationship_type TEXT NOT NULL,
description TEXT,
source_hash TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
save-extraction.mjs 保存结果# 从文件提取并保存
node save-extraction.mjs --input document.md --output entities.json
# 查看已保存的实体
node save-extraction.mjs --list
# 按来源查询
node save-extraction.mjs --query "fidelity"