You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For `allow_regex` and `deny_regex`, prefer unquoted `/pattern/i` literal form so regex escapes such as `\s` and `\b` stay copyable from tools like regex101. If you use structured `pattern:` form, use single-quoted YAML strings or double each backslash in double-quoted strings.
618
+
619
619
## Website
620
620
621
621
The `website/` directory contains a standalone marketing website for PromptOpsKit.
Copy file name to clipboardExpand all lines: SKILL.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -105,7 +105,9 @@ Rules:
105
105
- Use object-form inputs with `max_size` when a variable is likely to grow large and should trigger early warnings
106
106
- Use `trim` to enforce byte budgets before interpolation when `max_size` is set
107
107
- Use `allow_regex` for allowlist checks and `deny_regex` for blocklist checks on risky inputs
108
-
- Prefer structured regexes like `{ pattern, flags }`; `/pattern/i` strings are also accepted and normalized internally
108
+
- Prefer unquoted `/pattern/i` literals for regex validators so backslash escapes such as `\s` and `\b` stay copyable from regex tools
109
+
- Use structured regexes like `{ pattern, flags, return_message }` when the validator needs a fallback message or separate flags
110
+
- In structured `pattern:` YAML, use single quotes for patterns with backslashes or double each backslash in double-quoted strings
109
111
- Use `non_empty: true` for required user text and `reject_secrets: true` for common secret redaction checks
110
112
- When the caller should receive a structured fallback message instead of an exception, use object form with `return_message` on `allow_regex`, `deny_regex`, `non_empty`, or `reject_secrets`
111
113
- Escape literal braces with `\{{` and `\}}`
@@ -127,7 +129,7 @@ At render time, callers can also pass `onContextOverflow` to transform oversized
127
129
128
130
If a validator declares `return_message`, `renderPrompt()` returns that message in a structured result and omits the provider request instead of throwing for that validation failure. Invalid regex definitions still fail during `validate` and `compile` as `POK013` prompt-authoring errors.
129
131
130
-
Malformed `allow_regex` and `deny_regex` values fail during `validate` and `compile`, not just at render time. When regex compilation fails, the error includes the prompt id, variable name, field name, and raw configured value.
132
+
Malformed `allow_regex` and `deny_regex` values fail during `validate` and `compile`, not just at render time. When regex compilation fails, the error includes the prompt id, variable name, field name, and raw configured value. Double-quoted YAML regex strings with raw backslashes fail as `POK013`; use `/pattern/i`, single-quoted `pattern: '...'`, or doubled backslashes.
131
133
132
134
Example: this is the minimal valid shape for a prompt that references
133
135
`{{ pull_request }}` even when provider/model are inherited from defaults:
`validatePrompt()` covers schema, include-graph, variable declaration issues, and context regex compilation. Render-time context size warnings are produced by `renderPrompt()`, not validation.
121
+
`validatePrompt()` covers schema, include-graph, variable declaration issues, context regex compilation, and context regex YAML quoting problems. Render-time context size warnings are produced by `renderPrompt()`, not validation.
`validateAsset()` reports malformed `allow_regex` and `deny_regex` values before runtime, including the prompt id, variable name, field name, and raw configured value in the error message.
226
+
`validateAsset()` reports malformed `allow_regex` and `deny_regex` values before runtime, including the prompt id, variable name, field name, and raw configured value in the error message. When parsing source Markdown through `parsePrompt()`, `loadPromptFile()`, or `validatePrompt()`, parser-level checks also report unsafe double-quoted YAML regex strings with raw backslashes as `POK013`; prefer unquoted `/pattern/i` literal form for copyable regex escapes.
Includes are resolved during compilation so compiled artifacts are self-sufficient. The output directory is cleared by default before compiling (unless `--no-clean` is set).
84
85
85
-
Compilation runs validation before writing artifacts. Invalid `allow_regex` or `deny_regex` definitions fail the compile step early with `POK013` instead of surfacing later during `renderPrompt()`.
86
+
Compilation runs validation before writing artifacts. Invalid `allow_regex` or `deny_regex` definitions, including unsafe double-quoted YAML regex strings with raw backslashes, fail the compile step early with `POK013` instead of surfacing later during `renderPrompt()`.
86
87
87
88
If you omit `<out>`, the CLI chooses `./.generated-prompts/json` for `json` and `./.generated-prompts/esm` for `esm`.
Copy file name to clipboardExpand all lines: docs/getting-started.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ context:
47
47
non_empty: true
48
48
reject_secrets: true
49
49
- name: app_context
50
-
allow_regex: "/^[A-Za-z0-9 _-]+$/i"
50
+
allow_regex: /^[A-Za-z0-9 _-]+$/i
51
51
includes:
52
52
- ./shared/tone.md
53
53
---
@@ -121,7 +121,7 @@ Your application owns the HTTP call — PromptOpsKit produces the request body o
121
121
npx promptopskit validate ./prompts
122
122
```
123
123
124
-
This checks all `.md` files for schema errors, unknown front matter keys (with "did you mean?" suggestions), variable usage mismatches, and malformed context regex definitions.
124
+
This checks all `.md` files for schema errors, unknown front matter keys (with "did you mean?" suggestions), variable usage mismatches, and malformed context regex definitions. For regex validators, prefer unquoted `/pattern/i` literals so backslash escapes stay copyable; double-quoted YAML regex strings with raw backslashes are reported as `POK013`.
Copy file name to clipboardExpand all lines: docs/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Open-source developer toolkit for managing prompts, system instructions, tools,
19
19
-[Schema](./schema.md) — Full YAML front matter schema reference
20
20
-[Vendor Schema Gap Analysis](./vendor-schema-gap-analysis.md) — Snapshot comparison against published OpenAI, Anthropic, Gemini, and OpenRouter schema capabilities
21
21
-[Testing](./testing.md) — Test helpers, mock assets, and sidecar test files
22
-
-[Validation](./validation.md) — Schema validation, "did you mean?" suggestions, variable checks, and early regex validation
22
+
-[Validation](./validation.md) — Schema validation, "did you mean?" suggestions, variable checks, early regex validation, and YAML regex quoting guidance
Copy file name to clipboardExpand all lines: docs/prompt-format.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -234,8 +234,8 @@ Each entry can be either a string variable name or an object with:
234
234
- `name`— the template variable name
235
235
- `max_size`— optional UTF-8 byte limit for the injected value
236
236
- `trim`— optional trim-to-budget (`true`/`end` keeps first bytes, `start` keeps trailing bytes) applied when `max_size` is set
237
-
- `allow_regex`— optional allowlist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }` and throws `POK031` on mismatch unless `return_message` is configured
238
-
- `deny_regex`— optional blocklist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }` and throws `POK032` on match unless `return_message` is configured
237
+
- `allow_regex`— optional allowlist regex; accepts `/pattern/i`, `"pattern"`, or `{ pattern, flags, return_message? }` and throws `POK031` on mismatch unless `return_message` is configured
238
+
- `deny_regex`— optional blocklist regex; accepts `/pattern/i`, `"pattern"`, or `{ pattern, flags, return_message? }` and throws `POK032` on match unless `return_message` is configured
239
239
- `non_empty`— optional boolean or object validator; use `true` to throw `POK033`, or `{ return_message }` to short-circuit rendering with a structured message
240
240
- `reject_secrets`— optional boolean or object validator; use `true` to throw `POK034`, or `{ return_message }` to short-circuit rendering with a structured message
241
241
@@ -245,7 +245,7 @@ The validator warns about:
245
245
246
246
At render time, PromptOpsKit also emits a non-blocking `POK030` warning when a provided variable exceeds its declared `max_size`. In source and auto modes, the warning is also written to `console.warn` to make local development issues visible early.
247
247
248
-
Malformed `allow_regex` and `deny_regex` values fail during `validate` and `compile` with `POK013`, so bad patterns are caught before runtime.
248
+
Malformed `allow_regex` and `deny_regex` values fail during `validate` and `compile` with `POK013`, so bad patterns are caught before runtime. Double-quoted YAML regex strings with raw backslashes are also reported as `POK013`; use unquoted `/pattern/i`, single-quoted `pattern: '...'`, or doubled backslashes in double quotes.
249
249
250
250
Example hardened input definition:
251
251
@@ -256,16 +256,18 @@ context:
256
256
trim: true
257
257
max_size: 24
258
258
allow_regex:
259
-
pattern: "^user_[a-z0-9]+$"
260
-
flags: "i"
261
-
return_message: "User IDs must use the user_123 format."
259
+
pattern: '^user_[a-z0-9]+$'
260
+
flags: 'i'
261
+
return_message: 'User IDs must use the user_123 format.'
262
262
- name: pull_request_body
263
263
non_empty:
264
-
return_message: "Pull request content is required."
264
+
return_message: 'Pull request content is required.'
Prefer unquoted `/pattern/i` literal form for regex patterns that contain backslashes. If you use a structured `pattern` field, use single-quoted YAML strings or double each backslash in double-quoted strings.
Copy file name to clipboardExpand all lines: docs/providers.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -149,7 +149,7 @@ interface ProviderAdapter {
149
149
}
150
150
```
151
151
152
-
Direct adapter rendering accepts the same `environment` and `tier` selectors as `kit.renderPrompt()`. Use the synchronous `validate()` and `render()` methods when you already have a compiled `ResolvedPromptAsset`, and use the async `validatePrompt()` and `renderPrompt()` helpers when you want the adapter to resolve either markdown source or a compiled artifact from disk. Context input validation runs through the same shared prompt-input wrapper for OpenAI, OpenAI Responses, Anthropic, Gemini, and OpenRouter, so `allow_regex`, `deny_regex`, `non_empty`, `reject_secrets`, and `return_message` behave consistently across all five.
152
+
Direct adapter rendering accepts the same `environment` and `tier` selectors as `kit.renderPrompt()`. Use the synchronous `validate()` and `render()` methods when you already have a compiled `ResolvedPromptAsset`, and use the async `validatePrompt()` and `renderPrompt()` helpers when you want the adapter to resolve either markdown source or a compiled artifact from disk. Context input validation runs through the same shared prompt-input wrapper for OpenAI, OpenAI Responses, Anthropic, Gemini, and OpenRouter, so `allow_regex`, `deny_regex`, `non_empty`, `reject_secrets`, and `return_message` behave consistently across all five. For regex validators authored in YAML, prefer unquoted `/pattern/i` literals so backslash escapes stay copyable.
- `max_size`: checked during `renderPrompt()` and can produce `POK030` warnings.
295
295
- `trim`: trims incoming values to the `max_size` budget before interpolation (`true`/`end` keeps leading bytes, `start` keeps trailing bytes).
296
-
- `allow_regex`: allowlist validation before interpolation; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }`. Non-matches throw `POK031` unless `return_message` is configured.
297
-
- `deny_regex`: blocklist validation before interpolation; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }`. Matches throw `POK032` unless `return_message` is configured.
296
+
- `allow_regex`: allowlist validation before interpolation; accepts `/pattern/i`, `"pattern"`, or `{ pattern, flags, return_message? }`. Non-matches throw `POK031` unless `return_message` is configured.
297
+
- `deny_regex`: blocklist validation before interpolation; accepts `/pattern/i`, `"pattern"`, or `{ pattern, flags, return_message? }`. Matches throw `POK032` unless `return_message` is configured.
298
298
- `non_empty`: accepts `true` or `{ return_message }`; blank values throw `POK033` unless `return_message` is configured.
299
299
- `reject_secrets`: accepts `true` or `{ return_message }`; secret-like values throw `POK034` unless `return_message` is configured.
300
300
301
-
Malformed `allow_regex` and `deny_regex` values are reported during `validate` and `compile` with `POK013`.
301
+
Prefer unquoted `/pattern/i` literal form for regex validators, especially when the pattern contains backslashes such as `\s` or `\b`. If you use structured `pattern:` form, use single-quoted YAML strings or double each backslash in double-quoted strings.
302
+
303
+
Malformed `allow_regex` and `deny_regex` values, including unsafe double-quoted YAML regex strings with raw backslashes, are reported during `validate` and `compile` with `POK013`.
Copy file name to clipboardExpand all lines: docs/validation.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ const result = await kit.validatePrompt('support/reply');
34
34
|`POK010`| Warning | Unknown front matter key (with "did you mean?" suggestion) |
35
35
|`POK011`| Warning | Variable used in template but not declared in `context.inputs`|
36
36
|`POK012`| Warning | Variable declared in `context.inputs` but never used |
37
-
|`POK013`| Error | Invalid context regex pattern (`allow_regex` or `deny_regex`), including prompt id, variable name, field name, and raw configured value |
37
+
|`POK013`| Error | Invalid context regex pattern or YAML regex quoting (`allow_regex` or `deny_regex`), including location and raw configured value when available|
38
38
|`POK014`| Warning |`trim` configured without `max_size` (trim-to-budget skipped) |
- Prefer unquoted `/pattern/i` literal form for regex patterns that contain backslashes. If you use a structured `pattern` field, use single-quoted YAML strings or double each backslash in double-quoted strings.
118
117
- `trim`trims values to the `max_size` byte budget before interpolation.
119
118
- `allow_regex`enforces an allowlist pattern before interpolation and throws `POK031` when a value fails validation, unless `return_message` is configured.
120
119
- `deny_regex`enforces a blocklist pattern before interpolation and throws `POK032` when a value matches, unless `return_message` is configured.
121
120
- `non_empty`rejects blank or whitespace-only values with `POK033`, unless `return_message` is configured.
122
121
- `reject_secrets`rejects common secret-like strings with `POK034`, unless `return_message` is configured.
123
122
- During static validation and compilation, malformed `allow_regex` or `deny_regex` patterns are reported as `POK013`.
123
+
- Double-quoted YAML regex strings with raw backslashes, such as `"\s+"`, are reported as `POK013` before YAML parsing. Prefer unquoted `/pattern/i` literals for copyable regexes.
124
124
- During static validation, `trim` without `max_size` returns a `POK014` warning.
125
125
- During static validation, risky unbounded inputs and missing hardening are flagged as `POK040` and `POK041`.
126
126
- During static validation, provider/cache hygiene checks can emit `POK042`–`POK045`.
127
127
- During static validation, inline tool quality checks can emit `POK047`.
128
128
129
-
Regex compilation errors include the prompt id, variable name, field name, and raw configured value to make bad prompt definitions easy to locate.
129
+
Regex compilation errors include the prompt id, variable name, field name, and raw configured value to make bad prompt definitions easy to locate. YAML quoting errors include the file and line when available.
130
130
131
131
If a validator declares `return_message`, `renderPrompt()` returns that message in a structured result and omits the provider request instead of throwing.
0 commit comments