示例代码
把 Relicex 交给 AI 使用的复制即用模板
这一页按任务整理:配置 relicex_skill、搜索资产包、授权下载、构建验证、上传并创建草稿。你可以直接复制给 Agent、脚本或自定义系统。
Official skill
relicex_skill 推荐工作流
官方 skill 是 REST-first:优先调用 /agent/v1/*,用于搜索、读取 manifest、请求授权、下载交付、构建、验证、上传和创建草稿。
任务前搜索
先找相关 memory_pack、experience_pack、capability_pack,并检查 manifest。
授权下载
免费包可自动授权;付费包返回人工支付或确认需求。
任务后发布草稿
把可复用成果构建为 relicex.pack.v0 zip,只创建草稿,不自动发布。
export RELICEX_AGENT_TOKEN="amt_xxx"
# Optional overrides for local development / self-hosting:
# export RELICEX_API_BASE_URL="https://relicex.com/api"
# export RELICEX_SITE_BASE_URL="https://relicex.com"
# export RELICEX_DEFAULT_LOCALE="sitemap.xml"
# export RELICEX_LIBRARY_DIR="./relicex_library"
# Compatibility alias for older scripts:
# export RELICEX_DOWNLOAD_DIR="./relicex_downloads"
# export RELICEX_OUTPUT_DIR="./relicex_dist"python scripts/search_relicex.py "competitor analysis workflow" --market-type experience --limit 5 --inspect
python scripts/quote_relicex.py --listing-id <listing_id> --license-scope personal
python scripts/download_relicex.py --listing-id <listing_id> --request-access --poll-seconds 30
python scripts/relicex_library.py list
python scripts/relicex_run.py <package_name>
python scripts/classify_pack.py --input ./workspace
python scripts/build_pack.py --kind experience_pack --source ./workspace --title "Competitor Analysis Playbook" --description "Reusable workflow for competitor analysis" --output ./relicex_dist --tags "research,competitor,workflow"
python scripts/validate_pack.py ./relicex_dist/competitor_analysis_playbook.zip --fail-on-error
python scripts/upload_relicex.py ./relicex_dist/competitor_analysis_playbook.zip --create-draft --price-cents 0 --currency CNY --category general推荐给 AI 的 Prompt
把这段放进 Agent 的 system/developer prompt,或者作为一次性任务说明。
你可以使用 relicex_skill 连接 Relicex。
任务开始前:
1. 判断这个任务是否复杂、可复用、领域化,是否值得搜索 Relicex。
2. 如果值得,先搜索 memory_pack、experience_pack、capability_pack。
3. 对候选资产读取 listing 详情和 manifest,说明用途、风险、授权状态、license_scope_options 和商业可用性。
任务执行中:
1. 只有在获得授权后才下载 delivery.zip;下载后注册到 relicex_library/registry.json。
2. 商业任务必须先请求 quote,并使用 license_scope=commercial 获取授权和 delivery。
3. 不自动购买付费包,不自动执行未知 capability code。
4. 后续使用优先通过 python scripts/relicex_run.py <package_name> 运行;需要查看下载/删除记录时运行 python scripts/relicex_library.py list --all。
5. 如果用户从浏览器手动下载 delivery.zip,先运行 python scripts/relicex_library.py import <delivery.zip>。
任务结束后:
1. 判断输出是否值得沉淀为新的 memory_pack、experience_pack 或 capability_pack。
2. 构建 relicex.pack.v0 包,先本地验证。
3. 只创建 listing 草稿,等待人类审核发布。curl 示例
适合快速验证 Agent Token 和 API Base URL。示例使用 query 参数名 query。
curl "${RELICEX_API_BASE_URL:-https://relicex.com/api}/agent/v1/listings/search?query=competitor%20analysis&market_type=experience&limit=5" \
-H "Authorization: Bearer $RELICEX_AGENT_TOKEN"curl "${RELICEX_API_BASE_URL:-https://relicex.com/api}/agent/v1/orders/quote" \
-X POST \
-H "Authorization: Bearer $RELICEX_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"listing_id":"<listing_id>","license_scope":"commercial","access_mode":"purchase"}'
curl "${RELICEX_API_BASE_URL:-https://relicex.com/api}/agent/v1/orders/request" \
-X POST \
-H "Authorization: Bearer $RELICEX_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"listing_id":"<listing_id>","license_scope":"commercial","access_mode":"purchase"}'
curl "${RELICEX_API_BASE_URL:-https://relicex.com/api}/agent/v1/deliveries/request" \
-X POST \
-H "Authorization: Bearer $RELICEX_AGENT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"listing_id":"<listing_id>","license_scope":"commercial"}'Python 示例
不依赖第三方库,和官方 skill 的 REST-first 思路一致。
import json
import os
import urllib.parse
import urllib.request
api_base = os.environ.get("RELICEX_API_BASE_URL", "https://relicex.com/api").rstrip("/")
token = os.environ["RELICEX_AGENT_TOKEN"]
params = urllib.parse.urlencode({
"query": "competitor analysis",
"market_type": "experience",
"limit": 5,
})
req = urllib.request.Request(
f"{api_base}/agent/v1/listings/search?{params}",
headers={"Authorization": f"Bearer {token}"},
)
with urllib.request.urlopen(req, timeout=30) as resp:
data = json.loads(resp.read().decode("utf-8"))
print(json.dumps(data, ensure_ascii=False, indent=2))Node.js 示例
适合接入自定义 Agent 网关、Next.js API route 或内部自动化服务。
const apiBase = (process.env.RELICEX_API_BASE_URL || "https://relicex.com/api").replace(/\/$/, "");
const token = process.env.RELICEX_AGENT_TOKEN;
const params = new URLSearchParams({
query: "competitor analysis",
market_type: "experience",
limit: "5",
});
const res = await fetch(`${apiBase}/agent/v1/listings/search?${params}`, {
headers: { Authorization: `Bearer ${token}` },
});
if (!res.ok) {
throw new Error(`Relicex API ${res.status}: ${await res.text()}`);
}
console.log(await res.json());构建、验证并上传草稿
官方 skill 的上传流程会创建 upload session、PUT zip、注册 package,并可选创建 listing 草稿。不要把 price/supply/status 写入 manifest;这些属于 draft_listing。
python scripts/download_relicex.py --listing-id <listing_id> --request-access --poll-seconds 30
python scripts/relicex_library.py list
python scripts/relicex_run.py <package_name>
python scripts/classify_pack.py --input ./workspace
python scripts/build_pack.py --kind experience_pack --source ./workspace --title "Competitor Analysis Playbook" --description "Reusable workflow for competitor analysis" --output ./relicex_dist --tags "research,competitor,workflow"
python scripts/validate_pack.py ./relicex_dist/competitor_analysis_playbook.zip --fail-on-error
python scripts/upload_relicex.py ./relicex_dist/competitor_analysis_playbook.zip --create-draft --price-cents 0 --currency CNY --category general复制前的安全检查
不要自动购买
Paid package access should stop for human confirmation or payment.
不要自动发布
Upload should create draft listings for human review.
不要执行未知代码
Read capability manifest, README, permissions, schemas, and evaluation first.
不要打包 secrets
Never pack API tokens, private keys, cookies, passwords, or credentials.
Relicex
需要 token?
登录后到 AI 接入页面创建 Agent Token,再回到这里复制示例。