mvframe 1.0.80 → 1.0.82

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mvframe",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.80",
4
+ "version": "1.0.82",
5
5
  "author": "matt avis",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -18,67 +18,73 @@ const path = require("path");
18
18
 
19
19
  const BEGIN = "<!-- MVFRAME-CODEX-RULES:BEGIN -->";
20
20
  const END = "<!-- MVFRAME-CODEX-RULES:END -->";
21
+ const STYLE_RULES_FILE = path.join(__dirname, "..", ".cursor", "rules", "style-system.mdc");
21
22
 
22
- function renderCodexAgentsSection() {
23
- return `${BEGIN}
24
- # MVFrame Codex Rules
25
-
26
- This project uses MVFrame. When editing Vue, JS, TS, SCSS, or CSS in this host app, prefer the framework globals before adding local implementations.
23
+ function stripFrontmatter(markdown) {
24
+ if (!markdown.startsWith("---")) {
25
+ return markdown;
26
+ }
27
+ const end = markdown.indexOf("\n---", 3);
28
+ if (end < 0) {
29
+ return markdown;
30
+ }
31
+ return markdown.slice(end + 4).replace(/^\s*\n/, "");
32
+ }
27
33
 
28
- ## Global Components
34
+ function shiftMarkdownHeadings(markdown, level = 1) {
35
+ return markdown.replace(/^(#{1,6})\s+/gm, (_all, hashes) => {
36
+ const nextLevel = Math.min(6, hashes.length + level);
37
+ return `${"#".repeat(nextLevel)} `;
38
+ });
39
+ }
29
40
 
30
- - Prefer MVFrame global components in templates without local imports: \`Frame\`, \`Page\`, \`Table\`, \`Form\`, \`Input\`, \`Textarea\`, \`Select\`, \`SelectV2\`, \`Tabs\`, \`BtnGroup\`, \`Icon\`, \`Loading\`, \`Drawer\`, \`DrawerArea\`, \`Login\`, \`Lang\`.
31
- - Do not rebuild an equivalent control with raw DOM, \`el-*\` combinations, or third-party components unless the MVFrame component cannot express the behavior.
32
- - For segmented controls, single-choice button groups, login forms, page shells, tables, drawers, loading masks, and framework navigation, check the MVFrame component first.
41
+ function getSharedStyleRulesForCodex() {
42
+ const raw = fs.readFileSync(STYLE_RULES_FILE, "utf8");
43
+ const withoutFrontmatter = stripFrontmatter(raw).trim();
44
+ const withoutRootTitle = withoutFrontmatter.replace(/^#\s+mvframe\s+样式系统\s*\n*/i, "");
45
+ return shiftMarkdownHeadings(withoutRootTitle, 1).trim();
46
+ }
33
47
 
34
- ## Global Style Utilities
48
+ function renderCodexAgentsSection() {
49
+ return `${BEGIN}
50
+ # MVFrame Codex 规则
35
51
 
36
- - Before writing scoped CSS, inline \`:style\`, or new SCSS utility code, check whether MVFrame global classes already cover it.
37
- - MVFrame styles must be imported once from the app entry: \`import "mvframe/style"\` and \`import "mvframe/style/cpt"\`. If utility classes appear missing, fix the import before duplicating CSS.
38
- - Prefer utility classes in templates for common layout, spacing, sizing, typography, color, border, scroll, hover, radius, and positioning work.
52
+ 本项目使用 MVFrame。在该宿主项目中编辑 Vue、JS、TS、SCSS CSS 时,新增本地实现前,优先检查并复用框架已有的全局能力。
39
53
 
40
- Common utility classes:
54
+ ## 全局组件
41
55
 
42
- | Need | Prefer |
43
- |------|--------|
44
- | flex layout | \`flexMode\`, \`flexV\`, \`flex1\`, \`flexGrow\`, \`noShrink\`, \`minw0\`, \`minh0\` |
45
- | flex alignment | \`hl\`, \`hc\`, \`hr\`, \`hb\`, \`ha\`, \`vl\`, \`vc\`, \`vr\`, \`vs\` |
46
- | wrapping / gaps | \`flexWrap\`, \`grid\`, \`g2\` ... \`g40\` |
47
- | spacing | \`p{N}\`, \`pt{N}\`, \`pr{N}\`, \`pb{N}\`, \`pl{N}\`, \`m{N}\`, \`mt{N}\`, \`mr{N}\`, \`mb{N}\`, \`ml{N}\` where N is one of \`0,2,4,6,8,10,12,16,20,24,30,32,36,40,48\` |
48
- | sizing | \`w{N}\`, \`h{N}\`, \`minw{N}\`, \`maxw{N}\`, \`minh{N}\`, \`maxh{N}\`, \`wp25\`, \`wp50\`, \`wp75\`, \`wp100\`, \`hp100\`, \`vh100\` |
49
- | text | \`fs{N}\`, \`lh{N}\`, \`fw300\`, \`fw500\`, \`fw700\`, \`txt-c\`, \`txt-r\`, \`txt-nowrap\`, \`txt-nowrap{N}\`, \`txt-wrap\`, \`txt-prewrap\` |
50
- | color / background | \`txt-h1\`, \`txt-h2\`, \`txt-p\`, \`txt-tip\`, \`txt-gray\`, \`txt-primary\`, \`bg-primary\`, \`bg-page-header\`, \`border\`, \`border-t\`, \`border-b\`, \`border-none\` |
51
- | positioning / effects | \`relative\`, \`abs\`, \`absFull\`, \`absCenter\`, \`sticky\`, \`z1\`, \`z2\`, \`z9\`, \`radius{N}\`, \`radiusP50\`, \`hover\`, \`trans-all\`, \`backdrop\` |
52
- | interaction / scroll | \`point\`, \`grab\`, \`yscroll\`, \`xscroll\`, \`nobar\`, \`noscroll\`, \`noselect\`, \`noevent\`, \`hide\` |
56
+ - 模板内优先直接使用 MVFrame 全局组件,不要重复本地 import:\`Frame\`、\`Page\`、\`Table\`、\`Form\`、\`Input\`、\`Textarea\`、\`Select\`、\`SelectV2\`、\`Tabs\`、\`BtnGroup\`、\`Icon\`、\`Loading\`、\`Drawer\`、\`DrawerArea\`、\`Login\`、\`Lang\`。
57
+ - 除非 MVFrame 组件确实无法表达该交互,否则不要用原生 DOM、\`el-*\` 组合或第三方组件去重造等价控件。
58
+ - 遇到分段切换、单选按钮组、登录表单、页面外壳、表格、抽屉、加载遮罩、框架导航等场景,先检查 MVFrame 组件是否已经覆盖。
53
59
 
54
- Spacing rule: do not add odd-pixel \`margin\` or \`padding\` such as \`3px\`, \`5px\`, \`7px\`, \`9px\`, or \`11px\`. Use the MVFrame spacing classes or rem values aligned with the spacing scale.
60
+ ## 全局样式工具类
55
61
 
56
- Scoped styles are still allowed for component-specific behavior, complex selectors, custom brand visuals, third-party overrides, or values not covered by the utility system. Keep those scoped rules narrow and combine them with MVFrame classes.
62
+ ${getSharedStyleRulesForCodex()}
57
63
 
58
- ## Global Methods
64
+ ## 全局方法
59
65
 
60
- - Prefer MVFrame globals instead of repeated imports or local helpers: \`globalThis.$d\`, \`$fa\`, \`$fu\`, \`$pm\`, \`$db\`, \`$copy\`, \`$deepClone\`, \`$getLang\`, \`$getImg\`, \`$sc\`, \`$c.info\`.
61
- - In templates, call global methods directly when they are provided through Vue globalProperties.
62
- - For ordinary JS modules, use \`globalThis.$xxx\` or the exported MVFrame subpath only when a direct import is explicitly needed.
66
+ - 优先使用 MVFrame 全局方法,不要重复 import 或本地封装等价 helper:\`globalThis.$d\`、\`$fa\`、\`$fu\`、\`$pm\`、\`$db\`、\`$copy\`、\`$deepClone\`、\`$getLang\`、\`$getImg\`、\`$sc\`、\`$c.info\`。
67
+ - 在模板里,如果这些方法已经通过 Vue globalProperties 注入,直接调用即可。
68
+ - 对普通 JS 模块,优先使用 \`globalThis.$xxx\`;只有确实需要显式 import 时,再使用 MVFrame 的子路径导出。
63
69
 
64
- ## Router, Store, And Maps
70
+ ## 路由、Store Maps
65
71
 
66
- - Prefer route \`name\` navigation over raw \`path\` navigation.
67
- - Use the MVFrame store factory pattern already wired by the app: \`inject("store")\` in components or \`import { store, pinia } from "mvframe/store"\` in setup code and guards.
68
- - For MVFrame maps/i18n maps, prefer \`useMap\`, \`getMaps\`, \`patchMaps\`, \`mapLang\`, and \`mapLangPath\` from \`mvframe/maps\`.
72
+ - 路由跳转优先使用 route \`name\`,不要优先写死 \`path\`。
73
+ - 使用项目已经接好的 MVFrame store factory 模式:组件内用 \`inject("store")\`,setup 代码或守卫里用 \`import { store, pinia } from "mvframe/store"\`。
74
+ - 涉及 MVFrame maps / i18n maps 时,优先使用 \`useMap\`、\`getMaps\`、\`patchMaps\`、\`mapLang\`、\`mapLangPath\`,来源为 \`mvframe/maps\`。
69
75
 
70
- ## Editing Checklist
76
+ ## 编辑检查清单
71
77
 
72
- - Before adding markup, check whether a MVFrame global component fits.
73
- - Before adding CSS, check whether MVFrame utility classes fit.
74
- - Before importing a helper library, check whether a MVFrame global helper already exists.
75
- - If local CSS or a new helper is still needed, keep it small and specific to the component.
78
+ - 新增结构前,先判断是否已有合适的 MVFrame 全局组件。
79
+ - 新增 CSS 前,先判断是否已有合适的 MVFrame 工具类。
80
+ - 引入新的 helper 库前,先判断 MVFrame 是否已经提供等价全局方法。
81
+ - 如果最终仍需新增本地 CSS helper,保持小而专,限定在当前组件范围内。
76
82
 
77
- ## Completion Notify
83
+ ## 完成后通知
78
84
 
79
- - After every completed development task, send one concise completion notification from the host project root with \`yarn exec mvframe-notify --once --message "<project or module>: <what changed and current result>"\`.
80
- - Keep the notify message short and delivery-focused. Include the affected module or page, the main completed work, and the current verification result when available.
81
- - If \`.env.mvframe-notify\` is missing, DingTalk notify is not configured, or the notify command fails, do not fake success. Report that notify could not be sent in the final response.
85
+ - 每次完成一个开发任务后,都要在宿主项目根目录发送一条简洁的完成通知:\`yarn exec mvframe-notify --once --message "<项目或模块>: <本次改动与当前结果>"\`。
86
+ - notify 文案保持简短、可投递、可扫读;包含受影响模块或页面、本次完成的主要工作,以及当前验证结果(如果已有)。
87
+ - 如果缺少 \`.env.mvframe-notify\`、钉钉 notify 未配置,或命令执行失败,不要伪造成功;需要在最终回复里明确说明通知未发送成功。
82
88
  ${END}
83
89
  `;
84
90
  }
