@open-dy/interest-card-cli 0.1.0-beta.30 → 0.1.0-beta.31
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/cli.mjs +10 -3
- package/browser-runtime/scripts/inspect-preview-state.mjs +6 -4
- 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 +1 -1
- 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 +10 -9
- 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-cli/SKILL.md +1 -1
- 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/private-data-intent-routing.md +1 -1
- package/card-skills/douyin-interest-card-generate/references/common/upgrade-to-post.md +1 -1
- 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/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 +20 -8
- package/package.json +1 -1
- package/card-skills/douyin-interest-card-capability/references/opencard/component/svg.md +0 -58
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs/promises';
|
|
3
|
+
/** Tools that Windows ships as `.cmd` shims rather than executables. */
|
|
4
|
+
const WINDOWS_SHIMS = new Set(['npm', 'npx']);
|
|
5
|
+
/**
|
|
6
|
+
* How to start `command` on this platform. Node cannot start a Windows `.cmd` shim directly
|
|
7
|
+
* (`spawn npm ENOENT`), so npm and npx go through cmd.exe there, with every argument quoted here
|
|
8
|
+
* because Node joins shell arguments without quoting them.
|
|
9
|
+
*/
|
|
10
|
+
export function commandInvocation(command, args, platform = process.platform) {
|
|
11
|
+
if (platform !== 'win32' || !WINDOWS_SHIMS.has(command)) {
|
|
12
|
+
return { command, args, options: { windowsHide: true } };
|
|
13
|
+
}
|
|
14
|
+
// One command line and no argument list: Node warns (DEP0190) about arguments passed to a shell.
|
|
15
|
+
return {
|
|
16
|
+
command: [command, ...args.map(quoteForCmd)].join(' '),
|
|
17
|
+
args: [],
|
|
18
|
+
options: { shell: true, windowsHide: true },
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Quotes one argument for cmd.exe: spaces and `&|<>^()` are literal inside double quotes. */
|
|
22
|
+
export function quoteForCmd(arg) {
|
|
23
|
+
if (/^[A-Za-z0-9_\-.:/=@\\,+]+$/.test(arg)) {
|
|
24
|
+
return arg;
|
|
25
|
+
}
|
|
26
|
+
// Backslashes before a quote, or before the closing quote, must be doubled for the program
|
|
27
|
+
// that parses the command line after cmd.exe.
|
|
28
|
+
const escaped = arg.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/, '$1$1');
|
|
29
|
+
return `"${escaped}"`;
|
|
30
|
+
}
|
|
31
|
+
/** A detached child gets its own console window on Windows unless it is hidden. */
|
|
32
|
+
export const DETACHED_WORKER_OPTIONS = { detached: true, windowsHide: true };
|
|
33
|
+
/** What to run so the system opens `url` in the default browser. */
|
|
34
|
+
export function browserOpenCommand(url, platform = process.platform) {
|
|
35
|
+
if (platform === 'darwin') {
|
|
36
|
+
return ['open', [url]];
|
|
37
|
+
}
|
|
38
|
+
if (platform === 'win32') {
|
|
39
|
+
// Not `cmd /c start`: cmd.exe would cut the URL at the first `&`.
|
|
40
|
+
return ['rundll32', ['url.dll,FileProtocolHandler', url]];
|
|
41
|
+
}
|
|
42
|
+
return ['xdg-open', [url]];
|
|
43
|
+
}
|
|
44
|
+
/** Why a child process could not start, in words a user can act on. */
|
|
45
|
+
export function spawnFailureCause(command, error) {
|
|
46
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
47
|
+
if (error?.code === 'ENOENT') {
|
|
48
|
+
return `${command} was not found on PATH (${message}). Install Node.js with npm, then reopen the terminal.`;
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
}
|
|
52
|
+
const BUSY_CODES = new Set(['EPERM', 'EACCES', 'EBUSY']);
|
|
53
|
+
const BUSY_RETRY_DELAYS_MS = [10, 25, 50, 100, 200, 400];
|
|
54
|
+
/**
|
|
55
|
+
* Runs a file operation, retrying on Windows while another process (a second CLI command, an
|
|
56
|
+
* antivirus scan, the search indexer) briefly holds the file.
|
|
57
|
+
*/
|
|
58
|
+
export async function retryWhileBusy(operation, platform = process.platform) {
|
|
59
|
+
for (const delay of platform === 'win32' ? BUSY_RETRY_DELAYS_MS : []) {
|
|
60
|
+
try {
|
|
61
|
+
return await operation();
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
if (!BUSY_CODES.has(error.code ?? '')) {
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return operation();
|
|
71
|
+
}
|
|
72
|
+
/** `fs.rename` over an existing file, which Windows refuses while the target is open. */
|
|
73
|
+
export async function renameReplacing(from, to, platform = process.platform, rename = fs.rename) {
|
|
74
|
+
await retryWhileBusy(() => rename(from, to), platform);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Replaces `target` with `content` through a temporary file. The temporary name is unique per
|
|
78
|
+
* write: two writes from one process must not share a file, or Windows fails the second open.
|
|
79
|
+
*/
|
|
80
|
+
export async function writeFileReplacing(target, content, mode) {
|
|
81
|
+
const temporary = `${target}.${process.pid}.${randomUUID().slice(0, 8)}.tmp`;
|
|
82
|
+
try {
|
|
83
|
+
await retryWhileBusy(() => fs.writeFile(temporary, content, { mode }));
|
|
84
|
+
await renameReplacing(temporary, target);
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
await fs.rm(temporary, { force: true }).catch(() => undefined);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** Whether two absolute paths are the same directory or `target` is inside `base`. */
|
|
92
|
+
export function isSameOrInside(base, target, platform = process.platform) {
|
|
93
|
+
const sep = platform === 'win32' ? '\\' : '/';
|
|
94
|
+
// Windows paths are case-insensitive, and the drive letter's case varies between tools.
|
|
95
|
+
const fold = (value) => (platform === 'win32' ? value.toLowerCase() : value);
|
|
96
|
+
const [a, b] = [fold(base), fold(target)];
|
|
97
|
+
return a === b || b.startsWith(a.endsWith(sep) ? a : `${a}${sep}`);
|
|
98
|
+
}
|
package/dist/src/platform.js
CHANGED
|
@@ -95,7 +95,7 @@ function resolveConfigPathValue(configPath, homeDir = os.homedir()) {
|
|
|
95
95
|
if (configPath === '~') {
|
|
96
96
|
return homeDir;
|
|
97
97
|
}
|
|
98
|
-
if (configPath.startsWith('~/')) {
|
|
98
|
+
if (configPath.startsWith('~/') || configPath.startsWith('~\\')) {
|
|
99
99
|
return path.join(homeDir, configPath.slice(2));
|
|
100
100
|
}
|
|
101
101
|
return path.resolve(configPath);
|
|
@@ -33,3 +33,7 @@ export const CLI_SOURCE_HEADERS = {
|
|
|
33
33
|
[CLI_SOURCE_HEADER_NAME]: CLI_SOURCE_HEADER_VALUE,
|
|
34
34
|
...laneHeaders(),
|
|
35
35
|
};
|
|
36
|
+
/** An explicit PPE flag takes precedence over the environment lane. */
|
|
37
|
+
export function cliSourceHeaders(ppe) {
|
|
38
|
+
return ppe ? { [CLI_SOURCE_HEADER_NAME]: CLI_SOURCE_HEADER_VALUE, 'x-tt-env': ppe, 'x-use-ppe': '1' } : CLI_SOURCE_HEADERS;
|
|
39
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many times the login check (tenant/list) was retried after a 5xx in this run, for the
|
|
3
|
+
* command's telemetry event. Only `login` retries: right after the server binds the shared
|
|
4
|
+
* invitation code for a new creator, the platform may still answer from a stale cache.
|
|
5
|
+
*/
|
|
6
|
+
let retries = 0;
|
|
7
|
+
/** Never throws. */
|
|
8
|
+
export function noteSessionCheckRetry() {
|
|
9
|
+
retries += 1;
|
|
10
|
+
}
|
|
11
|
+
export function notedSessionCheckRetries() {
|
|
12
|
+
return retries;
|
|
13
|
+
}
|
|
14
|
+
/** For tests: one process there runs many commands. */
|
|
15
|
+
export function resetSessionCheckRetries() {
|
|
16
|
+
retries = 0;
|
|
17
|
+
}
|
package/dist/src/telemetry.js
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { DETACHED_WORKER_OPTIONS } from './platform-process.js';
|
|
7
8
|
import { readBinding, findProjectRoot } from './card/binding.js';
|
|
8
9
|
import { CARD_PROJECT_PAGE_URL } from './card/constants.js';
|
|
9
10
|
import { getString } from './cli-helpers.js';
|
|
@@ -12,6 +13,7 @@ import { getConfigBaseUrl, resolveConfigPath, tryLoadConfig } from './config.js'
|
|
|
12
13
|
import { isCreatorPlatform, isExternalPlatform } from './platform.js';
|
|
13
14
|
import { laneHeaders } from './request-source.js';
|
|
14
15
|
import { notedTelemetryProject } from './telemetry-project.js';
|
|
16
|
+
import { notedSessionCheckRetries } from './telemetry-session.js';
|
|
15
17
|
import { CliError, DEFAULT_CONFIG_DIR } from './types.js';
|
|
16
18
|
import { getCliVersion } from './version.js';
|
|
17
19
|
/**
|
|
@@ -93,7 +95,8 @@ const ERROR_MESSAGE_REDACTIONS = [
|
|
|
93
95
|
'$1<redacted>',
|
|
94
96
|
],
|
|
95
97
|
[/[A-Za-z0-9+/_-]{40,}={0,2}/g, '<redacted>'],
|
|
96
|
-
|
|
98
|
+
// Not `@scope/name@1.2.3`: a package spec looks like an address but says which install failed.
|
|
99
|
+
[/(?<!@[\w.-]+\/[\w.+-]*)[\w.+-]+@[\w-]+(?:\.[\w-]+)+/g, '<email>'],
|
|
97
100
|
// A query string can carry anything; the path is enough to tell which request failed.
|
|
98
101
|
[/(https?:\/\/[^\s?#"']+)[?#][^\s"']*/g, '$1'],
|
|
99
102
|
];
|
|
@@ -293,6 +296,7 @@ export function buildTelemetryJob(telemetry, identity, options = {}) {
|
|
|
293
296
|
login: identity.userId ? '1' : '0',
|
|
294
297
|
auth_type: identity.authType || 'none',
|
|
295
298
|
login_method: telemetry.loginMethod || '',
|
|
299
|
+
session_check_retries: Math.max(0, Math.round(telemetry.sessionCheckRetries || 0)),
|
|
296
300
|
user_id: identity.userId || '',
|
|
297
301
|
cli_device_id: identity.deviceId,
|
|
298
302
|
client: 'interest_card_cli',
|
|
@@ -337,6 +341,7 @@ export async function reportCommand(parsed, outcome) {
|
|
|
337
341
|
projectId: project.projectId,
|
|
338
342
|
attemptId: outcome.attemptId,
|
|
339
343
|
loginMethod: telemetryLoginMethod(parsed),
|
|
344
|
+
sessionCheckRetries: notedSessionCheckRetries(),
|
|
340
345
|
}, identity);
|
|
341
346
|
spawnSender(job);
|
|
342
347
|
}
|
|
@@ -519,7 +524,7 @@ function spawnSender(job) {
|
|
|
519
524
|
const file = path.join(dir, 'job.json');
|
|
520
525
|
fs.writeFileSync(file, JSON.stringify(job), { mode: 0o600 });
|
|
521
526
|
const child = spawn(process.execPath, [sender, file], {
|
|
522
|
-
|
|
527
|
+
...DETACHED_WORKER_OPTIONS,
|
|
523
528
|
stdio: 'ignore',
|
|
524
529
|
});
|
|
525
530
|
child.on('error', () => fs.rmSync(dir, { recursive: true, force: true }));
|
package/dist/src/update-check.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'node:fs/promises';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { resolveConfigPath } from './config.js';
|
|
6
|
+
import { commandInvocation, DETACHED_WORKER_OPTIONS, renameReplacing } from './platform-process.js';
|
|
6
7
|
import { compareVersions, isPublishedVersion, releaseChannel, STABLE_CHANNEL } from './semver.js';
|
|
7
8
|
import { DEFAULT_CONFIG_DIR } from './types.js';
|
|
8
9
|
import { getCliVersion } from './version.js';
|
|
@@ -95,7 +96,7 @@ export async function rememberDistTags(distTags, homeDir = os.homedir(), checked
|
|
|
95
96
|
try {
|
|
96
97
|
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
97
98
|
await fs.writeFile(tempPath, `${JSON.stringify(body, null, 2)}\n`);
|
|
98
|
-
await
|
|
99
|
+
await renameReplacing(tempPath, filePath);
|
|
99
100
|
}
|
|
100
101
|
catch {
|
|
101
102
|
await fs.rm(tempPath, { force: true }).catch(() => undefined);
|
|
@@ -134,7 +135,7 @@ export function scheduleUpdateCacheRefresh() {
|
|
|
134
135
|
}
|
|
135
136
|
const execArgv = process.execArgv.filter(arg => !arg.includes('inspect'));
|
|
136
137
|
const child = spawn(process.execPath, [...execArgv, entry, REFRESH_ARG], {
|
|
137
|
-
|
|
138
|
+
...DETACHED_WORKER_OPTIONS,
|
|
138
139
|
stdio: 'ignore',
|
|
139
140
|
});
|
|
140
141
|
child.on('error', () => undefined);
|
|
@@ -231,7 +232,8 @@ function safeCliVersion() {
|
|
|
231
232
|
}
|
|
232
233
|
function runCapture(command, args, timeoutMs) {
|
|
233
234
|
return new Promise((resolve, reject) => {
|
|
234
|
-
const
|
|
235
|
+
const run = commandInvocation(command, args);
|
|
236
|
+
const child = spawn(run.command, run.args, { ...run.options, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
235
237
|
let stdout = '';
|
|
236
238
|
let stderr = '';
|
|
237
239
|
const timer = setTimeout(() => {
|
package/dist/src/upgrade.js
CHANGED
|
@@ -5,6 +5,7 @@ import { printText } from './output.js';
|
|
|
5
5
|
import { findProjectRoot } from './card/binding.js';
|
|
6
6
|
import { installGlobalSkills, readGlobalStamp } from './card/global-skills.js';
|
|
7
7
|
import { upgradeCardSkills } from './card/skills.js';
|
|
8
|
+
import { commandInvocation, isSameOrInside, spawnFailureCause } from './platform-process.js';
|
|
8
9
|
import { CliError } from './types.js';
|
|
9
10
|
import { CLI_PACKAGE_NAME, CLI_INTERNAL_REGISTRY, CLI_REGISTRY, CLI_SCOPE_REGISTRY_ARG, installCommand, queryRegistryDistTags, rememberDistTags, scopeRegistryArg, upgradeTarget, } from './update-check.js';
|
|
10
11
|
import { getCliPackageDir, getCliVersion } from './version.js';
|
|
@@ -130,9 +131,7 @@ export async function isGlobalInstall() {
|
|
|
130
131
|
if (!root) {
|
|
131
132
|
return false;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
const globalRoot = path.resolve(root);
|
|
135
|
-
return packageDir === globalRoot || packageDir.startsWith(`${globalRoot}${path.sep}`);
|
|
134
|
+
return isSameOrInside(path.resolve(root), path.resolve(getCliPackageDir()));
|
|
136
135
|
}
|
|
137
136
|
/** The registry that answered the last dist-tag query; the upgrade installs from it. */
|
|
138
137
|
let answeredRegistry;
|
|
@@ -165,7 +164,7 @@ export async function installGlobalPackage(version, json) {
|
|
|
165
164
|
], json);
|
|
166
165
|
}
|
|
167
166
|
catch (error) {
|
|
168
|
-
const cause =
|
|
167
|
+
const cause = failureCause(error);
|
|
169
168
|
throw new CliError(`Could not install ${CLI_PACKAGE_NAME}@${version}.`, 'CARD_UPGRADE_FAILED', {
|
|
170
169
|
cause,
|
|
171
170
|
installCommand: installCommand(version, registry),
|
|
@@ -183,9 +182,16 @@ async function refreshProjectSkills(parsed, useInstalledCli = false, json = fals
|
|
|
183
182
|
}
|
|
184
183
|
return upgradeCardSkills(root);
|
|
185
184
|
}
|
|
185
|
+
/** The message of a failed child process, with the reason it could not start when there is one. */
|
|
186
|
+
function failureCause(error) {
|
|
187
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
188
|
+
const cause = error instanceof CliError ? error.details?.cause : undefined;
|
|
189
|
+
return typeof cause === 'string' && cause ? `${message} ${cause}` : message;
|
|
190
|
+
}
|
|
186
191
|
function runCapture(command, args) {
|
|
187
192
|
return new Promise((resolve, reject) => {
|
|
188
|
-
const
|
|
193
|
+
const run = commandInvocation(command, args);
|
|
194
|
+
const child = spawn(run.command, run.args, { ...run.options, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
189
195
|
let stdout = '';
|
|
190
196
|
let stderr = '';
|
|
191
197
|
child.stdout.on('data', chunk => {
|
|
@@ -198,16 +204,22 @@ function runCapture(command, args) {
|
|
|
198
204
|
child.on('close', code => resolve({ code: code ?? 1, stdout, stderr }));
|
|
199
205
|
}).catch((error) => {
|
|
200
206
|
throw new CliError(`Failed to run ${command}.`, 'CARD_UPGRADE_FAILED', {
|
|
201
|
-
cause:
|
|
207
|
+
cause: spawnFailureCause(command, error),
|
|
202
208
|
});
|
|
203
209
|
});
|
|
204
210
|
}
|
|
205
211
|
/** With --json, child output goes to stderr so stdout stays one JSON document. */
|
|
206
212
|
function runInherit(command, args, json = false) {
|
|
207
213
|
return new Promise((resolve, reject) => {
|
|
208
|
-
const
|
|
214
|
+
const run = commandInvocation(command, args);
|
|
215
|
+
const child = spawn(run.command, run.args, {
|
|
216
|
+
...run.options,
|
|
217
|
+
stdio: json ? ['ignore', 2, 2] : 'inherit',
|
|
218
|
+
});
|
|
209
219
|
child.on('error', error => {
|
|
210
|
-
reject(new CliError(`Failed to run ${command}.`, 'CARD_UPGRADE_FAILED', {
|
|
220
|
+
reject(new CliError(`Failed to run ${command}.`, 'CARD_UPGRADE_FAILED', {
|
|
221
|
+
cause: spawnFailureCause(command, error),
|
|
222
|
+
}));
|
|
211
223
|
});
|
|
212
224
|
child.on('close', code => {
|
|
213
225
|
if (code === 0) {
|
package/package.json
CHANGED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# svg
|
|
2
|
-
|
|
3
|
-
兴趣卡 SVG 承载组件,使用 src 加载 SVG 资源或使用 content 传入内联 SVG。
|
|
4
|
-
|
|
5
|
-
## 能力信息
|
|
6
|
-
|
|
7
|
-
- Taro 组件:`Svg`
|
|
8
|
-
- 能力分类:`basic-content`
|
|
9
|
-
- 最低基础库:`未确认`
|
|
10
|
-
- 版本核验:
|
|
11
|
-
- OpenCard 组件白名单:确认 OpenCard Taro 提供 Svg 组件和 src、content 用法,但未记录最低基础库版本。
|
|
12
|
-
- queryFeAbilityList TechType=5:未找到 svg 组件元数据。
|
|
13
|
-
- 抖音开放平台官网检索:未找到 OpenCard Svg 组件的最低基础库说明。
|
|
14
|
-
- 能力来源:兴趣卡 OpenCard 组件能力清单
|
|
15
|
-
|
|
16
|
-
## OpenCard 使用说明
|
|
17
|
-
|
|
18
|
-
- 从 `@tarojs/components` 导入 `Svg`,在 TSX 中使用 Taro/React 属性名。
|
|
19
|
-
- 下方“OpenCard 可用属性”和“OpenCard 可用事件”是该组件在卡片场景的组件专属范围;公共的 `className`、`style`、`id`、`data-*` 属性继续按 Taro 组件类型使用。
|
|
20
|
-
- 使用 `src` 加载 SVG 资源,或使用 `content` 传入内联 SVG 字符串,并设置明确尺寸。
|
|
21
|
-
- SVG 资源仅通过 `Svg` 的 `src` 或 `content` 承载;`Image`、CSS 背景或遮罩、inline style 和普通业务图片字段用于位图资源。
|
|
22
|
-
- 当前 OpenCard `Svg` 不使用旧 `context` 属性。
|
|
23
|
-
|
|
24
|
-
## OpenCard 可用属性
|
|
25
|
-
|
|
26
|
-
| 字段 | 类型 | 必填 | 默认值 | 字段最低基础库 | 说明 |
|
|
27
|
-
| --- | --- | --- | --- | --- | --- |
|
|
28
|
-
| `src` | string | 否 | - | - | SVG 网络资源或本地静态资源地址。 |
|
|
29
|
-
| `content` | string | 否 | - | - | 内联 SVG 字符串。 |
|
|
30
|
-
|
|
31
|
-
## OpenCard 可用事件
|
|
32
|
-
|
|
33
|
-
无组件专属项。
|
|
34
|
-
|
|
35
|
-
## 错误码
|
|
36
|
-
|
|
37
|
-
无元数据。
|
|
38
|
-
|
|
39
|
-
## Taro 代码示例
|
|
40
|
-
|
|
41
|
-
来源:[兴趣卡原 Skill 的 OpenCard 组件能力说明](https://douyin-ai.bytedance.net/skills/2/7665703674215598884?_withType=true&space=%22douyin_experience%22)
|
|
42
|
-
|
|
43
|
-
```tsx
|
|
44
|
-
import { Svg } from '@tarojs/components';
|
|
45
|
-
|
|
46
|
-
const badgeSvg = `
|
|
47
|
-
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
48
|
-
<circle cx="12" cy="12" r="10" fill="#FE2C55" />
|
|
49
|
-
</svg>`;
|
|
50
|
-
|
|
51
|
-
export default function Badge() {
|
|
52
|
-
return <Svg className='badge' content={badgeSvg} />;
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## 使用与验证
|
|
57
|
-
|
|
58
|
-
按官网文档确认子节点、布局要求和 Taro 属性名后写入 TSX。在真机触发事件:使用 `console.log` 输出 `event.detail`,错误事件使用 `console.error` 输出完整事件对象,并根据页面表现和控制台输出确认功能及样式。
|