create-donghanh 0.5.0 → 0.6.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Rezza Hub
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -6,8 +6,8 @@ import path from "node:path";
6
6
  import readline from "node:readline";
7
7
  var TEMPLATES = ["minimal", "kanban-gpt"];
8
8
  var DESCRIPTIONS = {
9
- minimal: "Hello world with D1 SQLite — 2 operations",
10
- "kanban-gpt": "Kanban board with Better Auth + Drizzle + GPT Store OAuth — 6 operations"
9
+ minimal: "Hello world with D1 SQLite \u2014 2 operations",
10
+ "kanban-gpt": "Kanban board with Better Auth + Drizzle + GPT Store OAuth (deprecated) \u2014 6 operations"
11
11
  };
12
12
  async function prompt(question) {
13
13
  const rl = readline.createInterface({
@@ -47,11 +47,11 @@ async function main() {
47
47
  if (flagIdx !== -1 && args[flagIdx + 1]) {
48
48
  template = args[flagIdx + 1];
49
49
  if (!target || target.startsWith("-")) {
50
- target = undefined;
50
+ target = void 0;
51
51
  }
52
52
  }
53
53
  console.log();
54
- console.log(" \x1B[1m@donghanh\x1B[0m — Conversational UI Framework");
54
+ console.log(" \x1B[1m@donghanh\x1B[0m \u2014 Conversational UI Framework");
55
55
  console.log();
56
56
  if (!target || target.startsWith("-")) {
57
57
  target = await prompt(" Project name: ");
@@ -63,8 +63,10 @@ async function main() {
63
63
  if (!template || !TEMPLATES.includes(template)) {
64
64
  console.log();
65
65
  console.log(" Templates:");
66
- for (let i = 0;i < TEMPLATES.length; i++) {
67
- console.log(` \x1B[1m${i + 1}\x1B[0m) ${TEMPLATES[i]} — ${DESCRIPTIONS[TEMPLATES[i]]}`);
66
+ for (let i = 0; i < TEMPLATES.length; i++) {
67
+ console.log(
68
+ ` \x1B[1m${i + 1}\x1B[0m) ${TEMPLATES[i]} \u2014 ${DESCRIPTIONS[TEMPLATES[i]]}`
69
+ );
68
70
  }
69
71
  console.log();
70
72
  const choice = await prompt(" Select template (1-2): ");
@@ -73,10 +75,16 @@ async function main() {
73
75
  }
74
76
  const destDir = path.resolve(target);
75
77
  if (fs.existsSync(destDir)) {
76
- console.log(` \x1B[31mError:\x1B[0m Directory "${target}" already exists.`);
78
+ console.log(
79
+ ` \x1B[31mError:\x1B[0m Directory "${target}" already exists.`
80
+ );
77
81
  process.exit(1);
78
82
  }
79
- const templatesDir = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "templates");
83
+ const templatesDir = path.join(
84
+ path.dirname(new URL(import.meta.url).pathname),
85
+ "..",
86
+ "templates"
87
+ );
80
88
  const srcDir = path.join(templatesDir, template);
81
89
  if (!fs.existsSync(srcDir)) {
82
90
  console.log(` \x1B[31mError:\x1B[0m Template "${template}" not found.`);
@@ -90,7 +98,9 @@ async function main() {
90
98
  ["my-kanban-db", `${appName}-db`]
91
99
  ]);
92
100
  console.log();
93
- console.log(` \x1B[32m✓\x1B[0m Created \x1B[1m${appName}\x1B[0m from \x1B[1m${template}\x1B[0m template`);
101
+ console.log(
102
+ ` \x1B[32m\u2713\x1B[0m Created \x1B[1m${appName}\x1B[0m from \x1B[1m${template}\x1B[0m template`
103
+ );
94
104
  console.log();
95
105
  console.log(" Next steps:");
96
106
  console.log(` cd ${target}`);
package/package.json CHANGED
@@ -1,15 +1,12 @@
1
1
  {
2
2
  "name": "create-donghanh",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Scaffold a donghanh project — conversational UI with JSX",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "create-donghanh": "dist/index.js"
9
9
  },
10
- "scripts": {
11
- "build": "bun build src/index.ts --outdir dist --target node"
12
- },
13
10
  "files": [
14
11
  "dist",
15
12
  "templates"
@@ -18,5 +15,11 @@
18
15
  "type": "git",
19
16
  "url": "https://github.com/rezzahub/donghanh",
20
17
  "directory": "create-donghanh"
18
+ },
19
+ "devDependencies": {
20
+ "esbuild": "^0.28.2"
21
+ },
22
+ "scripts": {
23
+ "build": "esbuild src/index.ts --bundle --platform=node --format=esm --outdir=dist"
21
24
  }
22
- }
25
+ }
@@ -1,6 +1,6 @@
1
1
  # Kanban GPT
2
2
 
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.
3
+ A kanban board powered by [@donghanh](https://github.com/rezzahub/donghanh). Ships with three adapters sharing the same operations: ChatGPT Apps SDK (MCP), self-hosted chat, and GPT Store (GPT Actions, deprecated).
4
4
 
5
5
  ## Setup
6
6
 
@@ -26,6 +26,8 @@ bun run dev
26
26
 
27
27
  ## GPT Store setup
28
28
 
29
+ > **Deprecated:** GPT Store support is deprecated. Use Apps SDK (`mcpRoutes`) for new projects. `gptRoutes` keeps working.
30
+
29
31
  1. Create a GPT Action in the [ChatGPT GPT Store editor](https://chatgpt.com/gpts/editor)
30
32
  2. Set the API server URL to your deployed worker URL
31
33
  3. Configure OAuth:
@@ -7,7 +7,7 @@ interface Data { board: { id: string; name: string }; members: { id: string; nam
7
7
  function AddMember({ data }: OperationProps<Data>) {
8
8
  return (
9
9
  <Brief>
10
- Member added to {data.board.name}. Now {data.members.length} member(s).
10
+ {`Member added to ${data.board.name}. Now ${data.members.length} member(s).`}
11
11
  <Display data={data.members.map(m => m.name)} />
12
12
  <Action operation="add-member" label="Add another member" variables={{ boardId: data.board.id }} />
13
13
  <Action operation="board-detail" label="View board" variables={{ boardId: data.board.id }} />
@@ -10,7 +10,7 @@ function BoardDetail({ data }: OperationProps<Data>) {
10
10
  const { board, columns, members } = data;
11
11
  return (
12
12
  <Brief>
13
- Board: {board.name} ({members.length} members)
13
+ {`Board: ${board.name} (${members.length} members)`}
14
14
  <Display data={columns.map(col => ({
15
15
  column: col.name,
16
16
  cards: col.cards.map(c => c.title),
@@ -16,7 +16,7 @@ function ListBoards({ data }: OperationProps<Data>) {
16
16
  }
17
17
  return (
18
18
  <Brief>
19
- You have {data.boards.length} board(s).
19
+ {`You have ${data.boards.length} board(s).`}
20
20
  <Display data={data.boards.map(b => `${b.name} (${b.card_count} cards, ${b.member_count} members)`)} />
21
21
  {data.boards.map(b => (
22
22
  <Action operation="board-detail" label={`View ${b.name}`} variables={{ boardId: b.id }} />
@@ -31,7 +31,7 @@ export default registerOperation(ListBoards, {
31
31
  type: "query",
32
32
  description: "List all boards",
33
33
  instruction: "Call this first to see available boards.",
34
- input: {},
34
+ input: { type: "object", properties: {} },
35
35
  responseKey: "listBoards",
36
36
  widget: "task-card",
37
37
  });
@@ -11,9 +11,9 @@
11
11
  "widgets": "vite build"
12
12
  },
13
13
  "dependencies": {
14
- "@donghanh/core": "^0.3.0",
15
- "@donghanh/hono": "^0.3.0",
16
- "@donghanh/config": "^0.1.0",
14
+ "@donghanh/core": "^0.5.0",
15
+ "@donghanh/hono": "^0.5.0",
16
+ "@donghanh/config": "^0.5.0",
17
17
  "@donghanh/widget": "^0.1.0",
18
18
  "better-auth": "^1.4.0",
19
19
  "drizzle-orm": "^0.45.0",
@@ -43,7 +43,7 @@ app.use("/*", async (c, next) => {
43
43
  await next();
44
44
  });
45
45
 
46
- // GPT Store operations
46
+ // GPT Store operations (deprecated, use mcpRoutes below)
47
47
  app.route("/api", gptRoutes({ registry, executor, authenticate }));
48
48
 
49
49
  // ChatGPT Apps SDK (MCP)
@@ -13,8 +13,10 @@ bun run dev
13
13
  ## Try it
14
14
 
15
15
  ```bash
16
- curl localhost:8787/api/operations
17
- curl localhost:8787/api/query/list-items
16
+ curl -X POST localhost:8787/mcp -H 'Content-Type: application/json' \
17
+ -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
18
+ curl -X POST localhost:8787/mcp -H 'Content-Type: application/json' \
19
+ -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list-items","arguments":{}}}'
18
20
  ```
19
21
 
20
22
  ## Deploy
@@ -24,3 +26,5 @@ npx wrangler d1 create my-donghanh-app-db
24
26
  # Copy the database_id into wrangler.toml
25
27
  npx wrangler deploy
26
28
  ```
29
+
30
+ Then set `resource` in `worker.ts` to your deployed URL and deploy again. MCP clients check it against the URL they connect to.
@@ -9,7 +9,7 @@ interface Data {
9
9
  function AddItem({ data }: OperationProps<Data>) {
10
10
  return (
11
11
  <Brief>
12
- Item added! You now have {data.items.length} item(s).
12
+ {`Item added! You now have ${data.items.length} item(s).`}
13
13
  <Display data={data.items} />
14
14
  <Action operation="add-item" label="Add another" />
15
15
  <Action operation="list-items" label="View all" />
@@ -30,4 +30,6 @@ export default registerOperation(AddItem, {
30
30
  },
31
31
  },
32
32
  responseKey: "addItem",
33
+ // This template has no sign-in. Remove this once you add real auth.
34
+ auth: "none",
33
35
  });
@@ -22,11 +22,10 @@ export default registerOperation(ListItems, {
22
22
  type: "query",
23
23
  description: "List all items",
24
24
  instruction: "Call this to see all items.",
25
- input: {},
25
+ input: { type: "object", properties: {} },
26
26
  responseKey: "listItems",
27
- // auth: "none" marks this op as callable anonymously. Your /public/query/list-items
28
- // route will serve it without a Bearer token — handy for ChatGPT Actions whose
29
- // OpenAPI security is per-path. Trade-off: the op cannot read a user-specific
27
+ // auth: "none" marks this op as callable anonymously: mcpRoutes serves it
28
+ // without a Bearer token. Trade-off: the op cannot read a user-specific
30
29
  // context. Switch to "optional" if you want both (anon by default, richer when linked).
31
30
  auth: "none",
32
31
  });
@@ -10,8 +10,8 @@
10
10
  "test": "bun test"
11
11
  },
12
12
  "dependencies": {
13
- "@donghanh/core": "^0.3.0",
14
- "@donghanh/hono": "^0.3.0",
13
+ "@donghanh/core": "^0.5.0",
14
+ "@donghanh/hono": "^0.5.0",
15
15
  "hono": "^4.7.0"
16
16
  },
17
17
  "devDependencies": {
@@ -0,0 +1,62 @@
1
+ import { expect, test } from "bun:test";
2
+ import app from "./worker";
3
+
4
+ type Tool = {
5
+ name: string;
6
+ securitySchemes: { type: string }[];
7
+ };
8
+
9
+ async function listTools() {
10
+ const res = await app.request(
11
+ "/mcp",
12
+ {
13
+ method: "POST",
14
+ headers: { "Content-Type": "application/json" },
15
+ body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/list" }),
16
+ },
17
+ { DB: {} },
18
+ );
19
+ expect(res.status).toBe(200);
20
+ const { result } = (await res.json()) as { result: { tools: Tool[] } };
21
+ return result.tools;
22
+ }
23
+
24
+ test("lists operations as MCP tools", async () => {
25
+ const names = (await listTools()).map((t) => t.name);
26
+ expect(names).toContain("list-items");
27
+ expect(names).toContain("add-item");
28
+ });
29
+
30
+ test("add-item runs and reports the new count", async () => {
31
+ const items = [{ id: 1, name: "Pack bags", created_at: "2026-10-31" }];
32
+ const statement = {
33
+ bind: () => statement,
34
+ run: async () => ({ success: true, meta: {} }),
35
+ all: async () => ({ results: items }),
36
+ };
37
+ const res = await app.request(
38
+ "/mcp",
39
+ {
40
+ method: "POST",
41
+ headers: { "Content-Type": "application/json" },
42
+ body: JSON.stringify({
43
+ jsonrpc: "2.0",
44
+ id: 1,
45
+ method: "tools/call",
46
+ params: { name: "add-item", arguments: { name: "Pack bags" } },
47
+ }),
48
+ },
49
+ { DB: { prepare: () => statement } },
50
+ );
51
+ const { result } = (await res.json()) as {
52
+ result: { isError?: boolean; content: { text: string }[] };
53
+ };
54
+ expect(result.isError).toBeFalsy();
55
+ expect(result.content[0].text).toContain("You now have 1 item(s).");
56
+ });
57
+
58
+ test("no tool asks for OAuth, since the template has no sign-in", async () => {
59
+ for (const tool of await listTools()) {
60
+ expect(tool.securitySchemes).toEqual([{ type: "noauth" }]);
61
+ }
62
+ });
@@ -1,5 +1,5 @@
1
1
  import { App, buildRegistry } from "@donghanh/core";
2
- import { gptRoutes } from "@donghanh/hono";
2
+ import { mcpRoutes } from "@donghanh/hono";
3
3
  import { Hono } from "hono";
4
4
  import { createExecutor } from "./executor";
5
5
  import { operations } from "./operations";
@@ -20,14 +20,17 @@ app.use("/*", async (c, next) => {
20
20
  });
21
21
 
22
22
  app.route(
23
- "/api",
24
- gptRoutes({
23
+ "/",
24
+ mcpRoutes({
25
25
  registry,
26
26
  executor: (opId, vars, ctx) => createExecutor(_db)(opId, vars, ctx),
27
27
  authenticate: async () => ({ userId: "anonymous" }),
28
+ // Replace with your deployed URL
29
+ resource: "https://example.com",
30
+ authorizationServers: [],
28
31
  }),
29
32
  );
30
33
 
31
- app.get("/", (c) => c.text("donghanh app running. Try GET /api/operations"));
34
+ app.get("/", (c) => c.text("donghanh app running. MCP endpoint: POST /mcp"));
32
35
 
33
36
  export default app;