claude-cli-advanced-starter-pack 1.0.0
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 +21 -0
- package/OVERVIEW.md +597 -0
- package/README.md +439 -0
- package/bin/gtask.js +282 -0
- package/bin/postinstall.js +53 -0
- package/package.json +69 -0
- package/src/agents/phase-dev-templates.js +1011 -0
- package/src/agents/templates.js +668 -0
- package/src/analysis/checklist-parser.js +414 -0
- package/src/analysis/codebase.js +481 -0
- package/src/cli/menu.js +958 -0
- package/src/commands/claude-audit.js +1482 -0
- package/src/commands/claude-settings.js +2243 -0
- package/src/commands/create-agent.js +681 -0
- package/src/commands/create-command.js +337 -0
- package/src/commands/create-hook.js +262 -0
- package/src/commands/create-phase-dev/codebase-analyzer.js +813 -0
- package/src/commands/create-phase-dev/documentation-generator.js +352 -0
- package/src/commands/create-phase-dev/post-completion.js +404 -0
- package/src/commands/create-phase-dev/scale-calculator.js +344 -0
- package/src/commands/create-phase-dev/wizard.js +492 -0
- package/src/commands/create-phase-dev.js +481 -0
- package/src/commands/create-skill.js +313 -0
- package/src/commands/create.js +446 -0
- package/src/commands/decompose.js +392 -0
- package/src/commands/detect-tech-stack.js +768 -0
- package/src/commands/explore-mcp/claude-md-updater.js +252 -0
- package/src/commands/explore-mcp/mcp-installer.js +346 -0
- package/src/commands/explore-mcp/mcp-registry.js +438 -0
- package/src/commands/explore-mcp.js +638 -0
- package/src/commands/gtask-init.js +641 -0
- package/src/commands/help.js +128 -0
- package/src/commands/init.js +1890 -0
- package/src/commands/install.js +250 -0
- package/src/commands/list.js +116 -0
- package/src/commands/roadmap.js +750 -0
- package/src/commands/setup-wizard.js +482 -0
- package/src/commands/setup.js +351 -0
- package/src/commands/sync.js +534 -0
- package/src/commands/test-run.js +456 -0
- package/src/commands/test-setup.js +456 -0
- package/src/commands/validate.js +67 -0
- package/src/config/tech-stack.defaults.json +182 -0
- package/src/config/tech-stack.schema.json +502 -0
- package/src/github/client.js +359 -0
- package/src/index.js +84 -0
- package/src/templates/claude-command.js +244 -0
- package/src/templates/issue-body.js +284 -0
- package/src/testing/config.js +411 -0
- package/src/utils/template-engine.js +398 -0
- package/src/utils/validate-templates.js +223 -0
- package/src/utils.js +396 -0
- package/templates/commands/ccasp-setup.template.md +113 -0
- package/templates/commands/context-audit.template.md +97 -0
- package/templates/commands/create-task-list.template.md +382 -0
- package/templates/commands/deploy-full.template.md +261 -0
- package/templates/commands/github-task-start.template.md +99 -0
- package/templates/commands/github-update.template.md +69 -0
- package/templates/commands/happy-start.template.md +117 -0
- package/templates/commands/phase-track.template.md +142 -0
- package/templates/commands/tunnel-start.template.md +127 -0
- package/templates/commands/tunnel-stop.template.md +106 -0
- package/templates/hooks/context-guardian.template.js +173 -0
- package/templates/hooks/deployment-orchestrator.template.js +219 -0
- package/templates/hooks/github-progress-hook.template.js +197 -0
- package/templates/hooks/happy-checkpoint-manager.template.js +222 -0
- package/templates/hooks/phase-dev-enforcer.template.js +183 -0
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Creation Templates
|
|
3
|
+
*
|
|
4
|
+
* Base templates for creating Claude Code components:
|
|
5
|
+
* - Individual agents
|
|
6
|
+
* - Hooks (PreToolUse, UserPromptSubmit, etc.)
|
|
7
|
+
* - Slash commands
|
|
8
|
+
* - Skills with RAG
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Hook template for enforcement/injection
|
|
13
|
+
*/
|
|
14
|
+
export function generateHookTemplate(config) {
|
|
15
|
+
const {
|
|
16
|
+
name,
|
|
17
|
+
description,
|
|
18
|
+
eventType = 'PreToolUse',
|
|
19
|
+
tools = ['Edit', 'Write'],
|
|
20
|
+
targetPatterns = [],
|
|
21
|
+
blockedPatterns = [],
|
|
22
|
+
warningPatterns = [],
|
|
23
|
+
blockReason = 'Pattern violation detected',
|
|
24
|
+
referenceDoc = '',
|
|
25
|
+
} = config;
|
|
26
|
+
|
|
27
|
+
const toolsArray = Array.isArray(tools) ? tools : [tools];
|
|
28
|
+
const toolsList = toolsArray.map((t) => `'${t}'`).join(', ');
|
|
29
|
+
|
|
30
|
+
return `#!/usr/bin/env node
|
|
31
|
+
/**
|
|
32
|
+
* ${name}
|
|
33
|
+
*
|
|
34
|
+
* Event: ${eventType} (${toolsArray.join('|')})
|
|
35
|
+
* Purpose: ${description}
|
|
36
|
+
*
|
|
37
|
+
* Created by: gtask create-hook
|
|
38
|
+
* Date: ${new Date().toISOString()}
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
const hookInput = JSON.parse(process.env.CLAUDE_HOOK_INPUT || '{}');
|
|
42
|
+
|
|
43
|
+
// Configuration
|
|
44
|
+
const CONFIG = {
|
|
45
|
+
targetPatterns: [${targetPatterns.map((p) => `'${p}'`).join(', ')}],
|
|
46
|
+
blockedPatterns: [${blockedPatterns.map((p) => `'${p}'`).join(', ')}],
|
|
47
|
+
warningPatterns: [${warningPatterns.map((p) => `'${p}'`).join(', ')}]
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// Helper functions
|
|
51
|
+
function isTargetFile(filePath) {
|
|
52
|
+
if (!filePath) return false;
|
|
53
|
+
const normalized = filePath.replace(/\\\\/g, '/').toLowerCase();
|
|
54
|
+
return CONFIG.targetPatterns.length === 0 ||
|
|
55
|
+
CONFIG.targetPatterns.some(p => normalized.includes(p.toLowerCase()));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function findBlockedPatterns(content) {
|
|
59
|
+
if (!content) return [];
|
|
60
|
+
return CONFIG.blockedPatterns.filter(p => content.includes(p));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function findWarningPatterns(content) {
|
|
64
|
+
if (!content) return [];
|
|
65
|
+
return CONFIG.warningPatterns.filter(p => content.includes(p));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Main hook logic
|
|
69
|
+
async function main() {
|
|
70
|
+
try {
|
|
71
|
+
const tool = hookInput.tool_name || '';
|
|
72
|
+
const input = hookInput.tool_input || {};
|
|
73
|
+
|
|
74
|
+
// Only process target tools
|
|
75
|
+
const MONITORED_TOOLS = [${toolsList}];
|
|
76
|
+
if (!MONITORED_TOOLS.includes(tool)) {
|
|
77
|
+
console.log(JSON.stringify({ decision: 'approve' }));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const filePath = input.file_path || '';
|
|
82
|
+
const content = input.content || input.new_string || '';
|
|
83
|
+
|
|
84
|
+
// Skip non-target files
|
|
85
|
+
if (!isTargetFile(filePath)) {
|
|
86
|
+
console.log(JSON.stringify({ decision: 'approve' }));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Check for blocked patterns
|
|
91
|
+
const blocked = findBlockedPatterns(content);
|
|
92
|
+
if (blocked.length > 0) {
|
|
93
|
+
console.log(JSON.stringify({
|
|
94
|
+
decision: 'block',
|
|
95
|
+
reason: '${blockReason}',
|
|
96
|
+
systemMessage: \`
|
|
97
|
+
## ${name} - Violation Detected
|
|
98
|
+
|
|
99
|
+
**Blocked patterns found:** \${blocked.join(', ')}
|
|
100
|
+
|
|
101
|
+
**Why this was blocked:**
|
|
102
|
+
${blockReason}
|
|
103
|
+
|
|
104
|
+
${referenceDoc ? `**Reference:** \`${referenceDoc}\`` : ''}
|
|
105
|
+
|
|
106
|
+
**To fix:**
|
|
107
|
+
1. Review the blocked patterns above
|
|
108
|
+
2. Update your code to follow the required pattern
|
|
109
|
+
3. Retry the operation
|
|
110
|
+
\`
|
|
111
|
+
}));
|
|
112
|
+
process.exit(1);
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Check for warning patterns
|
|
117
|
+
const warnings = findWarningPatterns(content);
|
|
118
|
+
if (warnings.length > 0) {
|
|
119
|
+
console.log(JSON.stringify({
|
|
120
|
+
decision: 'approve',
|
|
121
|
+
systemMessage: \`
|
|
122
|
+
## ${name} - Warning
|
|
123
|
+
|
|
124
|
+
**Patterns that may need review:** \${warnings.join(', ')}
|
|
125
|
+
|
|
126
|
+
This is a warning only - the operation will proceed.
|
|
127
|
+
\`
|
|
128
|
+
}));
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// All checks passed
|
|
133
|
+
console.log(JSON.stringify({ decision: 'approve' }));
|
|
134
|
+
|
|
135
|
+
} catch (error) {
|
|
136
|
+
// Always approve on error (fail-safe)
|
|
137
|
+
console.log(JSON.stringify({
|
|
138
|
+
decision: 'approve',
|
|
139
|
+
reason: \`Hook error (non-blocking): \${error.message}\`
|
|
140
|
+
}));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
main();
|
|
145
|
+
`;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Slash command template
|
|
150
|
+
*/
|
|
151
|
+
export function generateCommandTemplate(config) {
|
|
152
|
+
const {
|
|
153
|
+
name,
|
|
154
|
+
description,
|
|
155
|
+
complexity = 'low',
|
|
156
|
+
delegatesTo = '',
|
|
157
|
+
arguments: args = '',
|
|
158
|
+
steps = [],
|
|
159
|
+
examples = [],
|
|
160
|
+
relatedCommands = [],
|
|
161
|
+
} = config;
|
|
162
|
+
|
|
163
|
+
const stepsMarkdown = steps
|
|
164
|
+
.map(
|
|
165
|
+
(step, i) => `### Step ${i + 1}: ${step.title}
|
|
166
|
+
|
|
167
|
+
${step.instructions}
|
|
168
|
+
`
|
|
169
|
+
)
|
|
170
|
+
.join('\n');
|
|
171
|
+
|
|
172
|
+
const examplesMarkdown = examples
|
|
173
|
+
.map((ex) => `# ${ex.description}\n/${name} ${ex.args}`)
|
|
174
|
+
.join('\n\n');
|
|
175
|
+
|
|
176
|
+
const relatedMarkdown = relatedCommands.map((cmd) => `- \`/${cmd}\``).join('\n');
|
|
177
|
+
|
|
178
|
+
return `---
|
|
179
|
+
description: ${description}
|
|
180
|
+
type: project
|
|
181
|
+
complexity: ${complexity}
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
# /${name}
|
|
185
|
+
|
|
186
|
+
${description}
|
|
187
|
+
|
|
188
|
+
## Usage
|
|
189
|
+
|
|
190
|
+
\`\`\`bash
|
|
191
|
+
/${name}${args ? ` ${args}` : ''}
|
|
192
|
+
\`\`\`
|
|
193
|
+
|
|
194
|
+
## Instructions
|
|
195
|
+
|
|
196
|
+
When this command is invoked:
|
|
197
|
+
|
|
198
|
+
${stepsMarkdown || `### Step 1: Execute
|
|
199
|
+
|
|
200
|
+
Follow the instructions for this command.
|
|
201
|
+
`}
|
|
202
|
+
|
|
203
|
+
${
|
|
204
|
+
delegatesTo
|
|
205
|
+
? `## Delegates To
|
|
206
|
+
|
|
207
|
+
This command uses: \`${delegatesTo}\`
|
|
208
|
+
`
|
|
209
|
+
: ''
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
## Examples
|
|
213
|
+
|
|
214
|
+
\`\`\`bash
|
|
215
|
+
${examplesMarkdown || `/${name}`}
|
|
216
|
+
\`\`\`
|
|
217
|
+
|
|
218
|
+
${
|
|
219
|
+
relatedCommands.length > 0
|
|
220
|
+
? `## Related Commands
|
|
221
|
+
|
|
222
|
+
${relatedMarkdown}
|
|
223
|
+
`
|
|
224
|
+
: ''
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
*Created by gtask create-command - ${new Date().toISOString()}*
|
|
229
|
+
`;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Individual agent template
|
|
234
|
+
*/
|
|
235
|
+
export function generateAgentTemplate(config) {
|
|
236
|
+
const {
|
|
237
|
+
name,
|
|
238
|
+
description,
|
|
239
|
+
level = 'L2',
|
|
240
|
+
tools = ['Read', 'Grep', 'Glob'],
|
|
241
|
+
model = 'sonnet',
|
|
242
|
+
specialization = '',
|
|
243
|
+
whenToUse = [],
|
|
244
|
+
workflow = [],
|
|
245
|
+
outputFormat = '',
|
|
246
|
+
} = config;
|
|
247
|
+
|
|
248
|
+
const toolsList = Array.isArray(tools) ? tools.join(', ') : tools;
|
|
249
|
+
const whenToUseMarkdown = whenToUse.map((item) => `- ${item}`).join('\n');
|
|
250
|
+
const workflowMarkdown = workflow
|
|
251
|
+
.map(
|
|
252
|
+
(step, i) => `### Step ${i + 1}: ${step.title}
|
|
253
|
+
|
|
254
|
+
${step.instructions}
|
|
255
|
+
`
|
|
256
|
+
)
|
|
257
|
+
.join('\n');
|
|
258
|
+
|
|
259
|
+
return `---
|
|
260
|
+
name: ${name}
|
|
261
|
+
description: ${description}
|
|
262
|
+
level: ${level}
|
|
263
|
+
tools: ${toolsList}
|
|
264
|
+
model: ${model}
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
# ${name}
|
|
268
|
+
|
|
269
|
+
${description}
|
|
270
|
+
|
|
271
|
+
## Specialization
|
|
272
|
+
|
|
273
|
+
${specialization || 'General-purpose agent for delegated tasks.'}
|
|
274
|
+
|
|
275
|
+
## When to Use
|
|
276
|
+
|
|
277
|
+
${whenToUseMarkdown || '- When you need specialized assistance with this domain'}
|
|
278
|
+
|
|
279
|
+
## Workflow
|
|
280
|
+
|
|
281
|
+
${workflowMarkdown || `### Step 1: Analyze
|
|
282
|
+
|
|
283
|
+
Analyze the request and gather context.
|
|
284
|
+
|
|
285
|
+
### Step 2: Execute
|
|
286
|
+
|
|
287
|
+
Perform the requested task.
|
|
288
|
+
|
|
289
|
+
### Step 3: Report
|
|
290
|
+
|
|
291
|
+
Provide a summary of findings/actions.
|
|
292
|
+
`}
|
|
293
|
+
|
|
294
|
+
## Output Format
|
|
295
|
+
|
|
296
|
+
${
|
|
297
|
+
outputFormat ||
|
|
298
|
+
`Provide a concise summary with:
|
|
299
|
+
- Key findings
|
|
300
|
+
- Actions taken
|
|
301
|
+
- Recommendations (if applicable)`
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
## Response Limits
|
|
305
|
+
|
|
306
|
+
${
|
|
307
|
+
level === 'L3'
|
|
308
|
+
? '- Maximum 500 tokens (worker-level response)'
|
|
309
|
+
: level === 'L2'
|
|
310
|
+
? '- Maximum 8,000 tokens (specialist-level response)'
|
|
311
|
+
: '- Comprehensive orchestration response'
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
*Created by gtask create-agent - ${new Date().toISOString()}*
|
|
316
|
+
`;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Skill template with RAG structure
|
|
321
|
+
*/
|
|
322
|
+
export function generateSkillTemplate(config) {
|
|
323
|
+
const {
|
|
324
|
+
name,
|
|
325
|
+
description,
|
|
326
|
+
triggers = [],
|
|
327
|
+
knowledgeAreas = [],
|
|
328
|
+
workflows = [],
|
|
329
|
+
hooks = [],
|
|
330
|
+
} = config;
|
|
331
|
+
|
|
332
|
+
const triggersMarkdown = triggers.map((t) => `- \`${t}\``).join('\n');
|
|
333
|
+
const knowledgeMarkdown = knowledgeAreas.map((k) => `- ${k}`).join('\n');
|
|
334
|
+
const workflowsMarkdown = workflows
|
|
335
|
+
.map(
|
|
336
|
+
(w) => `### ${w.name}
|
|
337
|
+
|
|
338
|
+
**File:** \`workflows/${w.file}\`
|
|
339
|
+
|
|
340
|
+
${w.description}
|
|
341
|
+
`
|
|
342
|
+
)
|
|
343
|
+
.join('\n');
|
|
344
|
+
const hooksMarkdown = hooks.map((h) => `- \`${h}\``).join('\n');
|
|
345
|
+
|
|
346
|
+
return `---
|
|
347
|
+
name: ${name}
|
|
348
|
+
description: ${description}
|
|
349
|
+
version: 1.0.0
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
# ${name} Skill
|
|
353
|
+
|
|
354
|
+
${description}
|
|
355
|
+
|
|
356
|
+
## Triggers
|
|
357
|
+
|
|
358
|
+
This skill activates on:
|
|
359
|
+
|
|
360
|
+
${triggersMarkdown || '- Direct invocation via `skill: "${name}"`'}
|
|
361
|
+
|
|
362
|
+
## Knowledge Base
|
|
363
|
+
|
|
364
|
+
### Areas of Expertise
|
|
365
|
+
|
|
366
|
+
${knowledgeMarkdown || '- Domain-specific knowledge'}
|
|
367
|
+
|
|
368
|
+
### Context Files
|
|
369
|
+
|
|
370
|
+
\`\`\`
|
|
371
|
+
.claude/skills/${name}/
|
|
372
|
+
├── SKILL.md # This file
|
|
373
|
+
├── context/ # Knowledge base
|
|
374
|
+
│ ├── README.md # Context overview
|
|
375
|
+
│ └── patterns/ # Common patterns
|
|
376
|
+
└── workflows/ # Agent workflows
|
|
377
|
+
└── README.md # Workflow index
|
|
378
|
+
\`\`\`
|
|
379
|
+
|
|
380
|
+
## Workflows
|
|
381
|
+
|
|
382
|
+
${workflowsMarkdown || 'No workflows defined yet.'}
|
|
383
|
+
|
|
384
|
+
## Hooks
|
|
385
|
+
|
|
386
|
+
${hooksMarkdown || 'No enforcement hooks defined.'}
|
|
387
|
+
|
|
388
|
+
## Usage
|
|
389
|
+
|
|
390
|
+
\`\`\`markdown
|
|
391
|
+
skill: "${name}"
|
|
392
|
+
|
|
393
|
+
[Your request here]
|
|
394
|
+
\`\`\`
|
|
395
|
+
|
|
396
|
+
## Validation Checklist
|
|
397
|
+
|
|
398
|
+
Before completing any task:
|
|
399
|
+
|
|
400
|
+
- [ ] Followed established patterns
|
|
401
|
+
- [ ] Verified against knowledge base
|
|
402
|
+
- [ ] Tested output if applicable
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
*Created by gtask create-skill - ${new Date().toISOString()}*
|
|
406
|
+
`;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Skill context README template
|
|
411
|
+
*/
|
|
412
|
+
export function generateSkillContextReadme(config) {
|
|
413
|
+
const { name, description, knowledgeAreas = [] } = config;
|
|
414
|
+
|
|
415
|
+
return `# ${name} - Context
|
|
416
|
+
|
|
417
|
+
This directory contains the knowledge base for the ${name} skill.
|
|
418
|
+
|
|
419
|
+
## Contents
|
|
420
|
+
|
|
421
|
+
- **patterns/** - Common patterns and best practices
|
|
422
|
+
- **examples/** - Reference implementations
|
|
423
|
+
- **rag/** - RAG retrieval data (if applicable)
|
|
424
|
+
|
|
425
|
+
## Knowledge Areas
|
|
426
|
+
|
|
427
|
+
${knowledgeAreas.map((k) => `- ${k}`).join('\n') || '- General domain knowledge'}
|
|
428
|
+
|
|
429
|
+
## Adding Context
|
|
430
|
+
|
|
431
|
+
1. Add markdown files to this directory
|
|
432
|
+
2. Reference them in the skill's workflows
|
|
433
|
+
3. Update this README
|
|
434
|
+
|
|
435
|
+
---
|
|
436
|
+
*Part of ${name} skill*
|
|
437
|
+
`;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* Skill workflows README template
|
|
442
|
+
*/
|
|
443
|
+
export function generateSkillWorkflowsReadme(config) {
|
|
444
|
+
const { name, workflows = [] } = config;
|
|
445
|
+
|
|
446
|
+
const workflowTable = workflows.length
|
|
447
|
+
? workflows.map((w) => `| ${w.name} | ${w.file} | ${w.description} |`).join('\n')
|
|
448
|
+
: '| (none) | - | No workflows defined |';
|
|
449
|
+
|
|
450
|
+
return `# ${name} - Workflows
|
|
451
|
+
|
|
452
|
+
Agent workflows for the ${name} skill.
|
|
453
|
+
|
|
454
|
+
## Available Workflows
|
|
455
|
+
|
|
456
|
+
| Name | File | Description |
|
|
457
|
+
|------|------|-------------|
|
|
458
|
+
${workflowTable}
|
|
459
|
+
|
|
460
|
+
## Creating Workflows
|
|
461
|
+
|
|
462
|
+
1. Create a new \`.md\` file in this directory
|
|
463
|
+
2. Use the agent template format
|
|
464
|
+
3. Reference context from \`../context/\`
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
*Part of ${name} skill*
|
|
468
|
+
`;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* L1 Orchestrator template for RAG pipeline
|
|
473
|
+
*/
|
|
474
|
+
export function generateOrchestratorTemplate(config) {
|
|
475
|
+
const { name, description, specialists = [], tokenLimits = {} } = config;
|
|
476
|
+
|
|
477
|
+
const specialistsMarkdown = specialists
|
|
478
|
+
.map(
|
|
479
|
+
(s) => `### ${s.name}
|
|
480
|
+
|
|
481
|
+
**File:** \`${s.file}\`
|
|
482
|
+
**Level:** ${s.level || 'L2'}
|
|
483
|
+
|
|
484
|
+
${s.description}
|
|
485
|
+
`
|
|
486
|
+
)
|
|
487
|
+
.join('\n');
|
|
488
|
+
|
|
489
|
+
return `---
|
|
490
|
+
name: ${name}-orchestrator
|
|
491
|
+
description: L1 Orchestrator for ${description}
|
|
492
|
+
level: L1
|
|
493
|
+
tools: Task, Read, Grep, Glob
|
|
494
|
+
model: sonnet
|
|
495
|
+
capabilities:
|
|
496
|
+
- token_monitoring
|
|
497
|
+
- context_compaction
|
|
498
|
+
- state_persistence
|
|
499
|
+
- auto_respawn
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
# ${name} - L1 Orchestrator
|
|
503
|
+
|
|
504
|
+
Central orchestrator for ${description}.
|
|
505
|
+
|
|
506
|
+
## Role
|
|
507
|
+
|
|
508
|
+
This orchestrator:
|
|
509
|
+
1. Routes requests to appropriate L2 specialists
|
|
510
|
+
2. Monitors token usage and triggers compaction
|
|
511
|
+
3. Aggregates results from specialists
|
|
512
|
+
4. Maintains session state
|
|
513
|
+
|
|
514
|
+
## Token Management
|
|
515
|
+
|
|
516
|
+
| Threshold | Action |
|
|
517
|
+
|-----------|--------|
|
|
518
|
+
| 75% | Compact context (summarize and archive) |
|
|
519
|
+
| 90% | Spawn continuation agent |
|
|
520
|
+
| 95% | Force compaction + respawn |
|
|
521
|
+
|
|
522
|
+
**Limits:**
|
|
523
|
+
- Compact threshold: ${tokenLimits.compact || 75}%
|
|
524
|
+
- Respawn threshold: ${tokenLimits.respawn || 90}%
|
|
525
|
+
|
|
526
|
+
## L2 Specialists
|
|
527
|
+
|
|
528
|
+
${specialistsMarkdown || 'No specialists defined.'}
|
|
529
|
+
|
|
530
|
+
## Workflow
|
|
531
|
+
|
|
532
|
+
### Phase 1: Analyze Request
|
|
533
|
+
|
|
534
|
+
1. Parse incoming request
|
|
535
|
+
2. Identify required specialists
|
|
536
|
+
3. Check token budget
|
|
537
|
+
|
|
538
|
+
### Phase 2: Delegate
|
|
539
|
+
|
|
540
|
+
1. Spawn appropriate L2 specialists
|
|
541
|
+
2. Pass context and instructions
|
|
542
|
+
3. Monitor progress
|
|
543
|
+
|
|
544
|
+
### Phase 3: Aggregate
|
|
545
|
+
|
|
546
|
+
1. Collect specialist results
|
|
547
|
+
2. Synthesize findings
|
|
548
|
+
3. Prepare final output
|
|
549
|
+
|
|
550
|
+
### Phase 4: Report
|
|
551
|
+
|
|
552
|
+
1. Present aggregated results
|
|
553
|
+
2. Update state if needed
|
|
554
|
+
3. Suggest next steps
|
|
555
|
+
|
|
556
|
+
## State Persistence
|
|
557
|
+
|
|
558
|
+
Session state saved to:
|
|
559
|
+
\`.claude/sessions/${name}-{session-id}.json\`
|
|
560
|
+
|
|
561
|
+
## Continuation Protocol
|
|
562
|
+
|
|
563
|
+
When respawning:
|
|
564
|
+
1. Save current state
|
|
565
|
+
2. Generate continuation prompt
|
|
566
|
+
3. Spawn new orchestrator instance
|
|
567
|
+
4. Resume from saved state
|
|
568
|
+
|
|
569
|
+
---
|
|
570
|
+
*Created by gtask create-agent - ${new Date().toISOString()}*
|
|
571
|
+
`;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Event types for hooks
|
|
576
|
+
*/
|
|
577
|
+
export const HOOK_EVENT_TYPES = {
|
|
578
|
+
PreToolUse: {
|
|
579
|
+
name: 'PreToolUse',
|
|
580
|
+
description: 'Triggers before a tool is executed (can block)',
|
|
581
|
+
canBlock: true,
|
|
582
|
+
useCase: 'Enforce patterns, validate inputs, prevent operations',
|
|
583
|
+
},
|
|
584
|
+
PostToolUse: {
|
|
585
|
+
name: 'PostToolUse',
|
|
586
|
+
description: 'Triggers after a tool completes (cannot block)',
|
|
587
|
+
canBlock: false,
|
|
588
|
+
useCase: 'Log operations, verify results, cleanup',
|
|
589
|
+
},
|
|
590
|
+
UserPromptSubmit: {
|
|
591
|
+
name: 'UserPromptSubmit',
|
|
592
|
+
description: 'Triggers when user sends a message (cannot block)',
|
|
593
|
+
canBlock: false,
|
|
594
|
+
useCase: 'Inject context, modify prompts, trigger workflows',
|
|
595
|
+
},
|
|
596
|
+
SessionStart: {
|
|
597
|
+
name: 'SessionStart',
|
|
598
|
+
description: 'Triggers when a session begins',
|
|
599
|
+
canBlock: false,
|
|
600
|
+
useCase: 'Initialize state, load context, set up environment',
|
|
601
|
+
},
|
|
602
|
+
SessionStop: {
|
|
603
|
+
name: 'SessionStop',
|
|
604
|
+
description: 'Triggers when a session ends',
|
|
605
|
+
canBlock: false,
|
|
606
|
+
useCase: 'Save state, cleanup, generate reports',
|
|
607
|
+
},
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* Available tools for hooks
|
|
612
|
+
*/
|
|
613
|
+
export const HOOK_TOOLS = [
|
|
614
|
+
'Edit',
|
|
615
|
+
'Write',
|
|
616
|
+
'Read',
|
|
617
|
+
'Bash',
|
|
618
|
+
'Grep',
|
|
619
|
+
'Glob',
|
|
620
|
+
'Task',
|
|
621
|
+
'WebFetch',
|
|
622
|
+
'WebSearch',
|
|
623
|
+
];
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Complexity levels
|
|
627
|
+
*/
|
|
628
|
+
export const COMPLEXITY_LEVELS = {
|
|
629
|
+
low: {
|
|
630
|
+
name: 'Low',
|
|
631
|
+
description: 'Simple, quick tasks',
|
|
632
|
+
duration: '< 5 minutes',
|
|
633
|
+
},
|
|
634
|
+
medium: {
|
|
635
|
+
name: 'Medium',
|
|
636
|
+
description: 'Multi-step tasks',
|
|
637
|
+
duration: '5-20 minutes',
|
|
638
|
+
},
|
|
639
|
+
high: {
|
|
640
|
+
name: 'High',
|
|
641
|
+
description: 'Complex, multi-agent tasks',
|
|
642
|
+
duration: '20-60+ minutes',
|
|
643
|
+
},
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
/**
|
|
647
|
+
* Agent levels
|
|
648
|
+
*/
|
|
649
|
+
export const AGENT_LEVELS = {
|
|
650
|
+
L1: {
|
|
651
|
+
name: 'L1 - Orchestrator',
|
|
652
|
+
description: 'Routes and coordinates L2 specialists',
|
|
653
|
+
tokenLimit: 'Full context',
|
|
654
|
+
model: 'sonnet or opus',
|
|
655
|
+
},
|
|
656
|
+
L2: {
|
|
657
|
+
name: 'L2 - Specialist',
|
|
658
|
+
description: 'Deep domain expertise',
|
|
659
|
+
tokenLimit: '1-8K tokens',
|
|
660
|
+
model: 'sonnet',
|
|
661
|
+
},
|
|
662
|
+
L3: {
|
|
663
|
+
name: 'L3 - Worker',
|
|
664
|
+
description: 'Parallel atomic tasks',
|
|
665
|
+
tokenLimit: '500 tokens',
|
|
666
|
+
model: 'haiku',
|
|
667
|
+
},
|
|
668
|
+
};
|