mega-brain-ai 1.2.5 → 1.2.7
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.
- package/.github/layer2-manifest.txt +1 -3
- package/bin/lib/installer.js +72 -27
- package/package.json +1 -1
|
@@ -23,9 +23,6 @@ agents/persons/
|
|
|
23
23
|
# Processed content
|
|
24
24
|
processing/
|
|
25
25
|
|
|
26
|
-
# BILHON company module
|
|
27
|
-
.bilhon/
|
|
28
|
-
|
|
29
26
|
# === LAYER 3 EXCLUSIONS (never in Layer 2) ===
|
|
30
27
|
# These are stripped from Layer 2 pushes:
|
|
31
28
|
# - inbox/ (raw user uploads)
|
|
@@ -38,3 +35,4 @@ processing/
|
|
|
38
35
|
# - .claude/monitoring/ (runtime state)
|
|
39
36
|
# - system/backups/ (personal backups)
|
|
40
37
|
# - system/jarvis-voice/audiobooks/ (personal audio)
|
|
38
|
+
# - .bilhon/ (company data - Layer 3)
|
package/bin/lib/installer.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 6. Post-install summary
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { existsSync, mkdirSync, cpSync, writeFileSync, readFileSync, readdirSync } from 'fs';
|
|
16
|
+
import { existsSync, mkdirSync, cpSync, writeFileSync, readFileSync, readdirSync, rmSync } from 'fs';
|
|
17
17
|
import { resolve, dirname, join } from 'path';
|
|
18
18
|
import { fileURLToPath } from 'url';
|
|
19
19
|
import { execSync } from 'child_process';
|
|
@@ -195,7 +195,6 @@ export async function runInstaller(version) {
|
|
|
195
195
|
|
|
196
196
|
try {
|
|
197
197
|
await fetchPremiumContent(targetDir, premiumToken, premiumSpinner);
|
|
198
|
-
premiumSpinner.succeed(chalk.green('Conteúdo PREMIUM instalado!'));
|
|
199
198
|
} catch (err) {
|
|
200
199
|
premiumSpinner.warn(chalk.yellow(`Não foi possível baixar conteúdo premium: ${err.message}`));
|
|
201
200
|
console.log(chalk.dim(' Tente novamente depois com: mega-brain upgrade'));
|
|
@@ -253,12 +252,12 @@ async function selectEdition() {
|
|
|
253
252
|
/**
|
|
254
253
|
* Fetch premium content from private repo using token
|
|
255
254
|
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
255
|
+
* LAYER 2 DESIGN:
|
|
256
|
+
* Layer 1 (npm) installs the empty shell.
|
|
257
|
+
* Layer 2 (this function) fills ONLY the premium paths defined
|
|
258
|
+
* in .github/layer2-manifest.txt — nothing else.
|
|
259
|
+
*
|
|
260
|
+
* After copying, the temporary clone is deleted to save disk space.
|
|
262
261
|
*/
|
|
263
262
|
async function fetchPremiumContent(targetDir, token, spinner) {
|
|
264
263
|
const tempDir = join(targetDir, '.layer-sync', 'premium-fetch');
|
|
@@ -270,13 +269,13 @@ async function fetchPremiumContent(targetDir, token, spinner) {
|
|
|
270
269
|
throw new Error('Erro interno: caminho de download fora do diretório de instalação.');
|
|
271
270
|
}
|
|
272
271
|
|
|
273
|
-
mkdirSync(
|
|
272
|
+
mkdirSync(join(targetDir, '.layer-sync'), { recursive: true });
|
|
274
273
|
|
|
275
|
-
// Clone with token in URL — .layer-sync/ is in .gitignore so token stays local
|
|
276
274
|
const authUrl = `https://x-access-token:${token}@github.com/thiagofinch/mega-brain-premium.git`;
|
|
277
275
|
|
|
276
|
+
// --- CLONE ---
|
|
278
277
|
if (!existsSync(join(tempDir, '.git'))) {
|
|
279
|
-
spinner.succeed(chalk.cyan('
|
|
278
|
+
spinner.succeed(chalk.cyan('Baixando conteúdo premium...'));
|
|
280
279
|
console.log(chalk.dim(' Isso pode levar alguns minutos dependendo da sua conexão.\n'));
|
|
281
280
|
|
|
282
281
|
try {
|
|
@@ -285,7 +284,7 @@ async function fetchPremiumContent(targetDir, token, spinner) {
|
|
|
285
284
|
timeout: 600000,
|
|
286
285
|
});
|
|
287
286
|
} catch (cloneErr) {
|
|
288
|
-
throw new Error(
|
|
287
|
+
throw new Error('Git clone falhou. Verifique sua conexão e tente novamente.');
|
|
289
288
|
}
|
|
290
289
|
|
|
291
290
|
console.log();
|
|
@@ -294,35 +293,81 @@ async function fetchPremiumContent(targetDir, token, spinner) {
|
|
|
294
293
|
spinner.text = 'Download anterior encontrado, reutilizando...';
|
|
295
294
|
}
|
|
296
295
|
|
|
297
|
-
// Verify clone has content
|
|
298
296
|
if (!existsSync(tempDir) || readdirSync(tempDir).length <= 1) {
|
|
299
297
|
throw new Error('Repositório premium clonado mas vazio.');
|
|
300
298
|
}
|
|
301
299
|
|
|
302
|
-
|
|
300
|
+
// --- READ LAYER 2 MANIFEST ---
|
|
301
|
+
// The manifest lives in the Layer 1 shell (already installed).
|
|
302
|
+
// It lists which paths are premium additions.
|
|
303
|
+
const manifestPath = join(targetDir, '.github', 'layer2-manifest.txt');
|
|
304
|
+
const layer2Paths = parseManifestPaths(manifestPath);
|
|
305
|
+
|
|
306
|
+
if (layer2Paths.length === 0) {
|
|
307
|
+
throw new Error('layer2-manifest.txt vazio ou não encontrado.');
|
|
308
|
+
}
|
|
303
309
|
|
|
304
|
-
//
|
|
305
|
-
|
|
306
|
-
const premiumEntries = readdirSync(tempDir, { withFileTypes: true });
|
|
310
|
+
// --- SELECTIVE COPY: only Layer 2 paths ---
|
|
311
|
+
spinner.text = 'Integrando conteúdo premium (apenas Layer 2)...';
|
|
307
312
|
let copied = 0;
|
|
308
313
|
|
|
309
|
-
for (const
|
|
310
|
-
|
|
314
|
+
for (const relPath of layer2Paths) {
|
|
315
|
+
const srcPath = join(tempDir, relPath);
|
|
316
|
+
const destPath = join(targetDir, relPath);
|
|
311
317
|
|
|
312
|
-
|
|
313
|
-
const destPath = join(targetDir, entry.name);
|
|
318
|
+
if (!existsSync(srcPath)) continue;
|
|
314
319
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
} else {
|
|
318
|
-
cpSync(srcPath, destPath, { force: true });
|
|
319
|
-
}
|
|
320
|
+
mkdirSync(dirname(destPath), { recursive: true });
|
|
321
|
+
cpSync(srcPath, destPath, { recursive: true, force: true });
|
|
320
322
|
copied++;
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
if (copied === 0) {
|
|
324
|
-
throw new Error('Nenhum conteúdo premium
|
|
326
|
+
throw new Error('Nenhum conteúdo premium encontrado no repositório.');
|
|
325
327
|
}
|
|
328
|
+
|
|
329
|
+
spinner.text = 'Limpando arquivos temporários...';
|
|
330
|
+
|
|
331
|
+
// --- CLEANUP: delete the clone to save disk space ---
|
|
332
|
+
try {
|
|
333
|
+
rmSync(join(targetDir, '.layer-sync'), { recursive: true, force: true });
|
|
334
|
+
} catch {
|
|
335
|
+
// Non-fatal: warn but don't fail if cleanup fails
|
|
336
|
+
console.log(chalk.dim(' Aviso: não foi possível limpar .layer-sync/'));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
spinner.succeed(chalk.green(`Conteúdo PREMIUM instalado! (${copied} módulos)`));
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Parse layer2-manifest.txt and return clean directory paths.
|
|
344
|
+
* Ignores comments (#), blank lines, and LAYER 3 EXCLUSIONS section.
|
|
345
|
+
*/
|
|
346
|
+
function parseManifestPaths(manifestPath) {
|
|
347
|
+
if (!existsSync(manifestPath)) return [];
|
|
348
|
+
|
|
349
|
+
const content = readFileSync(manifestPath, 'utf-8');
|
|
350
|
+
const paths = [];
|
|
351
|
+
let inExclusions = false;
|
|
352
|
+
|
|
353
|
+
for (const raw of content.split('\n')) {
|
|
354
|
+
const line = raw.trim();
|
|
355
|
+
|
|
356
|
+
// Stop parsing at Layer 3 exclusions section
|
|
357
|
+
if (line.includes('LAYER 3 EXCLUSIONS')) {
|
|
358
|
+
inExclusions = true;
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
if (inExclusions) continue;
|
|
362
|
+
|
|
363
|
+
// Skip comments and blanks
|
|
364
|
+
if (!line || line.startsWith('#')) continue;
|
|
365
|
+
|
|
366
|
+
// Normalize: remove trailing slash
|
|
367
|
+
paths.push(line.replace(/\/+$/, ''));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return paths;
|
|
326
371
|
}
|
|
327
372
|
|
|
328
373
|
/**
|