You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Chat With Code (CWC) introduces the flexibility of custom templates to enhance the conversational coding experience.
116
+
Templates are pre-defined system messages and prompts that tailor interactions with your codebase.
117
+
A template envelops default prompts, system messages and variables, allowing for a personalized and context-aware dialogue.
118
+
119
+
### Template Schema
120
+
121
+
Each template follows a specific YAML schema defined in`templates.yaml`.
122
+
Here's an outline of the schema for a CWC template:
123
+
124
+
```yaml
125
+
templates:
126
+
- name: template_name
127
+
description: A brief description of the template's purpose
128
+
defaultPrompt: An optional default prompt to use if none is provided
129
+
systemMessage: |
130
+
The system message that details the instructions and context for the chat session.
131
+
This message supports placeholders for {{ .Context }} which is the gathered file context,
132
+
as well as custom variables `{{ .Variables.variableName }}` fed into the session with cli args.
133
+
variables:
134
+
- name: variableName
135
+
description: Description of the variable
136
+
defaultValue: Default value for the variable
137
+
```
138
+
139
+
### Placement
140
+
141
+
Templates may be placed within the repository or under the user's configuration directory, adhering to the XDG Base Directory Specification:
142
+
143
+
1. **In the Repository Directory**: To include the templates specifically for a repository, place a `templates.yaml` inside the `.cwc` directory at the root of your repository:
144
+
145
+
```
146
+
.
147
+
├── .cwc
148
+
│ └── templates.yaml
149
+
...
150
+
```
151
+
152
+
2. **In the User XDG CWC Config Directory**: For global user templates, place the `templates.yaml` within the XDG configuration directory for CWC, which is typically `~/.config/cwc/` on Unix-like systems:
153
+
154
+
```
155
+
$XDG_CONFIG_HOME/cwc/templates.yaml
156
+
```
157
+
158
+
If `$XDG_CONFIG_HOME` is not set, it defaults to `~/.config`.
159
+
160
+
### Example Usage
161
+
162
+
You can specify a template using the `-t` flag and pass variables with the `-v` flag in the terminal. These flags allow you to customize the chat session based on the selected template and provided variables.
163
+
164
+
#### Selecting a Template
165
+
166
+
To begin a chat session using a specific template, use the `-t` flag followed by the template name:
167
+
168
+
```sh
169
+
cwc -t my_template
170
+
```
171
+
172
+
This command will start a conversation with the system message and default prompt defined in the template named `my_template`.
173
+
174
+
#### Passing Variables to a Template
175
+
176
+
You can pass variables to a template using the `-v` flag followed by a key-value pair:
0 commit comments