opencode-studio-server 1.9.2 → 1.9.4

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 +27 -7
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1310,6 +1310,10 @@ const getProfileDir = (provider, activePlugin) => {
1310
1310
  const plainDir = path.join(AUTH_PROFILES_DIR, 'google');
1311
1311
  const nsHas = fs.existsSync(nsDir) && fs.readdirSync(nsDir).filter(f => f.endsWith('.json')).length > 0;
1312
1312
  const plainHas = fs.existsSync(plainDir) && fs.readdirSync(plainDir).filter(f => f.endsWith('.json')).length > 0;
1313
+
1314
+ // Debug
1315
+ console.log(`[Auth] getProfileDir: ns=${ns}, nsHas=${nsHas}, plainHas=${plainHas}`);
1316
+
1313
1317
  if (!nsHas && plainHas) return plainDir;
1314
1318
  }
1315
1319
  return path.join(AUTH_PROFILES_DIR, ns);
@@ -1318,7 +1322,11 @@ const getProfileDir = (provider, activePlugin) => {
1318
1322
  const listAuthProfiles = (p, activePlugin) => {
1319
1323
  const d = getProfileDir(p, activePlugin);
1320
1324
  if (!fs.existsSync(d)) return [];
1321
- try { return fs.readdirSync(d).filter(f => f.endsWith('.json')).map(f => f.replace('.json', '')); } catch { return []; }
1325
+ try {
1326
+ const files = fs.readdirSync(d).filter(f => f.endsWith('.json'));
1327
+ console.log(`[Auth] listAuthProfiles(${p}): dir=${d}, count=${files.length}`);
1328
+ return files.map(f => f.replace('.json', ''));
1329
+ } catch { return []; }
1322
1330
  };
1323
1331
 
1324
1332
  app.get('/api/auth/providers', (req, res) => {
@@ -1513,6 +1521,7 @@ app.post('/api/auth/profiles/:provider/:name/activate', (req, res) => {
1513
1521
 
1514
1522
  app.delete('/api/auth/profiles/:provider/:name', (req, res) => {
1515
1523
  const { provider, name } = req.params;
1524
+ console.log(`[Auth] Deleting profile: ${provider}/${name}`);
1516
1525
  const activePlugin = getActiveGooglePlugin();
1517
1526
  const namespace = provider === 'google'
1518
1527
  ? (activePlugin === 'antigravity' ? 'google.antigravity' : 'google.gemini')
@@ -1520,7 +1529,14 @@ app.delete('/api/auth/profiles/:provider/:name', (req, res) => {
1520
1529
 
1521
1530
  const dir = getProfileDir(provider, activePlugin);
1522
1531
  const profilePath = path.join(dir, `${name}.json`);
1523
- if (fs.existsSync(profilePath)) fs.unlinkSync(profilePath);
1532
+ console.log(`[Auth] Target path: ${profilePath}, Exists: ${fs.existsSync(profilePath)}`);
1533
+
1534
+ if (fs.existsSync(profilePath)) {
1535
+ fs.unlinkSync(profilePath);
1536
+ console.log(`[Auth] Deleted file`);
1537
+ } else {
1538
+ console.log(`[Auth] File not found`);
1539
+ }
1524
1540
 
1525
1541
  const studio = loadStudioConfig();
1526
1542
  if (studio.activeProfiles && studio.activeProfiles[provider] === name) {
@@ -1692,12 +1708,14 @@ app.delete('/api/auth/:provider', (req, res) => {
1692
1708
  if (studio.activeProfiles) delete studio.activeProfiles[provider];
1693
1709
  saveStudioConfig(studio);
1694
1710
 
1695
- const providerDir = path.join(AUTH_PROFILES_DIR, provider);
1696
- if (fs.existsSync(providerDir)) fs.rmSync(providerDir, { recursive: true, force: true });
1711
+ // Do NOT delete the profile directory on logout. Users want to keep saved profiles.
1712
+ // const providerDir = path.join(AUTH_PROFILES_DIR, provider);
1713
+ // if (fs.existsSync(providerDir)) fs.rmSync(providerDir, { recursive: true, force: true });
1697
1714
 
1698
- const metadata = loadPoolMetadata();
1699
- delete metadata[provider];
1700
- savePoolMetadata(metadata);
1715
+ // Do NOT delete metadata either, as it tracks profile stats.
1716
+ // const metadata = loadPoolMetadata();
1717
+ // delete metadata[provider];
1718
+ // savePoolMetadata(metadata);
1701
1719
  }
1702
1720
 
1703
1721
  if (provider === 'google' && activePlugin) {
@@ -2563,6 +2581,8 @@ app.post('/api/auth/google/start', async (req, res) => {
2563
2581
  if (!fs.existsSync(profileDir)) fs.mkdirSync(profileDir, { recursive: true });
2564
2582
  const profileName = email || `google-${Date.now()}`;
2565
2583
  const profilePath = path.join(profileDir, `${profileName}.json`);
2584
+
2585
+ console.log(`[Auth] Saving profile to: ${profilePath}`);
2566
2586
  atomicWriteFileSync(profilePath, JSON.stringify(credentials, null, 2));
2567
2587
 
2568
2588
  const metadata = loadPoolMetadata();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {