opencommit 3.2.21 → 3.3.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/README.md +23 -2
- package/out/cli.cjs +140 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,6 +90,25 @@ export OLLAMA_HOST=0.0.0.0
|
|
|
90
90
|
|
|
91
91
|
This will make Ollama listen on all interfaces, including IPv6 and IPv4, resolving the connection issue. You can add this line to your shell configuration file (like `.bashrc` or `.zshrc`) to make it persistent across sessions.
|
|
92
92
|
|
|
93
|
+
### Running locally with llama.cpp
|
|
94
|
+
|
|
95
|
+
You can run OpenCommit with local models served by [llama.cpp](https://github.com/ggerganov/llama.cpp):
|
|
96
|
+
|
|
97
|
+
- install and build llama.cpp
|
|
98
|
+
- start the server with a GGUF model: `./llama-server -m model.gguf --port 8080`
|
|
99
|
+
- run (in your project directory):
|
|
100
|
+
|
|
101
|
+
```sh
|
|
102
|
+
git add <files...>
|
|
103
|
+
oco config set OCO_AI_PROVIDER='llamacpp' OCO_API_URL='http://localhost:8080'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If the server is running on a different machine, set the URL accordingly:
|
|
107
|
+
|
|
108
|
+
```sh
|
|
109
|
+
oco config set OCO_API_URL='http://192.168.1.10:8080'
|
|
110
|
+
```
|
|
111
|
+
|
|
93
112
|
### Flags
|
|
94
113
|
|
|
95
114
|
There are multiple optional flags that can be used with the `oco` command:
|
|
@@ -122,7 +141,7 @@ Create a `.env` file and add OpenCommit config variables there like this:
|
|
|
122
141
|
|
|
123
142
|
```env
|
|
124
143
|
...
|
|
125
|
-
OCO_AI_PROVIDER=<openai (default), anthropic, azure, ollama, gemini, flowise, deepseek, aimlapi>
|
|
144
|
+
OCO_AI_PROVIDER=<openai (default), anthropic, azure, ollama, llamacpp, gemini, flowise, deepseek, aimlapi>
|
|
126
145
|
OCO_API_KEY=<your OpenAI API token> // or other LLM provider API token
|
|
127
146
|
OCO_API_URL=<may be used to set proxy path to OpenAI api>
|
|
128
147
|
OCO_API_CUSTOM_HEADERS=<JSON string of custom HTTP headers to include in API requests>
|
|
@@ -227,7 +246,7 @@ oco models --provider anthropic
|
|
|
227
246
|
|
|
228
247
|
By default OpenCommit uses [OpenAI](https://openai.com).
|
|
229
248
|
|
|
230
|
-
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/) or Flowise or Ollama.
|
|
249
|
+
You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cognitive-services/openai/) or Flowise or Ollama or llama.cpp.
|
|
231
250
|
|
|
232
251
|
```sh
|
|
233
252
|
oco config set OCO_AI_PROVIDER=azure OCO_API_KEY=<your_azure_api_key> OCO_API_URL=<your_azure_endpoint>
|
|
@@ -235,6 +254,8 @@ oco config set OCO_AI_PROVIDER=azure OCO_API_KEY=<your_azure_api_key> OCO_API_UR
|
|
|
235
254
|
oco config set OCO_AI_PROVIDER=flowise OCO_API_KEY=<your_flowise_api_key> OCO_API_URL=<your_flowise_endpoint>
|
|
236
255
|
|
|
237
256
|
oco config set OCO_AI_PROVIDER=ollama OCO_API_KEY=<your_ollama_api_key> OCO_API_URL=<your_ollama_endpoint>
|
|
257
|
+
|
|
258
|
+
oco config set OCO_AI_PROVIDER=llamacpp OCO_API_URL=<your_llamacpp_endpoint>
|
|
238
259
|
```
|
|
239
260
|
|
|
240
261
|
### Use with Proxy
|
package/out/cli.cjs
CHANGED
|
@@ -33737,7 +33737,7 @@ var require_retries = __commonJS({
|
|
|
33737
33737
|
retryInterval = initialInterval * Math.pow(x5, exponent) + Math.random() * 1e3;
|
|
33738
33738
|
}
|
|
33739
33739
|
const d7 = Math.min(retryInterval, maxInterval);
|
|
33740
|
-
await
|
|
33740
|
+
await delay3(d7);
|
|
33741
33741
|
x5++;
|
|
33742
33742
|
}
|
|
33743
33743
|
}
|
|
@@ -33758,8 +33758,8 @@ var require_retries = __commonJS({
|
|
|
33758
33758
|
}
|
|
33759
33759
|
return 0;
|
|
33760
33760
|
}
|
|
33761
|
-
async function delay4
|
|
33762
|
-
return new Promise((resolve) => setTimeout(resolve,
|
|
33761
|
+
async function delay3(delay4) {
|
|
33762
|
+
return new Promise((resolve) => setTimeout(resolve, delay4));
|
|
33763
33763
|
}
|
|
33764
33764
|
}
|
|
33765
33765
|
});
|
|
@@ -48186,9 +48186,9 @@ var require_timers = __commonJS({
|
|
|
48186
48186
|
}
|
|
48187
48187
|
}
|
|
48188
48188
|
var Timeout = class {
|
|
48189
|
-
constructor(callback,
|
|
48189
|
+
constructor(callback, delay3, opaque) {
|
|
48190
48190
|
this.callback = callback;
|
|
48191
|
-
this.delay =
|
|
48191
|
+
this.delay = delay3;
|
|
48192
48192
|
this.opaque = opaque;
|
|
48193
48193
|
this.state = -2;
|
|
48194
48194
|
this.refresh();
|
|
@@ -48207,8 +48207,8 @@ var require_timers = __commonJS({
|
|
|
48207
48207
|
}
|
|
48208
48208
|
};
|
|
48209
48209
|
module2.exports = {
|
|
48210
|
-
setTimeout(callback,
|
|
48211
|
-
return
|
|
48210
|
+
setTimeout(callback, delay3, opaque) {
|
|
48211
|
+
return delay3 < 1e3 ? setTimeout(callback, delay3, opaque) : new Timeout(callback, delay3, opaque);
|
|
48212
48212
|
},
|
|
48213
48213
|
clearTimeout(timeout) {
|
|
48214
48214
|
if (timeout instanceof Timeout) {
|
|
@@ -57312,7 +57312,7 @@ var require_mock_utils = __commonJS({
|
|
|
57312
57312
|
if (mockDispatch2.data.callback) {
|
|
57313
57313
|
mockDispatch2.data = { ...mockDispatch2.data, ...mockDispatch2.data.callback(opts) };
|
|
57314
57314
|
}
|
|
57315
|
-
const { data: { statusCode, data, headers, trailers, error }, delay:
|
|
57315
|
+
const { data: { statusCode, data, headers, trailers, error }, delay: delay3, persist } = mockDispatch2;
|
|
57316
57316
|
const { timesInvoked, times } = mockDispatch2;
|
|
57317
57317
|
mockDispatch2.consumed = !persist && timesInvoked >= times;
|
|
57318
57318
|
mockDispatch2.pending = timesInvoked < times;
|
|
@@ -57321,10 +57321,10 @@ var require_mock_utils = __commonJS({
|
|
|
57321
57321
|
handler.onError(error);
|
|
57322
57322
|
return true;
|
|
57323
57323
|
}
|
|
57324
|
-
if (typeof
|
|
57324
|
+
if (typeof delay3 === "number" && delay3 > 0) {
|
|
57325
57325
|
setTimeout(() => {
|
|
57326
57326
|
handleReply(this[kDispatches]);
|
|
57327
|
-
},
|
|
57327
|
+
}, delay3);
|
|
57328
57328
|
} else {
|
|
57329
57329
|
handleReply(this[kDispatches]);
|
|
57330
57330
|
}
|
|
@@ -65273,7 +65273,7 @@ function G3(t2, e3) {
|
|
|
65273
65273
|
// package.json
|
|
65274
65274
|
var package_default = {
|
|
65275
65275
|
name: "opencommit",
|
|
65276
|
-
version: "3.2
|
|
65276
|
+
version: "3.3.2",
|
|
65277
65277
|
description: "Auto-generate impressive commits in 1 second. Killing lame commits with AI \u{1F92F}\u{1F52B}",
|
|
65278
65278
|
keywords: [
|
|
65279
65279
|
"git",
|
|
@@ -67524,9 +67524,9 @@ var MODEL_LIST = {
|
|
|
67524
67524
|
"deepseek/deepseek-prover-v2",
|
|
67525
67525
|
"google/gemma-3n-e4b-it",
|
|
67526
67526
|
"cohere/command-a",
|
|
67527
|
+
"minimax/minimax-m3",
|
|
67527
67528
|
"MiniMax-Text-01",
|
|
67528
67529
|
"abab6.5s-chat",
|
|
67529
|
-
"minimax/m1",
|
|
67530
67530
|
"bagoodex/bagoodex-search-v1",
|
|
67531
67531
|
"moonshot/kimi-k2-preview",
|
|
67532
67532
|
"perplexity/sonar",
|
|
@@ -67701,7 +67701,7 @@ var MODEL_LIST = {
|
|
|
67701
67701
|
"microsoft/phi-4-reasoning-plus:free",
|
|
67702
67702
|
"microsoft/phi-4-reasoning:free",
|
|
67703
67703
|
"microsoft/wizardlm-2-8x22b",
|
|
67704
|
-
"minimax/minimax-
|
|
67704
|
+
"minimax/minimax-m3",
|
|
67705
67705
|
"mistralai/codestral-2501",
|
|
67706
67706
|
"mistralai/devstral-small",
|
|
67707
67707
|
"mistralai/devstral-small:free",
|
|
@@ -67871,6 +67871,8 @@ var getDefaultModel = (provider) => {
|
|
|
67871
67871
|
switch (provider) {
|
|
67872
67872
|
case "ollama":
|
|
67873
67873
|
return "";
|
|
67874
|
+
case "llamacpp":
|
|
67875
|
+
return "";
|
|
67874
67876
|
case "mlx":
|
|
67875
67877
|
return "";
|
|
67876
67878
|
case "anthropic":
|
|
@@ -68051,8 +68053,8 @@ var configValidators = {
|
|
|
68051
68053
|
"deepseek",
|
|
68052
68054
|
"aimlapi",
|
|
68053
68055
|
"openrouter"
|
|
68054
|
-
].includes(value) || value.startsWith("ollama"),
|
|
68055
|
-
`${value} is not supported yet, use 'ollama', 'mlx', 'anthropic', 'azure', 'gemini', 'flowise', 'mistral', 'deepseek', 'aimlapi' or 'openai' (default)`
|
|
68056
|
+
].includes(value) || value.startsWith("ollama") || value.startsWith("llamacpp"),
|
|
68057
|
+
`${value} is not supported yet, use 'ollama', 'llamacpp', 'mlx', 'anthropic', 'azure', 'gemini', 'flowise', 'mistral', 'deepseek', 'aimlapi' or 'openai' (default)`
|
|
68056
68058
|
);
|
|
68057
68059
|
return value;
|
|
68058
68060
|
},
|
|
@@ -68088,6 +68090,7 @@ var configValidators = {
|
|
|
68088
68090
|
typeof value === "boolean",
|
|
68089
68091
|
"Must be true or false"
|
|
68090
68092
|
);
|
|
68093
|
+
return value;
|
|
68091
68094
|
},
|
|
68092
68095
|
["OCO_OLLAMA_THINK" /* OCO_OLLAMA_THINK */](value) {
|
|
68093
68096
|
validateConfig(
|
|
@@ -68095,11 +68098,11 @@ var configValidators = {
|
|
|
68095
68098
|
typeof value === "boolean",
|
|
68096
68099
|
"Must be true or false"
|
|
68097
68100
|
);
|
|
68098
|
-
return value;
|
|
68099
68101
|
}
|
|
68100
68102
|
};
|
|
68101
68103
|
var OCO_AI_PROVIDER_ENUM = /* @__PURE__ */ ((OCO_AI_PROVIDER_ENUM2) => {
|
|
68102
68104
|
OCO_AI_PROVIDER_ENUM2["OLLAMA"] = "ollama";
|
|
68105
|
+
OCO_AI_PROVIDER_ENUM2["LLAMACPP"] = "llamacpp";
|
|
68103
68106
|
OCO_AI_PROVIDER_ENUM2["OPENAI"] = "openai";
|
|
68104
68107
|
OCO_AI_PROVIDER_ENUM2["ANTHROPIC"] = "anthropic";
|
|
68105
68108
|
OCO_AI_PROVIDER_ENUM2["GEMINI"] = "gemini";
|
|
@@ -68125,6 +68128,7 @@ var PROVIDER_API_KEY_URLS = {
|
|
|
68125
68128
|
["aimlapi" /* AIMLAPI */]: "https://aimlapi.com/app/keys",
|
|
68126
68129
|
["azure" /* AZURE */]: "https://portal.azure.com/",
|
|
68127
68130
|
["ollama" /* OLLAMA */]: null,
|
|
68131
|
+
["llamacpp" /* LLAMACPP */]: null,
|
|
68128
68132
|
["mlx" /* MLX */]: null,
|
|
68129
68133
|
["flowise" /* FLOWISE */]: null,
|
|
68130
68134
|
["test" /* TEST */]: null
|
|
@@ -79802,6 +79806,40 @@ var GeminiEngine = class {
|
|
|
79802
79806
|
}
|
|
79803
79807
|
};
|
|
79804
79808
|
|
|
79809
|
+
// src/engine/llamacpp.ts
|
|
79810
|
+
var DEFAULT_LLAMACPP_URL = "http://localhost:8080";
|
|
79811
|
+
var LLAMACPP_CHAT_PATH = "/v1/chat/completions";
|
|
79812
|
+
var LlamaCppEngine = class {
|
|
79813
|
+
constructor(config8) {
|
|
79814
|
+
this.config = config8;
|
|
79815
|
+
const baseUrl = config8.baseURL || DEFAULT_LLAMACPP_URL;
|
|
79816
|
+
this.chatUrl = `${baseUrl}${LLAMACPP_CHAT_PATH}`;
|
|
79817
|
+
const headers = {
|
|
79818
|
+
"Content-Type": "application/json",
|
|
79819
|
+
...config8.customHeaders
|
|
79820
|
+
};
|
|
79821
|
+
this.client = axios_default.create({ headers });
|
|
79822
|
+
}
|
|
79823
|
+
async generateCommitMessage(messages) {
|
|
79824
|
+
const params = {
|
|
79825
|
+
model: this.config.model ?? "",
|
|
79826
|
+
messages,
|
|
79827
|
+
temperature: 0,
|
|
79828
|
+
top_p: 0.1,
|
|
79829
|
+
repeat_penalty: 1.1,
|
|
79830
|
+
stream: false
|
|
79831
|
+
};
|
|
79832
|
+
try {
|
|
79833
|
+
const response = await this.client.post(this.chatUrl, params);
|
|
79834
|
+
const choices = response.data.choices;
|
|
79835
|
+
const message = choices[0].message;
|
|
79836
|
+
return removeContentTags(message?.content, "think");
|
|
79837
|
+
} catch (error) {
|
|
79838
|
+
throw normalizeEngineError(error, "llamacpp", this.config.model);
|
|
79839
|
+
}
|
|
79840
|
+
}
|
|
79841
|
+
};
|
|
79842
|
+
|
|
79805
79843
|
// src/engine/ollama.ts
|
|
79806
79844
|
var DEFAULT_OLLAMA_URL = "http://localhost:11434";
|
|
79807
79845
|
var OLLAMA_CHAT_PATH = "/api/chat";
|
|
@@ -84838,6 +84876,8 @@ function getEngine() {
|
|
|
84838
84876
|
...DEFAULT_CONFIG2,
|
|
84839
84877
|
ollamaThink: config8.OCO_OLLAMA_THINK
|
|
84840
84878
|
});
|
|
84879
|
+
case "llamacpp" /* LLAMACPP */:
|
|
84880
|
+
return new LlamaCppEngine(DEFAULT_CONFIG2);
|
|
84841
84881
|
case "anthropic" /* ANTHROPIC */:
|
|
84842
84882
|
return new AnthropicEngine(DEFAULT_CONFIG2);
|
|
84843
84883
|
case "test" /* TEST */:
|
|
@@ -85467,11 +85507,7 @@ var generateCommitMessageByDiff = async (diff, fullGitMojiSpec = false, context
|
|
|
85467
85507
|
fullGitMojiSpec,
|
|
85468
85508
|
context
|
|
85469
85509
|
);
|
|
85470
|
-
const commitMessages =
|
|
85471
|
-
for (const promise of commitMessagePromises) {
|
|
85472
|
-
commitMessages.push(await promise);
|
|
85473
|
-
await delay3(2e3);
|
|
85474
|
-
}
|
|
85510
|
+
const commitMessages = await Promise.all(commitMessagePromises);
|
|
85475
85511
|
return commitMessages.join("\n\n");
|
|
85476
85512
|
}
|
|
85477
85513
|
const messages = await generateCommitMessageChatCompletionPrompt(
|
|
@@ -85592,9 +85628,6 @@ var getCommitMsgsPromisesFromFileDiffs = async (diff, maxDiffLength, fullGitMoji
|
|
|
85592
85628
|
}
|
|
85593
85629
|
return commitMessagePromises;
|
|
85594
85630
|
};
|
|
85595
|
-
function delay3(ms) {
|
|
85596
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
85597
|
-
}
|
|
85598
85631
|
|
|
85599
85632
|
// src/utils/git.ts
|
|
85600
85633
|
var import_fs3 = require("fs");
|
|
@@ -86098,9 +86131,15 @@ var prepareCommitMessageHook = async (isStageAllFlag = false) => {
|
|
|
86098
86131
|
}
|
|
86099
86132
|
const spin = le();
|
|
86100
86133
|
spin.start("Generating commit message");
|
|
86101
|
-
|
|
86102
|
-
|
|
86103
|
-
|
|
86134
|
+
let commitMessage;
|
|
86135
|
+
try {
|
|
86136
|
+
commitMessage = await generateCommitMessageByDiff(
|
|
86137
|
+
await getDiff({ files: staged })
|
|
86138
|
+
);
|
|
86139
|
+
} catch (error) {
|
|
86140
|
+
spin.stop("Done");
|
|
86141
|
+
throw error;
|
|
86142
|
+
}
|
|
86104
86143
|
spin.stop("Done");
|
|
86105
86144
|
const fileContent = await import_promises4.default.readFile(messageFilePath);
|
|
86106
86145
|
const messageWithComment = `# ${commitMessage}
|
|
@@ -86116,8 +86155,24 @@ ${fileContent.toString()}`;
|
|
|
86116
86155
|
const message = config8.OCO_HOOK_AUTO_UNCOMMENT ? messageWithoutComment : messageWithComment;
|
|
86117
86156
|
await import_promises4.default.writeFile(messageFilePath, message);
|
|
86118
86157
|
} catch (error) {
|
|
86119
|
-
|
|
86120
|
-
|
|
86158
|
+
try {
|
|
86159
|
+
ce(`${source_default.red("\u2716")} ${error}`);
|
|
86160
|
+
const fileContent = await import_promises4.default.readFile(messageFilePath);
|
|
86161
|
+
const commentedError = String(error).replace(new RegExp("^", "gm"), "# ");
|
|
86162
|
+
const message = `
|
|
86163
|
+
|
|
86164
|
+
# ---------- [OpenCommit] ---------- #
|
|
86165
|
+
# Failed to generate the commit message.
|
|
86166
|
+
# To cancel the commit, just close this window without making any changes.
|
|
86167
|
+
|
|
86168
|
+
${commentedError}
|
|
86169
|
+
|
|
86170
|
+
${fileContent.toString()}`;
|
|
86171
|
+
await import_promises4.default.writeFile(messageFilePath, message);
|
|
86172
|
+
} catch (error2) {
|
|
86173
|
+
ce(`${source_default.red("\u2716")} ${error2}`);
|
|
86174
|
+
process.exit(1);
|
|
86175
|
+
}
|
|
86121
86176
|
}
|
|
86122
86177
|
};
|
|
86123
86178
|
|
|
@@ -86186,6 +86241,18 @@ async function fetchOllamaModels(baseUrl = "http://localhost:11434") {
|
|
|
86186
86241
|
return [];
|
|
86187
86242
|
}
|
|
86188
86243
|
}
|
|
86244
|
+
async function fetchLlamaCppModels(baseUrl = "http://localhost:8080") {
|
|
86245
|
+
try {
|
|
86246
|
+
const response = await fetch(`${baseUrl}/v1/models`);
|
|
86247
|
+
if (!response.ok) {
|
|
86248
|
+
return [];
|
|
86249
|
+
}
|
|
86250
|
+
const data = await response.json();
|
|
86251
|
+
return data.data?.map((m5) => m5.id) || [];
|
|
86252
|
+
} catch {
|
|
86253
|
+
return [];
|
|
86254
|
+
}
|
|
86255
|
+
}
|
|
86189
86256
|
async function fetchAnthropicModels(apiKey) {
|
|
86190
86257
|
try {
|
|
86191
86258
|
const response = await fetch("https://api.anthropic.com/v1/models", {
|
|
@@ -86291,6 +86358,9 @@ async function fetchModelsForProvider(provider, apiKey, baseUrl, forceRefresh =
|
|
|
86291
86358
|
case "ollama" /* OLLAMA */:
|
|
86292
86359
|
models = await fetchOllamaModels(baseUrl);
|
|
86293
86360
|
break;
|
|
86361
|
+
case "llamacpp" /* LLAMACPP */:
|
|
86362
|
+
models = await fetchLlamaCppModels(baseUrl);
|
|
86363
|
+
break;
|
|
86294
86364
|
case "anthropic" /* ANTHROPIC */:
|
|
86295
86365
|
if (apiKey) {
|
|
86296
86366
|
models = await fetchAnthropicModels(apiKey);
|
|
@@ -86371,6 +86441,7 @@ var PROVIDER_DISPLAY_NAMES = {
|
|
|
86371
86441
|
["openai" /* OPENAI */]: "OpenAI (GPT-4o, GPT-4)",
|
|
86372
86442
|
["anthropic" /* ANTHROPIC */]: "Anthropic (Claude Sonnet, Opus)",
|
|
86373
86443
|
["ollama" /* OLLAMA */]: "Ollama (Free, runs locally)",
|
|
86444
|
+
["llamacpp" /* LLAMACPP */]: "llama.cpp (Free, runs locally)",
|
|
86374
86445
|
["gemini" /* GEMINI */]: "Google Gemini",
|
|
86375
86446
|
["groq" /* GROQ */]: "Groq (Fast inference, free tier)",
|
|
86376
86447
|
["mistral" /* MISTRAL */]: "Mistral AI",
|
|
@@ -86383,7 +86454,8 @@ var PROVIDER_DISPLAY_NAMES = {
|
|
|
86383
86454
|
var PRIMARY_PROVIDERS = [
|
|
86384
86455
|
"openai" /* OPENAI */,
|
|
86385
86456
|
"anthropic" /* ANTHROPIC */,
|
|
86386
|
-
"ollama" /* OLLAMA
|
|
86457
|
+
"ollama" /* OLLAMA */,
|
|
86458
|
+
"llamacpp" /* LLAMACPP */
|
|
86387
86459
|
];
|
|
86388
86460
|
var OTHER_PROVIDERS = [
|
|
86389
86461
|
"gemini" /* GEMINI */,
|
|
@@ -86397,12 +86469,14 @@ var OTHER_PROVIDERS = [
|
|
|
86397
86469
|
];
|
|
86398
86470
|
var NO_API_KEY_PROVIDERS = [
|
|
86399
86471
|
"ollama" /* OLLAMA */,
|
|
86472
|
+
"llamacpp" /* LLAMACPP */,
|
|
86400
86473
|
"mlx" /* MLX */,
|
|
86401
86474
|
"test" /* TEST */
|
|
86402
86475
|
];
|
|
86403
86476
|
var MODEL_REQUIRED_PROVIDERS = [
|
|
86404
86477
|
"ollama" /* OLLAMA */,
|
|
86405
|
-
"mlx" /* MLX
|
|
86478
|
+
"mlx" /* MLX */,
|
|
86479
|
+
"llamacpp" /* LLAMACPP */
|
|
86406
86480
|
];
|
|
86407
86481
|
async function selectProvider() {
|
|
86408
86482
|
const primaryOptions = PRIMARY_PROVIDERS.map((provider) => ({
|
|
@@ -86615,6 +86689,28 @@ async function setupOllama() {
|
|
|
86615
86689
|
apiUrl: apiUrl || defaultUrl
|
|
86616
86690
|
};
|
|
86617
86691
|
}
|
|
86692
|
+
async function setupLlamaCpp() {
|
|
86693
|
+
console.log(source_default.cyan("\n llama.cpp - Free Local AI\n"));
|
|
86694
|
+
console.log(source_default.dim(" Setup steps:"));
|
|
86695
|
+
console.log(
|
|
86696
|
+
source_default.dim(" 1. Install: https://github.com/ggerganov/llama.cpp")
|
|
86697
|
+
);
|
|
86698
|
+
console.log(
|
|
86699
|
+
source_default.dim(" 2. Start server: llama-server -m <model.gguf> --port 8080\n")
|
|
86700
|
+
);
|
|
86701
|
+
const defaultUrl = "http://localhost:8080";
|
|
86702
|
+
const apiUrl = await J4({
|
|
86703
|
+
message: "llama.cpp server URL (press Enter for default):",
|
|
86704
|
+
placeholder: defaultUrl,
|
|
86705
|
+
defaultValue: defaultUrl
|
|
86706
|
+
});
|
|
86707
|
+
if (hD2(apiUrl)) return null;
|
|
86708
|
+
return {
|
|
86709
|
+
provider: "llamacpp" /* LLAMACPP */,
|
|
86710
|
+
model: "",
|
|
86711
|
+
apiUrl: apiUrl || defaultUrl
|
|
86712
|
+
};
|
|
86713
|
+
}
|
|
86618
86714
|
async function runSetup() {
|
|
86619
86715
|
ae(source_default.bgCyan(" Welcome to OpenCommit! "));
|
|
86620
86716
|
const provider = await selectProvider();
|
|
@@ -86654,6 +86750,19 @@ async function runSetup() {
|
|
|
86654
86750
|
OCO_API_KEY: "mlx"
|
|
86655
86751
|
// Placeholder
|
|
86656
86752
|
};
|
|
86753
|
+
} else if (provider === "llamacpp" /* LLAMACPP */) {
|
|
86754
|
+
const llamacppConfig = await setupLlamaCpp();
|
|
86755
|
+
if (!llamacppConfig) {
|
|
86756
|
+
ce("Setup cancelled");
|
|
86757
|
+
return false;
|
|
86758
|
+
}
|
|
86759
|
+
config8 = {
|
|
86760
|
+
OCO_AI_PROVIDER: llamacppConfig.provider,
|
|
86761
|
+
OCO_MODEL: llamacppConfig.model,
|
|
86762
|
+
OCO_API_URL: llamacppConfig.apiUrl,
|
|
86763
|
+
OCO_API_KEY: "llamacpp"
|
|
86764
|
+
// Placeholder
|
|
86765
|
+
};
|
|
86657
86766
|
} else {
|
|
86658
86767
|
const apiKey = await getApiKey(provider);
|
|
86659
86768
|
if (hD2(apiKey)) {
|