perstack 0.0.128 → 0.0.130

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/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { a as __toCommonJS, i as __require, n as __esmMin, o as __toESM, r as __exportAll, t as __commonJSMin } from "../chunk-DORXReHP.js";
3
- import { $ as intersection, A as runCommandInputSchema, At as NEVER, B as resolveModelTier, C as runSettingSchema, Ct as parseAsync, D as stopRunByDelegate, Dt as defineLazy, E as startRun, Et as clone, F as expertSchema, G as _enum, H as number$1, I as isCoordinatorExpert, J as any, K as _instanceof, L as validateDelegation, M as perstackConfigSchema, N as lockfileSchema, O as stopRunByError, Ot as normalizeParams, P as jobSchema, Pt as createId, Q as discriminatedUnion, R as checkpointSchema, S as runParamsSchema, St as parse$1, T as startGeneration, Tt as safeParseAsync$1, U as ZodIssueCode$1, V as resolveModelTierWithFallback, W as ZodOptional$1, X as boolean, Y as array$1, Z as custom, _ as parseExpertKey, _t as toJSONSchema, a as validateEventFilter, at as object$2, b as resumeFromStop, bt as $ZodObject, c as createBaseToolActivity, ct as record, d as completeRun, dt as tuple, et as lazy, f as continueToNextStep, ft as union, g as finishToolCall, gt as datetime, h as finishMcpTools, ht as safeParseAsync$2, i as createFilteredEventListener, it as number, j as startCommandInputSchema, jt as PerstackError, k as stopRunByInteractiveTool, kt as $constructor, l as createGeneralToolActivity, lt as strictObject, m as createStreamingEvent, mt as url, n as parseWithFriendlyError, nt as looseObject, o as getFilteredEnv, ot as optional, p as createRuntimeEvent, pt as unknown, q as _null, r as truncateText$1, rt as never, st as preprocess, t as createApiClient, tt as literal, u as callTools, ut as string, v as proceedToInteractiveTools, w as skipDelegates, wt as safeParse$1, x as retry, xt as $ZodType, y as resolveToolResults, z as knownModels } from "../dist-RHs5gh6F.js";
3
+ import { $ as discriminatedUnion, A as stopRunByInteractiveTool, At as $constructor, B as knownModels, C as runParamsSchema, Ct as parse$1, D as startRun, Dt as clone, E as startGeneration, Et as safeParseAsync$1, F as jobSchema, Ft as createId, G as ZodOptional$1, H as resolveModelTierWithFallback, I as expertSchema, J as _null, K as _enum, L as isCoordinatorExpert, M as startCommandInputSchema, Mt as PerstackError, N as perstackConfigSchema, O as stopRunByDelegate, Ot as defineLazy, P as lockfileSchema, Q as custom, R as validateDelegation, S as retry, St as $ZodType, T as skipDelegates, Tt as safeParse$1, U as number$1, V as resolveModelTier, W as ZodIssueCode$1, X as array$1, Y as any, Z as boolean, _ as finishToolCall, _t as datetime, a as createFilteredEventListener, at as number, b as resolveToolResults, ct as preprocess, d as callTools, dt as string, et as intersection, f as completeRun, ft as tuple, g as finishMcpTools, gt as safeParseAsync$2, h as createStreamingEvent, ht as url, i as truncateText$1, it as never, j as runCommandInputSchema, jt as NEVER, k as stopRunByError, kt as normalizeParams, l as createBaseToolActivity, lt as record, m as createRuntimeEvent, mt as unknown, n as formatZodError, nt as literal, o as validateEventFilter, ot as object$2, p as continueToNextStep, pt as union, q as _instanceof, r as parseWithFriendlyError, rt as looseObject, s as getFilteredEnv, st as optional, t as createApiClient, tt as lazy, u as createGeneralToolActivity, ut as strictObject, v as parseExpertKey, vt as toJSONSchema, w as runSettingSchema, wt as parseAsync, x as resumeFromStop, xt as $ZodObject, y as proceedToInteractiveTools, z as checkpointSchema } from "../dist-C1wXMdbD.js";
4
4
  import { t as require_token_error } from "../token-error-Bru5BVnt.js";
5
5
  import fs, { constants, lstat, mkdir, open, readFile, stat, writeFile } from "node:fs/promises";
6
6
  import path, { dirname, extname } from "node:path";
@@ -1010,6 +1010,59 @@ async function findConfigPathRecursively(cwd) {
1010
1010
  return await findConfigPathRecursively(path.dirname(cwd));
1011
1011
  }
1012
1012
  }
