jetic-cli 0.1.2 → 0.1.4
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 +450 -50
- package/dist/dashboard/assets/index-DIr8-5sp.css +1 -0
- package/dist/dashboard/assets/index-DeZbqocl.js +379 -0
- package/dist/dashboard/index.html +3 -3
- package/dist/dashboard/jetic.svg +4 -0
- package/dist/dashboard/jetic_light.png +0 -0
- package/dist/dashboard/jetic_logo.svg +10 -0
- package/dist/dashboard/jetic_white_bg.png +0 -0
- package/dist/index.js +2197 -1375
- package/package.json +7 -9
- package/dist/dashboard/assets/index-Dk01eD-3.js +0 -347
- package/dist/dashboard/assets/index-cvc-GV1-.css +0 -1
- package/dist/dashboard/react.svg +0 -1
- package/dist/dashboard/vite.svg +0 -1
- package/src/commands/config.ts +0 -36
- package/src/commands/dev.ts +0 -451
- package/src/commands/init.ts +0 -64
- package/src/commands/inspect.ts +0 -47
- package/src/commands/memory.ts +0 -71
- package/src/commands/scan.ts +0 -22
- package/src/commands/simulate-workflow.ts +0 -794
- package/src/commands/simulate.ts +0 -512
- package/src/index.ts +0 -26
- package/tsconfig.json +0 -8
- package/tsup.config.ts +0 -26
package/src/commands/init.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { loadConfig, saveConfig, ensureDirSync } from '@jetic/core';
|
|
3
|
-
import * as readline from 'readline/promises';
|
|
4
|
-
import { stdin as input, stdout as output } from 'process';
|
|
5
|
-
|
|
6
|
-
export const initCommand = new Command('init')
|
|
7
|
-
.description('Initialize Jetic in the current directory')
|
|
8
|
-
.action(async () => {
|
|
9
|
-
const config = loadConfig();
|
|
10
|
-
ensureDirSync(config.jeticDir);
|
|
11
|
-
|
|
12
|
-
console.log('\x1b[36mWelcome to Jetic Initialization\x1b[0m\n');
|
|
13
|
-
|
|
14
|
-
const rl = readline.createInterface({ input, output });
|
|
15
|
-
|
|
16
|
-
const providerInput = await rl.question('AI Provider [default: openrouter]: ');
|
|
17
|
-
const modelInput = await rl.question('Model name [default: meta-llama/llama-3.1-8b-instruct]: ');
|
|
18
|
-
const apiKeyInput = await rl.question('API Key: ');
|
|
19
|
-
|
|
20
|
-
rl.close();
|
|
21
|
-
|
|
22
|
-
const provider = providerInput.trim() || 'openrouter';
|
|
23
|
-
const envVarName = `${provider.toUpperCase()}_API_KEY`;
|
|
24
|
-
|
|
25
|
-
config.ai = {
|
|
26
|
-
provider: provider,
|
|
27
|
-
model: modelInput.trim() || 'meta-llama/llama-3.1-8b-instruct',
|
|
28
|
-
apiKeyEnvVar: envVarName
|
|
29
|
-
};
|
|
30
|
-
saveConfig(config);
|
|
31
|
-
|
|
32
|
-
if (apiKeyInput.trim()) {
|
|
33
|
-
const fs = require('fs');
|
|
34
|
-
const envPath = require('path').join(process.cwd(), '.env');
|
|
35
|
-
const envContent = `\n${envVarName}=${apiKeyInput.trim()}\n`;
|
|
36
|
-
fs.appendFileSync(envPath, envContent);
|
|
37
|
-
console.log(`\n\x1b[32m✓\x1b[0m Saved API key to .env file as ${envVarName}`);
|
|
38
|
-
console.log(`(Alternatively, you can run: set ${envVarName}=${apiKeyInput.trim()})\n`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const banner = `
|
|
42
|
-
\x1b[36m
|
|
43
|
-
__ __ _ _____
|
|
44
|
-
\\ \\ / /__| | ___ ___ _ __ ___ ___ |_ _|__
|
|
45
|
-
\\ \\ /\\ / / _ \\ |/ __/ _ \\| '_ \` _ \\ / _ \\ | |/ _ \\
|
|
46
|
-
\\ V V / __/ | (_| (_) | | | | | | __/ | | (_) |
|
|
47
|
-
\\_/\\_/ \\___|_|\\___\\___/|_| |_| |_|\\___| |_|\\___/
|
|
48
|
-
|
|
49
|
-
_ _____ _____ ___ ___
|
|
50
|
-
| | ____|_ _|_ _/ __|
|
|
51
|
-
_ | | _| | | | | |
|
|
52
|
-
| |_| | |___ | | | | |__
|
|
53
|
-
\\___/|_____| |_| |___\\___|
|
|
54
|
-
\x1b[0m`;
|
|
55
|
-
|
|
56
|
-
console.log(banner);
|
|
57
|
-
console.log(`\x1b[32m✓\x1b[0m Successfully initialized Jetic in \x1b[1m${config.jeticDir}\x1b[0m\n`);
|
|
58
|
-
console.log('Available Commands:');
|
|
59
|
-
console.log(' \x1b[36mjetic init\x1b[0m Initialize Jetic in the current directory');
|
|
60
|
-
console.log(' \x1b[36mjetic scan\x1b[0m Scan the project for API routes and generate behavioral model');
|
|
61
|
-
console.log(' \x1b[36mjetic inspect\x1b[0m Inspect discovered endpoints and details');
|
|
62
|
-
console.log(' \x1b[36mjetic config\x1b[0m Manage Jetic AI provider and settings');
|
|
63
|
-
console.log('');
|
|
64
|
-
});
|
package/src/commands/inspect.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { loadConfig, readJsonSync } from '@jetic/core';
|
|
3
|
-
import { BehavioralModel } from '@jetic/model';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
|
|
6
|
-
export const inspectCommand = new Command('inspect')
|
|
7
|
-
.description('Inspect the discovered API model')
|
|
8
|
-
.action(() => {
|
|
9
|
-
const config = loadConfig();
|
|
10
|
-
const modelPath = path.join(config.jeticDir, 'model.json');
|
|
11
|
-
const model = readJsonSync<BehavioralModel>(modelPath);
|
|
12
|
-
|
|
13
|
-
if (!model) {
|
|
14
|
-
console.error('No behavioral model found. Run `jetic scan` first.');
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
console.log(`Model Version: ${model.version}`);
|
|
19
|
-
console.log(`Endpoints (${model.endpoints.length}):\n`);
|
|
20
|
-
|
|
21
|
-
for (const ep of model.endpoints) {
|
|
22
|
-
console.log(`${ep.method} ${ep.path}`);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
inspectCommand
|
|
27
|
-
.command('endpoint <method> <path>')
|
|
28
|
-
.description('Inspect a specific endpoint')
|
|
29
|
-
.action((method, urlPath) => {
|
|
30
|
-
const config = loadConfig();
|
|
31
|
-
const modelPath = path.join(config.jeticDir, 'model.json');
|
|
32
|
-
const model = readJsonSync<BehavioralModel>(modelPath);
|
|
33
|
-
|
|
34
|
-
if (!model) return;
|
|
35
|
-
|
|
36
|
-
const ep = model.endpoints.find(
|
|
37
|
-
e => e.method.toLowerCase() === method.toLowerCase() && e.path === urlPath
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
if (!ep) {
|
|
41
|
-
console.error('Endpoint not found');
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
console.log(`${ep.method} ${ep.path}\n`);
|
|
46
|
-
console.log(`Source:\n ${ep.source.file}:${ep.source.line}`);
|
|
47
|
-
});
|
package/src/commands/memory.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { JeticMemory } from '@jetic/memory';
|
|
3
|
-
import * as readline from 'readline/promises';
|
|
4
|
-
import { stdin as input, stdout as output } from 'process';
|
|
5
|
-
|
|
6
|
-
export const memoryCommand = new Command('memory')
|
|
7
|
-
.description('Manage Jetic memory state')
|
|
8
|
-
.action(() => {
|
|
9
|
-
const allMemory = JeticMemory.getAllMemory();
|
|
10
|
-
|
|
11
|
-
let sn = 1;
|
|
12
|
-
const tableData: Array<{ 'S/N': number, KEY: string, TEXT: string }> = [];
|
|
13
|
-
|
|
14
|
-
for (const scope in allMemory) {
|
|
15
|
-
for (const key in allMemory[scope]) {
|
|
16
|
-
const value = allMemory[scope][key];
|
|
17
|
-
const text = typeof value === 'object' ? JSON.stringify(value) : String(value);
|
|
18
|
-
|
|
19
|
-
tableData.push({
|
|
20
|
-
'S/N': sn++,
|
|
21
|
-
'KEY': `${scope}:${key}`,
|
|
22
|
-
'TEXT': text.length > 50 ? text.substring(0, 47) + '...' : text
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
if (tableData.length === 0) {
|
|
28
|
-
console.log('Memory is empty.');
|
|
29
|
-
} else {
|
|
30
|
-
console.table(tableData, ['S/N', 'KEY', 'TEXT']);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
memoryCommand
|
|
35
|
-
.command('add')
|
|
36
|
-
.description('Add a new entry to memory interactively')
|
|
37
|
-
.action(async () => {
|
|
38
|
-
const rl = readline.createInterface({ input, output });
|
|
39
|
-
|
|
40
|
-
const keyInput = await rl.question('Key/Identifier: ');
|
|
41
|
-
if (!keyInput.trim()) {
|
|
42
|
-
console.log('Key is required.');
|
|
43
|
-
rl.close();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const textInput = await rl.question('Text: ');
|
|
48
|
-
rl.close();
|
|
49
|
-
|
|
50
|
-
const parts = keyInput.trim().split(':');
|
|
51
|
-
let scope = 'global';
|
|
52
|
-
let key = parts[0];
|
|
53
|
-
|
|
54
|
-
if (parts.length > 1) {
|
|
55
|
-
scope = parts[0];
|
|
56
|
-
key = parts.slice(1).join(':');
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const memory = new JeticMemory({ scope });
|
|
60
|
-
await memory.set(key, textInput);
|
|
61
|
-
|
|
62
|
-
console.log(`\x1b[32m✓\x1b[0m Successfully added ${keyInput.trim()} to memory.`);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
memoryCommand
|
|
66
|
-
.command('clear')
|
|
67
|
-
.description('Clear memory')
|
|
68
|
-
.action(() => {
|
|
69
|
-
JeticMemory.clearAllMemory();
|
|
70
|
-
console.log('Memory cleared.');
|
|
71
|
-
});
|
package/src/commands/scan.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { loadConfig, writeJsonSync, ensureDirSync } from '@jetic/core';
|
|
3
|
-
import { ExpressScanner } from '@jetic/scanner';
|
|
4
|
-
import * as path from 'path';
|
|
5
|
-
|
|
6
|
-
export const scanCommand = new Command('scan')
|
|
7
|
-
.description('Scan the project for API routes')
|
|
8
|
-
.action(async () => {
|
|
9
|
-
console.log('Jetic API Intelligence\nScanning project...\n');
|
|
10
|
-
|
|
11
|
-
const config = loadConfig();
|
|
12
|
-
ensureDirSync(config.jeticDir);
|
|
13
|
-
|
|
14
|
-
const scanner = new ExpressScanner(config);
|
|
15
|
-
const model = await scanner.scan();
|
|
16
|
-
|
|
17
|
-
const modelPath = path.join(config.jeticDir, 'model.json');
|
|
18
|
-
writeJsonSync(modelPath, model);
|
|
19
|
-
|
|
20
|
-
console.log(`✓ Discovered ${model.endpoints.length} endpoints`);
|
|
21
|
-
console.log(`Behavioral model generated at ${modelPath}`);
|
|
22
|
-
});
|