claude-pangu 1.0.6 → 1.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-pangu",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "基于中国传统文化的 Claude Code 智能编排插件 - A Claude Code plugin inspired by Chinese traditional culture (原名 oh-my-claude)",
5
5
  "keywords": [
6
6
  "claude-code",
package/scripts/cli.js CHANGED
@@ -12,7 +12,7 @@ const os = require('os');
12
12
 
13
13
  // ==================== 常量配置 ====================
14
14
 
15
- const VERSION = '1.0.6';
15
+ const VERSION = '1.0.8';
16
16
  const PLUGIN_NAME = 'oh-my-claude';
17
17
 
18
18
  // 路径配置
@@ -289,6 +289,18 @@ function getPluginDir() {
289
289
  return path.join(home, '.claude', 'plugins', PLUGIN_NAME);
290
290
  }
291
291
 
292
+ // 获取 commands 安装路径
293
+ function getCommandsDir() {
294
+ const home = os.homedir();
295
+ return path.join(home, '.claude', 'commands', 'zcf');
296
+ }
297
+
298
+ // 获取 skills 安装路径
299
+ function getSkillsDir() {
300
+ const home = os.homedir();
301
+ return path.join(home, '.claude', 'skills');
302
+ }
303
+
292
304
  // 获取当前包的路径
293
305
  function getPackageDir() {
294
306
  return path.resolve(__dirname, '..');
@@ -401,6 +413,154 @@ function setHookPermissions(pluginDir) {
401
413
  }
402
414
  }
403
415
 
416
+ /**
417
+ * 安装 slash commands 到 ~/.claude/commands/zcf/
418
+ * @param {string} packageDir - 源目录
419
+ * @returns {Object} 安装结果
420
+ */
421
+ function installCommands(packageDir) {
422
+ const commandsDir = getCommandsDir();
423
+ const commandsSrc = path.join(packageDir, 'commands');
424
+ const stats = { count: 0, errors: [] };
425
+
426
+ info('正在安装 slash commands...');
427
+
428
+ // 创建 commands 目录
429
+ if (!fs.existsSync(commandsDir)) {
430
+ fs.mkdirSync(commandsDir, { recursive: true });
431
+ }
432
+
433
+ // 复制所有 .md 文件
434
+ if (fs.existsSync(commandsSrc)) {
435
+ const mdFiles = fs.readdirSync(commandsSrc).filter(f => f.endsWith('.md'));
436
+ for (const file of mdFiles) {
437
+ try {
438
+ fs.copyFileSync(
439
+ path.join(commandsSrc, file),
440
+ path.join(commandsDir, file)
441
+ );
442
+ stats.count++;
443
+ } catch (err) {
444
+ stats.errors.push(`复制 ${file} 失败: ${err.message}`);
445
+ }
446
+ }
447
+ }
448
+
449
+ if (stats.count > 0) {
450
+ success(`Slash commands 安装完成 (${stats.count} 个命令)`);
451
+ info(`Commands 位置: ${commandsDir}`);
452
+ } else {
453
+ warn('未找到任何命令文件');
454
+ }
455
+
456
+ return stats;
457
+ }
458
+
459
+ /**
460
+ * 安装 skills 到 ~/.claude/skills/
461
+ * @param {string} packageDir - 源目录
462
+ * @returns {Object} 安装结果
463
+ */
464
+ function installSkills(packageDir) {
465
+ const skillsDir = getSkillsDir();
466
+ const skillsSrc = path.join(packageDir, 'skills');
467
+ const stats = { count: 0, errors: [] };
468
+
469
+ info('正在安装 skills...');
470
+
471
+ if (fs.existsSync(skillsSrc)) {
472
+ const skillDirs = fs.readdirSync(skillsSrc, { withFileTypes: true })
473
+ .filter(d => d.isDirectory());
474
+
475
+ for (const skillDir of skillDirs) {
476
+ const skillName = skillDir.name;
477
+ const skillSrcDir = path.join(skillsSrc, skillName);
478
+ const skillDestDir = path.join(skillsDir, skillName);
479
+
480
+ try {
481
+ // 创建 skill 目录
482
+ if (!fs.existsSync(skillDestDir)) {
483
+ fs.mkdirSync(skillDestDir, { recursive: true });
484
+ }
485
+
486
+ // 复制 SKILL.md (如果存在)
487
+ const skillMdSrc = path.join(skillSrcDir, 'SKILL.md');
488
+ if (fs.existsSync(skillMdSrc)) {
489
+ fs.copyFileSync(skillMdSrc, path.join(skillDestDir, 'SKILL.md'));
490
+ }
491
+
492
+ // 复制其他支持文件(排除 skill.json)
493
+ const files = fs.readdirSync(skillSrcDir, { withFileTypes: true })
494
+ .filter(f => f.isFile() && f.name !== 'skill.json');
495
+
496
+ for (const file of files) {
497
+ try {
498
+ fs.copyFileSync(
499
+ path.join(skillSrcDir, file.name),
500
+ path.join(skillDestDir, file.name)
501
+ );
502
+ } catch {
503
+ // 忽略非关键文件的复制错误
504
+ }
505
+ }
506
+
507
+ stats.count++;
508
+ } catch (err) {
509
+ stats.errors.push(`安装 skill ${skillName} 失败: ${err.message}`);
510
+ }
511
+ }
512
+ }
513
+
514
+ if (stats.count > 0) {
515
+ success(`Skills 安装完成 (${stats.count} 个 skill)`);
516
+ info(`Skills 位置: ${skillsDir}`);
517
+ }
518
+
519
+ return stats;
520
+ }
521
+
522
+ /**
523
+ * 验证安装结果
524
+ * @returns {Object} 验证结果
525
+ */
526
+ function verifyInstallation() {
527
+ info('验证安装...');
528
+ const commandsDir = getCommandsDir();
529
+ const result = { success: true, errors: [] };
530
+
531
+ // 检查关键命令文件
532
+ const yishanPath = path.join(commandsDir, 'yishan.md');
533
+ if (fs.existsSync(yishanPath)) {
534
+ success('✓ yishan.md 已安装');
535
+ } else {
536
+ warn('✗ yishan.md 未找到');
537
+ result.errors.push('yishan.md 未找到');
538
+ result.success = false;
539
+ }
540
+
541
+ // 检查命令数量
542
+ if (fs.existsSync(commandsDir)) {
543
+ const cmdFiles = fs.readdirSync(commandsDir).filter(f => f.endsWith('.md'));
544
+ if (cmdFiles.length > 0) {
545
+ success(`✓ 已安装 ${cmdFiles.length} 个命令`);
546
+ } else {
547
+ warn('✗ 未检测到任何命令文件');
548
+ result.errors.push('未检测到命令文件');
549
+ result.success = false;
550
+ }
551
+ } else {
552
+ warn('✗ commands 目录不存在');
553
+ result.errors.push('commands 目录不存在');
554
+ result.success = false;
555
+ }
556
+
557
+ if (!result.success) {
558
+ warn('安装可能不完整,请检查上述警告');
559
+ }
560
+
561
+ return result;
562
+ }
563
+
404
564
  /**
405
565
  * 注册插件到 Claude Code
406
566
  * @param {string} pluginDir - 插件目录
@@ -631,14 +791,37 @@ function install() {
631
791
  process.exit(1);
632
792
  }
633
793
 
634
- // 注册插件
635
- registerPlugin(pluginDir);
794
+ // 安装 commands 到 ~/.claude/commands/zcf/
795
+ installCommands(packageDir);
796
+
797
+ // 安装 skills 到 ~/.claude/skills/
798
+ installSkills(packageDir);
636
799
 
800
+ // 验证安装
801
+ verifyInstallation();
802
+
803
+ // 显示完成信息
637
804
  log('\n🎉 安装完成!', 'green');
638
- log('━'.repeat(DIVIDER_LENGTH), 'cyan');
639
- info('使用 /yishan 或 /愚公 开始愚公移山模式');
640
- info('使用 /zhuge /诸葛 召唤诸葛顾问');
641
- info('查看所有命令: 阅读 README.md\n');
805
+ log('━'.repeat(DIVIDER_LENGTH), 'green');
806
+ log('');
807
+ warn('⚠️ 重要:请完全退出并重新启动 Claude Code 以加载新命令');
808
+ warn(' (仅关闭窗口可能不够,需要完全退出应用)');
809
+ if (os.platform() === 'darwin') {
810
+ warn(' macOS: 使用 Cmd+Q 完全退出应用');
811
+ }
812
+ log('');
813
+ log('快速开始(使用 /zcf: 前缀):', 'cyan');
814
+ info(' /zcf:yishan - 愚公移山模式(大规模任务)');
815
+ info(' /zcf:zhuge - 诸葛顾问(架构设计)');
816
+ info(' /zcf:bianque - 扁鹊诊断(调试问题)');
817
+ info(' /zcf:luban - 鲁班巧工(前端开发)');
818
+ info(' /zcf:wukong - 悟空探索(代码搜索)');
819
+ log('');
820
+ log('安装位置:', 'cyan');
821
+ info(` Commands: ${getCommandsDir()}`);
822
+ info(` Skills: ${getSkillsDir()}`);
823
+ info(` Plugin: ${pluginDir}`);
824
+ log('');
642
825
  }
643
826
 
644
827
  // 执行卸载操作
@@ -763,6 +946,24 @@ function update() {
763
946
  process.exit(1);
764
947
  }
765
948
 
949
+ // 更新 commands 到 ~/.claude/commands/zcf/
950
+ installCommands(packageDir);
951
+
952
+ // 更新 skills 到 ~/.claude/skills/
953
+ installSkills(packageDir);
954
+
955
+ // 验证安装
956
+ verifyInstallation();
957
+
958
+ // 显示完成信息
959
+ log('\n🎉 更新完成!', 'green');
960
+ log('━'.repeat(DIVIDER_LENGTH), 'green');
961
+ log('');
962
+ warn('⚠️ 重要:请完全退出并重新启动 Claude Code 以加载新命令');
963
+ warn(' (仅关闭窗口可能不够,需要完全退出应用)');
964
+ if (os.platform() === 'darwin') {
965
+ warn(' macOS: 使用 Cmd+Q 完全退出应用');
966
+ }
766
967
  log('');
767
968
  }
768
969
 
@@ -265,6 +265,35 @@ function Install-Plugin {
265
265
  }
266
266
  }
267
267
 
268
+ # 验证安装
269
+ function Test-Installation {
270
+ Write-Info "验证安装..."
271
+ $errors = 0
272
+
273
+ # 检查关键命令文件
274
+ $yishanPath = Join-Path $CommandsDir "yishan.md"
275
+ if (Test-Path $yishanPath) {
276
+ Write-Success "✓ yishan.md 已安装"
277
+ } else {
278
+ Write-Warn "✗ yishan.md 未找到"
279
+ $errors++
280
+ }
281
+
282
+ # 检查命令数量
283
+ $cmdFiles = Get-ChildItem -Path $CommandsDir -Filter "*.md" -ErrorAction SilentlyContinue
284
+ $cmdCount = ($cmdFiles | Measure-Object).Count
285
+ if ($cmdCount -gt 0) {
286
+ Write-Success "✓ 已安装 $cmdCount 个命令"
287
+ } else {
288
+ Write-Warn "✗ 未检测到任何命令文件"
289
+ $errors++
290
+ }
291
+
292
+ if ($errors -gt 0) {
293
+ Write-Warn "安装可能不完整,请检查上述警告"
294
+ }
295
+ }
296
+
268
297
  # 显示完成信息
269
298
  function Show-Success {
270
299
  Write-Host ""
@@ -272,7 +301,8 @@ function Show-Success {
272
301
  Write-Host "🎉 安装完成!" -ForegroundColor Green
273
302
  Write-Host "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Green
274
303
  Write-Host ""
275
- Write-Host "⚠️ 重要:请重启 Claude Code 以加载新命令" -ForegroundColor Yellow
304
+ Write-Host "⚠️ 重要:请完全退出并重新启动 Claude Code 以加载新命令" -ForegroundColor Yellow
305
+ Write-Host " (仅关闭窗口可能不够,需要完全退出应用)" -ForegroundColor Yellow
276
306
  Write-Host ""
277
307
  Write-Host "快速开始(使用 /zcf: 前缀):" -ForegroundColor Cyan
278
308
  Write-Host " /zcf:yishan - 愚公移山模式(大规模任务)"
@@ -295,4 +325,5 @@ function Show-Success {
295
325
  Show-Banner
296
326
  Test-Dependencies
297
327
  Install-Plugin
328
+ Test-Installation
298
329
  Show-Success
@@ -222,6 +222,33 @@ install_plugin() {
222
222
  fi
223
223
  }
224
224
 
225
+ # 验证安装
226
+ verify_installation() {
227
+ info "验证安装..."
228
+ local errors=0
229
+
230
+ # 检查关键命令文件
231
+ if [ -f "$COMMANDS_DIR/yishan.md" ]; then
232
+ success "✓ yishan.md 已安装"
233
+ else
234
+ warn "✗ yishan.md 未找到"
235
+ errors=$((errors + 1))
236
+ fi
237
+
238
+ # 检查命令数量
239
+ local cmd_count=$(ls -1 "$COMMANDS_DIR"/*.md 2>/dev/null | wc -l)
240
+ if [ "$cmd_count" -gt 0 ]; then
241
+ success "✓ 已安装 $cmd_count 个命令"
242
+ else
243
+ warn "✗ 未检测到任何命令文件"
244
+ errors=$((errors + 1))
245
+ fi
246
+
247
+ if [ $errors -gt 0 ]; then
248
+ warn "安装可能不完整,请检查上述警告"
249
+ fi
250
+ }
251
+
225
252
  # 显示完成信息
226
253
  show_success() {
227
254
  echo ""
@@ -229,7 +256,8 @@ show_success() {
229
256
  echo -e "${GREEN}🎉 安装完成!${NC}"
230
257
  echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
231
258
  echo ""
232
- echo -e "${YELLOW}⚠️ 重要:请重启 Claude Code 以加载新命令${NC}"
259
+ echo -e "${YELLOW}⚠️ 重要:请完全退出并重新启动 Claude Code 以加载新命令${NC}"
260
+ echo -e "${YELLOW} (仅关闭窗口可能不够,需要完全退出应用)${NC}"
233
261
  echo ""
234
262
  echo -e "${CYAN}快速开始(使用 /zcf: 前缀):${NC}"
235
263
  echo " /zcf:yishan - 愚公移山模式(大规模任务)"
@@ -253,6 +281,7 @@ main() {
253
281
  show_banner
254
282
  check_dependencies
255
283
  install_plugin
284
+ verify_installation
256
285
  show_success
257
286
  }
258
287