@brainbase-labs/cli 0.7.0 → 0.7.1
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 +53 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -29449,7 +29449,7 @@ function padStart(s, n) {
|
|
|
29449
29449
|
// package.json
|
|
29450
29450
|
var package_default = {
|
|
29451
29451
|
name: "@brainbase-labs/cli",
|
|
29452
|
-
version: "0.7.
|
|
29452
|
+
version: "0.7.1",
|
|
29453
29453
|
description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
|
|
29454
29454
|
type: "module",
|
|
29455
29455
|
bin: {
|
|
@@ -54478,6 +54478,33 @@ function writeOrchManifest(cwd2, manifest) {
|
|
|
54478
54478
|
function memberDir(cwd2, slug) {
|
|
54479
54479
|
return path51.join(cwd2, ORCH_MEMBERS_DIR, slug);
|
|
54480
54480
|
}
|
|
54481
|
+
var MEMBER_SLUG_MAX = 50;
|
|
54482
|
+
function slugifyRaw(raw) {
|
|
54483
|
+
return (raw || "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
54484
|
+
}
|
|
54485
|
+
function resolveMemberSlugs(members) {
|
|
54486
|
+
const SAFE = /^[a-z0-9][a-z0-9-]*$/;
|
|
54487
|
+
const used = new Set;
|
|
54488
|
+
const byAgent = new Map;
|
|
54489
|
+
for (const m3 of members) {
|
|
54490
|
+
const raw = (m3.slug ?? "").trim();
|
|
54491
|
+
let base2 = raw && SAFE.test(raw) ? raw : slugifyRaw(raw) || slugifyRaw(m3.name ?? "") || "agent";
|
|
54492
|
+
if (base2.length > MEMBER_SLUG_MAX) {
|
|
54493
|
+
base2 = base2.slice(0, MEMBER_SLUG_MAX).replace(/-+$/, "") || base2.slice(0, MEMBER_SLUG_MAX);
|
|
54494
|
+
}
|
|
54495
|
+
let slug = base2;
|
|
54496
|
+
if (used.has(slug)) {
|
|
54497
|
+
const suffix = (m3.agent_id || "").split("-")[0] || "x";
|
|
54498
|
+
slug = `${base2}-${suffix}`;
|
|
54499
|
+
let n = 2;
|
|
54500
|
+
while (used.has(slug))
|
|
54501
|
+
slug = `${base2}-${suffix}-${n++}`;
|
|
54502
|
+
}
|
|
54503
|
+
used.add(slug);
|
|
54504
|
+
byAgent.set(m3.agent_id, slug);
|
|
54505
|
+
}
|
|
54506
|
+
return byAgent;
|
|
54507
|
+
}
|
|
54481
54508
|
|
|
54482
54509
|
// src/core/orchestration-link.ts
|
|
54483
54510
|
import path52 from "node:path";
|
|
@@ -54774,6 +54801,8 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54774
54801
|
handleApiError5(err);
|
|
54775
54802
|
return;
|
|
54776
54803
|
}
|
|
54804
|
+
const slugByAgent = resolveMemberSlugs(cloud.members);
|
|
54805
|
+
const slugFor = (agentId) => slugByAgent.get(agentId) ?? agentId;
|
|
54777
54806
|
const planLines = [];
|
|
54778
54807
|
planLines.push("");
|
|
54779
54808
|
planLines.push(` ${import_picocolors33.default.bold(cloud.name)} ${import_picocolors33.default.dim(`(${cloud.id})`)}`);
|
|
@@ -54784,14 +54813,14 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54784
54813
|
for (const m3 of cloud.members) {
|
|
54785
54814
|
const skipped = !m3.manifest;
|
|
54786
54815
|
const tail2 = skipped ? import_picocolors33.default.red(" (manifest unavailable — skipped)") : "";
|
|
54787
|
-
planLines.push(` ${import_picocolors33.default.cyan("•")} ${import_picocolors33.default.bold(m3.
|
|
54816
|
+
planLines.push(` ${import_picocolors33.default.cyan("•")} ${import_picocolors33.default.bold(slugFor(m3.agent_id))} ${import_picocolors33.default.dim(`(${m3.name})`)}${tail2}`);
|
|
54788
54817
|
}
|
|
54789
54818
|
if (cloud.edges.length) {
|
|
54790
54819
|
planLines.push("");
|
|
54791
54820
|
planLines.push(` ${import_picocolors33.default.dim("edges:")}`);
|
|
54792
54821
|
for (const e2 of cloud.edges) {
|
|
54793
|
-
const from = e2.
|
|
54794
|
-
const to2 = e2.
|
|
54822
|
+
const from = slugFor(e2.from_agent_id);
|
|
54823
|
+
const to2 = slugFor(e2.to_agent_id);
|
|
54795
54824
|
const desc = e2.description ? ` ${import_picocolors33.default.dim("— " + e2.description)}` : "";
|
|
54796
54825
|
planLines.push(` ${import_picocolors33.default.cyan(from)} ${import_picocolors33.default.dim("→")} ${import_picocolors33.default.cyan(to2)}${desc}`);
|
|
54797
54826
|
}
|
|
@@ -54822,16 +54851,17 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54822
54851
|
f2.warn(`Skipping member ${m3.slug}: server did not return a manifest.`);
|
|
54823
54852
|
continue;
|
|
54824
54853
|
}
|
|
54825
|
-
const
|
|
54854
|
+
const slug = slugFor(m3.agent_id);
|
|
54855
|
+
const dest = memberDir(cwd2, slug);
|
|
54826
54856
|
const memberSp = de();
|
|
54827
|
-
memberSp.start(`Installing ${
|
|
54857
|
+
memberSp.start(`Installing ${slug}…`);
|
|
54828
54858
|
try {
|
|
54829
54859
|
await installAgentFresh({
|
|
54830
54860
|
cwd: dest,
|
|
54831
54861
|
agent: {
|
|
54832
54862
|
id: m3.agent_id,
|
|
54833
|
-
name: m3.name ||
|
|
54834
|
-
slug
|
|
54863
|
+
name: m3.name || slug,
|
|
54864
|
+
slug,
|
|
54835
54865
|
tagline: undefined,
|
|
54836
54866
|
org_id: cloud.group_id,
|
|
54837
54867
|
team_id: cloud.group_id,
|
|
@@ -54843,14 +54873,14 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54843
54873
|
scope: "project",
|
|
54844
54874
|
pullSecrets: true
|
|
54845
54875
|
});
|
|
54846
|
-
memberSp.stop(`Installed ${import_picocolors33.default.bold(
|
|
54876
|
+
memberSp.stop(`Installed ${import_picocolors33.default.bold(slug)} ${import_picocolors33.default.dim(`(${m3.manifest.components.length} components)`)}.`);
|
|
54847
54877
|
installedMembers.push({
|
|
54848
54878
|
agent_id: m3.agent_id,
|
|
54849
|
-
slug
|
|
54879
|
+
slug,
|
|
54850
54880
|
revision: m3.manifest.revision
|
|
54851
54881
|
});
|
|
54852
54882
|
} catch (err) {
|
|
54853
|
-
memberSp.stop(`Failed to install ${
|
|
54883
|
+
memberSp.stop(`Failed to install ${slug}.`);
|
|
54854
54884
|
f2.error(err.message);
|
|
54855
54885
|
}
|
|
54856
54886
|
}
|
|
@@ -54863,13 +54893,16 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54863
54893
|
...cloud.icon_color ? { icon_color: cloud.icon_color } : {},
|
|
54864
54894
|
...cloud.credit_limit != null ? { credit_limit: cloud.credit_limit } : {}
|
|
54865
54895
|
},
|
|
54866
|
-
members: cloud.members.map((m3) =>
|
|
54867
|
-
slug
|
|
54868
|
-
|
|
54869
|
-
|
|
54896
|
+
members: cloud.members.map((m3) => {
|
|
54897
|
+
const slug = slugFor(m3.agent_id);
|
|
54898
|
+
return {
|
|
54899
|
+
slug,
|
|
54900
|
+
...m3.name && m3.name !== slug ? { name: m3.name } : {}
|
|
54901
|
+
};
|
|
54902
|
+
}),
|
|
54870
54903
|
edges: cloud.edges.map((e2) => ({
|
|
54871
|
-
from: e2.
|
|
54872
|
-
to: e2.
|
|
54904
|
+
from: slugFor(e2.from_agent_id),
|
|
54905
|
+
to: slugFor(e2.to_agent_id),
|
|
54873
54906
|
...e2.description ? { description: e2.description } : {},
|
|
54874
54907
|
...e2.payload_schema && Object.keys(e2.payload_schema).length ? { payload_schema: e2.payload_schema } : {}
|
|
54875
54908
|
}))
|
|
@@ -54892,8 +54925,8 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
54892
54925
|
synced_at: new Date().toISOString(),
|
|
54893
54926
|
members: installedMembers,
|
|
54894
54927
|
edges: cloud.edges.map((e2) => ({
|
|
54895
|
-
from_slug: e2.
|
|
54896
|
-
to_slug: e2.
|
|
54928
|
+
from_slug: slugFor(e2.from_agent_id),
|
|
54929
|
+
to_slug: slugFor(e2.to_agent_id),
|
|
54897
54930
|
description: e2.description ?? "",
|
|
54898
54931
|
payload_schema: e2.payload_schema ?? {}
|
|
54899
54932
|
}))
|
|
@@ -54963,7 +54996,7 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
54963
54996
|
slugToAgentId.set(m3.slug, memberLink.agent_id);
|
|
54964
54997
|
}
|
|
54965
54998
|
if (missing.length) {
|
|
54966
|
-
f2.error(`These members have no local checkout (expected at agents/<slug
|
|
54999
|
+
f2.error(`These members have no local checkout (expected at agents/<slug>/brainbase.agent.yaml): ${missing.join(", ")}.`);
|
|
54967
55000
|
f2.info(`Run ${import_picocolors34.default.cyan("brainbase orchestration pull")} to materialise the missing folders.`);
|
|
54968
55001
|
return;
|
|
54969
55002
|
}
|