-
Notifications
You must be signed in to change notification settings - Fork 330
Expand file tree
/
Copy pathexport.ts
More file actions
97 lines (91 loc) · 2.91 KB
/
export.ts
File metadata and controls
97 lines (91 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Command } from 'commander';
import { resolve } from 'node:path';
import { error, heading, info, success } from '../utils/format.js';
import {
exportToSystemPrompt,
exportToClaudeCode,
exportToOpenAI,
exportToCrewAI,
exportToOpenClawString,
exportToNanobotString,
exportToCopilotString,
exportToOpenCodeString,
exportToCursorString,
exportToGeminiString,
exportToCodexString,
} from '../adapters/index.js';
import { exportToLyzrString } from '../adapters/lyzr.js';
import { exportToGitHubString } from '../adapters/github.js';
interface ExportOptions {
format: string;
dir: string;
output: string | undefined;
}
export const exportCommand = new Command('export')
.description('Export agent to other formats')
.requiredOption('-f, --format <format>', 'Export format (system-prompt, claude-code, openai, crewai, openclaw, nanobot, lyzr, github, copilot, opencode, cursor, gemini, codex)')
.option('-d, --dir <dir>', 'Agent directory', '.')
.option('-o, --output <output>', 'Output file path')
.action(async (options: ExportOptions) => {
const dir = resolve(options.dir);
heading('Exporting agent');
info(`Format: ${options.format}`);
try {
let result: string;
switch (options.format) {
case 'system-prompt':
result = exportToSystemPrompt(dir);
break;
case 'claude-code':
result = exportToClaudeCode(dir);
break;
case 'openai':
result = exportToOpenAI(dir);
break;
case 'crewai':
result = exportToCrewAI(dir);
break;
case 'openclaw':
result = exportToOpenClawString(dir);
break;
case 'nanobot':
result = exportToNanobotString(dir);
break;
case 'lyzr':
result = exportToLyzrString(dir);
break;
case 'github':
result = exportToGitHubString(dir);
break;
case 'copilot':
result = exportToCopilotString(dir);
break;
case 'opencode':
result = exportToOpenCodeString(dir);
break;
case 'cursor':
result = exportToCursorString(dir);
break;
case 'gemini':
result = exportToGeminiString(dir);
break;
case 'codex':
result = exportToCodexString(dir);
break;
default:
error(`Unknown format: ${options.format}`);
info('Supported formats: system-prompt, claude-code, openai, crewai, openclaw, nanobot, lyzr, github, copilot, opencode, cursor, gemini, codex');
process.exit(1);
}
if (options.output) {
const { writeFileSync } = await import('node:fs');
writeFileSync(resolve(options.output), result, 'utf-8');
success(`Exported to ${options.output}`);
} else {
console.log(result);
}
} catch (e) {
error((e as Error).message);
process.exit(1);
}
});