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
`validatePrompt()` covers schema, include-graph, and variable declaration issues. Render-time context size warnings are produced by `renderPrompt()`, not validation.
111
+
104
112
## `kit.clearCache()`
105
113
106
114
Clear the internal LRU cache.
@@ -234,6 +242,7 @@ const result = await renderPrompt({
Copy file name to clipboardExpand all lines: docs/prompt-format.md
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,13 +160,21 @@ context:
160
160
inputs:
161
161
- name
162
162
- company
163
-
- app_context
163
+
- name: app_context
164
+
max_size: 2000
164
165
```
165
166
167
+
Each entry can be either a string variable name or an object with:
168
+
169
+
- `name` — the template variable name
170
+
- `max_size`— optional UTF-8 byte limit for the injected value
171
+
166
172
The validator warns about:
167
173
- Variables used in templates but not declared in `context.inputs`
168
174
- Variables declared in `context.inputs` but never used
169
175
176
+
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.
| `inputs` | `Array<string | { name, max_size? }>` | Expected variable names, optionally with a UTF-8 byte budget for render-time warnings |
142
143
| `history` | `object` | History settings |
143
144
| `history.max_items` | `number` | Maximum history items |
144
145
146
+
String-form inputs remain valid:
147
+
148
+
```yaml
149
+
context:
150
+
inputs:
151
+
- user_message
152
+
- account_summary
153
+
```
154
+
155
+
Object-form inputs add optional `max_size`, which is checked during `renderPrompt()` and can produce a `POK030` warning when the injected value exceeds the declared budget.
Copy file name to clipboardExpand all lines: docs/validation.md
+37-1Lines changed: 37 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Validation
2
2
3
-
PromptOpsKit validates prompts at multiple levels — schema structure, front matter keys, variable usage, and include graphs.
3
+
PromptOpsKit validates prompts at multiple levels — schema structure, front matter keys, variable usage, and include graphs. Render-time context size limits are checked separately during prompt rendering.
4
4
5
5
## Quick start
6
6
@@ -18,6 +18,12 @@ const result = await kit.validatePrompt('support/reply');
`validatePrompt()` does not execute render-time context size checks. Those warnings are produced by `renderPrompt()` when variables are provided.
22
+
23
+
## Render-time warnings
24
+
25
+
`renderPrompt()` can emit `POK030` when a provided variable exceeds the `max_size` declared for a context input.
26
+
21
27
## Error codes
22
28
23
29
| Code | Severity | Description |
@@ -58,6 +64,36 @@ context:
58
64
Hello {{ name }} from {{ company }}! <!-- POK011 warning: company used but not declared -->
59
65
```
60
66
67
+
Object-form inputs can also declare size limits:
68
+
69
+
```yaml
70
+
context:
71
+
inputs:
72
+
- name: account_summary
73
+
max_size: 4096
74
+
```
75
+
76
+
If `account_summary` is rendered with a value larger than 4096 UTF-8 bytes, `renderPrompt()` returns a `POK030` warning. In source and auto modes, PromptOpsKit also writes the warning to `console.warn` so oversized context is visible during local development.
77
+
78
+
You can override that behavior at the kit level:
79
+
80
+
```typescript
81
+
const kit = createPromptOpsKit({
82
+
sourceDir: './prompts',
83
+
warnings: {
84
+
contextSize: 'off',
85
+
},
86
+
});
87
+
```
88
+
89
+
`warnings.contextSize` supports:
90
+
91
+
- `auto`— default behavior; include in `renderPrompt().warnings`, and log to console outside `compiled-only`
92
+
- `off`— suppress context size warnings entirely
93
+
- `result-only`— return warnings but do not log them
94
+
- `console`— log warnings but do not include them in the returned `warnings` array
95
+
- `console-and-result`— log and return warnings in all modes
96
+
61
97
## Include validation
62
98
63
99
`validateAssetWithIncludes` resolves the full include graph and catches:
0 commit comments