bamboo-agents 0.1.5-dev.42.12bcb59 → 0.1.5-dev.43.f469566

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.42.12bcb59
1
+ 0.1.5-dev.43.f469566
package/dist/index.js CHANGED
@@ -2823,16 +2823,16 @@ Expecting one of '${allowedValues.join("', '")}'`);
2823
2823
  */
2824
2824
  _getHelpContext(contextOptions) {
2825
2825
  contextOptions = contextOptions || {};
2826
- const context = { error: !!contextOptions.error };
2826
+ const context2 = { error: !!contextOptions.error };
2827
2827
  let write;
2828
- if (context.error) {
2828
+ if (context2.error) {
2829
2829
  write = (arg) => this._outputConfiguration.writeErr(arg);
2830
2830
  } else {
2831
2831
  write = (arg) => this._outputConfiguration.writeOut(arg);
2832
2832
  }
2833
- context.write = contextOptions.write || write;
2834
- context.command = this;
2835
- return context;
2833
+ context2.write = contextOptions.write || write;
2834
+ context2.command = this;
2835
+ return context2;
2836
2836
  }
2837
2837
  /**
2838
2838
  * Output help information for this command.
@@ -2847,23 +2847,23 @@ Expecting one of '${allowedValues.join("', '")}'`);
2847
2847
  deprecatedCallback = contextOptions;
2848
2848
  contextOptions = void 0;
2849
2849
  }
2850
- const context = this._getHelpContext(contextOptions);
2851
- this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context));
2852
- this.emit("beforeHelp", context);
2853
- let helpInformation = this.helpInformation(context);
2850
+ const context2 = this._getHelpContext(contextOptions);
2851
+ this._getCommandAndAncestors().reverse().forEach((command) => command.emit("beforeAllHelp", context2));
2852
+ this.emit("beforeHelp", context2);
2853
+ let helpInformation = this.helpInformation(context2);
2854
2854
  if (deprecatedCallback) {
2855
2855
  helpInformation = deprecatedCallback(helpInformation);
2856
2856
  if (typeof helpInformation !== "string" && !Buffer.isBuffer(helpInformation)) {
2857
2857
  throw new Error("outputHelp callback must return a string or a Buffer");
2858
2858
  }
2859
2859
  }
2860
- context.write(helpInformation);
2860
+ context2.write(helpInformation);
2861
2861
  if (this._getHelpOption()?.long) {
2862
2862
  this.emit(this._getHelpOption().long);
2863
2863
  }
2864
- this.emit("afterHelp", context);
2864
+ this.emit("afterHelp", context2);
2865
2865
  this._getCommandAndAncestors().forEach(
2866
- (command) => command.emit("afterAllHelp", context)
2866
+ (command) => command.emit("afterAllHelp", context2)
2867
2867
  );
2868
2868
  }
