@round2ai/r2-cli 1.0.12 → 1.0.13
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/dist/r2-cli.js
CHANGED
|
@@ -34,7 +34,7 @@ var me=Object.defineProperty;var at=(o,t)=>()=>(o&&(t=o(o=0)),t);var ct=(o,t)=>{
|
|
|
34
34
|
`));else if(o instanceof A)console.error(j.red(`\u25B2 \u64CD\u4F5C\u5931\u8D25: ${o.message}`)),o.status&&console.error(j.gray(` \u72B6\u6001\u7801: ${o.status}`));else if(o instanceof $)console.error(j.red(`\u25B2 \u914D\u7F6E\u6587\u4EF6\u5F02\u5E38: ${o.message}`)),o.path&&console.error(j.gray(` \u8DEF\u5F84: ${o.path}`)),console.error(j.gray(`\u2192 \u8BF7\u5C1D\u8BD5\u91CD\u65B0\u767B\u5F55: r2-cli auth login
|
|
35
35
|
`));else{let t=o instanceof Error?o.message:String(o);console.error(j.red(`\u25B2 ${t}`))}process.exit(1)}function qt(o){console.log(JSON.stringify({success:!1,error:o})),process.exit(1)}function g(o){return async t=>{try{await o(t)}catch(e){if(t.json){let r=e instanceof Error?e.message:String(e),n=e instanceof A?e.status:void 0;console.log(JSON.stringify({success:!1,error:r,...n!=null&&{status:n}})),process.exit(1)}v(e)}}}function yt(o){return async(...t)=>{try{await o(...t)}catch(e){let r=e instanceof Error?e.message:String(e);qt(r)}}}var je=new Set(["accessToken","refreshExpireIn"]);function To(o){return o.map(t=>{let e={};for(let[r,n]of Object.entries(t))je.has(r)||(e[r]=n);return e})}async function wt(o){let{qrInfo:t,qrUrl:e,setStatus:r,closeServer:n,waitArgs:s}=await o.generate();console.log(JSON.stringify(t,null,2)),B(e);try{let i=await o.waitResult(s,r);console.log(JSON.stringify(o.formatSuccess(i)))}catch(i){let a=i instanceof Error?i.message:String(i);console.log(JSON.stringify({success:!1,error:a})),process.exit(1)}finally{setTimeout(n,1e3)}}function Xt(){let o=new bo("login");o.description("\u626B\u7801\u767B\u5F55 Round2AI \u8D26\u6237").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09");let t=new bo("poll").description("\u8F6E\u8BE2\u767B\u5F55\u72B6\u6001\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").requiredOption("--token <qrToken>","\u4E8C\u7EF4\u7801 token").option("--expire <ms>","\u8FC7\u671F\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09","300000").option("--interval <ms>","\u8F6E\u8BE2\u95F4\u9694\uFF08\u6BEB\u79D2\uFF09","1000").action(yt(async e=>{let n=await R().waitForLogin(e.token,Number.parseInt(e.expire,10),Number.parseInt(e.interval,10));console.log(JSON.stringify({success:!0,...n}))}));return o.addCommand(t),o.action(async e=>{try{e.json?await wt({generate:async()=>{let r=R(),{qrData:n,qrUrl:s,setStatus:i,closeServer:a}=await r.generateQR(),l=Number.parseInt(n.expireTime,10),w=Number.parseInt(n.pollInterval,10);return{qrInfo:{qrToken:n.qrToken,expireTimeMs:l,pollIntervalMs:w,url:`https://m.puresnake.com/r2/auth/login?qrToken=${n.qrContent}&from=wechat`,qrUrl:s},qrUrl:s,setStatus:i,closeServer:a,waitArgs:{qrToken:n.qrToken,expireMs:l,intervalMs:w}}},waitResult:({qrToken:r,expireMs:n,intervalMs:s},i)=>R().waitForLogin(r,n,s,void 0,i,!0),formatSuccess:r=>({success:!0,userInfo:r.userInfo})}):await R().login()}catch(r){if(e.json){let n=r instanceof Error?r.message:String(r);console.log(JSON.stringify({success:!1,error:n})),process.exit(1)}v(r)}}),o}import{Command as Ee}from"commander";function _t(){let o=new Ee("logout");return o.description("\u9000\u51FA\u767B\u5F55"),o.action(async()=>{try{await R().logout()}catch(t){v(t)}}),o}import{Command as $e}from"commander";function Qt(){let o=new $e("status");return o.description("\u67E5\u770B\u767B\u5F55\u72B6\u6001"),o.action(async()=>{try{await R().status()}catch(t){v(t)}}),o}import{Command as Po}from"commander";function Mt(){let o=new Po("xianyu");o.description("\u95F2\u9C7C\u5E97\u94FA\u6388\u6743").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09");let t=new Po("poll").description("\u8F6E\u8BE2\u95F2\u9C7C\u6388\u6743\u72B6\u6001\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").requiredOption("--state <state>","\u6388\u6743\u8F6E\u8BE2 token").option("--expire <ms>","\u8FC7\u671F\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09","300000").option("--interval <ms>","\u8F6E\u8BE2\u95F4\u9694\uFF08\u6BEB\u79D2\uFF09","1000").action(yt(async e=>{let r=await nt(e.state,Number.parseInt(e.expire,10),Number.parseInt(e.interval,10));r.status==="success"?console.log(JSON.stringify({success:!0,shopId:r.shopId,shopName:r.shopName})):qt(`\u6388\u6743\u72B6\u6001: ${r.status}`)}));return o.addCommand(t),o.action(async e=>{try{e.json?await wt({generate:async()=>{let{authData:r,qrUrl:n,setStatus:s,closeServer:i}=await ht(),a=r.expireTime?Number.parseInt(r.expireTime,10):3e5,l=r.pollInterval?Number.parseInt(r.pollInterval,10):1e3;return{qrInfo:{state:r.state,expireTimeMs:a,pollIntervalMs:l,qrUrl:n},qrUrl:n,setStatus:s,closeServer:i,waitArgs:{state:r.state,expireMs:a,intervalMs:l}}},waitResult:async({state:r,expireMs:n,intervalMs:s},i)=>{let a=await nt(r,n,s,void 0,i);if(a.status!=="success")throw new Error(`\u6388\u6743\u72B6\u6001: ${a.status}`);return a},formatSuccess:r=>({success:!0,shopId:r.shopId,shopName:r.shopName})}):await Jt()}catch(r){if(e.json){let n=r instanceof Error?r.message:String(r);console.log(JSON.stringify({success:!1,error:n})),process.exit(1)}v(r)}}),o}import{Command as gr}from"commander";import{Command as Je}from"commander";import L from"chalk";import{select as zt,input as qe,confirm as Xe}from"@inquirer/prompts";import{readFileSync as Be}from"node:fs";import{basename as Ge}from"node:path";function X(o){let t=new URLSearchParams;for(let[e,r]of Object.entries(o))r!=null&&r!==""&&t.append(e,String(r));return t}var C=gt;async function Ft(o){return C.post("mms/goods/listing/up/xianyu",o)}async function Ao(o){return C.get("mms/goods/listing/get",X({...o}))}async function ko(o){return C.post("mms/goods/listing/down/xianyu",o)}async function vo(o){return C.post("mms/goods/listing/update/xyPrice",o)}async function No(o){return C.post("mms/goods/listing/update/goodsInfo",o)}async function Ro(o){return C.get("mms/goods/listing/list",o?X({...o}):void 0)}async function xt(){return await C.get("mms/user/shop/list")??[]}async function It(){return await C.get("mms/user/stock/list")??[]}async function St(o){let t=o?X({...o}):void 0;return C.get("mms/seller/goods/select/list",t)}async function Lo(o,t){let e=[];for(let r of t){let n=Be(r),s=Ge(r),i=new FormData;i.append("file",new Blob([n]),s);let a=await C.upload(`platform/xy/media/upload?shopId=${encodeURIComponent(o)}`,i);e.push(a)}return e}async function Oo(o){return C.post("mms/goods/listing/hang/up/xianyu",o)}async function Do(o=16){return await C.get("platform/xy/cat",X({spBizType:o}))??[]}async function Uo(o){return await C.get("platform/xy/props",X({channelCatId:o}))??[]}async function jo(o,t,e){return await C.get("platform/xy/props/value",X({channelCatId:o,propId:t,key:e}))??[]}var _e=2e3,Qe=1e4;function Me(o){let t=o.status?.toLowerCase()??"";return t===""||t==="init"||t==="pending"||t==="processing"}async function Eo(o,t,e,r){r||process.stdout.write(L.cyan("\u23F3 \u6B63\u5728\u67E5\u8BE2\u4E0A\u67B6\u8FDB\u5EA6..."));let n=await F(()=>Ao({stockGoodsId:o,shopId:t,platform:e}),{interval:_e,timeout:Qe,condition:s=>!Me(s)});return r||process.stdout.write("\r"+" ".repeat(30)+"\r"),n}function $o(){let o=new Je("up");return o.description("\u4E0A\u67B6\u5546\u54C1\u5230\u95F2\u9C7C"),o.option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1ID\uFF08\u4ECE goods list \u83B7\u53D6\uFF09").option("--shop-id <id>","\u5E97\u94FAID\uFF08\u4ECE goods shops \u83B7\u53D6\uFF09").option("--price <amount>","\u4E0A\u67B6\u4EF7\u683C").option("-p, --platform <platform>","\u5E73\u53F0","xianyu").option("--json","\u8F93\u51FA JSON\uFF08Agent \u7528\uFF09").action(g(async t=>{if(t.json&&!(t.stockGoodsId&&t.shopId&&t.price)&&(console.log(JSON.stringify({success:!1,error:"Agent \u6A21\u5F0F\u9700\u8981 --stock-goods-id, --shop-id, --price"})),process.exit(1)),t.stockGoodsId&&t.shopId&&t.price){let d=Number(t.stockGoodsId),k=t.shopId,At=Number(t.price),Q=t.platform,de=await Ft({stockGoodsId:d,shopId:k,price:At,platform:Q}),kt=await Eo(d,k,Q,t.json);if(t.json)console.log(JSON.stringify({success:!0,data:{submit:de,listing:kt}},null,2));else{let ue=kt.status?.toLowerCase()!=="failed";console.log(ue?L.green("\u2713 \u4E0A\u67B6\u6210\u529F"):L.red("\u2717 \u4E0A\u67B6\u5931\u8D25")),console.log(JSON.stringify(kt,null,2))}return}let e=await xt();if(e.length===0){console.log(L.yellow("\u6CA1\u6709\u5DF2\u6388\u6743\u5E97\u94FA\uFF0C\u8BF7\u5148\u8FD0\u884C r2-cli auth xianyu \u6388\u6743"));return}let r=await zt({message:"\u9009\u62E9\u5E97\u94FA",choices:e.map(d=>({name:`${d.shopName} (${d.platform})`,value:d.shopId}))}),n=await It();if(n.length===0){console.log(L.yellow("\u6CA1\u6709\u53EF\u7528\u7684\u4ED3\u5E93"));return}let s=await zt({message:"\u9009\u62E9\u4ED3\u5E93",choices:n.map(d=>({name:d.stockName,value:d.stockId}))}),i=await St({stockId:s,size:100});if(!i.items?.length){console.log(L.yellow("\u8BE5\u4ED3\u5E93\u6CA1\u6709\u53EF\u9009\u7684\u5546\u54C1"));return}let a=await zt({message:"\u9009\u62E9\u5546\u54C1",choices:i.items.map(d=>({name:`${d.goodsName} ${d.size?`| ${d.size}`:""} | \xA5${d.salePrice}`,value:d.stockGoodsId}))}),l=await qe({message:"\u8F93\u5165\u4E0A\u67B6\u4EF7\u683C",default:i.items.find(d=>d.stockGoodsId===a)?.salePrice?.toString()??"",validate:d=>Number(d)>0?!0:"\u4EF7\u683C\u5FC5\u987B\u4E3A\u6B63\u6570"});if(!await Xe({message:`\u786E\u8BA4\u4E0A\u67B6\uFF1F\u4EF7\u683C \xA5${l}`,default:!0})){console.log(L.gray("\u5DF2\u53D6\u6D88"));return}let m=Number(a);await Ft({stockGoodsId:m,shopId:r,price:Number(l),platform:"xianyu"}),console.log(L.green("\u2713 \u4E0A\u67B6\u5DF2\u63D0\u4EA4\uFF0C\u6B63\u5728\u67E5\u8BE2\u8FDB\u5EA6..."));let P=await Eo(m,r,"xianyu"),_=P.status?.toLowerCase()!=="failed";console.log(_?L.green("\u2713 \u4E0A\u67B6\u6210\u529F"):L.red("\u2717 \u4E0A\u67B6\u5931\u8D25")),console.log(JSON.stringify(P,null,2))})),o}import{Command as Ve}from"commander";import qo from"chalk";function Xo(){let o=new Ve("shops");return o.description("\u67E5\u770B\u6240\u6709\u5DF2\u6388\u6743\u5E97\u94FA\uFF08\u8DE8\u5E73\u53F0\uFF09"),o.option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{let e=await xt();if(t.json){console.log(JSON.stringify(To(e),null,2));return}if(!e.length){console.log(qo.yellow("\u672A\u627E\u5230\u5DF2\u6388\u6743\u7684\u5E97\u94FA")),console.log(qo.gray(" \u63D0\u793A: \u8BF7\u5148\u5728\u7B2C\u4E8C\u56DE\u5408 APP \u4E2D\u6388\u6743\u5E97\u94FA"));return}let{ShopsTable:r}=await Promise.resolve().then(()=>(Jo(),Go)),{renderComponent:n}=await Promise.resolve().then(()=>(rt(),pt));n(r,{shops:e,platform:"all"})})),o}import{Command as tr}from"commander";import or from"chalk";function Mo(){let o=new tr("stocks");return o.description("\u67E5\u770B\u6240\u6709\u4ED3\u5E93"),o.option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{let e=await It();if(t.json){console.log(JSON.stringify(e,null,2));return}if(!e.length){console.log(or.yellow("\u672A\u627E\u5230\u4ED3\u5E93\u4FE1\u606F"));return}let{StocksTable:r}=await Promise.resolve().then(()=>(Qo(),_o)),{renderComponent:n}=await Promise.resolve().then(()=>(rt(),pt));n(r,{stocks:e})})),o}import{Command as er}from"commander";import Z from"chalk";function Fo(){let o=new er("list");return o.description("\u67E5\u770B\u4ED3\u5E93\u4E2D\u7684\u9009\u54C1\u5546\u54C1"),o.option("--stock-id <id>","\u4ED3\u5E93 ID\uFF08\u4ECE goods stocks \u83B7\u53D6\uFF09").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--page <n>","\u9875\u7801","1").option("--size <n>","\u6BCF\u9875\u6570\u91CF","20").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{let r=await St({stockId:t.stockId||void 0,stockGoodsId:t.stockGoodsId||void 0,page:Number(t.page)||1,size:Number(t.size)||20})??{items:[],total:0};if(t.json){r.items?.length?console.log(JSON.stringify(r,null,2)):console.log(JSON.stringify({...r,hint:"\u9009\u54C1\u5546\u54C1\u4E3A\u7A7A\uFF0C\u8BF7\u5148\u5728\u540E\u53F0\u751F\u6210\u9009\u54C1\u8868\u6570\u636E\u540E\u518D\u8BD5"},null,2));return}if(!r.items?.length){console.log(Z.yellow("\u6682\u65E0\u9009\u54C1\u5546\u54C1\uFF0C\u8BF7\u5148\u7ED1\u5B9A\u4ED3\u5E93\u6216\u5728\u540E\u53F0\u751F\u6210\u9009\u54C1\u8868\u6570\u636E"));return}console.log(Z.cyan(`
|
|
36
36
|
\u9009\u54C1\u5546\u54C1\uFF08\u5171 ${r.total} \u4EF6\uFF0C\u7B2C ${r.page} \u9875\uFF09
|
|
37
|
-
`));for(let n of r.items)console.log(` ${Z.bold(n.goodsName)} ${n.size?Z.gray(`| ${n.size}`):""}`),console.log(` \u54C1\u724C: ${n.brand} \u5EFA\u8BAE\u552E\u4EF7: \xA5${n.salePrice} stockGoodsId: ${Z.green(n.stockGoodsId)}`),console.log(Z.gray(` \u5206\u7C7B: ${n.cate1Name} > ${n.cate2Name} > ${n.cate3Name}`)),console.log()})),o}import{Command as ar}from"commander";import cr from"chalk";rt();import{Box as p,Text as h}from"ink";import{jsx as c,jsxs as E}from"react/jsx-runtime";var rr={init:{label:"\u5F85\u4E0A\u67B6",color:"yellow"},up:{label:"\u5DF2\u4E0A\u67B6",color:"green"},down:{label:"\u5DF2\u4E0B\u67B6",color:"gray"},fail:{label:"\u5931\u8D25",color:"red"}},oo=4,eo=8,Ct=12,ro=10,no=6,so=8;function zo(o,t){return o.length>t?o.slice(0,t-1)+"\u2026":o}function Wo(o){if(!o)return"-";let t=new Date(o),e=r=>String(r).padStart(2,"0");return`${e(t.getMonth()+1)}/${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}`}function nr({fillWidth:o}){return E(p,{flexDirection:"row",children:[c(p,{width:oo,children:c(h,{bold:!0,color:"white",children:"ID"})}),c(p,{width:eo,children:c(h,{bold:!0,color:"white",children:"\u72B6\u6001"})}),c(p,{width:Ct,children:c(h,{bold:!0,color:"white",children:"\u54C1\u724C"})}),c(p,{width:o,children:c(h,{bold:!0,color:"white",children:"\u5546\u54C1\u540D\u79F0"})}),c(p,{width:ro,children:c(h,{bold:!0,color:"white",children:"\u4EF7\u683C"})}),c(p,{width:no,children:c(h,{bold:!0,color:"white",children:"\u89C4\u683C"})}),c(p,{width:so,children:c(h,{bold:!0,color:"white",children:"\u5E93\u5B58ID"})})]})}function sr({item:o}){return c(p,{flexDirection:"column",children:c(h,{color:"gray",children:` shopId: ${o.shopId} thirdItemNo: ${o.thirdItemNo||"-"} outItemNo: ${o.outItemNo||"-"} \u8D27\u53F7: ${o.goodsNo||"-"} ${o.type||"-"} ${o.platform} \u521B\u5EFA: ${Wo(o.gmtCreate)} \u4FEE\u6539: ${Wo(o.gmtModified)}`})})}function ir({item:o,fillWidth:t}){let e=rr[o.status]??{label:o.status,color:"white"};return E(p,{flexDirection:"column",children:[E(p,{flexDirection:"row",children:[c(p,{width:oo,children:c(h,{color:"gray",children:o.id})}),c(p,{width:eo,children:c(h,{color:e.color,children:e.label})}),c(p,{width:Ct,children:c(h,{color:"cyan",children:zo(o.brandName||"-",Ct-1)})}),c(p,{width:t,children:c(h,{children:zo(o.goodsName,t-1)})}),c(p,{width:ro,children:E(h,{color:"yellow",children:["\xA5",o.price]})}),c(p,{width:no,children:c(h,{color:"gray",children:o.spec||"-"})}),c(p,{width:so,children:c(h,{color:"gray",children:o.stockGoodsId})})]}),c(sr,{item:o})]})}function Ho({items:o,total:t}){let e=process.stdout.columns||80,r=4,n=oo+eo+Ct+ro+no+so,s=Math.max(e-r-n,20),i=n+s;return E(p,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"gray",paddingX:1,children:[E(p,{flexDirection:"row",children:[c(h,{bold:!0,color:"cyan",children:"\u4E0A\u67B6\u5217\u8868"}),E(h,{color:"gray",children:[" \xB7 \u5171 ",t," \u6761"]})]}),E(p,{flexDirection:"column",marginTop:1,children:[c(nr,{fillWidth:s}),c(h,{color:"gray",children:"\u2500".repeat(i)}),o.map(a=>c(ir,{item:a,fillWidth:s},a.id))]})]})}function Vo(){let o=new ar("listing");return o.description("\u67E5\u8BE2\u4E0A\u67B6\u5546\u54C1\u5217\u8868"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--stock-id <id>","\u4ED3\u5E93 ID").option("-s, --status <status>","\u72B6\u6001\u8FC7\u6EE4\uFF08init/up/down/fail\uFF09").option("-p, --platform <platform>","\u5E73\u53F0","xianyu").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{let r=await Ro({id:t.id,stockGoodsId:t.stockGoodsId?Number(t.stockGoodsId):void 0,shopId:t.shopId,stockId:t.stockId,status:t.status,platform:t.platform})??{items:[],total:0};if(t.json){r.items?.length?console.log(JSON.stringify(r,null,2)):console.log(JSON.stringify({...r,hint:"\u6682\u65E0\u4E0A\u67B6\u8BB0\u5F55"},null,2));return}if(!r.items?.length){console.log(cr.yellow("\u6682\u65E0\u4E0A\u67B6\u8BB0\u5F55"));return}Bt(Ho,{items:r.items,total:r.total})})),o}import{Command as lr}from"commander";import io from"chalk";function Ko(){let o=new lr("down");return o.description("\u4E0B\u67B6\u95F2\u9C7C\u5546\u54C1"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.id&&!(t.stockGoodsId&&t.shopId)){t.json&&(console.log(JSON.stringify({success:!1,error:"\u8BF7\u6307\u5B9A\u4E0B\u67B6\u6761\u4EF6\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"})),process.exit(1)),console.log(io.yellow("\u8BF7\u6307\u5B9A\u4E0B\u67B6\u6761\u4EF6\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"));return}let e={};t.id&&(e.id=t.id),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.shopId&&(e.shopId=t.shopId),t.json||console.log(io.cyan("\u{1F4E6} \u6B63\u5728\u4E0B\u67B6\u5546\u54C1..."));let r=await ko(e);t.json?console.log(JSON.stringify({success:!0,data:r},null,2)):(console.log(io.green("\u2705 \u4E0B\u67B6\u6210\u529F")),console.log(JSON.stringify(r,null,2)))})),o}import{Command as dr}from"commander";import Tt from"chalk";function Yo(){let o=new dr("price");return o.description("\u4FEE\u6539\u95F2\u9C7C\u4E0A\u67B6\u5546\u54C1\u4EF7\u683C"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--price <amount>","\u65B0\u4EF7\u683C\uFF08\u5FC5\u586B\uFF09").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.price){t.json&&(console.log(JSON.stringify({success:!1,error:"--price <amount> \u4E3A\u5FC5\u586B\u53C2\u6570"})),process.exit(1)),console.log(Tt.yellow("--price <amount> \u4E3A\u5FC5\u586B\u53C2\u6570"));return}if(!t.id&&!(t.stockGoodsId&&t.shopId)){t.json&&(console.log(JSON.stringify({success:!1,error:"\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"})),process.exit(1)),console.log(Tt.yellow("\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"));return}let e={price:Number(t.price)};t.id&&(e.id=t.id),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.shopId&&(e.shopId=t.shopId),t.json||console.log(Tt.cyan(`\u{1F4B0} \u6B63\u5728\u4FEE\u6539\u4EF7\u683C\u4E3A ${t.price}...`));let r=await vo(e);t.json?console.log(JSON.stringify({success:!0,data:r},null,2)):(console.log(Tt.green("\u2705 \u4EF7\u683C\u4FEE\u6539\u6210\u529F")),console.log(JSON.stringify(r,null,2)))})),o}import{Command as ur}from"commander";import st from"chalk";function Zo(){let o=new ur("edit");return o.description("\u4FEE\u6539\u5DF2\u4E0A\u67B6\u5546\u54C1\u4FE1\u606F\uFF08\u6807\u9898\u3001\u63CF\u8FF0\u3001\u54C1\u724C\u3001\u7C7B\u76EE\u3001\u56FE\u7247\u3001\u5C5E\u6027\u7B49\uFF09"),o.option("--id <id>","\u5546\u54C1\u4E0A\u67B6 ID\uFF08goodsListingId\uFF0C\u63A8\u8350\uFF09").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID\uFF08\u4E0E --account \u914D\u5408\uFF09").option("--account <shopId>","\u95F2\u9C7C\u7528\u6237\u540D/\u5E97\u94FA ID\uFF08\u4E0E --stock-goods-id \u914D\u5408\uFF09").option("--title <title>","\u5546\u54C1\u6807\u9898").option("--desc <desc>","\u5546\u54C1\u63CF\u8FF0").option("--category-id <id>","\u5546\u54C1\u7C7B\u76EE ID\uFF08\u5927\u5206\u7C7B\uFF0C\u540E\u7AEF\u5FC5\u586B\uFF09").option("--channel-cat-id <id>","\u6E20\u9053\u7C7B\u76EE ID\uFF08\u5C0F\u5206\u7C7B\uFF0C\u540E\u7AEF\u5FC5\u586B\uFF09").option("--image-ids <ids>","\u56FE\u7247 ID \u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--item-attrs <json>","\u5546\u54C1\u5C5E\u6027\u5217\u8868\uFF08JSON \u5B57\u7B26\u4E32\uFF09").option("--brand-name <name>","\u54C1\u724C\u540D\u79F0").option("--stuff-status <status>","\u6210\u8272\u7B49\u7EA7\uFF1A100=\u5168\u65B0 -1=\u51C6\u65B0 99=99\u65B0 95=95\u65B0 90=9\u65B0").option("--goods-no <no>","\u8D27\u53F7").option("--original-price <price>","\u539F\u4EF7\uFF08\u5355\u4F4D\uFF1A\u5143\uFF09").option("--size <size>","\u5C3A\u7801").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.id&&!(t.stockGoodsId&&t.account)){t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <goodsListingId> \u6216 --stock-goods-id <id> --account <shopId>"})),process.exit(1)),console.log(st.yellow("\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <goodsListingId> \u6216 --stock-goods-id <id> --account <shopId>"));return}let e={};if(t.id&&(e.goodsListingId=Number(t.id)),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.account&&(e.account=t.account),t.title&&(e.title=t.title),t.desc&&(e.desc=t.desc),t.categoryId&&(e.categoryId=Number(t.categoryId)),t.channelCatId&&(e.channelCatId=t.channelCatId),t.imageIds&&(e.imageIdList=t.imageIds.split(",").map(s=>s.trim())),t.brandName&&(e.brandName=t.brandName),t.stuffStatus&&(e.stuffStatus=Number(t.stuffStatus)),t.goodsNo&&(e.goodsNo=t.goodsNo),t.originalPrice&&(e.originalPrice=Number(t.originalPrice)),t.size&&(e.size=t.size),t.itemAttrs)try{e.itemAttrList=JSON.parse(t.itemAttrs)}catch{t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"--item-attrs JSON \u89E3\u6790\u5931\u8D25"})),process.exit(1)),console.log(st.yellow("--item-attrs JSON \u89E3\u6790\u5931\u8D25"));return}if(!Object.keys(e).some(s=>!["goodsListingId","stockGoodsId","account"].includes(s))){t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"\u672A\u6307\u5B9A\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"})),process.exit(1)),console.log(st.yellow("\u672A\u6307\u5B9A\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"));return}t.json||console.log(st.cyan("\u6B63\u5728\u4FEE\u6539\u5546\u54C1\u4FE1\u606F..."));let n=await No(e);t.json?console.log(JSON.stringify({success:!0,data:n},null,2)):(console.log(st.green("\u2705 \u5546\u54C1\u4FE1\u606F\u4FEE\u6539\u6210\u529F")),console.log(JSON.stringify(n,null,2)))})),o}import{Command as tt}from"commander";import y from"chalk";var mr={100:"\u5168\u65B0",[-1]:"\u51C6\u65B0",99:"99\u65B0",95:"95\u65B0",90:"9\u65B0"};function te(){let o=new tt("hang-up");return o.description("\u95F2\u9C7C\u6302\u552E\u4E0A\u67B6\uFF08\u5B8C\u6574\u5546\u54C1\u4FE1\u606F\u6A21\u5F0F\uFF09"),o.addCommand(new tt("categories").description("\u83B7\u53D6\u95F2\u9C7C\u7C7B\u76EE\u5217\u8868\uFF08\u5927\u5206\u7C7B \u2192 \u5C0F\u5206\u7C7B\uFF09").option("--sp-biz-type <n>","\u4E1A\u52A1\u5206\u7C7B\uFF0C16=\u5962\u54C1","16").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=await Do(Number(t.spBizType));if(t.json){console.log(JSON.stringify(e,null,2));return}let r=new Map;for(let n of e){let s=String(n.catId);r.has(s)||r.set(s,{catName:n.catName,children:[]}),r.get(s).children.push({channel:n.channel,channelCatId:n.channelCatId})}for(let[n,s]of r){console.log(y.bold(`${s.catName} (catId: ${y.green(n)})`));for(let i of s.children)console.log(` ${i.channel} (channelCatId: ${y.green(i.channelCatId)})`)}}))),o.addCommand(new tt("props").description("\u83B7\u53D6\u6307\u5B9A\u7C7B\u76EE\u4E0B\u7684\u5C5E\u6027\u5217\u8868\uFF08\u542B\u53EF\u9009\u503C\uFF09").requiredOption("--channel-cat-id <id>","\u5C0F\u5206\u7C7B ID\uFF08\u4ECE categories \u83B7\u53D6\uFF09").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=await Uo(t.channelCatId);if(t.json){console.log(JSON.stringify(e,null,2));return}for(let r of e)if(console.log(y.bold(`
|
|
37
|
+
`));for(let n of r.items)console.log(` ${Z.bold(n.goodsName)} ${n.size?Z.gray(`| ${n.size}`):""}`),console.log(` \u54C1\u724C: ${n.brand} \u5EFA\u8BAE\u552E\u4EF7: \xA5${n.salePrice} stockGoodsId: ${Z.green(n.stockGoodsId)}`),console.log(Z.gray(` \u5206\u7C7B: ${n.cate1Name} > ${n.cate2Name} > ${n.cate3Name}`)),console.log()})),o}import{Command as ar}from"commander";import cr from"chalk";rt();import{Box as p,Text as h}from"ink";import{jsx as c,jsxs as E}from"react/jsx-runtime";var rr={init:{label:"\u5F85\u4E0A\u67B6",color:"yellow"},up:{label:"\u5DF2\u4E0A\u67B6",color:"green"},down:{label:"\u5DF2\u4E0B\u67B6",color:"gray"},fail:{label:"\u5931\u8D25",color:"red"}},oo=4,eo=8,Ct=12,ro=10,no=6,so=8;function zo(o,t){return o.length>t?o.slice(0,t-1)+"\u2026":o}function Wo(o){if(!o)return"-";let t=new Date(o),e=r=>String(r).padStart(2,"0");return`${e(t.getMonth()+1)}/${e(t.getDate())} ${e(t.getHours())}:${e(t.getMinutes())}`}function nr({fillWidth:o}){return E(p,{flexDirection:"row",children:[c(p,{width:oo,children:c(h,{bold:!0,color:"white",children:"ID"})}),c(p,{width:eo,children:c(h,{bold:!0,color:"white",children:"\u72B6\u6001"})}),c(p,{width:Ct,children:c(h,{bold:!0,color:"white",children:"\u54C1\u724C"})}),c(p,{width:o,children:c(h,{bold:!0,color:"white",children:"\u5546\u54C1\u540D\u79F0"})}),c(p,{width:ro,children:c(h,{bold:!0,color:"white",children:"\u4EF7\u683C"})}),c(p,{width:no,children:c(h,{bold:!0,color:"white",children:"\u89C4\u683C"})}),c(p,{width:so,children:c(h,{bold:!0,color:"white",children:"\u5E93\u5B58ID"})})]})}function sr({item:o}){return c(p,{flexDirection:"column",children:c(h,{color:"gray",children:` shopId: ${o.shopId} thirdItemNo: ${o.thirdItemNo||"-"} outItemNo: ${o.outItemNo||"-"} \u8D27\u53F7: ${o.goodsNo||"-"} ${o.type||"-"} ${o.platform} \u521B\u5EFA: ${Wo(o.gmtCreate)} \u4FEE\u6539: ${Wo(o.gmtModified)}`})})}function ir({item:o,fillWidth:t}){let e=rr[o.status]??{label:o.status,color:"white"};return E(p,{flexDirection:"column",children:[E(p,{flexDirection:"row",children:[c(p,{width:oo,children:c(h,{color:"gray",children:o.id})}),c(p,{width:eo,children:c(h,{color:e.color,children:e.label})}),c(p,{width:Ct,children:c(h,{color:"cyan",children:zo(o.brandName||"-",Ct-1)})}),c(p,{width:t,children:c(h,{children:zo(o.goodsName,t-1)})}),c(p,{width:ro,children:E(h,{color:"yellow",children:["\xA5",o.price]})}),c(p,{width:no,children:c(h,{color:"gray",children:o.spec||"-"})}),c(p,{width:so,children:c(h,{color:"gray",children:o.stockGoodsId})})]}),c(sr,{item:o})]})}function Ho({items:o,total:t}){let e=process.stdout.columns||80,r=4,n=oo+eo+Ct+ro+no+so,s=Math.max(e-r-n,20),i=n+s;return E(p,{flexDirection:"column",marginTop:1,borderStyle:"round",borderColor:"gray",paddingX:1,children:[E(p,{flexDirection:"row",children:[c(h,{bold:!0,color:"cyan",children:"\u4E0A\u67B6\u5217\u8868"}),E(h,{color:"gray",children:[" \xB7 \u5171 ",t," \u6761"]})]}),E(p,{flexDirection:"column",marginTop:1,children:[c(nr,{fillWidth:s}),c(h,{color:"gray",children:"\u2500".repeat(i)}),o.map(a=>c(ir,{item:a,fillWidth:s},a.id))]})]})}function Vo(){let o=new ar("listing");return o.description("\u67E5\u8BE2\u4E0A\u67B6\u5546\u54C1\u5217\u8868"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--stock-id <id>","\u4ED3\u5E93 ID").option("-s, --status <status>","\u72B6\u6001\u8FC7\u6EE4\uFF08init/up/down/fail/sold\uFF09").option("-p, --platform <platform>","\u5E73\u53F0","xianyu").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{let r=await Ro({id:t.id,stockGoodsId:t.stockGoodsId?Number(t.stockGoodsId):void 0,shopId:t.shopId,stockId:t.stockId,status:t.status,platform:t.platform})??{items:[],total:0};if(t.json){r.items?.length?console.log(JSON.stringify(r,null,2)):console.log(JSON.stringify({...r,hint:"\u6682\u65E0\u4E0A\u67B6\u8BB0\u5F55"},null,2));return}if(!r.items?.length){console.log(cr.yellow("\u6682\u65E0\u4E0A\u67B6\u8BB0\u5F55"));return}Bt(Ho,{items:r.items,total:r.total})})),o}import{Command as lr}from"commander";import io from"chalk";function Ko(){let o=new lr("down");return o.description("\u4E0B\u67B6\u95F2\u9C7C\u5546\u54C1"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.id&&!(t.stockGoodsId&&t.shopId)){t.json&&(console.log(JSON.stringify({success:!1,error:"\u8BF7\u6307\u5B9A\u4E0B\u67B6\u6761\u4EF6\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"})),process.exit(1)),console.log(io.yellow("\u8BF7\u6307\u5B9A\u4E0B\u67B6\u6761\u4EF6\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"));return}let e={};t.id&&(e.id=t.id),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.shopId&&(e.shopId=t.shopId),t.json||console.log(io.cyan("\u{1F4E6} \u6B63\u5728\u4E0B\u67B6\u5546\u54C1..."));let r=await ko(e);t.json?console.log(JSON.stringify({success:!0,data:r},null,2)):(console.log(io.green("\u2705 \u4E0B\u67B6\u6210\u529F")),console.log(JSON.stringify(r,null,2)))})),o}import{Command as dr}from"commander";import Tt from"chalk";function Yo(){let o=new dr("price");return o.description("\u4FEE\u6539\u95F2\u9C7C\u4E0A\u67B6\u5546\u54C1\u4EF7\u683C"),o.option("--id <id>","\u4E0A\u67B6\u8BB0\u5F55 ID").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID").option("--shop-id <id>","\u5E97\u94FA ID").option("--price <amount>","\u65B0\u4EF7\u683C\uFF08\u5FC5\u586B\uFF09").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.price){t.json&&(console.log(JSON.stringify({success:!1,error:"--price <amount> \u4E3A\u5FC5\u586B\u53C2\u6570"})),process.exit(1)),console.log(Tt.yellow("--price <amount> \u4E3A\u5FC5\u586B\u53C2\u6570"));return}if(!t.id&&!(t.stockGoodsId&&t.shopId)){t.json&&(console.log(JSON.stringify({success:!1,error:"\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"})),process.exit(1)),console.log(Tt.yellow("\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <id> \u6216 --stock-goods-id <id> --shop-id <id>"));return}let e={price:Number(t.price)};t.id&&(e.id=t.id),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.shopId&&(e.shopId=t.shopId),t.json||console.log(Tt.cyan(`\u{1F4B0} \u6B63\u5728\u4FEE\u6539\u4EF7\u683C\u4E3A ${t.price}...`));let r=await vo(e);t.json?console.log(JSON.stringify({success:!0,data:r},null,2)):(console.log(Tt.green("\u2705 \u4EF7\u683C\u4FEE\u6539\u6210\u529F")),console.log(JSON.stringify(r,null,2)))})),o}import{Command as ur}from"commander";import st from"chalk";function Zo(){let o=new ur("edit");return o.description("\u4FEE\u6539\u5DF2\u4E0A\u67B6\u5546\u54C1\u4FE1\u606F\uFF08\u6807\u9898\u3001\u63CF\u8FF0\u3001\u54C1\u724C\u3001\u7C7B\u76EE\u3001\u56FE\u7247\u3001\u5C5E\u6027\u7B49\uFF09"),o.option("--id <id>","\u5546\u54C1\u4E0A\u67B6 ID\uFF08goodsListingId\uFF0C\u63A8\u8350\uFF09").option("--stock-goods-id <id>","\u5E93\u5B58\u5546\u54C1 ID\uFF08\u4E0E --account \u914D\u5408\uFF09").option("--account <shopId>","\u95F2\u9C7C\u7528\u6237\u540D/\u5E97\u94FA ID\uFF08\u4E0E --stock-goods-id \u914D\u5408\uFF09").option("--title <title>","\u5546\u54C1\u6807\u9898").option("--desc <desc>","\u5546\u54C1\u63CF\u8FF0").option("--category-id <id>","\u5546\u54C1\u7C7B\u76EE ID\uFF08\u5927\u5206\u7C7B\uFF0C\u540E\u7AEF\u5FC5\u586B\uFF09").option("--channel-cat-id <id>","\u6E20\u9053\u7C7B\u76EE ID\uFF08\u5C0F\u5206\u7C7B\uFF0C\u540E\u7AEF\u5FC5\u586B\uFF09").option("--image-ids <ids>","\u56FE\u7247 ID \u5217\u8868\uFF08\u9017\u53F7\u5206\u9694\uFF09").option("--item-attrs <json>","\u5546\u54C1\u5C5E\u6027\u5217\u8868\uFF08JSON \u5B57\u7B26\u4E32\uFF09").option("--brand-name <name>","\u54C1\u724C\u540D\u79F0").option("--stuff-status <status>","\u6210\u8272\u7B49\u7EA7\uFF1A100=\u5168\u65B0 -1=\u51C6\u65B0 99=99\u65B0 95=95\u65B0 90=9\u65B0").option("--goods-no <no>","\u8D27\u53F7").option("--original-price <price>","\u539F\u4EF7\uFF08\u5355\u4F4D\uFF1A\u5143\uFF09").option("--size <size>","\u5C3A\u7801").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09"),o.action(g(async t=>{if(!t.id&&!(t.stockGoodsId&&t.account)){t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <goodsListingId> \u6216 --stock-goods-id <id> --account <shopId>"})),process.exit(1)),console.log(st.yellow("\u8BF7\u6307\u5B9A\u5546\u54C1\uFF1A--id <goodsListingId> \u6216 --stock-goods-id <id> --account <shopId>"));return}let e={};if(t.id&&(e.goodsListingId=Number(t.id)),t.stockGoodsId&&(e.stockGoodsId=Number(t.stockGoodsId)),t.account&&(e.account=t.account),t.title&&(e.title=t.title),t.desc&&(e.desc=t.desc),t.categoryId&&(e.categoryId=Number(t.categoryId)),t.channelCatId&&(e.channelCatId=t.channelCatId),t.imageIds&&(e.imageIdList=t.imageIds.split(",").map(s=>s.trim())),t.brandName&&(e.brandName=t.brandName),t.stuffStatus&&(e.stuffStatus=Number(t.stuffStatus)),t.goodsNo&&(e.goodsNo=t.goodsNo),t.originalPrice&&(e.originalPrice=Number(t.originalPrice)),t.size&&(e.size=t.size),t.itemAttrs)try{e.itemAttrList=JSON.parse(t.itemAttrs)}catch{t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"--item-attrs JSON \u89E3\u6790\u5931\u8D25"})),process.exit(1)),console.log(st.yellow("--item-attrs JSON \u89E3\u6790\u5931\u8D25"));return}if(!Object.keys(e).some(s=>!["goodsListingId","stockGoodsId","account"].includes(s))){t.json&&(console.log(JSON.stringify({success:!1,status:400,error:"\u672A\u6307\u5B9A\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"})),process.exit(1)),console.log(st.yellow("\u672A\u6307\u5B9A\u9700\u8981\u4FEE\u6539\u7684\u5B57\u6BB5"));return}t.json||console.log(st.cyan("\u6B63\u5728\u4FEE\u6539\u5546\u54C1\u4FE1\u606F..."));let n=await No(e);t.json?console.log(JSON.stringify({success:!0,data:n},null,2)):(console.log(st.green("\u2705 \u5546\u54C1\u4FE1\u606F\u4FEE\u6539\u6210\u529F")),console.log(JSON.stringify(n,null,2)))})),o}import{Command as tt}from"commander";import y from"chalk";var mr={100:"\u5168\u65B0",[-1]:"\u51C6\u65B0",99:"99\u65B0",95:"95\u65B0",90:"9\u65B0"};function te(){let o=new tt("hang-up");return o.description("\u95F2\u9C7C\u6302\u552E\u4E0A\u67B6\uFF08\u5B8C\u6574\u5546\u54C1\u4FE1\u606F\u6A21\u5F0F\uFF09"),o.addCommand(new tt("categories").description("\u83B7\u53D6\u95F2\u9C7C\u7C7B\u76EE\u5217\u8868\uFF08\u5927\u5206\u7C7B \u2192 \u5C0F\u5206\u7C7B\uFF09").option("--sp-biz-type <n>","\u4E1A\u52A1\u5206\u7C7B\uFF0C16=\u5962\u54C1","16").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=await Do(Number(t.spBizType));if(t.json){console.log(JSON.stringify(e,null,2));return}let r=new Map;for(let n of e){let s=String(n.catId);r.has(s)||r.set(s,{catName:n.catName,children:[]}),r.get(s).children.push({channel:n.channel,channelCatId:n.channelCatId})}for(let[n,s]of r){console.log(y.bold(`${s.catName} (catId: ${y.green(n)})`));for(let i of s.children)console.log(` ${i.channel} (channelCatId: ${y.green(i.channelCatId)})`)}}))),o.addCommand(new tt("props").description("\u83B7\u53D6\u6307\u5B9A\u7C7B\u76EE\u4E0B\u7684\u5C5E\u6027\u5217\u8868\uFF08\u542B\u53EF\u9009\u503C\uFF09").requiredOption("--channel-cat-id <id>","\u5C0F\u5206\u7C7B ID\uFF08\u4ECE categories \u83B7\u53D6\uFF09").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=await Uo(t.channelCatId);if(t.json){console.log(JSON.stringify(e,null,2));return}for(let r of e)if(console.log(y.bold(`
|
|
38
38
|
${r.propName} (propId: ${r.propId})`)),r.propsValues?.length)for(let n of r.propsValues)console.log(` ${n.valueName} (valueId: ${n.valueId})`);else console.log(y.gray(" \uFF08\u4F7F\u7528 brands \u5B50\u547D\u4EE4\u641C\u7D22\uFF09"))}))),o.addCommand(new tt("brands").description("\u641C\u7D22\u95F2\u9C7C\u54C1\u724C\uFF08\u6309\u5173\u952E\u5B57\u8FC7\u6EE4\uFF09").requiredOption("--channel-cat-id <id>","\u5C0F\u5206\u7C7B ID").requiredOption("--prop-id <id>","\u5C5E\u6027 ID\uFF08\u54C1\u724C\u5C5E\u6027\u7684 propId\uFF09").requiredOption("--key <keyword>","\u641C\u7D22\u5173\u952E\u5B57").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=await jo(t.channelCatId,t.propId,t.key);if(t.json){console.log(JSON.stringify(e,null,2));return}if(!e.length){console.log(y.yellow("\u672A\u627E\u5230\u5339\u914D\u7684\u54C1\u724C"));return}for(let r of e)console.log(` ${r.valueName} (valueId: ${r.valueId})`)}))),o.addCommand(new tt("upload-images").description("\u6279\u91CF\u4E0A\u4F20\u56FE\u7247\u5230\u95F2\u9C7C\uFF08\u6302\u552E\u524D\u5FC5\u987B\u5148\u4E0A\u4F20\u56FE\u7247\uFF09").requiredOption("--shop-id <id>","\u5E97\u94FA ID").requiredOption("--files <paths>","\u56FE\u7247\u6587\u4EF6\u8DEF\u5F84\uFF0C\u9017\u53F7\u5206\u9694").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=t.files.split(",").map(n=>n.trim()).filter(Boolean);if(e.length===0){t.json&&(console.log(JSON.stringify({success:!1,error:"\u8BF7\u63D0\u4F9B\u81F3\u5C11\u4E00\u5F20\u56FE\u7247"})),process.exit(1)),console.log(y.yellow("\u8BF7\u63D0\u4F9B\u81F3\u5C11\u4E00\u5F20\u56FE\u7247"));return}t.json||console.log(y.cyan(`\u6B63\u5728\u4E0A\u4F20 ${e.length} \u5F20\u56FE\u7247...`));let r=await Lo(t.shopId,e);if(t.json)console.log(JSON.stringify({success:!0,images:r},null,2));else{console.log(y.green(`\u4E0A\u4F20\u6210\u529F\uFF0C\u5171 ${r.length} \u5F20`));for(let n of r)console.log(` \u56FE\u7247ID: ${n.value}`)}}))),o.addCommand(new tt("submit").description("\u63D0\u4EA4\u6302\u552E\u4E0A\u67B6").requiredOption("--shop-id <id>","\u5E97\u94FA ID\uFF08\u5373\u95F2\u9C7C\u7528\u6237\u540D account\uFF09").requiredOption("--title <title>","\u5546\u54C1\u6807\u9898").requiredOption("--price <amount>","\u552E\u4EF7").requiredOption("--category-id <id>","\u5927\u5206\u7C7B ID\uFF08\u4ECE categories \u83B7\u53D6\uFF09").requiredOption("--channel-cat-id <id>","\u5C0F\u5206\u7C7B ID\uFF08\u4ECE categories \u83B7\u53D6\uFF09").requiredOption("--image-ids <ids>","\u56FE\u7247 ID \u5217\u8868\uFF0C\u9017\u53F7\u5206\u9694\uFF08\u5148\u901A\u8FC7 upload-images \u83B7\u53D6\uFF09").requiredOption("--stuff-status <n>","\u6210\u8272\uFF1A100 \u5168\u65B0 / -1 \u51C6\u65B0 / 99 99\u65B0 / 95 95\u65B0 / 90 9\u65B0").option("--item-attrs <json>",'\u5546\u54C1\u5C5E\u6027\u5217\u8868 JSON\uFF0C\u683C\u5F0F: [{"propId":"x","valueId":"y","valueName":"z"}]').option("--brand-name <name>","\u54C1\u724C\u540D\u79F0").option("--desc <desc>","\u5546\u54C1\u63CF\u8FF0").option("--size <size>","\u5C3A\u7801").option("--goods-no <no>","\u8D27\u53F7").option("--original-price <amount>","\u539F\u4EF7").option("--trade-type <n>","\u4EA4\u6613\u65B9\u5F0F\uFF1A0 \u4EC5\u5728\u7EBF / 1 \u4EC5\u7EBF\u4E0B / 2 \u7EBF\u4E0A\u6216\u7EBF\u4E0B","0").option("--transport-fee <amount>","\u8FD0\u8D39\uFF08\u9ED8\u8BA4 0 \u5305\u90AE\uFF09","0").option("--yhb","\u662F\u5426\u5F00\u542F\u9A8C\u8D27\u5B9D").requiredOption("--out-item-no <no>","\u5546\u5BB6\u7F16\u7801\uFF08\u540C\u5E97\u94FA\u552F\u4E00\uFF0C\u7528\u6237\u81EA\u5B9A\u4E49\uFF09").option("--division-id <id>","\u884C\u653F\u533A\u5212 ID\uFF08\u5E02\u7EA7 ID\uFF0C\u9ED8\u8BA4\u676D\u5DDE 330100\uFF09","330100").option("--json","\u8F93\u51FA JSON\uFF08\u4F9B AI Agent \u4F7F\u7528\uFF09").action(g(async t=>{let e=t.imageIds.split(",").map(s=>s.trim()),r={account:t.shopId,title:t.title,reservePrice:Number(t.price),categoryId:Number(t.categoryId),channelCatId:t.channelCatId,imageIdList:e,stuffStatus:Number(t.stuffStatus),itemBizType:2,spBizType:"16",tradeType:Number(t.tradeType)||0,transportFee:Number(t.transportFee)||0,yhb:t.yhb??!1,...t.brandName&&{brandName:t.brandName},...t.desc&&{desc:t.desc},...t.size&&{size:t.size},...t.goodsNo&&{goodsNo:t.goodsNo},...t.originalPrice&&{originalPrice:Number(t.originalPrice)},outItemNo:t.outItemNo,divisionId:Number(t.divisionId)||330100,apiAfterSalesDo:{supportFd10msPolicy:!1,supportFd24hsPolicy:!1,supportNfrPolicy:!1,supportSdrPolicy:!1,supportVnrPolicy:!1,supportGpaPolicy:!1,supportFd48hsPolicy:!1},...t.itemAttrs&&{itemAttrList:JSON.parse(t.itemAttrs)}};t.json||(console.log(y.cyan("\u6B63\u5728\u63D0\u4EA4\u6302\u552E...")),console.log(y.gray(` \u6807\u9898: ${r.title}`)),console.log(y.gray(` \u552E\u4EF7: \xA5${r.reservePrice}`)),console.log(y.gray(` \u6210\u8272: ${mr[r.stuffStatus]??r.stuffStatus}`)),console.log(y.gray(` \u56FE\u7247: ${e.length} \u5F20`)),r.itemAttrList?.length&&console.log(y.gray(` \u5C5E\u6027: ${r.itemAttrList.length} \u9879`)));let n=await Oo(r);t.json?console.log(JSON.stringify({success:!0,data:n},null,2)):(console.log(y.green("\u6302\u552E\u63D0\u4EA4\u6210\u529F")),console.log(JSON.stringify(n,null,2)))}))),o}function oe(){let o=new gr("goods");return o.description("\u5546\u54C1\u7BA1\u7406"),o.addCommand(Xo()),o.addCommand(Mo()),o.addCommand(Fo()),o.addCommand(Vo()),o.addCommand(Ko()),o.addCommand(Yo()),o.addCommand(Zo()),o.addCommand($o()),o.addCommand(te()),o}import{Command as pr}from"commander";import O from"chalk";import{promises as fr}from"node:fs";import hr from"node:path";import yr from"node:os";import{spawn as wr}from"node:child_process";var bt="@round2ai/r2-cli";function ee(){let o=new pr("uninstall");return o.description("\u5378\u8F7D R2-CLI \u5E76\u6E05\u9664\u6240\u6709\u914D\u7F6E"),o.action(async()=>{try{console.log(O.yellow(`
|
|
39
39
|
\u26A0\uFE0F \u5373\u5C06\u6267\u884C\u4EE5\u4E0B\u64CD\u4F5C\uFF1A`)),console.log(O.gray(" 1. \u5220\u9664\u914D\u7F6E\u76EE\u5F55 ~/.r2-cli/")),console.log(O.gray(` 2. \u5168\u5C40\u5378\u8F7D ${bt}
|
|
40
40
|
`));let{confirm:t}=await import("@inquirer/prompts");if(!await t({message:"\u786E\u8BA4\u5378\u8F7D\uFF1F",default:!1})){console.log(O.gray("\u5DF2\u53D6\u6D88\u5378\u8F7D"));return}let r=hr.join(yr.homedir(),".r2-cli");try{await fr.rm(r,{recursive:!0,force:!0}),console.log(O.green("\u2705 \u914D\u7F6E\u6587\u4EF6\u5DF2\u6E05\u9664"))}catch{console.log(O.yellow("\u26A0\uFE0F \u914D\u7F6E\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u65E0\u6CD5\u5220\u9664\uFF08\u53EF\u5FFD\u7565\uFF09"))}console.log(O.cyan(`\u6B63\u5728\u5378\u8F7D ${bt}...`)),wr("npm",["uninstall","-g",bt],{stdio:"inherit",shell:!0}).on("exit",s=>{s===0?console.log(O.green(`
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@round2ai/r2-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "R2-CLI,向 AI 开放二手潮奢交易全链路能力",
|
|
5
5
|
"main": "dist/r2-cli.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"bin": {
|
|
8
|
-
"r2-cli": "
|
|
8
|
+
"r2-cli": "dist/r2-cli.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
11
|
"postinstall": "node scripts/install-skills.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|
|
42
|
-
"url": "https://github.com/Round2AI/r2-cli"
|
|
42
|
+
"url": "git+https://github.com/Round2AI/r2-cli.git"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@inquirer/prompts": "^8.4.2",
|
|
@@ -1,63 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* postinstall:
|
|
2
|
+
* postinstall: 通过 skills CLI 将本地 skills 安装到所有 Agent 目录
|
|
3
|
+
* 自动适配 Claude Code / Codex / Gemini CLI 等所有 Agent
|
|
3
4
|
*/
|
|
4
5
|
|
|
5
|
-
import
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import os from "node:os";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
|
|
10
10
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
let src;
|
|
21
|
-
try { src = fs.realpathSync(rawSrc); } catch { continue; }
|
|
22
|
-
if (!fs.statSync(src).isDirectory()) continue;
|
|
23
|
-
|
|
24
|
-
const dest = path.join(agentsDir, name);
|
|
25
|
-
if (fs.existsSync(dest)) {
|
|
26
|
-
for (const old of fs.readdirSync(dest)) {
|
|
27
|
-
const oldPath = path.join(dest, old);
|
|
28
|
-
fs.statSync(oldPath).isDirectory()
|
|
29
|
-
? fs.rmSync(oldPath, { recursive: true })
|
|
30
|
-
: fs.unlinkSync(oldPath);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
34
|
-
|
|
35
|
-
for (const file of fs.readdirSync(src)) {
|
|
36
|
-
const fileSrc = path.join(src, file);
|
|
37
|
-
const fileDest = path.join(dest, file);
|
|
38
|
-
if (fs.statSync(fileSrc).isDirectory()) {
|
|
39
|
-
copyDir(fileSrc, fileDest);
|
|
40
|
-
} else {
|
|
41
|
-
fs.copyFileSync(fileSrc, fileDest);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function copyDir(src, dest) {
|
|
47
|
-
if (fs.existsSync(dest)) {
|
|
48
|
-
for (const old of fs.readdirSync(dest)) {
|
|
49
|
-
const oldPath = path.join(dest, old);
|
|
50
|
-
fs.statSync(oldPath).isDirectory()
|
|
51
|
-
? fs.rmSync(oldPath, { recursive: true })
|
|
52
|
-
: fs.unlinkSync(oldPath);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
fs.mkdirSync(dest, { recursive: true });
|
|
56
|
-
for (const file of fs.readdirSync(src)) {
|
|
57
|
-
const fileSrc = path.join(src, file);
|
|
58
|
-
const fileDest = path.join(dest, file);
|
|
59
|
-
fs.statSync(fileSrc).isDirectory()
|
|
60
|
-
? copyDir(fileSrc, fileDest)
|
|
61
|
-
: fs.copyFileSync(fileSrc, fileDest);
|
|
62
|
-
}
|
|
11
|
+
const skillsDir = path.join(__dirname, "..", "skills");
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
execSync(`npx skills add "${skillsDir}" --all -g`, {
|
|
15
|
+
stdio: "inherit",
|
|
16
|
+
timeout: 60_000,
|
|
17
|
+
});
|
|
18
|
+
} catch {
|
|
19
|
+
// 网络不可用或 skills CLI 失败时静默跳过
|
|
63
20
|
}
|
package/skills/r2-goods/SKILL.md
CHANGED
|
@@ -118,7 +118,7 @@ metadata:
|
|
|
118
118
|
5. **汇总展示**:自动填充的字段标 ✅,缺失字段标 ❓ 让用户补充
|
|
119
119
|
6. **提交**:`hang-up submit` — 必填:`shop-id`、`title`、`price`、`category-id`、`channel-cat-id`、`image-ids`、`stuff-status`、`desc`、`out-item-no`
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
**核心原则**:**图片里能看到的,就别问用户**。只问价格和商家编码(优先用户自定义,不填则推荐自动生成),其他全部从图片自动提取。
|
|
122
122
|
|
|
123
123
|
**关键注意事项**:
|
|
124
124
|
- **品牌必须双传**:`--brand-name` + itemAttrs 中的一项(含 propId/valueId/valueName),缺一不可
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
挂售模式支持完整商品信息:图片、类目、属性等。与普通上架(`goods up`)是不同流程。
|
|
6
6
|
|
|
7
|
-
**核心理念**:**图片里能看到的,就别问用户**。Agent
|
|
7
|
+
**核心理念**:**图片里能看到的,就别问用户**。Agent 从图片中提取一切可识别的信息,用户只需要提供价格。
|
|
8
8
|
|
|
9
9
|
## 核心原则
|
|
10
10
|
|
|
11
11
|
- **图片优先**:所有字段优先从图片提取,图片无法识别时才问用户
|
|
12
|
-
-
|
|
13
|
-
-
|
|
12
|
+
- 必须问用户的只有:**价格**
|
|
13
|
+
- 商家编码(`out-item-no`)**优先让用户自定义**,用户不填则推荐自动生成编码(如 `GS20260512-0005`)
|
|
14
|
+
- **必须问用户的条件**:价格(永远无法从图片判断)。其他一切字段都应尝试从图片获取。商家编码优先用户自定义,不填则推荐自动生成
|
|
14
15
|
- **描述必须自动生成**:基于 AI 识别的品牌+款式+颜色+材质+货号自动组合,不要标记为"需要补充"
|
|
15
16
|
- **品牌必须双传**:`--brand-name`(文本字段)+ itemAttrs 中的一项(含 propId/valueId/valueName),缺一不可
|
|
16
17
|
- **季节自动推断**:根据商品类型推断适用季节(夹克/风衣→春秋季,羽绒服→秋冬季,T恤/短裤→夏季),不需要问用户
|
|
@@ -69,7 +70,7 @@ r2-cli goods hang-up upload-images --shop-id <shopId> --files /path/img1.jpg,/pa
|
|
|
69
70
|
| `--goods-no`(货号) | ⚠️ | 有标签则读取,无则留空 |
|
|
70
71
|
| 款式/颜色/材质属性 | ⚠️ | 能识别则自动匹配 propsValues,不能则汇总时问 |
|
|
71
72
|
| `--price`(售价) | ❌ | **必须问用户** |
|
|
72
|
-
| `--out-item-no`(商家编码) |
|
|
73
|
+
| `--out-item-no`(商家编码) | ⚠️ | 先问用户自定义编码,不填则推荐自动生成(如 `GS20260512-0005`) |
|
|
73
74
|
| `--shop-id`(店铺) | ❌ | 只有一个店铺时自动选,多个则问 |
|
|
74
75
|
|
|
75
76
|
**成色判断映射**:
|
|
@@ -209,7 +210,7 @@ r2-cli goods hang-up submit \
|
|
|
209
210
|
| 缺失字段 | 何时询问 | 询问方式 |
|
|
210
211
|
|----------|----------|----------|
|
|
211
212
|
| `--price`(售价) | 上传图片时 | "这个商品上架价格是多少?" |
|
|
212
|
-
| `--out-item-no`(商家编码) | 上传图片时 | "
|
|
213
|
+
| `--out-item-no`(商家编码) | 上传图片时 | 先问:"商家编码是什么?"用户不填则推荐自动生成编码 |
|
|
213
214
|
| `--shop-id`(店铺) | 流程开始时 | 展示店铺列表让用户选择 |
|
|
214
215
|
| `--title`(标题) | 图片识别无法生成时 | "商品标题用什么?" |
|
|
215
216
|
| `--desc`(描述) | 图片识别无法生成时 | "商品描述?" |
|
|
@@ -54,10 +54,11 @@ r2-cli goods list --stock-id <stockId> --page 2 --size 20 --json
|
|
|
54
54
|
|
|
55
55
|
```bash
|
|
56
56
|
r2-cli goods listing --json
|
|
57
|
-
r2-cli goods listing --status up --json
|
|
57
|
+
r2-cli goods listing --status up --json # 只看已上架
|
|
58
|
+
r2-cli goods listing --status sold --json # 只看已售出
|
|
58
59
|
r2-cli goods listing --shop-id <id> --json # 按店铺过滤
|
|
59
60
|
r2-cli goods listing --stock-goods-id <id> --json # 按商品过滤
|
|
60
61
|
r2-cli goods listing --id <id> --json # 精确查询
|
|
61
62
|
```
|
|
62
63
|
|
|
63
|
-
过滤参数:`--id`、`--stock-goods-id`、`--shop-id`、`--stock-id`、`--status`(init/up/down/fail)、`--platform`
|
|
64
|
+
过滤参数:`--id`、`--stock-goods-id`、`--shop-id`、`--stock-id`、`--status`(init/up/down/fail/sold)、`--platform`
|