@elyracode/flux-ui 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 +93 -39
  2. package/package.json +1 -1
@@ -1,13 +1,29 @@
1
1
  import { readFileSync } from "node:fs";
2
- import type { ExtensionAPI } from "@elyracode/coding-agent";
2
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
3
3
  import { Type } from "typebox";
4
4
  import { fetchRepoContents } from "./github-fetch.js";
5
5
 
6
6
  const FLUX_REPO = "livewire/flux";
7
7
  const FLUX_BRANCH = "main";
8
8
 
9
- export default function (elyra: ExtensionAPI): void {
9
+ /** Details reported by flux_component_index. */
10
+ interface ComponentIndexDetails {
11
+ componentCount?: number;
12
+ }
10
13
 
14
+ /** Details reported by blade_to_flux. */
15
+ interface BladeToFluxDetails {
16
+ suggestions?: number;
17
+ }
18
+
19
+ /** Details reported by flux_generate_page. */
20
+ interface GeneratePageDetails {
21
+ pageName?: string;
22
+ layout?: "header" | "sidebar";
23
+ componentCount?: number;
24
+ }
25
+
26
+ export default function (elyra: ExtensionAPI): void {
11
27
  // ── Tool 1: flux_component_index ──
12
28
  // Fetches the actual Flux UI source from GitHub and builds a live component reference
13
29
  elyra.registerTool({
@@ -25,7 +41,7 @@ export default function (elyra: ExtensionAPI): void {
25
41
  }),
26
42
  ),
27
43
  }),
