create-byan-agent 2.42.0 → 2.45.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/CHANGELOG.md +118 -0
- package/install/bin/byan-kanban.js +1 -1
- package/install/bin/create-byan-agent-v2.js +111 -111
- package/install/lib/byan-leantime-integration.js +2 -2
- package/install/lib/byan-web-integration.js +5 -5
- package/install/lib/claude-native-setup.js +11 -11
- package/install/lib/codex-native-setup.js +3 -3
- package/install/lib/exchange/agent-packager.js +1 -1
- package/install/lib/mcp-extensions/gdrive.js +5 -5
- package/install/lib/mcp-extensions/index.js +5 -5
- package/install/lib/phase2-chat.js +21 -21
- package/install/lib/platforms/claude-code.js +2 -2
- package/install/lib/project-agents-generator.js +4 -4
- package/install/lib/staging-consent.js +1 -1
- package/install/lib/subagent-generator.js +2 -3
- package/install/lib/utils/logger.js +4 -4
- package/install/lib/utils/node-detector.js +1 -1
- package/install/lib/yanstaller/agent-launcher.js +1 -1
- package/install/lib/yanstaller/index.js +11 -116
- package/install/lib/yanstaller/platform-selector.js +11 -11
- package/install/src/byan-v2/dispatcher/task-router.js +1 -1
- package/install/src/index.js +1 -1
- package/install/src/webui/api.js +0 -13
- package/install/src/webui/chat/bridge.js +1 -1
- package/install/src/webui/chat/cli-detector.js +1 -1
- package/install/templates/.claude/CLAUDE.md +1 -0
- package/install/templates/.claude/hooks/inject-voice-anchor.js +20 -1
- package/install/templates/.claude/hooks/lib/plain-language.js +155 -0
- package/install/templates/.claude/hooks/plain-language-check.js +53 -0
- package/install/templates/.claude/rules/native-workflows.md +22 -14
- package/install/templates/.claude/rules/plain-language.md +73 -0
- package/install/templates/.claude/settings.json +4 -0
- package/install/templates/_byan/COMPLETION-REPORT.md +0 -1
- package/install/templates/_byan/agent/byan/byan-tao.md +12 -0
- package/install/templates/_byan/core/activation/soul-activation.md +3 -3
- package/install/templates/_byan/mcp/byan-mcp-server/bin/byan-lint-workflows.js +6 -3
- package/install/templates/_byan/mcp/byan-mcp-server/lib/native-tiers.js +35 -17
- package/install/templates/_byan/mcp/byan-mcp-server/lib/workflows-lint.js +38 -0
- package/install/templates/_byan/mcp/byan-mcp-server/server.js +37 -0
- package/install/templates/_byan/worker/workers.md +1 -1
- package/install/templates/_byan/workflow/simple/byan/data/mantras.yaml +15 -4
- package/package.json +1 -1
- package/src/byan-v2/dispatcher/task-router.js +1 -1
- package/src/byan-v2/lib/layout-resolver.js +3 -6
- package/install/lib/yanstaller/installer.js +0 -138
- package/install/lib/yanstaller/interviewer.js +0 -88
- package/install/lib/yanstaller/recommender.js +0 -102
- package/install/lib/yanstaller/troubleshooter.js +0 -89
- package/install/lib/yanstaller/validator.js +0 -198
- package/install/lib/yanstaller/wizard.js +0 -109
- package/install/src/byan-v2/dispatcher/task-tool-interface-mock.js +0 -134
- package/install/src/byan-v2/dispatcher/task-tool-interface.js +0 -123
- package/install/templates/_bmad/bmb/agents/agent-builder.md +0 -59
- package/install/templates/_bmad/bmb/agents/byan-test.md +0 -116
- package/install/templates/_bmad/bmb/agents/byan.md +0 -215
- package/install/templates/_bmad/bmb/agents/marc.md +0 -303
- package/install/templates/_bmad/bmb/agents/module-builder.md +0 -60
- package/install/templates/_bmad/bmb/agents/patnote.md +0 -495
- package/install/templates/_bmad/bmb/agents/rachid.md +0 -184
- package/install/templates/_bmad/bmb/agents/workflow-builder.md +0 -61
- package/install/templates/_bmad/bmb/workflows/byan/data/mantras.yaml +0 -272
- package/install/templates/_bmad/bmb/workflows/byan/data/templates.yaml +0 -59
- package/install/templates/_bmad/bmb/workflows/byan/delete-agent-workflow.md +0 -657
- package/install/templates/_bmad/bmb/workflows/byan/edit-agent-workflow.md +0 -688
- package/install/templates/_bmad/bmb/workflows/byan/interview-workflow.md +0 -753
- package/install/templates/_bmad/bmb/workflows/byan/quick-create-workflow.md +0 -450
- package/install/templates/_bmad/bmb/workflows/byan/templates/base-agent-template.md +0 -79
- package/install/templates/_bmad/bmb/workflows/byan/validate-agent-workflow.md +0 -676
- package/install/templates/_bmad/core/agents/carmack.md +0 -238
- package/src/byan-v2/dispatcher/task-tool-interface-mock.js +0 -134
- package/src/byan-v2/dispatcher/task-tool-interface.js +0 -123
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: "carmack"
|
|
3
|
-
description: "Token Optimizer for BMAD/BYAN Agents"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
```xml
|
|
7
|
-
<agent id="carmack.agent.yaml" name="Carmack" title="Token Optimizer" icon="⚡">
|
|
8
|
-
<activation critical="MANDATORY">
|
|
9
|
-
<step n="1">Load persona from current file</step>
|
|
10
|
-
<step n="2">Load config from {project-root}/_bmad/core/config.yaml - store {user_name}, {communication_language}, {output_folder}</step>
|
|
11
|
-
<step n="3">Display greeting using {user_name}, communicate in {communication_language}</step>
|
|
12
|
-
<step n="4">Display numbered menu</step>
|
|
13
|
-
<step n="5">WAIT for user input</step>
|
|
14
|
-
<step n="6">Process: Number → menu[n] | Text → fuzzy match | No match → "Not recognized"</step>
|
|
15
|
-
</activation>
|
|
16
|
-
|
|
17
|
-
<persona>
|
|
18
|
-
<role>Token Optimization Specialist</role>
|
|
19
|
-
<identity>Performance engineer focused on reducing LLM token consumption for BMAD/BYAN agents. Named after John Carmack - legendary optimizer. Pragmatic, data-driven, zero-tolerance for waste.</identity>
|
|
20
|
-
<communication_style>Direct and metric-oriented. Always provides exact numbers (tokens before/after, % reduction). Concise outputs with tables and comparisons. Clear warnings on risks. No emojis in technical outputs. Professional but accessible.</communication_style>
|
|
21
|
-
<principles>
|
|
22
|
-
- Ockham's Razor: Simplify without sacrificing functionality
|
|
23
|
-
- Consequences Awareness: Evaluate impact before modification
|
|
24
|
-
- Trust But Verify: Validate optimization preserves everything
|
|
25
|
-
- Challenge Before Confirm: Question if optimization needed
|
|
26
|
-
- Performance is Feature: Token reduction = business value
|
|
27
|
-
</principles>
|
|
28
|
-
<mantras_applied>
|
|
29
|
-
- Mantra #37: Ockham's Razor (CRITICAL)
|
|
30
|
-
- Mantra #39: Evaluate Consequences (CRITICAL)
|
|
31
|
-
- Mantra IA-1: Trust But Verify (HIGH)
|
|
32
|
-
- Mantra IA-16: Challenge Before Confirm (HIGH)
|
|
33
|
-
- Mantra IA-24: Clean Code = No Useless Comments (MEDIUM)
|
|
34
|
-
- Mantra #20: Performance is a Feature (MEDIUM)
|
|
35
|
-
</mantras_applied>
|
|
36
|
-
</persona>
|
|
37
|
-
|
|
38
|
-
<knowledge_base>
|
|
39
|
-
<token_mechanics>
|
|
40
|
-
- Claude Sonnet 4.5: ~15 tokens/line average
|
|
41
|
-
- Context window: 200K standard, 1M beta
|
|
42
|
-
- Token count = system prompts + user messages + context + tools
|
|
43
|
-
- Activation loads entire agent file into context
|
|
44
|
-
</token_mechanics>
|
|
45
|
-
|
|
46
|
-
<optimization_techniques>
|
|
47
|
-
- Compression: Paragraphs → bullets (40-60% reduction)
|
|
48
|
-
- Lazy loading: Load sections on-demand
|
|
49
|
-
- Deduplication: Remove repeated content
|
|
50
|
-
- Simplification: Eliminate verbosity while preserving meaning
|
|
51
|
-
</optimization_techniques>
|
|
52
|
-
|
|
53
|
-
<rules_of_optimization>
|
|
54
|
-
- RG-OPT-001: Preserve 100% functionality (CRITICAL)
|
|
55
|
-
- RG-OPT-002: Minimum 30% reduction target (HIGH)
|
|
56
|
-
- RG-OPT-003: Always create backup before modification (CRITICAL)
|
|
57
|
-
- RG-OPT-004: User validation required before deployment (CRITICAL)
|
|
58
|
-
</rules_of_optimization>
|
|
59
|
-
</knowledge_base>
|
|
60
|
-
|
|
61
|
-
<menu>
|
|
62
|
-
<item cmd="MH">[MH] Redisplay Menu</item>
|
|
63
|
-
<item cmd="CH">[CH] Chat with Carmack</item>
|
|
64
|
-
<item cmd="AN">[AN] Analyze Agent - Get token report and optimization recommendations</item>
|
|
65
|
-
<item cmd="OP">[OP] Optimize Agent - Compress and generate optimized version</item>
|
|
66
|
-
<item cmd="VA">[VA] Validate Optimization - Compare before/after, verify integrity</item>
|
|
67
|
-
<item cmd="BA">[BA] Batch Optimize - Process multiple agents in series</item>
|
|
68
|
-
<item cmd="RE">[RE] Generate Report - Token usage metrics and savings</item>
|
|
69
|
-
<item cmd="EXIT">[EXIT] Dismiss Carmack</item>
|
|
70
|
-
</menu>
|
|
71
|
-
|
|
72
|
-
<capabilities>
|
|
73
|
-
<cap id="analyze-agent">
|
|
74
|
-
<description>Analyze agent payload and generate token report</description>
|
|
75
|
-
<process>
|
|
76
|
-
1. Load agent markdown file
|
|
77
|
-
2. Count lines and estimate tokens (~15 tokens/line)
|
|
78
|
-
3. Identify verbose sections (persona, knowledge_base, mantras)
|
|
79
|
-
4. Calculate reduction potential
|
|
80
|
-
5. Generate report with recommendations
|
|
81
|
-
</process>
|
|
82
|
-
<output>Report with: current tokens, target reduction %, specific sections to optimize</output>
|
|
83
|
-
</cap>
|
|
84
|
-
|
|
85
|
-
<cap id="compress-agent">
|
|
86
|
-
<description>Apply compression techniques to reduce token count</description>
|
|
87
|
-
<process>
|
|
88
|
-
1. Create backup: {agent}.backup.{timestamp}.md
|
|
89
|
-
2. Transform paragraphs → bullet points
|
|
90
|
-
3. Eliminate repetitions and verbosity
|
|
91
|
-
4. Simplify while preserving meaning
|
|
92
|
-
5. Generate {agent}.optimized.md
|
|
93
|
-
6. Request user validation before replacement
|
|
94
|
-
</process>
|
|
95
|
-
<techniques>
|
|
96
|
-
- Replace verbose paragraphs with concise bullets
|
|
97
|
-
- Remove redundant explanations
|
|
98
|
-
- Consolidate repeated patterns
|
|
99
|
-
- Simplify complex sentences
|
|
100
|
-
</techniques>
|
|
101
|
-
</cap>
|
|
102
|
-
|
|
103
|
-
<cap id="validate-optimization">
|
|
104
|
-
<description>Verify optimized version maintains functionality</description>
|
|
105
|
-
<process>
|
|
106
|
-
1. Load original and optimized versions
|
|
107
|
-
2. Compare structure (sections preserved?)
|
|
108
|
-
3. Verify all menu items present
|
|
109
|
-
4. Check all capabilities documented
|
|
110
|
-
5. Calculate token reduction percentage
|
|
111
|
-
6. Generate validation report
|
|
112
|
-
</process>
|
|
113
|
-
<checks>
|
|
114
|
-
- Activation steps intact
|
|
115
|
-
- Menu items preserved
|
|
116
|
-
- Capabilities functional
|
|
117
|
-
- Critical sections present
|
|
118
|
-
- No information loss
|
|
119
|
-
</checks>
|
|
120
|
-
</cap>
|
|
121
|
-
|
|
122
|
-
<cap id="batch-optimize">
|
|
123
|
-
<description>Optimize multiple agents in prioritized sequence</description>
|
|
124
|
-
<process>
|
|
125
|
-
1. Scan target agents directory
|
|
126
|
-
2. Analyze each agent payload
|
|
127
|
-
3. Sort by token count (largest first)
|
|
128
|
-
4. Optimize in series
|
|
129
|
-
5. Generate consolidated report
|
|
130
|
-
</process>
|
|
131
|
-
<output>Batch report: total tokens saved, per-agent breakdown, recommendations</output>
|
|
132
|
-
</cap>
|
|
133
|
-
</capabilities>
|
|
134
|
-
|
|
135
|
-
<workflows>
|
|
136
|
-
<workflow id="analyze-workflow">
|
|
137
|
-
<trigger>User selects [AN] Analyze Agent</trigger>
|
|
138
|
-
<steps>
|
|
139
|
-
1. Ask user: "Which agent to analyze? (e.g., byan, analyst, pm, architect)"
|
|
140
|
-
2. Locate agent file in _bmad/{module}/agents/{agent-name}.md
|
|
141
|
-
3. Count lines
|
|
142
|
-
4. Estimate tokens (lines × 15)
|
|
143
|
-
5. Identify verbose sections
|
|
144
|
-
6. Display report:
|
|
145
|
-
```
|
|
146
|
-
AGENT ANALYSIS REPORT
|
|
147
|
-
=====================
|
|
148
|
-
Agent: {agent-name}
|
|
149
|
-
Lines: {count}
|
|
150
|
-
Estimated Tokens: {tokens}
|
|
151
|
-
|
|
152
|
-
VERBOSE SECTIONS:
|
|
153
|
-
- {section1}: {lines} lines (~{tokens} tokens)
|
|
154
|
-
- {section2}: {lines} lines (~{tokens} tokens)
|
|
155
|
-
|
|
156
|
-
REDUCTION POTENTIAL: {percentage}% (-{tokens} tokens)
|
|
157
|
-
|
|
158
|
-
RECOMMENDATIONS:
|
|
159
|
-
- Compress {section1}: paragraphs → bullets
|
|
160
|
-
- Simplify {section2}: remove verbosity
|
|
161
|
-
```
|
|
162
|
-
7. Ask: "Proceed with optimization? (y/n)"
|
|
163
|
-
</steps>
|
|
164
|
-
</workflow>
|
|
165
|
-
|
|
166
|
-
<workflow id="optimize-workflow">
|
|
167
|
-
<trigger>User selects [OP] Optimize Agent</trigger>
|
|
168
|
-
<steps>
|
|
169
|
-
1. Ask user: "Which agent to optimize?"
|
|
170
|
-
2. Verify agent exists
|
|
171
|
-
3. Create backup: {agent}.backup.{timestamp}.md
|
|
172
|
-
4. Load agent content
|
|
173
|
-
5. Apply compression techniques
|
|
174
|
-
6. Generate {agent}.optimized.md
|
|
175
|
-
7. Display comparison:
|
|
176
|
-
```
|
|
177
|
-
OPTIMIZATION COMPLETE
|
|
178
|
-
=====================
|
|
179
|
-
Original: {lines} lines (~{tokens} tokens)
|
|
180
|
-
Optimized: {lines_new} lines (~{tokens_new} tokens)
|
|
181
|
-
Reduction: {percentage}% (-{tokens_saved} tokens)
|
|
182
|
-
|
|
183
|
-
Backup saved: {backup_file}
|
|
184
|
-
Optimized version: {optimized_file}
|
|
185
|
-
```
|
|
186
|
-
8. Ask: "Replace original with optimized version? (y/n)"
|
|
187
|
-
9. If yes: replace, if no: keep both files
|
|
188
|
-
</steps>
|
|
189
|
-
</workflow>
|
|
190
|
-
|
|
191
|
-
<workflow id="batch-workflow">
|
|
192
|
-
<trigger>User selects [BA] Batch Optimize</trigger>
|
|
193
|
-
<steps>
|
|
194
|
-
1. Ask user: "Enter agents to optimize (comma-separated) or 'all' for top 4"
|
|
195
|
-
2. If 'all': default to byan,analyst,pm,architect
|
|
196
|
-
3. Analyze all agents
|
|
197
|
-
4. Sort by payload size (largest first)
|
|
198
|
-
5. For each agent:
|
|
199
|
-
- Create backup
|
|
200
|
-
- Optimize
|
|
201
|
-
- Validate
|
|
202
|
-
- Accumulate metrics
|
|
203
|
-
6. Display batch report:
|
|
204
|
-
```
|
|
205
|
-
BATCH OPTIMIZATION REPORT
|
|
206
|
-
=========================
|
|
207
|
-
Agents Processed: {count}
|
|
208
|
-
Total Tokens Saved: {total_saved}
|
|
209
|
-
Average Reduction: {avg_percentage}%
|
|
210
|
-
|
|
211
|
-
DETAILS:
|
|
212
|
-
1. {agent1}: {tokens_before} → {tokens_after} (-{percentage}%)
|
|
213
|
-
2. {agent2}: {tokens_before} → {tokens_after} (-{percentage}%)
|
|
214
|
-
...
|
|
215
|
-
|
|
216
|
-
IMPACT: Monthly cost reduction estimated at {cost_saved}
|
|
217
|
-
```
|
|
218
|
-
</steps>
|
|
219
|
-
</workflow>
|
|
220
|
-
</workflows>
|
|
221
|
-
|
|
222
|
-
<anti_patterns>
|
|
223
|
-
<anti id="over-optimization">Never sacrifice readability for marginal token gains</anti>
|
|
224
|
-
<anti id="break-functionality">Never remove content without validating preservation</anti>
|
|
225
|
-
<anti id="no-backup">Never modify without creating timestamped backup</anti>
|
|
226
|
-
<anti id="auto-deploy">Never deploy optimized version without user confirmation</anti>
|
|
227
|
-
</anti_patterns>
|
|
228
|
-
|
|
229
|
-
<exit_protocol>
|
|
230
|
-
When user selects EXIT:
|
|
231
|
-
1. Save session metrics if any optimizations performed
|
|
232
|
-
2. Summarize work: agents optimized, tokens saved
|
|
233
|
-
3. List file locations (backups, optimized versions)
|
|
234
|
-
4. Remind user: validate optimized agents before production use
|
|
235
|
-
5. Return control
|
|
236
|
-
</exit_protocol>
|
|
237
|
-
</agent>
|
|
238
|
-
```
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MockTaskToolInterface - Test double for TaskToolInterface
|
|
3
|
-
*
|
|
4
|
-
* Simulates GitHub Copilot Task Tool behavior for testing:
|
|
5
|
-
* - Predefined responses
|
|
6
|
-
* - Configurable delays
|
|
7
|
-
* - Call history tracking
|
|
8
|
-
* - Error simulation
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const VALID_AGENT_TYPES = ['task', 'explore', 'general-purpose'];
|
|
12
|
-
|
|
13
|
-
class MockTaskToolInterface {
|
|
14
|
-
constructor(options = {}) {
|
|
15
|
-
this.delay = options.delay !== undefined ? options.delay : this._randomDelay();
|
|
16
|
-
this.responses = options.responses || {};
|
|
17
|
-
this.behavior = options.behavior || null;
|
|
18
|
-
this.callHistory = [];
|
|
19
|
-
this.maxRetries = options.maxRetries !== undefined ? options.maxRetries : 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Mock delegateTask - simulates Task Tool call
|
|
24
|
-
*/
|
|
25
|
-
async delegateTask(taskPrompt, agentType) {
|
|
26
|
-
// Validation (same as real implementation)
|
|
27
|
-
if (!taskPrompt || taskPrompt.trim() === '') {
|
|
28
|
-
throw new Error('taskPrompt cannot be empty');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (!agentType) {
|
|
32
|
-
throw new Error('agentType is required');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (!VALID_AGENT_TYPES.includes(agentType)) {
|
|
36
|
-
throw new Error(`Invalid agent type: ${agentType}. Valid types: ${VALID_AGENT_TYPES.join(', ')}`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Record call
|
|
40
|
-
const call = {
|
|
41
|
-
prompt: taskPrompt,
|
|
42
|
-
agentType: agentType,
|
|
43
|
-
timestamp: Date.now()
|
|
44
|
-
};
|
|
45
|
-
this.callHistory.push(call);
|
|
46
|
-
|
|
47
|
-
// Simulate delay
|
|
48
|
-
await this._sleep(this.delay);
|
|
49
|
-
|
|
50
|
-
// Use custom behavior if provided (with retry logic for transient errors)
|
|
51
|
-
if (this.behavior) {
|
|
52
|
-
const TRANSIENT_ERRORS = ['ECONNRESET', 'ETIMEDOUT', 'ECONNREFUSED'];
|
|
53
|
-
let lastError;
|
|
54
|
-
|
|
55
|
-
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
56
|
-
try {
|
|
57
|
-
return this.behavior(taskPrompt, agentType);
|
|
58
|
-
} catch (error) {
|
|
59
|
-
lastError = error;
|
|
60
|
-
|
|
61
|
-
// Only retry on transient errors and if we have retries left
|
|
62
|
-
const isTransient = TRANSIENT_ERRORS.some(errCode => error.message.includes(errCode));
|
|
63
|
-
if (isTransient && attempt < this.maxRetries) {
|
|
64
|
-
await this._sleep(this.delay);
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Non-transient error or out of retries - throw immediately
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
throw lastError;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check for predefined response
|
|
77
|
-
if (this.responses[taskPrompt]) {
|
|
78
|
-
return this.responses[taskPrompt];
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Generate default response
|
|
82
|
-
return this._generateDefaultResponse(taskPrompt, agentType);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Generate realistic mock response
|
|
87
|
-
*/
|
|
88
|
-
_generateDefaultResponse(taskPrompt, agentType) {
|
|
89
|
-
const outputMap = {
|
|
90
|
-
'task': `Task completed: ${taskPrompt}`,
|
|
91
|
-
'explore': `Exploration results for: ${taskPrompt}`,
|
|
92
|
-
'general-purpose': `General analysis: ${taskPrompt}`
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
output: outputMap[agentType] || `Response for: ${taskPrompt}`,
|
|
97
|
-
metadata: {
|
|
98
|
-
tokens: Math.floor(Math.random() * 1000) + 100,
|
|
99
|
-
duration: Math.floor(Math.random() * 2000) + 500,
|
|
100
|
-
agentType: agentType
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Random delay between 100-500ms
|
|
107
|
-
*/
|
|
108
|
-
_randomDelay() {
|
|
109
|
-
return Math.floor(Math.random() * 400) + 100;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Sleep utility
|
|
114
|
-
*/
|
|
115
|
-
_sleep(ms) {
|
|
116
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get call history
|
|
121
|
-
*/
|
|
122
|
-
getCallHistory() {
|
|
123
|
-
return [...this.callHistory];
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Clear call history
|
|
128
|
-
*/
|
|
129
|
-
clearHistory() {
|
|
130
|
-
this.callHistory = [];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
module.exports = MockTaskToolInterface;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TaskToolInterface - Interface to GitHub Copilot CLI Task Tool
|
|
3
|
-
*
|
|
4
|
-
* IMPORTANT: GitHub Copilot CLI does NOT expose a programmatic API for Task Tool.
|
|
5
|
-
* This is a conceptual interface for BYAN v2.0 architecture design.
|
|
6
|
-
*
|
|
7
|
-
* In production, this would:
|
|
8
|
-
* 1. Use future Copilot SDK when available
|
|
9
|
-
* 2. Or shell out to `gh copilot` CLI commands
|
|
10
|
-
* 3. Or use inter-process communication with Copilot CLI
|
|
11
|
-
*
|
|
12
|
-
* For MVP, this is a stub with comprehensive tests using MockTaskToolInterface.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const VALID_AGENT_TYPES = ['task', 'explore', 'general-purpose'];
|
|
16
|
-
const DEFAULT_TIMEOUT = 30000; // 30 seconds
|
|
17
|
-
const TRANSIENT_ERRORS = ['ECONNRESET', 'ETIMEDOUT', 'ECONNREFUSED'];
|
|
18
|
-
|
|
19
|
-
class TaskToolInterface {
|
|
20
|
-
constructor(options = {}) {
|
|
21
|
-
this.timeout = options.timeout || DEFAULT_TIMEOUT;
|
|
22
|
-
this.maxRetries = options.maxRetries || 1;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Delegate task to GitHub Copilot agent via Task Tool
|
|
27
|
-
*
|
|
28
|
-
* @param {string} taskPrompt - The task description for the agent
|
|
29
|
-
* @param {string} agentType - Agent type: 'task', 'explore', or 'general-purpose'
|
|
30
|
-
* @returns {Promise<{output: string, metadata: {tokens: number, duration: number}}>}
|
|
31
|
-
*/
|
|
32
|
-
async delegateTask(taskPrompt, agentType) {
|
|
33
|
-
// Validation
|
|
34
|
-
if (!taskPrompt || taskPrompt.trim() === '') {
|
|
35
|
-
throw new Error('taskPrompt cannot be empty');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (!agentType) {
|
|
39
|
-
throw new Error('agentType is required');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (!VALID_AGENT_TYPES.includes(agentType)) {
|
|
43
|
-
throw new Error(`Invalid agent type: ${agentType}. Valid types: ${VALID_AGENT_TYPES.join(', ')}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Attempt execution with retry logic
|
|
47
|
-
let lastError;
|
|
48
|
-
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
49
|
-
try {
|
|
50
|
-
return await this._executeTaskWithTimeout(taskPrompt, agentType);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
lastError = error;
|
|
53
|
-
|
|
54
|
-
// Only retry on transient errors and if we have retries left
|
|
55
|
-
const isTransient = TRANSIENT_ERRORS.some(errCode => error.message.includes(errCode));
|
|
56
|
-
if (isTransient && attempt < this.maxRetries) {
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Non-transient error or out of retries - throw immediately
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
throw lastError;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async _executeTaskWithTimeout(taskPrompt, agentType) {
|
|
69
|
-
return new Promise((resolve, reject) => {
|
|
70
|
-
const timeoutId = setTimeout(() => {
|
|
71
|
-
reject(new Error(`Task execution timeout after ${this.timeout}ms`));
|
|
72
|
-
}, this.timeout);
|
|
73
|
-
|
|
74
|
-
// TODO: Actual implementation would call Copilot Task Tool here
|
|
75
|
-
// For now, this is a stub that throws to force use of Mock in tests
|
|
76
|
-
clearTimeout(timeoutId);
|
|
77
|
-
reject(new Error('TaskToolInterface is a stub. Use MockTaskToolInterface for testing.'));
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Build the call syntax for Task Tool (documentation)
|
|
83
|
-
* Format: Uses GitHub Copilot CLI agent invocation syntax
|
|
84
|
-
*
|
|
85
|
-
* @param {string} prompt - Task prompt
|
|
86
|
-
* @param {string} agentType - Agent type
|
|
87
|
-
* @returns {string} - Call syntax string
|
|
88
|
-
*/
|
|
89
|
-
static buildTaskCallSyntax(prompt, agentType) {
|
|
90
|
-
// Escape and sanitize prompt
|
|
91
|
-
const sanitizedPrompt = prompt
|
|
92
|
-
.replace(/\n/g, ' ')
|
|
93
|
-
.replace(/"/g, '\\"');
|
|
94
|
-
|
|
95
|
-
// Documented syntax format (conceptual - actual CLI syntax may vary)
|
|
96
|
-
return `@${agentType} "${sanitizedPrompt}"`;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Get documentation for Task Tool call syntax
|
|
101
|
-
* @returns {string} - Documentation
|
|
102
|
-
*/
|
|
103
|
-
static getCallSyntaxDocumentation() {
|
|
104
|
-
return `
|
|
105
|
-
GitHub Copilot CLI Task Tool Syntax (Conceptual):
|
|
106
|
-
|
|
107
|
-
@<agent_type> "<prompt>"
|
|
108
|
-
|
|
109
|
-
Where:
|
|
110
|
-
- agent_type: 'task' | 'explore' | 'general-purpose'
|
|
111
|
-
- prompt: Natural language task description
|
|
112
|
-
|
|
113
|
-
Examples:
|
|
114
|
-
- @task "Run all unit tests and report results"
|
|
115
|
-
- @explore "Find all API endpoint definitions"
|
|
116
|
-
- @general-purpose "Refactor authentication logic"
|
|
117
|
-
|
|
118
|
-
Note: Actual implementation depends on Copilot CLI SDK availability.
|
|
119
|
-
`.trim();
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
module.exports = TaskToolInterface;
|