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
ENHANCEMENT: When runtime context failed an allow_regex, deny_regex or the built-in validators you can optionally use the return_message argument for the input to send a message in addition to raising an exception (current behavior, and default)
Copy file name to clipboardExpand all lines: SKILL.md
+26-3Lines changed: 26 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,6 +104,7 @@ Rules:
104
104
- Use `allow_regex` for allowlist checks and `deny_regex` for blocklist checks on risky inputs
105
105
- Prefer structured regexes like `{ pattern, flags }`; `/pattern/i` strings are also accepted and normalized internally
106
106
- Use `non_empty: true` for required user text and `reject_secrets: true` for common secret redaction checks
107
+
- 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`
107
108
- Escape literal braces with `\{{` and `\}}`
108
109
- In strict mode, missing variables throw an error
109
110
- In permissive mode, unresolved placeholders are left intact
@@ -121,6 +122,8 @@ context:
121
122
If a rendered value exceeds `max_size`, `renderPrompt()` emits a non-blocking `POK030` warning.
122
123
At render time, callers can also pass `onContextOverflow` to transform oversized values before warnings/rendering.
123
124
125
+
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.
126
+
124
127
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.
125
128
126
129
Example: this is the minimal valid shape for a prompt that references
request:ProviderRequest; // { body, provider, model }
82
+
request?:ProviderRequest; // { body, provider, model } when rendering continues
83
+
returnMessage?:string; // Short-circuit message from context validation when configured
83
84
warnings:string[]; // Non-fatal provider and render-time warnings
84
85
}
85
86
```
86
87
87
88
`warnings` may include provider adapter warnings and render-time `POK030` context size warnings when configured to be included in results.
88
89
90
+
If a context validator fails and that validator declares `return_message`, `renderPrompt()` returns `returnMessage` and omits `request` instead of throwing.
91
+
89
92
## `kit.loadPrompt(path)`
90
93
91
94
Load a prompt asset from compiled or source (based on mode). Returns a `PromptAsset`.
Copy file name to clipboardExpand all lines: docs/prompt-format.md
+7-5Lines changed: 7 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -169,10 +169,10 @@ Each entry can be either a string variable name or an object with:
169
169
- `name` — the template variable name
170
170
- `max_size`— optional UTF-8 byte limit for the injected value
171
171
- `trim`— optional trim-to-budget (`true`/`end` keeps first bytes, `start` keeps trailing bytes) applied when `max_size` is set
172
-
- `allow_regex`— optional allowlist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags}` and throws `POK031` on mismatch
173
-
- `deny_regex`— optional blocklist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags}` and throws `POK032` on match
174
-
- `non_empty`— optional boolean validator; throws `POK033` when the final value is blank or whitespace-only
175
-
- `reject_secrets`— optional boolean validator; throws `POK034` when the value matches the built-in secret detector
172
+
- `allow_regex`— optional allowlist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }` and throws `POK031` on mismatch unless `return_message` is configured
173
+
- `deny_regex`— optional blocklist regex; accepts `"pattern"`, `/pattern/i`, or `{ pattern, flags, return_message? }` and throws `POK032` on match unless `return_message` is configured
174
+
- `non_empty`— optional boolean or object validator; use `true` to throw `POK033`, or `{ return_message }` to short-circuit rendering with a structured message
175
+
- `reject_secrets`— optional boolean or object validator; use `true` to throw `POK034`, or `{ return_message }` to short-circuit rendering with a structured message
176
176
177
177
The validator warns about:
178
178
- Variables used in templates but not declared in `context.inputs`
@@ -193,8 +193,10 @@ context:
193
193
allow_regex:
194
194
pattern: "^user_[a-z0-9]+$"
195
195
flags: "i"
196
+
return_message: "User IDs must use the user_123 format."
196
197
- name: pull_request_body
197
-
non_empty: true
198
+
non_empty:
199
+
return_message: "Pull request content is required."
0 commit comments