promptopskit 0.7.0 → 0.7.1

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 (2) hide show
  1. package/README.md +38 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -39,6 +39,7 @@ Core capabilities:
39
39
  - **Reusable composition** — share tone, policy, and safety instructions with `includes`, and apply folder-level standards with `defaults.md`.
40
40
  - **Environment and tier overrides** — keep dev/prod and plan-specific behavior in one prompt source with explicit, reviewable overrides.
41
41
  - **Sidecar tests** — run deterministic prompt checks in local development and CI without calling a model.
42
+ - **Prompt compression** — optionally compress rendered prompt templates with TheTokenCompany before provider caching and request generation.
42
43
 
43
44
  ## Install
44
45
 
@@ -149,6 +150,7 @@ Supported values for `warnings.contextSize` are `auto`, `off`, `result-only`, `c
149
150
  - **Folder defaults** — `defaults.md` inheritance for shared provider, model, options, metadata, and system instructions
150
151
  - **Overrides** — Environment and tier-based overrides (base → env → tier → runtime)
151
152
  - **6 provider adapters** — OpenAI (Chat), OpenAI (Responses), Anthropic, Gemini, OpenRouter, LLMAsAService
153
+ - **Prompt compression** — optional `compression.thetokencompany` front matter calls TheTokenCompany directly before provider cache fields are applied
152
154
  - **Provider-aware input caching controls** — optional `cache` front matter maps to OpenAI prompt cache hints, Anthropic `cache_control`, and Gemini `cachedContent`
153
155
  - **Vendor escape hatch** — optional `raw.<provider>` blocks shallow-merge unmodeled request-body fields into the final provider payload
154
156
  - **Validation** — Zod schema validation, Levenshtein-based "did you mean?" for typos, variable usage checks
@@ -259,9 +261,38 @@ const request = openaiAdapter.render(prompt, {
259
261
 
260
262
  In browser or client-side code, keep provider credentials on the server. Use the rendered request body with your own server endpoint, server action, or edge function rather than calling a provider directly from the client.
261
263
 
262
- ### Provider-specific fields and raw passthrough
264
+ ### Prompt compression, provider-specific fields, and raw passthrough
263
265
 
264
- Use normalized fields first (`sampling`, `response`, `cache`, `tools`) so prompts stay portable. `response.schema` is the neutral JSON Schema path; adapters emit it as OpenAI/OpenRouter/LLMAsAService `response_format`, OpenAI Responses `text.format`, Anthropic `output_config.format`, and Gemini `generationConfig.responseJsonSchema`. You can also provide `response.schema_ref` to load schema from a prompt-relative `.json` file or `.js/.mjs/.cjs` zod module (mutually exclusive with `response.schema`).
266
+ Use normalized fields first (`sampling`, `response`, `compression`, `cache`, `tools`) so prompts stay portable. `response.schema` is the neutral JSON Schema path; adapters emit it as OpenAI/OpenRouter/LLMAsAService `response_format`, OpenAI Responses `text.format`, Anthropic `output_config.format`, and Gemini `generationConfig.responseJsonSchema`. You can also provide `response.schema_ref` to load schema from a prompt-relative `.json` file or `.js/.mjs/.cjs` zod module (mutually exclusive with `response.schema`).
267
+
268
+ Use `compression.thetokencompany` when a prompt template should be compressed before provider request generation and cache controls:
269
+
270
+ ```yaml
271
+ compression:
272
+ thetokencompany:
273
+ enabled: true
274
+ model: bear-2
275
+ aggressiveness: 0.2
276
+ cache:
277
+ openai:
278
+ prompt_cache_key: support-reply-v1
279
+ retention: 24h
280
+ ```
281
+
282
+ At render time, pass the caller-owned API key. PromptOpsKit calls `POST https://api.thetokencompany.com/v1/compress` directly with `fetch`; no TheTokenCompany SDK is required.
283
+
284
+ ```typescript
285
+ const result = await kit.renderPrompt({
286
+ path: 'support/reply',
287
+ provider: 'openai',
288
+ variables,
289
+ theTokenCompany: {
290
+ apiKey: process.env.THETOKENCOMPANY_API_KEY,
291
+ },
292
+ });
293
+ ```
294
+
295
+ Compression applies only to the rendered `# Prompt template`. System instructions and history are left unchanged, and provider cache fields are applied to the compressed prompt text.
265
296
 
266
297
  Use `provider_options` when PromptOpsKit has a known provider-specific mapping, such as Anthropic `top_k`, Gemini's native `response_schema`, OpenRouter routing fields, or LLMAsAService gateway routing/customer metadata.
267
298
 
@@ -340,29 +371,6 @@ If you need a different layout, keep passing `sourceDir` and `compiledDir` expli
340
371
 
341
372
  `renderPrompt()` and `validatePrompt()` use the same source-versus-compiled resolution rules as `kit.renderPrompt()`. The existing synchronous `render()` and `validate()` methods still work for already-resolved compiled or inline assets.
342
373
 
