@codemap-ai/cli 0.1.3 → 0.1.6

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.
@@ -1,7 +1,7 @@
1
1
  import{createRequire as __cmr}from"node:module";import{fileURLToPath as __f2p}from"node:url";import{dirname as __dn}from"node:path";var require=__cmr(import.meta.url);var __filename=__f2p(import.meta.url);var __dirname=__dn(__filename);
2
2
  import {
3
3
  fetchResourceContext
4
- } from "./chunk-WNJNT3FC.js";
4
+ } from "./chunk-MF6QRGI5.js";
5
5
  import {
6
6
  executeCommand,
7
7
  getCachedContext,
@@ -10,7 +10,7 @@ import {
10
10
  loadThreadIntoUI,
11
11
  runShell,
12
12
  warmupFileSearch
13
- } from "./chunk-KWYP3ADN.js";
13
+ } from "./chunk-EUHYFJ32.js";
14
14
  import {
15
15
  buildLocalIndex,
16
16
  getMastraCurrentModelId,
@@ -26,7 +26,7 @@ import {
26
26
  switchMastraThread,
27
27
  tryGetCurrentWorkspaceInfo,
28
28
  warmupHarness
29
- } from "./chunk-FFFJKKKM.js";
29
+ } from "./chunk-GGIXJZYK.js";
30
30
  import {
31
31
  C_ERROR,
32
32
  C_SUCCESS,
@@ -1025,7 +1025,7 @@ var ChatTerminal = class {
1025
1025
  this.store.dispatch({ synthRunning: false });
1026
1026
  this.bus.scheduleRefresh();
1027
1027
  });
1028
- const { startPiTuiApp } = await import("./pi-tui-app-GVZ3AN42.js");
1028
+ const { startPiTuiApp } = await import("./pi-tui-app-DCD7TEN5.js");
1029
1029
  await startPiTuiApp(this);
1030
1030
  }
1031
1031
  // ─── Session management ───────────────────────────────────
