bamboo-agents 0.1.5-dev.59.bf3c8c5 → 0.1.5-dev.61.c67ae11

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.59.bf3c8c5
1
+ 0.1.5-dev.61.c67ae11
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.59.bf3c8c5";
3040
+ VERSION = "0.1.5-dev.61.c67ae11";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7161,7 +7161,9 @@ var init_history = __esm({
7161
7161
  tool_name: external_exports.string().nullable(),
7162
7162
  status: external_exports.string(),
7163
7163
  timestamp: external_exports.string(),
7164
- duration_ms: external_exports.number().nullable()
7164
+ duration_ms: external_exports.number().nullable(),
7165
+ /** BAM-2661: runtime origin so `bamboo history --source <X>` can filter. */
7166
+ source: external_exports.string().nullable()
7165
7167
  });
7166
7168
  HistoryResponseSchema = external_exports.object({
7167
7169
  entries: external_exports.array(HistoryEntrySchema),
@@ -12389,6 +12391,65 @@ var init_brand = __esm({
12389
12391
  }
12390
12392
  });
12391
12393
 
12394
+ // ../../src/lib/api-contracts/cli/skill-apply.ts
12395
+ var SkillEditOpSchema, SkillApplyRequestSchema, SkillApplySuccessResponseSchema;
12396
+ var init_skill_apply = __esm({
12397
+ "../../src/lib/api-contracts/cli/skill-apply.ts"() {
12398
+ init_zod();
12399
+ SkillEditOpSchema = external_exports.object({
12400
+ op: external_exports.enum(["add", "delete", "replace"]),
12401
+ anchor: external_exports.string().min(1).describe(
12402
+ "The section heading the op targets, verbatim including the `#` prefix."
12403
+ ),
12404
+ before: external_exports.string().optional().describe(
12405
+ "Exact existing text to find. Required for `replace` and `delete`."
12406
+ ),
12407
+ after: external_exports.string().optional().describe("New text. Required for `add` and `replace`.")
12408
+ }).superRefine((val, ctx) => {
12409
+ if ((val.op === "replace" || val.op === "delete") && !val.before) {
12410
+ ctx.addIssue({
12411
+ code: external_exports.ZodIssueCode.custom,
12412
+ message: `op '${val.op}' requires 'before'`,
12413
+ path: ["before"]
12414
+ });
12415
+ }
12416
+ if ((val.op === "replace" || val.op === "add") && !val.after) {
12417
+ ctx.addIssue({
12418
+ code: external_exports.ZodIssueCode.custom,
12419
+ message: `op '${val.op}' requires 'after'`,
12420
+ path: ["after"]
12421
+ });
12422
+ }
12423
+ });
12424
+ SkillApplyRequestSchema = external_exports.object({
12425
+ skill_name: external_exports.string().min(1).describe("Kebab-case skill name, e.g. `draft-content`."),
12426
+ current_skill_body: external_exports.string().min(1).describe(
12427
+ "The SKILL.md body the ops were reasoned against. For a Library skill with no per-org fork yet, pass the bundled body \u2014 the fork writes that same body, so the ops still apply."
12428
+ ),
12429
+ ops: external_exports.array(SkillEditOpSchema).describe(
12430
+ "Bounded add/delete/replace ops (1\u20138). Budget + protected-section rules enforced in `applyOps` server-side."
12431
+ ),
12432
+ behavior_summary: external_exports.string().min(1).describe(
12433
+ "One plain-English sentence describing the behavior change (what the user approves on the card)."
12434
+ )
12435
+ });
12436
+ SkillApplySuccessResponseSchema = external_exports.object({
12437
+ proposed: external_exports.literal(true),
12438
+ /** Whether a Library skill was forked into the workspace before applying ops. */
12439
+ forked: external_exports.boolean(),
12440
+ skill: external_exports.string(),
12441
+ repo_path: external_exports.string(),
12442
+ pr_number: external_exports.number().int().nullable(),
12443
+ pr_url: external_exports.string().url().nullable(),
12444
+ applied_ops: external_exports.number().int(),
12445
+ dropped_protected: external_exports.number().int(),
12446
+ behavior_summary: external_exports.string(),
12447
+ /** Plain-English next-step hint for the agent's log. */
12448
+ note: external_exports.string()
12449
+ });
12450
+ }
12451
+ });
12452
+
12392
12453
  // ../../src/lib/api-contracts/cli/context-health.ts
12393
12454
  var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
12394
12455
  var init_context_health = __esm({
@@ -12564,6 +12625,19 @@ async function getKnowledgeSlots(bambooSession) {
12564
12625
  const json = await res.json();
12565
12626
  return KnowledgeSlotsResponseSchema.parse(json);
12566
12627
  }
12628
+ async function applySkillEdit(bambooSession, body) {
12629
+ const res = await cliApiFetch(`${apiBase()}/api/v1/cli/skill-apply`, {
12630
+ method: "POST",
12631
+ headers: {
12632
+ Authorization: `Bearer ${bambooSession}`,
12633
+ "Content-Type": "application/json"
12634
+ },
12635
+ body: JSON.stringify(body)
12636
+ });
12637
+ if (!res.ok) throw await parseError(res);
12638
+ const json = await res.json();
12639
+ return SkillApplySuccessResponseSchema.parse(json);
12640
+ }
12567
12641
  async function saveKnowledge(bambooSession, body) {
12568
12642
  const res = await cliApiFetch(`${apiBase()}/api/v1/cli/knowledge/save`, {
12569
12643
  method: "POST",
@@ -12593,6 +12667,7 @@ async function saveWorkspace(bambooSession, body) {
12593
12667
  async function getHistory(bambooSession, opts = {}) {
12594
12668
  const url = new URL(`${apiBase()}/api/v1/cli/history`);
12595
12669
  if (opts.limit) url.searchParams.set("limit", String(opts.limit));
12670
+ if (opts.source) url.searchParams.set("source", opts.source);
12596
12671
  const res = await cliApiFetch(url.toString(), {
12597
12672
  headers: { Authorization: `Bearer ${bambooSession}` }
12598
12673
  });
@@ -12946,6 +13021,7 @@ var init_api = __esm({
12946
13021
  init_agents();
12947
13022
  init_knowledge_slots();
12948
13023
  init_knowledge_save();
13024
+ init_skill_apply();
12949
13025
  init_save();
12950
13026
  init_history();
12951
13027
  init_changes();
@@ -16838,6 +16914,7 @@ var init_skills_local = __esm({
16838
16914
  // src/commands/skills.ts
16839
16915
  var skills_exports = {};
16840
16916
  __export(skills_exports, {
16917
+ runSkillsApply: () => runSkillsApply,
16841
16918
  runSkillsCreate: () => runSkillsCreate,
16842
16919
  runSkillsGet: () => runSkillsGet,
16843
16920
  runSkillsList: () => runSkillsList,
@@ -17175,6 +17252,88 @@ async function runSkillsUpdateImpl(agentIdentifier, skillName) {
17175
17252
  console.log(" git -C $(bamboo-agents status) pull");
17176
17253
  console.log("");
17177
17254
  }
17255
+ async function readJsonFromStdin() {
17256
+ if (process.stdin.isTTY) {
17257
+ throw new Error(
17258
+ "expected JSON on stdin (no input piped). Example: `bamboo-agents skills apply <skill> < lesson.json`"
17259
+ );
17260
+ }
17261
+ const chunks = [];
17262
+ for await (const chunk of process.stdin) {
17263
+ chunks.push(chunk);
17264
+ }
17265
+ const raw = Buffer.concat(chunks).toString("utf8").trim();
17266
+ if (!raw) {
17267
+ throw new Error("stdin was empty \u2014 pipe a JSON body in.");
17268
+ }
17269
+ try {
17270
+ return JSON.parse(raw);
17271
+ } catch (err) {
17272
+ throw new Error(`stdin is not valid JSON: ${err.message}`);
17273
+ }
17274
+ }
17275
+ async function runSkillsApply(skillName) {
17276
+ const envToken = process.env.BAMBOO_API_TOKEN?.trim();
17277
+ let session = null;
17278
+ if (envToken) {
17279
+ session = envToken;
17280
+ } else {
17281
+ const creds = await readCredentials();
17282
+ session = creds?.bamboo_session ?? null;
17283
+ }
17284
+ if (!session) {
17285
+ console.error(
17286
+ "bamboo-agents: not signed in. Run `bamboo-agents login` first (or set BAMBOO_API_TOKEN for headless / managed-agent use)."
17287
+ );
17288
+ process.exit(1);
17289
+ }
17290
+ let body;
17291
+ try {
17292
+ const raw = await readJsonFromStdin();
17293
+ if (typeof raw !== "object" || raw === null) {
17294
+ throw new Error("stdin JSON must be an object");
17295
+ }
17296
+ body = { ...raw, skill_name: skillName };
17297
+ } catch (err) {
17298
+ console.error(`bamboo-agents: ${err.message}`);
17299
+ process.exit(1);
17300
+ }
17301
+ try {
17302
+ const result = await applySkillEdit(session, body);
17303
+ console.log("");
17304
+ console.log(
17305
+ ` \u2713 Queued skill-edit PR \u2014 the "Boo is learning" card is in the inbox.`
17306
+ );
17307
+ console.log("");
17308
+ console.log(` Skill: ${result.skill}`);
17309
+ console.log(` Behavior: ${result.behavior_summary}`);
17310
+ console.log(` Applied ops: ${result.applied_ops}`);
17311
+ if (result.dropped_protected > 0) {
17312
+ console.log(
17313
+ ` Dropped protected: ${result.dropped_protected} (anchor hit a <!-- protected --> section)`
17314
+ );
17315
+ }
17316
+ if (result.forked) {
17317
+ console.log(` Forked Library skill into the workspace first.`);
17318
+ }
17319
+ if (result.pr_url) {
17320
+ console.log(` PR: ${result.pr_url}`);
17321
+ }
17322
+ console.log("");
17323
+ console.log(` ${result.note}`);
17324
+ console.log("");
17325
+ } catch (err) {
17326
+ if (err instanceof ApiError) {
17327
+ const exitCode = err.status >= 500 ? 2 : 1;
17328
+ console.error("");
17329
+ console.error(` bamboo-agents: ${err.message}`);
17330
+ console.error("");
17331
+ process.exit(exitCode);
17332
+ }
17333
+ console.error(`bamboo-agents: ${err.message}`);
17334
+ process.exit(2);
17335
+ }
17336
+ }
17178
17337
  var init_skills = __esm({
17179
17338
  "src/commands/skills.ts"() {
17180
17339
  "use strict";
@@ -17410,7 +17569,10 @@ async function runHistory(options) {
17410
17569
  const session = await requireSession4(opts);
17411
17570
  let data;
17412
17571
  try {
17413
- data = await getHistory(session, { limit: parseLimit(options.limit) });
17572
+ data = await getHistory(session, {
17573
+ limit: parseLimit(options.limit),
17574
+ source: options.source
17575
+ });
17414
17576
  } catch (err) {
17415
17577
  emitError(
17416
17578
  { code: "history_failed", message: `couldn't load history: ${err.message}` },
@@ -18360,6 +18522,12 @@ skills.command("update <agent> <skill-name>").description("Update an installed s
18360
18522
  const { runSkillsUpdate: runSkillsUpdate2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
18361
18523
  await runSkillsUpdate2(agent, skillName);
18362
18524
  });
18525
+ skills.command("apply <skill-name>").description(
18526
+ 'Apply a bounded skill edit \u2014 opens a queued, human-gated PR (the "Boo is learning" card). Reads JSON body from stdin.'
18527
+ ).option("--no-sync", "Skip the auto-sync git pull on this command").action(async (skillName) => {
18528
+ const { runSkillsApply: runSkillsApply2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
18529
+ await runSkillsApply2(skillName);
18530
+ });
18363
18531
  var knowledge = program2.command("knowledge").description("Knowledge surface for CLI-first skills");
18364
18532
  knowledge.command("slots").description("Print the knowledge slot schema (kind \xD7 scope \u2192 path) + dimensions").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
18365
18533
  const { runKnowledgeSlots: runKnowledgeSlots2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
@@ -18369,7 +18537,10 @@ knowledge.command("save").description("Save a knowledge file (routed write \u201
18369
18537
  const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
18370
18538
  await runKnowledgeSave2(options);
18371
18539
  });
18372
- program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
18540
+ program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option(
18541
+ "--source <runtime>",
18542
+ "Filter by runtime origin (boo | sandbox-boo | managed-agent)"
18543
+ ).option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
18373
18544
  const { runHistory: runHistory2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
18374
18545
  await runHistory2(options);
18375
18546
  });