@innominatum/agentforge-cli 1.0.6 → 1.0.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.
- package/dist/index.js +37 -11
- package/package.json +1 -1
- package/src/index.ts +45 -12
package/dist/index.js
CHANGED
|
@@ -357,27 +357,53 @@ async function deployContextFiles(slug, config, resolvedId) {
|
|
|
357
357
|
throw new Error(`Agente não encontrado em agents/${slug}`);
|
|
358
358
|
}
|
|
359
359
|
const files = await fs_extra_1.default.readdir(agentPath);
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
360
|
+
// Identificar ficheiros de contexto e de memória
|
|
361
|
+
const memoryFileNames = ['MEMORY.md', 'memory.md'];
|
|
362
|
+
const memoryDirName = 'memory';
|
|
363
|
+
const contextFiles = files.filter(f => (f.endsWith('.md') || f.endsWith('.txt') || f.endsWith('.py')) &&
|
|
364
|
+
f !== 'README.md' &&
|
|
365
|
+
f !== 'agent.json' &&
|
|
366
|
+
!memoryFileNames.includes(f));
|
|
367
|
+
const hasMemoryDir = await fs_extra_1.default.pathExists(path_1.default.join(agentPath, memoryDirName));
|
|
368
|
+
const memoryFilesFound = files.filter(f => memoryFileNames.includes(f));
|
|
369
|
+
const hasMemory = hasMemoryDir || memoryFilesFound.length > 0;
|
|
370
|
+
if (contextFiles.length === 0 && !hasMemory) {
|
|
371
|
+
console.log(`Nenhum ficheiro de contexto ou memória encontrado para "${slug}".`);
|
|
363
372
|
return;
|
|
364
373
|
}
|
|
365
374
|
const tempExportDir = path_1.default.join(basePath, `temp_export_${slug}`);
|
|
366
375
|
const tempContextDir = path_1.default.join(tempExportDir, "context_files");
|
|
376
|
+
const tempMemoryDir = path_1.default.join(tempExportDir, "memory");
|
|
367
377
|
const tarPath = path_1.default.join(basePath, `temp_export_${slug}.tar.gz`);
|
|
368
378
|
try {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
379
|
+
const sections = [];
|
|
380
|
+
if (contextFiles.length > 0) {
|
|
381
|
+
sections.push("context_files");
|
|
382
|
+
await fs_extra_1.default.ensureDir(tempContextDir);
|
|
383
|
+
for (const file of contextFiles) {
|
|
384
|
+
await fs_extra_1.default.copy(path_1.default.join(agentPath, file), path_1.default.join(tempContextDir, file));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
if (hasMemory) {
|
|
388
|
+
sections.push("memory");
|
|
389
|
+
await fs_extra_1.default.ensureDir(tempMemoryDir);
|
|
390
|
+
// Copiar ficheiros de memória explícitos para a pasta memory no arquivo
|
|
391
|
+
for (const file of memoryFilesFound) {
|
|
392
|
+
await fs_extra_1.default.copy(path_1.default.join(agentPath, file), path_1.default.join(tempMemoryDir, file));
|
|
393
|
+
}
|
|
394
|
+
// Copiar conteúdo da pasta memory se existir
|
|
395
|
+
if (hasMemoryDir) {
|
|
396
|
+
await fs_extra_1.default.copy(path_1.default.join(agentPath, memoryDirName), tempMemoryDir);
|
|
397
|
+
}
|
|
372
398
|
}
|
|
373
399
|
await tar.c({
|
|
374
400
|
gzip: true,
|
|
375
401
|
file: tarPath,
|
|
376
402
|
cwd: tempExportDir
|
|
377
|
-
},
|
|
403
|
+
}, sections);
|
|
378
404
|
const form = new form_data_1.default();
|
|
379
405
|
form.append("file", fs_extra_1.default.createReadStream(tarPath));
|
|
380
|
-
const url = `${config.goclaw.api_url}/v1/agents/${agentId}/import?include
|
|
406
|
+
const url = `${config.goclaw.api_url}/v1/agents/${agentId}/import?include=${sections.join(",")}`;
|
|
381
407
|
await axios_1.default.post(url, form, {
|
|
382
408
|
headers: {
|
|
383
409
|
...form.getHeaders(),
|
|
@@ -385,7 +411,7 @@ async function deployContextFiles(slug, config, resolvedId) {
|
|
|
385
411
|
"X-GoClaw-User-Id": config.goclaw.username || "system"
|
|
386
412
|
}
|
|
387
413
|
});
|
|
388
|
-
console.log(`✅ Upload cirúrgico de ${contextFiles.length}
|
|
414
|
+
console.log(`✅ Upload cirúrgico de ${contextFiles.length} ficheiros de contexto e ${hasMemory ? 'dados de memória' : 'sem memória'} concluído com sucesso!`);
|
|
389
415
|
}
|
|
390
416
|
finally {
|
|
391
417
|
if (await fs_extra_1.default.pathExists(tempExportDir))
|
|
@@ -562,7 +588,7 @@ pullCmd
|
|
|
562
588
|
for (const agent of agents) {
|
|
563
589
|
const slug = agent.agent_key;
|
|
564
590
|
console.log(`📦 Baixando agente: ${slug}...`);
|
|
565
|
-
const url = `${config.goclaw.api_url}/v1/agents/${agent.id}/export`;
|
|
591
|
+
const url = `${config.goclaw.api_url}/v1/agents/${agent.id}/export?sections=config,context_files,memory`;
|
|
566
592
|
const response = await axios_1.default.get(url, {
|
|
567
593
|
headers: { Authorization: `Bearer ${config.goclaw.token}`, "X-GoClaw-User-Id": config.goclaw.username || "system" },
|
|
568
594
|
responseType: "stream"
|
|
@@ -582,7 +608,7 @@ pullCmd
|
|
|
582
608
|
cwd: agentPath,
|
|
583
609
|
strip: 0,
|
|
584
610
|
filter: (path) => {
|
|
585
|
-
return path === 'agent.json' || path.startsWith('context_files/');
|
|
611
|
+
return path === 'agent.json' || path.startsWith('context_files/') || path.startsWith('memory/') || path === 'MEMORY.md' || path === 'memory.md';
|
|
586
612
|
}
|
|
587
613
|
});
|
|
588
614
|
const contextDir = path_1.default.join(agentPath, "context_files");
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -376,33 +376,66 @@ async function deployContextFiles(slug: string, config: any, resolvedId?: string
|
|
|
376
376
|
}
|
|
377
377
|
|
|
378
378
|
const files = await fs.readdir(agentPath);
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
|
|
380
|
+
// Identificar ficheiros de contexto e de memória
|
|
381
|
+
const memoryFileNames = ['MEMORY.md', 'memory.md'];
|
|
382
|
+
const memoryDirName = 'memory';
|
|
383
|
+
|
|
384
|
+
const contextFiles = files.filter(f =>
|
|
385
|
+
(f.endsWith('.md') || f.endsWith('.txt') || f.endsWith('.py')) &&
|
|
386
|
+
f !== 'README.md' &&
|
|
387
|
+
f !== 'agent.json' &&
|
|
388
|
+
!memoryFileNames.includes(f)
|
|
389
|
+
);
|
|
390
|
+
|
|
391
|
+
const hasMemoryDir = await fs.pathExists(path.join(agentPath, memoryDirName));
|
|
392
|
+
const memoryFilesFound = files.filter(f => memoryFileNames.includes(f));
|
|
393
|
+
const hasMemory = hasMemoryDir || memoryFilesFound.length > 0;
|
|
394
|
+
|
|
395
|
+
if (contextFiles.length === 0 && !hasMemory) {
|
|
396
|
+
console.log(`Nenhum ficheiro de contexto ou memória encontrado para "${slug}".`);
|
|
383
397
|
return;
|
|
384
398
|
}
|
|
385
399
|
|
|
386
400
|
const tempExportDir = path.join(basePath, `temp_export_${slug}`);
|
|
387
401
|
const tempContextDir = path.join(tempExportDir, "context_files");
|
|
402
|
+
const tempMemoryDir = path.join(tempExportDir, "memory");
|
|
388
403
|
const tarPath = path.join(basePath, `temp_export_${slug}.tar.gz`);
|
|
389
404
|
|
|
390
405
|
try {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
406
|
+
const sections: string[] = [];
|
|
407
|
+
|
|
408
|
+
if (contextFiles.length > 0) {
|
|
409
|
+
sections.push("context_files");
|
|
410
|
+
await fs.ensureDir(tempContextDir);
|
|
411
|
+
for (const file of contextFiles) {
|
|
412
|
+
await fs.copy(path.join(agentPath, file), path.join(tempContextDir, file));
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (hasMemory) {
|
|
417
|
+
sections.push("memory");
|
|
418
|
+
await fs.ensureDir(tempMemoryDir);
|
|
419
|
+
// Copiar ficheiros de memória explícitos para a pasta memory no arquivo
|
|
420
|
+
for (const file of memoryFilesFound) {
|
|
421
|
+
await fs.copy(path.join(agentPath, file), path.join(tempMemoryDir, file));
|
|
422
|
+
}
|
|
423
|
+
// Copiar conteúdo da pasta memory se existir
|
|
424
|
+
if (hasMemoryDir) {
|
|
425
|
+
await fs.copy(path.join(agentPath, memoryDirName), tempMemoryDir);
|
|
426
|
+
}
|
|
394
427
|
}
|
|
395
428
|
|
|
396
429
|
await tar.c({
|
|
397
430
|
gzip: true,
|
|
398
431
|
file: tarPath,
|
|
399
432
|
cwd: tempExportDir
|
|
400
|
-
},
|
|
433
|
+
}, sections);
|
|
401
434
|
|
|
402
435
|
const form = new FormData();
|
|
403
436
|
form.append("file", fs.createReadStream(tarPath));
|
|
404
437
|
|
|
405
|
-
const url = `${config.goclaw.api_url}/v1/agents/${agentId}/import?include
|
|
438
|
+
const url = `${config.goclaw.api_url}/v1/agents/${agentId}/import?include=${sections.join(",")}`;
|
|
406
439
|
await axios.post(url, form, {
|
|
407
440
|
headers: {
|
|
408
441
|
...form.getHeaders(),
|
|
@@ -411,7 +444,7 @@ async function deployContextFiles(slug: string, config: any, resolvedId?: string
|
|
|
411
444
|
}
|
|
412
445
|
});
|
|
413
446
|
|
|
414
|
-
console.log(`✅ Upload cirúrgico de ${contextFiles.length}
|
|
447
|
+
console.log(`✅ Upload cirúrgico de ${contextFiles.length} ficheiros de contexto e ${hasMemory ? 'dados de memória' : 'sem memória'} concluído com sucesso!`);
|
|
415
448
|
} finally {
|
|
416
449
|
if (await fs.pathExists(tempExportDir)) await fs.remove(tempExportDir);
|
|
417
450
|
if (await fs.pathExists(tarPath)) await fs.remove(tarPath);
|
|
@@ -607,7 +640,7 @@ pullCmd
|
|
|
607
640
|
const slug = agent.agent_key;
|
|
608
641
|
console.log(`📦 Baixando agente: ${slug}...`);
|
|
609
642
|
|
|
610
|
-
const url = `${config.goclaw.api_url}/v1/agents/${agent.id}/export`;
|
|
643
|
+
const url = `${config.goclaw.api_url}/v1/agents/${agent.id}/export?sections=config,context_files,memory`;
|
|
611
644
|
const response = await axios.get(url, {
|
|
612
645
|
headers: { Authorization: `Bearer ${config.goclaw.token}`, "X-GoClaw-User-Id": config.goclaw.username || "system" },
|
|
613
646
|
responseType: "stream"
|
|
@@ -632,7 +665,7 @@ pullCmd
|
|
|
632
665
|
cwd: agentPath,
|
|
633
666
|
strip: 0,
|
|
634
667
|
filter: (path) => {
|
|
635
|
-
return path === 'agent.json' || path.startsWith('context_files/');
|
|
668
|
+
return path === 'agent.json' || path.startsWith('context_files/') || path.startsWith('memory/') || path === 'MEMORY.md' || path === 'memory.md';
|
|
636
669
|
}
|
|
637
670
|
});
|
|
638
671
|
|