bamboo-agents 0.1.5-dev.34.b4abfd1 → 0.1.5-dev.36.1aed6b6

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5-dev.34.b4abfd1
1
+ 0.1.5-dev.36.1aed6b6
package/dist/index.js CHANGED
@@ -3037,7 +3037,7 @@ var VERSION;
3037
3037
  var init_version = __esm({
3038
3038
  "src/version.ts"() {
3039
3039
  "use strict";
3040
- VERSION = "0.1.5-dev.34.b4abfd1";
3040
+ VERSION = "0.1.5-dev.36.1aed6b6";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7205,7 +7205,8 @@ var init_credentials = __esm({
7205
7205
  });
7206
7206
 
7207
7207
  // src/lib/state.ts
7208
- import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "node:fs/promises";
7208
+ import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2, chmod as chmod2, rename, unlink } from "node:fs/promises";
7209
+ import { randomBytes } from "node:crypto";
7209
7210
  async function readConfig() {
7210
7211
  try {
7211
7212
  const raw = await readFile2(configPath(), "utf8");
@@ -7226,7 +7227,7 @@ async function writeConfig(cfg) {
7226
7227
  mode: 420
7227
7228
  });
7228
7229
  }
7229
- var ConfigSchema;
7230
+ var ConfigSchema, STATE_SCHEMA_VERSION, WorkspaceStateSchema;
7230
7231
  var init_state = __esm({
7231
7232
  "src/lib/state.ts"() {
7232
7233
  "use strict";
@@ -7242,6 +7243,18 @@ var init_state = __esm({
7242
7243
  installed_at: external_exports.string()
7243
7244
  // ISO8601
7244
7245
  });
7246
+ STATE_SCHEMA_VERSION = 1;
7247
+ WorkspaceStateSchema = external_exports.object({
7248
+ $schema_version: external_exports.literal(STATE_SCHEMA_VERSION),
7249
+ workspace_path: external_exports.string().min(1),
7250
+ org_id: external_exports.string().min(1),
7251
+ org_slug: external_exports.string().min(1),
7252
+ cloned_at: external_exports.string().min(1),
7253
+ // ISO-8601
7254
+ last_sync: external_exports.string().min(1),
7255
+ // ISO-8601
7256
+ remote_url: external_exports.string().url()
7257
+ });
7245
7258
  }
7246
7259
  });
7247
7260
 
@@ -11589,7 +11602,11 @@ var init_agents = __esm({
11589
11602
  name: external_exports.string(),
11590
11603
  /** `false` = user-created (eligible for picker choices).
11591
11604
  * `true` = pre-installed (MAM etc.) — shown informational-only. */
11592
- is_auto_installed: external_exports.boolean()
11605
+ is_auto_installed: external_exports.boolean(),
11606
+ /** Canonical kebab-case identifier — last segment of `folder_path`
11607
+ * (`brands/<brand>/agents/<slug>`). `null` for legacy rows whose
11608
+ * `folder_path` is missing or malformed. */
11609
+ slug: external_exports.string().nullable()
11593
11610
  });
11594
11611
  CliTierCapSchema = external_exports.object({
11595
11612
  limit: external_exports.number().int(),
@@ -11798,6 +11815,68 @@ async function createAgentFromCli(bambooSession, body) {
11798
11815
  const json = await res.json();
11799
11816
  return CliCreateAgentResponseSchema.parse(json);
11800
11817
  }
11818
+ async function getAgentSkills(bambooSession, agentId) {
11819
+ const res = await cliApiFetch(
11820
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11821
+ {
11822
+ headers: { Authorization: `Bearer ${bambooSession}` }
11823
+ }
11824
+ );
11825
+ if (!res.ok) throw await parseError(res);
11826
+ const json = await res.json();
11827
+ return SkillCatalogResponseSchema.parse(json.data);
11828
+ }
11829
+ async function postAgentSkill(bambooSession, agentId, body) {
11830
+ const res = await cliApiFetch(
11831
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11832
+ {
11833
+ method: "POST",
11834
+ headers: {
11835
+ Authorization: `Bearer ${bambooSession}`,
11836
+ "Content-Type": "application/json"
11837
+ },
11838
+ body: JSON.stringify(body)
11839
+ }
11840
+ );
11841
+ if (!res.ok) throw await parseError(res);
11842
+ const json = await res.json();
11843
+ return SkillSubscriptionsResponseSchema.parse(json.data);
11844
+ }
11845
+ async function updateSkillFromRegistry(bambooSession, agentId, skillName) {
11846
+ const res = await cliApiFetch(
11847
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11848
+ {
11849
+ method: "POST",
11850
+ headers: {
11851
+ Authorization: `Bearer ${bambooSession}`,
11852
+ "Content-Type": "application/json"
11853
+ },
11854
+ body: JSON.stringify({
11855
+ action: "update_from_registry",
11856
+ skill_name: skillName
11857
+ })
11858
+ }
11859
+ );
11860
+ if (!res.ok) throw await parseError(res);
11861
+ const json = await res.json();
11862
+ return SkillSubscriptionsResponseSchema.parse(json.data);
11863
+ }
11864
+ async function scaffoldSkill(bambooSession, args) {
11865
+ const res = await cliApiFetch(
11866
+ `${apiBase()}/api/v1/orgs/me/skills/scaffold`,
11867
+ {
11868
+ method: "POST",
11869
+ headers: {
11870
+ Authorization: `Bearer ${bambooSession}`,
11871
+ "Content-Type": "application/json"
11872
+ },
11873
+ body: JSON.stringify(args)
11874
+ }
11875
+ );
11876
+ if (!res.ok) throw await parseError(res);
11877
+ const json = await res.json();
11878
+ return ScaffoldSkillResponseSchema.parse(json.data);
11879
+ }
11801
11880
  async function uploadClaudeMdFromCli(bambooSession, body) {
11802
11881
  const res = await cliApiFetch(
11803
11882
  `${apiBase()}/api/v1/cli/agents/upload-claude-md`,
@@ -11814,7 +11893,7 @@ async function uploadClaudeMdFromCli(bambooSession, body) {
11814
11893
  const json = await res.json();
11815
11894
  return CliUploadAgentResponseSchema.parse(json);
11816
11895
  }
11817
- var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema;
11896
+ var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema, SkillCatalogEntrySchema, SkillCatalogResponseSchema, SkillSubscriptionsResponseSchema, ScaffoldSkillResponseSchema;
11818
11897
  var init_api = __esm({
11819
11898
  "src/lib/api.ts"() {
11820
11899
  "use strict";
@@ -11846,6 +11925,32 @@ var init_api = __esm({
11846
11925
  FirstAutoInstalledAgentResponseSchema = external_exports.object({
11847
11926
  agent_id: external_exports.string().nullable()
11848
11927
  });
11928
+ SkillCatalogEntrySchema = external_exports.object({
11929
+ name: external_exports.string(),
11930
+ display_name: external_exports.string(),
11931
+ description: external_exports.string(),
11932
+ tier: external_exports.enum(["system", "agent"]),
11933
+ source: external_exports.enum(["bamboo", "org", "community"]),
11934
+ category: external_exports.string().nullable(),
11935
+ recommended_for: external_exports.array(external_exports.string()),
11936
+ allowed_tools: external_exports.array(external_exports.string()),
11937
+ disable_model_invocation: external_exports.boolean(),
11938
+ body_hash: external_exports.string().nullable(),
11939
+ org_id: external_exports.string().nullable()
11940
+ });
11941
+ SkillCatalogResponseSchema = external_exports.object({
11942
+ always_on: external_exports.array(SkillCatalogEntrySchema),
11943
+ available: external_exports.array(SkillCatalogEntrySchema),
11944
+ installed: external_exports.array(SkillCatalogEntrySchema),
11945
+ custom: external_exports.array(SkillCatalogEntrySchema),
11946
+ subscriptions: external_exports.array(external_exports.string())
11947
+ });
11948
+ SkillSubscriptionsResponseSchema = external_exports.object({
11949
+ subscriptions: external_exports.array(external_exports.string())
11950
+ });
11951
+ ScaffoldSkillResponseSchema = external_exports.object({
11952
+ skill_name: external_exports.string()
11953
+ });
11849
11954
  }
11850
11955
  });
11851
11956
 
@@ -11868,7 +11973,7 @@ __export(login_exports, {
11868
11973
  startCallbackServer: () => startCallbackServer,
11869
11974
  verificationCode: () => verificationCode
11870
11975
  });
11871
- import { randomBytes } from "node:crypto";
11976
+ import { randomBytes as randomBytes2 } from "node:crypto";
11872
11977
  import {
11873
11978
  createServer
11874
11979
  } from "node:http";
@@ -11993,7 +12098,7 @@ async function startCallbackServer(expectedState) {
11993
12098
  };
11994
12099
  }
11995
12100
  async function runLogin() {
11996
- const state = randomBytes(32).toString("hex");
12101
+ const state = randomBytes2(32).toString("hex");
11997
12102
  const code = verificationCode(state);
11998
12103
  const { port, session: sessionPromise } = await startCallbackServer(state);
11999
12104
  const cbUrl = `http://localhost:${port}/`;
@@ -13948,8 +14053,12 @@ var init_skills_local = __esm({
13948
14053
  // src/commands/skills.ts
13949
14054
  var skills_exports = {};
13950
14055
  __export(skills_exports, {
14056
+ runSkillsCreate: () => runSkillsCreate,
13951
14057
  runSkillsGet: () => runSkillsGet,
13952
- runSkillsList: () => runSkillsList
14058
+ runSkillsList: () => runSkillsList,
14059
+ runSkillsSubscribe: () => runSkillsSubscribe,
14060
+ runSkillsUnsubscribe: () => runSkillsUnsubscribe,
14061
+ runSkillsUpdate: () => runSkillsUpdate
13953
14062
  });
13954
14063
  async function resolveWorkspacePath() {
13955
14064
  const cfg = await readConfig();
@@ -13969,7 +14078,94 @@ function summarize(description, max = 80) {
13969
14078
  function padRight(s, n) {
13970
14079
  return s.length >= n ? s : s + " ".repeat(n - s.length);
13971
14080
  }
13972
- async function runSkillsList() {
14081
+ async function resolveAgent(bambooSession, identifier) {
14082
+ const list = await listCliAgents(bambooSession);
14083
+ const target = identifier.trim().toLowerCase();
14084
+ if (target.length === 0) return null;
14085
+ const bySlug = list.agents.find(
14086
+ (a) => a.slug !== null && a.slug.toLowerCase() === target
14087
+ );
14088
+ if (bySlug) return { id: bySlug.id, name: bySlug.name };
14089
+ const byId = list.agents.find((a) => a.id.toLowerCase() === target) ?? (target.length >= 8 ? list.agents.find((a) => a.id.toLowerCase().startsWith(target)) : void 0);
14090
+ if (byId) return { id: byId.id, name: byId.name };
14091
+ const byName = list.agents.find((a) => a.name.toLowerCase() === target);
14092
+ if (byName) return { id: byName.id, name: byName.name };
14093
+ return null;
14094
+ }
14095
+ function printAgentNotFound(identifier, agents) {
14096
+ console.error(`bamboo-agents: agent not found: ${identifier}`);
14097
+ if (agents.length === 0) {
14098
+ console.error(
14099
+ "No agents in this org yet. Run `bamboo-agents` to create one."
14100
+ );
14101
+ } else {
14102
+ console.error("");
14103
+ console.error("Available agents (slug \u2014 name):");
14104
+ for (const a of agents) {
14105
+ const label = a.slug ?? `${a.id.slice(0, 8)} (no slug)`;
14106
+ console.error(` ${label} \u2014 ${a.name}`);
14107
+ }
14108
+ }
14109
+ process.exit(2);
14110
+ }
14111
+ async function requireSession() {
14112
+ const creds = await readCredentials();
14113
+ if (!creds) {
14114
+ console.error(
14115
+ "bamboo-agents: not logged in. Run `bamboo-agents login` first."
14116
+ );
14117
+ process.exit(1);
14118
+ }
14119
+ return creds.bamboo_session;
14120
+ }
14121
+ async function runSkillsList(options = {}) {
14122
+ if (options.agent) {
14123
+ const bambooSession = await requireSession();
14124
+ const resolved = await resolveAgent(bambooSession, options.agent);
14125
+ if (!resolved) {
14126
+ const list = await listCliAgents(bambooSession);
14127
+ return printAgentNotFound(options.agent, list.agents);
14128
+ }
14129
+ const { available, installed, custom: custom2, subscriptions } = await getAgentSkills(
14130
+ bambooSession,
14131
+ resolved.id
14132
+ );
14133
+ const subscribedSet = new Set(subscriptions);
14134
+ const filtered = [...installed, ...custom2, ...available].filter(
14135
+ (s) => subscribedSet.has(s.name)
14136
+ );
14137
+ if (filtered.length === 0) {
14138
+ console.log("");
14139
+ console.log(` No subscribed skills for ${resolved.name}.`);
14140
+ console.log(
14141
+ ` Subscribe with: bamboo-agents skills subscribe ${resolved.name} <skill-name>`
14142
+ );
14143
+ console.log("");
14144
+ return;
14145
+ }
14146
+ const nameCol2 = Math.max(
14147
+ "name".length,
14148
+ ...filtered.map((s) => s.name.length)
14149
+ );
14150
+ const header2 = ` ${padRight("name", nameCol2)} description`;
14151
+ const rule2 = " " + "\u2500".repeat(nameCol2) + " " + "\u2500".repeat(Math.min(60, 80 - nameCol2));
14152
+ console.log("");
14153
+ console.log(` Skills subscribed by ${resolved.name}:`);
14154
+ console.log("");
14155
+ console.log(header2);
14156
+ console.log(rule2);
14157
+ for (const s of filtered) {
14158
+ console.log(
14159
+ ` ${padRight(s.name, nameCol2)} ${summarize(s.description, 80 - nameCol2 - 4)}`
14160
+ );
14161
+ }
14162
+ console.log("");
14163
+ console.log(
14164
+ ` ${filtered.length} skill${filtered.length === 1 ? "" : "s"} subscribed.`
14165
+ );
14166
+ console.log("");
14167
+ return;
14168
+ }
13973
14169
  const repoPath = await resolveWorkspacePath();
13974
14170
  const skills2 = await listLocalSkills(repoPath);
13975
14171
  if (skills2.length === 0) {
@@ -14060,11 +14256,129 @@ async function printNotFound(repoPath, name) {
14060
14256
  console.error(` ${s.name}`);
14061
14257
  }
14062
14258
  }
14259
+ async function runSkillsSubscribe(agentIdentifier, skillName) {
14260
+ await runSubscribeOp("subscribe", agentIdentifier, skillName);
14261
+ }
14262
+ async function runSkillsUnsubscribe(agentIdentifier, skillName) {
14263
+ await runSubscribeOp("unsubscribe", agentIdentifier, skillName);
14264
+ }
14265
+ async function runSubscribeOp(action, agentIdentifier, skillName) {
14266
+ if (!agentIdentifier || !skillName) {
14267
+ console.error(
14268
+ `bamboo-agents: \`skills ${action}\` requires an agent identifier and a skill name.`
14269
+ );
14270
+ console.error(
14271
+ `Example: bamboo-agents skills ${action} "Paid Ads" walk-pr`
14272
+ );
14273
+ process.exit(2);
14274
+ }
14275
+ const bambooSession = await requireSession();
14276
+ const resolved = await resolveAgent(bambooSession, agentIdentifier);
14277
+ if (!resolved) {
14278
+ const list = await listCliAgents(bambooSession);
14279
+ printAgentNotFound(agentIdentifier, list.agents);
14280
+ }
14281
+ let result;
14282
+ try {
14283
+ result = await postAgentSkill(bambooSession, resolved.id, {
14284
+ action,
14285
+ skill_name: skillName
14286
+ });
14287
+ } catch (err) {
14288
+ console.error(
14289
+ `bamboo-agents: could not ${action} ${skillName}: ${err.message}`
14290
+ );
14291
+ process.exit(1);
14292
+ }
14293
+ if (action === "subscribe") {
14294
+ console.log("");
14295
+ console.log(` Subscribed ${resolved.name} to ${skillName}.`);
14296
+ } else {
14297
+ console.log("");
14298
+ console.log(` Unsubscribed ${resolved.name} from ${skillName}.`);
14299
+ }
14300
+ console.log("");
14301
+ console.log(
14302
+ ` ${resolved.name} now has ${result.subscriptions.length} skill${result.subscriptions.length === 1 ? "" : "s"} subscribed.`
14303
+ );
14304
+ console.log(
14305
+ " Pull the workspace repo to see the manifest.yml update locally:"
14306
+ );
14307
+ console.log(" git -C $(bamboo-agents status) pull");
14308
+ console.log("");
14309
+ }
14310
+ async function runSkillsCreate(skillName, options = {}) {
14311
+ if (!skillName || !skillName.trim()) {
14312
+ console.error("bamboo-agents: skills create requires a skill name.");
14313
+ console.error("Example: bamboo-agents skills create analyze-creative");
14314
+ process.exit(2);
14315
+ }
14316
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(skillName.trim())) {
14317
+ console.error(
14318
+ "bamboo-agents: skill name must be kebab-case (lowercase + dashes)."
14319
+ );
14320
+ process.exit(2);
14321
+ }
14322
+ const bambooSession = await requireSession();
14323
+ let result;
14324
+ try {
14325
+ result = await scaffoldSkill(bambooSession, {
14326
+ skill_name: skillName.trim(),
14327
+ category: options.category,
14328
+ description: options.description
14329
+ });
14330
+ } catch (err) {
14331
+ console.error(
14332
+ `bamboo-agents: could not scaffold ${skillName}: ${err.message}`
14333
+ );
14334
+ process.exit(1);
14335
+ }
14336
+ console.log("");
14337
+ console.log(` Scaffolded ${result.skill_name}.`);
14338
+ console.log("");
14339
+ console.log(
14340
+ ` Edit skills/${result.skill_name}/SKILL.md in your workspace clone:`
14341
+ );
14342
+ console.log(" git -C $(bamboo-agents status) pull");
14343
+ console.log(` $EDITOR skills/${result.skill_name}/SKILL.md`);
14344
+ console.log("");
14345
+ }
14346
+ async function runSkillsUpdate(agentIdentifier, skillName) {
14347
+ if (!agentIdentifier || !skillName) {
14348
+ console.error(
14349
+ "bamboo-agents: `skills update` requires an agent identifier and a skill name."
14350
+ );
14351
+ console.error('Example: bamboo-agents skills update "Paid Ads" walk-pr');
14352
+ process.exit(2);
14353
+ }
14354
+ const bambooSession = await requireSession();
14355
+ const resolved = await resolveAgent(bambooSession, agentIdentifier);
14356
+ if (!resolved) {
14357
+ const list = await listCliAgents(bambooSession);
14358
+ printAgentNotFound(agentIdentifier, list.agents);
14359
+ }
14360
+ try {
14361
+ await updateSkillFromRegistry(bambooSession, resolved.id, skillName);
14362
+ } catch (err) {
14363
+ console.error(
14364
+ `bamboo-agents: could not update ${skillName}: ${err.message}`
14365
+ );
14366
+ process.exit(1);
14367
+ }
14368
+ console.log("");
14369
+ console.log(` Updated ${skillName} from the bamboo registry.`);
14370
+ console.log("");
14371
+ console.log(" Pull your workspace to see the new body locally:");
14372
+ console.log(" git -C $(bamboo-agents status) pull");
14373
+ console.log("");
14374
+ }
14063
14375
  var init_skills = __esm({
14064
14376
  "src/commands/skills.ts"() {
14065
14377
  "use strict";
14066
14378
  init_state();
14379
+ init_credentials();
14067
14380
  init_skills_local();
14381
+ init_api();
14068
14382
  }
14069
14383
  });
14070
14384
 
@@ -14114,15 +14428,36 @@ program2.command("doctor").description("Verify your local setup is ready").actio
14114
14428
  await runDoctor2();
14115
14429
  });
14116
14430
  var skills = program2.command("skills").description("Read workspace skills from your local clone");
14117
- skills.command("list").description("List every skill in the workspace").action(async () => {
14431
+ skills.command("list").description("List every skill in the workspace").option(
14432
+ "--agent <slug>",
14433
+ "Filter to one agent's subscribed skills (via server)"
14434
+ ).action(async (options) => {
14118
14435
  const { runSkillsList: runSkillsList2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14119
- await runSkillsList2();
14436
+ await runSkillsList2(options);
14120
14437
  });
14121
14438
  skills.command("get <name>").description("Print one skill's SKILL.md body to stdout").action(async (name) => {
14122
14439
  const { runSkillsGet: runSkillsGet2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14123
14440
  await runSkillsGet2(name);
14124
14441
  });
14125
- program2.parseAsync().catch((err) => {
14442
+ skills.command("subscribe <agent> <skill-name>").description("Subscribe an agent to a skill from the catalog").action(async (agent, skillName) => {
14443
+ const { runSkillsSubscribe: runSkillsSubscribe2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14444
+ await runSkillsSubscribe2(agent, skillName);
14445
+ });
14446
+ skills.command("unsubscribe <agent> <skill-name>").description("Unsubscribe an agent from a skill").action(async (agent, skillName) => {
14447
+ const { runSkillsUnsubscribe: runSkillsUnsubscribe2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14448
+ await runSkillsUnsubscribe2(agent, skillName);
14449
+ });
14450
+ skills.command("create <skill-name>").description("Scaffold a new org-custom skill in your workspace").option("--category <category>", "Optional category label (e.g. analysis)").option("--description <description>", "Optional one-line description").action(
14451
+ async (skillName, options) => {
14452
+ const { runSkillsCreate: runSkillsCreate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14453
+ await runSkillsCreate2(skillName, options);
14454
+ }
14455
+ );
14456
+ skills.command("update <agent> <skill-name>").description("Update an installed skill from the bamboo registry").action(async (agent, skillName) => {
14457
+ const { runSkillsUpdate: runSkillsUpdate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14458
+ await runSkillsUpdate2(agent, skillName);
14459
+ });
14460
+ program2.parseAsync(process.argv).catch((err) => {
14126
14461
  const message = err instanceof Error ? err.message : String(err);
14127
14462
  console.error(`bamboo-agents: ${message}`);
14128
14463
  process.exit(1);