opencode-studio-server 1.23.0 → 1.25.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.
Files changed (2) hide show
  1. package/index.js +31 -17
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1163,23 +1163,26 @@ async function bootstrapEmptyRepo(token, owner, repo) {
1163
1163
  function collectBlobs(rootDir, basePath = '', blobs = []) {
1164
1164
  const dir = basePath || rootDir;
1165
1165
  if (!fs.existsSync(dir)) return blobs;
1166
+ const SKIP_EXT = ['.log', '.tmp', '.db', '.sqlite', '.cache', '.pack', '.idx'];
1166
1167
 
1167
1168
  for (const name of fs.readdirSync(dir)) {
1168
1169
  const fullPath = path.join(dir, name);
1169
1170
  const stat = fs.statSync(fullPath);
1170
1171
 
1171
1172
  if (stat.isDirectory()) {
1172
- if (name === 'node_modules' || name === '.git' || name === '.next') continue;
1173
+ if (name === 'node_modules' || name === '.git' || name === '.next' || name === 'cache') continue;
1173
1174
  collectBlobs(rootDir, fullPath, blobs);
1174
1175
  } else {
1175
- if (name.endsWith('.log') || name.endsWith('.tmp')) continue;
1176
- const content = fs.readFileSync(fullPath, 'utf8');
1177
- blobs.push({
1178
- path: path.relative(rootDir, fullPath).replace(/\\/g, '/'),
1179
- mode: '100644',
1180
- type: 'blob',
1181
- content
1182
- });
1176
+ if (SKIP_EXT.some(ext => name.endsWith(ext))) continue;
1177
+ try {
1178
+ const content = fs.readFileSync(fullPath, 'utf8');
1179
+ blobs.push({
1180
+ path: path.relative(rootDir, fullPath).replace(/\\/g, '/'),
1181
+ mode: '100644',
1182
+ type: 'blob',
1183
+ content
1184
+ });
1185
+ } catch (e) { }
1183
1186
  }
1184
1187
  }
1185
1188
  return blobs;
@@ -1377,20 +1380,31 @@ app.post('/api/github/backup', async (req, res) => {
1377
1380
 
1378
1381
  const opencodeBlobs = collectBlobs(opencodeDir);
1379
1382
  const studioBlobs = collectBlobs(studioDir);
1383
+ const skipped = [];
1380
1384
 
1381
1385
  for (const blob of opencodeBlobs) {
1382
- blob.sha = await createGitHubBlob(token, repoName, blob);
1383
- blob.path = `opencode/${blob.path}`;
1384
- delete blob.content;
1386
+ try {
1387
+ blob.sha = await createGitHubBlob(token, repoName, blob);
1388
+ blob.path = `opencode/${blob.path}`;
1389
+ delete blob.content;
1390
+ } catch (e) {
1391
+ skipped.push({ path: `opencode/${blob.path}`, reason: e.message, size: Buffer.byteLength(blob.content) });
1392
+ blob.skip = true;
1393
+ }
1385
1394
  }
1386
1395
 
1387
1396
  for (const blob of studioBlobs) {
1388
- blob.sha = await createGitHubBlob(token, repoName, blob);
1389
- blob.path = `opencode-studio/${blob.path}`;
1390
- delete blob.content;
1397
+ try {
1398
+ blob.sha = await createGitHubBlob(token, repoName, blob);
1399
+ blob.path = `opencode-studio/${blob.path}`;
1400
+ delete blob.content;
1401
+ } catch (e) {
1402
+ skipped.push({ path: `opencode-studio/${blob.path}`, reason: e.message, size: Buffer.byteLength(blob.content) });
1403
+ blob.skip = true;
1404
+ }
1391
1405
  }
1392
1406
 
1393
- const allBlobs = [...opencodeBlobs, ...studioBlobs];
1407
+ const allBlobs = [...opencodeBlobs, ...studioBlobs].filter(b => !b.skip);
1394
1408
  const rootTreeSha = await createGitHubTree(token, repoName, allBlobs);
1395
1409
 
1396
1410
  const timestamp = new Date().toISOString();
@@ -1403,7 +1417,7 @@ app.post('/api/github/backup', async (req, res) => {
1403
1417
  studio.lastGithubBackup = timestamp;
1404
1418
  saveStudioConfig(studio);
1405
1419
 
1406
- res.json({ success: true, timestamp, commit: commitSha, url: `https://github.com/${repoName}` });
1420
+ res.json({ success: true, timestamp, commit: commitSha, url: `https://github.com/${repoName}`, skipped });
1407
1421
  } catch (err) {
1408
1422
  console.error('GitHub backup error:', err);
1409
1423
  res.status(500).json({ error: err.message });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.23.0",
3
+ "version": "1.25.0",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {