@elyracode/seo 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,6 +1,6 @@
1
1
  import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { basename, extname, join, relative } from "node:path";
3
- import type { ExtensionAPI } from "@elyracode/coding-agent";
3
+ import type { AgentToolResult, ExtensionAPI } from "@elyracode/coding-agent";
4
4
  import { Type } from "typebox";
5
5
 
6
6
  // ── Types ───────────────────────────────────────────────────────────────────
@@ -54,7 +54,17 @@ function isTemplateFile(filePath: string): boolean {
54
54
 
55
55
  function walkDir(dir: string, maxDepth = 8): string[] {
56
56
  const results: string[] = [];
57
- const ignored = new Set(["node_modules", ".git", ".next", ".nuxt", "dist", "build", ".output", "vendor", "__pycache__"]);
57
+ const ignored = new Set([
58
+ "node_modules",
59
+ ".git",
60
+ ".next",
61
+ ".nuxt",
62
+ "dist",
63
+ "build",
64
+ ".output",
65
+ "vendor",
66
+ "__pycache__",
67
+ ]);
58
68
 
59
69
  function walk(current: string, depth: number): void {
60
70
  if (depth > maxDepth) return;
@@ -84,15 +94,12 @@ function walkDir(dir: string, maxDepth = 8): string[] {
84
94
  }
85
95
 
86
96
  function analyzePage(filePath: string, content: string): PageMeta {
87
- const lower = content.toLowerCase();
88
-
89
97
  // Title
90
98
  const hasTitle = /<title[\s>]/i.test(content) || /["']title["']\s*:/i.test(content);
91
99
 
92
100
  // Meta description
93
101
  const hasDescription =
94
- /meta\s[^>]*name\s*=\s*["']description["']/i.test(content) ||
95
- /description\s*:/i.test(content);
102
+ /meta\s[^>]*name\s*=\s*["']description["']/i.test(content) || /description\s*:/i.test(content);
96
103
 
97
104
  // Canonical
98
105
  const hasCanonical = /rel\s*=\s*["']canonical["']/i.test(content);
@@ -273,9 +280,7 @@ function formatIssues(issues: AuditIssue[]): string {
273
280
  return lines.join("\n");
274
281
  }
275
282
 
276
- function detectSiteStructure(
277
- cwd: string,
278
- ): { pages: Array<{ title: string; path: string }>; framework: string | null } {
283
+ function detectSiteStructure(cwd: string): { pages: Array<{ title: string; path: string }>; framework: string | null } {
279
284
  const pages: Array<{ title: string; path: string }> = [];
280
285
  let framework: string | null = null;
281
286
 
@@ -320,7 +325,6 @@ function detectSiteStructure(
320
325
  try {
321
326
  const files = walkDir(fullDir, 3);
322
327
  for (const file of files) {
323
- const rel = relative(cwd, file);
324
328
  const name = basename(file, extname(file))
325
329
  .replace(/\.(page|route|view|blade)$/i, "")
326
330
  .replace(/[-_]/g, " ")
@@ -336,10 +340,7 @@ function detectSiteStructure(
336
340
  return { pages, framework };
337
341
  }
338
342
 
339
- function generateLlmsTxt(
340
- cwd: string,
341
- siteUrl: string,
342
- ): string {
343
+ function generateLlmsTxt(cwd: string, siteUrl: string): string {
343
344
  const { pages, framework } = detectSiteStructure(cwd);
344
345
 
345
346
  // Try to extract site name from package.json
@@ -387,9 +388,7 @@ function generateLlmsTxt(
387
388
  }
388
389
 
389
390
  function auditMetaTags(cwd: string, targetPath?: string): string {
390
- const files = targetPath
391
- ? [join(cwd, targetPath)]
392
- : walkDir(cwd);
391
+ const files = targetPath ? [join(cwd, targetPath)] : walkDir(cwd);
393
392
 
394
393
  if (files.length === 0) {
395
394
  return "No template files found to audit.";
@@ -440,9 +439,7 @@ export default function (elyra: ExtensionAPI): void {
440
439
  // ── seo_audit ────────────────────────────────────────────────────────
441
440
 
442
441
  const auditSchema = Type.Object({
443
- path: Type.Optional(
444
- Type.String({ description: "Relative path to audit. Omit to audit the entire project." }),
445
- ),
442
+ path: Type.Optional(Type.String({ description: "Relative path to audit. Omit to audit the entire project." })),
446
443
  });
447
444
 
448
445
  elyra.registerTool({
@@ -452,13 +449,16 @@ export default function (elyra: ExtensionAPI): void {
452
449
  "Analyze project files for SEO and LLM readability issues. Checks meta tags, headings, structured data, images, OpenGraph, Twitter Cards, and llms.txt. Returns a prioritized list of issues by severity.",
453
450
  parameters: auditSchema,
454
451
  promptSnippet: "Audit a project for SEO and LLM readability issues",
455
- async execute(_toolCallId, params) {
452
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
456
453
  try {
457
454
  const targetDir = params.path ? join(cwd, params.path) : cwd;
458
455
  const files = walkDir(targetDir);
459
456
 
460
457
  if (files.length === 0) {
461
- return { content: [{ type: "text", text: "No template files (HTML, JSX, Vue, etc.) found to audit." }] };
458
+ return {
459
+ content: [{ type: "text", text: "No template files (HTML, JSX, Vue, etc.) found to audit." }],
460
+ details: undefined,
461
+ };
462
462
  }
463
463
 
464
464
  const allIssues: AuditIssue[] = [];
@@ -487,10 +487,10 @@ export default function (elyra: ExtensionAPI): void {
487
487
  const header = `Scanned ${filesScanned} template file${filesScanned === 1 ? "" : "s"}${files.length > 50 ? ` (${files.length} total, showing first 50)` : ""}.\n\n`;
488
488
  const report = header + formatIssues(allIssues);
489
489
 
490
- return { content: [{ type: "text", text: report }] };
490
+ return { content: [{ type: "text", text: report }], details: undefined };
491
491
  } catch (error) {
492
492
  const msg = error instanceof Error ? error.message : String(error);
493
- return { content: [{ type: "text", text: `Audit error: ${msg}` }], isError: true };
493
+ throw new Error(`Audit error: ${msg}`);
494
494
  }
495
495
  },
496
496
  });
@@ -515,7 +515,7 @@ export default function (elyra: ExtensionAPI): void {
515
515
  "Generate an llms.txt file for LLM discoverability. Scans the project structure to find pages and routes, then creates a formatted llms.txt following the llmstxt.org specification. The generated file should be reviewed and edited by the user before deploying.",
516
516
  parameters: llmsTxtSchema,
517
517
  promptSnippet: "Generate llms.txt from project structure",
518
- async execute(_toolCallId, params) {
518
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
519
519
  try {
520
520
  const content = generateLlmsTxt(cwd, params.site_url);
521
521
  const outputPath = params.output_path ?? "public/llms.txt";
@@ -527,10 +527,11 @@ export default function (elyra: ExtensionAPI): void {
527
527
  text: `Generated llms.txt content for ${params.site_url}.\n\nSuggested path: ${outputPath}\n\n---\n\n${content}\n\n---\n\nReview and edit the content above, then write it to ${outputPath} using the write tool. Add descriptions to each page link for better LLM context.`,
528
528
  },
529
529
  ],
530
+ details: undefined,
530
531
  };
531
532
  } catch (error) {
532
533
  const msg = error instanceof Error ? error.message : String(error);
533
- return { content: [{ type: "text", text: `Generation error: ${msg}` }], isError: true };
534
+ throw new Error(`Generation error: ${msg}`);
534
535
  }
535
536
  },
536
537
  });
@@ -554,18 +555,19 @@ export default function (elyra: ExtensionAPI): void {
554
555
  "Analyze a template file and generate appropriate JSON-LD structured data. Returns the JSON-LD script tag to add to the page. If a schema.org type is not specified, suggests one based on the page content.",
555
556
  parameters: schemaSchema,
556
557
  promptSnippet: "Generate JSON-LD structured data for a page",
557
- async execute(_toolCallId, params) {
558
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
559
+ const filePath = join(cwd, params.file);
560
+ if (!existsSync(filePath)) {
561
+ throw new Error(`File not found: ${params.file}`);
562
+ }
558
563
  try {
559
- const filePath = join(cwd, params.file);
560
- if (!existsSync(filePath)) {
561
- return { content: [{ type: "text", text: `File not found: ${params.file}` }], isError: true };
562
- }
563
-
564
564
  const content = readFileSync(filePath, "utf-8");
565
565
  const lower = content.toLowerCase();
566
566
 
567
567
  // Detect existing JSON-LD
568
- const existingLd = content.match(/<script\s+type\s*=\s*["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi);
568
+ const existingLd = content.match(
569
+ /<script\s+type\s*=\s*["']application\/ld\+json["'][^>]*>([\s\S]*?)<\/script>/gi,
570
+ );
569
571
  let existingInfo = "";
570
572
  if (existingLd && existingLd.length > 0) {
571
573
  existingInfo = `\n\nExisting JSON-LD found (${existingLd.length} block${existingLd.length > 1 ? "s" : ""}):\n${existingLd.join("\n")}`;
@@ -710,10 +712,10 @@ export default function (elyra: ExtensionAPI): void {
710
712
  "Replace the UPPERCASE placeholders with actual values from the page content, then add this to the page using the edit tool.",
711
713
  ].join("\n");
712
714
 
713
- return { content: [{ type: "text", text: output }] };
715
+ return { content: [{ type: "text", text: output }], details: undefined };
714
716
  } catch (error) {
715
717
  const msg = error instanceof Error ? error.message : String(error);
716
- return { content: [{ type: "text", text: `Schema generation error: ${msg}` }], isError: true };
718
+ throw new Error(`Schema generation error: ${msg}`);
717
719
  }
718
720
  },
719
721
  });
@@ -722,7 +724,9 @@ export default function (elyra: ExtensionAPI): void {
722
724
 
723
725
  const metaSchema = Type.Object({
724
726
  path: Type.Optional(
725
- Type.String({ description: "Relative path to a specific file or directory. Omit to audit the entire project." }),
727
+ Type.String({
728
+ description: "Relative path to a specific file or directory. Omit to audit the entire project.",
729
+ }),
726
730
  ),
727
731
  });
728
732
 
@@ -733,13 +737,13 @@ export default function (elyra: ExtensionAPI): void {
733
737
  "Audit template files for missing meta tags (title, description, canonical, OpenGraph, Twitter Cards). Returns a per-file report of missing tags with recommendations.",
734
738
  parameters: metaSchema,
735
739
  promptSnippet: "Audit and report missing meta tags across the project",
736
- async execute(_toolCallId, params) {
740
+ async execute(_toolCallId, params): Promise<AgentToolResult<undefined>> {
737
741
  try {
738
742
  const report = auditMetaTags(cwd, params.path);
739
- return { content: [{ type: "text", text: report }] };
743
+ return { content: [{ type: "text", text: report }], details: undefined };
740
744
  } catch (error) {
741
745
  const msg = error instanceof Error ? error.message : String(error);
742
- return { content: [{ type: "text", text: `Meta tag audit error: ${msg}` }], isError: true };
746
+ throw new Error(`Meta tag audit error: ${msg}`);
743
747
  }
744
748
  },
745
749
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyracode/seo",
3
- "version": "0.9.56",
3
+ "version": "0.9.58",
4
4
  "description": "SEO and LLM optimization for Elyra -- audit, structured data, llms.txt, meta tags",
5
5
  "type": "module",
6
6
  "keywords": [