universal-dev-standards 6.15.0 → 6.16.0-beta.2

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 (41) hide show
  1. package/bin/uds.js +2 -0
  2. package/bundled/locales/zh-CN/CHANGELOG.md +34 -4
  3. package/bundled/locales/zh-CN/CLAUDE.md +2 -2
  4. package/bundled/locales/zh-CN/README.md +17 -14
  5. package/bundled/locales/zh-CN/SECURITY.md +1 -0
  6. package/bundled/locales/zh-CN/docs/CHEATSHEET.md +1 -1
  7. package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +24 -2
  8. package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +3 -1
  9. package/bundled/locales/zh-TW/CHANGELOG.md +34 -4
  10. package/bundled/locales/zh-TW/CLAUDE.md +2 -2
  11. package/bundled/locales/zh-TW/README.md +17 -14
  12. package/bundled/locales/zh-TW/SECURITY.md +1 -0
  13. package/bundled/locales/zh-TW/docs/CHEATSHEET.md +1 -1
  14. package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +24 -2
  15. package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +3 -1
  16. package/package.json +3 -3
  17. package/src/commands/skills.js +9 -0
  18. package/src/commands/update.js +223 -2
  19. package/src/reconciler/desired-state-calculator.js +11 -2
  20. package/src/utils/optional-skills-report.js +86 -0
  21. package/src/utils/optional-skills.js +20 -0
  22. package/src/utils/skill-selection.js +137 -0
  23. package/src/utils/skills-installer.js +11 -4
  24. package/standards-registry.json +7 -7
  25. package/src/core/agent-communication-protocol.js +0 -257
  26. package/src/flow/condition-evaluator.js +0 -86
  27. package/src/flow/flow-bundler.js +0 -80
  28. package/src/flow/flow-commands.js +0 -107
  29. package/src/flow/flow-engine.js +0 -154
  30. package/src/flow/flow-inheritance.js +0 -100
  31. package/src/flow/flow-parser.js +0 -104
  32. package/src/flow/flow-validator.js +0 -37
  33. package/src/flow/gate-checker.js +0 -82
  34. package/src/flow/gate-loader.js +0 -52
  35. package/src/missions/MissionManager.js +0 -533
  36. package/src/utils/e2e-analyzer.js +0 -471
  37. package/src/utils/e2e-detector.js +0 -132
  38. package/src/utils/hook-stats.js +0 -151
  39. package/src/utils/workflow-executor.js +0 -870
  40. package/src/utils/workflows-installer.js +0 -545
  41. package/src/vibe/auto-sweep.js +0 -349
