ai_member_xiaoyan/skills/interactive-component-json/SKILL.md

128 lines
4.6 KiB
Markdown
Raw 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: interactive-component-json
version: 0.1.0
description: >
互动组件配置JSON生成器全量版。覆盖约30种互动组件类型从规范化的原始剧本格式出发
经过组件类型匹配、知识点匹配、AI衍生字段生产最终输出符合系统要求的组件配置JSON
并持久化到本地SQLite数据库。组件类型采用注册机制支持逐步扩展。
metadata:
requires:
tools: ["exec", "read", "write"]
identity: bot
---
# 互动组件配置JSON生成器
## 概述
本skill实现从**原始剧本格式** → **结构化组件配置JSON**的完整生产流水线。
覆盖全部约30种互动组件类型采用**注册机制**逐步扩展。
### 核心流程
```
原始剧本文本
[1] 组件类型识别与匹配(基于注册表)
[2] 知识点提取与匹配(词库/句型库校验)
[3] AI衍生字段生产基于组件类型专属prompt
[4] 组件配置JSON生成按schema校验
[5] 写入本地SQLite数据库
(后续) HTML预览 / 推送公司数据库
```
## 目录结构
```
interactive-component-json/
├── SKILL.md # 本文件 - skill入口与总览
├── references/ # 参考文档
│ ├── component_registry.md # 🔑 组件类型注册表(全量,逐步填充)
│ ├── script_format_spec.md # 原始剧本格式规范(输入格式定义)
│ └── json_output_spec.md # 最终JSON输出格式规范输出格式定义
├── prompts/ # AI衍生字段生产的提示词按组件类型分文件
│ ├── README.md # 提示词目录说明
│ └── {component_type}.md # 各组件类型的衍生字段prompt逐步添加
├── schemas/ # JSON Schema定义按组件类型
│ ├── common.json # 公共字段schema
│ └── {component_type}.json # 各组件类型的专属schema逐步添加
├── scripts/ # 自动化脚本
│ ├── db_manager.py # SQLite数据库管理建表/读写/查询)
│ ├── parse_script.py # 剧本文本解析器
│ ├── match_component.py # 组件类型匹配器
│ ├── match_knowledge.py # 知识点匹配器
│ ├── generate_json.py # JSON配置生成器
│ └── validate_json.py # JSON校验器
└── db/
└── components.db # SQLite数据库运行时生成
```
## 组件类型注册机制
### 设计理念
- 不硬编码组件类型列表,通过**注册表**`references/component_registry.md`)统一管理
- 每新增一种组件类型需要注册3项
1. 在注册表中添加类型定义(标识、名称、匹配规则、字段列表)
2.`prompts/` 中添加对应的AI衍生prompt
3.`schemas/` 中添加对应的JSON Schema
- 注册表是**唯一的类型真相源**,所有脚本从注册表读取类型信息
### 当前注册进度
详见 `references/component_registry.md`
## 数据库设计SQLite
### 表结构
1. **`components`** — 组件主表
- component_id, script_id, component_index
- component_type, component_subtype, level, unit_id
- raw_text, parsed_data(JSON), knowledge_points(JSON)
- ai_derived_fields(JSON), final_config_json(JSON)
- status: draft → parsed → matched → generated → validated → exported
- created_at, updated_at
2. **`generation_logs`** — 生成日志表
- log_id, component_id, step, input/output摘要, model_used, success, error
### 操作入口
```bash
python3 scripts/db_manager.py init # 初始化
python3 scripts/db_manager.py stats # 统计
python3 scripts/db_manager.py list # 列表
```
## 开发计划
### Phase 1: 基础框架 ← 当前阶段
- [x] 目录结构
- [x] 数据库DDL与基础操作
- [x] 组件注册表框架
- [ ] 逐步注册组件类型(随参考文件提供)
### Phase 2: 输入输出格式定义
- [ ] 原始剧本格式规范(需提供样例)
- [ ] 目标JSON格式规范需提供样例
### Phase 3: 解析与匹配引擎
- [ ] 剧本文本解析器
- [ ] 组件类型匹配器
- [ ] 知识点匹配器
### Phase 4: AI衍生字段生产
- [ ] 各组件类型的prompt模板逐步添加
- [ ] AI调用流程
### Phase 5: JSON生成与校验
- [ ] JSON Schema逐步添加
- [ ] 配置JSON生成器 + 校验器
### Phase 6: 扩展
- [ ] HTML预览
- [ ] 公司数据库推送