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 +41 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +41 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3327,6 +3327,7 @@ var RISKY_UNBOUNDED_INPUT_NAMES = [
|
|
|
3327
3327
|
"body",
|
|
3328
3328
|
"context"
|
|
3329
3329
|
];
|
|
3330
|
+
var COMPRESS_MODIFIER_RE = /\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\|\s*compress\s*\}\}/g;
|
|
3330
3331
|
function validateAsset(asset, frontMatterKeys, filePath) {
|
|
3331
3332
|
const errors = [];
|
|
3332
3333
|
const warnings = [];
|
|
@@ -3408,6 +3409,26 @@ function validateAsset(asset, frontMatterKeys, filePath) {
|
|
|
3408
3409
|
suggestion: "Declare context.inputs to enable input policy validation."
|
|
3409
3410
|
});
|
|
3410
3411
|
}
|
|
3412
|
+
if (asset.compression?.heuristic?.enabled === true && asset.compression.heuristic.json_to_toon !== true) {
|
|
3413
|
+
warnings.push({
|
|
3414
|
+
code: "POK055",
|
|
3415
|
+
message: "Prompt-level heuristic compression is enabled for the full prompt template.",
|
|
3416
|
+
filePath,
|
|
3417
|
+
suggestion: "Prefer per-placeholder compression for bulky context values so instructions, output constraints, and safety conditions are not sentence-selected away."
|
|
3418
|
+
});
|
|
3419
|
+
}
|
|
3420
|
+
const systemHeuristicCompressionVariables = findSystemHeuristicCompressionVariables(
|
|
3421
|
+
asset.sections?.system_instructions,
|
|
3422
|
+
declaredInputsByName
|
|
3423
|
+
);
|
|
3424
|
+
if (systemHeuristicCompressionVariables.length > 0) {
|
|
3425
|
+
warnings.push({
|
|
3426
|
+
code: "POK056",
|
|
3427
|
+
message: `System instructions use heuristic compression for ${formatQuotedList(systemHeuristicCompressionVariables)}.`,
|
|
3428
|
+
filePath,
|
|
3429
|
+
suggestion: "Avoid compressing values inside system instructions; move lossy compression to prompt-template context placeholders when possible."
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3411
3432
|
for (const input of contextInputs) {
|
|
3412
3433
|
const lowerName = input.name.toLowerCase();
|
|
3413
3434
|
const inputWarningsEnabled = areContextInputWarningsEnabled(input);
|
|
@@ -3599,6 +3620,26 @@ function findClosestMatch(input, candidates) {
|
|
|
3599
3620
|
}
|
|
3600
3621
|
return best;
|
|
3601
3622
|
}
|
|
3623
|
+
function findSystemHeuristicCompressionVariables(systemInstructions, declaredInputsByName) {
|
|
3624
|
+
if (!systemInstructions) {
|
|
3625
|
+
return [];
|
|
3626
|
+
}
|
|
3627
|
+
const variables = /* @__PURE__ */ new Set();
|
|
3628
|
+
for (const match of systemInstructions.matchAll(COMPRESS_MODIFIER_RE)) {
|
|
3629
|
+
variables.add(match[1]);
|
|
3630
|
+
}
|
|
3631
|
+
for (const variable of extractVariables(systemInstructions)) {
|
|
3632
|
+
const input = declaredInputsByName.get(variable);
|
|
3633
|
+
const heuristic = input?.compression?.heuristic;
|
|
3634
|
+
if (heuristic?.enabled === true && heuristic.json_to_toon !== true) {
|
|
3635
|
+
variables.add(variable);
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
return [...variables].sort();
|
|
3639
|
+
}
|
|
3640
|
+
function formatQuotedList(values) {
|
|
3641
|
+
return values.map((value) => `"${value}"`).join(", ");
|
|
3642
|
+
}
|
|
3602
3643
|
function isRecord2(value) {
|
|
3603
3644
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3604
3645
|
}
|