bamboo-agents 0.1.5-dev.48.0e1a6eb → 0.1.5-dev.49.eaaa602

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.48.0e1a6eb";
3040
+ VERSION = "0.1.5-dev.49.eaaa602";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -14386,6 +14386,85 @@ var init_open2 = __esm({
14386
14386
  }
14387
14387
  });
14388
14388
 
14389
+ // src/lib/output.ts
14390
+ function isJsonMode(opts = {}) {
14391
+ if (opts.json === true) return true;
14392
+ return process.stdout.isTTY !== true;
14393
+ }
14394
+ function parseFields(raw) {
14395
+ if (!raw) return [];
14396
+ return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
14397
+ }
14398
+ function pluckPath(value, segments) {
14399
+ if (segments.length === 0) return value;
14400
+ if (value === null || value === void 0) return void 0;
14401
+ if (Array.isArray(value)) {
14402
+ return value.map((item) => pluckPath(item, segments)).filter((v) => v !== void 0);
14403
+ }
14404
+ if (typeof value === "object") {
14405
+ const [head, ...rest] = segments;
14406
+ return pluckPath(value[head], rest);
14407
+ }
14408
+ return void 0;
14409
+ }
14410
+ function projectFields(data, fields) {
14411
+ if (fields.length === 0) return data;
14412
+ if (data === null || typeof data !== "object" || Array.isArray(data)) {
14413
+ return data;
14414
+ }
14415
+ const out = {};
14416
+ for (const field of fields) {
14417
+ const segments = field.split(".").filter((s) => s.length > 0);
14418
+ if (segments.length === 0) continue;
14419
+ const value = pluckPath(data, segments);
14420
+ if (value === void 0) continue;
14421
+ out[field] = value;
14422
+ }
14423
+ return out;
14424
+ }
14425
+ function writeStdout(line) {
14426
+ process.stdout.write(line.endsWith("\n") ? line : line + "\n");
14427
+ }
14428
+ function writeStderr(line) {
14429
+ process.stderr.write(line.endsWith("\n") ? line : line + "\n");
14430
+ }
14431
+ function emitSuccess(data, opts, renderHuman) {
14432
+ if (isJsonMode(opts)) {
14433
+ const projected = projectFields(data, parseFields(opts.fields));
14434
+ const envelope = { ok: true, data: projected };
14435
+ writeStdout(JSON.stringify(envelope, null, 2));
14436
+ return;
14437
+ }
14438
+ if (opts.quiet) return;
14439
+ if (renderHuman) renderHuman(data);
14440
+ }
14441
+ function emitError(err, opts, exitCode) {
14442
+ if (isJsonMode(opts)) {
14443
+ const envelope = {
14444
+ ok: false,
14445
+ error: {
14446
+ code: err.code,
14447
+ message: err.message,
14448
+ ...err.hint ? { hint: err.hint } : {}
14449
+ }
14450
+ };
14451
+ writeStdout(JSON.stringify(envelope, null, 2));
14452
+ } else if (!opts.quiet) {
14453
+ writeStderr(`bamboo-agents: ${err.message}`);
14454
+ if (err.hint) writeStderr(` ${err.hint}`);
14455
+ }
14456
+ if (exitCode !== void 0) process.exit(exitCode);
14457
+ }
14458
+ function human(line = "", opts = {}) {
14459
+ if (opts.quiet) return;
14460
+ writeStderr(line);
14461
+ }
14462
+ var init_output = __esm({
14463
+ "src/lib/output.ts"() {
14464
+ "use strict";
14465
+ }
14466
+ });
14467
+
14389
14468
  // src/commands/save.ts
14390
14469
  var save_exports = {};