@@ -3,12 +3,14 @@
3
3
  * 在目标工程生成 MVFrame 推荐目录与雏形文件(views / component / api / pinia / router / config / assets)。
4
4
  *
5
5
  * 用法:
6
- * node path/to/mvframe/scripts/scaffold-app.js [项目根] [--force]
6
+ * node path/to/mvframe/scripts/scaffold-app.js [项目根] [--force|-f]
7
7
  * yarn exec mvframe-init-app
8
8
  *
9
9
  * 环境变量:MVFRAME_SCAFFOLD_TARGET=/path/to/project
10
10
  *
11
- * 选项:--no-package-json 不读不写 package.json(仅生成源码与 Vite 配置)
11
+ * 选项:
12
+ * --force, -f 覆盖已存在的脚手架文件
13
+ * --no-package-json, -n 不读不写 package.json(仅生成源码与 Vite 配置)
12
14
  */
13
15
 
14
16
  const fs = require("fs");
@@ -16,10 +18,10 @@ const path = require("path");
16
18
  const { execFileSync } = require("child_process");
17
19
  const { upsertCodexAgents } = require("./install-codex-agents.js");
18
20
 
19
- const FORCE = process.argv.includes("--force");
20
- const NO_PKG = process.argv.includes("--no-package-json");
21
+ const FORCE = process.argv.includes("--force") || process.argv.includes("-f");
22
+ const NO_PKG = process.argv.includes("--no-package-json") || process.argv.includes("-n");
21
23
  const argPath = process.argv.find(
22
- (a, i) => i >= 2 && a !== "--force" && !a.startsWith("--"),
24
+ (a, i) => i >= 2 && !a.startsWith("-"),
23
25
  );
