copilot-flow 0.3.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/README.md +300 -0
- package/bin/copilot-flow.js +13 -0
- package/dist/agents/executor.d.ts +24 -0
- package/dist/agents/executor.d.ts.map +1 -0
- package/dist/agents/executor.js +85 -0
- package/dist/agents/executor.js.map +1 -0
- package/dist/agents/pool.d.ts +22 -0
- package/dist/agents/pool.d.ts.map +1 -0
- package/dist/agents/pool.js +84 -0
- package/dist/agents/pool.js.map +1 -0
- package/dist/agents/registry.d.ts +16 -0
- package/dist/agents/registry.d.ts.map +1 -0
- package/dist/agents/registry.js +140 -0
- package/dist/agents/registry.js.map +1 -0
- package/dist/commands/agent.d.ts +3 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +105 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +119 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hooks.d.ts +3 -0
- package/dist/commands/hooks.d.ts.map +1 -0
- package/dist/commands/hooks.js +75 -0
- package/dist/commands/hooks.js.map +1 -0
- package/dist/commands/index.d.ts +5 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +31 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init.d.ts +3 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +37 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/memory.d.ts +3 -0
- package/dist/commands/memory.d.ts.map +1 -0
- package/dist/commands/memory.js +109 -0
- package/dist/commands/memory.js.map +1 -0
- package/dist/commands/route.d.ts +3 -0
- package/dist/commands/route.d.ts.map +1 -0
- package/dist/commands/route.js +36 -0
- package/dist/commands/route.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +58 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/swarm.d.ts +3 -0
- package/dist/commands/swarm.d.ts.map +1 -0
- package/dist/commands/swarm.js +106 -0
- package/dist/commands/swarm.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +95 -0
- package/dist/config.js.map +1 -0
- package/dist/core/client-manager.d.ts +19 -0
- package/dist/core/client-manager.d.ts.map +1 -0
- package/dist/core/client-manager.js +69 -0
- package/dist/core/client-manager.js.map +1 -0
- package/dist/core/error-handler.d.ts +25 -0
- package/dist/core/error-handler.d.ts.map +1 -0
- package/dist/core/error-handler.js +135 -0
- package/dist/core/error-handler.js.map +1 -0
- package/dist/core/retry.d.ts +56 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +107 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/hooks/executor.d.ts +25 -0
- package/dist/hooks/executor.d.ts.map +1 -0
- package/dist/hooks/executor.js +57 -0
- package/dist/hooks/executor.js.map +1 -0
- package/dist/hooks/registry.d.ts +22 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +36 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/memory/store.d.ts +32 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/memory/store.js +149 -0
- package/dist/memory/store.js.map +1 -0
- package/dist/output.d.ts +26 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +157 -0
- package/dist/output.js.map +1 -0
- package/dist/swarm/coordinator.d.ts +20 -0
- package/dist/swarm/coordinator.d.ts.map +1 -0
- package/dist/swarm/coordinator.js +129 -0
- package/dist/swarm/coordinator.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +22 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent type registry — defines system prompts and capabilities for each
|
|
4
|
+
* built-in agent type. Inspired by Ruflo's 12 agent types.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.AGENT_REGISTRY = void 0;
|
|
8
|
+
exports.getAgentDefinition = getAgentDefinition;
|
|
9
|
+
exports.listAgentTypes = listAgentTypes;
|
|
10
|
+
exports.routeTask = routeTask;
|
|
11
|
+
exports.AGENT_REGISTRY = {
|
|
12
|
+
coder: {
|
|
13
|
+
model: 'gpt-4o',
|
|
14
|
+
description: 'Writes clean, efficient, production-ready code',
|
|
15
|
+
systemMessage: 'You are an expert software engineer. Write clean, efficient, production-ready code. ' +
|
|
16
|
+
'Follow best practices, add appropriate error handling, and include inline comments ' +
|
|
17
|
+
'only where logic is non-obvious.',
|
|
18
|
+
capabilities: ['coding', 'implementation', 'refactoring', 'debugging'],
|
|
19
|
+
},
|
|
20
|
+
researcher: {
|
|
21
|
+
model: 'gpt-4o',
|
|
22
|
+
description: 'Investigates topics and gathers information thoroughly',
|
|
23
|
+
systemMessage: 'You are a thorough researcher. Investigate topics deeply, gather relevant information, ' +
|
|
24
|
+
'and present findings in a clear, structured format with citations where applicable.',
|
|
25
|
+
capabilities: ['research', 'analysis', 'documentation', 'summarisation'],
|
|
26
|
+
},
|
|
27
|
+
tester: {
|
|
28
|
+
model: 'gpt-4o',
|
|
29
|
+
description: 'Writes comprehensive tests and identifies edge cases',
|
|
30
|
+
systemMessage: 'You are a testing expert. Write comprehensive unit tests, integration tests, and ' +
|
|
31
|
+
'identify edge cases. Follow TDD principles and aim for high coverage of critical paths.',
|
|
32
|
+
capabilities: ['testing', 'validation', 'coverage-analysis', 'qa'],
|
|
33
|
+
},
|
|
34
|
+
reviewer: {
|
|
35
|
+
model: 'gpt-4o',
|
|
36
|
+
description: 'Reviews code for quality, correctness, and security',
|
|
37
|
+
systemMessage: 'You are a senior code reviewer. Identify bugs, security vulnerabilities, performance ' +
|
|
38
|
+
'issues, and style violations. Be constructive and specific. Prioritise critical issues.',
|
|
39
|
+
capabilities: ['code-review', 'security', 'quality', 'feedback'],
|
|
40
|
+
},
|
|
41
|
+
architect: {
|
|
42
|
+
model: 'gpt-4o',
|
|
43
|
+
description: 'Designs system architecture and makes high-level technical decisions',
|
|
44
|
+
systemMessage: 'You are a software architect. Design scalable, maintainable system architectures. ' +
|
|
45
|
+
'Consider trade-offs, scalability, security, and long-term maintainability. Produce ' +
|
|
46
|
+
'clear diagrams and decision rationale.',
|
|
47
|
+
capabilities: ['architecture', 'design', 'planning', 'decision-making'],
|
|
48
|
+
},
|
|
49
|
+
coordinator: {
|
|
50
|
+
model: 'gpt-4o',
|
|
51
|
+
description: 'Coordinates multi-agent workflows and decomposes complex tasks',
|
|
52
|
+
systemMessage: 'You are a multi-agent coordinator. Break down complex tasks into clear subtasks. ' +
|
|
53
|
+
'Assign work to appropriate specialists and synthesise their outputs into a coherent result.',
|
|
54
|
+
capabilities: ['coordination', 'planning', 'decomposition', 'synthesis'],
|
|
55
|
+
},
|
|
56
|
+
analyst: {
|
|
57
|
+
model: 'gpt-4o',
|
|
58
|
+
description: 'Analyses requirements, data, and systems',
|
|
59
|
+
systemMessage: 'You are a requirements and systems analyst. Analyse requirements, identify ambiguities, ' +
|
|
60
|
+
'and produce precise specifications. Investigate system behaviour and propose solutions.',
|
|
61
|
+
capabilities: ['analysis', 'requirements', 'specification', 'problem-solving'],
|
|
62
|
+
},
|
|
63
|
+
debugger: {
|
|
64
|
+
model: 'gpt-4o',
|
|
65
|
+
description: 'Diagnoses and fixes bugs and runtime issues',
|
|
66
|
+
systemMessage: 'You are a debugging specialist. Methodically identify root causes of bugs and runtime ' +
|
|
67
|
+
'issues. Propose targeted fixes with minimal side effects. Explain your diagnosis clearly.',
|
|
68
|
+
capabilities: ['debugging', 'root-cause-analysis', 'fixing', 'tracing'],
|
|
69
|
+
},
|
|
70
|
+
documenter: {
|
|
71
|
+
model: 'gpt-4o',
|
|
72
|
+
description: 'Writes clear technical documentation',
|
|
73
|
+
systemMessage: 'You are a technical writer. Write clear, concise, and accurate documentation including ' +
|
|
74
|
+
'READMEs, API docs, and inline comments. Tailor content to the intended audience.',
|
|
75
|
+
capabilities: ['documentation', 'writing', 'api-docs', 'readme'],
|
|
76
|
+
},
|
|
77
|
+
optimizer: {
|
|
78
|
+
model: 'gpt-4o',
|
|
79
|
+
description: 'Optimises code for performance and efficiency',
|
|
80
|
+
systemMessage: 'You are a performance optimisation specialist. Profile and optimise code for speed, ' +
|
|
81
|
+
'memory, and efficiency. Explain the impact of each optimisation and any trade-offs.',
|
|
82
|
+
capabilities: ['optimisation', 'performance', 'profiling', 'refactoring'],
|
|
83
|
+
},
|
|
84
|
+
'security-auditor': {
|
|
85
|
+
model: 'gpt-4o',
|
|
86
|
+
description: 'Audits code and systems for security vulnerabilities',
|
|
87
|
+
systemMessage: 'You are a security auditor. Identify OWASP Top 10 vulnerabilities, injection flaws, ' +
|
|
88
|
+
'authentication weaknesses, and insecure configurations. Provide concrete remediation steps.',
|
|
89
|
+
capabilities: ['security', 'vulnerability-scanning', 'penetration-testing', 'remediation'],
|
|
90
|
+
},
|
|
91
|
+
'performance-engineer': {
|
|
92
|
+
model: 'gpt-4o',
|
|
93
|
+
description: 'Engineers systems for high performance and scalability',
|
|
94
|
+
systemMessage: 'You are a performance engineer. Design and implement high-performance systems. Conduct ' +
|
|
95
|
+
'benchmarks, analyse bottlenecks, and recommend architecture changes for scalability.',
|
|
96
|
+
capabilities: ['performance-engineering', 'benchmarking', 'scalability', 'infrastructure'],
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
/** Get the definition for an agent type, or throw if unknown. */
|
|
100
|
+
function getAgentDefinition(type) {
|
|
101
|
+
const def = exports.AGENT_REGISTRY[type];
|
|
102
|
+
if (!def)
|
|
103
|
+
throw new Error(`Unknown agent type: ${type}`);
|
|
104
|
+
return def;
|
|
105
|
+
}
|
|
106
|
+
/** Return all agent types as an array. */
|
|
107
|
+
function listAgentTypes() {
|
|
108
|
+
return Object.keys(exports.AGENT_REGISTRY);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Suggest the best agent type for a given task description.
|
|
112
|
+
* Simple keyword-based routing — no ML required.
|
|
113
|
+
*/
|
|
114
|
+
function routeTask(task) {
|
|
115
|
+
const t = task.toLowerCase();
|
|
116
|
+
if (/secur|vuln|exploit|cve|owasp|auth(entication|orization)/.test(t))
|
|
117
|
+
return 'security-auditor';
|
|
118
|
+
if (/test|spec|coverage|tdd|jest|vitest|mocha/.test(t))
|
|
119
|
+
return 'tester';
|
|
120
|
+
if (/review|audit|quality|lint|feedback/.test(t))
|
|
121
|
+
return 'reviewer';
|
|
122
|
+
if (/architect|design|system|scalab|diagram|adr/.test(t))
|
|
123
|
+
return 'architect';
|
|
124
|
+
if (/debug|fix|bug|error|crash|exception|trace/.test(t))
|
|
125
|
+
return 'debugger';
|
|
126
|
+
if (/document|readme|jsdoc|api doc|comment/.test(t))
|
|
127
|
+
return 'documenter';
|
|
128
|
+
if (/optim|performance|speed|memory|profil|bench/.test(t))
|
|
129
|
+
return 'optimizer';
|
|
130
|
+
if (/research|investigate|find|explore|gather/.test(t))
|
|
131
|
+
return 'researcher';
|
|
132
|
+
if (/analys|requirement|spec|business logic/.test(t))
|
|
133
|
+
return 'analyst';
|
|
134
|
+
if (/coordinat|orchestrat|plan|decompos|workflow/.test(t))
|
|
135
|
+
return 'coordinator';
|
|
136
|
+
if (/implement|write|build|create|add|refactor/.test(t))
|
|
137
|
+
return 'coder';
|
|
138
|
+
return 'coder'; // sensible default
|
|
139
|
+
}
|
|
140
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/agents/registry.ts"],"names":[],"mappings":";AAAA;;;GAGG;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,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/commands/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AASpC,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkHpD"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerAgent = registerAgent;
|
|
4
|
+
const executor_js_1 = require("../agents/executor.js");
|
|
5
|
+
const pool_js_1 = require("../agents/pool.js");
|
|
6
|
+
const registry_js_1 = require("../agents/registry.js");
|
|
7
|
+
const output_js_1 = require("../output.js");
|
|
8
|
+
const config_js_1 = require("../config.js");
|
|
9
|
+
function registerAgent(program) {
|
|
10
|
+
const agent = program.command('agent').description('Manage Copilot agents');
|
|
11
|
+
// ── agent spawn ────────────────────────────────────────────────────────────
|
|
12
|
+
agent
|
|
13
|
+
.command('spawn')
|
|
14
|
+
.description('Spawn a Copilot agent and run a task')
|
|
15
|
+
.requiredOption('--task <task>', 'Task description to run')
|
|
16
|
+
.option('--type <type>', 'Agent type (default: auto-routed from task)')
|
|
17
|
+
.option('--model <model>', 'Override the default model')
|
|
18
|
+
.option('--timeout <ms>', 'Session timeout in ms', '120000')
|
|
19
|
+
.option('--max-retries <n>', 'Maximum retry attempts', '3')
|
|
20
|
+
.option('--retry-delay <ms>', 'Initial retry delay in ms', '1000')
|
|
21
|
+
.option('--retry-strategy <strategy>', 'Backoff strategy (exponential|linear|constant|fibonacci)', 'exponential')
|
|
22
|
+
.option('--no-retry', 'Disable retries')
|
|
23
|
+
.option('--stream', 'Stream output as it arrives')
|
|
24
|
+
.action(async (opts) => {
|
|
25
|
+
const config = (0, config_js_1.loadConfig)();
|
|
26
|
+
const agentType = opts.type ?? (0, registry_js_1.routeTask)(opts.task);
|
|
27
|
+
output_js_1.output.info(`${(0, output_js_1.agentBadge)(agentType)} Running: ${opts.task.slice(0, 80)}`);
|
|
28
|
+
const result = await (0, executor_js_1.runAgentTask)(agentType, opts.task, {
|
|
29
|
+
model: opts.model ?? config.defaultModel,
|
|
30
|
+
timeoutMs: parseInt(opts.timeout, 10),
|
|
31
|
+
retryConfig: opts.retry === false
|
|
32
|
+
? { maxAttempts: 1 }
|
|
33
|
+
: {
|
|
34
|
+
maxAttempts: parseInt(opts.maxRetries, 10),
|
|
35
|
+
initialDelayMs: parseInt(opts.retryDelay, 10),
|
|
36
|
+
backoffStrategy: opts.retryStrategy,
|
|
37
|
+
},
|
|
38
|
+
onChunk: opts.stream ? chunk => process.stdout.write(chunk) : undefined,
|
|
39
|
+
});
|
|
40
|
+
if (opts.stream)
|
|
41
|
+
output_js_1.output.blank();
|
|
42
|
+
if (result.success) {
|
|
43
|
+
if (!opts.stream)
|
|
44
|
+
output_js_1.output.print(result.output);
|
|
45
|
+
output_js_1.output.blank();
|
|
46
|
+
output_js_1.output.success(`Done in ${result.durationMs}ms` +
|
|
47
|
+
(result.attempts > 1 ? ` (${result.attempts} attempts)` : ''));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
output_js_1.output.error(`Failed: ${result.error}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
// ── agent list ─────────────────────────────────────────────────────────────
|
|
55
|
+
agent
|
|
56
|
+
.command('list')
|
|
57
|
+
.description('List agents and their states')
|
|
58
|
+
.option('--type <type>', 'Filter by agent type')
|
|
59
|
+
.option('--status <status>', 'Filter by status (idle|busy|error|terminated)')
|
|
60
|
+
.action((opts) => {
|
|
61
|
+
const agents = pool_js_1.agentPool.list({
|
|
62
|
+
type: opts.type,
|
|
63
|
+
status: opts.status,
|
|
64
|
+
});
|
|
65
|
+
if (agents.length === 0) {
|
|
66
|
+
output_js_1.output.dim('No agents found.');
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
output_js_1.output.header('Active Agents');
|
|
70
|
+
for (const a of agents) {
|
|
71
|
+
(0, output_js_1.printTable)([
|
|
72
|
+
['ID', a.id],
|
|
73
|
+
['Type', (0, output_js_1.agentBadge)(a.type)],
|
|
74
|
+
['Status', a.status],
|
|
75
|
+
['Task', a.task?.slice(0, 60) ?? '—'],
|
|
76
|
+
['Started', new Date(a.startedAt).toISOString()],
|
|
77
|
+
]);
|
|
78
|
+
output_js_1.output.blank();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
// ── agent types ────────────────────────────────────────────────────────────
|
|
82
|
+
agent
|
|
83
|
+
.command('types')
|
|
84
|
+
.description('List all available agent types')
|
|
85
|
+
.action(() => {
|
|
86
|
+
output_js_1.output.header('Available Agent Types');
|
|
87
|
+
for (const type of (0, registry_js_1.listAgentTypes)()) {
|
|
88
|
+
output_js_1.output.print(` ${(0, output_js_1.agentBadge)(type)}`);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
// ── agent stop ─────────────────────────────────────────────────────────────
|
|
92
|
+
agent
|
|
93
|
+
.command('stop <id>')
|
|
94
|
+
.description('Mark an agent as terminated')
|
|
95
|
+
.action((id) => {
|
|
96
|
+
const agent = pool_js_1.agentPool.get(id);
|
|
97
|
+
if (!agent) {
|
|
98
|
+
output_js_1.output.error(`Agent not found: ${id}`);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
pool_js_1.agentPool.update(id, { status: 'terminated', completedAt: Date.now() });
|
|
102
|
+
output_js_1.output.success(`Agent ${id} marked as terminated`);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/commands/agent.ts"],"names":[],"mappings":";;AASA,sCAkHC;AA1HD,uDAAqD;AACrD,+CAA8C;AAC9C,uDAAkE;AAClE,4CAA8D;AAC9D,4CAA0C;AAI1C,SAAgB,aAAa,CAA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AI,CAAC,EAAE,CAAC,CAAC;QACxC,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,8EAA8E;IAC9E,KAAK;SACF,OAAO,CAAC,WAAW,CAAC;SACpB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,CAAC,EAAU,EAAE,EAAE;QACrB,MAAM,KAAK,GAAG,mBAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,kBAAM,CAAC,KAAK,CAAC,oBAAoB,EAAE,EAAE,CAAC,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QACD,mBAAS,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QACxE,kBAAM,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiHrD"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerDoctor = registerDoctor;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const output_js_1 = require("../output.js");
|
|
6
|
+
const config_js_1 = require("../config.js");
|
|
7
|
+
const client_manager_js_1 = require("../core/client-manager.js");
|
|
8
|
+
function registerDoctor(program) {
|
|
9
|
+
program
|
|
10
|
+
.command('doctor')
|
|
11
|
+
.description('Check system health and prerequisites')
|
|
12
|
+
.option('--verbose', 'Show extra detail')
|
|
13
|
+
.action(async (opts) => {
|
|
14
|
+
output_js_1.output.header('copilot-flow doctor');
|
|
15
|
+
const checks = [];
|
|
16
|
+
// ── Node.js version ──────────────────────────────────────────────────
|
|
17
|
+
const nodeVersion = process.version;
|
|
18
|
+
const nodeMajor = parseInt(nodeVersion.slice(1), 10);
|
|
19
|
+
checks.push({
|
|
20
|
+
name: 'Node.js >= 20',
|
|
21
|
+
ok: nodeMajor >= 20,
|
|
22
|
+
detail: nodeVersion,
|
|
23
|
+
});
|
|
24
|
+
// ── copilot CLI installed ────────────────────────────────────────────
|
|
25
|
+
let copilotVersion = '';
|
|
26
|
+
let copilotInstalled = false;
|
|
27
|
+
try {
|
|
28
|
+
copilotVersion = (0, child_process_1.execSync)('copilot version', { stdio: 'pipe' }).toString().trim();
|
|
29
|
+
copilotInstalled = true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
try {
|
|
33
|
+
// Some installations expose it via 'gh copilot' as well
|
|
34
|
+
copilotVersion = (0, child_process_1.execSync)('gh copilot --version', { stdio: 'pipe' }).toString().trim();
|
|
35
|
+
copilotInstalled = true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
copilotInstalled = false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
checks.push({
|
|
42
|
+
name: 'copilot CLI installed',
|
|
43
|
+
ok: copilotInstalled,
|
|
44
|
+
detail: copilotInstalled ? copilotVersion : 'Not found — install from https://github.com/github/copilot',
|
|
45
|
+
});
|
|
46
|
+
// ── copilot authenticated ────────────────────────────────────────────
|
|
47
|
+
let authenticated = false;
|
|
48
|
+
if (copilotInstalled) {
|
|
49
|
+
try {
|
|
50
|
+
(0, child_process_1.execSync)('copilot --version', { stdio: 'pipe' });
|
|
51
|
+
// A successful ping via SDK is the real test — we do that below
|
|
52
|
+
authenticated = true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
authenticated = false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
checks.push({
|
|
59
|
+
name: 'copilot authenticated',
|
|
60
|
+
ok: authenticated,
|
|
61
|
+
detail: authenticated ? 'Logged in' : 'Run: copilot login',
|
|
62
|
+
});
|
|
63
|
+
// ── @github/copilot-sdk reachable ───────────────────────────────────
|
|
64
|
+
let sdkPing = false;
|
|
65
|
+
if (copilotInstalled && authenticated) {
|
|
66
|
+
try {
|
|
67
|
+
sdkPing = await client_manager_js_1.clientManager.ping();
|
|
68
|
+
await client_manager_js_1.clientManager.shutdown();
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
sdkPing = false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
checks.push({
|
|
75
|
+
name: '@github/copilot-sdk ping',
|
|
76
|
+
ok: sdkPing,
|
|
77
|
+
detail: sdkPing ? 'OK' : copilotInstalled ? 'Failed — check copilot login status' : 'Skipped',
|
|
78
|
+
});
|
|
79
|
+
// ── .copilot-flow initialised ────────────────────────────────────────
|
|
80
|
+
checks.push({
|
|
81
|
+
name: 'copilot-flow initialised',
|
|
82
|
+
ok: (0, config_js_1.isInitialised)(),
|
|
83
|
+
detail: (0, config_js_1.isInitialised)() ? '.copilot-flow/config.json found' : 'Run: copilot-flow init',
|
|
84
|
+
});
|
|
85
|
+
// ── better-sqlite3 available ────────────────────────────────────────
|
|
86
|
+
let sqliteOk = false;
|
|
87
|
+
try {
|
|
88
|
+
require('better-sqlite3');
|
|
89
|
+
sqliteOk = true;
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
sqliteOk = false;
|
|
93
|
+
}
|
|
94
|
+
checks.push({
|
|
95
|
+
name: 'better-sqlite3 available',
|
|
96
|
+
ok: sqliteOk,
|
|
97
|
+
detail: sqliteOk ? 'OK' : 'Run: npm install better-sqlite3',
|
|
98
|
+
});
|
|
99
|
+
// ── Print results ───────────────────────────────────────────────────
|
|
100
|
+
output_js_1.output.blank();
|
|
101
|
+
for (const check of checks) {
|
|
102
|
+
const icon = check.ok ? '✓' : '✗';
|
|
103
|
+
const colour = check.ok
|
|
104
|
+
? (s) => s
|
|
105
|
+
: (s) => `\x1b[31m${s}\x1b[0m`;
|
|
106
|
+
output_js_1.output.print(` ${icon} ${colour(check.name.padEnd(35))} ${check.detail}`);
|
|
107
|
+
}
|
|
108
|
+
output_js_1.output.blank();
|
|
109
|
+
const failed = checks.filter(c => !c.ok);
|
|
110
|
+
if (failed.length === 0) {
|
|
111
|
+
output_js_1.output.success('All checks passed — copilot-flow is ready!');
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
output_js_1.output.warn(`${failed.length} check(s) failed. See details above.`);
|
|
115
|
+
process.exit(1);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":";;AAaA,wCAiHC;AA7HD,iDAAyC;AAEzC,4CAAkD;AAClD,4CAA6C;AAC7C,iEAA0D;AAQ1D,SAAgB,cAAc,CAAC,OAAgB;IAC7C,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,uCAAuC,CAAC;SACpD,MAAM,CAAC,WAAW,EAAE,mBAAmB,CAAC;SACxC,MAAM,CAAC,KAAK,EAAE,IAA0B,EAAE,EAAE;QAC3C,kBAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAErC,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,wEAAwE;QACxE,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;QACpC,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,eAAe;YACrB,EAAE,EAAE,SAAS,IAAI,EAAE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"__esModule", { value: true });
|
|
3
|
+
exports.registerHooks = registerHooks;
|
|
4
|
+
const registry_js_1 = require("../hooks/registry.js");
|
|
5
|
+
const executor_js_1 = require("../hooks/executor.js");
|
|
6
|
+
const output_js_1 = require("../output.js");
|
|
7
|
+
function registerHooks(program) {
|
|
8
|
+
const hooks = program.command('hooks').description('Manage and fire lifecycle hooks');
|
|
9
|
+
// ── hooks list ─────────────────────────────────────────────────────────────
|
|
10
|
+
hooks
|
|
11
|
+
.command('list')
|
|
12
|
+
.description('List all registered hooks')
|
|
13
|
+
.action(() => {
|
|
14
|
+
const registered = registry_js_1.globalHooks.list();
|
|
15
|
+
if (registered.length === 0) {
|
|
16
|
+
output_js_1.output.dim('No hooks registered.');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
output_js_1.output.header('Registered Hooks');
|
|
20
|
+
for (const h of registered) {
|
|
21
|
+
(0, output_js_1.printTable)([
|
|
22
|
+
['ID', h.id],
|
|
23
|
+
['Event', h.event],
|
|
24
|
+
['Priority', String(h.priority)],
|
|
25
|
+
]);
|
|
26
|
+
output_js_1.output.blank();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
// ── hooks fire ─────────────────────────────────────────────────────────────
|
|
30
|
+
hooks
|
|
31
|
+
.command('fire <event>')
|
|
32
|
+
.description('Manually fire a hook event')
|
|
33
|
+
.option('--data <json>', 'JSON data to pass to handlers')
|
|
34
|
+
.action(async (event, opts) => {
|
|
35
|
+
const validEvents = [
|
|
36
|
+
'pre-task', 'post-task', 'session-start', 'session-end',
|
|
37
|
+
'agent-spawn', 'agent-terminate', 'swarm-start', 'swarm-end',
|
|
38
|
+
];
|
|
39
|
+
if (!validEvents.includes(event)) {
|
|
40
|
+
output_js_1.output.error(`Unknown event: ${event}. Valid: ${validEvents.join(', ')}`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
let data;
|
|
44
|
+
if (opts.data) {
|
|
45
|
+
try {
|
|
46
|
+
data = JSON.parse(opts.data);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
output_js_1.output.error('--data must be valid JSON');
|
|
50
|
+
process.exit(1);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
await (0, executor_js_1.emit)(event, data);
|
|
54
|
+
output_js_1.output.success(`Fired: ${event}`);
|
|
55
|
+
});
|
|
56
|
+
// ── Convenience hook commands matching Ruflo's pattern ────────────────────
|
|
57
|
+
for (const event of ['pre-task', 'post-task', 'session-start', 'session-end']) {
|
|
58
|
+
hooks
|
|
59
|
+
.command(event)
|
|
60
|
+
.description(`Fire the ${event} hook`)
|
|
61
|
+
.option('--data <json>', 'JSON payload')
|
|
62
|
+
.action(async (opts) => {
|
|
63
|
+
let data;
|
|
64
|
+
if (opts.data) {
|
|
65
|
+
try {
|
|
66
|
+
data = JSON.parse(opts.data);
|
|
67
|
+
}
|
|
68
|
+
catch { /* ignore */ }
|
|
69
|
+
}
|
|
70
|
+
await (0, executor_js_1.emit)(event, data);
|
|
71
|
+
output_js_1.output.success(`Fired: ${event}`);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/commands/hooks.ts"],"names":[],"mappings":";;AAMA,sCAqEC;AA1ED,sDAAmD;AACnD,sDAA4C;AAC5C,4CAAkD;AAGlD,SAAgB,aAAa,CAAC,OAAgB;IAC5C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,iCAAiC,CAAC,CAAC;IAEtF,8EAA8E;IAC9E,KAAK;SACF,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,2BAA2B,CAAC;SACxC,MAAM,CAAC,GAAG,EAAE;QACX,MAAM,UAAU,GAAG,yBAAW,CAAC,IAAI,EAAE,CAAC;QACtC,IAAI,UAAU,CA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,MAAM,CAAC;gBACP,kBAAM,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;gBAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;QACH,CAAC;QAED,MAAM,IAAA,kBAAI,EAAC,KAAkB,EAAE,IAAI,CAAC,CAAC;QACrC,kBAAM,CAAC,OAAO,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEL,6EAA6E;IAC7E,KAAK,MAAM,KAAK,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,CAAgB,EAAE,CAAC;QAC7F,KAAK;aACF,OAAO,CAAC,KAAK,CAAC;aACd,WAAW,CAAC,YAAY,KAAK,OAAO,CAAC;aACrC,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC;aACvC,MAAM,CAAC,KAAK,EAAE,IAAuB,EAAE,EAAE;YACxC,IAAI,IAAa,CAAC;YAClB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,IAAI,CAAC;oBAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;YAC9D,CAAC;YACD,MAAM,IAAA,kBAAI,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACxB,kBAAM,CAAC,OAAO,CAAC,UAAU,KAAK,EAAE,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point — registers all commands and parses arguments.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const commander_1 = require("commander");
|
|
7
|
+
const init_js_1 = require("./init.js");
|
|
8
|
+
const agent_js_1 = require("./agent.js");
|
|
9
|
+
const swarm_js_1 = require("./swarm.js");
|
|
10
|
+
const memory_js_1 = require("./memory.js");
|
|
11
|
+
const hooks_js_1 = require("./hooks.js");
|
|
12
|
+
const route_js_1 = require("./route.js");
|
|
13
|
+
const status_js_1 = require("./status.js");
|
|
14
|
+
const doctor_js_1 = require("./doctor.js");
|
|
15
|
+
const program = new commander_1.Command();
|
|
16
|
+
program
|
|
17
|
+
.name('copilot-flow')
|
|
18
|
+
.description('Multi-agent orchestration framework for GitHub Copilot CLI\n' +
|
|
19
|
+
'Inspired by Ruflo (claude-flow) — https://github.com/ruvnet/claude-flow')
|
|
20
|
+
.version('1.0.0');
|
|
21
|
+
// Register all commands
|
|
22
|
+
(0, init_js_1.registerInit)(program);
|
|
23
|
+
(0, agent_js_1.registerAgent)(program);
|
|
24
|
+
(0, swarm_js_1.registerSwarm)(program);
|
|
25
|
+
(0, memory_js_1.registerMemory)(program);
|
|
26
|
+
(0, hooks_js_1.registerHooks)(program);
|
|
27
|
+
(0, route_js_1.registerRoute)(program);
|
|
28
|
+
(0, status_js_1.registerStatus)(program);
|
|
29
|
+
(0, doctor_js_1.registerDoctor)(program);
|
|
30
|
+
program.parse(process.argv);
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAEH,yCAAoC;AACpC,uCAAyC;AACzC,yCAA2C;AAC3C,yCAA2C;AAC3C,2CAA6C;AAC7C,yCAA2C;AAC3C,yCAA2C;AAC3C,2CAA6C;AAC7C,2CAA6C;AAE7C,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,cAAc,CAAC;KACpB,WAAW,CACV,8DAA8D;IAC9D,yEAAyE,CAC1E;KACA,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,wBAAwB;AACxB,IAAA,sBAAY,EAAC,OAAO,CAAC,CAAC;AACtB,IAAA,wBAAa,EAAC,OAAO,CAAC,CAAC;AACvB,IAAA,wBAAa,EAAC,OAAO,CAAC,CAAC;AACvB,IAAA,0BAAc,EAAC,OAAO,CAAC,CAAC;AACxB,IAAA,wBAAa,EAAC,OAAO,CAAC,CAAC;AACvB,IAAA,wBAAa,EAAC,OAAO,CAAC,CAAC;AACvB,IAAA,0BAAc,EAAC,OAAO,CAAC,CAAC;AACxB,IAAA,0BAAc,EAAC,OAAO,CAAC,CAAC;AAExB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiCnD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerInit = registerInit;
|
|
4
|
+
const config_js_1 = require("../config.js");
|
|
5
|
+
const output_js_1 = require("../output.js");
|
|
6
|
+
function registerInit(program) {
|
|
7
|
+
program
|
|
8
|
+
.command('init')
|
|
9
|
+
.description('Initialise copilot-flow in the current directory')
|
|
10
|
+
.option('--model <model>', 'Default model to use', config_js_1.DEFAULT_CONFIG.defaultModel)
|
|
11
|
+
.option('--max-agents <n>', 'Maximum concurrent agents', String(config_js_1.DEFAULT_CONFIG.swarm.maxAgents))
|
|
12
|
+
.option('--topology <type>', 'Swarm topology (hierarchical|mesh|sequential)', config_js_1.DEFAULT_CONFIG.swarm.topology)
|
|
13
|
+
.action((opts) => {
|
|
14
|
+
if ((0, config_js_1.isInitialised)()) {
|
|
15
|
+
output_js_1.output.warn('.copilot-flow/config.json already exists. Re-initialising...');
|
|
16
|
+
}
|
|
17
|
+
const config = {
|
|
18
|
+
...config_js_1.DEFAULT_CONFIG,
|
|
19
|
+
defaultModel: opts.model,
|
|
20
|
+
swarm: {
|
|
21
|
+
...config_js_1.DEFAULT_CONFIG.swarm,
|
|
22
|
+
topology: opts.topology,
|
|
23
|
+
maxAgents: parseInt(opts.maxAgents, 10),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
(0, config_js_1.ensureRuntimeDirs)();
|
|
27
|
+
(0, config_js_1.saveConfig)(config);
|
|
28
|
+
output_js_1.output.success('Initialised copilot-flow');
|
|
29
|
+
output_js_1.output.blank();
|
|
30
|
+
output_js_1.output.print(' Config: .copilot-flow/config.json');
|
|
31
|
+
output_js_1.output.print(' Memory: .copilot-flow/memory.db');
|
|
32
|
+
output_js_1.output.print(' Agents: .copilot-flow/agents/');
|
|
33
|
+
output_js_1.output.blank();
|
|
34
|
+
output_js_1.output.dim('Next: copilot-flow agent spawn --type coder --task "Your task"');
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;AAIA,oCAiCC;AApCD,4CAA4F;AAC5F,4CAAsC;AAEtC,SAAgB,YAAY,CAAC,OAAgB;IAC3C,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,kDAAkD,CAAC;SAC/D,MAAM,CAAC,iBAAiB,EAAE,sBAAsB,EAAE,0BAAc,CAAC,YAAY,CAAC;SAC9E,MAAM,CAAC,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,CAAC,0BAAc,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;SAC/F,MAAM,CAAC,mBAAmB,EAAE,+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