feat: add code graph feature with interactive visualization

- Implemented CodeGraphView component for visualizing project file structure using Sigma.js.
- Added NodeSearchBox for searching nodes within the graph.
- Created API module to fetch file data from backend.
- Developed graph building logic to construct a tree structure from file data.
- Integrated new routes and updated route tree to include the code graph page.
- Updated Vite configuration to load environment variables and changed server port.
- Added example data for testing the code graph functionality.
This commit is contained in:
xiongxiao
2026-03-13 22:01:14 +08:00
committed by cnb
parent 3e54f994fd
commit fa11796aef
15 changed files with 1457 additions and 17 deletions

View File

@@ -34,6 +34,14 @@ const api = {
"optional": true
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -57,6 +65,14 @@ const api = {
"description": "要移除的项目根目录绝对路径,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -80,6 +96,14 @@ const api = {
"description": "要暂停监听的项目根目录绝对路径,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -103,6 +127,14 @@ const api = {
"description": "要查询的项目根目录绝对路径,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -115,6 +147,14 @@ const api = {
"key": "list",
"description": "列出所有已注册的项目及其当前运行状态(路径、仓库名称、监听是否活跃等)",
"metadata": {
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -183,6 +223,14 @@ const api = {
"optional": true
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -195,6 +243,7 @@ const api = {
* @param data - Request parameters
* @param data.q - {string} 搜索关键词,选填;留空或不传则返回全部文件
* @param data.projectPath - {string} 按项目根目录路径过滤,仅返回该项目下的文件,选填
* @param data.filepath - {string} 按文件绝对路径过滤,选填
* @param data.repo - {string} 按代码仓库标识过滤(如 owner/repo选填
* @param data.title - {string} 按人工标注的标题字段过滤,选填
* @param data.tags - {array} 按人工标注的标签列表过滤,选填
@@ -223,6 +272,12 @@ const api = {
"type": "string",
"optional": true
},
"filepath": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "按文件绝对路径过滤,选填",
"type": "string",
"optional": true
},
"repo": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "按代码仓库标识过滤(如 owner/repo选填",
@@ -284,6 +339,14 @@ const api = {
"optional": true
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -309,6 +372,52 @@ const api = {
"description": "要读取的文件绝对路径,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
},
/**
* 将 base64 编码的内容写入指定文件路径,用于更新或创建文件
*
* @param data - Request parameters
* @param data.filepath - {string (minLength: 1)} 要写入的文件绝对路径,必填
* @param data.content - {string (minLength: 1)} 文件内容的 base64 编码,必填
*/
"update-content": {
"path": "project-file",
"key": "update-content",
"description": "将 base64 编码的内容写入指定文件路径,用于更新或创建文件",
"metadata": {
"args": {
"filepath": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
"minLength": 1,
"description": "要写入的文件绝对路径,必填"
},
"content": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string",
"minLength": 1,
"description": "文件内容的 base64 编码,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -370,6 +479,14 @@ const api = {
"optional": true
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}
@@ -393,6 +510,14 @@ const api = {
"description": "要删除的文件绝对路径,必填"
}
},
"viewItem": {
"api": {
"url": "/root/v1/cnb-dev"
},
"type": "api",
"title": "CNB_BOARD",
"routerStatus": "active"
},
"url": "/root/v1/cnb-dev",
"source": "query-proxy-api"
}