nimblebrain 0.5.0 → 0.7.0

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/README.md CHANGED
@@ -36,7 +36,7 @@ later.
36
36
  `--json` makes every command answer one JSON object, `{"ok": true, ...}` or
37
37
  `{"ok": false, "error": "<CODE>", "fix": "..."}`, for scripts and coding agents.
38
38
  `--yes` takes every default. `--agent claude-code|cursor|codex|none` names the agent to
39
- connect. `npx nimblebrain help --json` lists every command, flag and error code.
39
+ connect. `npx nimblebrain help --json` lists every command with the fields it answers, every flag and every error code.
40
40
 
41
41
  When a newer CLI or NimbleBrain release exists, the CLI says so on stderr after its
42
42
  answer (once a day at most; it never updates anything itself).
@@ -222,7 +222,6 @@ var ERRORS = {
222
222
  NOT_INSTALLED: "Run `npx nimblebrain` to install it.",
223
223
  NOT_OURS: "Another install holds this name or its data. Remove it yourself, or choose a --home whose folder has another name.",
224
224
  NETWORK: "Check the network connection, then run the same command again.",
225
- MODEL_KEY_MISSING: "Run `npx nimblebrain key` in your own terminal to enter a model key.",
226
225
  HEALTH_TIMEOUT: "Run `npx nimblebrain logs` and look at the last error line.",
227
226
  AGENT_UNSUPPORTED: "Pass --agent claude-code, cursor, codex or none.",
228
227
  START_FAILED: "Run `npx nimblebrain logs` and look at the last error line, then run this again.",
@@ -248,6 +247,17 @@ var ERRORS = {
248
247
  REQUEST_FAILED: "Run `npx nimblebrain logs` and look at the last error line, then run this again."
249
248
  };
250
249
  var FIX_VARIANTS = {
250
+ DOCKER_MISSING: {
251
+ mac_brew: "Install Docker Desktop with `brew install --cask docker`, open it once from Applications, then run this again.",
252
+ mac: "Install Docker Desktop (https://docs.docker.com/desktop/setup/install/mac-install/), open it once, then run this again."
253
+ },
254
+ COMPOSE_MISSING: {
255
+ brew: "Install Compose with `brew install docker-compose`, then run this again."
256
+ },
257
+ LOW_MEMORY: {
258
+ colima: "Restart Colima with more memory: `colima stop && colima start --memory 4`, then run this again.",
259
+ docker_desktop: "In Docker Desktop, open Settings > Resources, set Memory to at least 2 GB, apply, then run this again."
260
+ },
251
261
  LOCAL_MODEL_UNREACHABLE: {
252
262
  brew_install: "Install Ollama with `brew install ollama`, then run this again; it offers to start Ollama for you.",
253
263
  app: "Open the Ollama app, then run this again.",
@@ -519,7 +529,7 @@ var FLAG_SPECS = {
519
529
  provider: {
520
530
  type: "string",
521
531
  takes: "name",
522
- description: "The model provider for key (default anthropic)",
532
+ description: "The model provider for key (default anthropic); the installed release decides which it takes, and key lists them",
523
533
  commands: ["key"]
524
534
  },
525
535
  "local-model": {
@@ -560,7 +570,7 @@ var FLAG_SPECS = {
560
570
  help: {
561
571
  type: "boolean",
562
572
  short: "h",
563
- description: "The commands and flags; with --json, these and every error code as JSON"
573
+ description: "The commands and flags; with --json, these, each command's answer and every error code as JSON"
564
574
  },
565
575
  version: { type: "boolean", short: "v", description: "This CLI's version" }
566
576
  };
@@ -719,9 +729,34 @@ function composeEnv(deps, vars) {
719
729
  }
720
730
  return env;
721
731
  }
732
+ var PLUGIN = { cmd: "docker", args: ["compose"] };
733
+ var found = new WeakMap;
734
+ function findCompose(deps) {
735
+ let lookup = found.get(deps);
736
+ if (!lookup) {
737
+ lookup = lookUpCompose(deps);
738
+ found.set(deps, lookup);
739
+ }
740
+ return lookup;
741
+ }
742
+ async function lookUpCompose(deps) {
743
+ for (const program of [PLUGIN, { cmd: "docker-compose", args: [] }]) {
744
+ const res = await deps.exec(program.cmd, [...program.args, "version", "--short"]);
745
+ if (res.code === 0 && majorOf(res.stdout) >= 2)
746
+ return { ...program, version: res.stdout.trim() };
747
+ }
748
+ return;
749
+ }
750
+ function majorOf(version) {
751
+ return Number.parseInt(version.trim().replace(/^v/, ""), 10);
752
+ }
753
+ async function composeExec(deps, args, opts) {
754
+ const program = await findCompose(deps) ?? PLUGIN;
755
+ return deps.exec(program.cmd, [...program.args, ...args], opts);
756
+ }
722
757
  async function compose(deps, home, args, timeoutMs = 120000) {
723
758
  const vars = keyVars(await deps.readText(paths(home).compose) ?? "");
724
- return deps.exec("docker", ["compose", ...args], {
759
+ return composeExec(deps, args, {
725
760
  cwd: home,
726
761
  env: composeEnv(deps, vars),
727
762
  timeoutMs
@@ -777,14 +812,14 @@ var INSTANCE_JSON = `${JSON.stringify({ auth: { adapter: "dev" } }, null, 2)}
777
812
 
778
813
  // src/doctor.ts
779
814
  var SUPPORTED_ARCH = ["x86_64", "amd64", "aarch64", "arm64"];
780
- var MIN_MEMORY = 2 * 1024 ** 3;
815
+ var MIN_MEMORY = 1.75 * 1024 ** 3;
781
816
  async function doctor(deps, port, portInUseByUs = false) {
782
817
  const log = recorder();
783
818
  await checkDocker(deps, log);
784
819
  const facts = await checkDaemon(deps, log);
785
820
  await checkCompose(deps, log);
786
821
  checkArch(facts.arch, log);
787
- checkMemory(facts.memory, log);
822
+ checkMemory(facts, log);
788
823
  await checkPort(deps, port, portInUseByUs, log);
789
824
  return { ok: true, checks: log.checks, arch: facts.arch };
790
825
  }
@@ -795,16 +830,18 @@ function recorder() {
795
830
  pass: (check, detail) => {
796
831
  checks.push({ check, ok: true, detail });
797
832
  },
798
- fail: (check, code, detail) => {
833
+ fail: (check, code, detail, variant) => {
799
834
  checks.push({ check, ok: false, detail });
800
- throw new CliError(code, detail, { check, checks });
835
+ throw new CliError(code, detail, { check, checks }, variant);
801
836
  }
802
837
  };
803
838
  }
804
839
  async function checkDocker(deps, log) {
805
840
  const version = await deps.exec("docker", ["--version"]);
806
- if (version.missing)
807
- log.fail("docker", "DOCKER_MISSING", "Docker is not installed.");
841
+ if (version.missing) {
842
+ const variant = deps.platform !== "darwin" ? undefined : await deps.which("brew") ? "mac_brew" : "mac";
843
+ log.fail("docker", "DOCKER_MISSING", "Docker is not installed.", variant);
844
+ }
808
845
  log.pass("docker", version.stdout.trim());
809
846
  }
810
847
  async function checkDaemon(deps, log) {
@@ -820,12 +857,12 @@ ${info.stdout}`)) {
820
857
  return parseInfo(info.stdout);
821
858
  }
822
859
  async function checkCompose(deps, log) {
823
- const compose = await deps.exec("docker", ["compose", "version", "--short"]);
824
- const major = Number.parseInt(compose.stdout.trim().replace(/^v/, ""), 10);
825
- if (compose.code !== 0 || !(major >= 2)) {
826
- log.fail("compose", "COMPOSE_MISSING", "Docker Compose v2 is not available.");
860
+ const program = await findCompose(deps);
861
+ if (!program) {
862
+ const variant = deps.platform === "darwin" && await deps.which("brew") ? "brew" : undefined;
863
+ log.fail("compose", "COMPOSE_MISSING", "Docker Compose v2 is not available.", variant);
827
864
  }
828
- log.pass("compose", compose.stdout.trim());
865
+ log.pass("compose", program.cmd === "docker" ? program.version : `${program.version} (${program.cmd})`);
829
866
  }
830
867
  function checkArch(arch, log) {
831
868
  if (!SUPPORTED_ARCH.includes(arch)) {
@@ -833,9 +870,9 @@ function checkArch(arch, log) {
833
870
  }
834
871
  log.pass("arch", arch);
835
872
  }
836
- function checkMemory(memory, log) {
873
+ function checkMemory({ memory, kind }, log) {
837
874
  if (memory > 0 && memory < MIN_MEMORY) {
838
- log.fail("memory", "LOW_MEMORY", `Docker has ${gib(memory)} of memory; NimbleBrain needs 2 GB.`);
875
+ log.fail("memory", "LOW_MEMORY", `Docker has ${gib(memory)} of memory; NimbleBrain needs 2 GB.`, kind);
839
876
  }
840
877
  log.pass("memory", memory > 0 ? gib(memory) : "unknown");
841
878
  }
@@ -851,7 +888,8 @@ function parseInfo(stdout) {
851
888
  const info = JSON.parse(stdout);
852
889
  return {
853
890
  arch: typeof info.Architecture === "string" ? info.Architecture : "",
854
- memory: typeof info.MemTotal === "number" ? info.MemTotal : 0
891
+ memory: typeof info.MemTotal === "number" ? info.MemTotal : 0,
892
+ kind: info.OperatingSystem === "Docker Desktop" ? "docker_desktop" : info.Name === "colima" ? "colima" : undefined
855
893
  };
856
894
  } catch {
857
895
  return { arch: "", memory: 0 };
@@ -861,23 +899,112 @@ function gib(bytes) {
861
899
  return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
862
900
  }
863
901
 
902
+ // src/answers.ts
903
+ var STATE = {
904
+ version: "The NimbleBrain runtime release installed, without the leading v",
905
+ cli_version: "This CLI's version; it moves independently of the runtime",
906
+ health: "ok when NimbleBrain answers, else down",
907
+ url: "Where the web UI and API answer, on 127.0.0.1",
908
+ workspaces: "Each workspace as {id, name, mcp}, mcp being its MCP URL; empty while down",
909
+ agent: "{connected, skill}: the coding agent init connected (or null), and the nimblebrain skill's name when that agent has it (else null)",
910
+ model_key: "set or missing: whether the install's .env holds a model key (never the key)",
911
+ host_loopback: "Whether this release can reach a server on this machine; mcp add needs it, update brings it",
912
+ local_model: "The Ollama model NimbleBrain's agents run on, or null for a hosted model key",
913
+ telemetry: "{state, locked?, ask?, set?}: on, off or undecided; locked says why no one can change it here; ask and set, only while undecided, are the question to pass to the person and the command that answers it",
914
+ updates: "{cli?, runtime?}, each {current, latest}: what the last cached lookup found; absent when nothing is known or the check is off"
915
+ };
916
+ var OLLAMA_STARTED = "The command that started Ollama, when this run started it";
917
+ var ANSWER_FIELDS = {
918
+ init: {
919
+ ...STATE,
920
+ already: "true when an install was already here; it was reported, not changed",
921
+ manual: "The settings to add to the coding agent by hand, when connecting it failed",
922
+ opened: "Whether the browser opened, when init tried (a new install, a person at a terminal)",
923
+ ollama_started: OLLAMA_STARTED
924
+ },
925
+ doctor: {
926
+ checks: "Each check run, in order, as {check, ok, detail}",
927
+ arch: "The CPU architecture Docker reports",
928
+ ollama_started: `${OLLAMA_STARTED}; on a local model only`
929
+ },
930
+ status: STATE,
931
+ open: {
932
+ url: "The web UI's URL, to open by hand when opened is false",
933
+ opened: "Whether a browser was started"
934
+ },
935
+ key: {
936
+ provider: "The provider the key was entered for",
937
+ model_key: "set"
938
+ },
939
+ "local-model": {
940
+ local_model: "The model NimbleBrain's agents now run on (nimblebrain-<model>)",
941
+ ollama_started: OLLAMA_STARTED
942
+ },
943
+ telemetry: { telemetry: STATE.telemetry },
944
+ up: { ...STATE, ollama_started: OLLAMA_STARTED },
945
+ down: { health: "down" },
946
+ logs: { lines: "The runtime's last log lines, up to 100" },
947
+ update: {
948
+ ...STATE,
949
+ already: "true when the install was already on that release",
950
+ from: "The release moved from, as vX.Y.Z, when it moved",
951
+ skill_update: "What happened to the connected agent's nimblebrain skill: updated, unchanged, not_installed or failed; absent with no agent"
952
+ },
953
+ uninstall: { removed: "true" },
954
+ "mcp add": {
955
+ serverName: "The name the server was added under",
956
+ url: "The URL as given",
957
+ dialed: "Where NimbleBrain, inside Docker, connects to it",
958
+ placements: "Where the server's UI appears, from its Server Card",
959
+ wsId: "The workspace it was added to",
960
+ warning: "Why the server is not connected yet (it was added anyway), when it is not",
961
+ notice: "Anything else NimbleBrain says about the server, when it says something"
962
+ },
963
+ "mcp list": {
964
+ wsId: "The workspace listed",
965
+ servers: "Each server as {serverName, displayName?, url?, state?, status?, statusReason?, toolCount?}"
966
+ },
967
+ "mcp remove": {
968
+ serverName: "The server removed",
969
+ wsId: "The workspace it was removed from"
970
+ },
971
+ help: {
972
+ cli_version: "This CLI's version",
973
+ commands: "Each command as {name, args, description, answer}",
974
+ flags: "Each flag as {name, short?, takes, description, commands?}",
975
+ errors: "Each error code as {code, fix, exit}"
976
+ }
977
+ };
978
+
864
979
  // src/help.ts
865
980
  var HELP_COMMAND = {
866
981
  name: "help",
867
982
  args: [],
868
- description: "These commands and flags; with --json, these and every error code as JSON"
983
+ description: "These commands and flags; with --json, these, each command's answer and every error code as JSON",
984
+ answer: { ...ANSWER_FIELDS.help }
869
985
  };
870
986
  function commands() {
871
987
  const list = Object.keys(COMMAND_SPECS).flatMap((name) => {
872
988
  if (name === "mcp") {
873
- return Object.entries(MCP_SUBCOMMANDS).map(([sub, spec]) => ({
874
- name: `mcp ${sub}`,
875
- args: spec.operand ? [`<${spec.operand}>`] : [],
876
- description: spec.description
877
- }));
989
+ return Object.keys(MCP_SUBCOMMANDS).map((sub) => {
990
+ const spec = MCP_SUBCOMMANDS[sub];
991
+ return {
992
+ name: `mcp ${sub}`,
993
+ args: spec.operand ? [`<${spec.operand}>`] : [],
994
+ description: spec.description,
995
+ answer: { ...ANSWER_FIELDS[`mcp ${sub}`] }
996
+ };
997
+ });
878
998
  }
879
999
  const spec = COMMAND_SPECS[name];
880
- return [{ name, args: [...spec.args], description: spec.description }];
1000
+ return [
1001
+ {
1002
+ name,
1003
+ args: [...spec.args],
1004
+ description: spec.description,
1005
+ answer: { ...ANSWER_FIELDS[name] }
1006
+ }
1007
+ ];
881
1008
  });
882
1009
  return [...list, HELP_COMMAND];
883
1010
  }
@@ -903,7 +1030,13 @@ function errors() {
903
1030
  }));
904
1031
  }
905
1032
  function describe(version) {
906
- return { ok: true, cli_version: version, commands: commands(), flags: flags(), errors: errors() };
1033
+ return {
1034
+ ok: true,
1035
+ cli_version: version,
1036
+ commands: commands(),
1037
+ flags: flags(),
1038
+ errors: errors()
1039
+ };
907
1040
  }
908
1041
  function helpText(version) {
909
1042
  const cmds = commands().map((c) => [[c.name, ...c.args].join(" "), c.description]);
@@ -924,7 +1057,7 @@ function helpText(version) {
924
1057
  "Flags:",
925
1058
  ...fls.map(row),
926
1059
  "",
927
- "Every error code and its fix: npx nimblebrain help --json",
1060
+ "What each command answers, and every error code and its fix: npx nimblebrain help --json",
928
1061
  ""
929
1062
  ].join(`
930
1063
  `);
@@ -1183,7 +1316,7 @@ async function setRuntimeTelemetry(deps, url, consent) {
1183
1316
  // package.json
1184
1317
  var package_default = {
1185
1318
  name: "nimblebrain",
1186
- version: "0.5.0",
1319
+ version: "0.7.0",
1187
1320
  description: "Install, run and connect NimbleBrain, the open-source runtime for agents and MCP apps, on this machine.",
1188
1321
  license: "Apache-2.0",
1189
1322
  type: "module",
@@ -1267,6 +1400,9 @@ async function readWorkspaces(deps, url) {
1267
1400
  const body = boot.body;
1268
1401
  return (body.workspaces ?? []).filter((w) => typeof w.id === "string" && typeof w.name === "string").map((w) => ({ id: w.id, name: w.name, mcp: `${url}/mcp/${w.id}` }));
1269
1402
  }
1403
+ function hasModelIn(r) {
1404
+ return r.model_key === "set" || r.local_model !== null;
1405
+ }
1270
1406
 
1271
1407
  // src/open.ts
1272
1408
  function browserCommand(deps, url) {
@@ -1396,15 +1532,13 @@ async function openWhenDone(ctx, result) {
1396
1532
  const { deps, flags } = ctx;
1397
1533
  if (!deps.interactive || flags.json || flags.noOpen)
1398
1534
  return result;
1399
- if (result.health !== "ok" || typeof result.url !== "string")
1535
+ if (result.health !== "ok" || !hasModelIn(result))
1400
1536
  return result;
1401
1537
  return { ...result, opened: await openBrowser(deps, result.url) };
1402
1538
  }
1403
1539
  async function settleFailure(rec, home, consent, err) {
1404
- if (err.code !== "MODEL_KEY_MISSING") {
1405
- const check = typeof err.detail.check === "string" ? err.detail.check : undefined;
1406
- rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
1407
- }
1540
+ const check = typeof err.detail.check === "string" ? err.detail.check : undefined;
1541
+ rec.record(check ? "cli.doctor_failed" : "cli.init_failed", { error: err.code, check });
1408
1542
  await rec.settle(home, consent);
1409
1543
  }
1410
1544
  async function chooseConsent(ctx) {
@@ -1460,11 +1594,6 @@ async function install(ctx, consent, rec, begun) {
1460
1594
  agent: state.agent ?? null
1461
1595
  });
1462
1596
  await rec.settle(home, consent);
1463
- if (result.model_key === "missing" && !result.local_model) {
1464
- throw new CliError("MODEL_KEY_MISSING", "NimbleBrain is running; chat needs a model key.", {
1465
- ...result
1466
- });
1467
- }
1468
1597
  return { ...result };
1469
1598
  });
1470
1599
  }
@@ -1731,7 +1860,7 @@ async function guardOurs(deps, home) {
1731
1860
  throw new CliError("NOT_OURS", `${file} already exists and this CLI did not write it.`);
1732
1861
  }
1733
1862
  }
1734
- const projects = await deps.exec("docker", ["compose", "ls", "-a", "--format", "json"]);
1863
+ const projects = await composeExec(deps, ["ls", "-a", "--format", "json"]);
1735
1864
  const taken = projects.code === 0 && listsProject(projects.stdout, project);
1736
1865
  const volumes = await deps.exec("docker", [
1737
1866
  "volume",
@@ -2107,7 +2236,9 @@ function statusLines(r, cli, command) {
2107
2236
  lines.push(` servers on this machine: not reachable until ${cli} update`);
2108
2237
  lines.push(telemetryLine(r.telemetry));
2109
2238
  lines.push(` CLI ${r.cli_version}`);
2110
- if (command === "init" && !r.already && r.health === "ok") {
2239
+ if (command === "init" && !r.already && r.health === "ok" && !hasModelIn(r)) {
2240
+ lines.push("", `Next: give NimbleBrain a model so it can chat. Run ${cli} key in your own terminal to enter a model key, or ${cli} local-model to run one on this machine with Ollama.`);
2241
+ } else if (command === "init" && !r.already && r.health === "ok") {
2111
2242
  const ask = agent ? `, or ask ${AGENT_NAMES[agent] ?? agent} what NimbleBrain can do` : "";
2112
2243
  const use = r.opened ? `use NimbleBrain in your browser at ${r.url}` : `open ${r.url}`;
2113
2244
  lines.push("", `Next: ${use}${ask}. Stop it with ${cli} down.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nimblebrain",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Install, run and connect NimbleBrain, the open-source runtime for agents and MCP apps, on this machine.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",