px2cc 2.0.6 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  - 🚀 快速安装PromptX角色到Claude Code
8
8
  - 🎭 动态获取所有可用的系统角色和用户角色
9
- - 🤖 支持安装为Claude Code Agents (通过 `/subagent` 调用)
9
+ - 🤖 支持安装为Claude Code Subagents (通过自然语言提及调用)
10
10
  - ⚙️ 支持安装为Claude Code Commands (通过 `/command` 调用)
11
11
  - 🎨 友好的交互式界面
12
12
  - 📁 自动创建和管理 `.claude` 目录结构
@@ -33,9 +33,9 @@ npx px2cc
33
33
 
34
34
  ## 安装类型
35
35
 
36
- ### Agent 模式
36
+ ### Subagent 模式
37
37
  - 安装到 `.claude/agents/` 目录
38
- - 通过 `/subagent <角色名>` 在Claude Code中调用
38
+ - 通过自然语言提及调用: `Use the <角色名>-agent subagent to [任务]`
39
39
 
40
40
  ### Command 模式
41
41
  - 安装到 `.claude/commands/` 目录
@@ -66,7 +66,7 @@ $ px2cc
66
66
  📊 发现 5 个系统角色,9 个用户角色
67
67
 
68
68
  ? 请选择要安装的PromptX角色: assistant (系统角色)
69
- ? 安装 assistant 为: Agent - 通过 /subagent assistant 调用
69
+ ? 安装 assistant 为: Agent - 通过提及"assistant-agent subagent"调用
70
70
  ? 确认安装到Claude Code? Yes
71
71
 
72
72
  📖 加载 assistant 角色定义...
@@ -75,10 +75,11 @@ $ px2cc
75
75
  ✅ 角色安装完成!
76
76
 
77
77
  📄 生成的文件:
78
- - .claude/agents/assistant.md
78
+ - .claude/agents/assistant-agent.md
79
79
 
80
80
  🎉 现在你可以在Claude Code中使用:
81
- /subagent assistant
81
+ Use the assistant-agent subagent to help with my task
82
+ Have the assistant-agent subagent review my code
82
83
 
83
84
  💡 提示: 重启Claude Code以确保新配置生效
