gencow 0.1.131 → 0.1.132

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.
Files changed (48) hide show
  1. package/bin/gencow-mcp.mjs +94 -83
  2. package/bin/gencow.mjs +5791 -4866
  3. package/core/index.js +540 -31
  4. package/dashboard/assets/index-CYN7QmGd.css +1 -0
  5. package/dashboard/assets/{index-C1WhUSu8.js → index-D2uOdJCM.js} +77 -72
  6. package/dashboard/index.html +10 -4
  7. package/lib/__tests__/api-codegen.test.mjs +87 -0
  8. package/lib/__tests__/deploy-auditor.test.ts +276 -169
  9. package/lib/__tests__/env-parser.test.ts +113 -117
  10. package/lib/__tests__/project-validator.test.ts +104 -112
  11. package/lib/__tests__/readme-codegen.test.ts +393 -385
  12. package/lib/api-codegen.mjs +91 -0
  13. package/lib/deploy-auditor.mjs +340 -150
  14. package/lib/env-parser.mjs +32 -33
  15. package/lib/project-validator.mjs +44 -58
  16. package/lib/readme-codegen.mjs +548 -536
  17. package/package.json +31 -31
  18. package/scripts/bundle-server.mjs +111 -78
  19. package/scripts/pre-publish-check.mjs +80 -80
  20. package/server/index.js +2345 -498
  21. package/server/index.js.map +4 -4
  22. package/templates/SECURITY.md +32 -0
  23. package/templates/admin-tool/items.ts +1 -1
  24. package/templates/admin-tool/schema.ts +7 -11
  25. package/templates/agent.ts +100 -0
  26. package/templates/ai-chat/ai.ts +416 -402
  27. package/templates/ai-chat/chat.ts +107 -113
  28. package/templates/ai-chat/schema.ts +14 -14
  29. package/templates/ai.ts +416 -402
  30. package/templates/auth-schema.ts +38 -34
  31. package/templates/auth.ts +15 -15
  32. package/templates/fullstack/ai.ts +416 -402
  33. package/templates/fullstack/files.ts +20 -20
  34. package/templates/fullstack/schema.ts +16 -14
  35. package/templates/fullstack/tasks.ts +76 -78
  36. package/templates/guardrails.ts +110 -110
  37. package/templates/memory.ts +162 -165
  38. package/templates/parsers.ts +85 -87
  39. package/templates/prompts.ts +20 -20
  40. package/templates/rag.ts +267 -272
  41. package/templates/reranker.ts +68 -66
  42. package/templates/schema-memory.ts +13 -12
  43. package/templates/schema-rag.ts +13 -20
  44. package/templates/task-app/files.ts +20 -20
  45. package/templates/task-app/schema.ts +16 -14
  46. package/templates/task-app/tasks.ts +76 -78
  47. package/templates/tools.ts +18 -15
  48. package/dashboard/assets/index-DoG4z4Kv.css +0 -1
@@ -22,10 +22,10 @@
22
22
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
23
23
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
24
24
  import {
25
- ListToolsRequestSchema,
26
- CallToolRequestSchema,
27
- ListResourcesRequestSchema,
28
- ReadResourceRequestSchema,
25
+ ListToolsRequestSchema,
26
+ CallToolRequestSchema,
27
+ ListResourcesRequestSchema,
28
+ ReadResourceRequestSchema,
29
29
  } from "@modelcontextprotocol/sdk/types.js";
30
30
 
31
31
  const BASE_URL = `http://localhost:${process.env.GENCOW_PORT || 5456}`;
@@ -33,119 +33,130 @@ const BASE_URL = `http://localhost:${process.env.GENCOW_PORT || 5456}`;
33
33
  // ─── Helpers ────────────────────────────────────────────
34
34
 
