@aws/nx-plugin-mcp 1.0.0-rc.5 → 1.0.0-rc.6
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/bin/aws-nx-mcp.js +110 -102
- package/docs/guides/typescript-project.mdx +5 -10
- package/docs/guides/workspace.mdx +1 -1
- package/package.json +1 -1
package/bin/aws-nx-mcp.js
CHANGED
|
@@ -19413,26 +19413,6 @@ const buildGeneratorInfoList = (baseDir) => Object.entries(generators$1).map(([i
|
|
|
19413
19413
|
..."guidePages" in info && info.guidePages ? { guidePages: info.guidePages } : {}
|
|
19414
19414
|
}));
|
|
19415
19415
|
//#endregion
|
|
19416
|
-
//#region ../nx-plugin/src/mcp-server/schema.ts
|
|
19417
|
-
/**
|
|
19418
|
-
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19419
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
19420
|
-
*/
|
|
19421
|
-
const PACKAGE_MANAGERS = [
|
|
19422
|
-
"pnpm",
|
|
19423
|
-
"yarn",
|
|
19424
|
-
"npm",
|
|
19425
|
-
"bun"
|
|
19426
|
-
];
|
|
19427
|
-
const PackageManagerSchema = _enum(PACKAGE_MANAGERS);
|
|
19428
|
-
//#endregion
|
|
19429
|
-
//#region ../nx-plugin/src/utils/iac-providers.ts
|
|
19430
|
-
/**
|
|
19431
|
-
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19432
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
19433
|
-
*/
|
|
19434
|
-
const IAC_PROVIDERS = ["cdk", "terraform"];
|
|
19435
|
-
//#endregion
|
|
19436
19416
|
//#region ../nx-plugin/src/utils/commands.ts
|
|
19437
19417
|
const PACKAGE_MANAGER_COMMANDS = {
|
|
19438
19418
|
npm: {
|
|
@@ -19502,6 +19482,26 @@ const buildCreateNxWorkspaceCommand = (pm, workspace, iac, tag) => {
|
|
|
19502
19482
|
].join(" ");
|
|
19503
19483
|
};
|
|
19504
19484
|
//#endregion
|
|
19485
|
+
//#region ../nx-plugin/src/utils/iac-providers.ts
|
|
19486
|
+
/**
|
|
19487
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19488
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
19489
|
+
*/
|
|
19490
|
+
const IAC_PROVIDERS = ["cdk", "terraform"];
|
|
19491
|
+
//#endregion
|
|
19492
|
+
//#region ../nx-plugin/src/mcp-server/schema.ts
|
|
19493
|
+
/**
|
|
19494
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
19495
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
19496
|
+
*/
|
|
19497
|
+
const PACKAGE_MANAGERS = [
|
|
19498
|
+
"pnpm",
|
|
19499
|
+
"yarn",
|
|
19500
|
+
"npm",
|
|
19501
|
+
"bun"
|
|
19502
|
+
];
|
|
19503
|
+
const PackageManagerSchema = _enum(PACKAGE_MANAGERS);
|
|
19504
|
+
//#endregion
|
|
19505
19505
|
//#region ../nx-plugin/src/mcp-server/tools/create-workspace-command.ts
|
|
19506
19506
|
/**
|
|
19507
19507
|
* Add a tool which tells a model how to create an Nx workspace
|
|
@@ -20546,88 +20546,6 @@ const kebabCase = (str) => {
|
|
|
20546
20546
|
return (0, import_lodash_deburr.default)(str).replace(/[^a-zA-Z0-9]+/g, "-").replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/^-+|-+$/g, "");
|
|
20547
20547
|
};
|
|
20548
20548
|
//#endregion
|
|
20549
|
-
//#region ../nx-plugin/src/mcp-server/option-filter.ts
|
|
20550
|
-
/**
|
|
20551
|
-
* Turn the `data.estree` of an `MdxJsxAttributeValueExpression` into a
|
|
20552
|
-
* `Predicate`. The estree is a Program wrapping a single ObjectExpression.
|
|
20553
|
-
*/
|
|
20554
|
-
const parseWhenExpression = (estree) => {
|
|
20555
|
-
const expression = unwrapProgram(estree);
|
|
20556
|
-
if (expression.type !== "ObjectExpression") throw new Error(`[option-filter] Expected object literal in 'when' prop, got ${expression.type}`);
|
|
20557
|
-
const result = {};
|
|
20558
|
-
for (const prop of expression.properties) {
|
|
20559
|
-
if (prop.type !== "Property") throw new Error(`[option-filter] Unsupported entry type '${prop.type}' in 'when' prop`);
|
|
20560
|
-
result[extractKey(prop)] = extractValues(prop.value);
|
|
20561
|
-
}
|
|
20562
|
-
return result;
|
|
20563
|
-
};
|
|
20564
|
-
/**
|
|
20565
|
-
* AND across keys, OR within a key's values, `not` negates. A key not
|
|
20566
|
-
* present in `options` is "no opinion". A predicate whose keys have no
|
|
20567
|
-
* intersection with `options` short-circuits to true.
|
|
20568
|
-
*/
|
|
20569
|
-
const evaluatePredicate = (predicate, not, options) => {
|
|
20570
|
-
let matched = true;
|
|
20571
|
-
let anyKeyTested = false;
|
|
20572
|
-
for (const [key, values] of Object.entries(predicate)) {
|
|
20573
|
-
const selected = options[key];
|
|
20574
|
-
if (selected === void 0) continue;
|
|
20575
|
-
anyKeyTested = true;
|
|
20576
|
-
if (!values.includes(selected)) {
|
|
20577
|
-
matched = false;
|
|
20578
|
-
break;
|
|
20579
|
-
}
|
|
20580
|
-
}
|
|
20581
|
-
if (!anyKeyTested) return true;
|
|
20582
|
-
return not ? !matched : matched;
|
|
20583
|
-
};
|
|
20584
|
-
/** Short human label used on the docs pill and in the `> [!NOTE] Only when …` marker. */
|
|
20585
|
-
const describePredicate = (predicate, not) => {
|
|
20586
|
-
const parts = Object.entries(predicate).map(([k, vs]) => `${k} = ${vs.join(" | ")}`);
|
|
20587
|
-
return `${not ? "Not when " : "Only when "}${parts.join(", ")}`;
|
|
20588
|
-
};
|
|
20589
|
-
const unwrapProgram = (estree) => {
|
|
20590
|
-
if (estree.type !== "Program") return estree;
|
|
20591
|
-
const program = estree;
|
|
20592
|
-
if (program.body.length !== 1) return estree;
|
|
20593
|
-
const stmt = program.body[0];
|
|
20594
|
-
return stmt.type === "ExpressionStatement" ? stmt.expression : estree;
|
|
20595
|
-
};
|
|
20596
|
-
const extractKey = (prop) => {
|
|
20597
|
-
const k = prop.key;
|
|
20598
|
-
if (k.type === "Identifier") return k.name;
|
|
20599
|
-
if (k.type === "Literal" && typeof k.value === "string") return k.value;
|
|
20600
|
-
throw new Error(`[option-filter] Unsupported key type '${k.type}' in 'when' prop`);
|
|
20601
|
-
};
|
|
20602
|
-
const extractValues = (value) => {
|
|
20603
|
-
if (value.type === "ArrayExpression") return value.elements.map((el) => {
|
|
20604
|
-
if (el === null || el.type === "SpreadElement") throw new Error(`[option-filter] Unsupported array element in 'when' prop`);
|
|
20605
|
-
return extractScalar(el);
|
|
20606
|
-
});
|
|
20607
|
-
return [extractScalar(value)];
|
|
20608
|
-
};
|
|
20609
|
-
/**
|
|
20610
|
-
* Extract a `string[]` from the estree of an attribute-value expression
|
|
20611
|
-
* like `{['a', 'b']}`. Used by JSX attribute readers (e.g. the
|
|
20612
|
-
* `commands={[...]}` prop on <NxCommands>). Throws if anything other than
|
|
20613
|
-
* string / number / boolean literal array elements are encountered.
|
|
20614
|
-
*/
|
|
20615
|
-
const extractStringArrayExpression = (estree) => {
|
|
20616
|
-
const expression = unwrapProgram(estree);
|
|
20617
|
-
if (expression.type !== "ArrayExpression") throw new Error(`[option-filter] Expected array literal, got ${expression.type}`);
|
|
20618
|
-
return expression.elements.map((el) => {
|
|
20619
|
-
if (el === null || el.type === "SpreadElement") throw new Error(`[option-filter] Unsupported array element`);
|
|
20620
|
-
return extractScalar(el);
|
|
20621
|
-
});
|
|
20622
|
-
};
|
|
20623
|
-
const extractScalar = (node) => {
|
|
20624
|
-
if (node.type === "Literal") {
|
|
20625
|
-
const lit = node;
|
|
20626
|
-
if (typeof lit.value === "string" || typeof lit.value === "number" || typeof lit.value === "boolean") return String(lit.value);
|
|
20627
|
-
}
|
|
20628
|
-
throw new Error(`[option-filter] Unsupported value type '${node.type}' in 'when' prop. Use string, number, boolean literals or arrays of them.`);
|
|
20629
|
-
};
|
|
20630
|
-
//#endregion
|
|
20631
20549
|
//#region ../nx-plugin/src/mcp-server/guide-render.ts
|
|
20632
20550
|
/**
|
|
20633
20551
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
@@ -22995,7 +22913,93 @@ var import_js_yaml = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((ex
|
|
|
22995
22913
|
var { Type, Schema, FAILSAFE_SCHEMA, JSON_SCHEMA, CORE_SCHEMA, DEFAULT_SCHEMA, load, loadAll, dump, YAMLException, types: types$2, safeLoad, safeLoadAll, safeDump } = import_js_yaml.default;
|
|
22996
22914
|
var index_vite_proxy_tmp_default = import_js_yaml.default;
|
|
22997
22915
|
//#endregion
|
|
22916
|
+
//#region ../nx-plugin/src/mcp-server/option-filter.ts
|
|
22917
|
+
/**
|
|
22918
|
+
* Turn the `data.estree` of an `MdxJsxAttributeValueExpression` into a
|
|
22919
|
+
* `Predicate`. The estree is a Program wrapping a single ObjectExpression.
|
|
22920
|
+
*/
|
|
22921
|
+
const parseWhenExpression = (estree) => {
|
|
22922
|
+
const expression = unwrapProgram(estree);
|
|
22923
|
+
if (expression.type !== "ObjectExpression") throw new Error(`[option-filter] Expected object literal in 'when' prop, got ${expression.type}`);
|
|
22924
|
+
const result = {};
|
|
22925
|
+
for (const prop of expression.properties) {
|
|
22926
|
+
if (prop.type !== "Property") throw new Error(`[option-filter] Unsupported entry type '${prop.type}' in 'when' prop`);
|
|
22927
|
+
result[extractKey(prop)] = extractValues(prop.value);
|
|
22928
|
+
}
|
|
22929
|
+
return result;
|
|
22930
|
+
};
|
|
22931
|
+
/**
|
|
22932
|
+
* AND across keys, OR within a key's values, `not` negates. A key not
|
|
22933
|
+
* present in `options` is "no opinion". A predicate whose keys have no
|
|
22934
|
+
* intersection with `options` short-circuits to true.
|
|
22935
|
+
*/
|
|
22936
|
+
const evaluatePredicate = (predicate, not, options) => {
|
|
22937
|
+
let matched = true;
|
|
22938
|
+
let anyKeyTested = false;
|
|
22939
|
+
for (const [key, values] of Object.entries(predicate)) {
|
|
22940
|
+
const selected = options[key];
|
|
22941
|
+
if (selected === void 0) continue;
|
|
22942
|
+
anyKeyTested = true;
|
|
22943
|
+
if (!values.includes(selected)) {
|
|
22944
|
+
matched = false;
|
|
22945
|
+
break;
|
|
22946
|
+
}
|
|
22947
|
+
}
|
|
22948
|
+
if (!anyKeyTested) return true;
|
|
22949
|
+
return not ? !matched : matched;
|
|
22950
|
+
};
|
|
22951
|
+
/** Short human label used on the docs pill and in the `> [!NOTE] Only when …` marker. */
|
|
22952
|
+
const describePredicate = (predicate, not) => {
|
|
22953
|
+
const parts = Object.entries(predicate).map(([k, vs]) => `${k} = ${vs.join(" | ")}`);
|
|
22954
|
+
return `${not ? "Not when " : "Only when "}${parts.join(", ")}`;
|
|
22955
|
+
};
|
|
22956
|
+
const unwrapProgram = (estree) => {
|
|
22957
|
+
if (estree.type !== "Program") return estree;
|
|
22958
|
+
const program = estree;
|
|
22959
|
+
if (program.body.length !== 1) return estree;
|
|
22960
|
+
const stmt = program.body[0];
|
|
22961
|
+
return stmt.type === "ExpressionStatement" ? stmt.expression : estree;
|
|
22962
|
+
};
|
|
22963
|
+
const extractKey = (prop) => {
|
|
22964
|
+
const k = prop.key;
|
|
22965
|
+
if (k.type === "Identifier") return k.name;
|
|
22966
|
+
if (k.type === "Literal" && typeof k.value === "string") return k.value;
|
|
22967
|
+
throw new Error(`[option-filter] Unsupported key type '${k.type}' in 'when' prop`);
|
|
22968
|
+
};
|
|
22969
|
+
const extractValues = (value) => {
|
|
22970
|
+
if (value.type === "ArrayExpression") return value.elements.map((el) => {
|
|
22971
|
+
if (el === null || el.type === "SpreadElement") throw new Error(`[option-filter] Unsupported array element in 'when' prop`);
|
|
22972
|
+
return extractScalar(el);
|
|
22973
|
+
});
|
|
22974
|
+
return [extractScalar(value)];
|
|
22975
|
+
};
|
|
22976
|
+
/**
|
|
22977
|
+
* Extract a `string[]` from the estree of an attribute-value expression
|
|
22978
|
+
* like `{['a', 'b']}`. Used by JSX attribute readers (e.g. the
|
|
22979
|
+
* `commands={[...]}` prop on <NxCommands>). Throws if anything other than
|
|
22980
|
+
* string / number / boolean literal array elements are encountered.
|
|
22981
|
+
*/
|
|
22982
|
+
const extractStringArrayExpression = (estree) => {
|
|
22983
|
+
const expression = unwrapProgram(estree);
|
|
22984
|
+
if (expression.type !== "ArrayExpression") throw new Error(`[option-filter] Expected array literal, got ${expression.type}`);
|
|
22985
|
+
return expression.elements.map((el) => {
|
|
22986
|
+
if (el === null || el.type === "SpreadElement") throw new Error(`[option-filter] Unsupported array element`);
|
|
22987
|
+
return extractScalar(el);
|
|
22988
|
+
});
|
|
22989
|
+
};
|
|
22990
|
+
const extractScalar = (node) => {
|
|
22991
|
+
if (node.type === "Literal") {
|
|
22992
|
+
const lit = node;
|
|
22993
|
+
if (typeof lit.value === "string" || typeof lit.value === "number" || typeof lit.value === "boolean") return String(lit.value);
|
|
22994
|
+
}
|
|
22995
|
+
throw new Error(`[option-filter] Unsupported value type '${node.type}' in 'when' prop. Use string, number, boolean literals or arrays of them.`);
|
|
22996
|
+
};
|
|
22997
|
+
//#endregion
|
|
22998
22998
|
//#region ../nx-plugin/src/mcp-server/mdx-ast.ts
|
|
22999
|
+
/**
|
|
23000
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
23001
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
23002
|
+
*/
|
|
22999
23003
|
const isJsxElement = (node) => node.type === "mdxJsxFlowElement" || node.type === "mdxJsxTextElement";
|
|
23000
23004
|
const findAttr = (node, name) => node.attributes.find((a) => a.type === "mdxJsxAttribute" && a.name === name);
|
|
23001
23005
|
const readStringAttr = (node, name) => {
|
|
@@ -52525,6 +52529,10 @@ var init_remark_frontmatter = __esmMin((() => {
|
|
|
52525
52529
|
}));
|
|
52526
52530
|
//#endregion
|
|
52527
52531
|
//#region ../nx-plugin/src/mcp-server/guide-pipeline.ts
|
|
52532
|
+
/**
|
|
52533
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
52534
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
52535
|
+
*/
|
|
52528
52536
|
let depsPromise;
|
|
52529
52537
|
const loadRemarkDeps = () => {
|
|
52530
52538
|
if (!depsPromise) depsPromise = (async () => ({
|
|
@@ -11,7 +11,7 @@ import NxCommands from '@components/nx-commands.astro';
|
|
|
11
11
|
import PackageManagerShortCommand from '@components/package-manager-short-command.astro';
|
|
12
12
|
import Link from '@components/link.astro';
|
|
13
13
|
|
|
14
|
-
The TypeScript project generator can be used to create a modern [TypeScript](https://www.typescriptlang.org/) library or application configured with best practices such as [ECMAScript Modules (ESM)](https://www.typescriptlang.org/docs/handbook/modules/reference.html), TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html), [Vitest](https://vitest.dev/) for running tests and [
|
|
14
|
+
The TypeScript project generator can be used to create a modern [TypeScript](https://www.typescriptlang.org/) library or application configured with best practices such as [ECMAScript Modules (ESM)](https://www.typescriptlang.org/docs/handbook/modules/reference.html), TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html), [Vitest](https://vitest.dev/) for running tests and [Biome](https://biomejs.dev/) for linting and formatting.
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
17
17
|
|
|
@@ -38,7 +38,6 @@ The generator will create the following project structure in the `<directory>/<n
|
|
|
38
38
|
- tsconfig.lib.json TypeScript configuration for your library (your runtime or packaged source)
|
|
39
39
|
- tsconfig.spec.json TypeScript configuration for your tests
|
|
40
40
|
- vitest.config.mts Configuration for Vitest
|
|
41
|
-
- eslint.config.mjs Configuration for ESLint
|
|
42
41
|
|
|
43
42
|
</FileTree>
|
|
44
43
|
|
|
@@ -198,7 +197,7 @@ If you're building an AWS Lambda function, check out the <Link path="/guides/ts-
|
|
|
198
197
|
|
|
199
198
|
If you are publishing your TypeScript project to NPM, you must create a `package.json` file for it.
|
|
200
199
|
|
|
201
|
-
This must declare the dependencies that your project references. Since at build time your project will resolve dependencies installed via the workspace root `package.json`,
|
|
200
|
+
This must declare the dependencies that your project references. Since at build time your project will resolve dependencies installed via the workspace root `package.json`, Biome's `noUndeclaredDependencies` rule will warn you if your project imports a package that isn't listed in its `package.json`.
|
|
202
201
|
|
|
203
202
|
### Building
|
|
204
203
|
|
|
@@ -269,11 +268,7 @@ If you are a VSCode user, we recommend installing the [Vitest Runner for VSCode
|
|
|
269
268
|
|
|
270
269
|
## Linting
|
|
271
270
|
|
|
272
|
-
TypeScript projects use [
|
|
273
|
-
|
|
274
|
-
We recommend configuring ESLint in the workspace root `eslint.config.mjs` file, as changes to this will apply to all TypeScript projects in your workspace and ensure consistency.
|
|
275
|
-
|
|
276
|
-
Likewise, you can configure Prettier in the root `.prettierrc` file.
|
|
271
|
+
TypeScript projects use [Biome](https://biomejs.dev/) for linting and formatting. Biome is configured in the workspace root `biome.json` file — changes to this apply to all TypeScript projects in your workspace and ensure consistency.
|
|
277
272
|
|
|
278
273
|
### Running the Linter
|
|
279
274
|
|
|
@@ -283,7 +278,7 @@ To invoke the linter to check your project, you can run the `lint` target.
|
|
|
283
278
|
|
|
284
279
|
### Fixing Lint Issues
|
|
285
280
|
|
|
286
|
-
The majority of linting or formatting issues can be fixed automatically
|
|
281
|
+
The majority of linting or formatting issues can be fixed automatically by running with the `--configuration=fix` argument.
|
|
287
282
|
|
|
288
283
|
<NxCommands commands={["lint <project-name> --configuration=fix"]} />
|
|
289
284
|
|
|
@@ -303,7 +298,7 @@ To avoid linting issues slowing you down during development (particularly if you
|
|
|
303
298
|
|
|
304
299
|
<NxCommands commands={["run-many --target build --configuration=skip-lint"]} />
|
|
305
300
|
|
|
306
|
-
This
|
|
301
|
+
This skips the lint target entirely during build.
|
|
307
302
|
|
|
308
303
|
:::tip[Shorthand Command]
|
|
309
304
|
This has a shorthand command from the root of your workspace:
|
|
@@ -134,7 +134,7 @@ This will run the chosen target as well as the targets it depends on.
|
|
|
134
134
|
|
|
135
135
|
### Linting
|
|
136
136
|
|
|
137
|
-
New workspaces are configured with [
|
|
137
|
+
New workspaces are configured with [Biome](https://biomejs.dev/) for static analysis and code formatting. Running `lint` checks all projects for issues, and `lint --configuration=fix` auto-fixes them.
|
|
138
138
|
|
|
139
139
|
### Git Secrets
|
|
140
140
|
|