@codemap-ai/cli 0.1.1 → 0.1.3

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.
Files changed (2) hide show
  1. package/dist/index.js +111 -34
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -8882,6 +8882,59 @@ function prompt(question, defaultValue) {
8882
8882
  });
8883
8883
  });
8884
8884
  }
8885
+ function select(question, options) {
8886
+ return new Promise((resolve) => {
8887
+ let current = 0;
8888
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
8889
+ process.stdin.setRawMode?.(true);
8890
+ process.stdin.resume();
8891
+ process.stdin.setEncoding("utf8");
8892
+ const render = () => {
8893
+ if (rendered > 0) {
8894
+ process.stdout.write(`\x1B[${rendered}A`);
8895
+ }
8896
+ process.stdout.write(`\r${question}
8897
+ `);
8898
+ for (let i = 0; i < options.length; i++) {
8899
+ const opt = options[i];
8900
+ const prefix = i === current ? "\u276F " : " ";
8901
+ const line = `${prefix}${opt.label}${opt.description ? ` \u2014 ${opt.description}` : ""}`;
8902
+ process.stdout.write(`\x1B[2K${line}
8903
+ `);
8904
+ }
8905
+ rendered = options.length + 1;
8906
+ };
8907
+ let rendered = 0;
8908
+ render();
8909
+ const onData = (key) => {
8910
+ if (key === "\x1B[A") {
8911
+ current = (current - 1 + options.length) % options.length;
8912
+ render();
8913
+ } else if (key === "\x1B[B") {
8914
+ current = (current + 1) % options.length;
8915
+ render();
8916
+ } else if (key === "\r" || key === "\n") {
8917
+ cleanup();
8918
+ process.stdout.write("\n");
8919
+ resolve(options[current].value);
8920
+ } else if (key >= "1" && key <= String(options.length)) {
8921
+ cleanup();
8922
+ process.stdout.write("\n");
8923
+ resolve(options[Number(key) - 1].value);
8924
+ } else if (key === "") {
8925
+ cleanup();
8926
+ process.exit(0);
8927
+ }
8928
+ };
8929
+ const cleanup = () => {
8930
+ process.stdin.removeListener("data", onData);
8931
+ process.stdin.setRawMode?.(false);
8932
+ process.stdin.pause();
8933
+ rl.close();
8934
+ };
8935
+ process.stdin.on("data", onData);
8936
+ });
8937
+ }
8885
8938
  function confirm(question, defaultValue = true) {
8886
8939
  return new Promise((resolve) => {
8887
8940
  const rl = createInterface({
@@ -8920,43 +8973,59 @@ function start9Router() {
8920
8973
  async function runInteractiveSetup() {
8921
8974
  console.log(`
8922
8975
  \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557
8923
- \u2551 \u{1F680} CodeMap Gateway Setup \u2551
8976
+ \u2551 \u{1F680} CodeMap Setup \u2551
8924
8977
  \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D
8925
8978
 
8926
- CodeMap needs a LLM gateway to power its AI features.
8979
+ CodeMap needs an LLM API to power its AI features.
8927
8980
 
8928
8981
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
8929
- \u{1F4CC} What is a Gateway?
8982
+ \u{1F4CC} How it works
8930
8983
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
8931
8984
 
8932
- The gateway is a proxy that routes your requests to LLM providers.
8933
- It manages model routing, load balancing, and token accounting.
8985
+ CodeMap sends prompts to any OpenAI-compatible API endpoint.
8986
+ You can use OpenAI, OpenRouter, a local model, or 9router \u2014 whichever you prefer.
8934
8987
 
8935
8988
  \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
8936
8989
 
8937
8990
  `);
8938
- console.log("\u2501\u2501\u2501 Gateway Type \u2501\u2501\u2501");
8939
- console.log("");
8940
- console.log(" 1. 9router local (default) \u2014 install and run locally");
8941
- console.log(" \u2022 Free, runs on your machine");
8942
- console.log(" \u2022 Pre-configured model routing (planner, coder, reviewer)");
8943
- console.log(" \u2022 No per-model API keys needed");
8944
- console.log("");
8945
- console.log(" 2. 9router Cloud \u2014 managed gateway at 9router.dev");
8946
- console.log(" \u2022 Usage-based billing");
8947
- console.log(" \u2022 Get your API key at: https://9router.dev/settings/api-keys");
8991
+ console.log("\u2501\u2501\u2501 API Provider \u2501\u2501\u2501");
8948
8992
  console.log("");
8949
- console.log(" 3. Self-hosted \u2014 run your own gateway");
8950
- console.log(" \u2022 Set baseUrl to your gateway URL");
8951
- console.log(" \u2022 Useful for local models or custom routing logic");
8952
- console.log("");
8953
- const gatewayChoice = await prompt("Choose gateway type", "1");
8954
- const choice = gatewayChoice.trim();
8993
+ const choice = await select("Choose API provider:", [
8994
+ {
8995
+ value: "1",
8996
+ label: "9router local (recommended)",
8997
+ description: "free, runs on your machine"
8998
+ },
8999
+ {
9000
+ value: "2",
9001
+ label: "OpenAI-compatible API",
9002
+ description: "use your own API key"
9003
+ },
9004
+ {
9005
+ value: "3",
9006
+ label: "Self-hosted",
9007
+ description: "run your own gateway"
9008
+ }
9009
+ ]);
8955
9010
  let baseUrl;
8956
9011
  let nineRouterDashUrl;
8957
9012
  if (choice === "2") {
8958
- baseUrl = "https://9router.dev/v1";
8959
- nineRouterDashUrl = "https://9router.dev/settings/api-keys";
9013
+ console.log("");
9014
+ console.log("\u2501\u2501\u2501 OpenAI-compatible API \u2501\u2501\u2501");
9015
+ console.log("Common base URLs:");
9016
+ console.log(" \u2022 OpenAI: https://api.openai.com/v1");
9017
+ console.log(" \u2022 OpenRouter: https://openrouter.ai/api/v1");
9018
+ console.log("");
9019
+ baseUrl = await prompt("Base URL", "https://api.openai.com/v1");
9020
+ while (baseUrl) {
9021
+ try {
9022
+ new URL(baseUrl);
9023
+ break;
9024
+ } catch {
9025
+ console.log("\u274C Invalid URL. Please try again.");
9026
+ baseUrl = await prompt("Base URL", "https://api.openai.com/v1");
9027
+ }
9028
+ }
8960
9029
  } else if (choice === "3") {
8961
9030
  console.log("");
8962
9031
  console.log("\u2501\u2501\u2501 Self-hosted Gateway URL \u2501\u2501\u2501");
@@ -8994,8 +9063,12 @@ It manages model routing, load balancing, and token accounting.
8994
9063
  console.log("\u2501\u2501\u2501 API Key \u2501\u2501\u2501");
8995
9064
  if (nineRouterDashUrl) {
8996
9065
  console.log(`Get your API key from: ${nineRouterDashUrl}`);
9066
+ console.log("Leave empty if your gateway doesn't require auth.");
9067
+ } else if (choice === "2") {
9068
+ console.log("Enter your API key for the provider.");
9069
+ } else {
9070
+ console.log("Leave empty if your gateway doesn't require auth.");
8997
9071
  }
8998
- console.log("Leave empty if your gateway doesn't require auth.");
8999
9072
  console.log("");
9000
9073
  const apiKey = await prompt(
9001
9074
  "API key (press Enter to skip)",
@@ -9003,17 +9076,21 @@ It manages model routing, load balancing, and token accounting.
9003
9076
  );
9004
9077
  console.log("");
9005
9078
  console.log("\u2501\u2501\u2501 Config Scope \u2501\u2501\u2501");
9006
- console.log("\u2022 global \u2014 ~/.codemap/llm-gateway.json (default, all projects)");
9007
- console.log("\u2022 project \u2014 .codemap/llm-gateway.json (current project only)");
9008
9079
  console.log("");
9009
9080
  let scope = "global";
9010
- const scopeInput = await prompt(
9011
- "Save config to",
9012
- "global"
9013
- );
9014
- if (scopeInput === "project") {
9015
- scope = "project";
9016
- }
9081
+ const scopeChoice = await select("Save config to:", [
9082
+ {
9083
+ value: "global",
9084
+ label: "Global",
9085
+ description: "~/.codemap/llm-gateway.json (all projects)"
9086
+ },
9087
+ {
9088
+ value: "project",
9089
+ label: "Project",
9090
+ description: ".codemap/llm-gateway.json (current project only)"
9091
+ }
9092
+ ]);
9093
+ scope = scopeChoice;
9017
9094
  const result = await writeGatewayConfig({
9018
9095
  scope,
9019
9096
  force: true,
@@ -9036,7 +9113,7 @@ Current settings:
9036
9113
 
9037
9114
  You can override config using environment variables:
9038
9115
 
9039
- CODEMAP_LLM_GATEWAY_BASE_URL Gateway URL
9116
+ CODEMAP_LLM_GATEWAY_BASE_URL API base URL
9040
9117
  CODEMAP_LLM_GATEWAY_API_KEY API key
9041
9118
  CODEMAP_LLM_GATEWAY_PLANNER_MODEL Planner model ID
9042
9119
  CODEMAP_LLM_GATEWAY_CODER_MODEL Coder model ID
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemap-ai/cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "CodeMap — AI-powered code intelligence and coding agent CLI",
6
6
  "license": "MIT",
@@ -34,16 +34,16 @@
34
34
  "tree-sitter-python": "^0.25.0",
35
35
  "tree-sitter-wasms": "^0.1.13",
36
36
  "web-tree-sitter": "^0.26.8",
37
- "zod": "^4.3.6",
38
- "@codemap/code-index": "1.0.0",
39
- "@codemap/shared": "1.0.1"
37
+ "zod": "^4.3.6"
40
38
  },
41
39
  "devDependencies": {
42
40
  "@mastra/core": "^1.35.0",
43
41
  "@types/node": "^24.12.2",
44
42
  "tsup": "^8.5.1",
45
43
  "tsx": "^4.21.0",
46
- "typescript": "~5.9.2"
44
+ "typescript": "~5.9.2",
45
+ "@codemap/code-index": "1.0.0",
46
+ "@codemap/shared": "1.0.2"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"