locadex 0.0.2-alpha.1 → 0.0.2-alpha.3

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 (156) hide show
  1. package/.locadex-mcp-stdio.json +9 -0
  2. package/.locadex-mcp.json +2 -3
  3. package/LICENSE.md +1 -1
  4. package/dist/cli.d.ts +1 -1
  5. package/dist/cli.d.ts.map +1 -1
  6. package/dist/cli.js +44 -9
  7. package/dist/cli.js.map +1 -1
  8. package/dist/commands/i18n.d.ts +1 -1
  9. package/dist/commands/i18n.d.ts.map +1 -1
  10. package/dist/commands/i18n.js +210 -140
  11. package/dist/commands/i18n.js.map +1 -1
  12. package/dist/commands/setup.d.ts +1 -1
  13. package/dist/commands/setup.d.ts.map +1 -1
  14. package/dist/commands/setup.js +85 -86
  15. package/dist/commands/setup.js.map +1 -1
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +5 -68
  19. package/dist/index.js.map +1 -1
  20. package/dist/{utils/logging.d.ts → logging/console.d.ts} +8 -12
  21. package/dist/logging/console.d.ts.map +1 -0
  22. package/dist/logging/console.js +134 -0
  23. package/dist/logging/console.js.map +1 -0
  24. package/dist/logging/constructInfo.d.ts +3 -0
  25. package/dist/logging/constructInfo.d.ts.map +1 -0
  26. package/dist/logging/constructInfo.js +15 -0
  27. package/dist/logging/constructInfo.js.map +1 -0
  28. package/dist/logging/logger.d.ts +24 -0
  29. package/dist/logging/logger.d.ts.map +1 -0
  30. package/dist/logging/logger.js +70 -0
  31. package/dist/logging/logger.js.map +1 -0
  32. package/dist/mcp/debugger.d.ts +3 -0
  33. package/dist/mcp/debugger.d.ts.map +1 -0
  34. package/dist/mcp/debugger.js +37 -0
  35. package/dist/mcp/debugger.js.map +1 -0
  36. package/dist/mcp/getDocs.d.ts.map +1 -0
  37. package/dist/mcp/getDocs.js +56 -0
  38. package/dist/mcp/getDocs.js.map +1 -0
  39. package/dist/mcp/getGuide.d.ts +5 -0
  40. package/dist/mcp/getGuide.d.ts.map +1 -0
  41. package/dist/mcp/getGuide.js +17 -0
  42. package/dist/mcp/getGuide.js.map +1 -0
  43. package/dist/{tools → mcp/tools}/docs.d.ts +3 -0
  44. package/dist/mcp/tools/docs.d.ts.map +1 -0
  45. package/dist/mcp/tools/docs.js +86 -0
  46. package/dist/mcp/tools/docs.js.map +1 -0
  47. package/dist/mcp/tools/fileManager.d.ts +6 -0
  48. package/dist/mcp/tools/fileManager.d.ts.map +1 -0
  49. package/dist/mcp/tools/fileManager.js +233 -0
  50. package/dist/mcp/tools/fileManager.js.map +1 -0
  51. package/dist/mcp/tools/guides.d.ts +11 -0
  52. package/dist/mcp/tools/guides.d.ts.map +1 -0
  53. package/dist/mcp/tools/guides.js +130 -0
  54. package/dist/mcp/tools/guides.js.map +1 -0
  55. package/dist/mcp-sse.d.ts +3 -0
  56. package/dist/mcp-sse.d.ts.map +1 -0
  57. package/dist/mcp-sse.js +72 -0
  58. package/dist/mcp-sse.js.map +1 -0
  59. package/dist/mcp.d.ts +3 -0
  60. package/dist/mcp.d.ts.map +1 -0
  61. package/dist/mcp.js +36 -0
  62. package/dist/mcp.js.map +1 -0
  63. package/dist/prompts/system.d.ts +4 -0
  64. package/dist/prompts/system.d.ts.map +1 -0
  65. package/dist/prompts/system.js +23 -0
  66. package/dist/prompts/system.js.map +1 -0
  67. package/dist/telemetry.d.ts +11 -0
  68. package/dist/telemetry.d.ts.map +1 -0
  69. package/dist/telemetry.js +104 -0
  70. package/dist/telemetry.js.map +1 -0
  71. package/dist/types/claude-sdk.d.ts +39 -0
  72. package/dist/types/claude-sdk.d.ts.map +1 -0
  73. package/dist/types/claude-sdk.js +5 -0
  74. package/dist/types/claude-sdk.js.map +1 -0
  75. package/dist/types/cli.d.ts +7 -0
  76. package/dist/types/cli.d.ts.map +1 -0
  77. package/dist/types/cli.js +5 -0
  78. package/dist/types/cli.js.map +1 -0
  79. package/dist/utils/agentManager.d.ts +22 -0
  80. package/dist/utils/agentManager.d.ts.map +1 -0
  81. package/dist/utils/agentManager.js +110 -0
  82. package/dist/utils/agentManager.js.map +1 -0
  83. package/dist/utils/claudeCode.d.ts +13 -5
  84. package/dist/utils/claudeCode.d.ts.map +1 -1
  85. package/dist/utils/claudeCode.js +155 -102
  86. package/dist/utils/claudeCode.js.map +1 -1
  87. package/dist/utils/dag/createDag.d.ts +24 -0
  88. package/dist/utils/dag/createDag.d.ts.map +1 -0
  89. package/dist/utils/dag/createDag.js +175 -0
  90. package/dist/utils/dag/createDag.js.map +1 -0
  91. package/dist/utils/debugLogger.d.ts +3 -0
  92. package/dist/utils/debugLogger.d.ts.map +1 -0
  93. package/dist/utils/debugLogger.js +36 -0
  94. package/dist/utils/debugLogger.js.map +1 -0
  95. package/dist/utils/fs/findConfigs.d.ts +11 -0
  96. package/dist/utils/fs/findConfigs.d.ts.map +1 -0
  97. package/dist/utils/fs/findConfigs.js +63 -0
  98. package/dist/utils/fs/findConfigs.js.map +1 -0
  99. package/dist/utils/fs/getFiles.d.ts +2 -0
  100. package/dist/utils/fs/getFiles.d.ts.map +1 -0
  101. package/dist/utils/fs/getFiles.js +8 -0
  102. package/dist/utils/fs/getFiles.js.map +1 -0
  103. package/dist/utils/fs/writeFiles.d.ts +2 -0
  104. package/dist/utils/fs/writeFiles.d.ts.map +1 -0
  105. package/dist/utils/fs/writeFiles.js +19 -0
  106. package/dist/utils/fs/writeFiles.js.map +1 -0
  107. package/dist/utils/getFiles.d.ts +30 -0
  108. package/dist/utils/getFiles.d.ts.map +1 -0
  109. package/dist/utils/getFiles.js +152 -0
  110. package/dist/utils/getFiles.js.map +1 -0
  111. package/dist/utils/getPaths.d.ts +1 -0
  112. package/dist/utils/getPaths.d.ts.map +1 -1
  113. package/dist/utils/getPaths.js +19 -3
  114. package/dist/utils/getPaths.js.map +1 -1
  115. package/dist/utils/mcpConfig.d.ts.map +1 -1
  116. package/dist/utils/mcpConfig.js +5 -2
  117. package/dist/utils/mcpConfig.js.map +1 -1
  118. package/dist/utils/shared.d.ts +2 -0
  119. package/dist/utils/shared.d.ts.map +1 -0
  120. package/dist/utils/shared.js +15 -0
  121. package/dist/utils/shared.js.map +1 -0
  122. package/dist/utils/validateConfig.d.ts +2 -0
  123. package/dist/utils/validateConfig.d.ts.map +1 -0
  124. package/dist/utils/validateConfig.js +12 -0
  125. package/dist/utils/validateConfig.js.map +1 -0
  126. package/guides/next/advanced/complicated-mapping-expressions.md +200 -0
  127. package/guides/next/advanced/interpolated-strings.md +162 -0
  128. package/guides/next/advanced/migrating.md +86 -0
  129. package/guides/next/advanced/ternary-operators.md +217 -0
  130. package/guides/next/advanced/var-outside-client-component.md +446 -0
  131. package/guides/next/advanced/var-outside-client-server-component.md +550 -0
  132. package/guides/next/advanced/var-outside-server-component.md +545 -0
  133. package/guides/next/basic/branches.md +282 -0
  134. package/guides/next/basic/client-side-components.md +214 -0
  135. package/guides/next/basic/jsx.md +259 -0
  136. package/guides/next/basic/locale-selector.md +5 -0
  137. package/guides/next/basic/server-side-components.md +164 -0
  138. package/guides/next/basic/setup.md +139 -0
  139. package/guides/next/basic/translating-html.md +36 -0
  140. package/guides/next/basic/variables.md +185 -0
  141. package/guides/next/important/functions.md +37 -0
  142. package/package.json +26 -13
  143. package/dist/resources/docs.d.ts +0 -4
  144. package/dist/resources/docs.d.ts.map +0 -1
  145. package/dist/resources/docs.js +0 -176
  146. package/dist/resources/docs.js.map +0 -1
  147. package/dist/tools/docs.d.ts.map +0 -1
  148. package/dist/tools/docs.js +0 -140
  149. package/dist/tools/docs.js.map +0 -1
  150. package/dist/utils/getDocs.d.ts.map +0 -1
  151. package/dist/utils/getDocs.js +0 -113
  152. package/dist/utils/getDocs.js.map +0 -1
  153. package/dist/utils/logging.d.ts.map +0 -1
  154. package/dist/utils/logging.js +0 -226
  155. package/dist/utils/logging.js.map +0 -1
  156. /package/dist/{utils → mcp}/getDocs.d.ts +0 -0
