@beastmode-develeap/beastmode 0.1.268 → 0.1.269

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
@@ -3326,24 +3326,35 @@ function createProjectRecord(input) {
3326
3326
  const parsed = typeof input.boardId === "string" ? parseInt(input.boardId, 10) : input.boardId;
3327
3327
  boardId = isNaN(parsed) ? null : parsed;
3328
3328
  }
3329
- let stack = { ...DEFAULT_STACK };
3329
+ let stack = input.stack || { ...DEFAULT_STACK };
3330
3330
  let gitRemote = input.gitRemote;
3331
- try {
3332
- const detected = detectStack(input.resolvedPath);
3333
- stack = {
3334
- detected: detected.framework,
3335
- build_command: detected.suggested_commands.build,
3336
- dev_command: detected.suggested_commands.dev,
3337
- test_command: detected.suggested_commands.test,
3338
- install_command: detected.suggested_commands.install,
3339
- dev_port: detected.dev_port,
3340
- is_monorepo: detected.is_monorepo,
3341
- total_packages: detected.total_packages,
3342
- primary_languages: detected.primary_languages,
3343
- ...detected.packages ? { packages: detected.packages } : {}
3344
- };
3345
- if (!gitRemote && detected.git_remote) gitRemote = detected.git_remote;
3346
- } catch {
3331
+ let plugins = input.plugins;
3332
+ let deployTarget = input.deployTarget;
3333
+ if (!input.stack || gitRemote === void 0 || plugins === void 0 || deployTarget === void 0) {
3334
+ try {
3335
+ const detected = detectStack(input.resolvedPath);
3336
+ if (!input.stack) {
3337
+ stack = {
3338
+ detected: detected.framework,
3339
+ build_command: detected.suggested_commands.build,
3340
+ dev_command: detected.suggested_commands.dev,
3341
+ test_command: detected.suggested_commands.test,
3342
+ install_command: detected.suggested_commands.install,
3343
+ dev_port: detected.dev_port,
3344
+ is_monorepo: detected.is_monorepo,
3345
+ total_packages: detected.total_packages,
3346
+ primary_languages: detected.primary_languages,
3347
+ ...detected.packages ? { packages: detected.packages } : {}
3348
+ };
3349
+ }
3350
+ if (gitRemote === void 0) gitRemote = detected.git_remote || "";
3351
+ if (plugins === void 0) plugins = detected.suggested_plugins || [];
3352
+ if (deployTarget === void 0) deployTarget = detected.suggested_deploy || "pr-only";
3353
+ } catch {
3354
+ if (gitRemote === void 0) gitRemote = "";
3355
+ if (plugins === void 0) plugins = [];
3356
+ if (deployTarget === void 0) deployTarget = "pr-only";
3357
+ }
3347
3358
  }
3348
3359
  const verifyPort = input.verifyPort ?? computeVerifyPort(input.existingProjects);
3349
3360
  return {
@@ -3360,13 +3371,13 @@ function createProjectRecord(input) {
3360
3371
  },
3361
3372
  stack,
3362
3373
  deploy: {
3363
- target: "pr-only",
3374
+ target: deployTarget,
3364
3375
  verify_port: verifyPort,
3365
3376
  config: {}
3366
3377
  },
3367
3378
  pipeline: {},
3368
3379
  models: {},
3369
- plugins: [],
3380
+ plugins,
3370
3381
  slots: { max: null },
3371
3382
  infra: { credentials: { mode: "factory" }, state_backend: "auto" },
3372
3383
  registered_at: (/* @__PURE__ */ new Date()).toISOString()
@@ -3419,6 +3430,7 @@ function readProjectRecord(projectsDir, name) {
3419
3430
  const needsWrite = shape !== "canonical" || isFlat || hasMissingCanonicalFields(parsed);
3420
3431
  if (needsWrite) {
3421
3432
  writeProjectRecord(projectsDir, name, record);
3433
+ console.error(`[project-record] Migrated ${name} from ${shape} to canonical schema`);
3422
3434
  if (isFlat) {
3423
3435
  try {
3424
3436
  unlinkSync(flatPath);
@@ -3442,7 +3454,7 @@ function listProjectRecords(projectsDir) {
3442
3454
  }
3443
3455
  continue;
3444
3456
  }
3445
- if (entry.endsWith(".json")) {
3457
+ if (entry.endsWith(".json") && !entry.endsWith(".json.bak") && !entry.includes(".verifier")) {
3446
3458
  const name = entry.slice(0, -5);
3447
3459
  if (!seen.has(name)) {
3448
3460
  seen.add(name);
@@ -6076,6 +6088,34 @@ function getBoardRoutes(factoryDir) {
6076
6088
  return { success: true };
6077
6089
  }
6078
6090
  },
6091
+ // ── Doctor ──
6092
+ {
6093
+ method: "GET",
6094
+ pattern: "/api/doctor",
6095
+ handler: () => {
6096
+ const projectsDir = join14(factoryDir, ".beastmode", "projects");
6097
+ const projects = listProjectRecords(projectsDir);
6098
+ const checks = [];
6099
+ for (const p of projects) {
6100
+ const hasStack = !!(p.stack && p.stack.detected);
6101
+ const hasPlugins = Array.isArray(p.plugins);
6102
+ const hasInfra = !!(p.infra && p.infra.credentials);
6103
+ const hasDeployTarget = !!(p.deploy && p.deploy.target);
6104
+ const isCanonical = hasStack && hasPlugins && hasInfra && hasDeployTarget;
6105
+ checks.push({
6106
+ name: p.name,
6107
+ status: isCanonical ? "ok" : "warning",
6108
+ details: isCanonical ? "canonical schema" : `missing: ${[!hasStack && "stack", !hasPlugins && "plugins", !hasInfra && "infra", !hasDeployTarget && "deploy.target"].filter(Boolean).join(", ")}`
6109
+ });
6110
+ }
6111
+ const overallStatus = checks.every((c) => c.status === "ok") ? "ok" : "warning";
6112
+ return {
6113
+ status: overallStatus,
6114
+ project_count: projects.length,
6115
+ checks
6116
+ };
6117
+ }
6118
+ },
6079
6119
  // ── Projects ──
6080
6120
  {
6081
6121
  method: "GET",
@@ -6219,21 +6259,22 @@ function getBoardRoutes(factoryDir) {
6219
6259
  name: projectName,
6220
6260
  resolvedPath,
6221
6261
  gitRemote: stack.git_remote || void 0,
6222
- verifyPort
6262
+ verifyPort,
6263
+ plugins: stack.suggested_plugins || [],
6264
+ deployTarget: stack.suggested_deploy || "pr-only",
6265
+ stack: {
6266
+ detected: stack.framework,
6267
+ build_command: stack.suggested_commands.build,
6268
+ dev_command: stack.suggested_commands.dev,
6269
+ test_command: stack.suggested_commands.test,
6270
+ install_command: stack.suggested_commands.install,
6271
+ dev_port: stack.dev_port,
6272
+ is_monorepo: stack.is_monorepo,
6273
+ total_packages: stack.total_packages,
6274
+ primary_languages: stack.primary_languages,
6275
+ ...stack.packages ? { packages: stack.packages } : {}
6276
+ }
6223
6277
  });
6224
- record.stack = {
6225
- detected: stack.framework,
6226
- build_command: stack.suggested_commands.build,
6227
- dev_command: stack.suggested_commands.dev,
6228
- test_command: stack.suggested_commands.test,
6229
- install_command: stack.suggested_commands.install,
6230
- dev_port: stack.dev_port,
6231
- is_monorepo: stack.is_monorepo,
6232
- total_packages: stack.total_packages,
6233
- primary_languages: stack.primary_languages,
6234
- ...stack.packages ? { packages: stack.packages } : {}
6235
- };
6236
- record.infra = { credentials: { mode: "factory" }, state_backend: "auto" };
6237
6278
  writeProjectRecord(projectsDir, projectName, record);
6238
6279
  const infraDir = join14(projectsDir, projectName, "infra");
6239
6280
  mkdirSync12(join14(infraDir, "terraform"), { recursive: true });
@@ -14647,9 +14688,15 @@ function projectAddAction(factoryDir, projectPath, opts) {
14647
14688
  if (typeof port === "number" && port >= verifyPort) verifyPort = port + 1;
14648
14689
  }
14649
14690
  const boardId = opts.boardId ? parseInt(opts.boardId, 10) : null;
14650
- const record = createProjectRecord({ name: projectName, resolvedPath, boardId, verifyPort, gitRemote });
14651
- if (detectedStack) {
14652
- record.stack = {
14691
+ const record = createProjectRecord({
14692
+ name: projectName,
14693
+ resolvedPath,
14694
+ boardId,
14695
+ verifyPort,
14696
+ gitRemote,
14697
+ plugins: detectedStack?.suggested_plugins || [],
14698
+ deployTarget: detectedStack?.suggested_deploy || "pr-only",
14699
+ stack: detectedStack ? {
14653
14700
  detected: detectedStack.framework,
14654
14701
  build_command: detectedStack.suggested_commands.build,
14655
14702
  dev_command: detectedStack.suggested_commands.dev,
@@ -14660,8 +14707,8 @@ function projectAddAction(factoryDir, projectPath, opts) {
14660
14707
  total_packages: detectedStack.total_packages,
14661
14708
  primary_languages: detectedStack.primary_languages,
14662
14709
  ...detectedStack.packages ? { packages: detectedStack.packages } : {}
14663
- };
14664
- }
14710
+ } : void 0
14711
+ });
14665
14712
  writeProjectRecord(projectsDir, projectName, record);
14666
14713
  const runsDir = join38(factoryDir, "runs", projectName);
14667
14714
  if (!existsSync39(runsDir)) mkdirSync24(runsDir, { recursive: true });