@beastmode-develeap/beastmode 0.1.34 → 0.1.35

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
@@ -8647,6 +8647,301 @@ function checkDocker() {
8647
8647
  fix: "Install Docker Desktop or start the Docker daemon"
8648
8648
  };
8649
8649
  }
8650
+ function checkDockerComposeVersion() {
8651
+ const v2 = tryExec("docker compose version --short 2>/dev/null");
8652
+ if (v2) {
8653
+ const major = parseInt(v2.split(".")[0], 10);
8654
+ if (!isNaN(major) && major >= 2) {
8655
+ return {
8656
+ label: "Docker Compose",
8657
+ status: "pass",
8658
+ detail: `v${v2} (plugin)`
8659
+ };
8660
+ }
8661
+ return {
8662
+ label: "Docker Compose",
8663
+ status: "fail",
8664
+ detail: `v${v2} \u2014 need v2.0 or newer`,
8665
+ fix: "Update Docker Desktop to the latest version"
8666
+ };
8667
+ }
8668
+ const v1 = tryExec("docker-compose version --short 2>/dev/null");
8669
+ if (v1) {
8670
+ return {
8671
+ label: "Docker Compose",
8672
+ status: "fail",
8673
+ detail: `legacy v${v1} \u2014 beastmode requires v2.0+ (plugin form)`,
8674
+ fix: "Install Docker Compose v2 (bundled with modern Docker Desktop)"
8675
+ };
8676
+ }
8677
+ return {
8678
+ label: "Docker Compose",
8679
+ status: "fail",
8680
+ detail: "not installed",
8681
+ fix: "Install Docker Compose v2 (bundled with Docker Desktop)"
8682
+ };
8683
+ }
8684
+ function checkProjectDirEnv(factoryDir) {
8685
+ if (!factoryDir) {
8686
+ return {
8687
+ label: "PROJECT_DIR (.env)",
8688
+ status: "warn",
8689
+ detail: "no factory in scope"
8690
+ };
8691
+ }
8692
+ const envPath = join22(factoryDir, ".env");
8693
+ if (!existsSync24(envPath)) {
8694
+ return {
8695
+ label: "PROJECT_DIR (.env)",
8696
+ status: "fail",
8697
+ detail: `.env not found at ${envPath}`,
8698
+ fix: "Run `beastmode init` in this directory to generate .env"
8699
+ };
8700
+ }
8701
+ let content;
8702
+ try {
8703
+ content = readFileSync21(envPath, "utf-8");
8704
+ } catch {
8705
+ return {
8706
+ label: "PROJECT_DIR (.env)",
8707
+ status: "fail",
8708
+ detail: ".env unreadable"
8709
+ };
8710
+ }
8711
+ const lines = content.split("\n");
8712
+ const line = lines.find(
8713
+ (l) => l.trim().startsWith("PROJECT_DIR=") && !l.trim().startsWith("#")
8714
+ );
8715
+ if (!line) {
8716
+ return {
8717
+ label: "PROJECT_DIR (.env)",
8718
+ status: "fail",
8719
+ detail: "PROJECT_DIR not set (or commented out)",
8720
+ fix: "Re-run `beastmode init --project <path>` to populate it"
8721
+ };
8722
+ }
8723
+ const value = line.split("=").slice(1).join("=").trim();
8724
+ if (!value) {
8725
+ return {
8726
+ label: "PROJECT_DIR (.env)",
8727
+ status: "fail",
8728
+ detail: "PROJECT_DIR is empty",
8729
+ fix: "Re-run `beastmode init --project <path>` to populate it"
8730
+ };
8731
+ }
8732
+ if (!existsSync24(value)) {
8733
+ return {
8734
+ label: "PROJECT_DIR (.env)",
8735
+ status: "fail",
8736
+ detail: `PROJECT_DIR=${value} does not exist`,
8737
+ fix: `Clone your project to ${value} or re-run 'beastmode init --project <path>'`
8738
+ };
8739
+ }
8740
+ if (!existsSync24(join22(value, ".git"))) {
8741
+ return {
8742
+ label: "PROJECT_DIR (.env)",
8743
+ status: "fail",
8744
+ detail: `PROJECT_DIR=${value} is not a git repo`,
8745
+ fix: "Run `git init` in the project dir, or point PROJECT_DIR at an existing git clone"
8746
+ };
8747
+ }
8748
+ const remote = tryExec(`git -C "${value}" remote get-url origin 2>/dev/null`);
8749
+ if (!remote) {
8750
+ return {
8751
+ label: "PROJECT_DIR (.env)",
8752
+ status: "warn",
8753
+ detail: `${value} has no origin remote \u2014 daemon can't auto-resolve github repo (Gap 2)`,
8754
+ fix: `cd ${value} && git remote add origin <url>, or set PROJECT_REPO in .env as a last-resort override`
8755
+ };
8756
+ }
8757
+ return {
8758
+ label: "PROJECT_DIR (.env)",
8759
+ status: "pass",
8760
+ detail: `${value} (origin: ${remote})`
8761
+ };
8762
+ }
8763
+ async function checkFactoryContainers(factoryDir) {
8764
+ if (!factoryDir) {
8765
+ return {
8766
+ label: "Factory containers",
8767
+ status: "warn",
8768
+ detail: "no factory in scope"
8769
+ };
8770
+ }
8771
+ const composePath = join22(factoryDir, "docker-compose.yml");
8772
+ if (!existsSync24(composePath)) {
8773
+ return {
8774
+ label: "Factory containers",
8775
+ status: "warn",
8776
+ detail: "no docker-compose.yml in factory",
8777
+ fix: "Run `beastmode init` to generate one"
8778
+ };
8779
+ }
8780
+ const out = tryExec(
8781
+ `docker compose -f "${composePath}" --project-directory "${factoryDir}" ps --format json 2>/dev/null`,
8782
+ 15e3
8783
+ );
8784
+ if (out === null) {
8785
+ return {
8786
+ label: "Factory containers",
8787
+ status: "warn",
8788
+ detail: "docker compose ps failed \u2014 factory may be down",
8789
+ fix: "Run `docker compose up -d` in the factory directory"
8790
+ };
8791
+ }
8792
+ if (!out.trim()) {
8793
+ return {
8794
+ label: "Factory containers",
8795
+ status: "warn",
8796
+ detail: "no containers running",
8797
+ fix: "Run `docker compose up -d` in the factory directory"
8798
+ };
8799
+ }
8800
+ const rows = [];
8801
+ for (const line of out.split("\n")) {
8802
+ const t = line.trim();
8803
+ if (!t) continue;
8804
+ try {
8805
+ const parsed = JSON.parse(t);
8806
+ if (Array.isArray(parsed)) {
8807
+ for (const p of parsed) rows.push(p);
8808
+ } else {
8809
+ rows.push(parsed);
8810
+ }
8811
+ } catch {
8812
+ }
8813
+ }
8814
+ if (rows.length === 0) {
8815
+ return {
8816
+ label: "Factory containers",
8817
+ status: "warn",
8818
+ detail: "docker compose ps output not parseable"
8819
+ };
8820
+ }
8821
+ const required = ["board", "ui", "daemon"];
8822
+ const byService = /* @__PURE__ */ new Map();
8823
+ for (const r of rows) {
8824
+ if (r.Service) {
8825
+ byService.set(r.Service, {
8826
+ state: r.State,
8827
+ health: r.Health,
8828
+ name: r.Name
8829
+ });
8830
+ }
8831
+ }
8832
+ const missing = required.filter((s) => !byService.has(s));
8833
+ if (missing.length > 0) {
8834
+ return {
8835
+ label: "Factory containers",
8836
+ status: "fail",
8837
+ detail: `missing services: ${missing.join(", ")}`,
8838
+ fix: "Run `docker compose up -d` in the factory directory"
8839
+ };
8840
+ }
8841
+ const unhealthy = [];
8842
+ for (const svc of required) {
8843
+ const info5 = byService.get(svc);
8844
+ if (!info5) continue;
8845
+ if (info5.state !== "running") {
8846
+ unhealthy.push(`${svc}(${info5.state})`);
8847
+ } else if (info5.health && info5.health !== "healthy" && info5.health !== "") {
8848
+ unhealthy.push(`${svc}(${info5.health})`);
8849
+ }
8850
+ }
8851
+ if (unhealthy.length > 0) {
8852
+ return {
8853
+ label: "Factory containers",
8854
+ status: "fail",
8855
+ detail: `unhealthy: ${unhealthy.join(", ")}`,
8856
+ fix: "Check `docker compose logs <service>` for the unhealthy container"
8857
+ };
8858
+ }
8859
+ return {
8860
+ label: "Factory containers",
8861
+ status: "pass",
8862
+ detail: `${required.join(", ")} running & healthy`
8863
+ };
8864
+ }
8865
+ async function checkUiServesBoard() {
8866
+ const ports = [8420, 8080, 3e3];
8867
+ for (const port of ports) {
8868
+ const code = await httpGet(`http://127.0.0.1:${port}/board`, 3e3);
8869
+ if (code !== null && code >= 200 && code < 400) {
8870
+ return {
8871
+ label: "UI /board endpoint",
8872
+ status: "pass",
8873
+ detail: `http://127.0.0.1:${port}/board \u2192 ${code}`
8874
+ };
8875
+ }
8876
+ }
8877
+ return {
8878
+ label: "UI /board endpoint",
8879
+ status: "warn",
8880
+ detail: "no UI server responding to /board on 8420, 8080, or 3000",
8881
+ fix: "Check `docker compose logs ui` \u2014 the Node process may have crashed after startup"
8882
+ };
8883
+ }
8884
+ function checkDaemonConfigLoad() {
8885
+ const container = tryExec(
8886
+ `docker ps --filter 'label=com.docker.compose.service=daemon' --format '{{.Names}}' 2>/dev/null | head -n1`
8887
+ );
8888
+ if (!container) {
8889
+ return {
8890
+ label: "Daemon config",
8891
+ status: "warn",
8892
+ detail: "no daemon container running",
8893
+ fix: "Run `docker compose up -d` in the factory directory"
8894
+ };
8895
+ }
8896
+ const pyScript = `
8897
+ from beastmode_daemon.config import DaemonConfig
8898
+ try:
8899
+ c = DaemonConfig.load()
8900
+ errors = c.validate_for_startup()
8901
+ print('REPO=' + (c.github.project_repo or ''))
8902
+ print('DIR=' + str(c.project_dir or ''))
8903
+ print('ERRORS=' + ('; '.join(errors) if errors else 'none'))
8904
+ except Exception as e:
8905
+ print('EXC=' + type(e).__name__ + ': ' + str(e))
8906
+ `.trim();
8907
+ const out = tryExec(
8908
+ `docker exec ${container} python -c "${pyScript.replace(/"/g, '\\"')}" 2>/dev/null`,
8909
+ 12e3
8910
+ );
8911
+ if (!out) {
8912
+ return {
8913
+ label: "Daemon config",
8914
+ status: "warn",
8915
+ detail: `could not execute python inside ${container}`
8916
+ };
8917
+ }
8918
+ const lines = out.split("\n");
8919
+ const repo = lines.find((l) => l.startsWith("REPO="))?.slice(5) ?? "";
8920
+ const dir = lines.find((l) => l.startsWith("DIR="))?.slice(4) ?? "";
8921
+ const errors = lines.find((l) => l.startsWith("ERRORS="))?.slice(7) ?? "";
8922
+ const exc = lines.find((l) => l.startsWith("EXC="))?.slice(4) ?? "";
8923
+ if (exc) {
8924
+ return {
8925
+ label: "Daemon config",
8926
+ status: "fail",
8927
+ detail: `exception: ${exc}`,
8928
+ fix: "Check docker logs + daemon/beastmode_daemon/config.py"
8929
+ };
8930
+ }
8931
+ if (errors && errors !== "none") {
8932
+ return {
8933
+ label: "Daemon config",
8934
+ status: "fail",
8935
+ detail: errors,
8936
+ fix: "See docs/zero-to-productive-readiness.md Gap 2"
8937
+ };
8938
+ }
8939
+ return {
8940
+ label: "Daemon config",
8941
+ status: "pass",
8942
+ detail: `repo=${repo || "<empty>"}, dir=${dir || "<empty>"}`
8943
+ };
8944
+ }
8650
8945
  function checkGhcrAuth() {
8651
8946
  if (isGhcrAuthenticated()) {
8652
8947
  return {
@@ -8971,10 +9266,15 @@ var doctorCommand = new Command11("doctor").description("Health check \u2014 val
8971
9266
  checks.push(...await checkClaudeAuth(env.ANTHROPIC_API_KEY));
8972
9267
  checks.push(checkGithubToken(env));
8973
9268
  checks.push(checkDocker());
9269
+ checks.push(checkDockerComposeVersion());
8974
9270
  checks.push(checkGhcrAuth());
8975
9271
  checks.push(checkGitHubCli());
9272
+ checks.push(checkProjectDirEnv(hasFactory ? factoryDir : null));
8976
9273
  checks.push(checkProjectDirectory(hasFactory ? factoryDir : null));
8977
9274
  checks.push(await checkBoardServer(hasFactory ? factoryDir : null));
9275
+ checks.push(await checkFactoryContainers(hasFactory ? factoryDir : null));
9276
+ checks.push(await checkUiServesBoard());
9277
+ checks.push(checkDaemonConfigLoad());
8978
9278
  checks.push(checkStack(hasFactory ? factoryDir : null));
8979
9279
  checks.push(checkPlaywright());
8980
9280
  checks.push(checkBoardPassword(env, hasFactory ? factoryDir : null));