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,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TROUBLESHOOTER Module
|
|
3
|
-
*
|
|
4
|
-
* Diagnoses and fixes common installation errors.
|
|
5
|
-
*
|
|
6
|
-
* Phase 5: 40h development
|
|
7
|
-
*
|
|
8
|
-
* @module yanstaller/troubleshooter
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} DiagnosticResult
|
|
13
|
-
* @property {string} error - Error type
|
|
14
|
-
* @property {string} cause - Root cause
|
|
15
|
-
* @property {string} solution - Recommended solution
|
|
16
|
-
* @property {boolean} canAutoFix - Whether auto-fix is available
|
|
17
|
-
* @property {Function} [autoFix] - Auto-fix function
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Diagnose installation error
|
|
22
|
-
*
|
|
23
|
-
* @param {Error} error - Installation error
|
|
24
|
-
* @param {Object} context - Installation context
|
|
25
|
-
* @returns {Promise<DiagnosticResult>}
|
|
26
|
-
*/
|
|
27
|
-
async function diagnose(error, context) {
|
|
28
|
-
// TODO: Pattern match error and return diagnostic
|
|
29
|
-
// Common errors:
|
|
30
|
-
// - Node version too old
|
|
31
|
-
// - Permission denied
|
|
32
|
-
// - Git not found
|
|
33
|
-
// - Platform not detected
|
|
34
|
-
// - Network error (template download)
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
error: error.message,
|
|
38
|
-
cause: 'Unknown',
|
|
39
|
-
solution: 'Please check logs',
|
|
40
|
-
canAutoFix: false
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Auto-fix permission error
|
|
46
|
-
*
|
|
47
|
-
* @param {string} path - File path with permission issue
|
|
48
|
-
* @returns {Promise<void>}
|
|
49
|
-
*/
|
|
50
|
-
async function fixPermissions(path) {
|
|
51
|
-
// TODO: chmod/chown on Unix, icacls on Windows
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Suggest Node.js upgrade
|
|
56
|
-
*
|
|
57
|
-
* @param {string} currentVersion - Current Node version
|
|
58
|
-
* @param {string} requiredVersion - Required Node version
|
|
59
|
-
* @returns {string} - Upgrade instructions
|
|
60
|
-
*/
|
|
61
|
-
function suggestNodeUpgrade(currentVersion, requiredVersion) {
|
|
62
|
-
// TODO: OS-specific instructions
|
|
63
|
-
return `Please upgrade Node.js from ${currentVersion} to ${requiredVersion}+`;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Check common issues
|
|
68
|
-
*
|
|
69
|
-
* @returns {Promise<string[]>} - List of detected issues
|
|
70
|
-
*/
|
|
71
|
-
async function checkCommonIssues() {
|
|
72
|
-
const issues = [];
|
|
73
|
-
|
|
74
|
-
// TODO: Check for:
|
|
75
|
-
// - Old Node version
|
|
76
|
-
// - Missing Git
|
|
77
|
-
// - Write permission in project root
|
|
78
|
-
// - Disk space
|
|
79
|
-
// - Network connectivity
|
|
80
|
-
|
|
81
|
-
return issues;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
module.exports = {
|
|
85
|
-
diagnose,
|
|
86
|
-
fixPermissions,
|
|
87
|
-
suggestNodeUpgrade,
|
|
88
|
-
checkCommonIssues
|
|
89
|
-
};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* VALIDATOR Module
|
|
3
|
-
*
|
|
4
|
-
* Validates BYAN installation with 10 automated checks.
|
|
5
|
-
*
|
|
6
|
-
* Phase 4: 32h development
|
|
7
|
-
*
|
|
8
|
-
* @module yanstaller/validator
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} ValidationResult
|
|
13
|
-
* @property {boolean} success - All checks passed
|
|
14
|
-
* @property {CheckResult[]} checks - Individual check results
|
|
15
|
-
* @property {string[]} errors - Critical errors
|
|
16
|
-
* @property {string[]} warnings - Non-critical issues
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @typedef {Object} CheckResult
|
|
21
|
-
* @property {string} id - Check identifier
|
|
22
|
-
* @property {string} name - Human-readable check name
|
|
23
|
-
* @property {boolean} passed
|
|
24
|
-
* @property {string} [message] - Error/warning message if failed
|
|
25
|
-
* @property {string} severity - 'critical' | 'warning'
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Validate BYAN installation
|
|
30
|
-
*
|
|
31
|
-
* @param {import('./installer').InstallConfig} config - Installation config
|
|
32
|
-
* @returns {Promise<ValidationResult>}
|
|
33
|
-
*/
|
|
34
|
-
async function validate(config) {
|
|
35
|
-
const checks = [];
|
|
36
|
-
const errors = [];
|
|
37
|
-
const warnings = [];
|
|
38
|
-
|
|
39
|
-
// TODO: Run all 10 checks
|
|
40
|
-
checks.push(await checkBmadStructure(config));
|
|
41
|
-
checks.push(await checkAgentFiles(config));
|
|
42
|
-
checks.push(await checkStubsYamlFrontmatter(config));
|
|
43
|
-
checks.push(await checkConfigFiles(config));
|
|
44
|
-
checks.push(await checkPlatformDetection(config));
|
|
45
|
-
checks.push(await checkFilePermissions(config));
|
|
46
|
-
checks.push(await checkManifests(config));
|
|
47
|
-
checks.push(await checkWorkflows(config));
|
|
48
|
-
checks.push(await checkTemplates(config));
|
|
49
|
-
checks.push(await checkDependencies(config));
|
|
50
|
-
|
|
51
|
-
const allPassed = checks.every(c => c.passed || c.severity === 'warning');
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
success: allPassed,
|
|
55
|
-
checks,
|
|
56
|
-
errors,
|
|
57
|
-
warnings
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Check 1: _bmad/ structure exists
|
|
63
|
-
*/
|
|
64
|
-
async function checkBmadStructure(config) {
|
|
65
|
-
// TODO: Verify directories exist
|
|
66
|
-
return {
|
|
67
|
-
id: 'bmad-structure',
|
|
68
|
-
name: '_bmad/ structure',
|
|
69
|
-
passed: true,
|
|
70
|
-
severity: 'critical'
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Check 2: Agent files copied correctly
|
|
76
|
-
*/
|
|
77
|
-
async function checkAgentFiles(config) {
|
|
78
|
-
// TODO: Verify all agent .md files exist
|
|
79
|
-
return {
|
|
80
|
-
id: 'agent-files',
|
|
81
|
-
name: 'Agent files',
|
|
82
|
-
passed: true,
|
|
83
|
-
severity: 'critical'
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Check 3: Platform stubs have valid YAML frontmatter
|
|
89
|
-
*/
|
|
90
|
-
async function checkStubsYamlFrontmatter(config) {
|
|
91
|
-
// TODO: Parse YAML frontmatter in .github/agents/*.md
|
|
92
|
-
return {
|
|
93
|
-
id: 'yaml-frontmatter',
|
|
94
|
-
name: 'YAML frontmatter',
|
|
95
|
-
passed: true,
|
|
96
|
-
severity: 'critical'
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Check 4: Module config files valid
|
|
102
|
-
*/
|
|
103
|
-
async function checkConfigFiles(config) {
|
|
104
|
-
// TODO: Verify config.yaml files
|
|
105
|
-
return {
|
|
106
|
-
id: 'config-files',
|
|
107
|
-
name: 'Config files',
|
|
108
|
-
passed: true,
|
|
109
|
-
severity: 'critical'
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Check 5: Platform detection works
|
|
115
|
-
*/
|
|
116
|
-
async function checkPlatformDetection(config) {
|
|
117
|
-
// TODO: Test agent detection on each platform
|
|
118
|
-
return {
|
|
119
|
-
id: 'platform-detection',
|
|
120
|
-
name: 'Platform detection',
|
|
121
|
-
passed: true,
|
|
122
|
-
severity: 'critical'
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Check 6: File permissions correct
|
|
128
|
-
*/
|
|
129
|
-
async function checkFilePermissions(config) {
|
|
130
|
-
// TODO: Verify read/write permissions
|
|
131
|
-
return {
|
|
132
|
-
id: 'file-permissions',
|
|
133
|
-
name: 'File permissions',
|
|
134
|
-
passed: true,
|
|
135
|
-
severity: 'warning'
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Check 7: Manifest files valid
|
|
141
|
-
*/
|
|
142
|
-
async function checkManifests(config) {
|
|
143
|
-
// TODO: Verify agent-manifest.csv, workflow-manifest.csv
|
|
144
|
-
return {
|
|
145
|
-
id: 'manifests',
|
|
146
|
-
name: 'Manifest files',
|
|
147
|
-
passed: true,
|
|
148
|
-
severity: 'warning'
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Check 8: Workflows accessible
|
|
154
|
-
*/
|
|
155
|
-
async function checkWorkflows(config) {
|
|
156
|
-
// TODO: Verify workflow files exist
|
|
157
|
-
return {
|
|
158
|
-
id: 'workflows',
|
|
159
|
-
name: 'Workflow files',
|
|
160
|
-
passed: true,
|
|
161
|
-
severity: 'warning'
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Check 9: Templates valid
|
|
167
|
-
*/
|
|
168
|
-
async function checkTemplates(config) {
|
|
169
|
-
// TODO: Verify templates/ structure
|
|
170
|
-
return {
|
|
171
|
-
id: 'templates',
|
|
172
|
-
name: 'Template files',
|
|
173
|
-
passed: true,
|
|
174
|
-
severity: 'warning'
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Check 10: Dependencies installed
|
|
180
|
-
*/
|
|
181
|
-
async function checkDependencies(config) {
|
|
182
|
-
// TODO: Verify npm dependencies
|
|
183
|
-
return {
|
|
184
|
-
id: 'dependencies',
|
|
185
|
-
name: 'Dependencies',
|
|
186
|
-
passed: true,
|
|
187
|
-
severity: 'critical'
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
module.exports = {
|
|
192
|
-
validate,
|
|
193
|
-
checkBmadStructure,
|
|
194
|
-
checkAgentFiles,
|
|
195
|
-
checkStubsYamlFrontmatter,
|
|
196
|
-
checkConfigFiles,
|
|
197
|
-
checkPlatformDetection
|
|
198
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WIZARD Module
|
|
3
|
-
*
|
|
4
|
-
* Post-installation wizard with 3 options: Create agent / Test / Exit.
|
|
5
|
-
*
|
|
6
|
-
* Phase 7: 16h development
|
|
7
|
-
*
|
|
8
|
-
* @module yanstaller/wizard
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
const inquirer = require('inquirer');
|
|
12
|
-
const logger = require('../utils/logger');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Show post-install wizard
|
|
16
|
-
*
|
|
17
|
-
* @param {import('./installer').InstallConfig} config - Installation config
|
|
18
|
-
* @returns {Promise<void>}
|
|
19
|
-
*/
|
|
20
|
-
async function show(config) {
|
|
21
|
-
logger.success('\n✅ BYAN installed successfully!\n');
|
|
22
|
-
|
|
23
|
-
const choices = [
|
|
24
|
-
{ name: '🎨 Create your first agent (BYAN interview)', value: 'create' },
|
|
25
|
-
{ name: '🧪 Test an installed agent', value: 'test' },
|
|
26
|
-
{ name: '🚪 Exit (start using BYAN)', value: 'exit' }
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const answer = await inquirer.prompt([
|
|
30
|
-
{
|
|
31
|
-
type: 'list',
|
|
32
|
-
name: 'action',
|
|
33
|
-
message: 'What would you like to do next?',
|
|
34
|
-
choices
|
|
35
|
-
}
|
|
36
|
-
]);
|
|
37
|
-
|
|
38
|
-
switch (answer.action) {
|
|
39
|
-
case 'create':
|
|
40
|
-
await launchByanInterview();
|
|
41
|
-
break;
|
|
42
|
-
case 'test':
|
|
43
|
-
await testAgent(config);
|
|
44
|
-
break;
|
|
45
|
-
case 'exit':
|
|
46
|
-
showExitMessage(config);
|
|
47
|
-
break;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Launch BYAN intelligent interview
|
|
53
|
-
*
|
|
54
|
-
* @returns {Promise<void>}
|
|
55
|
-
*/
|
|
56
|
-
async function launchByanInterview() {
|
|
57
|
-
logger.info('\nLaunching BYAN intelligent interview...');
|
|
58
|
-
// TODO: Exec `@bmad-agent-byan` or similar
|
|
59
|
-
logger.info('To create an agent, run: @bmad-agent-byan');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Test installed agent
|
|
64
|
-
*
|
|
65
|
-
* @param {import('./installer').InstallConfig} config - Installation config
|
|
66
|
-
* @returns {Promise<void>}
|
|
67
|
-
*/
|
|
68
|
-
async function testAgent(config) {
|
|
69
|
-
const agentChoices = config.agents.map(name => ({
|
|
70
|
-
name: `@bmad-agent-${name}`,
|
|
71
|
-
value: name
|
|
72
|
-
}));
|
|
73
|
-
|
|
74
|
-
const answer = await inquirer.prompt([
|
|
75
|
-
{
|
|
76
|
-
type: 'list',
|
|
77
|
-
name: 'agent',
|
|
78
|
-
message: 'Which agent would you like to test?',
|
|
79
|
-
choices: agentChoices
|
|
80
|
-
}
|
|
81
|
-
]);
|
|
82
|
-
|
|
83
|
-
logger.info(`\nTo activate ${answer.agent}, run: @bmad-agent-${answer.agent}`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Show exit message with next steps
|
|
88
|
-
*
|
|
89
|
-
* @param {import('./installer').InstallConfig} config - Installation config
|
|
90
|
-
*/
|
|
91
|
-
function showExitMessage(config) {
|
|
92
|
-
logger.info('\n🎉 You\'re all set! Here\'s how to get started:\n');
|
|
93
|
-
logger.info('1. Activate an agent:');
|
|
94
|
-
logger.info(' @bmad-agent-byan (Create new agents)');
|
|
95
|
-
logger.info(' @bmad-agent-bmm-pm (Project management)');
|
|
96
|
-
logger.info(' @bmad-agent-bmm-dev (Development)\n');
|
|
97
|
-
logger.info('2. Get help anytime:');
|
|
98
|
-
logger.info(' /bmad-help\n');
|
|
99
|
-
logger.info('3. Documentation:');
|
|
100
|
-
logger.info(' Check _bmad/README.md\n');
|
|
101
|
-
logger.info('Happy building! 🚀\n');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
module.exports = {
|
|
105
|
-
show,
|
|
106
|
-
launchByanInterview,
|
|
107
|
-
testAgent,
|
|
108
|
-
showExitMessage
|
|
109
|
-
};
|
|
@@ -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;
|