jumpstart-mode 1.1.11 → 1.1.13

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 (188) hide show
  1. package/.github/agents/jumpstart-adversary.agent.md +2 -1
  2. package/.github/agents/jumpstart-architect.agent.md +6 -7
  3. package/.github/agents/jumpstart-challenger.agent.md +2 -1
  4. package/.github/agents/jumpstart-developer.agent.md +1 -1
  5. package/.github/agents/jumpstart-devops.agent.md +2 -2
  6. package/.github/agents/jumpstart-diagram-verifier.agent.md +2 -1
  7. package/.github/agents/jumpstart-maintenance.agent.md +1 -0
  8. package/.github/agents/jumpstart-performance.agent.md +1 -0
  9. package/.github/agents/jumpstart-pm.agent.md +1 -1
  10. package/.github/agents/jumpstart-refactor.agent.md +1 -0
  11. package/.github/agents/jumpstart-requirements-extractor.agent.md +1 -0
  12. package/.github/agents/jumpstart-researcher.agent.md +1 -0
  13. package/.github/agents/jumpstart-retrospective.agent.md +1 -0
  14. package/.github/agents/jumpstart-reviewer.agent.md +2 -0
  15. package/.github/agents/jumpstart-scout.agent.md +1 -1
  16. package/.github/agents/jumpstart-scrum-master.agent.md +1 -0
  17. package/.github/agents/jumpstart-security.agent.md +2 -1
  18. package/.github/agents/jumpstart-tech-writer.agent.md +1 -0
  19. package/.github/agents/jumpstart-uiux-designer.agent.md +66 -0
  20. package/.github/workflows/quality.yml +19 -2
  21. package/.jumpstart/agents/analyst.md +38 -0
  22. package/.jumpstart/agents/architect.md +39 -1
  23. package/.jumpstart/agents/challenger.md +38 -0
  24. package/.jumpstart/agents/developer.md +41 -0
  25. package/.jumpstart/agents/pm.md +38 -0
  26. package/.jumpstart/agents/scout.md +33 -0
  27. package/.jumpstart/agents/ux-designer.md +29 -9
  28. package/.jumpstart/commands/commands.md +6 -5
  29. package/.jumpstart/config.yaml +25 -1
  30. package/.jumpstart/roadmap.md +1 -1
  31. package/.jumpstart/schemas/timeline.schema.json +1 -0
  32. package/.jumpstart/skills/README.md +1 -0
  33. package/.jumpstart/skills/quality-gates/SKILL.md +126 -0
  34. package/.jumpstart/skills/skill-creator/SKILL.md +485 -357
  35. package/.jumpstart/skills/skill-creator/agents/analyzer.md +274 -0
  36. package/.jumpstart/skills/skill-creator/agents/comparator.md +202 -0
  37. package/.jumpstart/skills/skill-creator/agents/grader.md +223 -0
  38. package/.jumpstart/skills/skill-creator/assets/eval_review.html +146 -0
  39. package/.jumpstart/skills/skill-creator/eval-viewer/generate_review.py +471 -0
  40. package/.jumpstart/skills/skill-creator/eval-viewer/viewer.html +1325 -0
  41. package/.jumpstart/skills/skill-creator/references/schemas.md +430 -0
  42. package/.jumpstart/skills/skill-creator/scripts/__init__.py +0 -0
  43. package/.jumpstart/skills/skill-creator/scripts/aggregate_benchmark.py +401 -0
  44. package/.jumpstart/skills/skill-creator/scripts/generate_report.py +326 -0
  45. package/.jumpstart/skills/skill-creator/scripts/improve_description.py +247 -0
  46. package/.jumpstart/skills/skill-creator/scripts/package_skill.py +136 -110
  47. package/.jumpstart/skills/skill-creator/scripts/run_eval.py +310 -0
  48. package/.jumpstart/skills/skill-creator/scripts/run_loop.py +328 -0
  49. package/.jumpstart/skills/skill-creator/scripts/utils.py +47 -0
  50. package/.jumpstart/skills/ui-ux-pro-max/SKILL.md +266 -0
  51. package/.jumpstart/skills/ui-ux-pro-max/data/charts.csv +26 -0
  52. package/.jumpstart/skills/ui-ux-pro-max/data/colors.csv +97 -0
  53. package/.jumpstart/skills/ui-ux-pro-max/data/icons.csv +101 -0
  54. package/.jumpstart/skills/ui-ux-pro-max/data/landing.csv +31 -0
  55. package/.jumpstart/skills/ui-ux-pro-max/data/products.csv +97 -0
  56. package/.jumpstart/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
  57. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  58. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  59. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
  60. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  61. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
  62. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
  63. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
  64. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  65. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
  66. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
  67. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
  68. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  69. package/.jumpstart/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  70. package/.jumpstart/skills/ui-ux-pro-max/data/styles.csv +68 -0
  71. package/.jumpstart/skills/ui-ux-pro-max/data/typography.csv +58 -0
  72. package/.jumpstart/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
  73. package/.jumpstart/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
  74. package/.jumpstart/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
  75. package/.jumpstart/skills/ui-ux-pro-max/scripts/core.py +253 -0
  76. package/.jumpstart/skills/ui-ux-pro-max/scripts/design_system.py +1067 -0
  77. package/.jumpstart/skills/ui-ux-pro-max/scripts/search.py +114 -0
  78. package/.jumpstart/state/timeline.json +659 -0
  79. package/.jumpstart/templates/model-map.md +1 -1
  80. package/.jumpstart/templates/ux-design.md +3 -3
  81. package/.jumpstart/usage-log.json +74 -3
  82. package/AGENTS.md +1 -1
  83. package/README.md +64 -3
  84. package/bin/cli.js +3217 -1
  85. package/bin/headless-runner.js +62 -2
  86. package/bin/lib/agent-checkpoint.js +168 -0
  87. package/bin/lib/ai-evaluation.js +104 -0
  88. package/bin/lib/ai-intake.js +152 -0
  89. package/bin/lib/ambiguity-heatmap.js +152 -0
  90. package/bin/lib/artifact-comparison.js +104 -0
  91. package/bin/lib/ast-edit-engine.js +157 -0
  92. package/bin/lib/backlog-sync.js +338 -0
  93. package/bin/lib/bcdr-planning.js +158 -0
  94. package/bin/lib/bidirectional-trace.js +199 -0
  95. package/bin/lib/branch-workflow.js +266 -0
  96. package/bin/lib/cab-output.js +119 -0
  97. package/bin/lib/chat-integration.js +122 -0
  98. package/bin/lib/ci-cd-integration.js +208 -0
  99. package/bin/lib/codebase-retrieval.js +125 -0
  100. package/bin/lib/collaboration.js +168 -0
  101. package/bin/lib/compliance-packs.js +213 -0
  102. package/bin/lib/context-chunker.js +128 -0
  103. package/bin/lib/context-onboarding.js +122 -0
  104. package/bin/lib/contract-first.js +124 -0
  105. package/bin/lib/cost-router.js +148 -0
  106. package/bin/lib/credential-boundary.js +155 -0
  107. package/bin/lib/data-classification.js +180 -0
  108. package/bin/lib/data-contracts.js +129 -0
  109. package/bin/lib/db-evolution.js +158 -0
  110. package/bin/lib/decision-conflicts.js +299 -0
  111. package/bin/lib/delivery-confidence.js +361 -0
  112. package/bin/lib/dependency-upgrade.js +153 -0
  113. package/bin/lib/design-system.js +133 -0
  114. package/bin/lib/deterministic-artifacts.js +151 -0
  115. package/bin/lib/diagram-studio.js +115 -0
  116. package/bin/lib/domain-ontology.js +140 -0
  117. package/bin/lib/ea-review-packet.js +151 -0
  118. package/bin/lib/enterprise-search.js +123 -0
  119. package/bin/lib/enterprise-templates.js +140 -0
  120. package/bin/lib/environment-promotion.js +220 -0
  121. package/bin/lib/estimation-studio.js +130 -0
  122. package/bin/lib/event-modeling.js +133 -0
  123. package/bin/lib/evidence-collector.js +179 -0
  124. package/bin/lib/finops-planner.js +182 -0
  125. package/bin/lib/fitness-functions.js +279 -0
  126. package/bin/lib/focus.js +448 -0
  127. package/bin/lib/governance-dashboard.js +165 -0
  128. package/bin/lib/guided-handoff.js +120 -0
  129. package/bin/lib/impact-analysis.js +190 -0
  130. package/bin/lib/incident-feedback.js +157 -0
  131. package/bin/lib/integrate.js +1 -1
  132. package/bin/lib/knowledge-graph.js +122 -0
  133. package/bin/lib/legacy-modernizer.js +160 -0
  134. package/bin/lib/migration-planner.js +144 -0
  135. package/bin/lib/model-governance.js +185 -0
  136. package/bin/lib/model-router.js +144 -0
  137. package/bin/lib/multi-repo.js +272 -0
  138. package/bin/lib/next-phase.js +53 -8
  139. package/bin/lib/ops-ownership.js +152 -0
  140. package/bin/lib/parallel-agents.js +257 -0
  141. package/bin/lib/pattern-library.js +115 -0
  142. package/bin/lib/persona-packs.js +99 -0
  143. package/bin/lib/plan-executor.js +366 -0
  144. package/bin/lib/platform-engineering.js +119 -0
  145. package/bin/lib/playback-summaries.js +126 -0
  146. package/bin/lib/policy-engine.js +240 -0
  147. package/bin/lib/portfolio-reporting.js +357 -0
  148. package/bin/lib/pr-package.js +197 -0
  149. package/bin/lib/project-memory.js +235 -0
  150. package/bin/lib/prompt-governance.js +130 -0
  151. package/bin/lib/promptless-mode.js +128 -0
  152. package/bin/lib/quality-graph.js +193 -0
  153. package/bin/lib/raci-matrix.js +188 -0
  154. package/bin/lib/refactor-planner.js +167 -0
  155. package/bin/lib/reference-architectures.js +304 -0
  156. package/bin/lib/release-readiness.js +171 -0
  157. package/bin/lib/repo-graph.js +262 -0
  158. package/bin/lib/requirements-baseline.js +358 -0
  159. package/bin/lib/risk-register.js +211 -0
  160. package/bin/lib/role-approval.js +249 -0
  161. package/bin/lib/role-views.js +142 -0
  162. package/bin/lib/root-cause-analysis.js +132 -0
  163. package/bin/lib/runtime-debugger.js +154 -0
  164. package/bin/lib/safe-rename.js +135 -0
  165. package/bin/lib/secret-scanner.js +313 -0
  166. package/bin/lib/semantic-diff.js +335 -0
  167. package/bin/lib/sla-slo.js +210 -0
  168. package/bin/lib/smoke-tester.js +344 -0
  169. package/bin/lib/spec-comments.js +147 -0
  170. package/bin/lib/spec-maturity.js +287 -0
  171. package/bin/lib/sre-integration.js +154 -0
  172. package/bin/lib/structured-elicitation.js +174 -0
  173. package/bin/lib/telemetry-feedback.js +118 -0
  174. package/bin/lib/test-generator.js +146 -0
  175. package/bin/lib/timeline.js +2 -1
  176. package/bin/lib/tool-bridge.js +159 -0
  177. package/bin/lib/tool-guardrails.js +139 -0
  178. package/bin/lib/tool-schemas.js +281 -3
  179. package/bin/lib/transcript-ingestion.js +150 -0
  180. package/bin/lib/type-checker.js +261 -0
  181. package/bin/lib/uat-coverage.js +411 -0
  182. package/bin/lib/vendor-risk.js +173 -0
  183. package/bin/lib/waiver-workflow.js +174 -0
  184. package/bin/lib/web-dashboard.js +126 -0
  185. package/bin/lib/workshop-mode.js +165 -0
  186. package/bin/lib/workstream-ownership.js +104 -0
  187. package/package.json +1 -1
  188. package/.github/agents/jumpstart-ux-designer.agent.md +0 -45
