- Create a new folder in the
.prich/templates/, ex..prich/templates/mytemplate/ - Add a new yaml file in the
.prich/templates/mytemplate/folder, ex..prich/templates/mytemplate/mytemplate.yaml
Note: Use same name for the template folder name and the yaml template file
- Add the template contents into the yaml file
id- the lowercase id of the template using letters, numbers, hyphens, and underscores (without spaces), ex.my-template,my_template,mytemplatename- string name of the template, used just for the informationschema_version- version of the template schema to define support by the prich toolversion- version of the template, used for the information by user as neededauthor- author of the template, used for the informationdescription- description of the template, used for describing the template purposetags- list of lowercase tags used to mark template with some tags, could be used for searching latersteps- list of pipeline workflow steps that would be executed in order during the template executionusage_examples- list of strings to show examples of the template execution commands, used for information onlyvariables- list of variables available for the templatevenv-isolated/sharedused only whenpythonsteps are used in the template to specify if isolated venv should be created or to use one shared venv for all templates
Each step defines an action for the template pipeline workflow executed in order.
Step can have next key parameters:
name: name of the step (should be unique for each step in the template)output_variable: save output of the execution into a variable for the following usageoutput_file: save output of the execution into a file (default would bewritemode)output_file:name: save output of the execution into a filemode:writeorappendfilter:strip_prefix: strip prefix string from the step outputslice_start: slice step output from character numberslice_end: slice step output to character numberwhen: execute step only when true - simple jinja evaluation likeworking_vs_last_commit or (not working_vs_last_commit and not working_vs_remote and not committed_vs_remote and not remote_vs_local)ornot remote_vs_local, etc.validate: validate step execution (seestep validate)- plus additional keys based on the step type
Step type:
-
llm- send request to a llm provider and receive or print the response- name: "Ask to explain code" type: llm instructions: | Assistant is a senior engineer who provides detailed code explanation. input: | Explain what this{% if lang %} {{ lang }}{% endif %} code does: File: {{ file }} ```{% if lang %}{{ lang.lower() }}{% endif %} {{ file | include_file }} ```
-
python- execute python script from the templates folder using shared or isolated python venv- name: "Preprocess step" type: "python" call: "parse_csv.py" args: ["{{csv_file}}"] output_variable: "csv_summary"
-
command- execute shell command- name: "Get current branch" type: "command" call: "git" args: ["rev-parse", "--abbrev-ref", "HEAD"] output_variable: "current_branch"
-
render- render jinja template- name: "Render text" type: "render" template: "Check the {{ file }} file" output_variable: "check_file_text"
Step validate:
Could be a dict or list of validations
match: regex to match output (jinja vars could be used)not_match: regex not match output (jinja vars could be used)match_exit_code: (for execution commands) match exit code number (jinja vars could be used when supplied as string)not_match_exit_code: (for execution commands) not match exit code number (jinja vars could be used when supplied as string)on_fail:error/warn/skip/continuedefault iserrormessage: text message to show on failure
id: "explain-code"
name: "Explain Code"
schema_version: "1.0"
version: "1.0"
author: "prich"
description: Provide detailed code explanation
tags: ["code"]
steps:
- name: "Ask to explain code"
type: llm
instructions: |
Assistant is a senior engineer who provides detailed code explanation.
input: |
Explain what this{% if lang %} {{ lang }}{% endif %} code does:
File: {{ file }}
```{% if lang %}{{ lang.lower() }}{% endif %}
{{ file | include_file }}
```
usage_examples:
- "explain-code --file mycode.py"
- "explain-code --file ./mycode.py --lang python"
- "explain-code --file ./proj/mycode.js --lang javascript"
variables:
- name: file
description: File to review
cli_option: --file
required: true
type: str
- name: lang
description: Code language (ex. Python, JavaScript, Java)
cli_option: --lang
required: false
default: null
type: str