@zeyue0329/xiaoma-cli 1.0.41 → 1.0.43
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.
- package/.idea/workspace.xml +23 -2
- package/JAVA-BACKEND-COMMANDS-REFERENCE.md +2 -2
- package/JAVA-BACKEND-ITERATION-GUIDE.md +31 -31
- package/dist/agents/architect.txt +1 -1
- package/dist/agents/pm.txt +20 -20
- package/dist/agents/po.txt +1 -1
- package/dist/agents/sm.txt +1 -1
- package/dist/agents/workflow-executor.txt +170 -20
- package/dist/agents/xiaoma-master.txt +20 -20
- package/dist/teams/team-all.txt +193 -43
- package/dist/teams/team-fullstack-with-database.txt +24 -24
- package/dist/teams/team-fullstack.txt +22 -22
- package/dist/teams/team-ide-minimal.txt +2 -2
- package/dist/teams/team-no-ui.txt +22 -22
- package/docs/architecture-sharding-modification.md +4 -4
- package/docs/automated-requirements-analysis-outputs.md +29 -29
- package/docs/prd/workflow-coordinator-prd.md +2 -2
- package/package.json +6 -1
- package/tools/api-server.js +367 -0
- package/xiaoma-core/agents/pm.md +1 -1
- package/xiaoma-core/agents/po.md +1 -1
- package/xiaoma-core/agents/requirements-coverage-auditor.yaml +1 -1
- package/xiaoma-core/agents/sm.md +1 -1
- package/xiaoma-core/agents/workflow-executor.md +174 -20
- package/xiaoma-core/tasks/batch-story-generation.md +1 -1
- package/xiaoma-core/tasks/requirements-coverage-audit.md +5 -5
- package/xiaoma-core/templates/fullstack-architecture-tmpl.yaml +1 -1
- package/xiaoma-core/templates/prd-tmpl.yaml +19 -19
- package/xiaoma-core/templates/requirements-coverage-audit.yaml +6 -6
- package/xiaoma-core/workflows/automated-requirements-analysis.yaml +90 -90
- package/xiaoma-core/workflows/automated-requirements-development.yaml +739 -0
- package/xiaoma-core/workflows/enhanced-fullstack-with-qa-loop.yaml +1 -1
- package/xiaoma-core/workflows/full-requirement-automation.yaml +1 -1
|
@@ -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;
|
package/xiaoma-core/agents/pm.md
CHANGED
|
@@ -55,7 +55,7 @@ commands:
|
|
|
55
55
|
- create-brownfield-epic: 运行任务 brownfield-create-epic.md
|
|
56
56
|
- create-brownfield-prd: 使用模板 brownfield-prd-tmpl.yaml 运行任务 create-doc.md
|
|
57
57
|
- create-brownfield-story: 运行任务 brownfield-create-story.md
|
|
58
|
-
- create-epic:
|
|
58
|
+
- create-epic: 为现有项目项目创建模块 (任务 brownfield-create-epic)
|
|
59
59
|
- create-prd: 使用模板 prd-tmpl.yaml 运行任务 create-doc.md
|
|
60
60
|
- create-story: 从需求创建用户故事 (任务 brownfield-create-story)
|
|
61
61
|
- doc-out: 将完整文档输出到当前目标文件
|
package/xiaoma-core/agents/po.md
CHANGED
|
@@ -55,7 +55,7 @@ persona:
|
|
|
55
55
|
commands:
|
|
56
56
|
- help: 显示以下命令的编号列表以供选择
|
|
57
57
|
- correct-course: 执行 correct-course 任务
|
|
58
|
-
- create-epic:
|
|
58
|
+
- create-epic: 为现有项目项目创建模块 (任务 brownfield-create-epic)
|
|
59
59
|
- create-story: 从需求创建用户故事 (任务 brownfield-create-story)
|
|
60
60
|
- doc-out: 将完整文档输出到当前目标文件
|
|
61
61
|
- execute-checklist-po: 运行任务 execute-checklist (清单 po-master-checklist)
|