promptopskit 0.8.1 → 0.8.2

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/cli/index.js CHANGED
@@ -1122,6 +1122,7 @@ var RISKY_UNBOUNDED_INPUT_NAMES = [
1122
1122
  "body",
1123
1123
  "context"
1124
1124
  ];
1125
+ var COMPRESS_MODIFIER_RE = /\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\|\s*compress\s*\}\}/g;
1125
1126
  function validateAsset(asset, frontMatterKeys, filePath) {
1126
1127
  const errors = [];
1127
1128
  const warnings = [];
@@ -1203,6 +1204,26 @@ function validateAsset(asset, frontMatterKeys, filePath) {
1203
1204
  suggestion: "Declare context.inputs to enable input policy validation."
1204
1205
  });
1205
1206
  }
1207
+ if (asset.compression?.heuristic?.enabled === true && asset.compression.heuristic.json_to_toon !== true) {
1208
+ warnings.push({
1209
+ code: "POK055",
1210
+ message: "Prompt-level heuristic compression is enabled for the full prompt template.",
1211
+ filePath,
1212
+ suggestion: "Prefer per-placeholder compression for bulky context values so instructions, output constraints, and safety conditions are not sentence-selected away."
1213
+ });
1214
+ }
1215
+ const systemHeuristicCompressionVariables = findSystemHeuristicCompressionVariables(
1216
+ asset.sections?.system_instructions,
1217
+ declaredInputsByName
1218
+ );
1219
+ if (systemHeuristicCompressionVariables.length > 0) {
1220
+ warnings.push({
1221
+ code: "POK056",
1222
+ message: `System instructions use heuristic compression for ${formatQuotedList(systemHeuristicCompressionVariables)}.`,
1223
+ filePath,
1224
+ suggestion: "Avoid compressing values inside system instructions; move lossy compression to prompt-template context placeholders when possible."
1225
+ });
1226
+ }
1206
1227
  for (const input of contextInputs) {
1207
1228
  const lowerName = input.name.toLowerCase();
1208
1229
  const inputWarningsEnabled = areContextInputWarningsEnabled(input);
@@ -1394,6 +1415,26 @@ function findClosestMatch(input, candidates) {
1394
1415
  }
1395
1416
  return best;
1396
1417
  }
1418
+ function findSystemHeuristicCompressionVariables(systemInstructions, declaredInputsByName) {
1419
+ if (!systemInstructions) {
1420
+ return [];
1421
+ }
1422
+ const variables = /* @__PURE__ */ new Set();
1423
+ for (const match of systemInstructions.matchAll(COMPRESS_MODIFIER_RE)) {
1424
+ variables.add(match[1]);
1425
+ }
1426
+ for (const variable of extractVariables(systemInstructions)) {
1427
+ const input = declaredInputsByName.get(variable);
1428
+ const heuristic = input?.compression?.heuristic;
1429
+ if (heuristic?.enabled === true && heuristic.json_to_toon !== true) {
1430
+ variables.add(variable);
1431
+ }
1432
+ }
1433
+ return [...variables].sort();
1434
+ }
1435
+ function formatQuotedList(values) {
1436
+ return values.map((value) => `"${value}"`).join(", ");
1437
+ }
1397
1438
  function isRecord(value) {
1398
1439
  return typeof value === "object" && value !== null && !Array.isArray(value);
1399
1440
  }