promptgraph-mcp 2.2.7 → 2.2.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.
Files changed (2) hide show
  1. package/index.js +70 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -34,6 +34,7 @@ function showHelp() {
34
34
  ['import <owner/repo>', 'Import skills from GitHub'],
35
35
  ['status', 'Show installed skills, repos, and bundles'],
36
36
  ['marketplace', 'Interactive TUI: browse + search + install skills & bundles'],
37
+ ['bundle update [id]', 'Update all (or one) installed GitHub bundles'],
37
38
  ['validate <file.md>', 'Validate a skill before publishing'],
38
39
  ['doctor', 'Clean orphaned chunks/edges/ratings'],
39
40
  ['update', 'Update to the latest version from npm'],
@@ -329,6 +330,75 @@ if (args[0] === 'search') {
329
330
  }
330
331
 
331
332
  if (args[0] === 'bundle') {
333
+ if (args[1] === 'update') {
334
+ const { loadConfig: _lcUpd, SKILLS_STORE_DIR: _ssDir } = await import('./config.js');
335
+ const { indexSource } = await import('./indexer.js');
336
+ const cfg = _lcUpd();
337
+ const githubSources = cfg.sources.filter(s => s.source.startsWith('github:'));
338
+
339
+ if (!githubSources.length) { info('No GitHub bundles installed.'); process.exit(0); }
340
+
341
+ const targetId = args[2]; // optional: pg bundle update <id>
342
+ const toUpdate = targetId
343
+ ? githubSources.filter(s => s.source.toLowerCase().includes(targetId.toLowerCase()))
344
+ : githubSources;
345
+
346
+ if (!toUpdate.length) { error(`No installed bundle matching "${targetId}"`); process.exit(1); }
347
+
348
+ let updated = 0, unchanged = 0, failed = 0;
349
+
350
+ for (const src of toUpdate) {
351
+ const repoName = src.source.replace('github:', '');
352
+ const dest = src.dir.replace(/[/\\]skills$|[/\\]commands$|[/\\]prompts$/, ''); // get repo root
353
+ const repoRoot = fs.existsSync(path.join(dest, '.git')) ? dest : src.dir;
354
+
355
+ if (!fs.existsSync(path.join(repoRoot, '.git'))) {
356
+ console.log(chalk.gray(` skip ${repoName} (not a git repo)`));
357
+ continue;
358
+ }
359
+
360
+ process.stdout.write(` Checking ${chalk.white(repoName)}... `);
361
+
362
+ // Get current HEAD hash
363
+ const before = spawnSync('git', ['-C', repoRoot, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).stdout.trim();
364
+
365
+ // Fetch + reset (same as install)
366
+ const fetch = spawnSync('git', ['-C', repoRoot, 'fetch', '--depth=1', 'origin'], { stdio: 'pipe' });
367
+ if (fetch.status !== 0) {
368
+ console.log(chalk.red('fetch failed'));
369
+ failed++;
370
+ continue;
371
+ }
372
+ const reset = spawnSync('git', ['-C', repoRoot, 'reset', '--hard', 'origin/HEAD'], { stdio: 'pipe' });
373
+ if (reset.status !== 0) {
374
+ spawnSync('git', ['-C', repoRoot, 'reset', '--hard', 'origin/main'], { stdio: 'pipe' });
375
+ }
376
+
377
+ const after = spawnSync('git', ['-C', repoRoot, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).stdout.trim();
378
+
379
+ if (before === after) {
380
+ console.log(chalk.gray('already up to date'));
381
+ unchanged++;
382
+ continue;
383
+ }
384
+
385
+ // Count changed .md files
386
+ const diff = spawnSync('git', ['-C', repoRoot, 'diff', '--name-only', before, after], { encoding: 'utf8' });
387
+ const changedMd = (diff.stdout || '').split('\n').filter(f => f.endsWith('.md')).length;
388
+ console.log(chalk.green(`${changedMd} files changed`) + chalk.gray(` (${before.slice(0,7)} → ${after.slice(0,7)})`));
389
+
390
+ // Reindex only this source — incremental hash check skips unchanged files
391
+ await indexSource(src.dir, src.source);
392
+ updated++;
393
+ }
394
+
395
+ console.log();
396
+ if (updated) success(`Updated ${updated} bundle(s)`);
397
+ if (unchanged) info(chalk.gray(`${unchanged} already up to date`));
398
+ if (failed) error(`${failed} failed`);
399
+ process.exit(failed > 0 ? 1 : 0);
400
+ }
401
+
332
402
  if (args[1] === 'install') {
333
403
  const { installBundle } = await import('./marketplace.js');
334
404
  const result = await installBundle(args[2]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptgraph-mcp",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {