@aws/nx-plugin 1.0.0-rc.48 → 1.0.0-rc.49
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/LICENSE-THIRD-PARTY +15 -0
- package/generators.json +7 -0
- package/migrations.json +5 -0
- package/package.json +4 -1
- package/src/mcp-server/guide-pipeline.js +1 -1
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/server.js +2 -0
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.d.ts +1 -1
- package/src/mcp-server/tools/general-guidance.js +1 -0
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/upgrade-workspace.d.ts +11 -0
- package/src/mcp-server/tools/upgrade-workspace.js +32 -0
- package/src/mcp-server/tools/upgrade-workspace.js.map +1 -0
- package/src/preset/__snapshots__/generator.spec.ts.snap +2 -0
- package/src/sdk/ts.d.ts +4 -2
- package/src/sdk/ts.js +4 -2
- package/src/sdk/ts.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +2 -1
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/agent/files/ag-ui/index.ts.template +25 -9
- package/src/ts/agent/files/common/agent.ts.template +2 -1
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +1 -0
- package/src/ts/nx-migration/files/migration.spec.ts.template +26 -0
- package/src/ts/nx-migration/files/migration.ts.template +55 -0
- package/src/ts/nx-migration/files/prompt.md.template +46 -0
- package/src/ts/nx-migration/generator.d.ts +24 -0
- package/src/ts/nx-migration/generator.js +122 -0
- package/src/ts/nx-migration/generator.js.map +1 -0
- package/src/ts/nx-migration/schema.d.js +6 -0
- package/src/ts/nx-migration/schema.d.js.map +1 -0
- package/src/ts/nx-migration/schema.d.ts +13 -0
- package/src/ts/nx-migration/schema.json +63 -0
- package/src/ts/nx-plugin/utils.d.ts +21 -1
- package/src/ts/nx-plugin/utils.js +43 -29
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/utils/agent-connection/agent-connection.js +4 -0
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-strands/base/tool-errors-strands.ts.template +22 -0
- package/src/utils/commands.d.ts +4 -3
- package/src/utils/commands.js +6 -2
- package/src/utils/commands.js.map +1 -1
- package/src/utils/migration-versions.d.ts +95 -0
- package/src/utils/migration-versions.js +128 -0
- package/src/utils/migration-versions.js.map +1 -0
- package/src/utils/nx.d.ts +5 -0
- package/src/utils/nx.js +1 -1
- package/src/utils/nx.js.map +1 -1
package/LICENSE-THIRD-PARTY
CHANGED
|
@@ -25979,6 +25979,21 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
25979
25979
|
|
|
25980
25980
|
---
|
|
25981
25981
|
|
|
25982
|
+
The following software may be included in this product: supports-color (10.2.2)
|
|
25983
|
+
This software contains the following license and notice below:
|
|
25984
|
+
|
|
25985
|
+
MIT License
|
|
25986
|
+
|
|
25987
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
25988
|
+
|
|
25989
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
25990
|
+
|
|
25991
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
25992
|
+
|
|
25993
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
25994
|
+
|
|
25995
|
+
---
|
|
25996
|
+
|
|
25982
25997
|
The following software may be included in this product: supports-preserve-symlinks-flag (1.0.0)
|
|
25983
25998
|
This software contains the following license and notice below:
|
|
25984
25999
|
|
package/generators.json
CHANGED
|
@@ -231,6 +231,13 @@
|
|
|
231
231
|
"metric": "g17",
|
|
232
232
|
"guidePages": ["nx-generator"]
|
|
233
233
|
},
|
|
234
|
+
"ts#nx-migration": {
|
|
235
|
+
"factory": "./src/ts/nx-migration/generator",
|
|
236
|
+
"schema": "./src/ts/nx-migration/schema.json",
|
|
237
|
+
"description": "Generator for adding an Nx Migration to an Nx Plugin, applied by nx migrate when users upgrade",
|
|
238
|
+
"metric": "g68",
|
|
239
|
+
"guidePages": ["nx-migration"]
|
|
240
|
+
},
|
|
234
241
|
"ts#nx-plugin": {
|
|
235
242
|
"factory": "./src/ts/nx-plugin/generator",
|
|
236
243
|
"schema": "./src/ts/nx-plugin/schema.json",
|
package/migrations.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws/nx-plugin",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.49",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/awslabs/nx-plugin-for-aws.git",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"generators": "./generators.json",
|
|
31
31
|
"executors": "./executors.json",
|
|
32
|
+
"nx-migrations": {
|
|
33
|
+
"migrations": "./migrations.json"
|
|
34
|
+
},
|
|
32
35
|
"engines": {
|
|
33
36
|
"node": ">=20.19.0"
|
|
34
37
|
},
|
|
@@ -326,8 +326,8 @@ const renderComponent = (node, opts, pm, deps)=>{
|
|
|
326
326
|
}
|
|
327
327
|
case 'InstallCommand':
|
|
328
328
|
{
|
|
329
|
+
// Without `pkg`, installs the workspace's existing dependencies
|
|
329
330
|
const pkg = readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');
|
|
330
|
-
if (!pkg) return undefined;
|
|
331
331
|
return [
|
|
332
332
|
codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev')))
|
|
333
333
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// inlineDynamicImports bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n if (!pkg) return undefined;\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,+BAA+B,QAC1B,uBAAoB;AAE3B,SACEC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SACEC,WA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ACyC,GACzC,MAAMsD,mBAAmB,CAACjF;IACxB,MAAM4E,SAAS3G,eAAe+B,MAAM;IACpC,IAAI,CAAC4E,QAAQ,OAAOjD;IACpB,IAAI;QACF,OAAOrD,6BAA6BsG;IACtC,EAAE,OAAM;QACN,OAAOjD;IACT;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/guide-pipeline.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport fs from 'fs';\n/**\n * Unified + remark-mdx pipeline for the MCP `generator-guide` tool.\n *\n * Passes (in order, each over the already-transformed tree):\n * 1. Snippet inlining — `<Snippet name>` → recursive post-process.\n * 2. Filter transforms — `<OptionFilter>`, `<Infrastructure>` slot\n * selection, `<Tabs><TabItem _filter>` pruning.\n * 3. Component transforms — `<NxCommands>` / `<RunGenerator>` /\n * `<GeneratorParameters>` / `<CreateNxWorkspaceCommand>` /\n * `<InstallCommand>` / `<PackageManagerShortCommand>` /\n * `<PackageManagerExecCommand>` render down to markdown.\n */\nimport type { Root, RootContent } from 'mdast';\nimport type { MdxJsxFlowElement } from 'mdast-util-mdx-jsx';\nimport {\n buildCreateNxWorkspaceCommand,\n buildInstallCommand,\n buildNxInitCommand,\n buildPackageManagerExecCommand,\n buildPackageManagerShortCommand,\n} from '../utils/commands';\nimport type { NxGeneratorInfo } from '../utils/generators';\nimport {\n buildNxCommand,\n renderGeneratorCommand,\n renderSchema,\n} from './guide-render';\nimport {\n hasBareAttr,\n isJsxElement,\n type JsxElement,\n type JsxParent,\n readEstreeAttr,\n readExpressionAttr,\n readStringAttr,\n} from './mdx-ast';\nimport {\n describePredicate,\n evaluatePredicate,\n extractStringArrayExpression,\n type Predicate,\n parseWhenExpression,\n} from './option-filter';\n\nexport interface PipelineOptions {\n generators: NxGeneratorInfo[];\n packageManager?: string;\n snippetContentProvider?: (name: string) => Promise<string> | string;\n options?: Record<string, string>;\n}\n\n// unified v11 is ESM-only and this package is CJS; dynamic import + rolldown's\n// inlineDynamicImports bundles everything into the published MCP binary.\ninterface RemarkDeps {\n unified: typeof import('unified').unified;\n remarkParse: typeof import('remark-parse').default;\n remarkMdx: typeof import('remark-mdx').default;\n remarkStringify: typeof import('remark-stringify').default;\n remarkFrontmatter: typeof import('remark-frontmatter').default;\n}\n\nlet depsPromise: Promise<RemarkDeps> | undefined;\nconst loadRemarkDeps = (): Promise<RemarkDeps> => {\n if (!depsPromise) {\n depsPromise = (async () => ({\n unified: (await import('unified')).unified,\n remarkParse: (await import('remark-parse')).default,\n remarkMdx: (await import('remark-mdx')).default,\n remarkStringify: (await import('remark-stringify')).default,\n remarkFrontmatter: (await import('remark-frontmatter')).default,\n }))();\n }\n return depsPromise;\n};\n\nconst parseMdxWithDeps = (source: string, deps: RemarkDeps): Root =>\n deps\n .unified()\n .use(deps.remarkParse)\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .parse(source) as Root;\n\n/** Parse MDX (with frontmatter) into mdast. Exposed so callers like\n * `fetchGuideFrontmatters` don't need to re-load remark themselves. */\nexport const parseMdx = async (source: string): Promise<Root> => {\n const deps = await loadRemarkDeps();\n return parseMdxWithDeps(source, deps);\n};\n\nconst stringifyMdx = (tree: Root, deps: RemarkDeps): string =>\n String(\n deps\n .unified()\n .use(deps.remarkFrontmatter)\n .use(deps.remarkMdx)\n .use(deps.remarkStringify, {\n bullet: '-',\n fences: true,\n listItemIndent: 'one',\n })\n .stringify(tree),\n );\n\n/**\n * Remove nodes that are meaningless once the MDX is rendered to plain markdown\n * for an agent: the YAML frontmatter block and the `import`/`export` (ESM)\n * statements at the top of every docs page. They add noise and tokens without\n * conveying guidance.\n */\nconst stripFrontmatterAndEsm = (tree: Root): void => {\n tree.children = tree.children.filter(\n (node) => node.type !== 'yaml' && node.type !== 'mdxjsEsm',\n );\n};\n\nexport const postProcessGuideWithRemark = async (\n guide: string,\n opts: PipelineOptions,\n): Promise<string> => {\n const deps = await loadRemarkDeps();\n const tree = parseMdxWithDeps(guide, deps);\n\n await inlineSnippets(tree, opts, deps);\n applyFilterTransforms(tree, opts.options);\n applyComponentTransforms(tree, opts, deps);\n stripFrontmatterAndEsm(tree);\n\n return stringifyMdx(tree, deps);\n};\n\nconst inlineSnippets = async (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): Promise<void> => {\n const provider = opts.snippetContentProvider;\n if (!provider) return;\n\n interface PendingSnippet {\n parent: JsxParent;\n index: number;\n name: string;\n node: JsxElement;\n }\n\n const pending: PendingSnippet[] = [];\n const walk = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n if (child.name === 'Snippet') {\n const name = readStringAttr(child, 'name');\n if (name) pending.push({ parent, index: i, name, node: child });\n continue;\n }\n walk(child);\n }\n };\n walk(tree);\n if (pending.length === 0) return;\n\n const fetched = await Promise.all(\n pending.map(async (p) => {\n let raw = '';\n try {\n raw = await provider(p.name);\n } catch {\n raw = '';\n }\n if (!raw) return { ...p, replacement: undefined };\n const processed = await postProcessGuideWithRemark(raw.trim(), opts);\n return { ...p, replacement: processed };\n }),\n );\n\n // Splice in descending index order per parent so earlier indices stay valid.\n const byParent = new Map<JsxParent, (typeof fetched)[number][]>();\n for (const f of fetched) {\n const bucket = byParent.get(f.parent) ?? [];\n bucket.push(f);\n byParent.set(f.parent, bucket);\n }\n for (const [parent, items] of byParent) {\n items.sort((a, b) => b.index - a.index);\n for (const { index, name, replacement, node } of items) {\n if (replacement === undefined) continue;\n const snippetTree = parseMdxWithDeps(replacement, deps);\n const wrapper: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'Snippet',\n attributes: [{ type: 'mdxJsxAttribute', name: 'name', value: name }],\n children: snippetTree.children as MdxJsxFlowElement['children'],\n };\n if ('position' in node && node.position) {\n (wrapper as { position?: unknown }).position = node.position;\n }\n (parent.children as RootContent[]).splice(\n index,\n 1,\n wrapper as RootContent,\n );\n }\n }\n};\n\nconst applyFilterTransforms = (\n tree: Root,\n options: Record<string, string> | undefined,\n): void => {\n const iac = options?.iac;\n\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n\n if (child.name === 'OptionFilter') {\n const when = parseWhenAttr(child);\n if (!when) continue; // malformed — leave alone\n // Recurse first so nested filters collapse before we replace this wrapper.\n transform(child);\n const not = hasBareAttr(child, 'not');\n if (options) {\n const replacement = evaluatePredicate(when, not, options)\n ? (child.children as RootContent[])\n : [];\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n } else {\n children.splice(i, 1, buildNoteQuote(child, when, not));\n }\n continue;\n }\n\n if (child.name === 'Infrastructure') {\n if (iac === 'cdk' || iac === 'terraform') {\n const body = selectInfrastructureSlot(child, iac);\n const pseudo: MdxJsxFlowElement = {\n type: 'mdxJsxFlowElement',\n name: 'tmp',\n attributes: [],\n children: body as MdxJsxFlowElement['children'],\n };\n transform(pseudo);\n children.splice(i, 1, ...(pseudo.children as RootContent[]));\n i--;\n continue;\n }\n // No iac → keep both slots so readers / agents see both variants.\n transform(child);\n continue;\n }\n\n if (child.name === 'Tabs' && child.type === 'mdxJsxFlowElement') {\n transform(child);\n const dropped = applyTabsFilter(child, options);\n if (dropped === 'empty') {\n children.splice(i, 1);\n i--;\n continue;\n }\n if (dropped === 'inline') {\n const survivor = (child.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) && c.name === 'TabItem',\n )!;\n const body = survivor.children as RootContent[];\n children.splice(i, 1, ...body);\n i += body.length - 1;\n continue;\n }\n continue;\n }\n\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst selectInfrastructureSlot = (\n node: JsxElement,\n iac: 'cdk' | 'terraform',\n): RootContent[] => {\n const slotName = iac.toLowerCase();\n const frag = (node.children as RootContent[]).find(\n (c): c is MdxJsxFlowElement =>\n isJsxElement(c) &&\n c.name === 'Fragment' &&\n readStringAttr(c, 'slot') === slotName,\n );\n return (frag?.children as RootContent[]) ?? [];\n};\n\n/**\n * Prune TabItems whose `_filter` doesn't match `options`. Returns:\n * - `'empty'` if the <Tabs> now has no <TabItem>s — caller drops it.\n * - `'inline'` if exactly one filtered <TabItem> survived — caller\n * inlines the body so agents see just the picked variant.\n * - `'keep'` otherwise.\n */\nconst applyTabsFilter = (\n tabs: MdxJsxFlowElement,\n options: Record<string, string> | undefined,\n): 'empty' | 'inline' | 'keep' => {\n const children = tabs.children as RootContent[];\n const surviving: RootContent[] = [];\n let anyFiltered = false;\n for (const child of children) {\n if (!isJsxElement(child) || child.name !== 'TabItem') {\n surviving.push(child);\n continue;\n }\n const filterEstree = readEstreeAttr(child, '_filter');\n if (!filterEstree) {\n surviving.push(child);\n continue;\n }\n anyFiltered = true;\n let predicate: Predicate;\n try {\n predicate = parseWhenExpression(filterEstree as never);\n } catch {\n stripFilterAttr(child);\n surviving.push(child);\n continue;\n }\n if (!options || evaluatePredicate(predicate, false, options)) {\n stripFilterAttr(child);\n surviving.push(child);\n }\n }\n if (anyFiltered) {\n tabs.children = surviving as MdxJsxFlowElement['children'];\n }\n const tabItems = surviving.filter(\n (c) => isJsxElement(c) && c.name === 'TabItem',\n );\n if (tabItems.length === 0 && surviving.length === 0) return 'empty';\n if (anyFiltered && tabItems.length === 1) return 'inline';\n return 'keep';\n};\n\nconst stripFilterAttr = (el: JsxElement): void => {\n el.attributes = el.attributes.filter(\n (a) => !(a.type === 'mdxJsxAttribute' && a.name === '_filter'),\n );\n};\n\n/**\n * `> [!NOTE] Only when …` blockquote. The alert header goes through as an\n * `html` node so remark-stringify doesn't escape the `[`/`]` brackets —\n * downstream agents match on the literal GitHub alert syntax.\n */\nconst buildNoteQuote = (\n source: JsxElement,\n predicate: Predicate,\n not: boolean,\n): RootContent => {\n const marker = describePredicate(predicate, not);\n const description = readStringAttr(source, 'description');\n const headerLines = description\n ? [`[!NOTE] ${marker}`, description]\n : [`[!NOTE] ${marker}`];\n const headerNodes: RootContent[] = headerLines.map(\n (line) => ({ type: 'html', value: line }) as RootContent,\n );\n return {\n type: 'blockquote',\n children: [...headerNodes, ...(source.children as RootContent[])] as never,\n } as RootContent;\n};\n\nconst parseWhenAttr = (node: JsxElement): Predicate | undefined => {\n const estree = readEstreeAttr(node, 'when');\n if (!estree) return undefined;\n try {\n return parseWhenExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n\nconst applyComponentTransforms = (\n tree: Root,\n opts: PipelineOptions,\n deps: RemarkDeps,\n): void => {\n const pm = opts.packageManager ?? 'pnpm';\n const transform = (parent: JsxParent): void => {\n const children = parent.children as RootContent[];\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (!isJsxElement(child)) continue;\n const replacement = renderComponent(child, opts, pm, deps);\n if (replacement !== undefined) {\n children.splice(i, 1, ...replacement);\n i += replacement.length - 1;\n continue;\n }\n transform(child);\n }\n };\n transform(tree);\n};\n\nconst renderComponent = (\n node: JsxElement,\n opts: PipelineOptions,\n pm: string,\n deps: RemarkDeps,\n): RootContent[] | undefined => {\n switch (node.name) {\n case 'NxCommands': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildNxCommand(c, opts.packageManager))\n .join('\\n'),\n ),\n ];\n }\n case 'RunGenerator': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(\n renderGeneratorCommand(generatorId, schema, opts.packageManager),\n deps,\n );\n }\n case 'GeneratorParameters': {\n const generatorId = readStringAttr(node, 'generator');\n if (!generatorId) return undefined;\n const schema = findSchema(opts.generators, generatorId);\n if (!schema) return undefined;\n return parseMarkdownFragment(renderSchema(schema), deps);\n }\n case 'CreateNxWorkspaceCommand': {\n const workspace = readStringAttr(node, 'workspace');\n if (!workspace) return undefined;\n const iac = readStringAttr(node, 'iac') as\n | 'cdk'\n | 'terraform'\n | undefined;\n return [codeBlock(buildCreateNxWorkspaceCommand(pm, workspace, iac))];\n }\n case 'NxInitCommand': {\n return [codeBlock(buildNxInitCommand(pm))];\n }\n case 'InstallCommand': {\n // Without `pkg`, installs the workspace's existing dependencies\n const pkg =\n readStringAttr(node, 'pkg') ?? readExpressionAttr(node, 'pkg');\n return [\n codeBlock(buildInstallCommand(pm, pkg, hasBareAttr(node, 'dev'))),\n ];\n }\n case 'PackageManagerShortCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands\n .map((c) => buildPackageManagerShortCommand(pm, c))\n .join('\\n'),\n ),\n ];\n }\n case 'PackageManagerExecCommand': {\n const commands = readCommandsAttr(node);\n if (!commands) return undefined;\n return [\n codeBlock(\n commands.map((c) => buildPackageManagerExecCommand(pm, c)).join('\\n'),\n ),\n ];\n }\n default:\n return undefined;\n }\n};\n\nconst codeBlock = (body: string): RootContent => ({\n type: 'code',\n lang: 'bash',\n value: body,\n});\n\nconst parseMarkdownFragment = (\n markdown: string,\n deps: RemarkDeps,\n): RootContent[] => {\n const fragTree = deps.unified().use(deps.remarkParse).parse(markdown) as Root;\n return fragTree.children as RootContent[];\n};\n\nconst findSchema = (\n generators: NxGeneratorInfo[],\n generatorId: string,\n):\n | { properties?: Record<string, unknown>; required?: string[] }\n | undefined => {\n const info = generators.find((g) => g.id === generatorId);\n if (!info) return undefined;\n try {\n return JSON.parse(fs.readFileSync(info.resolvedSchemaPath, 'utf-8'));\n } catch {\n return undefined;\n }\n};\n\n/** Parse the `commands={[…]}` attribute from the estree that remark-mdx\n * attaches to the JSX attribute value. */\nconst readCommandsAttr = (node: JsxElement): string[] | undefined => {\n const estree = readEstreeAttr(node, 'commands');\n if (!estree) return undefined;\n try {\n return extractStringArrayExpression(estree as never);\n } catch {\n return undefined;\n }\n};\n"],"names":["fs","buildCreateNxWorkspaceCommand","buildInstallCommand","buildNxInitCommand","buildPackageManagerExecCommand","buildPackageManagerShortCommand","buildNxCommand","renderGeneratorCommand","renderSchema","hasBareAttr","isJsxElement","readEstreeAttr","readExpressionAttr","readStringAttr","describePredicate","evaluatePredicate","extractStringArrayExpression","parseWhenExpression","depsPromise","loadRemarkDeps","unified","remarkParse","default","remarkMdx","remarkStringify","remarkFrontmatter","parseMdxWithDeps","source","deps","use","parse","parseMdx","stringifyMdx","tree","String","bullet","fences","listItemIndent","stringify","stripFrontmatterAndEsm","children","filter","node","type","postProcessGuideWithRemark","guide","opts","inlineSnippets","applyFilterTransforms","options","applyComponentTransforms","provider","snippetContentProvider","pending","walk","parent","i","length","child","name","push","index","fetched","Promise","all","map","p","raw","replacement","undefined","processed","trim","byParent","Map","f","bucket","get","set","items","sort","a","b","snippetTree","wrapper","attributes","value","position","splice","iac","transform","when","parseWhenAttr","not","buildNoteQuote","body","selectInfrastructureSlot","pseudo","dropped","applyTabsFilter","survivor","find","c","slotName","toLowerCase","frag","tabs","surviving","anyFiltered","filterEstree","predicate","stripFilterAttr","tabItems","el","marker","description","headerLines","headerNodes","line","estree","pm","packageManager","renderComponent","commands","readCommandsAttr","codeBlock","join","generatorId","schema","findSchema","generators","parseMarkdownFragment","workspace","pkg","lang","markdown","fragTree","info","g","id","JSON","readFileSync","resolvedSchemaPath"],"mappings":"AAAA;;;CAGC,GAED,OAAOA,QAAQ,KAAK;AAepB,SACEC,6BAA6B,EAC7BC,mBAAmB,EACnBC,kBAAkB,EAClBC,8BAA8B,EAC9BC,+BAA+B,QAC1B,uBAAoB;AAE3B,SACEC,cAAc,EACdC,sBAAsB,EACtBC,YAAY,QACP,oBAAiB;AACxB,SACEC,WAAW,EACXC,YAAY,EAGZC,cAAc,EACdC,kBAAkB,EAClBC,cAAc,QACT,eAAY;AACnB,SACEC,iBAAiB,EACjBC,iBAAiB,EACjBC,4BAA4B,EAE5BC,mBAAmB,QACd,qBAAkB;AAmBzB,IAAIC;AACJ,MAAMC,iBAAiB;IACrB,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
|
@@ -11,6 +11,7 @@ import { addCreateWorkspaceCommandTool } from "./tools/create-workspace-command.
|
|
|
11
11
|
import { addGeneralGuidanceTool, TOOL_SELECTION_GUIDE } from "./tools/general-guidance.js";
|
|
12
12
|
import { addGeneratorGuideTool } from "./tools/generator-guide.js";
|
|
13
13
|
import { addListGeneratorsTool } from "./tools/list-generators.js";
|
|
14
|
+
import { addUpgradeWorkspaceTool } from "./tools/upgrade-workspace.js";
|
|
14
15
|
/**
|
|
15
16
|
* Create the MCP Server
|
|
16
17
|
*/ export const createServer = ()=>{
|
|
@@ -34,6 +35,7 @@ ${TOOL_SELECTION_GUIDE}
|
|
|
34
35
|
addListGeneratorsTool(server, generators);
|
|
35
36
|
addGeneratorGuideTool(server, generators);
|
|
36
37
|
addToExistingProjectTool(server, generators);
|
|
38
|
+
addUpgradeWorkspaceTool(server, generators);
|
|
37
39
|
return server;
|
|
38
40
|
};
|
|
39
41
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { listGenerators } from '../utils/nx';\nimport { addToExistingProjectTool } from './tools/add-to-existing-project';\nimport { addCreateWorkspaceCommandTool } from './tools/create-workspace-command';\nimport {\n addGeneralGuidanceTool,\n TOOL_SELECTION_GUIDE,\n} from './tools/general-guidance';\nimport { addGeneratorGuideTool } from './tools/generator-guide';\nimport { addListGeneratorsTool } from './tools/list-generators';\n\n/**\n * Create the MCP Server\n */\nexport const createServer = () => {\n const generators = listGenerators();\n\n const server = new McpServer(\n {\n name: 'nx-plugin-for-aws',\n version: PackageJson.version,\n },\n {\n instructions: `# Nx Plugin for AWS MCP Server\n\nThis server provides resources and tools for quickly scaffolding AWS projects within an Nx workspace (monorepo), using the Nx Plugin for AWS (@aws/nx-plugin).\n\nThe Nx Plugin for AWS provides \"generators\" to add projects or functionality to your workspace. Use this to build the foundations of any project you are building\non AWS, if the generators apply to your use case.\n\n${TOOL_SELECTION_GUIDE}\n`,\n },\n );\n\n addGeneralGuidanceTool(server, generators);\n addCreateWorkspaceCommandTool(server);\n addListGeneratorsTool(server, generators);\n addGeneratorGuideTool(server, generators);\n addToExistingProjectTool(server, generators);\n\n return server;\n};\n"],"names":["McpServer","PackageJson","type","listGenerators","addToExistingProjectTool","addCreateWorkspaceCommandTool","addGeneralGuidanceTool","TOOL_SELECTION_GUIDE","addGeneratorGuideTool","addListGeneratorsTool","createServer","generators","server","name","version","instructions"],"mappings":"AAAA;;;CAGC,GACD,SAASA,SAAS,QAAQ,0CAA0C;AACpE,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM;AAAO,EAAE;AACnE,SAASC,cAAc,QAAQ,iBAAc;AAC7C,SAASC,wBAAwB,QAAQ,qCAAkC;AAC3E,SAASC,6BAA6B,QAAQ,sCAAmC;AACjF,SACEC,sBAAsB,EACtBC,oBAAoB,QACf,8BAA2B;AAClC,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,qBAAqB,QAAQ,6BAA0B;
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/mcp-server/server.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport PackageJson from '../../package.json' with { type: 'json' };\nimport { listGenerators } from '../utils/nx';\nimport { addToExistingProjectTool } from './tools/add-to-existing-project';\nimport { addCreateWorkspaceCommandTool } from './tools/create-workspace-command';\nimport {\n addGeneralGuidanceTool,\n TOOL_SELECTION_GUIDE,\n} from './tools/general-guidance';\nimport { addGeneratorGuideTool } from './tools/generator-guide';\nimport { addListGeneratorsTool } from './tools/list-generators';\nimport { addUpgradeWorkspaceTool } from './tools/upgrade-workspace';\n\n/**\n * Create the MCP Server\n */\nexport const createServer = () => {\n const generators = listGenerators();\n\n const server = new McpServer(\n {\n name: 'nx-plugin-for-aws',\n version: PackageJson.version,\n },\n {\n instructions: `# Nx Plugin for AWS MCP Server\n\nThis server provides resources and tools for quickly scaffolding AWS projects within an Nx workspace (monorepo), using the Nx Plugin for AWS (@aws/nx-plugin).\n\nThe Nx Plugin for AWS provides \"generators\" to add projects or functionality to your workspace. Use this to build the foundations of any project you are building\non AWS, if the generators apply to your use case.\n\n${TOOL_SELECTION_GUIDE}\n`,\n },\n );\n\n addGeneralGuidanceTool(server, generators);\n addCreateWorkspaceCommandTool(server);\n addListGeneratorsTool(server, generators);\n addGeneratorGuideTool(server, generators);\n addToExistingProjectTool(server, generators);\n addUpgradeWorkspaceTool(server, generators);\n\n return server;\n};\n"],"names":["McpServer","PackageJson","type","listGenerators","addToExistingProjectTool","addCreateWorkspaceCommandTool","addGeneralGuidanceTool","TOOL_SELECTION_GUIDE","addGeneratorGuideTool","addListGeneratorsTool","addUpgradeWorkspaceTool","createServer","generators","server","name","version","instructions"],"mappings":"AAAA;;;CAGC,GACD,SAASA,SAAS,QAAQ,0CAA0C;AACpE,OAAOC,iBAAiB,0BAA0B;IAAEC,MAAM;AAAO,EAAE;AACnE,SAASC,cAAc,QAAQ,iBAAc;AAC7C,SAASC,wBAAwB,QAAQ,qCAAkC;AAC3E,SAASC,6BAA6B,QAAQ,sCAAmC;AACjF,SACEC,sBAAsB,EACtBC,oBAAoB,QACf,8BAA2B;AAClC,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,uBAAuB,QAAQ,+BAA4B;AAEpE;;CAEC,GACD,OAAO,MAAMC,eAAe;IAC1B,MAAMC,aAAaT;IAEnB,MAAMU,SAAS,IAAIb,UACjB;QACEc,MAAM;QACNC,SAASd,YAAYc,OAAO;IAC9B,GACA;QACEC,cAAc,CAAC;;;;;;;AAOrB,EAAET,qBAAqB;AACvB,CAAC;IACG;IAGFD,uBAAuBO,QAAQD;IAC/BP,8BAA8BQ;IAC9BJ,sBAAsBI,QAAQD;IAC9BJ,sBAAsBK,QAAQD;IAC9BR,yBAAyBS,QAAQD;IACjCF,wBAAwBG,QAAQD;IAEhC,OAAOC;AACT,EAAE"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
6
|
import type { NxGeneratorInfo } from '../../utils/generators';
|
|
7
|
-
export declare const TOOL_SELECTION_GUIDE = "## Tool Selection Guide\n\n- Use the `general-guidance` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the `create-workspace-command` tool to discover how to create a workspace to start a new project.\n- Use the `add-to-existing-project` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the `list-generators` tool to discover the available generators and how to run them.\n- Use the `generator-guide` tool to retrieve detailed information about a specific generator.";
|
|
7
|
+
export declare const TOOL_SELECTION_GUIDE = "## Tool Selection Guide\n\n- Use the `general-guidance` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the `create-workspace-command` tool to discover how to create a workspace to start a new project.\n- Use the `add-to-existing-project` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the `upgrade-workspace` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the `list-generators` tool to discover the available generators and how to run them.\n- Use the `generator-guide` tool to retrieve detailed information about a specific generator.";
|
|
8
8
|
/**
|
|
9
9
|
* Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS
|
|
10
10
|
*/
|
|
@@ -9,6 +9,7 @@ export const TOOL_SELECTION_GUIDE = `## Tool Selection Guide
|
|
|
9
9
|
- Use the \`general-guidance\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.
|
|
10
10
|
- Use the \`create-workspace-command\` tool to discover how to create a workspace to start a new project.
|
|
11
11
|
- Use the \`add-to-existing-project\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.
|
|
12
|
+
- Use the \`upgrade-workspace\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.
|
|
12
13
|
- Use the \`list-generators\` tool to discover the available generators and how to run them.
|
|
13
14
|
- Use the \`generator-guide\` tool to retrieve detailed information about a specific generator.`;
|
|
14
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/general-guidance.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { NxGeneratorInfo } from '../../utils/generators';\nimport { IAC_PROVIDERS } from '../../utils/iac-providers';\nimport { buildNxCommand, fetchGuidePages } from '../generator-info';\nimport { PACKAGE_MANAGERS } from '../schema';\n\nexport const TOOL_SELECTION_GUIDE = `## Tool Selection Guide\n\n- Use the \\`general-guidance\\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the \\`create-workspace-command\\` tool to discover how to create a workspace to start a new project.\n- Use the \\`add-to-existing-project\\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the \\`list-generators\\` tool to discover the available generators and how to run them.\n- Use the \\`generator-guide\\` tool to retrieve detailed information about a specific generator.`;\n\n/**\n * Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS\n */\nexport const addGeneralGuidanceTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'general-guidance',\n {\n title: 'General Guidance',\n description:\n 'Tool for guidance and best practices for working with Nx and the Nx Plugin for AWS',\n },\n async () => ({\n content: [\n {\n type: 'text' as const,\n text: `# Nx Plugin for AWS Guidance\n\n${TOOL_SELECTION_GUIDE}\n\n## Getting Started\n\n- Choose a package manager first. You can choose between ${PACKAGE_MANAGERS.join(', ')}. It's recommended to use \"pnpm\" if the user has no preference\n- Choose an infrastructure as code (IaC) provider next. You can choose between ${IAC_PROVIDERS.join(', ')}. It's recommended to use CDK if the user has no preference\n- Next, you must create an Nx workspace. Use the \\`create-workspace-command\\` tool for more details, and provide it with your chosen package manager\n- After this, you can start scaffolding the main components of your application using generators. Use the \\`list-generators\\` tool to discover available generators, and the \\`generator-guide\\` tool for more detailed information about a specific generator\n\n## Nx Primer\n\n- Prefix nx commands with the appropriate prefix for your package manager, for example:\n${PACKAGE_MANAGERS.map((pm) => buildNxCommand('<options>', pm)).join(' - \\n')}\n- Each project in your workspace has a file named \\`project.json\\` which contains important project information such as its name, and defines the \"targets\" which can be run for that project, for example building or testing the project\n- Use the command \\`nx reset\\` to reset the Nx daemon when unexpected issues arise\n- After adding dependencies between TypeScript projects, use \\`nx sync\\` to ensure project references are set up correctly\n\n## General Instructions\n\n- Each project declares the third-party runtime dependencies its source imports in its own \\`package.json\\`; shared build/test tooling (test runners, bundlers, etc.) is declared in the root \\`package.json\\` \\`devDependencies\\`. Versions follow a single version policy, recorded in the package manager's dependency catalog where supported (referenced as \\`catalog:\\`). Install with the appropriate command for your package manager:\n - Add a project runtime dependency: \\`pnpm add <package> --filter <project>\\` / \\`yarn workspace <project> add <package>\\` / \\`npm install <package> -w <project>\\` / \\`bun add <package> --cwd <project-directory>\\`\n - Add a shared dev tool at the root: \\`pnpm add -Dw <package>\\` / \\`yarn add -D <package>\\` / \\`npm install --legacy-peer-deps -D <package>\\` / \\`bun install -D <package>\\`\n- The \\`noUndeclaredDependencies\\` lint rule enforces that a project's source only imports packages declared in its own \\`package.json\\`\n- Projects in the same workspace can import one another directly by package name (eg \\`@workspace-name/project-name\\`) without declaring a dependency in \\`package.json\\` — TypeScript path aliases in \\`tsconfig.base.json\\` resolve these imports\n- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example \\`@workspace-name/project-name\\`. Check the \\`project.json\\` file for the specific package to find its fully qualified name\n- When no generator exists for a specific framework required, use the base \\`ts#project\\` and \\`py#project\\` generators and build on top.\n- Leave the \\`--infra\\` option at its default value unless the user has explicitly instructed otherwise. Generators choose a sensible default type of infrastructure to deploy the project with, so only override \\`--infra\\` when the user has specified a particular requirement.\n\n## Useful Commands\n\n- Fix lint issues with \\`nx run-many --target lint --configuration=fix --all --output-style=stream\\`\n- Build all projects with \\`nx run-many --target build --all --output-style=stream\\`\n- Prefer importing the CDK constructs vended by generators in \\`packages/common/constructs\\` over writing your own\n\n## Best Practices\n\n- After running a generator, use the \\`nx show projects\\` command to check which projects have been added (if any)\n- Carefully examine the files that have been generated and always refer back to the generator guide when working in a generated project\n- Generate all projects into the \\`packages/\\` directory\n- After making changes to your projects, fix linting issues, then run a full build\n- When it's time to start testing a project, suggest to the user that infrastructure is deployed to AWS. For websites, if a runtime-config.json is needed, use the load:runtime-config target after a deployment to point a local website at a sandbox stack.\n\n## Batching Generators\n\nWhen scaffolding several projects in one go, chain generators to avoid a slow dependency install after every generator:\n\n- **Chain generators** with \\`&&\\` in a single command. Pass \\`--prefer-install-dependencies=false\\` on each generator except the last so dependencies install once at the end, for example:\n\n${PACKAGE_MANAGERS.map(\n (pm) => ` \\`\\`\\`bash\n ${buildNxCommand('g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=IAM --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#react-website --no-interactive --name=my-app-website --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:connection --no-interactive --sourceProject=@my-app/my-app-website --targetProject=@my-app/my-app-api --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#infra --no-interactive --name=infra', pm)} && \\\\\n ${buildNxCommand('sync', pm)}\n \\`\\`\\``,\n).join('\\n')}\n\n- **\\`--prefer-install-dependencies=false\\`** asks a generator to defer its dependency install so the batch installs once at the end (the final generator above omits the flag and installs everything).\n- **\\`nx sync\\`** is required before building — generators modify TypeScript project references.\n\n## Detailed Guides\n\nPlease refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects.\n\n${await fetchGuidePages(['workspace', 'typescript-project', 'python-project'], generators)}\n\n `,\n },\n ],\n }),\n );\n};\n"],"names":["IAC_PROVIDERS","buildNxCommand","fetchGuidePages","PACKAGE_MANAGERS","TOOL_SELECTION_GUIDE","addGeneralGuidanceTool","server","generators","registerTool","title","description","content","type","text","join","map","pm"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,aAAa,QAAQ,+BAA4B;AAC1D,SAASC,cAAc,EAAEC,eAAe,QAAQ,uBAAoB;AACpE,SAASC,gBAAgB,QAAQ,eAAY;AAE7C,OAAO,MAAMC,uBAAuB,CAAC
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/general-guidance.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { NxGeneratorInfo } from '../../utils/generators';\nimport { IAC_PROVIDERS } from '../../utils/iac-providers';\nimport { buildNxCommand, fetchGuidePages } from '../generator-info';\nimport { PACKAGE_MANAGERS } from '../schema';\n\nexport const TOOL_SELECTION_GUIDE = `## Tool Selection Guide\n\n- Use the \\`general-guidance\\` tool for guidance and best practices for working with Nx and the Nx Plugin for AWS.\n- Use the \\`create-workspace-command\\` tool to discover how to create a workspace to start a new project.\n- Use the \\`add-to-existing-project\\` tool when adding the plugin to an existing Nx workspace or non-Nx monorepo, or when troubleshooting configuration errors in such a workspace.\n- Use the \\`upgrade-workspace\\` tool when upgrading Nx or the Nx Plugin for AWS to a newer version.\n- Use the \\`list-generators\\` tool to discover the available generators and how to run them.\n- Use the \\`generator-guide\\` tool to retrieve detailed information about a specific generator.`;\n\n/**\n * Add a tool which provides general guidance for using Nx and the Nx Plugin for AWS\n */\nexport const addGeneralGuidanceTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'general-guidance',\n {\n title: 'General Guidance',\n description:\n 'Tool for guidance and best practices for working with Nx and the Nx Plugin for AWS',\n },\n async () => ({\n content: [\n {\n type: 'text' as const,\n text: `# Nx Plugin for AWS Guidance\n\n${TOOL_SELECTION_GUIDE}\n\n## Getting Started\n\n- Choose a package manager first. You can choose between ${PACKAGE_MANAGERS.join(', ')}. It's recommended to use \"pnpm\" if the user has no preference\n- Choose an infrastructure as code (IaC) provider next. You can choose between ${IAC_PROVIDERS.join(', ')}. It's recommended to use CDK if the user has no preference\n- Next, you must create an Nx workspace. Use the \\`create-workspace-command\\` tool for more details, and provide it with your chosen package manager\n- After this, you can start scaffolding the main components of your application using generators. Use the \\`list-generators\\` tool to discover available generators, and the \\`generator-guide\\` tool for more detailed information about a specific generator\n\n## Nx Primer\n\n- Prefix nx commands with the appropriate prefix for your package manager, for example:\n${PACKAGE_MANAGERS.map((pm) => buildNxCommand('<options>', pm)).join(' - \\n')}\n- Each project in your workspace has a file named \\`project.json\\` which contains important project information such as its name, and defines the \"targets\" which can be run for that project, for example building or testing the project\n- Use the command \\`nx reset\\` to reset the Nx daemon when unexpected issues arise\n- After adding dependencies between TypeScript projects, use \\`nx sync\\` to ensure project references are set up correctly\n\n## General Instructions\n\n- Each project declares the third-party runtime dependencies its source imports in its own \\`package.json\\`; shared build/test tooling (test runners, bundlers, etc.) is declared in the root \\`package.json\\` \\`devDependencies\\`. Versions follow a single version policy, recorded in the package manager's dependency catalog where supported (referenced as \\`catalog:\\`). Install with the appropriate command for your package manager:\n - Add a project runtime dependency: \\`pnpm add <package> --filter <project>\\` / \\`yarn workspace <project> add <package>\\` / \\`npm install <package> -w <project>\\` / \\`bun add <package> --cwd <project-directory>\\`\n - Add a shared dev tool at the root: \\`pnpm add -Dw <package>\\` / \\`yarn add -D <package>\\` / \\`npm install --legacy-peer-deps -D <package>\\` / \\`bun install -D <package>\\`\n- The \\`noUndeclaredDependencies\\` lint rule enforces that a project's source only imports packages declared in its own \\`package.json\\`\n- Projects in the same workspace can import one another directly by package name (eg \\`@workspace-name/project-name\\`) without declaring a dependency in \\`package.json\\` — TypeScript path aliases in \\`tsconfig.base.json\\` resolve these imports\n- When specifying project names as arguments to generators, prefer the _fully qualified_ project name, for example \\`@workspace-name/project-name\\`. Check the \\`project.json\\` file for the specific package to find its fully qualified name\n- When no generator exists for a specific framework required, use the base \\`ts#project\\` and \\`py#project\\` generators and build on top.\n- Leave the \\`--infra\\` option at its default value unless the user has explicitly instructed otherwise. Generators choose a sensible default type of infrastructure to deploy the project with, so only override \\`--infra\\` when the user has specified a particular requirement.\n\n## Useful Commands\n\n- Fix lint issues with \\`nx run-many --target lint --configuration=fix --all --output-style=stream\\`\n- Build all projects with \\`nx run-many --target build --all --output-style=stream\\`\n- Prefer importing the CDK constructs vended by generators in \\`packages/common/constructs\\` over writing your own\n\n## Best Practices\n\n- After running a generator, use the \\`nx show projects\\` command to check which projects have been added (if any)\n- Carefully examine the files that have been generated and always refer back to the generator guide when working in a generated project\n- Generate all projects into the \\`packages/\\` directory\n- After making changes to your projects, fix linting issues, then run a full build\n- When it's time to start testing a project, suggest to the user that infrastructure is deployed to AWS. For websites, if a runtime-config.json is needed, use the load:runtime-config target after a deployment to point a local website at a sandbox stack.\n\n## Batching Generators\n\nWhen scaffolding several projects in one go, chain generators to avoid a slow dependency install after every generator:\n\n- **Chain generators** with \\`&&\\` in a single command. Pass \\`--prefer-install-dependencies=false\\` on each generator except the last so dependencies install once at the end, for example:\n\n${PACKAGE_MANAGERS.map(\n (pm) => ` \\`\\`\\`bash\n ${buildNxCommand('g @aws/nx-plugin:ts#trpc-api --no-interactive --name=my-app-api --auth=IAM --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#react-website --no-interactive --name=my-app-website --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:connection --no-interactive --sourceProject=@my-app/my-app-website --targetProject=@my-app/my-app-api --prefer-install-dependencies=false', pm)} && \\\\\n ${buildNxCommand('g @aws/nx-plugin:ts#infra --no-interactive --name=infra', pm)} && \\\\\n ${buildNxCommand('sync', pm)}\n \\`\\`\\``,\n).join('\\n')}\n\n- **\\`--prefer-install-dependencies=false\\`** asks a generator to defer its dependency install so the batch installs once at the end (the final generator above omits the flag and installs everything).\n- **\\`nx sync\\`** is required before building — generators modify TypeScript project references.\n\n## Detailed Guides\n\nPlease refer to the below documentation for important details regarding workspaces and working with TypeScript or Python projects.\n\n${await fetchGuidePages(['workspace', 'typescript-project', 'python-project'], generators)}\n\n `,\n },\n ],\n }),\n );\n};\n"],"names":["IAC_PROVIDERS","buildNxCommand","fetchGuidePages","PACKAGE_MANAGERS","TOOL_SELECTION_GUIDE","addGeneralGuidanceTool","server","generators","registerTool","title","description","content","type","text","join","map","pm"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,aAAa,QAAQ,+BAA4B;AAC1D,SAASC,cAAc,EAAEC,eAAe,QAAQ,uBAAoB;AACpE,SAASC,gBAAgB,QAAQ,eAAY;AAE7C,OAAO,MAAMC,uBAAuB,CAAC;;;;;;;+FAO0D,CAAC,CAAC;AAEjG;;CAEC,GACD,OAAO,MAAMC,yBAAyB,CACpCC,QACAC;IAEAD,OAAOE,YAAY,CACjB,oBACA;QACEC,OAAO;QACPC,aACE;IACJ,GACA,UAAa,CAAA;YACXC,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAM,CAAC;;AAEjB,EAAET,qBAAqB;;;;yDAIkC,EAAED,iBAAiBW,IAAI,CAAC,MAAM;+EACR,EAAEd,cAAcc,IAAI,CAAC,MAAM;;;;;;;AAO1G,EAAEX,iBAAiBY,GAAG,CAAC,CAACC,KAAOf,eAAe,aAAae,KAAKF,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoC9E,EAAEX,iBAAiBY,GAAG,CACpB,CAACC,KAAO,CAAC;EACT,EAAEf,eAAe,kHAAkHe,IAAI;IACrI,EAAEf,eAAe,gHAAgHe,IAAI;IACrI,EAAEf,eAAe,8JAA8Je,IAAI;IACnL,EAAEf,eAAe,2DAA2De,IAAI;IAChF,EAAEf,eAAe,QAAQe,IAAI;QACzB,CAAC,EACPF,IAAI,CAAC,MAAM;;;;;;;;;AASb,EAAE,MAAMZ,gBAAgB;wBAAC;wBAAa;wBAAsB;qBAAiB,EAAEK,YAAY;;IAEvF,CAAC;gBACG;aACD;QACH,CAAA;AAEJ,EAAE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
|
+
import type { NxGeneratorInfo } from '../../utils/generators';
|
|
7
|
+
/**
|
|
8
|
+
* Add a tool which guides an agent through upgrading Nx and @aws/nx-plugin in a
|
|
9
|
+
* workspace, returning the `upgrading` docs page.
|
|
10
|
+
*/
|
|
11
|
+
export declare const addUpgradeWorkspaceTool: (server: McpServer, generators: NxGeneratorInfo[]) => void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/ import { fetchGuidePages } from "../generator-info.js";
|
|
5
|
+
import { PackageManagerSchema } from "../schema.js";
|
|
6
|
+
/** The guide page backing this tool, so it never drifts from the docs. */ const UPGRADING_GUIDE = 'upgrading';
|
|
7
|
+
/**
|
|
8
|
+
* Add a tool which guides an agent through upgrading Nx and @aws/nx-plugin in a
|
|
9
|
+
* workspace, returning the `upgrading` docs page.
|
|
10
|
+
*/ export const addUpgradeWorkspaceTool = (server, generators)=>{
|
|
11
|
+
server.registerTool('upgrade-workspace', {
|
|
12
|
+
title: 'Upgrade Workspace',
|
|
13
|
+
description: 'Tool for upgrading Nx and the Nx Plugin for AWS in a workspace. Use this when a user wants to update @aws/nx-plugin or Nx to a newer version, or asks how to run migrations with nx migrate.',
|
|
14
|
+
inputSchema: {
|
|
15
|
+
packageManager: PackageManagerSchema.optional()
|
|
16
|
+
}
|
|
17
|
+
}, async ({ packageManager })=>{
|
|
18
|
+
const guide = await fetchGuidePages([
|
|
19
|
+
UPGRADING_GUIDE
|
|
20
|
+
], generators, packageManager);
|
|
21
|
+
return {
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'text',
|
|
25
|
+
text: guide
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=upgrade-workspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../packages/nx-plugin/src/mcp-server/tools/upgrade-workspace.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\nimport type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { NxGeneratorInfo } from '../../utils/generators';\nimport { fetchGuidePages } from '../generator-info';\nimport { PackageManagerSchema } from '../schema';\n\n/** The guide page backing this tool, so it never drifts from the docs. */\nconst UPGRADING_GUIDE = 'upgrading';\n\n/**\n * Add a tool which guides an agent through upgrading Nx and @aws/nx-plugin in a\n * workspace, returning the `upgrading` docs page.\n */\nexport const addUpgradeWorkspaceTool = (\n server: McpServer,\n generators: NxGeneratorInfo[],\n) => {\n server.registerTool(\n 'upgrade-workspace',\n {\n title: 'Upgrade Workspace',\n description:\n 'Tool for upgrading Nx and the Nx Plugin for AWS in a workspace. Use this when a user wants to update @aws/nx-plugin or Nx to a newer version, or asks how to run migrations with nx migrate.',\n inputSchema: {\n packageManager: PackageManagerSchema.optional(),\n },\n },\n async ({ packageManager }) => {\n const guide = await fetchGuidePages(\n [UPGRADING_GUIDE],\n generators,\n packageManager,\n );\n return {\n content: [\n {\n type: 'text' as const,\n text: guide,\n },\n ],\n };\n },\n );\n};\n"],"names":["fetchGuidePages","PackageManagerSchema","UPGRADING_GUIDE","addUpgradeWorkspaceTool","server","generators","registerTool","title","description","inputSchema","packageManager","optional","guide","content","type","text"],"mappings":"AAAA;;;CAGC,GAGD,SAASA,eAAe,QAAQ,uBAAoB;AACpD,SAASC,oBAAoB,QAAQ,eAAY;AAEjD,wEAAwE,GACxE,MAAMC,kBAAkB;AAExB;;;CAGC,GACD,OAAO,MAAMC,0BAA0B,CACrCC,QACAC;IAEAD,OAAOE,YAAY,CACjB,qBACA;QACEC,OAAO;QACPC,aACE;QACFC,aAAa;YACXC,gBAAgBT,qBAAqBU,QAAQ;QAC/C;IACF,GACA,OAAO,EAAED,cAAc,EAAE;QACvB,MAAME,QAAQ,MAAMZ,gBAClB;YAACE;SAAgB,EACjBG,YACAK;QAEF,OAAO;YACLG,SAAS;gBACP;oBACEC,MAAM;oBACNC,MAAMH;gBACR;aACD;QACH;IACF;AAEJ,EAAE"}
|
|
@@ -122,6 +122,8 @@ The following list of generators are what is currently available in the \`@aws/n
|
|
|
122
122
|
|
|
123
123
|
- **ts#nx-generator**: Generator for adding an Nx Generator to an existing TypeScript project
|
|
124
124
|
|
|
125
|
+
- **ts#nx-migration**: Generator for adding an Nx Migration to an Nx Plugin, applied by nx migrate when users upgrade
|
|
126
|
+
|
|
125
127
|
- **ts#nx-plugin**: Generate an Nx Plugin of your own! Build custom generators automatically made available for AI vibe-coding via MCP
|
|
126
128
|
|
|
127
129
|
- **ts#project**: Generates a TypeScript project
|
package/src/sdk/ts.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export { tsAgentGenerator } from '../ts/agent/generator';
|
|
|
8
8
|
export type { TsAgentGeneratorSchema } from '../ts/agent/schema';
|
|
9
9
|
export { tsApiGenerator } from '../ts/api/generator';
|
|
10
10
|
export type { TsApiGeneratorSchema } from '../ts/api/schema';
|
|
11
|
-
export { tsDocsGenerator } from '../ts/docs/generator';
|
|
12
|
-
export type { TsDocsGeneratorSchema } from '../ts/docs/schema';
|
|
13
11
|
export { tsDcrProxyGenerator } from '../ts/dcr-proxy/generator';
|
|
14
12
|
export type { TsDcrProxyGeneratorSchema } from '../ts/dcr-proxy/schema';
|
|
13
|
+
export { tsDocsGenerator } from '../ts/docs/generator';
|
|
14
|
+
export type { TsDocsGeneratorSchema } from '../ts/docs/schema';
|
|
15
15
|
export { tsDynamoDBGenerator } from '../ts/dynamodb/generator';
|
|
16
16
|
export type { TsDynamoDBGeneratorSchema } from '../ts/dynamodb/schema';
|
|
17
17
|
export { tsLambdaFunctionGenerator } from '../ts/lambda-function/generator';
|
|
@@ -22,6 +22,8 @@ export { tsMcpServerGenerator } from '../ts/mcp-server/generator';
|
|
|
22
22
|
export type { TsMcpServerGeneratorSchema } from '../ts/mcp-server/schema';
|
|
23
23
|
export { tsNxGeneratorGenerator } from '../ts/nx-generator/generator';
|
|
24
24
|
export type { TsNxGeneratorGeneratorSchema } from '../ts/nx-generator/schema';
|
|
25
|
+
export { tsNxMigrationGenerator } from '../ts/nx-migration/generator';
|
|
26
|
+
export type { TsNxMigrationGeneratorSchema } from '../ts/nx-migration/schema';
|
|
25
27
|
export { tsNxPluginGenerator } from '../ts/nx-plugin/generator';
|
|
26
28
|
export type { TsNxPluginGeneratorSchema } from '../ts/nx-plugin/schema';
|
|
27
29
|
export { tsRdbGenerator } from '../ts/rdb/generator';
|
package/src/sdk/ts.js
CHANGED
|
@@ -7,10 +7,10 @@ export { tsInfraGenerator } from "../infra/app/generator.js";
|
|
|
7
7
|
export { tsAgentGenerator } from "../ts/agent/generator.js";
|
|
8
8
|
// TypeScript API
|
|
9
9
|
export { tsApiGenerator } from "../ts/api/generator.js";
|
|
10
|
-
// Documentation Site Generator
|
|
11
|
-
export { tsDocsGenerator } from "../ts/docs/generator.js";
|
|
12
10
|
// TypeScript DCR Proxy Generator
|
|
13
11
|
export { tsDcrProxyGenerator } from "../ts/dcr-proxy/generator.js";
|
|
12
|
+
// Documentation Site Generator
|
|
13
|
+
export { tsDocsGenerator } from "../ts/docs/generator.js";
|
|
14
14
|
// DynamoDB Generator
|
|
15
15
|
export { tsDynamoDBGenerator } from "../ts/dynamodb/generator.js";
|
|
16
16
|
// TypeScript Lambda Function
|
|
@@ -21,6 +21,8 @@ export { tsProjectGenerator } from "../ts/lib/generator.js";
|
|
|
21
21
|
export { tsMcpServerGenerator } from "../ts/mcp-server/generator.js";
|
|
22
22
|
// TypeScript Nx Generator Generator
|
|
23
23
|
export { tsNxGeneratorGenerator } from "../ts/nx-generator/generator.js";
|
|
24
|
+
// TypeScript Nx Migration Generator
|
|
25
|
+
export { tsNxMigrationGenerator } from "../ts/nx-migration/generator.js";
|
|
24
26
|
// TypeScript Nx Plugin Generator
|
|
25
27
|
export { tsNxPluginGenerator } from "../ts/nx-plugin/generator.js";
|
|
26
28
|
// Relational Database Generator
|
package/src/sdk/ts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/ts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// TypeScript Infrastructure\nexport { tsInfraGenerator } from '../infra/app/generator';\nexport type { TsInfraGeneratorSchema } from '../infra/app/schema';\n// TypeScript Agent Generator\nexport { tsAgentGenerator } from '../ts/agent/generator';\nexport type { TsAgentGeneratorSchema } from '../ts/agent/schema';\n// TypeScript API\nexport { tsApiGenerator } from '../ts/api/generator';\nexport type { TsApiGeneratorSchema } from '../ts/api/schema';\n//
|
|
1
|
+
{"version":3,"sources":["../../../../../packages/nx-plugin/src/sdk/ts.ts"],"sourcesContent":["/**\n * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// TypeScript Infrastructure\nexport { tsInfraGenerator } from '../infra/app/generator';\nexport type { TsInfraGeneratorSchema } from '../infra/app/schema';\n// TypeScript Agent Generator\nexport { tsAgentGenerator } from '../ts/agent/generator';\nexport type { TsAgentGeneratorSchema } from '../ts/agent/schema';\n// TypeScript API\nexport { tsApiGenerator } from '../ts/api/generator';\nexport type { TsApiGeneratorSchema } from '../ts/api/schema';\n// TypeScript DCR Proxy Generator\nexport { tsDcrProxyGenerator } from '../ts/dcr-proxy/generator';\nexport type { TsDcrProxyGeneratorSchema } from '../ts/dcr-proxy/schema';\n// Documentation Site Generator\nexport { tsDocsGenerator } from '../ts/docs/generator';\nexport type { TsDocsGeneratorSchema } from '../ts/docs/schema';\n// DynamoDB Generator\nexport { tsDynamoDBGenerator } from '../ts/dynamodb/generator';\nexport type { TsDynamoDBGeneratorSchema } from '../ts/dynamodb/schema';\n// TypeScript Lambda Function\nexport { tsLambdaFunctionGenerator } from '../ts/lambda-function/generator';\nexport type { TsLambdaFunctionGeneratorSchema } from '../ts/lambda-function/schema';\n// TypeScript Project Generator\nexport { tsProjectGenerator } from '../ts/lib/generator';\nexport type { TsProjectGeneratorSchema } from '../ts/lib/schema';\n// TypeScript MCP Server Generator\nexport { tsMcpServerGenerator } from '../ts/mcp-server/generator';\nexport type { TsMcpServerGeneratorSchema } from '../ts/mcp-server/schema';\n// TypeScript Nx Generator Generator\nexport { tsNxGeneratorGenerator } from '../ts/nx-generator/generator';\nexport type { TsNxGeneratorGeneratorSchema } from '../ts/nx-generator/schema';\n// TypeScript Nx Migration Generator\nexport { tsNxMigrationGenerator } from '../ts/nx-migration/generator';\nexport type { TsNxMigrationGeneratorSchema } from '../ts/nx-migration/schema';\n// TypeScript Nx Plugin Generator\nexport { tsNxPluginGenerator } from '../ts/nx-plugin/generator';\nexport type { TsNxPluginGeneratorSchema } from '../ts/nx-plugin/schema';\n// Relational Database Generator\nexport { tsRdbGenerator } from '../ts/rdb/generator';\nexport type { TsRdbGeneratorSchema } from '../ts/rdb/schema';\n// Runtime Config\nexport { runtimeConfigGenerator } from '../ts/react-website/runtime-config/generator';\nexport type { RuntimeConfigGeneratorSchema } from '../ts/react-website/runtime-config/schema';\n// TypeScript Website Generator\nexport { tsWebsiteGenerator } from '../ts/website/app/generator';\nexport type { TsWebsiteGeneratorSchema } from '../ts/website/app/schema';\n// TypeScript Website Auth Generator\nexport { tsWebsiteAuthGenerator } from '../ts/website/auth/generator';\nexport type { TsWebsiteAuthGeneratorSchema } from '../ts/website/auth/schema';\n\n// Shared Constructs\nexport { sharedConstructsGenerator } from '../utils/shared-constructs';\n"],"names":["tsInfraGenerator","tsAgentGenerator","tsApiGenerator","tsDcrProxyGenerator","tsDocsGenerator","tsDynamoDBGenerator","tsLambdaFunctionGenerator","tsProjectGenerator","tsMcpServerGenerator","tsNxGeneratorGenerator","tsNxMigrationGenerator","tsNxPluginGenerator","tsRdbGenerator","runtimeConfigGenerator","tsWebsiteGenerator","tsWebsiteAuthGenerator","sharedConstructsGenerator"],"mappings":"AAAA;;;CAGC,GAED,4BAA4B;AAC5B,SAASA,gBAAgB,QAAQ,4BAAyB;AAE1D,6BAA6B;AAC7B,SAASC,gBAAgB,QAAQ,2BAAwB;AAEzD,iBAAiB;AACjB,SAASC,cAAc,QAAQ,yBAAsB;AAErD,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,+BAA+B;AAC/B,SAASC,eAAe,QAAQ,0BAAuB;AAEvD,qBAAqB;AACrB,SAASC,mBAAmB,QAAQ,8BAA2B;AAE/D,6BAA6B;AAC7B,SAASC,yBAAyB,QAAQ,qCAAkC;AAE5E,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,yBAAsB;AAEzD,kCAAkC;AAClC,SAASC,oBAAoB,QAAQ,gCAA6B;AAElE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAEtE,iCAAiC;AACjC,SAASC,mBAAmB,QAAQ,+BAA4B;AAEhE,gCAAgC;AAChC,SAASC,cAAc,QAAQ,yBAAsB;AAErD,iBAAiB;AACjB,SAASC,sBAAsB,QAAQ,kDAA+C;AAEtF,+BAA+B;AAC/B,SAASC,kBAAkB,QAAQ,iCAA8B;AAEjE,oCAAoC;AACpC,SAASC,sBAAsB,QAAQ,kCAA+B;AAGtE,oBAAoB;AACpB,SAASC,yBAAyB,QAAQ,gCAA6B"}
|
|
@@ -1390,7 +1390,7 @@ output "security_group_id" {
|
|
|
1390
1390
|
|
|
1391
1391
|
exports[`ts#agent generator > should match snapshot for generated files > agent-agent.ts 1`] = `
|
|
1392
1392
|
"import { Agent, tool } from '@strands-agents/sdk';
|
|
1393
|
-
import { logModelErrors } from '@proj/agent-connection';
|
|
1393
|
+
import { logModelErrors, logToolErrors } from '@proj/agent-connection';
|
|
1394
1394
|
import { z } from 'zod';
|
|
1395
1395
|
|
|
1396
1396
|
const multiply = tool({
|
|
@@ -1411,6 +1411,7 @@ export const getAgent = async () => {
|
|
|
1411
1411
|
tools: [multiply],
|
|
1412
1412
|
});
|
|
1413
1413
|
logModelErrors(agent);
|
|
1414
|
+
logToolErrors(agent);
|
|
1414
1415
|
return agent;
|
|
1415
1416
|
};
|
|
1416
1417
|
"
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ts#agent#a2a-connection generator > should match snapshot for agent-connection src files > agent-connection-index.ts 1`] = `
|
|
4
4
|
"export * from './app/remote-client-strands.js';
|
|
5
|
+
export * from './core/tool-errors-strands.js';
|
|
5
6
|
export * from './core/model-errors-strands.js';
|
|
6
7
|
export * from './core/with-session-id-strands.js';
|
|
7
8
|
export * from './core/session-context.js';
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { StrandsAgent } from '@ag-ui/aws-strands';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
addStrandsExpressEndpoint,
|
|
4
|
+
addPing,
|
|
5
|
+
addCapabilities,
|
|
6
|
+
} from '@ag-ui/aws-strands/server';
|
|
7
|
+
import express, { type Request, type Response, type NextFunction } from 'express';
|
|
8
|
+
import cors from 'cors';
|
|
3
9
|
import { randomUUID } from 'node:crypto';
|
|
4
|
-
import type { Request, Response, NextFunction } from 'express';
|
|
5
10
|
import { runWithSessionId } from '<%- agentConnectionImport %>';
|
|
6
11
|
import { getAgent } from './agent<% if (esm) { %>.js<% } %>';
|
|
7
12
|
|
|
@@ -10,6 +15,13 @@ const HOST = '0.0.0.0';
|
|
|
10
15
|
|
|
11
16
|
const SESSION_ID_HEADER = 'x-amzn-bedrock-agentcore-runtime-session-id';
|
|
12
17
|
|
|
18
|
+
// Bind the inbound session (or a fresh UUID) for downstream MCP / A2A calls.
|
|
19
|
+
const sessionIdMiddleware = (req: Request, _res: Response, next: NextFunction) => {
|
|
20
|
+
const header = req.headers[SESSION_ID_HEADER];
|
|
21
|
+
const sessionId = (Array.isArray(header) ? header[0] : header) ?? randomUUID();
|
|
22
|
+
runWithSessionId(sessionId, () => next());
|
|
23
|
+
};
|
|
24
|
+
|
|
13
25
|
void (async () => {
|
|
14
26
|
const agent = await getAgent();
|
|
15
27
|
|
|
@@ -22,14 +34,18 @@ void (async () => {
|
|
|
22
34
|
description: 'A Strands Agent exposed via the AG-UI protocol.',
|
|
23
35
|
});
|
|
24
36
|
|
|
25
|
-
|
|
37
|
+
// Built up manually (mirroring createStrandsApp's defaults) rather than via createStrandsApp
|
|
38
|
+
// https://github.com/ag-ui-protocol/ag-ui/blob/main/integrations/aws-strands/typescript/src/server.ts
|
|
39
|
+
const app = express();
|
|
40
|
+
app.use(cors({ origin: '*', credentials: true }));
|
|
41
|
+
app.use(express.json({ limit: '50mb' }));
|
|
26
42
|
|
|
27
|
-
|
|
28
|
-
app
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
43
|
+
addPing(app, '/ping');
|
|
44
|
+
addCapabilities(app, '/capabilities', { agent: aguiAgent });
|
|
45
|
+
|
|
46
|
+
app.use(sessionIdMiddleware);
|
|
47
|
+
|
|
48
|
+
addStrandsExpressEndpoint(app, aguiAgent, { path: '/invocations' });
|
|
33
49
|
|
|
34
50
|
app.listen(PORT, HOST, () => {
|
|
35
51
|
console.log(`AG-UI server listening on ${HOST}:${PORT}`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent, tool } from '@strands-agents/sdk';
|
|
2
|
-
import { logModelErrors } from '<%- agentConnectionImport %>';
|
|
2
|
+
import { logModelErrors, logToolErrors } from '<%- agentConnectionImport %>';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
const multiply = tool({
|
|
@@ -20,5 +20,6 @@ export const getAgent = async () => {
|
|
|
20
20
|
tools: [multiply],
|
|
21
21
|
});
|
|
22
22
|
logModelErrors(agent);
|
|
23
|
+
logToolErrors(agent);
|
|
23
24
|
return agent;
|
|
24
25
|
};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ts#agent#gateway-connection generator > should match snapshot for agent-connection src files > agent-connection-index.ts 1`] = `
|
|
4
4
|
"export * from './app/my-gateway-client-strands.js';
|
|
5
|
+
export * from './core/tool-errors-strands.js';
|
|
5
6
|
export * from './core/model-errors-strands.js';
|
|
6
7
|
export * from './core/with-session-id-strands.js';
|
|
7
8
|
export * from './core/session-context.js';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`ts#agent#mcp-connection generator > should match snapshot for agent-connection src files > agent-connection-index.ts 1`] = `
|
|
4
4
|
"export * from './app/inventory-mcp-client-strands.js';
|
|
5
|
+
export * from './core/tool-errors-strands.js';
|
|
5
6
|
export * from './core/model-errors-strands.js';
|
|
6
7
|
export * from './core/with-session-id-strands.js';
|
|
7
8
|
export * from './core/session-context.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Tree } from '@nx/devkit';
|
|
2
|
+
import { createTreeUsingTsSolutionSetup } from '<%- testImportPath %>';
|
|
3
|
+
import migration from './migration';
|
|
4
|
+
|
|
5
|
+
describe('<%= name %> migration', () => {
|
|
6
|
+
let tree: Tree;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
tree = createTreeUsingTsSolutionSetup();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should apply to the shape your generators produce', async () => {
|
|
13
|
+
// TODO: arrange the "before" state and assert the expected changes.
|
|
14
|
+
const result = await migration(tree);
|
|
15
|
+
expect(result.nextSteps).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should skip and report a customised file', () => {
|
|
19
|
+
// TODO: arrange a diverged file and assert it is left untouched and
|
|
20
|
+
// reported via nextSteps.
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should be idempotent', () => {
|
|
24
|
+
// TODO: run the migration twice and assert the second run is a no-op.
|
|
25
|
+
});
|
|
26
|
+
});
|