px2cc 2.2.4 → 2.2.5

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/cli.js CHANGED
@@ -186,11 +186,17 @@ async function showRoleMenu(systemRoles, userRoles, availableServers) {
186
186
  },
187
187
  {
188
188
  name: `⚙️ Command - 通过 /${roleAnswer.selectedRole.role} 调用`,
189
- value: 'commands',
189
+ value: 'commands',
190
190
  short: 'Command'
191
191
  }
192
192
  ]
193
193
  },
194
+ {
195
+ type: 'confirm',
196
+ name: 'includeKnowledge',
197
+ message: '是否包含专业知识(Knowledge)?(知识内容可能较多,会增加文件大小)',
198
+ default: true
199
+ },
194
200
  {
195
201
  type: 'confirm',
196
202
  name: 'customName',
@@ -246,6 +252,7 @@ async function showRoleMenu(systemRoles, userRoles, availableServers) {
246
252
  return {
247
253
  selectedRole: roleAnswer.selectedRole,
248
254
  installType: typeAnswer.installType,
255
+ includeKnowledge: typeAnswer.includeKnowledge,
249
256
  confirm: confirmAnswer.confirm,
250
257
  customName: customName,
251
258
  selectedTools: selectedTools
@@ -268,7 +275,7 @@ function checkDirectory() {
268
275
  }
269
276
 
270
277
  // 安装角色
271
- async function installRole(selectedRole, installType, claudeDir, selectedTools, customName = '') {
278
+ async function installRole(selectedRole, installType, claudeDir, selectedTools, customName = '', includeKnowledge = true) {
272
279
  const roleName = selectedRole.role;
273
280
  const results = {};
274
281
 
@@ -276,7 +283,7 @@ async function installRole(selectedRole, installType, claudeDir, selectedTools,
276
283
  // 使用新的PromptXActionProcessor执行完整的action流程
277
284
  const processor = new PromptXActionProcessor();
278
285
  const mode = installType === 'agents' ? 'subagent' : 'command';
279
- const processedContent = await processor.processRole(roleName, mode);
286
+ const processedContent = await processor.processRole(roleName, mode, { includeKnowledge });
280
287
 
281
288
  // 根据安装模式创建相应文件
282
289
  const finalName = customName || (installType === 'agents' ? `${roleName}-agent` : roleName);
@@ -376,7 +383,7 @@ export async function main() {
376
383
  console.log(`📊 发现 ${chalk.bold(systemRoles.length)} 个系统角色,${chalk.bold(userRoles.length)} 个用户角色\n`);
377
384
 
378
385
  // 显示角色选择
379
- const { selectedRole, installType, confirm, selectedTools, customName } = await showRoleMenu(systemRoles, userRoles, availableServers);
386
+ const { selectedRole, installType, includeKnowledge, confirm, selectedTools, customName } = await showRoleMenu(systemRoles, userRoles, availableServers);
380
387
 
381
388
  if (!confirm) {
382
389
  console.log(chalk.yellow('\n👋 安装已取消'));
@@ -387,9 +394,12 @@ export async function main() {
387
394
  const claudeDir = checkDirectory();
388
395
 
389
396
  console.log(chalk.blue(`\n🎭 开始安装角色: ${selectedRole.role} (${installType})`));
397
+ if (!includeKnowledge) {
398
+ console.log(chalk.gray(' 📚 不包含专业知识(Knowledge)'));
399
+ }
390
400
 
391
401
  // 安装角色
392
- const result = await installRole(selectedRole, installType, claudeDir, selectedTools, customName);
402
+ const result = await installRole(selectedRole, installType, claudeDir, selectedTools, customName, includeKnowledge);
393
403
 
394
404
  console.log(chalk.green.bold('\n✅ 角色安装完成!'));
395
405
  console.log(`\n📄 生成的文件:`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "px2cc",
3
- "version": "2.2.4",
3
+ "version": "2.2.5",
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",
@@ -319,9 +319,12 @@ class LayerAssembler {
319
319
  * @param {Object} dependencies - 依赖资源
320
320
  * @param {Object} cognitionData - 认知数据
321
321
  * @param {string} mode - 模式 (command|subagent)
322
+ * @param {Object} options - 选项
323
+ * @param {boolean} options.includeKnowledge - 是否包含知识内容
322
324
  * @returns {string} 组装后的内容
323
325
  */
324
- assembleContent(roleInfo, dependencies, cognitionData, mode = 'command') {
326
+ assembleContent(roleInfo, dependencies, cognitionData, mode = 'command', options = {}) {
327
+ const { includeKnowledge = true } = options;
325
328
  const parts = [];
326
329
 
327
330
  // 标题部分
@@ -398,6 +401,20 @@ class LayerAssembler {
398
401
  });
399
402
  }
400
403
 
404
+ if (includeKnowledge && dependencies.knowledges.length > 0) {
405
+ parts.push('## 📚 专业知识');
406
+ dependencies.knowledges.forEach(knowledge => {
407
+ parts.push(`### ${knowledge.id}`);
408
+ parts.push(this.cleanContent(knowledge.content));
409
+ parts.push('');
410
+ });
411
+ } else if (!includeKnowledge && dependencies.knowledges.length > 0) {
412
+ parts.push('## 📚 专业知识');
413
+ parts.push(`> ℹ️ 该角色包含 ${dependencies.knowledges.length} 个知识模块,已按用户选择跳过加载。`);
414
+ parts.push(`> 知识模块: ${dependencies.knowledges.map(k => k.id).join(', ')}`);
415
+ parts.push('');
416
+ }
417
+
401
418
  // StateLayer - 状态信息
402
419
  parts.push('---');
403
420
  parts.push('');
@@ -469,11 +486,18 @@ export class PromptXActionProcessor {
469
486
  * 执行完整的PromptX Action流程
470
487
  * @param {string} roleId - 角色ID
471
488
  * @param {string} mode - 模式 (command|subagent)
489
+ * @param {Object} options - 选项
490
+ * @param {boolean} options.includeKnowledge - 是否包含知识内容(默认true)
472
491
  * @returns {string} 处理后的内容
473
492
  */
474
- async processRole(roleId, mode = 'command') {
493
+ async processRole(roleId, mode = 'command', options = {}) {
494
+ const { includeKnowledge = true } = options;
495
+
475
496
  try {
476
497
  console.log(chalk.blue(`\n🎭 开始执行 ${roleId} 的 PromptX Action 流程 (${mode} 模式)`));
498
+ if (!includeKnowledge) {
499
+ console.log(chalk.gray(` 📚 跳过知识内容加载`));
500
+ }
477
501
 
478
502
  // 1. 加载角色定义
479
503
  const roleInfo = await this.roleLoader.loadRole(roleId);
@@ -485,7 +509,7 @@ export class PromptXActionProcessor {
485
509
  const cognitionData = await this.cognitionLoader.checkNetworkExists(roleId);
486
510
 
487
511
  // 4. 三层组装
488
- const content = this.layerAssembler.assembleContent(roleInfo, dependencies, cognitionData, mode);
512
+ const content = this.layerAssembler.assembleContent(roleInfo, dependencies, cognitionData, mode, { includeKnowledge });
489
513
 
490
514
  console.log(chalk.green(`✅ PromptX Action 流程完成!`));
491
515