bamboo-agents 0.1.5-dev.62.c11b819 → 0.1.5-dev.63.0d55db2
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 +1 -1
- package/dist/index.js +215 -7
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.5-dev.
|
|
1
|
+
0.1.5-dev.63.0d55db2
|
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.
|
|
3040
|
+
VERSION = "0.1.5-dev.63.0d55db2";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -12502,6 +12502,45 @@ var init_inbox_revise = __esm({
|
|
|
12502
12502
|
}
|
|
12503
12503
|
});
|
|
12504
12504
|
|
|
12505
|
+
// ../../src/lib/api-contracts/cli/inbox-apply-revision.ts
|
|
12506
|
+
var InboxApplyRevisionRequestSchema, InboxApplyRevisionResponseSchema;
|
|
12507
|
+
var init_inbox_apply_revision = __esm({
|
|
12508
|
+
"../../src/lib/api-contracts/cli/inbox-apply-revision.ts"() {
|
|
12509
|
+
init_zod();
|
|
12510
|
+
init_save();
|
|
12511
|
+
InboxApplyRevisionRequestSchema = external_exports.object({
|
|
12512
|
+
/** PR number in the org's workspace repo. */
|
|
12513
|
+
pr_number: external_exports.number().int().positive(),
|
|
12514
|
+
/** Repo-relative path of the single file being revised. */
|
|
12515
|
+
file: external_exports.string().min(1).max(512),
|
|
12516
|
+
/** The complete new file content — the full file, not a diff. */
|
|
12517
|
+
new_content: external_exports.string().min(1).max(1e6),
|
|
12518
|
+
/** Short commit message, e.g. "revision: tighten tone in intro". */
|
|
12519
|
+
commit_message: external_exports.string().min(1).max(200),
|
|
12520
|
+
/**
|
|
12521
|
+
* Blob SHA from the `inbox revise` response — GitHub's optimistic
|
|
12522
|
+
* concurrency check. A stale SHA → 409 `pr_branch_moved`.
|
|
12523
|
+
*/
|
|
12524
|
+
file_sha: external_exports.string().min(1).max(64),
|
|
12525
|
+
/**
|
|
12526
|
+
* The head branch from the `inbox revise` response. Validated against
|
|
12527
|
+
* the PR's actual head ref server-side (409 `branch_mismatch` on drift);
|
|
12528
|
+
* the commit always targets the PR's own head ref.
|
|
12529
|
+
*/
|
|
12530
|
+
branch: external_exports.string().min(1).max(255).optional()
|
|
12531
|
+
}).refine((r) => isSafeRepoPath(r.file), {
|
|
12532
|
+
message: "unsafe file path: no '..' traversal, absolute paths, backslashes, or control chars",
|
|
12533
|
+
path: ["file"]
|
|
12534
|
+
});
|
|
12535
|
+
InboxApplyRevisionResponseSchema = external_exports.object({
|
|
12536
|
+
committed: external_exports.literal(true),
|
|
12537
|
+
/** The PR head branch the revision landed on. */
|
|
12538
|
+
branch: external_exports.string(),
|
|
12539
|
+
pr_number: external_exports.number()
|
|
12540
|
+
});
|
|
12541
|
+
}
|
|
12542
|
+
});
|
|
12543
|
+
|
|
12505
12544
|
// ../../src/lib/api-contracts/cli/context-health.ts
|
|
12506
12545
|
var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
|
|
12507
12546
|
var init_context_health = __esm({
|
|
@@ -12716,6 +12755,19 @@ async function requestInboxRevision(bambooSession, body) {
|
|
|
12716
12755
|
const json = await res.json();
|
|
12717
12756
|
return InboxReviseResponseSchema.parse(json);
|
|
12718
12757
|
}
|
|
12758
|
+
async function requestInboxApplyRevision(bambooSession, body) {
|
|
12759
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/inbox/apply-revision`, {
|
|
12760
|
+
method: "POST",
|
|
12761
|
+
headers: {
|
|
12762
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
12763
|
+
"Content-Type": "application/json"
|
|
12764
|
+
},
|
|
12765
|
+
body: JSON.stringify(body)
|
|
12766
|
+
});
|
|
12767
|
+
if (!res.ok) throw await parseError(res);
|
|
12768
|
+
const json = await res.json();
|
|
12769
|
+
return InboxApplyRevisionResponseSchema.parse(json);
|
|
12770
|
+
}
|
|
12719
12771
|
async function saveWorkspace(bambooSession, body) {
|
|
12720
12772
|
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/save`, {
|
|
12721
12773
|
method: "POST",
|
|
@@ -13088,6 +13140,7 @@ var init_api = __esm({
|
|
|
13088
13140
|
init_knowledge_save();
|
|
13089
13141
|
init_skill_apply();
|
|
13090
13142
|
init_inbox_revise();
|
|
13143
|
+
init_inbox_apply_revision();
|
|
13091
13144
|
init_save();
|
|
13092
13145
|
init_history();
|
|
13093
13146
|
init_changes();
|
|
@@ -17588,9 +17641,12 @@ var init_knowledge = __esm({
|
|
|
17588
17641
|
// src/commands/inbox.ts
|
|
17589
17642
|
var inbox_exports = {};
|
|
17590
17643
|
__export(inbox_exports, {
|
|
17644
|
+
runInboxApplyRevision: () => runInboxApplyRevision,
|
|
17591
17645
|
runInboxRevise: () => runInboxRevise
|
|
17592
17646
|
});
|
|
17593
|
-
import { readFile as readFile8 } from "node:fs/promises";
|
|
17647
|
+
import { mkdir as mkdir5, readFile as readFile8, writeFile as writeFile4 } from "node:fs/promises";
|
|
17648
|
+
import { tmpdir } from "node:os";
|
|
17649
|
+
import { basename, join as join6 } from "node:path";
|
|
17594
17650
|
async function requireSession4(opts) {
|
|
17595
17651
|
const session = await resolveSession();
|
|
17596
17652
|
if (!session) {
|
|
@@ -17628,6 +17684,31 @@ async function readSelectionFile(path2) {
|
|
|
17628
17684
|
}
|
|
17629
17685
|
return parsed.data;
|
|
17630
17686
|
}
|
|
17687
|
+
async function materializeReviseContent(result, file) {
|
|
17688
|
+
const { file_content, file_content_base, ...rest } = result;
|
|
17689
|
+
if (result.dispatched || !file_content || !result.file_sha || !result.branch) {
|
|
17690
|
+
return rest;
|
|
17691
|
+
}
|
|
17692
|
+
const dir = join6(tmpdir(), `bamboo-revise-${result.pr_number}`);
|
|
17693
|
+
const headFile = join6(dir, `head-${basename(file)}`);
|
|
17694
|
+
try {
|
|
17695
|
+
await mkdir5(dir, { recursive: true });
|
|
17696
|
+
await writeFile4(headFile, file_content, "utf8");
|
|
17697
|
+
let baseFile;
|
|
17698
|
+
if (file_content_base !== void 0) {
|
|
17699
|
+
baseFile = join6(dir, `base-${basename(file)}`);
|
|
17700
|
+
await writeFile4(baseFile, file_content_base, "utf8");
|
|
17701
|
+
}
|
|
17702
|
+
return {
|
|
17703
|
+
...rest,
|
|
17704
|
+
head_file: headFile,
|
|
17705
|
+
base_file: baseFile,
|
|
17706
|
+
next_step: `Edit ${headFile} to apply the requested change, then run: bamboo-agents inbox apply-revision --pr ${result.pr_number} --file "${file}" --content-file ${headFile} --sha ${result.file_sha} --branch "${result.branch}" --message "revision: <short summary>" --json`
|
|
17707
|
+
};
|
|
17708
|
+
} catch {
|
|
17709
|
+
return result;
|
|
17710
|
+
}
|
|
17711
|
+
}
|
|
17631
17712
|
function printReviseResult(result, opts) {
|
|
17632
17713
|
if (result.dispatched) {
|
|
17633
17714
|
human(
|
|
@@ -17639,10 +17720,18 @@ function printReviseResult(result, opts) {
|
|
|
17639
17720
|
}
|
|
17640
17721
|
human(` \u2022 Not dispatched \u2014 this PR's source is not a managed agent.`, opts);
|
|
17641
17722
|
if (result.message) human(` ${result.message}`, opts);
|
|
17642
|
-
|
|
17643
|
-
`
|
|
17644
|
-
|
|
17645
|
-
|
|
17723
|
+
if (result.head_file) {
|
|
17724
|
+
human(` PR-head content written to ${result.head_file}`, opts);
|
|
17725
|
+
human(
|
|
17726
|
+
` Edit that file, then commit it back with \`bamboo-agents inbox apply-revision\` (see next_step).`,
|
|
17727
|
+
opts
|
|
17728
|
+
);
|
|
17729
|
+
} else {
|
|
17730
|
+
human(
|
|
17731
|
+
` The file content could not be read from the PR branch \u2014 make the edit via the Inbox or GitHub.`,
|
|
17732
|
+
opts
|
|
17733
|
+
);
|
|
17734
|
+
}
|
|
17646
17735
|
}
|
|
17647
17736
|
async function runInboxRevise(options) {
|
|
17648
17737
|
const opts = options;
|
|
@@ -17717,7 +17806,122 @@ async function runInboxRevise(options) {
|
|
|
17717
17806
|
);
|
|
17718
17807
|
return;
|
|
17719
17808
|
}
|
|
17720
|
-
|
|
17809
|
+
const output = await materializeReviseContent(result, file);
|
|
17810
|
+
emitSuccess(output, opts, (r) => printReviseResult(r, opts));
|
|
17811
|
+
}
|
|
17812
|
+
async function runInboxApplyRevision(options) {
|
|
17813
|
+
const opts = options;
|
|
17814
|
+
const session = await requireSession4(opts);
|
|
17815
|
+
const prNumber = Number.parseInt(options.pr ?? "", 10);
|
|
17816
|
+
if (!Number.isInteger(prNumber) || prNumber <= 0) {
|
|
17817
|
+
emitError(
|
|
17818
|
+
{
|
|
17819
|
+
code: "invalid_pr",
|
|
17820
|
+
message: `--pr must be a positive PR number (got ${JSON.stringify(options.pr ?? null)}).`
|
|
17821
|
+
},
|
|
17822
|
+
opts,
|
|
17823
|
+
1
|
|
17824
|
+
);
|
|
17825
|
+
return;
|
|
17826
|
+
}
|
|
17827
|
+
const file = options.file?.trim();
|
|
17828
|
+
if (!file) {
|
|
17829
|
+
emitError(
|
|
17830
|
+
{
|
|
17831
|
+
code: "missing_file",
|
|
17832
|
+
message: "inbox apply-revision requires --file (the repo-relative path being revised)."
|
|
17833
|
+
},
|
|
17834
|
+
opts,
|
|
17835
|
+
1
|
|
17836
|
+
);
|
|
17837
|
+
return;
|
|
17838
|
+
}
|
|
17839
|
+
const sha = options.sha?.trim();
|
|
17840
|
+
if (!sha) {
|
|
17841
|
+
emitError(
|
|
17842
|
+
{
|
|
17843
|
+
code: "missing_sha",
|
|
17844
|
+
message: "inbox apply-revision requires --sha (the file_sha from `inbox revise`).",
|
|
17845
|
+
hint: "GitHub uses it to reject the write if the PR branch moved since the file was read."
|
|
17846
|
+
},
|
|
17847
|
+
opts,
|
|
17848
|
+
1
|
|
17849
|
+
);
|
|
17850
|
+
return;
|
|
17851
|
+
}
|
|
17852
|
+
const message = options.message?.trim();
|
|
17853
|
+
if (!message) {
|
|
17854
|
+
emitError(
|
|
17855
|
+
{
|
|
17856
|
+
code: "missing_message",
|
|
17857
|
+
message: "inbox apply-revision requires --message (a short commit message).",
|
|
17858
|
+
hint: 'e.g. --message "revision: tighten tone in intro paragraph"'
|
|
17859
|
+
},
|
|
17860
|
+
opts,
|
|
17861
|
+
1
|
|
17862
|
+
);
|
|
17863
|
+
return;
|
|
17864
|
+
}
|
|
17865
|
+
if (!options.contentFile) {
|
|
17866
|
+
emitError(
|
|
17867
|
+
{
|
|
17868
|
+
code: "missing_content_file",
|
|
17869
|
+
message: "inbox apply-revision requires --content-file (the revised file content on disk).",
|
|
17870
|
+
hint: "Edit the head_file from `inbox revise`, then pass its path here \u2014 the FULL file, not a diff."
|
|
17871
|
+
},
|
|
17872
|
+
opts,
|
|
17873
|
+
1
|
|
17874
|
+
);
|
|
17875
|
+
return;
|
|
17876
|
+
}
|
|
17877
|
+
let newContent;
|
|
17878
|
+
try {
|
|
17879
|
+
newContent = await readFile8(options.contentFile, "utf8");
|
|
17880
|
+
} catch (err) {
|
|
17881
|
+
emitError(
|
|
17882
|
+
{
|
|
17883
|
+
code: "invalid_content_file",
|
|
17884
|
+
message: `couldn't read content file ${options.contentFile}: ${err.message}`
|
|
17885
|
+
},
|
|
17886
|
+
opts,
|
|
17887
|
+
1
|
|
17888
|
+
);
|
|
17889
|
+
return;
|
|
17890
|
+
}
|
|
17891
|
+
if (!newContent.trim()) {
|
|
17892
|
+
emitError(
|
|
17893
|
+
{
|
|
17894
|
+
code: "empty_content_file",
|
|
17895
|
+
message: `content file ${options.contentFile} is empty \u2014 apply-revision commits the full revised file.`,
|
|
17896
|
+
hint: "To remove the change entirely, decline the PR instead."
|
|
17897
|
+
},
|
|
17898
|
+
opts,
|
|
17899
|
+
1
|
|
17900
|
+
);
|
|
17901
|
+
return;
|
|
17902
|
+
}
|
|
17903
|
+
let result;
|
|
17904
|
+
try {
|
|
17905
|
+
result = await requestInboxApplyRevision(session, {
|
|
17906
|
+
pr_number: prNumber,
|
|
17907
|
+
file,
|
|
17908
|
+
new_content: newContent,
|
|
17909
|
+
commit_message: message,
|
|
17910
|
+
file_sha: sha,
|
|
17911
|
+
branch: options.branch?.trim() || void 0
|
|
17912
|
+
});
|
|
17913
|
+
} catch (err) {
|
|
17914
|
+
const code = err instanceof ApiError && err.errorCode ? err.errorCode : "apply_revision_failed";
|
|
17915
|
+
emitError(
|
|
17916
|
+
{ code, message: `apply-revision failed: ${err.message}` },
|
|
17917
|
+
opts,
|
|
17918
|
+
1
|
|
17919
|
+
);
|
|
17920
|
+
return;
|
|
17921
|
+
}
|
|
17922
|
+
emitSuccess(result, opts, (r) => {
|
|
17923
|
+
human(` \u2713 Revision committed to ${r.branch} \u2014 the Inbox diff is updated.`, opts);
|
|
17924
|
+
});
|
|
17721
17925
|
}
|
|
17722
17926
|
var SelectionFileSchema;
|
|
17723
17927
|
var init_inbox = __esm({
|
|
@@ -18758,6 +18962,10 @@ inbox.command("revise").description("Request a revision on a pending inbox PR (d
|
|
|
18758
18962
|
const { runInboxRevise: runInboxRevise2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
|
|
18759
18963
|
await runInboxRevise2(options);
|
|
18760
18964
|
});
|
|
18965
|
+
inbox.command("apply-revision").description("Commit revised file content to a pending inbox PR's head branch (the dispatched:false follow-up to `inbox revise`)").requiredOption("--pr <number>", "PR number in the workspace repo").requiredOption("--file <path>", "Repo-relative path of the file being revised").requiredOption("--content-file <path>", "Local file holding the COMPLETE revised content (edit the head_file from `inbox revise`)").requiredOption("--sha <sha>", "The file_sha from `inbox revise` (GitHub's stale-write check)").requiredOption("--message <text>", "Short commit message, e.g. 'revision: tighten tone in intro'").option("--branch <name>", "PR head branch from `inbox revise` (validated server-side)").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) => {
|
|
18966
|
+
const { runInboxApplyRevision: runInboxApplyRevision2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
|
|
18967
|
+
await runInboxApplyRevision2(options);
|
|
18968
|
+
});
|
|
18761
18969
|
program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--limit <n>", "Max entries (default 20, max 100)").option(
|
|
18762
18970
|
"--source <runtime>",
|
|
18763
18971
|
"Filter by runtime origin (boo | sandbox-boo | managed-agent)"
|