@makerbi/remodex 2.0.0 → 2.3.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.
@@ -0,0 +1,108 @@
1
+ // FILE: opencode-models.js
2
+ // Purpose: Normalizes OpenCode CLI model metadata into Remodex provider-aware model entries.
3
+ // Layer: Bridge runtime provider helper
4
+ // Exports: OpenCode provider constants plus model/provider parsing helpers.
5
+ // Depends on: ./runtime-provider-models
6
+
7
+ const {
8
+ CODEX_PROVIDER_ID,
9
+ OPENCODE_PROVIDER_ID,
10
+ buildRuntimeModelOption,
11
+ isCodexProvider,
12
+ isOpenCodeProvider,
13
+ normalizeRuntimeProvider,
14
+ readModelProvider,
15
+ } = require("./runtime-provider-models");
16
+ const DEFAULT_OPENCODE_MODEL = "opencode/gpt-5.5";
17
+
18
+ function buildOpenCodeModelOption(modelReference, { isDefault = false } = {}) {
19
+ const normalizedReference = normalizeOpenCodeModelReference(modelReference);
20
+ if (!normalizedReference) {
21
+ return null;
22
+ }
23
+
24
+ return buildRuntimeModelOption({
25
+ provider: OPENCODE_PROVIDER_ID,
26
+ id: normalizedReference,
27
+ model: normalizedReference,
28
+ displayName: displayNameForOpenCodeModel(normalizedReference),
29
+ description: `OpenCode local provider model (${normalizedReference})`,
30
+ isDefault,
31
+ supportsFastMode: false,
32
+ supportedReasoningEfforts: [],
33
+ defaultReasoningEffort: null,
34
+ });
35
+ }
36
+
37
+ function parseOpenCodeModelsOutput(output) {
38
+ const seen = new Set();
39
+ const models = [];
40
+ const lines = String(output || "").split(/\r?\n/);
41
+
42
+ for (const line of lines) {
43
+ const modelReference = normalizeOpenCodeModelReference(line);
44
+ if (!modelReference || seen.has(modelReference)) {
45
+ continue;
46
+ }
47
+
48
+ seen.add(modelReference);
49
+ models.push(buildOpenCodeModelOption(modelReference, {
50
+ isDefault: modelReference === DEFAULT_OPENCODE_MODEL,
51
+ }));
52
+ }
53
+
54
+ return models.filter(Boolean);
55
+ }
56
+
57
+ function normalizeOpenCodeModelReference(value) {
58
+ const normalized = typeof value === "string" ? value.trim() : "";
59
+ if (!normalized || normalized.startsWith("{") || normalized.startsWith("[")) {
60
+ return "";
61
+ }
62
+ if (!/^[A-Za-z0-9._:-]+\/[A-Za-z0-9._:-]+$/.test(normalized)) {
63
+ return "";
64
+ }
65
+ return normalized;
66
+ }
67
+
68
+ function displayNameForOpenCodeModel(modelReference) {
69
+ const normalized = normalizeOpenCodeModelReference(modelReference);
70
+ const modelId = normalized.split("/").pop() || normalized;
71
+ const lowered = modelId.toLowerCase();
72
+
73
+ if (lowered.startsWith("gpt-")) {
74
+ return `GPT-${modelId.slice(4)}`;
75
+ }
76
+ if (lowered.startsWith("claude-")) {
77
+ return modelId
78
+ .split("-")
79
+ .map((part) => (part.length <= 2 ? part.toUpperCase() : titleCase(part)))
80
+ .join(" ");
81
+ }
82
+
83
+ return modelId
84
+ .split(/[-_]/)
85
+ .map(titleCase)
86
+ .join(" ");
87
+ }
88
+
89
+ function titleCase(value) {
90
+ if (!value) {
91
+ return "";
92
+ }
93
+ return value.charAt(0).toUpperCase() + value.slice(1);
94
+ }
95
+
96
+ module.exports = {
97
+ CODEX_PROVIDER_ID,
98
+ DEFAULT_OPENCODE_MODEL,
99
+ OPENCODE_PROVIDER_ID,
100
+ buildOpenCodeModelOption,
101
+ displayNameForOpenCodeModel,
102
+ isCodexProvider,
103
+ isOpenCodeProvider,
104
+ normalizeOpenCodeModelReference,
105
+ normalizeRuntimeProvider,
106
+ parseOpenCodeModelsOutput,
107
+ readModelProvider,
108
+ };