Skip to content

Commit c3b1812

Browse files
ENHANCEMENT: Cascading of defaults adds model & vendor fields
1 parent 30f6bd9 commit c3b1812

18 files changed

Lines changed: 152 additions & 21 deletions

File tree

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Provider adapters for OpenAI, Anthropic, Gemini, and OpenRouter produce a ready-
1515
- **Centralized, not scattered** — each prompt is a single Markdown file that captures prompt text, model config, tool bindings, and context rules together.
1616
- **Operational, not just templated** — model name, temperature, reasoning effort, tools, and response format are declared alongside the prompt they govern.
1717
- **Reusable, not duplicated**`includes` lets you define shared tone, policy, or safety instructions once and compose them into any prompt.
18-
- **Layered defaults, not repetition**`defaults.md` in any folder sets shared `metadata` and `# System instructions` for that subtree, with nearest-folder override behavior.
18+
- **Layered defaults, not repetition**`defaults.md` in any folder sets shared `provider`, `model`, `metadata`, and `# System instructions` for that subtree, with nearest-folder override behavior.
1919
- **Release-aware, not ad hoc** — environment and tier overrides swap models and parameters without forking prompt files.
2020
- **Provider-portable** — write once, render for OpenAI, Anthropic, Gemini, or OpenRouter with correct body shapes.
2121
- **Validate early** — Zod schema validation, Levenshtein-based "did you mean?" suggestions for typos, and variable usage checks catch mistakes before runtime.
@@ -40,6 +40,7 @@ This creates:
4040

4141
```
4242
prompts/
43+
├── defaults.md # Folder-level defaults (provider, model, metadata, system instructions)
4344
├── hello.md # Sample prompt with variables
4445
├── hello.test.yaml # Test sidecar with sample inputs
4546
└── shared/
@@ -107,7 +108,7 @@ const response = await fetch('https://api.openai.com/v1/chat/completions', {
107108
- **Prompts as Markdown** — YAML front matter for settings, H1 headings for sections (`# System instructions`, `# Prompt template`, `# Notes`)
108109
- **Variable interpolation**`{{ variable }}` syntax with strict and permissive modes
109110
- **Composition**`includes` to share system instructions across prompts, with circular detection
110-
- **Folder defaults**`defaults.md` inheritance for shared metadata and system instructions
111+
- **Folder defaults**`defaults.md` inheritance for shared provider, model, metadata, and system instructions
111112
- **Overrides** — Environment and tier-based overrides (base → env → tier → runtime)
112113
- **4 provider adapters** — OpenAI, Anthropic, Gemini, OpenRouter — body-only output
113114
- **Validation** — Zod schema validation, Levenshtein-based "did you mean?" for typos, variable usage checks
@@ -221,6 +222,7 @@ Handle support requests carefully.
221222

222223
Define a `defaults.md` file in `prompts/` (and optional subfolders) to provide inherited defaults for prompts:
223224

225+
- Shared `provider` and `model` in front matter
224226
- Shared `metadata` defaults in front matter
225227
- Shared `# System instructions` in body
226228
- Nearest subfolder `defaults.md` overrides parent defaults

docs/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Creates:
2222

2323
```
2424
prompts/
25-
├── defaults.md # Folder-level defaults (metadata + system instructions)
25+
├── defaults.md # Folder-level defaults (provider, model, metadata, system instructions)
2626
├── hello.md # Sample prompt with variables
2727
├── hello.test.yaml # Test sidecar with sample inputs
2828
└── shared/
@@ -50,7 +50,7 @@ Checks:
5050
- Unknown front matter keys with Levenshtein-based "did you mean?" suggestions
5151
- Variable usage — used but undeclared, declared but unused
5252
- Include resolution — missing files, circular includes
53-
- Folder defaults inheritance from `defaults.md` (metadata + system instructions)
53+
- Folder defaults inheritance from `defaults.md` (provider, model, metadata, system instructions)
5454

5555
Output per file:
5656
```

docs/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This creates:
1818

1919
```
2020
prompts/
21-
├── defaults.md # Folder-level defaults (metadata + system instructions)
21+
├── defaults.md # Folder-level defaults (provider, model, metadata, system instructions)
2222
├── hello.md # Sample prompt with variables
2323
├── hello.test.yaml # Test sidecar with sample inputs
2424
└── shared/

docs/prompt-format.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,18 @@ You can define shared defaults for an entire prompt tree by adding a `defaults.m
5252

5353
Supported default fields:
5454

55-
- `metadata` (front matter)
56-
- `# System instructions` (body section)
55+
- `provider` (front matter) — default provider for the folder
56+
- `model` (front matter) — default model for the folder
57+
- `metadata` (front matter) — merged with prompt-local metadata
58+
- `# System instructions` (body section) — used when the prompt has none
59+
60+
This lets you configure app-wide settings like `provider` and `model` in a single place. Individual prompts only need to declare what's unique to them.
5761

