Repository navigation
Expand file tree
/
Copy pathModelCatalogTests.cs
More file actions
734 lines (601 loc) · 30.2 KB
/
Copy pathModelCatalogTests.cs
File metadata and controls
734 lines (601 loc) · 30.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
/* *******************************************************************************************************************
* Application: ClaudeCodeExtension
*
* Autor: Daniel Carvalho Liedke / Claude Code
*
* Copyright © Daniel Carvalho Liedke 2026
* Usage and reproduction in any manner whatsoever without the written permission of Daniel Carvalho Liedke is strictly forbidden.
*
* Purpose: Unit tests for the model-list parsers and the ACP launch flag that carries a model
*
* *******************************************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using ClaudeCodeVS.Agents;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace ClaudeCodeExtension.Tests
{
/// <summary>
/// Covers the text handling behind the model menu. The sample outputs are trimmed copies of what
/// the real CLIs printed when each listing command was measured.
/// </summary>
[TestClass]
public class ModelCatalogTests
{
#region Codex
[TestMethod]
public void ParseCodexCatalog_ReadsSlugAndDisplayName()
{
const string json = @"{
""models"": [
{ ""slug"": ""gpt-5.6-sol"", ""display_name"": ""GPT-5.6-Sol"", ""visibility"": ""list"" },
{ ""slug"": ""gpt-5.6-codex"", ""display_name"": ""GPT-5.6-Codex"", ""visibility"": ""list"" }
]
}";
List<ModelOption> models = ModelCatalogParsers.ParseCodexCatalog(json);
Assert.AreEqual(2, models.Count);
Assert.AreEqual("gpt-5.6-sol", models[0].Id);
Assert.AreEqual("GPT-5.6-Sol", models[0].DisplayName);
}
[TestMethod]
public void ParseCodexCatalog_SkipsModelsCodexItselfHides()
{
const string json = @"{
""models"": [
{ ""slug"": ""gpt-5.6-sol"", ""display_name"": ""GPT-5.6-Sol"", ""visibility"": ""list"" },
{ ""slug"": ""gpt-5-legacy"", ""display_name"": ""Legacy"", ""visibility"": ""hidden"" }
]
}";
List<ModelOption> models = ModelCatalogParsers.ParseCodexCatalog(json);
Assert.AreEqual(1, models.Count);
Assert.AreEqual("gpt-5.6-sol", models[0].Id);
}
[TestMethod]
public void ParseCodexCatalog_ReturnsEmptyForOutputThatIsNotTheCatalog()
{
Assert.AreEqual(0, ModelCatalogParsers.ParseCodexCatalog("codex: unknown command 'debug'").Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseCodexCatalog(string.Empty).Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseCodexCatalog(null).Count);
}
#endregion
#region Cursor Agent
[TestMethod]
public void ParseIdDashNameList_TakesTheEntriesAndDropsTheBanner()
{
const string text =
"Available models:\n" +
"auto - Auto\n" +
"claude-4.5-sonnet - Claude 4.5 Sonnet\n" +
"gpt-5 - GPT-5\n";
List<ModelOption> models = ModelCatalogParsers.ParseIdDashNameList(text);
CollectionAssert.AreEqual(
new[] { "auto", "claude-4.5-sonnet", "gpt-5" },
models.Select(m => m.Id).ToArray());
Assert.AreEqual("Claude 4.5 Sonnet", models[1].DisplayName);
}
[TestMethod]
public void ParseIdDashNameList_IgnoresColourEscapesAndCarriageReturns()
{
const string text = "\u001B[1mAvailable models:\u001B[0m\r\n\u001B[32mgpt-5\u001B[0m - GPT-5\r\n";
List<ModelOption> models = ModelCatalogParsers.ParseIdDashNameList(text);
Assert.AreEqual(1, models.Count);
Assert.AreEqual("gpt-5", models[0].Id);
Assert.AreEqual("GPT-5", models[0].DisplayName);
}
[TestMethod]
public void ParseIdDashNameList_DropsTheMarkerCursorPutsOnTheActiveModel()
{
const string text =
"auto - Auto (current, default)\n" +
"claude-fable-5-high - Fable 5 1M (NO ZDR)\n";
List<ModelOption> models = ModelCatalogParsers.ParseIdDashNameList(text);
// The state marker goes; a parenthesis that is part of the name stays.
Assert.AreEqual("Auto", models[0].DisplayName);
Assert.AreEqual("Fable 5 1M (NO ZDR)", models[1].DisplayName);
}
#endregion
#region PI
[TestMethod]
public void ParsePiModelList_JoinsProviderAndModelTheWayPiTakesThemBack()
{
const string text =
"provider model context max-out\n" +
"anthropic claude-opus-5 200000 64000\n" +
"openai gpt-5.6 400000 128000\n";
List<ModelOption> models = ModelCatalogParsers.ParsePiModelList(text);
CollectionAssert.AreEqual(
new[] { "anthropic/claude-opus-5", "openai/gpt-5.6" },
models.Select(m => m.Id).ToArray());
}
[TestMethod]
public void ParsePiModelList_DropsTheHeaderRowAndProseLines()
{
const string text =
"provider model\n" +
"No models are configured yet\n" +
"anthropic claude-opus-5\n";
List<ModelOption> models = ModelCatalogParsers.ParsePiModelList(text);
Assert.AreEqual(1, models.Count);
Assert.AreEqual("anthropic/claude-opus-5", models[0].Id);
}
#endregion
#region Antigravity / Open Code
[TestMethod]
public void ParsePlainList_TakesOneIdPerLine()
{
const string text = "gemini-3-pro\ngemini-3-flash\nclaude-opus-5\n";
List<ModelOption> models = ModelCatalogParsers.ParsePlainList(text);
CollectionAssert.AreEqual(
new[] { "gemini-3-pro", "gemini-3-flash", "claude-opus-5" },
models.Select(m => m.Id).ToArray());
}
[TestMethod]
public void ParsePlainList_DropsBannersAndWarnings()
{
const string text =
"Available models:\n" +
"opencode/big-pickle\n" +
" ⚠ update available\n" +
"\n";
List<ModelOption> models = ModelCatalogParsers.ParsePlainList(text);
Assert.AreEqual(1, models.Count);
Assert.AreEqual("opencode/big-pickle", models[0].Id);
}
[TestMethod]
public void ParsePlainList_ListsEachModelOnce()
{
// A WSL profile that echoes its command prints the list twice.
const string text = "gemini-3-pro\ngemini-3-pro\n";
Assert.AreEqual(1, ModelCatalogParsers.ParsePlainList(text).Count);
}
#endregion
#region Grok
[TestMethod]
public void ParseGrokModelList_ReadsTheRealOutput()
{
// Measured: grok models on Grok Build, signed in with a grok.com account.
const string text =
"You are logged in with grok.com.\r\n" +
"\r\n" +
"Default model: grok-4.7\r\n" +
"\r\n" +
"Available models:\r\n" +
" * grok-4.7 (default)\r\n";
List<ModelOption> models = ModelCatalogParsers.ParseGrokModelList(text);
Assert.AreEqual(1, models.Count);
Assert.AreEqual("grok-4.7", models[0].Id);
}
[TestMethod]
public void ParseGrokModelList_TakesUnstarredEntriesAndSkipsTheBanner()
{
const string text =
"Default model: grok-4.7\n" +
"Available models:\n" +
" * grok-4.7 (default)\n" +
" grok-4.7-mini\n";
List<ModelOption> models = ModelCatalogParsers.ParseGrokModelList(text);
CollectionAssert.AreEqual(new[] { "grok-4.7", "grok-4.7-mini" }, models.Select(m => m.Id).ToArray());
}
[TestMethod]
public void ParseGrokModelList_IsEmptyWithoutTheListHeader()
{
// Signed out, grok models prints only a login hint — no model must be invented from it.
Assert.AreEqual(0, ModelCatalogParsers.ParseGrokModelList("Run grok login to sign in.\n").Count);
}
[TestMethod]
public void HasNonGrokPathHit_IgnoresGrokBuildsOwnAgentExe()
{
// Grok Build installs agent.exe next to grok.exe; "where agent" listing only that one
// must not make Cursor Agent look installed.
Assert.IsFalse(ClaudeCodeVS.ClaudeCodeControl.HasNonGrokPathHit(
"C:\\Users\\me\\.grok\\bin\\agent.exe\r\n"));
Assert.IsTrue(ClaudeCodeVS.ClaudeCodeControl.HasNonGrokPathHit(
"C:\\Users\\me\\AppData\\Local\\cursor-agent\\agent.cmd\r\nC:\\Users\\me\\.grok\\bin\\agent.exe\r\n"));
Assert.IsFalse(ClaudeCodeVS.ClaudeCodeControl.HasNonGrokPathHit(string.Empty));
}
#endregion
#region Grouping
/// <summary>A list of the given length, ids shaped like the ones cursor-agent prints.</summary>
private static List<ModelOption> Models(params string[] ids)
{
return ids.Select(id => new ModelOption { Id = id, Name = id }).ToList();
}
[TestMethod]
public void Group_LeavesAShortListFlat()
{
List<ModelGroup> groups = ModelCatalogGrouping.Group(
Models("gpt-5.6-sol", "gpt-5.6-codex", "gpt-5.4-high"));
Assert.AreEqual(1, groups.Count);
Assert.IsFalse(groups[0].IsSubmenu);
Assert.AreEqual(3, groups[0].Models.Count);
}
[TestMethod]
public void Group_ReturnsNothingForAnEmptyList()
{
Assert.AreEqual(0, ModelCatalogGrouping.Group(Models()).Count);
Assert.AreEqual(0, ModelCatalogGrouping.Group(null).Count);
}
[TestMethod]
public void Group_SplitsALongListByFamilyKeepingTheClisOrder()
{
var ids = new List<string>();
for (int i = 0; i < 14; i++) ids.Add("claude-opus-4-" + i);
for (int i = 0; i < 14; i++) ids.Add("gpt-5.6-" + i);
List<ModelGroup> groups = ModelCatalogGrouping.Group(Models(ids.ToArray()));
Assert.AreEqual(2, groups.Count);
Assert.AreEqual("claude-opus", groups[0].Name);
Assert.AreEqual("gpt-5.6", groups[1].Name);
Assert.AreEqual(14, groups[0].Models.Count);
Assert.AreEqual("claude-opus-4-0", groups[0].Models[0].Id);
}
[TestMethod]
public void Group_ShowsAFamilyOfOneAsAPlainEntry()
{
var ids = new List<string> { "auto" };
for (int i = 0; i < 26; i++) ids.Add("claude-opus-4-" + i);
List<ModelGroup> groups = ModelCatalogGrouping.Group(Models(ids.ToArray()));
Assert.AreEqual(2, groups.Count);
Assert.IsFalse(groups[0].IsSubmenu);
Assert.AreEqual("auto", groups[0].Models[0].Id);
Assert.AreEqual("claude-opus", groups[1].Name);
}
[TestMethod]
public void GetGroupKey_TakesTheProviderHalfOfAProviderSlashModelId()
{
Assert.AreEqual("anthropic", ModelCatalogGrouping.GetGroupKey("anthropic/claude-opus-5"));
Assert.AreEqual("opencode", ModelCatalogGrouping.GetGroupKey("opencode/big-pickle"));
}
[TestMethod]
public void GetGroupKey_TakesTwoSegmentsOfADashedId()
{
Assert.AreEqual("claude-opus", ModelCatalogGrouping.GetGroupKey("claude-opus-4-8-high"));
Assert.AreEqual("gemini-3.6", ModelCatalogGrouping.GetGroupKey("gemini-3.6-flash-high"));
Assert.AreEqual("gpt-5", ModelCatalogGrouping.GetGroupKey("gpt-5"));
Assert.AreEqual("auto", ModelCatalogGrouping.GetGroupKey("auto"));
Assert.AreEqual(string.Empty, ModelCatalogGrouping.GetGroupKey(null));
}
[TestMethod]
public void Group_PrefersTheFamilyTheCliNamedItself()
{
// Devin's own families separate "Claude Opus 4.8" from "Claude Opus 5"; GetGroupKey
// reduces both ids to "claude-opus" and would merge them into one 20-entry submenu.
var models = new List<ModelOption>();
for (int i = 0; i < 14; i++)
{
models.Add(new ModelOption { Id = "claude-opus-4-8-" + i, Name = "A" + i, Group = "Claude Opus 4.8" });
}
for (int i = 0; i < 14; i++)
{
models.Add(new ModelOption { Id = "claude-opus-5-" + i, Name = "B" + i, Group = "Claude Opus 5" });
}
List<ModelGroup> groups = ModelCatalogGrouping.Group(models);
Assert.AreEqual(2, groups.Count);
Assert.AreEqual("Claude Opus 4.8", groups[0].Name);
Assert.AreEqual("Claude Opus 5", groups[1].Name);
}
#endregion
#region Devin models
/// <summary>Trimmed from a real `devin models list --format json` run (v3000.6.2).</summary>
private const string DevinModelsJson = @"{
""families"": [
{
""family_label"": ""Claude Opus 5"",
""family_uid"": ""claude-opus-5"",
""aliases"": [""opus""],
""variants"": [
{ ""model_uid"": ""claude-opus-5-medium"", ""label"": ""Claude Opus 5 Medium"", ""max_context_tokens"": 1000000, ""cost_tier"": ""High cost"", ""cost_summary"": ""$5 / 1M Input \u00b7 $25 / 1M Output"", ""is_new"": false, ""is_beta"": false },
{ ""model_uid"": ""claude-opus-5-high"", ""label"": ""Claude Opus 5 High"", ""max_context_tokens"": 1000000, ""cost_tier"": ""High cost"", ""is_new"": true, ""is_beta"": true }
]
},
{
""family_label"": ""Claude Haiku 4.5"",
""family_uid"": ""Claude Haiku 4.5"",
""variants"": [
{ ""model_uid"": ""MODEL_PRIVATE_11"", ""label"": ""Claude Haiku 4.5"", ""description"": ""Fast and cheap"" }
]
}
]
}";
[TestMethod]
public void ParseDevinCatalog_ReadsEveryVariantOfEveryFamily()
{
List<ModelOption> models = ModelCatalogParsers.ParseDevinCatalog(DevinModelsJson);
Assert.AreEqual(3, models.Count);
Assert.AreEqual("claude-opus-5-medium", models[0].Id);
Assert.AreEqual("Claude Opus 5 Medium", models[0].DisplayName);
}
[TestMethod]
public void ParseDevinCatalog_KeepsTheModelUidEvenWhenItLooksInternal()
{
// Devin's older families are listed under ids like MODEL_PRIVATE_11. They are what both
// `devin --model` and the ACP model picker accept; the label matches no fuzzy name.
List<ModelOption> models = ModelCatalogParsers.ParseDevinCatalog(DevinModelsJson);
Assert.AreEqual("MODEL_PRIVATE_11", models[2].Id);
Assert.AreEqual("Claude Haiku 4.5", models[2].DisplayName);
}
[TestMethod]
public void ParseDevinCatalog_ReadsTheDetailsTheMenuShows()
{
List<ModelOption> models = ModelCatalogParsers.ParseDevinCatalog(DevinModelsJson);
Assert.AreEqual("High cost", models[0].CostTier);
StringAssert.Contains(models[0].CostSummary, "$25 / 1M Output");
Assert.AreEqual(1000000, models[0].ContextTokens);
Assert.IsTrue(models[1].IsNew);
Assert.IsTrue(models[1].IsBeta);
Assert.IsFalse(models[0].IsNew);
// The details pane's own fields: Devin describes Adaptive and its cheaper models.
Assert.AreEqual("Fast and cheap", models[2].Description);
Assert.AreEqual(string.Empty, models[0].Description);
}
[TestMethod]
public void ParseCostSummary_SplitsTheThreePricesInTheOrderTheCliPrintsThem()
{
List<ModelPrice> prices = ModelCatalogParsers.ParseCostSummary(
"$8 / 1M Input \u00B7 $0.4 / 1M Cached input \u00B7 $40 / 1M Output");
Assert.AreEqual(3, prices.Count);
Assert.AreEqual("Input", prices[0].Label);
Assert.AreEqual("$8", prices[0].Text);
Assert.AreEqual("1M", prices[0].Denominator);
Assert.AreEqual(8.0, prices[0].Amount, 1e-9);
Assert.AreEqual("Cached input", prices[1].Label);
Assert.AreEqual("$0.4", prices[1].Text);
Assert.AreEqual("Output", prices[2].Label);
Assert.AreEqual("$40", prices[2].Text);
Assert.AreEqual(40.0, prices[2].Amount, 1e-9);
}
[TestMethod]
public void ParseCostSummary_KeepsTwoPricesWhenTheCliReportsNoCachedRate()
{
// The first variant of DevinModelsJson carries no cached-input price.
string summary = ModelCatalogParsers.ParseDevinCatalog(DevinModelsJson)[0].CostSummary;
List<ModelPrice> prices = ModelCatalogParsers.ParseCostSummary(summary);
Assert.AreEqual(2, prices.Count);
Assert.AreEqual("Output", prices[1].Label);
Assert.AreEqual("$25", prices[1].Text);
}
[TestMethod]
public void ParseCostSummary_ReturnsNothingWhenTheSummaryIsMissingOrUnfamiliar()
{
Assert.AreEqual(0, ModelCatalogParsers.ParseCostSummary(null).Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseCostSummary("Free").Count);
// One unfamiliar part makes the whole summary unfamiliar, so the pane shows it as written.
Assert.AreEqual(0, ModelCatalogParsers.ParseCostSummary("$5 / 1M Input \u00B7 about $25 out").Count);
}
/// <summary>A few models priced the way the account's catalog prices them, plus one with no prices.</summary>
private static List<ModelOption> CostCatalog()
{
return new List<ModelOption>
{
new ModelOption { Id = "claude-haiku-5-5-low", Name = "Claude Haiku 5.5 Low", CostSummary = "$0.1 / 1M Input \u00B7 $0.01 / 1M Cached input \u00B7 $0.5 / 1M Output" },
new ModelOption { Id = "gemini-3-8-flash-medium", Name = "Gemini 3.8 Flash Medium", CostSummary = "$0.75 / 1M Input \u00B7 $0.08 / 1M Cached input \u00B7 $3.75 / 1M Output" },
new ModelOption { Id = "claude-opus-5-5-max-fast", Name = "Claude Opus 5.5 Max Fast", CostSummary = "$8 / 1M Input \u00B7 $0.4 / 1M Cached input \u00B7 $40 / 1M Output" },
new ModelOption { Id = "gpt-5-5-priority", Name = "GPT-5.5 Priority", CostSummary = "$12.5 / 1M Input \u00B7 $1.25 / 1M Cached input \u00B7 $75 / 1M Output" },
new ModelOption { Id = "adaptive", Name = "Adaptive" }
};
}
[TestMethod]
public void ModelCostScale_RunsEachCaptionFromTheCheapestPriceInTheListToTheDearest()
{
Dictionary<string, ModelCostRange> ranges = ModelCostScale.Build(CostCatalog());
Assert.AreEqual(0.1, ranges["Input"].Bottom, 1e-9);
Assert.AreEqual(12.5, ranges["Input"].Top, 1e-9);
Assert.AreEqual(0.01, ranges["Cached input"].Bottom, 1e-9);
Assert.AreEqual(1.25, ranges["Cached input"].Top, 1e-9);
Assert.AreEqual(0.5, ranges["Output"].Bottom, 1e-9);
Assert.AreEqual(75, ranges["Output"].Top, 1e-9);
}
[TestMethod]
public void ModelCostScale_PlacesPricesWhereDevinsPickerDrawsThem()
{
// On the same account Devin's picker draws Haiku 5.5 Low ($0.1 input) at the left end, Gemini 3.8 Flash
// Medium ($0.75) a little under a fifth of the way along, and Opus 5.5 Max Fast ($8) a little over four-fifths.
ModelCostRange input = ModelCostScale.Build(CostCatalog())["Input"];
Assert.AreEqual(0, ModelCostScale.Percent(0.1, input), 1e-9);
Assert.AreEqual(18.5, ModelCostScale.Percent(0.75, input), 0.1);
Assert.AreEqual(83.8, ModelCostScale.Percent(8, input), 0.1);
}
[TestMethod]
public void ModelCostScale_StaysOnTheBarAndIsZeroWithoutARange()
{
var range = new ModelCostRange { Bottom = 0.5, Top = 75 };
Assert.AreEqual(0, ModelCostScale.Percent(0.1, range), 1e-9);
Assert.AreEqual(100, ModelCostScale.Percent(500, range), 1e-9);
Assert.AreEqual(0, ModelCostScale.Percent(3, new ModelCostRange { Bottom = 2, Top = 2 }), 1e-9);
Assert.AreEqual(0, ModelCostScale.Percent(3, null), 1e-9);
}
[TestMethod]
public void MenuCaption_AppendsWhateverTheCliReported()
{
var model = new ModelOption
{
Id = "grok-4-6-low",
Name = "Grok 4.6 Low",
CostTier = "Med cost",
ContextTokens = 500000,
IsNew = true,
IsBeta = true
};
Assert.AreEqual("Grok 4.6 Low — 500K · Med cost · New · Beta", model.BuildMenuCaption());
}
[TestMethod]
public void MenuCaption_RoundsDevinsContextWindowsTheWayDevinPrintsThem()
{
// Devin reports 1047576 and 1048576 for the windows its own picker calls "1M".
Assert.AreEqual("A — 1M", new ModelOption { Name = "A", ContextTokens = 1048576 }.BuildMenuCaption());
Assert.AreEqual("A — 1M", new ModelOption { Name = "A", ContextTokens = 1000000 }.BuildMenuCaption());
Assert.AreEqual("A — 272K", new ModelOption { Name = "A", ContextTokens = 272000 }.BuildMenuCaption());
Assert.AreEqual("A — 1.5M", new ModelOption { Name = "A", ContextTokens = 1500000 }.BuildMenuCaption());
}
[TestMethod]
public void MenuCaption_IsTheBareNameForAnAgentThatReportsNoDetails()
{
// Every CLI except Devin lists ids and names only; their menus must not grow a stray dash.
Assert.AreEqual("GPT-5.6-Sol", new ModelOption { Id = "gpt-5.6-sol", Name = "GPT-5.6-Sol" }.BuildMenuCaption());
Assert.AreEqual("adaptive", new ModelOption { Id = "adaptive" }.BuildMenuCaption());
}
[TestMethod]
public void ParseDevinCatalog_CarriesDevinsOwnFamilyAsTheSubmenu()
{
List<ModelOption> models = ModelCatalogParsers.ParseDevinCatalog(DevinModelsJson);
Assert.AreEqual("Claude Opus 5", models[0].Group);
Assert.AreEqual("Claude Haiku 4.5", models[2].Group);
}
[TestMethod]
public void ParseDevinCatalog_SkipAnyBannerPrintedBeforeTheJson()
{
List<ModelOption> models = ModelCatalogParsers.ParseDevinCatalog(
"A new version of devin is available!" + Environment.NewLine + DevinModelsJson);
Assert.AreEqual(3, models.Count);
}
[TestMethod]
public void ParseDevinCatalog_ReturnsNothingForUnusableOutput()
{
// An empty list keeps the previous catalog (FetchProviderModelsAsync) and leaves the
// launch flag empty, which starts Devin on the model its account defaults to.
Assert.AreEqual(0, ModelCatalogParsers.ParseDevinCatalog(null).Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseDevinCatalog("devin: command not found").Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseDevinCatalog("{\"families\":[]}").Count);
}
#endregion
#region Reasonix providers
/// <summary>Trimmed from a real `reasonix doctor --json` run (v1.18.0).</summary>
private const string ReasonixDoctorJson = @"{
""version"": ""v1.18.0"",
""config"": { ""default_model"": ""deepseek-flash"" },
""providers"": [
{ ""name"": ""deepseek-flash"", ""models"": [""deepseek-v4-flash""], ""key_present"": true, ""is_default"": true },
{ ""name"": ""deepseek-pro"", ""models"": [""deepseek-v4-pro""], ""key_present"": false, ""is_default"": false }
],
""warnings"": []
}";
[TestMethod]
public void ReasonixProviders_AreListedByProviderNameNotModelId()
{
List<ModelOption> models = ModelCatalogParsers.ParseReasonixProviders(ReasonixDoctorJson);
// The ids must be the provider names: those are what --model accepts. Listing
// "deepseek-v4-flash" instead is exactly the mistake that broke native Reasonix.
Assert.AreEqual(2, models.Count);
Assert.AreEqual("deepseek-flash", models[0].Id);
Assert.AreEqual("deepseek-pro", models[1].Id);
}
[TestMethod]
public void ReasonixProviders_ShowTheServedModelInTheCaption()
{
List<ModelOption> models = ModelCatalogParsers.ParseReasonixProviders(ReasonixDoctorJson);
Assert.AreEqual("deepseek-flash — deepseek-v4-flash", models[0].DisplayName);
}
[TestMethod]
public void ReasonixProviders_KeepAProviderWhoseApiKeyIsMissing()
{
// key_present is an environment variable away from being true; hiding the entry would
// leave the user no way to select it once the key is set.
List<ModelOption> models = ModelCatalogParsers.ParseReasonixProviders(ReasonixDoctorJson);
Assert.IsTrue(models.Exists(m => m.Id == "deepseek-pro"));
}
[TestMethod]
public void ReasonixProviders_SkipAnyBannerPrintedBeforeTheJson()
{
List<ModelOption> models = ModelCatalogParsers.ParseReasonixProviders(
"A new version of reasonix is available!" + Environment.NewLine + ReasonixDoctorJson);
Assert.AreEqual(2, models.Count);
}
[TestMethod]
public void ReasonixProviders_ReturnNothingForUnusableOutput()
{
// An empty list keeps the previous catalog (FetchProviderModelsAsync) and leaves the
// launch flag empty, which starts Reasonix on its own configured default.
Assert.AreEqual(0, ModelCatalogParsers.ParseReasonixProviders(null).Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseReasonixProviders("command not found").Count);
Assert.AreEqual(0, ModelCatalogParsers.ParseReasonixProviders("{\"version\":\"v1.18.0\"}").Count);
}
#endregion
#region ACP launch flag
[TestMethod]
public void AcpArguments_CarryTheModelForAnAgentThatPublishesNoPicker()
{
var options = new AcpSessionOptions
{
ExecutablePath = @"C:\npm\reasonix.cmd",
ModelLaunchArgument = AcpCommandBuilder.BuildReasonixModelArgument("deepseek-v4-pro")
};
Assert.AreEqual("/c \"C:\\npm\\reasonix.cmd acp -model deepseek-v4-pro\"",
AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void ReasonixModelArgument_SpellsTheFlagOutInFull()
{
// "reasonix acp" parses flags with Go's flag package: no prefix matching, so "-m" exits
// with code 2 before the ACP server starts. Shipping that abbreviation broke every native
// Reasonix launch that had a model picked, and the failure looked like a dead pipe.
Assert.AreEqual("-model deepseek-chat", AcpCommandBuilder.BuildReasonixModelArgument("deepseek-chat"));
}
[TestMethod]
public void ReasonixModelArgument_IsEmptyWhenNoModelIsPicked()
{
// An empty flag is what leaves the CLI on its own config default; "-model" alone would
// swallow the next token as its value.
Assert.AreEqual(string.Empty, AcpCommandBuilder.BuildReasonixModelArgument(null));
Assert.AreEqual(string.Empty, AcpCommandBuilder.BuildReasonixModelArgument(" "));
}
[TestMethod]
public void AcpArguments_AreUnchangedWithoutAModel()
{
var options = new AcpSessionOptions { ExecutablePath = "opencode.exe" };
Assert.AreEqual("acp", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_UseQwenCodeAcpFlag()
{
// Qwen Code enters ACP through a flag, not a subcommand.
var options = new AcpSessionOptions { ExecutablePath = "qwen.exe", AcpArgument = "--acp" };
Assert.AreEqual("--acp", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_WrapQwenCodeNpmShimInCmd()
{
var options = new AcpSessionOptions { ExecutablePath = @"C:\npm\qwen.cmd", AcpArgument = "--acp" };
Assert.AreEqual("/c \"C:\\npm\\qwen.cmd --acp\"", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_PutGrokFlagsBeforeStdio()
{
// "grok agent stdio --always-approve" fails with "unexpected argument": every flag,
// including user-supplied extras, has to land before the stdio subcommand.
var options = new AcpSessionOptions
{
ExecutablePath = "grok.exe",
AcpArgument = "agent --always-approve",
ExtraArguments = "--verbose",
TrailingArgument = "stdio"
};
Assert.AreEqual("agent --always-approve --verbose stdio", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_GrokWithoutFlags()
{
var options = new AcpSessionOptions { ExecutablePath = "grok.exe", AcpArgument = "agent", TrailingArgument = "stdio" };
Assert.AreEqual("agent stdio", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_WrapGrokBatchShimInCmdWithStdioLast()
{
var options = new AcpSessionOptions { ExecutablePath = @"C:\tools\grok.cmd", AcpArgument = "agent", TrailingArgument = "stdio" };
Assert.AreEqual("/c \"C:\\tools\\grok.cmd agent stdio\"", AcpCommandBuilder.GetArguments(options));
}
[TestMethod]
public void AcpArguments_CarryTheModelInsideWsl()
{
var options = new AcpSessionOptions
{
ExecutablePath = "devin",
UseWsl = true,
WslWorkingDirectory = "/mnt/c/work",
ModelLaunchArgument = "-m swe-1.6"
};
Assert.AreEqual("bash -ic \"cd '/mnt/c/work' && devin acp -m swe-1.6\"",
AcpCommandBuilder.GetArguments(options));
}
#endregion
}
}