@kya-os/create-mcpi-app 1.7.38-canary.2 → 1.7.38

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 (67) hide show
  1. package/.turbo/turbo-build.log +4 -0
  2. package/.turbo/turbo-test$colon$coverage.log +755 -0
  3. package/.turbo/turbo-test.log +200 -0
  4. package/dist/helpers/fetch-cloudflare-mcpi-template.d.ts.map +1 -1
  5. package/dist/helpers/fetch-cloudflare-mcpi-template.js +35 -914
  6. package/dist/helpers/fetch-cloudflare-mcpi-template.js.map +1 -1
  7. package/dist/utils/fetch-remote-config.d.ts.map +1 -1
  8. package/dist/utils/fetch-remote-config.js +2 -2
  9. package/dist/utils/fetch-remote-config.js.map +1 -1
  10. package/package/package.json +77 -0
  11. package/package.json +1 -1
  12. package/ARCHITECTURE_ANALYSIS.md +0 -392
  13. package/CHANGELOG.md +0 -372
  14. package/DEPRECATION_WARNINGS_ANALYSIS.md +0 -192
  15. package/IMPLEMENTATION_SUMMARY.md +0 -108
  16. package/REMEDIATION_PLAN.md +0 -99
  17. package/dist/.tsbuildinfo +0 -1
  18. package/scripts/prepare-pack.js +0 -47
  19. package/scripts/validate-no-workspace.js +0 -79
  20. package/src/__tests__/cloudflare-template.test.ts +0 -490
  21. package/src/__tests__/helpers/fetch-cloudflare-mcpi-template.test.ts +0 -337
  22. package/src/__tests__/helpers/generate-config.test.ts +0 -312
  23. package/src/__tests__/helpers/generate-identity.test.ts +0 -271
  24. package/src/__tests__/helpers/install.test.ts +0 -370
  25. package/src/__tests__/helpers/validate-project-structure.test.ts +0 -467
  26. package/src/__tests__.bak/regression.test.ts +0 -434
  27. package/src/effects/index.ts +0 -80
  28. package/src/helpers/__tests__/config-builder.spec.ts +0 -231
  29. package/src/helpers/apply-identity-preset.ts +0 -209
  30. package/src/helpers/config-builder.ts +0 -165
  31. package/src/helpers/copy-template.ts +0 -11
  32. package/src/helpers/create.ts +0 -239
  33. package/src/helpers/fetch-cloudflare-mcpi-template.ts +0 -2404
  34. package/src/helpers/fetch-cloudflare-template.ts +0 -361
  35. package/src/helpers/fetch-mcpi-template.ts +0 -236
  36. package/src/helpers/fetch-xmcp-template.ts +0 -153
  37. package/src/helpers/generate-config.ts +0 -118
  38. package/src/helpers/generate-identity.ts +0 -163
  39. package/src/helpers/identity-manager.ts +0 -186
  40. package/src/helpers/install.ts +0 -79
  41. package/src/helpers/rename.ts +0 -17
  42. package/src/helpers/validate-project-structure.ts +0 -127
  43. package/src/index.ts +0 -520
  44. package/src/utils/__tests__/fetch-remote-config.test.ts +0 -271
  45. package/src/utils/check-node.ts +0 -17
  46. package/src/utils/fetch-remote-config.ts +0 -179
  47. package/src/utils/is-folder-empty.ts +0 -60
  48. package/src/utils/validate-project-name.ts +0 -132
  49. package/test-cloudflare/README.md +0 -164
  50. package/test-cloudflare/package.json +0 -28
  51. package/test-cloudflare/src/index.ts +0 -341
  52. package/test-cloudflare/src/tools/greet.ts +0 -19
  53. package/test-cloudflare/tests/cache-invalidation.test.ts +0 -410
  54. package/test-cloudflare/tests/cors-security.test.ts +0 -349
  55. package/test-cloudflare/tests/delegation.test.ts +0 -335
  56. package/test-cloudflare/tests/do-routing.test.ts +0 -314
  57. package/test-cloudflare/tests/integration.test.ts +0 -205
  58. package/test-cloudflare/tests/session-management.test.ts +0 -359
  59. package/test-cloudflare/tsconfig.json +0 -16
  60. package/test-cloudflare/vitest.config.ts +0 -9
  61. package/test-cloudflare/wrangler.toml +0 -37
  62. package/test-node/README.md +0 -44
  63. package/test-node/package.json +0 -23
  64. package/test-node/src/tools/greet.ts +0 -25
  65. package/test-node/xmcp.config.ts +0 -20
  66. package/tsconfig.json +0 -26
  67. package/vitest.config.ts +0 -14
@@ -1,239 +0,0 @@
1
- import path from "path";
2
- import fs from "fs-extra";
3
- import { fileURLToPath } from "url";
4
- import { fetchMCPITemplate } from "./fetch-mcpi-template.js";
5
- import { fetchCloudflareTemplate } from "./fetch-cloudflare-template.js";
6
- import { fetchCloudflareMcpiTemplate } from "./fetch-cloudflare-mcpi-template.js";
7
- import { renameFiles } from "./rename.js";
8
- import { install } from "./install.js";
9
- import {
10
- validateProjectStructure,
11
- ensureLockfile,
12
- } from "./validate-project-structure.js";
13
- import type { ScaffolderResult } from "@kya-os/contracts";
14
- import chalk from "chalk";
15
- import crypto from "crypto";
16
-
17
- const __filename = fileURLToPath(import.meta.url);
18
- const __dirname = path.dirname(__filename);
19
-
20
- // Function to generate claim URL
21
- function generateClaimUrl(did: string, privateKeyBase64: string): string {
22
- try {
23
- const timestamp = Date.now();
24
- const message = `${did}:${timestamp}`;
25
-
26
- const privateKeyBuffer = Buffer.from(privateKeyBase64, "base64");
27
- const privateKeyBytes =
28
- privateKeyBuffer.length === 64
29
- ? privateKeyBuffer.subarray(0, 32)
30
- : privateKeyBuffer;
31
-
32
- const privateKey = crypto.createPrivateKey({
33
- key: Buffer.concat([
34
- Buffer.from("302e020100300506032b657004220420", "hex"),
35
- privateKeyBytes,
36
- ]),
37
- format: "der",
38
- type: "pkcs8",
39
- });
40
-
41
- const signature = crypto.sign(null, Buffer.from(message), privateKey);
42
- const signatureBase64 = signature.toString("base64");
43
-
44
- const params = new URLSearchParams({
45
- did: did,
46
- timestamp: timestamp.toString(),
47
- signature: signatureBase64,
48
- });
49
-
50
- return `https://knowthat.ai/agents/claim?${params.toString()}`;
51
- } catch (error) {
52
- console.error("Error generating claim URL:", error);
53
- return "";
54
- }
55
- }
56
-
57
- interface CreateProjectOptions {
58
- projectPath: string;
59
- projectName: string;
60
- packageManager: string;
61
- transports: string[];
62
- packageVersion: string;
63
- useLocalXmcp?: boolean;
64
- mcpiVersion?: string;
65
- deployToVercel?: boolean;
66
- skipInstall?: boolean;
67
- agentName?: string;
68
- agentDescription?: string;
69
- agentRepository?: string;
70
- skipIdentity?: boolean;
71
- skipAnimation?: boolean;
72
- fastAnimation?: boolean;
73
- spinner?: any; // ora spinner instance
74
- platform?: string; // Platform: 'node' or 'cloudflare'
75
- mode?: string; // Mode: 'mcp-i' or 'verifier'
76
- template?: string; // [DEPRECATED] Template type: 'default' or 'cloudflare'
77
- apikey?: string; // AgentShield API key for Cloudflare deployment
78
- projectId?: string; // AgentShield Project ID for Cloudflare deployment
79
- }
80
-
81
- /**
82
- * Create necessary project directories
83
- */
84
- function createProjectDirectories(projectPath: string): void {
85
- fs.ensureDirSync(path.join(projectPath, ".mcpi"));
86
- }
87
-
88
- /**
89
- * Create a new MCP-I project with identity features
90
- */
91
- export async function createProject(
92
- options: CreateProjectOptions
93
- ): Promise<ScaffolderResult> {
94
- const {
95
- projectPath,
96
- projectName,
97
- packageManager,
98
- transports,
99
- packageVersion,
100
- useLocalXmcp,
101
- mcpiVersion,
102
- deployToVercel,
103
- skipInstall,
104
- agentName = projectName,
105
- agentDescription = "MCP-I server with identity features",
106
- agentRepository = "",
107
- skipIdentity = false,
108
- skipAnimation = false,
109
- fastAnimation = false,
110
- platform = "node",
111
- mode = "mcp-i",
112
- template = "default",
113
- apikey,
114
- projectId,
115
- } = options;
116
-
117
- const warnings: string[] = [];
118
- let resolvedMcpiVersion = mcpiVersion;
119
-
120
- try {
121
- // Ensure the project directory exists
122
- fs.ensureDirSync(projectPath);
123
-
124
- // Scaffold project based on platform/mode
125
- console.log(chalk.blue("\nšŸ“ Scaffolding project..."));
126
-
127
- if (platform === "cloudflare" && mode === "verifier") {
128
- // Cloudflare Worker verifier template (standalone verifier)
129
- await fetchCloudflareTemplate(projectPath, {
130
- packageManager,
131
- });
132
- } else if (platform === "cloudflare" && mode === "mcp-i") {
133
- // Cloudflare Worker MCP-I server template (NEW)
134
- await fetchCloudflareMcpiTemplate(projectPath, {
135
- packageManager,
136
- projectName,
137
- apikey,
138
- projectId,
139
- skipIdentity,
140
- });
141
- } else if (platform === "node" && mode === "mcp-i") {
142
- // Node.js MCP-I server template (default)
143
- await fetchMCPITemplate(projectPath, {
144
- mcpiVersion,
145
- packageManager,
146
- skipIdentity,
147
- });
148
- } else {
149
- throw new Error(`Unsupported platform/mode combination: ${platform}/${mode}`);
150
- }
151
-
152
- // Capture the resolved version for the result
153
- const packageJsonPath = path.join(projectPath, "package.json");
154
- if (fs.existsSync(packageJsonPath)) {
155
- const packageJson = fs.readJsonSync(packageJsonPath);
156
- // Try to extract version from dependencies
157
- resolvedMcpiVersion =
158
- packageJson.dependencies?.["@kya-os/mcp-i"] || mcpiVersion || "unknown";
159
- }
160
-
161
- // Rename special files (e.g., _gitignore to .gitignore)
162
- renameFiles(projectPath);
163
-
164
- // Add vercel.json if deployToVercel is true
165
- if (deployToVercel) {
166
- // Create a basic vercel.json for MCP-I deployment
167
- const vercelConfig = {
168
- functions: {
169
- "src/server.ts": {
170
- runtime: "@vercel/node@3",
171
- },
172
- },
173
- rewrites: [
174
- {
175
- source: "/(.*)",
176
- destination: "/src/server.ts",
177
- },
178
- ],
179
- };
180
-
181
- fs.writeJsonSync(path.join(projectPath, "vercel.json"), vercelConfig, {
182
- spaces: 2,
183
- });
184
- }
185
-
186
- // Create necessary project directories (skip for cloudflare templates)
187
- const isCloudflare = platform === "cloudflare";
188
- if (!isCloudflare) {
189
- createProjectDirectories(projectPath);
190
- }
191
-
192
- // Install project dependencies
193
- if (!skipInstall) {
194
- install(projectPath, packageManager, packageVersion);
195
-
196
- // Ensure lockfile is properly created
197
- ensureLockfile(projectPath, packageManager);
198
- }
199
-
200
- // Validate project structure meets requirements (skip for cloudflare)
201
- if (!isCloudflare) {
202
- const validation = validateProjectStructure(projectPath, !skipIdentity);
203
- if (!validation.valid) {
204
- console.warn(chalk.yellow("āš ļø Project structure validation issues:"));
205
- for (const issue of validation.issues) {
206
- console.warn(chalk.yellow(` - ${issue}`));
207
- warnings.push(...validation.issues);
208
- }
209
- }
210
- }
211
-
212
- // Identity setup is now handled by the CLI after scaffolding (not for cloudflare)
213
- if (!skipIdentity && !isCloudflare) {
214
- console.log(chalk.blue("\nšŸ” Identity setup will be handled by the CLI"));
215
- console.log(
216
- chalk.gray(" Run 'mcpi init' after scaffolding to set up identity")
217
- );
218
- }
219
-
220
- return {
221
- success: true,
222
- projectPath,
223
- xmcpVersion: resolvedMcpiVersion || "unknown",
224
- identityEnabled: !skipIdentity,
225
- warnings: warnings.length > 0 ? warnings : undefined,
226
- };
227
- } catch (error) {
228
- console.error(chalk.red("Failed to create project:"), error);
229
- return {
230
- success: false,
231
- projectPath,
232
- xmcpVersion: resolvedMcpiVersion || "unknown",
233
- identityEnabled: !skipIdentity,
234
- warnings: [
235
- `Project creation failed: ${error instanceof Error ? error.message : String(error)}`,
236
- ],
237
- };
238
- }
239
- }