5862
Example:
5963

6064
```text
6165
prompts/
62-
├── defaults.md # global metadata + system instructions
66+
├── defaults.md # global settings, metadata + system instructions
6367
└── support/
6468
├── defaults.md # overrides for support/*
6569
└── reply.md # inherits from support/defaults.md
@@ -69,6 +73,8 @@ prompts/
6973

7074
```markdown
7175
---
76+
provider: openai
77+
model: gpt-5.4
7278
metadata:
7379
owner: platform
7480
review_required: true
@@ -93,6 +99,8 @@ Use support tone and escalation policy.
9399
```
94100

95101
`prompts/support/reply.md` (no local `metadata.owner` and no local system section) will use:
102+
- `provider: openai` (inherited from root defaults)
103+
- `model: gpt-5.4` (inherited from root defaults)
96104
- `metadata.owner: support` (nearest override)
97105
- `metadata.review_required: true` (inherited from parent defaults)
98106
- system instructions from `support/defaults.md`

docs/schema.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Prompt files use YAML front matter. This page documents every supported field.
2929

3030
| Field | Type | Description |
3131
|-------|------|-------------|
32+
| `provider` | `enum` | Default provider (`openai`, `anthropic`, `google`, `gemini`, `openrouter`, `any`) |
33+
| `model` | `string` | Default model identifier |
3234
| `metadata` | `object` | Same as the prompt `metadata` block (`owner`, `tags`, `review_required`, `stable`) |
3335
| `# System instructions` | section | System instructions inherited by prompts in this folder |
3436

fixtures/compiled/.gitkeep

Lines changed: 0 additions & 1 deletion
This file was deleted.

fixtures/compiled/hello.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"id": "hello",
3+
"schema_version": 1,
4+
"context": {
5+
"inputs": [
6+
"name",
7+
"app_context"
8+
]
9+
},
10+
"sections": {
11+
"system_instructions": "You are a friendly assistant helping in {{ app_context }}.",
12+
"prompt_template": "Say hello to {{ name }}."
13+
},
14+
"source": {
15+
"file_path": "fixtures\\prompts\\hello.md"
16+
},
17+
"provider": "openai",
18+
"model": "gpt-5.4",
19+
"metadata": {
20+
"owner": "platform-team",
21+
"review_required": true
22+
}
23+
}

fixtures/compiled/shared/tone.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"id": "shared.tone",
3+
"schema_version": 1,
4+
"sections": {
5+
"system_instructions": "Always be polite, professional, and concise. Avoid jargon unless the user uses it first."
6+
},
7+
"source": {
8+
"file_path": "fixtures\\prompts\\shared\\tone.md"
9+
},
10+
"provider": "openai",
11+
"model": "gpt-5.4",
12+
"metadata": {
13+
"owner": "platform-team",
14+
"review_required": true
15+
}
16+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"id": "support.reply",
3+
"schema_version": 1,
4+
"provider": "openai",
5+
"model": "gpt-5.4",
6+
"fallback_models": [
7+
"gpt-5.4-mini"
8+
],
9+
"reasoning": {
10+
"effort": "medium"
11+
},
12+
"sampling": {
13+
"temperature": 0.7,
14+
"max_output_tokens": 2048
15+
},
16+
"response": {
17+
"format": "text"
18+
},
19+
"tools": [
20+
"get_account_status"
21+
],
22+
"context": {
23+
"inputs": [
24+
"user_message",
25+
"account_summary",
26+
"app_context"
27+
],
28+
"history": {
29+
"max_items": 8
30+
}
31+
},
32+
"environments": {
33+
"dev": {
34+
"model": "gpt-5.4-mini",
35+
"reasoning": {
36+
"effort": "low"
37+
}
38+
},
39+
"prod": {
40+
"model": "gpt-5.4"
41+
}
42+
},
43+
"tiers": {
44+
"free": {
45+
"model": "gpt-5.4-mini"
46+
},
47+
"pro": {
48+
"model": "gpt-5.4"
49+
}
50+
},
51+
"metadata": {
52+
"owner": "support-platform",
53+
"review_required": true,
54+
"stable": true
55+
},
56+
"sections": {
57+
"system_instructions": "Always be polite, professional, and concise. Avoid jargon unless the user uses it first.\n\nYou are a careful support assistant. Follow refund policy exactly.\nCurrent app context: {{ app_context }}.",
58+
"prompt_template": "Customer message:\n{{ user_message }}\n\nAccount summary:\n{{ account_summary }}"
59+
},
60+
"source": {
61+
"file_path": "fixtures\\prompts\\support\\reply.md"
62+
}
63+
}

fixtures/prompts/defaults.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
---
2+
provider: openai
3+
model: gpt-5.4
24
metadata:
35
owner: platform-team
46
review_required: true

0 commit comments

Comments
 (0)