opencode-azure-setup 1.0.1 → 1.0.2
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/index.js +30 -4
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -79,12 +79,35 @@ function askPassword(question) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
// Fetch latest defaults from GitHub (falls back to hardcoded if offline)
|
|
83
|
+
async function fetchDefaults() {
|
|
84
|
+
const defaults = {
|
|
85
|
+
deployment: 'model-router',
|
|
86
|
+
apiVersion: '2025-01-01-preview',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const res = await fetch('https://raw.githubusercontent.com/schwarztim/opencode/dev/azure-defaults.json', {
|
|
91
|
+
signal: AbortSignal.timeout(3000),
|
|
92
|
+
});
|
|
93
|
+
if (res.ok) {
|
|
94
|
+
const data = await res.json();
|
|
95
|
+
if (data.apiVersion) defaults.apiVersion = data.apiVersion;
|
|
96
|
+
if (data.deployment) defaults.deployment = data.deployment;
|
|
97
|
+
}
|
|
98
|
+
} catch {
|
|
99
|
+
// Offline or fetch failed - use hardcoded defaults
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return defaults;
|
|
103
|
+
}
|
|
104
|
+
|
|
82
105
|
// Parse Azure endpoint - handles both full URL and base URL
|
|
83
|
-
function parseAzureEndpoint(input) {
|
|
106
|
+
function parseAzureEndpoint(input, defaults) {
|
|
84
107
|
const result = {
|
|
85
108
|
baseUrl: '',
|
|
86
|
-
deployment:
|
|
87
|
-
apiVersion:
|
|
109
|
+
deployment: defaults.deployment,
|
|
110
|
+
apiVersion: defaults.apiVersion,
|
|
88
111
|
};
|
|
89
112
|
|
|
90
113
|
try {
|
|
@@ -170,6 +193,9 @@ async function main() {
|
|
|
170
193
|
console.log('─'.repeat(40));
|
|
171
194
|
console.log();
|
|
172
195
|
|
|
196
|
+
// Fetch latest defaults (non-blocking, falls back to hardcoded)
|
|
197
|
+
const defaults = await fetchDefaults();
|
|
198
|
+
|
|
173
199
|
// Endpoint - accepts full URL or just the base
|
|
174
200
|
console.log('Paste your Azure OpenAI endpoint');
|
|
175
201
|
console.log(colors.dim + 'Tip: You can paste the full URL from Azure Portal - we\'ll extract what we need' + colors.reset);
|
|
@@ -182,7 +208,7 @@ async function main() {
|
|
|
182
208
|
}
|
|
183
209
|
|
|
184
210
|
// Parse the endpoint - extracts base URL, deployment, and api-version automatically
|
|
185
|
-
const parsed = parseAzureEndpoint(rawEndpoint);
|
|
211
|
+
const parsed = parseAzureEndpoint(rawEndpoint, defaults);
|
|
186
212
|
|
|
187
213
|
// API Key
|
|
188
214
|
console.log();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-azure-setup",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Easy Azure OpenAI setup for OpenCode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"repository": {
|
|
24
24
|
"type": "git",
|
|
25
|
-
"url": "https://github.com/schwarztim/opencode.git"
|
|
25
|
+
"url": "git+https://github.com/schwarztim/opencode.git"
|
|
26
26
|
},
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=18"
|