28
- execute: async (_toolCallId, params) => {
44
+ execute: async (_toolCallId, params): Promise<AgentToolResult<ComponentIndexDetails>> => {
29
45
  try {
30
46
  const files = await fetchRepoContents(FLUX_REPO, FLUX_BRANCH, {
31
47
  extensions: [".blade.php", ".php"],
@@ -34,17 +50,12 @@ export default function (elyra: ExtensionAPI): void {
34
50
 
35
51
  // Find component files (typically in stubs/ or src/components/)
36
52
  let componentFiles = files.filter(
37
- (f) =>
38
- f.path.includes("stubs/") ||
39
- f.path.includes("components/") ||
40
- f.path.includes("views/"),
53
+ (f) => f.path.includes("stubs/") || f.path.includes("components/") || f.path.includes("views/"),
41
54
  );
42
55
 
43
56
  if (params.component) {
44
57
  const search = params.component.toLowerCase();
45
- componentFiles = componentFiles.filter(
46
- (f) => f.path.toLowerCase().includes(search),
47
- );
58
+ componentFiles = componentFiles.filter((f) => f.path.toLowerCase().includes(search));
48
59
  }
49
60
 
50
61
  if (componentFiles.length === 0) {
@@ -111,7 +122,7 @@ export default function (elyra: ExtensionAPI): void {
111
122
  description: "Path to the Blade file to analyze (relative to cwd)",
112
123
  }),
113
124
  }),
114
- execute: async (_toolCallId, params) => {
125
+ execute: async (_toolCallId, params): Promise<AgentToolResult<BladeToFluxDetails>> => {
115
126
  try {
116
127
  const content = readFileSync(params.file_path, "utf-8");
117
128
 
@@ -122,18 +133,62 @@ export default function (elyra: ExtensionAPI): void {
122
133
  { pattern: /<button[\s>]/gi, flux: "<flux:button>", description: "Replace <button> with <flux:button>" },
123
134
  { pattern: /<input[\s>]/gi, flux: "<flux:input>", description: "Replace <input> with <flux:input>" },
124
135
  { pattern: /<select[\s>]/gi, flux: "<flux:select>", description: "Replace <select> with <flux:select>" },
125
- { pattern: /<textarea[\s>]/gi, flux: "<flux:textarea>", description: "Replace <textarea> with <flux:textarea>" },
126
- { pattern: /<table[\s>]/gi, flux: "<flux:table>", description: "Replace <table> with <flux:table> + <flux:columns> + <flux:rows>" },
127
- { pattern: /<dialog[\s>]|x-data=.*modal|x-show=.*modal/gi, flux: "<flux:modal>", description: "Replace modal pattern with <flux:modal>" },
128
- { pattern: /<nav[\s>].*tab|role="tablist"/gi, flux: "<flux:tabs>", description: "Replace tab navigation with <flux:tabs>" },
129
- { pattern: /<div.*class=".*card.*"/gi, flux: "<flux:card>", description: "Replace card div with <flux:card>" },
136
+ {
137
+ pattern: /<textarea[\s>]/gi,
138
+ flux: "<flux:textarea>",
139
+ description: "Replace <textarea> with <flux:textarea>",
140
+ },
141
+ {
142
+ pattern: /<table[\s>]/gi,
143
+ flux: "<flux:table>",
144
+ description: "Replace <table> with <flux:table> + <flux:columns> + <flux:rows>",
145
+ },
146
+ {
147
+ pattern: /<dialog[\s>]|x-data=.*modal|x-show=.*modal/gi,
148
+ flux: "<flux:modal>",
149
+ description: "Replace modal pattern with <flux:modal>",
150
+ },
151
+ {
152
+ pattern: /<nav[\s>].*tab|role="tablist"/gi,
153
+ flux: "<flux:tabs>",
154
+ description: "Replace tab navigation with <flux:tabs>",
155
+ },
156
+ {
157
+ pattern: /<div.*class=".*card.*"/gi,
158
+ flux: "<flux:card>",
159
+ description: "Replace card div with <flux:card>",
160
+ },
130
161
  { pattern: /class=".*badge.*"/gi, flux: "<flux:badge>", description: "Replace badge with <flux:badge>" },
131
- { pattern: /<div.*class=".*dropdown.*"|x-data=.*dropdown/gi, flux: "<flux:dropdown>", description: "Replace dropdown with <flux:dropdown>" },
132
- { pattern: /<div.*class=".*breadcrumb.*"/gi, flux: "<flux:breadcrumbs>", description: "Replace breadcrumb with <flux:breadcrumbs>" },
133
- { pattern: /<div.*class=".*tooltip.*"|x-data=.*tooltip/gi, flux: "<flux:tooltip>", description: "Replace tooltip with <flux:tooltip>" },
134
- { pattern: /<div.*class=".*switch.*"|type="checkbox".*role="switch"/gi, flux: "<flux:switch>", description: "Replace switch/toggle with <flux:switch>" },
135
- { pattern: /<header[\s>]/gi, flux: "<flux:header>", description: "Consider <flux:header> for page headers" },
136
- { pattern: /<aside[\s>]|class=".*sidebar.*"/gi, flux: "<flux:sidebar>", description: "Consider <flux:sidebar> for side navigation" },
162
+ {
163
+ pattern: /<div.*class=".*dropdown.*"|x-data=.*dropdown/gi,
164
+ flux: "<flux:dropdown>",
165
+ description: "Replace dropdown with <flux:dropdown>",
166
+ },
167
+ {
168
+ pattern: /<div.*class=".*breadcrumb.*"/gi,
169
+ flux: "<flux:breadcrumbs>",
170
+ description: "Replace breadcrumb with <flux:breadcrumbs>",
171
+ },
172
+ {
173
+ pattern: /<div.*class=".*tooltip.*"|x-data=.*tooltip/gi,
174
+ flux: "<flux:tooltip>",
175
+ description: "Replace tooltip with <flux:tooltip>",
176
+ },
177
+ {
178
+ pattern: /<div.*class=".*switch.*"|type="checkbox".*role="switch"/gi,
179
+ flux: "<flux:switch>",
180
+ description: "Replace switch/toggle with <flux:switch>",
181
+ },
182
+ {
183
+ pattern: /<header[\s>]/gi,
184
+ flux: "<flux:header>",
185
+ description: "Consider <flux:header> for page headers",
186
+ },
187
+ {
188
+ pattern: /<aside[\s>]|class=".*sidebar.*"/gi,
189
+ flux: "<flux:sidebar>",
190
+ description: "Consider <flux:sidebar> for side navigation",
191
+ },
137
192
  ];
138
193
 
139
194
  for (const { pattern, description } of patterns) {
@@ -146,16 +201,17 @@ export default function (elyra: ExtensionAPI): void {
146
201
  // Check for wire:model patterns that could use Flux form components
147
202
  const wireModels = content.match(/wire:model[.\w]*/g);
148
203
  if (wireModels) {
149
- suggestions.push(`- ${wireModels.length} wire:model binding(s) found -- ensure Flux form components use wire:model directly`);
204
+ suggestions.push(
205
+ `- ${wireModels.length} wire:model binding(s) found -- ensure Flux form components use wire:model directly`,
206
+ );
150
207
  }
151
208
 
152
- const result: string[] = [
153
- `# Blade to Flux UI Analysis: ${params.file_path}`,
154
- "",
155
- ];
209
+ const result: string[] = [`# Blade to Flux UI Analysis: ${params.file_path}`, ""];
156
210
 
157
211
  if (suggestions.length === 0) {
158
- result.push("No obvious conversion opportunities found. The file may already use Flux UI or contain custom components.");
212
+ result.push(
213
+ "No obvious conversion opportunities found. The file may already use Flux UI or contain custom components.",
214
+ );
159
215
  } else {
160
216
  result.push(`Found ${suggestions.length} conversion opportunities:`, "");
161
217
  result.push(...suggestions);
@@ -165,7 +221,9 @@ export default function (elyra: ExtensionAPI): void {
165
221
  result.push(content);
166
222
  result.push("```");
167
223
  result.push("");
168
- result.push("To convert, use the flux_component_index tool to get the exact Flux API, then rewrite the file.");
224
+ result.push(
225
+ "To convert, use the flux_component_index tool to get the exact Flux API, then rewrite the file.",
226
+ );
169
227
  }
170
228
 
171
229
  return {
@@ -206,7 +264,7 @@ export default function (elyra: ExtensionAPI): void {
206
264
  }),
207
265
  ),
208
266
  }),
209
- execute: async (_toolCallId, params) => {
267
+ execute: async (_toolCallId, params): Promise<AgentToolResult<GeneratePageDetails>> => {
210
268
  try {
211
269
  // Fetch Flux component index for accurate API usage
212
270
  const files = await fetchRepoContents(FLUX_REPO, FLUX_BRANCH, {
@@ -215,17 +273,11 @@ export default function (elyra: ExtensionAPI): void {
215
273
  });
216
274
 
217
275
  const componentFiles = files.filter(
218
- (f) =>
219
- f.path.includes("stubs/") ||
220
- f.path.includes("components/") ||
221
- f.path.includes("views/"),
276
+ (f) => f.path.includes("stubs/") || f.path.includes("components/") || f.path.includes("views/"),
222
277
  );
223
278
 
224
279
  // Build compact component reference (just names and key props)
225
- const componentIndex: string[] = [
226
- "# Available Flux UI Components (from source)",
227
- "",
228
- ];
280
+ const componentIndex: string[] = ["# Available Flux UI Components (from source)", ""];
229
281
 
230
282
  for (const file of componentFiles.slice(0, 50)) {
231
283
  const name = file.path.split("/").pop()?.replace(".blade.php", "") ?? file.path;
@@ -298,7 +350,9 @@ export default function (elyra: ExtensionAPI): void {
298
350
  if (selected.startsWith("Component Index")) {
299
351
  elyra.sendUserMessage("Fetch the Flux UI component index and show me the available components.");
300
352
  } else if (selected.startsWith("Blade to Flux")) {
301
- elyra.sendUserMessage("I want to convert a Blade view to use Flux UI components. Ask me which file to analyze.");
353
+ elyra.sendUserMessage(
354
+ "I want to convert a Blade view to use Flux UI components. Ask me which file to analyze.",
355
+ );
302
356
  } else if (selected.startsWith("Generate Page")) {
303
357
  elyra.sendUserMessage("I want to generate a new Flux UI page. Ask me what the page should do.");
304
358
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/flux-ui",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "Elyra extension for Flux UI -- live component index, Blade-to-Flux converter, and page generator",
5
5
  "type": "module",
6
6
  "keywords": [