promptopskit 0.3.6 → 0.3.8

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.
Files changed (55) hide show
  1. package/README.md +41 -12
  2. package/SKILL.md +31 -4
  3. package/dist/{chunk-6FLNJVE7.js → chunk-5OYWNRNC.js} +19 -3
  4. package/dist/{chunk-6FLNJVE7.js.map → chunk-5OYWNRNC.js.map} +1 -1
  5. package/dist/{chunk-MYXDJMWV.js → chunk-BBVVA27J.js} +2 -2
  6. package/dist/{chunk-SOY2CEJM.js → chunk-E2NXJLS6.js} +3 -3
  7. package/dist/{chunk-J32I6DSG.js → chunk-E6NPZOJL.js} +2 -2
  8. package/dist/{chunk-MN3RQ7DZ.js → chunk-UJU5XERR.js} +2 -2
  9. package/dist/{chunk-SHYKSLVR.js → chunk-X73VG645.js} +182 -9
  10. package/dist/chunk-X73VG645.js.map +1 -0
  11. package/dist/cli/index.js +252 -100
  12. package/dist/cli/index.js.map +1 -1
  13. package/dist/index.cjs +216 -17
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +6 -5
  16. package/dist/index.d.ts +6 -5
  17. package/dist/index.js +26 -14
  18. package/dist/index.js.map +1 -1
  19. package/dist/providers/anthropic.cjs +197 -9
  20. package/dist/providers/anthropic.cjs.map +1 -1
  21. package/dist/providers/anthropic.d.cts +2 -2
  22. package/dist/providers/anthropic.d.ts +2 -2
  23. package/dist/providers/anthropic.js +3 -3
  24. package/dist/providers/gemini.cjs +197 -9
  25. package/dist/providers/gemini.cjs.map +1 -1
  26. package/dist/providers/gemini.d.cts +2 -2
  27. package/dist/providers/gemini.d.ts +2 -2
  28. package/dist/providers/gemini.js +3 -3
  29. package/dist/providers/openai.cjs +197 -9
  30. package/dist/providers/openai.cjs.map +1 -1
  31. package/dist/providers/openai.d.cts +2 -2
  32. package/dist/providers/openai.d.ts +2 -2
  33. package/dist/providers/openai.js +3 -3
  34. package/dist/providers/openrouter.cjs +197 -9
  35. package/dist/providers/openrouter.cjs.map +1 -1
  36. package/dist/providers/openrouter.d.cts +2 -2
  37. package/dist/providers/openrouter.d.ts +2 -2
  38. package/dist/providers/openrouter.js +4 -4
  39. package/dist/{schema-D145q3Dw.d.cts → schema-DwzYbZba.d.cts} +178 -56
  40. package/dist/{schema-D145q3Dw.d.ts → schema-DwzYbZba.d.ts} +178 -56
  41. package/dist/testing.cjs +18 -2
  42. package/dist/testing.cjs.map +1 -1
  43. package/dist/testing.d.cts +1 -1
  44. package/dist/testing.d.ts +1 -1
  45. package/dist/testing.js +1 -1
  46. package/dist/{types-B3sWHzIo.d.cts → types-C6RG0Si0.d.cts} +12 -5
  47. package/dist/{types-CXlVWckk.d.ts → types-fBvo_d4k.d.ts} +12 -5
  48. package/dist/usagetap/index.d.cts +2 -2
  49. package/dist/usagetap/index.d.ts +2 -2
  50. package/package.json +1 -1
  51. package/dist/chunk-SHYKSLVR.js.map +0 -1
  52. /package/dist/{chunk-MYXDJMWV.js.map → chunk-BBVVA27J.js.map} +0 -0
  53. /package/dist/{chunk-SOY2CEJM.js.map → chunk-E2NXJLS6.js.map} +0 -0
  54. /package/dist/{chunk-J32I6DSG.js.map → chunk-E6NPZOJL.js.map} +0 -0
  55. /package/dist/{chunk-MN3RQ7DZ.js.map → chunk-UJU5XERR.js.map} +0 -0
package/README.md CHANGED
@@ -63,9 +63,15 @@ sampling:
63
63
  temperature: 0.7
64
64
  context:
65
65
  inputs:
66
- - user_message
66
+ - name: user_message
67
+ non_empty:
68
+ return_message: "Please enter a message before continuing."
69
+ reject_secrets: true
67
70
  - name: app_context
68
71
  max_size: 2000
72
+ allow_regex:
73
+ pattern: "^[A-Za-z0-9 _-]+$"
74
+ flags: "i"
69
75
  includes:
70
76
  - ./shared/tone.md
71
77
  ---
@@ -95,6 +101,10 @@ const result = await kit.renderPrompt({
95
101
  },
96
102
  });
97
103
 
104
+ if (result.returnMessage) {
105
+ return result.returnMessage;
106
+ }
107
+
98
108
  // result.request.body is ready for fetch()
