vibecodingmachine-core 2025.12.1-534 → 2025.12.6-1702

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.
@@ -0,0 +1,310 @@
1
+ const fs = require('fs-extra');
2
+ const path = require('path');
3
+
4
+ /**
5
+ * Parse requirements file and extract all sections
6
+ * This matches the CLI's parsing logic to ensure consistency
7
+ * @param {string} content - The requirements file content
8
+ * @returns {Object} Parsed requirements with sections: requirements, completed, needInformation, changelog, verified
9
+ */
10
+ function parseRequirementsFile(content) {
11
+ const lines = content.split('\n');
12
+ const requirements = [];
13
+ const completed = [];
14
+ const needInformation = [];
15
+ const changelog = [];
16
+ const verified = [];
17
+
18
+ let currentSection = '';
19
+ let inSection = false;
20
+
21
+ // Section detection patterns (matching CLI logic)
22
+ const sectionPatterns = {
23
+ todo: ['⏳ Requirements not yet completed', 'Requirements not yet completed'],
24
+ verify: [
25
+ '🔍 TO VERIFY BY HUMAN',
26
+ 'TO VERIFY BY HUMAN',
27
+ '🔍 TO VERIFY',
28
+ 'TO VERIFY',
29
+ '✅ TO VERIFY',
30
+ '✅ Verified by AI screenshot. Needs Human to Verify and move to CHANGELOG',
31
+ 'Verified by AI screenshot. Needs Human to Verify and move to CHANGELOG',
32
+ 'Verified by AI screenshot'
33
+ ],
34
+ verified: ['📝 VERIFIED', 'VERIFIED'],
35
+ changelog: ['CHANGELOG'],
36
+ needInformation: ['❓ Requirements needing', 'Requirements needing', 'needing manual feedback', 'needing information']
37
+ };
38
+
39
+ for (let i = 0; i < lines.length; i++) {
40
+ const line = lines[i];
41
+ const trimmed = line.trim();
42
+
43
+ // Check for section headers (## but not ###)
44
+ if (trimmed.startsWith('##') && !trimmed.startsWith('###')) {
45
+ // Determine which section we're entering
46
+ if (sectionPatterns.todo.some(pattern => trimmed.includes(pattern))) {
47
+ currentSection = 'todo';
48
+ inSection = true;
49
+ continue;
50
+ } else if (sectionPatterns.verify.some(pattern => {
51
+ const matches = trimmed.includes(pattern);
52
+ // Make sure it's not a VERIFIED section (without TO VERIFY)
53
+ if (matches && !trimmed.includes('📝 VERIFIED') && !trimmed.match(/^##\s+VERIFIED$/i) && !trimmed.includes('📝 VERIFIED')) {
54
+ return true;
55
+ }
56
+ return false;
57
+ })) {
58
+ currentSection = 'verify';
59
+ inSection = true;
60
+ continue;
61
+ } else if (sectionPatterns.verified.some(pattern => trimmed.includes(pattern))) {
62
+ currentSection = 'verified';
63
+ inSection = true;
64
+ continue;
65
+ } else if (sectionPatterns.changelog.some(pattern => trimmed.includes(pattern))) {
66
+ currentSection = 'changelog';
67
+ inSection = true;
68
+ continue;
69
+ } else if (sectionPatterns.needInformation.some(pattern => trimmed.includes(pattern))) {
70
+ currentSection = 'needInformation';
71
+ inSection = true;
72
+ continue;
73
+ } else {
74
+ // Different section header - exit current section
75
+ if (inSection) {
76
+ // Check if we're leaving TO VERIFY section
77
+ if (currentSection === 'verify') {
78
+ const isTodoSection = trimmed.includes('⏳ Requirements not yet completed') || trimmed.includes('Requirements not yet completed');
79
+ const isVerifiedSection = trimmed === '## 📝 VERIFIED' || trimmed.startsWith('## 📝 VERIFIED');
80
+ const isRecycledSection = trimmed === '## ♻️ RECYCLED' || trimmed.startsWith('## ♻️ RECYCLED') ||
81
+ trimmed === '## 📦 RECYCLED' || trimmed.startsWith('## 📦 RECYCLED');
82
+ const isClarificationSection = trimmed.includes('## ❓ Requirements needing') || trimmed.includes('❓ Requirements needing');
83
+
84
+ if (isVerifiedSection || isTodoSection || isRecycledSection || isClarificationSection) {
85
+ inSection = false;
86
+ currentSection = '';
87
+ }
88
+ // Otherwise continue - might be REJECTED or CHANGELOG which are not section boundaries for TO VERIFY
89
+ } else {
90
+ inSection = false;
91
+ currentSection = '';
92
+ }
93
+ }
94
+ continue;
95
+ }
96
+ }
97
+
98
+ // Parse requirements in new format (### header)
99
+ if (inSection && trimmed.startsWith('###')) {
100
+ const title = trimmed.replace(/^###\s*/, '').trim();
101
+
102
+ // Skip malformed requirements (title is just a package name, empty, or too short)
103
+ const packageNames = ['cli', 'core', 'electron-app', 'web', 'mobile', 'vscode-extension', 'sync-server'];
104
+ if (!title || title.length === 0 || packageNames.includes(title.toLowerCase())) {
105
+ continue;
106
+ }
107
+
108
+ const details = [];
109
+ let package = null;
110
+ let options = null;
111
+ let optionsType = null;
112
+
113
+ // Read package, description, and options
114
+ for (let j = i + 1; j < lines.length; j++) {
115
+ const nextLine = lines[j].trim();
116
+
117
+ // Stop if we hit another requirement or section
118
+ if (nextLine.startsWith('###') || (nextLine.startsWith('##') && !nextLine.startsWith('###'))) {
119
+ break;
120
+ }
121
+
122
+ // Check for PACKAGE line
123
+ if (nextLine.startsWith('PACKAGE:')) {
124
+ package = nextLine.replace(/^PACKAGE:\s*/, '').trim();
125
+ }
126
+ // Check for OPTIONS line (for need information requirements)
127
+ else if (nextLine.startsWith('OPTIONS:')) {
128
+ optionsType = 'checkbox'; // default
129
+ const optionsText = nextLine.replace(/^OPTIONS:\s*/, '').trim();
130
+ // Parse options (could be checkbox or radio)
131
+ if (optionsText.includes('|')) {
132
+ options = optionsText.split('|').map(opt => opt.trim()).filter(opt => opt);
133
+ } else {
134
+ options = [optionsText];
135
+ }
136
+ }
137
+ // Description line (include all lines including empty ones to preserve formatting)
138
+ else if (nextLine !== undefined) {
139
+ details.push(nextLine);
140
+ }
141
+ }
142
+
143
+ const requirement = {
144
+ title,
145
+ description: details.join('\n'),
146
+ package,
147
+ options,
148
+ optionsType,
149
+ lineIndex: i
150
+ };
151
+
152
+ // Add to appropriate array based on current section
153
+ if (currentSection === 'todo') {
154
+ requirements.push(requirement);
155
+ } else if (currentSection === 'verify') {
156
+ completed.push(requirement);
157
+ } else if (currentSection === 'needInformation') {
158
+ needInformation.push(requirement);
159
+ } else if (currentSection === 'changelog') {
160
+ changelog.push(requirement);
161
+ } else if (currentSection === 'verified') {
162
+ verified.push(requirement);
163
+ }
164
+ }
165
+
166
+ // Also support old format (lines starting with -) for backwards compatibility
167
+ if (inSection && trimmed.startsWith('- ') && !trimmed.startsWith('###')) {
168
+ const requirementText = trimmed.substring(2).trim();
169
+ if (requirementText) {
170
+ // Extract date if present (format: "2025-12-25 2:35 PM MDT - " or "2025-10-03: ")
171
+ const dateTimeMatch = requirementText.match(/^(\d{4}-\d{2}-\d{2})(?:\s+\d{1,2}:\d{2}\s+[AP]M(?:\s+[A-Z]{2,5})?)?\s*[-:]\s*/);
172
+ const date = dateTimeMatch ? dateTimeMatch[1] : null;
173
+ const title = dateTimeMatch ? requirementText.substring(dateTimeMatch[0].length).trim() : requirementText;
174
+
175
+ const requirement = {
176
+ title: title.length > 100 ? title.substring(0, 100) + '...' : title,
177
+ description: title,
178
+ date: date
179
+ };
180
+
181
+ if (currentSection === 'todo') {
182
+ requirements.push(requirement);
183
+ } else if (currentSection === 'verify' || currentSection === 'completed') {
184
+ completed.push(requirement);
185
+ } else if (currentSection === 'changelog') {
186
+ changelog.push(requirement);
187
+ }
188
+ }
189
+ }
190
+ }
191
+
192
+ // Remove duplicates based on title (keep first occurrence)
193
+ const seenTitles = new Set();
194
+ const uniqueRequirements = [];
195
+ for (const req of requirements) {
196
+ const normalizedTitle = req.title.replace(/^TRY AGAIN \(\d+(st|nd|rd|th) time\):\s*/i, '').trim();
197
+ if (!seenTitles.has(normalizedTitle)) {
198
+ seenTitles.add(normalizedTitle);
199
+ uniqueRequirements.push(req);
200
+ }
201
+ }
202
+
203
+ return {
204
+ requirements: uniqueRequirements,
205
+ completed,
206
+ needInformation,
207
+ changelog,
208
+ verified
209
+ };
210
+ }
211
+
212
+ /**
213
+ * Load verified requirements from CHANGELOG.md
214
+ * @param {string} repoPath - Path to repository root
215
+ * @returns {Promise<Array>} Array of verified requirement titles
216
+ */
217
+ async function loadVerifiedFromChangelog(repoPath) {
218
+ try {
219
+ const changelogPath = path.join(repoPath, 'CHANGELOG.md');
220
+ if (!await fs.pathExists(changelogPath)) {
221
+ return [];
222
+ }
223
+
224
+ const content = await fs.readFile(changelogPath, 'utf8');
225
+ const lines = content.split('\n');
226
+ const requirements = [];
227
+ let inVerifiedSection = false;
228
+
229
+ for (const line of lines) {
230
+ const trimmed = line.trim();
231
+
232
+ // Check for Verified Requirements section
233
+ if (trimmed.includes('## Verified Requirements')) {
234
+ inVerifiedSection = true;
235
+ continue;
236
+ }
237
+
238
+ // Exit section if we hit another ## header
239
+ if (inVerifiedSection && trimmed.startsWith('##') && !trimmed.includes('Verified Requirements')) {
240
+ break;
241
+ }
242
+
243
+ // Only collect items from within the Verified Requirements section
244
+ if (inVerifiedSection && trimmed.startsWith('- ') && trimmed.length > 10) {
245
+ const title = trimmed.substring(2).trim();
246
+ // Extract date if present (format: "Title (2025-12-05)")
247
+ const dateMatch = title.match(/^(.+?)\s*\((\d{4}-\d{2}-\d{2})\)$/);
248
+ const cleanTitle = dateMatch ? dateMatch[1].trim() : title;
249
+ const date = dateMatch ? dateMatch[2] : null;
250
+
251
+ requirements.push({
252
+ title: cleanTitle,
253
+ description: cleanTitle,
254
+ date: date
255
+ });
256
+ }
257
+ }
258
+
259
+ return requirements;
260
+ } catch (error) {
261
+ // If CHANGELOG.md doesn't exist or can't be read, return empty array
262
+ return [];
263
+ }
264
+ }
265
+
266
+ /**
267
+ * Load and parse requirements from file
268
+ * @param {string} reqPath - Path to requirements file
269
+ * @param {string} repoPath - Optional path to repository root (for loading CHANGELOG.md)
270
+ * @returns {Promise<Object>} Parsed requirements
271
+ */
272
+ async function loadRequirementsFromFile(reqPath, repoPath = null) {
273
+ try {
274
+ const parsed = {
275
+ requirements: [],
276
+ completed: [],
277
+ needInformation: [],
278
+ changelog: [],
279
+ verified: []
280
+ };
281
+
282
+ if (await fs.pathExists(reqPath)) {
283
+ const content = await fs.readFile(reqPath, 'utf8');
284
+ const fileParsed = parseRequirementsFile(content);
285
+ Object.assign(parsed, fileParsed);
286
+ }
287
+
288
+ // Also load verified from CHANGELOG.md if repoPath is provided
289
+ if (repoPath) {
290
+ const verifiedFromChangelog = await loadVerifiedFromChangelog(repoPath);
291
+ // Merge with verified from requirements file (CHANGELOG.md takes precedence)
292
+ if (verifiedFromChangelog.length > 0) {
293
+ parsed.verified = verifiedFromChangelog;
294
+ }
295
+ }
296
+
297
+ return parsed;
298
+ } catch (error) {
299
+ throw new Error(`Failed to load requirements from file: ${error.message}`);
300
+ }
301
+ }
302
+
303
+ module.exports = {
304
+ parseRequirementsFile,
305
+ loadRequirementsFromFile,
306
+ loadVerifiedFromChangelog
307
+ };
308
+
309
+
310
+