straylight-ai 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/bin/cli.js +39 -0
- package/bin/mcp-shim.js +85 -0
- package/dist/commands/setup.d.ts +9 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +61 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/start.d.ts +6 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +33 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +11 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +40 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +6 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +25 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/docker.d.ts +42 -0
- package/dist/docker.d.ts.map +1 -0
- package/dist/docker.js +126 -0
- package/dist/docker.js.map +1 -0
- package/dist/health.d.ts +22 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +44 -0
- package/dist/health.js.map +1 -0
- package/dist/mcp-register.d.ts +19 -0
- package/dist/mcp-register.d.ts.map +1 -0
- package/dist/mcp-register.js +59 -0
- package/dist/mcp-register.js.map +1 -0
- package/dist/open.d.ts +6 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +70 -0
- package/dist/open.js.map +1 -0
- package/package.json +39 -0
- package/src/__tests__/commands.test.ts +272 -0
- package/src/__tests__/docker.test.ts +139 -0
- package/src/__tests__/health.test.ts +107 -0
- package/src/__tests__/mcp-register.test.ts +123 -0
- package/src/__tests__/open.test.ts +61 -0
- package/src/commands/setup.ts +72 -0
- package/src/commands/start.ts +44 -0
- package/src/commands/status.ts +51 -0
- package/src/commands/stop.ts +31 -0
- package/src/docker.ts +102 -0
- package/src/health.ts +55 -0
- package/src/mcp-register.ts +62 -0
- package/src/open.ts +33 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { execSync, spawnSync } from "child_process";
|
|
2
|
+
|
|
3
|
+
/** Name to use when registering the MCP server */
|
|
4
|
+
const MCP_SERVER_NAME = "straylight-ai";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Check whether the Claude Code CLI is available on PATH.
|
|
8
|
+
*/
|
|
9
|
+
export function isClaudeAvailable(): boolean {
|
|
10
|
+
try {
|
|
11
|
+
execSync("claude --version", { stdio: "pipe" });
|
|
12
|
+
return true;
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Register the Straylight-AI MCP server with Claude Code.
|
|
20
|
+
*
|
|
21
|
+
* Runs:
|
|
22
|
+
* claude mcp add straylight-ai --transport stdio -- npx straylight-ai mcp
|
|
23
|
+
*
|
|
24
|
+
* @returns true on success, false if claude is unavailable or the command fails.
|
|
25
|
+
*/
|
|
26
|
+
export async function registerMCP(): Promise<boolean> {
|
|
27
|
+
if (!isClaudeAvailable()) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const result = spawnSync(
|
|
32
|
+
"claude",
|
|
33
|
+
[
|
|
34
|
+
"mcp",
|
|
35
|
+
"add",
|
|
36
|
+
MCP_SERVER_NAME,
|
|
37
|
+
"--transport",
|
|
38
|
+
"stdio",
|
|
39
|
+
"--",
|
|
40
|
+
"npx",
|
|
41
|
+
"straylight-ai",
|
|
42
|
+
"mcp",
|
|
43
|
+
],
|
|
44
|
+
{ stdio: "pipe" }
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return result.status === 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build the manual registration instructions string for users who do not have
|
|
52
|
+
* Claude Code installed.
|
|
53
|
+
*/
|
|
54
|
+
export function manualRegistrationInstructions(): string {
|
|
55
|
+
return [
|
|
56
|
+
"To register the MCP server manually, run:",
|
|
57
|
+
"",
|
|
58
|
+
" claude mcp add straylight-ai --transport stdio -- npx straylight-ai mcp",
|
|
59
|
+
"",
|
|
60
|
+
"Or add it directly to your Claude Code settings.",
|
|
61
|
+
].join("\n");
|
|
62
|
+
}
|
package/src/open.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import * as os from "os";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Open the given URL in the system's default browser.
|
|
6
|
+
* Best-effort: failure is silent to avoid blocking the setup flow.
|
|
7
|
+
*/
|
|
8
|
+
export async function openBrowser(url: string): Promise<void> {
|
|
9
|
+
const platform = os.platform();
|
|
10
|
+
let command: string;
|
|
11
|
+
|
|
12
|
+
if (platform === "darwin") {
|
|
13
|
+
command = "open";
|
|
14
|
+
} else if (platform === "win32") {
|
|
15
|
+
command = "start";
|
|
16
|
+
} else {
|
|
17
|
+
command = "xdg-open";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return new Promise<void>((resolve) => {
|
|
21
|
+
try {
|
|
22
|
+
const child = spawn(command, [url], {
|
|
23
|
+
stdio: "ignore",
|
|
24
|
+
detached: true,
|
|
25
|
+
});
|
|
26
|
+
child.unref();
|
|
27
|
+
} catch {
|
|
28
|
+
// Best-effort: ignore errors opening the browser
|
|
29
|
+
}
|
|
30
|
+
// Resolve immediately; we don't wait for the browser to finish
|
|
31
|
+
resolve();
|
|
32
|
+
});
|
|
33
|
+
}
|