99
109
  const response = await fetch('https://api.openai.com/v1/chat/completions', {
100
110
  method: 'POST',
@@ -127,11 +137,13 @@ Supported values for `warnings.contextSize` are `auto`, `off`, `result-only`, `c
127
137
  - **Overrides** — Environment and tier-based overrides (base → env → tier → runtime)
128
138
  - **4 provider adapters** — OpenAI, Anthropic, Gemini, OpenRouter — body-only output
129
139
  - **Validation** — Zod schema validation, Levenshtein-based "did you mean?" for typos, variable usage checks
140
+ - **Context hardening** — structured regexes with flags, `/pattern/i` convenience syntax, and built-in `non_empty` / `reject_secrets` validators
141
+ - **Optional short-circuit messages** — validators can return a structured `returnMessage` instead of throwing when configured
130
142
  - **Context size guardrails** — optional per-input `max_size` metadata with non-blocking render-time warnings
131
143
  - **Warning controls** — top-level config can suppress or emit context size warnings differently in dev and prod
132
144
  - **Caching** — LRU cache with mtime-based invalidation
133
145
  - **CLI** — init, validate, compile, render, inspect, skill
134
- - **Compiled artifacts** — Pre-compile `.md` → JSON or ESM for production
146
+ - **Compiled artifacts** — Pre-compile `.md` → JSON or ESM for production, with validation before artifacts are written
135
147
 
136
148
  ## Provider Adapters
137
149
 
@@ -141,35 +153,40 @@ Each adapter produces a `{ body, provider, model }` object shaped for the target
141
153
  // OpenAI
142
154
  import { createPromptOpsKit } from 'promptopskit';
143
155
  const kit = createPromptOpsKit();
144
- const { request } = await kit.renderPrompt({
156
+ let result = await kit.renderPrompt({
145
157
  path: 'hello',
146
158
  provider: 'openai',
147
159
  variables: { name: 'World', app_context: 'Welcome screen' },
148
160
  });
161
+ if (!result.request) throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
162
+ const { request } = result;
149
163
  // request.body → { model, messages, temperature, reasoning_effort, ... }
150
164
 
151
165
  // Anthropic — system is a top-level field, max_tokens defaults to 4096
152
- const { request } = await kit.renderPrompt({
166
+ result = await kit.renderPrompt({
153
167
  path: 'hello',
154
168
  provider: 'anthropic',
155
169
  variables: { name: 'World', app_context: 'Welcome screen' },
156
170
  });
171
+ if (!result.request) throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
157
172
  // request.body → { model, messages, system, max_tokens, ... }
158
173
 
159
174
  // Gemini — contents/systemInstruction/generationConfig structure
160
- const { request } = await kit.renderPrompt({
175
+ result = await kit.renderPrompt({
161
176
  path: 'hello',
162
177
  provider: 'gemini',
163
178
  variables: { name: 'World', app_context: 'Welcome screen' },
164
179
  });
180
+ if (!result.request) throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
165
181
  // request.body → { contents, systemInstruction, generationConfig, ... }
166
182
 
167
183
  // OpenRouter — same shape as OpenAI, different provider label
168
- const { request } = await kit.renderPrompt({
184
+ result = await kit.renderPrompt({
169
185
  path: 'hello',
170
186
  provider: 'openrouter',
171
187
  variables: { name: 'World', app_context: 'Welcome screen' },
172
188
  });
189
+ if (!result.request) throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
173
190
  ```
174
191
 
175
192
  Provider adapters are also available as direct imports:
@@ -211,7 +228,7 @@ On the server, adapters also provide async prompt-aware helpers so you can use t
211
228
  ```typescript
212
229
  import { openaiAdapter } from 'promptopskit/openai';
213
230
 
214
- const request = await openaiAdapter.renderPrompt(
231
+ const result = await openaiAdapter.renderPrompt(
215
232
  {
216
233
  path: 'summarizePullRequest',
217
234
  },
@@ -223,6 +240,12 @@ const request = await openaiAdapter.renderPrompt(
223
240
  strict: true,
224
241
  },
225
242
  );
243
+
244
+ if (!('body' in result)) {
245
+ throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
246
+ }
247
+
248
+ const request = result;
226
249
  ```
227
250
 
228
251
  If you need a different layout, keep passing `sourceDir` and `compiledDir` explicitly.
@@ -240,7 +263,7 @@ import { createUsageTapClient, runOpenAIWithUsageTap } from 'promptopskit/usaget
240
263
  const kit = createPromptOpsKit({ sourceDir: './prompts' });
241
264
  const usageTap = createUsageTapClient({ apiKey: process.env.USAGETAP_API_KEY! });
242
265
 
243
- const { request } = await kit.renderPrompt({
266
+ const result = await kit.renderPrompt({
244
267
  path: 'support/reply',
245
268
  provider: 'openai',
246
269
  variables: {
@@ -249,6 +272,12 @@ const { request } = await kit.renderPrompt({
249
272
  },
250
273
  });
251
274
 
275
+ if (!result.request) {
276
+ throw new Error(result.returnMessage ?? 'Prompt rendering failed.');
277
+ }
278
+
279
+ const { request } = result;
280
+
252
281
  const tracked = await runOpenAIWithUsageTap(usageTap, {
253
282
  begin: {
254
283
  customerId: 'user_123',
@@ -381,10 +410,10 @@ promptopskit init [dir]
381
410
  promptopskit skill
382
411
 
383
412
  # Validate all .md files in a directory
384
- promptopskit validate <dir> [--strict]
413
+ promptopskit validate [sourceDir] [--source <dir>] [--strict]
385
414
 
386
415
  # Compile .md → JSON/ESM artifacts
387
- promptopskit compile [src] [out] [--dry-run] [--format json|esm] [--no-clean]
416
+ promptopskit compile [sourceDir] [outputDir] [--source <dir>] [--output <dir>] [--dry-run] [--format json|esm] [--no-clean]
388
417
 
389
418
  # Render a prompt preview (auto-loads .test.yaml sidecar)
390
419
  promptopskit render <file> [--env <name>] [--tier <name>] [--vars <file>] [--json]
@@ -466,7 +495,7 @@ Creates a `PromptOpsKit` instance.
466
495
 
467
496
  ### `kit.renderPrompt(options)`
468
497
 
469
- Renders a prompt for a specific provider. Returns `{ resolved, request, warnings }`.
498
+ Renders a prompt for a specific provider. Returns `{ resolved, request?, returnMessage?, warnings }`.
470
499
 
471
500
  | Option | Type | Description |
472
501
  |--------|------|-------------|
@@ -507,7 +536,7 @@ Prompt files use YAML front matter with these fields:
507
536
  | `response` | `object` | `{ format, stream }` |
508
537
  | `tools` | `array` | Tool references (string names or inline definitions) |
509
538
  | `mcp` | `object` | MCP server references |
510
- | `context` | `object` | `{ inputs, history }` — declare expected variables, with optional per-input `max_size`, `trim`, and `allow_regex`/`deny_regex` controls |
539
+ | `context` | `object` | `{ inputs, history }` — declare expected variables, with optional per-input `max_size`, `trim`, structured or literal `allow_regex`/`deny_regex`, and built-in `non_empty` / `reject_secrets` validators |
511
540
  | `includes` | `string[]` | Paths to included prompt files |
512
541
  | `environments` | `object` | Named environment overrides |
513
542
  | `tiers` | `object` | Named tier overrides |
package/SKILL.md CHANGED
@@ -66,7 +66,7 @@ the fields required by that specific file:
66
66
  | `response` | object | no | `{ format: text|json|markdown, stream: boolean }` |
67
67
  | `tools` | array | no | Tool names (strings) or inline definitions with `{ name, description, input_schema }` |
68
68
  | `mcp` | object | no | `{ servers: [string | { name, config }] }` |
69
- | `context.inputs` | `Array<string | { name, max_size?, trim?, allow_regex?, deny_regex? }>` | no | Declared variable names used in templates, with optional size budgets and runtime hardening controls |
69
+ | `context.inputs` | `Array<string | { name, max_size?, trim?, allow_regex?, deny_regex?, non_empty?, reject_secrets? }>` | no | Declared variable names used in templates, with optional size budgets and runtime hardening controls |
70
70
  | `context.history` | object | no | `{ max_items: number }` |
71
71
  | `includes` | string[] | no | Relative paths to other prompt files to include |
72
72
  | `environments` | object | no | Per-environment overrides (see Overrides) |
@@ -102,6 +102,9 @@ Rules:
102
102
  - Use object-form inputs with `max_size` when a variable is likely to grow large and should trigger early warnings
103
103
  - Use `trim` to enforce byte budgets before interpolation when `max_size` is set
104
104
  - Use `allow_regex` for allowlist checks and `deny_regex` for blocklist checks on risky inputs
105
+ - Prefer structured regexes like `{ pattern, flags }`; `/pattern/i` strings are also accepted and normalized internally
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`
105
108
  - Escape literal braces with `\{{` and `\}}`
106
109
  - In strict mode, missing variables throw an error
107
110
  - In permissive mode, unresolved placeholders are left intact
@@ -119,6 +122,10 @@ context:
119
122
  If a rendered value exceeds `max_size`, `renderPrompt()` emits a non-blocking `POK030` warning.
120
123
  At render time, callers can also pass `onContextOverflow` to transform oversized values before warnings/rendering.
121
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
+
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.
128
+
122
129
  Example: this is the minimal valid shape for a prompt that references
123
130
  `{{ pull_request }}` even when provider/model are inherited from defaults:
124
131
 
@@ -267,7 +274,7 @@ const kit = createPromptOpsKit({
267
274
  },
268
275
  });
269
276
 
270
- const { request } = await kit.renderPrompt({
277
+ const result = await kit.renderPrompt({
271
278
  path: 'support/reply',
272
279
  provider: 'openai',
273
280
  environment: 'production',
@@ -276,6 +283,16 @@ const { request } = await kit.renderPrompt({
276
283
  app_context: 'Account settings',
277
284
  },
278
285
  });
286
+
287
+ if (result.returnMessage) {
288
+ return result.returnMessage;
289
+ }
290
+
291
+ if (!result.request) {
292
+ throw new Error('Prompt rendering did not produce a provider request.');
293
+ }
294
+
295
+ const { request } = result;
279
296
  ```
280
297
 
281
298
  ### Use `adapter.renderPrompt()` when:
@@ -288,7 +305,7 @@ const { request } = await kit.renderPrompt({
288
305
  import path from 'node:path';
289
306
  import { openaiAdapter } from 'promptopskit/openai';
290
307
 
291
- const request = await openaiAdapter.renderPrompt(
308
+ const result = await openaiAdapter.renderPrompt(
292
309
  {
293
310
  path: 'support/reply',
294
311
  sourceDir: path.join(process.cwd(), 'prompts'),
@@ -303,6 +320,16 @@ const request = await openaiAdapter.renderPrompt(
303
320
  strict: true,
304
321
  },
305
322
  );
323
+
324
+ if (result.returnMessage) {
325
+ return result.returnMessage;
326
+ }
327
+
328
+ if (!('body' in result)) {
329
+ throw new Error('Prompt rendering did not produce a provider request.');
330
+ }
331
+
332
+ const request = result;
306
333
  ```
307
334
 
308
335
  ### Use `adapter.render()` when:
@@ -434,7 +461,7 @@ Hello {{ name }}
434
461
  | Command | Description |
435
462
  |---------|-------------|
436
463
  | `promptopskit init [dir]` | Scaffold a prompts directory with starter files (including `defaults.md`) |
437
- | `promptopskit validate <dir>` | Validate all prompt files in a directory |
464
+ | `promptopskit validate [sourceDir] [options]` | Validate all prompt files in a directory, defaulting to `./prompts` |
438
465
  | `promptopskit compile [src] [out]` | Compile `.md` prompts to JSON or ESM artifacts |
439
466
  | `promptopskit render <file>` | Render a prompt preview |
440
467
  | `promptopskit inspect <file>` | Print the normalized prompt asset |
@@ -32,12 +32,28 @@ var ResponseSchema = z.object({
32
32
  var HistorySchema = z.object({
33
33
  max_items: z.number().int().positive().optional()
34
34
  });
35
+ var ContextRegexSchema = z.union([
36
+ z.string(),
37
+ z.object({
38
+ pattern: z.string(),
39
+ flags: z.string().optional(),
40
+ return_message: z.string().optional()
41
+ })
42
+ ]);
43
+ var ContextBuiltInValidatorSchema = z.union([
44
+ z.boolean(),
45
+ z.object({
46
+ return_message: z.string().optional()
47
+ })
48
+ ]);
35
49
  var ContextInputDefinitionObjectSchema = z.object({
36
50
  name: z.string(),
37
51
  max_size: z.number().int().positive().optional(),
38
52
  trim: z.union([z.boolean(), z.enum(["start", "end", "both"])]).optional(),
39
- allow_regex: z.string().optional(),
40
- deny_regex: z.string().optional()
53
+ allow_regex: ContextRegexSchema.optional(),
54
+ deny_regex: ContextRegexSchema.optional(),
55
+ non_empty: ContextBuiltInValidatorSchema.optional(),
56
+ reject_secrets: ContextBuiltInValidatorSchema.optional()
41
57
  });
42
58
  var ContextInputDefinitionSchema = z.union([
43
59
  z.string(),
@@ -261,4 +277,4 @@ export {
261
277
  parsePrompt,
262
278
  loadPromptFile
263
279
  };
264
- //# sourceMappingURL=chunk-6FLNJVE7.js.map
280
+ //# sourceMappingURL=chunk-5OYWNRNC.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/schema/schema.ts","../src/parser/sections.ts","../src/parser/parser.ts","../src/parser/loader.ts"],"sourcesContent":["import { z } from 'zod';\n\n// --- Tool definitions ---\n\nexport const InlineToolDefSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n input_schema: z.record(z.unknown()).optional(),\n});\n\nexport type InlineToolDef = z.infer<typeof InlineToolDefSchema>;\n\nexport const ToolRefSchema = z.union([z.string(), InlineToolDefSchema]);\n\n// --- MCP ---\n\nexport const MCPServerRefSchema = z.union([\n z.string(),\n z.object({\n name: z.string(),\n config: z.record(z.unknown()).optional(),\n }),\n]);\n\nexport type MCPServerRef = z.infer<typeof MCPServerRefSchema>;\n\n// --- Reasoning ---\n\nexport const ReasoningSchema = z.object({\n effort: z.enum(['low', 'medium', 'high']).optional(),\n budget_tokens: z.number().int().positive().optional(),\n});\n\n// --- Sampling ---\n\nexport const SamplingSchema = z.object({\n temperature: z.number().min(0).max(2).optional(),\n top_p: z.number().min(0).max(1).optional(),\n frequency_penalty: z.number().optional(),\n presence_penalty: z.number().optional(),\n stop: z.array(z.string()).optional(),\n max_output_tokens: z.number().int().positive().optional(),\n});\n\n// --- Response ---\n\nexport const ResponseSchema = z.object({\n format: z.enum(['text', 'json', 'markdown']).optional(),\n stream: z.boolean().optional(),\n});\n\n// --- Context ---\n\nexport const HistorySchema = z.object({\n max_items: z.number().int().positive().optional(),\n});\n\nexport const ContextInputDefinitionObjectSchema = z.object({\n name: z.string(),\n max_size: z.number().int().positive().optional(),\n trim: z.union([z.boolean(), z.enum(['start', 'end', 'both'])]).optional(),\n allow_regex: z.string().optional(),\n deny_regex: z.string().optional(),\n});\n\nexport const ContextInputDefinitionSchema = z.union([\n z.string(),\n ContextInputDefinitionObjectSchema,\n]);\n\nexport type ContextInputDefinition = z.infer<typeof ContextInputDefinitionSchema>;\n\nexport const ContextSchema = z.object({\n inputs: z.array(ContextInputDefinitionSchema).optional(),\n history: HistorySchema.optional(),\n});\n\n// --- Metadata ---\n\nexport const MetadataSchema = z.object({\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n review_required: z.boolean().optional(),\n stable: z.boolean().optional(),\n});\n\n// --- MCP block ---\n\nexport const MCPSchema = z.object({\n servers: z.array(MCPServerRefSchema).optional(),\n});\n\n// --- Overrides (subset allowed in environments/tiers) ---\n\nexport const PromptAssetOverridesSchema = z.object({\n model: z.string().optional(),\n fallback_models: z.array(z.string()).optional(),\n reasoning: ReasoningSchema.optional(),\n sampling: SamplingSchema.optional(),\n response: ResponseSchema.optional(),\n tools: z.array(ToolRefSchema).optional(),\n});\n\nexport type PromptAssetOverrides = z.infer<typeof PromptAssetOverridesSchema>;\n\n// --- Source tracking ---\n\nexport const SourceSchema = z.object({\n file_path: z.string().optional(),\n checksum: z.string().optional(),\n});\n\n// --- Sections (populated by parser) ---\n\nexport const SectionsSchema = z.object({\n system_instructions: z.string().optional(),\n prompt_template: z.string().optional(),\n notes: z.string().optional(),\n});\n\n// --- Defaults files (folder-level inheritance) ---\n\nexport const PromptDefaultsSchema = z.object({\n provider: z.enum(['openai', 'anthropic', 'google', 'gemini', 'openrouter', 'any']).optional(),\n model: z.string().optional(),\n metadata: MetadataSchema.optional(),\n sections: z.object({\n system_instructions: z.string().optional(),\n }).optional(),\n});\n\nexport type PromptDefaults = z.infer<typeof PromptDefaultsSchema>;\n\n// --- Top-level PromptAsset ---\n\nexport const PromptAssetSchema = z.object({\n id: z.string(),\n schema_version: z.number().int().positive().default(1),\n description: z.string().optional(),\n\n provider: z.enum(['openai', 'anthropic', 'google', 'gemini', 'openrouter', 'any']).optional(),\n model: z.string().optional(),\n fallback_models: z.array(z.string()).optional(),\n\n reasoning: ReasoningSchema.optional(),\n sampling: SamplingSchema.optional(),\n response: ResponseSchema.optional(),\n\n tools: z.array(ToolRefSchema).optional(),\n mcp: MCPSchema.optional(),\n\n context: ContextSchema.optional(),\n\n includes: z.array(z.string()).optional(),\n\n environments: z.record(PromptAssetOverridesSchema).optional(),\n tiers: z.record(PromptAssetOverridesSchema).optional(),\n\n metadata: MetadataSchema.optional(),\n\n // Populated by parser, not authored in YAML\n sections: SectionsSchema.optional(),\n source: SourceSchema.optional(),\n});\n\nexport type PromptAsset = z.infer<typeof PromptAssetSchema>;\n\n// --- Resolved asset (after includes, overrides applied) ---\n\nexport interface ResolvedPromptAsset extends PromptAsset {\n sections: {\n system_instructions?: string;\n prompt_template?: string;\n notes?: string;\n };\n source: {\n file_path?: string;\n checksum?: string;\n };\n}\n","export interface Sections {\n system_instructions?: string;\n prompt_template?: string;\n notes?: string;\n}\n\nconst SECTION_MAP: Record<string, keyof Sections> = {\n 'system instructions': 'system_instructions',\n 'prompt template': 'prompt_template',\n 'notes': 'notes',\n};\n\n/**\n * Extract named sections from the markdown body using H1 headings.\n * Case-insensitive. H2+ within a section is treated as content.\n * If no H1 headings are found, the entire body is treated as prompt_template.\n */\nexport function extractSections(body: string): Sections {\n const lines = body.split(/\\r?\\n/);\n const sections: Sections = {};\n\n let currentKey: keyof Sections | null = null;\n let currentLines: string[] = [];\n let foundAnyH1 = false;\n\n for (const line of lines) {\n const h1Match = line.match(/^#\\s+(.+)$/);\n if (h1Match) {\n // Flush previous section\n if (currentKey) {\n sections[currentKey] = currentLines.join('\\n').trim();\n }\n\n foundAnyH1 = true;\n const heading = h1Match[1].trim().toLowerCase();\n currentKey = SECTION_MAP[heading] ?? null;\n currentLines = [];\n } else {\n currentLines.push(line);\n }\n }\n\n // Flush last section\n if (currentKey) {\n sections[currentKey] = currentLines.join('\\n').trim();\n }\n\n // If no H1 headings found, treat entire body as prompt_template\n if (!foundAnyH1) {\n const trimmed = body.trim();\n if (trimmed) {\n sections.prompt_template = trimmed;\n }\n }\n\n return sections;\n}\n","import matter from 'gray-matter';\nimport { PromptAssetSchema } from '../schema/index.js';\nimport type { PromptAsset } from '../schema/index.js';\nimport { extractSections } from './sections.js';\n\nexport interface ParseResult {\n asset: PromptAsset;\n raw: {\n frontMatter: Record<string, unknown>;\n body: string;\n };\n}\n\n/**\n * Parse a prompt markdown string (YAML front matter + markdown body)\n * into a validated PromptAsset.\n */\nexport function parsePrompt(content: string, filePath?: string): ParseResult {\n const { data: frontMatter, content: body } = matter(content);\n\n const sections = extractSections(body);\n\n const raw = {\n ...frontMatter,\n sections,\n source: filePath ? { file_path: filePath } : undefined,\n };\n\n const asset = PromptAssetSchema.parse(raw);\n\n return {\n asset,\n raw: {\n frontMatter: frontMatter as Record<string, unknown>,\n body,\n },\n };\n}\n","import { readFile } from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport matter from 'gray-matter';\nimport { parsePrompt } from './parser.js';\nimport type { ParseResult } from './parser.js';\nimport { extractSections } from './sections.js';\nimport { PromptDefaultsSchema } from '../schema/index.js';\nimport type { PromptDefaults } from '../schema/index.js';\n\nconst DEFAULTS_FILE_NAME = 'defaults.md';\n\nexport interface LoadPromptOptions {\n /**\n * Optional boundary directory for defaults discovery.\n * If provided, defaults are loaded from this directory down to the prompt directory.\n */\n defaultsRoot?: string;\n}\n\n/**\n * Load and parse a prompt file from disk.\n */\nexport async function loadPromptFile(filePath: string, options: LoadPromptOptions = {}): Promise<ParseResult> {\n const content = await readFile(filePath, 'utf-8');\n const parsed = parsePrompt(content, filePath);\n // Default the boundary to the file's own directory so traversal never\n // walks above the prompt tree when no explicit root is provided.\n const root = options.defaultsRoot ?? dirname(filePath);\n const defaults = await loadDefaultsForPath(filePath, root);\n const asset = applyDefaults(parsed.asset, defaults);\n\n return {\n ...parsed,\n asset,\n };\n}\n\nasync function loadDefaultsForPath(filePath: string, defaultsRoot?: string): Promise<PromptDefaults> {\n const directories = getDirectoriesToCheck(filePath, defaultsRoot);\n let merged: PromptDefaults = {};\n\n for (const dir of directories) {\n const defaultsPath = join(dir, DEFAULTS_FILE_NAME);\n try {\n const defaultsContent = await readFile(defaultsPath, 'utf-8');\n const defaults = parseDefaults(defaultsContent);\n merged = mergeDefaults(merged, defaults);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n return merged;\n}\n\nfunction getDirectoriesToCheck(filePath: string, defaultsRoot?: string): string[] {\n const dirs: string[] = [];\n let current = resolve(dirname(filePath));\n const boundary = defaultsRoot ? resolve(defaultsRoot) : undefined;\n\n while (true) {\n dirs.unshift(current);\n if ((boundary && current === boundary) || current === dirname(current)) {\n break;\n }\n current = dirname(current);\n }\n\n return dirs;\n}\n\nfunction parseDefaults(content: string): PromptDefaults {\n const { data: frontMatter, content: body } = matter(content);\n const sections = extractSections(body);\n\n return PromptDefaultsSchema.parse({\n ...frontMatter,\n sections: {\n system_instructions: sections.system_instructions,\n },\n });\n}\n\nfunction mergeDefaults(base: PromptDefaults, local: PromptDefaults): PromptDefaults {\n return {\n provider: local.provider ?? base.provider,\n model: local.model ?? base.model,\n metadata: {\n ...(base.metadata ?? {}),\n ...(local.metadata ?? {}),\n },\n sections: {\n ...(base.sections ?? {}),\n ...(local.sections ?? {}),\n },\n };\n}\n\nfunction applyDefaults(asset: ParseResult['asset'], defaults: PromptDefaults): ParseResult['asset'] {\n const hasDefaultMetadata = defaults.metadata && Object.keys(defaults.metadata).length > 0;\n const hasDefaultSystem = !!defaults.sections?.system_instructions;\n const hasDefaultScalars = defaults.provider !== undefined\n || defaults.model !== undefined;\n\n // Short-circuit: nothing to merge\n if (!hasDefaultMetadata && !hasDefaultSystem && !hasDefaultScalars) {\n return asset;\n }\n\n const mergedMetadata = {\n ...(defaults.metadata ?? {}),\n ...(asset.metadata ?? {}),\n };\n const metadata = Object.keys(mergedMetadata).length > 0 ? mergedMetadata : undefined;\n\n const systemInstructions = asset.sections?.system_instructions ?? defaults.sections?.system_instructions;\n\n const sections = asset.sections\n ? { ...asset.sections, system_instructions: systemInstructions }\n : systemInstructions\n ? { system_instructions: systemInstructions }\n : undefined;\n\n return {\n ...asset,\n provider: asset.provider ?? defaults.provider,\n model: asset.model ?? defaults.model,\n metadata,\n sections,\n };\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAIX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC/C,CAAC;AAIM,IAAM,gBAAgB,EAAE,MAAM,CAA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C/B;AAAA,IACA;AAAA,EACF;AACF;","names":["matter","matter"]}
1
+ {"version":3,"sources":["../src/schema/schema.ts","../src/parser/sections.ts","../src/parser/parser.ts","../src/parser/loader.ts"],"sourcesContent":["import { z } from 'zod';\n\n// --- Tool definitions ---\n\nexport const InlineToolDefSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n input_schema: z.record(z.unknown()).optional(),\n});\n\nexport type InlineToolDef = z.infer<typeof InlineToolDefSchema>;\n\nexport const ToolRefSchema = z.union([z.string(), InlineToolDefSchema]);\n\n// --- MCP ---\n\nexport const MCPServerRefSchema = z.union([\n z.string(),\n z.object({\n name: z.string(),\n config: z.record(z.unknown()).optional(),\n }),\n]);\n\nexport type MCPServerRef = z.infer<typeof MCPServerRefSchema>;\n\n// --- Reasoning ---\n\nexport const ReasoningSchema = z.object({\n effort: z.enum(['low', 'medium', 'high']).optional(),\n budget_tokens: z.number().int().positive().optional(),\n});\n\n// --- Sampling ---\n\nexport const SamplingSchema = z.object({\n temperature: z.number().min(0).max(2).optional(),\n top_p: z.number().min(0).max(1).optional(),\n frequency_penalty: z.number().optional(),\n presence_penalty: z.number().optional(),\n stop: z.array(z.string()).optional(),\n max_output_tokens: z.number().int().positive().optional(),\n});\n\n// --- Response ---\n\nexport const ResponseSchema = z.object({\n format: z.enum(['text', 'json', 'markdown']).optional(),\n stream: z.boolean().optional(),\n});\n\n// --- Context ---\n\nexport const HistorySchema = z.object({\n max_items: z.number().int().positive().optional(),\n});\n\nexport const ContextRegexSchema = z.union([\n z.string(),\n z.object({\n pattern: z.string(),\n flags: z.string().optional(),\n return_message: z.string().optional(),\n }),\n]);\n\nexport const ContextBuiltInValidatorSchema = z.union([\n z.boolean(),\n z.object({\n return_message: z.string().optional(),\n }),\n]);\n\nexport const ContextInputDefinitionObjectSchema = z.object({\n name: z.string(),\n max_size: z.number().int().positive().optional(),\n trim: z.union([z.boolean(), z.enum(['start', 'end', 'both'])]).optional(),\n allow_regex: ContextRegexSchema.optional(),\n deny_regex: ContextRegexSchema.optional(),\n non_empty: ContextBuiltInValidatorSchema.optional(),\n reject_secrets: ContextBuiltInValidatorSchema.optional(),\n});\n\nexport const ContextInputDefinitionSchema = z.union([\n z.string(),\n ContextInputDefinitionObjectSchema,\n]);\n\nexport type ContextInputDefinition = z.infer<typeof ContextInputDefinitionSchema>;\nexport type ContextRegexDefinition = z.infer<typeof ContextRegexSchema>;\nexport type ContextBuiltInValidatorDefinition = z.infer<typeof ContextBuiltInValidatorSchema>;\n\nexport const ContextSchema = z.object({\n inputs: z.array(ContextInputDefinitionSchema).optional(),\n history: HistorySchema.optional(),\n});\n\n// --- Metadata ---\n\nexport const MetadataSchema = z.object({\n owner: z.string().optional(),\n tags: z.array(z.string()).optional(),\n review_required: z.boolean().optional(),\n stable: z.boolean().optional(),\n});\n\n// --- MCP block ---\n\nexport const MCPSchema = z.object({\n servers: z.array(MCPServerRefSchema).optional(),\n});\n\n// --- Overrides (subset allowed in environments/tiers) ---\n\nexport const PromptAssetOverridesSchema = z.object({\n model: z.string().optional(),\n fallback_models: z.array(z.string()).optional(),\n reasoning: ReasoningSchema.optional(),\n sampling: SamplingSchema.optional(),\n response: ResponseSchema.optional(),\n tools: z.array(ToolRefSchema).optional(),\n});\n\nexport type PromptAssetOverrides = z.infer<typeof PromptAssetOverridesSchema>;\n\n// --- Source tracking ---\n\nexport const SourceSchema = z.object({\n file_path: z.string().optional(),\n checksum: z.string().optional(),\n});\n\n// --- Sections (populated by parser) ---\n\nexport const SectionsSchema = z.object({\n system_instructions: z.string().optional(),\n prompt_template: z.string().optional(),\n notes: z.string().optional(),\n});\n\n// --- Defaults files (folder-level inheritance) ---\n\nexport const PromptDefaultsSchema = z.object({\n provider: z.enum(['openai', 'anthropic', 'google', 'gemini', 'openrouter', 'any']).optional(),\n model: z.string().optional(),\n metadata: MetadataSchema.optional(),\n sections: z.object({\n system_instructions: z.string().optional(),\n }).optional(),\n});\n\nexport type PromptDefaults = z.infer<typeof PromptDefaultsSchema>;\n\n// --- Top-level PromptAsset ---\n\nexport const PromptAssetSchema = z.object({\n id: z.string(),\n schema_version: z.number().int().positive().default(1),\n description: z.string().optional(),\n\n provider: z.enum(['openai', 'anthropic', 'google', 'gemini', 'openrouter', 'any']).optional(),\n model: z.string().optional(),\n fallback_models: z.array(z.string()).optional(),\n\n reasoning: ReasoningSchema.optional(),\n sampling: SamplingSchema.optional(),\n response: ResponseSchema.optional(),\n\n tools: z.array(ToolRefSchema).optional(),\n mcp: MCPSchema.optional(),\n\n context: ContextSchema.optional(),\n\n includes: z.array(z.string()).optional(),\n\n environments: z.record(PromptAssetOverridesSchema).optional(),\n tiers: z.record(PromptAssetOverridesSchema).optional(),\n\n metadata: MetadataSchema.optional(),\n\n // Populated by parser, not authored in YAML\n sections: SectionsSchema.optional(),\n source: SourceSchema.optional(),\n});\n\nexport type PromptAsset = z.infer<typeof PromptAssetSchema>;\n\n// --- Resolved asset (after includes, overrides applied) ---\n\nexport interface ResolvedPromptAsset extends PromptAsset {\n sections: {\n system_instructions?: string;\n prompt_template?: string;\n notes?: string;\n };\n source: {\n file_path?: string;\n checksum?: string;\n };\n}\n","export interface Sections {\n system_instructions?: string;\n prompt_template?: string;\n notes?: string;\n}\n\nconst SECTION_MAP: Record<string, keyof Sections> = {\n 'system instructions': 'system_instructions',\n 'prompt template': 'prompt_template',\n 'notes': 'notes',\n};\n\n/**\n * Extract named sections from the markdown body using H1 headings.\n * Case-insensitive. H2+ within a section is treated as content.\n * If no H1 headings are found, the entire body is treated as prompt_template.\n */\nexport function extractSections(body: string): Sections {\n const lines = body.split(/\\r?\\n/);\n const sections: Sections = {};\n\n let currentKey: keyof Sections | null = null;\n let currentLines: string[] = [];\n let foundAnyH1 = false;\n\n for (const line of lines) {\n const h1Match = line.match(/^#\\s+(.+)$/);\n if (h1Match) {\n // Flush previous section\n if (currentKey) {\n sections[currentKey] = currentLines.join('\\n').trim();\n }\n\n foundAnyH1 = true;\n const heading = h1Match[1].trim().toLowerCase();\n currentKey = SECTION_MAP[heading] ?? null;\n currentLines = [];\n } else {\n currentLines.push(line);\n }\n }\n\n // Flush last section\n if (currentKey) {\n sections[currentKey] = currentLines.join('\\n').trim();\n }\n\n // If no H1 headings found, treat entire body as prompt_template\n if (!foundAnyH1) {\n const trimmed = body.trim();\n if (trimmed) {\n sections.prompt_template = trimmed;\n }\n }\n\n return sections;\n}\n","import matter from 'gray-matter';\nimport { PromptAssetSchema } from '../schema/index.js';\nimport type { PromptAsset } from '../schema/index.js';\nimport { extractSections } from './sections.js';\n\nexport interface ParseResult {\n asset: PromptAsset;\n raw: {\n frontMatter: Record<string, unknown>;\n body: string;\n };\n}\n\n/**\n * Parse a prompt markdown string (YAML front matter + markdown body)\n * into a validated PromptAsset.\n */\nexport function parsePrompt(content: string, filePath?: string): ParseResult {\n const { data: frontMatter, content: body } = matter(content);\n\n const sections = extractSections(body);\n\n const raw = {\n ...frontMatter,\n sections,\n source: filePath ? { file_path: filePath } : undefined,\n };\n\n const asset = PromptAssetSchema.parse(raw);\n\n return {\n asset,\n raw: {\n frontMatter: frontMatter as Record<string, unknown>,\n body,\n },\n };\n}\n","import { readFile } from 'node:fs/promises';\nimport { dirname, join, resolve } from 'node:path';\nimport matter from 'gray-matter';\nimport { parsePrompt } from './parser.js';\nimport type { ParseResult } from './parser.js';\nimport { extractSections } from './sections.js';\nimport { PromptDefaultsSchema } from '../schema/index.js';\nimport type { PromptDefaults } from '../schema/index.js';\n\nconst DEFAULTS_FILE_NAME = 'defaults.md';\n\nexport interface LoadPromptOptions {\n /**\n * Optional boundary directory for defaults discovery.\n * If provided, defaults are loaded from this directory down to the prompt directory.\n */\n defaultsRoot?: string;\n}\n\n/**\n * Load and parse a prompt file from disk.\n */\nexport async function loadPromptFile(filePath: string, options: LoadPromptOptions = {}): Promise<ParseResult> {\n const content = await readFile(filePath, 'utf-8');\n const parsed = parsePrompt(content, filePath);\n // Default the boundary to the file's own directory so traversal never\n // walks above the prompt tree when no explicit root is provided.\n const root = options.defaultsRoot ?? dirname(filePath);\n const defaults = await loadDefaultsForPath(filePath, root);\n const asset = applyDefaults(parsed.asset, defaults);\n\n return {\n ...parsed,\n asset,\n };\n}\n\nasync function loadDefaultsForPath(filePath: string, defaultsRoot?: string): Promise<PromptDefaults> {\n const directories = getDirectoriesToCheck(filePath, defaultsRoot);\n let merged: PromptDefaults = {};\n\n for (const dir of directories) {\n const defaultsPath = join(dir, DEFAULTS_FILE_NAME);\n try {\n const defaultsContent = await readFile(defaultsPath, 'utf-8');\n const defaults = parseDefaults(defaultsContent);\n merged = mergeDefaults(merged, defaults);\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {\n throw error;\n }\n }\n }\n\n return merged;\n}\n\nfunction getDirectoriesToCheck(filePath: string, defaultsRoot?: string): string[] {\n const dirs: string[] = [];\n let current = resolve(dirname(filePath));\n const boundary = defaultsRoot ? resolve(defaultsRoot) : undefined;\n\n while (true) {\n dirs.unshift(current);\n if ((boundary && current === boundary) || current === dirname(current)) {\n break;\n }\n current = dirname(current);\n }\n\n return dirs;\n}\n\nfunction parseDefaults(content: string): PromptDefaults {\n const { data: frontMatter, content: body } = matter(content);\n const sections = extractSections(body);\n\n return PromptDefaultsSchema.parse({\n ...frontMatter,\n sections: {\n system_instructions: sections.system_instructions,\n },\n });\n}\n\nfunction mergeDefaults(base: PromptDefaults, local: PromptDefaults): PromptDefaults {\n return {\n provider: local.provider ?? base.provider,\n model: local.model ?? base.model,\n metadata: {\n ...(base.metadata ?? {}),\n ...(local.metadata ?? {}),\n },\n sections: {\n ...(base.sections ?? {}),\n ...(local.sections ?? {}),\n },\n };\n}\n\nfunction applyDefaults(asset: ParseResult['asset'], defaults: PromptDefaults): ParseResult['asset'] {\n const hasDefaultMetadata = defaults.metadata && Object.keys(defaults.metadata).length > 0;\n const hasDefaultSystem = !!defaults.sections?.system_instructions;\n const hasDefaultScalars = defaults.provider !== undefined\n || defaults.model !== undefined;\n\n // Short-circuit: nothing to merge\n if (!hasDefaultMetadata && !hasDefaultSystem && !hasDefaultScalars) {\n return asset;\n }\n\n const mergedMetadata = {\n ...(defaults.metadata ?? {}),\n ...(asset.metadata ?? {}),\n };\n const metadata = Object.keys(mergedMetadata).length > 0 ? mergedMetadata : undefined;\n\n const systemInstructions = asset.sections?.system_instructions ?? defaults.sections?.system_instructions;\n\n const sections = asset.sections\n ? { ...asset.sections, system_instructions: systemInstructions }\n : systemInstructions\n ? { system_instructions: systemInstructions }\n : undefined;\n\n return {\n ...asset,\n provider: asset.provider ?? defaults.provider,\n model: asset.model ?? defaults.model,\n metadata,\n sections,\n };\n}\n"],"mappings":";AAAA,SAAS,SAAS;AAIX,IAAM,sBAAsB,EAAE,OAAO;AAAA,EAC1C,MAAM,EAAE,OAAO;AAAA,EACf,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAC/C,CAAC;AAIM,IAAM,gBAAgB,EAAE,MAAM,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;AAI/D,IAAM,qBAAqB,EAAE,MAAM;AAAA,EACxC,EAAE,OAAO;AAAA,EACT,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO;AAAA,IACf,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACzC,CAAC;AACH,CAAC;AAMM,IAAM,kBAAkB,EAAE,OAAO;AAAA,EACtC,QAAQ,EAAE,KAAK,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,SAAS;AAAA,EACnD,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS;AACtD,CAAC;AAIM,IAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EAC/C,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS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SAAS,cAAc,MAAsB,OAAuC;AAClF,SAAO;AAAA,IACL,UAAU,MAAM,YAAY,KAAK;AAAA,IACjC,OAAO,MAAM,SAAS,KAAK;AAAA,IAC3B,UAAU;AAAA,MACR,GAAI,KAAK,YAAY,CAAC;AAAA,MACtB,GAAI,MAAM,YAAY,CAAC;AAAA,IACzB;AAAA,IACA,UAAU;AAAA,MACR,GAAI,KAAK,YAAY,CAAC;AAAA,MACtB,GAAI,MAAM,YAAY,CAAC;AAAA,IACzB;AAAA,EACF;AACF;AAEA,SAAS,cAAc,OAA6B,UAAgD;AAClG,QAAM,qBAAqB,SAAS,YAAY,OAAO,KAAK,SAAS,QAAQ,EAAE,SAAS;AACxF,QAAM,mBAAmB,CAAC,CAAC,SAAS,UAAU;AAC9C,QAAM,oBAAoB,SAAS,aAAa,UAC3C,SAAS,UAAU;AAGxB,MAAI,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,mBAAmB;AAClE,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB;AAAA,IACrB,GAAI,SAAS,YAAY,CAAC;AAAA,IAC1B,GAAI,MAAM,YAAY,CAAC;AAAA,EACzB;AACA,QAAM,WAAW,OAAO,KAAK,cAAc,EAAE,SAAS,IAAI,iBAAiB;AAE3E,QAAM,qBAAqB,MAAM,UAAU,uBAAuB,SAAS,UAAU;AAErF,QAAM,WAAW,MAAM,WACnB,EAAE,GAAG,MAAM,UAAU,qBAAqB,mBAAmB,IAC7D,qBACE,EAAE,qBAAqB,mBAAmB,IAC1C;AAEN,SAAO;AAAA,IACL,GAAG;AAAA,IACH,UAAU,MAAM,YAAY,SAAS;AAAA,IACrC,OAAO,MAAM,SAAS,SAAS;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AACF;","names":["matter","matter"]}
@@ -2,7 +2,7 @@ import {
2
2
  renderSections,
3
3
  resolveAssetForProvider,
4
4
  withPromptInputSupport
5
- } from "./chunk-SHYKSLVR.js";
5
+ } from "./chunk-X73VG645.js";
6
6
 
7
7
  // src/providers/anthropic.ts
8
8
  var anthropicAdapter = withPromptInputSupport({
@@ -89,4 +89,4 @@ var anthropicAdapter = withPromptInputSupport({
89
89
  export {
90
90
  anthropicAdapter
91
91
  };
92
- //# sourceMappingURL=chunk-MYXDJMWV.js.map
92
+ //# sourceMappingURL=chunk-BBVVA27J.js.map
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  openaiAdapter
3
- } from "./chunk-MN3RQ7DZ.js";
3
+ } from "./chunk-UJU5XERR.js";
4
4
  import {
5
5
  withPromptInputSupport
6
- } from "./chunk-SHYKSLVR.js";
6
+ } from "./chunk-X73VG645.js";
7
7
 
8
8
  // src/providers/openrouter.ts
9
9
  var openrouterAdapter = withPromptInputSupport({
@@ -23,4 +23,4 @@ var openrouterAdapter = withPromptInputSupport({
23
23
  export {
24
24
  openrouterAdapter
25
25
  };
26
- //# sourceMappingURL=chunk-SOY2CEJM.js.map
26
+ //# sourceMappingURL=chunk-E2NXJLS6.js.map
@@ -2,7 +2,7 @@ import {
2
2
  renderSections,
3
3
  resolveAssetForProvider,
4
4
  withPromptInputSupport
5
- } from "./chunk-SHYKSLVR.js";
5
+ } from "./chunk-X73VG645.js";
6
6
 
7
7
  // src/providers/gemini.ts
8
8
  var geminiAdapter = withPromptInputSupport({
@@ -93,4 +93,4 @@ var geminiAdapter = withPromptInputSupport({
93
93
  export {
94
94
  geminiAdapter
95
95
  };
96
- //# sourceMappingURL=chunk-J32I6DSG.js.map
96
+ //# sourceMappingURL=chunk-E6NPZOJL.js.map
@@ -2,7 +2,7 @@ import {
2
2
  renderSections,
3
3
  resolveAssetForProvider,
4
4
  withPromptInputSupport
5
- } from "./chunk-SHYKSLVR.js";
5
+ } from "./chunk-X73VG645.js";
6
6
 
7
7
  // src/providers/openai.ts
8
8
  var openaiAdapter = withPromptInputSupport({
@@ -84,4 +84,4 @@ var openaiAdapter = withPromptInputSupport({
84
84
  export {
85
85
  openaiAdapter
86
86
  };
87
- //# sourceMappingURL=chunk-MN3RQ7DZ.js.map
87
+ //# sourceMappingURL=chunk-UJU5XERR.js.map