init-xmcp 0.2.1-canary.2 → 0.2.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > init-xmcp@0.2.1-canary.2 build /home/runner/work/xmcp/xmcp/packages/init-xmcp
2
+ > init-xmcp@0.2.1 build /home/runner/work/xmcp/xmcp/packages/init-xmcp
3
3
  > tsc
4
4
 
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,59 @@
1
+ import { describe, it, beforeEach, afterEach } from "node:test";
2
+ import assert from "node:assert";
3
+ import path from "path";
4
+ import fs from "fs-extra";
5
+ import os from "os";
6
+ import { generateConfig } from "../helpers/generate-config.js";
7
+ describe("generateConfig", () => {
8
+ let tempDir;
9
+ let projectPath;
10
+ beforeEach(() => {
11
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "xmcp-test-"));
12
+ projectPath = tempDir;
13
+ });
14
+ afterEach(() => {
15
+ fs.removeSync(tempDir);
16
+ });
17
+ it("should generate config without paths when both toolsPath and promptsPath are falsy", () => {
18
+ generateConfig(projectPath, "nextjs");
19
+ const configPath = path.join(projectPath, "xmcp.config.ts");
20
+ assert(fs.existsSync(configPath), "Config file should be created");
21
+ const configContent = fs.readFileSync(configPath, "utf-8");
22
+ assert(!configContent.includes("paths:"), "Should not include paths key when both are falsy");
23
+ const pathsMatches = configContent.match(/paths:/g);
24
+ assert(!pathsMatches, "Should not contain any paths key");
25
+ });
26
+ it("should generate config with paths object containing only tools when toolsPath is truthy", () => {
27
+ generateConfig(projectPath, "nextjs", "./tools");
28
+ const configPath = path.join(projectPath, "xmcp.config.ts");
29
+ assert(fs.existsSync(configPath), "Config file should be created");
30
+ const configContent = fs.readFileSync(configPath, "utf-8");
31
+ assert(configContent.includes("paths: {"), "Should include paths object");
32
+ assert(configContent.includes('tools: "./tools"'), "Should include tools path");
33
+ assert(!configContent.includes("prompts:"), "Should not include prompts path");
34
+ const pathsMatches = configContent.match(/paths:/g);
35
+ assert(pathsMatches && pathsMatches.length === 1, "Should contain exactly one paths object");
36
+ });
37
+ it("should generate config with paths object containing only prompts when promptsPath is truthy", () => {
38
+ generateConfig(projectPath, "nextjs", undefined, "./prompts");
39
+ const configPath = path.join(projectPath, "xmcp.config.ts");
40
+ assert(fs.existsSync(configPath), "Config file should be created");
41
+ const configContent = fs.readFileSync(configPath, "utf-8");
42
+ assert(configContent.includes("paths: {"), "Should include paths object");
43
+ assert(configContent.includes('prompts: "./prompts"'), "Should include prompts path");
44
+ assert(!configContent.includes("tools:"), "Should not include tools path");
45
+ const pathsMatches = configContent.match(/paths:/g);
46
+ assert(pathsMatches && pathsMatches.length === 1, "Should contain exactly one paths object");
47
+ });
48
+ it("should generate config with paths object containing both when both are truthy", () => {
49
+ generateConfig(projectPath, "nextjs", "./tools", "./prompts");
50
+ const configPath = path.join(projectPath, "xmcp.config.ts");
51
+ assert(fs.existsSync(configPath), "Config file should be created");
52
+ const configContent = fs.readFileSync(configPath, "utf-8");
53
+ assert(configContent.includes("paths: {"), "Should include paths object");
54
+ assert(configContent.includes('tools: "./tools"'), "Should include tools path");
55
+ assert(configContent.includes('prompts: "./prompts"'), "Should include prompts path");
56
+ const pathsMatches = configContent.match(/paths:/g);
57
+ assert(pathsMatches && pathsMatches.length === 1, "Should contain exactly one paths object");
58
+ });
59
+ });
@@ -14,11 +14,18 @@ const config: XmcpConfig = {
14
14
  experimental: {
15
15
  adapter: "${frameworkAdapter}",
16
16
  },`;
17
- if (toolsPath && promptsPath) {
17
+ if (toolsPath || promptsPath) {
18
+ configContent += `
19
+ paths: {`;
20
+ if (toolsPath) {
21
+ configContent += `
22
+ tools: "${toolsPath}",`;
23
+ }
24
+ if (promptsPath) {
25
+ configContent += `
26
+ prompts: "${promptsPath}",`;
27
+ }
18
28
  configContent += `
19
- paths: {
20
- tools: "${toolsPath}",
21
- prompts: "${promptsPath}",
22
29
  },`;
23
30
  }
24
31
  configContent += `
package/dist/index.js CHANGED
@@ -231,7 +231,7 @@ const program = new Command()
231
231
  console.log(` • ${toolsPath}/greet.ts`);
232
232
  }
233
233
  if (promptsPath) {
234
- console.log(` • ${promptsPath}/greet.ts`);
234
+ console.log(` • ${promptsPath}/review-code.ts`);
235
235
  }
236
236
  if (routePath) {
237
237
  console.log(` • ${routePath}/route.ts`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "init-xmcp",
3
- "version": "0.2.1-canary.2",
3
+ "version": "0.2.1",
4
4
  "author": {
5
5
  "name": "Basement Studio",
6
6
  "email": "hello@basement.studio",
@@ -0,0 +1,105 @@
1
+ import { describe, it, beforeEach, afterEach } from "node:test";
2
+ import assert from "node:assert";
3
+ import path from "path";
4
+ import fs from "fs-extra";
5
+ import os from "os";
6
+ import { generateConfig } from "../helpers/generate-config.js";
7
+
8
+ describe("generateConfig", () => {
9
+ let tempDir: string;
10
+ let projectPath: string;
11
+
12
+ beforeEach(() => {
13
+ tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "xmcp-test-"));
14
+ projectPath = tempDir;
15
+ });
16
+
17
+ afterEach(() => {
18
+ fs.removeSync(tempDir);
19
+ });
20
+
21
+ it("should generate config without paths when both toolsPath and promptsPath are falsy", () => {
22
+ generateConfig(projectPath, "nextjs");
23
+
24
+ const configPath = path.join(projectPath, "xmcp.config.ts");
25
+ assert(fs.existsSync(configPath), "Config file should be created");
26
+
27
+ const configContent = fs.readFileSync(configPath, "utf-8");
28
+ assert(
29
+ !configContent.includes("paths:"),
30
+ "Should not include paths key when both are falsy"
31
+ );
32
+
33
+ const pathsMatches = configContent.match(/paths:/g);
34
+ assert(!pathsMatches, "Should not contain any paths key");
35
+ });
36
+
37
+ it("should generate config with paths object containing only tools when toolsPath is truthy", () => {
38
+ generateConfig(projectPath, "nextjs", "./tools");
39
+
40
+ const configPath = path.join(projectPath, "xmcp.config.ts");
41
+ assert(fs.existsSync(configPath), "Config file should be created");
42
+
43
+ const configContent = fs.readFileSync(configPath, "utf-8");
44
+ assert(configContent.includes("paths: {"), "Should include paths object");
45
+ assert(
46
+ configContent.includes('tools: "./tools"'),
47
+ "Should include tools path"
48
+ );
49
+ assert(
50
+ !configContent.includes("prompts:"),
51
+ "Should not include prompts path"
52
+ );
53
+
54
+ const pathsMatches = configContent.match(/paths:/g);
55
+ assert(
56
+ pathsMatches && pathsMatches.length === 1,
57
+ "Should contain exactly one paths object"
58
+ );
59
+ });
60
+
61
+ it("should generate config with paths object containing only prompts when promptsPath is truthy", () => {
62
+ generateConfig(projectPath, "nextjs", undefined, "./prompts");
63
+
64
+ const configPath = path.join(projectPath, "xmcp.config.ts");
65
+ assert(fs.existsSync(configPath), "Config file should be created");
66
+
67
+ const configContent = fs.readFileSync(configPath, "utf-8");
68
+ assert(configContent.includes("paths: {"), "Should include paths object");
69
+ assert(
70
+ configContent.includes('prompts: "./prompts"'),
71
+ "Should include prompts path"
72
+ );
73
+ assert(!configContent.includes("tools:"), "Should not include tools path");
74
+
75
+ const pathsMatches = configContent.match(/paths:/g);
76
+ assert(
77
+ pathsMatches && pathsMatches.length === 1,
78
+ "Should contain exactly one paths object"
79
+ );
80
+ });
81
+
82
+ it("should generate config with paths object containing both when both are truthy", () => {
83
+ generateConfig(projectPath, "nextjs", "./tools", "./prompts");
84
+
85
+ const configPath = path.join(projectPath, "xmcp.config.ts");
86
+ assert(fs.existsSync(configPath), "Config file should be created");
87
+
88
+ const configContent = fs.readFileSync(configPath, "utf-8");
89
+ assert(configContent.includes("paths: {"), "Should include paths object");
90
+ assert(
91
+ configContent.includes('tools: "./tools"'),
92
+ "Should include tools path"
93
+ );
94
+ assert(
95
+ configContent.includes('prompts: "./prompts"'),
96
+ "Should include prompts path"
97
+ );
98
+
99
+ const pathsMatches = configContent.match(/paths:/g);
100
+ assert(
101
+ pathsMatches && pathsMatches.length === 1,
102
+ "Should contain exactly one paths object"
103
+ );
104
+ });
105
+ });
@@ -21,11 +21,20 @@ const config: XmcpConfig = {
21
21
  adapter: "${frameworkAdapter}",
22
22
  },`;
23
23
 
24
- if (toolsPath && promptsPath) {
24
+ if (toolsPath || promptsPath) {
25
+ configContent += `
26
+ paths: {`;
27
+
28
+ if (toolsPath) {
29
+ configContent += `
30
+ tools: "${toolsPath}",`;
31
+ }
32
+
33
+ if (promptsPath) {
34
+ configContent += `
35
+ prompts: "${promptsPath}",`;
36
+ }
25
37
  configContent += `
26
- paths: {
27
- tools: "${toolsPath}",
28
- prompts: "${promptsPath}",
29
38
  },`;
30
39
  }
31
40
 
package/src/index.ts CHANGED
@@ -300,7 +300,7 @@ const program = new Command()
300
300
  }
301
301
 
302
302
  if (promptsPath) {
303
- console.log(` • ${promptsPath}/greet.ts`);
303
+ console.log(` • ${promptsPath}/review-code.ts`);
304
304
  }
305
305
 
306
306
  if (routePath) {