-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathindex.ts
More file actions
120 lines (99 loc) · 2.64 KB
/
index.ts
File metadata and controls
120 lines (99 loc) · 2.64 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/usr/bin/env node
import { auth } from './auth';
import { build } from './build';
import { deploy } from './deploy';
import { docsMcpServer } from './docs-mcp-server';
import { createPipe } from './pipe/create';
import { runPipe } from './pipe/run';
import { updatePipe } from './pipe/update';
import { listPipes } from './pipe/list';
import cli from './utils/cli';
import debugMode from './utils/debug-mode';
import cliInit from './utils/init';
import { createMemory } from './memory/create';
import { listMemories } from './memory/list';
import { deleteMemory } from './memory/delete';
import { uploadDocs } from './memory/upload-docs';
import { embedDoc } from './memory/embed-doc';
import { retriveFromMemory } from './memory/retrive';
import { listDocs } from './memory/list-docs';
const { flags, input, showHelp } = cli;
const { clear, debug } = flags;
// Utility function to check if a command is present
const command = (cmd: string): boolean => input.includes(cmd);
// Utility function to check if a flag is present
const flag = (flg: string): boolean => Boolean(flags[flg]);
(async () => {
// Skip welcome message for docs-mcp-server command
if (!command('docs-mcp-server')) {
await cliInit({ clear });
}
if (debug) debugMode(cli);
if (command('help')) {
showHelp(0);
}
if (command('auth')) {
await auth();
}
if (command('build')) {
const filePath = flags.file;
await build({ filePath });
// await deploy({ isDev, agent, filePath, apiKey });
}
if (command('deploy')) {
const isDev = flag('dev');
const agent = flags.agent;
const filePath = flags.file;
const apiKey = flags.key;
await deploy({ isDev, agent, filePath, apiKey });
}
if (command('docs-mcp-server')) {
await docsMcpServer();
}
if (
command('pipe') &&
!flag('run') &&
!flag('update') &&
!flag('listPipes')
) {
await createPipe();
}
if (command('pipe') && flag('run')) {
await runPipe();
}
if (command('pipe') && flag('update')) {
await updatePipe();
}
if (command('pipe') && flag('listPipes')) {
await listPipes();
}
if (
command('memory') &&
!flag('upload') &&
!flag('embed') &&
!flag('retrieve') &&
!flag('listDocs') &&
!flag('delete') &&
!flag('listMemories')
) {
await createMemory();
}
if (command('memory') && flag('listMemories')) {
await listMemories();
}
if (command('memory') && flag('delete')) {
await deleteMemory();
}
if (command('memory') && flag('upload')) {
await uploadDocs();
}
if (command('memory') && flag('embed')) {
await embedDoc();
}
if (command('memory') && flag('retrieve')) {
await retriveFromMemory();
}
if (command('memory') && flag('listDocs')) {
await listDocs();
}
})();