create-donghanh 0.3.2 → 0.4.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/package.json +1 -1
- package/templates/kanban-gpt/README.md +24 -3
- package/templates/kanban-gpt/donghanh.config.ts +20 -0
- package/templates/kanban-gpt/executor.ts +1 -0
- package/templates/kanban-gpt/manifest/manifest.d.ts +2 -0
- package/templates/kanban-gpt/manifest/manifest.js +2 -0
- package/templates/kanban-gpt/operations/add-card.tsx +1 -0
- package/templates/kanban-gpt/operations/add-member.tsx +1 -0
- package/templates/kanban-gpt/operations/board-detail.tsx +1 -0
- package/templates/kanban-gpt/operations/create-board.tsx +1 -0
- package/templates/kanban-gpt/operations/list-boards.tsx +1 -0
- package/templates/kanban-gpt/operations/move-card.tsx +1 -0
- package/templates/kanban-gpt/package.json +13 -4
- package/templates/kanban-gpt/tsconfig.json +2 -2
- package/templates/kanban-gpt/vite.config.ts +18 -0
- package/templates/kanban-gpt/widgets/task-card.tsx +5 -0
- package/templates/kanban-gpt/widgets/tsconfig.json +14 -0
- package/templates/kanban-gpt/worker.ts +35 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Kanban GPT
|
|
2
2
|
|
|
3
|
-
A kanban board powered by [@donghanh](https://github.com/rezzahub/donghanh) with GPT Store
|
|
3
|
+
A kanban board powered by [@donghanh](https://github.com/rezzahub/donghanh). Ships with three adapters sharing the same operations: GPT Store (GPT Actions), ChatGPT Apps SDK (MCP), and self-hosted chat.
|
|
4
4
|
|
|
5
5
|
## Setup
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ A kanban board powered by [@donghanh](https://github.com/rezzahub/donghanh) with
|
|
|
8
8
|
bun install
|
|
9
9
|
npx wrangler d1 create my-kanban-db
|
|
10
10
|
# Copy the database_id into wrangler.toml
|
|
11
|
-
|
|
11
|
+
bun run db:init
|
|
12
12
|
npx wrangler secret put BETTER_AUTH_SECRET
|
|
13
13
|
bun run dev
|
|
14
14
|
```
|
|
@@ -24,7 +24,7 @@ bun run dev
|
|
|
24
24
|
| `move-card` | mutation | Move card between columns |
|
|
25
25
|
| `add-member` | mutation | Add member to board |
|
|
26
26
|
|
|
27
|
-
## GPT Store
|
|
27
|
+
## GPT Store setup
|
|
28
28
|
|
|
29
29
|
1. Create a GPT Action in the [ChatGPT GPT Store editor](https://chatgpt.com/gpts/editor)
|
|
30
30
|
2. Set the API server URL to your deployed worker URL
|
|
@@ -38,8 +38,29 @@ bun run dev
|
|
|
38
38
|
npx wrangler secret put GPT_OAUTH_CLIENT_SECRET
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
## ChatGPT Apps SDK (MCP) setup
|
|
42
|
+
|
|
43
|
+
The worker exposes an MCP server at `/mcp` for use as a ChatGPT connector.
|
|
44
|
+
|
|
45
|
+
1. Update `donghanh.config.ts` with your deployed HTTPS URL and Better Auth issuer.
|
|
46
|
+
2. Build widgets:
|
|
47
|
+
```bash
|
|
48
|
+
bun run widgets
|
|
49
|
+
```
|
|
50
|
+
This regenerates `manifest/manifest.js` — the worker imports it at build time. A placeholder ships so the worker compiles before the first build.
|
|
51
|
+
3. Deploy:
|
|
52
|
+
```bash
|
|
53
|
+
npx wrangler deploy
|
|
54
|
+
```
|
|
55
|
+
4. In ChatGPT: **Settings → Apps & Connectors → Advanced settings** → enable **Developer Mode**.
|
|
56
|
+
5. **Settings → Connectors → Create** → paste `https://your-worker.dev/mcp`.
|
|
57
|
+
6. Open a chat, click **+** → **More** → select the connector.
|
|
58
|
+
|
|
59
|
+
The `widgets/task-card.tsx` entry renders the default `DongHanhWidget` — customize it by editing that file and re-running `bun run widgets`.
|
|
60
|
+
|
|
41
61
|
## Deploy
|
|
42
62
|
|
|
43
63
|
```bash
|
|
64
|
+
bun run widgets # build widget manifest first
|
|
44
65
|
npx wrangler deploy
|
|
45
66
|
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from "@donghanh/config";
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
operations: "./operations/**/*.tsx",
|
|
5
|
+
widgets: {
|
|
6
|
+
"task-card": "./widgets/task-card.tsx",
|
|
7
|
+
},
|
|
8
|
+
server: {
|
|
9
|
+
// Replace with your deployed HTTPS URL for the MCP server.
|
|
10
|
+
resource: "https://example.com",
|
|
11
|
+
// Replace with your OAuth authorization server (Better Auth by default).
|
|
12
|
+
authorizationServers: ["https://example.com"],
|
|
13
|
+
scopes: [],
|
|
14
|
+
widgetDomain: "https://example.com",
|
|
15
|
+
csp: {
|
|
16
|
+
connectDomains: [],
|
|
17
|
+
resourceDomains: ["https://persistent.oaistatic.com"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
@@ -3,6 +3,7 @@ import * as queries from "./db/queries";
|
|
|
3
3
|
|
|
4
4
|
export const executor: Executor = async (operationId, variables, context) => {
|
|
5
5
|
const v = variables as Record<string, string>;
|
|
6
|
+
if (!context.userId) throw new Error("Unauthenticated");
|
|
6
7
|
const userId = context.userId;
|
|
7
8
|
|
|
8
9
|
switch (operationId) {
|
|
@@ -7,20 +7,29 @@
|
|
|
7
7
|
"dev": "wrangler dev",
|
|
8
8
|
"deploy": "wrangler deploy",
|
|
9
9
|
"db:init": "wrangler d1 execute my-kanban-db --local --file=schema.sql",
|
|
10
|
-
"db:generate": "drizzle-kit generate"
|
|
10
|
+
"db:generate": "drizzle-kit generate",
|
|
11
|
+
"widgets": "vite build"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
|
-
"@donghanh/core": "^0.
|
|
14
|
-
"@donghanh/hono": "^0.
|
|
14
|
+
"@donghanh/core": "^0.2.0",
|
|
15
|
+
"@donghanh/hono": "^0.2.0",
|
|
16
|
+
"@donghanh/config": "^0.1.0",
|
|
17
|
+
"@donghanh/widget": "^0.1.0",
|
|
15
18
|
"better-auth": "^1.4.0",
|
|
16
19
|
"drizzle-orm": "^0.45.0",
|
|
17
|
-
"hono": "^4.7.0"
|
|
20
|
+
"hono": "^4.7.0",
|
|
21
|
+
"react": "^19.0.0",
|
|
22
|
+
"react-dom": "^19.0.0"
|
|
18
23
|
},
|
|
19
24
|
"devDependencies": {
|
|
20
25
|
"@cloudflare/workers-types": "^4.0.0",
|
|
26
|
+
"@donghanh/widget-vite": "^0.1.0",
|
|
21
27
|
"@types/node": "^22.0.0",
|
|
28
|
+
"@types/react": "^19.0.0",
|
|
29
|
+
"@types/react-dom": "^19.0.0",
|
|
22
30
|
"better-sqlite3": "^11.0.0",
|
|
23
31
|
"drizzle-kit": "^0.31.0",
|
|
32
|
+
"vite": "^7.0.0",
|
|
24
33
|
"wrangler": "^4.0.0",
|
|
25
34
|
"typescript": "^5.8.0"
|
|
26
35
|
}
|
|
@@ -11,6 +11,6 @@
|
|
|
11
11
|
"jsx": "react-jsx",
|
|
12
12
|
"jsxImportSource": "@donghanh/core"
|
|
13
13
|
},
|
|
14
|
-
"include": ["**/*.ts", "
|
|
15
|
-
"exclude": ["node_modules"]
|
|
14
|
+
"include": ["**/*.ts", "operations/**/*.tsx"],
|
|
15
|
+
"exclude": ["node_modules", "widgets", "dist", "manifest", "vite.config.ts"]
|
|
16
16
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { donghanhWidgets } from "@donghanh/widget-vite";
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
|
+
import config from "./donghanh.config";
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
build: {
|
|
7
|
+
outDir: "manifest",
|
|
8
|
+
emptyOutDir: false,
|
|
9
|
+
},
|
|
10
|
+
plugins: [
|
|
11
|
+
donghanhWidgets({
|
|
12
|
+
entries: config.widgets ?? {},
|
|
13
|
+
outDir: "manifest",
|
|
14
|
+
domain: config.server?.widgetDomain,
|
|
15
|
+
csp: config.server?.csp,
|
|
16
|
+
}),
|
|
17
|
+
],
|
|
18
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"types": ["@donghanh/widget"],
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"module": "esnext",
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"jsx": "react-jsx"
|
|
12
|
+
},
|
|
13
|
+
"include": ["**/*.ts", "**/*.tsx"]
|
|
14
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { App, buildRegistry } from "@donghanh/core";
|
|
2
|
-
import { gptRoutes } from "@donghanh/hono";
|
|
2
|
+
import { type Authenticate, gptRoutes, mcpRoutes } from "@donghanh/hono";
|
|
3
3
|
import { Hono } from "hono";
|
|
4
4
|
import { auth } from "./auth";
|
|
5
|
+
import dhConfig from "./donghanh.config";
|
|
5
6
|
import { type Env, setEnv } from "./env";
|
|
6
7
|
import { executor } from "./executor";
|
|
7
8
|
import { oauthAuthorize } from "./oauth/authorize";
|
|
@@ -9,9 +10,31 @@ import { oauthCode } from "./oauth/code";
|
|
|
9
10
|
import { oauthToken } from "./oauth/token";
|
|
10
11
|
import { operations } from "./operations";
|
|
11
12
|
|
|
13
|
+
// Widget manifest is regenerated by `bun run widgets` (vite build).
|
|
14
|
+
// A placeholder with `{}` ships so this import always resolves.
|
|
15
|
+
import { widgets } from "./manifest/manifest.js";
|
|
16
|
+
|
|
12
17
|
const appNode = App({ operations });
|
|
13
18
|
const registry = buildRegistry(appNode);
|
|
14
19
|
|
|
20
|
+
const authenticate: Authenticate = async (request) => {
|
|
21
|
+
const authHeader = request.headers.get("Authorization");
|
|
22
|
+
if (!authHeader?.startsWith("Bearer ")) {
|
|
23
|
+
return {
|
|
24
|
+
error: Response.json({ error: "Unauthorized" }, { status: 401 }),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const token = authHeader.slice(7);
|
|
28
|
+
const ctx = await auth.$context;
|
|
29
|
+
const result = await ctx.internalAdapter.findSession(token).catch(() => null);
|
|
30
|
+
if (!result) {
|
|
31
|
+
return {
|
|
32
|
+
error: Response.json({ error: "Session expired" }, { status: 401 }),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
return { userId: result.user.id };
|
|
36
|
+
};
|
|
37
|
+
|
|
15
38
|
const app = new Hono<{ Bindings: Env }>();
|
|
16
39
|
|
|
17
40
|
// Inject env bindings on each request
|
|
@@ -21,28 +44,19 @@ app.use("/*", async (c, next) => {
|
|
|
21
44
|
});
|
|
22
45
|
|
|
23
46
|
// GPT Store operations
|
|
47
|
+
app.route("/api", gptRoutes({ registry, executor, authenticate }));
|
|
48
|
+
|
|
49
|
+
// ChatGPT Apps SDK (MCP)
|
|
24
50
|
app.route(
|
|
25
|
-
"/
|
|
26
|
-
|
|
51
|
+
"/",
|
|
52
|
+
mcpRoutes({
|
|
27
53
|
registry,
|
|
28
54
|
executor,
|
|
29
|
-
authenticate
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
const token = authHeader.slice(7);
|
|
37
|
-
const ctx = await auth.$context;
|
|
38
|
-
const result = await ctx.internalAdapter.findSession(token);
|
|
39
|
-
if (!result) {
|
|
40
|
-
return {
|
|
41
|
-
error: Response.json({ error: "Session expired" }, { status: 401 }),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
return { userId: result.user.id };
|
|
45
|
-
},
|
|
55
|
+
authenticate,
|
|
56
|
+
resource: dhConfig.server?.resource ?? "https://example.com",
|
|
57
|
+
authorizationServers: dhConfig.server?.authorizationServers ?? [],
|
|
58
|
+
scopes: dhConfig.server?.scopes,
|
|
59
|
+
widgets,
|
|
46
60
|
}),
|
|
47
61
|
);
|
|
48
62
|
|
|
@@ -55,7 +69,7 @@ app.post("/oauth/code", (c) => oauthCode(c));
|
|
|
55
69
|
app.post("/oauth/token", (c) => oauthToken(c));
|
|
56
70
|
|
|
57
71
|
app.get("/", (c) =>
|
|
58
|
-
c.text("Kanban
|
|
72
|
+
c.text("Kanban running. Try GET /api/operations or POST /mcp"),
|
|
59
73
|
);
|
|
60
74
|
|
|
61
75
|
export default app;
|