343
- ## How It Compares to GitHub Models
344
-
345
- GitHub Models is a good place to prototype prompts, compare models, and run evaluations inside GitHub.
346
-
347
- PromptOpsKit is focused on the application runtime layer. Use it when prompt behavior needs to live in your repo with validated inputs, reusable composition, environment and tier overrides, sidecar tests, compiled artifacts, and provider-ready request bodies.
348
-
349
- Use GitHub Models when you want:
350
-
351
- - A GitHub-hosted prompt playground
352
- - Side-by-side model comparison
353
- - Evaluation workflows inside GitHub
354
- - `.prompt.yml` files for prompt experiments and evals
355
-
356
- Use PromptOpsKit when you want:
357
-
358
- - Runtime-focused Markdown prompt assets
359
- - Production input hardening and validation
360
- - Reusable `includes` and folder-level `defaults.md`
361
- - Environment-specific model and parameter overrides
362
- - Deterministic local and CI testing without model calls
363
- - Provider-specific request bodies for your own runtime code
364
- - Control over SDKs, auth, retries, routing, observability, and billing
365
-
366
374
  ## Optional UsageTap Tracking
367
375
 
368
376
  PromptOpsKit can also help you track provider calls with UsageTap.com while keeping the core render API transport-light.
@@ -496,14 +504,14 @@ Handle support requests carefully.
496
504
 
497
505
  Define a `defaults.md` file in `prompts/` (and optional subfolders) to provide inherited defaults for prompts:
498
506
 
499
- - Shared `provider`, `model`, `fallback_models`, `reasoning`, `sampling`, `response`, `cache`, `provider_options`, `raw`, `tools`, `mcp`, `context`, `includes`, `environments`, and `tiers` in front matter
507
+ - Shared `provider`, `model`, `fallback_models`, `reasoning`, `sampling`, `response`, `compression`, `cache`, `provider_options`, `raw`, `tools`, `mcp`, `context`, `includes`, `environments`, and `tiers` in front matter
500
508
  - Shared `metadata` defaults in front matter
501
509
  - Shared `# System instructions` in body
502
510
  - Nearest subfolder `defaults.md` overrides parent defaults
503
511
  - Prompt-local values always win over defaults
504
512
  - Included files (`includes`) are not affected by folder defaults
505
513
 
506
- Scalars and arrays are replaced by nearer values. Object blocks are shallow-merged, including provider sub-blocks such as `provider_options.llmasaservice` and `cache.openai`.
514
+ Scalars and arrays are replaced by nearer values. Object blocks are shallow-merged, including provider sub-blocks such as `provider_options.llmasaservice`, `compression.thetokencompany`, and `cache.openai`.
507
515
 
508
516
  > `promptopskit init` scaffolds a starter `defaults.md` in the prompts root.
509
517
 
@@ -618,7 +626,7 @@ Creates a `PromptOpsKit` instance.
618
626
 
619
627
  ### `kit.renderPrompt(options)`
620
628
 
621
- Renders a prompt for a specific provider. Returns `{ resolved, request?, returnMessage?, warnings }`.
629
+ Renders a prompt for a specific provider. Returns `{ resolved, request?, returnMessage?, compression?, warnings }`.
622
630
 
623
631
  | Option | Type | Description |
624
632
  |--------|------|-------------|
@@ -634,6 +642,7 @@ Renders a prompt for a specific provider. Returns `{ resolved, request?, returnM
634
642
  | `toolRegistry` | `Record<string, unknown>` | Tool definitions for resolving string tool references |
635
643
  | `strict` | `boolean` | Fail on missing variables except object-form inputs marked `optional: true` |
636
644
  | `openaiResponses` | `object` | Optional Responses API extras (`previous_response_id`, `conversation`, `instructions`, `parallel_tool_calls`, `max_tool_calls`, `store`, `metadata`, `include`, `background`) |
645
+ | `theTokenCompany` | `object` | Optional compression settings (`apiKey`, `baseURL`, `fetch`) used when `compression.thetokencompany.enabled: true` |
637
646
 
638
647
  ### `kit.loadPrompt(path)` / `kit.resolvePrompt(path, options)` / `kit.validatePrompt(path)`
639
648
 
@@ -659,6 +668,7 @@ Prompt files use YAML front matter with these fields:
659
668
  | `reasoning` | `object` | `{ effort, budget_tokens }` |
660
669
  | `sampling` | `object` | `{ temperature, top_p, frequency_penalty, presence_penalty, stop, max_output_tokens }` |
661
670
  | `response` | `object` | `{ format, stream, schema, schema_ref, schema_name, schema_description, schema_strict }` |
671
+ | `compression` | `object` | Prompt-template compression controls (`thetokencompany`) |
662
672
  | `cache` | `object` | Provider-specific cache controls (`openai`, `anthropic`, `gemini`/`google`) |
663
673
  | `tools` | `array` | Tool references (string names or inline definitions) |
664
674
  | `provider_options` | `object` | Provider-specific non-portable options (`anthropic`, `gemini`, `openrouter`, `llmasaservice`) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptopskit",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Manage prompts, system instructions, tools, and model settings as code",
5
5
  "type": "module",
6
6
  "bin": {