@open-dy/interest-card-cli 0.1.0-beta.30 → 0.1.0-beta.32
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/browser-runtime/scripts/capture-feed-card.sh +23 -18
- package/browser-runtime/scripts/cli.mjs +10 -3
- package/browser-runtime/scripts/inspect-preview-state.mjs +6 -4
- package/browser-runtime/scripts/preview-session.mjs +9 -0
- package/card-skills/douyin-interest-card-browser/references/commands.md +1 -1
- package/card-skills/douyin-interest-card-capability/SKILL.md +12 -4
- package/card-skills/douyin-interest-card-capability/references/common/openapi/external/guide.md +5 -5
- package/card-skills/douyin-interest-card-capability/references/microapp/api/capability-index.json +27 -27
- package/card-skills/douyin-interest-card-capability/references/microapp/api/connect-socket.md +24 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-bytenn-engine-context.md +11 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-camera-context.md +12 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-canvas-context.md +45 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-effect-camera-stream.md +21 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-inner-audio-context.md +80 -3
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-intersection-observer.md +12 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-interstitial-ad.md +12 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-live-player-context.md +16 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-map-context.md +24 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-media-recorder.md +17 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-offscreen-canvas.md +9 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-rewarded-video-ad.md +16 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-rtc-room-context.md +33 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-scene-activity-context.md +13 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-selector-query.md +13 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-sticker-manager.md +11 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/create-video-context.md +17 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/download-file.md +10 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/get-algorithm-manager.md +9 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/get-background-audio-manager.md +60 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/api/get-file-system-manager.md +37 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/get-recorder-manager.md +23 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/get-update-manager.md +11 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/preload-video.md +8 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/request.md +8 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/api/upload-file.md +10 -0
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/capability-index.json +9 -4
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/censor-image.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/censor-text.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/check-fans.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/create-activity.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-affiliate-id.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-aiuser-data-info.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-aiuser-item-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-aiuser-profile.md +7 -5
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-fans-favourite.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-fans-profile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-fans-source.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-feed.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-follow-feed.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-follow-hot-word.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-friend-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-hot-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-music-collection-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-recommend.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-related-id.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-room-real-time-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-basic-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-cert-labels-info.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-comment-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-constellation.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-fans-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-fans-profile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-following.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-hash-mobile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-interest.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-item-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-like-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-profile-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-user-share-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/get-video-pack.md +48 -3
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/modify-activity.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/query-activity-info.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/query-activity-user-completion-status.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/query-room-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-experience.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-general.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-live.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-music.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-user.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-video.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/microapp/openapi/external/search-vision.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/api/call-container.md +1 -0
- package/card-skills/douyin-interest-card-capability/references/opencard/api/capability-index.json +6 -6
- package/card-skills/douyin-interest-card-capability/references/opencard/api/create-inner-audio-context.md +60 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/api/create-map-context.md +24 -0
- package/card-skills/douyin-interest-card-capability/references/opencard/api/create-selector-query.md +13 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/api/create-video-context.md +17 -0
- package/card-skills/douyin-interest-card-capability/references/opencard/api/download-file.md +1 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/api/get-background-audio-manager.md +60 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/api/request.md +1 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/api/upload-file.md +1 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/closed-domain-openapi.md +2 -2
- package/card-skills/douyin-interest-card-capability/references/opencard/component/button.md +4 -2
- package/card-skills/douyin-interest-card-capability/references/opencard/component/canvas.md +4 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/component/capability-index.json +8 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/component/checkbox-group.md +2 -0
- package/card-skills/douyin-interest-card-capability/references/opencard/component/image.md +3 -2
- package/card-skills/douyin-interest-card-capability/references/opencard/component/input.md +3 -2
- package/card-skills/douyin-interest-card-capability/references/opencard/component/text.md +3 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/component/textarea.md +5 -5
- package/card-skills/douyin-interest-card-capability/references/opencard/component/video.md +10 -2
- package/card-skills/douyin-interest-card-capability/references/opencard/component-guide.md +5 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/capability-index.json +16 -11
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/censor-image.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/censor-text.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/check-fans.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/create-activity.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-affiliate-id.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-aiuser-data-info.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-aiuser-item-list.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-aiuser-profile.md +16 -13
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-fans-favourite.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-fans-profile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-fans-source.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-feed.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-follow-feed.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-follow-hot-word.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-friend-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-hot-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-music-collection-list.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-recommend.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-related-id.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-room-real-time-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-basic-data.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-cert-labels-info.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-comment-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-constellation.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-fans-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-fans-profile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-following.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-hash-mobile.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-interest.md +10 -9
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-item-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-like-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-profile-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-user-share-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/get-video-pack.md +48 -3
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/modify-activity.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/query-activity-info.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/query-activity-user-completion-status.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/query-room-data.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-experience.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-general.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-live.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-music.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-user.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-video.md +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/openapi/search-vision.md +1 -1
- package/card-skills/douyin-interest-card-capability/scripts/search-capabilities.mjs +7 -4
- package/card-skills/douyin-interest-card-cli/SKILL.md +11 -5
- package/card-skills/douyin-interest-card-generate/SKILL.md +5 -3
- package/card-skills/douyin-interest-card-generate/init.sh +13 -23
- package/card-skills/douyin-interest-card-generate/references/common/fullstack.md +6 -10
- package/card-skills/douyin-interest-card-generate/references/common/post-card-differences.md +29 -3
- package/card-skills/douyin-interest-card-generate/references/common/private-data-intent-routing.md +1 -1
- package/card-skills/douyin-interest-card-generate/references/common/upgrade-to-post.md +29 -6
- package/card-skills/douyin-interest-card-generate/references/microapp/microapp.md +1 -1
- package/card-skills/douyin-interest-card-generate/references/opencard/api.md +8 -0
- package/card-skills/douyin-interest-card-generate/references/opencard/closed-domain-card.md +1 -1
- package/card-skills/douyin-interest-card-generate/references/opencard/components.md +11 -28
- package/card-skills/douyin-interest-card-generate/references/opencard/opencard.md +9 -7
- package/card-skills/douyin-interest-card-generate/references/opencard/rendering.md +5 -5
- package/card-skills/douyin-interest-card-generate/references/opencard/taro-dsl.md +6 -6
- package/card-skills/douyin-interest-card-generate/scripts/inspect-post-upgrade.mjs +630 -0
- package/card-skills/douyin-interest-card-generate/templates/fragments/opencard/package.json +2 -2
- package/card-skills/douyin-interest-card-generate/templates/fragments/opencard/pnpm-lock.yaml +17 -17
- package/card-skills/douyin-interest-card-generate/templates/taro/closed-domain-server/package.json +1 -1
- package/card-skills/douyin-interest-card-generate/templates/taro/package.json +5 -4
- package/card-skills/douyin-interest-card-generate/templates/taro/pnpm-lock.yaml +27 -26
- package/card-skills/douyin-interest-card-generate/templates/taro/server/package.json +1 -1
- package/dist/src/args.js +23 -8
- package/dist/src/browser.js +3 -1
- package/dist/src/card/agent-chat.js +4 -0
- package/dist/src/card/binding.js +2 -1
- package/dist/src/card/candidate.js +90 -0
- package/dist/src/card/card-api.js +2 -2
- package/dist/src/card/card-token.js +25 -2
- package/dist/src/card/chat-commands.js +26 -11
- package/dist/src/card/constants.js +5 -0
- package/dist/src/card/create-project-client.js +2 -2
- package/dist/src/card/create.js +29 -3
- package/dist/src/card/editor-client.js +41 -6
- package/dist/src/card/editor-fs.js +4 -4
- package/dist/src/card/global-skills.js +6 -1
- package/dist/src/card/handlers-misc.js +3 -6
- package/dist/src/card/handlers.js +32 -24
- package/dist/src/card/help.js +6 -4
- package/dist/src/card/ignore.js +22 -0
- package/dist/src/card/project.js +13 -4
- package/dist/src/card-install.js +8 -9
- package/dist/src/cli.js +5 -2
- package/dist/src/config.js +26 -3
- package/dist/src/creator-device-login.js +2 -1
- package/dist/src/creator-login-session.js +6 -6
- package/dist/src/creator-passport-login.js +8 -2
- package/dist/src/creator-session.js +30 -7
- package/dist/src/current-user.js +29 -0
- package/dist/src/help-access.js +22 -0
- package/dist/src/help.js +6 -2
- package/dist/src/http.js +4 -4
- package/dist/src/login-handlers.js +2 -1
- package/dist/src/platform-process.js +98 -0
- package/dist/src/platform.js +1 -1
- package/dist/src/request-source.js +4 -0
- package/dist/src/telemetry-session.js +17 -0
- package/dist/src/telemetry.js +7 -2
- package/dist/src/update-check.js +5 -3
- package/dist/src/upgrade.js +56 -12
- package/package.json +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/component/svg.md +0 -58
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync, readdirSync, realpathSync, statSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { isDeepStrictEqual, parseArgs } from 'node:util';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const templates = fileURLToPath(new URL('../templates/', import.meta.url));
|
|
9
|
+
const configFile = /^(?:\.npmrc|(?:babel|eslint|postcss)\.config\.[a-z]+|(?:turbo|tsconfig|project)(?:\.[\w-]+)*\.json)$/u;
|
|
10
|
+
const entryPoint = /^(?:(?:build|dev|lint|pack|verify)(?::|$)|check-routes$|validate-feed-card$)/u;
|
|
11
|
+
const toolchain = /^(?:@open-dy\/(?:vibecoding-cli|vibecoding-sdk-(?:taro|opencard)|opencard-taro)|@tarojs\/.+|turbo|eslint|typescript)$/u;
|
|
12
|
+
const dependencyFields = ['dependencies', 'devDependencies', 'optionalDependencies'];
|
|
13
|
+
const workspaceName = 'pnpm-workspace.yaml';
|
|
14
|
+
const schemaName = 'custom-card-schema.json';
|
|
15
|
+
const routingFile = 'config/card-routing.json';
|
|
16
|
+
const devRestartTriggerIds = new Set([
|
|
17
|
+
'DEPENDENCY_DECLARATION', 'PARENT_DEPENDENCY', 'DEPENDENCY_UNRESOLVED', 'MANIFEST_SETTING',
|
|
18
|
+
'PATCH_MISSING', 'LOCAL_REFERENCE_REVIEW', 'ROOT_WORKSPACE_REVIEW', 'OPENCARD_WORKSPACE_REVIEW',
|
|
19
|
+
'SCRIPT_ENTRY_DIFFERS', 'SCRIPT_TARGET_MISSING', 'FILE_DIFFERS',
|
|
20
|
+
]);
|
|
21
|
+
const legacyLucideGuidance = '存在旧图标别名 `paths["lucide-taro"]`(指向本地 `icons`):在 `package.json` 声明 `@open-dy/lucide-taro` 后,将 `src/` 中的 `lucide-taro` 导入改为 `@open-dy/lucide-taro`,并删除该 `paths` 别名。';
|
|
22
|
+
const help = 'Usage: node inspect-post-upgrade.mjs --project <card-app root> [--format markdown|json]\nDefault format: markdown';
|
|
23
|
+
const isMissingRouting = item => item.id === 'FILE_MISSING' && item.file === routingFile;
|
|
24
|
+
|
|
25
|
+
function inside(root, file) {
|
|
26
|
+
const relative = path.relative(root, file);
|
|
27
|
+
return relative !== '..' && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Restrict reads to explicit engineering files, including when a file is a symlink.
|
|
31
|
+
function localFile(root, relative) {
|
|
32
|
+
const file = path.resolve(root, relative);
|
|
33
|
+
const allowed = value => inside(root, value) && !path.relative(root, value).split(path.sep).includes('src');
|
|
34
|
+
if (!allowed(file)) throw new Error('path is outside the supported inspection scope');
|
|
35
|
+
try {
|
|
36
|
+
const real = realpathSync(file);
|
|
37
|
+
if (!allowed(real)) throw new Error('symlink is outside the supported inspection scope');
|
|
38
|
+
if (!statSync(real).isFile()) throw new Error('expected a file');
|
|
39
|
+
return real;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (error.code === 'ENOENT' || error.code === 'ENOTDIR') return null;
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function workspacePatterns(text) {
|
|
47
|
+
// Recognize simple pnpm package lists. Leave YAML aliases and complex values for review.
|
|
48
|
+
const lines = text.split(/\r?\n/u);
|
|
49
|
+
const start = lines.findIndex(line => /^packages\s*:/u.test(line));
|
|
50
|
+
if (start < 0) return null;
|
|
51
|
+
const tail = lines[start].replace(/^packages\s*:\s*/u, '').replace(/\s+#.*$|^#.*$/u, '').trim();
|
|
52
|
+
let values = [];
|
|
53
|
+
if (tail) {
|
|
54
|
+
if (!tail.startsWith('[') || !tail.endsWith(']')) return null;
|
|
55
|
+
values = tail.slice(1, -1).split(',').map(value => value.trim()).filter(Boolean);
|
|
56
|
+
} else {
|
|
57
|
+
for (const line of lines.slice(start + 1)) {
|
|
58
|
+
if (/^\s*(?:#.*)?$/u.test(line)) continue;
|
|
59
|
+
if (/^[\w-]+\s*:/u.test(line)) break;
|
|
60
|
+
const item = line.match(/^\s*-\s+(.+?)\s*$/u);
|
|
61
|
+
if (!item) return null;
|
|
62
|
+
values.push(item[1].replace(/\s+#.*$/u, ''));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const patterns = values.map(value => value.replace(/^(['"])(.*?)\1$/u, '$2'));
|
|
66
|
+
return patterns.every(value => /^!?[\w./*?@+-]+$/u.test(value)) ? patterns : null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function findWorkspace(root) {
|
|
70
|
+
for (let dir = root; ; dir = path.dirname(dir)) {
|
|
71
|
+
const file = localFile(dir, workspaceName);
|
|
72
|
+
if (file) return { file: path.join(dir, workspaceName), root: dir, patterns: workspacePatterns(readFileSync(file, 'utf8')) };
|
|
73
|
+
if (path.dirname(dir) === dir) return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function workspaceMembership(workspace, root) {
|
|
78
|
+
if (!workspace) return false;
|
|
79
|
+
if (workspace.root === root) return true;
|
|
80
|
+
if (!workspace.patterns || typeof path.posix.matchesGlob !== 'function') return null;
|
|
81
|
+
const relative = path.relative(workspace.root, root).split(path.sep).join('/');
|
|
82
|
+
return workspace.patterns.some(pattern => !pattern.startsWith('!') && path.posix.matchesGlob(relative, pattern)) &&
|
|
83
|
+
!workspace.patterns.some(pattern => pattern.startsWith('!') && path.posix.matchesGlob(relative, pattern.slice(1)));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function declarations(manifest) {
|
|
87
|
+
return Object.assign({}, ...dependencyFields.map(field => manifest[field]));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function dependencySource(value) {
|
|
91
|
+
if (typeof value !== 'string') return null;
|
|
92
|
+
return /^[\w@./:^~*+ -]+$/u.test(value) && !value.includes('://') ? value : 'custom source';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function installedPackage(root, name) {
|
|
96
|
+
const fromProject = createRequire(path.join(root, 'package.json'));
|
|
97
|
+
try {
|
|
98
|
+
let manifest;
|
|
99
|
+
try {
|
|
100
|
+
manifest = fromProject.resolve(`${name}/package.json`);
|
|
101
|
+
} catch {
|
|
102
|
+
// Some SDKs export their public entry but do not export package.json.
|
|
103
|
+
const entry = fromProject.resolve(name);
|
|
104
|
+
for (let dir = path.dirname(entry); path.dirname(dir) !== dir; dir = path.dirname(dir)) {
|
|
105
|
+
const file = localFile(dir, 'package.json');
|
|
106
|
+
if (!file) continue;
|
|
107
|
+
const metadata = JSON.parse(readFileSync(file, 'utf8'));
|
|
108
|
+
if (metadata.name && metadata.version) {
|
|
109
|
+
manifest = file;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (!manifest) return null;
|
|
115
|
+
const { name: installedName, version } = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
116
|
+
const direct = fromProject.resolve.paths(name)?.find(dir => {
|
|
117
|
+
try {
|
|
118
|
+
return realpathSync(path.join(dir, name)) === realpathSync(path.dirname(manifest));
|
|
119
|
+
} catch {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return { name: installedName, version, manifest, fromParent: Boolean(direct && !inside(root, direct)) };
|
|
124
|
+
} catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function scriptReferences(command = '') {
|
|
130
|
+
// Trace literal repo script paths and simple local pnpm / Turbo calls. Never evaluate shell.
|
|
131
|
+
const files = [...command.matchAll(/(?:^|[\s'"=&|;])(?:\.\/)?(scripts\/[\w./-]+\.(?:[cm]?js|[cm]?ts|sh))(?=$|[\s'";&|])/gu)]
|
|
132
|
+
.map(match => match[1]).filter(file => !file.split('/').includes('..'));
|
|
133
|
+
const localCalls = [...command.matchAll(/(?:^|[;&|]\s*)pnpm\s+(?:run\s+)?([\w:-]+)\b|\bturbo\s+[^;&|]*?\brun\s+([\w:-]+)/gu)]
|
|
134
|
+
.map(match => match[1] ?? match[2])
|
|
135
|
+
.filter(name => entryPoint.test(name));
|
|
136
|
+
return { files: [...new Set(files)], scripts: [...new Set(localCalls)] };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function hasLegacyLucideAlias(text) {
|
|
140
|
+
// tsconfig.json allows JSON comments and trailing commas. Preserve quoted strings in both passes.
|
|
141
|
+
const withoutComments = text.replace(/"(?:[^"\\]|\\.)*"|\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/gu,
|
|
142
|
+
token => token.startsWith('"') ? token : ' ');
|
|
143
|
+
const json = withoutComments.replace(/"(?:[^"\\]|\\.)*"|,\s*(?=[}\]])/gu,
|
|
144
|
+
token => token.startsWith('"') ? token : '');
|
|
145
|
+
try {
|
|
146
|
+
const aliases = JSON.parse(json.replace(/^\uFEFF/u, ''))?.compilerOptions?.paths?.['lucide-taro'];
|
|
147
|
+
return Array.isArray(aliases) && aliases.includes('icons');
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function inspect(root) {
|
|
154
|
+
const findings = [];
|
|
155
|
+
const add = (id, file, message, details = {}) => findings.push({ id, file, message, ...details });
|
|
156
|
+
const taroTemplate = path.join(templates, 'taro');
|
|
157
|
+
const openCardTemplate = path.join(templates, 'fragments/opencard');
|
|
158
|
+
const taroManifest = JSON.parse(readFileSync(path.join(taroTemplate, 'package.json'), 'utf8'));
|
|
159
|
+
const openCardManifest = JSON.parse(readFileSync(path.join(openCardTemplate, 'package.json'), 'utf8'));
|
|
160
|
+
const templateSchema = JSON.parse(readFileSync(path.join(taroTemplate, 'feed', schemaName), 'utf8'));
|
|
161
|
+
const postTemplateInputs = [
|
|
162
|
+
['templates/taro/package.json', declarations(taroManifest), ['@open-dy/vibecoding-sdk-taro', '@open-dy/vibecoding-cli']],
|
|
163
|
+
['templates/fragments/opencard/package.json', declarations(openCardManifest), ['@open-dy/vibecoding-sdk-opencard', '@open-dy/vibecoding-cli']],
|
|
164
|
+
[`templates/taro/feed/${schemaName}`, templateSchema.properties ?? {}, ['BgMusicUrl']],
|
|
165
|
+
];
|
|
166
|
+
for (const [file, entries, keys] of postTemplateInputs) {
|
|
167
|
+
const missing = keys.filter(key => !entries[key]);
|
|
168
|
+
if (missing.length) add('TEMPLATE_POST_CAPABILITY_MISSING', file, 'The bundled template lacks a required post upgrade capability.', { missing });
|
|
169
|
+
}
|
|
170
|
+
const postSupported = findings.length === 0;
|
|
171
|
+
const projectPath = (dir, name) => path.relative(root, path.join(dir, name)).split(path.sep).join('/');
|
|
172
|
+
const locate = (dir, name) => {
|
|
173
|
+
try {
|
|
174
|
+
return localFile(dir, name);
|
|
175
|
+
} catch (error) {
|
|
176
|
+
add('FILE_UNREADABLE', projectPath(dir, name), error.code ?? error.message);
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const read = (dir, name, { json = false, required = false, file = locate(dir, name) } = {}) => {
|
|
181
|
+
const location = projectPath(dir, name);
|
|
182
|
+
try {
|
|
183
|
+
if (!file) {
|
|
184
|
+
if (file === null && required) add('FILE_MISSING', location, 'Required project file is missing.');
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const text = readFileSync(file, 'utf8');
|
|
188
|
+
if (!json) return text;
|
|
189
|
+
const data = JSON.parse(text);
|
|
190
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) throw new Error('expected a JSON object');
|
|
191
|
+
return data;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
add('FILE_UNREADABLE', location, error instanceof SyntaxError ? 'Invalid JSON.' : (error.code ?? error.message));
|
|
194
|
+
return null;
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
function checkFiles(dir, template, scriptFiles) {
|
|
199
|
+
const config = path.join(template, 'config');
|
|
200
|
+
const names = readdirSync(template, { withFileTypes: true })
|
|
201
|
+
.filter(entry => entry.isFile() && configFile.test(entry.name)).map(entry => entry.name);
|
|
202
|
+
names.push(...readdirSync(config, { withFileTypes: true })
|
|
203
|
+
.filter(entry => entry.isFile() && entry.name !== 'card-routing.json').map(entry => `config/${entry.name}`));
|
|
204
|
+
for (const name of [...new Set([...names, ...scriptFiles])].sort()) {
|
|
205
|
+
if (name.split('/').includes('src')) continue;
|
|
206
|
+
const templateFile = localFile(template, name);
|
|
207
|
+
const actual = read(dir, name, { required: true });
|
|
208
|
+
if (actual === null || !templateFile) continue;
|
|
209
|
+
const expected = readFileSync(templateFile, 'utf8');
|
|
210
|
+
const differs = name === '.npmrc'
|
|
211
|
+
? expected.split(/\r?\n/u).map(line => line.trim())
|
|
212
|
+
.filter(line => /^(?:registry|@[^:]+:registry|node-linker|public-hoist-pattern|shamefully-hoist)\s*=/u.test(line))
|
|
213
|
+
.some(line => !actual.split(/\r?\n/u).map(item => item.trim()).includes(line))
|
|
214
|
+
: actual.trim() !== expected.trim();
|
|
215
|
+
if (differs) add('FILE_DIFFERS', projectPath(dir, name), 'Review this engineering file against the matching Skill template.', {
|
|
216
|
+
template: path.relative(templates, templateFile).split(path.sep).join('/'),
|
|
217
|
+
...(dir === root && name === 'tsconfig.json' && hasLegacyLucideAlias(actual) ? { guidance: legacyLucideGuidance } : {}),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function checkProject(dir, template, target, scope) {
|
|
223
|
+
const manifest = read(dir, 'package.json', { json: true, required: true });
|
|
224
|
+
if (!manifest) return null;
|
|
225
|
+
const manifestPath = projectPath(dir, 'package.json');
|
|
226
|
+
const ownDeps = declarations(manifest);
|
|
227
|
+
const targetDeps = declarations(target);
|
|
228
|
+
const installed = {};
|
|
229
|
+
const deps = new Set([...Object.keys(ownDeps), ...Object.keys(targetDeps)].filter(name => toolchain.test(name)));
|
|
230
|
+
for (const name of [...deps].sort()) {
|
|
231
|
+
if (ownDeps[name] !== targetDeps[name]) {
|
|
232
|
+
add('DEPENDENCY_DECLARATION', manifestPath, 'Review the toolchain dependency against the matching template.', {
|
|
233
|
+
dependency: name, declared: dependencySource(ownDeps[name]), expected: dependencySource(targetDeps[name]),
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
installed[name] = installedPackage(dir, name);
|
|
237
|
+
if (installed[name]?.fromParent && scope === 'opencard' && Object.hasOwn(targetDeps, name)) {
|
|
238
|
+
add('PARENT_DEPENDENCY', manifestPath, 'OpenCard resolves this dependency from an ancestor installation.', {
|
|
239
|
+
dependency: name, resolved: installed[name],
|
|
240
|
+
});
|
|
241
|
+
} else if (!installed[name] && Object.hasOwn(ownDeps, name) && /^@open-dy\//u.test(name)) {
|
|
242
|
+
add('DEPENDENCY_UNRESOLVED', manifestPath, 'This SDK or CLI cannot be resolved from the project directory.', { dependency: name });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
for (const name of ['packageManager', 'pnpm']) {
|
|
246
|
+
if (!isDeepStrictEqual(manifest[name], target[name])) {
|
|
247
|
+
const keys = name === 'pnpm' ? [...new Set([...Object.keys(manifest.pnpm ?? {}), ...Object.keys(target.pnpm ?? {})])]
|
|
248
|
+
.filter(key => !isDeepStrictEqual(manifest.pnpm?.[key], target.pnpm?.[key])).sort() : undefined;
|
|
249
|
+
add('MANIFEST_SETTING', manifestPath, 'Review this package manager setting against the template.', { key: name, keys });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const localRefs = Object.entries(manifest.pnpm?.patchedDependencies ?? {});
|
|
253
|
+
for (const map of [ownDeps, manifest.pnpm?.overrides ?? {}]) {
|
|
254
|
+
for (const [name, value] of Object.entries(map)) {
|
|
255
|
+
if (typeof value === 'string' && value.startsWith('file:')) localRefs.push([name, value.slice(5)]);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
for (const [name, relative] of localRefs) {
|
|
259
|
+
try {
|
|
260
|
+
if (typeof relative !== 'string' || !localFile(dir, relative)) {
|
|
261
|
+
add('PATCH_MISSING', manifestPath, 'A referenced local dependency or patch file is missing.', { dependency: name, reference: relative });
|
|
262
|
+
}
|
|
263
|
+
} catch {
|
|
264
|
+
add('LOCAL_REFERENCE_REVIEW', manifestPath, 'Check this local dependency or patch reference manually.', { dependency: name });
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const scripts = {};
|
|
269
|
+
const scriptFiles = new Set(scope === 'root' ? ['scripts/dev_run.sh', 'scripts/pack.sh'] : []);
|
|
270
|
+
const scriptKeys = new Set([...Object.keys(target.scripts ?? {}), ...Object.keys(manifest.scripts ?? {})].filter(key => entryPoint.test(key)));
|
|
271
|
+
for (const key of scriptKeys) {
|
|
272
|
+
const actual = manifest.scripts?.[key];
|
|
273
|
+
const refs = scriptReferences(typeof actual === 'string' ? actual : '');
|
|
274
|
+
scripts[key] = refs;
|
|
275
|
+
refs.files.forEach(file => scriptFiles.add(file));
|
|
276
|
+
if (actual !== target.scripts?.[key]) {
|
|
277
|
+
add('SCRIPT_ENTRY_DIFFERS', manifestPath, 'Review the actual command chain before changing this script.', {
|
|
278
|
+
key: `scripts.${key}`, present: typeof actual === 'string', references: refs, templateCommand: target.scripts?.[key] ?? null,
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
for (const called of refs.scripts) {
|
|
282
|
+
if (typeof manifest.scripts?.[called] !== 'string') {
|
|
283
|
+
add('SCRIPT_TARGET_MISSING', manifestPath, 'This entry calls another project script that is missing.', { key, called });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
checkFiles(dir, template, scriptFiles);
|
|
288
|
+
let workspace = null;
|
|
289
|
+
let member = null;
|
|
290
|
+
try {
|
|
291
|
+
workspace = findWorkspace(dir);
|
|
292
|
+
member = workspaceMembership(workspace, dir);
|
|
293
|
+
} catch (error) {
|
|
294
|
+
add('WORKSPACE_UNREADABLE', projectPath(dir, workspaceName), error.code ?? error.message);
|
|
295
|
+
}
|
|
296
|
+
if (scope === 'root' && workspace?.root !== dir) {
|
|
297
|
+
add('ROOT_WORKSPACE_REVIEW', workspaceName, 'The template declares the service workspace in the app root.');
|
|
298
|
+
}
|
|
299
|
+
if (scope === 'opencard' && workspace && workspace.root !== dir && member !== false) {
|
|
300
|
+
add('OPENCARD_WORKSPACE_REVIEW', workspace.file, member
|
|
301
|
+
? 'OpenCard belongs to an ancestor workspace. The current Skill template installs it independently.'
|
|
302
|
+
: 'Cannot determine OpenCard workspace membership from this packages declaration.');
|
|
303
|
+
}
|
|
304
|
+
return { workspace: workspace?.file ?? null, workspaceMember: member,
|
|
305
|
+
hasLockfile: Boolean(locate(dir, 'pnpm-lock.yaml')), installed, scripts };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const app = checkProject(root, taroTemplate, taroManifest, 'root');
|
|
309
|
+
const openCard = checkProject(path.join(root, 'opencard'), openCardTemplate, openCardManifest, 'opencard');
|
|
310
|
+
const routing = read(root, routingFile, { json: true, required: true });
|
|
311
|
+
const serviceDomain = routing?.cardData?.serviceDomain ?? null;
|
|
312
|
+
if (routing && !['open', 'closed'].includes(serviceDomain)) {
|
|
313
|
+
add('SERVICE_DOMAIN_REVIEW', 'config/card-routing.json', 'Confirm the current service domain using project route evidence.', { serviceDomain });
|
|
314
|
+
}
|
|
315
|
+
if (routing && Object.hasOwn(routing, 'cardType') && !['interest', 'post'].includes(routing.cardType)) {
|
|
316
|
+
add('CARD_TYPE_INVALID', 'config/card-routing.json', 'cardType must be interest or post when present.');
|
|
317
|
+
}
|
|
318
|
+
if (routing && (routing.version !== 1 || routing.cardData?.path !== '/api/dy_card/data' ||
|
|
319
|
+
(routing.cardData?.routes !== undefined && (!Array.isArray(routing.cardData.routes) ||
|
|
320
|
+
routing.cardData.routes.some(route => typeof route !== 'string' || !route.trim()))))) {
|
|
321
|
+
add('CARD_ROUTING_SHAPE', 'config/card-routing.json', 'Review version, cardData.path and cardData.routes against the routing contract.');
|
|
322
|
+
}
|
|
323
|
+
for (const service of serviceDomain === 'closed' ? ['server', 'closed-domain-server'] : ['server']) {
|
|
324
|
+
const manifest = read(root, `${service}/package.json`, { json: true, required: true });
|
|
325
|
+
if (manifest && manifest.name !== service) {
|
|
326
|
+
add('SERVER_PACKAGE_NAME', `${service}/package.json`, 'Confirm that the package name matches the pnpm filter used by the project scripts.', {
|
|
327
|
+
expected: service,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const schemas = [`scripts/schemas/${schemaName}`, `feed/${schemaName}`];
|
|
333
|
+
const schemaFiles = schemas.map(name => [name, locate(root, name)]);
|
|
334
|
+
const candidate = schemaFiles.find(([, file]) => file)?.[0] ?? null;
|
|
335
|
+
let supportsBgMusicUrl = null;
|
|
336
|
+
for (const [name, file] of schemaFiles) {
|
|
337
|
+
const schema = read(root, name, { json: true, required: name.startsWith('feed/'), file });
|
|
338
|
+
if (name === candidate && schema) supportsBgMusicUrl = Object.hasOwn(schema.properties ?? {}, 'BgMusicUrl');
|
|
339
|
+
if (schema && !isDeepStrictEqual(schema, templateSchema)) {
|
|
340
|
+
add('FEED_SCHEMA_DIFFERS', name, 'Review this project Feed Schema against the template.', { effectiveCandidate: name === candidate });
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
if (supportsBgMusicUrl === false) {
|
|
344
|
+
add('POST_SCHEMA_BGM_UNSUPPORTED', candidate, 'The selected project Feed Schema does not declare BgMusicUrl.');
|
|
345
|
+
}
|
|
346
|
+
const feed = read(root, 'feed/feed-card.json', { json: true, required: true });
|
|
347
|
+
if (feed && (typeof feed.BgMusicUrl !== 'string' || !/^https:\/\/[^\s]+$/iu.test(feed.BgMusicUrl.trim()))) {
|
|
348
|
+
add('POST_BGM_REVIEW', 'feed/feed-card.json', 'A post needs a valid HTTPS BgMusicUrl.');
|
|
349
|
+
}
|
|
350
|
+
const missingRouting = findings.findIndex(isMissingRouting);
|
|
351
|
+
if (missingRouting > 0) findings.unshift(...findings.splice(missingRouting, 1));
|
|
352
|
+
return {
|
|
353
|
+
status: findings.length ? 'review' : 'no-findings', project: root,
|
|
354
|
+
template: { postSupported },
|
|
355
|
+
projects: { root: app, opencard: openCard },
|
|
356
|
+
routing: { cardType: routing ? (Object.hasOwn(routing, 'cardType') ? routing.cardType : 'interest') : null,
|
|
357
|
+
isCardTypeUpdating: routing?.isCardTypeUpdating ?? null, serviceDomain,
|
|
358
|
+
route: routing?.cardData?.path ?? null },
|
|
359
|
+
feedSchema: { candidate, fallback: candidate ? null : 'cli', supportsBgMusicUrl, eligible: ['open', 'closed'].includes(serviceDomain) },
|
|
360
|
+
findings,
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
const code = value => `\`${String(value).replace(/[`\r\n]/gu, ' ')}\``;
|
|
365
|
+
const codeList = values => values.map(code).join('、');
|
|
366
|
+
|
|
367
|
+
function findingText(item) {
|
|
368
|
+
const { id, file, key, dependency, declared, expected, references, resolved } = item;
|
|
369
|
+
const location = code(file);
|
|
370
|
+
switch (id) {
|
|
371
|
+
case 'TEMPLATE_POST_CAPABILITY_MISSING':
|
|
372
|
+
return `${location} 缺少 ${codeList(item.missing)}。`;
|
|
373
|
+
case 'SERVICE_DOMAIN_REVIEW':
|
|
374
|
+
return `${location} 的服务域是 ${code(item.serviceDomain ?? '缺失')}。先核实现有卡片接口注册在哪个服务,再处理服务域配置。`;
|
|
375
|
+
case 'CARD_TYPE_INVALID':
|
|
376
|
+
return `${location} 的形态值无效。按现有升级状态核实 \`cardType\`,允许值为 \`interest\` 或 \`post\`。`;
|
|
377
|
+
case 'CARD_ROUTING_SHAPE':
|
|
378
|
+
return `${location} 的路由结构与契约不符。核对 \`version\`、\`cardData.path\` 和 \`cardData.routes\`。`;
|
|
379
|
+
case 'SERVER_PACKAGE_NAME':
|
|
380
|
+
return `${location} 的包名与模板中的 ${code(expected)} 不一致。先核对工程实际使用的 pnpm filter。`;
|
|
381
|
+
case 'DEPENDENCY_DECLARATION':
|
|
382
|
+
return `${location} 的 ${code(dependency)} 当前 ${declared === null ? '未声明' : code(declared)},模板${expected === null ? '未声明' : `是 ${code(expected)}`}。`;
|
|
383
|
+
case 'PARENT_DEPENDENCY':
|
|
384
|
+
return `${location} 的 ${code(dependency)} 实际解析到了父级安装 ${code(resolved.version)},位置在 ${code(resolved.manifest)}。`;
|
|
385
|
+
case 'DEPENDENCY_UNRESOLVED':
|
|
386
|
+
return `${location} 已声明 ${code(dependency)},但从该工程目录解析不到它。`;
|
|
387
|
+
case 'MANIFEST_SETTING':
|
|
388
|
+
return `${location} 的 ${code(key)} 与模板有差异${item.keys?.length ? `,涉及 ${codeList(item.keys)}` : ''}。`;
|
|
389
|
+
case 'PATCH_MISSING':
|
|
390
|
+
return `${location} 引用的 ${code(dependency)} 本地文件不存在,路径是 ${code(item.reference ?? '无效路径')}。`;
|
|
391
|
+
case 'LOCAL_REFERENCE_REVIEW':
|
|
392
|
+
return `${location} 的 ${code(dependency)} 是无法静态核实的本地引用,需确认实际文件位置。`;
|
|
393
|
+
case 'ROOT_WORKSPACE_REVIEW':
|
|
394
|
+
return `${location} 未在项目根生效。核实服务端包实际归属的 workspace。`;
|
|
395
|
+
case 'OPENCARD_WORKSPACE_REVIEW':
|
|
396
|
+
return `${location} 的 OpenCard 安装边界需要核实,当前作品模板按独立项目安装 OpenCard。`;
|
|
397
|
+
case 'WORKSPACE_UNREADABLE':
|
|
398
|
+
return `${location} 无法读取,需核实 workspace 路径和文件权限。`;
|
|
399
|
+
case 'SCRIPT_ENTRY_DIFFERS': {
|
|
400
|
+
const chain = [...references.scripts, ...references.files];
|
|
401
|
+
const actual = !item.present ? '项目未定义' : chain.length ? `项目当前引用 ${codeList(chain)}` : '项目当前命令与模板不同';
|
|
402
|
+
return `${location} 的 ${code(key)},${actual}。模板${item.templateCommand ? `使用 ${code(item.templateCommand)}` : '未定义这一项'}。`;
|
|
403
|
+
}
|
|
404
|
+
case 'SCRIPT_TARGET_MISSING':
|
|
405
|
+
return `${location} 的 ${code(key)} 调用了未定义的脚本 ${code(item.called)}。`;
|
|
406
|
+
case 'FILE_DIFFERS':
|
|
407
|
+
return `${location} 和 ${code(item.template)} 不同。对照实际入口核对是否需要合并模板改动。${item.guidance ? ` ${item.guidance}` : ''}`;
|
|
408
|
+
case 'FILE_MISSING':
|
|
409
|
+
if (isMissingRouting(item)) return `缺少 ${location}:先核实现有卡片接口归属,再补路由配置。`;
|
|
410
|
+
return `缺少 ${location},核实是否为当前入口所需。`;
|
|
411
|
+
case 'FILE_UNREADABLE':
|
|
412
|
+
return `${location} 无法读取,检查文件内容或路径(${code(item.message)})。`;
|
|
413
|
+
case 'FEED_SCHEMA_DIFFERS':
|
|
414
|
+
return `Feed Schema:${location}${item.effectiveCandidate ? ' 是实际优先使用的 Schema 且' : ' '}与模板不同,先处理后再用项目 Feed 校验入口复验。`;
|
|
415
|
+
case 'POST_SCHEMA_BGM_UNSUPPORTED':
|
|
416
|
+
return `Feed Schema:优先使用的 ${location} 缺少 \`BgMusicUrl\`,先同步支持该字段的 Schema,再用项目 Feed 校验入口复验。`;
|
|
417
|
+
case 'POST_BGM_REVIEW':
|
|
418
|
+
return `作品配乐:${location} 的 \`BgMusicUrl\` 缺失或格式无效,按作品配乐规则补齐有效 HTTPS 地址。`;
|
|
419
|
+
default:
|
|
420
|
+
return `${location} — ${item.message}`;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
function extraDependencyGroupKey(dependency, declared) {
|
|
425
|
+
const scoped = dependency.match(/^@([^/]+)\/(.+)$/u);
|
|
426
|
+
if (scoped && typeof declared === 'string' && declared.startsWith('file:')) {
|
|
427
|
+
const [, scope, pkg] = scoped;
|
|
428
|
+
const slug = `${scope}-${pkg}`;
|
|
429
|
+
if (declared.includes(slug)) return declared.replace(slug, `${scope}-*`);
|
|
430
|
+
}
|
|
431
|
+
return declared;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function groupBy(items, getKey) {
|
|
435
|
+
const groups = new Map();
|
|
436
|
+
for (const item of items) {
|
|
437
|
+
const key = getKey(item);
|
|
438
|
+
if (!groups.has(key)) groups.set(key, []);
|
|
439
|
+
groups.get(key).push(item);
|
|
440
|
+
}
|
|
441
|
+
return groups;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
function renderDependencySection(items) {
|
|
445
|
+
const lines = [];
|
|
446
|
+
const directIds = new Set([
|
|
447
|
+
'PATCH_MISSING', 'LOCAL_REFERENCE_REVIEW', 'OPENCARD_WORKSPACE_REVIEW',
|
|
448
|
+
'ROOT_WORKSPACE_REVIEW', 'WORKSPACE_UNREADABLE', 'PARENT_DEPENDENCY', 'DEPENDENCY_UNRESOLVED',
|
|
449
|
+
]);
|
|
450
|
+
for (const item of items.filter(entry => directIds.has(entry.id))) {
|
|
451
|
+
lines.push(`- ${findingText(item)}`);
|
|
452
|
+
}
|
|
453
|
+
const byFile = groupBy(items.filter(entry => !directIds.has(entry.id)), entry => entry.file);
|
|
454
|
+
for (const [file, fileItems] of byFile) {
|
|
455
|
+
const missing = [];
|
|
456
|
+
const mismatch = [];
|
|
457
|
+
const extra = [];
|
|
458
|
+
const settings = [];
|
|
459
|
+
for (const item of fileItems) {
|
|
460
|
+
if (item.id === 'MANIFEST_SETTING') {
|
|
461
|
+
settings.push(item.keys?.length ? `${code(item.key)} 差异:${codeList(item.keys)}` : `${code(item.key)} 与模板不同`);
|
|
462
|
+
} else if (item.declared === null) {
|
|
463
|
+
missing.push(`${code(item.dependency)} (${code(item.expected)})`);
|
|
464
|
+
} else if (item.expected === null) {
|
|
465
|
+
extra.push(item);
|
|
466
|
+
} else {
|
|
467
|
+
mismatch.push(`${code(item.dependency)} (${code(item.declared)} -> ${code(item.expected)})`);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const settingSuffix = settings.length ? `;${settings.join(';')}` : '';
|
|
471
|
+
if (missing.length) {
|
|
472
|
+
lines.push(`- ${code(file)} 缺失:${missing.join('、')}${mismatch.length ? '' : settingSuffix}`);
|
|
473
|
+
}
|
|
474
|
+
if (mismatch.length) {
|
|
475
|
+
lines.push(`- ${code(file)} 版本差异:${mismatch.join('、')}${settingSuffix}`);
|
|
476
|
+
} else if (!missing.length && settings.length) {
|
|
477
|
+
lines.push(`- ${code(file)} 配置差异:${settings.join(';')}`);
|
|
478
|
+
}
|
|
479
|
+
if (extra.length) {
|
|
480
|
+
const extraGroups = groupBy(extra, item => extraDependencyGroupKey(item.dependency, item.declared));
|
|
481
|
+
const formatted = [...extraGroups.entries()].map(([pattern, entries]) => [
|
|
482
|
+
entries.length === 1 ? entries[0].declared : pattern,
|
|
483
|
+
entries.map(entry => entry.dependency),
|
|
484
|
+
]);
|
|
485
|
+
if (formatted.length === 1) {
|
|
486
|
+
lines.push(`- ${code(file)} 模板未声明(${code(formatted[0][0])}):${codeList(formatted[0][1])}`);
|
|
487
|
+
} else {
|
|
488
|
+
lines.push(`- ${code(file)} 模板未声明:`);
|
|
489
|
+
for (const [label, deps] of formatted) {
|
|
490
|
+
lines.push(` - ${code(label)}:${codeList(deps)}`);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
return lines;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function renderConfigSection(items) {
|
|
499
|
+
const lines = [];
|
|
500
|
+
const diffs = items.filter(item => item.id === 'FILE_DIFFERS');
|
|
501
|
+
const buckets = [
|
|
502
|
+
['根工程(对比 `taro/*`)', item => !item.file.startsWith('opencard/') && item.template.startsWith('taro/')],
|
|
503
|
+
['OpenCard(对比 `fragments/opencard/*`)', item => item.file.startsWith('opencard/') && item.template.startsWith('fragments/opencard/')],
|
|
504
|
+
];
|
|
505
|
+
const handled = new Set();
|
|
506
|
+
for (const [label, match] of buckets) {
|
|
507
|
+
const matched = diffs.filter(match);
|
|
508
|
+
if (!matched.length) continue;
|
|
509
|
+
matched.forEach(item => handled.add(item));
|
|
510
|
+
lines.push(`- ${label}:${codeList(matched.map(item => item.file))}`);
|
|
511
|
+
for (const item of matched.filter(entry => entry.guidance)) {
|
|
512
|
+
lines.push(` - ${code(item.file)} ${item.guidance}`);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
for (const item of diffs.filter(entry => !handled.has(entry))) {
|
|
516
|
+
lines.push(`- ${code(item.file)}(对比 ${code(item.template)})`);
|
|
517
|
+
if (item.guidance) lines.push(` - ${code(item.file)} ${item.guidance}`);
|
|
518
|
+
}
|
|
519
|
+
const missingFiles = items.filter(entry => entry.id === 'FILE_MISSING');
|
|
520
|
+
if (missingFiles.length) {
|
|
521
|
+
lines.push(`- 缺失文件(核实是否为当前入口所需):${codeList(missingFiles.map(entry => entry.file))}`);
|
|
522
|
+
}
|
|
523
|
+
for (const item of items.filter(entry => entry.id !== 'FILE_DIFFERS' && entry.id !== 'FILE_MISSING')) {
|
|
524
|
+
lines.push(`- ${findingText(item)}`);
|
|
525
|
+
}
|
|
526
|
+
return lines;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
function renderScriptSection(items) {
|
|
530
|
+
const lines = [];
|
|
531
|
+
for (const item of items.filter(entry => entry.id === 'SCRIPT_TARGET_MISSING')) {
|
|
532
|
+
lines.push(`- ${findingText(item)}`);
|
|
533
|
+
}
|
|
534
|
+
const byFile = groupBy(items.filter(entry => entry.id === 'SCRIPT_ENTRY_DIFFERS'), entry => entry.file);
|
|
535
|
+
for (const [file, entries] of byFile) {
|
|
536
|
+
lines.push(`- ${code(file)}:`);
|
|
537
|
+
for (const item of entries) {
|
|
538
|
+
const name = item.key.replace(/^scripts\./u, '');
|
|
539
|
+
const chain = [...item.references.scripts, ...item.references.files];
|
|
540
|
+
const actual = !item.present ? '未定义' : chain.length ? `引用 ${codeList(chain)}` : '命令不同';
|
|
541
|
+
const expected = item.templateCommand ? code(item.templateCommand) : '模板未定义';
|
|
542
|
+
lines.push(` - ${code(name)}: ${actual} -> ${expected}`);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return lines;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
function markdownReport(report) {
|
|
549
|
+
const { project, template, routing, feedSchema, findings } = report;
|
|
550
|
+
const schemaLabel = feedSchema.candidate ? code(feedSchema.candidate) : 'CLI 内置 Schema(需核对 CLI 版本)';
|
|
551
|
+
const lines = [
|
|
552
|
+
'# 个人页作品升级预检',
|
|
553
|
+
`工程 ${code(project)} | 形态 ${code(routing.cardType ?? '未知')} | 服务域 ${code(routing.serviceDomain ?? '未知')} | Feed Schema ${schemaLabel}`,
|
|
554
|
+
];
|
|
555
|
+
const templateFindings = findings.filter(item => item.id === 'TEMPLATE_POST_CAPABILITY_MISSING');
|
|
556
|
+
if (!template.postSupported) {
|
|
557
|
+
lines.push('', '**先更新 Skill 模板,再复跑预检。** 当前模板缺少作品升级所需能力,下面只列能直接确认的工程问题。', '');
|
|
558
|
+
lines.push(...templateFindings.map(item => `- ${findingText(item)}`), '');
|
|
559
|
+
} else if (!findings.length) {
|
|
560
|
+
lines.push('', '预检范围内未发现问题。可以继续按升级流程适配和验收。');
|
|
561
|
+
return lines.join('\n');
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
const templateComparisons = new Set(['DEPENDENCY_DECLARATION', 'MANIFEST_SETTING', 'SCRIPT_ENTRY_DIFFERS',
|
|
565
|
+
'FILE_DIFFERS', 'FEED_SCHEMA_DIFFERS', 'ROOT_WORKSPACE_REVIEW', 'OPENCARD_WORKSPACE_REVIEW']);
|
|
566
|
+
const remaining = findings.filter(item => !isMissingRouting(item) && item.id !== 'TEMPLATE_POST_CAPABILITY_MISSING' &&
|
|
567
|
+
(template.postSupported || item.guidance || !templateComparisons.has(item.id)));
|
|
568
|
+
|
|
569
|
+
const priorityItems = [];
|
|
570
|
+
const missingRouting = findings.find(isMissingRouting);
|
|
571
|
+
if (missingRouting) priorityItems.push(findingText(missingRouting));
|
|
572
|
+
const priorityIds = new Set([
|
|
573
|
+
'SERVICE_DOMAIN_REVIEW', 'CARD_TYPE_INVALID', 'CARD_ROUTING_SHAPE', 'SERVER_PACKAGE_NAME',
|
|
574
|
+
'POST_SCHEMA_BGM_UNSUPPORTED', 'FEED_SCHEMA_DIFFERS', 'POST_BGM_REVIEW',
|
|
575
|
+
]);
|
|
576
|
+
for (const item of remaining.filter(entry => priorityIds.has(entry.id))) {
|
|
577
|
+
priorityItems.push(findingText(item));
|
|
578
|
+
}
|
|
579
|
+
const needsDevRestart = template.postSupported && remaining.some(item => devRestartTriggerIds.has(item.id)
|
|
580
|
+
|| (item.id === 'FILE_MISSING' && !item.file.startsWith('feed/')));
|
|
581
|
+
if (needsDevRestart) {
|
|
582
|
+
priorityItems.push('迁移后重启:完成下述依赖、配置或启动脚本迁移并安装完依赖后,调用 `curl -fsS -X POST http://127.0.0.1:7983/dev/run -H \'Content-Type: application/json\' -d \'{"projectKey":"card-app"}\'` 重启一次开发服务(不要直接在终端运行 `pnpm dev` / `pnpm run dev`)。');
|
|
583
|
+
}
|
|
584
|
+
if (priorityItems.length) {
|
|
585
|
+
lines.push('**阻塞与必做**:', ...priorityItems.map((text, index) => `${index + 1}. ${text}`));
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
const depIds = new Set([
|
|
589
|
+
'PATCH_MISSING', 'LOCAL_REFERENCE_REVIEW', 'OPENCARD_WORKSPACE_REVIEW', 'ROOT_WORKSPACE_REVIEW',
|
|
590
|
+
'WORKSPACE_UNREADABLE', 'PARENT_DEPENDENCY', 'DEPENDENCY_UNRESOLVED', 'DEPENDENCY_DECLARATION', 'MANIFEST_SETTING',
|
|
591
|
+
]);
|
|
592
|
+
const configIds = new Set(['FILE_DIFFERS', 'FILE_MISSING', 'FILE_UNREADABLE']);
|
|
593
|
+
const scriptIds = new Set(['SCRIPT_TARGET_MISSING', 'SCRIPT_ENTRY_DIFFERS']);
|
|
594
|
+
|
|
595
|
+
const sections = [
|
|
596
|
+
['依赖与安装边界(修正后复跑预检核对包解析位置)', renderDependencySection(remaining.filter(item => depIds.has(item.id)))],
|
|
597
|
+
['配置文件差异(对照实际入口核对是否合并模板改动)', renderConfigSection(remaining.filter(item => configIds.has(item.id)))],
|
|
598
|
+
['脚本入口差异(格式:`script`: 当前 -> 模板;沿实际脚本适配并保留必要自定义步骤)', renderScriptSection(remaining.filter(item => scriptIds.has(item.id)))],
|
|
599
|
+
];
|
|
600
|
+
for (const [title, body] of sections) {
|
|
601
|
+
if (!body.length) continue;
|
|
602
|
+
lines.push('', `## ${title}`, ...body);
|
|
603
|
+
}
|
|
604
|
+
return lines.join('\n').trimEnd();
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
let format = 'markdown';
|
|
608
|
+
try {
|
|
609
|
+
const { values } = parseArgs({ options: {
|
|
610
|
+
project: { type: 'string' },
|
|
611
|
+
format: { type: 'string', default: format },
|
|
612
|
+
help: { type: 'boolean', short: 'h' },
|
|
613
|
+
} });
|
|
614
|
+
if (values.help) {
|
|
615
|
+
console.log(help);
|
|
616
|
+
} else {
|
|
617
|
+
format = values.format;
|
|
618
|
+
if (!values.project?.trim() || !['json', 'markdown'].includes(values.format)) throw new Error(help);
|
|
619
|
+
const root = realpathSync(values.project);
|
|
620
|
+
if (!statSync(root).isDirectory()) throw new Error('--project must be the root directory of the card app.');
|
|
621
|
+
const result = inspect(root);
|
|
622
|
+
console.log(values.format === 'markdown' ? markdownReport(result) : JSON.stringify(result, null, 2));
|
|
623
|
+
if (result.findings.length) process.exitCode = 1;
|
|
624
|
+
}
|
|
625
|
+
} catch (error) {
|
|
626
|
+
console.log(format === 'json'
|
|
627
|
+
? JSON.stringify({ status: 'error', error: error.message })
|
|
628
|
+
: `# 个人页作品升级预检失败\n\n${error.message}`);
|
|
629
|
+
process.exitCode = 2;
|
|
630
|
+
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"lint": "vibecoding-interest-card lint"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@open-dy/vibecoding-sdk-opencard": "^0.1.
|
|
15
|
+
"@open-dy/vibecoding-sdk-opencard": "^0.1.24",
|
|
16
16
|
"@vitejs/plugin-react": "^4.3.0",
|
|
17
17
|
"react": "^18.0.0",
|
|
18
18
|
"react-dom": "^18.0.0"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.9.3",
|
|
32
32
|
"turbo": "^2.9.9",
|
|
33
33
|
"typescript-eslint": "^8.20.0",
|
|
34
|
-
"@open-dy/vibecoding-cli": "^0.1.
|
|
34
|
+
"@open-dy/vibecoding-cli": "^0.1.27"
|
|
35
35
|
},
|
|
36
36
|
"packageManager": "pnpm@10.4.1"
|
|
37
37
|
}
|