@@ -10,7 +10,7 @@ import {
10
10
  removeMcpServerEntry,
11
11
  require_dist,
12
12
  saveMcpServerEntry
13
- } from "./chunk-FFFJKKKM.js";
13
+ } from "./chunk-GGIXJZYK.js";
14
14
  import {
15
15
  __toESM,
16
16
  clearGlobalAuthConfig,
@@ -216811,14 +216811,8 @@ async function runStatusCommand() {
216811
216811
 
216812
216812
  // src/cli-agent/chat/harness/models.ts
216813
216813
  var FALLBACK_GATEWAY_MODEL = process.env.CODEMAP_LLM_GATEWAY_DEFAULT_MODEL ?? "cx/gpt-5.3-codex";
216814
- var KNOWN_PROFILE_LABELS = /* @__PURE__ */ new Set(["planner", "coder", "reviewer"]);
216815
216814
  function resolveGatewayModel(modelId, availableModels, availableCombos) {
216816
216815
  if (availableCombos?.includes(modelId)) return modelId;
216817
- if (KNOWN_PROFILE_LABELS.has(modelId)) {
216818
- console.warn(
216819
- `[resolveGatewayModel] Received profile label "${modelId}" \u2014 callers should resolve profiles to a concrete model ID or combo ID before calling this function.`
216820
- );
216821
- }
216822
216816
  if (availableModels && availableModels.length > 0) {
216823
216817
  if (availableModels.includes(modelId)) return modelId;
216824
216818
  const fallback = availableModels[0];
@@ -2,7 +2,7 @@ import{createRequire as __cmr}from"node:module";import{fileURLToPath as __f2p}fr
2
2
  import {
3
3
  readMcpServerConfigs,
4
4
  readPriorityResources
5
- } from "./chunk-FFFJKKKM.js";
5
+ } from "./chunk-GGIXJZYK.js";
6
6
 
7
7
  // src/cli-agent/chat/mcp-tools/mcp-tool-client.ts
8
8
  import { existsSync } from "fs";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  } from "./chunk-A2QHID6K.js";
6
6
  import {
7
7
  CodeMapMcpToolClient
8
- } from "./chunk-WNJNT3FC.js";
8
+ } from "./chunk-MF6QRGI5.js";
9
9
  import {
10
10
  buildImportHealth,
11
11
  buildLocalIndex,
@@ -29,7 +29,7 @@ import {
29
29
  shouldUseLocalIndexBeforeRemote,
30
30
  toRepoRelativePath,
31
31
  tryGetCurrentWorkspaceInfo
32
- } from "./chunk-FFFJKKKM.js";
32
+ } from "./chunk-GGIXJZYK.js";
33
33
  import {
34
34
  clearGlobalAuthConfig,
35
35
  createCodeMapClient,
@@ -8175,6 +8175,9 @@ async function writeGatewayConfig(options) {
8175
8175
  if (options.apiKey) {
8176
8176
  config.apiKey = options.apiKey;
8177
8177
  }
8178
+ if (options.defaultModel) {
8179
+ config.defaultModel = options.defaultModel;
8180
+ }
8178
8181
  try {
8179
8182
  await mkdir2(path12.dirname(configPath), { recursive: true });
8180
8183
  await writeFile5(configPath, `${JSON.stringify(config, null, 2)}
@@ -8668,7 +8671,7 @@ async function runChat(ctx) {
8668
8671
  });
8669
8672
  try {
8670
8673
  const mcpConfig = await loadConfig();
8671
- const { ChatTerminal } = await import("./chat-terminal-DFFYQ6AF.js");
8674
+ const { ChatTerminal } = await import("./chat-terminal-7KX3PEP3.js");
8672
8675
  const terminal = new ChatTerminal({
8673
8676
  provider,
8674
8677
  model,
@@ -8950,6 +8953,31 @@ function confirm(question, defaultValue = true) {
8950
8953
  });
8951
8954
  });
8952
8955
  }
8956
+ async function fetchModels(baseUrl, apiKey) {
8957
+ const url = `${baseUrl}/models`;
8958
+ const headers = {
8959
+ "Content-Type": "application/json"
8960
+ };
8961
+ if (apiKey) {
8962
+ headers["Authorization"] = `Bearer ${apiKey}`;
8963
+ }
8964
+ try {
8965
+ const response = await fetch(url, {
8966
+ method: "GET",
8967
+ headers,
8968
+ signal: AbortSignal.timeout(1e4)
8969
+ });
8970
+ if (!response.ok) {
8971
+ console.log(`\u26A0\uFE0F Failed to fetch models: HTTP ${response.status}`);
8972
+ return [];
8973
+ }
8974
+ const data = await response.json();
8975
+ return data.data || [];
8976
+ } catch (error) {
8977
+ console.log("\u26A0\uFE0F Could not connect to API to fetch models.");
8978
+ return [];
8979
+ }
8980
+ }
8953
8981
  function is9RouterInstalled() {
8954
8982
  try {
8955
8983
  execSync("which 9router", { stdio: "ignore" });
@@ -8962,6 +8990,18 @@ async function install9Router() {
8962
8990
  console.log(" Installing 9router globally...");
8963
8991
  execSync("npm install -g 9router", { stdio: "inherit" });
8964
8992
  }
8993
+ async function is9RouterRunning() {
8994
+ try {
8995
+ await fetch(`http://localhost:${NINE_ROUTER_LOCAL_PORT}/v1/models`, {
8996
+ method: "GET",
8997
+ signal: AbortSignal.timeout(2e3)
8998
+ });
8999
+ return true;
9000
+ } catch (err) {
9001
+ console.log(` [debug] 9router not reachable at http://localhost:${NINE_ROUTER_LOCAL_PORT}: ${err instanceof Error ? err.message : String(err)}`);
9002
+ return false;
9003
+ }
9004
+ }
8965
9005
  function start9Router() {
8966
9006
  console.log(" Starting 9router in the background...");
8967
9007
  const child = spawn("9router", ["--port", String(NINE_ROUTER_LOCAL_PORT)], {
@@ -9053,8 +9093,12 @@ You can use OpenAI, OpenRouter, a local model, or 9router \u2014 whichever you p
9053
9093
  }
9054
9094
  }
9055
9095
  if (is9RouterInstalled()) {
9056
- start9Router();
9057
- console.log(` 9router is running at http://localhost:${NINE_ROUTER_LOCAL_PORT}`);
9096
+ if (await is9RouterRunning()) {
9097
+ console.log(` 9router is already running at http://localhost:${NINE_ROUTER_LOCAL_PORT}`);
9098
+ } else {
9099
+ start9Router();
9100
+ console.log(` 9router started at http://localhost:${NINE_ROUTER_LOCAL_PORT}`);
9101
+ }
9058
9102
  }
9059
9103
  baseUrl = NINE_ROUTER_LOCAL_BASE_URL;
9060
9104
  nineRouterDashUrl = `http://localhost:${NINE_ROUTER_LOCAL_PORT}/dashboard/endpoint`;
@@ -9075,6 +9119,52 @@ You can use OpenAI, OpenRouter, a local model, or 9router \u2014 whichever you p
9075
9119
  ""
9076
9120
  );
9077
9121
  console.log("");
9122
+ console.log("\u2501\u2501\u2501 Default Model \u2501\u2501\u2501");
9123
+ console.log("Fetching available models...");
9124
+ console.log("");
9125
+ let defaultModel = "coder";
9126
+ const models = await fetchModels(baseUrl, apiKey || void 0);
9127
+ if (models.length > 0) {
9128
+ console.log(`Found ${models.length} model(s):`);
9129
+ console.log("");
9130
+ const modelOptions = models.slice(0, 20).map((m) => ({
9131
+ value: m.id,
9132
+ label: m.id,
9133
+ description: m.owned_by
9134
+ }));
9135
+ modelOptions.push({
9136
+ value: "__custom__",
9137
+ label: "Enter custom model ID",
9138
+ description: "type your own model name"
9139
+ });
9140
+ const selectedModel = await select("Choose default model:", modelOptions);
9141
+ if (selectedModel === "__custom__") {
9142
+ defaultModel = await prompt("Model ID", "");
9143
+ if (!defaultModel) {
9144
+ defaultModel = "coder";
9145
+ console.log("Using default profile: coder");
9146
+ }
9147
+ } else {
9148
+ defaultModel = selectedModel;
9149
+ }
9150
+ } else {
9151
+ console.log("No models returned by the API.");
9152
+ console.log("");
9153
+ console.log("You can enter a model ID manually, or use a profile label:");
9154
+ console.log(" \u2022 coder \u2014 for code generation tasks");
9155
+ console.log(" \u2022 planner \u2014 for planning and reasoning");
9156
+ console.log(" \u2022 reviewer \u2014 for code review tasks");
9157
+ console.log("");
9158
+ console.log("Leave empty to use 'coder' profile.");
9159
+ console.log("");
9160
+ defaultModel = await prompt("Model ID or profile", "coder");
9161
+ if (!defaultModel) {
9162
+ defaultModel = "coder";
9163
+ }
9164
+ }
9165
+ console.log("");
9166
+ console.log(` Default model set to: ${defaultModel}`);
9167
+ console.log("");
9078
9168
  console.log("\u2501\u2501\u2501 Config Scope \u2501\u2501\u2501");
9079
9169
  console.log("");
9080
9170
  let scope = "global";
@@ -9095,7 +9185,8 @@ You can use OpenAI, OpenRouter, a local model, or 9router \u2014 whichever you p
9095
9185
  scope,
9096
9186
  force: true,
9097
9187
  baseUrl,
9098
- apiKey: apiKey || void 0
9188
+ apiKey: apiKey || void 0,
9189
+ defaultModel
9099
9190
  });
