phinix 0.0.4

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 (36) hide show
  1. package/README.md +311 -0
  2. package/debug-client.js +56 -0
  3. package/docs/src/DPHeader/README.md +36 -0
  4. package/docs/src/DPHeader/demo/advanced.tsx +49 -0
  5. package/docs/src/DPHeader/demo/basic.tsx +26 -0
  6. package/examples/create-button.json +38 -0
  7. package/examples/create-modal.json +43 -0
  8. package/mcp-config.json +10 -0
  9. package/package.json +34 -0
  10. package/quick-test.js +111 -0
  11. package/src/component-composer.js +582 -0
  12. package/src/components/DPHeader/DPHeader.tsx +25 -0
  13. package/src/components/DPHeader/define.ts +37 -0
  14. package/src/components/DPHeader.css +33 -0
  15. package/src/components/DPHeader.tsx +38 -0
  16. package/src/config.js +34 -0
  17. package/src/index.js +4 -0
  18. package/src/resources/components-info.json +334 -0
  19. package/src/resources/project-knowledge.md +134 -0
  20. package/src/rules/instruction-components.md +970 -0
  21. package/src/rules/instruction-core.md +99 -0
  22. package/src/rules/instruction-tailwind-details.md +494 -0
  23. package/src/rules/instruction.md +423 -0
  24. package/src/server.js +109 -0
  25. package/src/tools/componentDefine.js +64 -0
  26. package/src/tools/componentDemos.js +156 -0
  27. package/src/tools/componentDetails.js +168 -0
  28. package/src/tools/componentList.js +80 -0
  29. package/src/tools/componentReadme.js +77 -0
  30. package/src/tools/componentSource.js +93 -0
  31. package/src/tools/index.js +41 -0
  32. package/src/tools/projectKnowledge.js +68 -0
  33. package/src/utils.js +62 -0
  34. package/templates/data-table-crud/EntityColumns.tsx +1 -0
  35. package/templates/data-table-crud/EntityList.tsx +1 -0
  36. package/test-mcp.sh +13 -0
package/src/utils.js ADDED
@@ -0,0 +1,62 @@
1
+ import path from "path";
2
+
3
+ // 工具函数:获取文件扩展名用于代码高亮
4
+ export function getFileExtension(filePath) {
5
+ if (!filePath) return "text";
6
+
7
+ const ext = path.extname(filePath).slice(1).toLowerCase();
8
+ switch (ext) {
9
+ case "tsx":
10
+ case "ts":
11
+ return "typescript";
12
+ case "jsx":
13
+ case "js":
14
+ return "javascript";
15
+ case "css":
16
+ return "css";
17
+ case "scss":
18
+ return "scss";
19
+ case "json":
20
+ return "json";
21
+ case "md":
22
+ return "markdown";
23
+ case "html":
24
+ return "html";
25
+ case "xml":
26
+ return "xml";
27
+ default:
28
+ return ext || "text";
29
+ }
30
+ }
31
+
32
+ // 内容截取函数
33
+ export function createTruncateFunction(maxContentLength) {
34
+ return function truncateContent(content, maxLength = maxContentLength) {
35
+ if (!content || content.length <= maxLength) {
36
+ return { content, truncated: false };
37
+ }
38
+ const truncated = content.substring(0, maxLength);
39
+ const lastNewLine = truncated.lastIndexOf("\n");
40
+ const finalContent = lastNewLine > maxLength * 0.8
41
+ ? truncated.substring(0, lastNewLine)
42
+ : truncated;
43
+ return {
44
+ content: finalContent + "\n\n// ... 内容过长,已截取 ...",
45
+ truncated: true,
46
+ originalLength: content.length,
47
+ };
48
+ };
49
+ }
50
+
51
+ // 获取文件摘要信息
52
+ export function getFileSummary(content) {
53
+ if (!content) return null;
54
+ const lines = content.split("\n");
55
+ return {
56
+ totalLines: lines.length,
57
+ imports: lines.filter((line) => line.trim().startsWith("import")).length,
58
+ exports: lines.filter((line) => line.trim().startsWith("export")).length,
59
+ functions: (content.match(/function\s+\w+|const\s+\w+\s*=\s*\(/g) || []).length,
60
+ components: (content.match(/const\s+\w+\s*=\s*\(/g) || []).length,
61
+ };
62
+ }
package/test-mcp.sh ADDED
@@ -0,0 +1,13 @@
1
+ #!/bin/bash
2
+
3
+ echo "测试MCP服务器..."
4
+
5
+ # 启动服务器并测试
6
+ echo "1. 测试获取工具列表:"
7
+ echo '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}' | node src/index.js
8
+
9
+ echo -e "\n\n2. 测试获取组件列表:"
10
+ echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"get_component_list","arguments":{"limit":5}}}' | node src/index.js
11
+
12
+ echo -e "\n\n3. 测试搜索组件:"
13
+ echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"get_component_list","arguments":{"search":"table","limit":3}}}' | node src/index.js