Repository navigation
feat(blocks): shared prompt and config blocks, with a sync command - #94
Draft
dhruva-vapi wants to merge 3 commits into
Draft
dhruva-vapi wants to merge 3 commits into
dhruva-vapi wants to merge 3 commits into
Conversation
A system prompt can include a Markdown block with a line that says only "@include <name>", and any mapping can include a YAML block with a "$include" key, where the file's own keys win. Blocks are looked up in resources/<org>/templates/ first, then in templates/ at the repository root, so an org can replace or extend a shared block. The loader expands them, so validate, push, PR checks and drift hashes all see the finished resource. Liquid inside a block is passed through untouched. Pull never writes a file that uses blocks. It used to rewrite a file whenever the dashboard matched it, was ahead of it, or under --force and --resolve=theirs, and each of those would replace a marker with a copy of the block. It now leaves the file as written and saves the dashboard version beside it when the two differ. validate warns about YAML merge keys and Liquid include/render/layout tags, which the engine and Vapi drop silently. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
A block edit changes what many resources send to Vapi without changing their files, so nothing in git said which resources still ran old text. Push now records the block content each resource went up with in resources/<org>/.vapi-blocks.json. "npm run sync-blocks" lists, across every org, the resources whose blocks changed since they were last pushed, and with --apply deploys them through apply, so the drift check still refuses a resource that was edited in the dashboard. Promotion plans those resources as "sync" entries for the destination org, the promotion workflow runs on templates/**, and a shared block edit selects every PR check. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Adds docs/guides/blocks.md and examples/blocks/, two clinics that share a red-flags prompt block and a voice config block, one with its own version of the block. The examples test now copies an example's templates/ folder, so the example is validated and the guide's snippets are checked against its files. Also corrects two statements the feature depends on: YAML merge keys are not processed by the engine, and an undefined Liquid variable is left in the prompt as written, not replaced with an empty string. Logs the pull behaviour this replaces as improvements entry 39, and a drift-check gap found while testing, in orgs with no credentials, as entry 40. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Value
V.A.L.U.E. tier: small. One new engine feature with its guard rails, tests, an example and a guide.
<<) aren't processed at all and get sent to the API as a field, and Liquid{% include %}renders as nothing on a call.How it works
@include <name>in a system prompt is replaced bytemplates/blocks/<name>.md. It works in an assistant's Markdown body, a system message in a.ymlassistant, and system messages in squad overrides. Nothing inside a block is interpreted, so{{variables}}and other Liquid reach Vapi as written.$include: <name>key in any mapping pulls intemplates/config/<name>.yml. The file's own keys win: mappings merge key by key, and anything else the file sets, lists included, replaces the block's value whole. Two blocks in one list that set the same field differently are refused, as is$includebeside a merge key.resources/<org>/templates/first, thentemplates/. An org block that includes its own name gets the shared one, so it can add to it instead of copying it. A missing block or a loop is an error, never empty text.--forceand under--resolve=theirs. Each of those would replace a marker with a copy of the block. It now leaves such a file as written and saves the dashboard version beside it as a.bkp.copy when the two differ, without moving the drift baseline, so the edit is still flagged at the next pull and push.npm run sync-blocks. A block edit changes many resources and none of their files. Push now records the block content each resource went up with inresources/<org>/.vapi-blocks.json(committed, like the state file). The command lists, across every org, the resources whose blocks changed since their last push.--applyrunsapplyper org for those files, so a resource edited in the dashboard is still refused by the drift check, and the command exits 1 naming what was left behind.sync, the promotion workflow runs ontemplates/**, and a shared block edit selects every PR check.include/render/layouttags, since both are dropped silently.Guide:
docs/guides/blocks.md. Example:examples/blocks/.Verification
Nothing here was run against a live org. Every behaviour is covered by tests against fixtures or a local stub API.
tests/blocks.test.tstests/blocks.test.tstests/blocks.test.tstests/blocks.test.ts--force,--resolve=theirstests/blocks-pull.test.ts(all five fail with the guard removed)tests/blocks-sync.test.ts--applygoes through apply → pull → push: the untouched resource is PATCHed, the dashboard-edited one is refused and stays listedtests/blocks-sync.test.tssyncand deploys ittests/blocks-promotion.test.tstests/blocks-promotion.test.tsvalidateand the guide's snippets match its filestests/examples.test.tsnpm run buildpasses andnpm testpasses 620/620 (584 before).Things to know
improvements.mdand not fixed here.--resolve=ours, as it does for every file it promotes, so asyncentry overwrites a dashboard edit in the destination.