Repository navigation
feat(blocks): shared prompt and config blocks, with a sync command - #111
Open
devin-ai-integration[bot] wants to merge 10 commits into
Open
devin-ai-integration[bot] wants to merge 10 commits into
devin-ai-integration[bot] wants to merge 10 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>
Push writes the record, so it belongs with the rest of the engine's files. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…s it An org whose state is still in the layout from before state/ gets its record at resources/<org>/.vapi-blocks.json. A commit step written for that layout stages resources/, so the record is committed, and a promotion run with nothing to promote no longer plans a sync for every resource that uses a block. An org whose state is in state/<org>/ keeps state/<org>/blocks.json. npm run migrate moves the record with the state file and the pin. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
In the older layout a push that uses blocks rewrites resources/<org>/.vapi-blocks.json, and until that is committed git shows it as modified. The record is on the list migrate moves, so pull leaves it out of what it counts as a person's edits. This pins it with a pull in a fresh clone. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
sync-blocks worked out the repository's directory for itself, the one module that still did. It would have worked in the repository while every other module worked in a test's temporary directory. tests/base-dir.test.ts names the line. The blocks tests import the engine sandbox first, as every engine test file does. The test that runs sync-blocks --apply gives that one call 240 seconds. It starts four commands in a row and took 72 seconds on a slow machine beside the rest of the suite. cliRun takes the limit as a parameter and keeps 60 seconds for every other call. Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
…umbers (#99) * feat(validate): warn on undefined squad variables Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(validate): reject Liquid transfer destination numbers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: explain squad variable and transfer number validation Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: link NHS example across stacked PR branches Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
* feat(validate): warn on undefined squad variables Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs(examples): add shared NHS practice squads Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(examples): inline practice-specific transfer destinations Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(validate): reject Liquid transfer destination numbers Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: explain squad variable and transfer number validation Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: add shared practice quick reference Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * docs: link NHS example across stacked PR branches Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
|
I'll fix CI failures and address comments from users with write access that start with 'Devin'.
|
Contributor
Author
Devin Review🟢 Devin Review found nothing to fix · View findings |
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.
Replaces #94 (same commits, rebased onto main), opened as the Devin bot so it can be approved.
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 instate/<org>/blocks.json(committed, like the state file). While an org's state is in the older layout the record isresources/<org>/.vapi-blocks.json, which the commit step such a repository already has stages, andnpm run migratemoves it with the rest. 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.tsmigratemoves ittests/blocks.test.tstests/state-records-third-round.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.tssync-blockstakes the repository's directory from the one module every command usestests/base-dir.test.tsLeaving blocks off the list of records
migratemoves fails the record test. Makingsync-blockswork out its own directory again failstests/base-dir.test.ts.npm run buildpasses andnpm testpasses 714/714 in CI (676 on the branch below), andnpm run test:repositorypasses 9/9.Things to know
resources/<org>/, so a commit step written beforestate/existed commits it. Run end to end on a pipeline whose commit step stages the old state file through a helper script, with one assistant using a block: a promotion run with nothing to promote plans "no changes" and sends 12 requests and 0 writes, the same as a control whose step also stagesstate/. A block edit still reaches every org, andnpm run sync-blocksin a clean clone lists nothing afterwards.improvements.mdand not fixed here.--resolve=ours, as it does for every file it promotes, so asyncentry overwrites a dashboard edit in the destination.sync-blocks --applygives that one call 240 s where other tests give a command 60: it starts four commands in a row, and on a slow machine running the rest of the suite beside it the call took 72 s.Stack
Third of three. Sits on #96, which sits on #97 (
state/<org>/, moved into only bynpm run migrate). The blocks record follows whichever layout the org is in.Rebase fixes (last commit)
After rebasing onto #104, #106 and #107:
adopt-alias-files.tshashes alias files with blocks expanded (parseResourceDataFromFile(path, RESOURCES_DIR)), so adoption cleanup works for files that use blocks.blocksFilePullpassesresourceTypetocanonicalizeForHash, so an assistant'smetadata.gitops.folderPathdoesn't show up as dashboard drift on every pull.hashLocalResourceexpands blocks and strips assistantfolderPath.pushBlockingFindingskeeps--strictblockingvariable-undefinedin the push preflight.recanonicalizereferences removed.Tests are in
tests/blocks-integration.test.tsandtests/push-preflight.test.ts.