intention-coding 0.3.8 → 0.4.1

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 (51) hide show
  1. package/package.json +1 -1
  2. package/dist/db/file-storage.js +0 -638
  3. package/dist/index.js +0 -26
  4. package/dist/server/index.js +0 -88
  5. package/dist/services/bug-fix-agent/index.js +0 -320
  6. package/dist/services/change-summarizer/index.js +0 -123
  7. package/dist/services/change-summarizer/prompt/change-analysis.js +0 -56
  8. package/dist/services/code-generator/index.js +0 -403
  9. package/dist/services/code-generator/stages/execution-stage.js +0 -549
  10. package/dist/services/code-generator/stages/ideation-stage.js +0 -267
  11. package/dist/services/code-generator/stages/optimization-stage.js +0 -334
  12. package/dist/services/code-generator/stages/planning-stage.js +0 -295
  13. package/dist/services/code-generator/stages/research-stage.js +0 -283
  14. package/dist/services/code-generator/stages/review-stage.js +0 -270
  15. package/dist/services/code-generator/types.js +0 -37
  16. package/dist/services/code-generator/utils/instruction-executor.js +0 -207
  17. package/dist/services/code-generator/workflow-manager.js +0 -252
  18. package/dist/services/image-analysis/analyzer.js +0 -530
  19. package/dist/services/image-analysis/index.js +0 -406
  20. package/dist/services/image-analysis/types.js +0 -46
  21. package/dist/services/image-converter/converter.js +0 -310
  22. package/dist/services/image-converter/index.js +0 -262
  23. package/dist/services/image-converter/types.js +0 -31
  24. package/dist/services/integrated-generator/index.js +0 -1297
  25. package/dist/services/pdf2md/index.js +0 -180
  26. package/dist/services/project-template/index.js +0 -83
  27. package/dist/services/project-template/prompt/project-rules.js +0 -98
  28. package/dist/services/requirement-analyzer/chunk-reader.js +0 -218
  29. package/dist/services/requirement-analyzer/core/document-generator.js +0 -254
  30. package/dist/services/requirement-analyzer/core/intelligent-analyzer.js +0 -169
  31. package/dist/services/requirement-analyzer/core/project-analyzer.js +0 -199
  32. package/dist/services/requirement-analyzer/core/requirement-analyzer-service.js +0 -191
  33. package/dist/services/requirement-analyzer/core/template-selector.js +0 -124
  34. package/dist/services/requirement-analyzer/core/types.js +0 -23
  35. package/dist/services/requirement-analyzer/index.js +0 -177
  36. package/dist/services/requirement-analyzer/prompt/api-template.js +0 -302
  37. package/dist/services/requirement-analyzer/prompt/app-template.js +0 -455
  38. package/dist/services/requirement-analyzer/prompt/intelligent-requirement-analysis.js +0 -92
  39. package/dist/services/requirement-analyzer/prompt/pc-page-template.js +0 -582
  40. package/dist/services/requirement-analyzer/prompt/requirement-analysis.js +0 -664
  41. package/dist/services/requirement-analyzer/prompt/sdk-template.js +0 -582
  42. package/dist/services/requirement-analyzer/utils/file-reader.js +0 -169
  43. package/dist/services/world2md/index.js +0 -157
  44. package/dist/types/index.js +0 -2
  45. package/dist/utils/common.js +0 -72
  46. package/dist/utils/config.js +0 -163
  47. package/dist/utils/context-manager.js +0 -114
  48. package/dist/utils/dify.js +0 -243
  49. package/dist/utils/logger.js +0 -129
  50. package/dist/utils/openai.js +0 -225
  51. package/dist/utils/pack.js +0 -75
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intention-coding",
3
- "version": "0.3.8",
3
+ "version": "0.4.1",
4
4
  "description": "软件工程化的需求分析,功能设计,代码编写,测试运行和发布部署",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@10.11.0",
