ceddcozum 0.1.4 → 0.1.6
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/index.js +84 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -27131,8 +27131,9 @@ function formatHuman(toolName, results, schema) {
|
|
|
27131
27131
|
lines.push("");
|
|
27132
27132
|
for (const r of altRows) {
|
|
27133
27133
|
if (r.altToolName && r.altArgs) {
|
|
27134
|
+
const kvParts = Object.entries(r.altArgs).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
27134
27135
|
lines.push(` ${dim("tip:")} ${r.value}`);
|
|
27135
|
-
lines.push(` ${dim(" ceddcozum")} ${r.altToolName} ${
|
|
27136
|
+
lines.push(` ${dim(" ceddcozum")} ${r.altToolName} ${kvParts}`);
|
|
27136
27137
|
} else {
|
|
27137
27138
|
lines.push(` ${dim("tip:")} ${r.value}`);
|
|
27138
27139
|
}
|
|
@@ -27147,12 +27148,13 @@ function formatHuman(toolName, results, schema) {
|
|
|
27147
27148
|
const noop = () => null;
|
|
27148
27149
|
globalThis.localStorage = { getItem: noop, setItem: noop, removeItem: noop, clear: noop, length: 0, key: noop };
|
|
27149
27150
|
})();
|
|
27150
|
-
var
|
|
27151
|
-
var
|
|
27152
|
-
var
|
|
27153
|
-
var
|
|
27154
|
-
var
|
|
27155
|
-
var
|
|
27151
|
+
var useColor = !process.env.NO_COLOR && process.stdout.isTTY !== false;
|
|
27152
|
+
var bold2 = (s) => useColor ? `\x1B[1m${s}\x1B[0m` : s;
|
|
27153
|
+
var dim2 = (s) => useColor ? `\x1B[2m${s}\x1B[0m` : s;
|
|
27154
|
+
var cyan2 = (s) => useColor ? `\x1B[36m${s}\x1B[0m` : s;
|
|
27155
|
+
var green = (s) => useColor ? `\x1B[32m${s}\x1B[0m` : s;
|
|
27156
|
+
var yellow2 = (s) => useColor ? `\x1B[33m${s}\x1B[0m` : s;
|
|
27157
|
+
var magenta = (s) => useColor ? `\x1B[35m${s}\x1B[0m` : s;
|
|
27156
27158
|
var HIDDEN_TOOL_IDS = [
|
|
27157
27159
|
"steroid-tapering",
|
|
27158
27160
|
"periop-adrenal",
|
|
@@ -27168,7 +27170,7 @@ var HIDDEN_TOOL_IDS = [
|
|
|
27168
27170
|
"gfr",
|
|
27169
27171
|
"leptin-sds"
|
|
27170
27172
|
];
|
|
27171
|
-
var VERSION = "0.1.
|
|
27173
|
+
var VERSION = "0.1.6";
|
|
27172
27174
|
var visibleSchemas = toolSchemas.filter(
|
|
27173
27175
|
(s) => !HIDDEN_TOOL_IDS.includes(s.function.name)
|
|
27174
27176
|
);
|
|
@@ -27205,6 +27207,56 @@ var CATEGORY_LABELS = {
|
|
|
27205
27207
|
function getSchemaByName(name) {
|
|
27206
27208
|
return visibleSchemas.find((s) => s.function.name === name);
|
|
27207
27209
|
}
|
|
27210
|
+
function camelToKebab(s) {
|
|
27211
|
+
return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
27212
|
+
}
|
|
27213
|
+
function kebabToCamel(s) {
|
|
27214
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
27215
|
+
}
|
|
27216
|
+
function levenshtein(a, b) {
|
|
27217
|
+
const m = a.length, n = b.length;
|
|
27218
|
+
const dp = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0));
|
|
27219
|
+
for (let i = 0; i <= m; i++) dp[i][0] = i;
|
|
27220
|
+
for (let j = 0; j <= n; j++) dp[0][j] = j;
|
|
27221
|
+
for (let i = 1; i <= m; i++) {
|
|
27222
|
+
for (let j = 1; j <= n; j++) {
|
|
27223
|
+
dp[i][j] = Math.min(
|
|
27224
|
+
dp[i - 1][j] + 1,
|
|
27225
|
+
dp[i][j - 1] + 1,
|
|
27226
|
+
dp[i - 1][j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1)
|
|
27227
|
+
);
|
|
27228
|
+
}
|
|
27229
|
+
}
|
|
27230
|
+
return dp[m][n];
|
|
27231
|
+
}
|
|
27232
|
+
function suggestTool(input) {
|
|
27233
|
+
let best = null;
|
|
27234
|
+
let bestDist = 4;
|
|
27235
|
+
for (const s of visibleSchemas) {
|
|
27236
|
+
const d = levenshtein(input.toLowerCase(), s.function.name.toLowerCase());
|
|
27237
|
+
if (d < bestDist) {
|
|
27238
|
+
bestDist = d;
|
|
27239
|
+
best = s.function.name;
|
|
27240
|
+
}
|
|
27241
|
+
}
|
|
27242
|
+
return best;
|
|
27243
|
+
}
|
|
27244
|
+
function exampleValue(key, prop) {
|
|
27245
|
+
if (prop.enum) return prop.enum[0];
|
|
27246
|
+
if (prop.type === "boolean") return "true";
|
|
27247
|
+
const k = key.toLowerCase();
|
|
27248
|
+
if (k === "age" || k.includes("age")) return "5.5";
|
|
27249
|
+
if (k === "height") return "110";
|
|
27250
|
+
if (k === "weight") return "19";
|
|
27251
|
+
if (k.includes("circumference") || k === "headcircumference") return "50";
|
|
27252
|
+
if (k === "gestationalweeks" || k.includes("gestational")) return "38";
|
|
27253
|
+
if (k === "birthweight") return "3200";
|
|
27254
|
+
if (k.includes("percent")) return "7.5";
|
|
27255
|
+
if (k.includes("systolic")) return "110";
|
|
27256
|
+
if (k.includes("diastolic")) return "70";
|
|
27257
|
+
if (prop.type === "number") return "10";
|
|
27258
|
+
return "value";
|
|
27259
|
+
}
|
|
27208
27260
|
function printHelp() {
|
|
27209
27261
|
console.log(`
|
|
27210
27262
|
${bold2("ceddcozum")} v${VERSION} ${dim2("\u2014 Pediatric clinical calculators")}
|
|
@@ -27236,7 +27288,8 @@ function printList() {
|
|
|
27236
27288
|
const name = schema.function.name;
|
|
27237
27289
|
const meta = findMeta(name);
|
|
27238
27290
|
const category = getCategoryForSchema(name);
|
|
27239
|
-
const
|
|
27291
|
+
const raw = meta?.subtitleFallback ?? schema.function.description;
|
|
27292
|
+
const subtitle = raw.length > 50 ? raw.slice(0, 49) + "\u2026" : raw;
|
|
27240
27293
|
if (!byCategory.has(category)) byCategory.set(category, []);
|
|
27241
27294
|
byCategory.get(category).push({ id: name, subtitle });
|
|
27242
27295
|
}
|
|
@@ -27307,9 +27360,7 @@ ${bold2("EXAMPLE")}`);
|
|
|
27307
27360
|
const exParts = [];
|
|
27308
27361
|
for (const key of required) {
|
|
27309
27362
|
const prop = params.properties[key];
|
|
27310
|
-
|
|
27311
|
-
else if (prop?.type === "number") exParts.push(`${key}=...`);
|
|
27312
|
-
else exParts.push(`${key}=...`);
|
|
27363
|
+
exParts.push(`${key}=${exampleValue(key, prop ?? { type: "string" })}`);
|
|
27313
27364
|
}
|
|
27314
27365
|
console.log(` ${dim2("$")} ceddcozum ${name} ${exParts.join(" ")}`);
|
|
27315
27366
|
console.log();
|
|
@@ -27363,7 +27414,9 @@ function parseKeyValueArgs(pairs, schema) {
|
|
|
27363
27414
|
}
|
|
27364
27415
|
const rawKey = pair.slice(0, eqIdx);
|
|
27365
27416
|
const raw = pair.slice(eqIdx + 1);
|
|
27366
|
-
const key = Object.keys(props).find(
|
|
27417
|
+
const key = Object.keys(props).find(
|
|
27418
|
+
(k) => k.toLowerCase() === rawKey.toLowerCase() || camelToKebab(k) === rawKey.toLowerCase() || k.toLowerCase() === kebabToCamel(rawKey).toLowerCase()
|
|
27419
|
+
) ?? rawKey;
|
|
27367
27420
|
const prop = props[key];
|
|
27368
27421
|
if (prop?.type === "number") {
|
|
27369
27422
|
const n = Number(raw);
|
|
@@ -27423,7 +27476,7 @@ function main() {
|
|
|
27423
27476
|
format: { type: "string", short: "f", default: "human" }
|
|
27424
27477
|
}
|
|
27425
27478
|
});
|
|
27426
|
-
if (values.help) {
|
|
27479
|
+
if (values.help && positionals.length === 0) {
|
|
27427
27480
|
printHelp();
|
|
27428
27481
|
return;
|
|
27429
27482
|
}
|
|
@@ -27456,10 +27509,26 @@ function main() {
|
|
|
27456
27509
|
const schema = getSchemaByName(toolName);
|
|
27457
27510
|
if (!schema) {
|
|
27458
27511
|
console.error(`${yellow2("!")} Unknown tool: ${bold2(toolName)}`);
|
|
27459
|
-
|
|
27512
|
+
const suggestion = suggestTool(toolName);
|
|
27513
|
+
if (suggestion) {
|
|
27514
|
+
console.error(` Did you mean ${cyan2(suggestion)}?`);
|
|
27515
|
+
} else {
|
|
27516
|
+
console.error(` Run ${cyan2("'ceddcozum --list'")} to see available tools.`);
|
|
27517
|
+
}
|
|
27460
27518
|
process.exit(1);
|
|
27461
27519
|
}
|
|
27520
|
+
if (values.help) {
|
|
27521
|
+
printToolInfo(toolName);
|
|
27522
|
+
return;
|
|
27523
|
+
}
|
|
27462
27524
|
const kvPairs = positionals.slice(1).filter((p) => p.includes("="));
|
|
27525
|
+
const nonKvArgs = positionals.slice(1).filter((p) => !p.includes("="));
|
|
27526
|
+
if (nonKvArgs.length > 0 && !values.args) {
|
|
27527
|
+
console.error(`${yellow2("!")} Unexpected arguments: ${bold2(nonKvArgs.join(" "))}`);
|
|
27528
|
+
console.error(` Use ${cyan2("key=value")} format: ${dim2(`ceddcozum ${toolName} sex=male age=5.5`)}`);
|
|
27529
|
+
console.error(` Run ${cyan2(`'ceddcozum ${toolName}'`)} to see parameter names.`);
|
|
27530
|
+
process.exit(1);
|
|
27531
|
+
}
|
|
27463
27532
|
if (values.args) {
|
|
27464
27533
|
let args;
|
|
27465
27534
|
try {
|