refactor: replace yup and front-matter, upgrade MCP to 2.x - #1927
Conversation
Drop yup in favor of shared zod, parse YAML front matter locally, and upgrade the MCP server package to 2.x. Tighten $cose and Qiniu types and rewrite tokenTools with TextEncoder. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🚀 Cloudflare Workers Preview has been successfully deployed! Preview URL: https://md-pr-1927.doocs.workers.dev Built with commit 08fc9a6 |
|
🚀 Surge Preview has been successfully deployed! Preview URL: https://doocs-md-preview-pr-1927.surge.sh Built with commit 08fc9a6 |
There was a problem hiding this comment.
Pull request overview
This PR refactors several dependency integrations across the monorepo to remove/unblock older packages and tighten typing, primarily in the web app’s form validation, the core renderer’s front-matter handling, and the MCP server package.
Changes:
- Replaces
yup+@vee-validate/yupform schemas with shared Zod helpers (requiredString/optionalString) across multiple web dialogs. - Removes
front-matterin@md/coreand adds a localjs-yaml-based YAML front matter parser + tests. - Migrates
@md/mcp-serverfrom@modelcontextprotocol/sdk1.x to@modelcontextprotocol/server2.x and updates Zod schema wiring.
Reviewed changes
Copilot reviewed 33 out of 35 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Removes overrides/patch entries tied to removed deps; adds zod to catalog. |
| pnpm-lock.yaml | Lockfile updates reflecting dependency migrations (yup/front-matter/sdk removal; zod/js-yaml additions). |
| patches/front-matter@4.0.2.patch | Deletes patch for removed front-matter dependency. |
| packages/shared/src/utils/tokenTools.ts | Replaces legacy UTF/base64 implementation with TextEncoder + btoa while keeping public API. |
| packages/shared/src/utils/tokenTools.test.ts | Adds byte-identity tests vs legacy implementation (Qiniu token compatibility). |
| packages/mcp-server/src/index.ts | Updates MCP server imports and converts input schema definition to a Zod object. |
| packages/mcp-server/package.json | Switches MCP dependency to @modelcontextprotocol/server and uses catalog Zod. |
| packages/core/src/utils/front-matter.ts | Adds local YAML front-matter parsing via js-yaml. |
| packages/core/src/utils/front-matter.test.ts | Adds tests for YAML fence parsing, CRLF/BOM, and non-object YAML docs. |
| packages/core/src/renderer/renderer.test.ts | Updates renderer test to assert returned YAML data from front matter parsing. |
| packages/core/src/renderer/renderer-impl.ts | Replaces front-matter usage with new parseFrontMatter helper. |
| packages/core/package.json | Removes front-matter; adds js-yaml + @types/js-yaml. |
| docs/custom-upload.md | Updates examples to prefer fetch and clarifies compatibility aliases. |
| CHANGELOG.md | Updates Vite version mention from v7 to v8. |
| apps/web/src/types/global.d.ts | Tightens window globals typing (e.g., $cose, __MP_Editor_JSAPI__) and converts to module augmentation style. |
| apps/web/src/types/cose.ts | Introduces typed interface for the injected doocs/cose window API. |
| apps/web/src/services/upload/providers.ts | Removes any cast for Qiniu region by building a typed config object. |
| apps/web/src/lib/form-schema.ts | Adds shared Zod schema helpers for optional/required strings. |
| apps/web/src/components/editor/editor-header/PostTaskDialog.vue | Replaces any task status typing with CoseTaskStatus and safer optional chaining. |
| apps/web/src/components/editor/editor-header/PostInfo.vue | Tightens $cose usage and avoids any platform mapping. |
| apps/web/src/components/editor/dialogs/upload-providers/*.vue | Migrates upload-provider validation schemas from yup to Zod. |
| apps/web/src/components/editor/dialogs/upload-providers/UploadProviderForm.vue | Loosens validationSchema prop typing and forwards schema into vee-validate Form. |
| apps/web/src/components/editor/dialogs/MpAccountConfigDialog.vue | Migrates schema to Zod and parses submit values with Zod. |
| apps/web/src/components/editor/dialogs/MarketplaceDialog.vue | Migrates marketplace publish form schema to Zod. |
| apps/web/package.json | Removes yup deps and adds Zod (catalog). |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Wrap Zod schemas in a vee-validate typed schema so required fields show errors on blur. Accept Markdown star lists in front matter, and fall back to the original document when YAML cannot be parsed. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🗑️ Cloudflare Workers preview deployment has been cleaned up. |
Summary
Replace a few outdated dependencies and tighten types. Follow-up commit restores form validation and front-matter fallbacks found in review.
@vee-validate/yup, wrapped with a localtoTypedSchema(__type: 'VVTypedSchema') so vee-validate still shows field errors on blur and submit.js-yaml. Markdown*lists are treated as sequences; invalid YAML keeps the original document instead of stripping the fence.@modelcontextprotocol/sdk1.x to@modelcontextprotocol/server2.0.0.$coseand Qiniuregionno longer rely onany;tokenToolsusesTextEncoder+btoawhile keeping the public API.DialogDescription(a11y). Changelog records Vite 8; custom-upload docs preferfetchand call out axios / CryptoJS / Buffer as compatibility aliases.Type of Change
Test Procedure
pnpm run type-check(web + core/shared/api/mcp + vscode)pnpm web buildpnpm vscode buildpnpm --filter @md/web exec vitest run src/lib/form-schema.test.tspnpm --filter @md/core exec vitest run src/utils/front-matter.test.tsZodErrorin the console)tags:+* itemstill extracts metadata---fences still appears in the preview bodyutil.tokenTools.utf16to8/base64encode/safe64names are unchanged (emoji HMAC may differ from the old CESU-8 encoder)Pre-flight Checklist