@beastmode-develeap/beastmode 0.1.3 → 0.1.4

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/index.js CHANGED
@@ -6901,6 +6901,58 @@ function isGhcrAuthenticated() {
6901
6901
  return false;
6902
6902
  }
6903
6903
  }
6904
+ function loginToGhcr(token) {
6905
+ try {
6906
+ execSync(`echo "${token}" | docker login ghcr.io -u beastmode --password-stdin`, {
6907
+ encoding: "utf-8",
6908
+ timeout: 15e3,
6909
+ stdio: ["pipe", "pipe", "pipe"]
6910
+ });
6911
+ return true;
6912
+ } catch {
6913
+ return false;
6914
+ }
6915
+ }
6916
+ function seedConfigFromImage(targetDir, tag) {
6917
+ const configDir = join8(targetDir, "config");
6918
+ const containerName = "bm-config-seed";
6919
+ try {
6920
+ try {
6921
+ execSync(`docker rm -f ${containerName}`, {
6922
+ encoding: "utf-8",
6923
+ timeout: 1e4,
6924
+ stdio: ["pipe", "pipe", "pipe"]
6925
+ });
6926
+ } catch {
6927
+ }
6928
+ execSync(`docker create --name ${containerName} ${GHCR_IMAGE_PREFIX}/daemon:${tag}`, {
6929
+ encoding: "utf-8",
6930
+ timeout: 3e4,
6931
+ stdio: ["pipe", "pipe", "pipe"]
6932
+ });
6933
+ execSync(`docker cp ${containerName}:/app/config/. "${configDir}/"`, {
6934
+ encoding: "utf-8",
6935
+ timeout: 15e3,
6936
+ stdio: ["pipe", "pipe", "pipe"]
6937
+ });
6938
+ execSync(`docker rm ${containerName}`, {
6939
+ encoding: "utf-8",
6940
+ timeout: 1e4,
6941
+ stdio: ["pipe", "pipe", "pipe"]
6942
+ });
6943
+ return true;
6944
+ } catch {
6945
+ try {
6946
+ execSync(`docker rm -f ${containerName}`, {
6947
+ encoding: "utf-8",
6948
+ timeout: 1e4,
6949
+ stdio: ["pipe", "pipe", "pipe"]
6950
+ });
6951
+ } catch {
6952
+ }
6953
+ return false;
6954
+ }
6955
+ }
6904
6956
  function generateComposeYaml(tag) {
6905
6957
  return `services:
6906
6958
  # Python board API \u2014 data layer (SQLite + WebSocket). Internal only.
@@ -6999,7 +7051,7 @@ function step(n, total, text) {
6999
7051
  }
7000
7052
 
7001
7053
  // src/cli/commands/init.ts
7002
- var initCommand = new Command("init").description("Create a new BeastMode factory").argument("[name]", "Factory name (default: current directory name)").option("--project <path>", "Path to target project").option("--preset <preset>", "Pipeline preset (full, lean, prototype, infra, docs)").option("--backend <backend>", "Task backend (beastmode-board, github-issues)").option("--deploy <target>", "Deploy target (pr-only, vercel, aws-ecs, ...)").option("--methodology <name>", "Development methodology plugin").option("--plugin <name>", "Install plugin (repeatable)", collect, []).option("--from <template>", "Import config from template file").option("--ui", "Open web wizard instead of CLI").option("--yes", "Accept all defaults (non-interactive)").action(async (name, opts) => {
7054
+ var initCommand = new Command("init").description("Create a new BeastMode factory").argument("[name]", "Factory name (default: current directory name)").option("--project <path>", "Path to target project").option("--preset <preset>", "Pipeline preset (full, lean, prototype, infra, docs)").option("--backend <backend>", "Task backend (beastmode-board, github-issues)").option("--deploy <target>", "Deploy target (pr-only, vercel, aws-ecs, ...)").option("--methodology <name>", "Development methodology plugin").option("--plugin <name>", "Install plugin (repeatable)", collect, []).option("--from <template>", "Import config from template file").option("--ui", "Open web wizard instead of CLI").option("--yes", "Accept all defaults (non-interactive)").option("--github-token <token>", "GitHub PAT (avoids interactive prompt)").option("--board-password <password>", "Board UI password (avoids interactive prompt)").action(async (name, opts) => {
7003
7055
  try {
7004
7056
  await runInit(name, opts);
7005
7057
  } catch (err) {
@@ -7304,7 +7356,7 @@ async function runImageModeInit(name, opts) {
7304
7356
  const factoryName = name || ".";
7305
7357
  const targetDir = resolve5(factoryName === "." ? "." : factoryName);
7306
7358
  step(1, totalSteps, "Credentials");
7307
- let githubToken = process.env.GITHUB_TOKEN || "";
7359
+ let githubToken = opts.githubToken || process.env.GITHUB_TOKEN || "";
7308
7360
  if (!githubToken && !opts.yes) {
7309
7361
  const answer = await inquirer.prompt([
7310
7362
  {
@@ -7321,8 +7373,8 @@ async function runImageModeInit(name, opts) {
7321
7373
  } else {
7322
7374
  warn("GITHUB_TOKEN not set \u2014 add to .env later");
7323
7375
  }
7324
- let uiPassword = "";
7325
- if (!opts.yes) {
7376
+ let uiPassword = opts.boardPassword || "";
7377
+ if (!uiPassword && !opts.yes) {
7326
7378
  const { password } = await inquirer.prompt([
7327
7379
  {
7328
7380
  type: "password",
@@ -7334,24 +7386,29 @@ async function runImageModeInit(name, opts) {
7334
7386
  uiPassword = password || "";
7335
7387
  if (uiPassword) success("Board UI password set");
7336
7388
  else info("No board password \u2014 UI will be open");
7389
+ } else if (uiPassword) {
7390
+ success("Board UI password set");
7337
7391
  }
7338
7392
  step(2, totalSteps, "Docker Registry");
7339
7393
  if (!isGhcrAuthenticated()) {
7340
- warn("Not logged in to ghcr.io");
7341
- info(" Run: docker login ghcr.io -u <your-github-username>");
7342
- info(" Use a GitHub PAT with read:packages scope as password");
7343
- if (!opts.yes) {
7344
- const { retry } = await inquirer.prompt([
7345
- {
7346
- type: "confirm",
7347
- name: "retry",
7348
- message: "Continue anyway? (you can log in later)",
7349
- default: true
7394
+ if (githubToken && loginToGhcr(githubToken)) {
7395
+ success("Authenticated to ghcr.io (via GitHub token)");
7396
+ } else {
7397
+ info("Not logged in to ghcr.io \u2014 images may still pull if public");
7398
+ info(" To log in manually: docker login ghcr.io -u <your-github-username>");
7399
+ if (!opts.yes && !opts.githubToken) {
7400
+ const { retry } = await inquirer.prompt([
7401
+ {
7402
+ type: "confirm",
7403
+ name: "retry",
7404
+ message: "Continue anyway?",
7405
+ default: true
7406
+ }
7407
+ ]);
7408
+ if (!retry) {
7409
+ error("Aborted \u2014 log in to ghcr.io first");
7410
+ process.exit(1);
7350
7411
  }
7351
- ]);
7352
- if (!retry) {
7353
- error("Aborted \u2014 log in to ghcr.io first");
7354
- process.exit(1);
7355
7412
  }
7356
7413
  }
7357
7414
  } else {
@@ -7374,7 +7431,7 @@ async function runImageModeInit(name, opts) {
7374
7431
  ];
7375
7432
  writeFileSync13(join15(targetDir, ".env"), envLines.join("\n"), "utf-8");
7376
7433
  success(".env");
7377
- for (const dir of ["data", "runs", "daemon/logs", ".beastmode"]) {
7434
+ for (const dir of ["data", "runs", "daemon/logs", ".beastmode", "config"]) {
7378
7435
  mkdirSync12(join15(targetDir, dir), { recursive: true });
7379
7436
  }
7380
7437
  step(4, totalSteps, "Pull Images");
@@ -7386,6 +7443,9 @@ async function runImageModeInit(name, opts) {
7386
7443
  timeout: 3e5
7387
7444
  });
7388
7445
  success("Images pulled successfully");
7446
+ if (seedConfigFromImage(targetDir, "latest")) {
7447
+ success("Default config files seeded");
7448
+ }
7389
7449
  } catch {
7390
7450
  console.log();
7391
7451
  error("Failed to pull BeastMode images from ghcr.io.");