march-cli 0.1.5 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "march-cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "March CLI — terminal-native coding agent with context reconstruction",
5
5
  "type": "module",
6
6
  "main": "./src/main.mjs",
@@ -1,6 +1,34 @@
1
1
  import { getProviderLabel } from "../../provider/presets.mjs";
2
2
  import { globalConfigJsonPath, upsertModelSelection } from "../../config/config-json.mjs";
3
3
 
4
+ // Deduplicate models by id, preferring canonical providers.
5
+ // When the same model id appears under multiple providers (e.g. supergrok-oauth
6
+ // and xai-oauth), keep only the entry with the preferred provider.
7
+ const PREFERRED_PROVIDERS = ["supergrok-oauth"];
8
+
9
+ function dedupByModelId(scopedModels) {
10
+ const seen = new Map();
11
+ const result = [];
12
+ for (const entry of scopedModels) {
13
+ const { model } = entry;
14
+ const existing = seen.get(model.id);
15
+ if (!existing) {
16
+ seen.set(model.id, entry);
17
+ result.push(entry);
18
+ } else {
19
+ // Prefer canonical provider when duplicates exist
20
+ const existingPref = PREFERRED_PROVIDERS.indexOf(existing.model.provider);
21
+ const currentPref = PREFERRED_PROVIDERS.indexOf(model.provider);
22
+ if (currentPref !== -1 && (existingPref === -1 || currentPref < existingPref)) {
23
+ const idx = result.indexOf(existing);
24
+ result[idx] = entry;
25
+ seen.set(model.id, entry);
26
+ }
27
+ }
28
+ }
29
+ return result;
30
+ }
31
+
4
32
  export function parseModelCommand(input) {
5
33
  if (input !== "/model" && !input.startsWith("/model ")) {
6
34
  return { type: "none" };
@@ -21,9 +49,10 @@ export async function selectModelByIndex(index, { runner }) {
21
49
  }
22
50
 
23
51
  export function buildModelSelectItems({ current, scopedModels = [] }) {
24
- return scopedModels.map(({ model }, index) => ({
52
+ const deduped = dedupByModelId(scopedModels);
53
+ return deduped.map(({ model }, index) => ({
25
54
  value: String(index),
26
- label: `${getProviderLabel(model.provider)} / ${model.name || model.id}`,
55
+ label: `${model.name || model.id} (${getProviderLabel(model.provider)})`,
27
56
  description: current && model.id === current.id && model.provider === current.provider ? "current" : model.provider,
28
57
  model,
29
58
  }));
@@ -34,19 +63,20 @@ export async function handleModelCommand(parsed, { runner, ui = null, configHome
34
63
  const scopedModels = runner.getScopedModels?.() || [];
35
64
  if (!ui?.selectList || scopedModels.length === 0) return "Use Ctrl+L to choose a model.";
36
65
  const current = runner.getCurrentModel?.();
37
- const selectedIndex = Math.max(0, scopedModels.findIndex(({ model }) =>
38
- current && model.id === current.id && model.provider === current.provider
66
+ const items = buildModelSelectItems({ current, scopedModels });
67
+ const selectedIndex = Math.max(0, items.findIndex((item) =>
68
+ current && item.model.id === current.id && item.model.provider === current.provider
39
69
  ));
40
- const item = await ui.selectList({
41
- items: buildModelSelectItems({ current, scopedModels }),
70
+ const selectedItem = await ui.selectList({
71
+ items,
42
72
  selectedIndex,
43
73
  width: 72,
44
74
  suppressInitialConfirm: true,
45
75
  searchable: true,
46
76
  getSearchText: modelSelectSearchText,
47
77
  });
48
- if (!item) return "Model unchanged.";
49
- const model = await runner.setModel(item.model);
78
+ if (!selectedItem) return "Model unchanged.";
79
+ const model = await runner.setModel(selectedItem.model);
50
80
  persistModelSelection(model, { configHomeDir });
51
81
  return `Model: ${model.name || model.id} (${model.provider})`;
52
82
  }
@@ -85,8 +115,9 @@ export function formatModelsList({ current, scopedModels = [] }) {
85
115
  }
86
116
 
87
117
  function formatGroupedModels({ current, scopedModels }) {
118
+ const deduped = dedupByModelId(scopedModels);
88
119
  const groups = new Map();
89
- for (const item of scopedModels) {
120
+ for (const item of deduped) {
90
121
  const provider = item.model.provider;
91
122
  if (!groups.has(provider)) groups.set(provider, []);
92
123
  groups.get(provider).push(item);
@@ -11,8 +11,12 @@ export function parseProviderCommand(input) {
11
11
 
12
12
  export function listProviders({ runner }) {
13
13
  const scopedModels = runner.getScopedModels?.() || [];
14
+ const seen = new Set();
14
15
  const providers = new Map();
15
16
  for (const { model } of scopedModels) {
17
+ // Deduplicate: skip models that differ only by provider (e.g. supergrok-oauth vs xai-oauth)
18
+ if (seen.has(model.id)) continue;
19
+ seen.add(model.id);
16
20
  if (!providers.has(model.provider)) {
17
21
  providers.set(model.provider, {
18
22
  provider: model.provider,
@@ -76,19 +76,20 @@ export function wireTuiHandlers({
76
76
  const scopedModels = runner.getScopedModels?.() || [];
77
77
  if (ui.selectList && scopedModels.length > 0) {
78
78
  const current = runner.getCurrentModel?.();
79
- const selectedIndex = Math.max(0, scopedModels.findIndex(({ model }) =>
80
- current && model.id === current.id && model.provider === current.provider
79
+ const items = buildModelSelectItems({ current, scopedModels });
80
+ const selectedIndex = Math.max(0, items.findIndex((item) =>
81
+ current && item.model.id === current.id && item.model.provider === current.provider
81
82
  ));
82
- const item = await ui.selectList({
83
- items: buildModelSelectItems({ current, scopedModels }),
83
+ const selectedItem = await ui.selectList({
84
+ items,
84
85
  selectedIndex,
85
86
  width: 72,
86
87
  });
87
- if (!item) {
88
+ if (!selectedItem) {
88
89
  ui.writeln(brightBlack(`● model: unchanged`));
89
90
  return;
90
91
  }
91
- const model = await runner.setModel(item.model);
92
+ const model = await runner.setModel(selectedItem.model);
92
93
  persistModelSelection(model, { configHomeDir });
93
94
  const name = model.name || model.id;
94
95
  ui.writeln(brightBlack(`● model: ${name} (${model.provider})`));
@@ -28,10 +28,10 @@ const PROVIDER_LABELS = {
28
28
  openai: "OpenAI",
29
29
  "openai-codex": "OpenAI Codex",
30
30
  openrouter: "OpenRouter",
31
- "supergrok-oauth": "SuperGrok OAuth (xAI Subscription)",
31
+ "supergrok-oauth": "SuperGrok",
32
32
  "vercel-ai-gateway": "Vercel AI Gateway",
33
33
  xai: "xAI",
34
- "xai-oauth": "xAI OAuth (SuperGrok compatible)",
34
+ "xai-oauth": "xAI OAuth",
35
35
  zai: "ZAI",
36
36
  xiaomi: "Xiaomi MiMo",
37
37
  "xiaomi-token-plan-cn": "Xiaomi MiMo Token Plan (China)",
@@ -14,7 +14,7 @@ export function registerSuperGrokProvider(modelRegistry) {
14
14
  if (!modelRegistry?.registerProvider) return;
15
15
  for (const providerId of [SUPERGROK_OAUTH_PROVIDER_ID, XAI_OAUTH_COMPAT_PROVIDER_ID]) {
16
16
  modelRegistry.registerProvider(providerId, {
17
- name: providerId === SUPERGROK_OAUTH_PROVIDER_ID ? "SuperGrok OAuth (xAI Subscription)" : "xAI OAuth (SuperGrok compatible)",
17
+ name: providerId === SUPERGROK_OAUTH_PROVIDER_ID ? "SuperGrok" : "xAI OAuth",
18
18
  baseUrl: XAI_BASE_URL,
19
19
  api: "openai-responses",
20
20
  oauth: { ...superGrokOAuthProvider, id: providerId },
@@ -33,4 +33,4 @@ export function registerSuperGrokProvider(modelRegistry) {
33
33
 
34
34
  export function getDefaultSuperGrokModelId() {
35
35
  return DEFAULT_SUPERGROK_MODEL;
36
- }
36
+ }