2869
2869
  /**
@@ -2948,15 +2948,15 @@ Expecting one of '${allowedValues.join("', '")}'`);
2948
2948
  Expecting one of '${allowedValues.join("', '")}'`);
2949
2949
  }
2950
2950
  const helpEvent = `${position}Help`;
2951
- this.on(helpEvent, (context) => {
2951
+ this.on(helpEvent, (context2) => {
2952
2952
  let helpStr;
2953
2953
  if (typeof text === "function") {
2954
- helpStr = text({ error: context.error, command: context.command });
2954
+ helpStr = text({ error: context2.error, command: context2.command });
2955
2955
  } else {
2956
2956
  helpStr = text;
2957
2957
  }
2958
2958
  if (helpStr) {
2959
- context.write(`${helpStr}
2959
+ context2.write(`${helpStr}
2960
2960
  `);
2961
2961
  }
2962
2962
  });
@@ -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.42.12bcb59";
3040
+ VERSION = "0.1.5-dev.43.f469566";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -12109,6 +12109,73 @@ var init_onboarding_status = __esm({
12109
12109
  }
12110
12110
  });
12111
12111
 
12112
+ // ../../src/lib/api-contracts/cli/context-health.ts
12113
+ var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, ContextHealthResponseSchema;
12114
+ var init_context_health = __esm({
12115
+ "../../src/lib/api-contracts/cli/context-health.ts"() {
12116
+ init_zod();
12117
+ ScopeKindSchema = external_exports.enum(["org", "brand", "agent"]);
12118
+ ScopeSchema = external_exports.object({
12119
+ kind: ScopeKindSchema,
12120
+ brandId: external_exports.string().nullish(),
12121
+ agentId: external_exports.string().nullish()
12122
+ });
12123
+ CriterionMetricsSchema = external_exports.object({
12124
+ rowCount: external_exports.number(),
12125
+ totalWords: external_exports.number(),
12126
+ hasRecent: external_exports.boolean()
12127
+ });
12128
+ StatusSchema = external_exports.enum(["empty", "basic", "good", "deep"]);
12129
+ CriterionContributionSchema = external_exports.object({
12130
+ repo_path: external_exports.string().nullable(),
12131
+ points: external_exports.number(),
12132
+ row_id: external_exports.string()
12133
+ });
12134
+ CriterionResultSchema = external_exports.object({
12135
+ key: external_exports.string(),
12136
+ status: StatusSchema,
12137
+ score: external_exports.number(),
12138
+ metrics: CriterionMetricsSchema,
12139
+ inheritedFrom: ScopeKindSchema.optional(),
12140
+ contributions: external_exports.array(CriterionContributionSchema),
12141
+ /** BAM-2445: category enrichment added by the tool layer. */
12142
+ category: external_exports.enum(["content", "hygiene"]).optional()
12143
+ });
12144
+ BucketScoresSchema = external_exports.object({
12145
+ inherited: external_exports.number().nullable(),
12146
+ structural: external_exports.number().nullable(),
12147
+ job_spec: external_exports.number().nullable()
12148
+ });
12149
+ ResolvedScopeSchema = external_exports.object({
12150
+ orgId: external_exports.string(),
12151
+ orgName: external_exports.string(),
12152
+ brandId: external_exports.string().optional(),
12153
+ brandName: external_exports.string().optional(),
12154
+ brandSlug: external_exports.string().optional(),
12155
+ agentId: external_exports.string().optional(),
12156
+ agentName: external_exports.string().optional(),
12157
+ agentSlug: external_exports.string().optional()
12158
+ });
12159
+ GapsSchema = external_exports.object({
12160
+ /** Criterion keys that are still in "empty" status (most urgent). */
12161
+ empty: external_exports.array(external_exports.string()),
12162
+ /** Criterion keys that are at "basic" status (partially filled). */
12163
+ basic: external_exports.array(external_exports.string())
12164
+ });
12165
+ ContextHealthResponseSchema = external_exports.object({
12166
+ scope: ScopeSchema,
12167
+ grade: external_exports.enum(["A", "B", "C", "D", "F"]),
12168
+ score: external_exports.number(),
12169
+ bucketScores: BucketScoresSchema,
12170
+ results: external_exports.array(CriterionResultSchema),
12171
+ resolvedScope: ResolvedScopeSchema.nullable(),
12172
+ /** Derived gap summary — pre-computed from `results` so CLI consumers
12173
+ * don't need to iterate the full results array. */
12174
+ gaps: GapsSchema
12175
+ });
12176
+ }
12177
+ });
12178
+
12112
12179
  // src/lib/api.ts
12113
12180
  import { platform as platform2 } from "node:os";