14391
14470
  __export(save_exports, {
@@ -14470,28 +14549,35 @@ async function currentBranch(repoPath) {
14470
14549
  const out = await gitC(repoPath, ["rev-parse", "--abbrev-ref", "HEAD"]);
14471
14550
  return out.trim() || "main";
14472
14551
  }
14473
- async function requireSession() {
14552
+ async function requireSession(opts) {
14474
14553
  const creds = await readCredentials();
14475
14554
  if (!creds) {
14476
- console.error(
14477
- "bamboo-agents save: not signed in. Run `bamboo-agents login` first."
14555
+ emitError(
14556
+ {
14557
+ code: "not_signed_in",
14558
+ message: "not signed in.",
14559
+ hint: "Run `bamboo-agents login` first."
14560
+ },
14561
+ opts,
14562
+ 1
14478
14563
  );
14479
- process.exit(1);
14564
+ throw new Error("unreachable");
14480
14565
  }
14481
14566
  return creds.bamboo_session;
14482
14567
  }
14483
- async function runSave(intent) {
14568
+ async function runSave(intent, options = {}) {
14569
+ const opts = options;
14484
14570
  let workspacePath;
14485
14571
  try {
14486
14572
  workspacePath = (await resolveWorkspace()).path;
14487
14573
  } catch (err) {
14488
14574
  if (err instanceof NoWorkspaceError) {
14489
- console.error(`bamboo-agents save: ${err.message}`);
14490
- process.exit(2);
14575
+ emitError({ code: "no_workspace", message: err.message }, opts, 2);
14576
+ return;
14491
14577
  }
14492
14578
  throw err;
14493
14579
  }
14494
- const session = await requireSession();
14580
+ const session = await requireSession(opts);
14495
14581
  let entries;
14496
14582
  try {
14497
14583
  const porcelain = await gitC(workspacePath, [
@@ -14502,22 +14588,39 @@ async function runSave(intent) {
14502
14588
  ]);
14503
14589
  entries = parsePorcelain(porcelain);
14504
14590
  } catch {
14505
- console.error(
14506
- " Couldn't read your workspace changes.\n Next: run `bamboo-agents doctor` to check your workspace is healthy."
14591
+ emitError(
14592
+ {
14593
+ code: "read_failed",
14594
+ message: "couldn't read your workspace changes.",
14595
+ hint: "Run `bamboo-agents doctor` to check your workspace is healthy."
14596
+ },
14597
+ opts,
14598
+ 1
14507
14599
  );
14508
- process.exit(1);
14600
+ return;
14509
14601
  }
14510
14602
  const { deletes, writes, skipped } = planBatchFromPorcelain(entries);
14511
14603
  if (deletes.length === 0 && writes.length === 0) {
14512
- console.log("");
14513
- if (skipped.length > 0) {
14514
- console.log(
14515
- " Nothing to save \u2014 the only changes are outside your context folders."
14516
- );
14517
- } else {
14518
- console.log(" Nothing to save \u2014 your workspace is already up to date.");
14519
- }
14520
- console.log("");
14604
+ const payload2 = {
14605
+ saved: 0,
14606
+ live: 0,
14607
+ queued: 0,
14608
+ skipped: skipped.length,
14609
+ pr_url: null,
14610
+ files: []
14611
+ };
14612
+ emitSuccess(payload2, opts, () => {
14613
+ human("", opts);
14614
+ if (skipped.length > 0) {
14615
+ human(
14616
+ " Nothing to save \u2014 the only changes are outside your context folders.",
14617
+ opts
14618
+ );
14619
+ } else {
14620
+ human(" Nothing to save \u2014 your workspace is already up to date.", opts);
14621
+ }
14622
+ human("", opts);
14623
+ });
14521
14624
  return;
14522
14625
  }
14523
14626
  const edits = [];
@@ -14527,10 +14630,16 @@ async function runSave(intent) {
14527
14630
  edits.push({ path: path2, content });
14528
14631
  }
14529
14632
  } catch {
14530
- console.error(
14531
- " Couldn't read one of your changed files.\n Next: make sure the file still exists, then run `bamboo-agents save` again."
14633
+ emitError(
14634
+ {
14635
+ code: "read_failed",
14636
+ message: "couldn't read one of your changed files.",
14637
+ hint: "Make sure the file still exists, then run `bamboo-agents save` again."
14638
+ },
14639
+ opts,
14640
+ 1
14532
14641
  );
14533
- process.exit(1);
14642
+ return;
14534
14643
  }
14535
14644
  for (const path2 of deletes) {
14536
14645
  edits.push({ path: path2, delete: true });
@@ -14543,19 +14652,28 @@ async function runSave(intent) {
14543
14652
  });
14544
14653
  } catch (err) {
14545
14654
  if (err instanceof ApiError && err.status === 403) {
14546
- console.error("");
14547
- console.error(
14548
- " Couldn't save \u2014 you don't have permission to change some of these files.\n Next: ask an org admin to review, or edit only your own brand/agent files."
14655
+ emitError(
14656
+ {
14657
+ code: "forbidden",
14658
+ message: "couldn't save \u2014 you don't have permission to change some of these files.",
14659
+ hint: "Ask an org admin to review, or edit only your own brand/agent files."
14660
+ },
14661
+ opts,
14662
+ 1
14549
14663
  );
14550
- process.exit(1);
14664
+ return;
14551
14665
  }
14552
14666
  const message = err instanceof Error ? err.message : String(err);
14553
- console.error("");
14554
- console.error(
14555
- ` Couldn't reach Bamboo to save your changes.
14556
- Next: check your connection and run \`bamboo-agents save\` again. (${message})`
14667
+ emitError(
14668
+ {
14669
+ code: "save_failed",
14670
+ message: `couldn't reach Bamboo to save your changes. (${message})`,
14671
+ hint: "Check your connection and run `bamboo-agents save` again."
14672
+ },
14673
+ opts,
14674
+ 1
14557
14675
  );
14558
- process.exit(1);
14676
+ return;
14559
14677
  }
14560
14678
  const { checkout, remove } = reconcilePlan(result.files, deletes);
14561
14679
  if (checkout.length > 0 || remove.length > 0) {
@@ -14574,29 +14692,41 @@ async function runSave(intent) {
14574
14692
  await rm2(join2(workspacePath, path2), { force: true });
14575
14693
  }
14576
14694
  } catch {
14577
- console.warn(
14578
- " (Saved, but couldn't refresh your local copy just now \u2014 it'll catch up on your next command.)"
14695
+ human(
14696
+ " (Saved, but couldn't refresh your local copy just now \u2014 it'll catch up on your next command.)",
14697
+ opts
14579
14698
  );
14580
14699
  }
14581
14700
  }
14582
14701
  const total = edits.length;
14583
14702
  const live = result.live_count;
14584
14703
  const queued = result.queued_count;
14585
- console.log("");
14586
- const parts = [];
14587
- if (live > 0) parts.push(`${live} live`);
14588
- if (queued > 0) parts.push(`${queued} queued for review`);
14589
- const summary = parts.length > 0 ? ` \u2014 ${parts.join(", ")}` : "";
14590
- console.log(` Saved ${total} file${total === 1 ? "" : "s"}${summary}.`);
14591
- if (queued > 0 && result.pr_url) {
14592
- console.log(` Review: ${result.pr_url}`);
14593
- }
14594
- if (skipped.length > 0) {
14595
- console.log(
14596
- ` (Skipped ${skipped.length} file${skipped.length === 1 ? "" : "s"} outside your context folders.)`
14597
- );
14598
- }
14599
- console.log("");
14704
+ const payload = {
14705
+ saved: total,
14706
+ live,
14707
+ queued,
14708
+ skipped: skipped.length,
14709
+ pr_url: result.pr_url ?? null,
14710
+ files: result.files
14711
+ };
14712
+ emitSuccess(payload, opts, () => {
14713
+ human("", opts);
14714
+ const parts = [];
14715
+ if (live > 0) parts.push(`${live} live`);
14716
+ if (queued > 0) parts.push(`${queued} queued for review`);
14717
+ const summary = parts.length > 0 ? ` \u2014 ${parts.join(", ")}` : "";
14718
+ human(` Saved ${total} file${total === 1 ? "" : "s"}${summary}.`, opts);
14719
+ if (queued > 0 && result.pr_url) {
14720
+ human(` Review: ${result.pr_url}`, opts);
14721
+ }
14722
+ if (skipped.length > 0) {
14723
+ human(
14724
+ ` (Skipped ${skipped.length} file${skipped.length === 1 ? "" : "s"} outside your context folders.)`,
14725
+ opts
14726
+ );
14727
+ }
14728
+ human("", opts);
14729
+ });
14600
14730
  }
14601
14731
  var execFileP3, MANAGED_PREFIXES, MANAGED_FILES;
14602
14732
  var init_save2 = __esm({
@@ -14605,6 +14735,7 @@ var init_save2 = __esm({
14605
14735
  init_api();
14606
14736
  init_credentials();
14607
14737
  init_workspace();
14738
+ init_output();
14608
14739
  execFileP3 = promisify8(execFile8);
14609
14740
  MANAGED_PREFIXES = [
14610
14741
  "brands/",
@@ -14734,52 +14865,79 @@ function formatSubscriptionLine(billing) {
14734
14865
  return `Subscription: not yet started \u2014 subscribe at ${billing.billing_url}`;
14735
14866
  }
14736
14867
  }
14737
- async function runStatus() {
14868
+ async function runStatus(options = {}) {
14869
+ const opts = options;
14738
14870
  return withFreshWorkspace(async () => {
14739
14871
  const creds = await readCredentials();
14740
14872
  const state = await readState().catch(() => null);
14741
14873
  const cfg = await readConfig();
14742
- console.log("");
14743
- console.log(" Bamboo CLI status");
14744
- console.log("");
14745
- if (!creds) {
14746
- console.log(" Credentials: not set (run `bamboo-agents login`)");
14747
- } else {
14748
- console.log(
14749
- ` Credentials: set${creds.github_username ? ` (@${creds.github_username})` : ""}`
14750
- );
14751
- console.log(` Written: ${creds.written_at}`);
14752
- if (creds.github_token_expires_at) {
14753
- console.log(` GitHub expires: ${creds.github_token_expires_at}`);
14754
- }
14755
- }
14756
14874
  const workspacePath = state?.workspace_path ?? cfg?.repo_path ?? null;
14757
- if (!workspacePath) {
14758
- console.log(" Workspace: not configured (run `bamboo-agents init`)");
14759
- } else {
14760
- const repoLabel = cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)";
14761
- console.log(` Workspace: ${repoLabel}`);
14762
- console.log(` Repo path: ${workspacePath}`);
14763
- console.log(` Org: ${cfg?.org_name ?? state?.org_slug ?? "(unknown)"}`);
14764
- console.log(` Installed: ${cfg?.installed_at ?? state?.cloned_at ?? "(unknown)"}`);
14765
- if (state?.last_sync) {
14766
- console.log(` Last sync: ${state.last_sync}`);
14767
- }
14875
+ const repoLabel = workspacePath ? cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)" : null;
14876
+ let sync = null;
14877
+ if (workspacePath) {
14768
14878
  const unsaved = await countUnsavedManagedEdits(workspacePath);
14769
14879
  const branch = await currentBranchOrNull(workspacePath);
14770
14880
  const ab = branch ? await aheadBehind(workspacePath, branch) : null;
14771
- console.log(
14772
- ` ${formatSyncLine({ unsaved, behind: ab?.behind ?? null, ahead: ab?.ahead ?? null })}`
14773
- );
14881
+ sync = { unsaved, behind: ab?.behind ?? null, ahead: ab?.ahead ?? null };
14774
14882
  }
14883
+ let billing = null;
14775
14884
  if (creds?.bamboo_session) {
14776
14885
  try {
14777
- const billing = await getCliBillingStatus(creds.bamboo_session);
14778
- console.log(` ${formatSubscriptionLine(billing)}`);
14886
+ billing = await getCliBillingStatus(creds.bamboo_session);
14779
14887
  } catch {
14780
14888
  }
14781
14889
  }
14782
- console.log("");
14890
+ const payload = {
14891
+ signed_in: !!creds,
14892
+ github_username: creds?.github_username ?? null,
14893
+ credentials_written_at: creds?.written_at ?? null,
14894
+ github_token_expires_at: creds?.github_token_expires_at ?? null,
14895
+ workspace: {
14896
+ configured: !!workspacePath,
14897
+ repo: repoLabel,
14898
+ path: workspacePath,
14899
+ org: cfg?.org_name ?? state?.org_slug ?? null,
14900
+ installed_at: cfg?.installed_at ?? state?.cloned_at ?? null,
14901
+ last_sync: state?.last_sync ?? null,
14902
+ sync
14903
+ },
14904
+ subscription: billing
14905
+ };
14906
+ emitSuccess(payload, opts, (d) => {
14907
+ human("", opts);
14908
+ human(" Bamboo CLI status", opts);
14909
+ human("", opts);
14910
+ if (!d.signed_in) {
14911
+ human(" Credentials: not set (run `bamboo-agents login`)", opts);
14912
+ } else {
14913
+ human(
14914
+ ` Credentials: set${d.github_username ? ` (@${d.github_username})` : ""}`,
14915
+ opts
14916
+ );
14917
+ human(` Written: ${d.credentials_written_at}`, opts);
14918
+ if (d.github_token_expires_at) {
14919
+ human(` GitHub expires: ${d.github_token_expires_at}`, opts);
14920
+ }
14921
+ }
14922
+ if (!d.workspace.configured) {
14923
+ human(" Workspace: not configured (run `bamboo-agents init`)", opts);
14924
+ } else {
14925
+ human(` Workspace: ${d.workspace.repo ?? "(unknown)"}`, opts);
14926
+ human(` Repo path: ${d.workspace.path}`, opts);
14927
+ human(` Org: ${d.workspace.org ?? "(unknown)"}`, opts);
14928
+ human(` Installed: ${d.workspace.installed_at ?? "(unknown)"}`, opts);
14929
+ if (d.workspace.last_sync) {
14930
+ human(` Last sync: ${d.workspace.last_sync}`, opts);
14931
+ }
14932
+ if (d.workspace.sync) {
14933
+ human(` ${formatSyncLine(d.workspace.sync)}`, opts);
14934
+ }
14935
+ }
14936
+ if (d.subscription) {
14937
+ human(` ${formatSubscriptionLine(d.subscription)}`, opts);
14938
+ }
14939
+ human("", opts);
14940
+ });
14783
14941
  });
14784
14942
  }
14785
14943
  var init_status = __esm({
@@ -14790,6 +14948,7 @@ var init_status = __esm({
14790
14948
  init_api();
14791
14949
  init_workspace();
14792
14950
  init_workspace_status();
14951
+ init_output();
14793
14952
  }
14794
14953
  });
14795
14954
 
@@ -15558,54 +15717,82 @@ async function bumpLastSync() {
15558
15717
  throw err;
15559
15718
  }
15560
15719
  }
15561
- async function runUpdate() {
15720
+ async function runUpdate(options = {}) {
15721
+ const opts = options;
15562
15722
  let workspacePath;
15563
15723
  try {
15564
15724
  workspacePath = (await resolveWorkspace()).path;
15565
15725
  } catch (err) {
15566
15726
  if (err instanceof NoWorkspaceError) {
15567
- console.error(`bamboo-agents update: ${err.message}`);
15568
- process.exit(2);
15727
+ emitError({ code: "no_workspace", message: err.message }, opts, 2);
15728
+ return;
15569
15729
  }
15570
15730
  throw err;
15571
15731
  }
15572
15732
  const { health } = await inspectCloneHealth(workspacePath);
15573
15733
  if (health === "wrecked") {
15574
- console.log("");
15575
- console.log(" Your local copy has drifted in a way that can't auto-update.");
15576
- console.log(
15577
- " Your workspace is a cached copy of the cloud \u2014 the safe fix is to refresh it from scratch."
15734
+ if (isJsonMode(opts)) {
15735
+ emitError(
15736
+ {
15737
+ code: "wrecked_clone",
15738
+ message: "your local copy has drifted in a way that can't auto-update.",
15739
+ hint: "Run `bamboo-agents update` interactively (or `bamboo-agents init --reset`) to refresh it from scratch."
15740
+ },
15741
+ opts,
15742
+ 1
15743
+ );
15744
+ return;
15745
+ }
15746
+ human("", opts);
15747
+ human(" Your local copy has drifted in a way that can't auto-update.", opts);
15748
+ human(
15749
+ " Your workspace is a cached copy of the cloud \u2014 the safe fix is to refresh it from scratch.",
15750
+ opts
15578
15751
  );
15579
- console.log("");
15752
+ human("", opts);
15580
15753
  const { runInit: runInit2 } = await Promise.resolve().then(() => (init_init(), init_exports));
15581
15754
  await runInit2({ reset: true });
15582
15755
  return;
15583
15756
  }
15584
15757
  const unsaved = await countUnsavedManagedEdits(workspacePath);
15585
15758
  if (unsaved > 0) {
15586
- console.log("");
15587
- console.log(
15588
- ` You have ${unsaved} unsaved change${unsaved === 1 ? "" : "s"} \u2014 saving ${unsaved === 1 ? "it" : "them"} first\u2026`
15759
+ human("", opts);
15760
+ human(
15761
+ ` You have ${unsaved} unsaved change${unsaved === 1 ? "" : "s"} \u2014 saving ${unsaved === 1 ? "it" : "them"} first\u2026`,
15762
+ opts
15589
15763
  );
15590
15764
  const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
15591
- await runSave2(void 0);
15765
+ if (isJsonMode(opts)) {
15766
+ await runSave2(void 0, { quiet: true, json: false });
15767
+ } else {
15768
+ await runSave2(void 0, opts);
15769
+ }
15592
15770
  }
15593
15771
  try {
15594
15772
  await gitPullFFOnly(workspacePath);
15595
- console.log("");
15596
- console.log(" Your workspace is up to date with the cloud.");
15597
- console.log(` (workspace: ${workspacePath})`);
15598
- console.log("");
15599
15773
  } catch {
15600
- console.log("");
15601
- console.log(" Couldn't reach the cloud to update just now.");
15602
- console.log(
15603
- " Next: check your connection and run `bamboo-agents update` again. If it keeps failing, run `bamboo-agents doctor`."
15774
+ emitError(
15775
+ {
15776
+ code: "update_failed",
15777
+ message: "couldn't reach the cloud to update just now.",
15778
+ hint: "Check your connection and run `bamboo-agents update` again. If it keeps failing, run `bamboo-agents doctor`."
15779
+ },
15780
+ opts,
15781
+ 1
15604
15782
  );
15605
- console.log("");
15606
- process.exit(1);
15783
+ return;
15607
15784
  }
15608
15785
  await bumpLastSync();
15786
+ emitSuccess(
15787
+ { status: "up_to_date", workspace: workspacePath, saved_before_update: unsaved },
15788
+ opts,
15789
+ () => {
15790
+ human("", opts);
15791
+ human(" Your workspace is up to date with the cloud.", opts);
15792
+ human(` (workspace: ${workspacePath})`, opts);
15793
+ human("", opts);
15794
+ }
15795
+ );
15609
15796
  }
15610
15797
  var init_update = __esm({
15611
15798
  "src/commands/update.ts"() {
@@ -15614,6 +15801,7 @@ var init_update = __esm({
15614
15801
  init_state();
15615
15802
  init_workspace();
15616
15803
  init_workspace_status();
15804
+ init_output();
15617
15805
  }
15618
15806
  });
15619
15807
 
@@ -16143,59 +16331,70 @@ __export(knowledge_exports, {
16143
16331
  runKnowledgeSlots: () => runKnowledgeSlots
16144
16332
  });
16145
16333
  import { readFile as readFile6 } from "node:fs/promises";
16146
- async function requireSession3() {
16334
+ async function requireSession3(opts) {
16147
16335
  const creds = await readCredentials();
16148
16336
  if (!creds) {
16149
- console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
16150
- process.exit(1);
16337
+ emitError(
16338
+ {
16339
+ code: "not_signed_in",
16340
+ message: "not signed in.",
16341
+ hint: "Run `bamboo-agents login` first."
16342
+ },
16343
+ opts,
16344
+ 1
16345
+ );
16346
+ throw new Error("unreachable");
16151
16347
  }
16152
16348
  return creds.bamboo_session;
16153
16349
  }
16154
16350
  function padRight2(s, n) {
16155
16351
  return s.length >= n ? s : s + " ".repeat(n - s.length);
16156
16352
  }
16157
- function printHuman(data) {
16158
- console.log("");
16159
- console.log(" Knowledge slots \u2014 where a file belongs in the workspace repo:");
16160
- console.log("");
16353
+ function printHuman(data, opts) {
16354
+ human("", opts);
16355
+ human(" Knowledge slots \u2014 where a file belongs in the workspace repo:", opts);
16356
+ human("", opts);
16161
16357
  const kindW = Math.max(4, ...data.kinds.map((k) => k.kind.length));
16162
16358
  const scopeW = Math.max(5, ...data.kinds.map((k) => k.scope.length));
16163
- console.log(
16164
- ` ${padRight2("KIND", kindW)} ${padRight2("SCOPE", scopeW)} PATH`
16165
- );
16359
+ human(` ${padRight2("KIND", kindW)} ${padRight2("SCOPE", scopeW)} PATH`, opts);
16166
16360
  for (const k of data.kinds) {
16167
16361
  const pinned = k.filename_pinned ? " (filename pinned)" : "";
16168
- console.log(
16169
- ` ${padRight2(k.kind, kindW)} ${padRight2(k.scope, scopeW)} ${k.example_path}${pinned}`
16362
+ human(
16363
+ ` ${padRight2(k.kind, kindW)} ${padRight2(k.scope, scopeW)} ${k.example_path}${pinned}`,
16364
+ opts
16170
16365
  );
16171
16366
  }
16172
- console.log("");
16173
- console.log(` Filename rule: ${data.filename_regex}`);
16174
- console.log("");
16175
- console.log(" Dimensions (tag freshly-written files with these):");
16367
+ human("", opts);
16368
+ human(` Filename rule: ${data.filename_regex}`, opts);
16369
+ human("", opts);
16370
+ human(" Dimensions (tag freshly-written files with these):", opts);
16176
16371
  const keyW = Math.max(3, ...data.dimensions.map((d) => d.key.length));
16177
16372
  for (const d of data.dimensions) {
16178
- console.log(` ${padRight2(d.key, keyW)} ${d.label} [${d.tags.join(", ")}]`);
16373
+ human(` ${padRight2(d.key, keyW)} ${d.label} [${d.tags.join(", ")}]`, opts);
16179
16374
  }
16180
- console.log("");
16181
- console.log(" Substitute {brand} / {agent} with your workspace slugs, then write");
16182
- console.log(" the file natively and push a branch \u2014 routeWrite merges or queues it.");
16183
- console.log("");
16375
+ human("", opts);
16376
+ human(" Substitute {brand} / {agent} with your workspace slugs, then write", opts);
16377
+ human(" the file natively and push a branch \u2014 routeWrite merges or queues it.", opts);
16378
+ human("", opts);
16184
16379
  }
16185
16380
  async function runKnowledgeSlots(options) {
16186
- const session = await requireSession3();
16381
+ const opts = options;
16382
+ const session = await requireSession3(opts);
16187
16383
  let data;
16188
16384
  try {
16189
16385
  data = await getKnowledgeSlots(session);
16190
16386
  } catch (err) {
16191
- console.error(`bamboo-agents: couldn't load knowledge slots: ${err.message}`);
16192
- process.exit(1);
16193
- }
16194
- if (options.json) {
16195
- console.log(JSON.stringify(data, null, 2));
16387
+ emitError(
16388
+ {
16389
+ code: "knowledge_slots_failed",
16390
+ message: `couldn't load knowledge slots: ${err.message}`
16391
+ },
16392
+ opts,
16393
+ 1
16394
+ );
16196
16395
  return;
16197
16396
  }
16198
- printHuman(data);
16397
+ emitSuccess(data, opts, (d) => printHuman(d, opts));
16199
16398
  }
16200
16399
  async function resolveContent(options) {
16201
16400
  if (options.contentFile) {
@@ -16213,20 +16412,52 @@ async function resolveContent(options) {
16213
16412
  }
16214
16413
  return "";
16215
16414
  }
16415
+ function printSaveResult(result, path2, opts) {
16416
+ switch (result.routed) {
16417
+ case "auto":
16418
+ human(` \u2713 Saved \u2014 auto-merged to main (${path2})`, opts);
16419
+ break;
16420
+ case "queued":
16421
+ case "submitted":
16422
+ human(
16423
+ ` \u2713 Queued for review (${path2})` + (result.pr_url ? `
16424
+ ${result.pr_url}` : ""),
16425
+ opts
16426
+ );
16427
+ break;
16428
+ case "noop":
16429
+ human(` \u2022 Nothing to do${result.reason ? ` (${result.reason})` : ""}.`, opts);
16430
+ break;
16431
+ }
16432
+ }
16216
16433
  async function runKnowledgeSave(options) {
16217
- const session = await requireSession3();
16434
+ const opts = options;
16435
+ const session = await requireSession3(opts);
16218
16436
  if (!options.path) {
16219
- console.error("bamboo-agents: knowledge save requires --path.");
16220
- console.error("Tip: run `bamboo-agents knowledge slots` to find the right path.");
16221
- process.exit(1);
16437
+ emitError(
16438
+ {
16439
+ code: "missing_path",
16440
+ message: "knowledge save requires --path.",
16441
+ hint: "Run `bamboo-agents knowledge slots` to find the right path."
16442
+ },
16443
+ opts,
16444
+ 1
16445
+ );
16446
+ return;
16222
16447
  }
16223
16448
  const isDelete = options.delete === true;
16224
16449
  const content = isDelete ? "" : await resolveContent(options);
16225
16450
  if (!isDelete && content.length === 0) {
16226
- console.error(
16227
- "bamboo-agents: no content. Pass --content, --content-file <path>, or pipe via stdin."
16451
+ emitError(
16452
+ {
16453
+ code: "missing_content",
16454
+ message: "no content.",
16455
+ hint: "Pass --content, --content-file <path>, or pipe via stdin."
16456
+ },
16457
+ opts,
16458
+ 1
16228
16459
  );
16229
- process.exit(1);
16460
+ return;
16230
16461
  }
16231
16462
  let result;
16232
16463
  try {
@@ -16237,37 +16468,33 @@ async function runKnowledgeSave(options) {
16237
16468
  intent: options.intent
16238
16469
  });
16239
16470
  } catch (err) {
16240
- console.error(`bamboo-agents: save failed: ${err.message}`);
16241
- process.exit(1);
16242
- }
16243
- if (options.json) {
16244
- console.log(JSON.stringify(result, null, 2));
16471
+ emitError(
16472
+ { code: "save_failed", message: `save failed: ${err.message}` },
16473
+ opts,
16474
+ 1
16475
+ );
16245
16476
  return;
16246
16477
  }
16247
- switch (result.routed) {
16248
- case "auto":
16249
- console.log(` \u2713 Saved \u2014 auto-merged to main (${options.path})`);
16250
- break;
16251
- case "queued":
16252
- case "submitted":
16253
- console.log(
16254
- ` \u2713 Queued for review (${options.path})` + (result.pr_url ? `
16255
- ${result.pr_url}` : "")
16256
- );
16257
- break;
16258
- case "noop":
16259
- console.log(` \u2022 Nothing to do${result.reason ? ` (${result.reason})` : ""}.`);
16260
- break;
16261
- case "rejected":
16262
- console.error(` \u2717 Rejected${result.reason ? `: ${result.reason}` : ""}.`);
16263
- process.exit(1);
16478
+ if (result.routed === "rejected") {
16479
+ emitError(
16480
+ {
16481
+ code: "rejected",
16482
+ message: `save rejected${result.reason ? `: ${result.reason}` : "."}`,
16483
+ hint: "Check the path scope and your permissions."
16484
+ },
16485
+ opts,
16486
+ 1
16487
+ );
16488
+ return;
16264
16489
  }
16490
+ emitSuccess(result, opts, (r) => printSaveResult(r, options.path, opts));
16265
16491
  }
16266
16492
  var init_knowledge = __esm({
16267
16493
  "src/commands/knowledge.ts"() {
16268
16494
  "use strict";
16269
16495
  init_credentials();
16270
16496
  init_api();
16497
+ init_output();
16271
16498
  }
16272
16499
  });
16273
16500
 
@@ -16277,11 +16504,19 @@ __export(history_exports2, {
16277
16504
  runChanges: () => runChanges,
16278
16505
  runHistory: () => runHistory
16279
16506
  });
16280
- async function requireSession4() {
16507
+ async function requireSession4(opts) {
16281
16508
  const creds = await readCredentials();
16282
16509
  if (!creds) {
16283
- console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
16284
- process.exit(1);
16510
+ emitError(
16511
+ {
16512
+ code: "not_signed_in",
16513
+ message: "not signed in.",
16514
+ hint: "Run `bamboo-agents login` first."
16515
+ },
16516
+ opts,
16517
+ 1
16518
+ );
16519
+ throw new Error("unreachable");
16285
16520
  }
16286
16521
  return creds.bamboo_session;
16287
16522
  }
@@ -16293,48 +16528,51 @@ function parseLimit(raw) {
16293
16528
  function padRight3(s, n) {
16294
16529
  return s.length >= n ? s : s + " ".repeat(n - s.length);
16295
16530
  }
16296
- function printHistory(data) {
16531
+ function printHistory(data, opts) {
16297
16532
  if (data.entries.length === 0) {
16298
- console.log(" No recent actions.");
16533
+ human(" No recent actions.", opts);
16299
16534
  return;
16300
16535
  }
16301
16536
  const nameW = Math.max(4, ...data.entries.map((e) => (e.tool_name ?? "\u2014").length));
16302
16537
  for (const e of data.entries) {
16303
16538
  const dur = e.duration_ms != null ? `${e.duration_ms}ms` : "";
16304
- console.log(
16305
- ` ${padRight3(e.tool_name ?? "\u2014", nameW)} ${padRight3(e.status, 10)} ${e.timestamp} ${dur}`
16539
+ human(
16540
+ ` ${padRight3(e.tool_name ?? "\u2014", nameW)} ${padRight3(e.status, 10)} ${e.timestamp} ${dur}`,
16541
+ opts
16306
16542
  );
16307
16543
  }
16308
- console.log(` ${data.count} action${data.count === 1 ? "" : "s"}.`);
16544
+ human(` ${data.count} action${data.count === 1 ? "" : "s"}.`, opts);
16309
16545
  }
16310
16546
  async function runHistory(options) {
16311
- const session = await requireSession4();
16547
+ const opts = options;
16548
+ const session = await requireSession4(opts);
16312
16549
  let data;
16313
16550
  try {
16314
16551
  data = await getHistory(session, { limit: parseLimit(options.limit) });
16315
16552
  } catch (err) {
16316
- console.error(`bamboo-agents: couldn't load history: ${err.message}`);
16317
- process.exit(1);
16318
- }
16319
- if (options.json) {
16320
- console.log(JSON.stringify(data, null, 2));
16553
+ emitError(
16554
+ { code: "history_failed", message: `couldn't load history: ${err.message}` },
16555
+ opts,
16556
+ 1
16557
+ );
16321
16558
  return;
16322
16559
  }
16323
- printHistory(data);
16560
+ emitSuccess(data, opts, (d) => printHistory(d, opts));
16324
16561
  }
16325
- function printChanges(data) {
16562
+ function printChanges(data, opts) {
16326
16563
  if (data.entries.length === 0) {
16327
- console.log(" No changes.");
16564
+ human(" No changes.", opts);
16328
16565
  return;
16329
16566
  }
16330
16567
  for (const e of data.entries) {
16331
16568
  const what = [e.action, e.entity_type, e.entity_name].filter(Boolean).join(" ");
16332
- console.log(` ${e.timestamp} ${what || e.tool_name || "\u2014"}`);
16569
+ human(` ${e.timestamp} ${what || e.tool_name || "\u2014"}`, opts);
16333
16570
  }
16334
- console.log(` ${data.count} change${data.count === 1 ? "" : "s"}.`);
16571
+ human(` ${data.count} change${data.count === 1 ? "" : "s"}.`, opts);
16335
16572
  }
16336
16573
  async function runChanges(options) {
16337
- const session = await requireSession4();
16574
+ const opts = options;
16575
+ const session = await requireSession4(opts);
16338
16576
  let data;
16339
16577
  try {
16340
16578
  data = await getChanges(session, {
@@ -16344,20 +16582,21 @@ async function runChanges(options) {
16344
16582
  entityType: options.entityType
16345
16583
  });
16346
16584
  } catch (err) {
16347
- console.error(`bamboo-agents: couldn't load changes: ${err.message}`);
16348
- process.exit(1);
16349
- }
16350
- if (options.json) {
16351
- console.log(JSON.stringify(data, null, 2));
16585
+ emitError(
16586
+ { code: "changes_failed", message: `couldn't load changes: ${err.message}` },
16587
+ opts,
16588
+ 1
16589
+ );
16352
16590
  return;
16353
16591
  }
16354
- printChanges(data);
16592
+ emitSuccess(data, opts, (d) => printChanges(d, opts));
16355
16593
  }
16356
16594
  var init_history2 = __esm({
16357
16595
  "src/commands/history.ts"() {
16358
16596
  "use strict";
16359
16597
  init_credentials();
16360
16598
  init_api();
16599
+ init_output();
16361
16600
  }
16362
16601
  });
16363
16602
 
@@ -16366,42 +16605,62 @@ var context_exports = {};
16366
16605
  __export(context_exports, {
16367
16606
  runContextHealth: () => runContextHealth
16368
16607
  });
16369
- async function requireSession5() {
16608
+ async function requireSession5(opts) {
16370
16609
  const creds = await readCredentials();
16371
16610
  if (!creds) {
16372
- console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
16373
- process.exit(1);
16611
+ emitError(
16612
+ {
16613
+ code: "not_signed_in",
16614
+ message: "not signed in.",
16615
+ hint: "Run `bamboo-agents login` first."
16616
+ },
16617
+ opts,
16618
+ 1
16619
+ );
16620
+ throw new Error("unreachable");
16374
16621
  }
16375
16622
  return creds.bamboo_session;
16376
16623
  }
16377
16624
  function gradeSymbol(grade) {
16378
16625
  return grade === "A" ? "\u2713" : grade === "B" || grade === "C" ? "\u2022" : "\u2717";
16379
16626
  }
16380
- function printHealth(data) {
16627
+ function printHealth(data, opts) {
16381
16628
  const { grade, score, gaps, bucketScores, scope } = data;
16382
16629
  const scopeLabel = scope.kind === "agent" ? `agent (${scope.agentId ?? "\u2014"})` : scope.kind === "brand" ? `brand (${scope.brandId ?? "\u2014"})` : "org";
16383
- console.log("");
16384
- console.log(
16385
- ` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`
16630
+ human("", opts);
16631
+ human(
16632
+ ` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`,
16633
+ opts
16386
16634
  );
16387
16635
  const fmtBucket = (label, v) => ` ${label.padEnd(12)} ${v != null ? `${Math.round(v)}/100` : "n/a"}`;
16388
- console.log(fmtBucket("inherited:", bucketScores.inherited));
16389
- console.log(fmtBucket("structural:", bucketScores.structural));
16390
- console.log(fmtBucket("job_spec:", bucketScores.job_spec));
16391
- console.log("");
16636
+ human(fmtBucket("inherited:", bucketScores.inherited), opts);
16637
+ human(fmtBucket("structural:", bucketScores.structural), opts);
16638
+ human(fmtBucket("job_spec:", bucketScores.job_spec), opts);
16639
+ human("", opts);
16392
16640
  if (gaps.empty.length > 0) {
16393
- console.log(` Missing (empty): ${gaps.empty.join(", ")}`);
16641
+ human(` Missing (empty): ${gaps.empty.join(", ")}`, opts);
16394
16642
  }
16395
16643
  if (gaps.basic.length > 0) {
16396
- console.log(` Sparse (basic): ${gaps.basic.join(", ")}`);
16644
+ human(` Sparse (basic): ${gaps.basic.join(", ")}`, opts);
16397
16645
  }
16398
16646
  if (gaps.empty.length === 0 && gaps.basic.length === 0) {
16399
- console.log(" No gaps \u2014 all criteria at good or deep.");
16647
+ human(" No gaps \u2014 all criteria at good or deep.", opts);
16400
16648
  }
16401
- console.log("");
16649
+ human("", opts);
16650
+ }
16651
+ function printHealthResponse(data, opts) {
16652
+ if (!data.available) {
16653
+ human("", opts);
16654
+ human(" Context health is unavailable right now.", opts);
16655
+ human(` (${data.reason})`, opts);
16656
+ human("", opts);
16657
+ return;
16658
+ }
16659
+ printHealth(data, opts);
16402
16660
  }
16403
16661
  async function runContextHealth(options) {
16404
- const session = await requireSession5();
16662
+ const opts = options;
16663
+ const session = await requireSession5(opts);
16405
16664
  let data;
16406
16665
  try {
16407
16666
  data = await getContextHealth(session, {
@@ -16409,27 +16668,24 @@ async function runContextHealth(options) {
16409
16668
  agentId: options.agent
16410
16669
  });
16411
16670
  } catch (err) {
16412
- console.error(`bamboo-agents: couldn't load context health: ${err.message}`);
16413
- process.exit(1);
16414
- }
16415
- if (options.json) {
16416
- console.log(JSON.stringify(data, null, 2));
16417
- return;
16418
- }
16419
- if (!data.available) {
16420
- console.log("");
16421
- console.log(" Context health is unavailable right now.");
16422
- console.log(` (${data.reason})`);
16423
- console.log("");
16671
+ emitError(
16672
+ {
16673
+ code: "context_health_failed",
16674
+ message: `couldn't load context health: ${err.message}`
16675
+ },
16676
+ opts,
16677
+ 1
16678
+ );
16424
16679
  return;
16425
16680
  }
16426
- printHealth(data);
16681
+ emitSuccess(data, opts, (d) => printHealthResponse(d, opts));
16427
16682
  }
16428
16683
  var init_context = __esm({
16429
16684
  "src/commands/context.ts"() {
16430
16685
  "use strict";
16431
16686
  init_credentials();
16432
16687
  init_api();
16688
+ init_output();
16433
16689
  }
16434
16690
  });
16435
16691
 
@@ -16438,44 +16694,58 @@ var onboarding_exports = {};
16438
16694
  __export(onboarding_exports, {
16439
16695
  runOnboardingStatus: () => runOnboardingStatus
16440
16696
  });
16441
- async function requireSession6() {
16697
+ async function requireSession6(opts) {
16442
16698
  const creds = await readCredentials();
16443
16699
  if (!creds) {
16444
- console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
16445
- process.exit(1);
16700
+ emitError(
16701
+ {
16702
+ code: "not_signed_in",
16703
+ message: "not signed in.",
16704
+ hint: "Run `bamboo-agents login` first."
16705
+ },
16706
+ opts,
16707
+ 1
16708
+ );
16709
+ throw new Error("unreachable");
16446
16710
  }
16447
16711
  return creds.bamboo_session;
16448
16712
  }
16449
- function printStatus(data) {
16713
+ function printStatus(data, opts) {
16450
16714
  const g = data.composite_gate;
16451
- console.log("");
16452
- console.log(` Onboarding: ${g.passed ? "\u2713 complete" : "\u2022 in progress"}`);
16453
- console.log(
16454
- ` knowledge: ${g.knowledge_ok ? "ok" : "needs work"} (grade ${data.health.grade ?? "\u2014"}, score ${data.health.score ?? "\u2014"})`
16715
+ human("", opts);
16716
+ human(` Onboarding: ${g.passed ? "\u2713 complete" : "\u2022 in progress"}`, opts);
16717
+ human(
16718
+ ` knowledge: ${g.knowledge_ok ? "ok" : "needs work"} (grade ${data.health.grade ?? "\u2014"}, score ${data.health.score ?? "\u2014"})`,
16719
+ opts
16455
16720
  );
16456
- console.log(` activation: ${g.activation_ok ? "ok" : "incomplete"}`);
16457
- console.log("");
16721
+ human(` activation: ${g.activation_ok ? "ok" : "incomplete"}`, opts);
16722
+ human("", opts);
16458
16723
  }
16459
16724
  async function runOnboardingStatus(options) {
16460
- const session = await requireSession6();
16725
+ const opts = options;
16726
+ const session = await requireSession6(opts);
16461
16727
  let data;
16462
16728
  try {
16463
16729
  data = await getOnboardingStatus(session, { brandId: options.brand });
16464
16730
  } catch (err) {
16465
- console.error(`bamboo-agents: couldn't load onboarding status: ${err.message}`);
16466
- process.exit(1);
16467
- }
16468
- if (options.json) {
16469
- console.log(JSON.stringify(data, null, 2));
16731
+ emitError(
16732
+ {
16733
+ code: "onboarding_status_failed",
16734
+ message: `couldn't load onboarding status: ${err.message}`
16735
+ },
16736
+ opts,
16737
+ 1
16738
+ );
16470
16739
  return;
16471
16740
  }
16472
- printStatus(data);
16741
+ emitSuccess(data, opts, (d) => printStatus(d, opts));
16473
16742
  }
16474
16743
  var init_onboarding = __esm({
16475
16744
  "src/commands/onboarding.ts"() {
16476
16745
  "use strict";
16477
16746
  init_credentials();
16478
16747
  init_api();
16748
+ init_output();
16479
16749
  }
16480
16750
  });
16481
16751
 
@@ -16500,6 +16770,35 @@ var {
16500
16770
  init_version();
16501
16771
 
16502
16772
  // src/lib/describe.ts
16773
+ var ENVELOPE = {
16774
+ success: {
16775
+ type: "object",
16776
+ properties: {
16777
+ ok: { const: true },
16778
+ data: {
16779
+ description: "The command's payload \u2014 its shape is the per-command `output_schema`."
16780
+ }
16781
+ },
16782
+ required: ["ok", "data"]
16783
+ },
16784
+ error: {
16785
+ type: "object",
16786
+ properties: {
16787
+ ok: { const: false },
16788
+ error: {
16789
+ type: "object",
16790
+ properties: {
16791
+ code: { type: "string" },
16792
+ message: { type: "string" },
16793
+ hint: { type: "string" }
16794
+ },
16795
+ required: ["code", "message"]
16796
+ }
16797
+ },
16798
+ required: ["ok", "error"]
16799
+ },
16800
+ note: "Every --json (or piped) response is wrapped in this envelope. On success, `data` matches the command's `output_schema`. On failure, `error.code` is a stable string an agent can branch on. stdout carries only the envelope; human/diagnostic text goes to stderr."
16801
+ };
16503
16802
  function zodToJsonSchema(schema) {
16504
16803
  const s = schema;
16505
16804
  const typeName = s?._def?.typeName ?? "";
@@ -16630,9 +16929,10 @@ async function buildManifest(program3, cliVersion) {
16630
16929
  output_schema: outputSchemas.get(fullName) ?? null
16631
16930
  }));
16632
16931
  return {
16633
- version: 1,
16932
+ version: 2,
16634
16933
  cli: program3.name(),
16635
16934
  cli_version: cliVersion,
16935
+ envelope: ENVELOPE,
16636
16936
  commands
16637
16937
  };
16638
16938
  }
@@ -16674,21 +16974,23 @@ program2.command("open").description("Launch Claude Code at your workspace").opt
16674
16974
  const { runOpen: runOpen2 } = await Promise.resolve().then(() => (init_open2(), open_exports));
16675
16975
  await runOpen2();
16676
16976
  });
16677
- program2.command("status").description("Show current Bamboo CLI state").option("--no-sync", "Skip the auto-sync git pull on this command").action(async () => {
16977
+ program2.command("status").description("Show current Bamboo CLI state").option("--no-sync", "Skip the auto-sync git pull on this command").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)").action(async (options) => {
16678
16978
  const { runStatus: runStatus2 } = await Promise.resolve().then(() => (init_status(), status_exports));
16679
- await runStatus2();
16979
+ await runStatus2(options);
16680
16980
  });
16681
16981
  program2.command("doctor").description("Verify your local setup is ready + heal workspace drift").option("--quiet", "Emit JSON without prompting (CI / scripts)").option("--auto-heal", "Apply non-destructive fixes silently").action(async (options) => {
16682
16982
  const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
16683
16983
  await runDoctor2({ quiet: options.quiet, autoHeal: options.autoHeal });
16684
16984
  });
16685
- program2.command("save [intent]").description("Save your workspace changes (routed write \u2014 auto-merges or queues)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (intent) => {
16686
- const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
16687
- await runSave2(intent);
16688
- });
16689
- program2.command("update").alias("sync").description("Update your workspace from the cloud (saves unsaved edits first, then pulls)").action(async () => {
16985
+ program2.command("save [intent]").description("Save your workspace changes (routed write \u2014 auto-merges or queues)").option("--no-sync", "Skip the auto-sync git pull on this command").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)").action(
16986
+ async (intent, options) => {
16987
+ const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
16988
+ await runSave2(intent, options);
16989
+ }
16990
+ );
16991
+ program2.command("update").alias("sync").description("Update your workspace from the cloud (saves unsaved edits first, then pulls)").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)").action(async (options) => {
16690
16992
  const { runUpdate: runUpdate2 } = await Promise.resolve().then(() => (init_update(), update_exports));
16691
- await runUpdate2();
16993
+ await runUpdate2(options);
16692
16994
  });
16693
16995
  var skills = program2.command("skills").description("Read workspace skills from your local clone");
16694
16996
  skills.command("list").description("List every skill in the workspace").option(
@@ -16721,31 +17023,31 @@ skills.command("update <agent> <skill-name>").description("Update an installed s
16721
17023
  await runSkillsUpdate2(agent, skillName);
16722
17024
  });
16723
17025
  var knowledge = program2.command("knowledge").description("Knowledge surface for CLI-first skills");
16724
- knowledge.command("slots").description("Print the knowledge slot schema (kind \xD7 scope \u2192 path) + dimensions").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
17026
+ 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) => {
16725
17027
  const { runKnowledgeSlots: runKnowledgeSlots2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
16726
17028
  await runKnowledgeSlots2(options);
16727
17029
  });
16728
- knowledge.command("save").description("Save a knowledge file (routed write \u2014 auto-merges or queues)").requiredOption("--path <path>", "Repo path (from `knowledge slots`), e.g. brands/acme/knowledge/competitors.md").option("--content <text>", "Inline file content").option("--content-file <file>", "Read file content from a local path").option("--delete", "Delete the file instead of writing content").option("--intent <text>", "Human-readable summary for the PR body").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
17030
+ knowledge.command("save").description("Save a knowledge file (routed write \u2014 auto-merges or queues)").requiredOption("--path <path>", "Repo path (from `knowledge slots`), e.g. brands/acme/knowledge/competitors.md").option("--content <text>", "Inline file content").option("--content-file <file>", "Read file content from a local path").option("--delete", "Delete the file instead of writing content").option("--intent <text>", "Human-readable summary for the PR body").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) => {
16729
17031
  const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
16730
17032
  await runKnowledgeSave2(options);
16731
17033
  });
16732
- program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
17034
+ 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) => {
16733
17035
  const { runHistory: runHistory2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
16734
17036
  await runHistory2(options);
16735
17037
  });
16736
- program2.command("changes").description("Structured change log \u2014 what was created/updated/deleted").option("--limit <n>", "Max entries (default 20, max 100)").option("--brand <id>", "Filter to one brand_id").option("--since <iso>", "Only changes at/after this ISO timestamp").option("--entity-type <type>", "Filter by entity type").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(
17038
+ program2.command("changes").description("Structured change log \u2014 what was created/updated/deleted").option("--limit <n>", "Max entries (default 20, max 100)").option("--brand <id>", "Filter to one brand_id").option("--since <iso>", "Only changes at/after this ISO timestamp").option("--entity-type <type>", "Filter by entity type").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(
16737
17039
  async (options) => {
16738
17040
  const { runChanges: runChanges2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
16739
17041
  await runChanges2(options);
16740
17042
  }
16741
17043
  );
16742
17044
  var context = program2.command("context").description("Context health for CLI-first skills");
16743
- context.command("health").description("Knowledge/context health \u2014 grade, score, and gaps").option("--brand <id>", "Scope to a brand_id (default: org)").option("--agent <id>", "Scope to an agent_id").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
17045
+ context.command("health").description("Knowledge/context health \u2014 grade, score, and gaps").option("--brand <id>", "Scope to a brand_id (default: org)").option("--agent <id>", "Scope to an agent_id").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) => {
16744
17046
  const { runContextHealth: runContextHealth2 } = await Promise.resolve().then(() => (init_context(), context_exports));
16745
17047
  await runContextHealth2(options);
16746
17048
  });
16747
17049
  var onboarding = program2.command("onboarding").description("Onboarding status for CLI-first skills");
16748
- onboarding.command("status").description("Composite onboarding gate (activation milestones + knowledge health)").option("--brand <id>", "Scope to a brand_id (default: org)").option("--json", "Emit raw JSON for agent consumption").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
17050
+ onboarding.command("status").description("Composite onboarding gate (activation milestones + knowledge health)").option("--brand <id>", "Scope to a brand_id (default: org)").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) => {
16749
17051
  const { runOnboardingStatus: runOnboardingStatus2 } = await Promise.resolve().then(() => (init_onboarding(), onboarding_exports));
16750
17052
  await runOnboardingStatus2(options);
16751
17053
  });