crewx 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +197 -9
- package/README.md +120 -28
- package/crewx.yaml +1273 -0
- package/dist/agent.types.d.ts +92 -0
- package/dist/agent.types.js +16 -0
- package/dist/agent.types.js.map +1 -0
- package/dist/ai-provider.service.d.ts +25 -0
- package/dist/ai-provider.service.js +138 -0
- package/dist/ai-provider.service.js.map +1 -0
- package/dist/ai.service.d.ts +50 -0
- package/dist/ai.service.js +625 -0
- package/dist/ai.service.js.map +1 -0
- package/dist/app.module.d.ts +5 -0
- package/dist/app.module.js +88 -0
- package/dist/app.module.js.map +1 -0
- package/dist/cli/chat.handler.d.ts +19 -0
- package/dist/cli/chat.handler.js +429 -0
- package/dist/cli/chat.handler.js.map +1 -0
- package/dist/cli/cli.handler.d.ts +4 -0
- package/dist/cli/cli.handler.js +93 -0
- package/dist/cli/cli.handler.js.map +1 -0
- package/dist/cli/doctor.handler.d.ts +36 -0
- package/dist/cli/doctor.handler.js +382 -0
- package/dist/cli/doctor.handler.js.map +1 -0
- package/dist/cli/execute.handler.d.ts +2 -0
- package/dist/cli/execute.handler.js +269 -0
- package/dist/cli/execute.handler.js.map +1 -0
- package/dist/cli/help.handler.d.ts +2 -0
- package/dist/cli/help.handler.js +10 -0
- package/dist/cli/help.handler.js.map +1 -0
- package/dist/cli/init.handler.d.ts +25 -0
- package/dist/cli/init.handler.js +355 -0
- package/dist/cli/init.handler.js.map +1 -0
- package/dist/cli/query.handler.d.ts +2 -0
- package/dist/cli/query.handler.js +351 -0
- package/dist/cli/query.handler.js.map +1 -0
- package/dist/cli/templates.handler.d.ts +2 -0
- package/dist/cli/templates.handler.js +100 -0
- package/dist/cli/templates.handler.js.map +1 -0
- package/dist/cli-options.d.ts +22 -0
- package/dist/cli-options.js +195 -0
- package/dist/cli-options.js.map +1 -0
- package/dist/config/timeout.config.d.ts +14 -0
- package/dist/config/timeout.config.js +34 -0
- package/dist/config/timeout.config.js.map +1 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/conversation/base-conversation-history.provider.d.ts +12 -0
- package/dist/conversation/base-conversation-history.provider.js +45 -0
- package/dist/conversation/base-conversation-history.provider.js.map +1 -0
- package/dist/conversation/cli-conversation-history.provider.d.ts +16 -0
- package/dist/conversation/cli-conversation-history.provider.js +104 -0
- package/dist/conversation/cli-conversation-history.provider.js.map +1 -0
- package/dist/conversation/conversation-config.d.ts +9 -0
- package/dist/conversation/conversation-config.js +25 -0
- package/dist/conversation/conversation-config.js.map +1 -0
- package/dist/conversation/conversation-history.interface.d.ts +25 -0
- package/dist/conversation/conversation-history.interface.js +3 -0
- package/dist/conversation/conversation-history.interface.js.map +1 -0
- package/dist/conversation/conversation-provider.factory.d.ts +10 -0
- package/dist/conversation/conversation-provider.factory.js +50 -0
- package/dist/conversation/conversation-provider.factory.js.map +1 -0
- package/dist/conversation/conversation-storage.service.d.ts +15 -0
- package/dist/conversation/conversation-storage.service.js +182 -0
- package/dist/conversation/conversation-storage.service.js.map +1 -0
- package/dist/conversation/index.d.ts +7 -0
- package/dist/conversation/index.js +24 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/conversation/slack-conversation-history.provider.d.ts +22 -0
- package/dist/conversation/slack-conversation-history.provider.js +239 -0
- package/dist/conversation/slack-conversation-history.provider.js.map +1 -0
- package/dist/crewx.tool.d.ts +421 -0
- package/dist/crewx.tool.js +1240 -0
- package/dist/crewx.tool.js.map +1 -0
- package/dist/knowledge/DocumentManager.d.ts +4 -0
- package/dist/knowledge/DocumentManager.js +119 -0
- package/dist/knowledge/DocumentManager.js.map +1 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +230 -0
- package/dist/main.js.map +1 -0
- package/dist/mcp.controller.d.ts +8 -0
- package/dist/mcp.controller.js +60 -0
- package/dist/mcp.controller.js.map +1 -0
- package/dist/project.service.d.ts +44 -0
- package/dist/project.service.js +299 -0
- package/dist/project.service.js.map +1 -0
- package/dist/providers/ai-provider.interface.d.ts +30 -0
- package/dist/providers/ai-provider.interface.js +11 -0
- package/dist/providers/ai-provider.interface.js.map +1 -0
- package/dist/providers/base-ai.provider.d.ts +42 -0
- package/dist/providers/base-ai.provider.js +515 -0
- package/dist/providers/base-ai.provider.js.map +1 -0
- package/dist/providers/claude.provider.d.ts +25 -0
- package/dist/providers/claude.provider.js +376 -0
- package/dist/providers/claude.provider.js.map +1 -0
- package/dist/providers/copilot.provider.d.ts +25 -0
- package/dist/providers/copilot.provider.js +280 -0
- package/dist/providers/copilot.provider.js.map +1 -0
- package/dist/providers/gemini.provider.d.ts +22 -0
- package/dist/providers/gemini.provider.js +163 -0
- package/dist/providers/gemini.provider.js.map +1 -0
- package/dist/services/agent-loader.service.d.ts +23 -0
- package/dist/services/agent-loader.service.js +313 -0
- package/dist/services/agent-loader.service.js.map +1 -0
- package/dist/services/config-validator.service.d.ts +28 -0
- package/dist/services/config-validator.service.js +427 -0
- package/dist/services/config-validator.service.js.map +1 -0
- package/dist/services/config.service.d.ts +25 -0
- package/dist/services/config.service.js +102 -0
- package/dist/services/config.service.js.map +1 -0
- package/dist/services/context-enhancement.service.d.ts +13 -0
- package/dist/services/context-enhancement.service.js +169 -0
- package/dist/services/context-enhancement.service.js.map +1 -0
- package/dist/services/document-loader.service.d.ts +16 -0
- package/dist/services/document-loader.service.js +137 -0
- package/dist/services/document-loader.service.js.map +1 -0
- package/dist/services/help.service.d.ts +5 -0
- package/dist/services/help.service.js +112 -0
- package/dist/services/help.service.js.map +1 -0
- package/dist/services/intelligent-compression.service.d.ts +20 -0
- package/dist/services/intelligent-compression.service.js +179 -0
- package/dist/services/intelligent-compression.service.js.map +1 -0
- package/dist/services/parallel-processing.service.d.ts +108 -0
- package/dist/services/parallel-processing.service.js +266 -0
- package/dist/services/parallel-processing.service.js.map +1 -0
- package/dist/services/result-formatter.service.d.ts +27 -0
- package/dist/services/result-formatter.service.js +126 -0
- package/dist/services/result-formatter.service.js.map +1 -0
- package/dist/services/task-management.service.d.ts +63 -0
- package/dist/services/task-management.service.js +270 -0
- package/dist/services/task-management.service.js.map +1 -0
- package/dist/services/template.service.d.ts +36 -0
- package/dist/services/template.service.js +195 -0
- package/dist/services/template.service.js.map +1 -0
- package/dist/services/tool-call.service.d.ts +53 -0
- package/dist/services/tool-call.service.js +819 -0
- package/dist/services/tool-call.service.js.map +1 -0
- package/dist/slack/formatters/message.formatter.d.ts +25 -0
- package/dist/slack/formatters/message.formatter.js +246 -0
- package/dist/slack/formatters/message.formatter.js.map +1 -0
- package/dist/slack/slack-bot.d.ts +23 -0
- package/dist/slack/slack-bot.js +435 -0
- package/dist/slack/slack-bot.js.map +1 -0
- package/dist/stderr.logger.d.ts +8 -0
- package/dist/stderr.logger.js +26 -0
- package/dist/stderr.logger.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/config-utils.d.ts +15 -0
- package/dist/utils/config-utils.js +69 -0
- package/dist/utils/config-utils.js.map +1 -0
- package/dist/utils/error-utils.d.ts +3 -0
- package/dist/utils/error-utils.js +27 -0
- package/dist/utils/error-utils.js.map +1 -0
- package/dist/utils/math-utils.d.ts +3 -0
- package/dist/utils/math-utils.js +10 -0
- package/dist/utils/math-utils.js.map +1 -0
- package/dist/utils/mcp-installer.d.ts +20 -0
- package/dist/utils/mcp-installer.js +199 -0
- package/dist/utils/mcp-installer.js.map +1 -0
- package/dist/utils/mention-parser.d.ts +18 -0
- package/dist/utils/mention-parser.js +136 -0
- package/dist/utils/mention-parser.js.map +1 -0
- package/dist/utils/simple-security.d.ts +3 -0
- package/dist/utils/simple-security.js +20 -0
- package/dist/utils/simple-security.js.map +1 -0
- package/dist/utils/stdin-utils.d.ts +2 -0
- package/dist/utils/stdin-utils.js +87 -0
- package/dist/utils/stdin-utils.js.map +1 -0
- package/dist/utils/string-utils.d.ts +1 -0
- package/dist/utils/string-utils.js +10 -0
- package/dist/utils/string-utils.js.map +1 -0
- package/dist/utils/template-processor.d.ts +32 -0
- package/dist/utils/template-processor.js +188 -0
- package/dist/utils/template-processor.js.map +1 -0
- package/docs/agent-configuration.md +373 -0
- package/docs/agent-registry-strategy.md +348 -0
- package/docs/branding-decision-crewx.md +395 -0
- package/docs/claude-code-docker-guide.md +264 -0
- package/docs/cli-guide.md +295 -0
- package/docs/development.md +595 -0
- package/docs/guides/agent-best-practices.md +97 -0
- package/docs/guides/bug-management.md +600 -0
- package/docs/guides/git-bug-reference.md +366 -0
- package/docs/mcp-integration.md +187 -0
- package/docs/process/development-workflow.md +84 -0
- package/docs/roadmap.md +528 -0
- package/docs/rules/branch-protection.md +40 -0
- package/docs/standards/rc-versioning.md +60 -0
- package/docs/standards/report-structure.md +67 -0
- package/docs/templates.md +517 -0
- package/docs/tools.md +583 -0
- package/docs/troubleshooting.md +585 -0
- package/package.json +106 -21
- package/bin/crewx.js +0 -20
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# Template System Guide
|
|
2
|
+
|
|
3
|
+
Complete guide for using the template system in CrewX, including document management, Handlebars helpers, and dynamic prompts.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Overview](#overview)
|
|
8
|
+
- [Document System](#document-system)
|
|
9
|
+
- [Handlebars Helpers](#handlebars-helpers)
|
|
10
|
+
- [Built-in Helpers](#built-in-helpers)
|
|
11
|
+
- [Template Examples](#template-examples)
|
|
12
|
+
- [Best Practices](#best-practices)
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
CrewX's template system enables:
|
|
17
|
+
- **Knowledge sharing** across agents
|
|
18
|
+
- **Project documentation** access through template variables
|
|
19
|
+
- **Dynamic prompts** with Handlebars
|
|
20
|
+
- **Context preservation** in agent system prompts
|
|
21
|
+
- **Coding standards** enforcement
|
|
22
|
+
|
|
23
|
+
## Document System
|
|
24
|
+
|
|
25
|
+
### 3-Level Document System
|
|
26
|
+
|
|
27
|
+
Documents are defined at three levels with clear priority:
|
|
28
|
+
|
|
29
|
+
1. **`documents.yaml`** - Global documents (shared across projects)
|
|
30
|
+
2. **`crewx.yaml` documents:** - Project-level documents
|
|
31
|
+
3. **`agent.inline.documents`** - Agent-specific documents
|
|
32
|
+
|
|
33
|
+
**Priority:** `agent.inline.documents` > `crewx.yaml documents` > `documents.yaml`
|
|
34
|
+
|
|
35
|
+
### Document Definition Methods
|
|
36
|
+
|
|
37
|
+
#### 1. Inline Raw Markdown (Simple)
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
# documents.yaml
|
|
41
|
+
documents:
|
|
42
|
+
quick-tips: |
|
|
43
|
+
# Quick Tips
|
|
44
|
+
- Use @agent:model to specify AI model
|
|
45
|
+
- Use q/x shortcuts for query/execute
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### 2. Object Format with Metadata
|
|
49
|
+
|
|
50
|
+
```yaml
|
|
51
|
+
documents:
|
|
52
|
+
coding-standards:
|
|
53
|
+
content: |
|
|
54
|
+
# Coding Standards
|
|
55
|
+
## TypeScript
|
|
56
|
+
- Always use strict type checking
|
|
57
|
+
summary: "Project coding standards"
|
|
58
|
+
type: "markdown"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
#### 3. Load from File Path
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
documents:
|
|
65
|
+
readme:
|
|
66
|
+
path: "docs/README.md"
|
|
67
|
+
summary: "Main project documentation"
|
|
68
|
+
type: "markdown"
|
|
69
|
+
lazy: false # Load immediately
|
|
70
|
+
|
|
71
|
+
large-guide:
|
|
72
|
+
path: "docs/large-guide.md"
|
|
73
|
+
summary: "Comprehensive guide"
|
|
74
|
+
lazy: true # Load on-demand (for large files)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Using Documents in Agents
|
|
78
|
+
|
|
79
|
+
Reference documents in `system_prompt` using Handlebars template variables:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
# crewx.yaml
|
|
83
|
+
documents:
|
|
84
|
+
project-guide: |
|
|
85
|
+
# Project Guide
|
|
86
|
+
This is project-specific documentation.
|
|
87
|
+
|
|
88
|
+
agents:
|
|
89
|
+
- id: "my_agent"
|
|
90
|
+
inline:
|
|
91
|
+
documents:
|
|
92
|
+
agent-doc: |
|
|
93
|
+
# Agent-Specific Doc
|
|
94
|
+
Only this agent can see this.
|
|
95
|
+
|
|
96
|
+
system_prompt: |
|
|
97
|
+
You are a helpful assistant.
|
|
98
|
+
|
|
99
|
+
<document name="quick-tips">
|
|
100
|
+
{{{documents.quick-tips.content}}}
|
|
101
|
+
</document>
|
|
102
|
+
|
|
103
|
+
<toc>
|
|
104
|
+
{{{documents.readme.toc}}}
|
|
105
|
+
</toc>
|
|
106
|
+
|
|
107
|
+
Summary: {{documents.readme.summary}}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Template Variables
|
|
111
|
+
|
|
112
|
+
**Content:**
|
|
113
|
+
- `{{{documents.name.content}}}` - Full document content (unescaped)
|
|
114
|
+
- `{{documents.name.content}}` - Escaped content
|
|
115
|
+
|
|
116
|
+
**Metadata:**
|
|
117
|
+
- `{{{documents.name.toc}}}` - Table of contents (markdown headings)
|
|
118
|
+
- `{{documents.name.summary}}` - Document summary
|
|
119
|
+
- `{{documents.name.type}}` - Document type
|
|
120
|
+
|
|
121
|
+
**Important:** Use triple braces `{{{...}}}` to preserve markdown formatting.
|
|
122
|
+
|
|
123
|
+
## Handlebars Helpers
|
|
124
|
+
|
|
125
|
+
### Available Context Variables
|
|
126
|
+
|
|
127
|
+
**Documents:**
|
|
128
|
+
```handlebars
|
|
129
|
+
{{{documents.doc-name.content}}} - Full document content (unescaped)
|
|
130
|
+
{{{documents.doc-name.toc}}} - Table of contents
|
|
131
|
+
{{documents.doc-name.summary}} - Document summary (escaped)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Environment Variables:**
|
|
135
|
+
```handlebars
|
|
136
|
+
{{env.NODE_ENV}} - Access any environment variable
|
|
137
|
+
{{env.API_KEY}}
|
|
138
|
+
{{env.DEBUG}}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Agent Metadata:**
|
|
142
|
+
```handlebars
|
|
143
|
+
{{agent.id}} - Agent ID
|
|
144
|
+
{{agent.name}} - Agent name
|
|
145
|
+
{{agent.provider}} - AI provider (claude, gemini, copilot)
|
|
146
|
+
{{agent.model}} - Model name (sonnet, haiku, etc.)
|
|
147
|
+
{{agent.workingDirectory}} - Working directory
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Mode:**
|
|
151
|
+
```handlebars
|
|
152
|
+
{{mode}} - 'query' or 'execute'
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Custom Variables:**
|
|
156
|
+
```handlebars
|
|
157
|
+
{{vars.customKey}} - Any custom variable passed in context
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Conditional Helpers
|
|
161
|
+
|
|
162
|
+
#### Equality Check
|
|
163
|
+
```handlebars
|
|
164
|
+
{{#if (eq agent.provider "claude")}}
|
|
165
|
+
You are using Claude AI.
|
|
166
|
+
{{else}}
|
|
167
|
+
You are using another AI provider.
|
|
168
|
+
{{/if}}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
#### Not Equal
|
|
172
|
+
```handlebars
|
|
173
|
+
{{#if (ne env.NODE_ENV "production")}}
|
|
174
|
+
Debug mode is enabled.
|
|
175
|
+
{{/if}}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
#### Contains (Array)
|
|
179
|
+
```handlebars
|
|
180
|
+
{{#if (contains options "--verbose")}}
|
|
181
|
+
Verbose output enabled.
|
|
182
|
+
{{/if}}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### Logical AND
|
|
186
|
+
```handlebars
|
|
187
|
+
{{#if (and agent.model env.DEBUG)}}
|
|
188
|
+
Model: {{agent.model}}, Debug enabled
|
|
189
|
+
{{/if}}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
#### Logical OR
|
|
193
|
+
```handlebars
|
|
194
|
+
{{#if (or (eq agent.provider "claude") (eq agent.provider "gemini"))}}
|
|
195
|
+
Web search is available.
|
|
196
|
+
{{/if}}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### Logical NOT
|
|
200
|
+
```handlebars
|
|
201
|
+
{{#if (not env.PRODUCTION)}}
|
|
202
|
+
Running in development mode.
|
|
203
|
+
{{/if}}
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
## Built-in Helpers
|
|
207
|
+
|
|
208
|
+
### formatConversation Helper
|
|
209
|
+
|
|
210
|
+
The `formatConversation` helper formats conversation history for AI prompts. It supports two modes: basic template (recommended) and custom template.
|
|
211
|
+
|
|
212
|
+
#### Basic Usage (Recommended)
|
|
213
|
+
|
|
214
|
+
Use the built-in template with one line:
|
|
215
|
+
|
|
216
|
+
```handlebars
|
|
217
|
+
{{{formatConversation messages platform}}}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Output example:**
|
|
221
|
+
```xml
|
|
222
|
+
<messages>
|
|
223
|
+
Previous conversation (22 messages):
|
|
224
|
+
(Slack thread)
|
|
225
|
+
|
|
226
|
+
**Doha (<@U08LSF2KNVD>)**: 안녕하세요
|
|
227
|
+
**crewxdev (<@U09J206RP8V>) (@CrewX)**: 안녕하세요! 무엇을 도와드릴까요?
|
|
228
|
+
...
|
|
229
|
+
</messages>
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Features:**
|
|
233
|
+
- ✅ Automatic `<messages>` tag wrapping
|
|
234
|
+
- ✅ Slack mention formatting
|
|
235
|
+
- ✅ Message count display
|
|
236
|
+
- ✅ Platform label (Slack thread)
|
|
237
|
+
- ✅ User/Agent distinction
|
|
238
|
+
|
|
239
|
+
#### Custom Template Usage
|
|
240
|
+
|
|
241
|
+
For special formatting needs, use as a block helper:
|
|
242
|
+
|
|
243
|
+
```handlebars
|
|
244
|
+
{{#formatConversation messages platform}}
|
|
245
|
+
<conversation-history platform="{{platform}}" count="{{messagesCount}}">
|
|
246
|
+
{{#each messages}}
|
|
247
|
+
{{#if isAssistant}}
|
|
248
|
+
[AI] {{{text}}}
|
|
249
|
+
{{else}}
|
|
250
|
+
[USER] {{{text}}}
|
|
251
|
+
{{/if}}
|
|
252
|
+
{{/each}}
|
|
253
|
+
</conversation-history>
|
|
254
|
+
{{/formatConversation}}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Output example:**
|
|
258
|
+
```xml
|
|
259
|
+
<messages>
|
|
260
|
+
<conversation-history platform="slack" count="22">
|
|
261
|
+
[USER] 안녕하세요
|
|
262
|
+
[AI] 안녕하세요! 무엇을 도와드릴까요?
|
|
263
|
+
...
|
|
264
|
+
</conversation-history>
|
|
265
|
+
</messages>
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
#### Available Variables in Block Helper
|
|
269
|
+
|
|
270
|
+
**Context variables:**
|
|
271
|
+
- `messages`: Message array
|
|
272
|
+
- `platform`: 'slack' or 'cli'
|
|
273
|
+
- `messagesCount`: Number of messages
|
|
274
|
+
|
|
275
|
+
**Each message object:**
|
|
276
|
+
```javascript
|
|
277
|
+
{
|
|
278
|
+
text: string, // Message content
|
|
279
|
+
isAssistant: boolean, // AI message indicator
|
|
280
|
+
metadata: {
|
|
281
|
+
agent_id: string, // Agent ID
|
|
282
|
+
slack: { // Slack metadata
|
|
283
|
+
user_id: string,
|
|
284
|
+
username: string,
|
|
285
|
+
user_profile: {
|
|
286
|
+
display_name: string,
|
|
287
|
+
real_name: string
|
|
288
|
+
},
|
|
289
|
+
bot_user_id: string,
|
|
290
|
+
bot_username: string
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
#### Best Practices
|
|
297
|
+
|
|
298
|
+
**✅ Recommended:**
|
|
299
|
+
1. Use basic template first: `{{{formatConversation messages platform}}}`
|
|
300
|
+
2. Use platform-specific branching when needed
|
|
301
|
+
3. Use meaningful XML tags
|
|
302
|
+
|
|
303
|
+
**❌ Avoid:**
|
|
304
|
+
1. Manually adding `<messages>` tags (helper does this automatically)
|
|
305
|
+
2. Complex logic in templates (keep it simple)
|
|
306
|
+
3. Missing metadata safety checks
|
|
307
|
+
|
|
308
|
+
## Template Examples
|
|
309
|
+
|
|
310
|
+
### Example 1: Environment-Specific Behavior
|
|
311
|
+
|
|
312
|
+
```yaml
|
|
313
|
+
agents:
|
|
314
|
+
- id: "dev_assistant"
|
|
315
|
+
inline:
|
|
316
|
+
system_prompt: |
|
|
317
|
+
You are a development assistant.
|
|
318
|
+
|
|
319
|
+
{{#if (eq env.NODE_ENV "production")}}
|
|
320
|
+
**Production Mode**: Be extra careful with suggestions.
|
|
321
|
+
Always recommend testing changes thoroughly.
|
|
322
|
+
{{else}}
|
|
323
|
+
**Development Mode**: Feel free to experiment.
|
|
324
|
+
You can suggest more experimental approaches.
|
|
325
|
+
{{/if}}
|
|
326
|
+
|
|
327
|
+
Working Directory: {{agent.workingDirectory}}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Example 2: Provider-Specific Features
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
agents:
|
|
334
|
+
- id: "researcher"
|
|
335
|
+
inline:
|
|
336
|
+
system_prompt: |
|
|
337
|
+
You are a research assistant.
|
|
338
|
+
|
|
339
|
+
{{#if (or (eq agent.provider "claude") (eq agent.provider "gemini"))}}
|
|
340
|
+
## Web Search Available
|
|
341
|
+
You have access to web search capabilities.
|
|
342
|
+
Use them to find the latest information.
|
|
343
|
+
{{else}}
|
|
344
|
+
## Local-Only Analysis
|
|
345
|
+
You don't have web search. Focus on analyzing provided code and files.
|
|
346
|
+
{{/if}}
|
|
347
|
+
|
|
348
|
+
Provider: {{agent.provider}}
|
|
349
|
+
Model: {{agent.model}}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Example 3: Model-Specific Instructions
|
|
353
|
+
|
|
354
|
+
```yaml
|
|
355
|
+
agents:
|
|
356
|
+
- id: "coder"
|
|
357
|
+
inline:
|
|
358
|
+
system_prompt: |
|
|
359
|
+
You are a coding assistant.
|
|
360
|
+
|
|
361
|
+
{{#if (eq agent.model "haiku")}}
|
|
362
|
+
## Fast Response Mode
|
|
363
|
+
Provide concise, quick answers.
|
|
364
|
+
Focus on the most important information.
|
|
365
|
+
{{else if (eq agent.model "opus")}}
|
|
366
|
+
## Deep Analysis Mode
|
|
367
|
+
Provide detailed, comprehensive analysis.
|
|
368
|
+
Consider edge cases and architectural implications.
|
|
369
|
+
{{else}}
|
|
370
|
+
## Balanced Mode
|
|
371
|
+
Provide clear, thorough but efficient responses.
|
|
372
|
+
{{/if}}
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Example 4: Multi-Level Documents
|
|
376
|
+
|
|
377
|
+
**documents.yaml (global):**
|
|
378
|
+
```yaml
|
|
379
|
+
documents:
|
|
380
|
+
coding-standards: |
|
|
381
|
+
# Coding Standards
|
|
382
|
+
## TypeScript
|
|
383
|
+
- Use strict type checking
|
|
384
|
+
- Prefer interfaces over types
|
|
385
|
+
- Document public APIs
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
**crewx.yaml (project):**
|
|
389
|
+
```yaml
|
|
390
|
+
documents:
|
|
391
|
+
project-conventions: |
|
|
392
|
+
# Project Conventions
|
|
393
|
+
- Follow trunk-based development
|
|
394
|
+
- Write tests for all features
|
|
395
|
+
- Use semantic commit messages
|
|
396
|
+
|
|
397
|
+
agents:
|
|
398
|
+
- id: "code_reviewer"
|
|
399
|
+
inline:
|
|
400
|
+
documents:
|
|
401
|
+
review-checklist: |
|
|
402
|
+
# Review Checklist
|
|
403
|
+
- Check type safety
|
|
404
|
+
- Verify test coverage
|
|
405
|
+
- Review error handling
|
|
406
|
+
|
|
407
|
+
system_prompt: |
|
|
408
|
+
You are a code reviewer.
|
|
409
|
+
|
|
410
|
+
<coding-standards>
|
|
411
|
+
{{{documents.coding-standards.content}}}
|
|
412
|
+
</coding-standards>
|
|
413
|
+
|
|
414
|
+
<project-conventions>
|
|
415
|
+
{{{documents.project-conventions.content}}}
|
|
416
|
+
</project-conventions>
|
|
417
|
+
|
|
418
|
+
<review-checklist>
|
|
419
|
+
{{{documents.review-checklist.content}}}
|
|
420
|
+
</review-checklist>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### Example 5: Conversation History Integration
|
|
424
|
+
|
|
425
|
+
```yaml
|
|
426
|
+
agents:
|
|
427
|
+
- id: "slack_bot"
|
|
428
|
+
inline:
|
|
429
|
+
system_prompt: |
|
|
430
|
+
You are a Slack assistant.
|
|
431
|
+
|
|
432
|
+
{{{formatConversation messages platform}}}
|
|
433
|
+
|
|
434
|
+
Respond naturally based on the conversation history.
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
## Best Practices
|
|
438
|
+
|
|
439
|
+
### 1. Organize by Scope
|
|
440
|
+
- **Global**: Coding standards, general guidelines
|
|
441
|
+
- **Project**: Project-specific conventions, architecture
|
|
442
|
+
- **Agent**: Role-specific checklists, workflows
|
|
443
|
+
|
|
444
|
+
### 2. Use Lazy Loading
|
|
445
|
+
For large documents (>100KB):
|
|
446
|
+
```yaml
|
|
447
|
+
documents:
|
|
448
|
+
large-spec:
|
|
449
|
+
path: "docs/large-spec.md"
|
|
450
|
+
lazy: true # Only load when accessed
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
### 3. Preserve Formatting
|
|
454
|
+
Always use triple braces for markdown:
|
|
455
|
+
```yaml
|
|
456
|
+
{{{documents.name.content}}} # Correct
|
|
457
|
+
{{documents.name.content}} # Escaped (wrong for markdown)
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### 4. Provide Summaries
|
|
461
|
+
Help agents understand document purpose:
|
|
462
|
+
```yaml
|
|
463
|
+
documents:
|
|
464
|
+
api-guide:
|
|
465
|
+
path: "docs/api.md"
|
|
466
|
+
summary: "RESTful API design patterns and best practices"
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### 5. Version Control
|
|
470
|
+
Store documents in Git:
|
|
471
|
+
```
|
|
472
|
+
project/
|
|
473
|
+
├── docs/
|
|
474
|
+
│ ├── *.md
|
|
475
|
+
├── documents.yaml
|
|
476
|
+
└── crewx.yaml
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
### 6. Use Environment Variables
|
|
480
|
+
Make agents context-aware:
|
|
481
|
+
```bash
|
|
482
|
+
export NODE_ENV=production
|
|
483
|
+
export FEATURE_FLAGS=experimental,beta
|
|
484
|
+
crewx query "@dev analyze this feature"
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### 7. Use Descriptive Variable Names
|
|
488
|
+
Make conditions clear:
|
|
489
|
+
```handlebars
|
|
490
|
+
{{#if (eq env.DEPLOYMENT_ENV "production")}} # Clear
|
|
491
|
+
{{#if (eq env.DE "prod")}} # Unclear
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
### 8. Provide Fallbacks
|
|
495
|
+
Always have an `{{else}}` clause:
|
|
496
|
+
```handlebars
|
|
497
|
+
{{#if tools}}
|
|
498
|
+
You have {{tools.count}} tools available.
|
|
499
|
+
{{else}}
|
|
500
|
+
No tools available at this time.
|
|
501
|
+
{{/if}}
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
## Benefits
|
|
505
|
+
|
|
506
|
+
✅ **Version Control** - Documents in YAML/markdown files
|
|
507
|
+
✅ **Reusability** - Share documents across agents
|
|
508
|
+
✅ **Organization** - Separate concerns (global, project, agent)
|
|
509
|
+
✅ **Performance** - Lazy loading for large documents
|
|
510
|
+
✅ **Flexibility** - Mix inline and file-based documents
|
|
511
|
+
✅ **Dynamic Behavior** - Environment and agent-aware prompts
|
|
512
|
+
|
|
513
|
+
## See Also
|
|
514
|
+
|
|
515
|
+
- [Agent Configuration Guide](agent-configuration.md) - Agent setup
|
|
516
|
+
- [CLI Guide](cli-guide.md) - Command-line usage
|
|
517
|
+
- [Tools Guide](tools.md) - Tool system integration
|