@base44-preview/cli 0.0.31-pr.228.ffa357a → 0.0.31-pr.229.68dc4c8
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/cli/index.js +23 -41
- package/dist/cli/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -160583,16 +160583,15 @@ async function fetchAgents() {
|
|
|
160583
160583
|
}
|
|
160584
160584
|
// src/core/resources/agent/config.ts
|
|
160585
160585
|
import { join as join3 } from "node:path";
|
|
160586
|
-
import { isDeepStrictEqual } from "node:util";
|
|
160587
160586
|
async function readAgentFile(agentPath) {
|
|
160588
|
-
const
|
|
160589
|
-
const result = AgentConfigSchema.safeParse(
|
|
160587
|
+
const parsed = await readJsonFile(agentPath);
|
|
160588
|
+
const result = AgentConfigSchema.safeParse(parsed);
|
|
160590
160589
|
if (!result.success) {
|
|
160591
160590
|
throw new SchemaValidationError("Invalid agent file", result.error, agentPath);
|
|
160592
160591
|
}
|
|
160593
|
-
return
|
|
160592
|
+
return result.data;
|
|
160594
160593
|
}
|
|
160595
|
-
async function
|
|
160594
|
+
async function readAllAgents(agentsDir) {
|
|
160596
160595
|
if (!await pathExists(agentsDir)) {
|
|
160597
160596
|
return [];
|
|
160598
160597
|
}
|
|
@@ -160600,49 +160599,35 @@ async function readAgentFiles(agentsDir) {
|
|
|
160600
160599
|
cwd: agentsDir,
|
|
160601
160600
|
absolute: true
|
|
160602
160601
|
});
|
|
160603
|
-
|
|
160604
|
-
const { data, raw: raw2 } = await readAgentFile(filePath);
|
|
160605
|
-
return { data, raw: raw2, filePath };
|
|
160606
|
-
}));
|
|
160607
|
-
}
|
|
160608
|
-
async function readAllAgents(agentsDir) {
|
|
160609
|
-
const entries = await readAgentFiles(agentsDir);
|
|
160602
|
+
const agents = await Promise.all(files.map((filePath) => readAgentFile(filePath)));
|
|
160610
160603
|
const names = new Set;
|
|
160611
|
-
for (const
|
|
160612
|
-
if (names.has(
|
|
160613
|
-
throw new Error(`Duplicate agent name "${
|
|
160604
|
+
for (const agent of agents) {
|
|
160605
|
+
if (names.has(agent.name)) {
|
|
160606
|
+
throw new Error(`Duplicate agent name "${agent.name}"`);
|
|
160614
160607
|
}
|
|
160615
|
-
names.add(
|
|
160608
|
+
names.add(agent.name);
|
|
160616
160609
|
}
|
|
160617
|
-
return
|
|
160610
|
+
return agents;
|
|
160618
160611
|
}
|
|
160619
160612
|
async function writeAgents(agentsDir, remoteAgents) {
|
|
160620
|
-
const
|
|
160621
|
-
const nameToEntry = new Map;
|
|
160622
|
-
for (const entry of entries) {
|
|
160623
|
-
if (nameToEntry.has(entry.data.name)) {
|
|
160624
|
-
throw new Error(`Duplicate agent name "${entry.data.name}"`);
|
|
160625
|
-
}
|
|
160626
|
-
nameToEntry.set(entry.data.name, entry);
|
|
160627
|
-
}
|
|
160613
|
+
const existingAgents = await readAllAgents(agentsDir);
|
|
160628
160614
|
const newNames = new Set(remoteAgents.map((a) => a.name));
|
|
160629
|
-
const
|
|
160630
|
-
for (const
|
|
160631
|
-
|
|
160632
|
-
|
|
160633
|
-
|
|
160615
|
+
const toDelete = existingAgents.filter((a) => !newNames.has(a.name));
|
|
160616
|
+
for (const agent of toDelete) {
|
|
160617
|
+
const files = await globby(`${agent.name}.${CONFIG_FILE_EXTENSION_GLOB}`, {
|
|
160618
|
+
cwd: agentsDir,
|
|
160619
|
+
absolute: true
|
|
160620
|
+
});
|
|
160621
|
+
for (const filePath of files) {
|
|
160622
|
+
await deleteFile(filePath);
|
|
160634
160623
|
}
|
|
160635
160624
|
}
|
|
160636
|
-
const written = [];
|
|
160637
160625
|
for (const agent of remoteAgents) {
|
|
160638
|
-
const
|
|
160639
|
-
if (existing && isDeepStrictEqual(existing.raw, agent)) {
|
|
160640
|
-
continue;
|
|
160641
|
-
}
|
|
160642
|
-
const filePath = existing?.filePath ?? join3(agentsDir, `${agent.name}.${CONFIG_FILE_EXTENSION}`);
|
|
160626
|
+
const filePath = join3(agentsDir, `${agent.name}.${CONFIG_FILE_EXTENSION}`);
|
|
160643
160627
|
await writeJsonFile(filePath, agent);
|
|
160644
|
-
written.push(agent.name);
|
|
160645
160628
|
}
|
|
160629
|
+
const written = remoteAgents.map((a) => a.name);
|
|
160630
|
+
const deleted = toDelete.map((a) => a.name);
|
|
160646
160631
|
return { written, deleted };
|
|
160647
160632
|
}
|
|
160648
160633
|
// src/core/resources/agent/resource.ts
|
|
@@ -168961,9 +168946,6 @@ async function pullAgentsAction() {
|
|
|
168961
168946
|
if (deleted.length > 0) {
|
|
168962
168947
|
M2.warn(`Deleted: ${deleted.join(", ")}`);
|
|
168963
168948
|
}
|
|
168964
|
-
if (written.length === 0 && deleted.length === 0) {
|
|
168965
|
-
M2.info("All agents are already up to date");
|
|
168966
|
-
}
|
|
168967
168949
|
return {
|
|
168968
168950
|
outroMessage: `Pulled ${remoteAgents.total} agents to ${agentsDir}`
|
|
168969
168951
|
};
|
|
@@ -174671,4 +174653,4 @@ export {
|
|
|
174671
174653
|
CLIExitError
|
|
174672
174654
|
};
|
|
174673
174655
|
|
|
174674
|
-
//# debugId=
|
|
174656
|
+
//# debugId=7DB4F7ABF0AFAEA664756E2164756E21
|