1013
+ async function validatePerstackConfigFile(filePath) {
1014
+ const errors = [];
1015
+ let content;
1016
+ try {
1017
+ content = await readFile(path.resolve(process.cwd(), filePath), "utf-8");
1018
+ } catch {
1019
+ return {
1020
+ valid: false,
1021
+ errors: [`File not found: ${filePath}`]
1022
+ };
1023
+ }
1024
+ let toml;
1025
+ try {
1026
+ toml = dist_default.parse(content);
1027
+ } catch (e) {
1028
+ return {
1029
+ valid: false,
1030
+ errors: [`TOML parse error: ${e instanceof Error ? e.message : String(e)}`]
1031
+ };
1032
+ }
1033
+ const configResult = perstackConfigSchema.safeParse(toml);
1034
+ if (!configResult.success) {
1035
+ errors.push(formatZodError(configResult.error));
1036
+ return {
1037
+ valid: false,
1038
+ errors
1039
+ };
1040
+ }
1041
+ const config = configResult.data;
1042
+ if (config.experts) for (const [name, expert] of Object.entries(config.experts)) {
1043
+ const expertResult = expertSchema.safeParse({
1044
+ key: name,
1045
+ name,
1046
+ version: expert.version ?? "1.0.0",
1047
+ description: expert.description,
1048
+ instruction: expert.instruction,
1049
+ skills: expert.skills,
1050
+ delegates: expert.delegates,
1051
+ tags: expert.tags,
1052
+ defaultModelTier: expert.defaultModelTier,
1053
+ minRuntimeVersion: expert.minRuntimeVersion,
1054
+ providerTools: expert.providerTools,
1055
+ providerSkills: expert.providerSkills,
1056
+ providerToolOptions: expert.providerToolOptions
1057
+ });
1058
+ if (!expertResult.success) errors.push(`Expert "${name}": ${formatZodError(expertResult.error)}`);
1059
+ }
1060
+ if (errors.length > 0) return {
1061
+ valid: false,
1062
+ errors
1063
+ };
1064
+ return { valid: true };
1065
+ }
1013
1066
  //#endregion
1014
1067
  //#region ../../packages/perstack-toml/src/lockfile.ts