9100
9191
  console.log(`
9101
9192
  \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
@@ -9103,9 +9194,10 @@ You can use OpenAI, OpenRouter, a local model, or 9router \u2014 whichever you p
9103
9194
  \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
9104
9195
 
9105
9196
  Current settings:
9106
- \u2022 Base URL: ${baseUrl}
9107
- \u2022 API Key: ${apiKey ? apiKey.substring(0, 10) + "...***" : "(not set)"}
9108
- \u2022 Scope: ${scope}
9197
+ \u2022 Base URL: ${baseUrl}
9198
+ \u2022 API Key: ${apiKey ? apiKey.substring(0, 10) + "...***" : "(not set)"}
9199
+ \u2022 Default Model: ${defaultModel}
9200
+ \u2022 Scope: ${scope}
9109
9201
 
9110
9202
  \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
9111
9203
  \u{1F4A1} Advanced: Environment Variables
@@ -5,10 +5,10 @@ import {
5
5
  import {
6
6
  getCommandList,
7
7
  searchIndexedFiles
8
- } from "./chunk-KWYP3ADN.js";
8
+ } from "./chunk-EUHYFJ32.js";
9
9
  import {
10
10
  getMastraMessages
11
- } from "./chunk-FFFJKKKM.js";
11
+ } from "./chunk-GGIXJZYK.js";
12
12
  import {
13
13
  BG_USER,
14
14
  BOLD,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codemap-ai/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "type": "module",
5
5
  "description": "CodeMap — AI-powered code intelligence and coding agent CLI",
6
6
  "license": "MIT",