bamboo-agents 0.1.5-dev.49.eaaa602 → 0.1.5-dev.50.88138ae

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.49.eaaa602
1
+ 0.1.5-dev.50.88138ae
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.49.eaaa602";
3040
+ VERSION = "0.1.5-dev.50.88138ae";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -7243,6 +7243,75 @@ var init_knowledge_slots = __esm({
7243
7243
  }
7244
7244
  });
7245
7245
 
7246
+ // ../../src/lib/api-contracts/cli/save.ts
7247
+ function isSafeRepoPath(path2) {
7248
+ if (!path2 || path2.length > 512) return false;
7249
+ if (path2.startsWith("/") || path2.startsWith("~")) return false;
7250
+ if (path2.includes("\\")) return false;
7251
+ for (let i = 0; i < path2.length; i++) {
7252
+ if (path2.charCodeAt(i) < 32) return false;
7253
+ }
7254
+ if (path2.split("/").includes("..")) return false;
7255
+ return true;
7256
+ }
7257
+ var SaveEditSchema, SaveBatchRequestSchema, SaveFileResultSchema, SaveBatchResponseSchema;
7258
+ var init_save = __esm({
7259
+ "../../src/lib/api-contracts/cli/save.ts"() {
7260
+ init_zod();
7261
+ SaveEditSchema = external_exports.object({
7262
+ /** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. */
7263
+ path: external_exports.string().min(1).max(512),
7264
+ /** UTF-8 file content. Required unless `delete` is true. */
7265
+ content: external_exports.string().optional(),
7266
+ /** Emit as a git-level deletion instead of a content write. */
7267
+ delete: external_exports.boolean().optional()
7268
+ }).refine((e) => e.delete === true || typeof e.content === "string", {
7269
+ message: "content is required unless delete is true"
7270
+ }).refine((e) => isSafeRepoPath(e.path), {
7271
+ message: "unsafe path: no '..' traversal, absolute paths, backslashes, or control chars",
7272
+ path: ["path"]
7273
+ });
7274
+ SaveBatchRequestSchema = external_exports.object({
7275
+ /** The changed + deleted files the client found vs the last-synced state. */
7276
+ edits: external_exports.array(SaveEditSchema).min(1).max(200),
7277
+ /** Human-readable summary surfaced in the PR body / commit trailer. */
7278
+ intent: external_exports.string().max(500).optional(),
7279
+ /** BAM-2588: classify-only preview — return the would-be routing, write nothing. */
7280
+ dry_run: external_exports.boolean().optional()
7281
+ });
7282
+ SaveFileResultSchema = external_exports.object({
7283
+ path: external_exports.string(),
7284
+ /** `auto` = merged to main; `queued` = opened/appended a review PR. */
7285
+ routed: external_exports.enum(["auto", "queued"]),
7286
+ /** Present when a PR was opened (queued, or auto via the queue-PR path). */
7287
+ pr_url: external_exports.string().optional(),
7288
+ pr_number: external_exports.number().optional()
7289
+ });
7290
+ SaveBatchResponseSchema = external_exports.object({
7291
+ /**
7292
+ * Aggregate routing decision from `executeKnowledgeWrite` for the whole
7293
+ * batch (the core routes a batch as one unit). `auto` when every edit
7294
+ * auto-merged, `queued` otherwise.
7295
+ */
7296
+ routed: external_exports.enum(["auto", "queued"]),
7297
+ classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
7298
+ /** Per-file detail. One entry per accepted edit. */
7299
+ files: external_exports.array(SaveFileResultSchema),
7300
+ /** Count of files that landed live (auto-merged). */
7301
+ live_count: external_exports.number().int().nonnegative(),
7302
+ /** Count of files queued for review. */
7303
+ queued_count: external_exports.number().int().nonnegative(),
7304
+ /** Present when a PR was opened for the batch. */
7305
+ pr_url: external_exports.string().optional(),
7306
+ pr_number: external_exports.number().optional(),
7307
+ /** Present on a rejected/forbidden batch — short machine-friendly reason. */
7308
+ reason: external_exports.string().optional(),
7309
+ /** BAM-2588: true when this was a --dry-run preview (nothing was written). */
7310
+ dry_run: external_exports.boolean().optional()
7311
+ });
7312
+ }
7313
+ });
7314
+
7246
7315
  // ../../src/lib/api-contracts/cli/knowledge-save.ts
7247
7316
  var knowledge_save_exports = {};