@@ -0,0 +1,185 @@
1
+ ## Variable Components Overview
2
+
3
+ Variable components wrap dynamic content like user names, numerical values, dates, and currencies. They format and render dynamic values according to the user's locale without requiring external translations.
4
+
5
+ **Import:** The variable components are exported from `gt-next`.
6
+
7
+ ```tsx
8
+ import { Var, Num, Currency, DateTime } from 'gt-next';
9
+ ```
10
+
11
+ **Key Behavior:**
12
+
13
+ - `<Var>`: Renders any content dynamically (user names, identifiers)
14
+ - `<Num>`: Formats numbers with locale-specific rules
15
+ - `<Currency>`: Formats currency with symbols and localization
16
+ - `<DateTime>`: Formats dates/times with locale conventions
17
+
18
+ **Processing Model:**
19
+
20
+ - JSX content → General Translation API for translation
21
+ - Variable components → Local formatting only (never sent to API)
22
+ - `<Num>`, `<Currency>`, `<DateTime>` → Use JS Intl API for locale formatting
23
+
24
+ **Important:** Content wrapped in variable components is never sent to the General Translation API, ensuring data privacy and security.
25
+
26
+ See the section on [Data Privacy](#privacy) for more information.
27
+
28
+ ---
29
+
30
+ ## Usage Patterns
31
+
32
+ ### Basic Syntax
33
+
34
+ All variable components use identical wrapping syntax:
35
+
36
+ ```tsx
37
+ <Var>{user.name}</Var>
38
+ <Num>{user.age}</Num>
39
+ <Currency>{user.balance}</Currency>
40
+ <DateTime>{user.birthday}</DateTime>
41
+ ```
42
+
43
+ ### Integration with `<T>` Components [#variable-in-t]
44
+
45
+ Variable components require locale context for formatting. Use within `<T>` components for automatic locale handling:
46
+
47
+ ```tsx
48
+ <T>
49
+ The current time is <DateTime>{time}</DateTime>.
50
+ </T>
51
+ ```
52
+
53
+ The `<T>` component provides locale context and translates surrounding text while preserving variable formatting.
54
+
55
+ ### Localization Behavior [#localization]
56
+
57
+ **Automatic Formatting:**
58
+
59
+ - `<Num>`: Localized decimal separators and number formatting
60
+ - `<Currency>`: Localized currency symbols and positioning
61
+ - `<DateTime>`: Locale-specific date/time conventions
62
+
63
+ **Customization:** Override default locale and formatting via component props.
64
+
65
+ ### Data Privacy [#privacy]
66
+
67
+ **Security Model:** Variable components process content locally and never send data to General Translation APIs.
68
+
69
+ **Use Cases by Component:**
70
+
71
+ - `<Var>`: Unformatted private data (user names, account numbers)
72
+ - `<Num>`: Private numbers needing locale formatting (quantities, ages, distances)
73
+ - `<Currency>`: Private currency values (transactions, balances)
74
+ - `<DateTime>`: Private dates/times (timestamps, creation dates)
75
+
76
+ **Warning - API Data Transmission Rules:**
77
+ - [Branching Components](/docs/next/guides/branches) and [`<T>` components](/docs/next/guides/jsx) → Sent to API
78
+ - `<T>` nested inside `<Var>` → Sent to API
79
+
80
+ ```tsx
81
+ <T>
82
+ <Var>
83
+ <T>Hello, World!</T> // → API Goodbye, World! // → Local only
84
+ </Var>
85
+ </T>
86
+ ```
87
+
88
+ ---
89
+
90
+ ## Implementation Examples
91
+
92
+ ### `<Var>` - Dynamic Content Isolation
93
+
94
+ **Basic Usage:** Always use with `<T>` for locale context.
95
+
96
+ ```jsx
97
+ <T>
98
+ Hello, <Var>{user.name}</Var>! Your address is <Var>{user.addr}</Var>
99
+ </T>
100
+ ```
101
+
102
+ **Dynamic Component Rendering:** Isolate conditional logic within `<T>`.
103
+
104
+ ```jsx
105
+ <T>
106
+ Your Dashboard:
107
+ <Var>{isAdmin ? <AdminDashboard /> : <UserDashboard />}</Var>
108
+ </T>
109
+ ```
110
+
111
+ **Rule:** Wrap all dynamic content in `<Var>` when using `<T>` components.
112
+
113
+ ### `<Num>` - Number Formatting
114
+
115
+ **Within `<T>`:** Automatic locale-aware formatting.
116
+
117
+ ```jsx
118
+ <T>
119
+ You have <Num>{quantity}</Num> items in your cart.
120
+ </T>
121
+ ```
122
+
123
+ **Standalone:** Equivalent to `quantity.toLocaleString()`
124
+
125
+ ```jsx
126
+ <Num>{quantity}</Num>
127
+ ```
128
+
129
+ ### `<Currency>` - Currency Formatting
130
+
131
+ **Within `<T>`:** Requires `currency` prop for proper formatting.
132
+
133
+ ```jsx
134
+ <T>
135
+ Your total is <Currency currency={'USD'}>{total}</Currency>.
136
+ </T>
137
+ ```
138
+
139
+ **Standalone:** Formats as localized currency (e.g., $1,000)
140
+
141
+ ```jsx
142
+ <Currency currency={'USD'}>{total}</Currency>
143
+ ```
144
+
145
+ ### `<DateTime>` - Date/Time Formatting
146
+
147
+ **Within `<T>`:** Automatic locale-aware date formatting.
148
+
149
+ ```jsx
150
+ <T>
151
+ Your order was placed on <DateTime>{date}</DateTime>.
152
+ </T>
153
+ ```
154
+
155
+ **Standalone:** Equivalent to `date.toLocaleDateString()` or `date.toLocaleTimeString()`
156
+
157
+ ```jsx
158
+ <DateTime>{date}</DateTime>
159
+ ```
160
+
161
+ ---
162
+
163
+ ## Common Implementation Issues
164
+
165
+ ### Missing Required Props [#localization-options]
166
+
167
+ **Critical:** `<Currency>` requires `currency` prop for proper symbol and formatting.
168
+
169
+ **Optimization:** All formatting components accept optional props for custom locale behavior.
170
+
171
+ ---
172
+
173
+ ## Key Principles
174
+
175
+ - **Data Isolation:** Variable components isolate dynamic content from translation processing
176
+ - **Privacy:** No data transmission to General Translation APIs
177
+ - **Flexibility:** Use as child of `<T>` or standalone component
178
+
179
+ ## API References
180
+
181
+ - [`<Var>`](/docs/next/api/components/var) - Dynamic content wrapper
182
+ - [`<Num>`](/docs/next/api/components/num) - Number formatting options
183
+ - [`<Currency>`](/docs/next/api/components/currency) - Currency formatting options
184
+ - [`<DateTime>`](/docs/next/api/components/datetime) - Date/time formatting options
185
+ - [Branching Components](/docs/next/guides/branches) - Conditional logic patterns
@@ -0,0 +1,37 @@
1
+ # Available imports for `gt-next`
2
+
3
+ ## IMPORTANT
4
+
5
+ - This is a comprehensive list of all the exports available in `gt-next`.
6
+ - **DO NOT** use any functions from `gt-next` that are not listed here.
7
+ - **DO NOT** change import paths. For example do not try to import from `gt-next` when something should be imported from `gt-next/client` or `gt-next/server`, and vice versa.
8
+ - When you are unsure about the correct usage of a function, please refer to the documentation by calling the MCP tools available to you.
9
+
10
+ ## Imports
11
+
12
+ ```tsx
13
+ import {
14
+ GTProvider,
15
+ T,
16
+ Tx,
17
+ Var,
18
+ Num,
19
+ Currency,
20
+ DateTime,
21
+ Branch,
22
+ Plural,
23
+ } from 'gt-next';
24
+
25
+ import {
26
+ useGT,
27
+ useLocale,
28
+ useLocales,
29
+ useSetLocale,
30
+ useDefaultLocale,
31
+ useDict,
32
+ LocaleSelector,
33
+ useLocaleSelector,
34
+ } from 'gt-next/client';
35
+
36
+ import { withGTConfig } from 'gt-next/config';
37
+ ```
package/package.json CHANGED
@@ -1,33 +1,44 @@
1
1
  {
2
2
  "name": "locadex",
3
- "version": "0.0.2-alpha.1",
3
+ "version": "0.0.2-alpha.3",
4
4
  "description": "An AI agent for internationalization",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "locadex": "dist/cli.js",
9
- "locadex-mcp": "dist/index.js"
9
+ "locadex-mcp": "dist/mcp.js"
10
10
  },
11
11
  "files": [
12
12
  "dist",
13
13
  "CHANGELOG.md",
14
- ".locadex-mcp.json"
14
+ ".locadex-mcp.json",
15
+ ".locadex-mcp-stdio.json",
16
+ "guides"
15
17
  ],
16
18
  "dependencies": {
19
+ "@anthropic-ai/claude-code": "^1.0.14",
20
+ "@anthropic-ai/sdk": "^0.52.0",
21
+ "@clack/prompts": "^1.0.0-alpha.1",
17
22
  "@modelcontextprotocol/sdk": "^1.12.0",
18
- "@anthropic-ai/claude-code": "1.0.8",
19
- "@clack/prompts": "^0.11.0",
23
+ "@sentry/cli": "^2.46.0",
24
+ "@sentry/node": "^9.26.0",
20
25
  "chalk": "^4.1.2",
21
26
  "commander": "^12.1.0",
22
- "dotenv": "^16.4.5"
27
+ "dependency-tree": "^11.1.1",
28
+ "dotenv": "^16.4.5",
29
+ "express": "^5.1.0",
30
+ "gtx-cli": "^1.2.23",
31
+ "posthog-node": "^4.18.0"
23
32
  },
24
33
  "devDependencies": {
25
34
  "@modelcontextprotocol/inspector": "^0.13.0",
35
+ "@types/express": "^5.0.2",
26
36
  "@types/jest": "^29.5.14",
27
37
  "@types/node": ">=20.0.0",
28
- "eslint": "^9.19.0",
29
38
  "@typescript-eslint/eslint-plugin": "^8.19.1",
30
39
  "@typescript-eslint/parser": "^8.19.1",
40
+ "eslint": "^9.19.0",
41
+ "eslint-plugin-import": "^2.31.0",
31
42
  "prettier": "^3.4.2",
32
43
  "tsx": "^4.16.5",
33
44
  "typescript": "^5.7.3"
@@ -35,17 +46,19 @@
35
46
  "scripts": {
36
47
  "patch": "npm version patch",
37
48
  "build": "tsc",
38
- "build:clean": "rm -rf dist; npm run lint && npm run build",
49
+ "build:release": "npm run build:clean && npm run sentry:sourcemaps",
50
+ "build:clean": "rm -rf dist && npm run build",
39
51
  "dev": "npm run build && node dist/index.js",
40
52
  "inspect": "npx @modelcontextprotocol/inspector node dist/index.js",
41
53
  "lint": "eslint .",
42
54
  "lint:fix": "eslint . --fix",
43
- "release": "npm run build:clean && npm publish --access public",
44
- "release:alpha": "npm run build:clean && npm publish --access public --tag alpha",
45
- "release:beta": "npm run build:clean && npm publish --access public --tag beta",
46
- "release:latest": "npm run build:clean && npm publish --access public --tag latest",
55
+ "release": "npm run build:release && npm publish --access public",
56
+ "release:alpha": "npm run build:release && npm publish --access public --tag alpha",
57
+ "release:beta": "npm run build:release && npm publish --access public --tag beta",
58
+ "release:latest": "npm run build:release && npm publish --access public --tag latest",
47
59
  "test": "vitest run",
48
- "test:watch": "vitest"
60
+ "test:watch": "vitest",
61
+ "sentry:sourcemaps": "sentry-cli sourcemaps inject --org general-translation --project locadex ./dist && sentry-cli sourcemaps upload --org general-translation --project locadex ./dist"
49
62
  },
50
63
  "repository": {
51
64
  "type": "git",
@@ -1,4 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- export declare function addDocsResource(server: McpServer): Promise<void>;
3
- export declare function startCacheRefreshJob(): () => void;
4
- //# sourceMappingURL=docs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/resources/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAEV,MAAM,yCAAyC,CAAC;AAGjD,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,iBA+EtD;AAGD,wBAAgB,oBAAoB,eAoBnC"}
@@ -1,176 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { ResourceTemplate, } from '@modelcontextprotocol/sdk/server/mcp.js';
38
- import { CACHE_TTL, fetchDocContent } from '../utils/getDocs.js';
39
- export function addDocsResource(server) {
40
- return __awaiter(this, void 0, void 0, function () {
41
- var _this = this;
42
- return __generator(this, function (_a) {
43
- // Add root resource for MCP docs
44
- server.resource('mcp-docs', new ResourceTemplate('mcp-docs://', {
45
- list: function () { return __awaiter(_this, void 0, void 0, function () {
46
- return __generator(this, function (_a) {
47
- return [2 /*return*/, ({
48
- resources: [
49
- {
50
- name: 'Standard LLM specification',
51
- uri: 'llms://llms.txt',
52
- },
53
- {
54
- name: 'Full LLM specification',
55
- uri: 'llms://llms-full.txt',
56
- },
57
- ],
58
- })];
59
- });
60
- }); },
61
- }), function (uri) { return __awaiter(_this, void 0, void 0, function () {
62
- return __generator(this, function (_a) {
63
- return [2 /*return*/, ({
64
- contents: [
65
- {
66
- uri: uri.href,
67
- text: 'MCP Documentation Resources',
68
- },
69
- ],
70
- })];
71
- });
72
- }); });
73
- // Resource for llms-full.txt
74
- server.resource('llms-full.txt', 'llms://llms-full.txt', function (uri) { return __awaiter(_this, void 0, void 0, function () {
75
- var content, error_1;
76
- return __generator(this, function (_a) {
77
- switch (_a.label) {
78
- case 0:
79
- _a.trys.push([0, 2, , 3]);
80
- return [4 /*yield*/, fetchDocContent('llms-full.txt')];
81
- case 1:
82
- content = _a.sent();
83
- return [2 /*return*/, {
84
- contents: [
85
- {
86
- uri: uri.href,
87
- text: content,
88
- },
89
- ],
90
- }];
91
- case 2:
92
- error_1 = _a.sent();
93
- console.error('Error retrieving llms-full.txt resource:', error_1);
94
- return [2 /*return*/, {
95
- contents: [
96
- {
97
- uri: uri.href,
98
- text: "Error: Unable to retrieve llms-full.txt resource. ".concat(error_1),
99
- },
100
- ],
101
- }];
102
- case 3: return [2 /*return*/];
103
- }
104
- });
105
- }); });
106
- // Resource for llms.txt
107
- server.resource('llms.txt', 'llms://llms.txt', function (uri) { return __awaiter(_this, void 0, void 0, function () {
108
- var content, error_2;
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- _a.trys.push([0, 2, , 3]);
113
- return [4 /*yield*/, fetchDocContent('llms.txt')];
114
- case 1:
115
- content = _a.sent();
116
- return [2 /*return*/, {
117
- contents: [
118
- {
119
- uri: uri.href,
120
- text: content,
121
- },
122
- ],
123
- }];
124
- case 2:
125
- error_2 = _a.sent();
126
- console.error('Error retrieving llms.txt resource:', error_2);
127
- return [2 /*return*/, {
128
- contents: [
129
- {
130
- uri: uri.href,
131
- text: "Error: Unable to retrieve llms.txt resource. ".concat(error_2),
132
- },
133
- ],
134
- }];
135
- case 3: return [2 /*return*/];
136
- }
137
- });
138
- }); });
139
- return [2 /*return*/];
140
- });
141
- });
142
- }
143
- // Start a background job to periodically refresh the cache
144
- export function startCacheRefreshJob() {
145
- var _this = this;
146
- var refreshCache = function () { return __awaiter(_this, void 0, void 0, function () {
147
- var error_3;
148
- return __generator(this, function (_a) {
149
- switch (_a.label) {
150
- case 0:
151
- _a.trys.push([0, 3, , 4]);
152
- console.error('Refreshing MCP resources cache...');
153
- return [4 /*yield*/, fetchDocContent('llms.txt')];
154
- case 1:
155
- _a.sent();
156
- return [4 /*yield*/, fetchDocContent('llms-full.txt')];
157
- case 2:
158
- _a.sent();
159
- console.error('Cache refresh complete');
160
- return [3 /*break*/, 4];
161
- case 3:
162
- error_3 = _a.sent();
163
- console.error('Error refreshing cache:', error_3);
164
- return [3 /*break*/, 4];
165
- case 4: return [2 /*return*/];
166
- }
167
- });
168
- }); };
169
- // Initial fetch
170
- refreshCache();
171
- // Set up periodic refresh
172
- var interval = setInterval(refreshCache, CACHE_TTL);
173
- // Return cleanup function
174
- return function () { return clearInterval(interval); };
175
- }
176
- //# sourceMappingURL=docs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/resources/docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,gBAAgB,GACjB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEjE,MAAM,UAAgB,eAAe,CAAC,MAAiB;;;;YACrD,iCAAiC;YACjC,MAAM,CAAC,QAAQ,CACb,UAAU,EACV,IAAI,gBAAgB,CAAC,aAAa,EAAE;gBAClC,IAAI,EAAE;;wBAAY,sBAAA,CAAC;gCACjB,SAAS,EAAE;oCACT;wCACE,IAAI,EAAE,4BAA4B;wCAClC,GAAG,EAAE,iBAAiB;qCACvB;oCACD;wCACE,IAAI,EAAE,wBAAwB;wCAC9B,GAAG,EAAE,sBAAsB;qCAC5B;iCACF;6BACF,CAAC,EAAA;;qBAAA;aACH,CAAC,EACF,UAAO,GAAG;;oBAAK,sBAAA,CAAC;4BACd,QAAQ,EAAE;gCACR;oCACE,GAAG,EAAE,GAAG,CAAC,IAAI;oCACb,IAAI,EAAE,6BAA6B;iCACpC;6BACF;yBACF,CAAC,EAAA;;iBAAA,CACH,CAAC;YAEF,6BAA6B;YAC7B,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE,sBAAsB,EAAE,UAAO,GAAG;;;;;;4BAE/C,qBAAM,eAAe,CAAC,eAAe,CAAC,EAAA;;4BAAhD,OAAO,GAAG,SAAsC;4BAEtD,sBAAO;oCACL,QAAQ,EAAE;wCACR;4CACE,GAAG,EAAE,GAAG,CAAC,IAAI;4CACb,IAAI,EAAE,OAAO;yCACd;qC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AA0B;IAC1B,IAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAEtD,0BAA0B;IAC1B,OAAO,cAAM,OAAA,aAAa,CAAC,QAAQ,CAAC,EAAvB,CAAuB,CAAC;AACvC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/tools/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,wBAAgB,YAAY,CAAC,MAAM,EAAE,SAAS,QAkG7C"}
@@ -1,140 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
12
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
- import { z } from 'zod';
38
- import { fetchDocContent, getDocs } from '../utils/getDocs.js';
39
- export function addDocsTools(server) {
40
- var _this = this;
41
- server.tool('fetch-docs', 'Fetches the content of a documentation file by its path.', {
42
- path: z
43
- .string()
44
- .describe('The path to the documentation file (e.g., "platform/index.mdx" or "react/introduction.mdx")'),
45
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
46
- var content, error_1;
47
- var path = _b.path;
48
- return __generator(this, function (_c) {
49
- switch (_c.label) {
50
- case 0:
51
- _c.trys.push([0, 2, , 3]);
52
- return [4 /*yield*/, getDocs(path)];
53
- case 1:
54
- content = _c.sent();
55
- if (!content) {
56
- return [2 /*return*/, {
57
- content: [
58
- {
59
- type: 'text',
60
- text: "Failed to fetch documentation for path: ".concat(path),
61
- },
62
- ],
63
- isError: true,
64
- }];
65
- }
66
- return [2 /*return*/, {
67
- content: [
68
- {
69
- type: 'text',
70
- text: content,
71
- },
72
- ],
73
- }];
74
- case 2:
75
- error_1 = _c.sent();
76
- return [2 /*return*/, {
77
- content: [
78
- {
79
- type: 'text',
80
- text: "Error fetching documentation: ".concat(error_1 instanceof Error ? error_1.message : String(error_1)),
81
- },
82
- ],
83
- isError: true,
84
- }];
85
- case 3: return [2 /*return*/];
86
- }
87
- });
88
- }); });
89
- server.tool('list-docs', 'Lists available documentation files in the format of an llms.txt or llms-full.txt file. "full" returns the full documentation, "short" returns a summary.', {
90
- type: z
91
- .enum(['full', 'short'])
92
- .default('short')
93
- .describe('Type of documentation list: "full" for llms-full.txt or "short" for llms.txt'),
94
- }, function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
95
- var filename, content, error_2;
96
- var type = _b.type;
97
- return __generator(this, function (_c) {
98
- switch (_c.label) {
99
- case 0:
100
- _c.trys.push([0, 2, , 3]);
101
- filename = type === 'full' ? 'llms-full.txt' : 'llms.txt';
102
- return [4 /*yield*/, fetchDocContent(filename)];
103
- case 1:
104
- content = _c.sent();
105
- if (!content) {
106
- return [2 /*return*/, {
107
- content: [
108
- {
109
- type: 'text',
110
- text: "Failed to fetch ".concat(filename, " documentation index"),
111
- },
112
- ],
113
- isError: true,
114
- }];
115
- }
116
- return [2 /*return*/, {
117
- content: [
118
- {
119
- type: 'text',
120
- text: content,
121
- },
122
- ],
123
- }];
124
- case 2:
125
- error_2 = _c.sent();
126
- return [2 /*return*/, {
127
- content: [
128
- {
129
- type: 'text',
130
- text: "Error listing documentation: ".concat(error_2 instanceof Error ? error_2.message : String(error_2)),
131
- },
132
- ],
133
- isError: true,
134
- }];
135
- case 3: return [2 /*return*/];
136
- }
137
- });
138
- }); });
139
- }
140
- //# sourceMappingURL=docs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../src/tools/docs.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,UAAU,YAAY,CAAC,MAAiB;IAA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