命令列工具,用於存取 treebuy.com 的 API。
推薦:使用 npm 全域安裝(固定版本)
npm install -g @nandemo-agent/treebuy-cli@0.1.0
或使用 npx(無需全域安裝)
npx @nandemo-agent/treebuy-cli@0.1.0 <command>
開發用途(本地 clone)
git clone https://github.com/nandemo-agent/treebuy-cli.git
cd treebuy-cli
npm install
npm link # 建立 global symlink
💡 為什麼固定版本?
- 確保行為穩定,避免 breaking changes
- 方便 audit 與 security review
- 明確知道使用哪個版本的功能與 schema
如需最新版本,請查看 npm package 頁面
# 列出所有 Featured Campaign
treebuy-cli featured list
# 只看 featured 類型
treebuy-cli featured list --kind featured
# 只看 topic 類型
treebuy-cli featured list --kind topic
# 輸出 JSON array
treebuy-cli featured list --json
# 輸出 NDJSON(每行一筆,agent / pipe 友好)
treebuy-cli featured list --ndjson
# 只取特定欄位(僅 products.*,減少 context 負擔)
treebuy-cli featured list --fields sku,title
# 自訂 API timeout(毫秒)
treebuy-cli featured list --timeout 8000
# 組合使用
treebuy-cli featured list --kind topic --ndjson --fields sku,title
- 預設 stdout 非 TTY 時自動輸出 NDJSON(可用
--json強制 JSON array) - 使用
--fields減少回應大小,避免 context window 浪費(僅作用於products) - 錯誤訊息輸出至 stderr,不影響 stdout 解析
- 支援
--timeout控制 API 超時 - API 端點:
https://v2api.treebuy.com
treebuy-cli
└── featured
└── list [--kind featured|topic] [--json] [--fields <欄位>]
# 搜尋商品
treebuy-cli search products "Dyson"
# 分頁
treebuy-cli search products "Dyson" --page 2 --limit 10
# 排序(rank / price_asc / price_desc / new)
treebuy-cli search products "Dyson" --sort-by price_asc
# JSON 輸出(含 pagination)
treebuy-cli search products "Dyson" --json
# NDJSON(每筆一行,agent/pipe 友好)
treebuy-cli search products "Dyson" --ndjson
# 指定欄位
treebuy-cli search products "Dyson" --fields id,name,selling_price,in_stock
# 組合
treebuy-cli search products "Dyson" --limit 5 --sort-by price_asc --fields id,name,selling_price --ndjson
透過 npx skills 分項安裝:
# Featured Campaign 技能
npx skills add https://github.com/nandemo-agent/treebuy-cli --skill treebuy-featured
# 搜尋商品技能
npx skills add https://github.com/nandemo-agent/treebuy-cli --skill treebuy-search
Skills 位於 skills/ 目錄(canonical),不要建立平行的 skill/ 結構。