@doubao-dev/cli 1.0.0-rc.8 → 1.0.0-rc.9
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/README.md +9 -3
- package/dist/691.js +75 -67
- package/dist/command.js +8 -8
- package/dist/command~2.js +1 -1
- package/dist/command~3.js +2 -1
- package/dist/command~5.js +6 -5
- package/dist/draft.js +2 -2
- package/dist/index.d.ts +268 -20
- package/dist/main.d.ts +268 -20
- package/dist/plugin.js +2 -2
- package/dist/ratatui-ui.js +1 -1
- package/dist/session.js +1 -1
- package/dist/skills/doubao-plugin-cli/SKILL.md +15 -7
- package/dist/skills/doubao-plugin-cli/references/development.md +7 -6
- package/dist/skills/doubao-plugin-cli/references/project-config.md +3 -2
- package/dist/skills/doubao-plugin-cli/references/upload.md +18 -8
- package/dist/skills/doubao-plugin-cli/references/workbench.md +164 -0
- package/dist/templates/standard/AGENTS.md +1 -1
- package/dist/templates/workbench/README.md.template +9 -0
- package/dist/templates/workbench/com.doubao/workbench/manifest.json +10 -0
- package/dist/uninstall.js +1 -1
- package/dist/versions~1.js +1 -1
- package/dist/workbench-search.js +1 -0
- package/package.json +3 -3
package/dist/ratatui-ui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{blockGlyphsSafe as e,error_errorMessage as t,state_State as a}from"./691.js";import{createDevServerHeader as s,captureTerminalOutput as n,createQRCodeCard as i}from"./dist.js";async function r(r,o){let l,c=[],d=new a([{name:"退出",commandId:"q",args:[]}]),m=new Set,p=r.states.createState({status:o.projectName,rows:[]}),u=new Set,g=!1,w=Promise.resolve(),f=(e,t=!1)=>y(()=>r.addMessage({type:"log",text:e,level:t?"error":"info"})),y=e=>{w=w.then(async()=>{g||await e()}).catch(e=>{g||(l=e,g=!0,o.onExit(!0))})},b=()=>Object.assign({},...c.map(e=>e.actions)),S=async(e,t)=>{let a=b()[e];if(!(g||!a||u.has(a))){u.add(a);try{await a.run({signal:AbortSignal.any([t,o.signal])})}finally{u.delete(a)}}},h=()=>{p.set({status:o.projectName,rows:c.flatMap(e=>[{label:e.title,text:
|
|
1
|
+
import{blockGlyphsSafe as e,error_errorMessage as t,state_State as a}from"./691.js";import{createDevServerHeader as s,captureTerminalOutput as n,createQRCodeCard as i}from"./dist.js";async function r(r,o){let l,c=[],d=new a([{name:"退出",commandId:"q",args:[]}]),m=new Set,p=r.states.createState({status:o.projectName,rows:[]}),u=new Set,g=!1,w=Promise.resolve(),f=(e,t=!1)=>y(()=>r.addMessage({type:"log",text:e,level:t?"error":"info"})),y=e=>{w=w.then(async()=>{g||await e()}).catch(e=>{g||(l=e,g=!0,o.onExit(!0))})},b=()=>Object.assign({},...c.map(e=>e.actions)),S=async(e,t)=>{let a=b()[e];if(!(g||!a||u.has(a))){u.add(a);try{await a.run({signal:AbortSignal.any([t,o.signal])})}finally{u.delete(a)}}},h=()=>{p.set({status:o.projectName,rows:c.flatMap(e=>[...e.message.split("\n").map((t,a)=>({label:0===a?e.title:"",text:t,status:0===a?e.status:"detail"})),...e.detail?[{label:"",text:e.detail,status:"detail"}]:[],...Object.entries(e.links??{}).map(([e,t])=>({label:e,text:t,status:"link"}))])})};await r.switchScene({id:"plugin-dev",compact:!0,commands:[{name:"q",description:"退出开发",callback:async()=>o.onExit(!1)}],headerComponent:s(p,!0),quickActions:d});let $=n({append(e,t){f(t,"error"===e)}}),_=()=>{g||(g=!0,o.onExit(!0))};return r.done.then(_,e=>{l=e,_()}),{interactive:!0,addTarget(t,a){let s,n={title:a,status:"pending",message:"正在启动"};c.push(n),h();let o=`[${t}] `;return{log:{info:e=>f(`${o}${e}`),success:e=>f(`${o}${e}`),warn:e=>f(`${o}警告:${e}`),error:e=>f(`${o}${e}`,!0)},ui:{update(e){!g&&(Object.assign(n,e),h(),"actions"in e&&y(async()=>{let e=Object.entries(b()).filter(([e])=>"q"!==e);for(let[t,a]of e)m.has(t)||(await r.registerCommand({name:t,description:a.label,callback:(e,a)=>S(t,a)}),m.add(t));d.set([...e.map(([e,t])=>({name:t.label,commandId:e,args:[]})),{name:"退出",commandId:"q",args:[]}])}))},async select(e,t){let a;if(!g)return await r.showSelection(t.map(({value:e,label:t})=>({label:t,action:()=>{a=e}})),{title:e}),a},print:f,qr({action:t,...a}){y(async()=>{if(!a.active&&(!s||s.disposed))return;let n={...a,openCommand:t,blockGlyphsSafe:e()};s&&!s.disposed?s.set(n):(s=r.states.createState(n),await r.addMessage({type:"component",...i(s)}))})}}}},async close(){$.dispose(),await w,g=!0;try{await r.close()}finally{d.dispose()}if(l)throw Error(`开发界面失败:${t(l)}`,{cause:l})}}}export{r as createRatatuiDevUI};
|
package/dist/session.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! LICENSE: session.js.LICENSE.txt */
|
|
2
|
-
import{dirname as t,join as e,relative as i,resolve as s,sep as r}from"node:path";import{EventEmitter as a}from"node:events";import{existsSync as o,stat as n,unwatchFile as l,watch as h,watchFile as d}from"node:fs";import{lstat as c,open as f,readdir as p,realpath as m,stat as u}from"node:fs/promises";import{Readable as _}from"node:stream";import{type as w}from"node:os";import{fileURLToPath as g}from"node:url";import{callHook as y,runtime as v,dist_ye as b,dist_xe as P,collectHooks as E,log as x,resolvePublicationType as k,pD as S,error_errorMessage as D,isInteractive as W,loadPackage as I}from"./691.js";import{ensureLogin as R}from"./command~1.js";import{uploadDraft as C}from"./draft.js";import*as F from"node:path";let z="files",j="directories",M="files_directories",T={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:z,lstat:!1,depth:0x80000000,alwaysStat:!1,highWaterMark:4096};Object.freeze(T);let A="READDIRP_RECURSIVE_ERROR",N=new Set(["ENOENT","EPERM","EACCES","ELOOP",A]),$=[j,"all",M,z],O=new Set([j,"all",M]),H=new Set(["all",M,z]),U="win32"===process.platform,K=t=>!0,L=t=>{if(void 0===t)return K;if("function"==typeof t)return t;if("string"==typeof t){let e=t.trim();return t=>t.basename===e}if(Array.isArray(t)){let e=t.map(t=>t.trim());return t=>e.some(e=>t.basename===e)}return K};class G extends _{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...T,...t},{root:i,type:r}=e;this._fileFilter=L(e.fileFilter),this._directoryFilter=L(e.directoryFilter);let a=e.lstat?c:u;U?this._stat=t=>a(t,{bigint:!0}):this._stat=a,this._maxDepth=null!=e.depth&&Number.isSafeInteger(e.depth)?e.depth:T.depth,this._wantsDir=!!r&&O.has(r),this._wantsFile=!!r&&H.has(r),this._wantsEverything="all"===r,this._root=s(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:s,depth:r}=e,a=i.splice(0,t).map(t=>this._formatEntry(t,s));for(let e of(await Promise.all(a))){if(!e)continue;if(this.destroyed)return;let i=await this._getEntryType(e);"directory"===i&&this._directoryFilter(e)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(e.fullPath,r+1)),this._wantsDir&&(this.push(e),t--)):("file"===i||this._includeAsFile(e))&&this._fileFilter(e)&&this._wantsFile&&(this.push(e),t--)}}else{let t=this.parents.pop();if(!t){this.push(null);break}if(this.parent=await t,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await p(t,this._rdOptions)}catch(t){this._onError(t)}return{files:i,depth:e,path:t}}async _formatEntry(t,r){let a,o=this._isDirent?t.name:t;try{let n=s(e(r,o));(a={path:i(this._root,n),fullPath:n,basename:o})[this._statsProp]=this._isDirent?t:await this._stat(n)}catch(t){this._onError(t);return}return a}_onError(t){N.has(t.code)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let e=t.fullPath;try{let t=await m(e),i=await c(t);if(i.isFile())return"file";if(i.isDirectory()){let i=t.length;if(e.startsWith(t)&&e.substr(i,1)===r){let i=Error(`Circular symlink detected: "${e}" points to "${t}"`);return i.code=A,this._onError(i)}return"directory"}}catch(t){return this._onError(t),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}let V=()=>{},q=process.platform,B="win32"===q,J="darwin"===q,Q="linux"===q,X="freebsd"===q,Y="OS400"===w(),Z="all",tt="ready",te="add",ti="change",ts="addDir",tr="unlink",ta="unlinkDir",to="raw",tn="error",tl={lstat:c,stat:u},th="listeners",td="errHandlers",tc="rawEmitters",tf=[th,td,tc],tp=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),tm=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},tu=(t,e,i)=>{let s=t[e];s instanceof Set||(t[e]=s=new Set([s])),s.add(i)},t_=(t,e,i)=>{let s=t[e];s instanceof Set?s.delete(i):s===i&&delete t[e]},tw=t=>t instanceof Set?0===t.size:!t,tg=new Map;function ty(t,e,i,s,r){try{return h(t,{persistent:e.persistent},(e,s)=>{i(t),r(e,s,{watchedPath:t}),s&&t!==s&&tv(F.resolve(t,s),th,F.join(t,s))})}catch(t){s(t);return}}let tv=(t,e,i,s,r)=>{let a=tg.get(t);a&&tm(a[e],t=>{t(i,s,r)})},tb=new Map;class tP{fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i,s=this.fsw.options,r=F.dirname(t),a=F.basename(t);this.fsw._getWatchedDir(r).add(a);let o=F.resolve(t),n={persistent:s.persistent};if(e||(e=V),s.usePolling)n.interval=s.interval!==s.binaryInterval&&tp.has(F.extname(a).slice(1).toLowerCase())?s.binaryInterval:s.interval,i=((t,e,i,s)=>{let{listener:r,rawEmitter:a}=s,o=tb.get(e),n=o&&o.options;return n&&(n.persistent<i.persistent||n.interval>i.interval)&&(l(e),o=void 0),o?(tu(o,th,r),tu(o,tc,a)):(o={listeners:r,rawEmitters:a,options:i,watcher:d(e,i,(i,s)=>{tm(o.rawEmitters,t=>{t(ti,e,{curr:i,prev:s})});let r=i.mtimeMs;(i.size!==s.size||r>s.mtimeMs||0===r)&&tm(o.listeners,e=>e(t,i))})},tb.set(e,o)),()=>{t_(o,th,r),t_(o,tc,a),tw(o.listeners)&&(tb.delete(e),l(e),o.options=o.watcher=void 0,Object.freeze(o))}})(t,o,n,{listener:e,rawEmitter:this.fsw._emitRaw});else i=((t,e,i,s)=>{let r,{listener:a,errHandler:o,rawEmitter:n}=s,l=tg.get(e);if(!i.persistent){if(!(r=ty(t,i,a,o,n)))return;return r.close.bind(r)}if(l)tu(l,th,a),tu(l,td,o),tu(l,tc,n);else{if(!(r=ty(t,i,tv.bind(null,e,th),o,tv.bind(null,e,tc))))return;r.on(tn,async i=>{let s=tv.bind(null,e,td);if(l&&(l.watcherUnusable=!0),B&&"EPERM"===i.code)try{let e=await f(t,"r");await e.close(),s(i)}catch(t){}else s(i)}),l={listeners:a,errHandlers:o,rawEmitters:n,watcher:r},tg.set(e,l)}return()=>{if(t_(l,th,a),t_(l,td,o),t_(l,tc,n),tw(l.listeners)){let t;l.watcher.close(),tg.delete(e),tf.forEach((t=l,e=>{let i=t[e];i instanceof Set?i.clear():delete t[e]})),l.watcher=void 0,Object.freeze(l)}}})(t,o,n,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return i}_handleFile(t,e,i){if(this.fsw.closed)return;let s=F.dirname(t),r=F.basename(t),a=this.fsw._getWatchedDir(s),o=e;if(a.has(r))return;let n=async(e,i)=>{if(this.fsw._throttle("watch",t,5))if(i&&0!==i.mtimeMs){if(a.has(r)){let e=i.atimeMs,s=i.mtimeMs;(!e||e<=s||s!==o.mtimeMs)&&this.fsw._emit(ti,t,i),o=i}}else try{let i=await u(t);if(this.fsw.closed)return;let s=i.atimeMs,r=i.mtimeMs;if((!s||s<=r||r!==o.mtimeMs)&&this.fsw._emit(ti,t,i),(J||Q||X)&&o.ino!==i.ino){this.fsw._closeFile(e),o=i;let s=this._watchWithNodeFs(t,n);s&&this.fsw._addPathCloser(e,s)}else o=i}catch(t){this.fsw._remove(s,r)}},l=this._watchWithNodeFs(t,n);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(te,t,0))return;this.fsw._emit(te,t,e)}return l}async _handleSymlink(t,e,i,s){if(this.fsw.closed)return;let r=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){let e;this.fsw._incrReadyCount();try{e=await m(i)}catch(t){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;return a.has(s)?this.fsw._symlinkPaths.get(r)!==e&&(this.fsw._symlinkPaths.set(r,e),this.fsw._emit(ti,i,t.stats)):(a.add(s),this.fsw._symlinkPaths.set(r,e),this.fsw._emit(te,i,t.stats)),this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(r))return!0;this.fsw._symlinkPaths.set(r,!0)}_handleRead(t,e,i,s,r,a,o){t=F.join(t,"");let n=s?`${t}:${s}`:t;if(!(o=this.fsw._throttle("readdir",n,1e3)))return;let l=this.fsw._getWatchedDir(i.path),h=new Set,d=this.fsw._readdirp(t,{fileFilter:t=>i.filterPath(t),directoryFilter:t=>i.filterDir(t)});if(d)return d.on("data",async o=>{if(this.fsw.closed){d=void 0;return}let n=o.path,c=F.join(t,n);if(h.add(n),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,t,c,n))){if(this.fsw.closed){d=void 0;return}n!==s&&(s||l.has(n))||(this.fsw._incrReadyCount(),c=F.join(r,F.relative(r,c)),this._addToNodeFs(c,e,i,a+1))}}).on(tn,this._boundHandleError),new Promise((e,n)=>{if(!d)return n();d.once("end",()=>{if(this.fsw.closed){d=void 0;return}let n=!!o&&o.clear();e(void 0),l.getChildren().filter(e=>e!==t&&!h.has(e)).forEach(e=>{this.fsw._remove(t,e)}),d=void 0,n&&this._handleRead(t,!1,i,s,r,a,o)})})}async _handleDir(t,e,i,s,r,a,o){let n,l,h=this.fsw._getWatchedDir(F.dirname(t)),d=h.has(F.basename(t));i&&this.fsw.options.ignoreInitial||r||d||this.fsw._emit(ts,t,e),h.add(F.basename(t)),this.fsw._getWatchedDir(t);let c=this.fsw.options.depth;if((null==c||s<=c)&&!this.fsw._symlinkPaths.has(o)){if(!r&&(await this._handleRead(t,i,a,r,t,s,n),this.fsw.closed))return;l=this._watchWithNodeFs(t,(e,i)=>{i&&0===i.mtimeMs||this._handleRead(e,!1,a,r,t,s,n)})}return l}async _addToNodeFs(t,e,i,s,r){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);i&&(o.filterPath=t=>i.filterPath(t),o.filterDir=t=>i.filterDir(t));try{let i,n=await tl[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let l=this.fsw.options.followSymlinks;if(n.isDirectory()){let a=F.resolve(t),h=l?await m(t):t;if(this.fsw.closed||(i=await this._handleDir(o.watchPath,n,e,s,r,o,h),this.fsw.closed))return;a!==h&&void 0!==h&&this.fsw._symlinkPaths.set(a,h)}else if(n.isSymbolicLink()){let r=l?await m(t):t;if(this.fsw.closed)return;let a=F.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(te,o.watchPath,n),i=await this._handleDir(a,n,e,s,t,o,r),this.fsw.closed)return;void 0!==r&&this.fsw._symlinkPaths.set(F.resolve(t),r)}else i=this._handleFile(o.watchPath,n,e);return a(),i&&this.fsw._addPathCloser(t,i),!1}catch(e){if(this.fsw._handleError(e))return a(),t}}}let tE=/\\/g,tx=/\/\//g,tk=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,tS=/^\.[/\\]/;function tD(t){return Array.isArray(t)?t:[t]}let tW=t=>"object"==typeof t&&null!==t&&!(t instanceof RegExp);function tI(t,e,i){let s=function(t){if("string"!=typeof t)throw Error("string expected");t=(t=F.normalize(t)).replace(/\\/g,"/");let e=!1;return t.startsWith("//")&&(e=!0),t=t.replace(tx,"/"),e&&(t="/"+t),t}(e);for(let e=0;e<t.length;e++)if((0,t[e])(s,i))return!0;return!1}let tR=t=>{let e=tD(t).flat();if(!e.every(t=>"string"==typeof t))throw TypeError(`Non-string provided as watch path: ${e}`);return e.map(tF)},tC=t=>{let e=t.replace(tE,"/"),i=!1;return e.startsWith("//")&&(i=!0),e=e.replace(tx,"/"),i&&(e="/"+e),e},tF=t=>tC(F.normalize(tC(t))),tz=(t="")=>e=>"string"==typeof e?tF(F.isAbsolute(e)?e:F.join(t,e)):e,tj=Object.freeze(new Set);class tM{path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&"."!==t&&".."!==t&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await p(i)}catch(t){this._removeWatcher&&this._removeWatcher(F.dirname(i),F.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=V,this.items=tj,Object.freeze(this)}}class tT{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,i){this.fsw=i;let s=t;this.path=t=t.replace(tS,""),this.watchPath=s,this.fullWatchPath=F.resolve(s),this.dirParts=[],this.dirParts.forEach(t=>{t.length>1&&t.pop()}),this.followSymlinks=e,this.statMethod=e?"stat":"lstat"}entryPath(t){return F.join(this.watchPath,F.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}}class tA extends a{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tD(t.ignored):tD([]),awaitWriteFinish:!0===e?i:"object"==typeof e&&{...i,...e}};Y&&(s.usePolling=!0),void 0===s.atomic&&(s.atomic=!s.usePolling);let r=process.env.CHOKIDAR_USEPOLLING;if(void 0!==r){let t=r.toLowerCase();"false"===t||"0"===t?s.usePolling=!1:"true"===t||"1"===t?s.usePolling=!0:s.usePolling=!!t}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{++o>=this._readyCount&&(this._emitReady=V,this._readyEmitted=!0,process.nextTick(()=>this.emit(tt)))},this._emitRaw=(...t)=>this.emit(to,...t),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new tP(this),Object.freeze(s)}_addIgnoredPath(t){if(tW(t)){for(let e of this._ignoredPaths)if(tW(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),"string"==typeof t)for(let e of this._ignoredPaths)tW(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let r=tR(t);return s&&(r=r.map(t=>F.isAbsolute(t)?t:F.join(s,t))),r.forEach(t=>{this._removeIgnoredPath(t)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async t=>{let s=await this._nodeFsHandler._addToNodeFs(t,!i,void 0,0,e);return s&&this._emitReady(),s})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(F.dirname(t),F.basename(e||t))})}),this}unwatch(t){if(this.closed)return this;let e=tR(t),{cwd:i}=this.options;return e.forEach(t=>{F.isAbsolute(t)||this._closers.has(t)||(i&&(t=F.join(i,t)),t=F.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(e=>{let i=e();i instanceof Promise&&t.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{t[(this.options.cwd?F.relative(this.options.cwd,i):i)||"."]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==tn&&this.emit(Z,t,...e)}async _emit(t,e,i){let s;if(this.closed)return;let r=this.options;B&&(e=F.normalize(e)),r.cwd&&(e=F.relative(r.cwd,e));let a=[e];null!=i&&a.push(i);let o=r.awaitWriteFinish;if(o&&(s=this._pendingWrites.get(e)))return s.lastChange=new Date,this;if(r.atomic){if(t===tr)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((t,e)=>{this.emit(...t),this.emit(Z,...t),this._pendingUnlinks.delete(e)})},"number"==typeof r.atomic?r.atomic:100),this;t===te&&this._pendingUnlinks.has(e)&&(t=ti,this._pendingUnlinks.delete(e))}if(o&&(t===te||t===ti)&&this._readyEmitted){let i=(e,i)=>{e?(t=tn,a[0]=e,this.emitWithAll(t,a)):i&&(a.length>1?a[1]=i:a.push(i),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,o.stabilityThreshold,t,i),this}if(t===ti&&!this._throttle(ti,e,50))return this;if(r.alwaysStat&&void 0===i&&(t===te||t===ts||t===ti)){let t,i=r.cwd?F.join(r.cwd,e):e;try{t=await u(i)}catch(t){}if(!t||this.closed)return;a.push(t)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&"ENOENT"!==e&&"ENOTDIR"!==e&&(!this.options.ignorePermissionErrors||"EPERM"!==e&&"EACCES"!==e)&&this.emit(tn,t),t||this.closed}_throttle(t,e,i){let s;this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw Error("invalid throttle");let a=r.get(e);if(a)return a.count++,!1;let o=()=>{let t=r.get(e),i=t?t.count:0;return r.delete(e),clearTimeout(s),t&&clearTimeout(t.timeoutObject),i},n={timeoutObject:s=setTimeout(o,i),clear:o,count:0};return r.set(e,n),n}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,s){let r,a=this.options.awaitWriteFinish;if("object"!=typeof a)return;let o=a.pollInterval,l=t;this.options.cwd&&!F.isAbsolute(t)&&(l=F.join(this.options.cwd,t));let h=new Date,d=this._pendingWrites;d.has(t)||(d.set(t,{lastChange:h,cancelWait:()=>(d.delete(t),clearTimeout(r),i)}),r=setTimeout(function i(a){n(l,(n,l)=>{if(n||!d.has(t)){n&&"ENOENT"!==n.code&&s(n);return}let h=Number(new Date);a&&l.size!==a.size&&(d.get(t).lastChange=h),h-d.get(t).lastChange>=e?(d.delete(t),s(void 0,l)):r=setTimeout(i,o,l)})},o))}_isIgnored(t,e){if(this.options.atomic&&tk.test(t))return!0;if(!this._userIgnored){let{cwd:t}=this.options,e=(this.options.ignored||[]).map(tz(t)),i=[...[...this._ignoredPaths].map(tz(t)),...e];this._userIgnored=function(t,e){if(null==t)throw TypeError("anymatch: specify first argument");let i=tD(t).map(t=>"function"==typeof t?t:"string"==typeof t?e=>t===e:t instanceof RegExp?e=>t.test(e):"object"==typeof t&&null!==t?e=>{if(t.path===e)return!0;if(t.recursive){let i=F.relative(t.path,e);return!!i&&!i.startsWith("..")&&!F.isAbsolute(i)}return!1}:()=>!1);return null==e?(t,e)=>tI(i,t,e):tI(i,e)}(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tT(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=F.resolve(t);return this._watched.has(e)||this._watched.set(e,new tM(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return!!this.options.ignorePermissionErrors||!!(256&Number(t.mode))}_remove(t,e,i){let s=F.join(t,e),r=F.resolve(s);if(i=null!=i?i:this._watched.has(s)||this._watched.has(r),!this._throttle("remove",s,100))return;i||1!==this._watched.size||this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(t=>this._remove(s,t));let a=this._getWatchedDir(t),o=a.has(e);a.remove(e),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let n=s;if(this.options.cwd&&(n=F.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(n)&&this._pendingWrites.get(n).cancelWait()===te)return;this._watched.delete(s),this._watched.delete(r);let l=i?ta:tr;o&&!this._isIgnored(s)&&this._emit(l,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=F.dirname(t);this._getWatchedDir(e).remove(F.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(t=>t()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i=function(t,e={}){let i=e.entryType||e.type;if("both"===i&&(i=M),i&&(e.type=i),t){if("string"!=typeof t)throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(i&&!$.includes(i))throw Error(`readdirp: Invalid type passed. Use one of ${$.join(", ")}`)}else throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new G(e)}(t,{type:Z,alwaysStat:!0,lstat:!0,...e,depth:0});return this._streams.add(i),i.once("close",()=>{i=void 0}),i.once("end",()=>{i&&(this._streams.delete(i),i=void 0)}),i}}function tN(){return{interactive:!1,addTarget(t,e){let i={status:"pending",message:"正在启动"};return{log:{info:e=>x.info(`[${t}] ${e}`),success:e=>x.success(`[${t}] ${e}`),warn:e=>x.warn(`[${t}] ${e}`),error:e=>x.error(`[${t}] ${e}`)},ui:{update(t){let s={...i};for(let[r,a]of(Object.assign(i,t),(i.message!==s.message||i.status!==s.status)&&(0,({pending:x.info,success:x.success,error:x.error})[i.status])(`${e}:${i.message}`),Object.entries(i.links??{})))s.links?.[r]!==a&&x.info(`${r}:${a}`)},select:async()=>void 0,print:t=>console.log(t)}}},close(){}}}async function t$(i){if(W())try{let{TUIManager:s,getNativePackageName:r}=await import("./dist.js"),{createRatatuiDevUI:a}=await import("./ratatui-ui.js"),n=e(t(g(import.meta.url)),"tui");if(!o(n)){let e=await I({name:r(),version:v.version,title:"交互界面"},".",i.signal,{interactive:!0,log:x});n=t(g(e))}i.signal.throwIfAborted();let l=new s({nativeDirectory:n});try{return await a(l,i)}catch(t){throw await l.close(),t}}catch(t){i.signal.aborted||x.warn(`无法启动交互界面,改用日志模式:${D(t)}`)}return tN()}async function tO(t,e,r){let a,o=new AbortController,n=Promise.withResolvers(),l=(t=!1)=>{t&&(process.exitCode=130),o.abort(),n.resolve()},h={project:t,options:e,signal:o.signal},d=await tU(h,r.devTargets);if(!d)return;if(await R(W()),t.plugin.id)await k(t);else if(d.some(({target:t})=>"app"===t.name)){x.info("未配置插件 ID,正在上传项目并创建平台草稿…");try{await C({project:t,options:{}},await E(r.exclude,{project:t},"draft"))}catch(t){throw Error(`插件初始化失败,未启动调试:${D(t)}`,{cause:t})}}let c=await E(r.exclude,{project:t},"dev"),f=()=>l(!0),p=()=>{process.exitCode=143,l()};process.on("SIGINT",f),process.on("SIGTERM",p);let m=d.some(({target:t})=>"app"===t.name)?await t$({signal:o.signal,onExit:l,projectName:t.plugin.name}):tN(),u=[],_=async t=>{for(let e of t.disposers.splice(0).reverse())try{await e()}catch(e){t.ctx.log.warn(`清理失败:${D(e)}`)}},w=(t,e)=>{o.signal.aborted||(t.ctx.ui.update({status:"error",message:"运行失败"}),t.ctx.log.error(D(e)))},g=t=>{t.changed.size&&t.ready&&!t.running&&!o.signal.aborted&&(t.running=(async()=>{try{for(;t.changed.size&&!o.signal.aborted;){let e=[...t.changed];t.changed.clear();try{await t.listener?.(e)}catch(e){w(t,e)}}}finally{t.running=void 0}})())};try{for(let e of d){let{name:r,title:a,label:o=a,watch:n=[]}=e.target,l={entry:e,paths:n.map(e=>i(t.root,s(t.root,e))),ready:!1,changed:new Set,disposers:[],ctx:{...h,...m.addTarget(r,o),interactive:m.interactive,packDevelopment:()=>t.pack({exclude:c}),onDispose:t=>l.disposers.push(t),onFilesChanged:t=>{l.listener=t}}};u.push(l)}let e=u.flatMap(({paths:t})=>t),r=function(t,e={}){let i=new tA(e);return i.add(t),i}(t.root,{ignoreInitial:!0,followSymlinks:!1,ignored:s=>{let r=i(t.root,s);return!!r&&!e.some(t=>tH(r,t)||tH(t,r))}});r.on("all",(e,s)=>{if(o.signal.aborted)return;let r=i(t.root,s);for(let t of u)t.paths.some(t=>tH(r,t))&&t.changed.add(r);clearTimeout(a),a=setTimeout(()=>u.forEach(g),400)}),r.on("error",n.reject);let l=Promise.all(u.map(async t=>{try{o.signal.throwIfAborted(),await t.entry.target.start(t.ctx),o.signal.throwIfAborted(),t.ready=!0,g(t)}catch(e){t.changed.clear(),w(t,e),await _(t)}}));try{await n.promise}finally{o.abort(),clearTimeout(a);try{await r.close()}finally{await l,await Promise.all(u.map(t=>t.running))}}}catch(t){if(t!==o.signal.reason&&!(t instanceof Error&&"AbortError"===t.name))throw t}finally{for(let t of(o.abort(),u.toReversed()))await _(t);try{await m.close()}finally{process.off("SIGINT",f),process.off("SIGTERM",p)}}}function tH(t,e){return!e||t===e||t.startsWith(`${e}${r}`)}async function tU(t,e){let{options:i}=t,s=[];for(let r of e){let{pluginName:e,target:a}=r,o=!a.appliesTo||await y({pluginName:e,callback:a.appliesTo},t);if(!o&&r.attribute&&i[r.attribute])throw Error(`[${e}] 当前项目不支持:${a.title}`);o&&s.push(r)}let r=s.filter(({attribute:t})=>t),a=({attribute:t})=>!!(t&&i[t]),o=new Set;if(r.length&&!i.plugin&&!r.some(a)&&W())for(let{target:t}of r){let e=await b({message:`是否同时启动${t.title}?`,initialValue:!1});if(S(e)){P("已取消调试。"),process.exitCode=130;return}e&&o.add(t.name)}let n=s.filter(t=>!t.attribute||a(t)||o.has(t.target.name));return n.some(({target:t})=>"app"===t.name)?n.filter(({target:t})=>"platform"!==t.name):n}export{tO as runSession};
|
|
2
|
+
import{dirname as t,join as e,relative as i,resolve as s,sep as r}from"node:path";import{EventEmitter as a}from"node:events";import{existsSync as o,stat as n,unwatchFile as l,watch as h,watchFile as d}from"node:fs";import{lstat as c,open as f,readdir as p,realpath as m,stat as u}from"node:fs/promises";import{Readable as _}from"node:stream";import{type as w}from"node:os";import{fileURLToPath as g}from"node:url";import{callHook as y,runtime as v,dist_ye as b,dist_xe as P,collectHooks as E,log as x,resolvePublicationType as k,pD as S,error_errorMessage as W,isInteractive as D,loadPackage as I}from"./691.js";import{ensureLogin as R}from"./command~1.js";import{uploadDraft as C}from"./draft.js";import*as F from"node:path";let j="files",z="directories",M="files_directories",T={root:".",fileFilter:t=>!0,directoryFilter:t=>!0,type:j,lstat:!1,depth:0x80000000,alwaysStat:!1,highWaterMark:4096};Object.freeze(T);let A="READDIRP_RECURSIVE_ERROR",$=new Set(["ENOENT","EPERM","EACCES","ELOOP",A]),N=[z,"all",M,j],O=new Set([z,"all",M]),H=new Set(["all",M,j]),U="win32"===process.platform,K=t=>!0,L=t=>{if(void 0===t)return K;if("function"==typeof t)return t;if("string"==typeof t){let e=t.trim();return t=>t.basename===e}if(Array.isArray(t)){let e=t.map(t=>t.trim());return t=>e.some(e=>t.basename===e)}return K};class G extends _{parents;reading;parent;_stat;_maxDepth;_wantsDir;_wantsFile;_wantsEverything;_root;_isDirent;_statsProp;_rdOptions;_fileFilter;_directoryFilter;constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...T,...t},{root:i,type:r}=e;this._fileFilter=L(e.fileFilter),this._directoryFilter=L(e.directoryFilter);let a=e.lstat?c:u;U?this._stat=t=>a(t,{bigint:!0}):this._stat=a,this._maxDepth=null!=e.depth&&Number.isSafeInteger(e.depth)?e.depth:T.depth,this._wantsDir=!!r&&O.has(r),this._wantsFile=!!r&&H.has(r),this._wantsEverything="all"===r,this._root=s(i),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(i,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,i=e&&e.files;if(i&&i.length>0){let{path:s,depth:r}=e,a=i.splice(0,t).map(t=>this._formatEntry(t,s));for(let e of(await Promise.all(a))){if(!e)continue;if(this.destroyed)return;let i=await this._getEntryType(e);"directory"===i&&this._directoryFilter(e)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(e.fullPath,r+1)),this._wantsDir&&(this.push(e),t--)):("file"===i||this._includeAsFile(e))&&this._fileFilter(e)&&this._wantsFile&&(this.push(e),t--)}}else{let t=this.parents.pop();if(!t){this.push(null);break}if(this.parent=await t,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(t,e){let i;try{i=await p(t,this._rdOptions)}catch(t){this._onError(t)}return{files:i,depth:e,path:t}}async _formatEntry(t,r){let a,o=this._isDirent?t.name:t;try{let n=s(e(r,o));(a={path:i(this._root,n),fullPath:n,basename:o})[this._statsProp]=this._isDirent?t:await this._stat(n)}catch(t){this._onError(t);return}return a}_onError(t){$.has(t.code)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let e=t.fullPath;try{let t=await m(e),i=await c(t);if(i.isFile())return"file";if(i.isDirectory()){let i=t.length;if(e.startsWith(t)&&e.substr(i,1)===r){let i=Error(`Circular symlink detected: "${e}" points to "${t}"`);return i.code=A,this._onError(i)}return"directory"}}catch(t){return this._onError(t),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}let V=()=>{},q=process.platform,B="win32"===q,J="darwin"===q,Q="linux"===q,X="freebsd"===q,Y="OS400"===w(),Z="all",tt="ready",te="add",ti="change",ts="addDir",tr="unlink",ta="unlinkDir",to="raw",tn="error",tl={lstat:c,stat:u},th="listeners",td="errHandlers",tc="rawEmitters",tf=[th,td,tc],tp=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),tm=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},tu=(t,e,i)=>{let s=t[e];s instanceof Set||(t[e]=s=new Set([s])),s.add(i)},t_=(t,e,i)=>{let s=t[e];s instanceof Set?s.delete(i):s===i&&delete t[e]},tw=t=>t instanceof Set?0===t.size:!t,tg=new Map;function ty(t,e,i,s,r){try{return h(t,{persistent:e.persistent},(e,s)=>{i(t),r(e,s,{watchedPath:t}),s&&t!==s&&tv(F.resolve(t,s),th,F.join(t,s))})}catch(t){s(t);return}}let tv=(t,e,i,s,r)=>{let a=tg.get(t);a&&tm(a[e],t=>{t(i,s,r)})},tb=new Map;class tP{fsw;_boundHandleError;constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let i,s=this.fsw.options,r=F.dirname(t),a=F.basename(t);this.fsw._getWatchedDir(r).add(a);let o=F.resolve(t),n={persistent:s.persistent};if(e||(e=V),s.usePolling)n.interval=s.interval!==s.binaryInterval&&tp.has(F.extname(a).slice(1).toLowerCase())?s.binaryInterval:s.interval,i=((t,e,i,s)=>{let{listener:r,rawEmitter:a}=s,o=tb.get(e),n=o&&o.options;return n&&(n.persistent<i.persistent||n.interval>i.interval)&&(l(e),o=void 0),o?(tu(o,th,r),tu(o,tc,a)):(o={listeners:r,rawEmitters:a,options:i,watcher:d(e,i,(i,s)=>{tm(o.rawEmitters,t=>{t(ti,e,{curr:i,prev:s})});let r=i.mtimeMs;(i.size!==s.size||r>s.mtimeMs||0===r)&&tm(o.listeners,e=>e(t,i))})},tb.set(e,o)),()=>{t_(o,th,r),t_(o,tc,a),tw(o.listeners)&&(tb.delete(e),l(e),o.options=o.watcher=void 0,Object.freeze(o))}})(t,o,n,{listener:e,rawEmitter:this.fsw._emitRaw});else i=((t,e,i,s)=>{let r,{listener:a,errHandler:o,rawEmitter:n}=s,l=tg.get(e);if(!i.persistent){if(!(r=ty(t,i,a,o,n)))return;return r.close.bind(r)}if(l)tu(l,th,a),tu(l,td,o),tu(l,tc,n);else{if(!(r=ty(t,i,tv.bind(null,e,th),o,tv.bind(null,e,tc))))return;r.on(tn,async i=>{let s=tv.bind(null,e,td);if(l&&(l.watcherUnusable=!0),B&&"EPERM"===i.code)try{let e=await f(t,"r");await e.close(),s(i)}catch(t){}else s(i)}),l={listeners:a,errHandlers:o,rawEmitters:n,watcher:r},tg.set(e,l)}return()=>{if(t_(l,th,a),t_(l,td,o),t_(l,tc,n),tw(l.listeners)){let t;l.watcher.close(),tg.delete(e),tf.forEach((t=l,e=>{let i=t[e];i instanceof Set?i.clear():delete t[e]})),l.watcher=void 0,Object.freeze(l)}}})(t,o,n,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return i}_handleFile(t,e,i){if(this.fsw.closed)return;let s=F.dirname(t),r=F.basename(t),a=this.fsw._getWatchedDir(s),o=e;if(a.has(r))return;let n=async(e,i)=>{if(this.fsw._throttle("watch",t,5))if(i&&0!==i.mtimeMs){if(a.has(r)){let e=i.atimeMs,s=i.mtimeMs;(!e||e<=s||s!==o.mtimeMs)&&this.fsw._emit(ti,t,i),o=i}}else try{let i=await u(t);if(this.fsw.closed)return;let s=i.atimeMs,r=i.mtimeMs;if((!s||s<=r||r!==o.mtimeMs)&&this.fsw._emit(ti,t,i),(J||Q||X)&&o.ino!==i.ino){this.fsw._closeFile(e),o=i;let s=this._watchWithNodeFs(t,n);s&&this.fsw._addPathCloser(e,s)}else o=i}catch(t){this.fsw._remove(s,r)}},l=this._watchWithNodeFs(t,n);if(!(i&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(te,t,0))return;this.fsw._emit(te,t,e)}return l}async _handleSymlink(t,e,i,s){if(this.fsw.closed)return;let r=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){let e;this.fsw._incrReadyCount();try{e=await m(i)}catch(t){return this.fsw._emitReady(),!0}if(this.fsw.closed)return;return a.has(s)?this.fsw._symlinkPaths.get(r)!==e&&(this.fsw._symlinkPaths.set(r,e),this.fsw._emit(ti,i,t.stats)):(a.add(s),this.fsw._symlinkPaths.set(r,e),this.fsw._emit(te,i,t.stats)),this.fsw._emitReady(),!0}if(this.fsw._symlinkPaths.has(r))return!0;this.fsw._symlinkPaths.set(r,!0)}_handleRead(t,e,i,s,r,a,o){t=F.join(t,"");let n=s?`${t}:${s}`:t;if(!(o=this.fsw._throttle("readdir",n,1e3)))return;let l=this.fsw._getWatchedDir(i.path),h=new Set,d=this.fsw._readdirp(t,{fileFilter:t=>i.filterPath(t),directoryFilter:t=>i.filterDir(t)});if(d)return d.on("data",async o=>{if(this.fsw.closed){d=void 0;return}let n=o.path,c=F.join(t,n);if(h.add(n),!(o.stats.isSymbolicLink()&&await this._handleSymlink(o,t,c,n))){if(this.fsw.closed){d=void 0;return}n!==s&&(s||l.has(n))||(this.fsw._incrReadyCount(),c=F.join(r,F.relative(r,c)),this._addToNodeFs(c,e,i,a+1))}}).on(tn,this._boundHandleError),new Promise((e,n)=>{if(!d)return n();d.once("end",()=>{if(this.fsw.closed){d=void 0;return}let n=!!o&&o.clear();e(void 0),l.getChildren().filter(e=>e!==t&&!h.has(e)).forEach(e=>{this.fsw._remove(t,e)}),d=void 0,n&&this._handleRead(t,!1,i,s,r,a,o)})})}async _handleDir(t,e,i,s,r,a,o){let n,l,h=this.fsw._getWatchedDir(F.dirname(t)),d=h.has(F.basename(t));i&&this.fsw.options.ignoreInitial||r||d||this.fsw._emit(ts,t,e),h.add(F.basename(t)),this.fsw._getWatchedDir(t);let c=this.fsw.options.depth;if((null==c||s<=c)&&!this.fsw._symlinkPaths.has(o)){if(!r&&(await this._handleRead(t,i,a,r,t,s,n),this.fsw.closed))return;l=this._watchWithNodeFs(t,(e,i)=>{i&&0===i.mtimeMs||this._handleRead(e,!1,a,r,t,s,n)})}return l}async _addToNodeFs(t,e,i,s,r){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);i&&(o.filterPath=t=>i.filterPath(t),o.filterDir=t=>i.filterDir(t));try{let i,n=await tl[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,n))return a(),!1;let l=this.fsw.options.followSymlinks;if(n.isDirectory()){let a=F.resolve(t),h=l?await m(t):t;if(this.fsw.closed||(i=await this._handleDir(o.watchPath,n,e,s,r,o,h),this.fsw.closed))return;a!==h&&void 0!==h&&this.fsw._symlinkPaths.set(a,h)}else if(n.isSymbolicLink()){let r=l?await m(t):t;if(this.fsw.closed)return;let a=F.dirname(o.watchPath);if(this.fsw._getWatchedDir(a).add(o.watchPath),this.fsw._emit(te,o.watchPath,n),i=await this._handleDir(a,n,e,s,t,o,r),this.fsw.closed)return;void 0!==r&&this.fsw._symlinkPaths.set(F.resolve(t),r)}else i=this._handleFile(o.watchPath,n,e);return a(),i&&this.fsw._addPathCloser(t,i),!1}catch(e){if(this.fsw._handleError(e))return a(),t}}}let tE=/\\/g,tx=/\/\//g,tk=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,tS=/^\.[/\\]/;function tW(t){return Array.isArray(t)?t:[t]}let tD=t=>"object"==typeof t&&null!==t&&!(t instanceof RegExp);function tI(t,e,i){let s=function(t){if("string"!=typeof t)throw Error("string expected");t=(t=F.normalize(t)).replace(/\\/g,"/");let e=!1;return t.startsWith("//")&&(e=!0),t=t.replace(tx,"/"),e&&(t="/"+t),t}(e);for(let e=0;e<t.length;e++)if((0,t[e])(s,i))return!0;return!1}let tR=t=>{let e=tW(t).flat();if(!e.every(t=>"string"==typeof t))throw TypeError(`Non-string provided as watch path: ${e}`);return e.map(tF)},tC=t=>{let e=t.replace(tE,"/"),i=!1;return e.startsWith("//")&&(i=!0),e=e.replace(tx,"/"),i&&(e="/"+e),e},tF=t=>tC(F.normalize(tC(t))),tj=(t="")=>e=>"string"==typeof e?tF(F.isAbsolute(e)?e:F.join(t,e)):e,tz=Object.freeze(new Set);class tM{path;_removeWatcher;items;constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&"."!==t&&".."!==t&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let i=this.path;try{await p(i)}catch(t){this._removeWatcher&&this._removeWatcher(F.dirname(i),F.basename(i))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=V,this.items=tz,Object.freeze(this)}}class tT{fsw;path;watchPath;fullWatchPath;dirParts;followSymlinks;statMethod;constructor(t,e,i){this.fsw=i;let s=t;this.path=t=t.replace(tS,""),this.watchPath=s,this.fullWatchPath=F.resolve(s),this.dirParts=[],this.dirParts.forEach(t=>{t.length>1&&t.pop()}),this.followSymlinks=e,this.statMethod=e?"stat":"lstat"}entryPath(t){return F.join(this.watchPath,F.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let i=this.entryPath(t);return this.fsw._isntIgnored(i,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}}class tA extends a{closed;options;_closers;_ignoredPaths;_throttled;_streams;_symlinkPaths;_watched;_pendingWrites;_pendingUnlinks;_readyCount;_emitReady;_closePromise;_userIgnored;_readyEmitted;_emitRaw;_boundRemove;_nodeFsHandler;constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,i={stabilityThreshold:2e3,pollInterval:100},s={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?tW(t.ignored):tW([]),awaitWriteFinish:!0===e?i:"object"==typeof e&&{...i,...e}};Y&&(s.usePolling=!0),void 0===s.atomic&&(s.atomic=!s.usePolling);let r=process.env.CHOKIDAR_USEPOLLING;if(void 0!==r){let t=r.toLowerCase();"false"===t||"0"===t?s.usePolling=!1:"true"===t||"1"===t?s.usePolling=!0:s.usePolling=!!t}let a=process.env.CHOKIDAR_INTERVAL;a&&(s.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{++o>=this._readyCount&&(this._emitReady=V,this._readyEmitted=!0,process.nextTick(()=>this.emit(tt)))},this._emitRaw=(...t)=>this.emit(to,...t),this._boundRemove=this._remove.bind(this),this.options=s,this._nodeFsHandler=new tP(this),Object.freeze(s)}_addIgnoredPath(t){if(tD(t)){for(let e of this._ignoredPaths)if(tD(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),"string"==typeof t)for(let e of this._ignoredPaths)tD(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,i){let{cwd:s}=this.options;this.closed=!1,this._closePromise=void 0;let r=tR(t);return s&&(r=r.map(t=>F.isAbsolute(t)?t:F.join(s,t))),r.forEach(t=>{this._removeIgnoredPath(t)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async t=>{let s=await this._nodeFsHandler._addToNodeFs(t,!i,void 0,0,e);return s&&this._emitReady(),s})).then(t=>{this.closed||t.forEach(t=>{t&&this.add(F.dirname(t),F.basename(e||t))})}),this}unwatch(t){if(this.closed)return this;let e=tR(t),{cwd:i}=this.options;return e.forEach(t=>{F.isAbsolute(t)||this._closers.has(t)||(i&&(t=F.join(i,t)),t=F.resolve(t)),this._closePath(t),this._addIgnoredPath(t),this._watched.has(t)&&this._addIgnoredPath({path:t,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(e=>{let i=e();i instanceof Promise&&t.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>void 0):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,i)=>{t[(this.options.cwd?F.relative(this.options.cwd,i):i)||"."]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==tn&&this.emit(Z,t,...e)}async _emit(t,e,i){let s;if(this.closed)return;let r=this.options;B&&(e=F.normalize(e)),r.cwd&&(e=F.relative(r.cwd,e));let a=[e];null!=i&&a.push(i);let o=r.awaitWriteFinish;if(o&&(s=this._pendingWrites.get(e)))return s.lastChange=new Date,this;if(r.atomic){if(t===tr)return this._pendingUnlinks.set(e,[t,...a]),setTimeout(()=>{this._pendingUnlinks.forEach((t,e)=>{this.emit(...t),this.emit(Z,...t),this._pendingUnlinks.delete(e)})},"number"==typeof r.atomic?r.atomic:100),this;t===te&&this._pendingUnlinks.has(e)&&(t=ti,this._pendingUnlinks.delete(e))}if(o&&(t===te||t===ti)&&this._readyEmitted){let i=(e,i)=>{e?(t=tn,a[0]=e,this.emitWithAll(t,a)):i&&(a.length>1?a[1]=i:a.push(i),this.emitWithAll(t,a))};return this._awaitWriteFinish(e,o.stabilityThreshold,t,i),this}if(t===ti&&!this._throttle(ti,e,50))return this;if(r.alwaysStat&&void 0===i&&(t===te||t===ts||t===ti)){let t,i=r.cwd?F.join(r.cwd,e):e;try{t=await u(i)}catch(t){}if(!t||this.closed)return;a.push(t)}return this.emitWithAll(t,a),this}_handleError(t){let e=t&&t.code;return t&&"ENOENT"!==e&&"ENOTDIR"!==e&&(!this.options.ignorePermissionErrors||"EPERM"!==e&&"EACCES"!==e)&&this.emit(tn,t),t||this.closed}_throttle(t,e,i){let s;this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw Error("invalid throttle");let a=r.get(e);if(a)return a.count++,!1;let o=()=>{let t=r.get(e),i=t?t.count:0;return r.delete(e),clearTimeout(s),t&&clearTimeout(t.timeoutObject),i},n={timeoutObject:s=setTimeout(o,i),clear:o,count:0};return r.set(e,n),n}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,i,s){let r,a=this.options.awaitWriteFinish;if("object"!=typeof a)return;let o=a.pollInterval,l=t;this.options.cwd&&!F.isAbsolute(t)&&(l=F.join(this.options.cwd,t));let h=new Date,d=this._pendingWrites;d.has(t)||(d.set(t,{lastChange:h,cancelWait:()=>(d.delete(t),clearTimeout(r),i)}),r=setTimeout(function i(a){n(l,(n,l)=>{if(n||!d.has(t)){n&&"ENOENT"!==n.code&&s(n);return}let h=Number(new Date);a&&l.size!==a.size&&(d.get(t).lastChange=h),h-d.get(t).lastChange>=e?(d.delete(t),s(void 0,l)):r=setTimeout(i,o,l)})},o))}_isIgnored(t,e){if(this.options.atomic&&tk.test(t))return!0;if(!this._userIgnored){let{cwd:t}=this.options,e=(this.options.ignored||[]).map(tj(t)),i=[...[...this._ignoredPaths].map(tj(t)),...e];this._userIgnored=function(t,e){if(null==t)throw TypeError("anymatch: specify first argument");let i=tW(t).map(t=>"function"==typeof t?t:"string"==typeof t?e=>t===e:t instanceof RegExp?e=>t.test(e):"object"==typeof t&&null!==t?e=>{if(t.path===e)return!0;if(t.recursive){let i=F.relative(t.path,e);return!!i&&!i.startsWith("..")&&!F.isAbsolute(i)}return!1}:()=>!1);return null==e?(t,e)=>tI(i,t,e):tI(i,e)}(i,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new tT(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=F.resolve(t);return this._watched.has(e)||this._watched.set(e,new tM(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return!!this.options.ignorePermissionErrors||!!(256&Number(t.mode))}_remove(t,e,i){let s=F.join(t,e),r=F.resolve(s);if(i=null!=i?i:this._watched.has(s)||this._watched.has(r),!this._throttle("remove",s,100))return;i||1!==this._watched.size||this.add(t,e,!0),this._getWatchedDir(s).getChildren().forEach(t=>this._remove(s,t));let a=this._getWatchedDir(t),o=a.has(e);a.remove(e),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let n=s;if(this.options.cwd&&(n=F.relative(this.options.cwd,s)),this.options.awaitWriteFinish&&this._pendingWrites.has(n)&&this._pendingWrites.get(n).cancelWait()===te)return;this._watched.delete(s),this._watched.delete(r);let l=i?ta:tr;o&&!this._isIgnored(s)&&this._emit(l,s),this._closePath(s)}_closePath(t){this._closeFile(t);let e=F.dirname(t);this._getWatchedDir(e).remove(F.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(t=>t()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let i=this._closers.get(t);i||(i=[],this._closers.set(t,i)),i.push(e)}_readdirp(t,e){if(this.closed)return;let i=function(t,e={}){let i=e.entryType||e.type;if("both"===i&&(i=M),i&&(e.type=i),t){if("string"!=typeof t)throw TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");else if(i&&!N.includes(i))throw Error(`readdirp: Invalid type passed. Use one of ${N.join(", ")}`)}else throw Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new G(e)}(t,{type:Z,alwaysStat:!0,lstat:!0,...e,depth:0});return this._streams.add(i),i.once("close",()=>{i=void 0}),i.once("end",()=>{i&&(this._streams.delete(i),i=void 0)}),i}}function t$(){return{interactive:!1,addTarget(t,e){let i={status:"pending",message:"正在启动"},s="workbench"===t?`${e}:`:`[${t}] `;return{log:{info:t=>x.info(`${s}${t}`),success:t=>x.success(`${s}${t}`),warn:t=>x.warn(`${s}${t}`),error:t=>x.error(`${s}${t}`)},ui:{update(t){let s={...i};for(let[r,a]of(Object.assign(i,t),(i.message!==s.message||i.status!==s.status)&&(0,({pending:x.info,success:x.success,error:x.error})[i.status])(`${e}:${i.message}`),Object.entries(i.links??{})))s.links?.[r]!==a&&x.info(`${r}:${a}`)},select:async()=>void 0,print:t=>console.log(t)}}},close(){}}}async function tN(i){if(D())try{let{TUIManager:s,getNativePackageName:r}=await import("./dist.js"),{createRatatuiDevUI:a}=await import("./ratatui-ui.js"),n=e(t(g(import.meta.url)),"tui");if(!o(n)){let e=await I({name:r(),version:v.version,title:"交互界面"},".",i.signal,{interactive:!0,log:x});n=t(g(e))}i.signal.throwIfAborted();let l=new s({nativeDirectory:n});try{return await a(l,i)}catch(t){throw await l.close(),t}}catch(t){i.signal.aborted||x.warn(`无法启动交互界面,改用日志模式:${W(t)}`)}return t$()}async function tO(t,e,r){let a,o=new AbortController,n=Promise.withResolvers(),l=(t=!1)=>{t&&(process.exitCode=130),o.abort(),n.resolve()},h={project:t,options:e,signal:o.signal};t.assertWorkbenchModules();let d=await tU(h,r.devTargets);if(!d)return;await R(D());let c=d.some(({target:t})=>"app"===t.name);if(t.plugin.id&&!t.hasWorkbench)await k(t);else if(!t.plugin.id&&c){x.info("未配置插件 ID,正在上传项目并创建平台草稿…");try{await C({project:t,options:{}},await E(r.exclude,{project:t},"draft"))}catch(t){throw Error(`插件初始化失败,未启动调试:${W(t)}`,{cause:t})}}let f=await E(r.exclude,{project:t},"dev"),p=()=>l(!0),m=()=>{process.exitCode=143,l()};process.on("SIGINT",p),process.on("SIGTERM",m);let u=c?await tN({signal:o.signal,onExit:l,projectName:t.plugin.name}):t$(),_=[],w=async t=>{for(let e of t.disposers.splice(0).reverse())try{await e()}catch(e){t.ctx.log.warn(`清理失败:${W(e)}`)}},g=(t,e)=>{o.signal.aborted||(t.ctx.ui.update({status:"error",message:"运行失败"}),t.ctx.log.error(W(e)))},y=t=>{t.changed.size&&t.ready&&!t.running&&!o.signal.aborted&&(t.running=(async()=>{try{for(;t.changed.size&&!o.signal.aborted;){let e=[...t.changed];t.changed.clear();try{await t.listener?.(e)}catch(e){g(t,e)}}}finally{t.running=void 0}})())};try{for(let e of d){let{name:r,title:a,label:o=a,watch:n=[]}=e.target,l={entry:e,paths:n.map(e=>i(t.root,s(t.root,e))),ready:!1,changed:new Set,disposers:[],ctx:{...h,...u.addTarget(r,o),interactive:u.interactive,packDevelopment:()=>t.pack({exclude:f}),onDispose:t=>l.disposers.push(t),onFilesChanged:t=>{l.listener=t}}};_.push(l)}let e=_.flatMap(({paths:t})=>t),r=function(t,e={}){let i=new tA(e);return i.add(t),i}(t.root,{ignoreInitial:!0,followSymlinks:!1,ignored:s=>{let r=i(t.root,s);return!!r&&!e.some(t=>tH(r,t)||tH(t,r))}});r.on("all",(e,s)=>{if(o.signal.aborted)return;let r=i(t.root,s);for(let t of _)t.paths.some(t=>tH(r,t))&&t.changed.add(r);clearTimeout(a),a=setTimeout(()=>_.forEach(y),400)}),r.on("error",n.reject);let l=Promise.all(_.map(async t=>{try{o.signal.throwIfAborted(),await t.entry.target.start(t.ctx),o.signal.throwIfAborted(),t.ready=!0,y(t)}catch(e){t.changed.clear(),g(t,e),await w(t)}}));try{await n.promise}finally{o.abort(),clearTimeout(a);try{await r.close()}finally{await l,await Promise.all(_.map(t=>t.running))}}}catch(t){if(t!==o.signal.reason&&!(t instanceof Error&&"AbortError"===t.name))throw t}finally{for(let t of(o.abort(),_.toReversed()))await w(t);try{await u.close()}finally{process.off("SIGINT",p),process.off("SIGTERM",m)}}}function tH(t,e){return!e||t===e||t.startsWith(`${e}${r}`)}async function tU(t,e){let{options:i}=t,s=[];for(let r of e){let{pluginName:e,target:a}=r,o=!a.appliesTo||await y({pluginName:e,callback:a.appliesTo},t);if(!o&&r.attribute&&i[r.attribute]){if("workbench"===a.name)throw Error("当前项目是普通插件,请在定制工作台项目中使用 dbx dev --workbench");throw Error(`[${e}] 当前项目不支持:${a.title}`)}o&&s.push(r)}if(t.project.hasWorkbench||i.workbench){if(i.plugin)throw Error("定制工作台请使用 dbx dev --workbench 调试");return s.filter(({target:t})=>"workbench"===t.name)}let r=s.filter(({attribute:t})=>t&&"workbench"!==t),a=({attribute:t})=>!!(t&&i[t]),o=new Set;if(r.length&&!i.plugin&&!r.some(a)&&D())for(let{target:t}of r){let e=await b({message:`是否启动${t.title}?`,initialValue:!1});if(S(e)){P("已取消调试。"),process.exitCode=130;return}e&&o.add(t.name)}let n=s.filter(t=>!t.attribute||a(t)||o.has(t.target.name));return n.some(({target:t})=>"app"===t.name)?n.filter(({target:t})=>"platform"!==t.name):n}export{tO as runSession};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: doubao-plugin-cli
|
|
3
|
-
description:
|
|
3
|
+
description: dbx 命令与项目配置参考。用于操作和排查应用插件 CLI,包括初始化、登录、调试、上传、提审、定制工作台、MCP Apps、MCP 鉴权和业务 CLI 连接器。
|
|
4
4
|
metadata:
|
|
5
5
|
display_name: 应用插件 CLI 开发
|
|
6
6
|
display_description: 使用 dbx 创建、配置、调试和上传应用插件,并处理审核流程。
|
|
@@ -10,17 +10,24 @@ metadata:
|
|
|
10
10
|
|
|
11
11
|
## 识别项目与命令
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
已有 `dbx` 时,用 `dbx --version` 核对版本。需要安装时执行:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install -g @doubao-dev/cli --registry=https://registry.npmjs.org
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
命令以当前安装版本的 `dbx <命令> --help` 为准。发布类型、调试目标和提审范围按开发者已明确的目标选择。需要开发者决定时,说明选项和影响并等答复,再执行相关命令。
|
|
14
20
|
|
|
15
21
|
- 以 `plugin.json` 识别项目,保留已有 `id` 和 `publicationType`;身份与发布类型字段见 [项目配置](references/project-config.md#pluginjson身份与展示信息)。
|
|
16
22
|
- `dev`、`uninstall`、`upload`、`audit`、`versions`、`cancel-audit` 和 `skills` 向上查找最近的 `plugin.json`,也支持 `--cwd <项目内目录>`;执行前确认目标项目。
|
|
17
|
-
- Agent 使用非 TTY
|
|
23
|
+
- Agent 使用非 TTY 模式,提供该操作所需的输入。常驻进程按 [开发调试](references/development.md) 管理。
|
|
18
24
|
|
|
19
25
|
## 按任务读取
|
|
20
26
|
|
|
21
27
|
| 任务 | 指引 |
|
|
22
28
|
| --- | --- |
|
|
23
29
|
| 创建项目,配置插件身份、MCP 和业务 Skill | [项目配置](references/project-config.md) |
|
|
30
|
+
| 工作台的初始化、Manifest、关联资源搜索、同步、卸载与提审 | [工作台命令](references/workbench.md) |
|
|
24
31
|
| 本地调试、同步、个人安装和卸载 | [开发调试](references/development.md) |
|
|
25
32
|
| 上传、预览、版本状态与审核 | [上传与审核](references/upload.md) |
|
|
26
33
|
| MCP 工具提供 HTML 交互界面 | [MCP Apps](references/mcp-apps.md) |
|
|
@@ -32,7 +39,7 @@ metadata:
|
|
|
32
39
|
|
|
33
40
|
## 登录
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
需要平台操作时,用 `dbx auth status` 检查登录。未登录时,交互终端使用 `dbx auth login`,由用户在浏览器授权。非 TTY 环境使用分步授权:
|
|
36
43
|
|
|
37
44
|
1. `dbx auth login --begin`:向用户展示授权地址和用户验证码。
|
|
38
45
|
2. 用户授权后,使用本次返回的设备码执行 `dbx auth login --complete <device-code>`。
|
|
@@ -40,10 +47,11 @@ metadata:
|
|
|
40
47
|
## 操作影响
|
|
41
48
|
|
|
42
49
|
- Skill / MCP(含 MCP Apps)用 `dbx dev --plugin`。CLI 上传开发包,用 `package_id` 安装到当前账号,无需先创建草稿或获取插件 ID。
|
|
50
|
+
- 定制工作台用 `dbx dev --workbench`,通过 `package_id` 安装工作台开发包,无需先建草稿。
|
|
43
51
|
- App 用 `dbx dev --app` 启动本地编译和 Web 模拟器。只有缺少插件 ID 时才先保存草稿并写回 ID,用于查询 App 信息。
|
|
44
|
-
- 直接运行 `dbx dev`
|
|
45
|
-
- `upload`
|
|
46
|
-
- `audit`
|
|
52
|
+
- 直接运行 `dbx dev` 时,工作台工程自动调试工作台,普通工程默认调试 Skill / MCP。含 App 的项目在交互终端可切换到 App 调试。
|
|
53
|
+
- `upload` 保存草稿和版本,输出版本链接;含 App 时还会等待云构建并生成预览。
|
|
54
|
+
- `audit` 读取当前草稿并显示本次提审版本,补齐草稿材料和企业专属插件申请范围、保存对应版本并提交审核,不选择历史版本;企业专属插件和工作台发起新提审前,向开发者确认本次可见范围,再按[范围参数](references/upload.md#企业专属插件可见范围)执行。审核中不能修改草稿或再次上传,须等待审核结束;仅在用户要求时撤回审核。只执行用户要求的上传、提审或发布操作。
|
|
47
55
|
- 根目录的 `README.md`、`AGENTS.md`、`CLAUDE.md`、`.agents/`、`.claude/`、`.codex/` 和 `.cursor/` 只用于本地开发。需要随业务 Skill 交付的资料放在该 Skill 的 `references/`、`scripts/` 或 `assets/` 中。`.env` 和 `.env.*` 也留在本地。
|
|
48
56
|
|
|
49
57
|
## 本地调试 MCP Server
|
|
@@ -4,26 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
| 命令 | 行为 |
|
|
6
6
|
| --- | --- |
|
|
7
|
-
| `dbx dev` |
|
|
7
|
+
| `dbx dev` | 工作台工程默认调试工作台;普通插件默认调试 Skill / MCP,含 App 的项目可在交互终端选择 App 调试 |
|
|
8
8
|
| `dbx dev --plugin` | 只调试 Skill / MCP |
|
|
9
9
|
| `dbx dev --app` | 启动 App 本地编译和 Web 模拟器 |
|
|
10
|
+
| `dbx dev --workbench` | 同步定制工作台及同工程的 MCP |
|
|
10
11
|
|
|
11
|
-
`--plugin`
|
|
12
|
+
`--plugin`、`--app` 和 `--workbench` 互斥。App 编译、模拟器和设备操作见项目内 `.agents/skills/doubao-plugin-app/references/app-development.md`。
|
|
12
13
|
|
|
13
14
|
## 初始化与同步
|
|
14
15
|
|
|
15
16
|
需要有效登录态;交互终端未登录时会发起授权,非 TTY 环境应先按 CLI Skill 的登录说明完成授权。
|
|
16
17
|
|
|
17
|
-
启动 App 调试且缺少 `plugin.json.id` 时,CLI 先上传项目、校验物料并保存平台草稿,将返回的 AbilityID 写回本地。失败则停止启动。Skill / MCP
|
|
18
|
+
启动 App 调试且缺少 `plugin.json.id` 时,CLI 先上传项目、校验物料并保存平台草稿,将返回的 AbilityID 写回本地。失败则停止启动。Skill / MCP 和工作台调试直接上传并安装开发包。已有插件 ID 时,CLI 会先核对平台发布类型。
|
|
18
19
|
|
|
19
|
-
平台同步监听业务 `skills/`、MCP
|
|
20
|
+
平台同步监听业务 `skills/`、MCP 和插件配置。工作台目标监听 MCP、插件配置和 `com.doubao/workbench/`,包括预装声明和页面资源。开发包在启动或文件变更后上传并安装到当前账号。工作台同步成功后,在豆包工作 PC 的「我的」切换试用。
|
|
20
21
|
|
|
21
22
|
新增或移除 App 后重启并选择调试目标。
|
|
22
23
|
|
|
23
24
|
## Agent 运行方式
|
|
24
25
|
|
|
25
|
-
`dev` 是常驻进程。先检查是否已有可复用实例;需要启动时,以非 TTY
|
|
26
|
+
`dev` 是常驻进程。先检查是否已有可复用实例;需要启动时,以非 TTY 模式通过后台进程工具运行,保留进程句柄,从日志读取状态和地址,不等待进程结束。按本次任务显式传 `--plugin`、`--app` 或 `--workbench`。首次 App 调试会上传并建草稿,平台及工作台调试会安装到当前账号。执行前核对已有授权是否覆盖相应操作,仅缺少授权时询问。同步调试从日志确认「已同步」或具体失败原因,App 调试从日志获取实际就绪状态和模拟器地址。
|
|
26
27
|
|
|
27
28
|
## 停止与卸载
|
|
28
29
|
|
|
29
|
-
Ctrl+C
|
|
30
|
+
Ctrl+C 或退出信号停止调试并清理服务。卸载开发包时先停止会话,再运行 `dbx uninstall`。卸载工作台开发包使用 `dbx uninstall --workbench`。
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
| `dbx init <name>` | 空插件骨架:根配置与开发指引,需补充实际业务能力 |
|
|
18
18
|
| `dbx init <name> --type enterprise` | 企业专属插件骨架,保存 ENTERPRISE 发布类型 |
|
|
19
19
|
| `dbx init <name> --app` | 增加 App、本地商品搜索端工具、业务 Skill、页面和卡片 |
|
|
20
|
+
| `dbx init <name> --workbench` | 增加原生首页配置,见[工作台命令](workbench.md) |
|
|
20
21
|
|
|
21
|
-
目标目录须不存在或为空。`--type public|enterprise` 指定发布类型。未指定类型时,`--app` 或非 TTY 默认使用 PUBLIC。其他交互场景会登录并查询企业插件发布权限,有权限时询问类型,否则直接使用 PUBLIC。显式指定 `--type enterprise`
|
|
22
|
+
目标目录须不存在或为空。`--type public|enterprise` 指定发布类型。未指定类型时,`--app` 或非 TTY 默认使用 PUBLIC。其他交互场景会登录并查询企业插件发布权限,有权限时询问类型,否则直接使用 PUBLIC。显式指定 `--type enterprise` 时会校验发布权限。交互创建时单选普通插件、普通插件(含 App)或定制工作台。企业专属项目不显示含 App 的选项。`--app` 和 `--workbench` 互斥。
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
创建普通插件或工作台时,如果本次会创建平台草稿且开发者未明确发布类型,先问要公开发布还是企业专属。按答复显式传 `--type public` 或 `--type enterprise`。App 仅支持公开类型,遇到同时要求企业专属和 App 时先请开发者取舍。显式创建企业专属项目失败时,说明 CLI 返回的限制。开发者同意改为公开后再用 `--type public` 重试。
|
|
24
25
|
|
|
25
26
|
App 模式准备 Kit 和前端依赖;`--no-install-deps` 跳过依赖安装。安装失败保留项目,在 `com.doubao/app/` 重试 `pnpm install`。
|
|
26
27
|
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
| `dbx upload` | 上传、校验并保存草稿、ID 和版本,输出实际版本号;含 App 时使用该版本等待云构建并生成预览,不执行个人安装或提审 |
|
|
6
6
|
| `dbx audit` | 读取当前草稿并显示提审版本,补齐草稿材料、保存对应版本并提交审核,不选择历史版本,不上传本地改动 |
|
|
7
7
|
| `dbx versions` | 以 JSON 查询各版本状态和审核摘要 |
|
|
8
|
-
| `dbx cancel-audit` |
|
|
8
|
+
| `dbx cancel-audit` | 撤回尚未处理的提审 |
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
上传前核对目标工程、已授权的上传范围和待打包内容。保存版本成功后输出实际版本号、对应版本详情页链接及 `dbx audit` 提审命令。详情链接通过分页查询版本列表、匹配实际保存的版本号取得;查询失败仅警告,并输出版本列表页入口。版本保存失败会报错、保留草稿并提供版本列表页入口;App 构建或预览失败仅警告。分别向开发者报告版本保存结果和预览结果,可从输出的链接继续处理。
|
|
11
11
|
|
|
12
12
|
本地修改后须重新上传。版本可省略,由平台确定;`dbx upload --version x.y.z` 仅覆盖包内版本,不修改本地清单,也不是创建并行开发版本的入口。未提审阶段重复上传会更新当前可编辑版本;后续版本推进由服务端根据生命周期处理,并非每次保存都递增。以 CLI 输出的实际保存版本号为准。
|
|
13
13
|
|
|
@@ -29,11 +29,21 @@
|
|
|
29
29
|
全租户
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
当前为指定对象时,额外显示默认选项“指定对象(当前)”;选择该项不传范围,保留平台配置,不根据对象列表推测是否仅本人。指定对象由平台管理。
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
企业专属插件或工作台发起新提审前,先确认开发者选择的范围。开发者未明确时,展示可用选项并等待答复。终端预选值、草稿范围和「提交审核」的请求本身都不能代表范围选择。
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
| 开发者的选择 | CLI 参数 |
|
|
37
|
+
|---|---|
|
|
38
|
+
| 仅本人 | `--visibility self` |
|
|
39
|
+
| 全租户 | `--visibility tenant` |
|
|
40
|
+
| 保留当前范围 | 先告知开发者草稿当前范围。确认保留后,交互选择当前范围,或在非交互提审时省略范围字段。 |
|
|
41
|
+
|
|
42
|
+
非交互提审按开发者的选择传入 `--visibility` 或在 `--input` 中提供范围。仅在开发者明确同意保留现有范围时省略。公开项目不传范围。
|
|
43
|
+
|
|
44
|
+
普通插件审核需填写一项意向分类,公开和企业专属工作台均跳过分类。普通插件的 OAuth 连接器缺少已保存的测试凭据时,需提供测试账号或 Key。其他审核材料包括每个 Skill 和应用插件的 HTTP 或 HTTPS 评测报告地址和 5–10 条示例提示词,以及每个 CLI 的使用说明文档链接。已有凭据可留空沿用。工作台按[内联 MCP 连通性检测](workbench.md#上传与提审)补充凭据。
|
|
45
|
+
|
|
46
|
+
普通插件当前缺少有效意向分类时,用 `dbx categories` 查询与发布类型对应的真实类目,向开发者确认后再填写 `category_id`。已有有效分类且本次未要求变更时直接沿用。缺少必填链接或测试资料时,请开发者提供实际值。
|
|
37
47
|
|
|
38
48
|
图标声明位置与路径见 [项目配置](project-config.md),图片要求如下:
|
|
39
49
|
|
|
@@ -54,7 +64,7 @@
|
|
|
54
64
|
- `isMinorIncluded` 表示服务用户是否包含未成年人,使用字符串 `"true"` 或 `"false"`,缺失或为空时按 `"false"` 处理。填 `"true"` 时,隐私政策需说明未成年人个人信息处理规则。
|
|
55
65
|
- `specialLicenseUrl` 是特殊行业资质证明链接,选填,填写时使用 HTTPS 绝对 URL。
|
|
56
66
|
|
|
57
|
-
`dbx audit` 检查已上传草稿。交互模式首次配置时逐项引导填写,修正已有声明时只询问缺少的必填项或格式有误的字段。输入有误时在当前题重试。声明保存到本地 `plugin.json` 后,经开发者确认,CLI 重新上传整个项目(包括其他尚未上传的本地改动),更新平台草稿并继续提审。如果保存声明后退出,再次运行 `dbx audit`
|
|
67
|
+
`dbx audit` 检查已上传草稿。交互模式首次配置时逐项引导填写,修正已有声明时只询问缺少的必填项或格式有误的字段。输入有误时在当前题重试。声明保存到本地 `plugin.json` 后,经开发者确认,CLI 重新上传整个项目(包括其他尚未上传的本地改动),更新平台草稿并继续提审。如果保存声明后退出,再次运行 `dbx audit` 可直接确认上传。Agent 提审前核对实际声明。缺少隐私政策、适用资质链接或未成年人声明时,向开发者索取真实链接或确认适用情况。终端默认值不能作为开发者的声明。非交互模式修正 `plugin.json` 后须先上传再提审。如果已有授权只覆盖当前草稿,先说明重新上传会包含其他未上传的本地改动,等开发者确认后再执行 `dbx upload`。
|
|
58
68
|
|
|
59
69
|
### 非交互审核
|
|
60
70
|
|
|
@@ -99,9 +109,9 @@ dbx audit --visibility tenant
|
|
|
99
109
|
|
|
100
110
|
MCP Apps 兼容使用 `mcp_app.mcp.test_credential`。
|
|
101
111
|
|
|
102
|
-
企业输入文件可增加 `"visibility_config": { "type": 1 }`(仅本人)或 `{ "type": 2 }`(全租户)。Devtool 写入使用独立范围类型,只接受 `type`,不接受 `entities`;`--visibility self` 对应 1,`tenant` 对应 2。草稿查询仍返回通用范围类型:2 为全租户、3 为指定对象、4 为仅自己,与写入类型分别处理。`--visibility` 与输入文件的 `visibility_config`
|
|
112
|
+
企业输入文件可增加 `"visibility_config": { "type": 1 }`(仅本人)或 `{ "type": 2 }`(全租户)。Devtool 写入使用独立范围类型,只接受 `type`,不接受 `entities`;`--visibility self` 对应 1,`tenant` 对应 2。草稿查询仍返回通用范围类型:2 为全租户、3 为指定对象、4 为仅自己,与写入类型分别处理。`--visibility` 与输入文件的 `visibility_config` 不能同时提供。省略范围时 CLI 会沿用草稿,执行前须确认开发者同意保留。
|
|
103
113
|
|
|
104
|
-
|
|
114
|
+
用 `dbx categories` 查询公开插件分类,用 `dbx categories --type enterprise` 查询企业专属普通插件分类。`module_id` 使用平台草稿返回值。拿不到模块 ID 时,在开放平台控制台完善草稿材料,再运行 `dbx audit` 复用。
|
|
105
115
|
|
|
106
116
|
未指定的材料沿用有效旧值,脱敏凭据不会作为新凭据上传;材料无效时在保存版本和提审前退出。
|
|
107
117
|
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# 定制工作台命令
|
|
2
|
+
|
|
3
|
+
## 初始化
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
dbx init my-workbench --workbench
|
|
7
|
+
cd my-workbench
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
非 TTY 创建时,省略 `--type` 默认公开。要创建企业专属项目时,加 `--type enterprise` 并通过发布权限校验。交互环境需要明确选定公开类型时,可以加 `--type public`。
|
|
11
|
+
|
|
12
|
+
直接运行 `dbx init` 时,用 ↑/↓ 选择「定制工作台」,回车确认。`--workbench` 与 `--app` 互斥。
|
|
13
|
+
|
|
14
|
+
CLI 通过项目根目录下的 `com.doubao/workbench/manifest.json` 识别工作台。默认模板如下:
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"schemaVersion": "1.0",
|
|
19
|
+
"additionalContext": "",
|
|
20
|
+
"reconfig": {
|
|
21
|
+
"home": {
|
|
22
|
+
"mode": "overlay",
|
|
23
|
+
"welcome": { "title": "欢迎使用我的工作台" }
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
工作台包可在根目录通过 `mcp.json` 接入 MCP。包内的 `skills/`、App、CLI 声明和 Hooks 会在打包前报错。更新已有项目时保留 `plugin.json.id` 和 `publicationType`。[项目配置](project-config.md)
|
|
30
|
+
|
|
31
|
+
## 选择界面配置
|
|
32
|
+
|
|
33
|
+
`schemaVersion` 必填,固定为 `"1.0"`。`additionalContext` 是可选字符串,用于补充工作台的业务背景和术语。`reconfig` 按需配置,省略的区域沿用宿主界面。`nav.rail` 和 `settings.more-menu` 各是一个完整的 JSON 键。
|
|
34
|
+
|
|
35
|
+
- 改欢迎语、图片或推荐时,使用 [overlay 首页](#overlay-欢迎区推荐导航和菜单)。
|
|
36
|
+
- 自定义整页时,使用 [takeover 首页](#takeover-随包-html-首页)。
|
|
37
|
+
|
|
38
|
+
### Overlay 欢迎区、推荐、导航和菜单
|
|
39
|
+
|
|
40
|
+
以下示例使用宿主首页,并增加一个推荐、一个左侧导航入口和一个帮助链接。只保留需要的区域和字段,推荐资源 ID 用搜索结果替换。
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"schemaVersion": "1.0",
|
|
45
|
+
"reconfig": {
|
|
46
|
+
"home": {
|
|
47
|
+
"mode": "overlay",
|
|
48
|
+
"welcome": { "title": "今天需要处理什么合同?", "icon": "assets/welcome.png" },
|
|
49
|
+
"suggestions": [
|
|
50
|
+
{
|
|
51
|
+
"target": { "type": "plugin", "id": "replace-with-resource-id" },
|
|
52
|
+
"items": [{ "text": "查询待签合同", "prompt": "列出我当前待签署的合同。" }]
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"nav.rail": {
|
|
57
|
+
"mode": "overlay",
|
|
58
|
+
"items": [
|
|
59
|
+
{
|
|
60
|
+
"text": "合同管理",
|
|
61
|
+
"icon": "assets/contracts.png",
|
|
62
|
+
"entrypoint": {
|
|
63
|
+
"type": "global",
|
|
64
|
+
"target": { "type": "mcp-tool", "tool": { "server": "legal", "name": "open_dashboard" } }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"settings.more-menu": {
|
|
70
|
+
"mode": "overlay",
|
|
71
|
+
"items": [
|
|
72
|
+
{
|
|
73
|
+
"id": "help",
|
|
74
|
+
"text": "帮助",
|
|
75
|
+
"action": {
|
|
76
|
+
"type": "open-link",
|
|
77
|
+
"target": { "type": "link", "url": "https://example.com/help" }
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- 欢迎区的 `title` 和 `icon` 均可省略,分别回退到宿主问候语和默认图片。这里的 `assets/welcome.png` 对应 `com.doubao/workbench/assets/welcome.png`。导航和菜单图标采用同一相对路径规则,插件列表图标仍按[项目配置](project-config.md)填写在根 `plugin.json`。
|
|
87
|
+
- 每个推荐目标用 `skill` 或 `plugin` 的 `type + id` 匹配[预装声明](#搜索并声明预装资源),同一目标只写一次。`items` 中每项的 `text` 必填,省略 `prompt` 或填空字符串时,用 `text` 预填输入框。
|
|
88
|
+
- 导航入口使用 `entrypoint`,省略 `text` 时使用工具名,省略 `icon` 时使用宿主图标。头像菜单的每项需要唯一、稳定的 `id` 和非空白 `text`,可选 `icon`,并在 HTTPS `action` 和 MCP `entrypoint` 中选一个。MCP 菜单项复用上例导航的 `entrypoint` 结构。
|
|
89
|
+
- MCP 页面入口的 `server` 是根 `mcp.json` 的 `mcpServers` 键,`name` 是该服务在 `tools/list` 返回的实际工具名。入口工具接受 `{}`,用 `_meta.ui.resourceUri` 绑定 UI Resource,在 `_meta["openai/ui"].entrypoints` 中声明 `{ "type": "global" }`。资源返回 `text/html;profile=mcp-app`,在 `_meta["doubao/ui"].availableDisplayModes` 中包含 `fullscreen`。更多接入细节见 [MCP Extension 协议](https://bytedance.larkoffice.com/docx/VHe1dvcYuoCV8lxGK60cl2MLnPb)。
|
|
90
|
+
|
|
91
|
+
### Takeover 随包 HTML 首页
|
|
92
|
+
|
|
93
|
+
把 `home` 配成 `takeover` 时使用 `entrypoint`,并省略 `welcome` 和 `suggestions`。`path` 从 `com.doubao/workbench/` 开始,指向 `web/` 下实际存在的 `.html` 文件。HTML 依赖的构建产物也放在 `web/` 下,页面内的相对引用以 HTML 所在目录为基准。
|
|
94
|
+
|
|
95
|
+
```json
|
|
96
|
+
{
|
|
97
|
+
"schemaVersion": "1.0",
|
|
98
|
+
"reconfig": {
|
|
99
|
+
"home": {
|
|
100
|
+
"mode": "takeover",
|
|
101
|
+
"entrypoint": {
|
|
102
|
+
"type": "global",
|
|
103
|
+
"target": {
|
|
104
|
+
"type": "html",
|
|
105
|
+
"html": {
|
|
106
|
+
"path": "web/home.html",
|
|
107
|
+
"startupCalls": [{ "server": "legal", "name": "get_contract_summary", "arguments": {} }]
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- 静态首页省略 `startupCalls`。整个项目都不使用 MCP 时可省略 `mcp.json`。随包页面使用 MCP Apps SDK 初始化,再按宿主提供的能力发起交互。
|
|
117
|
+
- 启动取数最多 32 项,只调用读工具。`server` 和 `name` 同样来自当前项目的 `mcp.json` 和实际工具列表。`arguments` 是符合工具输入 schema 的对象,省略时按 `{}` 处理。
|
|
118
|
+
- 初始化后检查 `hostCapabilities.experimental["doubao/workbench"].startupClaims`,通过 `doubao/claimStartup` 按声明的 `server`、`name`、`arguments` 领取结果。主动重新取数时检查 `serverRouting`,再用 `doubao/callServerTool`。
|
|
119
|
+
- 页面有额外网络或浏览器能力需求时,在 `html` 对象内按需加 `csp` 和 `permissions`。`csp` 的 `connectDomains`、`resourceDomains`、`frameDomains`、`baseUriDomains` 分别填写所需来源数组,如 `["https://api.example.com"]`。`permissions.clipboardWrite: {}` 用于申请剪贴板写入。通过宿主调用 MCP 时无需把 MCP 地址加入 `connectDomains`。
|
|
120
|
+
|
|
121
|
+
其余字段约束见[工作台协议](https://bytedance.larkoffice.com/docx/NrkgdZ25QoaMbBx0d5Fcy6kOnzm)。
|
|
122
|
+
|
|
123
|
+
## 搜索并声明预装资源
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
dbx workbench search "合同" --json
|
|
127
|
+
dbx workbench search "合同" --source official store --json
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
命令按当前登录账号查询插件和独立 Skill,无需项目目录或插件 ID。可省略关键词或按 `official`、`store`、`enterprise`、`personal` 筛选。服务端最多返回 100 条,结果过多时缩小关键词或来源范围。
|
|
131
|
+
|
|
132
|
+
按需创建 `com.doubao/workbench/preinstall-resources.json`,将下面的 ID 换成搜索得到的实际资源 ID。
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"preinstallResources": [
|
|
137
|
+
{ "type": "plugin", "id": "replace-with-resource-id", "source": "store" }
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
按工作台发布范围筛选预装资源。公开(ISV)工作台可选 `official`(已发布的官方 Skill)和 `store`,企业专属工作台还可选本企业的 `enterprise`。搜索也支持 `personal`,协议未把它列为这两种发布范围的预装来源。
|
|
143
|
+
|
|
144
|
+
同一 `type + id` 只声明一次,首页推荐按这两个字段引用。工作台安装会发起预装,关联功能仍取决于资源是否安装及授权。没有预装需求时可省略该文件。旧项目的 `com.doubao/references.json` 需按新路径和结构迁移。
|
|
145
|
+
|
|
146
|
+
## 调试与卸载
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
dbx dev --workbench
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`--workbench`、`--plugin` 和 `--app` 互斥。工作台目标上传开发包并安装到当前账号。开发包包含工作台配置、资源及同工程的 MCP。修改 `com.doubao/workbench/` 下的文件、`mcp.json` 或 `plugin.json` 会触发重新同步。
|
|
153
|
+
|
|
154
|
+
调试前需要有效登录态,登录状态未知时可用 `dbx auth status` 检查。CLI 直接上传并安装工作台开发包。需要保存平台草稿时运行 `dbx upload`。日志显示「已同步」后,可在豆包工作 PC 的「我的」切换到工作台开发版。[登录和常驻进程](development.md)
|
|
155
|
+
|
|
156
|
+
用 Ctrl+C 或 SIGTERM 停止调试。需要卸载工作台开发包时,停止监听后执行 `dbx uninstall --workbench`。
|
|
157
|
+
|
|
158
|
+
## 上传与提审
|
|
159
|
+
|
|
160
|
+
对工作台工程执行 `dbx upload`,CLI 从项目识别 `WORKBENCH` 产物类型,保存草稿和版本并输出平台版本链接。项目的 `publicationType` 决定公开或企业专属发布。需要指定上传版本时才加 `--version`。
|
|
161
|
+
|
|
162
|
+
已有平台 ID 的旧工作台如果缺少 `publicationType`,CLI 会按 ID 查询公开和企业专属草稿,确认唯一匹配后补回类型。
|
|
163
|
+
|
|
164
|
+
用 `dbx audit` 提审当前草稿。公开和企业专属工作台均跳过意向分类。CLI 根据平台草稿检测内联 MCP 的连通性,测试凭据按检测结果补充。企业专属工作台先确认开发者选择的范围,再按[企业提审参数](upload.md#企业专属插件可见范围)执行。通过 `dbx versions` 查询版本和审核状态。[上传与审核参数](upload.md)
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
先阅读 [CLI 开发 Skill](.agents/skills/doubao-plugin-cli/SKILL.md),按任务选择其中的配置、上传或 MCP Apps 指引。
|
|
4
4
|
|
|
5
|
-
链接缺失时运行 `dbx skills
|
|
5
|
+
链接缺失时运行 `dbx skills`。普通插件的业务 Skill 放在 `skills/`。定制工作台的界面、上下文和资源预装配置见[工作台开发参考](.agents/skills/doubao-plugin-cli/references/workbench.md)。开发指引不进入上传包。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# __PLUGIN_NAME__
|
|
2
|
+
|
|
3
|
+
在 `com.doubao/workbench/manifest.json` 配置首页,按需填写 `additionalContext`。接入 MCP 时在项目根目录添加 `mcp.json`。预装已有 Skill 或插件时添加 `com.doubao/workbench/preinstall-resources.json`。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
dbx dev --workbench
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
开发与上传指引见 [工作台开发参考](.agents/skills/doubao-plugin-cli/references/workbench.md)。
|
package/dist/uninstall.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{log as _,updateUserPlugin as
|
|
1
|
+
import{log as _,updateUserPlugin as i}from"./691.js";import{withProgress as t}from"./progress.js";import{ensureLogin as n}from"./command~1.js";async function o(a,r=!1){await n(!1);let{name:l}=a.plugin,m=r?"定制工作台":"应用插件";await t(`从当前账号卸载${m}开发包`,()=>i({name:l,action:"Uninstall"},void 0,r)),_.success(`${m}开发包已卸载:${l}`)}export{o as runUninstall};
|
package/dist/versions~1.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{listPluginVersions as e,
|
|
1
|
+
import{listPluginVersions as e,getApproval as t,projectIdentity as i,resolvePublicationType as n}from"./691.js";async function*a(t,a){let o,r=a?.isWorkbench??t.hasWorkbench;!a&&r&&t.plugin.id&&!t.plugin.publicationType&&await n(t);let l=a?.identity??i(t),p=new Set;do{let{items:t=[],page:i}=await e({...l,page_size:20,page_token:o},void 0,r),n=i?.next_page_token;if(n&&p.has(n))throw Error("版本列表返回了重复的分页标记,请稍后重试");n&&p.add(n),yield{items:t},o=n}while(o)}async function o(e,i){let n=new Set;for await(let{items:o}of a(e))for(let a of o){let o=a.current_approval?.approval_id;if(!o||n.has(o))continue;n.add(o);let{approval:r}=await t(o,{publicationType:i,workbench:e.hasWorkbench});if(!r)throw Error(`服务端未返回审核记录:${o}`);if(null==r.handled_at_ms)return o}}export{o as findPendingApproval,a as listProjectVersionPages};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{z as o}from"zod";import{searchWorkbenchResources as e,WORKBENCH_RESOURCE_SOURCES as t,isInteractive as r}from"./691.js";import{ensureLogin as i}from"./command~1.js";let l=Object.fromEntries(Object.entries(t).map(([o,e])=>[e,o])),n=o.enum(Object.keys(t)),a={1:"skill",2:"plugin"};async function m(o,{source:c,json:s}){let _=c?.map(o=>t[n.parse(o)]);await i(!1);let{items:p=[]}=await e({keyword:o?.trim()||void 0,sources:_}),d=p.flatMap(({resource_id:o,resource_type:e,source:t,name:r})=>{let i=void 0===e?void 0:a[e],n=void 0===t?void 0:l[t];return o&&i&&n?[{name:r||o,type:i,id:o,source:n}]:[]});s||!r()?console.log(JSON.stringify(d,null,2)):d.length?console.table(d):console.log("未找到可关联的资源")}export{m as runWorkbenchSearch};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doubao-dev/cli",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"description": "Doubao Plugins CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"ofetch": "1.5.1",
|
|
37
37
|
"open": "10.1.0",
|
|
38
38
|
"ora": "8.1.0",
|
|
39
|
-
"@byted-doubao-apps/cli": "1.0.0-rc.
|
|
39
|
+
"@byted-doubao-apps/cli": "1.0.0-rc.9",
|
|
40
40
|
"@doubao-dev/kit": "0.9.0",
|
|
41
|
-
"@doubao-dev/plugin-app-dev": "1.0.0-rc.
|
|
41
|
+
"@doubao-dev/plugin-app-dev": "1.0.0-rc.9",
|
|
42
42
|
"@rslib/core": "1.0.0-beta.1",
|
|
43
43
|
"@types/node": "22.20.4",
|
|
44
44
|
"@types/qrcode": "1.5.6",
|