@vtstech/pi-ollama-sync 1.0.3 → 1.0.4
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/ollama-sync.js +31 -44
- package/package.json +3 -2
package/ollama-sync.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
1
|
// .build-npm/ollama-sync/ollama-sync.temp.ts
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
import {
|
|
3
|
+
MODELS_JSON_PATH as MODELS_FILE,
|
|
4
|
+
fetchOllamaModels,
|
|
5
|
+
readModelsJson,
|
|
6
|
+
writeModelsJson,
|
|
7
|
+
isReasoningModel,
|
|
8
|
+
getOllamaBaseUrl
|
|
9
|
+
} from "@vtstech/pi-shared/ollama";
|
|
10
|
+
import { section, ok, warn, info } from "@vtstech/pi-shared/format";
|
|
27
11
|
var BRANDING = [
|
|
28
12
|
` \u26A1 Pi Ollama Sync v1.0.3`,
|
|
29
13
|
` Written by VTSTech`,
|
|
@@ -31,7 +15,7 @@ var BRANDING = [
|
|
|
31
15
|
` Website: www.vts-tech.org`
|
|
32
16
|
].join("\n");
|
|
33
17
|
function getProviderConfig(existing) {
|
|
34
|
-
const defaultUrl =
|
|
18
|
+
const defaultUrl = getOllamaBaseUrl();
|
|
35
19
|
const ollama = existing.providers["ollama"];
|
|
36
20
|
return {
|
|
37
21
|
baseUrl: ollama?.baseUrl ?? defaultUrl + "/v1",
|
|
@@ -46,7 +30,7 @@ function getProviderConfig(existing) {
|
|
|
46
30
|
function buildModelEntry(m) {
|
|
47
31
|
return {
|
|
48
32
|
id: m.name,
|
|
49
|
-
reasoning:
|
|
33
|
+
reasoning: isReasoningModel(m.name),
|
|
50
34
|
parameterSize: m.details.parameter_size,
|
|
51
35
|
quantizationLevel: m.details.quantization_level,
|
|
52
36
|
modelFamily: m.details.family || m.details.families?.[0] || "unknown"
|
|
@@ -70,7 +54,7 @@ function ollama_sync_temp_default(pi) {
|
|
|
70
54
|
pi.registerCommand("ollama-sync", {
|
|
71
55
|
description: "Sync models from Ollama into models.json. Use: /ollama-sync [url]",
|
|
72
56
|
getArgumentCompletions: async () => {
|
|
73
|
-
const url =
|
|
57
|
+
const url = getOllamaBaseUrl();
|
|
74
58
|
return [
|
|
75
59
|
{ value: url, label: url, description: "Default Ollama URL..." }
|
|
76
60
|
];
|
|
@@ -80,10 +64,10 @@ function ollama_sync_temp_default(pi) {
|
|
|
80
64
|
const overrideUrl = arg || void 0;
|
|
81
65
|
ctx.ui.setStatus("ollama-sync", "Fetching models from Ollama...");
|
|
82
66
|
try {
|
|
83
|
-
const existing =
|
|
67
|
+
const existing = readModelsJson();
|
|
84
68
|
const config = getProviderConfig(existing);
|
|
85
|
-
const ollamaBaseUrl = overrideUrl ? overrideUrl.replace(/\/v1$/, "").replace(/\/+$/, "") : config.baseUrl?.replace(/\/v1$/, "") ??
|
|
86
|
-
const models = await
|
|
69
|
+
const ollamaBaseUrl = overrideUrl ? overrideUrl.replace(/\/v1$/, "").replace(/\/+$/, "") : config.baseUrl?.replace(/\/v1$/, "") ?? getOllamaBaseUrl();
|
|
70
|
+
const models = await fetchOllamaModels(ollamaBaseUrl);
|
|
87
71
|
if (models.length === 0) {
|
|
88
72
|
ctx.ui.notify("No models found in Ollama", "info");
|
|
89
73
|
ctx.ui.setStatus("ollama-sync", void 0);
|
|
@@ -105,30 +89,30 @@ function ollama_sync_temp_default(pi) {
|
|
|
105
89
|
baseUrl: ollamaBaseUrl + "/v1",
|
|
106
90
|
models: mergedModels
|
|
107
91
|
};
|
|
108
|
-
|
|
92
|
+
writeModelsJson(existing);
|
|
109
93
|
const lines = [""];
|
|
110
94
|
lines.push(` Ollama: ${ollamaBaseUrl}`);
|
|
111
95
|
lines.push(` Synced ${newModels.length} models from Ollama`);
|
|
112
|
-
lines.push(
|
|
96
|
+
lines.push(section("Synced Models"));
|
|
113
97
|
for (const m of newModels) {
|
|
114
|
-
lines.push(
|
|
98
|
+
lines.push(ok(m.id));
|
|
115
99
|
lines.push(
|
|
116
100
|
` Params: ${m.parameterSize ?? "?"} \xB7 Quant: ${m.quantizationLevel ?? "?"} \xB7 Family: ${m.modelFamily ?? "?"}`
|
|
117
101
|
);
|
|
118
102
|
}
|
|
119
103
|
if (added.length > 0 || removed.length > 0) {
|
|
120
|
-
lines.push(
|
|
104
|
+
lines.push(section("Changes"));
|
|
121
105
|
if (added.length > 0) {
|
|
122
|
-
lines.push(
|
|
106
|
+
lines.push(ok(`Added ${added.length}: ${added.map((m) => m.id).join(", ")}`));
|
|
123
107
|
}
|
|
124
108
|
if (removed.length > 0) {
|
|
125
|
-
lines.push(
|
|
109
|
+
lines.push(warn(`Removed ${removed.length}: ${removed.join(", ")}`));
|
|
126
110
|
}
|
|
127
111
|
} else {
|
|
128
|
-
lines.push(
|
|
112
|
+
lines.push(info("No changes \u2014 already in sync"));
|
|
129
113
|
}
|
|
130
114
|
lines.push("");
|
|
131
|
-
lines.push(` Written to ${
|
|
115
|
+
lines.push(` Written to ${MODELS_FILE}`);
|
|
132
116
|
lines.push(` Run /reload to pick up changes`);
|
|
133
117
|
lines.push(BRANDING);
|
|
134
118
|
const report = lines.join("\n");
|
|
@@ -163,11 +147,11 @@ function ollama_sync_temp_default(pi) {
|
|
|
163
147
|
},
|
|
164
148
|
async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
|
|
165
149
|
const overrideUrl = params?.url;
|
|
166
|
-
const existing =
|
|
150
|
+
const existing = readModelsJson();
|
|
167
151
|
const config = getProviderConfig(existing);
|
|
168
|
-
const ollamaBaseUrl = overrideUrl ? overrideUrl.replace(/\/v1$/, "").replace(/\/+$/, "") : config.baseUrl?.replace(/\/v1$/, "") ??
|
|
152
|
+
const ollamaBaseUrl = overrideUrl ? overrideUrl.replace(/\/v1$/, "").replace(/\/+$/, "") : config.baseUrl?.replace(/\/v1$/, "") ?? getOllamaBaseUrl();
|
|
169
153
|
try {
|
|
170
|
-
const models = await
|
|
154
|
+
const models = await fetchOllamaModels(ollamaBaseUrl);
|
|
171
155
|
const sorted = [...models].sort((a, b) => a.size - b.size);
|
|
172
156
|
const newModels = sorted.map(buildModelEntry);
|
|
173
157
|
const mergedModels = mergeModels(
|
|
@@ -179,7 +163,7 @@ function ollama_sync_temp_default(pi) {
|
|
|
179
163
|
baseUrl: ollamaBaseUrl + "/v1",
|
|
180
164
|
models: mergedModels
|
|
181
165
|
};
|
|
182
|
-
|
|
166
|
+
writeModelsJson(existing);
|
|
183
167
|
const modelDetails = newModels.map(
|
|
184
168
|
(m) => ` \u2022 ${m.id} (${m.parameterSize}, ${m.quantizationLevel}, family: ${m.modelFamily})`
|
|
185
169
|
).join("\n");
|
|
@@ -189,7 +173,7 @@ function ollama_sync_temp_default(pi) {
|
|
|
189
173
|
type: "text",
|
|
190
174
|
text: `${BRANDING}
|
|
191
175
|
|
|
192
|
-
Synced ${newModels.length} models from ${ollamaBaseUrl} to ${
|
|
176
|
+
Synced ${newModels.length} models from ${ollamaBaseUrl} to ${MODELS_FILE}. Run /reload to pick up changes.
|
|
193
177
|
|
|
194
178
|
${modelDetails}`
|
|
195
179
|
}
|
|
@@ -205,3 +189,6 @@ ${modelDetails}`
|
|
|
205
189
|
}
|
|
206
190
|
});
|
|
207
191
|
}
|
|
192
|
+
export {
|
|
193
|
+
ollama_sync_temp_default as default
|
|
194
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vtstech/pi-ollama-sync",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Ollama model sync extension for Pi Coding Agent",
|
|
5
5
|
"main": "ollama-sync.js",
|
|
6
6
|
"keywords": ["pi-package", "pi-extensions"],
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"access": "public",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"author": "VTSTech",
|
|
10
11
|
"homepage": "https://www.vts-tech.org",
|
|
11
12
|
"repository": {
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
"url": "https://github.com/VTSTech/pi-coding-agent"
|
|
14
15
|
},
|
|
15
16
|
"dependencies": {
|
|
16
|
-
"@vtstech/pi-shared": "1.0.
|
|
17
|
+
"@vtstech/pi-shared": "1.0.4"
|
|
17
18
|
},
|
|
18
19
|
"peerDependencies": {
|
|
19
20
|
"@mariozechner/pi-coding-agent": ">=0.66"
|