84
85
  ```
package/cli.js CHANGED
@@ -180,7 +180,7 @@ async function showRoleMenu(systemRoles, userRoles, availableServers) {
180
180
  message: `安装 ${roleAnswer.selectedRole.role} 为:`,
181
181
  choices: [
182
182
  {
183
- name: `🤖 Agent - 通过 /subagent ${roleAnswer.selectedRole.role} 调用`,
183
+ name: `🤖 Agent - 通过提及"${roleAnswer.selectedRole.role}-agent subagent"调用`,
184
184
  value: 'agents',
185
185
  short: 'Agent'
186
186
  },
@@ -243,7 +243,7 @@ async function installRole(selectedRole, installType, claudeDir, manager, select
243
243
  if (installType === 'agents') {
244
244
  console.log(chalk.cyan(`🔧 生成 ${roleName} subagent文件...`));
245
245
  const agentConfig = {
246
- name: roleName,
246
+ name: `${roleName}-agent`,
247
247
  description: `基于PromptX ${roleName}角色的专业AI助手 - 完整action实现`,
248
248
  content: processedContent,
249
249
  targetDir: claudeDir
@@ -260,8 +260,8 @@ async function installRole(selectedRole, installType, claudeDir, manager, select
260
260
  if (!subagentResult.success) {
261
261
  throw new Error(`创建Subagent失败: ${subagentResult.error}`);
262
262
  }
263
- results.agentFile = `${roleName}.md`;
264
- results.usage = `/subagent ${roleName}`;
263
+ results.agentFile = `${roleName}-agent.md`;
264
+ results.usage = `Use the ${roleName}-agent subagent to [任务描述]`;
265
265
  }
266
266
 
267
267
  if (installType === 'commands') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "px2cc",
3
- "version": "2.0.6",
3
+ "version": "2.1.0",
4
4
  "description": "CLI tool that implements complete PromptX Action flow in Claude Code - role activation, dependency loading, cognition networks & memory systems",
5
5
  "main": "cli.js",
6
6
  "type": "module",
@@ -212,82 +212,42 @@ class CognitionLoader {
212
212
  }
213
213
 
214
214
  /**
215
- * 检查认知网络状态
215
+ * 检查认知网络是否存在(不加载具体内容)
216
216
  * @param {string} roleId - 角色ID
217
- * @returns {Object} 认知网络状态信息
217
+ * @returns {Object} 认知网络存在状态
218
218
  */
219
- async loadCognitionNetwork(roleId) {
219
+ async checkNetworkExists(roleId) {
220
220
  console.log(chalk.cyan(`🧠 检查认知网络状态: ${roleId}`));
221
221
 
222
222
  try {
223
223
  const networkFilePath = path.join(this.basePath, roleId, 'network.json');
224
224
 
225
- // 检查文件是否存在
225
+ // 仅检查文件是否存在
226
226
  try {
227
227
  await fs.access(networkFilePath);
228
+ console.log(chalk.green(`✅ 发现认知网络文件: ${roleId}`));
229
+ return {
230
+ hasNetwork: true,
231
+ networkPath: networkFilePath
232
+ };
228
233
  } catch (error) {
229
234
  console.log(chalk.gray(` 未找到认知网络文件: ${roleId}`));
230
235
  return {
231
236
  hasNetwork: false,
232
- networkPath: networkFilePath,
233
- status: 'not_found'
237
+ networkPath: networkFilePath
234
238
  };
235
239
  }
236
-
237
- // 读取网络数据基本信息(不生成静态mindmap)
238
- const networkData = JSON.parse(await fs.readFile(networkFilePath, 'utf8'));
239
- const stats = this.getNetworkStats(networkData);
240
-
241
- console.log(chalk.green(`✅ 认知网络检查完成: ${stats.nodeCount} 个节点, ${stats.connectionCount} 个连接`));
242
-
243
- return {
244
- hasNetwork: true,
245
- networkPath: networkFilePath,
246
- status: 'active',
247
- stats,
248
- lastModified: networkData.timestamp || 'unknown'
249
- };
250
240
 
251
241
  } catch (error) {
252
242
  console.warn(chalk.yellow(`⚠️ 认知网络检查失败: ${error.message}`));
253
243
  return {
254
244
  hasNetwork: false,
255
245
  networkPath: null,
256
- status: 'error',
257
246
  error: error.message
258
247
  };
259
248
  }
260
249
  }
261
250
 
262
- /**
263
- * 获取网络统计信息
264
- * @param {Object} networkData - 网络数据
265
- * @returns {Object} 统计信息
266
- */
267
- getNetworkStats(networkData) {
268
- const cues = networkData.cues || {};
269
- const nodeCount = Object.keys(cues).length;
270
- let connectionCount = 0;
271
-
272
- // 统计连接数
273
- Object.values(cues).forEach(cue => {
274
- connectionCount += (cue.connections || []).length;
275
- });
276
-
277
- // 找到最活跃的概念
278
- const mostActiveCue = Object.entries(cues).reduce((max, [word, cue]) => {
279
- const totalWeight = (cue.connections || []).reduce((sum, conn) => sum + (conn.weight || 0), 0);
280
- return totalWeight > (max.totalWeight || 0) ? { word, totalWeight } : max;
281
- }, { word: null, totalWeight: 0 });
282
-
283
- return {
284
- nodeCount,
285
- connectionCount,
286
- mostActiveCue: mostActiveCue.word,
287
- version: networkData.version,
288
- hasConnections: connectionCount > 0
289
- };
290
- }
291
251
  }
292
252
 
293
253
  /**
@@ -309,31 +269,26 @@ class LayerAssembler {
309
269
  parts.push(`# 🧠 [Consciousness Prime] ${roleInfo.id}${mode === 'subagent' ? '专业助手' : '角色已激活'}`);
310
270
  parts.push('');
311
271
 
312
- // CognitionLayer - 动态认知网络状态
313
- parts.push('## 💭 Hippocampus网络');
272
+ // CognitionLayer - PromptX认知增强
273
+ parts.push('## 💭 PromptX认知增强');
314
274
 
