Collect missing command variables#24
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a variables field to the structured command/answer schema, enabling CLAI to identify missing user-provided values via {{variable_name}} placeholders, prompt users for those values before execution, shell-escape them, and persist the resolved command in history.
Changes:
- Extended the JSON schema, system prompts, template messages, and default queries to include the
variablesarray field alongside existingcmd,info, andriskfields. - Added three new functions (
normalize_variables,contains_unresolved_placeholders,resolve_command_variables) to validate, collect, and substitute missing variable values, with rejection of commands containing unresolved placeholders. - Added four new test cases covering variable prompting, skip on fully-specified commands, shell-escaping of collected values, and rejection of unresolved placeholders, plus schema assertions for all three providers.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| clai.sh | Adds variables to schema, prompts, templates; adds normalize/resolve/check functions; integrates variable collection into main loop |
| test/smoke.bats | Adds schema assertions for variables field across providers; adds four new test cases for variable collection behavior |
| README.md | Documents the new variables field and variable collection flow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
variablesfield to the command/answer schema so the model can mark missing user-provided valuesVerification