TPC服务器

用于人工智能协作的Node.js/Express API,从用于思想和计划的JSON文件存储开始。
设置和使用
- 安装依赖项:
npm install - 启动服务器:
node server.js - 服务器运行在
http://localhost:3001
更新日志
看 更改日志.md 查看详细的发行说明。
测试
跑 npm test (或 npm run test:unit)执行Jest API/集成测试。 跑 npm run test:e2e 用于Playwright UI测试。 跑 npm run smoke:mcp 用于确定性MCP计划/思想生命周期烟雾验证。
生产安全
/tpc.db 默认情况下,下载在生产环境中是禁用的。 要明确允许它,请设置 EXPOSE_TPC_DB=true.
操作端点
GET /health返回基本活性信息。GET /ready返回准备状态信息和数据库路径。
数据合同(REST+MCP)
- 鉴定:SQLite中用于计划/想法的整数自动递增ID。
- 时间戳:
- thoughts.timestamp, plans.timestamp =ISO8601字符串。 - plans.created_at, plans.last_modified_at =历元毫秒。
- 标签:数据库列中的JSON编码字符串数组。
项目结构
server.js:模块化结构的主Express服务器(db/、routes/、中间件/)。mcp-server.js:用于AI客户端的MCP服务器(stdio传输)。与一起跑步npm run mcp.data/tpc.db:SQLite数据库,用于持久存储想法和计划。tests/:测试文件(Jest单元测试、MCP测试)。public/:静态单页UI。
使用示例
REST API
- 检索所有想法:
curl http://localhost:3001/thoughts - 检索所有计划:
curl http://localhost:3001/plans - 创造一个想法:
curl -X POST http://localhost:3001/thoughts -H "Content-Type: application/json" -d '{"content": "My thought"}' - 制定计划:
curl -X POST http://localhost:3001/plans -H "Content-Type: application/json" -d '{"title": "My Plan", "description": "Plan details"}' - 更新计划状态:
curl -X PATCH http://localhost:3001/plans/1 -H "Content-Type: application/json" -d '{"status": "in_progress"}' - 在计划/想法中搜索:
curl "http://localhost:3001/search?q=AI&type=plans&tags=urgent&limit=5" - 在计划中添加标签:
curl -X PATCH http://localhost:3001/plans/1/tags -H "Content-Type: application/json" -d '{"tag": "ai"}'(附加)或{"tags": ["ai", "urgent"]}(替换) - 按标签筛选计划:
curl "http://localhost:3001/plans?tags=ai,urgent" - 查看UI:访问http://localhost:3001/index.html启动服务器后。
MCP服务器
- 启动MCP服务器:
npm run mcp - 通过stdio连接--配置您的MCP客户端以使用此
- 可用工具:列表计划、获取计划、创建计划、更新计划、列表想法、创建想法、搜索想法、获取文本
- 可用资源:tpc://plans, tpc://thoughts, tpc://context
特性
- MCP服务器:为AI客户端实现完整的MCP协议。与一起跑步
npm run mcp(stdio传输)。 - 模块化服务器架构:分为db/、路由/和中间件/,用于可维护的API开发。
- SQLite持久性:单一
data/tpc.db用于具有幂等模式迁移的想法和计划。 - 综合测试:Jest用于单元测试(端点、验证、集成),Playwright用于E2E UI测试(渲染、交互)。
- 人工智能协作重点:端点
/context为代理内存聚合数据;支持带有审阅标志的人工编辑。 - 富文本支持:计划描述接受Markdown格式(粗体、列表等),并使用marked.js在UI中显示。
- 搜索和组织:全文搜索API(
/search?q=)带有类型/标签/限制过滤器;UI搜索输入和基于标签的过滤/编辑。 - 标记系统:通过API/UI添加/编辑/过滤计划/想法上的标记,以便更好地分类(例如,\[‘ai’,‘emergent’\])。
v2.7-搜索和组织
已实现的功能
- 全文搜索端点(
GET /search?q=)可选?type=plans|thoughts,?tags=tag1,tag2,?limit=N以获得有针对性的结果。 - 标签系统:
tags计划/想法表上的列(JSON数组);通过管理POST/PUT/PATCH /plans/:id/tags(以及思考)。 - 标签过滤:
?tags=ai,urgent列表端点上的(AND逻辑)(/plans,/thoughts,/search). - 增强
/context随着?search=以过滤聚合数据。 - UI:全局搜索输入、详细标签编辑、列表中的标签过滤下拉菜单。
用法
- API搜索:
curl "http://localhost:3001/search?q=collaboration&type=plans&tags=ai" - 标记计划:
curl -X PATCH http://localhost:3001/plans/1/tags -H "Content-Type: application/json" -d '{"tags": ["ai", "urgent"]}'(替换)或{"tag": "new"}(附后)。 - 按标签筛选:
curl "http://localhost:3001/plans?tags=ai,urgent" - UI:在搜索框中输入查询;单击标签在平面图/思维图中编辑/过滤。
显著变化
- 架构添加:
tags计划/想法表的TEXT列(默认为“\[\]”);与回填向后兼容的迁移。 - 新路线:
/search用于统一查询。 - 基于v2.6 Markdown支持和模块化结构构建。