7248
7317
  __export(knowledge_save_exports, {
@@ -7253,6 +7322,7 @@ var KnowledgeSaveRequestSchema, KnowledgeSaveResponseSchema;
7253
7322
  var init_knowledge_save = __esm({
7254
7323
  "../../src/lib/api-contracts/cli/knowledge-save.ts"() {
7255
7324
  init_zod();
7325
+ init_save();
7256
7326
  KnowledgeSaveRequestSchema = external_exports.object({
7257
7327
  /** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. Derived by the caller from `knowledge slots`. */
7258
7328
  path: external_exports.string().min(1).max(512),
@@ -7262,6 +7332,9 @@ var init_knowledge_save = __esm({
7262
7332
  delete: external_exports.boolean().optional(),
7263
7333
  /** Human-readable summary surfaced in the PR body / commit trailer. */
7264
7334
  intent: external_exports.string().max(500).optional()
7335
+ }).refine((r) => isSafeRepoPath(r.path), {
7336
+ message: "unsafe path: no '..' traversal, absolute paths, backslashes, or control chars",
7337
+ path: ["path"]
7265
7338
  });
7266
7339
  KnowledgeSaveResponseSchema = external_exports.object({
7267
7340
  /** Routing outcome from `executeKnowledgeWrite`. */
@@ -12134,58 +12207,6 @@ var init_agents = __esm({
12134
12207
  }
12135
12208
  });
12136
12209
 
12137
- // ../../src/lib/api-contracts/cli/save.ts
12138
- var SaveEditSchema, SaveBatchRequestSchema, SaveFileResultSchema, SaveBatchResponseSchema;
12139
- var init_save = __esm({
12140
- "../../src/lib/api-contracts/cli/save.ts"() {
12141
- init_zod();
12142
- SaveEditSchema = external_exports.object({
12143
- /** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. */
12144
- path: external_exports.string().min(1).max(512),
12145
- /** UTF-8 file content. Required unless `delete` is true. */
12146
- content: external_exports.string().optional(),
12147
- /** Emit as a git-level deletion instead of a content write. */
12148
- delete: external_exports.boolean().optional()
12149
- }).refine((e) => e.delete === true || typeof e.content === "string", {
12150
- message: "content is required unless delete is true"
12151
- });
12152
- SaveBatchRequestSchema = external_exports.object({
12153
- /** The changed + deleted files the client found vs the last-synced state. */
12154
- edits: external_exports.array(SaveEditSchema).min(1).max(200),
12155
- /** Human-readable summary surfaced in the PR body / commit trailer. */
12156
- intent: external_exports.string().max(500).optional()
12157
- });
12158
- SaveFileResultSchema = external_exports.object({
12159
- path: external_exports.string(),
12160
- /** `auto` = merged to main; `queued` = opened/appended a review PR. */
12161
- routed: external_exports.enum(["auto", "queued"]),
12162
- /** Present when a PR was opened (queued, or auto via the queue-PR path). */
12163
- pr_url: external_exports.string().optional(),
12164
- pr_number: external_exports.number().optional()
12165
- });
12166
- SaveBatchResponseSchema = external_exports.object({
12167
- /**
12168
- * Aggregate routing decision from `executeKnowledgeWrite` for the whole
12169
- * batch (the core routes a batch as one unit). `auto` when every edit
12170
- * auto-merged, `queued` otherwise.
12171
- */
12172
- routed: external_exports.enum(["auto", "queued"]),
12173
- classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
12174
- /** Per-file detail. One entry per accepted edit. */
12175
- files: external_exports.array(SaveFileResultSchema),
12176
- /** Count of files that landed live (auto-merged). */
12177
- live_count: external_exports.number().int().nonnegative(),
12178
- /** Count of files queued for review. */
12179
- queued_count: external_exports.number().int().nonnegative(),
12180
- /** Present when a PR was opened for the batch. */
12181
- pr_url: external_exports.string().optional(),
12182
- pr_number: external_exports.number().optional(),
12183
- /** Present on a rejected/forbidden batch — short machine-friendly reason. */
12184
- reason: external_exports.string().optional()
12185
- });
12186
- }
12187
- });
12188
-
12189
12210
  // ../../src/lib/api-contracts/cli/context-health.ts
12190
12211
  var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
12191
12212
  var init_context_health = __esm({
@@ -14567,6 +14588,7 @@ async function requireSession(opts) {
14567
14588
  }
14568
14589
  async function runSave(intent, options = {}) {
14569
14590
  const opts = options;
14591
+ const dryRun = options.dryRun ?? false;
14570
14592
  let workspacePath;
14571
14593
  try {
14572
14594
  workspacePath = (await resolveWorkspace()).path;
@@ -14600,6 +14622,19 @@ async function runSave(intent, options = {}) {
14600
14622
  return;
14601
14623
  }
14602
14624
  const { deletes, writes, skipped } = planBatchFromPorcelain(entries);
14625
+ const unsafePath = [...writes, ...deletes].find((p) => !isSafeRepoPath(p));
14626
+ if (unsafePath) {
14627
+ emitError(
14628
+ {
14629
+ code: "unsafe_path",
14630
+ message: `refusing to save an unsafe path: ${unsafePath}`,
14631
+ hint: "Paths must be repo-relative \u2014 no '..', absolute paths, backslashes, or control chars."
14632
+ },
14633
+ opts,
14634
+ 1
14635
+ );
14636
+ return;
14637
+ }
14603
14638
  if (deletes.length === 0 && writes.length === 0) {
14604
14639
  const payload2 = {
14605
14640
  saved: 0,
@@ -14648,7 +14683,8 @@ async function runSave(intent, options = {}) {
14648
14683
  try {
14649
14684
  result = await saveWorkspace(session, {
14650
14685
  edits,
14651
- intent: intent?.trim() || void 0
14686
+ intent: intent?.trim() || void 0,
14687
+ dry_run: dryRun || void 0
14652
14688
  });
14653
14689
  } catch (err) {
14654
14690
  if (err instanceof ApiError && err.status === 403) {
@@ -14675,7 +14711,7 @@ async function runSave(intent, options = {}) {
14675
14711
  );
14676
14712
  return;
14677
14713
  }
14678
- const { checkout, remove } = reconcilePlan(result.files, deletes);
14714
+ const { checkout, remove } = dryRun ? { checkout: [], remove: [] } : reconcilePlan(result.files, deletes);
14679
14715
  if (checkout.length > 0 || remove.length > 0) {
14680
14716
  try {
14681
14717
  const branch = await currentBranch(workspacePath);
@@ -14707,17 +14743,27 @@ async function runSave(intent, options = {}) {
14707
14743
  queued,
14708
14744
  skipped: skipped.length,
14709
14745
  pr_url: result.pr_url ?? null,
14710
- files: result.files
14746
+ files: result.files,
14747
+ dry_run: dryRun
14711
14748
  };
14712
14749
  emitSuccess(payload, opts, () => {
14713
14750
  human("", opts);
14751
+ const verb = dryRun ? "would go live" : "live";
14752
+ const qverb = dryRun ? "would queue for review" : "queued for review";
14714
14753
  const parts = [];
14715
- if (live > 0) parts.push(`${live} live`);
14716
- if (queued > 0) parts.push(`${queued} queued for review`);
14754
+ if (live > 0) parts.push(`${live} ${verb}`);
14755
+ if (queued > 0) parts.push(`${queued} ${qverb}`);
14717
14756
  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);
14757
+ if (dryRun) {
14758
+ human(
14759
+ ` Dry run: ${total} file${total === 1 ? "" : "s"}${summary}. Nothing written.`,
14760
+ opts
14761
+ );
14762
+ } else {
14763
+ human(` Saved ${total} file${total === 1 ? "" : "s"}${summary}.`, opts);
14764
+ if (queued > 0 && result.pr_url) {
14765
+ human(` Review: ${result.pr_url}`, opts);
14766
+ }
14721
14767
  }
14722
14768
  if (skipped.length > 0) {
14723
14769
  human(
@@ -14733,6 +14779,7 @@ var init_save2 = __esm({
14733
14779
  "src/commands/save.ts"() {
14734
14780
  "use strict";
14735
14781
  init_api();
14782
+ init_save();
14736
14783
  init_credentials();
14737
14784
  init_workspace();
14738
14785
  init_output();
@@ -16982,7 +17029,7 @@ program2.command("doctor").description("Verify your local setup is ready + heal
16982
17029
  const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
16983
17030
  await runDoctor2({ quiet: options.quiet, autoHeal: options.autoHeal });
16984
17031
  });
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(
17032
+ 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)").option("--dry-run", "Show what would be saved (routed auto/queue) without writing").action(
16986
17033
  async (intent, options) => {
16987
17034
  const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
16988
17035
  await runSave2(intent, options);