@@ -1,349 +0,0 @@
1
- /**
2
- * Auto-Sweep Module for Vibe Coding Integration
3
- *
4
- * Applies refactoring standards automatically to clean up code
5
- * after vibe coding sessions. Integrates with HITL for safety.
6
- *
7
- * @module vibe/auto-sweep
8
- * @see docs/specs/system/vibe-coding-integration.md (AC-2)
9
- */
10
-
11
- // Note: execSync is used here with hardcoded git commands only (no user input).
12
- // This is safe from command injection as the commands are fully controlled.
13
- import { execSync } from 'node:child_process';
14
- import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'node:fs';
15
- import { join, extname } from 'node:path';
16
- import { hitl } from '../hitl/manager.js';
17
- import { config } from '../utils/config-manager.js';
18
-
19
- /**
20
- * Sweep action types with their risk levels
21
- */
22
- export const SweepActions = {
23
- REMOVE_CONSOLE_LOG: {
24
- id: 'remove-console-log',
25
- name: 'Remove console.log statements',
26
- risk: 1, // Standard - modifies code
27
- pattern: /console\.(log|debug|info|warn|error)\s*\([^)]*\);?\s*\n?/g
28
- },
29
- REMOVE_DEBUGGER: {
30
- id: 'remove-debugger',
31
- name: 'Remove debugger statements',
32
- risk: 1,
33
- pattern: /debugger\s*;?\s*\n?/g
34
- },
35
- FLAG_TODO_FIXME: {
36
- id: 'flag-todo-fixme',
37
- name: 'Flag TODO/FIXME comments',
38
- risk: 0, // Routine - read-only detection
39
- pattern: /\/\/\s*(TODO|FIXME|XXX|HACK):?\s*.*/gi
40
- },
41
- FLAG_DEAD_CODE: {
42
- id: 'flag-dead-code',
43
- name: 'Flag potential dead code',
44
- risk: 0, // Detection only
45
- patterns: {
46
- unusedVariables: /^\s*(?:const|let|var)\s+(\w+)\s*=(?:(?!.*\1).)*$/gm,
47
- unreachableReturn: /return\s+[^;]+;\s*\n\s*[^}]/g
48
- }
49
- },
50
- SUGGEST_TYPES: {
51
- id: 'suggest-types',
52
- name: 'Suggest TypeScript type annotations',
53
- risk: 0, // Suggestion only
54
- applicable: ['.ts', '.tsx']
55
- }
56
- };
57
-
58
- /**
59
- * AutoSweep class for code cleanup operations
60
- */
61
- export class AutoSweep {
62
- constructor(options = {}) {
63
- this.cwd = options.cwd || process.cwd();
64
- this.dryRun = options.dryRun ?? true;
65
- this.verbose = options.verbose ?? false;
66
- this.config = config.get('vibe-coding.auto-sweep', {
67
- enabled: true,
68
- actions: ['remove-console-logs', 'flag-dead-code', 'suggest-types']
69
- });
70
- }
71
-
72
- /**
73
- * Get changed files from git
74
- * @returns {string[]} Array of changed file paths
75
- */
76
- getChangedFiles() {
77
- try {
78
- // Hardcoded git commands - safe from injection
79
- const staged = execSync('git diff --cached --name-only', {
80
- cwd: this.cwd,
81
- encoding: 'utf-8'
82
- }).trim();
83
-
84
- const unstaged = execSync('git diff --name-only', {
85
- cwd: this.cwd,
86
- encoding: 'utf-8'
87
- }).trim();
88
-
89
- const files = new Set([
90
- ...staged.split('\n').filter(Boolean),
91
- ...unstaged.split('\n').filter(Boolean)
92
- ]);
93
-
94
- // Filter to only code files
95
- const codeExtensions = ['.js', '.jsx', '.ts', '.tsx', '.mjs', '.cjs', '.vue', '.svelte'];
96
- return [...files].filter(f => codeExtensions.includes(extname(f)));
97
- } catch {
98
- return [];
99
- }
100
- }
101
-
102
- /**
103
- * Scan a file for issues
104
- * @param {string} filePath - Path to the file
105
- * @returns {Object} Scan results with issues found
106
- */
107
- scanFile(filePath) {
108
- const fullPath = join(this.cwd, filePath);
109
- if (!existsSync(fullPath)) {
110
- return { file: filePath, issues: [], error: 'File not found' };
111
- }
112
-
113
- const content = readFileSync(fullPath, 'utf-8');
114
- const ext = extname(filePath);
115
- const issues = [];
116
-
117
- // Check for console statements
118
- const consoleMatches = content.match(SweepActions.REMOVE_CONSOLE_LOG.pattern);
119
- if (consoleMatches) {
120
- issues.push({
121
- type: 'console-log',
122
- action: SweepActions.REMOVE_CONSOLE_LOG,
123
- count: consoleMatches.length,
124
- fixable: true,
125
- matches: consoleMatches.map(m => m.trim().substring(0, 50))
126
- });
127
- }
128
-
129
- // Check for debugger statements
130
- const debuggerMatches = content.match(SweepActions.REMOVE_DEBUGGER.pattern);
131
- if (debuggerMatches) {
132
- issues.push({
133
- type: 'debugger',
134
- action: SweepActions.REMOVE_DEBUGGER,
135
- count: debuggerMatches.length,
136
- fixable: true
137
- });
138
- }
139
-
140
- // Check for TODO/FIXME comments
141
- const todoMatches = content.match(SweepActions.FLAG_TODO_FIXME.pattern);
142
- if (todoMatches) {
143
- issues.push({
144
- type: 'todo-comments',
145
- action: SweepActions.FLAG_TODO_FIXME,
146
- count: todoMatches.length,
147
- fixable: false,
148
- matches: todoMatches.map(m => m.trim())
149
- });
150
- }
151
-
152
- // TypeScript type suggestions (for .ts/.tsx files without explicit types)
153
- if (SweepActions.SUGGEST_TYPES.applicable.includes(ext)) {
154
- const anyTypeMatches = content.match(/:\s*any\b/g);
155
- if (anyTypeMatches) {
156
- issues.push({
157
- type: 'any-types',
158
- action: SweepActions.SUGGEST_TYPES,
159
- count: anyTypeMatches.length,
160
- fixable: false,
161
- suggestion: 'Consider replacing `any` with specific types'
162
- });
163
- }
164
- }
165
-
166
- return { file: filePath, issues, content };
167
- }
168
-
169
- /**
170
- * Apply fixes to a file
171
- * @param {string} filePath - Path to the file
172
- * @param {Object[]} issues - Issues to fix
173
- * @returns {Promise<Object>} Result of fix operation
174
- */
175
- async applyFixes(filePath, issues) {
176
- const fullPath = join(this.cwd, filePath);
177
- let content = readFileSync(fullPath, 'utf-8');
178
- const fixableIssues = issues.filter(i => i.fixable);
179
-
180
- if (fixableIssues.length === 0) {
181
- return { file: filePath, fixed: 0, skipped: issues.length };
182
- }
183
-
184
- // HITL check for code modification
185
- const operation = `Modify file: ${filePath} (remove ${fixableIssues.length} debug statements)`;
186
- const allowed = await hitl.enforce(operation, {
187
- reason: 'Auto-sweep cleanup',
188
- issues: fixableIssues.map(i => `${i.type}: ${i.count} occurrences`)
189
- });
190
-
191
- if (!allowed) {
192
- return { file: filePath, fixed: 0, blocked: true };
193
- }
194
-
195
- let fixCount = 0;
196
-
197
- // Apply fixes
198
- for (const issue of fixableIssues) {
199
- if (issue.type === 'console-log') {
200
- content = content.replace(SweepActions.REMOVE_CONSOLE_LOG.pattern, '');
201
- fixCount += issue.count;
202
- }
203
- if (issue.type === 'debugger') {
204
- content = content.replace(SweepActions.REMOVE_DEBUGGER.pattern, '');
205
- fixCount += issue.count;
206
- }
207
- }
208
-
209
- if (!this.dryRun) {
210
- writeFileSync(fullPath, content, 'utf-8');
211
- }
212
-
213
- return { file: filePath, fixed: fixCount, dryRun: this.dryRun };
214
- }
215
-
216
- /**
217
- * Run sweep on all changed files
218
- * @returns {Promise<Object>} Sweep results
219
- */
220
- async sweep() {
221
- const files = this.getChangedFiles();
222
- const results = {
223
- timestamp: new Date().toISOString(),
224
- filesScanned: files.length,
225
- totalIssues: 0,
226
- totalFixed: 0,
227
- files: [],
228
- summary: {
229
- consoleLogs: 0,
230
- debuggers: 0,
231
- todoComments: 0,
232
- anyTypes: 0
233
- }
234
- };
235
-
236
- if (files.length === 0) {
237
- results.message = 'No changed files to sweep';
238
- return results;
239
- }
240
-
241
- for (const file of files) {
242
- const scanResult = this.scanFile(file);
243
-
244
- if (scanResult.issues.length > 0) {
245
- results.totalIssues += scanResult.issues.reduce((sum, i) => sum + i.count, 0);
246
-
247
- // Update summary counts
248
- for (const issue of scanResult.issues) {
249
- if (issue.type === 'console-log') results.summary.consoleLogs += issue.count;
250
- if (issue.type === 'debugger') results.summary.debuggers += issue.count;
251
- if (issue.type === 'todo-comments') results.summary.todoComments += issue.count;
252
- if (issue.type === 'any-types') results.summary.anyTypes += issue.count;
253
- }
254
-
255
- // Apply fixes if not dry-run
256
- if (!this.dryRun) {
257
- const fixResult = await this.applyFixes(file, scanResult.issues);
258
- results.totalFixed += fixResult.fixed || 0;
259
- scanResult.fixResult = fixResult;
260
- }
261
-
262
- results.files.push(scanResult);
263
- }
264
- }
265
-
266
- return results;
267
- }
268
-
269
- /**
270
- * Generate markdown report
271
- * @param {Object} results - Sweep results
272
- * @returns {string} Markdown report
273
- */
274
- generateReport(results) {
275
- const lines = [
276
- '# Auto-Sweep Report',
277
- '',
278
- `**Generated**: ${results.timestamp}`,
279
- `**Mode**: ${this.dryRun ? 'Dry Run (Preview)' : 'Applied'}`,
280
- '',
281
- '## Summary',
282
- '',
283
- '| Metric | Count |',
284
- '|--------|-------|',
285
- `| Files Scanned | ${results.filesScanned} |`,
286
- `| Total Issues | ${results.totalIssues} |`,
287
- `| Fixed | ${results.totalFixed} |`,
288
- '',
289
- '## Issues by Type',
290
- '',
291
- '| Type | Count |',
292
- '|------|-------|',
293
- `| Console Logs | ${results.summary.consoleLogs} |`,
294
- `| Debugger Statements | ${results.summary.debuggers} |`,
295
- `| TODO/FIXME Comments | ${results.summary.todoComments} |`,
296
- `| TypeScript \`any\` Types | ${results.summary.anyTypes} |`,
297
- ''
298
- ];
299
-
300
- if (results.files.length > 0) {
301
- lines.push('## Details by File', '');
302
-
303
- for (const file of results.files) {
304
- lines.push(`### \`${file.file}\``, '');
305
-
306
- for (const issue of file.issues) {
307
- const status = issue.fixable
308
- ? (this.dryRun ? '[ ] Fixable' : '[x] Fixed')
309
- : '[-] Info only';
310
- lines.push(`- ${status}: ${issue.action.name} (${issue.count})`);
311
-
312
- if (issue.matches && this.verbose) {
313
- for (const match of issue.matches.slice(0, 3)) {
314
- lines.push(` - \`${match}\``);
315
- }
316
- if (issue.matches.length > 3) {
317
- lines.push(` - ... and ${issue.matches.length - 3} more`);
318
- }
319
- }
320
- }
321
- lines.push('');
322
- }
323
- }
324
-
325
- return lines.join('\n');
326
- }
327
-
328
- /**
329
- * Save report to .uds/reports/
330
- * @param {string} report - Report content
331
- * @returns {string} Path to saved report
332
- */
333
- saveReport(report) {
334
- const reportsDir = join(this.cwd, '.uds', 'reports');
335
- if (!existsSync(reportsDir)) {
336
- mkdirSync(reportsDir, { recursive: true });
337
- }
338
-
339
- const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
340
- const filename = `sweep-${timestamp}.md`;
341
- const filepath = join(reportsDir, filename);
342
-
343
- writeFileSync(filepath, report, 'utf-8');
344
- return filepath;
345
- }
346
- }
347
-
348
- // Export singleton instance for simple usage
349
- export const autoSweep = new AutoSweep();