-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.ts
More file actions
43 lines (36 loc) · 1.3 KB
/
index.ts
File metadata and controls
43 lines (36 loc) · 1.3 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
#!/usr/bin/env node
/**
* CLI entry point for context-connectors
*/
import { Command } from "commander";
import { createRequire } from "module";
import { indexCommand } from "./cmd-index.js";
import { searchCommand } from "./cmd-search.js";
import { mcpCommand } from "./cmd-mcp.js";
import { listCommand, deleteCommand } from "./cmd-local.js";
import { agentCommand } from "./cmd-agent.js";
const require = createRequire(import.meta.url);
const packageJson = require("../../package.json");
const program = new Command();
program
.name("ctxc")
.description("Index and search any data source with Augment's context engine")
.version(packageJson.version);
// Add subcommands
program.addCommand(indexCommand);
program.addCommand(listCommand);
program.addCommand(deleteCommand);
program.addCommand(searchCommand);
program.addCommand(mcpCommand);
program.addCommand(agentCommand);
// Auto-detect URL mode: ctxc index <url> -> ctxc index url <url>
// URL must be the first argument after 'index' (like any subcommand)
const indexIdx = process.argv.indexOf("index");
if (indexIdx !== -1 && indexIdx + 1 < process.argv.length) {
const nextArg = process.argv[indexIdx + 1];
if (nextArg.match(/^https?:\/\//)) {
// Insert 'url' before the URL
process.argv.splice(indexIdx + 1, 0, "url");
}
}
program.parse();