@@ -0,0 +1,132 @@
1
+ /**
2
+ * root-cause-analysis.js — Root Cause Analysis Assistant (Item 59)
3
+ *
4
+ * Given failing tests or broken builds, generate ranked hypotheses
5
+ * and next actions.
6
+ *
7
+ * Usage:
8
+ * node bin/lib/root-cause-analysis.js analyze|report [options]
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ const FAILURE_PATTERNS = [
17
+ { pattern: /Cannot find module ['"]([^'"]+)['"]/g, category: 'missing-dependency', fix: 'Install or fix import path' },
18
+ { pattern: /SyntaxError:\s*(.+)/g, category: 'syntax-error', fix: 'Fix syntax at indicated location' },
19
+ { pattern: /TypeError:\s*(.+)\s+is not a function/g, category: 'type-error', fix: 'Check API usage and version compatibility' },
20
+ { pattern: /ENOENT.*['"]([^'"]+)['"]/g, category: 'missing-file', fix: 'Create missing file or fix path reference' },
21
+ { pattern: /AssertionError|AssertionError:\s*(.+)/g, category: 'test-assertion', fix: 'Update test or fix implementation' },
22
+ { pattern: /ReferenceError:\s*(\w+)\s+is not defined/g, category: 'reference-error', fix: 'Import or declare the missing variable' },
23
+ { pattern: /ECONNREFUSED/g, category: 'connection-error', fix: 'Ensure required services are running' },
24
+ { pattern: /out of memory|heap|OOM/gi, category: 'memory-error', fix: 'Optimize memory usage or increase limits' },
25
+ { pattern: /timeout|ETIMEDOUT/gi, category: 'timeout', fix: 'Increase timeout or optimize slow operations' },
26
+ { pattern: /permission denied|EACCES/gi, category: 'permission-error', fix: 'Check file permissions or user privileges' }
27
+ ];
28
+
29
+ /**
30
+ * Analyze failure output.
31
+ *
32
+ * @param {string} output - Build/test failure output.
33
+ * @param {object} [options]
34
+ * @returns {object}
35
+ */
36
+ function analyzeFailure(output, options = {}) {
37
+ if (!output) return { success: false, error: 'output is required' };
38
+
39
+ const hypotheses = [];
40
+ const seen = new Set();
41
+
42
+ for (const fp of FAILURE_PATTERNS) {
43
+ const regex = new RegExp(fp.pattern.source, fp.pattern.flags);
44
+ let match;
45
+ while ((match = regex.exec(output)) !== null) {
46
+ const key = `${fp.category}:${(match[1] || '').substring(0, 50)}`;
47
+ if (seen.has(key)) continue;
48
+ seen.add(key);
49
+
50
+ const lineNum = output.substring(0, match.index).split('\n').length;
51
+ hypotheses.push({
52
+ category: fp.category,
53
+ detail: match[1] || match[0].trim(),
54
+ line: lineNum,
55
+ suggested_fix: fp.fix,
56
+ confidence: 'high',
57
+ context: output.split('\n').slice(Math.max(0, lineNum - 3), lineNum + 2).join('\n')
58
+ });
59
+ }
60
+ }
61
+
62
+ // Sort by confidence and category severity
63
+ const severity = { 'syntax-error': 1, 'missing-dependency': 2, 'reference-error': 3, 'type-error': 4, 'missing-file': 5, 'test-assertion': 6 };
64
+ hypotheses.sort((a, b) => (severity[a.category] || 99) - (severity[b.category] || 99));
65
+
66
+ return {
67
+ success: true,
68
+ total_hypotheses: hypotheses.length,
69
+ hypotheses,
70
+ primary_cause: hypotheses[0] || null,
71
+ categories: [...new Set(hypotheses.map(h => h.category))],
72
+ recommended_actions: hypotheses.slice(0, 3).map(h => ({
73
+ action: h.suggested_fix,
74
+ detail: h.detail,
75
+ category: h.category
76
+ }))
77
+ };
78
+ }
79
+
80
+ /**
81
+ * Analyze a test result file.
82
+ *
83
+ * @param {string} filePath - Path to test output file.
84
+ * @param {object} [options]
85
+ * @returns {object}
86
+ */
87
+ function analyzeTestFile(filePath, options = {}) {
88
+ if (!fs.existsSync(filePath)) {
89
+ return { success: false, error: `File not found: ${filePath}` };
90
+ }
91
+
92
+ const content = fs.readFileSync(filePath, 'utf8');
93
+ const result = analyzeFailure(content, options);
94
+ result.file = filePath;
95
+ return result;
96
+ }
97
+
98
+ /**
99
+ * Generate root cause report.
100
+ *
101
+ * @param {object} analysis
102
+ * @returns {object}
103
+ */
104
+ function generateReport(analysis) {
105
+ if (!analysis || !analysis.hypotheses) {
106
+ return { success: false, error: 'Invalid analysis result' };
107
+ }
108
+
109
+ const byCategory = analysis.hypotheses.reduce((acc, h) => {
110
+ acc[h.category] = (acc[h.category] || 0) + 1;
111
+ return acc;
112
+ }, {});
113
+
114
+ return {
115
+ success: true,
116
+ summary: {
117
+ total_issues: analysis.total_hypotheses,
118
+ primary_cause: analysis.primary_cause ? analysis.primary_cause.category : 'unknown',
119
+ categories: Object.keys(byCategory).length
120
+ },
121
+ by_category: byCategory,
122
+ action_plan: analysis.recommended_actions,
123
+ hypotheses: analysis.hypotheses
124
+ };
125
+ }
126
+
127
+ module.exports = {
128
+ analyzeFailure,
129
+ analyzeTestFile,
130
+ generateReport,
131
+ FAILURE_PATTERNS
132
+ };
@@ -0,0 +1,154 @@
1
+ /**
2
+ * runtime-debugger.js — Runtime-Aware Debugging Mode (Item 46)
3
+ *
4
+ * Consume logs, traces, exceptions, and metrics to guide fixes.
5
+ *
6
+ * Usage:
7
+ * node bin/lib/runtime-debugger.js analyze|correlate|report [options]
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const fs = require('fs');
13
+ const path = require('path');
14
+
15
+ const LOG_PATTERNS = {
16
+ error: /\b(?:ERROR|FATAL|CRITICAL)\b/i,
17
+ warning: /\b(?:WARN(?:ING)?)\b/i,
18
+ exception: /(?:Error|Exception|Traceback|at\s+\S+\s+\()/,
19
+ stack_trace: /^\s+at\s+/m,
20
+ timeout: /\b(?:timeout|timed?\s*out|ETIMEDOUT)\b/i,
21
+ oom: /\b(?:out\s*of\s*memory|heap|OOM|ENOMEM)\b/i,
22
+ connection: /\b(?:ECONNREFUSED|ECONNRESET|connection\s+refused)\b/i
23
+ };
24
+
25
+ /**
26
+ * Analyze log content for patterns.
27
+ *
28
+ * @param {string} logContent - Raw log text.
29
+ * @param {object} [options]
30
+ * @returns {object}
31
+ */
32
+ function analyzeLogs(logContent, options = {}) {
33
+ const lines = logContent.split('\n');
34
+ const findings = [];
35
+
36
+ for (let i = 0; i < lines.length; i++) {
37
+ const line = lines[i];
38
+ for (const [type, pattern] of Object.entries(LOG_PATTERNS)) {
39
+ if (pattern.test(line)) {
40
+ findings.push({
41
+ type,
42
+ line: i + 1,
43
+ content: line.trim().substring(0, 200),
44
+ severity: type === 'error' || type === 'exception' ? 'high' : 'medium'
45
+ });
46
+ break;
47
+ }
48
+ }
49
+ }
50
+
51
+ const summary = {
52
+ total_lines: lines.length,
53
+ errors: findings.filter(f => f.type === 'error').length,
54
+ warnings: findings.filter(f => f.type === 'warning').length,
55
+ exceptions: findings.filter(f => f.type === 'exception').length,
56
+ timeouts: findings.filter(f => f.type === 'timeout').length,
57
+ oom: findings.filter(f => f.type === 'oom').length,
58
+ connection_issues: findings.filter(f => f.type === 'connection').length
59
+ };
60
+
61
+ return { success: true, findings, summary, total_findings: findings.length };
62
+ }
63
+
64
+ /**
65
+ * Analyze a log file.
66
+ *
67
+ * @param {string} filePath - Path to log file.
68
+ * @param {object} [options]
69
+ * @returns {object}
70
+ */
71
+ function analyzeLogFile(filePath, options = {}) {
72
+ if (!fs.existsSync(filePath)) {
73
+ return { success: false, error: `Log file not found: ${filePath}` };
74
+ }
75
+
76
+ const content = fs.readFileSync(filePath, 'utf8');
77
+ const result = analyzeLogs(content, options);
78
+ result.file = filePath;
79
+ return result;
80
+ }
81
+
82
+ /**
83
+ * Correlate errors with source files.
84
+ *
85
+ * @param {object[]} findings - Error findings from log analysis.
86
+ * @param {string} root - Project root.
87
+ * @returns {object}
88
+ */
89
+ function correlateWithSource(findings, root) {
90
+ const correlations = [];
91
+
92
+ for (const finding of findings) {
93
+ // Extract file references from error messages
94
+ const fileMatch = finding.content.match(/(?:at\s+)?(\S+\.(?:js|ts|py)):(\d+)/);
95
+ if (fileMatch) {
96
+ const [, file, line] = fileMatch;
97
+ const absPath = path.join(root, file);
98
+ const exists = fs.existsSync(absPath);
99
+
100
+ correlations.push({
101
+ error: finding.content.substring(0, 100),
102
+ source_file: file,
103
+ source_line: parseInt(line),
104
+ file_exists: exists,
105
+ severity: finding.severity
106
+ });
107
+ }
108
+ }
109
+
110
+ return {
111
+ success: true,
112
+ correlations,
113
+ total: correlations.length,
114
+ actionable: correlations.filter(c => c.file_exists).length
115
+ };
116
+ }
117
+
118
+ /**
119
+ * Generate debugging report with hypotheses.
120
+ *
121
+ * @param {object} analysis - Log analysis result.
122
+ * @returns {object}
123
+ */
124
+ function generateHypotheses(analysis) {
125
+ const hypotheses = [];
126
+
127
+ if (analysis.summary.oom > 0) {
128
+ hypotheses.push({ hypothesis: 'Memory leak or insufficient heap allocation', confidence: 'high', action: 'Check for unbounded data structures or increase memory limits' });
129
+ }
130
+ if (analysis.summary.timeouts > 0) {
131
+ hypotheses.push({ hypothesis: 'Network connectivity or slow dependency', confidence: 'medium', action: 'Check network configuration, increase timeouts, or add retries' });
132
+ }
133
+ if (analysis.summary.connection_issues > 0) {
134
+ hypotheses.push({ hypothesis: 'Service dependency unavailable', confidence: 'high', action: 'Verify dependent services are running and network rules allow connection' });
135
+ }
136
+ if (analysis.summary.exceptions > 0) {
137
+ hypotheses.push({ hypothesis: 'Unhandled exception in application code', confidence: 'high', action: 'Review stack traces and add error handling' });
138
+ }
139
+
140
+ return {
141
+ success: true,
142
+ hypotheses,
143
+ total: hypotheses.length,
144
+ summary: analysis.summary
145
+ };
146
+ }
147
+
148
+ module.exports = {
149
+ analyzeLogs,
150
+ analyzeLogFile,
151
+ correlateWithSource,
152
+ generateHypotheses,
153
+ LOG_PATTERNS
154
+ };
@@ -0,0 +1,135 @@
1
+ /**
2
+ * safe-rename.js — Safe Large-Scale Rename & Move Engine (Item 50)
3
+ *
4
+ * Preserve imports, references, tests, docs, and architecture
5
+ * mappings during broad changes.
6
+ *
7
+ * Usage:
8
+ * node bin/lib/safe-rename.js plan|execute|validate [options]
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const fs = require('fs');
14
+ const path = require('path');
15
+
16
+ const REFERENCE_PATTERNS = [
17
+ { type: 'import', pattern: /(?:import\s+.*from\s+['"]|require\(['"])(\.{0,2}\/[^'"]+)['"]/g },
18
+ { type: 'markdown-link', pattern: /\[([^\]]*)\]\(([^)]+)\)/g },
19
+ { type: 'config-path', pattern: /"(?:path|file|dir|src|entry)":\s*"([^"]+)"/g }
20
+ ];
21
+
22
+ /**
23
+ * Plan a rename/move operation.
24
+ *
25
+ * @param {string} root - Project root.
26
+ * @param {string} oldPath - Current path (relative to root).
27
+ * @param {string} newPath - Target path (relative to root).
28
+ * @param {object} [options]
29
+ * @returns {object}
30
+ */
31
+ function planRename(root, oldPath, newPath, options = {}) {
32
+ if (!oldPath || !newPath) return { success: false, error: 'oldPath and newPath are required' };
33
+
34
+ const absOld = path.join(root, oldPath);
35
+ if (!fs.existsSync(absOld)) {
36
+ return { success: false, error: `Source not found: ${oldPath}` };
37
+ }
38
+
39
+ const references = findReferences(root, oldPath, options);
40
+
41
+ return {
42
+ success: true,
43
+ old_path: oldPath,
44
+ new_path: newPath,
45
+ references_found: references.length,
46
+ affected_files: [...new Set(references.map(r => r.file))],
47
+ references,
48
+ safe: true,
49
+ warnings: references.length > 10 ? ['Large number of references — review carefully'] : []
50
+ };
51
+ }
52
+
53
+ /**
54
+ * Find all references to a file path in the project.
55
+ *
56
+ * @param {string} root - Project root.
57
+ * @param {string} targetPath - Path to search for.
58
+ * @param {object} [options]
59
+ * @returns {object[]}
60
+ */
61
+ function findReferences(root, targetPath, options = {}) {
62
+ const excludeDirs = options.excludeDirs || ['node_modules', '.git', 'dist', 'build'];
63
+ const references = [];
64
+ const searchTerms = [
65
+ targetPath,
66
+ targetPath.replace(/\\/g, '/'),
67
+ path.basename(targetPath, path.extname(targetPath))
68
+ ];
69
+
70
+ function walk(dir) {
71
+ if (!fs.existsSync(dir)) return;
72
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
73
+ if (entry.isDirectory()) {
74
+ if (!excludeDirs.includes(entry.name)) walk(path.join(dir, entry.name));
75
+ } else if (entry.isFile()) {
76
+ const ext = path.extname(entry.name).toLowerCase();
77
+ if (['.js', '.ts', '.md', '.json', '.yaml', '.yml'].includes(ext)) {
78
+ try {
79
+ const content = fs.readFileSync(path.join(dir, entry.name), 'utf8');
80
+ const relFile = path.relative(root, path.join(dir, entry.name)).replace(/\\/g, '/');
81
+
82
+ for (const term of searchTerms) {
83
+ if (content.includes(term)) {
84
+ const lines = content.split('\n');
85
+ for (let i = 0; i < lines.length; i++) {
86
+ if (lines[i].includes(term)) {
87
+ references.push({
88
+ file: relFile,
89
+ line: i + 1,
90
+ content: lines[i].trim().substring(0, 150),
91
+ match: term
92
+ });
93
+ }
94
+ }
95
+ }
96
+ }
97
+ } catch { /* skip */ }
98
+ }
99
+ }
100
+ }
101
+ }
102
+
103
+ walk(root);
104
+ return references;
105
+ }
106
+
107
+ /**
108
+ * Validate that a rename was applied correctly.
109
+ *
110
+ * @param {string} root - Project root.
111
+ * @param {string} oldPath - Original path.
112
+ * @param {string} newPath - New path.
113
+ * @returns {object}
114
+ */
115
+ function validateRename(root, oldPath, newPath) {
116
+ const newExists = fs.existsSync(path.join(root, newPath));
117
+ const oldExists = fs.existsSync(path.join(root, oldPath));
118
+ const staleRefs = findReferences(root, oldPath);
119
+
120
+ return {
121
+ success: true,
122
+ new_file_exists: newExists,
123
+ old_file_removed: !oldExists,
124
+ stale_references: staleRefs.length,
125
+ stale_files: [...new Set(staleRefs.map(r => r.file))],
126
+ clean: newExists && !oldExists && staleRefs.length === 0
127
+ };
128
+ }
129
+
130
+ module.exports = {
131
+ planRename,
132
+ findReferences,
133
+ validateRename,
134
+ REFERENCE_PATTERNS
135
+ };