@callsitehq/cli 0.1.0
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/dist/index.d.ts +8 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/package.json +27 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { mkdir, writeFile } from "fs/promises";
|
|
5
|
+
import { dirname, resolve } from "path";
|
|
6
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
7
|
+
import {
|
|
8
|
+
emitChatGptAppConfig,
|
|
9
|
+
emitClaudeConnectorConfig,
|
|
10
|
+
emitMcpJson,
|
|
11
|
+
emitOpenApi
|
|
12
|
+
} from "@callsitehq/emit";
|
|
13
|
+
async function build(options) {
|
|
14
|
+
const configUrl = pathToFileURL(resolve(options.configPath));
|
|
15
|
+
const configModule = await import(configUrl.href);
|
|
16
|
+
const ir = readIR(configModule.default ?? configModule.ir);
|
|
17
|
+
const outDir = resolve(options.outDir);
|
|
18
|
+
await writeArtifact(resolve(outDir, "mcp.json"), emitMcpJson(ir));
|
|
19
|
+
await writeArtifact(resolve(outDir, "openapi.json"), emitOpenApi(ir));
|
|
20
|
+
await writeArtifact(resolve(outDir, "chatgpt-app.json"), emitChatGptAppConfig(ir));
|
|
21
|
+
await writeArtifact(resolve(outDir, "claude-connector.json"), emitClaudeConnectorConfig(ir));
|
|
22
|
+
}
|
|
23
|
+
async function main(argv = process.argv.slice(2)) {
|
|
24
|
+
const [command, ...args] = argv;
|
|
25
|
+
if (command !== "build") {
|
|
26
|
+
printHelp();
|
|
27
|
+
return command === void 0 || command === "--help" || command === "-h" ? 0 : 1;
|
|
28
|
+
}
|
|
29
|
+
const configPath = readFlag(args, "--config") ?? "callsite.config.js";
|
|
30
|
+
const outDir = readFlag(args, "--out") ?? "dist/callsite";
|
|
31
|
+
await build({ configPath, outDir });
|
|
32
|
+
return 0;
|
|
33
|
+
}
|
|
34
|
+
function readIR(value) {
|
|
35
|
+
if (typeof value !== "object" || value === null || !("version" in value) || value.version !== 1 || !("capabilities" in value) || !Array.isArray(value.capabilities)) {
|
|
36
|
+
throw new TypeError("Callsite config must export a CapabilityIR object.");
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
function readFlag(args, name) {
|
|
41
|
+
const index = args.indexOf(name);
|
|
42
|
+
if (index === -1) {
|
|
43
|
+
return void 0;
|
|
44
|
+
}
|
|
45
|
+
return args[index + 1];
|
|
46
|
+
}
|
|
47
|
+
async function writeArtifact(path, content) {
|
|
48
|
+
await mkdir(dirname(path), { recursive: true });
|
|
49
|
+
await writeFile(path, content);
|
|
50
|
+
}
|
|
51
|
+
function printHelp() {
|
|
52
|
+
process.stdout.write(`callsite
|
|
53
|
+
|
|
54
|
+
Usage:
|
|
55
|
+
callsite build [--config callsite.config.js] [--out dist/callsite]
|
|
56
|
+
`);
|
|
57
|
+
}
|
|
58
|
+
var isDirectRun = process.argv[1] === fileURLToPath(import.meta.url);
|
|
59
|
+
if (isDirectRun) {
|
|
60
|
+
main().then(
|
|
61
|
+
(exitCode) => {
|
|
62
|
+
process.exitCode = exitCode;
|
|
63
|
+
},
|
|
64
|
+
(error) => {
|
|
65
|
+
process.stderr.write(`${error instanceof Error ? error.message : String(error)}
|
|
66
|
+
`);
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
build,
|
|
73
|
+
main
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\n\nimport {\n emitChatGptAppConfig,\n emitClaudeConnectorConfig,\n emitMcpJson,\n emitOpenApi\n} from \"@callsitehq/emit\";\n\nimport type { CapabilityIR } from \"@callsitehq/core\";\n\nexport interface BuildOptions {\n readonly configPath: string;\n readonly outDir: string;\n}\n\nexport async function build(options: BuildOptions): Promise<void> {\n const configUrl = pathToFileURL(resolve(options.configPath));\n const configModule = (await import(configUrl.href)) as { default?: unknown; ir?: unknown };\n const ir = readIR(configModule.default ?? configModule.ir);\n const outDir = resolve(options.outDir);\n\n await writeArtifact(resolve(outDir, \"mcp.json\"), emitMcpJson(ir));\n await writeArtifact(resolve(outDir, \"openapi.json\"), emitOpenApi(ir));\n await writeArtifact(resolve(outDir, \"chatgpt-app.json\"), emitChatGptAppConfig(ir));\n await writeArtifact(resolve(outDir, \"claude-connector.json\"), emitClaudeConnectorConfig(ir));\n}\n\nexport async function main(argv: readonly string[] = process.argv.slice(2)): Promise<number> {\n const [command, ...args] = argv;\n\n if (command !== \"build\") {\n printHelp();\n return command === undefined || command === \"--help\" || command === \"-h\" ? 0 : 1;\n }\n\n const configPath = readFlag(args, \"--config\") ?? \"callsite.config.js\";\n const outDir = readFlag(args, \"--out\") ?? \"dist/callsite\";\n\n await build({ configPath, outDir });\n return 0;\n}\n\nfunction readIR(value: unknown): CapabilityIR {\n if (\n typeof value !== \"object\" ||\n value === null ||\n !(\"version\" in value) ||\n value.version !== 1 ||\n !(\"capabilities\" in value) ||\n !Array.isArray(value.capabilities)\n ) {\n throw new TypeError(\"Callsite config must export a CapabilityIR object.\");\n }\n\n return value as CapabilityIR;\n}\n\nfunction readFlag(args: readonly string[], name: string): string | undefined {\n const index = args.indexOf(name);\n\n if (index === -1) {\n return undefined;\n }\n\n return args[index + 1];\n}\n\nasync function writeArtifact(path: string, content: string): Promise<void> {\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, content);\n}\n\nfunction printHelp(): void {\n process.stdout.write(`callsite\n\nUsage:\n callsite build [--config callsite.config.js] [--out dist/callsite]\n`);\n}\n\nconst isDirectRun = process.argv[1] === fileURLToPath(import.meta.url);\n\nif (isDirectRun) {\n main().then(\n (exitCode) => {\n process.exitCode = exitCode;\n },\n (error: unknown) => {\n process.stderr.write(`${error instanceof Error ? error.message : String(error)}\\n`);\n process.exitCode = 1;\n }\n );\n}\n"],"mappings":";;;AAAA,SAAS,OAAO,iBAAiB;AACjC,SAAS,SAAS,eAAe;AACjC,SAAS,eAAe,qBAAqB;AAE7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AASP,eAAsB,MAAM,SAAsC;AAChE,QAAM,YAAY,cAAc,QAAQ,QAAQ,UAAU,CAAC;AAC3D,QAAM,eAAgB,MAAM,OAAO,UAAU;AAC7C,QAAM,KAAK,OAAO,aAAa,WAAW,aAAa,EAAE;AACzD,QAAM,SAAS,QAAQ,QAAQ,MAAM;AAErC,QAAM,cAAc,QAAQ,QAAQ,UAAU,GAAG,YAAY,EAAE,CAAC;AAChE,QAAM,cAAc,QAAQ,QAAQ,cAAc,GAAG,YAAY,EAAE,CAAC;AACpE,QAAM,cAAc,QAAQ,QAAQ,kBAAkB,GAAG,qBAAqB,EAAE,CAAC;AACjF,QAAM,cAAc,QAAQ,QAAQ,uBAAuB,GAAG,0BAA0B,EAAE,CAAC;AAC7F;AAEA,eAAsB,KAAK,OAA0B,QAAQ,KAAK,MAAM,CAAC,GAAoB;AAC3F,QAAM,CAAC,SAAS,GAAG,IAAI,IAAI;AAE3B,MAAI,YAAY,SAAS;AACvB,cAAU;AACV,WAAO,YAAY,UAAa,YAAY,YAAY,YAAY,OAAO,IAAI;AAAA,EACjF;AAEA,QAAM,aAAa,SAAS,MAAM,UAAU,KAAK;AACjD,QAAM,SAAS,SAAS,MAAM,OAAO,KAAK;AAE1C,QAAM,MAAM,EAAE,YAAY,OAAO,CAAC;AAClC,SAAO;AACT;AAEA,SAAS,OAAO,OAA8B;AAC5C,MACE,OAAO,UAAU,YACjB,UAAU,QACV,EAAE,aAAa,UACf,MAAM,YAAY,KAClB,EAAE,kBAAkB,UACpB,CAAC,MAAM,QAAQ,MAAM,YAAY,GACjC;AACA,UAAM,IAAI,UAAU,oDAAoD;AAAA,EAC1E;AAEA,SAAO;AACT;AAEA,SAAS,SAAS,MAAyB,MAAkC;AAC3E,QAAM,QAAQ,KAAK,QAAQ,IAAI;AAE/B,MAAI,UAAU,IAAI;AAChB,WAAO;AAAA,EACT;AAEA,SAAO,KAAK,QAAQ,CAAC;AACvB;AAEA,eAAe,cAAc,MAAc,SAAgC;AACzE,QAAM,MAAM,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAC9C,QAAM,UAAU,MAAM,OAAO;AAC/B;AAEA,SAAS,YAAkB;AACzB,UAAQ,OAAO,MAAM;AAAA;AAAA;AAAA;AAAA,CAItB;AACD;AAEA,IAAM,cAAc,QAAQ,KAAK,CAAC,MAAM,cAAc,YAAY,GAAG;AAErE,IAAI,aAAa;AACf,OAAK,EAAE;AAAA,IACL,CAAC,aAAa;AACZ,cAAQ,WAAW;AAAA,IACrB;AAAA,IACA,CAAC,UAAmB;AAClB,cAAQ,OAAO,MAAM,GAAG,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,CAAC;AAAA,CAAI;AAClF,cAAQ,WAAW;AAAA,IACrB;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@callsitehq/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Command-line tools for building Callsite generated artifacts.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"callsite": "./dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@callsitehq/core": "0.1.0",
|
|
20
|
+
"@callsitehq/emit": "0.1.0"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
25
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
26
|
+
}
|
|
27
|
+
}
|