mega-brain-ai 1.2.3 → 1.2.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.

Potentially problematic release.


This version of mega-brain-ai might be problematic. Click here for more details.

@@ -261,45 +261,47 @@ async function selectEdition() {
261
261
  * This installer runs on other people's machines — we never risk data loss.
262
262
  */
263
263
  async function fetchPremiumContent(targetDir, token, spinner) {
264
- const premiumRepo = 'https://github.com/thiagofinch/mega-brain-premium.git';
265
264
  const tempDir = join(targetDir, '.layer-sync', 'premium-fetch');
266
265
 
267
- // Safety: ensure tempDir is strictly INSIDE targetDir (prevent path traversal)
266
+ // Safety: ensure tempDir is strictly INSIDE targetDir
268
267
  const resolvedTemp = resolve(tempDir);
269
268
  const resolvedTarget = resolve(targetDir);
270
269
  if (!resolvedTemp.startsWith(resolvedTarget + '/') && !resolvedTemp.startsWith(resolvedTarget + '\\')) {
271
270
  throw new Error('Erro interno: caminho de download fora do diretório de instalação.');
272
271
  }
273
272
 
274
- if (!existsSync(dirname(tempDir))) {
275
- mkdirSync(dirname(tempDir), { recursive: true });
276
- }
273
+ mkdirSync(dirname(tempDir), { recursive: true });
274
+
275
+ // Clone with token in URL — .layer-sync/ is in .gitignore so token stays local
276
+ const authUrl = `https://x-access-token:${token}@github.com/thiagofinch/mega-brain-premium.git`;
277
277
 
278
- // If a previous clone exists, reuse it (no delete + re-clone)
279
278
  if (!existsSync(join(tempDir, '.git'))) {
280
279
  spinner.text = 'Clonando repositório premium...';
281
280
 
282
- // Use http.extraheader so the token is NEVER written to .git/config.
283
- // The -c flag is a runtime-only override — not persisted to disk.
284
- const base64Auth = Buffer.from(`x-access-token:${token}`).toString('base64');
285
-
286
- execSync(
287
- `git -c "http.https://github.com/.extraheader=AUTHORIZATION: basic ${base64Auth}" clone --depth 1 "${premiumRepo}" "${tempDir}"`,
288
- {
281
+ try {
282
+ execSync(`git clone --depth 1 "${authUrl}" "${tempDir}"`, {
289
283
  stdio: 'pipe',
290
284
  encoding: 'utf-8',
291
285
  timeout: 120000,
292
- }
293
- );
286
+ });
287
+ } catch (cloneErr) {
288
+ throw new Error(`Git clone falhou: ${cloneErr.message.split('\n')[0]}`);
289
+ }
294
290
  } else {
295
291
  spinner.text = 'Download anterior encontrado, reutilizando...';
296
292
  }
297
293
 
294
+ // Verify clone has content
295
+ if (!existsSync(tempDir) || readdirSync(tempDir).length <= 1) {
296
+ throw new Error('Repositório premium clonado mas vazio.');
297
+ }
298
+
298
299
  spinner.text = 'Integrando conteúdo premium na estrutura...';
299
300
 
300
301
  // Copy premium content over the shell (merge, not replace)
301
302
  const premiumExclude = ['.git', 'node_modules', 'bin', '.layer-sync'];
302
303
  const premiumEntries = readdirSync(tempDir, { withFileTypes: true });
304
+ let copied = 0;
303
305
 
304
306
  for (const entry of premiumEntries) {
305
307
  if (premiumExclude.includes(entry.name)) continue;
@@ -312,12 +314,12 @@ async function fetchPremiumContent(targetDir, token, spinner) {
312
314
  } else {
313
315
  cpSync(srcPath, destPath, { force: true });
314
316
  }
317
+ copied++;
315
318
  }
316
319
 
317
- // NOTE: .layer-sync/ is intentionally NOT deleted.
318
- // It is listed in .gitignore and contains no sensitive data
319
- // (token was never written to disk thanks to http.extraheader).
320
- // We NEVER use recursive delete operations on user machines.
320
+ if (copied === 0) {
321
+ throw new Error('Nenhum conteúdo premium copiado.');
322
+ }
321
323
  }
322
324
 
323
325
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mega-brain-ai",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "AI Knowledge Management System - Transform expert materials into actionable playbooks",
5
5
  "type": "module",
6
6
  "bin": {