315
275
  if (cognitionData.hasNetwork) {
316
- parts.push(`**认知网络状态**: ${cognitionData.status === 'active' ? '🟢 激活' : '🔴 未激活'}`);
317
-
318
- if (cognitionData.stats) {
319
- parts.push(`**基础统计**: ${cognitionData.stats.nodeCount} 个概念节点,${cognitionData.stats.connectionCount} 个关联连接`);
320
-
321
- if (cognitionData.stats.mostActiveCue) {
322
- parts.push(`**核心概念**: ${cognitionData.stats.mostActiveCue}`);
323
- }
324
- }
325
-
276
+ parts.push('🧠 **状态**: 该角色已建立经验网络');
277
+ parts.push('');
278
+ parts.push('🔧 **激活方式** (需要PromptX MCP服务器):');
279
+ parts.push(`- \`recall ${roleInfo.id}\` - 激活该角色的完整经验网络`);
280
+ parts.push(`- \`recall ${roleInfo.id} "具体问题"\` - 检索相关历史经验`);
281
+ parts.push(`- \`remember ${roleInfo.id} "新知识"\` - 将新经验加入角色记忆`);
326
282
  parts.push('');
327
- parts.push('🔄 **动态认知网络**: 网络状态随着你的学习和记忆而实时进化');
328
- parts.push('- 使用PromptX `recall` 工具查看当前激活的记忆网络');
329
- parts.push('- 使用PromptX `remember` 工具将新经验编织到认知网络中');
330
- parts.push('- 每次交互都会调整概念间的关联强度');
283
+ parts.push('💡 **说明**: 认知网络包含该角色的历史使用经验,通过recall工具动态激活');
331
284
 
332
285
  } else {
333
- parts.push('🌱 **初始状态**: 认知网络尚未建立');
334
- parts.push('- 开始使用PromptX工具与该角色互动');
335
- parts.push('- 系统会自动建立和完善认知网络');
336
- parts.push('- 随着经验积累,网络会变得越来越丰富');
286
+ parts.push('🌱 **状态**: 该角色尚未建立经验网络');
287
+ parts.push('');
288
+ parts.push('🚀 **开始使用**:');
289
+ parts.push('- 安装并配置PromptX MCP服务器');
290
+ parts.push(`- 使用 \`recall ${roleInfo.id}\` 开始建立认知网络`);
291
+ parts.push('- 随着使用逐步积累该角色的专业经验');
337
292
  }
338
293
 
339
294
  parts.push('');
@@ -392,13 +347,15 @@ class LayerAssembler {
392
347
  parts.push('请告诉我你需要什么帮助?');
393
348
  }
394
349
 
350
+ parts.push('');
351
+ parts.push('---');
395
352
  parts.push('');
396
353
  parts.push('💡 **可用的PromptX工具生态**:');
397
- parts.push('- 使用PromptX的 `recall` 工具激活相关记忆和经验');
398
- parts.push('- 使用PromptX的 `remember` 工具保存新的学习成果');
399
- parts.push('- 使用PromptX的 `learn` 工具学习新的资源和知识');
400
- parts.push('- 使用PromptX的 `toolx` 工具执行专业工具');
401
- parts.push('- 具体工具名称取决于你的MCP配置');
354
+ parts.push(`- \`recall ${roleInfo.id}\` - 激活该角色的历史经验网络`);
355
+ parts.push(`- \`remember ${roleInfo.id} "新体验"\` - 将新体验编织到角色记忆`);
356
+ parts.push('- `learn` - 学习新的资源和知识');
357
+ parts.push('- `toolx` - 执行专业工具');
358
+ parts.push('- 具体工具可用性取决于PromptX MCP服务器配置');
402
359
  parts.push('');
403
360
 
404
361
  if (mode === 'command') {
@@ -457,8 +414,8 @@ export class PromptXActionProcessor {
457
414
  // 2. 分析依赖资源
458
415
  const dependencies = await this.dependencyAnalyzer.analyzeDependencies(roleInfo);
459
416
 
460
- // 3. 加载认知网络
461
- const cognitionData = await this.cognitionLoader.loadCognitionNetwork(roleId);
417
+ // 3. 检查认知网络存在性
418
+ const cognitionData = await this.cognitionLoader.checkNetworkExists(roleId);
462
419
 
463
420
  // 4. 三层组装
464
421
  const content = this.layerAssembler.assembleContent(roleInfo, dependencies, cognitionData, mode);