instar 0.8.11 → 0.8.12

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/dist/cli.js CHANGED
@@ -624,5 +624,34 @@ autostartCmd
624
624
  console.log(pc.yellow(`Auto-start is not supported on ${process.platform}.`));
625
625
  }
626
626
  });
627
+ // Hidden command: run post-update migration from the NEW binary
628
+ // Called by the auto-updater after `npm install -g` to ensure
629
+ // migrations use the latest code, not the old in-memory modules.
630
+ program
631
+ .command('migrate')
632
+ .description('Run post-update knowledge migration')
633
+ .option('-d, --dir <path>', 'Project directory')
634
+ .action(async (opts) => {
635
+ try {
636
+ const { loadConfig } = await import('./core/Config.js');
637
+ const { PostUpdateMigrator } = await import('./core/PostUpdateMigrator.js');
638
+ const config = loadConfig(opts.dir);
639
+ const hasTelegram = config.messaging?.some((m) => m.type === 'telegram') ?? false;
640
+ const migrator = new PostUpdateMigrator({
641
+ projectDir: config.projectDir,
642
+ stateDir: config.stateDir,
643
+ port: config.port,
644
+ hasTelegram,
645
+ projectName: config.projectName,
646
+ });
647
+ const result = migrator.migrate();
648
+ // Output as JSON for the calling process to parse
649
+ console.log(JSON.stringify(result));
650
+ }
651
+ catch (err) {
652
+ console.error(JSON.stringify({ error: err instanceof Error ? err.message : String(err) }));
653
+ process.exit(1);
654
+ }
655
+ });
627
656
  program.parse();
628
657
  //# sourceMappingURL=cli.js.map
@@ -128,21 +128,34 @@ export class UpdateChecker {
128
128
  if (success) {
129
129
  this.saveRollbackInfo(previousVersion, newVersion);
130
130
  }
131
- // Post-update migration: upgrade hooks, CLAUDE.md, scripts
131
+ // Post-update migration: spawn the NEW binary to run migrations.
132
+ // Critical: the old process has stale modules in memory — only the
133
+ // new binary on disk has the latest PostUpdateMigrator entries.
132
134
  let migrationSummary = '';
133
135
  if (success && this.migratorConfig) {
134
136
  try {
135
- const migrator = new PostUpdateMigrator(this.migratorConfig);
136
- const migration = migrator.migrate();
137
- if (migration.upgraded.length > 0) {
137
+ const dirFlag = this.migratorConfig.projectDir ? `--dir ${this.migratorConfig.projectDir}` : '';
138
+ const output = await this.execAsync('instar', ['migrate', ...(dirFlag ? ['--dir', this.migratorConfig.projectDir] : [])], 30000);
139
+ const migration = JSON.parse(output);
140
+ if (migration.upgraded && migration.upgraded.length > 0) {
138
141
  migrationSummary = ` Intelligence download: ${migration.upgraded.length} files upgraded (${migration.upgraded.join(', ')}).`;
139
142
  }
140
- if (migration.errors.length > 0) {
143
+ if (migration.errors && migration.errors.length > 0) {
141
144
  migrationSummary += ` Migration warnings: ${migration.errors.join('; ')}.`;
142
145
  }
143
146
  }
144
147
  catch (err) {
145
- migrationSummary = ` Post-update migration failed: ${err instanceof Error ? err.message : String(err)}.`;
148
+ // Fallback: run in-memory migrator (better than nothing)
149
+ try {
150
+ const migrator = new PostUpdateMigrator(this.migratorConfig);
151
+ const migration = migrator.migrate();
152
+ if (migration.upgraded.length > 0) {
153
+ migrationSummary = ` Intelligence download (fallback): ${migration.upgraded.length} files upgraded (${migration.upgraded.join(', ')}).`;
154
+ }
155
+ }
156
+ catch (fallbackErr) {
157
+ migrationSummary = ` Post-update migration failed: ${err instanceof Error ? err.message : String(err)}.`;
158
+ }
146
159
  }
147
160
  }
148
161
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "Persistent autonomy infrastructure for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",