feat(upload_local): load credentials from project .env; fix usage path

- Load SKILLS_MP_TEST_USER from gitignored .env (env var still overrides);
  add .env.example template with placeholder values.
- Fix usage(): resolve script path before the cd to repo root so the
  awk-based help no longer fails when run with no args.
- Bump okx-cex-market skill to v1.3.6 (okx-trade-cli@1.3.6).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
shaolong.wang
2026-06-02 15:54:07 +08:00
parent 3d3aa4ae70
commit d73f3c9684
3 changed files with 23 additions and 7 deletions
+6
View File
@@ -0,0 +1,6 @@
# Copy this file to .env and fill in real values. .env is gitignored — never commit it.
#
# Non-2FA test account used by scripts/upload_local.sh to log in to the Skills
# Marketplace. Must be a single-line JSON string (single-quoted to protect the
# inner double quotes).
SKILLS_MP_TEST_USER='{"loginName":"you@okg.com","password":"REPLACE_ME","passwordHash":"REPLACE_ME"}'
+15 -5
View File
@@ -3,8 +3,10 @@
# Self-contained: the only other file it needs is skills_sync.sh (the signed
# login + priapi upload). Run this one script to achieve the goal.
#
# 1) Export the non-2FA test account JSON (never commit this value):
# export SKILLS_MP_TEST_USER='{"loginName":"you@okg.com","password":"...","passwordHash":"..."}'
# 1) Provide the non-2FA test account JSON via the project .env (never commit it).
# Copy .env.example to .env and fill in the value:
# SKILLS_MP_TEST_USER='{"loginName":"you@okg.com","password":"...","passwordHash":"..."}'
# (.env is gitignored. A pre-exported env var still overrides the .env file.)
#
# 2) Run one of:
# scripts/upload_local.sh okx-cex-trade # one or more skills by name
@@ -22,6 +24,7 @@
set -euo pipefail
HERE="$(cd "$(dirname "$0")" && pwd)"
SELF="$HERE/$(basename "$0")" # absolute path to this script (survives the cd below)
cd "$(git rev-parse --show-toplevel)"
SKILLS_DIR="${SKILLS_DIR:-skills}"
@@ -29,6 +32,13 @@ OUT_DIR="${OUT_DIR:-dist}"
SYNC_SCRIPT="${SYNC_SCRIPT:-$HERE/skills_sync.sh}"
DRY_RUN="${DRY_RUN:-0}"
# ---- load credentials from project .env (gitignored; never committed) -------
# A pre-set environment variable always wins over the .env file.
ENV_FILE="${ENV_FILE:-.env}"
if [ -z "${SKILLS_MP_TEST_USER:-}" ] && [ -f "$ENV_FILE" ]; then
set -a; . "$ENV_FILE"; set +a
fi
# ---- logging (to stderr, so stdout stays clean for captured values) ---------
_ts() { date -u '+%Y-%m-%dT%H:%M:%SZ'; }
log() { printf '%s [INFO] %s\n' "$(_ts)" "$*" >&2; }
@@ -51,7 +61,7 @@ category_for() {
esac
}
usage() { awk 'NR>=2 && /^#/{sub(/^# ?/,""); print; next} NR>=2{exit}' "$0"; exit "${1:-0}"; }
usage() { awk 'NR>=2 && /^#/{sub(/^# ?/,""); print; next} NR>=2{exit}' "$SELF"; exit "${1:-0}"; }
# ---- change detection (only used by --changed) ------------------------------
version_at_ref() { # $1=ref ("" = working tree) $2=path
@@ -124,8 +134,8 @@ log "targets: ${TARGETS[*]}"
# ---- credentials (real upload only) -----------------------------------------
if [ "$DRY_RUN" != "1" ]; then
if [ -z "${SKILLS_MP_TEST_USER:-}" ]; then
log_error "SKILLS_MP_TEST_USER is not set. Export it first, e.g.:"
log_error " export SKILLS_MP_TEST_USER='{\"loginName\":\"you@okg.com\",\"password\":\"...\",\"passwordHash\":\"...\"}'"
log_error "SKILLS_MP_TEST_USER is not set. Add it to $ENV_FILE (copy .env.example), e.g.:"
log_error " SKILLS_MP_TEST_USER='{\"loginName\":\"you@okg.com\",\"password\":\"...\",\"passwordHash\":\"...\"}'"
exit 1
fi
export USER="$SKILLS_MP_TEST_USER"
+2 -2
View File
@@ -4,7 +4,7 @@ description: "Use this skill when the user asks for: price of any asset, ticker,
license: MIT
metadata:
author: okx
version: "1.3.5"
version: "1.3.6"
homepage: "https://www.okx.com"
agent:
requires:
@@ -12,7 +12,7 @@ metadata:
install:
- id: npm
kind: node
package: "@okx_ai/okx-trade-cli@1.3.3"
package: "@okx_ai/okx-trade-cli@1.3.6"
bins: ["okx"]
label: "Install okx CLI (npm)"
---