pikakit 3.0.5 → 3.7.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 (100) hide show
  1. package/README.md +1 -1
  2. package/bin/lib/commands/install.js +119 -242
  3. package/package.json +3 -4
  4. package/lib/agent-cli/bin/agent.js +0 -187
  5. package/lib/agent-cli/dashboard/dashboard_server.js +0 -312
  6. package/lib/agent-cli/lib/ab-testing.js +0 -364
  7. package/lib/agent-cli/lib/audit.js +0 -154
  8. package/lib/agent-cli/lib/audit.test.js +0 -100
  9. package/lib/agent-cli/lib/auto-learn.js +0 -319
  10. package/lib/agent-cli/lib/backup.js +0 -138
  11. package/lib/agent-cli/lib/backup.test.js +0 -78
  12. package/lib/agent-cli/lib/causality-engine.js +0 -331
  13. package/lib/agent-cli/lib/cognitive-lesson.js +0 -476
  14. package/lib/agent-cli/lib/completion.js +0 -149
  15. package/lib/agent-cli/lib/config.js +0 -35
  16. package/lib/agent-cli/lib/dashboard-data.js +0 -380
  17. package/lib/agent-cli/lib/eslint-fix.js +0 -238
  18. package/lib/agent-cli/lib/evolution-signal.js +0 -215
  19. package/lib/agent-cli/lib/export.js +0 -86
  20. package/lib/agent-cli/lib/export.test.js +0 -65
  21. package/lib/agent-cli/lib/fix.js +0 -337
  22. package/lib/agent-cli/lib/fix.test.js +0 -80
  23. package/lib/agent-cli/lib/gemini-export.js +0 -83
  24. package/lib/agent-cli/lib/generate-registry.js +0 -42
  25. package/lib/agent-cli/lib/hooks/install-hooks.js +0 -152
  26. package/lib/agent-cli/lib/hooks/lint-learn.js +0 -172
  27. package/lib/agent-cli/lib/icons.js +0 -93
  28. package/lib/agent-cli/lib/ignore.js +0 -116
  29. package/lib/agent-cli/lib/ignore.test.js +0 -58
  30. package/lib/agent-cli/lib/init.js +0 -124
  31. package/lib/agent-cli/lib/knowledge-index.js +0 -326
  32. package/lib/agent-cli/lib/knowledge-metrics.js +0 -335
  33. package/lib/agent-cli/lib/knowledge-retention.js +0 -398
  34. package/lib/agent-cli/lib/knowledge-validator.js +0 -312
  35. package/lib/agent-cli/lib/learn.js +0 -255
  36. package/lib/agent-cli/lib/learn.test.js +0 -70
  37. package/lib/agent-cli/lib/metrics-collector.js +0 -410
  38. package/lib/agent-cli/lib/proposals.js +0 -199
  39. package/lib/agent-cli/lib/proposals.test.js +0 -56
  40. package/lib/agent-cli/lib/recall.js +0 -835
  41. package/lib/agent-cli/lib/recall.test.js +0 -107
  42. package/lib/agent-cli/lib/reinforcement.js +0 -299
  43. package/lib/agent-cli/lib/selfevolution-bridge.js +0 -167
  44. package/lib/agent-cli/lib/settings.js +0 -203
  45. package/lib/agent-cli/lib/skill-generator.js +0 -379
  46. package/lib/agent-cli/lib/skill-learn.js +0 -296
  47. package/lib/agent-cli/lib/stats.js +0 -132
  48. package/lib/agent-cli/lib/stats.test.js +0 -94
  49. package/lib/agent-cli/lib/types.js +0 -33
  50. package/lib/agent-cli/lib/ui/audit-ui.js +0 -146
  51. package/lib/agent-cli/lib/ui/backup-ui.js +0 -107
  52. package/lib/agent-cli/lib/ui/clack-helpers.js +0 -317
  53. package/lib/agent-cli/lib/ui/common.js +0 -83
  54. package/lib/agent-cli/lib/ui/completion-ui.js +0 -126
  55. package/lib/agent-cli/lib/ui/custom-select.js +0 -69
  56. package/lib/agent-cli/lib/ui/dashboard-ui.js +0 -222
  57. package/lib/agent-cli/lib/ui/evolution-signals-ui.js +0 -107
  58. package/lib/agent-cli/lib/ui/export-ui.js +0 -94
  59. package/lib/agent-cli/lib/ui/fix-all-ui.js +0 -191
  60. package/lib/agent-cli/lib/ui/help-ui.js +0 -49
  61. package/lib/agent-cli/lib/ui/index.js +0 -199
  62. package/lib/agent-cli/lib/ui/init-ui.js +0 -56
  63. package/lib/agent-cli/lib/ui/knowledge-ui.js +0 -55
  64. package/lib/agent-cli/lib/ui/learn-ui.js +0 -706
  65. package/lib/agent-cli/lib/ui/lessons-ui.js +0 -148
  66. package/lib/agent-cli/lib/ui/pretty.js +0 -145
  67. package/lib/agent-cli/lib/ui/proposals-ui.js +0 -99
  68. package/lib/agent-cli/lib/ui/recall-ui.js +0 -342
  69. package/lib/agent-cli/lib/ui/routing-demo.js +0 -79
  70. package/lib/agent-cli/lib/ui/routing-ui.js +0 -325
  71. package/lib/agent-cli/lib/ui/settings-ui.js +0 -381
  72. package/lib/agent-cli/lib/ui/stats-ui.js +0 -123
  73. package/lib/agent-cli/lib/ui/watch-ui.js +0 -236
  74. package/lib/agent-cli/lib/watcher.js +0 -181
  75. package/lib/agent-cli/lib/watcher.test.js +0 -85
  76. package/lib/agent-cli/src/MIGRATION.md +0 -418
  77. package/lib/agent-cli/src/README.md +0 -367
  78. package/lib/agent-cli/src/core/evolution/evolution-signal.js +0 -42
  79. package/lib/agent-cli/src/core/evolution/index.js +0 -17
  80. package/lib/agent-cli/src/core/evolution/review-gate.js +0 -40
  81. package/lib/agent-cli/src/core/evolution/signal-detector.js +0 -137
  82. package/lib/agent-cli/src/core/evolution/signal-queue.js +0 -79
  83. package/lib/agent-cli/src/core/evolution/threshold-checker.js +0 -79
  84. package/lib/agent-cli/src/core/index.js +0 -15
  85. package/lib/agent-cli/src/core/learning/cognitive-enhancer.js +0 -282
  86. package/lib/agent-cli/src/core/learning/index.js +0 -12
  87. package/lib/agent-cli/src/core/learning/lesson-synthesizer.js +0 -83
  88. package/lib/agent-cli/src/core/scanning/index.js +0 -14
  89. package/lib/agent-cli/src/data/index.js +0 -13
  90. package/lib/agent-cli/src/data/repositories/index.js +0 -8
  91. package/lib/agent-cli/src/data/repositories/lesson-repository.js +0 -130
  92. package/lib/agent-cli/src/data/repositories/signal-repository.js +0 -119
  93. package/lib/agent-cli/src/data/storage/index.js +0 -8
  94. package/lib/agent-cli/src/data/storage/json-storage.js +0 -64
  95. package/lib/agent-cli/src/data/storage/yaml-storage.js +0 -66
  96. package/lib/agent-cli/src/infrastructure/index.js +0 -13
  97. package/lib/agent-cli/src/presentation/formatters/skill-formatter.js +0 -232
  98. package/lib/agent-cli/src/services/export-service.js +0 -162
  99. package/lib/agent-cli/src/services/index.js +0 -13
  100. package/lib/agent-cli/src/services/learning-service.js +0 -99
