momo-ai 1.0.18 → 1.0.19

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "momo-ai",
3
- "version": "1.0.18",
3
+ "version": "1.0.19",
4
4
  "description": "Rachel Momo ( OpenSpec )",
5
5
  "main": "src/momo.js",
6
6
  "bin": {
@@ -4,7 +4,7 @@
4
4
  详细解读 specification/requirement.md 需求文档中的模块和每个模块的功能列表,在 specification/changes/ 目录之下创建模块的核心文档,每个模块用 MXX- 前缀,其中 XX 是模块编号。
5
5
 
6
6
  1. 每个模块中包括 tasks/ 目录、任务明细文档存放位置。
7
- 2. 每个模块中包括 proposal.md,此文档中用来存放模块的详细需求。
7
+ 2. 每个模块中包括 proposal.md,此文档中用来存放模块的详细需求,记得头部使用带有需求编号的注释:`<!-- CODE: XXX -->`。
8
8
  3. 每个模块中包括 tasks.md,此文档中是描述所有任务的总清单。
9
9
  4. 模块所需的数据模型可参考 specification/project-model.md 文档。
10
10
  5. 有多少模块在于你的模块的整体设计,记得模块内部业务要形成完整闭环。
@@ -8,4 +8,5 @@
8
8
  3. 任务文件名统一成 MXX-TNNN.md,其中 NN 是任务编号,NNN 是任务编号,编号长度不足用 0 填充。
9
9
  4. 每个任务文件中要写出任务实施过程的详细步骤。
10
10
  5. 系统相关的数据模型参考 specification/data-model.md 文件。
11
+ 4. 更新 specification/changes/MXX-模块/tasks.md 文件时,每个任务必须使用 `- [ ]` 的前缀做任务标记,后边跟上任务编号和标题。
11
12
  <!-- END -->
@@ -5,10 +5,17 @@ const Ec = require('../epic');
5
5
  /**
6
6
  * 从 Markdown 文件中提取编号信息
7
7
  * @param {string} filePath 文件路径
8
+ * @param {string} dirName 目录名(用于从目录名中提取编号)
8
9
  * @returns {string} 编号信息或 'N/A'
9
10
  */
10
- const _extractId = (filePath) => {
11
+ const _extractId = (filePath, dirName) => {
11
12
  try {
13
+ // 首先尝试从目录名中提取编号(MXX格式)
14
+ const dirMatch = dirName.match(/^M\d{2}/);
15
+ if (dirMatch) {
16
+ return dirMatch[0];
17
+ }
18
+
12
19
  if (!fs.existsSync(filePath)) {
13
20
  return 'N/A';
14
21
  }
@@ -21,8 +28,17 @@ const _extractId = (filePath) => {
21
28
  return codeMatch[1].trim();
22
29
  }
23
30
 
24
- // 如果没有找到CODE格式,尝试查找 "- 编号:" 格式
31
+ // 然后尝试从文件内容的标题中提取编号(MXX格式)
25
32
  const lines = content.split('\n');
33
+ for (const line of lines) {
34
+ // 匹配 # MXX 格式的标题(M后跟两位数字)
35
+ const titleMatch = line.match(/^#\s+(M\d{2})/);
36
+ if (titleMatch) {
37
+ return titleMatch[1];
38
+ }
39
+ }
40
+
41
+ // 如果没有找到CODE格式,尝试查找 "- 编号:" 格式
26
42
  for (const line of lines) {
27
43
  const idMatch = line.match(/-\s*编号[::]\s*(.+)/);
28
44
  if (idMatch) {
@@ -51,10 +67,11 @@ const _countTasks = (tasksFile) => {
51
67
  const lines = content.split('\n');
52
68
  let count = 0;
53
69
 
54
- // 使用更直接的方法匹配任务
70
+ // 匹配任务列表格式:
71
+ // - [ ] 任务描述
72
+ // - [xxx] 任务描述
55
73
  for (const line of lines) {
56
- // 匹配任务格式,例如: - [ ] [任务1简要描述](tasks/M01-T001-01.md)
57
- if (line.trim().startsWith('- [') && line.includes('] [') && line.includes('](') && line.includes('tasks/')) {
74
+ if (line.trim().match(/^-\s*\[.*\]/)) {
58
75
  count++;
59
76
  }
60
77
  }
@@ -89,17 +106,22 @@ module.exports = (options) => {
89
106
  process.exit(0);
90
107
  }
91
108
 
92
- // 显示表头
93
- Ec.waiting('编号\t\t名称\t\t\t任务数量');
94
- Ec.waiting('------------------------------------------------');
109
+ // 显示表头(调整列宽和间距)
110
+ const header = '编号'.padEnd(12) + '名称'.padEnd(32) + '任务数量';
111
+ Ec.waiting(header);
112
+
113
+ // 显示分隔线
114
+ const separator = '-'.repeat(10) + ' ' + '-'.repeat(30) + ' ' + '-'.repeat(8);
115
+ Ec.waiting(separator);
95
116
 
96
117
  // 显示需求列表
97
118
  requirements.forEach((requirement) => {
98
119
  const proposalFile = path.join(changesDir, requirement, 'proposal.md');
99
120
  const tasksFile = path.join(changesDir, requirement, 'tasks.md');
100
- const id = _extractId(proposalFile);
121
+ const id = _extractId(proposalFile, requirement);
101
122
  const taskCount = _countTasks(tasksFile);
102
- Ec.waiting(`${id}\t\t${requirement}\t\t\t${taskCount}`);
123
+ const line = id.padEnd(12) + requirement.padEnd(32) + String(taskCount);
124
+ Ec.waiting(line);
103
125
  });
104
126
 
105
127
  Ec.info(`✅ 共找到 ${requirements.length} 个需求`);