huhaa-myskills 0.2.4 → 0.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.
@@ -360,13 +360,50 @@ async function syncToEditor(skills, editor) {
360
360
  }
361
361
 
362
362
  async function interactiveSync(skills) {
363
+ const readline = await import('node:readline');
364
+ const rl = readline.createInterface({
365
+ input: process.stdin,
366
+ output: process.stdout
367
+ });
368
+
369
+ const question = (prompt) => new Promise(resolve => rl.question(prompt, resolve));
370
+
371
+ console.log(`\n[sync] found ${skills.length} skills`);
363
372
  console.log('\nSupported editors:');
364
373
  console.log(' [1] cursor [2] vscode [3] windsurf');
365
374
  console.log(' [4] zed [5] neovim [6] helix');
366
375
  console.log(' [7] sublime [8] vim [9] emacs');
367
376
  console.log(' [0] all editors');
368
- console.log('\nUse HUHAA_SYNC env to sync without prompt:');
369
- console.log(' HUHAA_SYNC=cursor,vscode huhaa-myskills sync');
377
+ console.log(' [q] quit\n');
378
+
379
+ const editorMap = {
380
+ '1': 'cursor', '2': 'vscode', '3': 'windsurf',
381
+ '4': 'zed', '5': 'neovim', '6': 'helix',
382
+ '7': 'sublime', '8': 'vim', '9': 'emacs'
383
+ };
384
+
385
+ const input = await question('Select editors (0/1/2/... or q): ');
386
+ rl.close();
387
+
388
+ if (input === 'q' || input === 'Q') {
389
+ console.log('[sync] cancelled');
390
+ return;
391
+ }
392
+
393
+ let editors = [];
394
+ if (input === '0') {
395
+ editors = Object.values(editorMap);
396
+ } else {
397
+ const selected = input.split(/[,\s]+/).filter(s => s);
398
+ editors = selected.map(s => editorMap[s]).filter(Boolean);
399
+ }
400
+
401
+ if (editors.length === 0) {
402
+ console.error('[sync] no valid editors selected');
403
+ return;
404
+ }
405
+
406
+ await syncToEditors(skills, editors);
370
407
  }
371
408
 
372
409
  // ---------------- helpers ----------------
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huhaa-myskills",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "private": false,
5
5
  "description": "Local skill / plugin / MCP aggregation hub. Browse all your AI agent skills at http://localhost:11520.",
6
6
  "license": "MIT",
