legion-cc 0.2.0 → 0.2.1

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
package/bin/install.js CHANGED
@@ -467,7 +467,11 @@ function doInstall() {
467
467
  logStep('Registering hooks in settings...');
468
468
  registerHooks();
469
469
 
470
- // ── Step 4: Generate manifest ───────────────────────────────────────────
470
+ // ── Step 4: Cleanup stale files from previous install ──────────────────
471
+
472
+ cleanupStaleFiles();
473
+
474
+ // ── Step 5: Generate manifest ───────────────────────────────────────────
471
475
 
472
476
  logStep('Generating file manifest...');
473
477
  generateManifest();
@@ -568,6 +572,59 @@ function registerHooks() {
568
572
  }
569
573
  }
570
574
 
575
+ // ─── Cleanup stale files from previous install ──────────────────────────────
576
+
577
+ function cleanupStaleFiles() {
578
+ const manifestPath = path.join(configDir, 'legion-file-manifest.json');
579
+ const oldManifest = readJSON(manifestPath);
580
+
581
+ if (!oldManifest || !oldManifest.files) return;
582
+
583
+ // Build set of files that exist in the NEW install (walk current dirs)
584
+ const newFiles = new Set();
585
+ const scanDirs = [
586
+ path.join(configDir, 'legion'),
587
+ path.join(configDir, 'commands', 'legion'),
588
+ ];
589
+ const scanFiles = [
590
+ path.join(configDir, 'hooks', 'legion-context-monitor.js'),
591
+ path.join(configDir, 'hooks', 'legion-statusline.js'),
592
+ ];
593
+
594
+ for (const dir of scanDirs) {
595
+ for (const filePath of walkDir(dir)) {
596
+ newFiles.add(path.relative(configDir, filePath));
597
+ }
598
+ }
599
+ for (const f of scanFiles) {
600
+ if (fs.existsSync(f)) {
601
+ newFiles.add(path.relative(configDir, f));
602
+ }
603
+ }
604
+
605
+ // Find files in old manifest that are NOT in new install
606
+ let removedCount = 0;
607
+ for (const rel of Object.keys(oldManifest.files)) {
608
+ if (!newFiles.has(rel)) {
609
+ const absPath = path.join(configDir, rel);
610
+ if (fs.existsSync(absPath)) {
611
+ if (flagDryRun) {
612
+ console.log(` ${c(dim, '[dry-run]')} would remove stale: ${rel}`);
613
+ } else {
614
+ try {
615
+ fs.unlinkSync(absPath);
616
+ removedCount++;
617
+ } catch (_e) { /* silent */ }
618
+ }
619
+ }
620
+ }
621
+ }
622
+
623
+ if (removedCount > 0) {
624
+ logOk(`Cleaned up ${removedCount} stale file(s) from previous install`);
625
+ }
626
+ }
627
+
571
628
  // ─── Generate manifest ──────────────────────────────────────────────────────
572
629
 
573
630
  function generateManifest() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "legion-cc",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Legion — multi-agent orchestration framework for Claude Code",
5
5
  "type": "commonjs",
6
6
  "main": "bin/legion-tools.cjs",