opencode-athena 0.6.1 → 0.7.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/dist/cli/index.js +70 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +7 -1
- package/dist/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from 'url';
|
|
|
4
4
|
import { confirm, select, checkbox } from '@inquirer/prompts';
|
|
5
5
|
import chalk4 from 'chalk';
|
|
6
6
|
import { Command } from 'commander';
|
|
7
|
-
import { existsSync, readFileSync, copyFileSync,
|
|
7
|
+
import { existsSync, readFileSync, mkdirSync, copyFileSync, unlinkSync, readdirSync, renameSync, writeFileSync } from 'fs';
|
|
8
8
|
import { homedir } from 'os';
|
|
9
9
|
import { exec, execSync } from 'child_process';
|
|
10
10
|
import ora2 from 'ora';
|
|
@@ -462,8 +462,14 @@ var CONFIG_PATHS = {
|
|
|
462
462
|
commandsDir: join(homedir(), ".config", "opencode", "command"),
|
|
463
463
|
/** Plugin directory */
|
|
464
464
|
pluginDir: join(homedir(), ".config", "opencode", "plugin"),
|
|
465
|
+
/** Athena internal files directory (state, backups) */
|
|
466
|
+
athenaDir: join(homedir(), ".config", "opencode", "athena"),
|
|
467
|
+
/** Athena backups directory */
|
|
468
|
+
backupsDir: join(homedir(), ".config", "opencode", "athena", "backups"),
|
|
465
469
|
/** Athena state file (for story tracking) */
|
|
466
|
-
stateFile: join(homedir(), ".config", "opencode", "athena-state.json")
|
|
470
|
+
stateFile: join(homedir(), ".config", "opencode", "athena", "athena-state.json"),
|
|
471
|
+
/** Legacy state file path (for migration) */
|
|
472
|
+
legacyStateFile: join(homedir(), ".config", "opencode", "athena-state.json")
|
|
467
473
|
};
|
|
468
474
|
var DEFAULTS = {
|
|
469
475
|
/** Maximum parallel stories */
|
|
@@ -635,13 +641,17 @@ var FileManager = class {
|
|
|
635
641
|
*/
|
|
636
642
|
async removeConfigFiles() {
|
|
637
643
|
const removedFiles = [];
|
|
638
|
-
const filesToRemove = [CONFIG_PATHS.globalAthenaConfig, CONFIG_PATHS.
|
|
644
|
+
const filesToRemove = [CONFIG_PATHS.globalAthenaConfig, CONFIG_PATHS.legacyStateFile];
|
|
639
645
|
for (const file of filesToRemove) {
|
|
640
646
|
if (existsSync(file)) {
|
|
641
647
|
await rm(file);
|
|
642
648
|
removedFiles.push(file);
|
|
643
649
|
}
|
|
644
650
|
}
|
|
651
|
+
if (existsSync(CONFIG_PATHS.athenaDir)) {
|
|
652
|
+
await rm(CONFIG_PATHS.athenaDir, { recursive: true });
|
|
653
|
+
removedFiles.push(CONFIG_PATHS.athenaDir);
|
|
654
|
+
}
|
|
645
655
|
return removedFiles;
|
|
646
656
|
}
|
|
647
657
|
/**
|
|
@@ -2219,16 +2229,19 @@ function createBackups() {
|
|
|
2219
2229
|
omoBackup: null,
|
|
2220
2230
|
opencodeBackup: null
|
|
2221
2231
|
};
|
|
2232
|
+
if (!existsSync(CONFIG_PATHS.backupsDir)) {
|
|
2233
|
+
mkdirSync(CONFIG_PATHS.backupsDir, { recursive: true });
|
|
2234
|
+
}
|
|
2222
2235
|
if (existsSync(CONFIG_PATHS.globalAthenaConfig)) {
|
|
2223
|
-
result.athenaBackup =
|
|
2236
|
+
result.athenaBackup = join(CONFIG_PATHS.backupsDir, `athena.json.backup-${timestamp}`);
|
|
2224
2237
|
copyFileSync(CONFIG_PATHS.globalAthenaConfig, result.athenaBackup);
|
|
2225
2238
|
}
|
|
2226
2239
|
if (existsSync(CONFIG_PATHS.globalOmoConfig)) {
|
|
2227
|
-
result.omoBackup =
|
|
2240
|
+
result.omoBackup = join(CONFIG_PATHS.backupsDir, `oh-my-opencode.json.backup-${timestamp}`);
|
|
2228
2241
|
copyFileSync(CONFIG_PATHS.globalOmoConfig, result.omoBackup);
|
|
2229
2242
|
}
|
|
2230
2243
|
if (existsSync(CONFIG_PATHS.globalOpencodeConfig)) {
|
|
2231
|
-
result.opencodeBackup =
|
|
2244
|
+
result.opencodeBackup = join(CONFIG_PATHS.backupsDir, `opencode.json.backup-${timestamp}`);
|
|
2232
2245
|
copyFileSync(CONFIG_PATHS.globalOpencodeConfig, result.opencodeBackup);
|
|
2233
2246
|
}
|
|
2234
2247
|
return result;
|
|
@@ -2274,8 +2287,51 @@ var MIGRATIONS = [
|
|
|
2274
2287
|
toVersion: "0.6.0",
|
|
2275
2288
|
description: "Migration system infrastructure (no config changes)",
|
|
2276
2289
|
migrateAthena: (config) => config
|
|
2290
|
+
},
|
|
2291
|
+
{
|
|
2292
|
+
fromVersion: "0.6.0",
|
|
2293
|
+
toVersion: "0.7.0",
|
|
2294
|
+
description: "Reorganize athena files into dedicated directory",
|
|
2295
|
+
migrateAthena: (config) => config
|
|
2277
2296
|
}
|
|
2278
2297
|
];
|
|
2298
|
+
function migrateLegacyFiles() {
|
|
2299
|
+
const result = {
|
|
2300
|
+
stateFileMoved: false,
|
|
2301
|
+
backupsMoved: 0
|
|
2302
|
+
};
|
|
2303
|
+
if (!existsSync(CONFIG_PATHS.athenaDir)) {
|
|
2304
|
+
mkdirSync(CONFIG_PATHS.athenaDir, { recursive: true });
|
|
2305
|
+
}
|
|
2306
|
+
if (existsSync(CONFIG_PATHS.legacyStateFile) && !existsSync(CONFIG_PATHS.stateFile)) {
|
|
2307
|
+
if (!existsSync(CONFIG_PATHS.athenaDir)) {
|
|
2308
|
+
mkdirSync(CONFIG_PATHS.athenaDir, { recursive: true });
|
|
2309
|
+
}
|
|
2310
|
+
copyFileSync(CONFIG_PATHS.legacyStateFile, CONFIG_PATHS.stateFile);
|
|
2311
|
+
unlinkSync(CONFIG_PATHS.legacyStateFile);
|
|
2312
|
+
result.stateFileMoved = true;
|
|
2313
|
+
}
|
|
2314
|
+
const backupPattern = /\.(backup-\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}-\d{3})$/;
|
|
2315
|
+
const configDir = CONFIG_PATHS.globalConfigDir;
|
|
2316
|
+
if (existsSync(configDir)) {
|
|
2317
|
+
const files = readdirSync(configDir);
|
|
2318
|
+
const legacyBackups = files.filter((f) => backupPattern.test(f));
|
|
2319
|
+
if (legacyBackups.length > 0) {
|
|
2320
|
+
if (!existsSync(CONFIG_PATHS.backupsDir)) {
|
|
2321
|
+
mkdirSync(CONFIG_PATHS.backupsDir, { recursive: true });
|
|
2322
|
+
}
|
|
2323
|
+
for (const backupFile of legacyBackups) {
|
|
2324
|
+
const sourcePath = join(configDir, backupFile);
|
|
2325
|
+
const destPath = join(CONFIG_PATHS.backupsDir, backupFile);
|
|
2326
|
+
if (!existsSync(destPath)) {
|
|
2327
|
+
renameSync(sourcePath, destPath);
|
|
2328
|
+
result.backupsMoved++;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
return result;
|
|
2334
|
+
}
|
|
2279
2335
|
|
|
2280
2336
|
// src/cli/utils/migrations/runner.ts
|
|
2281
2337
|
init_esm_shims();
|
|
@@ -2532,6 +2588,14 @@ Current version: ${existingVersion}`));
|
|
|
2532
2588
|
Boolean
|
|
2533
2589
|
).length;
|
|
2534
2590
|
spinner.succeed(`Created ${backupCount} backup file(s)`);
|
|
2591
|
+
const fileMigrationResult = migrateLegacyFiles();
|
|
2592
|
+
if (fileMigrationResult.stateFileMoved || fileMigrationResult.backupsMoved > 0) {
|
|
2593
|
+
const moved = [];
|
|
2594
|
+
if (fileMigrationResult.stateFileMoved) moved.push("state file");
|
|
2595
|
+
if (fileMigrationResult.backupsMoved > 0)
|
|
2596
|
+
moved.push(`${fileMigrationResult.backupsMoved} backup(s)`);
|
|
2597
|
+
console.log(chalk4.gray(` Migrated ${moved.join(", ")} to new athena/ directory`));
|
|
2598
|
+
}
|
|
2535
2599
|
const migrationSpinner = ora2("Applying migrations...").start();
|
|
2536
2600
|
const migrationResult = migrateConfigs(athena || {}, omo || {}, existingVersion);
|
|
2537
2601
|
if (migrationResult.migrationsApplied.length > 0) {
|