@@ -193,126 +193,236 @@ sync_to_cursor() {
193
193
  sync_to_vscode() {
194
194
  local editor_path="$1" root="$2"
195
195
  mkdir -p "$editor_path/User/snippets"
196
+
197
+ # 尝试同步 .cursorrules 作为注释文件用于参考
198
+ if [[ -f "$root/.cursorrules" ]]; then
199
+ cp "$root/.cursorrules" "$editor_path/User/.cursorrules.txt" 2>/dev/null || true
200
+ fi
201
+
196
202
  log_success "VS Code: 已同步"
197
203
  }
198
204
 
199
205
  sync_to_vscode_insiders() {
200
206
  local editor_path="$1" root="$2"
201
207
  mkdir -p "$editor_path/User/snippets"
208
+
209
+ # 尝试同步 .cursorrules 作为注释文件用于参考
210
+ if [[ -f "$root/.cursorrules" ]]; then
211
+ cp "$root/.cursorrules" "$editor_path/User/.cursorrules.txt" 2>/dev/null || true
212
+ fi
213
+
202
214
  log_success "VS Code Insiders: 已同步"
203
215
  }
204
216
 
205
217
  sync_to_windsurf() {
206
218
  local editor_path="$1" root="$2"
207
219
  mkdir -p "$editor_path"
220
+
221
+ # 同步 .cursorrules 如果存在
222
+ if [[ -f "$root/.cursorrules" ]]; then
223
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Windsurf: .cursorrules 复制失败"
224
+ fi
225
+
208
226
  log_success "Windsurf: 已同步"
209
227
  }
210
228
 
211
229
  sync_to_zed() {
212
230
  local editor_path="$1" root="$2"
213
231
  mkdir -p "$editor_path"
232
+
233
+ # Zed 支持 .cursorrules
234
+ if [[ -f "$root/.cursorrules" ]]; then
235
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Zed: .cursorrules 复制失败"
236
+ fi
237
+
214
238
  log_success "Zed: 已同步"
215
239
  }
216
240
 
217
241
  sync_to_helix() {
218
242
  local editor_path="$1" root="$2"
219
243
  mkdir -p "$editor_path"
244
+
245
+ # 尝试同步技能相关的配置
246
+ if [[ -f "$root/.cursorrules" ]]; then
247
+ cp "$root/.cursorrules" "$editor_path/rules.md" 2>/dev/null || log_warn "Helix: rules 复制失败"
248
+ fi
249
+
220
250
  log_success "Helix: 已同步"
221
251
  }
222
252
 
223
253
  sync_to_neovim() {
224
254
  local editor_path="$1" root="$2"
225
255
  mkdir -p "$editor_path/plugin"
256
+
257
+ # 创建基础配置加载文件
258
+ if [[ -f "$root/.cursorrules" ]]; then
259
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "Neovim: rules 复制失败"
260
+ fi
261
+
226
262
  log_success "Neovim: 已同步"
227
263
  }
228
264
 
229
265
  sync_to_vim() {
230
266
  local editor_path="$1" root="$2"
231
267
  mkdir -p "$editor_path/plugin"
268
+
269
+ # 创建基础配置加载文件
270
+ if [[ -f "$root/.cursorrules" ]]; then
271
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "Vim: rules 复制失败"
272
+ fi
273
+
232
274
  log_success "Vim: 已同步"
233
275
  }
234
276
 
235
277
  sync_to_emacs() {
236
278
  local editor_path="$1" root="$2"
237
279
  mkdir -p "$editor_path"
280
+
281
+ # Emacs 用户可以加载规则文件
282
+ if [[ -f "$root/.cursorrules" ]]; then
283
+ cp "$root/.cursorrules" "$editor_path/huhaa-rules.md" 2>/dev/null || log_warn "Emacs: rules 复制失败"
284
+ fi
285
+
238
286
  log_success "Emacs: 已同步"
239
287
  }
240
288
 
241
289
  sync_to_sublime() {
242
290
  local editor_path="$1" root="$2"
243
291
  mkdir -p "$editor_path/Packages/User"
292
+
293
+ # 同步规则到 Sublime 用户目录
294
+ if [[ -f "$root/.cursorrules" ]]; then
295
+ cp "$root/.cursorrules" "$editor_path/Packages/User/huhaa_rules.md" 2>/dev/null || log_warn "Sublime Text: rules 复制失败"
296
+ fi
297
+
244
298
  log_success "Sublime Text: 已同步"
245
299
  }
246
300
 
247
301
  sync_to_sublime4() {
248
302
  local editor_path="$1" root="$2"
249
303
  mkdir -p "$editor_path/Packages/User"
304
+
305
+ # 同步规则到 Sublime 用户目录
306
+ if [[ -f "$root/.cursorrules" ]]; then
307
+ cp "$root/.cursorrules" "$editor_path/Packages/User/huhaa_rules.md" 2>/dev/null || log_warn "Sublime Text 4: rules 复制失败"
308
+ fi
309
+
250
310
  log_success "Sublime Text 4: 已同步"
251
311
  }
252
312
 
253
313
  sync_to_textmate() {
254
314
  local editor_path="$1" root="$2"
255
315
  mkdir -p "$editor_path"
316
+
317
+ if [[ -f "$root/.cursorrules" ]]; then
318
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "TextMate: rules 复制失败"
319
+ fi
320
+
256
321
  log_success "TextMate: 已同步"
257
322
  }
258
323
 
259
324
  sync_to_bbedit() {
260
325
  local editor_path="$1" root="$2"
261
326
  mkdir -p "$editor_path"
327
+
328
+ if [[ -f "$root/.cursorrules" ]]; then
329
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "BBEdit: rules 复制失败"
330
+ fi
331
+
262
332
  log_success "BBEdit: 已同步"
263
333
  }
264
334
 
265
335
  sync_to_atom() {
266
336
  local editor_path="$1" root="$2"
267
337
  mkdir -p "$editor_path/packages"
338
+
339
+ if [[ -f "$root/.cursorrules" ]]; then
340
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "Atom: rules 复制失败"
341
+ fi
342
+
268
343
  log_success "Atom: 已同步"
269
344
  }
270
345
 
271
346
  sync_to_kate() {
272
347
  local editor_path="$1" root="$2"
273
348
  mkdir -p "$editor_path"
349
+
350
+ if [[ -f "$root/.cursorrules" ]]; then
351
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "Kate: rules 复制失败"
352
+ fi
353
+
274
354
  log_success "Kate: 已同步"
275
355
  }
276
356
 
277
357
  sync_to_gedit() {
278
358
  local editor_path="$1" root="$2"
279
359
  mkdir -p "$editor_path"
360
+
361
+ if [[ -f "$root/.cursorrules" ]]; then
362
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "Gedit: rules 复制失败"
363
+ fi
364
+
280
365
  log_success "Gedit: 已同步"
281
366
  }
282
367
 
283
368
  sync_to_jetbrains() {
284
369
  local editor_path="$1" root="$2"
285
370
  mkdir -p "$editor_path"
371
+
372
+ if [[ -f "$root/.cursorrules" ]]; then
373
+ cp "$root/.cursorrules" "$editor_path/huhaa_rules.md" 2>/dev/null || log_warn "JetBrains IDEs: rules 复制失败"
374
+ fi
375
+
286
376
  log_success "JetBrains IDEs: 已同步"
287
377
  }
288
378
 
289
379
  sync_to_openclaw() {
290
380
  local editor_path="$1" root="$2"
291
381
  mkdir -p "$editor_path"
382
+
383
+ if [[ -f "$root/.cursorrules" ]]; then
384
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Openclaw: .cursorrules 复制失败"
385
+ fi
386
+
292
387
  log_success "Openclaw: 已同步"
293
388
  }
294
389
 
295
390
  sync_to_herems() {
296
391
  local editor_path="$1" root="$2"
297
392
  mkdir -p "$editor_path"
393
+
394
+ if [[ -f "$root/.cursorrules" ]]; then
395
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Herems: .cursorrules 复制失败"
396
+ fi
397
+
298
398
  log_success "Herems: 已同步"
299
399
  }
300
400
 
301
401
  sync_to_trae() {
302
402
  local editor_path="$1" root="$2"
303
403
  mkdir -p "$editor_path"
404
+
405
+ if [[ -f "$root/.cursorrules" ]]; then
406
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Trae: .cursorrules 复制失败"
407
+ fi
408
+
304
409
  log_success "Trae: 已同步"
305
410
  }
306
411
 
307
412
  sync_to_trae_cn() {
308
413
  local editor_path="$1" root="$2"
309
414
  mkdir -p "$editor_path"
415
+
416
+ if [[ -f "$root/.cursorrules" ]]; then
417
+ cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null || log_warn "Trae CN: .cursorrules 复制失败"
418
+ fi
419
+
310
420
  log_success "Trae CN: 已同步"
311
421
  }
312
422
 
313
423
  sync_to_codex() {
314
424
  local editor_path="$1" root="$2"
315
- [[ -f "$root/.cursorrules" ]] && cp "$root/.cursorrules" "$editor_path/.cursorrules" && log_success "Codex: 已同步" || log_warn "Codex: 跳过"
425
+ [[ -f "$root/.cursorrules" ]] && cp "$root/.cursorrules" "$editor_path/.cursorrules" 2>/dev/null && log_success "Codex: 已同步" || log_warn "Codex: 跳过"
316
426
  }
317
427
 
318
428
  sync_to_claude() {
@@ -321,33 +431,101 @@ sync_to_claude() {
321
431
  }
322
432
 
323
433
  main() {
324
- echo -e "\n${CYAN}╔════════════════════════════════════════════════════════╗${NC}"
325
- echo -e "${CYAN}║ HuHaa-MySkills 编辑器技能同步 v0.1.5 ║${NC}"
326
- echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${NC}\n"
434
+ local selection="$1"
435
+ local editor_name="$2"
436
+ local is_auto_mode=false
437
+
438
+ # 如果通过 --editor 参数指定编辑器名称
439
+ if [[ "$selection" == "--editor" && -n "$editor_name" ]]; then
440
+ selection="$editor_name"
441
+ is_auto_mode=true
442
+ # 如果通过环境变量指定编辑器
443
+ elif [[ -n "${HUHAA_EDITOR:-}" ]]; then
444
+ selection="$HUHAA_EDITOR"
445
+ is_auto_mode=true
446
+ # 如果通过参数指定了选择,进入自动模式
447
+ elif [[ -n "$selection" && "$selection" != "" && "$selection" != "0" ]]; then
448
+ is_auto_mode=true
449
+ fi
327
450
 
328
- log_info "扫描已安装的编辑器...\n"
451
+ if [[ "$is_auto_mode" == false ]]; then
452
+ echo -e "\n${CYAN}╔════════════════════════════════════════════════════════╗${NC}"
453
+ echo -e "${CYAN}║ HuHaa-MySkills 编辑器技能同步 v0.1.5 ║${NC}"
454
+ echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${NC}\n"
329
455
 
330
- editors=$(detect_editors)
456
+ log_info "扫描已安装的编辑器...\n"
331
457
 
332
- if [[ -z "$editors" ]]; then
333
- log_error "未发现支持的编辑器"
334
- exit 1
335
- fi
458
+ editors=$(detect_editors)
336
459
 
337
- count=$(echo "$editors" | wc -l)
338
- log_success "发现 $count 个编辑器"
460
+ if [[ -z "$editors" ]]; then
461
+ log_error "未发现支持的编辑器"
462
+ exit 1
463
+ fi
339
464
 
340
- show_editors "$editors"
341
- read -p "请输入选择 (0/1,2,...或q): " selection
465
+ count=$(echo "$editors" | wc -l)
466
+ log_success "发现 $count 个编辑器"
342
467
 
343
- [[ "$selection" == "q" ]] && exit 0
468
+ show_editors "$editors"
469
+ read -p "请输入选择 (0/1,2,...或q): " selection
470
+
471
+ [[ "$selection" == "q" ]] && exit 0
472
+ fi
344
473
 
345
474
  huhaa_root=$(find_huhaa_root) || exit 1
346
- log_info "同步根目录: $huhaa_root\n"
347
475
 
348
- echo -e "${CYAN}╔════════════════════════════════════════════════════════╗${NC}"
349
- echo -e "${CYAN}║ 开始同步编辑器技能 ║${NC}"
350
- echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${NC}\n"
476
+ if [[ "$is_auto_mode" == false ]]; then
477
+ log_info "同步根目录: $huhaa_root\n"
478
+
479
+ echo -e "${CYAN}╔════════════════════════════════════════════════════════╗${NC}"
480
+ echo -e "${CYAN}║ 开始同步编辑器技能 ║${NC}"
481
+ echo -e "${CYAN}╚════════════════════════════════════════════════════════╝${NC}\n"
482
+ fi
483
+
484
+ editors=$(detect_editors)
485
+
486
+ # 处理编辑器名称(如 cursor, vscode 等)
487
+ if [[ "$is_auto_mode" == true && "$selection" != "0" ]]; then
488
+ # 将编辑器名称转换为可处理的格式
489
+ local editor_name="$selection"
490
+ local editor_path=""
491
+
492
+ # 从 editors 列表中找到对应的路径
493
+ editor_path=$(echo "$editors" | grep "|$editor_name|" | cut -d'|' -f3)
494
+
495
+ if [[ -n "$editor_path" ]]; then
496
+ case "$editor_name" in
497
+ cursor) sync_to_cursor "$editor_path" "$huhaa_root" ;;
498
+ vscode) sync_to_vscode "$editor_path" "$huhaa_root" ;;
499
+ vscode-insiders) sync_to_vscode_insiders "$editor_path" "$huhaa_root" ;;
500
+ windsurf) sync_to_windsurf "$editor_path" "$huhaa_root" ;;
501
+ zed) sync_to_zed "$editor_path" "$huhaa_root" ;;
502
+ helix) sync_to_helix "$editor_path" "$huhaa_root" ;;
503
+ neovim) sync_to_neovim "$editor_path" "$huhaa_root" ;;
504
+ vim) sync_to_vim "$editor_path" "$huhaa_root" ;;
505
+ emacs) sync_to_emacs "$editor_path" "$huhaa_root" ;;
506
+ sublime) sync_to_sublime "$editor_path" "$huhaa_root" ;;
507
+ sublime4) sync_to_sublime4 "$editor_path" "$huhaa_root" ;;
508
+ textmate) sync_to_textmate "$editor_path" "$huhaa_root" ;;
509
+ bbedit) sync_to_bbedit "$editor_path" "$huhaa_root" ;;
510
+ atom) sync_to_atom "$editor_path" "$huhaa_root" ;;
511
+ kate) sync_to_kate "$editor_path" "$huhaa_root" ;;
512
+ gedit) sync_to_gedit "$editor_path" "$huhaa_root" ;;
513
+ jetbrains) sync_to_jetbrains "$editor_path" "$huhaa_root" ;;
514
+ openclaw) sync_to_openclaw "$editor_path" "$huhaa_root" ;;
515
+ herems) sync_to_herems "$editor_path" "$huhaa_root" ;;
516
+ trae) sync_to_trae "$editor_path" "$huhaa_root" ;;
517
+ trae-cn) sync_to_trae_cn "$editor_path" "$huhaa_root" ;;
518
+ codex) sync_to_codex "$editor_path" "$huhaa_root" ;;
519
+ claude) sync_to_claude "$editor_path" "$huhaa_root" ;;
520
+ esac
521
+ echo
522
+ echo -e "${GREEN}✨ 技能同步完成!${NC}\n"
523
+ return 0
524
+ else
525
+ log_error "未找到编辑器: $editor_name"
526
+ exit 1
527
+ fi
528
+ fi
351
529
 
352
530
  if [[ "$selection" == "0" ]]; then
353
531
  echo "$editors" | while IFS='|' read -r idx name path; do