hostctl 0.1.55 → 0.1.57
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/hostctl.js +147 -7
- package/dist/bin/hostctl.js.map +1 -1
- package/dist/index.js +147 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2719,7 +2719,7 @@ var Verbosity = {
|
|
|
2719
2719
|
};
|
|
2720
2720
|
|
|
2721
2721
|
// src/version.ts
|
|
2722
|
-
var version = "0.1.
|
|
2722
|
+
var version = "0.1.57";
|
|
2723
2723
|
|
|
2724
2724
|
// src/commands/pkg/create.ts
|
|
2725
2725
|
import { promises as fs5 } from "fs";
|
|
@@ -31924,8 +31924,8 @@ function renderTaskRows(rows, {
|
|
|
31924
31924
|
name: r.name,
|
|
31925
31925
|
description: r.description,
|
|
31926
31926
|
module: r.module,
|
|
31927
|
-
inputSchema:
|
|
31928
|
-
outputSchema:
|
|
31927
|
+
inputSchema: schemaToDescriptor(r.inputSchema),
|
|
31928
|
+
outputSchema: schemaToDescriptor(r.outputSchema),
|
|
31929
31929
|
schemaSource: r.schemaSource
|
|
31930
31930
|
}));
|
|
31931
31931
|
console.log(JSON.stringify(sanitized, null, 2));
|
|
@@ -31966,9 +31966,12 @@ function summarizeType(val) {
|
|
|
31966
31966
|
case "optional":
|
|
31967
31967
|
case "ZodNullable":
|
|
31968
31968
|
case "nullable":
|
|
31969
|
+
case "ZodDefault":
|
|
31970
|
+
case "default":
|
|
31969
31971
|
return summarizeType(def.innerType || def.type);
|
|
31970
31972
|
case "ZodEffects":
|
|
31971
|
-
|
|
31973
|
+
case "pipe":
|
|
31974
|
+
return summarizeType(def.schema || def.in);
|
|
31972
31975
|
case "ZodString":
|
|
31973
31976
|
case "string":
|
|
31974
31977
|
return { type: "string", desc };
|
|
@@ -31991,8 +31994,11 @@ function summarizeType(val) {
|
|
|
31991
31994
|
return types.length ? { type: types.join(" | "), desc } : {};
|
|
31992
31995
|
}
|
|
31993
31996
|
case "ZodLiteral":
|
|
31994
|
-
case "literal":
|
|
31995
|
-
|
|
31997
|
+
case "literal": {
|
|
31998
|
+
const values3 = Array.isArray(def?.values) ? def.values : def?.value !== void 0 ? [def.value] : [];
|
|
31999
|
+
const value = values3.length ? values3[0] : void 0;
|
|
32000
|
+
return { type: value !== void 0 ? JSON.stringify(value) : void 0, desc };
|
|
32001
|
+
}
|
|
31996
32002
|
case "ZodObject":
|
|
31997
32003
|
case "object":
|
|
31998
32004
|
return { type: "object", desc };
|
|
@@ -32000,6 +32006,140 @@ function summarizeType(val) {
|
|
|
32000
32006
|
return { type: String(tn).replace(/^Zod/, "").toLowerCase(), desc };
|
|
32001
32007
|
}
|
|
32002
32008
|
}
|
|
32009
|
+
function schemaToDescriptor(schema) {
|
|
32010
|
+
if (!schema) return null;
|
|
32011
|
+
const { schema: base, nullable } = unwrapSchema(schema);
|
|
32012
|
+
const def = base?._def ?? base?.def;
|
|
32013
|
+
const typeName = def?.typeName || def?.type;
|
|
32014
|
+
const description = def?.description || base?.description;
|
|
32015
|
+
let descriptor = {};
|
|
32016
|
+
switch (typeName) {
|
|
32017
|
+
case "ZodString":
|
|
32018
|
+
case "string":
|
|
32019
|
+
descriptor.type = "string";
|
|
32020
|
+
break;
|
|
32021
|
+
case "ZodNumber":
|
|
32022
|
+
case "number":
|
|
32023
|
+
descriptor.type = "number";
|
|
32024
|
+
break;
|
|
32025
|
+
case "ZodBoolean":
|
|
32026
|
+
case "boolean":
|
|
32027
|
+
descriptor.type = "boolean";
|
|
32028
|
+
break;
|
|
32029
|
+
case "ZodArray":
|
|
32030
|
+
case "array": {
|
|
32031
|
+
const inner = def?.element ?? def?.type;
|
|
32032
|
+
descriptor.type = "array";
|
|
32033
|
+
descriptor.items = schemaToDescriptor(inner);
|
|
32034
|
+
break;
|
|
32035
|
+
}
|
|
32036
|
+
case "ZodObject":
|
|
32037
|
+
case "object": {
|
|
32038
|
+
const shapeSource = def?.shape || def?.shape_;
|
|
32039
|
+
const shape = shapeSource && typeof shapeSource === "function" ? shapeSource.call(def) : shapeSource;
|
|
32040
|
+
const properties = {};
|
|
32041
|
+
const required = [];
|
|
32042
|
+
if (shape && typeof shape === "object") {
|
|
32043
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
32044
|
+
const { schema: fieldSchema, optional, nullable: fieldNullable } = unwrapSchema(value);
|
|
32045
|
+
const fieldDescriptor = schemaToDescriptor(fieldSchema) ?? {};
|
|
32046
|
+
if (fieldNullable) {
|
|
32047
|
+
fieldDescriptor.nullable = true;
|
|
32048
|
+
}
|
|
32049
|
+
properties[key] = fieldDescriptor;
|
|
32050
|
+
if (!optional) {
|
|
32051
|
+
required.push(key);
|
|
32052
|
+
}
|
|
32053
|
+
}
|
|
32054
|
+
}
|
|
32055
|
+
descriptor.type = "object";
|
|
32056
|
+
descriptor.properties = properties;
|
|
32057
|
+
descriptor.required = required.length ? required : void 0;
|
|
32058
|
+
break;
|
|
32059
|
+
}
|
|
32060
|
+
case "ZodUnion":
|
|
32061
|
+
case "union": {
|
|
32062
|
+
const options = def?.options ?? [];
|
|
32063
|
+
descriptor.anyOf = options.map((option) => schemaToDescriptor(option)).filter(Boolean);
|
|
32064
|
+
break;
|
|
32065
|
+
}
|
|
32066
|
+
case "ZodLiteral":
|
|
32067
|
+
case "literal": {
|
|
32068
|
+
const values3 = Array.isArray(def?.values) ? def.values : def?.value !== void 0 ? [def.value] : [];
|
|
32069
|
+
const sample = values3.length ? values3[0] : void 0;
|
|
32070
|
+
descriptor.type = sample === null ? "null" : typeof sample;
|
|
32071
|
+
descriptor.enum = values3;
|
|
32072
|
+
break;
|
|
32073
|
+
}
|
|
32074
|
+
case "ZodEnum":
|
|
32075
|
+
case "enum":
|
|
32076
|
+
const enumValues = Array.isArray(def?.values) ? def.values : Object.values(def?.entries ?? {});
|
|
32077
|
+
descriptor.enum = enumValues;
|
|
32078
|
+
if (enumValues.length) {
|
|
32079
|
+
const hasNumber = enumValues.some((value) => typeof value === "number");
|
|
32080
|
+
const hasString = enumValues.some((value) => typeof value === "string");
|
|
32081
|
+
descriptor.type = hasNumber && !hasString ? "number" : "string";
|
|
32082
|
+
} else {
|
|
32083
|
+
descriptor.type = "string";
|
|
32084
|
+
}
|
|
32085
|
+
break;
|
|
32086
|
+
case "ZodNativeEnum":
|
|
32087
|
+
case "nativeenum": {
|
|
32088
|
+
const values3 = Array.isArray(def?.values) ? def.values : Object.values(def?.entries ?? def?.values ?? {});
|
|
32089
|
+
descriptor.type = values3.every((value) => typeof value === "number") ? "number" : "string";
|
|
32090
|
+
descriptor.enum = values3;
|
|
32091
|
+
break;
|
|
32092
|
+
}
|
|
32093
|
+
default:
|
|
32094
|
+
descriptor.type = typeName ? String(typeName).replace(/^Zod/, "").toLowerCase() : "unknown";
|
|
32095
|
+
break;
|
|
32096
|
+
}
|
|
32097
|
+
if (description) {
|
|
32098
|
+
descriptor.description = description;
|
|
32099
|
+
}
|
|
32100
|
+
if (nullable) {
|
|
32101
|
+
descriptor.nullable = true;
|
|
32102
|
+
}
|
|
32103
|
+
return descriptor;
|
|
32104
|
+
}
|
|
32105
|
+
function unwrapSchema(schema) {
|
|
32106
|
+
let current = schema;
|
|
32107
|
+
let optional = false;
|
|
32108
|
+
let nullable = false;
|
|
32109
|
+
while (current) {
|
|
32110
|
+
const def = current?._def ?? current?.def;
|
|
32111
|
+
const typeName = def?.typeName || def?.type;
|
|
32112
|
+
if (typeName === "ZodOptional" || typeName === "optional") {
|
|
32113
|
+
optional = true;
|
|
32114
|
+
current = def?.innerType ?? def?.type;
|
|
32115
|
+
continue;
|
|
32116
|
+
}
|
|
32117
|
+
if (typeName === "ZodNullable" || typeName === "nullable") {
|
|
32118
|
+
nullable = true;
|
|
32119
|
+
current = def?.innerType ?? def?.type;
|
|
32120
|
+
continue;
|
|
32121
|
+
}
|
|
32122
|
+
if (typeName === "ZodDefault" || typeName === "default") {
|
|
32123
|
+
optional = true;
|
|
32124
|
+
current = def?.innerType ?? def?.type;
|
|
32125
|
+
continue;
|
|
32126
|
+
}
|
|
32127
|
+
if (typeName === "ZodEffects" || typeName === "effects") {
|
|
32128
|
+
current = def?.schema;
|
|
32129
|
+
continue;
|
|
32130
|
+
}
|
|
32131
|
+
if (typeName === "pipe") {
|
|
32132
|
+
current = def?.in ?? def?.schema;
|
|
32133
|
+
continue;
|
|
32134
|
+
}
|
|
32135
|
+
if (typeName === "transform") {
|
|
32136
|
+
current = def?.schema ?? def?.in;
|
|
32137
|
+
continue;
|
|
32138
|
+
}
|
|
32139
|
+
break;
|
|
32140
|
+
}
|
|
32141
|
+
return { schema: current, optional, nullable };
|
|
32142
|
+
}
|
|
32003
32143
|
function formatSchemaLines(schema) {
|
|
32004
32144
|
if (!schema) return ["none"];
|
|
32005
32145
|
const def = schema._def ?? schema.def;
|
|
@@ -32012,7 +32152,7 @@ function formatSchemaLines(schema) {
|
|
|
32012
32152
|
const tn = anyVal?._def?.typeName || anyVal?.def?.type;
|
|
32013
32153
|
const typeString = summary2.type || (tn ? String(tn).replace(/^Zod/, "").toLowerCase() : void 0);
|
|
32014
32154
|
const desc = summary2.desc;
|
|
32015
|
-
const optional =
|
|
32155
|
+
const optional = ["ZodOptional", "optional", "ZodNullable", "nullable", "ZodDefault", "default"].includes(tn);
|
|
32016
32156
|
const typePart = typeString ? `: ${typeString}` : "";
|
|
32017
32157
|
const descPart = desc ? ` - ${desc}` : "";
|
|
32018
32158
|
return `- ${key}${optional ? "?" : ""}${typePart}${descPart}`;
|