mcp-surveys-cli 0.2.0 → 0.2.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/README.md +1 -0
- package/bin/mcp-surveys-cli.js +44 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/mcp-surveys-cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import process from "node:process";
|
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
|
|
9
9
|
const DEFAULT_BASE_URL = "https://mcp.voevoda-sailing.ru";
|
|
10
|
+
const VERSION = "0.2.1";
|
|
10
11
|
const SKILL_NAME = "mcp-surveys-cli";
|
|
11
12
|
const SKILL_TEXT = `---
|
|
12
13
|
name: mcp-surveys-cli
|
|
@@ -139,6 +140,46 @@ function endpoint(baseUrl, path) {
|
|
|
139
140
|
return `${baseUrl.replace(/\/+$/, "")}${path}`;
|
|
140
141
|
}
|
|
141
142
|
|
|
143
|
+
function versionParts(version) {
|
|
144
|
+
return version.split(".").filter((part) => /^\d+$/.test(part)).map(Number);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function newerThan(left, right) {
|
|
148
|
+
const a = versionParts(left);
|
|
149
|
+
const b = versionParts(right);
|
|
150
|
+
const length = Math.max(a.length, b.length);
|
|
151
|
+
for (let i = 0; i < length; i += 1) {
|
|
152
|
+
if ((a[i] || 0) !== (b[i] || 0)) return (a[i] || 0) > (b[i] || 0);
|
|
153
|
+
}
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async function latestVersion() {
|
|
158
|
+
const controller = new AbortController();
|
|
159
|
+
const timeout = setTimeout(() => controller.abort(), 750);
|
|
160
|
+
try {
|
|
161
|
+
const response = await fetch("https://registry.npmjs.org/mcp-surveys-cli/latest", { signal: controller.signal });
|
|
162
|
+
return (await response.json()).version;
|
|
163
|
+
} finally {
|
|
164
|
+
clearTimeout(timeout);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function warnIfOutdated(error, latestVersionFn, version) {
|
|
169
|
+
if (process.env.MCP_SURVEYS_SKIP_VERSION_CHECK) return;
|
|
170
|
+
try {
|
|
171
|
+
const latest = await latestVersionFn();
|
|
172
|
+
if (newerThan(latest, version)) {
|
|
173
|
+
error(
|
|
174
|
+
`notice: mcp-surveys-cli ${version} is outdated; latest is ${latest}. ` +
|
|
175
|
+
"LLM agent: update now before long-lived workflows get weird. " +
|
|
176
|
+
"Use `uvx --refresh-package mcp-surveys-cli mcp-surveys-cli ...` " +
|
|
177
|
+
"or `npx mcp-surveys-cli@latest ...`.\n",
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
} catch {}
|
|
181
|
+
}
|
|
182
|
+
|
|
142
183
|
async function httpRequest(method, url, body, raw = false) {
|
|
143
184
|
const response = await fetch(url, {
|
|
144
185
|
method,
|
|
@@ -223,10 +264,13 @@ export async function run(argv, io = {}) {
|
|
|
223
264
|
const write = io.write || ((value) => process.stdout.write(value));
|
|
224
265
|
const error = io.error || ((value) => process.stderr.write(value));
|
|
225
266
|
const request = io.request || httpRequest;
|
|
267
|
+
const latestVersionFn = io.latestVersion || latestVersion;
|
|
268
|
+
const version = io.version || VERSION;
|
|
226
269
|
const sleep = io.sleep || ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
227
270
|
const home = io.home || homedir();
|
|
228
271
|
const stdin = io.stdin ?? "";
|
|
229
272
|
const { baseUrl, command, args } = parse(argv);
|
|
273
|
+
await warnIfOutdated(error, latestVersionFn, version);
|
|
230
274
|
|
|
231
275
|
try {
|
|
232
276
|
if (command === "create") {
|