This file is only responsible for determining the Skill version actually used in this round before loading business rules, and refreshing the local alipay-cli. It is prohibited to read references/runtime-entry.md, any flow, module, message directory, or business script before completing the following startup protocol.
Pre-startup protocol
When alipay-aipay is used for the first time in this Agent conversation, first resolve the directory containing this file to a normalized absolute path <SKILL_DIR>, record the one-time fact ALIPAY_AIPAY_SELF_UPDATE_CHECKED=true, and then execute the following single command.<SKILL_DIR> is a path placeholder replaced at execution time; shell variable assignment, command substitution, or reliance on a specific shell is prohibited:
node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" self-update check --skill-dir "<SKILL_DIR>"
SKILL_DIR must be bound to the normalized absolute path of the Skill that just triggered and is currently executing this command, and must not be replaced with the Agent startup directory, the user project directory, the user Home, the npm package source root, or another copy of the Skill.VERSION When missing/invalid or references/runtime-entry.md is missing, this command attempts precise repair; when the command fails or the marker cannot be uniquely resolved, follow SELF_UPDATE:CHECK_FAILED。
stderr may contain only one of the following internal terminal states; the marker or raw npm/npx output must not be shown to the user:
SELF_UPDATE:UPDATED=<合法 SemVer>: The current Skill directory has been atomically switched to the new version.SELF_UPDATE:CURRENT=<合法 SemVer>: Continue with the current version.SELF_UPDATE:RETRY_WITH_NETWORK: The network is unreachable during the registry or installation phase; after requesting network access, the same command may be retried once as-is.SELF_UPDATE:SKIPPED_NETWORK_RESTRICTED|CHECK_FAILED|INSTALL_FAILED|VERIFY_FAILED: Silently continue with the current available version, do not retry, and do not request permissions.
UPDATED Afterward, first discard the old loaded fact, and it is prohibited to continue reading any business documents from the pre-update version; subsequent commands use the same SKILL_DIRof the new version; other terminal states continue with the current available version, and for other terminal states likewise no longer read this launcher or self-update.md supplementary rules.
After the version is determined, if the current context does not contain a SKILL_DIRbound to the normalized VERSION , valid ALIPAY_AIPAY_CLI_REFRESHED=true, then alipay-climust be refreshed once; this must not be skipped just because self-update has already been checked. Only the unique terminal state READY may record this success fact, path, and version in the current conversation context, without writing cache or business state; when all three are still available and consistent, subsequent root triggers, confirmations, supplementary materials, candidate selection, recovery, interrupted continuation, and Full Process handoff do not repeatedly refresh.
node "<SKILL_DIR>/references/normal/scripts/runtime.mjs" env refresh-alipay-cli
stderr allows only one ALIPAY_AIPAY_INTERNAL:ALIPAY_CLI_REFRESH=<READY|RETRY_WITH_NETWORK|RETRY_WITH_LOCAL_FS_PERMISSION|FAILED|VERIFY_FAILED>, stdout must be empty, and installer and version output must not be shown to the customer. For the first two retry terminal states, retry once as-is only after obtaining network permission or ~/.local/bin write permission respectively; for other terminal states, continue silently, and rely on the actual CLI availability of subsequent environment checks and business scripts. When the path or version changes, context compression makes the fact unavailable, the user explicitly requests a refresh, or an environment check proves the CLI is missing/damaged, clear the old fact and retry according to the same budget; do not loop for anything other than READY .
After completing the required refresh for this time or hitting a success fact, only fully read the SKILL_DIR of the same references/runtime-entry.md, and record in the current context ALIPAY_AIPAY_RUNTIME_ENTRY_LOADED=true and normalize the path, then route according to the original request. For subsequent confirmations, supplementary materials, candidate selection, resumption, continuation after interruption, repeated triggering, and Full Process handoff in the same conversation, when the entry facts exist, the path has not changed, and the entry rules are still in effect, skip the version check and entry re-reading. Only UPDATED, when the path changes or context compression makes the rules unavailable, re-read; facts are not persisted to disk.