mvframe 1.0.95 → 1.1.0

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/dist/vendor.js CHANGED
@@ -13477,7 +13477,7 @@ const xr = (e, o = {}) => {
13477
13477
  }, Nr = {
13478
13478
  name: "Matt Avias Frame",
13479
13479
  copyright: "©2026",
13480
- version: "1.0.95",
13480
+ version: "1.1.0",
13481
13481
  author: "Matt Avias",
13482
13482
  date: "2026-02-26",
13483
13483
  /** 默认语言 key,与 `$getLang`、localStorage `lang` 一致;业务在 app.use(mvframe, { config }) 里覆盖 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mvframe",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.95",
4
+ "version": "1.1.0",
5
5
  "author": "matt avis",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -44,6 +44,8 @@
44
44
  "d": "node scripts/dev-with-notify.js",
45
45
  "notify": "node scripts/notify-server.js",
46
46
  "build": "node scripts/prebuild.js",
47
+ "init-rules": "node scripts/init-rules.js",
48
+ "install-cursor-rules": "node scripts/install-cursor-rules.js",
47
49
  "install-cursor-skill": "node scripts/install-cursor-skill.js",
48
50
  "install-codex-rules": "node scripts/install-codex-agents.js",
49
51
  "scaffold-app": "node scripts/scaffold-app.js",
@@ -54,7 +56,9 @@
54
56
  "mvframe-b": "scripts/build-host.js",
55
57
  "mvframe-d": "scripts/dev-with-notify.js",
56
58
  "mvframe-init-app": "scripts/scaffold-app.js",
59
+ "mvframe-init-rules": "scripts/init-rules.js",
57
60
  "mvframe-install-codex-rules": "scripts/install-codex-agents.js",
61
+ "mvframe-install-cursor-rules": "scripts/install-cursor-rules.js",
58
62
  "mvframe-install-cursor-skill": "scripts/install-cursor-skill.js",
59
63
  "mvframe-notify": "scripts/notify-server.js"
60
64
  },
@@ -63,7 +67,9 @@
63
67
  "src/style/chip/mixin.scss",
64
68
  "scripts/build-host.js",
65
69
  "scripts/dev-with-notify.js",
70
+ "scripts/init-rules.js",
66
71
  "scripts/install-codex-agents.js",
72
+ "scripts/install-cursor-rules.js",
67
73
  "scripts/install-cursor-skill.js",
68
74
  "scripts/notify-server.js",
69
75
  "scripts/scaffold-app.js",
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 一次初始化宿主项目的 MVFrame Codex + Cursor 规则。
4
+ *
5
+ * 用法:
6
+ * node path/to/mvframe/scripts/init-rules.js
7
+ * node path/to/mvframe/scripts/init-rules.js /abs/path/to/your-project
8
+ * yarn exec mvframe-init-rules
9
+ *
10
+ * 环境变量(可选):
11
+ * MVFRAME_INIT_RULES_OUT=/path/to/project 等价于第一个参数
12
+ */
13
+
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+ const { upsertCodexAgents } = require("./install-codex-agents.js");
17
+ const { installCursorRules } = require("./install-cursor-rules.js");
18
+
19
+ function main() {
20
+ const argPath = process.argv.find((a, i) => i >= 2 && !a.startsWith("--"));
21
+ const projectRoot = path.resolve(
22
+ process.env.MVFRAME_INIT_RULES_OUT || argPath || process.cwd(),
23
+ );
24
+
25
+ if (!fs.existsSync(projectRoot)) {
26
+ console.error("[mvframe] 目录不存在:", projectRoot);
27
+ process.exit(1);
28
+ }
29
+
30
+ installCursorRules(projectRoot);
31
+ upsertCodexAgents(projectRoot);
32
+
33
+ console.log("[mvframe] 已完成 MVFrame 规则初始化:");
34
+ console.log(" - Cursor: .cursor/rules/*.mdc");
35
+ console.log(" - Codex: AGENTS.md");
36
+ console.log("[mvframe] 请重开 Cursor / 开启新 Codex 会话,确保新规则被重新读取。");
37
+ }
38
+
39
+ if (require.main === module) {
40
+ main();
41
+ }
@@ -0,0 +1,67 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 将 MVFrame 包内 `.cursor/rules/*.mdc` 补充到目标工程的 `.cursor/rules/`。
4
+ * 若宿主项目已存在同名规则文件,则保留宿主文件,不覆盖。
5
+ *
6
+ * 用法:
7
+ * node path/to/mvframe/scripts/install-cursor-rules.js
8
+ * node path/to/mvframe/scripts/install-cursor-rules.js /abs/path/to/your-project
9
+ *
10
+ * 环境变量(可选):
11
+ * MVFRAME_CURSOR_RULES_OUT=/path/to/project 等价于第一个参数
12
+ */
13
+
14
+ const fs = require("fs");
15
+ const path = require("path");
16
+
17
+ function installCursorRules(projectRoot) {
18
+ const targetRoot = path.resolve(projectRoot);
19
+ const rulesSrc = path.join(__dirname, "..", ".cursor", "rules");
20
+
21
+ if (!fs.existsSync(rulesSrc)) {
22
+ console.warn(
23
+ "[mvframe] 未找到包内 .cursor/rules(请使用含该目录的 mvframe 版本),跳过 Cursor 规则复制",
24
+ );
25
+ return;
26
+ }
27
+
28
+ const entries = fs.readdirSync(rulesSrc, { withFileTypes: true });
29
+ for (const ent of entries) {
30
+ if (!ent.isFile() || !ent.name.endsWith(".mdc")) continue;
31
+ const src = path.join(rulesSrc, ent.name);
32
+ const dest = path.join(targetRoot, ".cursor", "rules", ent.name);
33
+ fs.mkdirSync(path.dirname(dest), { recursive: true });
34
+ if (fs.existsSync(dest)) {
35
+ console.log("[mvframe] 已存在 Cursor 规则,跳过:");
36
+ console.log(" ", dest);
37
+ continue;
38
+ }
39
+ fs.copyFileSync(src, dest);
40
+ console.log("[mvframe] 已写入 Cursor 规则:");
41
+ console.log(" ", dest);
42
+ }
43
+
44
+ console.log("[mvframe] Cursor 打开该项目后会读取 .cursor/rules/*.mdc。");
45
+ }
46
+
47
+ function main() {
48
+ const argPath = process.argv.find((a, i) => i >= 2 && !a.startsWith("--"));
49
+ const projectRoot = path.resolve(
50
+ process.env.MVFRAME_CURSOR_RULES_OUT || argPath || process.cwd(),
51
+ );
52
+
53
+ if (!fs.existsSync(projectRoot)) {
54
+ console.error("[mvframe] 目录不存在:", projectRoot);
55
+ process.exit(1);
56
+ }
57
+
58
+ installCursorRules(projectRoot);
59
+ }
60
+
61
+ if (require.main === module) {
62
+ main();
63
+ }
64
+
65
+ module.exports = {
66
+ installCursorRules,
67
+ };
@@ -17,6 +17,7 @@ const fs = require("fs");
17
17
  const path = require("path");
18
18
  const { execFileSync } = require("child_process");
19
19
  const { upsertCodexAgents } = require("./install-codex-agents.js");
20
+ const { installCursorRules } = require("./install-cursor-rules.js");
20
21
 
21
22
  const FORCE = process.argv.includes("--force") || process.argv.includes("-f");
22
23
  const NO_PKG = process.argv.includes("--no-package-json") || process.argv.includes("-n");
@@ -54,27 +55,6 @@ function appendGitignoreLines(lines) {
54
55
  console.log("[mvframe-init] 已更新 .gitignore");
55
56
  }
56
57
 
57
- /**
58
- * 将本包 `.cursor/rules/*.mdc` 复制到目标工程,与 mvframe 仓库内 Cursor 规则保持一致。
59
- * 发布包需在 `package.json` 的 `files` 中包含 `.cursor/rules`。
60
- */
61
- function copyCursorRulesFromPackage() {
62
- const rulesSrc = path.join(__dirname, "..", ".cursor", "rules");
63
- if (!fs.existsSync(rulesSrc)) {
64
- console.warn(
65
- "[mvframe-init] 未找到包内 .cursor/rules(请使用含该目录的 mvframe 版本),跳过 Cursor 规则复制",
66
- );
67
- return;
68
- }
69
- const entries = fs.readdirSync(rulesSrc, { withFileTypes: true });
70
- for (const ent of entries) {
71
- if (!ent.isFile() || !ent.name.endsWith(".mdc")) continue;
72
- const content = fs.readFileSync(path.join(rulesSrc, ent.name), "utf8");
73
- const rel = path.join(".cursor", "rules", ent.name);
74
- write(rel.replace(/\\/g, "/"), content);
75
- }
76
- }
77
-
78
58
  /** 与 main.js / vite.config 模板一致;版本号与 mvframe 本仓库对齐思路,可随发布调整 */
79
59
  // @vue/shared 为 Vue 3 内部包,传递依赖在部分包管理器下未提升时 Vite 解析失败,故写入直连依赖
80
60
  const SCAFFOLD_DEPENDENCIES = {
@@ -187,7 +167,7 @@ function main() {
187
167
  fs.mkdirSync(path.join(target, d), { recursive: true });
188
168
  }
189
169
 
190
- copyCursorRulesFromPackage();
170
+ installCursorRules(target);
191
171
  upsertCodexAgents(target);
192
172
  appendGitignoreLines([".env.local", ".env.mvframe-notify"]);
193
173
 
@@ -976,6 +956,12 @@ await notify("需要发送到钉钉的消息");
976
956
 
977
957
  初始化脚本会写入/更新项目根 **\`AGENTS.md\`** 的 MVFrame 区块,供 Codex 在宿主项目内优先使用 **MVFrame 全局组件、全局方法与全局样式工具类**,并要求 **每次 AI 完成开发后调用 \`yarn exec mvframe-notify --once --message "..."\` 发送完成通知**。该区块带有 \`MVFRAME-CODEX-RULES\` 标记,重复执行脚手架会更新这段内容,不会覆盖你在 \`AGENTS.md\` 中的其它规则。
978
958
 
959
+ 同时初始化 Codex + Cursor 两侧规则:
960
+
961
+ \`\`\`bash
962
+ yarn exec mvframe-init-rules
963
+ \`\`\`
964
+
979
965
  仅安装 Codex 规则:
980
966
 
981
967
  \`\`\`bash
@@ -984,7 +970,13 @@ yarn exec mvframe-install-codex-rules
984
970
 
985
971
  ## Cursor 规则(\`.cursor/rules\`)
986
972
 
987
- 初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 写入目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若目录或文件已存在且未加 \`--force\` / \`-f\`,则跳过对应文件。
973
+ 初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 补充到目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若宿主项目已存在同名规则文件,则保留宿主文件,仅补缺失项。
974
+
975
+ 仅安装 Cursor 规则:
976
+
977
+ \`\`\`bash
978
+ yarn exec mvframe-install-cursor-rules
979
+ \`\`\`
988
980
 
989
981
  npm 包需在 \`files\` 中包含 \`.cursor/rules\`;使用本地 \`file:\` / 源码链接时同样可用。
990
982