@genrtl/grtl 0.1.0 → 0.1.1

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/README.md CHANGED
@@ -83,7 +83,7 @@ not commit project-level MCP configuration containing a real key.
83
83
  The default endpoint is:
84
84
 
85
85
  ```text
86
- https://www.genrtl.com/api/mcp
86
+ https://genrtl.com/api/mcp
87
87
  ```
88
88
 
89
89
  Use `--base-url` for another deployment:
package/dist/index.js CHANGED
@@ -114,7 +114,7 @@ var SETUP_AGENT_NAMES = {
114
114
  antigravity: "Antigravity",
115
115
  gemini: "Gemini CLI"
116
116
  };
117
- var mcpBaseUrl = "https://www.genrtl.com/api/mcp";
117
+ var mcpBaseUrl = "https://genrtl.com/api/mcp";
118
118
  function setMcpBaseUrl(url) {
119
119
  const normalized = url.replace(/\/+$/, "");
120
120
  mcpBaseUrl = normalized.endsWith("/api/mcp") ? normalized : `${normalized}/api/mcp`;
@@ -651,7 +651,7 @@ var VERSION = pkg.version;
651
651
  var NAME = pkg.name;
652
652
 
653
653
  // src/utils/knowledge-api.ts
654
- var baseUrl = "https://www.genrtl.com";
654
+ var baseUrl = "https://genrtl.com";
655
655
  function setBaseUrl(url) {
656
656
  baseUrl = url.replace(/\/+$/, "");
657
657
  }
@@ -659,7 +659,14 @@ function getMcpEndpoint() {
659
659
  return baseUrl.endsWith("/api/mcp") ? baseUrl : `${baseUrl}/api/mcp`;
660
660
  }
661
661
  function getApiKey() {
662
- return process.env.GRTL_API_KEY || process.env.GENRTL_API_KEY;
662
+ return [process.env.GRTL_API_KEY, process.env.GENRTL_API_KEY].map((value) => value?.trim()).find((value) => Boolean(value));
663
+ }
664
+ function validateApiKey(apiKey) {
665
+ if (!/^gtr_(?:live|test)_[A-Za-z0-9_-]{32,128}$/.test(apiKey)) {
666
+ throw new Error(
667
+ "Invalid GenRTL API key format. Use the full key shown once when it was created; it must start with gtr_live_ or gtr_test_."
668
+ );
669
+ }
663
670
  }
664
671
  function getMcpErrorMessage(content) {
665
672
  if (!Array.isArray(content)) return void 0;
@@ -668,11 +675,20 @@ function getMcpErrorMessage(content) {
668
675
  );
669
676
  return item?.text;
670
677
  }
678
+ function getStructuredMcpError(content) {
679
+ if (!content || typeof content !== "object") return void 0;
680
+ const errorContent = content;
681
+ return {
682
+ error: typeof errorContent.error === "string" ? errorContent.error : void 0,
683
+ code: typeof errorContent.code === "string" ? errorContent.code : void 0
684
+ };
685
+ }
671
686
  async function callGenrtlKnowledgeTool(toolName, input) {
672
687
  const apiKey = getApiKey();
673
688
  if (!apiKey) {
674
689
  throw new Error("Authentication required. Set GRTL_API_KEY or GENRTL_API_KEY.");
675
690
  }
691
+ validateApiKey(apiKey);
676
692
  const response = await fetch(getMcpEndpoint(), {
677
693
  method: "POST",
678
694
  headers: {
@@ -698,7 +714,9 @@ async function callGenrtlKnowledgeTool(toolName, input) {
698
714
  const result = payload?.result;
699
715
  if (!result) throw new Error("GenRTL MCP returned an empty result.");
700
716
  if (result.isError) {
701
- throw new Error(getMcpErrorMessage(result.content) || "GenRTL knowledge search failed.");
717
+ const structuredError = getStructuredMcpError(result.structuredContent);
718
+ const message = structuredError?.error || getMcpErrorMessage(result.content) || "GenRTL knowledge search failed.";
719
+ throw new Error(structuredError?.code ? `${message} (${structuredError.code})` : message);
702
720
  }
703
721
  if (!result.structuredContent) {
704
722
  throw new Error("GenRTL MCP response did not include structured knowledge results.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genrtl/grtl",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "CLI for GenRTL RTL engineering knowledge and MCP setup",
5
5
  "type": "module",
6
6
  "bin": {
@@ -63,7 +63,7 @@
63
63
  "bugs": {
64
64
  "url": "https://github.com/xroting/grtl/issues"
65
65
  },
66
- "homepage": "https://www.genrtl.com",
66
+ "homepage": "https://genrtl.com",
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },