legion-cc 0.2.0 → 0.2.2

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.2
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() {
@@ -28,6 +28,7 @@ function usage() {
28
28
  ' task-record <type> <desc> <status> Add a task record to STATE.md',
29
29
  ' context-load [path] Load context from .legion/codebase/ and .legion/planning/',
30
30
  ' domain list|info [name] Domain registry operations',
31
+ ' session-record <summary> Create a session record in .legion/planning/sessions/',
31
32
  ' update-check Check for newer version on npm',
32
33
  '',
33
34
  'Examples:',
@@ -39,6 +40,7 @@ function usage() {
39
40
  ' legion-tools generate-slug "My Cool Project"',
40
41
  ' legion-tools current-timestamp date',
41
42
  ' legion-tools task-record architect "Initial architecture" done',
43
+ ' legion-tools session-record "Created codebase documentation"',
42
44
  ' legion-tools context-load',
43
45
  ' legion-tools domain list',
44
46
  ' legion-tools domain info devops',
@@ -266,6 +268,30 @@ function cmdTaskRecord(args) {
266
268
  console.log(`${core.UI.check} Task recorded: [${type}] ${desc} (${status})`);
267
269
  }
268
270
 
271
+ // ─── Command: session-record ─────────────────────────────────────────────────
272
+
273
+ function cmdSessionRecord(args) {
274
+ const summary = args.join(' ');
275
+ if (!summary) {
276
+ die('Usage: legion-tools session-record <summary>');
277
+ }
278
+
279
+ const planningDir = requirePlanningDir();
280
+
281
+ // Load current state for domain/stage context
282
+ const stateObj = state.loadState(planningDir);
283
+ const cfg = config.loadConfig(planningDir);
284
+
285
+ const sessionPath = session.createSession(planningDir, {
286
+ domain: (cfg && cfg.domain) || (stateObj && stateObj.project && stateObj.project.domain) || undefined,
287
+ stage: (stateObj && stateObj.currentWork && stateObj.currentWork.stage) || undefined,
288
+ description: summary,
289
+ });
290
+
291
+ const fileName = path.basename(sessionPath);
292
+ console.log(`${core.UI.check} Session recorded: ${fileName}`);
293
+ }
294
+
269
295
  // ─── Command: context-load ───────────────────────────────────────────────────
270
296
 
271
297
  function cmdContextLoad(args) {
@@ -436,6 +462,9 @@ function main() {
436
462
  case 'task-record':
437
463
  cmdTaskRecord(commandArgs);
438
464
  break;
465
+ case 'session-record':
466
+ cmdSessionRecord(commandArgs);
467
+ break;
439
468
  case 'context-load':
440
469
  cmdContextLoad(commandArgs);
441
470
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "legion-cc",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Legion — multi-agent orchestration framework for Claude Code",
5
5
  "type": "commonjs",
6
6
  "main": "bin/legion-tools.cjs",