@zeyue0329/xiaoma-cli 1.0.40 → 1.0.42

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 (29) hide show
  1. package/.idea/workspace.xml +8 -1
  2. package/.xiaoma-core/.coordinator-state.json +19 -0
  3. package/dist/agents/architect.txt +192 -0
  4. package/dist/agents/workflow-executor.txt +151 -1
  5. package/dist/agents/workflow-helper.txt +93 -0
  6. package/dist/teams/team-all.txt +396 -191
  7. package/dist/teams/team-fullstack-with-database.txt +2 -0
  8. package/dist/teams/team-fullstack.txt +2 -0
  9. package/dist/teams/team-no-ui.txt +2 -0
  10. package/docs/architecture/workflow-coordinator-implementation.md +1188 -0
  11. package/docs/prd/workflow-coordinator-prd.md +1214 -0
  12. package/package.json +6 -1
  13. package/tools/api-server.js +367 -0
  14. package/tools/installer/package.json +1 -1
  15. package/tools/workflow-coordinator/README.md +38 -0
  16. package/tools/workflow-coordinator/USAGE.md +548 -0
  17. package/tools/workflow-coordinator/package-lock.json +4868 -0
  18. package/tools/workflow-coordinator/package.json +35 -0
  19. package/tools/workflow-coordinator/src/api/server.js +207 -0
  20. package/tools/workflow-coordinator/src/controller/workflow-controller.js +263 -0
  21. package/tools/workflow-coordinator/src/index.js +113 -0
  22. package/tools/workflow-coordinator/src/parser/workflow-parser.js +144 -0
  23. package/tools/workflow-coordinator/src/utils/state-manager.js +59 -0
  24. package/tools/workflow-coordinator/src/utils/validator.js +86 -0
  25. package/tools/workflow-coordinator/test/integration-test.js +266 -0
  26. package/tools/workflow-coordinator/test/quick-test.js +127 -0
  27. package/xiaoma-core/agents/workflow-executor.md +155 -1
  28. package/xiaoma-core/agents/workflow-helper.md +481 -0
  29. package/xiaoma-core/workflows/automated-requirements-development.yaml +739 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@zeyue0329/xiaoma-cli",
4
- "version": "1.0.40",
4
+ "version": "1.0.42",
5
5
  "description": "XiaoMa Cli: Universal AI Agent Framework",
6
6
  "keywords": [
7
7
  "agile",
@@ -24,6 +24,8 @@
24
24
  "xiaoma-cli": "tools/xiaoma-npx-wrapper.js"
25
25
  },
26
26
  "scripts": {
27
+ "api:start": "node tools/api-server.js",
28
+ "api:dev": "nodemon tools/api-server.js",
27
29
  "build": "node tools/cli.js build --no-expansions",
28
30
  "build:agents": "node tools/cli.js build --agents-only",
29
31
  "build:teams": "node tools/cli.js build --teams-only",
@@ -73,8 +75,11 @@
73
75
  },
