@elyracode/perf-tools 0.9.56 → 0.9.58

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 (2) hide show
  1. package/extensions/index.ts +35 -16
  2. package/package.json +1 -1
@@ -1,11 +1,10 @@
1
+ import { execSync } from "node:child_process";
1
2
  import { existsSync, readFileSync } from "node:fs";
2
3
  import { join } from "node:path";
3
- import { execSync } from "node:child_process";
4
4
  import type { ExtensionAPI } from "@elyracode/coding-agent";
5
5
  import { Type } from "typebox";
6
6
 
7
7
  export default function (elyra: ExtensionAPI): void {
8
-
9
8
  // ── Tool: analyze_queries ──
10
9
  elyra.registerTool({
11
10
  name: "analyze_queries",
@@ -84,20 +83,27 @@ export default function (elyra: ExtensionAPI): void {
84
83
  findings.push(n1Patterns);
85
84
  findings.push("```");
86
85
  }
87
- } catch { /* no matches */ }
86
+ } catch {
87
+ /* no matches */
88
+ }
88
89
 
89
90
  // Find models without $with or common relationship loading
90
91
  try {
91
- const models = execSync(
92
- `grep -rl --include="*.php" "extends Model" app/ 2>/dev/null | head -20`,
93
- { cwd, timeout: 10000, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] },
94
- ).trim();
92
+ const models = execSync(`grep -rl --include="*.php" "extends Model" app/ 2>/dev/null | head -20`, {
93
+ cwd,
94
+ timeout: 10000,
95
+ encoding: "utf-8",
96
+ stdio: ["pipe", "pipe", "pipe"],
97
+ }).trim();
95
98
  if (models) {
96
99
  const modelFiles = models.split("\n").filter((l) => l.trim());
97
100
  const missingWith: string[] = [];
98
101
  for (const modelFile of modelFiles) {
99
102
  const modelContent = readFileSync(join(cwd, modelFile), "utf-8");
100
- const hasRelationships = /function\s+\w+\(\).*?(?:hasMany|belongsTo|hasOne|belongsToMany|morphTo|morphMany)/s.test(modelContent);
103
+ const hasRelationships =
104
+ /function\s+\w+\(\).*?(?:hasMany|belongsTo|hasOne|belongsToMany|morphTo|morphMany)/s.test(
105
+ modelContent,
106
+ );
101
107
  const hasDefaultWith = /\$with\s*=\s*\[/.test(modelContent);
102
108
  if (hasRelationships && !hasDefaultWith) {
103
109
  missingWith.push(modelFile);
@@ -111,7 +117,9 @@ export default function (elyra: ExtensionAPI): void {
111
117
  }
112
118
  }
113
119
  }
114
- } catch { /* ignore */ }
120
+ } catch {
121
+ /* ignore */
122
+ }
115
123
 
116
124
  // Find missing indexes (check migrations for foreign keys without indexes)
117
125
  try {
@@ -126,7 +134,9 @@ export default function (elyra: ExtensionAPI): void {
126
134
  findings.push(migrations);
127
135
  findings.push("```");
128
136
  }
129
- } catch { /* ignore */ }
137
+ } catch {
138
+ /* ignore */
139
+ }
130
140
 
131
141
  findings.push("");
132
142
  }
@@ -163,10 +173,12 @@ export default function (elyra: ExtensionAPI): void {
163
173
  }),
164
174
  execute: async (_toolCallId, params) => {
165
175
  return {
166
- content: [{
167
- type: "text",
168
- text: `Run EXPLAIN on this query and analyze the execution plan:\n\nEXPLAIN ${params.sql}\n\nLook for: full table scans (type=ALL), missing indexes, high row estimates, filesort, temporary tables.`,
169
- }],
176
+ content: [
177
+ {
178
+ type: "text",
179
+ text: `Run EXPLAIN on this query and analyze the execution plan:\n\nEXPLAIN ${params.sql}\n\nLook for: full table scans (type=ALL), missing indexes, high row estimates, filesort, temporary tables.`,
180
+ },
181
+ ],
170
182
  details: {},
171
183
  };
172
184
  },
@@ -176,7 +188,9 @@ export default function (elyra: ExtensionAPI): void {
176
188
  elyra.registerCommand("perf", {
177
189
  description: "Analyze database query performance",
178
190
  handler: async (_args, _ctx) => {
179
- elyra.sendUserMessage("Analyze this project for database performance issues: N+1 queries, slow queries, missing indexes, and eager loading opportunities.");
191
+ elyra.sendUserMessage(
192
+ "Analyze this project for database performance issues: N+1 queries, slow queries, missing indexes, and eager loading opportunities.",
193
+ );
180
194
  },
181
195
  });
182
196
  }
@@ -187,7 +201,12 @@ interface DuplicatePattern {
187
201
  }
188
202
 
189
203
  function findDuplicatePatterns(queries: string[]): DuplicatePattern[] {
190
- const normalized = queries.map((q) => q.replace(/\d+/g, "?").replace(/['"][^'"]*['"]/g, "?").slice(0, 100));
204
+ const normalized = queries.map((q) =>
205
+ q
206
+ .replace(/\d+/g, "?")
207
+ .replace(/['"][^'"]*['"]/g, "?")
208
+ .slice(0, 100),
209
+ );
191
210
  const counts = new Map<string, number>();
192
211
  for (const q of normalized) {
193
212
  counts.set(q, (counts.get(q) ?? 0) + 1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/perf-tools",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "Elyra extension for performance analysis -- N+1 queries, slow queries, missing indexes",
5
5
  "type": "module",
6
6
  "keywords": [