35
35
  async function fetchJSON(path) {
36
- const res = await fetch(`${BASE_URL}${path}`);
37
- if (!res.ok) throw new Error(`Gencow API error: ${res.status} ${await res.text()}`);
38
- return res.json();
36
+ const res = await fetch(`${BASE_URL}${path}`);
37
+ if (!res.ok) throw new Error(`Gencow API error: ${res.status} ${await res.text()}`);
38
+ return res.json();
39
39
  }
40
40
 
41
41
  async function postJSON(path, body) {
42
- const res = await fetch(`${BASE_URL}${path}`, {
43
- method: "POST",
44
- headers: { "Content-Type": "application/json" },
45
- body: JSON.stringify(body),
46
- });
47
- const data = await res.json();
48
- return { status: res.status, data };
42
+ const res = await fetch(`${BASE_URL}${path}`, {
43
+ method: "POST",
44
+ headers: { "Content-Type": "application/json" },
45
+ body: JSON.stringify(body),
46
+ });
47
+ const data = await res.json();
48
+ return { status: res.status, data };
49
49
  }
50
50
 
51
51
  // ─── MCP Server ─────────────────────────────────────────
52
52
 
53
53
  const server = new Server(
54
- { name: "gencow", version: "0.1.0" },
55
- {
56
- capabilities: {
57
- tools: {},
58
- resources: {},
59
- },
60
- }
54
+ { name: "gencow", version: "0.1.0" },
55
+ {
56
+ capabilities: {
57
+ tools: {},
58
+ resources: {},
59
+ },
60
+ },
61
61
  );
62
62
 
63
63
  // ── Tools ───────────────────────────────────────────────
64
64
 
