bamboo-agents 0.1.5-dev.31 → 0.1.5-dev.33
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 +301 -1
- 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.33
|
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.33";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -13777,6 +13777,297 @@ var init_doctor = __esm({
|
|
|
13777
13777
|
}
|
|
13778
13778
|
});
|
|
13779
13779
|
|
|
13780
|
+
// src/lib/skills-local.ts
|
|
13781
|
+
import { readdir as readdir2, readFile as readFile4, stat as stat2 } from "node:fs/promises";
|
|
13782
|
+
import { join as join2 } from "node:path";
|
|
13783
|
+
function parseSimpleFrontmatter(raw) {
|
|
13784
|
+
const text = raw.replace(/\r\n/g, "\n");
|
|
13785
|
+
const m = text.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
13786
|
+
if (!m) {
|
|
13787
|
+
return { data: {}, body: text };
|
|
13788
|
+
}
|
|
13789
|
+
const fm = m[1] ?? "";
|
|
13790
|
+
const body = m[2] ?? "";
|
|
13791
|
+
const data = {};
|
|
13792
|
+
const lines = fm.split("\n");
|
|
13793
|
+
let i = 0;
|
|
13794
|
+
while (i < lines.length) {
|
|
13795
|
+
const line = lines[i];
|
|
13796
|
+
i++;
|
|
13797
|
+
if (!line.trim() || line.trim().startsWith("#")) continue;
|
|
13798
|
+
const colon = line.indexOf(":");
|
|
13799
|
+
if (colon < 0) continue;
|
|
13800
|
+
const key = line.slice(0, colon).trim();
|
|
13801
|
+
let value = line.slice(colon + 1).trim();
|
|
13802
|
+
if (!key) continue;
|
|
13803
|
+
const blockMatch = value.match(/^([>|])([+-]?)\s*$/);
|
|
13804
|
+
if (blockMatch) {
|
|
13805
|
+
const style = blockMatch[1];
|
|
13806
|
+
const chomp = blockMatch[2] ?? "";
|
|
13807
|
+
const collected = [];
|
|
13808
|
+
while (i < lines.length) {
|
|
13809
|
+
const next = lines[i];
|
|
13810
|
+
if (next.trim() === "") {
|
|
13811
|
+
collected.push("");
|
|
13812
|
+
i++;
|
|
13813
|
+
continue;
|
|
13814
|
+
}
|
|
13815
|
+
if (!/^\s/.test(next)) break;
|
|
13816
|
+
collected.push(next.replace(/^\s+/, ""));
|
|
13817
|
+
i++;
|
|
13818
|
+
}
|
|
13819
|
+
while (collected.length && collected[collected.length - 1] === "") {
|
|
13820
|
+
collected.pop();
|
|
13821
|
+
}
|
|
13822
|
+
let folded;
|
|
13823
|
+
if (style === ">") {
|
|
13824
|
+
const parts = [];
|
|
13825
|
+
let buf = [];
|
|
13826
|
+
for (const c of collected) {
|
|
13827
|
+
if (c === "") {
|
|
13828
|
+
if (buf.length) {
|
|
13829
|
+
parts.push(buf.join(" "));
|
|
13830
|
+
buf = [];
|
|
13831
|
+
}
|
|
13832
|
+
parts.push("");
|
|
13833
|
+
} else {
|
|
13834
|
+
buf.push(c);
|
|
13835
|
+
}
|
|
13836
|
+
}
|
|
13837
|
+
if (buf.length) parts.push(buf.join(" "));
|
|
13838
|
+
folded = parts.join("\n").replace(/\n+/g, (m2) => m2.length > 1 ? "\n\n" : "\n");
|
|
13839
|
+
} else {
|
|
13840
|
+
folded = collected.join("\n");
|
|
13841
|
+
}
|
|
13842
|
+
if (chomp !== "-") folded += "\n";
|
|
13843
|
+
data[key] = folded;
|
|
13844
|
+
continue;
|
|
13845
|
+
}
|
|
13846
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
13847
|
+
value = value.slice(1, -1);
|
|
13848
|
+
}
|
|
13849
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
13850
|
+
const inner = value.slice(1, -1).trim();
|
|
13851
|
+
data[key] = inner ? inner.split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")) : [];
|
|
13852
|
+
continue;
|
|
13853
|
+
}
|
|
13854
|
+
if (value === "true") {
|
|
13855
|
+
data[key] = true;
|
|
13856
|
+
continue;
|
|
13857
|
+
}
|
|
13858
|
+
if (value === "false") {
|
|
13859
|
+
data[key] = false;
|
|
13860
|
+
continue;
|
|
13861
|
+
}
|
|
13862
|
+
data[key] = value;
|
|
13863
|
+
}
|
|
13864
|
+
return { data, body };
|
|
13865
|
+
}
|
|
13866
|
+
function parseSkillContent(raw, sourcePath) {
|
|
13867
|
+
const { data: fm, body } = parseSimpleFrontmatter(raw);
|
|
13868
|
+
const name = typeof fm.name === "string" ? fm.name : "";
|
|
13869
|
+
const description = typeof fm.description === "string" ? fm.description.trim() : "";
|
|
13870
|
+
const disableModelInvocation = fm["disable-model-invocation"] === true || fm.disableModelInvocation === true;
|
|
13871
|
+
const allowedToolsRaw = fm["allowed-tools"] ?? fm.allowedTools;
|
|
13872
|
+
const allowedTools = Array.isArray(allowedToolsRaw) ? allowedToolsRaw.filter((t) => typeof t === "string") : [];
|
|
13873
|
+
const errors = [];
|
|
13874
|
+
if (!name) errors.push("missing name");
|
|
13875
|
+
if (name.length > 64) errors.push(`name > 64 chars (${name.length})`);
|
|
13876
|
+
if (name && !/^[a-z0-9-]+$/.test(name)) errors.push("name must be kebab-case");
|
|
13877
|
+
if (!description) errors.push("missing description");
|
|
13878
|
+
if (description.length > 1024)
|
|
13879
|
+
errors.push(`description > 1024 chars (${description.length})`);
|
|
13880
|
+
if (body.split("\n").length > 500) errors.push("body > 500 lines");
|
|
13881
|
+
if (errors.length) {
|
|
13882
|
+
console.warn(
|
|
13883
|
+
`bamboo-agents: skipping ${sourcePath}: ${errors.join("; ")}`
|
|
13884
|
+
);
|
|
13885
|
+
return null;
|
|
13886
|
+
}
|
|
13887
|
+
return {
|
|
13888
|
+
name,
|
|
13889
|
+
description,
|
|
13890
|
+
disableModelInvocation,
|
|
13891
|
+
allowedTools,
|
|
13892
|
+
content: body.replace(/^\n+/, "").trimEnd(),
|
|
13893
|
+
sourcePath
|
|
13894
|
+
};
|
|
13895
|
+
}
|
|
13896
|
+
async function resolveSkillsDir(repoPath) {
|
|
13897
|
+
const dir = join2(repoPath, "skills");
|
|
13898
|
+
try {
|
|
13899
|
+
const s = await stat2(dir);
|
|
13900
|
+
return s.isDirectory() ? dir : null;
|
|
13901
|
+
} catch {
|
|
13902
|
+
return null;
|
|
13903
|
+
}
|
|
13904
|
+
}
|
|
13905
|
+
async function listLocalSkills(repoPath) {
|
|
13906
|
+
const dir = await resolveSkillsDir(repoPath);
|
|
13907
|
+
if (!dir) return [];
|
|
13908
|
+
const entries = await readdir2(dir, { withFileTypes: true });
|
|
13909
|
+
const skillDirs = entries.filter((e) => e.isDirectory());
|
|
13910
|
+
const skills2 = [];
|
|
13911
|
+
for (const entry of skillDirs) {
|
|
13912
|
+
const full = join2(dir, entry.name, "SKILL.md");
|
|
13913
|
+
let raw;
|
|
13914
|
+
try {
|
|
13915
|
+
raw = await readFile4(full, "utf8");
|
|
13916
|
+
} catch (err) {
|
|
13917
|
+
const code = err.code;
|
|
13918
|
+
if (code === "ENOENT") continue;
|
|
13919
|
+
console.warn(
|
|
13920
|
+
`bamboo-agents: couldn't read ${full}: ${err.message}`
|
|
13921
|
+
);
|
|
13922
|
+
continue;
|
|
13923
|
+
}
|
|
13924
|
+
const parsed = parseSkillContent(raw, full);
|
|
13925
|
+
if (parsed) skills2.push(parsed);
|
|
13926
|
+
}
|
|
13927
|
+
skills2.sort((a, b) => a.name.localeCompare(b.name));
|
|
13928
|
+
return skills2;
|
|
13929
|
+
}
|
|
13930
|
+
async function getLocalSkill(repoPath, name) {
|
|
13931
|
+
const dir = await resolveSkillsDir(repoPath);
|
|
13932
|
+
if (!dir) return null;
|
|
13933
|
+
const full = join2(dir, name, "SKILL.md");
|
|
13934
|
+
let raw;
|
|
13935
|
+
try {
|
|
13936
|
+
raw = await readFile4(full, "utf8");
|
|
13937
|
+
} catch {
|
|
13938
|
+
return null;
|
|
13939
|
+
}
|
|
13940
|
+
return parseSkillContent(raw, full);
|
|
13941
|
+
}
|
|
13942
|
+
var init_skills_local = __esm({
|
|
13943
|
+
"src/lib/skills-local.ts"() {
|
|
13944
|
+
"use strict";
|
|
13945
|
+
}
|
|
13946
|
+
});
|
|
13947
|
+
|
|
13948
|
+
// src/commands/skills.ts
|
|
13949
|
+
var skills_exports = {};
|
|
13950
|
+
__export(skills_exports, {
|
|
13951
|
+
runSkillsGet: () => runSkillsGet,
|
|
13952
|
+
runSkillsList: () => runSkillsList
|
|
13953
|
+
});
|
|
13954
|
+
async function resolveWorkspacePath() {
|
|
13955
|
+
const cfg = await readConfig();
|
|
13956
|
+
if (!cfg) {
|
|
13957
|
+
console.error(
|
|
13958
|
+
"bamboo-agents: no workspace configured. Run `bamboo-agents init` first."
|
|
13959
|
+
);
|
|
13960
|
+
process.exit(1);
|
|
13961
|
+
}
|
|
13962
|
+
return cfg.repo_path;
|
|
13963
|
+
}
|
|
13964
|
+
function summarize(description, max = 80) {
|
|
13965
|
+
const oneLine = description.replace(/\s+/g, " ").trim();
|
|
13966
|
+
if (oneLine.length <= max) return oneLine;
|
|
13967
|
+
return oneLine.slice(0, max - 1) + "\u2026";
|
|
13968
|
+
}
|
|
13969
|
+
function padRight(s, n) {
|
|
13970
|
+
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
13971
|
+
}
|
|
13972
|
+
async function runSkillsList() {
|
|
13973
|
+
const repoPath = await resolveWorkspacePath();
|
|
13974
|
+
const skills2 = await listLocalSkills(repoPath);
|
|
13975
|
+
if (skills2.length === 0) {
|
|
13976
|
+
console.log("");
|
|
13977
|
+
console.log(" No skills found.");
|
|
13978
|
+
console.log(` Looked in: ${repoPath}/skills/`);
|
|
13979
|
+
console.log(
|
|
13980
|
+
" Skills are seeded into your workspace on provision (BAM-2309)."
|
|
13981
|
+
);
|
|
13982
|
+
console.log(
|
|
13983
|
+
" If this is empty, the workspace may not have synced yet \u2014 try"
|
|
13984
|
+
);
|
|
13985
|
+
console.log(" `bamboo-agents doctor` to verify your setup.");
|
|
13986
|
+
console.log("");
|
|
13987
|
+
return;
|
|
13988
|
+
}
|
|
13989
|
+
const nameCol = Math.max(
|
|
13990
|
+
"name".length,
|
|
13991
|
+
...skills2.map((s) => s.name.length)
|
|
13992
|
+
);
|
|
13993
|
+
const header = ` ${padRight("name", nameCol)} description`;
|
|
13994
|
+
const rule = " " + "\u2500".repeat(nameCol) + " " + "\u2500".repeat(Math.min(60, 80 - nameCol));
|
|
13995
|
+
console.log("");
|
|
13996
|
+
console.log(header);
|
|
13997
|
+
console.log(rule);
|
|
13998
|
+
for (const skill of skills2) {
|
|
13999
|
+
console.log(
|
|
14000
|
+
` ${padRight(skill.name, nameCol)} ${summarize(skill.description, 80 - nameCol - 4)}`
|
|
14001
|
+
);
|
|
14002
|
+
}
|
|
14003
|
+
console.log("");
|
|
14004
|
+
console.log(` ${skills2.length} skill${skills2.length === 1 ? "" : "s"}.`);
|
|
14005
|
+
console.log("");
|
|
14006
|
+
console.log(" Print one with: bamboo-agents skills get <name>");
|
|
14007
|
+
console.log("");
|
|
14008
|
+
}
|
|
14009
|
+
async function runSkillsGet(name) {
|
|
14010
|
+
if (!name || !name.trim()) {
|
|
14011
|
+
console.error("bamboo-agents: skills get requires a skill name.");
|
|
14012
|
+
console.error("Example: bamboo-agents skills get enhance-instructions");
|
|
14013
|
+
process.exit(2);
|
|
14014
|
+
}
|
|
14015
|
+
const repoPath = await resolveWorkspacePath();
|
|
14016
|
+
const skill = await getLocalSkill(repoPath, name.trim());
|
|
14017
|
+
if (!skill) {
|
|
14018
|
+
await printNotFound(repoPath, name);
|
|
14019
|
+
process.exit(2);
|
|
14020
|
+
}
|
|
14021
|
+
printSkillToStdout(skill);
|
|
14022
|
+
}
|
|
14023
|
+
function printSkillToStdout(skill) {
|
|
14024
|
+
process.stdout.write("---\n");
|
|
14025
|
+
process.stdout.write(`name: ${skill.name}
|
|
14026
|
+
`);
|
|
14027
|
+
process.stdout.write(`description: ${skill.description}
|
|
14028
|
+
`);
|
|
14029
|
+
if (skill.disableModelInvocation) {
|
|
14030
|
+
process.stdout.write("disable-model-invocation: true\n");
|
|
14031
|
+
}
|
|
14032
|
+
if (skill.allowedTools.length > 0) {
|
|
14033
|
+
process.stdout.write(
|
|
14034
|
+
`allowed-tools: [${skill.allowedTools.join(", ")}]
|
|
14035
|
+
`
|
|
14036
|
+
);
|
|
14037
|
+
}
|
|
14038
|
+
process.stdout.write("---\n");
|
|
14039
|
+
process.stdout.write("\n");
|
|
14040
|
+
process.stdout.write(skill.content);
|
|
14041
|
+
if (!skill.content.endsWith("\n")) process.stdout.write("\n");
|
|
14042
|
+
}
|
|
14043
|
+
async function printNotFound(repoPath, name) {
|
|
14044
|
+
const all = await listLocalSkills(repoPath);
|
|
14045
|
+
console.error(`bamboo-agents: skill not found: ${name}`);
|
|
14046
|
+
if (all.length === 0) {
|
|
14047
|
+
console.error(`No skills in ${repoPath}/skills/.`);
|
|
14048
|
+
return;
|
|
14049
|
+
}
|
|
14050
|
+
const lower = name.toLowerCase();
|
|
14051
|
+
const prefixMatches = all.filter(
|
|
14052
|
+
(s) => s.name.toLowerCase().startsWith(lower)
|
|
14053
|
+
);
|
|
14054
|
+
const suggestions = prefixMatches.length > 0 ? prefixMatches : all;
|
|
14055
|
+
console.error("");
|
|
14056
|
+
console.error(
|
|
14057
|
+
prefixMatches.length > 0 ? "Did you mean:" : "Available skills (run `bamboo-agents skills list` for descriptions):"
|
|
14058
|
+
);
|
|
14059
|
+
for (const s of suggestions) {
|
|
14060
|
+
console.error(` ${s.name}`);
|
|
14061
|
+
}
|
|
14062
|
+
}
|
|
14063
|
+
var init_skills = __esm({
|
|
14064
|
+
"src/commands/skills.ts"() {
|
|
14065
|
+
"use strict";
|
|
14066
|
+
init_state();
|
|
14067
|
+
init_skills_local();
|
|
14068
|
+
}
|
|
14069
|
+
});
|
|
14070
|
+
|
|
13780
14071
|
// node_modules/commander/esm.mjs
|
|
13781
14072
|
var import_index = __toESM(require_commander(), 1);
|
|
13782
14073
|
var {
|
|
@@ -13822,6 +14113,15 @@ program2.command("doctor").description("Verify your local setup is ready").actio
|
|
|
13822
14113
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
13823
14114
|
await runDoctor2();
|
|
13824
14115
|
});
|
|
14116
|
+
var skills = program2.command("skills").description("Read workspace skills from your local clone");
|
|
14117
|
+
skills.command("list").description("List every skill in the workspace").action(async () => {
|
|
14118
|
+
const { runSkillsList: runSkillsList2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
|
|
14119
|
+
await runSkillsList2();
|
|
14120
|
+
});
|
|
14121
|
+
skills.command("get <name>").description("Print one skill's SKILL.md body to stdout").action(async (name) => {
|
|
14122
|
+
const { runSkillsGet: runSkillsGet2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
|
|
14123
|
+
await runSkillsGet2(name);
|
|
14124
|
+
});
|
|
13825
14125
|
program2.parseAsync().catch((err) => {
|
|
13826
14126
|
const message = err instanceof Error ? err.message : String(err);
|
|
13827
14127
|
console.error(`bamboo-agents: ${message}`);
|