bamboo-agents 0.1.5-dev.31 → 0.1.5-dev.32

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.31
1
+ 0.1.5-dev.32
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.31";
3040
+ VERSION = "0.1.5-dev.32";
3041
3041
  }
3042
3042
  });
3043
3043
 
@@ -13777,6 +13777,298 @@ 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);
13909
+ const matches = entries.filter((e) => e.endsWith(".skill.md"));
13910
+ const skills2 = [];
13911
+ for (const entry of matches) {
13912
+ const full = join2(dir, entry);
13913
+ let raw;
13914
+ try {
13915
+ raw = await readFile4(full, "utf8");
13916
+ } catch (err) {
13917
+ console.warn(
13918
+ `bamboo-agents: couldn't read ${full}: ${err.message}`
13919
+ );
13920
+ continue;
13921
+ }
13922
+ const parsed = parseSkillContent(raw, full);
13923
+ if (parsed) skills2.push(parsed);
13924
+ }
13925
+ skills2.sort((a, b) => a.name.localeCompare(b.name));
13926
+ return skills2;
13927
+ }
13928
+ async function getLocalSkill(repoPath, name) {
13929
+ const dir = await resolveSkillsDir(repoPath);
13930
+ if (!dir) return null;
13931
+ const expectedFile = `${name}.skill.md`;
13932
+ const entries = await readdir2(dir);
13933
+ if (!entries.includes(expectedFile)) return null;
13934
+ const full = join2(dir, expectedFile);
13935
+ let raw;
13936
+ try {
13937
+ raw = await readFile4(full, "utf8");
13938
+ } catch {
13939
+ return null;
13940
+ }
13941
+ return parseSkillContent(raw, full);
13942
+ }
13943
+ var init_skills_local = __esm({
13944
+ "src/lib/skills-local.ts"() {
13945
+ "use strict";
13946
+ }
13947
+ });
13948
+
13949
+ // src/commands/skills.ts
13950
+ var skills_exports = {};
13951
+ __export(skills_exports, {
13952
+ runSkillsGet: () => runSkillsGet,
13953
+ runSkillsList: () => runSkillsList
13954
+ });
13955
+ async function resolveWorkspacePath() {
13956
+ const cfg = await readConfig();
13957
+ if (!cfg) {
13958
+ console.error(
13959
+ "bamboo-agents: no workspace configured. Run `bamboo-agents init` first."
13960
+ );
13961
+ process.exit(1);
13962
+ }
13963
+ return cfg.repo_path;
13964
+ }
13965
+ function summarize(description, max = 80) {
13966
+ const oneLine = description.replace(/\s+/g, " ").trim();
13967
+ if (oneLine.length <= max) return oneLine;
13968
+ return oneLine.slice(0, max - 1) + "\u2026";
13969
+ }
13970
+ function padRight(s, n) {
13971
+ return s.length >= n ? s : s + " ".repeat(n - s.length);
13972
+ }
13973
+ async function runSkillsList() {
13974
+ const repoPath = await resolveWorkspacePath();
13975
+ const skills2 = await listLocalSkills(repoPath);
13976
+ if (skills2.length === 0) {
13977
+ console.log("");
13978
+ console.log(" No skills found.");
13979
+ console.log(` Looked in: ${repoPath}/skills/`);
13980
+ console.log(
13981
+ " Skills are seeded into your workspace on provision (BAM-2309)."
13982
+ );
13983
+ console.log(
13984
+ " If this is empty, the workspace may not have synced yet \u2014 try"
13985
+ );
13986
+ console.log(" `bamboo-agents doctor` to verify your setup.");
13987
+ console.log("");
13988
+ return;
13989
+ }
13990
+ const nameCol = Math.max(
13991
+ "name".length,
13992
+ ...skills2.map((s) => s.name.length)
13993
+ );
13994
+ const header = ` ${padRight("name", nameCol)} description`;
13995
+ const rule = " " + "\u2500".repeat(nameCol) + " " + "\u2500".repeat(Math.min(60, 80 - nameCol));
13996
+ console.log("");
13997
+ console.log(header);
13998
+ console.log(rule);
13999
+ for (const skill of skills2) {
14000
+ console.log(
14001
+ ` ${padRight(skill.name, nameCol)} ${summarize(skill.description, 80 - nameCol - 4)}`
14002
+ );
14003
+ }
14004
+ console.log("");
14005
+ console.log(` ${skills2.length} skill${skills2.length === 1 ? "" : "s"}.`);
14006
+ console.log("");
14007
+ console.log(" Print one with: bamboo-agents skills get <name>");
14008
+ console.log("");
14009
+ }
14010
+ async function runSkillsGet(name) {
14011
+ if (!name || !name.trim()) {
14012
+ console.error("bamboo-agents: skills get requires a skill name.");
14013
+ console.error("Example: bamboo-agents skills get enhance-instructions");
14014
+ process.exit(2);
14015
+ }
14016
+ const repoPath = await resolveWorkspacePath();
14017
+ const skill = await getLocalSkill(repoPath, name.trim());
14018
+ if (!skill) {
14019
+ await printNotFound(repoPath, name);
14020
+ process.exit(2);
14021
+ }
14022
+ printSkillToStdout(skill);
14023
+ }
14024
+ function printSkillToStdout(skill) {
14025
+ process.stdout.write("---\n");
14026
+ process.stdout.write(`name: ${skill.name}
14027
+ `);
14028
+ process.stdout.write(`description: ${skill.description}
14029
+ `);
14030
+ if (skill.disableModelInvocation) {
14031
+ process.stdout.write("disable-model-invocation: true\n");
14032
+ }
14033
+ if (skill.allowedTools.length > 0) {
14034
+ process.stdout.write(
14035
+ `allowed-tools: [${skill.allowedTools.join(", ")}]
14036
+ `
14037
+ );
14038
+ }
14039
+ process.stdout.write("---\n");
14040
+ process.stdout.write("\n");
14041
+ process.stdout.write(skill.content);
14042
+ if (!skill.content.endsWith("\n")) process.stdout.write("\n");
14043
+ }
14044
+ async function printNotFound(repoPath, name) {
14045
+ const all = await listLocalSkills(repoPath);
14046
+ console.error(`bamboo-agents: skill not found: ${name}`);
14047
+ if (all.length === 0) {
14048
+ console.error(`No skills in ${repoPath}/skills/.`);
14049
+ return;
14050
+ }
14051
+ const lower = name.toLowerCase();
14052
+ const prefixMatches = all.filter(
14053
+ (s) => s.name.toLowerCase().startsWith(lower)
14054
+ );
14055
+ const suggestions = prefixMatches.length > 0 ? prefixMatches : all;
14056
+ console.error("");
14057
+ console.error(
14058
+ prefixMatches.length > 0 ? "Did you mean:" : "Available skills (run `bamboo-agents skills list` for descriptions):"
14059
+ );
14060
+ for (const s of suggestions) {
14061
+ console.error(` ${s.name}`);
14062
+ }
14063
+ }
14064
+ var init_skills = __esm({
14065
+ "src/commands/skills.ts"() {
14066
+ "use strict";
14067
+ init_state();
14068
+ init_skills_local();
14069
+ }
14070
+ });
14071
+
13780
14072
  // node_modules/commander/esm.mjs
13781
14073
  var import_index = __toESM(require_commander(), 1);
13782
14074
  var {
@@ -13822,6 +14114,15 @@ program2.command("doctor").description("Verify your local setup is ready").actio
13822
14114
  const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
13823
14115
  await runDoctor2();
13824
14116
  });
14117
+ var skills = program2.command("skills").description("Read workspace skills from your local clone");
14118
+ skills.command("list").description("List every skill in the workspace").action(async () => {
14119
+ const { runSkillsList: runSkillsList2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14120
+ await runSkillsList2();
14121
+ });
14122
+ skills.command("get <name>").description("Print one skill's SKILL.md body to stdout").action(async (name) => {
14123
+ const { runSkillsGet: runSkillsGet2 } = await Promise.resolve().then(() => (init_skills(), skills_exports));
14124
+ await runSkillsGet2(name);
14125
+ });
13825
14126
  program2.parseAsync().catch((err) => {
13826
14127
  const message = err instanceof Error ? err.message : String(err);
13827
14128
  console.error(`bamboo-agents: ${message}`);