12114
12181
  function defaultApiBase(version) {
@@ -12213,6 +12280,16 @@ async function getChanges(bambooSession, opts = {}) {
12213
12280
  if (!res.ok) throw await parseError(res);
12214
12281
  return ChangesResponseSchema.parse(await res.json());
12215
12282
  }
12283
+ async function getContextHealth(bambooSession, opts = {}) {
12284
+ const url = new URL(`${apiBase()}/api/v1/cli/context/health`);
12285
+ if (opts.brandId) url.searchParams.set("brand_id", opts.brandId);
12286
+ if (opts.agentId) url.searchParams.set("agent_id", opts.agentId);
12287
+ const res = await cliApiFetch(url.toString(), {
12288
+ headers: { Authorization: `Bearer ${bambooSession}` }
12289
+ });
12290
+ if (!res.ok) throw await parseError(res);
12291
+ return ContextHealthResponseSchema.parse(await res.json());
12292
+ }
12216
12293
  async function getOnboardingStatus(bambooSession, opts = {}) {
12217
12294
  const url = new URL(`${apiBase()}/api/v1/cli/onboarding/status`);
12218
12295
  if (opts.brandId) url.searchParams.set("brand_id", opts.brandId);
@@ -12416,6 +12493,7 @@ var init_api = __esm({
12416
12493
  init_history();
12417
12494
  init_changes();
12418
12495
  init_onboarding_status();
12496
+ init_context_health();
12419
12497
  init_version();
12420
12498
  PROD_DEFAULT_BASE = "https://withbamboo.com";
12421
12499
  DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
@@ -15899,12 +15977,77 @@ var init_history2 = __esm({
15899
15977
  }
15900
15978
  });
15901
15979
 
15980
+ // src/commands/context.ts
15981
+ var context_exports = {};
15982
+ __export(context_exports, {
15983
+ runContextHealth: () => runContextHealth
15984
+ });
15985
+ async function requireSession4() {
15986
+ const creds = await readCredentials();
15987
+ if (!creds) {
15988
+ console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
15989
+ process.exit(1);
15990
+ }
15991
+ return creds.bamboo_session;
15992
+ }
15993
+ function gradeSymbol(grade) {
15994
+ return grade === "A" ? "\u2713" : grade === "B" || grade === "C" ? "\u2022" : "\u2717";
15995
+ }
15996
+ function printHealth(data) {
15997
+ const { grade, score, gaps, bucketScores, scope } = data;
15998
+ const scopeLabel = scope.kind === "agent" ? `agent (${scope.agentId ?? "\u2014"})` : scope.kind === "brand" ? `brand (${scope.brandId ?? "\u2014"})` : "org";
15999
+ console.log("");
16000
+ console.log(
16001
+ ` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`
16002
+ );
16003
+ const fmtBucket = (label, v) => ` ${label.padEnd(12)} ${v != null ? `${Math.round(v)}/100` : "n/a"}`;
16004
+ console.log(fmtBucket("inherited:", bucketScores.inherited));
16005
+ console.log(fmtBucket("structural:", bucketScores.structural));
16006
+ console.log(fmtBucket("job_spec:", bucketScores.job_spec));
16007
+ console.log("");
16008
+ if (gaps.empty.length > 0) {
16009
+ console.log(` Missing (empty): ${gaps.empty.join(", ")}`);
16010
+ }
16011
+ if (gaps.basic.length > 0) {
16012
+ console.log(` Sparse (basic): ${gaps.basic.join(", ")}`);
16013
+ }
16014
+ if (gaps.empty.length === 0 && gaps.basic.length === 0) {
16015
+ console.log(" No gaps \u2014 all criteria at good or deep.");
16016
+ }
16017
+ console.log("");
16018
+ }
16019
+ async function runContextHealth(options) {
16020
+ const session = await requireSession4();
16021
+ let data;
16022
+ try {
16023
+ data = await getContextHealth(session, {
16024
+ brandId: options.brand,
16025
+ agentId: options.agent
16026
+ });
16027
+ } catch (err) {
16028
+ console.error(`bamboo-agents: couldn't load context health: ${err.message}`);
16029
+ process.exit(1);
16030
+ }
16031
+ if (options.json) {
16032
+ console.log(JSON.stringify(data, null, 2));
16033
+ return;
16034
+ }
16035
+ printHealth(data);
16036
+ }
16037
+ var init_context = __esm({
16038
+ "src/commands/context.ts"() {
16039
+ "use strict";
16040
+ init_credentials();
16041
+ init_api();
16042
+ }
16043
+ });
16044
+
15902
16045
  // src/commands/onboarding.ts
15903
16046
  var onboarding_exports = {};
15904
16047
  __export(onboarding_exports, {
15905
16048
  runOnboardingStatus: () => runOnboardingStatus
15906
16049
  });
15907
- async function requireSession4() {
16050
+ async function requireSession5() {
15908
16051
  const creds = await readCredentials();
15909
16052
  if (!creds) {
15910
16053
  console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
@@ -15923,7 +16066,7 @@ function printStatus(data) {
15923
16066
  console.log("");
15924
16067
  }
15925
16068
  async function runOnboardingStatus(options) {
15926
- const session = await requireSession4();
16069
+ const session = await requireSession5();
15927
16070
  let data;
15928
16071
  try {
15929
16072
  data = await getOnboardingStatus(session, { brandId: options.brand });
@@ -16050,6 +16193,11 @@ program2.command("changes").description("Structured change log \u2014 what was c
16050
16193
  await runChanges2(options);
16051
16194
  }
16052
16195
  );
16196
+ var context = program2.command("context").description("Context health for CLI-first skills");
16197
+ 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) => {
16198
+ const { runContextHealth: runContextHealth2 } = await Promise.resolve().then(() => (init_context(), context_exports));
16199
+ await runContextHealth2(options);
16200
+ });
16053
16201
  var onboarding = program2.command("onboarding").description("Onboarding status for CLI-first skills");
16054
16202
  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) => {
16055
16203
  const { runOnboardingStatus: runOnboardingStatus2 } = await Promise.resolve().then(() => (init_onboarding(), onboarding_exports));