-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
82 lines (68 loc) · 1.87 KB
/
cli.js
File metadata and controls
82 lines (68 loc) · 1.87 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
import readline from 'node:readline';
// CLI Interface Setup
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
/**
* Display help information and exit
*/
export function showHelp() {
console.log(`
Metatron - Stepwise Secure Code Generator
USAGE:
node metatron.js [options]
OPTIONS:
--help, -h Show this help message
--test Run parser tests
--session=filename Load a saved session file
SUPPORTED PROVIDERS:
1. Grok (xAI) - Requires GROK_API_KEY environment variable
2. Ollama - Local models, no API key needed (OLLAMA_MODEL env var optional)
3. Groq - Fast inference, requires GROQ_API_KEY environment variable
4. Claude (Anthropic) - Requires CLAUDE_API_KEY environment variable
EXAMPLES:
node metatron.js
GROK_API_KEY=your_key node metatron.js
OLLAMA_MODEL=llama2 node metatron.js
DESCRIPTION:
Generates code step-by-step with mandatory verification gates.
Each step requires EXPLANATION/CODE/VERIFICATION format from AI.
`);
}
/**
* Parse command line arguments and handle flags
* @returns {Object} Parsed arguments
*/
export function parseArgs() {
const args = {
showHelp: false,
runTests: false,
sessionFile: null
};
if (process.argv.includes('--help') || process.argv.includes('-h')) {
args.showHelp = true;
}
if (process.argv.includes('--test')) {
args.runTests = true;
}
const sessionArg = process.argv.find(arg => arg.startsWith('--session='));
if (sessionArg) {
args.sessionFile = sessionArg.split('=')[1];
}
return args;
}
/**
* Prompt user for input
* @param {string} question - The question to ask
* @returns {Promise<string>} User input
*/
export async function ask(question) {
return new Promise(resolve => rl.question(question + ' ', resolve));
}
/**
* Close the readline interface
*/
export function closeInterface() {
rl.close();
}