74
76
  "dependencies": {
75
77
  "@kayvan/markdown-tree-parser": "^1.6.1",
78
+ "body-parser": "^2.2.0",
76
79
  "chalk": "^4.1.2",
77
80
  "commander": "^14.0.0",
81
+ "cors": "^2.8.5",
82
+ "express": "^5.1.0",
78
83
  "fs-extra": "^11.3.1",
79
84
  "glob": "^11.0.3",
80
85
  "ignore": "^7.0.5",
@@ -0,0 +1,367 @@
1
+ const express = require("express");
2
+ const cors = require("cors");
3
+ const path = require("node:path");
4
+ const fs = require("node:fs").promises;
5
+ const WebBuilder = require("./builders/web-builder");
6
+ const DependencyResolver = require("./lib/dependency-resolver");
7
+
8
+ const app = express();
9
+ const PORT = process.env.PORT || 3000;
10
+
11
+ // 中间件
12
+ app.use(cors());
13
+ app.use(express.json());
14
+
15
+ // 初始化构建器
16
+ const rootDir = path.join(__dirname, "..");
17
+ const builder = new WebBuilder({ rootDir });
18
+ const resolver = new DependencyResolver(rootDir);
19
+
20
+ // ==================== API 路由 ====================
21
+
22
+ /**
23
+ * 健康检查
24
+ */
25
+ app.get("/health", (req, res) => {
26
+ res.json({
27
+ status: "ok",
28
+ timestamp: new Date().toISOString(),
29
+ version: "1.0.0",
30
+ });
31
+ });
32
+
33
+ /**
34
+ * 获取所有可用的智能体列表
35
+ * GET /api/agents
36
+ */
37
+ app.get("/api/agents", async (req, res) => {
38
+ try {
39
+ const agents = await resolver.listAgents();
40
+ res.json({
41
+ success: true,
42
+ data: agents,
43
+ count: agents.length,
44
+ });
45
+ } catch (error) {
46
+ console.error("Error listing agents:", error);
47
+ res.status(500).json({
48
+ success: false,
49
+ error: error.message,
50
+ });
51
+ }
52
+ });
53
+
54
+ /**
55
+ * 获取所有可用的团队列表
56
+ * GET /api/teams
57
+ */
58
+ app.get("/api/teams", async (req, res) => {
59
+ try {
60
+ const teams = await resolver.listTeams();
61
+ res.json({
62
+ success: true,
63
+ data: teams,
64
+ count: teams.length,
65
+ });
66
+ } catch (error) {
67
+ console.error("Error listing teams:", error);
68
+ res.status(500).json({
69
+ success: false,
70
+ error: error.message,
71
+ });
72
+ }
73
+ });
74
+
75
+ /**
76
+ * 获取特定智能体的详细信息
77
+ * GET /api/agents/:name/info
78
+ */
79
+ app.get("/api/agents/:name/info", async (req, res) => {
80
+ try {
81
+ const agentName = req.params.name;
82
+ const agentPath = path.join(rootDir, "xiaoma-core", "agents", `${agentName}.md`);
83
+
84
+ // 检查文件是否存在
85
+ try {
86
+ await fs.access(agentPath);
87
+ } catch {
88
+ return res.status(404).json({
89
+ success: false,
90
+ error: `Agent '${agentName}' not found`,
91
+ });
92
+ }
93
+
94
+ const content = await fs.readFile(agentPath, "utf-8");
95
+
96
+ // 解析 YAML 配置 (简单提取)
97
+ const yamlMatch = content.match(/```yaml\n([\s\S]*?)\n```/);
98
+ let config = null;
99
+ if (yamlMatch) {
100
+ const yaml = require("js-yaml");
101
+ config = yaml.load(yamlMatch[1]);
102
+ }
103
+
104
+ res.json({
105
+ success: true,
106
+ data: {
107
+ name: agentName,
108
+ path: agentPath,
109
+ config: config,
110
+ },
111
+ });
112
+ } catch (error) {
113
+ console.error("Error getting agent info:", error);
114
+ res.status(500).json({
115
+ success: false,
116
+ error: error.message,
117
+ });
118
+ }
119
+ });
120
+
121
+ /**
122
+ * 获取智能体的完整 bundle 内容
123
+ * GET /api/agents/:name/bundle
124
+ */
125
+ app.get("/api/agents/:name/bundle", async (req, res) => {
126
+ try {
127
+ const agentName = req.params.name;
128
+ const bundlePath = path.join(rootDir, "dist", "agents", `${agentName}.txt`);
129
+
130
+ // 检查 bundle 是否存在
131
+ try {
132
+ await fs.access(bundlePath);
133
+ } catch {
134
+ return res.status(404).json({
135
+ success: false,
136
+ error: `Bundle for agent '${agentName}' not found. Please run 'npm run build' first.`,
137
+ });
138
+ }
139
+
140
+ const content = await fs.readFile(bundlePath, "utf-8");
141
+
142
+ res.json({
143
+ success: true,
144
+ data: {
145
+ agent: agentName,
146
+ bundle: content,
147
+ size: content.length,
148
+ },
149
+ });
150
+ } catch (error) {
151
+ console.error("Error getting agent bundle:", error);
152
+ res.status(500).json({
153
+ success: false,
154
+ error: error.message,
155
+ });
156
+ }
157
+ });
158
+
159
+ /**
160
+ * 获取团队的完整 bundle 内容
161
+ * GET /api/teams/:name/bundle
162
+ */
163
+ app.get("/api/teams/:name/bundle", async (req, res) => {
164
+ try {
165
+ const teamName = req.params.name;
166
+ const bundlePath = path.join(rootDir, "dist", "teams", `${teamName}.txt`);
167
+
168
+ // 检查 bundle 是否存在
169
+ try {
170
+ await fs.access(bundlePath);
171
+ } catch {
172
+ return res.status(404).json({
173
+ success: false,
174
+ error: `Bundle for team '${teamName}' not found. Please run 'npm run build' first.`,
175
+ });
176
+ }
177
+
178
+ const content = await fs.readFile(bundlePath, "utf-8");
179
+
180
+ res.json({
181
+ success: true,
182
+ data: {
183
+ team: teamName,
184
+ bundle: content,
185
+ size: content.length,
186
+ },
187
+ });
188
+ } catch (error) {
189
+ console.error("Error getting team bundle:", error);
190
+ res.status(500).json({
191
+ success: false,
192
+ error: error.message,
193
+ });
194
+ }
195
+ });
196
+
197
+ /**
198
+ * 构建智能体 bundles
199
+ * POST /api/build/agents
200
+ */
201
+ app.post("/api/build/agents", async (req, res) => {
202
+ try {
203
+ console.log("Building agent bundles...");
204
+ await builder.buildAgents();
205
+
206
+ res.json({
207
+ success: true,
208
+ message: "Agent bundles built successfully",
209
+ });
210
+ } catch (error) {
211
+ console.error("Error building agents:", error);
212
+ res.status(500).json({
213
+ success: false,
214
+ error: error.message,
215
+ });
216
+ }
217
+ });
218
+
219
+ /**
220
+ * 构建团队 bundles
221
+ * POST /api/build/teams
222
+ */
223
+ app.post("/api/build/teams", async (req, res) => {
224
+ try {
225
+ console.log("Building team bundles...");
226
+ await builder.buildTeams();
227
+
228
+ res.json({
229
+ success: true,
230
+ message: "Team bundles built successfully",
231
+ });
232
+ } catch (error) {
233
+ console.error("Error building teams:", error);
234
+ res.status(500).json({
235
+ success: false,
236
+ error: error.message,
237
+ });
238
+ }
239
+ });
240
+
241
+ /**
242
+ * 构建所有 bundles
243
+ * POST /api/build/all
244
+ */
245
+ app.post("/api/build/all", async (req, res) => {
246
+ try {
247
+ console.log("Building all bundles...");
248
+ await builder.buildAgents();
249
+ await builder.buildTeams();
250
+
251
+ res.json({
252
+ success: true,
253
+ message: "All bundles built successfully",
254
+ });
255
+ } catch (error) {
256
+ console.error("Error building all:", error);
257
+ res.status(500).json({
258
+ success: false,
259
+ error: error.message,
260
+ });
261
+ }
262
+ });
263
+
264
+ /**
265
+ * 验证配置
266
+ * POST /api/validate
267
+ */
268
+ app.post("/api/validate", async (req, res) => {
269
+ try {
270
+ const agents = await resolver.listAgents();
271
+ const teams = await resolver.listTeams();
272
+
273
+ const validationResults = {
274
+ agents: [],
275
+ teams: [],
276
+ };
277
+
278
+ // 验证智能体
279
+ for (const agent of agents) {
280
+ try {
281
+ await resolver.resolveAgentDependencies(agent);
282
+ validationResults.agents.push({ name: agent, valid: true });
283
+ } catch (error) {
284
+ validationResults.agents.push({
285
+ name: agent,
286
+ valid: false,
287
+ error: error.message
288
+ });
289
+ }
290
+ }
291
+
292
+ // 验证团队
293
+ for (const team of teams) {
294
+ try {
295
+ await resolver.resolveTeamDependencies(team);
296
+ validationResults.teams.push({ name: team, valid: true });
297
+ } catch (error) {
298
+ validationResults.teams.push({
299
+ name: team,
300
+ valid: false,
301
+ error: error.message
302
+ });
303
+ }
304
+ }
305
+
306
+ const allValid = validationResults.agents.every(a => a.valid) &&
307
+ validationResults.teams.every(t => t.valid);
308
+
309
+ res.json({
310
+ success: allValid,
311
+ message: allValid ? "All configurations are valid" : "Some configurations have errors",
312
+ data: validationResults,
313
+ });
314
+ } catch (error) {
315
+ console.error("Error validating:", error);
316
+ res.status(500).json({
317
+ success: false,
318
+ error: error.message,
319
+ });
320
+ }
321
+ });
322
+
323
+ // 错误处理中间件
324
+ app.use((err, req, res, next) => {
325
+ console.error("Unhandled error:", err);
326
+ res.status(500).json({
327
+ success: false,
328
+ error: "Internal server error",
329
+ message: err.message,
330
+ });
331
+ });
332
+
333
+ // 404 处理
334
+ app.use((req, res) => {
335
+ res.status(404).json({
336
+ success: false,
337
+ error: "Endpoint not found",
338
+ });
339
+ });
340
+
341
+ // 启动服务器
342
+ app.listen(PORT, () => {
343
+ console.log(`
344
+ ╔════════════════════════════════════════════════════════╗
345
+ ║ XiaoMa-CLI API Server Started ║
346
+ ╠════════════════════════════════════════════════════════╣
347
+ ║ Port: ${PORT} ║
348
+ ║ Environment: ${process.env.NODE_ENV || "development"} ║
349
+ ║ Root Dir: ${rootDir.substring(0, 40)}... ║
350
+ ╠════════════════════════════════════════════════════════╣
351
+ ║ Available Endpoints: ║
352
+ ║ - GET /health Health check ║
353
+ ║ - GET /api/agents List agents ║
354
+ ║ - GET /api/teams List teams ║
355
+ ║ - GET /api/agents/:name/info Agent info ║
356
+ ║ - GET /api/agents/:name/bundle Agent bundle ║
357
+ ║ - GET /api/teams/:name/bundle Team bundle ║
358
+ ║ - POST /api/build/agents Build agents ║
359
+ ║ - POST /api/build/teams Build teams ║
360
+ ║ - POST /api/build/all Build all ║
361
+ ║ - POST /api/validate Validate configs ║
362
+ ╚════════════════════════════════════════════════════════╝
363
+ `);
364
+ console.log(`API Server is running at http://localhost:${PORT}`);
365
+ });
366
+
367
+ module.exports = app;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xiaoma-cli",
3
- "version": "1.0.29",
3
+ "version": "1.0.41",
4
4
  "description": "XiaoMa-Cli installer - AI-powered Agile development framework",
5
5
  "keywords": [
6
6
  "bmad",
@@ -0,0 +1,38 @@
1
+ # XiaoMa 工作流协调器
2
+
3
+ 工作流协调器是一个外部进程,负责驱动Claude Code中的工作流自动执行。
4
+
5
+ ## 快速开始
6
+
7
+ ```bash
8
+ # 1. 安装依赖
9
+ npm install
10
+
11
+ # 2. 启动协调器
12
+ npm start start requirements-analysis
13
+
14
+ # 3. 在Claude Code中执行
15
+ # /workflow-helper
16
+ # *start-workflow requirements-analysis
17
+ ```
18
+
19
+ ## 架构
20
+
21
+ ```
22
+ 协调器 (Node.js进程)
23
+ ↕️ HTTP API
24
+ Claude Code (执行智能体)
25
+ ```
26
+
27
+ ## 功能
28
+
29
+ - ✅ 解析工作流YAML定义
30
+ - ✅ HTTP服务器接收Claude Code回调
31
+ - ✅ 步骤流程控制和决策
32
+ - ✅ 状态持久化和恢复
33
+ - ✅ 质量门控验证
34
+
35
+ ## 相关文档
36
+
37
+ - [PRD文档](../../docs/prd/workflow-coordinator-prd.md)
38
+ - [实现指南](../../docs/architecture/workflow-coordinator-implementation.md)