opencode-studio-server 1.22.0 → 1.24.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 +19 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1104,7 +1104,11 @@ async function ensureGitHubRepo(token, repoName) {
1104
1104
 
1105
1105
  if (response.ok) {
1106
1106
  const data = await response.json();
1107
- if (!data.default_branch) {
1107
+ const branch = data.default_branch || 'main';
1108
+ const refRes = await fetch(`https://api.github.com/repos/${owner}/${repo}/git/refs/heads/${branch}`, {
1109
+ headers: { 'Authorization': `Bearer ${token}` }
1110
+ });
1111
+ if (refRes.status === 404 || refRes.status === 409) {
1108
1112
  await bootstrapEmptyRepo(token, owner, repo);
1109
1113
  }
1110
1114
  return data;
@@ -1159,23 +1163,28 @@ async function bootstrapEmptyRepo(token, owner, repo) {
1159
1163
  function collectBlobs(rootDir, basePath = '', blobs = []) {
1160
1164
  const dir = basePath || rootDir;
1161
1165
  if (!fs.existsSync(dir)) return blobs;
1166
+ const MAX_FILE_SIZE = 1024 * 1024;
1167
+ const SKIP_EXT = ['.log', '.tmp', '.db', '.sqlite', '.cache', '.pack', '.idx'];
1162
1168
 
1163
1169
  for (const name of fs.readdirSync(dir)) {
1164
1170
  const fullPath = path.join(dir, name);
1165
1171
  const stat = fs.statSync(fullPath);
1166
1172
 
1167
1173
  if (stat.isDirectory()) {
1168
- if (name === 'node_modules' || name === '.git' || name === '.next') continue;
1174
+ if (name === 'node_modules' || name === '.git' || name === '.next' || name === 'cache') continue;
1169
1175
  collectBlobs(rootDir, fullPath, blobs);
1170
1176
  } else {
1171
- if (name.endsWith('.log') || name.endsWith('.tmp')) continue;
1172
- const content = fs.readFileSync(fullPath, 'utf8');
1173
- blobs.push({
1174
- path: path.relative(rootDir, fullPath).replace(/\\/g, '/'),
1175
- mode: '100644',
1176
- type: 'blob',
1177
- content
1178
- });
1177
+ if (SKIP_EXT.some(ext => name.endsWith(ext))) continue;
1178
+ if (stat.size > MAX_FILE_SIZE) continue;
1179
+ try {
1180
+ const content = fs.readFileSync(fullPath, 'utf8');
1181
+ blobs.push({
1182
+ path: path.relative(rootDir, fullPath).replace(/\\/g, '/'),
1183
+ mode: '100644',
1184
+ type: 'blob',
1185
+ content
1186
+ });
1187
+ } catch (e) { }
1179
1188
  }
1180
1189
  }
1181
1190
  return blobs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-studio-server",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "Backend server for OpenCode Studio - manages opencode configurations",
5
5
  "main": "index.js",
6
6
  "bin": {