Skip to content

Commit 26a27e3

Browse files
Docs review: align provider examples with app_context runtime variables
1 parent 917f6bc commit 26a27e3

12 files changed

Lines changed: 157 additions & 10 deletions

File tree

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ sampling:
5959
context:
6060
inputs:
6161
- user_message
62+
- app_context
6263
includes:
6364
- ./shared/tone.md
6465
---
6566

6667
# System instructions
6768

68-
You are a helpful support assistant.
69+
You are a helpful support assistant working in {{ app_context }}.
6970

7071
# Prompt template
7172

@@ -82,7 +83,10 @@ const kit = createPromptOpsKit({ sourceDir: './prompts' });
8283
const result = await kit.renderPrompt({
8384
path: 'support/reply',
8485
provider: 'openai',
85-
variables: { user_message: 'How do I reset my password?' },
86+
variables: {
87+
user_message: 'How do I reset my password?',
88+
app_context: 'Account settings page',
89+
},
8690
});
8791

8892
// result.request.body is ready for fetch()
@@ -116,19 +120,35 @@ Each adapter produces a `{ body, provider, model }` object shaped for the target
116120
// OpenAI
117121
import { createPromptOpsKit } from 'promptopskit';
118122
const kit = createPromptOpsKit({ sourceDir: './prompts' });
119-
const { request } = await kit.renderPrompt({ path: 'hello', provider: 'openai', variables: { name: 'World' } });
123+
const { request } = await kit.renderPrompt({
124+
path: 'hello',
125+
provider: 'openai',
126+
variables: { name: 'World', app_context: 'Welcome screen' },
127+
});
120128
// request.body → { model, messages, temperature, reasoning_effort, ... }
121129

122130
// Anthropic — system is a top-level field, max_tokens defaults to 4096
123-
const { request } = await kit.renderPrompt({ path: 'hello', provider: 'anthropic', variables: { name: 'World' } });
131+
const { request } = await kit.renderPrompt({
132+
path: 'hello',
133+
provider: 'anthropic',
134+
variables: { name: 'World', app_context: 'Welcome screen' },
135+
});
124136
// request.body → { model, messages, system, max_tokens, ... }
125137

126138
// Gemini — contents/systemInstruction/generationConfig structure
127-
const { request } = await kit.renderPrompt({ path: 'hello', provider: 'gemini', variables: { name: 'World' } });
139+
const { request } = await kit.renderPrompt({
140+
path: 'hello',
141+
provider: 'gemini',
142+
variables: { name: 'World', app_context: 'Welcome screen' },
143+
});
128144
// request.body → { contents, systemInstruction, generationConfig, ... }
129145

130146
// OpenRouter — same shape as OpenAI, different provider label
131-
const { request } = await kit.renderPrompt({ path: 'hello', provider: 'openrouter', variables: { name: 'World' } });
147+
const { request } = await kit.renderPrompt({
148+
path: 'hello',
149+
provider: 'openrouter',
150+
variables: { name: 'World', app_context: 'Welcome screen' },
151+
});
132152
```
133153

134154
Provider adapters are also available as direct imports:

docs/cli.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ promptopskit render <file> [--env <name>] [--tier <name>] [--vars <file>] [--jso
108108

109109
If no `--vars` file is provided, the command auto-loads a `.test.yaml` sidecar file (same name as the prompt, with `.test.yaml` extension) and uses the first test case's variables.
110110

111+
`--vars` keys map directly to placeholder names in `{{ name }}` syntax.
112+
111113
Readable output:
112114
```
113115
── support.reply (openai, gpt-5.4) ────────────────────────

docs/composition.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
`includes` lets you define shared system instructions once and reuse them across prompts. Included instructions are prepended before local system instructions.
44

5+
Included files can also contain runtime placeholders (`{{ variable }}`), so shared guidance can consume app-specific context passed at render time.
6+
57
## How it works
68

79
1. List paths in the `includes` front matter field (relative to the prompt file).

docs/getting-started.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ sampling:
4343
context:
4444
inputs:
4545
- user_message
46+
- app_context
4647
includes:
4748
- ./shared/tone.md
4849
---
4950

5051
# System instructions
5152

52-
You are a helpful support assistant.
53+
You are a helpful support assistant helping inside {{ app_context }}.
5354

5455
# Prompt template
5556

@@ -68,7 +69,10 @@ const kit = createPromptOpsKit({ sourceDir: './prompts' });
6869
const result = await kit.renderPrompt({
6970
path: 'support/reply',
7071
provider: 'openai',
71-
variables: { user_message: 'How do I reset my password?' },
72+
variables: {
73+
user_message: 'How do I reset my password?',
74+
app_context: 'Billing settings page',
75+
},
7276
});
7377

7478
// result.request.body is ready for fetch()

docs/prompt-format.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Use `{{ mustache }}` syntax for variable interpolation:
6565
# Prompt template
6666

6767
Hello {{ name }}, welcome to {{ company }}.
68+
Runtime context: {{ app_context }}.
6869
```
6970

7071
Variable names must match `[a-zA-Z_][a-zA-Z0-9_]*`.
@@ -95,6 +96,7 @@ context:
9596
inputs:
9697
- name
9798
- company
99+
- app_context
98100
```
99101
100102
The validator warns about:

docs/providers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const kit = createPromptOpsKit({ sourceDir: './prompts' });
2121
const { request } = await kit.renderPrompt({
2222
path: 'hello',
2323
provider: 'openai',
24-
variables: { name: 'World' },
24+
variables: { name: 'World', app_context: 'Welcome screen' },
2525
});
2626

2727
// request.body is ready for fetch()

fixtures/prompts/hello.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ model: gpt-5.4
66
context:
77
inputs:
88
- name
9+
- app_context
910
---
1011

1112
# System instructions
1213

13-
You are a friendly assistant.
14+
You are a friendly assistant helping in {{ app_context }}.
1415

1516
# Prompt template
1617

fixtures/prompts/hello.test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ cases:
22
- name: basic
33
variables:
44
name: "World"
5+
app_context: "Onboarding flow"
56
- name: named
67
variables:
78
name: "Alice"
9+
app_context: "Dashboard"

fixtures/prompts/support/reply.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ context:
1616
inputs:
1717
- user_message
1818
- account_summary
19+
- app_context
1920
history:
2021
max_items: 8
2122
tools:
@@ -42,6 +43,7 @@ metadata:
4243
# System instructions
4344

4445
You are a careful support assistant. Follow refund policy exactly.
46+
Current app context: {{ app_context }}.
4547

4648
# Prompt template
4749

src/cli/commands/init.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ model: gpt-5.4
1919
context:
2020
inputs:
2121
- name
22+
- app_context
2223
includes:
2324
- ./shared/tone.md
2425
---
2526
2627
# System instructions
2728
2829
You are a friendly assistant. Be helpful and concise.
30+
Current app context: {{ app_context }}.
2931
3032
# Prompt template
3133
@@ -46,9 +48,11 @@ const TEST_SIDECAR = `cases:
4648
- name: basic-greeting
4749
variables:
4850
name: "World"
51+
app_context: "Welcome screen"
4952
- name: named-greeting
5053
variables:
5154
name: "Alice"
55+
app_context: "Settings page"
5256
`;
5357

5458
export async function init(args: string[]): Promise<void> {

0 commit comments

Comments
 (0)