1015
1068
  function loadLockfile(lockfilePath) {
@@ -1042,6 +1095,86 @@ function generateLockfileToml(lockfile) {
1042
1095
  return dist_default.stringify(lockfile);
1043
1096
  }
1044
1097
  //#endregion
1098
+ //#region ../../packages/perstack-toml/src/schema-printer.ts
1099
+ function formatType(prop) {
1100
+ if (prop.const) return `"${prop.const}"`;
1101
+ if (prop.enum) return prop.enum.map((v) => `"${v}"`).join(" | ");
1102
+ if (prop.oneOf) return prop.oneOf.map(formatType).filter(Boolean).join(" | ");
1103
+ if (prop.type === "array" && prop.items) return `${formatType(prop.items)}[]`;
1104
+ if (Array.isArray(prop.type)) return prop.type.join(" | ");
1105
+ return prop.type ?? "any";
1106
+ }
1107
+ function formatConstraints(prop) {
1108
+ const parts = [];
1109
+ if (prop.minLength !== void 0) parts.push(`min ${prop.minLength}`);
1110
+ if (prop.maxLength !== void 0) parts.push(`max ${prop.maxLength}`);
1111
+ if (prop.minimum !== void 0) parts.push(`min ${prop.minimum}`);
1112
+ if (prop.maximum !== void 0) parts.push(`max ${prop.maximum}`);
1113
+ if (prop.pattern) parts.push(`pattern: ${prop.pattern}`);
1114
+ return parts.length > 0 ? ` (${parts.join(", ")})` : "";
1115
+ }
1116
+ function printObjectFields(properties, required, indent = "") {
1117
+ const lines = [];
1118
+ for (const [name, prop] of Object.entries(properties)) {
1119
+ const reqLabel = required.includes(name) ? "required" : "optional";
1120
+ const type = formatType(prop);
1121
+ const constraints = formatConstraints(prop);
1122
+ lines.push(`${indent}${name.padEnd(24)} ${type.padEnd(20)} (${reqLabel})${constraints}`);
1123
+ }
1124
+ return lines.join("\n");
1125
+ }
1126
+ function printPerstackSchema() {
1127
+ const jsonSchema = toJSONSchema(perstackConfigSchema, { unrepresentable: "any" });
1128
+ const sections = [];
1129
+ sections.push("# perstack.toml Schema Reference");
1130
+ sections.push("");
1131
+ if (jsonSchema.properties) {
1132
+ sections.push("## Top-level fields");
1133
+ sections.push("");
1134
+ const topLevel = { ...jsonSchema.properties };
1135
+ delete topLevel.experts;
1136
+ sections.push(printObjectFields(topLevel, jsonSchema.required ?? []));
1137
+ sections.push("");
1138
+ }
1139
+ const expertValueSchema = (jsonSchema.properties?.experts)?.additionalProperties;
1140
+ if (expertValueSchema?.properties) {
1141
+ sections.push("## Expert definition: [experts.\"expert-name\"]");
1142
+ sections.push("");
1143
+ sections.push(printObjectFields(expertValueSchema.properties, expertValueSchema.required ?? []));
1144
+ sections.push("");
1145
+ const skillValueSchema = expertValueSchema.properties.skills?.additionalProperties;
1146
+ if (skillValueSchema?.oneOf) {
1147
+ sections.push("## Skill types: [experts.\"name\".skills.\"skill-name\"]");
1148
+ sections.push("");
1149
+ for (const variant of skillValueSchema.oneOf) if (variant.properties?.type?.const) {
1150
+ sections.push(`### ${variant.properties.type.const}`);
1151
+ sections.push("");
1152
+ sections.push(printObjectFields(variant.properties, variant.required ?? [], " "));
1153
+ sections.push("");
1154
+ }
1155
+ }
1156
+ }
1157
+ sections.push("## @perstack/base available tools");
1158
+ sections.push("");
1159
+ sections.push("Basic tools:");
1160
+ sections.push(" readTextFile, readImageFile, readPdfFile, writeTextFile, editTextFile,");
1161
+ sections.push(" exec, todo, clearTodo, attemptCompletion");
1162
+ sections.push("");
1163
+ sections.push("Skill & delegation management tools:");
1164
+ sections.push(" addSkill, removeSkill, addDelegate, removeDelegate,");
1165
+ sections.push(" createExpert, addDelegateFromConfig");
1166
+ sections.push("");
1167
+ sections.push("## Naming rules");
1168
+ sections.push("");
1169
+ sections.push("- Coordinators: kebab-case (e.g., \"my-expert\")");
1170
+ sections.push("- Delegates: @coordinator/name (e.g., \"@my-expert/verify\")");
1171
+ sections.push("- No self-delegation");
1172
+ sections.push("- Delegates must be in-scope (same coordinator prefix)");
1173
+ sections.push("- Delegates cannot delegate to their own coordinator");
1174
+ sections.push("");
1175
+ return sections.join("\n");
1176
+ }
1177
+ //#endregion
1045
1178
  //#region ../../packages/installer/src/expert-resolver.ts
1046
1179
  function toRuntimeExpert(key, expert) {
1047
1180
  const skills = Object.fromEntries(Object.entries(expert.skills ?? {}).map(([name, skill]) => {
@@ -21092,7 +21225,7 @@ async function expertVersionsHandler(scopeName, options) {
21092
21225
  }
21093
21226
  //#endregion
21094
21227
  //#region ../../packages/runtime/package.json
21095
- var version$1 = "0.0.139";
21228
+ var version$1 = "0.0.140";
21096
21229
  //#endregion
21097
21230
  //#region ../../packages/runtime/src/helpers/usage.ts
21098
21231
  function createEmptyUsage() {
@@ -79577,7 +79710,7 @@ function validateRuntimeVersion(experts) {
79577
79710
  //#endregion
79578
79711
  //#region ../../packages/runtime/src/helpers/setup-experts.ts
79579
79712
  async function setupExperts(setting, resolveExpertToRun) {
79580
- const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-temTHQyu.js")).resolveExpertToRun;
79713
+ const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-JQOam2_2.js")).resolveExpertToRun;
79581
79714
  const { expertKey } = setting;
79582
79715
  const experts = { ...setting.experts };
79583
79716
  const clientOptions = {
@@ -92490,6 +92623,9 @@ function getDelegateMetaInstruction() {
92490
92623
  return import_dist.dedent`
92491
92624
  Before starting work, investigate the workspace and understand the current state. Then use the todo tool to create a plan of action. Work through the todos step by step, marking each completed as you go.
92492
92625
 
92626
+ NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.
92627
+ NEVER proactively create documentation files. Only create documentation files if explicitly requested.
92628
+
92493
92629
  When the task is complete, call attemptCompletion with a result parameter containing your final response.
92494
92630
  When you cannot help, call attemptCompletion without a result.
92495
92631
 
@@ -124509,7 +124645,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
124509
124645
  //#endregion
124510
124646
  //#region package.json
124511
124647
  var name = "perstack";
124512
- var version = "0.0.128";
124648
+ var version = "0.0.130";
124513
124649
  var description = "PerStack CLI";
124514
124650
  //#endregion
124515
124651
  //#region bin/cli.ts
@@ -124561,6 +124697,17 @@ program.command("install").description("Generate perstack.lock with tool definit
124561
124697
  envPath: options.envPath
124562
124698
  });
124563
124699
  });
124700
+ program.command("validate").description("Validate a perstack.toml file against the schema").argument("<path>", "Path to perstack.toml file to validate").action(async (pathArg) => {
124701
+ const result = await validatePerstackConfigFile(pathArg);
124702
+ if (result.valid) console.log("Valid");
124703
+ else {
124704
+ for (const error of result.errors) console.error(error);
124705
+ process.exit(1);
124706
+ }
124707
+ });
124708
+ program.command("schema").description("Print the perstack.toml schema reference").action(() => {
124709
+ console.log(printPerstackSchema());
124710
+ });
124564
124711
  function getParentOptions(cmd) {
124565
124712
  const parent = cmd.parent?.opts();
124566
124713
  return {