@@ -1,638 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.dbOperations = void 0;
46
- const fs = __importStar(require("fs"));
47
- const path = __importStar(require("path"));
48
- const logger_1 = require("../utils/logger");
49
- const config_1 = require("../utils/config");
50
- class FileStorage {
51
- constructor() {
52
- try {
53
- const storageDir = (0, config_1.getStorageDir)();
54
- this.dataDir = path.join(storageDir, "api-test");
55
- this.plansFile = path.join(this.dataDir, "test-plans.json");
56
- this.tasksFile = path.join(this.dataDir, "test-tasks.json");
57
- // 需求管理数据目录
58
- this.requirementDataDir = path.join(storageDir, "requirements");
59
- this.projectsFile = path.join(this.requirementDataDir, "projects.json");
60
- this.analysesFile = path.join(this.requirementDataDir, "analyses.json");
61
- this.requirementItemsFile = path.join(this.requirementDataDir, "requirement-items.json");
62
- this.validationsFile = path.join(this.requirementDataDir, "validations.json");
63
- // 代码生成数据目录
64
- this.codeGenerationDataDir = path.join(storageDir, "code-generation");
65
- this.codeSessionsFile = path.join(this.codeGenerationDataDir, "sessions.json");
66
- this.codeTasksFile = path.join(this.codeGenerationDataDir, "tasks.json");
67
- this.ensureDataDir();
68
- }
69
- catch (error) {
70
- console.warn("FileStorage初始化失败,使用默认路径:", error);
71
- // 使用默认路径
72
- const defaultDir = path.join(process.cwd(), ".aico");
73
- this.dataDir = path.join(defaultDir, "api-test");
74
- this.plansFile = path.join(this.dataDir, "test-plans.json");
75
- this.tasksFile = path.join(this.dataDir, "test-tasks.json");
76
- this.requirementDataDir = path.join(defaultDir, "requirements");
77
- this.projectsFile = path.join(this.requirementDataDir, "projects.json");
78
- this.analysesFile = path.join(this.requirementDataDir, "analyses.json");
79
- this.requirementItemsFile = path.join(this.requirementDataDir, "requirement-items.json");
80
- this.validationsFile = path.join(this.requirementDataDir, "validations.json");
81
- this.codeGenerationDataDir = path.join(defaultDir, "code-generation");
82
- this.codeSessionsFile = path.join(this.codeGenerationDataDir, "sessions.json");
83
- this.codeTasksFile = path.join(this.codeGenerationDataDir, "tasks.json");
84
- this.ensureDataDir();
85
- }
86
- }
87
- ensureDataDir() {
88
- // API测试数据目录
89
- if (!fs.existsSync(this.dataDir)) {
90
- fs.mkdirSync(this.dataDir, { recursive: true });
91
- }
92
- // Initialize API test files if they don't exist
93
- if (!fs.existsSync(this.plansFile)) {
94
- fs.writeFileSync(this.plansFile, "[]", "utf8");
95
- }
96
- if (!fs.existsSync(this.tasksFile)) {
97
- fs.writeFileSync(this.tasksFile, "[]", "utf8");
98
- }
99
- // 需求管理数据目录
100
- if (!fs.existsSync(this.requirementDataDir)) {
101
- fs.mkdirSync(this.requirementDataDir, { recursive: true });
102
- }
103
- // Initialize requirement files if they don't exist
104
- if (!fs.existsSync(this.projectsFile)) {
105
- fs.writeFileSync(this.projectsFile, "[]", "utf8");
106
- }
107
- if (!fs.existsSync(this.analysesFile)) {
108
- fs.writeFileSync(this.analysesFile, "[]", "utf8");
109
- }
110
- if (!fs.existsSync(this.requirementItemsFile)) {
111
- fs.writeFileSync(this.requirementItemsFile, "[]", "utf8");
112
- }
113
- if (!fs.existsSync(this.validationsFile)) {
114
- fs.writeFileSync(this.validationsFile, "[]", "utf8");
115
- }
116
- // 代码生成数据目录
117
- if (!fs.existsSync(this.codeGenerationDataDir)) {
118
- fs.mkdirSync(this.codeGenerationDataDir, { recursive: true });
119
- }
120
- // Initialize code generation files if they don't exist
121
- if (!fs.existsSync(this.codeSessionsFile)) {
122
- fs.writeFileSync(this.codeSessionsFile, "[]", "utf8");
123
- }
124
- if (!fs.existsSync(this.codeTasksFile)) {
125
- fs.writeFileSync(this.codeTasksFile, "[]", "utf8");
126
- }
127
- }
128
- readPlans() {
129
- try {
130
- const data = fs.readFileSync(this.plansFile, "utf8");
131
- return JSON.parse(data).map((p) => (Object.assign(Object.assign({}, p), { createdAt: new Date(p.createdAt), updatedAt: new Date(p.updatedAt) })));
132
- }
133
- catch (error) {
134
- logger_1.logger.error("Error reading plans file", error);
135
- return [];
136
- }
137
- }
138
- writePlans(plans) {
139
- fs.writeFileSync(this.plansFile, JSON.stringify(plans, null, 2), "utf8");
140
- }
141
- readTasks() {
142
- try {
143
- const data = fs.readFileSync(this.tasksFile, "utf8");
144
- return JSON.parse(data).map((t) => (Object.assign(Object.assign({}, t), { createdAt: new Date(t.createdAt), updatedAt: new Date(t.updatedAt) })));
145
- }
146
- catch (error) {
147
- logger_1.logger.error("Error reading tasks file", error);
148
- return [];
149
- }
150
- }
151
- writeTasks(tasks) {
152
- fs.writeFileSync(this.tasksFile, JSON.stringify(tasks, null, 2), "utf8");
153
- }
154
- getNextId(items) {
155
- return items.length > 0 ? Math.max(...items.map(i => i.id)) + 1 : 1;
156
- }
157
- // Test Plan operations
158
- createTestPlan(data) {
159
- return __awaiter(this, void 0, void 0, function* () {
160
- const plans = this.readPlans();
161
- const newPlan = {
162
- id: this.getNextId(plans),
163
- uuid: data.uuid,
164
- name: data.name,
165
- status: data.status || "pending",
166
- completed: false,
167
- createdAt: new Date(),
168
- updatedAt: new Date()
169
- };
170
- plans.push(newPlan);
171
- this.writePlans(plans);
172
- return [newPlan];
173
- });
174
- }
175
- getTestPlan(uuid) {
176
- return __awaiter(this, void 0, void 0, function* () {
177
- const plans = this.readPlans();
178
- return plans.filter(p => p.uuid === uuid);
179
- });
180
- }
181
- getAllTestPlans() {
182
- return __awaiter(this, void 0, void 0, function* () {
183
- return this.readPlans();
184
- });
185
- }
186
- updateTestPlan(uuid, data) {
187
- return __awaiter(this, void 0, void 0, function* () {
188
- const plans = this.readPlans();
189
- const planIndex = plans.findIndex(p => p.uuid === uuid);
190
- if (planIndex >= 0) {
191
- plans[planIndex] = Object.assign(Object.assign(Object.assign({}, plans[planIndex]), data), { updatedAt: new Date() });
192
- this.writePlans(plans);
193
- }
194
- });
195
- }
196
- // Test Task operations
197
- createTestTask(data) {
198
- return __awaiter(this, void 0, void 0, function* () {
199
- const tasks = this.readTasks();
200
- const newTask = {
201
- id: this.getNextId(tasks),
202
- uuid: data.uuid,
203
- tableUuid: data.tableUuid,
204
- url: data.url,
205
- method: data.method || "GET",
206
- query: data.query,
207
- headers: data.headers,
208
- body: data.body,
209
- hopeRes: data.hopeRes,
210
- status: "pending",
211
- completed: false,
212
- createdAt: new Date(),
213
- updatedAt: new Date()
214
- };
215
- tasks.push(newTask);
216
- this.writeTasks(tasks);
217
- return [newTask];
218
- });
219
- }
220
- getTestTask(uuid) {
221
- return __awaiter(this, void 0, void 0, function* () {
222
- const tasks = this.readTasks();
223
- return tasks.filter(t => t.uuid === uuid);
224
- });
225
- }
226
- getTestTasksByPlan(tableUuid) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- const tasks = this.readTasks();
229
- return tasks.filter(t => t.tableUuid === tableUuid);
230
- });
231
- }
232
- updateTestTask(uuid, data) {
233
- return __awaiter(this, void 0, void 0, function* () {
234
- const tasks = this.readTasks();
235
- const taskIndex = tasks.findIndex(t => t.uuid === uuid);
236
- if (taskIndex >= 0) {
237
- tasks[taskIndex] = Object.assign(Object.assign(Object.assign({}, tasks[taskIndex]), data), { updatedAt: new Date() });
238
- this.writeTasks(tasks);
239
- }
240
- });
241
- }
242
- batchUpdateTaskSummaries(updates) {
243
- return __awaiter(this, void 0, void 0, function* () {
244
- const tasks = this.readTasks();
245
- let updated = false;
246
- for (const update of updates) {
247
- const taskIndex = tasks.findIndex(t => t.uuid === update.uuid);
248
- if (taskIndex >= 0) {
249
- tasks[taskIndex] = Object.assign(Object.assign({}, tasks[taskIndex]), { review: update.summary, suggest: update.suggest, completed: true, updatedAt: new Date() });
250
- updated = true;
251
- }
252
- }
253
- if (updated) {
254
- this.writeTasks(tasks);
255
- }
256
- });
257
- }
258
- // ==================== 需求管理相关方法 ====================
259
- // 项目管理
260
- readProjects() {
261
- try {
262
- const data = fs.readFileSync(this.projectsFile, "utf8");
263
- return JSON.parse(data).map((p) => (Object.assign(Object.assign({}, p), { createdAt: new Date(p.createdAt), updatedAt: new Date(p.updatedAt) })));
264
- }
265
- catch (error) {
266
- logger_1.logger.error("Error reading projects file", error);
267
- return [];
268
- }
269
- }
270
- writeProjects(projects) {
271
- fs.writeFileSync(this.projectsFile, JSON.stringify(projects, null, 2), "utf8");
272
- }
273
- createRequirementProject(data) {
274
- return __awaiter(this, void 0, void 0, function* () {
275
- const projects = this.readProjects();
276
- const newProject = {
277
- id: this.getNextId(projects),
278
- uuid: data.uuid,
279
- name: data.name,
280
- description: data.description,
281
- status: "planning",
282
- priority: data.priority || "medium",
283
- stakeholders: data.stakeholders,
284
- createdAt: new Date(),
285
- updatedAt: new Date()
286
- };
287
- projects.push(newProject);
288
- this.writeProjects(projects);
289
- return newProject;
290
- });
291
- }
292
- getRequirementProject(uuid) {
293
- return __awaiter(this, void 0, void 0, function* () {
294
- const projects = this.readProjects();
295
- return projects.find(p => p.uuid === uuid) || null;
296
- });
297
- }
298
- getAllRequirementProjects() {
299
- return __awaiter(this, void 0, void 0, function* () {
300
- return this.readProjects();
301
- });
302
- }
303
- updateRequirementProject(uuid, data) {
304
- return __awaiter(this, void 0, void 0, function* () {
305
- const projects = this.readProjects();
306
- const projectIndex = projects.findIndex(p => p.uuid === uuid);
307
- if (projectIndex >= 0) {
308
- projects[projectIndex] = Object.assign(Object.assign(Object.assign({}, projects[projectIndex]), data), { updatedAt: new Date() });
309
- this.writeProjects(projects);
310
- }
311
- });
312
- }
313
- // 分析管理
314
- readAnalyses() {
315
- try {
316
- const data = fs.readFileSync(this.analysesFile, "utf8");
317
- return JSON.parse(data).map((a) => (Object.assign(Object.assign({}, a), { createdAt: new Date(a.createdAt), updatedAt: new Date(a.updatedAt) })));
318
- }
319
- catch (error) {
320
- logger_1.logger.error("Error reading analyses file", error);
321
- return [];
322
- }
323
- }
324
- writeAnalyses(analyses) {
325
- fs.writeFileSync(this.analysesFile, JSON.stringify(analyses, null, 2), "utf8");
326
- }
327
- createRequirementAnalysis(data) {
328
- return __awaiter(this, void 0, void 0, function* () {
329
- const analyses = this.readAnalyses();
330
- const newAnalysis = {
331
- id: this.getNextId(analyses),
332
- uuid: data.uuid,
333
- projectUuid: data.projectUuid,
334
- analysisType: data.analysisType,
335
- title: data.title,
336
- content: data.content,
337
- originalInput: data.originalInput,
338
- analysisParams: data.analysisParams,
339
- filePath: data.filePath,
340
- status: "completed",
341
- version: 1,
342
- createdAt: new Date(),
343
- updatedAt: new Date()
344
- };
345
- analyses.push(newAnalysis);
346
- this.writeAnalyses(analyses);
347
- return newAnalysis;
348
- });
349
- }
350
- getRequirementAnalyses(projectUuid) {
351
- return __awaiter(this, void 0, void 0, function* () {
352
- const analyses = this.readAnalyses();
353
- return analyses.filter(a => a.projectUuid === projectUuid);
354
- });
355
- }
356
- getRequirementAnalysis(uuid) {
357
- return __awaiter(this, void 0, void 0, function* () {
358
- const analyses = this.readAnalyses();
359
- return analyses.find(a => a.uuid === uuid) || null;
360
- });
361
- }
362
- // 需求条目管理
363
- readRequirementItems() {
364
- try {
365
- const data = fs.readFileSync(this.requirementItemsFile, "utf8");
366
- return JSON.parse(data).map((r) => (Object.assign(Object.assign({}, r), { createdAt: new Date(r.createdAt), updatedAt: new Date(r.updatedAt) })));
367
- }
368
- catch (error) {
369
- logger_1.logger.error("Error reading requirement items file", error);
370
- return [];
371
- }
372
- }
373
- writeRequirementItems(items) {
374
- fs.writeFileSync(this.requirementItemsFile, JSON.stringify(items, null, 2), "utf8");
375
- }
376
- createRequirementItem(data) {
377
- return __awaiter(this, void 0, void 0, function* () {
378
- const items = this.readRequirementItems();
379
- const newItem = {
380
- id: this.getNextId(items),
381
- uuid: data.uuid,
382
- projectUuid: data.projectUuid,
383
- analysisUuid: data.analysisUuid,
384
- type: data.type,
385
- category: data.category,
386
- title: data.title,
387
- description: data.description,
388
- priority: data.priority || "should",
389
- status: "draft",
390
- acceptanceCriteria: data.acceptanceCriteria,
391
- dependencies: data.dependencies,
392
- estimatedEffort: data.estimatedEffort,
393
- assignee: data.assignee,
394
- tags: data.tags,
395
- createdAt: new Date(),
396
- updatedAt: new Date()
397
- };
398
- items.push(newItem);
399
- this.writeRequirementItems(items);
400
- return newItem;
401
- });
402
- }
403
- getRequirementItems(projectUuid) {
404
- return __awaiter(this, void 0, void 0, function* () {
405
- const items = this.readRequirementItems();
406
- return items.filter(r => r.projectUuid === projectUuid);
407
- });
408
- }
409
- updateRequirementItem(uuid, data) {
410
- return __awaiter(this, void 0, void 0, function* () {
411
- const items = this.readRequirementItems();
412
- const itemIndex = items.findIndex(r => r.uuid === uuid);
413
- if (itemIndex >= 0) {
414
- items[itemIndex] = Object.assign(Object.assign(Object.assign({}, items[itemIndex]), data), { updatedAt: new Date() });
415
- this.writeRequirementItems(items);
416
- }
417
- });
418
- }
419
- // 验证管理
420
- readValidations() {
421
- try {
422
- const data = fs.readFileSync(this.validationsFile, "utf8");
423
- return JSON.parse(data).map((v) => (Object.assign(Object.assign({}, v), { createdAt: new Date(v.createdAt), updatedAt: new Date(v.updatedAt) })));
424
- }
425
- catch (error) {
426
- logger_1.logger.error("Error reading validations file", error);
427
- return [];
428
- }
429
- }
430
- writeValidations(validations) {
431
- fs.writeFileSync(this.validationsFile, JSON.stringify(validations, null, 2), "utf8");
432
- }
433
- createRequirementValidation(data) {
434
- return __awaiter(this, void 0, void 0, function* () {
435
- const validations = this.readValidations();
436
- const newValidation = {
437
- id: this.getNextId(validations),
438
- uuid: data.uuid,
439
- requirementUuid: data.requirementUuid,
440
- validationType: data.validationType,
441
- status: data.status,
442
- issues: data.issues,
443
- suggestions: data.suggestions,
444
- validatedBy: data.validatedBy,
445
- createdAt: new Date(),
446
- updatedAt: new Date()
447
- };
448
- validations.push(newValidation);
449
- this.writeValidations(validations);
450
- return newValidation;
451
- });
452
- }
453
- getRequirementValidations(requirementUuid) {
454
- return __awaiter(this, void 0, void 0, function* () {
455
- const validations = this.readValidations();
456
- return validations.filter(v => v.requirementUuid === requirementUuid);
457
- });
458
- }
459
- initCodeGenerationStorage() {
460
- this.codeGenerationDataDir = path.join((0, config_1.getStorageDir)(), "code-generation");
461
- this.codeSessionsFile = path.join(this.codeGenerationDataDir, "sessions.json");
462
- this.codeTasksFile = path.join(this.codeGenerationDataDir, "tasks.json");
463
- if (!fs.existsSync(this.codeGenerationDataDir)) {
464
- fs.mkdirSync(this.codeGenerationDataDir, { recursive: true });
465
- }
466
- if (!fs.existsSync(this.codeSessionsFile)) {
467
- fs.writeFileSync(this.codeSessionsFile, "[]", "utf8");
468
- }
469
- if (!fs.existsSync(this.codeTasksFile)) {
470
- fs.writeFileSync(this.codeTasksFile, "[]", "utf8");
471
- }
472
- }
473
- readCodeSessions() {
474
- try {
475
- if (!fs.existsSync(this.codeSessionsFile)) {
476
- this.initCodeGenerationStorage();
477
- return [];
478
- }
479
- const data = fs.readFileSync(this.codeSessionsFile, "utf8");
480
- return JSON.parse(data).map((s) => (Object.assign(Object.assign({}, s), { createdAt: new Date(s.createdAt), updatedAt: new Date(s.updatedAt), startedAt: s.startedAt ? new Date(s.startedAt) : undefined, completedAt: s.completedAt ? new Date(s.completedAt) : undefined })));
481
- }
482
- catch (error) {
483
- logger_1.logger.error("Error reading code sessions file", error);
484
- return [];
485
- }
486
- }
487
- writeCodeSessions(sessions) {
488
- if (!fs.existsSync(this.codeGenerationDataDir)) {
489
- this.initCodeGenerationStorage();
490
- }
491
- fs.writeFileSync(this.codeSessionsFile, JSON.stringify(sessions, null, 2), "utf8");
492
- }
493
- readCodeTasks() {
494
- try {
495
- if (!fs.existsSync(this.codeTasksFile)) {
496
- this.initCodeGenerationStorage();
497
- return [];
498
- }
499
- const data = fs.readFileSync(this.codeTasksFile, "utf8");
500
- return JSON.parse(data).map((t) => (Object.assign(Object.assign({}, t), { createdAt: new Date(t.createdAt), updatedAt: new Date(t.updatedAt), startedAt: t.startedAt ? new Date(t.startedAt) : undefined, completedAt: t.completedAt ? new Date(t.completedAt) : undefined })));
501
- }
502
- catch (error) {
503
- logger_1.logger.error("Error reading code tasks file", error);
504
- return [];
505
- }
506
- }
507
- writeCodeTasks(tasks) {
508
- if (!fs.existsSync(this.codeGenerationDataDir)) {
509
- this.initCodeGenerationStorage();
510
- }
511
- fs.writeFileSync(this.codeTasksFile, JSON.stringify(tasks, null, 2), "utf8");
512
- }
513
- createCodeGenerationSession(data) {
514
- return __awaiter(this, void 0, void 0, function* () {
515
- const sessions = this.readCodeSessions();
516
- const newSession = {
517
- id: this.getNextId(sessions),
518
- uuid: data.uuid,
519
- sessionId: data.sessionId,
520
- taskTitle: data.taskTitle,
521
- taskDescription: data.taskDescription,
522
- projectName: data.projectName,
523
- programmingLanguage: data.programmingLanguage,
524
- framework: data.framework,
525
- featureType: data.featureType,
526
- priority: data.priority,
527
- userStory: data.userStory,
528
- acceptanceCriteria: JSON.stringify(data.acceptanceCriteria),
529
- technicalRequirements: data.technicalRequirements,
530
- testRequirements: data.testRequirements,
531
- customContext: data.customContext,
532
- sessionDir: data.sessionDir,
533
- status: "pending",
534
- generatedFiles: 0,
535
- totalDuration: 0,
536
- createdAt: new Date(),
537
- updatedAt: new Date()
538
- };
539
- sessions.push(newSession);
540
- this.writeCodeSessions(sessions);
541
- return newSession;
542
- });
543
- }
544
- getCodeGenerationSession(uuid) {
545
- return __awaiter(this, void 0, void 0, function* () {
546
- const sessions = this.readCodeSessions();
547
- return sessions.find(s => s.uuid === uuid) || null;
548
- });
549
- }
550
- getAllCodeGenerationSessions() {
551
- return __awaiter(this, void 0, void 0, function* () {
552
- return this.readCodeSessions();
553
- });
554
- }
555
- updateCodeGenerationSession(uuid, data) {
556
- return __awaiter(this, void 0, void 0, function* () {
557
- const sessions = this.readCodeSessions();
558
- const sessionIndex = sessions.findIndex(s => s.uuid === uuid);
559
- if (sessionIndex >= 0) {
560
- sessions[sessionIndex] = Object.assign(Object.assign(Object.assign({}, sessions[sessionIndex]), data), { updatedAt: new Date() });
561
- this.writeCodeSessions(sessions);
562
- }
563
- });
564
- }
565
- createCodeGenerationTask(data) {
566
- return __awaiter(this, void 0, void 0, function* () {
567
- const tasks = this.readCodeTasks();
568
- const newTask = {
569
- id: this.getNextId(tasks),
570
- uuid: data.uuid,
571
- sessionUuid: data.sessionUuid,
572
- taskType: data.taskType,
573
- taskName: data.taskName,
574
- description: data.description,
575
- inputData: data.inputData,
576
- outputPath: data.outputPath,
577
- fileSize: data.fileSize,
578
- status: "pending",
579
- duration: 0,
580
- createdAt: new Date(),
581
- updatedAt: new Date()
582
- };
583
- tasks.push(newTask);
584
- this.writeCodeTasks(tasks);
585
- return newTask;
586
- });
587
- }
588
- getCodeGenerationTasksBySession(sessionUuid) {
589
- return __awaiter(this, void 0, void 0, function* () {
590
- const tasks = this.readCodeTasks();
591
- return tasks.filter(t => t.sessionUuid === sessionUuid);
592
- });
593
- }
594
- updateCodeGenerationTask(uuid, data) {
595
- return __awaiter(this, void 0, void 0, function* () {
596
- const tasks = this.readCodeTasks();
597
- const taskIndex = tasks.findIndex(t => t.uuid === uuid);
598
- if (taskIndex >= 0) {
599
- tasks[taskIndex] = Object.assign(Object.assign(Object.assign({}, tasks[taskIndex]), data), { updatedAt: new Date() });
600
- this.writeCodeTasks(tasks);
601
- }
602
- });
603
- }
604
- }
605
- const storage = new FileStorage();
606
- exports.dbOperations = {
607
- // API测试相关
608
- createTestPlan: storage.createTestPlan.bind(storage),
609
- getTestPlan: storage.getTestPlan.bind(storage),
610
- getAllTestPlans: storage.getAllTestPlans.bind(storage),
611
- updateTestPlan: storage.updateTestPlan.bind(storage),
612
- createTestTask: storage.createTestTask.bind(storage),
613
- getTestTask: storage.getTestTask.bind(storage),
614
- getTestTasksByPlan: storage.getTestTasksByPlan.bind(storage),
615
- updateTestTask: storage.updateTestTask.bind(storage),
616
- batchUpdateTaskSummaries: storage.batchUpdateTaskSummaries.bind(storage),
617
- // 需求管理相关
618
- createRequirementProject: storage.createRequirementProject.bind(storage),
619
- getRequirementProject: storage.getRequirementProject.bind(storage),
620
- getAllRequirementProjects: storage.getAllRequirementProjects.bind(storage),
621
- updateRequirementProject: storage.updateRequirementProject.bind(storage),
622
- createRequirementAnalysis: storage.createRequirementAnalysis.bind(storage),
623
- getRequirementAnalyses: storage.getRequirementAnalyses.bind(storage),
624
- getRequirementAnalysis: storage.getRequirementAnalysis.bind(storage),
625
- createRequirementItem: storage.createRequirementItem.bind(storage),
626
- getRequirementItems: storage.getRequirementItems.bind(storage),
627
- updateRequirementItem: storage.updateRequirementItem.bind(storage),
628
- createRequirementValidation: storage.createRequirementValidation.bind(storage),
629
- getRequirementValidations: storage.getRequirementValidations.bind(storage),
630
- // 代码生成相关
631
- createCodeGenerationSession: storage.createCodeGenerationSession.bind(storage),
632
- getCodeGenerationSession: storage.getCodeGenerationSession.bind(storage),
633
- getAllCodeGenerationSessions: storage.getAllCodeGenerationSessions.bind(storage),
634
- updateCodeGenerationSession: storage.updateCodeGenerationSession.bind(storage),
635
- createCodeGenerationTask: storage.createCodeGenerationTask.bind(storage),
636
- getCodeGenerationTasksBySession: storage.getCodeGenerationTasksBySession.bind(storage),
637
- updateCodeGenerationTask: storage.updateCodeGenerationTask.bind(storage)
638
- };
package/dist/index.js DELETED
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
13
- const index_1 = require("./server/index");
14
- const logger_1 = require("./utils/logger");
15
- const config_1 = require("./utils/config");
16
- // 初始化项目根目录
17
- (0, config_1.initializeProjectRoot)();
18
- // 创建MCP服务器实例
19
- const server = (0, index_1.createMcpServer)();
20
- // 创建stdio传输
21
- const transport = new stdio_js_1.StdioServerTransport();
22
- // 启动服务
23
- logger_1.logger.info("启动智能软件星工厂 MCP 服务器 (stdio模式)");
24
- (() => __awaiter(void 0, void 0, void 0, function* () {
25
- yield server.connect(transport);
26
- }))();