@elyracode/laravel 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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.58] - 2026-11-18
4
+
5
+ ## [0.9.57] - 2026-11-10
6
+
7
+ ### Fixed
8
+
9
+ - Tool failures were returned as normal results (`isError` on the return value is ignored) and the model saw them as successes; they now throw so the result is marked as an error
10
+
3
11
  ## [0.9.56] - 2026-11-01
4
12
 
5
13
  ## [0.9.55] - 2026-10-21
@@ -1,7 +1,7 @@
1
1
  import { execSync } from "node:child_process";
2
2
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
3
- import { basename, join, relative } from "node:path";
4
- import type { ExtensionAPI } from "@elyracode/coding-agent";
3
+ import { join, relative } from "node:path";
4
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
5
5
  import { Type } from "typebox";
6
6
 
7
7
  // ── Helpers ─────────────────────────────────────────────────────────────────
@@ -98,8 +98,7 @@ function parseModel(filePath: string, cwd: string): ModelInfo | null {
98
98
  const relationships: ModelInfo["relationships"] = [];
99
99
  const relRegex =
100
100
  /(?:public\s+)?function\s+(\w+)\s*\([^)]*\)\s*(?::\s*\w+)?\s*\{[^}]*\$this->(hasOne|hasMany|belongsTo|belongsToMany|hasManyThrough|hasOneThrough|morphOne|morphMany|morphToMany|morphTo|morphedByMany)\s*\(\s*(?:\\?[\w\\]*\\)?(\w+)::class/g;
101
- let relMatch: RegExpExecArray | null = null;
102
- while ((relMatch = relRegex.exec(content)) !== null) {
101
+ for (const relMatch of content.matchAll(relRegex)) {
103
102
  relationships.push({
104
103
  method: relMatch[1],
105
104
  type: relMatch[2],
@@ -119,7 +118,9 @@ function parseModel(filePath: string, cwd: string): ModelInfo | null {
119
118
 
120
119
  // Casts
121
120
  const casts: string[] = [];
122
- const castsMatch = content.match(/(?:protected\s+function\s+casts\s*\(\)[\s\S]*?return\s*\[([\s\S]*?)\]|\$casts\s*=\s*\[([\s\S]*?)\])/);
121
+ const castsMatch = content.match(
122
+ /(?:protected\s+function\s+casts\s*\(\)[\s\S]*?return\s*\[([\s\S]*?)\]|\$casts\s*=\s*\[([\s\S]*?)\])/,
123
+ );
123
124
  if (castsMatch) {
124
125
  const castBlock = castsMatch[1] ?? castsMatch[2] ?? "";
125
126
  const castItems = castBlock.match(/'(\w+)'\s*=>\s*'?([^',\]]+)/g);
@@ -134,16 +135,14 @@ function parseModel(filePath: string, cwd: string): ModelInfo | null {
134
135
  // Scopes
135
136
  const scopes: string[] = [];
136
137
  const scopeRegex = /function\s+scope(\w+)\s*\(/g;
137
- let scopeMatch: RegExpExecArray | null = null;
138
- while ((scopeMatch = scopeRegex.exec(content)) !== null) {
138
+ for (const scopeMatch of content.matchAll(scopeRegex)) {
139
139
  scopes.push(scopeMatch[1].charAt(0).toLowerCase() + scopeMatch[1].slice(1));
140
140
  }
141
141
 
142
142
  // Traits
143
143
  const traits: string[] = [];
144
144
  const useRegex = /use\s+([\w\\]+(?:\s*,\s*[\w\\]+)*)\s*;/g;
145
- let useMatch: RegExpExecArray | null = null;
146
- while ((useMatch = useRegex.exec(content)) !== null) {
145
+ for (const useMatch of content.matchAll(useRegex)) {
147
146
  // Only traits inside the class body (after 'class X extends')
148
147
  if (content.indexOf(useMatch[0]) > content.indexOf("extends")) {
149
148
  const traitNames = useMatch[1].split(",").map((t) => {
@@ -239,9 +238,7 @@ function parseRoutes(cwd: string, prefix?: string): string {
239
238
 
240
239
  for (const route of routes) {
241
240
  const methods = route.method.toUpperCase();
242
- const mw = Array.isArray(route.middleware)
243
- ? route.middleware.join(", ")
244
- : route.middleware || "";
241
+ const mw = Array.isArray(route.middleware) ? route.middleware.join(", ") : route.middleware || "";
245
242
 
246
243
  lines.push(`${methods} /${route.uri}`);
247
244
  if (route.name) lines.push(` name: ${route.name}`);
@@ -278,12 +275,18 @@ function analyzeProject(cwd: string, models: ModelInfo[]): string {
278
275
 
279
276
  // Detect stack
280
277
  const composer = JSON.parse(readFileSync(join(cwd, "composer.json"), "utf-8")) as Record<string, unknown>;
281
- const require = { ...(composer.require as Record<string, string> ?? {}), ...(composer["require-dev"] as Record<string, string> ?? {}) };
278
+ const require = {
279
+ ...((composer.require as Record<string, string>) ?? {}),
280
+ ...((composer["require-dev"] as Record<string, string>) ?? {}),
281
+ };
282
282
  const packageJson = existsSync(join(cwd, "package.json"))
283
283
  ? (JSON.parse(readFileSync(join(cwd, "package.json"), "utf-8")) as Record<string, unknown>)
284
284
  : null;
285
285
  const npmDeps = packageJson
286
- ? { ...(packageJson.dependencies as Record<string, string> ?? {}), ...(packageJson.devDependencies as Record<string, string> ?? {}) }
286
+ ? {
287
+ ...((packageJson.dependencies as Record<string, string>) ?? {}),
288
+ ...((packageJson.devDependencies as Record<string, string>) ?? {}),
289
+ }
287
290
  : {};
288
291
 
289
292
  const stack: string[] = [`Laravel ${laravelVersion}`];
@@ -372,9 +375,7 @@ function analyzeProject(cwd: string, models: ModelInfo[]): string {
372
375
  if (existsSync(factoryDir)) {
373
376
  try {
374
377
  const factories = readdirSync(factoryDir).filter((f) => f.endsWith(".php"));
375
- const modelsWithoutFactory = models.filter(
376
- (m) => !factories.some((f) => f.includes(m.name)),
377
- );
378
+ const modelsWithoutFactory = models.filter((m) => !factories.some((f) => f.includes(m.name)));
378
379
  lines.push(`Factories: ${factories.length}`);
379
380
  if (modelsWithoutFactory.length > 0) {
380
381
  lines.push(`Missing factories: ${modelsWithoutFactory.map((m) => m.name).join(", ")}`);
@@ -419,13 +420,7 @@ function getInstalledPackages(cwd: string): Array<{ name: string; version: strin
419
420
  "nunomaduro/",
420
421
  "barryvdh/",
421
422
  ];
422
- const npmEcosystemPatterns = [
423
- "@inertiajs/",
424
- "tailwindcss",
425
- "alpinejs",
426
- "@tailwindcss/",
427
- "@livewire/",
428
- ];
423
+ const npmEcosystemPatterns = ["@inertiajs/", "tailwindcss", "alpinejs", "@tailwindcss/", "@livewire/"];
429
424
 
430
425
  const composerLockPath = join(cwd, "composer.lock");
431
426
  if (existsSync(composerLockPath)) {
@@ -449,8 +444,8 @@ function getInstalledPackages(cwd: string): Array<{ name: string; version: strin
449
444
  try {
450
445
  const pkgJson = JSON.parse(readFileSync(packageJsonPath, "utf-8")) as Record<string, unknown>;
451
446
  const deps = {
452
- ...(pkgJson.dependencies as Record<string, string> ?? {}),
453
- ...(pkgJson.devDependencies as Record<string, string> ?? {}),
447
+ ...((pkgJson.dependencies as Record<string, string>) ?? {}),
448
+ ...((pkgJson.devDependencies as Record<string, string>) ?? {}),
454
449
  };
455
450
  for (const [name, version] of Object.entries(deps)) {
456
451
  if (npmEcosystemPatterns.some((p) => name === p || name.startsWith(p))) {
@@ -507,13 +502,10 @@ export default function (elyra: ExtensionAPI): void {
507
502
  }
508
503
 
509
504
  function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
510
-
511
505
  // ── laravel_models ───────────────────────────────────────────────────
512
506
 
513
507
  const modelsSchema = Type.Object({
514
- filter: Type.Optional(
515
- Type.String({ description: "Filter models by name (case-insensitive substring match)" }),
516
- ),
508
+ filter: Type.Optional(Type.String({ description: "Filter models by name (case-insensitive substring match)" })),
517
509
  });
518
510
 
519
511
  elyra.registerTool({
@@ -523,9 +515,9 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
523
515
  "Map all Eloquent models in the project with their relationships, fillable fields, casts, scopes, and traits. Returns a complete data model overview. Use this before generating code that involves database models.",
524
516
  parameters: modelsSchema,
525
517
  promptSnippet: "Map all Eloquent models with relationships and structure",
526
- async execute(_toolCallId, params) {
518
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
527
519
  if (!isLaravelProject(getCwd())) {
528
- return { content: [{ type: "text", text: "Not a Laravel project (no laravel/framework in composer.json)" }], isError: true };
520
+ throw new Error("Not a Laravel project (no laravel/framework in composer.json)");
529
521
  }
530
522
 
531
523
  const modelDirs = [
@@ -550,16 +542,14 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
550
542
  }
551
543
 
552
544
  allModels.sort((a, b) => a.name.localeCompare(b.name));
553
- return { content: [{ type: "text", text: formatModels(allModels) }] };
545
+ return { content: [{ type: "text", text: formatModels(allModels) }], details: undefined };
554
546
  },
555
547
  });
556
548
 
557
549
  // ── laravel_routes ───────────────────────────────────────────────────
558
550
 
559
551
  const routesSchema = Type.Object({
560
- prefix: Type.Optional(
561
- Type.String({ description: "Filter routes by URI prefix (e.g. 'api', 'auth', 'admin')" }),
562
- ),
552
+ prefix: Type.Optional(Type.String({ description: "Filter routes by URI prefix (e.g. 'api', 'auth', 'admin')" })),
563
553
  });
564
554
 
565
555
  elyra.registerTool({
@@ -569,12 +559,12 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
569
559
  "List all registered routes with their HTTP methods, middleware, controller actions, and names. Requires php artisan to be available. Use this to understand the existing API surface before adding new routes.",
570
560
  parameters: routesSchema,
571
561
  promptSnippet: "List Laravel routes with middleware and controllers",
572
- async execute(_toolCallId, params) {
562
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
573
563
  if (!isLaravelProject(getCwd())) {
574
- return { content: [{ type: "text", text: "Not a Laravel project" }], isError: true };
564
+ throw new Error("Not a Laravel project");
575
565
  }
576
566
  const result = parseRoutes(getCwd(), params.prefix);
577
- return { content: [{ type: "text", text: result }] };
567
+ return { content: [{ type: "text", text: result }], details: undefined };
578
568
  },
579
569
  });
580
570
 
@@ -589,9 +579,9 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
589
579
  "Analyze the Laravel project architecture: framework version, stack (Livewire/Inertia/Vue/React), authentication method, patterns used (Actions/Services/Repositories), controller style, model count, test framework, and missing factories. Run this first when working on a Laravel project to understand conventions.",
590
580
  parameters: analyzeSchema,
591
581
  promptSnippet: "Analyze Laravel project architecture and conventions",
592
- async execute() {
582
+ async execute(): Promise<AgentToolResult<undefined>> {
593
583
  if (!isLaravelProject(getCwd())) {
594
- return { content: [{ type: "text", text: "Not a Laravel project" }], isError: true };
584
+ throw new Error("Not a Laravel project");
595
585
  }
596
586
 
597
587
  // Parse models for the analysis
@@ -609,7 +599,7 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
609
599
  }
610
600
 
611
601
  const result = analyzeProject(getCwd(), allModels);
612
- return { content: [{ type: "text", text: result }] };
602
+ return { content: [{ type: "text", text: result }], details: undefined };
613
603
  },
614
604
  });
615
605
 
@@ -624,9 +614,7 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
624
614
  description: "Limit search to specific packages. Uses all detected packages if omitted.",
625
615
  }),
626
616
  ),
627
- token_limit: Type.Optional(
628
- Type.Integer({ description: "Max tokens in response. Default 3000, max 100000." }),
629
- ),
617
+ token_limit: Type.Optional(Type.Integer({ description: "Max tokens in response. Default 3000, max 100000." })),
630
618
  });
631
619
 
632
620
  elyra.registerTool({
@@ -636,9 +624,9 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
636
624
  "Search version-specific documentation for Laravel ecosystem packages (Laravel, Livewire, Inertia, Filament, Pest, Tailwind, etc). Uses semantic search across 17,000+ documentation entries. Always use this before consulting external documentation. Results are specific to the versions installed in this project.",
637
625
  parameters: docsSchema,
638
626
  promptSnippet: "Search Laravel ecosystem documentation for version-specific guidance",
639
- async execute(_toolCallId, params) {
627
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
640
628
  if (!isLaravelProject(getCwd())) {
641
- return { content: [{ type: "text", text: "Not a Laravel project" }], isError: true };
629
+ throw new Error("Not a Laravel project");
642
630
  }
643
631
 
644
632
  let packages = getInstalledPackages(getCwd());
@@ -662,14 +650,14 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
662
650
  });
663
651
 
664
652
  if (!response.ok) {
665
- return { content: [{ type: "text", text: `Docs API returned ${response.status}: ${await response.text()}` }], isError: true };
653
+ throw new Error(`Docs API returned ${response.status}: ${await response.text()}`);
666
654
  }
667
655
 
668
656
  const text = await response.text();
669
- return { content: [{ type: "text", text }] };
657
+ return { content: [{ type: "text", text }], details: undefined };
670
658
  } catch (err) {
671
659
  const message = err instanceof Error ? err.message : String(err);
672
- return { content: [{ type: "text", text: `Failed to fetch docs: ${message}` }], isError: true };
660
+ throw new Error(`Failed to fetch docs: ${message}`);
673
661
  }
674
662
  },
675
663
  });
@@ -678,7 +666,11 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
678
666
 
679
667
  const logsSchema = Type.Object({
680
668
  entries: Type.Optional(Type.Integer({ description: "Number of log entries to return. Default 10, max 50." })),
681
- level: Type.Optional(Type.String({ description: "Filter by log level: emergency, alert, critical, error, warning, notice, info, debug" })),
669
+ level: Type.Optional(
670
+ Type.String({
671
+ description: "Filter by log level: emergency, alert, critical, error, warning, notice, info, debug",
672
+ }),
673
+ ),
682
674
  });
683
675
 
684
676
  elyra.registerTool({
@@ -688,10 +680,10 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
688
680
  "Read recent log entries from the Laravel application log (storage/logs/laravel.log). Parses multi-line PSR-3 formatted entries. Use this to diagnose errors, check for warnings, or understand application behavior.",
689
681
  parameters: logsSchema,
690
682
  promptSnippet: "Read recent Laravel log entries",
691
- async execute(_toolCallId, params) {
683
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
692
684
  const logPath = join(getCwd(), "storage/logs/laravel.log");
693
685
  if (!existsSync(logPath)) {
694
- return { content: [{ type: "text", text: "Log file not found at storage/logs/laravel.log" }], isError: true };
686
+ throw new Error("Log file not found at storage/logs/laravel.log");
695
687
  }
696
688
 
697
689
  const content = readFileSync(logPath, "utf-8");
@@ -709,7 +701,17 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
709
701
  entries = entries.slice(-count);
710
702
 
711
703
  if (entries.length === 0) {
712
- return { content: [{ type: "text", text: params.level ? `No log entries found with level "${params.level}".` : "No log entries found." }] };
704
+ return {
705
+ content: [
706
+ {
707
+ type: "text",
708
+ text: params.level
709
+ ? `No log entries found with level "${params.level}".`
710
+ : "No log entries found.",
711
+ },
712
+ ],
713
+ details: undefined,
714
+ };
713
715
  }
714
716
 
715
717
  let output = entries.join("\n\n");
@@ -718,7 +720,7 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
718
720
  output = output.slice(-maxSize);
719
721
  }
720
722
 
721
- return { content: [{ type: "text", text: output }] };
723
+ return { content: [{ type: "text", text: output }], details: undefined };
722
724
  },
723
725
  });
724
726
 
@@ -733,10 +735,10 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
733
735
  "Get the most recent error or exception from the Laravel application log. Useful for quick debugging when something has gone wrong.",
734
736
  parameters: lastErrorSchema,
735
737
  promptSnippet: "Get the last error from Laravel logs",
736
- async execute() {
738
+ async execute(): Promise<AgentToolResult<undefined>> {
737
739
  const logPath = join(getCwd(), "storage/logs/laravel.log");
738
740
  if (!existsSync(logPath)) {
739
- return { content: [{ type: "text", text: "Log file not found at storage/logs/laravel.log" }], isError: true };
741
+ throw new Error("Log file not found at storage/logs/laravel.log");
740
742
  }
741
743
 
742
744
  const content = readFileSync(logPath, "utf-8");
@@ -748,13 +750,13 @@ function registerTools(elyra: ExtensionAPI, getCwd: () => string): void {
748
750
  if (match && errorLevels.has(match[1].toUpperCase())) {
749
751
  let entry = entries[i];
750
752
  if (entry.length > 2048) {
751
- entry = entry.slice(0, 2048) + "\n... (truncated)";
753
+ entry = `${entry.slice(0, 2048)}\n... (truncated)`;
752
754
  }
753
- return { content: [{ type: "text", text: entry }] };
755
+ return { content: [{ type: "text", text: entry }], details: undefined };
754
756
  }
755
757
  }
756
758
 
757
- return { content: [{ type: "text", text: "No error entries found in the log." }] };
759
+ return { content: [{ type: "text", text: "No error entries found in the log." }], details: undefined };
758
760
  },
759
761
  });
760
762
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/laravel",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "Deep Laravel project understanding for Elyra -- model relationships, route mapping, architecture analysis",
5
5
  "type": "module",
6
6
  "keywords": [