@kyubiware/commit-mint 0.11.0 โ 0.12.1
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/dist/bin.mjs +37 -12
- package/dist/bin.mjs.map +1 -1
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -33,7 +33,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
33
33
|
//#region package.json
|
|
34
34
|
var package_default = {
|
|
35
35
|
name: "@kyubiware/commit-mint",
|
|
36
|
-
version: "0.
|
|
36
|
+
version: "0.12.1",
|
|
37
37
|
description: "๐ฟ AI-powered git commit tool โ auto-group changed files, generate messages, run pre-commit checks",
|
|
38
38
|
type: "module",
|
|
39
39
|
bin: { "cmint": "./dist/bin.mjs" },
|
|
@@ -135,13 +135,19 @@ const PROVIDER_CONFIGS = {
|
|
|
135
135
|
mistral: {
|
|
136
136
|
baseURL: "https://api.mistral.ai/v1",
|
|
137
137
|
defaultModel: "mistral-small"
|
|
138
|
+
},
|
|
139
|
+
omniroute: {
|
|
140
|
+
baseURL: "http://localhost:20128/v1",
|
|
141
|
+
defaultModel: "auto",
|
|
142
|
+
requiresApiKey: false
|
|
138
143
|
}
|
|
139
144
|
};
|
|
140
145
|
const ALLOWED_PROVIDERS = Object.keys(PROVIDER_CONFIGS);
|
|
141
146
|
const PROVIDER_ENV_KEYS = {
|
|
142
147
|
groq: "GROQ_API_KEY",
|
|
143
148
|
cerebras: "CEREBRAS_API_KEY",
|
|
144
|
-
mistral: "MISTRAL_API_KEY"
|
|
149
|
+
mistral: "MISTRAL_API_KEY",
|
|
150
|
+
omniroute: "OMNIROUTE_API_KEY"
|
|
145
151
|
};
|
|
146
152
|
function formatProviderName(provider) {
|
|
147
153
|
return provider.charAt(0).toUpperCase() + provider.slice(1);
|
|
@@ -165,16 +171,21 @@ function createFetchClient(baseURL, apiKey, timeout) {
|
|
|
165
171
|
method: "POST",
|
|
166
172
|
headers: {
|
|
167
173
|
"Content-Type": "application/json",
|
|
168
|
-
Authorization: `Bearer ${apiKey}`
|
|
174
|
+
...apiKey ? { Authorization: `Bearer ${apiKey}` } : {}
|
|
169
175
|
},
|
|
170
|
-
body: JSON.stringify(
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
...params,
|
|
178
|
+
stream: false
|
|
179
|
+
}),
|
|
171
180
|
signal: controller.signal
|
|
172
181
|
});
|
|
173
182
|
if (!response.ok) {
|
|
174
183
|
const text = await response.text().catch(() => "");
|
|
175
184
|
throw new Error(`${response.status} ${text}`);
|
|
176
185
|
}
|
|
177
|
-
|
|
186
|
+
const data = await response.json();
|
|
187
|
+
for (const choice of data.choices ?? []) if (!choice.message?.reasoning && choice.message?.reasoning_content) choice.message.reasoning = choice.message.reasoning_content;
|
|
188
|
+
return data;
|
|
178
189
|
} finally {
|
|
179
190
|
clearTimeout(timer);
|
|
180
191
|
}
|
|
@@ -249,6 +260,10 @@ async function getProviderApiKey(provider) {
|
|
|
249
260
|
return config[configKey];
|
|
250
261
|
}
|
|
251
262
|
debug("getProviderApiKey(%s): not found", provider);
|
|
263
|
+
if (PROVIDER_CONFIGS[provider]?.requiresApiKey === false) {
|
|
264
|
+
debug("getProviderApiKey(%s): optional key not set, continuing without auth", provider);
|
|
265
|
+
return "";
|
|
266
|
+
}
|
|
252
267
|
throw new Error(`Please set your ${formatProviderName(provider)} API key via \`cmint config set ${envVar}=<your token>\``);
|
|
253
268
|
}
|
|
254
269
|
/** Check if a model name is the default for a provider OTHER than the given one. */
|
|
@@ -4528,9 +4543,10 @@ function buildConfigDisplay(config) {
|
|
|
4528
4543
|
const provider = isValidProvider(config.provider ?? "groq") ? config.provider : "groq";
|
|
4529
4544
|
const apiKey = config[PROVIDER_ENV_KEYS[provider]];
|
|
4530
4545
|
const effectiveModel = getModelForProvider(config, provider, PROVIDER_CONFIGS[provider].defaultModel);
|
|
4546
|
+
const keyLabel = apiKey ?? (PROVIDER_CONFIGS[provider].requiresApiKey === false ? dim("(optional)") : void 0);
|
|
4531
4547
|
return [
|
|
4532
4548
|
`Provider: ${bold(formatProviderName(provider))}`,
|
|
4533
|
-
`API Key: ${maskKey(
|
|
4549
|
+
`API Key: ${maskKey(keyLabel)}`,
|
|
4534
4550
|
`Model: ${effectiveModel}`,
|
|
4535
4551
|
`Locale: ${config.locale ?? "en"}`,
|
|
4536
4552
|
`Max Length: ${config["max-length"] ?? "100"}`,
|
|
@@ -4560,20 +4576,29 @@ async function promptProvider() {
|
|
|
4560
4576
|
label: "Mistral",
|
|
4561
4577
|
value: "mistral",
|
|
4562
4578
|
hint: PROVIDER_CONFIGS.mistral.defaultModel
|
|
4579
|
+
},
|
|
4580
|
+
{
|
|
4581
|
+
label: "OmniRoute",
|
|
4582
|
+
value: "omniroute",
|
|
4583
|
+
hint: `local gateway ยท ${PROVIDER_CONFIGS.omniroute.defaultModel}`
|
|
4563
4584
|
}
|
|
4564
4585
|
]
|
|
4565
4586
|
});
|
|
4566
4587
|
}
|
|
4567
4588
|
async function promptApiKey(provider) {
|
|
4568
4589
|
const keyName = PROVIDER_ENV_KEYS[provider];
|
|
4590
|
+
const requiresKey = PROVIDER_CONFIGS[provider].requiresApiKey !== false;
|
|
4569
4591
|
const result = await p$1.text({
|
|
4570
|
-
message: `${formatProviderName(provider)} API key:`,
|
|
4571
|
-
placeholder: "Paste your API key",
|
|
4572
|
-
validate: (v) => !v?.trim() ? "API key cannot be empty" : void 0
|
|
4592
|
+
message: `${formatProviderName(provider)} API key${requiresKey ? "" : " (optional)"}:`,
|
|
4593
|
+
placeholder: requiresKey ? "Paste your API key" : "Leave empty for none",
|
|
4594
|
+
validate: (v) => !v?.trim() && requiresKey ? "API key cannot be empty" : void 0
|
|
4573
4595
|
});
|
|
4574
4596
|
if (p$1.isCancel(result)) return result;
|
|
4575
|
-
|
|
4576
|
-
|
|
4597
|
+
const trimmed = result.toString().trim();
|
|
4598
|
+
if (trimmed) {
|
|
4599
|
+
await writeConfig({ [keyName]: trimmed });
|
|
4600
|
+
debug("config: %s set", keyName);
|
|
4601
|
+
}
|
|
4577
4602
|
return result;
|
|
4578
4603
|
}
|
|
4579
4604
|
async function promptTextSetting(label, configKey, currentValue, validate) {
|
|
@@ -4606,7 +4631,7 @@ function getSettingHandlers(config) {
|
|
|
4606
4631
|
});
|
|
4607
4632
|
debug("config: provider set to %s, model set to %s", newProvider, newDefaultModel);
|
|
4608
4633
|
const keyName = PROVIDER_ENV_KEYS[newProvider];
|
|
4609
|
-
if (!(await readConfig())[keyName]) {
|
|
4634
|
+
if (!(await readConfig())[keyName] && PROVIDER_CONFIGS[newProvider].requiresApiKey !== false) {
|
|
4610
4635
|
const keyResult = await promptApiKey(newProvider);
|
|
4611
4636
|
if (p$1.isCancel(keyResult)) return keyResult;
|
|
4612
4637
|
}
|