huhaa-myskills 0.1.9 → 0.2.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
@@ -182,10 +182,10 @@ npm install
182
182
  npm start
183
183
  ```
184
184
 
185
- ### 方式 C:npm 全局安装(不含编辑器同步)
185
+ ### 方式 C:npm 全局安装(推荐)
186
186
 
187
187
  ```bash
188
- npm install -g github:aquarkgn/HuHaa-MySkills
188
+ npm install -g huhaa-myskills
189
189
  huhaa-myskills init
190
190
  huhaa-myskills start
191
191
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "huhaa-myskills",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
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",
@@ -14,6 +14,7 @@ import fs from 'node:fs';
14
14
  import path from 'node:path';
15
15
  import { fileURLToPath } from 'node:url';
16
16
  import { spawn } from 'node:child_process';
17
+ import { readFileSync } from 'node:fs';
17
18
 
18
19
  import {
19
20
  homeDir,
@@ -30,6 +31,18 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
31
  const REPO_ROOT = path.resolve(__dirname, '..', '..');
31
32
  const SERVICE_ROOT = path.resolve(__dirname, '..');
32
33
 
34
+ // Load version from package.json
35
+ function getVersion() {
36
+ try {
37
+ const pkgPath = path.join(REPO_ROOT, 'package.json');
38
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
39
+ return pkg.version;
40
+ } catch {
41
+ return 'unknown';
42
+ }
43
+ }
44
+
45
+ const VERSION = getVersion();
33
46
  const cmd = process.argv[2] || 'start';
34
47
 
35
48
  const handlers = {
@@ -40,9 +53,13 @@ const handlers = {
40
53
  init: cmdInit,
41
54
  purge: cmdPurge,
42
55
  dev: cmdDev,
56
+ sync: cmdSync,
43
57
  help: cmdHelp,
44
58
  '--help': cmdHelp,
45
59
  '-h': cmdHelp,
60
+ '--version': cmdVersion,
61
+ '-v': cmdVersion,
62
+ version: cmdVersion,
46
63
  };
47
64
 
48
65
  const fn = handlers[cmd] || cmdHelp;
@@ -53,11 +70,17 @@ fn().catch(err => {
53
70
 
54
71
  // ---------------- handlers ----------------
55
72
 
73
+ // ---------------- commands ----------------
74
+
75
+ async function cmdVersion() {
76
+ console.log(`huhaa-myskills v${VERSION}`);
77
+ }
78
+
56
79
  async function cmdHelp() {
57
- console.log(`huhaa-myskills — local skill / plugin / MCP aggregation hub
80
+ console.log(`huhaa-myskills v${VERSION} — local skill / plugin / MCP aggregation hub
58
81
 
59
82
  Usage:
60
- huhaa-myskills <command>
83
+ huhaa-myskills <command> [options]
61
84
 
62
85
  Commands:
63
86
  start Scan + start server + open browser (default)
@@ -66,12 +89,17 @@ Commands:
66
89
  duplicates Scan + print duplicate diagnostics by name/content/path
67
90
  init Write default sources.yaml to ~/.config/huhaa-myskills/
68
91
  purge Remove all user data under ~/.config/huhaa-myskills/
92
+ sync Sync current skills to selected editors
69
93
  dev Dev mode (Vite + nodemon)
70
- help Show this message
94
+
95
+ Options:
96
+ -v, --version Show version
97
+ -h, --help Show this message
71
98
 
72
99
  Env:
73
100
  HUHAA_HOME override user data dir (default: ~/.config/huhaa-myskills)
74
101
  PORT override preferred port (default: 11520, falls back +10)
102
+ HUHAA_SYNC comma-separated list of editors to sync (e.g. "cursor,vscode")
75
103
 
76
104
  Paths:
77
105
  config ${configFile()}
@@ -291,6 +319,76 @@ async function cmdDev() {
291
319
  await cmdStart();
292
320
  }
293
321
 
322
+ async function cmdSync() {
323
+ const syncEnv = process.env.HUHAA_SYNC;
324
+ const editors = syncEnv
325
+ ? syncEnv.split(',').map(e => e.trim().toLowerCase())
326
+ : null;
327
+
328
+ const { scan } = await import('@huhaa/scanner');
329
+ await ensureConfigOrInit();
330
+ const items = await scan();
331
+
332
+ // Get skills with content
333
+ const skills = items.filter(it => it.raw && it.raw.trim());
334
+
335
+ console.log(`[sync] found ${skills.length} skills to sync`);
336
+
337
+ if (editors) {
338
+ console.log(`[sync] syncing to editors: ${editors.join(', ')}`);
339
+ await syncToEditors(skills, editors);
340
+ } else {
341
+ await interactiveSync(skills);
342
+ }
343
+ }
344
+
345
+ async function syncToEditors(skills, editors) {
346
+ const supported = ['cursor', 'vscode', 'windsurf', 'zed', 'neovim', 'helix', 'sublime', 'vim', 'emacs'];
347
+ const validEditors = editors.filter(e => supported.includes(e));
348
+
349
+ if (validEditors.length === 0) {
350
+ console.error(`[sync] no valid editors. Supported: ${supported.join(', ')}`);
351
+ return;
352
+ }
353
+
354
+ for (const editor of validEditors) {
355
+ await syncToEditor(skills, editor);
356
+ }
357
+ }
358
+
359
+ async function syncToEditor(skills, editor) {
360
+ console.log(`[sync] syncing ${skills.length} skills to ${editor}...`);
361
+
362
+ const syncScript = path.join(SERVICE_ROOT, 'scripts', 'sync-skills.sh');
363
+ const skillsJson = JSON.stringify(skills);
364
+
365
+ return new Promise((resolve, reject) => {
366
+ const child = spawn('bash', [syncScript, '--editor', editor, '--skills', skillsJson], {
367
+ stdio: ['pipe', 'inherit', 'inherit']
368
+ });
369
+
370
+ child.on('close', (code) => {
371
+ if (code === 0) {
372
+ console.log(`[sync] ${editor}: done`);
373
+ resolve();
374
+ } else {
375
+ console.error(`[sync] ${editor}: failed (exit ${code})`);
376
+ resolve();
377
+ }
378
+ });
379
+ });
380
+ }
381
+
382
+ async function interactiveSync(skills) {
383
+ console.log('\nSupported editors:');
384
+ console.log(' [1] cursor [2] vscode [3] windsurf');
385
+ console.log(' [4] zed [5] neovim [6] helix');
386
+ console.log(' [7] sublime [8] vim [9] emacs');
387
+ console.log(' [0] all editors');
388
+ console.log('\nUse HUHAA_SYNC env to sync without prompt:');
389
+ console.log(' HUHAA_SYNC=cursor,vscode huhaa-myskills sync');
390
+ }
391
+
294
392
  // ---------------- helpers ----------------
295
393
 
296
394
  async function ensureConfigOrInit() {