refactor: 重构resource/domain为resource/role - 提升目录语义化

## 核心改进
- 将resource/domain重命名为resource/role,语义更清晰直观
- 统一更新所有硬编码路径引用,确保系统完整性
- 重新生成注册表,所有61个资源引用路径完全更新

## 目录结构优化
- resource/role (原domain) - 角色定义和专家能力
- resource/tool - JavaScript工具资源
- resource/protocol - 协议规范文档
- resource/core - 核心思维和执行模式

## 技术实现
### 发现器更新
- ProjectDiscovery.js: _scanDomainDirectory → _scanRoleDirectory
- PackageDiscovery.js: 同步更新函数名和路径引用
- 所有@project://.promptx/resource/domain/ → @project://.promptx/resource/role/
- 所有@package://resource/domain/ → @package://resource/role/

### 协议处理器
- PromptProtocol.js: domain注册表映射 → role注册表映射
- 更新协议示例和描述信息

### 注册表重新生成
- 使用generate-package-registry.js重新生成
- 61个资源路径引用全部更新为resource/role/
- 保持所有功能完全兼容

## 验证结果
-  角色发现功能正常:8个系统角色+1个项目角色
-  资源加载完全正常:61个资源正确识别
-  零功能影响:所有现有功能继续工作

这个重构显著提升了代码的语义化程度,role比domain更直观地表达目录用途,
同时建立了清晰的资源分类体系:role、tool、protocol、core。

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
sean
2025-06-28 15:24:19 +08:00
parent 808c5af9fa
commit 559c146af1
58 changed files with 264 additions and 264 deletions

View File

@ -353,31 +353,31 @@ class ProjectDiscovery extends BaseDiscovery {
* @private
*/
async _scanDirectory(resourcesDir, registryData) {
// 扫描domain目录
const domainDir = path.join(resourcesDir, 'domain')
if (await this._fsExists(domainDir)) {
await this._scanDomainDirectory(domainDir, registryData)
// 扫描role目录
const roleDir = path.join(resourcesDir, 'role')
if (await this._fsExists(roleDir)) {
await this._scanRoleDirectory(roleDir, registryData)
}
}
/**
* 扫描domain目录(项目角色资源)
* @param {string} domainDir - domain目录路径
* 扫描role目录(项目角色资源)
* @param {string} roleDir - role目录路径
* @param {RegistryData} registryData - 注册表数据
* @private
*/
async _scanDomainDirectory(domainDir, registryData) {
const items = await fs.readdir(domainDir)
async _scanRoleDirectory(roleDir, registryData) {
const items = await fs.readdir(roleDir)
for (const item of items) {
const itemPath = path.join(domainDir, item)
const itemPath = path.join(roleDir, item)
const stat = await fs.stat(itemPath)
if (stat.isDirectory()) {
// 查找role文件
const roleFile = path.join(itemPath, `${item}.role.md`)
if (await this._fsExists(roleFile)) {
const reference = `@project://.promptx/resource/domain/${item}/${item}.role.md`
const reference = `@project://.promptx/resource/role/${item}/${item}.role.md`
const resourceData = new ResourceData({
id: item,
@ -401,7 +401,7 @@ class ProjectDiscovery extends BaseDiscovery {
for (const thoughtFile of thoughtFiles) {
if (thoughtFile.endsWith('.thought.md')) {
const thoughtId = path.basename(thoughtFile, '.thought.md')
const reference = `@project://.promptx/resource/domain/${item}/thought/${thoughtFile}`
const reference = `@project://.promptx/resource/role/${item}/thought/${thoughtFile}`
const resourceData = new ResourceData({
id: thoughtId,
@ -427,7 +427,7 @@ class ProjectDiscovery extends BaseDiscovery {
for (const execFile of executionFiles) {
if (execFile.endsWith('.execution.md')) {
const execId = path.basename(execFile, '.execution.md')
const reference = `@project://.promptx/resource/domain/${item}/execution/${execFile}`
const reference = `@project://.promptx/resource/role/${item}/execution/${execFile}`
const resourceData = new ResourceData({
id: execId,
@ -453,7 +453,7 @@ class ProjectDiscovery extends BaseDiscovery {
for (const knowledgeFile of knowledgeFiles) {
if (knowledgeFile.endsWith('.knowledge.md')) {
const knowledgeId = path.basename(knowledgeFile, '.knowledge.md')
const reference = `@project://.promptx/resource/domain/${item}/knowledge/${knowledgeFile}`
const reference = `@project://.promptx/resource/role/${item}/knowledge/${knowledgeFile}`
const resourceData = new ResourceData({
id: knowledgeId,