MCPcopy Create free account
hub / github.com/docsagent/docsagent / main

Function main

src/cli.ts:10–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8const remaining = args.slice(1);
9
10const main = async () => {
11 if (!command || command === "--help" || command === "-h" || command === "help") {
12 console.log(`
13DocsAgent CLI (Aliases: dag, da)
14
15Usage:
16 docsagent server [paths...] Start persistent service (MCP)
17 docsagent search <q> Search contexts for the query in documents
18 docsagent add <paths...> Add directories or files to DocsAgent
19 docsagent status Check engine status
20 docsagent list List all indexed documents
21 docsagent stop Stop the background service
22
23Examples:
24 docsagent search "Barclays case" (Formal)
25 dag search "Barclays case" (Geeky)
26 da status (Short)
27 `);
28 return;
29 }
30
31 // Any command can auto-start the engine if needed
32 let initPaths: string[] | undefined = undefined;
33 if (command === "server") {
34 const paths = remaining.length > 0 ? remaining : ["."];
35 initPaths = paths.map(p => path.resolve(p));
36 }
37
38 switch (command) {
39 case "server": {
40 const docsagent = new DocsAgent(initPaths);
41 const displayPaths = initPaths ? initPaths.join(", ") : ".";
42 console.log(`Starting DocsAgent MCP Server (indexing: ${displayPaths})...`);
43 await docsagent.startMcpServer();
44 break;
45 }
46
47 case "add": {
48 const docsagent = new DocsAgent(initPaths);
49 if (remaining.length === 0) {
50 console.error("Please specify at least one directory or file to add.");
51 process.exit(1);
52 }
53 const absolutePaths = remaining.map(p => path.resolve(p));
54 await docsagent.add(absolutePaths);
55 console.log(`Added ${absolutePaths.join(", ")} to DocsAgent.`);
56 break;
57 }
58
59 case "search": {
60 const docsagent = new DocsAgent(initPaths);
61 const query = remaining.join(" ");
62 if (!query) {
63 console.error("Please specify a search query.");
64 process.exit(1);
65 }
66 const results = await docsagent.search(query);
67 if (results.length === 0) {

Callers 1

cli.tsFile · 0.85

Calls 6

startMcpServerMethod · 0.95
addMethod · 0.95
searchMethod · 0.95
statusMethod · 0.95
listMethod · 0.95
closeMethod · 0.95

Tested by

no test coverage detected