bamboo-agents 0.1.5-dev.35.1be3c48 → 0.1.5-dev.37.e3cb3a7

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 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.35.1be3c48";
3040
+ VERSION = "0.1.5-dev.37.e3cb3a7";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7159,6 +7159,15 @@ function configPath() {
7159
7159
  function credentialsPath() {
7160
7160
  return join(bambooDir(), "credentials.json");
7161
7161
  }
7162
+ function bambooStateDir() {
7163
+ if (process.env.BAMBOO_STATE_HOME) return process.env.BAMBOO_STATE_HOME;
7164
+ if (process.env.XDG_STATE_HOME)
7165
+ return join(process.env.XDG_STATE_HOME, "bamboo-agents");
7166
+ return join(homedir(), ".config", "bamboo-agents");
7167
+ }
7168
+ function statePath() {
7169
+ return join(bambooStateDir(), "state.json");
7170
+ }
7162
7171
  var init_paths = __esm({
7163
7172
  "src/lib/paths.ts"() {
7164
7173
  "use strict";
@@ -7227,7 +7236,81 @@ async function writeConfig(cfg) {
7227
7236
  mode: 420
7228
7237
  });
7229
7238
  }
7230
- var ConfigSchema, STATE_SCHEMA_VERSION, WorkspaceStateSchema;
7239
+ async function readState() {
7240
+ const file = statePath();
7241
+ let raw;
7242
+ try {
7243
+ raw = await readFile2(file, "utf8");
7244
+ } catch (err) {
7245
+ if (err.code === "ENOENT") return null;
7246
+ throw new WorkspaceStateError(
7247
+ "io",
7248
+ file,
7249
+ `Couldn't read ${file}: ${err.message}. Run \`bamboo-agents init\` to rebuild.`
7250
+ );
7251
+ }
7252
+ let parsed;
7253
+ try {
7254
+ parsed = JSON.parse(raw);
7255
+ } catch (err) {
7256
+ throw new WorkspaceStateError(
7257
+ "corrupt_json",
7258
+ file,
7259
+ `${file} is not valid JSON: ${err.message}. Delete it and re-run \`bamboo-agents init\` to rebuild.`
7260
+ );
7261
+ }
7262
+ const version = parsed && typeof parsed === "object" && "$schema_version" in parsed ? parsed.$schema_version : void 0;
7263
+ if (typeof version === "number" && version !== STATE_SCHEMA_VERSION) {
7264
+ throw new WorkspaceStateError(
7265
+ "schema_mismatch",
7266
+ file,
7267
+ `${file} uses schema version ${version}, but this CLI expects version ${STATE_SCHEMA_VERSION}. Run \`bamboo-agents init --reset\` to rebuild.`
7268
+ );
7269
+ }
7270
+ const result = WorkspaceStateSchema.safeParse(parsed);
7271
+ if (!result.success) {
7272
+ throw new WorkspaceStateError(
7273
+ "schema_mismatch",
7274
+ file,
7275
+ `${file} doesn't match the expected schema: ${result.error.message}. Run \`bamboo-agents init --reset\` to rebuild.`
7276
+ );
7277
+ }
7278
+ return result.data;
7279
+ }
7280
+ async function writeState(state) {
7281
+ WorkspaceStateSchema.parse(state);
7282
+ const dir = bambooStateDir();
7283
+ const target = statePath();
7284
+ await mkdir2(dir, { recursive: true, mode: 448 });
7285
+ await chmod2(dir, 448);
7286
+ const tmp = `${target}.${randomBytes(6).toString("hex")}.tmp`;
7287
+ await writeFile2(tmp, JSON.stringify(state, null, 2) + "\n", {
7288
+ encoding: "utf8",
7289
+ mode: 384
7290
+ });
7291
+ try {
7292
+ await rename(tmp, target);
7293
+ } catch (err) {
7294
+ try {
7295
+ await unlink(tmp);
7296
+ } catch {
7297
+ }
7298
+ throw err;
7299
+ }
7300
+ await chmod2(target, 384);
7301
+ }
7302
+ async function updateLastSync(when) {
7303
+ const current = await readState();
7304
+ if (!current) {
7305
+ throw new WorkspaceStateError(
7306
+ "io",
7307
+ statePath(),
7308
+ `Cannot update last_sync \u2014 no workspace state at ${statePath()}. Run \`bamboo-agents init\` first.`
7309
+ );
7310
+ }
7311
+ await writeState({ ...current, last_sync: when.toISOString() });
7312
+ }
7313
+ var ConfigSchema, STATE_SCHEMA_VERSION, WorkspaceStateSchema, WorkspaceStateError;
7231
7314
  var init_state = __esm({
7232
7315
  "src/lib/state.ts"() {
7233
7316
  "use strict";
@@ -7255,6 +7338,16 @@ var init_state = __esm({
7255
7338
  // ISO-8601
7256
7339
  remote_url: external_exports.string().url()
7257
7340
  });
7341
+ WorkspaceStateError = class extends Error {
7342
+ kind;
7343
+ path;
7344
+ constructor(kind, path2, message) {
7345
+ super(message);
7346
+ this.name = "WorkspaceStateError";
7347
+ this.kind = kind;
7348
+ this.path = path2;
7349
+ }
7350
+ };
7258
7351
  }
7259
7352
  });
7260
7353
 
@@ -11602,7 +11695,11 @@ var init_agents = __esm({
11602
11695
  name: external_exports.string(),
11603
11696
  /** `false` = user-created (eligible for picker choices).
11604
11697
  * `true` = pre-installed (MAM etc.) — shown informational-only. */
11605
- is_auto_installed: external_exports.boolean()
11698
+ is_auto_installed: external_exports.boolean(),
11699
+ /** Canonical kebab-case identifier — last segment of `folder_path`
11700
+ * (`brands/<brand>/agents/<slug>`). `null` for legacy rows whose
11701
+ * `folder_path` is missing or malformed. */
11702
+ slug: external_exports.string().nullable()
11606
11703
  });
11607
11704
  CliTierCapSchema = external_exports.object({
11608
11705
  limit: external_exports.number().int(),
@@ -11811,6 +11908,68 @@ async function createAgentFromCli(bambooSession, body) {
11811
11908
  const json = await res.json();
11812
11909
  return CliCreateAgentResponseSchema.parse(json);
11813
11910
  }
11911
+ async function getAgentSkills(bambooSession, agentId) {
11912
+ const res = await cliApiFetch(
11913
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11914
+ {
11915
+ headers: { Authorization: `Bearer ${bambooSession}` }
11916
+ }
11917
+ );
11918
+ if (!res.ok) throw await parseError(res);
11919
+ const json = await res.json();
11920
+ return SkillCatalogResponseSchema.parse(json.data);
11921
+ }
11922
+ async function postAgentSkill(bambooSession, agentId, body) {
11923
+ const res = await cliApiFetch(
11924
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11925
+ {
11926
+ method: "POST",
11927
+ headers: {
11928
+ Authorization: `Bearer ${bambooSession}`,
11929
+ "Content-Type": "application/json"
11930
+ },
11931
+ body: JSON.stringify(body)
11932
+ }
11933
+ );
11934
+ if (!res.ok) throw await parseError(res);
11935
+ const json = await res.json();
11936
+ return SkillSubscriptionsResponseSchema.parse(json.data);
11937
+ }
11938
+ async function updateSkillFromRegistry(bambooSession, agentId, skillName) {
11939
+ const res = await cliApiFetch(
11940
+ `${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
11941
+ {
11942
+ method: "POST",
11943
+ headers: {
11944
+ Authorization: `Bearer ${bambooSession}`,
11945
+ "Content-Type": "application/json"
11946
+ },
11947
+ body: JSON.stringify({
11948
+ action: "update_from_registry",
11949
+ skill_name: skillName
11950
+ })
11951
+ }
11952
+ );
11953
+ if (!res.ok) throw await parseError(res);
11954
+ const json = await res.json();
11955
+ return SkillSubscriptionsResponseSchema.parse(json.data);
11956
+ }
11957
+ async function scaffoldSkill(bambooSession, args) {
11958
+ const res = await cliApiFetch(
11959
+ `${apiBase()}/api/v1/orgs/me/skills/scaffold`,
11960
+ {
11961
+ method: "POST",
11962
+ headers: {
11963
+ Authorization: `Bearer ${bambooSession}`,
11964
+ "Content-Type": "application/json"
11965
+ },
11966
+ body: JSON.stringify(args)
11967
+ }
11968
+ );
11969
+ if (!res.ok) throw await parseError(res);
11970
+ const json = await res.json();
11971
+ return ScaffoldSkillResponseSchema.parse(json.data);
11972
+ }
11814
11973
  async function uploadClaudeMdFromCli(bambooSession, body) {
11815
11974
  const res = await cliApiFetch(
11816
11975
  `${apiBase()}/api/v1/cli/agents/upload-claude-md`,
@@ -11827,7 +11986,7 @@ async function uploadClaudeMdFromCli(bambooSession, body) {
11827
11986
  const json = await res.json();
11828
11987
  return CliUploadAgentResponseSchema.parse(json);
11829
11988
  }
11830
- var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema;
11989
+ var PROD_DEFAULT_BASE, DEV_DEFAULT_BASE, REQUEST_TIMEOUT_MS, ApiError, OAuthRelinkStartResponseSchema, ProvisionWorkspaceResponseSchema, FirstAutoInstalledAgentResponseSchema, SkillCatalogEntrySchema, SkillCatalogResponseSchema, SkillSubscriptionsResponseSchema, ScaffoldSkillResponseSchema;
11831
11990
  var init_api = __esm({
11832
11991
  "src/lib/api.ts"() {
11833
11992
  "use strict";
@@ -11859,6 +12018,32 @@ var init_api = __esm({
11859
12018
  FirstAutoInstalledAgentResponseSchema = external_exports.object({
11860
12019
  agent_id: external_exports.string().nullable()
11861
12020
  });
12021
+ SkillCatalogEntrySchema = external_exports.object({
12022
+ name: external_exports.string(),
12023
+ display_name: external_exports.string(),
12024
+ description: external_exports.string(),
12025
+ tier: external_exports.enum(["system", "agent"]),
12026
+ source: external_exports.enum(["bamboo", "org", "community"]),
12027
+ category: external_exports.string().nullable(),
12028
+ recommended_for: external_exports.array(external_exports.string()),
12029
+ allowed_tools: external_exports.array(external_exports.string()),
12030
+ disable_model_invocation: external_exports.boolean(),
12031
+ body_hash: external_exports.string().nullable(),
12032
+ org_id: external_exports.string().nullable()
12033
+ });
12034
+ SkillCatalogResponseSchema = external_exports.object({
12035
+ always_on: external_exports.array(SkillCatalogEntrySchema),
12036
+ available: external_exports.array(SkillCatalogEntrySchema),
12037
+ installed: external_exports.array(SkillCatalogEntrySchema),
12038
+ custom: external_exports.array(SkillCatalogEntrySchema),
12039
+ subscriptions: external_exports.array(external_exports.string())
12040
+ });
12041
+ SkillSubscriptionsResponseSchema = external_exports.object({
12042
+ subscriptions: external_exports.array(external_exports.string())
12043
+ });
12044
+ ScaffoldSkillResponseSchema = external_exports.object({
12045
+ skill_name: external_exports.string()
12046
+ });
11862
12047
  }
11863
12048
  });
11864
12049
 
@@ -13543,35 +13728,81 @@ var init_claude_desktop = __esm({
13543
13728
  }
13544
13729
  });
13545
13730
 
13731
+ // src/lib/workspace.ts
13732
+ import { existsSync } from "node:fs";
13733
+ async function resolveWorkspace() {
13734
+ const state = await readState();
13735
+ if (state) {
13736
+ if (!existsSync(state.workspace_path)) {
13737
+ throw new NoWorkspaceError(
13738
+ `Bamboo workspace not found.
13739
+ (State recorded ${state.workspace_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
13740
+ );
13741
+ }
13742
+ return { path: state.workspace_path, orgId: state.org_id };
13743
+ }
13744
+ const config = await readConfig();
13745
+ if (config) {
13746
+ if (!existsSync(config.repo_path)) {
13747
+ throw new NoWorkspaceError(
13748
+ `Bamboo workspace not found.
13749
+ (Config recorded ${config.repo_path} but it's missing on disk \u2014 run \`bamboo-agents init --reset\` to re-clone.)`
13750
+ );
13751
+ }
13752
+ return { path: config.repo_path, orgId: config.org_id };
13753
+ }
13754
+ throw new NoWorkspaceError(
13755
+ "No Bamboo workspace yet. Run `bamboo-agents init` first."
13756
+ );
13757
+ }
13758
+ var NoWorkspaceError;
13759
+ var init_workspace = __esm({
13760
+ "src/lib/workspace.ts"() {
13761
+ "use strict";
13762
+ init_state();
13763
+ NoWorkspaceError = class extends Error {
13764
+ constructor(message) {
13765
+ super(message);
13766
+ this.name = "NoWorkspaceError";
13767
+ }
13768
+ };
13769
+ }
13770
+ });
13771
+
13546
13772
  // src/commands/open.ts
13547
13773
  var open_exports = {};
13548
13774
  __export(open_exports, {
13549
13775
  runOpen: () => runOpen
13550
13776
  });
13551
13777
  async function runOpen() {
13552
- const cfg = await readConfig();
13553
- if (!cfg) {
13554
- console.error("No workspace configured. Run `bamboo-agents init` first.");
13555
- process.exit(2);
13778
+ let workspacePath;
13779
+ try {
13780
+ workspacePath = (await resolveWorkspace()).path;
13781
+ } catch (err) {
13782
+ if (err instanceof NoWorkspaceError) {
13783
+ console.error(err.message);
13784
+ process.exit(2);
13785
+ }
13786
+ throw err;
13556
13787
  }
13557
13788
  const status = await detectClaudeDesktop();
13558
13789
  if (status.kind === "missing") {
13559
13790
  console.error(
13560
13791
  `Claude Desktop isn't installed. Get it at ${DOWNLOAD_URL}, then re-run \`bamboo-agents open\`.`
13561
13792
  );
13562
- console.error(`(Your workspace is cloned at ${cfg.repo_path}.)`);
13793
+ console.error(`(Your workspace is cloned at ${workspacePath}.)`);
13563
13794
  process.exit(1);
13564
13795
  }
13565
13796
  if (status.kind === "unsupported_platform") {
13566
13797
  console.log("");
13567
13798
  console.log(" Claude Desktop isn't available on Linux yet.");
13568
- console.log(` Your workspace is cloned at: ${cfg.repo_path}`);
13799
+ console.log(` Your workspace is cloned at: ${workspacePath}`);
13569
13800
  console.log("");
13570
13801
  return;
13571
13802
  }
13572
- const url = `claude://code/new?folder=${encodeURIComponent(cfg.repo_path)}`;
13803
+ const url = `claude://code/new?folder=${encodeURIComponent(workspacePath)}`;
13573
13804
  await open_default(url);
13574
- console.log(`Opening Claude Code at ${cfg.repo_path}\u2026`);
13805
+ console.log(`Opening Claude Code at ${workspacePath}\u2026`);
13575
13806
  console.log("(Claude Desktop will ask you to trust the folder the first time.)");
13576
13807
  }
13577
13808
  var DOWNLOAD_URL;
@@ -13580,7 +13811,7 @@ var init_open2 = __esm({
13580
13811
  "use strict";
13581
13812
  init_open();
13582
13813
  init_claude_desktop();
13583
- init_state();
13814
+ init_workspace();
13584
13815
  DOWNLOAD_URL = "https://claude.com/download";
13585
13816
  }
13586
13817
  });
@@ -13608,6 +13839,7 @@ function formatSubscriptionLine(billing) {
13608
13839
  }
13609
13840
  async function runStatus() {
13610
13841
  const creds = await readCredentials();
13842
+ const state = await readState().catch(() => null);
13611
13843
  const cfg = await readConfig();
13612
13844
  console.log("");
13613
13845
  console.log(" Bamboo CLI status");
@@ -13623,13 +13855,18 @@ async function runStatus() {
13623
13855
  console.log(` GitHub expires: ${creds.github_token_expires_at}`);
13624
13856
  }
13625
13857
  }
13626
- if (!cfg) {
13858
+ const workspacePath = state?.workspace_path ?? cfg?.repo_path ?? null;
13859
+ if (!workspacePath) {
13627
13860
  console.log(" Workspace: not configured (run `bamboo-agents init`)");
13628
13861
  } else {
13629
- console.log(` Workspace: ${cfg.workspace_repo}`);
13630
- console.log(` Repo path: ${cfg.repo_path}`);
13631
- console.log(` Org: ${cfg.org_name}`);
13632
- console.log(` Installed: ${cfg.installed_at}`);
13862
+ const repoLabel = cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)";
13863
+ console.log(` Workspace: ${repoLabel}`);
13864
+ console.log(` Repo path: ${workspacePath}`);
13865
+ console.log(` Org: ${cfg?.org_name ?? state?.org_slug ?? "(unknown)"}`);
13866
+ console.log(` Installed: ${cfg?.installed_at ?? state?.cloned_at ?? "(unknown)"}`);
13867
+ if (state?.last_sync) {
13868
+ console.log(` Last sync: ${state.last_sync}`);
13869
+ }
13633
13870
  }
13634
13871
  if (creds?.bamboo_session) {
13635
13872
  try {
@@ -13790,6 +14027,130 @@ var init_doctor = __esm({
13790
14027
  }
13791
14028
  });
13792
14029
 
14030
+ // src/commands/save.ts
14031
+ var save_exports = {};
14032
+ __export(save_exports, {
14033
+ runSave: () => runSave
14034
+ });
14035
+ import { execFile as execFile8 } from "node:child_process";
14036
+ import { promisify as promisify8 } from "node:util";
14037
+ async function gitC(repoPath, args) {
14038
+ const { stdout, stderr } = await execFileP3("git", ["-C", repoPath, ...args], {
14039
+ encoding: "utf8"
14040
+ });
14041
+ return { stdout, stderr };
14042
+ }
14043
+ async function runSave(message) {
14044
+ if (!message || !message.trim()) {
14045
+ console.error("bamboo-agents save: commit message is required.");
14046
+ console.error('Example: bamboo-agents save "tightened the brand voice doc"');
14047
+ process.exit(2);
14048
+ }
14049
+ let workspacePath;
14050
+ try {
14051
+ workspacePath = (await resolveWorkspace()).path;
14052
+ } catch (err) {
14053
+ if (err instanceof NoWorkspaceError) {
14054
+ console.error(`bamboo-agents save: ${err.message}`);
14055
+ process.exit(2);
14056
+ }
14057
+ throw err;
14058
+ }
14059
+ try {
14060
+ await gitC(workspacePath, ["add", "-A"]);
14061
+ let hasStagedChanges = false;
14062
+ try {
14063
+ await gitC(workspacePath, ["diff", "--cached", "--quiet"]);
14064
+ } catch {
14065
+ hasStagedChanges = true;
14066
+ }
14067
+ if (!hasStagedChanges) {
14068
+ console.log("");
14069
+ console.log(" Nothing to save \u2014 your workspace is already up to date.");
14070
+ console.log("");
14071
+ return;
14072
+ }
14073
+ await gitC(workspacePath, ["commit", "-m", message.trim()]);
14074
+ await gitC(workspacePath, ["push"]);
14075
+ console.log("");
14076
+ console.log(` Saved: ${message.trim()}`);
14077
+ console.log(` (pushed from ${workspacePath})`);
14078
+ console.log("");
14079
+ } catch (err) {
14080
+ const e = err;
14081
+ console.error("bamboo-agents save: git failed.");
14082
+ if (e.stderr?.trim()) console.error(e.stderr.trim());
14083
+ else console.error(e.message);
14084
+ process.exit(1);
14085
+ }
14086
+ }
14087
+ var execFileP3;
14088
+ var init_save = __esm({
14089
+ "src/commands/save.ts"() {
14090
+ "use strict";
14091
+ init_workspace();
14092
+ execFileP3 = promisify8(execFile8);
14093
+ }
14094
+ });
14095
+
14096
+ // src/commands/sync.ts
14097
+ var sync_exports = {};
14098
+ __export(sync_exports, {
14099
+ runSync: () => runSync
14100
+ });
14101
+ import { execFile as execFile9 } from "node:child_process";
14102
+ import { promisify as promisify9 } from "node:util";
14103
+ async function runSync() {
14104
+ let workspacePath;
14105
+ try {
14106
+ workspacePath = (await resolveWorkspace()).path;
14107
+ } catch (err) {
14108
+ if (err instanceof NoWorkspaceError) {
14109
+ console.error(`bamboo-agents sync: ${err.message}`);
14110
+ process.exit(2);
14111
+ }
14112
+ throw err;
14113
+ }
14114
+ try {
14115
+ const { stdout } = await execFileP4(
14116
+ "git",
14117
+ ["-C", workspacePath, "pull", "--ff-only"],
14118
+ { encoding: "utf8" }
14119
+ );
14120
+ console.log("");
14121
+ console.log(" Synced your workspace with the remote.");
14122
+ if (stdout.trim()) {
14123
+ console.log(` ${stdout.trim().split("\n").pop()}`);
14124
+ }
14125
+ console.log(` (workspace: ${workspacePath})`);
14126
+ console.log("");
14127
+ } catch (err) {
14128
+ const e = err;
14129
+ console.error("bamboo-agents sync: git failed.");
14130
+ if (e.stderr?.trim()) console.error(e.stderr.trim());
14131
+ else console.error(e.message);
14132
+ process.exit(1);
14133
+ }
14134
+ try {
14135
+ const state = await readState();
14136
+ if (state) await updateLastSync(/* @__PURE__ */ new Date());
14137
+ } catch (err) {
14138
+ if (err instanceof WorkspaceStateError) {
14139
+ return;
14140
+ }
14141
+ throw err;
14142
+ }
14143
+ }
14144
+ var execFileP4;
14145
+ var init_sync = __esm({
14146
+ "src/commands/sync.ts"() {
14147
+ "use strict";
14148
+ init_state();
14149
+ init_workspace();
14150
+ execFileP4 = promisify9(execFile9);
14151
+ }
14152
+ });
14153
+
13793
14154
  // src/lib/skills-local.ts
13794
14155
  import { readdir as readdir2, readFile as readFile4, stat as stat2 } from "node:fs/promises";
13795
14156
  import { join as join2 } from "node:path";
@@ -13961,18 +14322,23 @@ var init_skills_local = __esm({
13961
14322
  // src/commands/skills.ts
13962
14323
  var skills_exports = {};
13963
14324
  __export(skills_exports, {
14325
+ runSkillsCreate: () => runSkillsCreate,
13964
14326
  runSkillsGet: () => runSkillsGet,
13965
- runSkillsList: () => runSkillsList
14327
+ runSkillsList: () => runSkillsList,
14328
+ runSkillsSubscribe: () => runSkillsSubscribe,
14329
+ runSkillsUnsubscribe: () => runSkillsUnsubscribe,
14330
+ runSkillsUpdate: () => runSkillsUpdate
13966
14331
  });
13967
14332
  async function resolveWorkspacePath() {
13968
- const cfg = await readConfig();
13969
- if (!cfg) {
13970
- console.error(
13971
- "bamboo-agents: no workspace configured. Run `bamboo-agents init` first."
13972
- );
13973
- process.exit(1);
14333
+ try {
14334
+ return (await resolveWorkspace()).path;
14335
+ } catch (err) {
14336
+ if (err instanceof NoWorkspaceError) {
14337
+ console.error(`bamboo-agents: ${err.message}`);
14338
+ process.exit(1);
14339
+ }
14340
+ throw err;
13974
14341
  }
13975
- return cfg.repo_path;
13976
14342
  }
13977
14343
  function summarize(description, max = 80) {
13978
14344
  const oneLine = description.replace(/\s+/g, " ").trim();
@@ -13982,7 +14348,94 @@ function summarize(description, max = 80) {
13982
14348
  function padRight(s, n) {
13983
14349
  return s.length >= n ? s : s + " ".repeat(n - s.length);
13984
14350
  }
13985
- async function runSkillsList() {
14351
+ async function resolveAgent(bambooSession, identifier) {
14352
+ const list = await listCliAgents(bambooSession);
14353
+ const target = identifier.trim().toLowerCase();
14354
+ if (target.length === 0) return null;
14355
+ const bySlug = list.agents.find(
14356
+ (a) => a.slug !== null && a.slug.toLowerCase() === target
14357
+ );
14358
+ if (bySlug) return { id: bySlug.id, name: bySlug.name };
14359
+ const byId = list.agents.find((a) => a.id.toLowerCase() === target) ?? (target.length >= 8 ? list.agents.find((a) => a.id.toLowerCase().startsWith(target)) : void 0);
14360
+ if (byId) return { id: byId.id, name: byId.name };
14361
+ const byName = list.agents.find((a) => a.name.toLowerCase() === target);
14362
+ if (byName) return { id: byName.id, name: byName.name };
14363
+ return null;
14364
+ }
14365
+ function printAgentNotFound(identifier, agents) {
14366
+ console.error(`bamboo-agents: agent not found: ${identifier}`);
14367
+ if (agents.length === 0) {
14368
+ console.error(
14369
+ "No agents in this org yet. Run `bamboo-agents` to create one."
14370
+ );
14371
+ } else {
14372
+ console.error("");
14373
+ console.error("Available agents (slug \u2014 name):");
14374
+ for (const a of agents) {
14375
+ const label = a.slug ?? `${a.id.slice(0, 8)} (no slug)`;
14376
+ console.error(` ${label} \u2014 ${a.name}`);
14377
+ }
14378
+ }
14379
+ process.exit(2);
14380
+ }
14381
+ async function requireSession() {
14382
+ const creds = await readCredentials();
14383
+ if (!creds) {
14384
+ console.error(
14385
+ "bamboo-agents: not logged in. Run `bamboo-agents login` first."
14386
+ );
14387
+ process.exit(1);
14388
+ }
14389
+ return creds.bamboo_session;
14390
+ }
14391
+ async function runSkillsList(options = {}) {
14392
+ if (options.agent) {
14393
+ const bambooSession = await requireSession();
14394
+ const resolved = await resolveAgent(bambooSession, options.agent);
14395
+ if (!resolved) {
14396
+ const list = await listCliAgents(bambooSession);
14397
+ return printAgentNotFound(options.agent, list.agents);
14398
+ }
14399
+ const { available, installed, custom: custom2, subscriptions } = await getAgentSkills(
14400
+ bambooSession,
14401
+ resolved.id
14402
+ );
14403
+ const subscribedSet = new Set(subscriptions);
14404
+ const filtered = [...installed, ...custom2, ...available].filter(
14405
+ (s) => subscribedSet.has(s.name)
14406
+ );
14407
+ if (filtered.length === 0) {
14408
+ console.log("");
14409
+ console.log(` No subscribed skills for ${resolved.name}.`);
14410
+ console.log(
14411
+ ` Subscribe with: bamboo-agents skills subscribe ${resolved.name} <skill-name>`
14412
+ );
14413
+ console.log("");
14414
+ return;
14415
+ }
14416
+ const nameCol2 = Math.max(
14417
+ "name".length,
14418
+ ...filtered.map((s) => s.name.length)
14419
+ );
14420
+ const header2 = ` ${padRight("name", nameCol2)} description`;
14421
+ const rule2 = " " + "\u2500".repeat(nameCol2) + " " + "\u2500".repeat(Math.min(60, 80 - nameCol2));
14422
+ console.log("");
14423
+ console.log(` Skills subscribed by ${resolved.name}:`);
14424
+ console.log("");
14425
+ console.log(header2);
14426
+ console.log(rule2);
14427
+ for (const s of filtered) {
14428
+ console.log(
14429
+ ` ${padRight(s.name, nameCol2)} ${summarize(s.description, 80 - nameCol2 - 4)}`
14430
+ );
14431
+ }
14432
+ console.log("");
14433
+ console.log(
14434
+ ` ${filtered.length} skill${filtered.length === 1 ? "" : "s"} subscribed.`
14435
+ );
14436
+ console.log("");
14437
+ return;
14438
+ }
13986
14439
  const repoPath = await resolveWorkspacePath();
13987
14440
  const skills2 = await listLocalSkills(repoPath);
13988
14441
  if (skills2.length === 0) {
@@ -14073,11 +14526,129 @@ async function printNotFound(repoPath, name) {
14073
14526
  console.error(` ${s.name}`);
14074
14527
  }
14075
14528
  }
14529
+ async function runSkillsSubscribe(agentIdentifier, skillName) {
14530
+ await runSubscribeOp("subscribe", agentIdentifier, skillName);
14531
+ }
14532
+ async function runSkillsUnsubscribe(agentIdentifier, skillName) {
14533
+ await runSubscribeOp("unsubscribe", agentIdentifier, skillName);
14534
+ }
14535
+ async function runSubscribeOp(action, agentIdentifier, skillName) {
14536
+ if (!agentIdentifier || !skillName) {
14537
+ console.error(
14538
+ `bamboo-agents: \`skills ${action}\` requires an agent identifier and a skill name.`
14539
+ );
14540
+ console.error(
14541
+ `Example: bamboo-agents skills ${action} "Paid Ads" walk-pr`
14542
+ );
14543
+ process.exit(2);
14544
+ }
14545
+ const bambooSession = await requireSession();
14546
+ const resolved = await resolveAgent(bambooSession, agentIdentifier);
14547
+ if (!resolved) {
14548
+ const list = await listCliAgents(bambooSession);
14549
+ printAgentNotFound(agentIdentifier, list.agents);
14550
+ }
14551
+ let result;
14552
+ try {
14553
+ result = await postAgentSkill(bambooSession, resolved.id, {
14554
+ action,
14555
+ skill_name: skillName
14556
+ });
14557
+ } catch (err) {
14558
+ console.error(
14559
+ `bamboo-agents: could not ${action} ${skillName}: ${err.message}`
14560
+ );
14561
+ process.exit(1);
14562
+ }
14563
+ if (action === "subscribe") {
14564
+ console.log("");
14565
+ console.log(` Subscribed ${resolved.name} to ${skillName}.`);
14566
+ } else {
14567
+ console.log("");
14568
+ console.log(` Unsubscribed ${resolved.name} from ${skillName}.`);
14569
+ }
14570
+ console.log("");
14571
+ console.log(
14572
+ ` ${resolved.name} now has ${result.subscriptions.length} skill${result.subscriptions.length === 1 ? "" : "s"} subscribed.`
14573
+ );
14574
+ console.log(
14575
+ " Pull the workspace repo to see the manifest.yml update locally:"
14576
+ );
14577
+ console.log(" git -C $(bamboo-agents status) pull");
14578
+ console.log("");
14579
+ }
14580
+ async function runSkillsCreate(skillName, options = {}) {
14581
+ if (!skillName || !skillName.trim()) {
14582
+ console.error("bamboo-agents: skills create requires a skill name.");
14583
+ console.error("Example: bamboo-agents skills create analyze-creative");
14584
+ process.exit(2);
14585
+ }
14586
+ if (!/^[a-z0-9][a-z0-9-]*$/.test(skillName.trim())) {
14587
+ console.error(
14588
+ "bamboo-agents: skill name must be kebab-case (lowercase + dashes)."
14589
+ );
14590
+ process.exit(2);
14591
+ }
14592
+ const bambooSession = await requireSession();
14593
+ let result;
14594
+ try {
14595
+ result = await scaffoldSkill(bambooSession, {
14596
+ skill_name: skillName.trim(),
14597
+ category: options.category,
14598
+ description: options.description
14599
+ });
14600
+ } catch (err) {
14601
+ console.error(
14602
+ `bamboo-agents: could not scaffold ${skillName}: ${err.message}`
14603
+ );
14604
+ process.exit(1);
14605
+ }
14606
+ console.log("");
14607
+ console.log(` Scaffolded ${result.skill_name}.`);
14608
+ console.log("");
14609
+ console.log(
14610
+ ` Edit skills/${result.skill_name}/SKILL.md in your workspace clone:`
14611
+ );
14612
+ console.log(" git -C $(bamboo-agents status) pull");
14613
+ console.log(` $EDITOR skills/${result.skill_name}/SKILL.md`);
14614
+ console.log("");
14615
+ }
14616
+ async function runSkillsUpdate(agentIdentifier, skillName) {
14617
+ if (!agentIdentifier || !skillName) {
14618
+ console.error(
14619
+ "bamboo-agents: `skills update` requires an agent identifier and a skill name."
14620
+ );
14621
+ console.error('Example: bamboo-agents skills update "Paid Ads" walk-pr');
14622
+ process.exit(2);
14623
+ }
14624
+ const bambooSession = await requireSession();
14625
+ const resolved = await resolveAgent(bambooSession, agentIdentifier);
14626
+ if (!resolved) {
14627
+ const list = await listCliAgents(bambooSession);
14628
+ printAgentNotFound(agentIdentifier, list.agents);
14629
+ }
14630
+ try {
14631
+ await updateSkillFromRegistry(bambooSession, resolved.id, skillName);
14632
+ } catch (err) {
14633
+ console.error(
14634
+ `bamboo-agents: could not update ${skillName}: ${err.message}`
14635
+ );
14636
+ process.exit(1);
14637
+ }
14638
+ console.log("");
14639
+ console.log(` Updated ${skillName} from the bamboo registry.`);
14640
+ console.log("");
14641
+ console.log(" Pull your workspace to see the new body locally:");
14642
+ console.log(" git -C $(bamboo-agents status) pull");
14643
+ console.log("");
14644
+ }
14076
14645
  var init_skills = __esm({
14077
14646
  "src/commands/skills.ts"() {
14078
14647
  "use strict";
14079
- init_state();
14648
+ init_credentials();
14649
+ init_workspace();
14080
14650
  init_skills_local();
14651
+ init_api();
14081
14652
  }
14082
14653
  });
14083
14654
 
@@ -14126,16 +14697,45 @@ program2.command("doctor").description("Verify your local setup is ready").actio
14126
14697
  const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
14127
14698
  await runDoctor2();
14128
14699
  });
14700
+ program2.command("save <message>").description("Commit + push everything in your workspace (cwd-agnostic)").action(async (message) => {
14701
+ const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save(), save_exports));
14702
+ await runSave2(message);
14703
+ });
14704
+ program2.command("sync").description("Pull your workspace clone up to remote (cwd-agnostic)").action(async () => {
14705
+ const { runSync: runSync2 } = await Promise.resolve().then(() => (init_sync(), sync_exports));
14706
+ await runSync2();
14707
+ });
14129
14708
  var skills = program2.command("skills").description("Read workspace skills from your local clone");
14130
- skills.command("list").description("List every skill in the workspace").action(async () => {
14709
+ skills.command("list").description("List every skill in the workspace").option(
14710
+ "--agent <slug>",
14711
+ "Filter to one agent's subscribed skills (via server)"
14712
+ ).action(async (options) => {
14131
14713
  const { runSkillsList: runSkillsList2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14132
- await runSkillsList2();
14714
+ await runSkillsList2(options);
14133
14715
  });
14134
14716
  skills.command("get <name>").description("Print one skill's SKILL.md body to stdout").action(async (name) => {
14135
14717
  const { runSkillsGet: runSkillsGet2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14136
14718
  await runSkillsGet2(name);
14137
14719
  });
14138
- program2.parseAsync().catch((err) => {
14720
+ skills.command("subscribe <agent> <skill-name>").description("Subscribe an agent to a skill from the catalog").action(async (agent, skillName) => {
14721
+ const { runSkillsSubscribe: runSkillsSubscribe2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14722
+ await runSkillsSubscribe2(agent, skillName);
14723
+ });
14724
+ skills.command("unsubscribe <agent> <skill-name>").description("Unsubscribe an agent from a skill").action(async (agent, skillName) => {
14725
+ const { runSkillsUnsubscribe: runSkillsUnsubscribe2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14726
+ await runSkillsUnsubscribe2(agent, skillName);
14727
+ });
14728
+ 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(
14729
+ async (skillName, options) => {
14730
+ const { runSkillsCreate: runSkillsCreate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14731
+ await runSkillsCreate2(skillName, options);
14732
+ }
14733
+ );
14734
+ skills.command("update <agent> <skill-name>").description("Update an installed skill from the bamboo registry").action(async (agent, skillName) => {
14735
+ const { runSkillsUpdate: runSkillsUpdate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14736
+ await runSkillsUpdate2(agent, skillName);
14737
+ });
14738
+ program2.parseAsync(process.argv).catch((err) => {
14139
14739
  const message = err instanceof Error ? err.message : String(err);
14140
14740
  console.error(`bamboo-agents: ${message}`);
14141
14741
  process.exit(1);