24
26
  const target = path.resolve(
25
27
  process.env.MVFRAME_SCAFFOLD_TARGET || argPath || process.cwd(),
@@ -831,7 +833,7 @@ yarn dev
831
833
  yarn exec mvframe-d
832
834
  \`\`\`
833
835
 
834
- 若需跳过对 \`package.json\` 的修改:\`node scripts/scaffold-app.js --no-package-json\`。
836
+ 若需跳过对 \`package.json\` 的修改:\`node scripts/scaffold-app.js --no-package-json\` 或 \`node scripts/scaffold-app.js -n\`。
835
837
 
836
838
  自动生成的 \`vite.config.js\` 已包含 \`unplugin-auto-import\`;\`dts: true\` 时类型默认写在项目根 \`auto-imports.d.ts\`。
837
839
 
@@ -934,7 +936,7 @@ yarn exec mvframe-install-codex-rules
934
936
 
935
937
  ## Cursor 规则(\`.cursor/rules\`)
936
938
 
937
- 初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 写入目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若目录或文件已存在且未加 \`--force\`,则跳过对应文件。
939
+ 初始化脚本会把 **mvframe 包内**与仓库一致的 **\`*.mdc\`** 写入目标项目 **\`/.cursor/rules/\`**(\`component-hierarchy\`、\`script-setup\`、\`style-system\`、\`views\`、\`router\`、\`global-components\`、\`data\`、\`util\`)。若目录或文件已存在且未加 \`--force\` / \`-f\`,则跳过对应文件。
938
940
 
939
941
  npm 包需在 \`files\` 中包含 \`.cursor/rules\`;使用本地 \`file:\` / 源码链接时同样可用。
940
942