mega-brain-ai 1.2.3 → 1.2.5

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,50 @@ 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
- spinner.text = 'Clonando repositório premium...';
281
-
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
- {
289
- stdio: 'pipe',
290
- encoding: 'utf-8',
291
- timeout: 120000,
292
- }
293
- );
279
+ spinner.succeed(chalk.cyan('Iniciando download do conteúdo premium (~300 MB)...'));
280
+ console.log(chalk.dim(' Isso pode levar alguns minutos dependendo da sua conexão.\n'));
281
+
282
+ try {
283
+ execSync(`git clone --depth 1 "${authUrl}" "${tempDir}"`, {
284
+ stdio: 'inherit',
285
+ timeout: 600000,
286
+ });
287
+ } catch (cloneErr) {
288
+ throw new Error(`Git clone falhou. Verifique sua conexão e tente novamente.`);
289
+ }
290
+
291
+ console.log();
292
+ spinner.start('Verificando download...');
294
293
  } else {
295
294
  spinner.text = 'Download anterior encontrado, reutilizando...';
296
295
  }
297
296
 
297
+ // Verify clone has content
298
+ if (!existsSync(tempDir) || readdirSync(tempDir).length <= 1) {
299
+ throw new Error('Repositório premium clonado mas vazio.');
300
+ }
301
+
298
302
  spinner.text = 'Integrando conteúdo premium na estrutura...';
299
303
 
300
304
  // Copy premium content over the shell (merge, not replace)
301
305
  const premiumExclude = ['.git', 'node_modules', 'bin', '.layer-sync'];
302
306
  const premiumEntries = readdirSync(tempDir, { withFileTypes: true });
307
+ let copied = 0;
303
308
 
304
309
  for (const entry of premiumEntries) {
305
310
  if (premiumExclude.includes(entry.name)) continue;
@@ -312,12 +317,12 @@ async function fetchPremiumContent(targetDir, token, spinner) {
312
317
  } else {
313
318
  cpSync(srcPath, destPath, { force: true });
314
319
  }
320
+ copied++;
315
321
  }
316
322
 
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.
323
+ if (copied === 0) {
324
+ throw new Error('Nenhum conteúdo premium copiado.');
325
+ }
321
326
  }
322
327
 
323
328
  /**
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.5",
4
4
  "description": "AI Knowledge Management System - Transform expert materials into actionable playbooks",
5
5
  "type": "module",
6
6
  "bin": {