perstack 0.0.129 → 0.0.131

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,131 @@ 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
+ sections.push("## Example");
1176
+ sections.push("");
1177
+ sections.push("```toml");
1178
+ sections.push("[experts.\"my-team\"]");
1179
+ sections.push("version = \"1.0.0\"");
1180
+ sections.push("defaultModelTier = \"high\"");
1181
+ sections.push("description = \"Coordinates task execution and delegates to specialists\"");
1182
+ sections.push("instruction = \"\"\"");
1183
+ sections.push("Domain-specific constraints and coordination rules here.");
1184
+ sections.push("\"\"\"");
1185
+ sections.push("delegates = [\"@my-team/build\", \"@my-team/verify\"]");
1186
+ sections.push("");
1187
+ sections.push("[experts.\"my-team\".skills.\"@perstack/base\"]");
1188
+ sections.push("type = \"mcpStdioSkill\"");
1189
+ sections.push("command = \"npx\"");
1190
+ sections.push("packageName = \"@perstack/base\"");
1191
+ sections.push("pick = [\"readTextFile\", \"exec\", \"attemptCompletion\"]");
1192
+ sections.push("");
1193
+ sections.push("[experts.\"@my-team/build\"]");
1194
+ sections.push("version = \"1.0.0\"");
1195
+ sections.push("defaultModelTier = \"middle\"");
1196
+ sections.push("description = \"Implements the core deliverable\"");
1197
+ sections.push("instruction = \"\"\"");
1198
+ sections.push("Domain constraints for this specialist.");
1199
+ sections.push("\"\"\"");
1200
+ sections.push("");
1201
+ sections.push("[experts.\"@my-team/build\".skills.\"@perstack/base\"]");
1202
+ sections.push("type = \"mcpStdioSkill\"");
1203
+ sections.push("command = \"npx\"");
1204
+ sections.push("packageName = \"@perstack/base\"");
1205
+ sections.push("pick = [\"readTextFile\", \"writeTextFile\", \"editTextFile\", \"exec\", \"todo\", \"attemptCompletion\"]");
1206
+ sections.push("```");
1207
+ sections.push("");
1208
+ sections.push("## Best Practices");
1209
+ sections.push("");
1210
+ sections.push("- Always set version, defaultModelTier, and description on every expert");
1211
+ sections.push("- Always set an explicit pick list — omitting it grants ALL tools");
1212
+ sections.push("- Instructions should contain only domain constraints the LLM cannot derive on its own");
1213
+ sections.push("- Do not put implementation procedures, file paths, or data schemas in instructions");
1214
+ sections.push("- Shorter instructions outperform longer ones — every line must earn its place");
1215
+ sections.push("- Delegate names should describe function, not persona (/build, /verify, not /builder)");
1216
+ sections.push("- Coordinators should have minimal pick lists (readTextFile, exec, attemptCompletion)");
1217
+ sections.push("- Leaf experts doing file I/O need: readTextFile, writeTextFile, editTextFile, exec, todo, attemptCompletion");
1218
+ sections.push("- Experts managing delegation need: addDelegateFromConfig, addDelegate, removeDelegate");
1219
+ sections.push("");
1220
+ return sections.join("\n");
1221
+ }
1222
+ //#endregion
1045
1223
  //#region ../../packages/installer/src/expert-resolver.ts
1046
1224
  function toRuntimeExpert(key, expert) {
1047
1225
  const skills = Object.fromEntries(Object.entries(expert.skills ?? {}).map(([name, skill]) => {
@@ -21092,7 +21270,7 @@ async function expertVersionsHandler(scopeName, options) {
21092
21270
  }
21093
21271
  //#endregion
21094
21272
  //#region ../../packages/runtime/package.json
21095
- var version$1 = "0.0.140";
21273
+ var version$1 = "0.0.141";
21096
21274
  //#endregion
21097
21275
  //#region ../../packages/runtime/src/helpers/usage.ts
21098
21276
  function createEmptyUsage() {
@@ -79577,7 +79755,7 @@ function validateRuntimeVersion(experts) {
79577
79755
  //#endregion
79578
79756
  //#region ../../packages/runtime/src/helpers/setup-experts.ts
79579
79757
  async function setupExperts(setting, resolveExpertToRun) {
79580
- const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-temTHQyu.js")).resolveExpertToRun;
79758
+ const resolveFn = resolveExpertToRun ?? (await import("../resolve-expert-JQOam2_2.js")).resolveExpertToRun;
79581
79759
  const { expertKey } = setting;
79582
79760
  const experts = { ...setting.experts };
79583
79761
  const clientOptions = {
@@ -92516,8 +92694,8 @@ function getCoordinatorMetaInstruction() {
92516
92694
  6. Aggregate results and clean up the workspace.
92517
92695
 
92518
92696
  Delegation guidelines:
92519
- - Be specific: include context, file paths, constraints, and expected output format. No vague delegations.
92520
- - Break large subtasks into focused units rather than overloading a single delegate.
92697
+ - Be specific: include context, constraints, and expected output format. No vague delegations.
92698
+ - A single delegate can handle a broad task if the role is straightforward. Only split into multiple delegates when responsibilities are genuinely distinct — unnecessary subdivision adds overhead without improving quality.
92521
92699
  - If no suitable delegate exists, use createExpert to create one, then addDelegate to register it.
92522
92700
 
92523
92701
  Workspace cleanup:
@@ -124512,7 +124690,7 @@ async function startHandler(expertKey, query, options, handlerOptions) {
124512
124690
  //#endregion
124513
124691
  //#region package.json
124514
124692
  var name = "perstack";
124515
- var version = "0.0.129";
124693
+ var version = "0.0.131";
124516
124694
  var description = "PerStack CLI";
124517
124695
  //#endregion
124518
124696
  //#region bin/cli.ts
@@ -124564,6 +124742,17 @@ program.command("install").description("Generate perstack.lock with tool definit
124564
124742
  envPath: options.envPath
124565
124743
  });
124566
124744
  });
124745
+ program.command("validate").description("Validate a perstack.toml file against the schema").argument("<path>", "Path to perstack.toml file to validate").action(async (pathArg) => {
124746
+ const result = await validatePerstackConfigFile(pathArg);
124747
+ if (result.valid) console.log("Valid");
124748
+ else {
124749
+ for (const error of result.errors) console.error(error);
124750
+ process.exit(1);
124751
+ }
124752
+ });
124753
+ program.command("schema").description("Print the perstack.toml schema reference").action(() => {
124754
+ console.log(printPerstackSchema());
124755
+ });
124567
124756
  function getParentOptions(cmd) {
124568
124757
  const parent = cmd.parent?.opts();
124569
124758
  return {