@standards-kit/conform 0.3.0 → 0.3.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.
@@ -165,7 +165,7 @@ function createListGuidelinesHandler(source) {
165
165
  // src/mcp/server.ts
166
166
  function createServer(options = {}) {
167
167
  const server = new McpServer({
168
- name: "cm-standards",
168
+ name: "standards",
169
169
  version: "1.0.0"
170
170
  });
171
171
  const { standardsSource } = options;
@@ -202,4 +202,4 @@ export {
202
202
  createServer,
203
203
  startServer
204
204
  };
205
- //# sourceMappingURL=mcp-T2JFU4E2.js.map
205
+ //# sourceMappingURL=mcp-DYQG6JEQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/mcp/server.ts","../src/mcp/tools/get-guideline.ts","../src/mcp/tools/get-ruleset.ts","../src/mcp/tools/get-standards.ts","../src/mcp/tools/list-guidelines.ts"],"sourcesContent":["/**\n * MCP Server for coding standards\n */\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport { loadConfigAsync } from \"../core/index.js\";\nimport {\n createGetGuidelineHandler,\n getGuidelineInputSchema,\n createGetRulesetHandler,\n getRulesetInputSchema,\n createGetStandardsHandler,\n getStandardsInputSchema,\n createListGuidelinesHandler,\n listGuidelinesInputSchema,\n} from \"./tools/index.js\";\n\n/** Options for creating the MCP server */\nexport interface CreateServerOptions {\n /** Standards repository source (e.g., \"github:owner/repo\" or local path) */\n standardsSource?: string;\n}\n\n/**\n * Create and configure the MCP server with all tools registered.\n */\nexport function createServer(options: CreateServerOptions = {}): McpServer {\n const server = new McpServer({\n name: \"standards\",\n version: \"1.0.0\",\n });\n\n const { standardsSource } = options;\n\n // Register get_standards tool - smart context matching\n server.registerTool(\"get_standards\", {\n description:\n \"Get composed coding standards matching a context string. Use this to fetch relevant guidelines for a specific technology stack or task.\",\n inputSchema: getStandardsInputSchema,\n }, createGetStandardsHandler(standardsSource));\n\n // Register list_guidelines tool\n server.registerTool(\"list_guidelines\", {\n description: \"List all available coding guidelines with optional category filter.\",\n inputSchema: listGuidelinesInputSchema,\n }, createListGuidelinesHandler(standardsSource));\n\n // Register get_guideline tool\n server.registerTool(\"get_guideline\", {\n description: \"Get a single coding guideline by its ID.\",\n inputSchema: getGuidelineInputSchema,\n }, createGetGuidelineHandler(standardsSource));\n\n // Register get_ruleset tool\n server.registerTool(\"get_ruleset\", {\n description:\n \"Get a tool configuration ruleset by ID (e.g., typescript-production, python-internal).\",\n inputSchema: getRulesetInputSchema,\n }, createGetRulesetHandler(standardsSource));\n\n return server;\n}\n\n/**\n * Start the MCP server with stdio transport.\n * Loads configuration from standards.toml to get the standards source.\n */\nexport async function startServer(): Promise<void> {\n let standardsSource: string | undefined;\n\n // Try to load config to get standards source\n try {\n const { config } = await loadConfigAsync();\n standardsSource = config.mcp?.standards?.source;\n } catch {\n // Config not found or invalid, use defaults\n }\n\n const server = createServer({ standardsSource });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","/**\n * MCP tool: get_guideline\n * Gets a single coding guideline by ID\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadGuideline,\n} from \"../standards/index.js\";\n\n/** Input schema for get_guideline tool */\nexport const getGuidelineInputSchema = {\n id: z.string().describe('Guideline ID (e.g., \"auth\", \"database\", \"typescript\")'),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n isError?: boolean;\n}\n\n/**\n * Create a get_guideline handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetGuidelineHandler(\n source?: string\n): (args: { id: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n const guideline = loadGuideline(guidelinesDir, args.id);\n\n if (!guideline) {\n return {\n content: [\n {\n type: \"text\",\n text: `Guideline not found: ${args.id}`,\n },\n ],\n isError: true,\n };\n }\n\n // Return full markdown content with frontmatter info\n const header = `# ${guideline.title}\\n\\n**Category:** ${guideline.category} | **Priority:** ${guideline.priority}\\n**Tags:** ${guideline.tags.join(\", \")}\\n\\n---\\n\\n`;\n\n return {\n content: [\n {\n type: \"text\",\n text: header + guideline.content,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: get_ruleset\n * Gets a tool configuration ruleset by ID\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getRulesetsDir,\n loadRuleset,\n listRulesets,\n} from \"../standards/index.js\";\n\n/** Input schema for get_ruleset tool */\nexport const getRulesetInputSchema = {\n id: z.string().describe('Ruleset ID (e.g., \"typescript-production\", \"python-internal\")'),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n isError?: boolean;\n}\n\n/**\n * Create a get_ruleset handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetRulesetHandler(\n source?: string\n): (args: { id: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const rulesetsDir = getRulesetsDir(repoPath);\n const ruleset = loadRuleset(rulesetsDir, args.id);\n\n if (!ruleset) {\n const available = listRulesets(rulesetsDir);\n return {\n content: [\n {\n type: \"text\",\n text: `Ruleset not found: ${args.id}\\n\\nAvailable rulesets:\\n${available.map((r) => `- ${r}`).join(\"\\n\")}`,\n },\n ],\n isError: true,\n };\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: `# Ruleset: ${ruleset.id}\\n\\n\\`\\`\\`toml\\n${ruleset.content}\\n\\`\\`\\``,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: get_standards\n * Gets composed coding standards matching a context string\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadAllGuidelines,\n matchGuidelines,\n composeGuidelines,\n} from \"../standards/index.js\";\n\n/** Input schema for get_standards tool */\nexport const getStandardsInputSchema = {\n context: z\n .string()\n .describe(\n 'Context string describing the task or technology stack (e.g., \"python fastapi llm postgresql\")'\n ),\n limit: z.number().optional().describe(\"Maximum number of guidelines to return (default: 5)\"),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n}\n\n/**\n * Create a get_standards handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetStandardsHandler(\n source?: string\n): (args: { context: string; limit?: number }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n const guidelines = loadAllGuidelines(guidelinesDir);\n\n const limit = args.limit ?? 5;\n const matches = matchGuidelines(guidelines, args.context, limit);\n\n const composed = composeGuidelines(matches);\n\n // Add summary header\n const summary =\n matches.length > 0\n ? `Found ${matches.length} matching guideline(s) for context: \"${args.context}\"\\n\\nMatched guidelines (by relevance):\\n${matches.map((m) => `- ${m.guideline.title} (score: ${m.score.toFixed(1)})`).join(\"\\n\")}\\n\\n---\\n\\n`\n : \"\";\n\n return {\n content: [\n {\n type: \"text\",\n text: summary + composed,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: list_guidelines\n * Lists all available coding guidelines with optional category filter\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadAllGuidelines,\n toListItems,\n} from \"../standards/index.js\";\n\n/** Input schema for list_guidelines tool */\nexport const listGuidelinesInputSchema = {\n category: z.string().optional().describe(\"Optional category filter (e.g., 'security', 'infrastructure')\"),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n}\n\n/**\n * Create a list_guidelines handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createListGuidelinesHandler(\n source?: string\n): (args: { category?: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n let guidelines = loadAllGuidelines(guidelinesDir);\n\n // Filter by category if provided\n if (args.category) {\n const categoryLower = args.category.toLowerCase();\n guidelines = guidelines.filter((g) => g.category.toLowerCase() === categoryLower);\n }\n\n const items = toListItems(guidelines);\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(items, null, 2),\n },\n ],\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;;;ACArC,SAAS,SAAS;AAUX,IAAM,0BAA0B;AAAA,EACrC,IAAI,EAAE,OAAO,EAAE,SAAS,uDAAuD;AACjF;AAaO,SAAS,0BACd,QACkD;AAClD,SAAO,OAAO,SAAS;AACrB,UAAM,WAAW,SACb,MAAM,6BAA6B,MAAM,IACzC,MAAM,mBAAmB;AAC7B,UAAM,gBAAgB,iBAAiB,QAAQ;AAC/C,UAAM,YAAY,cAAc,eAAe,KAAK,EAAE;AAEtD,QAAI,CAAC,WAAW;AACd,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,wBAAwB,KAAK,EAAE;AAAA,UACvC;AAAA,QACF;AAAA,QACA,SAAS;AAAA,MACX;AAAA,IACF;AAGA,UAAM,SAAS,KAAK,UAAU,KAAK;AAAA;AAAA,gBAAqB,UAAU,QAAQ,oBAAoB,UAAU,QAAQ;AAAA,YAAe,UAAU,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O,SAAS,aAAa,UAA+B,CAAC,GAAc;AACzE,QAAM,SAAS,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,EACX,CAAC;AAED,QAAM,EAAE,gBAAgB,IAAI;AAG5B,SAAO,aAAa,iBAAiB;AAAA,IACnC,aACE;AAAA,IACF,aAAa;AAAA,EACf,GAAG,0BAA0B,eAAe,CAAC;AAG7C,SAAO,aAAa,mBAAmB;AAAA,IACrC,aAAa;AAAA,IACb,aAAa;AAAA,EACf,GAAG,4BAA4B,eAAe,CAAC;AAG/C,SAAO,aAAa,iBAAiB;AAAA,IACnC,aAAa;AAAA,IACb,aAAa;AAAA,EACf,GAAG,0BAA0B,eAAe,CAAC;AAG7C,SAAO,aAAa,eAAe;AAAA,IACjC,aACE;AAAA,IACF,aAAa;AAAA,EACf,GAAG,wBAAwB,eAAe,CAAC;AAE3C,SAAO;AACT;AAMA,eAAsB,cAA6B;AACjD,MAAI;AAGJ,MAAI;AACF,UAAM,EAAE,OAAO,IAAI,MAAM,gBAAgB;AACzC,sBAAkB,OAAO,KAAK,WAAW;AAAA,EAC3C,QAAQ;AAAA,EAER;AAEA,QAAM,SAAS,aAAa,EAAE,gBAAgB,CAAC;AAC/C,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAChC;","names":["z","z","z","z","z","z"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@standards-kit/conform",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Standards conformance checking - in-repo enforcement CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/mcp/server.ts","../src/mcp/tools/get-guideline.ts","../src/mcp/tools/get-ruleset.ts","../src/mcp/tools/get-standards.ts","../src/mcp/tools/list-guidelines.ts"],"sourcesContent":["/**\n * MCP Server for coding standards\n */\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\n\nimport { loadConfigAsync } from \"../core/index.js\";\nimport {\n createGetGuidelineHandler,\n getGuidelineInputSchema,\n createGetRulesetHandler,\n getRulesetInputSchema,\n createGetStandardsHandler,\n getStandardsInputSchema,\n createListGuidelinesHandler,\n listGuidelinesInputSchema,\n} from \"./tools/index.js\";\n\n/** Options for creating the MCP server */\nexport interface CreateServerOptions {\n /** Standards repository source (e.g., \"github:owner/repo\" or local path) */\n standardsSource?: string;\n}\n\n/**\n * Create and configure the MCP server with all tools registered.\n */\nexport function createServer(options: CreateServerOptions = {}): McpServer {\n const server = new McpServer({\n name: \"cm-standards\",\n version: \"1.0.0\",\n });\n\n const { standardsSource } = options;\n\n // Register get_standards tool - smart context matching\n server.registerTool(\"get_standards\", {\n description:\n \"Get composed coding standards matching a context string. Use this to fetch relevant guidelines for a specific technology stack or task.\",\n inputSchema: getStandardsInputSchema,\n }, createGetStandardsHandler(standardsSource));\n\n // Register list_guidelines tool\n server.registerTool(\"list_guidelines\", {\n description: \"List all available coding guidelines with optional category filter.\",\n inputSchema: listGuidelinesInputSchema,\n }, createListGuidelinesHandler(standardsSource));\n\n // Register get_guideline tool\n server.registerTool(\"get_guideline\", {\n description: \"Get a single coding guideline by its ID.\",\n inputSchema: getGuidelineInputSchema,\n }, createGetGuidelineHandler(standardsSource));\n\n // Register get_ruleset tool\n server.registerTool(\"get_ruleset\", {\n description:\n \"Get a tool configuration ruleset by ID (e.g., typescript-production, python-internal).\",\n inputSchema: getRulesetInputSchema,\n }, createGetRulesetHandler(standardsSource));\n\n return server;\n}\n\n/**\n * Start the MCP server with stdio transport.\n * Loads configuration from standards.toml to get the standards source.\n */\nexport async function startServer(): Promise<void> {\n let standardsSource: string | undefined;\n\n // Try to load config to get standards source\n try {\n const { config } = await loadConfigAsync();\n standardsSource = config.mcp?.standards?.source;\n } catch {\n // Config not found or invalid, use defaults\n }\n\n const server = createServer({ standardsSource });\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n","/**\n * MCP tool: get_guideline\n * Gets a single coding guideline by ID\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadGuideline,\n} from \"../standards/index.js\";\n\n/** Input schema for get_guideline tool */\nexport const getGuidelineInputSchema = {\n id: z.string().describe('Guideline ID (e.g., \"auth\", \"database\", \"typescript\")'),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n isError?: boolean;\n}\n\n/**\n * Create a get_guideline handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetGuidelineHandler(\n source?: string\n): (args: { id: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n const guideline = loadGuideline(guidelinesDir, args.id);\n\n if (!guideline) {\n return {\n content: [\n {\n type: \"text\",\n text: `Guideline not found: ${args.id}`,\n },\n ],\n isError: true,\n };\n }\n\n // Return full markdown content with frontmatter info\n const header = `# ${guideline.title}\\n\\n**Category:** ${guideline.category} | **Priority:** ${guideline.priority}\\n**Tags:** ${guideline.tags.join(\", \")}\\n\\n---\\n\\n`;\n\n return {\n content: [\n {\n type: \"text\",\n text: header + guideline.content,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: get_ruleset\n * Gets a tool configuration ruleset by ID\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getRulesetsDir,\n loadRuleset,\n listRulesets,\n} from \"../standards/index.js\";\n\n/** Input schema for get_ruleset tool */\nexport const getRulesetInputSchema = {\n id: z.string().describe('Ruleset ID (e.g., \"typescript-production\", \"python-internal\")'),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n isError?: boolean;\n}\n\n/**\n * Create a get_ruleset handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetRulesetHandler(\n source?: string\n): (args: { id: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const rulesetsDir = getRulesetsDir(repoPath);\n const ruleset = loadRuleset(rulesetsDir, args.id);\n\n if (!ruleset) {\n const available = listRulesets(rulesetsDir);\n return {\n content: [\n {\n type: \"text\",\n text: `Ruleset not found: ${args.id}\\n\\nAvailable rulesets:\\n${available.map((r) => `- ${r}`).join(\"\\n\")}`,\n },\n ],\n isError: true,\n };\n }\n\n return {\n content: [\n {\n type: \"text\",\n text: `# Ruleset: ${ruleset.id}\\n\\n\\`\\`\\`toml\\n${ruleset.content}\\n\\`\\`\\``,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: get_standards\n * Gets composed coding standards matching a context string\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadAllGuidelines,\n matchGuidelines,\n composeGuidelines,\n} from \"../standards/index.js\";\n\n/** Input schema for get_standards tool */\nexport const getStandardsInputSchema = {\n context: z\n .string()\n .describe(\n 'Context string describing the task or technology stack (e.g., \"python fastapi llm postgresql\")'\n ),\n limit: z.number().optional().describe(\"Maximum number of guidelines to return (default: 5)\"),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n}\n\n/**\n * Create a get_standards handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createGetStandardsHandler(\n source?: string\n): (args: { context: string; limit?: number }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n const guidelines = loadAllGuidelines(guidelinesDir);\n\n const limit = args.limit ?? 5;\n const matches = matchGuidelines(guidelines, args.context, limit);\n\n const composed = composeGuidelines(matches);\n\n // Add summary header\n const summary =\n matches.length > 0\n ? `Found ${matches.length} matching guideline(s) for context: \"${args.context}\"\\n\\nMatched guidelines (by relevance):\\n${matches.map((m) => `- ${m.guideline.title} (score: ${m.score.toFixed(1)})`).join(\"\\n\")}\\n\\n---\\n\\n`\n : \"\";\n\n return {\n content: [\n {\n type: \"text\",\n text: summary + composed,\n },\n ],\n };\n };\n}\n","/**\n * MCP tool: list_guidelines\n * Lists all available coding guidelines with optional category filter\n */\nimport { z } from \"zod\";\n\nimport {\n fetchStandardsRepo,\n fetchStandardsRepoFromSource,\n getGuidelinesDir,\n loadAllGuidelines,\n toListItems,\n} from \"../standards/index.js\";\n\n/** Input schema for list_guidelines tool */\nexport const listGuidelinesInputSchema = {\n category: z.string().optional().describe(\"Optional category filter (e.g., 'security', 'infrastructure')\"),\n};\n\n/** Handler result type - must have index signature for MCP SDK */\ninterface HandlerResult {\n [x: string]: unknown;\n content: { type: \"text\"; text: string }[];\n}\n\n/**\n * Create a list_guidelines handler with optional custom source.\n * @param source - Optional standards source (e.g., \"github:owner/repo\" or local path)\n */\nexport function createListGuidelinesHandler(\n source?: string\n): (args: { category?: string }) => Promise<HandlerResult> {\n return async (args) => {\n const repoPath = source\n ? await fetchStandardsRepoFromSource(source)\n : await fetchStandardsRepo();\n const guidelinesDir = getGuidelinesDir(repoPath);\n let guidelines = loadAllGuidelines(guidelinesDir);\n\n // Filter by category if provided\n if (args.category) {\n const categoryLower = args.category.toLowerCase();\n guidelines = guidelines.filter((g) => g.category.toLowerCase() === categoryLower);\n }\n\n const items = toListItems(guidelines);\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(items, null, 2),\n },\n ],\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGA,SAAS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