@@ -1,380 +0,0 @@
1
- /**
2
- * Dashboard Data v7.0 - Data Aggregation
3
- *
4
- * Aggregates data from all modules for dashboard widgets.
5
- * Provides trends, alerts, and widget data.
6
- *
7
- * @version 7.0.0
8
- * @author PikaKit
9
- */
10
-
11
- import fs from 'fs';
12
- import path from 'path';
13
- import { fileURLToPath } from 'url';
14
-
15
- const __filename = fileURLToPath(import.meta.url);
16
- const __dirname = path.dirname(__filename);
17
-
18
- // Find project root
19
- function findProjectRoot() {
20
- let dir = process.cwd();
21
- while (dir !== path.dirname(dir)) {
22
- if (fs.existsSync(path.join(dir, '.agent'))) return dir;
23
- if (fs.existsSync(path.join(dir, 'package.json'))) return dir;
24
- dir = path.dirname(dir);
25
- }
26
- return process.cwd();
27
- }
28
-
29
- const projectRoot = findProjectRoot();
30
- const METRICS_DIR = path.join(projectRoot, '.agent', 'metrics');
31
-
32
- // Try to import other modules dynamically
33
- let metricsCollector = null;
34
- let causalityEngine = null;
35
- let reinforcement = null;
36
- let abTesting = null;
37
- let skillGenerator = null;
38
-
39
- async function loadModules() {
40
- try {
41
- metricsCollector = await import('./metrics-collector.js');
42
- } catch (e) { /* optional */ }
43
-
44
- try {
45
- causalityEngine = await import('./causality-engine.js');
46
- } catch (e) { /* optional */ }
47
-
48
- try {
49
- reinforcement = await import('./reinforcement.js');
50
- } catch (e) { /* optional */ }
51
-
52
- try {
53
- abTesting = await import('./ab-testing.js');
54
- } catch (e) { /* optional */ }
55
-
56
- try {
57
- skillGenerator = await import('./skill-generator.js');
58
- } catch (e) { /* optional */ }
59
- }
60
-
61
- // Initialize modules
62
- loadModules();
63
-
64
- // ============================================================================
65
- // FULL DASHBOARD DATA
66
- // ============================================================================
67
-
68
- /**
69
- * Get full dashboard data aggregated from all sources
70
- */
71
- export function getFullDashboardData() {
72
- const kpis = metricsCollector?.getKPIs?.() || { kpis: {}, summary: {} };
73
- const patterns = causalityEngine?.loadCausalPatterns?.() || [];
74
- const reinforcementStats = reinforcement?.getStats?.() || { rewards: 0, penalties: 0, avgConfidence: 0 };
75
- const abStats = abTesting?.getActiveTests?.() || [];
76
- const skills = skillGenerator?.getAllSkills?.() || [];
77
-
78
- return {
79
- kpis: kpis.kpis,
80
- summary: {
81
- ...kpis.summary,
82
- patternsLearned: patterns.length,
83
- skillsGenerated: skills.length,
84
- activeTests: abStats.length
85
- },
86
- reinforcement: reinforcementStats,
87
- abTesting: {
88
- active: abStats,
89
- count: abStats.length
90
- },
91
- patterns: {
92
- total: patterns.length,
93
- recent: patterns.slice(-5)
94
- },
95
- skills: {
96
- total: skills.length,
97
- recent: skills.slice(-5)
98
- },
99
- version: '7.0.0',
100
- timestamp: new Date().toISOString()
101
- };
102
- }
103
-
104
- // ============================================================================
105
- // TRENDS
106
- // ============================================================================
107
-
108
- /**
109
- * Get key trends (week-over-week comparison)
110
- */
111
- export function getKeyTrends() {
112
- const historyPath = path.join(METRICS_DIR, 'history.json');
113
-
114
- if (!fs.existsSync(historyPath)) {
115
- return {
116
- task_success_rate: { current: 0, previous: 0, change: 0 },
117
- error_repeat_rate: { current: 0, previous: 0, change: 0 },
118
- patterns_learned: { current: 0, previous: 0, change: 0 },
119
- learning_velocity: generateVelocityData()
120
- };
121
- }
122
-
123
- try {
124
- const history = JSON.parse(fs.readFileSync(historyPath, 'utf8'));
125
- const entries = history.entries || [];
126
-
127
- // Get last 7 days and previous 7 days
128
- const now = new Date();
129
- const weekAgo = new Date(now - 7 * 24 * 60 * 60 * 1000);
130
- const twoWeeksAgo = new Date(now - 14 * 24 * 60 * 60 * 1000);
131
-
132
- const currentWeek = entries.filter(e => new Date(e.timestamp) >= weekAgo);
133
- const previousWeek = entries.filter(e => {
134
- const d = new Date(e.timestamp);
135
- return d >= twoWeeksAgo && d < weekAgo;
136
- });
137
-
138
- const avgCurrent = calculateAverage(currentWeek, 'task_success_rate');
139
- const avgPrevious = calculateAverage(previousWeek, 'task_success_rate');
140
-
141
- const errorCurrent = calculateAverage(currentWeek, 'error_repeat_rate');
142
- const errorPrevious = calculateAverage(previousWeek, 'error_repeat_rate');
143
-
144
- const patternsCurrent = currentWeek.length > 0 ? currentWeek[currentWeek.length - 1].patterns_learned || 0 : 0;
145
- const patternsPrevious = previousWeek.length > 0 ? previousWeek[previousWeek.length - 1].patterns_learned || 0 : 0;
146
-
147
- return {
148
- task_success_rate: {
149
- current: avgCurrent,
150
- previous: avgPrevious,
151
- change: avgCurrent - avgPrevious
152
- },
153
- error_repeat_rate: {
154
- current: errorCurrent,
155
- previous: errorPrevious,
156
- change: errorCurrent - errorPrevious
157
- },
158
- patterns_learned: {
159
- current: patternsCurrent,
160
- previous: patternsPrevious,
161
- change: patternsCurrent - patternsPrevious
162
- },
163
- learning_velocity: generateVelocityData(entries)
164
- };
165
- } catch (e) {
166
- return {
167
- task_success_rate: { current: 0, previous: 0, change: 0 },
168
- error_repeat_rate: { current: 0, previous: 0, change: 0 },
169
- patterns_learned: { current: 0, previous: 0, change: 0 },
170
- learning_velocity: generateVelocityData()
171
- };
172
- }
173
- }
174
-
175
- /**
176
- * Calculate average of a metric from entries
177
- */
178
- function calculateAverage(entries, metric) {
179
- if (entries.length === 0) return 0;
180
- const sum = entries.reduce((acc, e) => acc + (e[metric] || 0), 0);
181
- return Math.round(sum / entries.length);
182
- }
183
-
184
- /**
185
- * Generate learning velocity data for chart
186
- */
187
- function generateVelocityData(entries = []) {
188
- const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
189
- const now = new Date();
190
- const dayOfWeek = now.getDay();
191
-
192
- // Reorder days to start from current day - 6
193
- const orderedDays = [];
194
- for (let i = 6; i >= 0; i--) {
195
- const idx = (dayOfWeek - i + 7) % 7;
196
- orderedDays.push(days[idx === 0 ? 6 : idx - 1]);
197
- }
198
-
199
- // Generate velocity values
200
- const velocity = orderedDays.map((day, idx) => {
201
- // Try to get actual data from entries
202
- const targetDate = new Date(now - (6 - idx) * 24 * 60 * 60 * 1000);
203
- const dayEntries = entries.filter(e => {
204
- const d = new Date(e.timestamp);
205
- return d.toDateString() === targetDate.toDateString();
206
- });
207
-
208
- if (dayEntries.length > 0) {
209
- return {
210
- day,
211
- value: dayEntries.reduce((acc, e) => acc + (e.patterns_learned || 0), 0) / dayEntries.length
212
- };
213
- }
214
-
215
- // Default random-ish value for demo
216
- return {
217
- day,
218
- value: Math.floor(Math.random() * 50) + 20
219
- };
220
- });
221
-
222
- return velocity;
223
- }
224
-
225
- // ============================================================================
226
- // ALERTS
227
- // ============================================================================
228
-
229
- /**
230
- * Generate alerts based on metrics thresholds
231
- */
232
- export function generateAlerts() {
233
- const alerts = [];
234
- const kpis = metricsCollector?.getKPIs?.()?.kpis || {};
235
-
236
- // Check task success rate
237
- if (kpis.task_success_rate) {
238
- const rate = parseInt(kpis.task_success_rate.value) || 0;
239
- if (rate < 50) {
240
- alerts.push({
241
- id: 'low-success-critical',
242
- severity: 'critical',
243
- message: 'Task success rate critically low',
244
- value: `${rate}%`,
245
- threshold: '50%'
246
- });
247
- } else if (rate < 80) {
248
- alerts.push({
249
- id: 'low-success-warning',
250
- severity: 'warning',
251
- message: 'Task success rate below target',
252
- value: `${rate}%`,
253
- threshold: '80%'
254
- });
255
- }
256
- }
257
-
258
- // Check error repeat rate
259
- if (kpis.error_repeat_rate) {
260
- const rate = parseInt(kpis.error_repeat_rate.value) || 0;
261
- if (rate > 30) {
262
- alerts.push({
263
- id: 'high-error-repeat',
264
- severity: 'warning',
265
- message: 'High error repeat rate detected',
266
- value: `${rate}%`,
267
- threshold: '30%'
268
- });
269
- }
270
- }
271
-
272
- // Check for stale patterns
273
- const patterns = causalityEngine?.loadCausalPatterns?.() || [];
274
- if (patterns.length === 0) {
275
- alerts.push({
276
- id: 'no-patterns',
277
- severity: 'info',
278
- message: 'No patterns learned yet',
279
- suggestion: 'Start using the agent to learn patterns'
280
- });
281
- }
282
-
283
- return alerts;
284
- }
285
-
286
- // ============================================================================
287
- // WIDGETS
288
- // ============================================================================
289
-
290
- /**
291
- * Get gauge widget data
292
- */
293
- export function getGaugeWidgets() {
294
- const kpis = metricsCollector?.getKPIs?.()?.kpis || {};
295
-
296
- return [
297
- {
298
- id: 'task-success',
299
- label: 'Task Success Rate',
300
- value: parseInt(kpis.task_success_rate?.value) || 0,
301
- max: 100,
302
- unit: '%',
303
- color: getGaugeColor(parseInt(kpis.task_success_rate?.value) || 0, 80, 50)
304
- },
305
- {
306
- id: 'first-time-success',
307
- label: 'First-Time Success',
308
- value: parseInt(kpis.first_time_success?.value) || 0,
309
- max: 100,
310
- unit: '%',
311
- color: getGaugeColor(parseInt(kpis.first_time_success?.value) || 0, 70, 40)
312
- },
313
- {
314
- id: 'skill-effectiveness',
315
- label: 'Skill Effectiveness',
316
- value: parseInt(kpis.skill_effectiveness?.value) || 0,
317
- max: 100,
318
- unit: '%',
319
- color: getGaugeColor(parseInt(kpis.skill_effectiveness?.value) || 0, 60, 30)
320
- }
321
- ];
322
- }
323
-
324
- /**
325
- * Get counter widget data
326
- */
327
- export function getCounterWidgets() {
328
- const kpis = metricsCollector?.getKPIs?.()?.kpis || {};
329
- const patterns = causalityEngine?.loadCausalPatterns?.() || [];
330
- const skills = skillGenerator?.getAllSkills?.() || [];
331
- const abTests = abTesting?.getActiveTests?.() || [];
332
-
333
- return [
334
- {
335
- id: 'total-tasks',
336
- label: 'Total Tasks',
337
- value: kpis.total_tasks?.value || 0,
338
- icon: '📊'
339
- },
340
- {
341
- id: 'patterns-learned',
342
- label: 'Patterns Learned',
343
- value: patterns.length,
344
- icon: '🧩'
345
- },
346
- {
347
- id: 'skills-generated',
348
- label: 'Skills Generated',
349
- value: skills.length,
350
- icon: '⚙️'
351
- },
352
- {
353
- id: 'ab-tests-active',
354
- label: 'A/B Tests Active',
355
- value: abTests.length,
356
- icon: '🧪'
357
- }
358
- ];
359
- }
360
-
361
- /**
362
- * Get gauge color based on value and thresholds
363
- */
364
- function getGaugeColor(value, goodThreshold, warningThreshold) {
365
- if (value >= goodThreshold) return '#00ff88';
366
- if (value >= warningThreshold) return '#ffbb00';
367
- return '#ff4444';
368
- }
369
-
370
- // ============================================================================
371
- // EXPORTS
372
- // ============================================================================
373
-
374
- export default {
375
- getFullDashboardData,
376
- getKeyTrends,
377
- generateAlerts,
378
- getGaugeWidgets,
379
- getCounterWidgets
380
- };
@@ -1,238 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * ESLint Fix Integration
4
- *
5
- * Wrapper around ESLint --fix to combine with pattern-based fix.
6
- * Auto-detects ESLint config and runs fixes.
7
- *
8
- * Usage: agent fix --eslint <path>
9
- */
10
-
11
- import { execSync, spawnSync } from "child_process";
12
- import fs from "fs";
13
- import path from "path";
14
- import { VERSION } from "./config.js";
15
-
16
- // ============================================================================
17
- // ESLINT DETECTION
18
- // ============================================================================
19
-
20
- /**
21
- * Find ESLint config file in project
22
- * @param {string} dir
23
- * @returns {string|null}
24
- */
25
- function findEslintConfig(dir) {
26
- const configFiles = [
27
- ".eslintrc.js",
28
- ".eslintrc.cjs",
29
- ".eslintrc.json",
30
- ".eslintrc.yaml",
31
- ".eslintrc.yml",
32
- ".eslintrc",
33
- "eslint.config.js",
34
- "eslint.config.mjs"
35
- ];
36
-
37
- let current = dir;
38
- while (current !== path.dirname(current)) {
39
- for (const config of configFiles) {
40
- const configPath = path.join(current, config);
41
- if (fs.existsSync(configPath)) {
42
- return configPath;
43
- }
44
- }
45
- // Check package.json for eslintConfig
46
- const pkgPath = path.join(current, "package.json");
47
- if (fs.existsSync(pkgPath)) {
48
- try {
49
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
50
- if (pkg.eslintConfig) {
51
- return pkgPath; // ESLint config in package.json
52
- }
53
- } catch (e) { }
54
- }
55
- current = path.dirname(current);
56
- }
57
- return null;
58
- }
59
-
60
- /**
61
- * Check if ESLint is available
62
- * @returns {boolean}
63
- */
64
- function isEslintAvailable() {
65
- try {
66
- execSync("npx eslint --version", { stdio: "ignore" });
67
- return true;
68
- } catch (e) {
69
- return false;
70
- }
71
- }
72
-
73
- // ============================================================================
74
- // ESLINT FIX
75
- // ============================================================================
76
-
77
- /**
78
- * Run ESLint --fix on a path
79
- * @param {string} targetPath
80
- * @param {object} options
81
- * @returns {{ success: boolean, fixed: number, errors: number }}
82
- */
83
- export function runEslintFix(targetPath, options = {}) {
84
- const result = {
85
- success: false,
86
- fixed: 0,
87
- errors: 0,
88
- output: ""
89
- };
90
-
91
- if (!isEslintAvailable()) {
92
- console.log("⚠️ ESLint not found. Install with: npm install eslint -D");
93
- return result;
94
- }
95
-
96
- const configPath = findEslintConfig(process.cwd());
97
- if (!configPath && !options.noConfig) {
98
- console.log("⚠️ No ESLint config found. Run: npx eslint --init");
99
- return result;
100
- }
101
-
102
- console.log(`\n🔧 Running ESLint --fix...`);
103
- if (configPath) {
104
- console.log(` Config: ${path.relative(process.cwd(), configPath)}`);
105
- }
106
-
107
- try {
108
- // Run ESLint with --fix
109
- const args = [
110
- "eslint",
111
- targetPath,
112
- "--fix",
113
- "--format", "json"
114
- ];
115
-
116
- const proc = spawnSync("npx", args, {
117
- encoding: "utf8",
118
- shell: true,
119
- maxBuffer: 10 * 1024 * 1024
120
- });
121
-
122
- // Parse output
123
- if (proc.stdout) {
124
- try {
125
- const results = JSON.parse(proc.stdout);
126
- let totalFixed = 0;
127
- let totalErrors = 0;
128
-
129
- results.forEach(file => {
130
- if (file.output) {
131
- // File was fixed (output contains fixed content)
132
- totalFixed++;
133
- }
134
- totalErrors += file.errorCount || 0;
135
- });
136
-
137
- result.fixed = totalFixed;
138
- result.errors = totalErrors;
139
- result.success = true;
140
- result.output = proc.stdout;
141
-
142
- console.log(` ✅ Fixed: ${totalFixed} file(s)`);
143
- if (totalErrors > 0) {
144
- console.log(` ⚠️ Remaining errors: ${totalErrors}`);
145
- }
146
- } catch (e) {
147
- // JSON parse failed, but fix might still have worked
148
- result.success = proc.status === 0;
149
- }
150
- }
151
-
152
- if (proc.status === 0) {
153
- result.success = true;
154
- console.log(" ✅ ESLint fix completed");
155
- }
156
-
157
- } catch (error) {
158
- console.error(` ❌ ESLint error: ${error.message}`);
159
- }
160
-
161
- return result;
162
- }
163
-
164
- // ============================================================================
165
- // COMBINED FIX
166
- // ============================================================================
167
-
168
- /**
169
- * Run combined fix (ESLint + pattern-based)
170
- * @param {string} targetPath
171
- * @param {object} options
172
- */
173
- export async function runCombinedFix(targetPath, options = {}) {
174
- console.log(`\n🔧 Combined Fix v${VERSION}`);
175
- console.log(`📂 Target: ${targetPath}`);
176
- console.log("─".repeat(50));
177
-
178
- // Step 1: ESLint fix
179
- if (options.eslint !== false) {
180
- runEslintFix(targetPath, options);
181
- }
182
-
183
- // Step 2: Pattern-based fix (import dynamically)
184
- console.log("\n🧠 Running pattern-based fix...");
185
- try {
186
- const { fixDirectory } = await import("./fix.js");
187
- const { loadKnowledge } = await import("./recall.js");
188
-
189
- const db = loadKnowledge();
190
- const results = fixDirectory(targetPath, db, options.mode || "safe");
191
-
192
- if (results.length > 0) {
193
- let total = 0;
194
- results.forEach(r => total += r.fixes);
195
- console.log(` ✅ Pattern fixes: ${total}`);
196
- } else {
197
- console.log(" ✅ No pattern violations to fix");
198
- }
199
- } catch (e) {
200
- console.log(` ⚠️ Pattern fix skipped: ${e.message}`);
201
- }
202
-
203
- console.log("\n" + "─".repeat(50));
204
- console.log("🎉 Combined fix completed!");
205
- }
206
-
207
- // ============================================================================
208
- // CLI
209
- // ============================================================================
210
-
211
- const args = process.argv.slice(2);
212
-
213
- if (args.includes("--help") || args.length === 0) {
214
- console.log(`
215
- 🔧 ESLint Fix Integration v${VERSION}
216
-
217
- Usage:
218
- node eslint-fix.js <path> [options]
219
-
220
- Options:
221
- --no-eslint Skip ESLint fix
222
- --no-pattern Skip pattern-based fix
223
- --mode <mode> Pattern fix mode (safe|aggressive)
224
- --help Show this help
225
-
226
- This combines ESLint --fix with pattern-based fixes.
227
- `);
228
- process.exit(0);
229
- }
230
-
231
- const target = args[0];
232
- const options = {
233
- eslint: !args.includes("--no-eslint"),
234
- pattern: !args.includes("--no-pattern"),
235
- mode: args.includes("--mode") ? args[args.indexOf("--mode") + 1] : "safe"
236
- };
237
-
238
- runCombinedFix(target, options);