mf-context

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Collect the following information step by step from
$ARGUMENTS
(defaults to the current working directory if empty), then output the aggregated MFContext.
$ARGUMENTS
中逐步收集以下信息(若为空则默认使用当前工作目录),随后输出聚合后的MFContext。

1. Basic Info

1. 基础信息

Read
{projectRoot}/package.json
and extract:
  • name
    : project name
  • Merge
    dependencies
    +
    devDependencies
    into a full dependency map
Detect the package manager (check files in order):
  • pnpm-lock.yaml
    → pnpm
  • yarn.lock
    → yarn
  • package-lock.json
    → npm
读取
{projectRoot}/package.json
并提取:
  • name
    :项目名称
  • 合并
    dependencies
    +
    devDependencies
    得到完整的依赖映射
检测包管理器(按顺序检查文件):
  • pnpm-lock.yaml
    → pnpm
  • yarn.lock
    → yarn
  • package-lock.json
    → npm

2. Bundler & MF Config

2. 打包工具与MF配置

Find config files in the following priority order (
.ts
/
.mts
take precedence over
.js
/
.mjs
/
.cjs
):
PriorityFilename
1
module-federation.config.{ts,mts,js,mjs,cjs}
2
rsbuild.config.{ts,mts,js,mjs,cjs}
3
rspack.config.{ts,mts,js,mjs,cjs}
4
modern.config.{ts,mts,js,mjs,cjs}
5
next.config.{ts,mts,js,mjs,cjs}
6
webpack.config.{ts,js}
Read the first matched file and extract the
remotes
,
exposes
, and
shared
fields. Determine the bundler from the filename (
rspack
/
rsbuild
/
webpack
).
按以下优先级查找配置文件(
.ts
/
.mts
优先级高于
.js
/
.mjs
/
.cjs
):
优先级文件名
1
module-federation.config.{ts,mts,js,mjs,cjs}
2
rsbuild.config.{ts,mts,js,mjs,cjs}
3
rspack.config.{ts,mts,js,mjs,cjs}
4
modern.config.{ts,mts,js,mjs,cjs}
5
next.config.{ts,mts,js,mjs,cjs}
6
webpack.config.{ts,js}
读取第一个匹配到的文件,提取
remotes
exposes
shared
字段,根据文件名确定打包工具(
rspack
/
rsbuild
/
webpack
)。

3. Determine MF Role

3. 确定MF角色

ConditionRole
Has
remotes
and
exposes
host+remote
Only
remotes
host
Only
exposes
remote
Neither
unknown
条件角色
同时存在
remotes
exposes
host+remote
仅存在
remotes
host
仅存在
exposes
remote
两者都不存在
unknown

4. Recent Error Event (optional)

4. 最近错误事件(可选)

Check if
.mf/diagnostics/latest.json
exists; if so, read its contents.
检查
.mf/diagnostics/latest.json
是否存在,若存在则读取其内容。

5. Build Artifacts (optional)

5. 构建产物(可选)

Check if
dist/mf-manifest.json
and
dist/mf-stats.json
exist; if so, read them.

Aggregate the above information and output the MFContext summary in the following structure:
project:
  name, packageManager, mfRole

bundler:
  name, configFile

mfConfig:
  remotes, exposes, shared

dependencies:
  (list installed packages related to MF and their versions)

latestErrorEvent: (if present)
buildArtifacts:   (if present)
For further diagnostics, call the corresponding diagnostic Skill based on this context.
检查
dist/mf-manifest.json
dist/mf-stats.json
是否存在,若存在则读取。

聚合以上信息,按以下结构输出MFContext摘要:
project:
  name, packageManager, mfRole

bundler:
  name, configFile

mfConfig:
  remotes, exposes, shared

dependencies:
  (list installed packages related to MF and their versions)

latestErrorEvent: (if present)
buildArtifacts:   (if present)
如需进一步诊断,可基于该上下文调用对应的诊断Skill。