@vibest/cli 0.0.0 → 0.0.1
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/CHANGELOG.md +9 -0
- package/package.json +37 -37
- package/src/cli.ts +19 -7
- package/src/server.ts +33 -58
- package/tsdown.config.ts +6 -0
- package/turbo.json +1 -1
package/CHANGELOG.md
ADDED
package/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
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
|
-
}
|
|
2
|
+
"name": "@vibest/cli",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"bin": {
|
|
6
|
+
"vibest": "./dist/cli.js"
|
|
7
|
+
},
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"@anthropic-ai/claude-agent-sdk": "^0.1.12",
|
|
10
|
+
"@hono/node-server": "^1.19.5",
|
|
11
|
+
"@orpc/openapi": "^1.9.3",
|
|
12
|
+
"@orpc/server": "^1.9.1",
|
|
13
|
+
"ai": "^5.0.63",
|
|
14
|
+
"hono": "^4.9.12",
|
|
15
|
+
"uuid": "^13.0.0",
|
|
16
|
+
"ws": "^8.18.3",
|
|
17
|
+
"zod": "^3.25.61",
|
|
18
|
+
"@vibest/web": "0.0.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/bun": "^1.3.0",
|
|
22
|
+
"tsdown": "^0.13.5",
|
|
23
|
+
"tsx": "latest",
|
|
24
|
+
"@vibe-web/agents": "0.0.1",
|
|
25
|
+
"@vibe-web/server-rpc": "0.0.1",
|
|
26
|
+
"@vibe-web/typescript": "0.0.0"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=18.0.0"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "tsx --watch src/cli.ts",
|
|
33
|
+
"build": "tsdown",
|
|
34
|
+
"start": "NODE_ENV=production bun --bun dist/cli.js",
|
|
35
|
+
"typecheck": "tsc --noEmit",
|
|
36
|
+
"clean": "git clean -xdf node_modules .turbo dist"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/src/cli.ts
CHANGED
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { serve } from "@hono/node-server";
|
|
3
4
|
import { createServer } from "./server";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
const app = createServer();
|
|
7
|
+
const server = serve({
|
|
8
|
+
fetch: app.fetch,
|
|
9
|
+
port: 4000,
|
|
10
|
+
});
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
// graceful shutdown
|
|
13
|
+
process.on("SIGINT", () => {
|
|
14
|
+
server.close();
|
|
15
|
+
process.exit(0);
|
|
16
|
+
});
|
|
17
|
+
process.on("SIGTERM", () => {
|
|
18
|
+
server.close((err) => {
|
|
19
|
+
if (err) {
|
|
20
|
+
console.error(err);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
process.exit(0);
|
|
10
24
|
});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
main();
|
|
25
|
+
});
|
package/src/server.ts
CHANGED
|
@@ -1,64 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { RPCHandler } from "@orpc/server/fetch";
|
|
7
|
-
import { ClaudeCodeAgent } from "@vibe-web/agents/claude-code";
|
|
8
|
-
import { router } from "@vibe-web/server-rpc/routes";
|
|
9
|
-
import { Elysia, file } from "elysia";
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path, { extname } from "node:path";
|
|
3
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
4
|
+
import { createFetchRPCHandler } from "@vibe-web/server-rpc";
|
|
5
|
+
import { Hono } from "hono";
|
|
10
6
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
const staticRoot = path.resolve(
|
|
9
|
+
path.dirname(require.resolve("@vibest/web/package.json")),
|
|
10
|
+
"dist",
|
|
11
|
+
);
|
|
16
12
|
|
|
17
13
|
export function createServer() {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
const handler = createFetchRPCHandler();
|
|
15
|
+
const app = new Hono();
|
|
16
|
+
app
|
|
17
|
+
.get("/api/health", (c) => c.json({ status: "ok" }))
|
|
18
|
+
.use("/api/rpc/*", async (c, next) => {
|
|
19
|
+
const { matched, response } = await handler(c.req.raw, {
|
|
20
|
+
prefix: "/api/rpc",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (matched) {
|
|
24
|
+
return c.newResponse(response.body, response);
|
|
25
|
+
}
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
new Elysia({
|
|
26
|
-
adapter: isBun ? undefined : node(),
|
|
27
|
+
await next();
|
|
27
28
|
})
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
context: { claudeCodeAgent },
|
|
39
|
-
});
|
|
40
|
-
return response ?? new Response("Not Found", { status: 404 });
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
parse: "none", // Disable Elysia body parser to prevent "body already used" error
|
|
44
|
-
},
|
|
45
|
-
)
|
|
46
|
-
// Static file serving (handles /assets/* and other static files)
|
|
47
|
-
.use(
|
|
48
|
-
staticPlugin({
|
|
49
|
-
assets: staticRoot,
|
|
50
|
-
prefix: "/",
|
|
51
|
-
indexHTML: false,
|
|
52
|
-
ignorePatterns: ["_shell.html"],
|
|
53
|
-
}),
|
|
54
|
-
)
|
|
55
|
-
// SPA fallback - serve _shell.html for all unmatched routes
|
|
56
|
-
.onError(({ code, set }) => {
|
|
57
|
-
if (code === "NOT_FOUND") {
|
|
58
|
-
set.status = 200;
|
|
59
|
-
set.headers["content-type"] = "text/html; charset=utf-8";
|
|
60
|
-
return file(path.join(staticRoot, "_shell.html"));
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
);
|
|
29
|
+
.use(
|
|
30
|
+
"*",
|
|
31
|
+
serveStatic({
|
|
32
|
+
root: staticRoot,
|
|
33
|
+
rewriteRequestPath: (requestPath) =>
|
|
34
|
+
extname(requestPath) ? requestPath : "/index.html",
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
return app;
|
|
64
39
|
}
|
package/tsdown.config.ts
ADDED