65
65
  const TOOLS = [
66
- {
67
- name: "list_apis",
68
- description: "등록된 전체 API 목록을 조회합니다. 각 API의 이름과 타입(query/mutation)을 반환합니다.",
69
- inputSchema: { type: "object", properties: {} },
70
- },
71
- {
72
- name: "call_query",
73
- description: "Gencow query를 호출합니다. 예: name='tasks.list', args={}. RPC 방식: POST /api/query",
74
- inputSchema: {
75
- type: "object",
76
- required: ["name"],
77
- properties: {
78
- name: { type: "string", description: "Query name (dot notation), e.g. 'tasks.list', 'tasks.get', 'files.list'" },
79
- args: { type: "object", description: "Query arguments as JSON object", additionalProperties: true },
80
- },
66
+ {
67
+ name: "list_apis",
68
+ description: "등록된 전체 API 목록을 조회합니다. 각 API의 이름과 타입(query/mutation)을 반환합니다.",
69
+ inputSchema: { type: "object", properties: {} },
70
+ },
71
+ {
72
+ name: "call_query",
73
+ description: "Gencow query를 호출합니다. 예: name='tasks.list', args={}. RPC 방식: POST /api/query",
74
+ inputSchema: {
75
+ type: "object",
76
+ required: ["name"],
77
+ properties: {
78
+ name: {
79
+ type: "string",
80
+ description: "Query name (dot notation), e.g. 'tasks.list', 'tasks.get', 'files.list'",
81
81
  },
82
+ args: { type: "object", description: "Query arguments as JSON object", additionalProperties: true },
83
+ },
82
84
  },
83
- {
84
- name: "call_mutation",
85
- description: "Gencow mutation을 호출합니다. 예: name='tasks.create', args={ title: '새 태스크' }. RPC 방식: POST /api/mutation",
86
- inputSchema: {
87
- type: "object",
88
- required: ["name"],
89
- properties: {
90
- name: { type: "string", description: "Mutation name (dot notation), e.g. 'tasks.create', 'tasks.update', 'tasks.delete'" },
91
- args: { type: "object", description: "Mutation arguments as JSON object", additionalProperties: true },
92
- },
85
+ },
86
+ {
87
+ name: "call_mutation",
88
+ description:
89
+ "Gencow mutation을 호출합니다. 예: name='tasks.create', args={ title: '새 태스크' }. RPC 방식: POST /api/mutation",
90
+ inputSchema: {
91
+ type: "object",
92
+ required: ["name"],
93
+ properties: {
94
+ name: {
95
+ type: "string",
96
+ description: "Mutation name (dot notation), e.g. 'tasks.create', 'tasks.update', 'tasks.delete'",
93
97
  },
98
+ args: {
99
+ type: "object",
100
+ description: "Mutation arguments as JSON object",
101
+ additionalProperties: true,
102
+ },
103
+ },
94
104
  },
105
+ },
95
106
  ];
96
107
 
97
108
  server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
98
109
 
99
110
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
100
- const { name: toolName, arguments: toolArgs } = request.params;
101
-
102
- try {
103
- switch (toolName) {
104
- case "list_apis": {
105
- // Use the health endpoint which returns queries list
106
- const info = await fetchJSON("/");
107
- return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
108
- }
109
- case "call_query": {
110
- const result = await postJSON("/api/query", { name: toolArgs.name, args: toolArgs.args || {} });
111
- return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
112
- }
113
- case "call_mutation": {
114
- const result = await postJSON("/api/mutation", { name: toolArgs.name, args: toolArgs.args || {} });
115
- return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
116
- }
117
- default:
118
- return { content: [{ type: "text", text: `Unknown tool: ${toolName}` }], isError: true };
119
- }
120
- } catch (err) {
121
- return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
111
+ const { name: toolName, arguments: toolArgs } = request.params;
112
+
113
+ try {
114
+ switch (toolName) {
115
+ case "list_apis": {
116
+ // Use the health endpoint which returns queries list
117
+ const info = await fetchJSON("/");
118
+ return { content: [{ type: "text", text: JSON.stringify(info, null, 2) }] };
119
+ }
120
+ case "call_query": {
121
+ const result = await postJSON("/api/query", { name: toolArgs.name, args: toolArgs.args || {} });
122
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
123
+ }
124
+ case "call_mutation": {
125
+ const result = await postJSON("/api/mutation", { name: toolArgs.name, args: toolArgs.args || {} });
126
+ return { content: [{ type: "text", text: JSON.stringify(result.data, null, 2) }] };
127
+ }
128
+ default:
129
+ return { content: [{ type: "text", text: `Unknown tool: ${toolName}` }], isError: true };
122
130
  }
131
+ } catch (err) {
132
+ return { content: [{ type: "text", text: `Error: ${err.message}` }], isError: true };
133
+ }
123
134
  });
124
135
 
125
136
  // ── Resources ───────────────────────────────────────────
126
137
 
127
138
  const RESOURCES = [
128
- {
129
- uri: "gencow://api-list",
130
- name: "api-list",
131
- description: "List of all registered API queries and server information",
132
- mimeType: "application/json",
133
- },
139
+ {
140
+ uri: "gencow://api-list",
141
+ name: "api-list",
142
+ description: "List of all registered API queries and server information",
143
+ mimeType: "application/json",
144
+ },
134
145
  ];
135
146
 
136
147
  server.setRequestHandler(ListResourcesRequestSchema, async () => ({ resources: RESOURCES }));
137
148
 
138
149
  server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
139
- const { uri } = request.params;
140
-
141
- switch (uri) {
142
- case "gencow://api-list": {
143
- const info = await fetchJSON("/");
144
- return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify(info, null, 2) }] };
145
- }
146
- default:
147
- throw new Error(`Unknown resource: ${uri}`);
150
+ const { uri } = request.params;
151
+
152
+ switch (uri) {
153
+ case "gencow://api-list": {
154
+ const info = await fetchJSON("/");
155
+ return { contents: [{ uri, mimeType: "application/json", text: JSON.stringify(info, null, 2) }] };
148
156
  }
157
+ default:
158
+ throw new Error(`Unknown resource: ${uri}`);
159
+ }
149
160
  });
150
161
 
151
162
  // ── Start ───────────────────────────────────────────────