ms-vite-plugin 1.4.83 → 1.4.84
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/build.js +1 -1
- package/dist/luaObfuscator/addVararg.js +1 -1
- package/dist/luaObfuscator/flatten.js +1 -1
- package/dist/luaObfuscator/rename.js +1 -1
- package/dist/luaObfuscator/scope.js +1 -1
- package/docs/AGENTS.md +18 -14
- package/docs/SKILL.md +18 -12
- package/docs/mcp-agent-description.md +15 -10
- package/package.json +2 -1
package/dist/build.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var F=Object.create;var L=Object.defineProperty;var $=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var C=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of N(e))!z.call(t,s)&&s!==o&&L(t,s,{get:()=>e[s],enumerable:!(i=$(e,s))||i.enumerable});return t};var W=(t,e,o)=>(o=t!=null?F(q(t)):{},C(e||!t||!t.__esModule?L(o,"default",{value:t,enumerable:!0}):o,t));var K=exports&&exports.__createBinding||(Object.create?(function(t,e,o,i){i===void 0&&(i=o);var s=Object.getOwnPropertyDescriptor(e,o);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,i,s)}):(function(t,e,o,i){i===void 0&&(i=o),t[i]=e[o]})),T=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),E=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(o){var i=[];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(i[i.length]=s);return i},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var i=t(e),s=0;s<i.length;s++)i[s]!=="default"&&K(o,e,i[s]);return T(o,e),o}})(),M=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAll=void 0;const A=M(require("archiver")),P=require("child_process"),r=E(require("fs-extra")),x=E(require("os")),n=E(require("path")),B=require("./stopGuardPlugin"),G=require("./luaBundle"),J=require("./scriptProtect"),H=M(require("vite-plugin-bundle-obfuscator"));async function R(t,e){const o=(0,A.default)("zip",{zlib:{level:9}}),i=r.createWriteStream(e);return new Promise((s,c)=>{o.directory(t,!1).on("error",a=>c(a)).pipe(i),i.on("close",()=>s()),o.finalize()})}function I(t){const e=n.join(t,"node_modules","typescript","lib","tsc.js");return r.pathExistsSync(e)?e:void 0}function Q(t){const e=n.join(t,"tsconfig.json");r.pathExistsSync(e)||(console.error("\u274C \u672A\u627E\u5230 tsconfig.json\uFF0C\u65E0\u6CD5\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C"),process.exit(1));const o=I(t);o||(console.error("\u274C \u672A\u627E\u5230 typescript\uFF0C\u8BF7\u5B89\u88C5\u540E\u91CD\u8BD5"),process.exit(1));const i=n.join(x.tmpdir(),`kuaijs-tsconfig-${process.pid}.json`),s=c=>c.replace(/\\/g,"/");r.writeJsonSync(i,{extends:s(e),include:[s(n.join(t,"env.d.ts")),s(n.join(t,"scripts/**/*"))],exclude:["node_modules","dist","msbundle","ui","res"].map(c=>s(n.join(t,c))),compilerOptions:{noEmit:!0,allowJs:!0,checkJs:!0,skipLibCheck:!0}}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const c=(0,P.spawnSync)(process.execPath,[o,"--noEmit","--pretty","-p",i],{cwd:t,stdio:"inherit"});c.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(c.status??1))}finally{r.removeSync(i)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function U(t,e){const o=[];async function i(s){const c=await r.readdir(s,{withFileTypes:!0});for(const a of c){const f=n.resolve(s,a.name);a.isDirectory()?await i(f):a.isFile()&&(/^main\.(js|ts)$/.test(a.name)||/_thread\.(js|ts)$/.test(a.name))&&o.push(n.relative(e,f))}}return await i(t),o}function V(){const t=[{cmd:n.join(x.homedir(),".KuaiJSDevloper","python","python.exe"),args:["--version"]},{cmd:n.join(x.homedir(),".KuaiJSDevloper","python","bin","python"),args:["--version"]},{cmd:"python",args:["--version"]},{cmd:"python3",args:["--version"]},{cmd:"python3.14",args:["--version"]}];for(const e of t)try{const o=(0,P.spawnSync)(e.cmd,e.args,{encoding:"utf8"}),i=(o.stdout||o.stderr||"").trim();if(i&&/Python\s+3\.14(\.\d+)?/i.test(i))return{ok:!0,path:e.cmd,version:i}}catch{}return{ok:!1}}async function X(t){async function e(o){const i=await r.readdir(o,{withFileTypes:!0});for(const s of i){const c=n.join(o,s.name);if(s.isDirectory())if(s.name==="__pycache__"){const a=await r.readdir(c,{withFileTypes:!0});for(const f of a){const S=n.join(c,f.name);if(f.isFile()&&f.name.endsWith(".cpython-314.pyc")){const O=n.dirname(c),b=f.name.replace(/\.cpython-314\.pyc$/,".pyc"),w=n.join(O,b);await r.move(S,w,{overwrite:!0})}}try{await r.remove(c)}catch{}}else await e(c);else if(s.isFile())if(s.name.endsWith(".cpython-314.pyc")){const a=c.replace(".cpython-314.pyc",".pyc");await r.move(c,a,{overwrite:!0})}else s.name.endsWith(".py")&&await r.remove(c)}}await e(t)}const Y=["Minify","Weak","Medium","Strong"];async function Z(t){const e=n.join(t,"obfuscator.json");if(!await r.pathExists(e))return{enabled:!0,preset:"Medium",bundle:!0};try{const o=await r.readJSON(e),i=o?.enabled!==!1,s=o?.bundle!==!1,c=k(o?.preset);return{enabled:i,preset:c,bundle:s}}catch(o){return console.error("\u274C \u65E0\u6CD5\u8BFB\u53D6 obfuscator.json"),console.error(o instanceof Error?o.message:String(o)),process.exit(1),{enabled:!0,preset:"Medium",bundle:!0}}}function k(t){if(typeof t!="string")return"Medium";const e=Y.find(o=>o.toLowerCase()===t.trim().toLowerCase());return e||(console.warn(`\u26A0\uFE0F obfuscator.json \u7684 preset \u65E0\u6548: ${t}\uFF0C\u5DF2\u6539\u7528 Medium`),"Medium")}function ee(t){return[n.join(t,"node_modules/@gamely/prometheus-cli/bin/cli.js"),n.join(t,"node_modules/ms-vite-plugin/node_modules/@gamely/prometheus-cli/bin/cli.js"),n.resolve(process.cwd(),"node_modules/@gamely/prometheus-cli/bin/cli.js")].find(o=>r.pathExistsSync(o))}const te=async(t=!0,e)=>{const o=n.join(e,"scripts"),i=await r.pathExists(n.join(o,"main.js"))||await r.pathExists(n.join(o,"main.ts")),s=await r.pathExists(n.join(o,"main.py")),c=await r.pathExists(n.join(o,"main.lua"));if(i){console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAJavaScript\u9879\u76EE..."),Q(e);const{build:l}=await import("vite"),u=n.join(e,"obfuscator.json");await r.pathExists(u)||(console.error("\u274C \u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u6709\u6548\u7684 \u5FEB\u70B9JS \u9879\u76EE"),console.error("\u8BF7\u786E\u4FDD\u76EE\u5F55\u5305\u542B\u4EE5\u4E0B\u6587\u4EF6:"),console.error(" - obfuscator.json"),process.exit(1));const h=await r.readJSON(u),m=h.scriptProtect===!0,{enabled:_,scriptProtect:y,...p}=h,d=n.join(e,t?"dist":"msbundle"),j=await U(o,o);await r.remove(d);const g=!t&&m?(0,J.createScriptProtectHelpers)():[];!t&&m&&console.log("\u{1F510} \u5DF2\u542F\u7528 JS \u539F\u751F\u4FDD\u62A4\uFF08scriptProtect=true\uFF09");for(const v of j)await l({root:e,build:{lib:{entry:{[n.basename(v,n.extname(v))]:`./scripts/${v}`},fileName:()=>v.replace(/\.ts$/,".js"),formats:["iife"],name:"KuaiJS"},outDir:t?"dist/scripts":"msbundle/scripts",emptyOutDir:!1,sourcemap:t,minify:!t,target:"safari15"},plugins:[(0,B.createStopGuardPlugin)(),...t?[]:[...m?[(0,J.createScriptProtectPlugin)(g)]:[],_?(0,H.default)({autoExcludeNodeModules:!0,threadPool:!0,options:{...p,target:"browser",debugProtection:!1,disableConsoleOutput:!1,domainLock:[],selfDefending:!1,renameGlobals:!1,renameProperties:!1,reservedNames:[...p.reservedNames||[],...g]}}):[],...m?[(0,J.createKjstEmbedPlugin)()]:[]]]})}if(t)return;const a=n.join(e,"msbundle");if(await r.ensureDir(a),(s||c)&&await r.copy(n.join(e,"scripts"),n.join(a,"scripts")),s){const l=V();if(l.ok){console.log(`\u2705 \u68C0\u6D4B\u5230 ${l.version} (${l.path})`);const u=(0,P.spawnSync)(l.path,["-m","compileall","scripts"],{encoding:"utf8",cwd:a});u.status===0?(console.log("\u2705 \u6210\u529F\u7F16\u8BD1\u6240\u6709 Python \u6587\u4EF6"),await X(n.join(a,"scripts"))):(console.error("\u274C \u7F16\u8BD1 Python \u6587\u4EF6\u5931\u8D25"),console.error(u.stderr),process.exit(1))}else console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u8BF7\u786E\u4FDD\u5728\u76EE\u6807\u8FD0\u884C\u73AF\u5883\u5B89\u88C5 Python 3.14")}else if(c){const l=await Z(e),u=n.join(a,"scripts");if(l.bundle?await(0,G.bundleLuaScripts)(u):console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u5355\u6587\u4EF6\u5408\u5E76\uFF08obfuscator.json bundle=false\uFF09"),!l.enabled)console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u6DF7\u6DC6\uFF08obfuscator.json enabled=false\uFF09");else{const h=[],m=async y=>{const p=await r.readdir(y,{withFileTypes:!0});for(const d of p){const j=n.join(y,d.name);d.isDirectory()?await m(j):d.isFile()&&d.name.endsWith(".lua")&&h.push(j)}};await m(u);const _=ee(e);_||(console.error("\u274C \u672A\u627E\u5230 @gamely/prometheus-cli\uFF0C\u65E0\u6CD5\u6DF7\u6DC6 Lua"),process.exit(1));for(const y of h){const p=n.relative(u,y);console.log(`\u{1F6E0}\uFE0F \u6DF7\u6DC6 Lua: ${p} (preset=${l.preset})`);const d=(0,P.spawnSync)(process.execPath,[_,p,"--preset",l.preset],{cwd:u,encoding:"utf8"});d.status!==0&&(console.error("\u274C \u6DF7\u6DC6 Lua \u5931\u8D25:",p),console.error(d.stderr||d.stdout||""),process.exit(1));const j=p.replace(/\.lua$/,".obfuscated.lua"),g=n.join(u,j);await r.pathExists(g)&&(await r.remove(y),await r.move(g,y,{overwrite:!0}))}console.log("\u2705 Lua \u6DF7\u6DC6\u5B8C\u6210")}}await r.copy(n.join(e,"res"),n.join(a,"res")),await r.copy(n.join(e,"ui"),n.join(a,"ui"));for(const l of["logo.jpg","logo.png"]){const u=n.join(e,l);await r.pathExists(u)&&await r.copy(u,n.join(a,l))}const f=n.join(e,"dist"),S=n.join(e,"package.json"),O=n.join(a,"package.json"),b=await r.readJSON(S);delete b.scripts,delete b.devDependencies,delete b.dependencies,await r.writeJSON(O,b,{spaces:2}),await r.emptyDir(f);const w=n.join(f,"ms.zip"),D=n.join(f,"ms.msbundle");await R(a,w),await r.rename(w,D),await r.remove(a)};exports.buildAll=te;
|
|
1
|
+
"use strict";var C=Object.create;var M=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var W=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of q(e))!z.call(t,s)&&s!==o&&M(t,s,{get:()=>e[s],enumerable:!(r=F(e,s))||r.enumerable});return t};var K=(t,e,o)=>(o=t!=null?C(N(t)):{},W(e||!t||!t.__esModule?M(o,"default",{value:t,enumerable:!0}):o,t));var T=exports&&exports.__createBinding||(Object.create?(function(t,e,o,r){r===void 0&&(r=o);var s=Object.getOwnPropertyDescriptor(e,o);(!s||("get"in s?!e.__esModule:s.writable||s.configurable))&&(s={enumerable:!0,get:function(){return e[o]}}),Object.defineProperty(t,r,s)}):(function(t,e,o,r){r===void 0&&(r=o),t[r]=e[o]})),A=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),E=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(o){var r=[];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[r.length]=s);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var o={};if(e!=null)for(var r=t(e),s=0;s<r.length;s++)r[s]!=="default"&&T(o,e,r[s]);return A(o,e),o}})(),L=exports&&exports.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.buildAll=void 0;const B=L(require("archiver")),g=require("child_process"),i=E(require("fs-extra")),G=require("module"),P=E(require("os")),n=E(require("path")),H=require("./stopGuardPlugin"),R=require("./luaBundle"),J=require("./scriptProtect"),I=L(require("vite-plugin-bundle-obfuscator"));async function V(t,e){const o=(0,B.default)("zip",{zlib:{level:9}}),r=i.createWriteStream(e);return new Promise((s,c)=>{o.directory(t,!1).on("error",a=>c(a)).pipe(r),r.on("close",()=>s()),o.finalize()})}function Q(t){const e=n.join(t,"node_modules","typescript","lib","tsc.js");return i.pathExistsSync(e)?e:void 0}function U(t){const e=n.join(t,"tsconfig.json");i.pathExistsSync(e)||(console.error("\u274C \u672A\u627E\u5230 tsconfig.json\uFF0C\u65E0\u6CD5\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C"),process.exit(1));const o=Q(t);o||(console.error("\u274C \u672A\u627E\u5230 typescript\uFF0C\u8BF7\u5B89\u88C5\u540E\u91CD\u8BD5"),process.exit(1));const r=n.join(P.tmpdir(),`kuaijs-tsconfig-${process.pid}.json`),s=c=>c.replace(/\\/g,"/");i.writeJsonSync(r,{extends:s(e),include:[s(n.join(t,"env.d.ts")),s(n.join(t,"scripts/**/*"))],exclude:["node_modules","dist","msbundle","ui","res"].map(c=>s(n.join(t,c))),compilerOptions:{noEmit:!0,allowJs:!0,checkJs:!0,skipLibCheck:!0}}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const c=(0,g.spawnSync)(process.execPath,[o,"--noEmit","--pretty","-p",r],{cwd:t,stdio:"inherit"});c.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(c.status??1))}finally{i.removeSync(r)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function X(t,e){const o=[];async function r(s){const c=await i.readdir(s,{withFileTypes:!0});for(const a of c){const p=n.resolve(s,a.name);a.isDirectory()?await r(p):a.isFile()&&(/^main\.(js|ts)$/.test(a.name)||/_thread\.(js|ts)$/.test(a.name))&&o.push(n.relative(e,p))}}return await r(t),o}function $(){const t=[{cmd:n.join(P.homedir(),".KuaiJSDevloper","python","python.exe"),args:["--version"]},{cmd:n.join(P.homedir(),".KuaiJSDevloper","python","bin","python"),args:["--version"]},{cmd:"python",args:["--version"]},{cmd:"python3",args:["--version"]},{cmd:"python3.14",args:["--version"]}];for(const e of t)try{const o=(0,g.spawnSync)(e.cmd,e.args,{encoding:"utf8"}),r=(o.stdout||o.stderr||"").trim();if(r&&/Python\s+3\.14(\.\d+)?/i.test(r))return{ok:!0,path:e.cmd,version:r}}catch{}return{ok:!1}}function Y(t){const e=[];try{e.push((0,G.createRequire)(__filename).resolve("pyright/index.js"))}catch{}return e.push(n.resolve(__dirname,"..","node_modules","pyright","index.js"),n.join(t,"node_modules","pyright","index.js"),n.join(t,"node_modules","ms-vite-plugin","node_modules","pyright","index.js")),e.find(o=>i.pathExistsSync(o))}function Z(t){const e=$();if(!e.ok){console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u5DF2\u8DF3\u8FC7\u7C7B\u578B\u6821\u9A8C");return}const o=Y(t);o||(console.error("\u274C \u672A\u627E\u5230 pyright\uFF0C\u8BF7\u91CD\u88C5 ms-vite-plugin \u540E\u91CD\u8BD5"),process.exit(1)),(0,g.spawnSync)(e.path,["-c","import kuaijs"],{encoding:"utf8"}).status!==0&&(console.error(`\u274C \u672A\u627E\u5230 kuaijs \u7C7B\u578B\u5E93\uFF0C\u8BF7\u6267\u884C: ${e.path} -m pip install kuaijs-ios`),process.exit(1));const s=n.join(P.tmpdir(),`kuaijs-pyrightconfig-${process.pid}.json`);i.writeJsonSync(s,{pythonVersion:"3.14",typeCheckingMode:"basic",reportMissingImports:"warning",reportMissingModuleSource:"none"}),console.log("\u{1F50E} \u6B63\u5728\u8FDB\u884C\u7C7B\u578B\u6821\u9A8C...");try{const c=(0,g.spawnSync)(process.execPath,[o,"--project",s,"--pythonpath",e.path,n.join(t,"scripts")],{cwd:t,stdio:"inherit"});c.status!==0&&(console.error("\u274C \u7C7B\u578B\u6821\u9A8C\u5931\u8D25"),process.exit(c.status??1))}finally{i.removeSync(s)}console.log("\u2705 \u7C7B\u578B\u6821\u9A8C\u901A\u8FC7")}async function k(t){async function e(o){const r=await i.readdir(o,{withFileTypes:!0});for(const s of r){const c=n.join(o,s.name);if(s.isDirectory())if(s.name==="__pycache__"){const a=await i.readdir(c,{withFileTypes:!0});for(const p of a){const x=n.join(c,p.name);if(p.isFile()&&p.name.endsWith(".cpython-314.pyc")){const O=n.dirname(c),h=p.name.replace(/\.cpython-314\.pyc$/,".pyc"),_=n.join(O,h);await i.move(x,_,{overwrite:!0})}}try{await i.remove(c)}catch{}}else await e(c);else if(s.isFile())if(s.name.endsWith(".cpython-314.pyc")){const a=c.replace(".cpython-314.pyc",".pyc");await i.move(c,a,{overwrite:!0})}else s.name.endsWith(".py")&&await i.remove(c)}}await e(t)}const ee=["Minify","Weak","Medium","Strong"];async function te(t){const e=n.join(t,"obfuscator.json");if(!await i.pathExists(e))return{enabled:!0,preset:"Medium",bundle:!0};try{const o=await i.readJSON(e),r=o?.enabled!==!1,s=o?.bundle!==!1,c=oe(o?.preset);return{enabled:r,preset:c,bundle:s}}catch(o){return console.error("\u274C \u65E0\u6CD5\u8BFB\u53D6 obfuscator.json"),console.error(o instanceof Error?o.message:String(o)),process.exit(1),{enabled:!0,preset:"Medium",bundle:!0}}}function oe(t){if(typeof t!="string")return"Medium";const e=ee.find(o=>o.toLowerCase()===t.trim().toLowerCase());return e||(console.warn(`\u26A0\uFE0F obfuscator.json \u7684 preset \u65E0\u6548: ${t}\uFF0C\u5DF2\u6539\u7528 Medium`),"Medium")}function ne(t){return[n.join(t,"node_modules/@gamely/prometheus-cli/bin/cli.js"),n.join(t,"node_modules/ms-vite-plugin/node_modules/@gamely/prometheus-cli/bin/cli.js"),n.resolve(process.cwd(),"node_modules/@gamely/prometheus-cli/bin/cli.js")].find(o=>i.pathExistsSync(o))}const se=async(t=!0,e)=>{const o=n.join(e,"scripts"),r=await i.pathExists(n.join(o,"main.js"))||await i.pathExists(n.join(o,"main.ts")),s=await i.pathExists(n.join(o,"main.py")),c=await i.pathExists(n.join(o,"main.lua"));if(r){console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAJavaScript\u9879\u76EE..."),U(e);const{build:l}=await import("vite"),u=n.join(e,"obfuscator.json");await i.pathExists(u)||(console.error("\u274C \u9519\u8BEF: \u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u6709\u6548\u7684 \u5FEB\u70B9JS \u9879\u76EE"),console.error("\u8BF7\u786E\u4FDD\u76EE\u5F55\u5305\u542B\u4EE5\u4E0B\u6587\u4EF6:"),console.error(" - obfuscator.json"),process.exit(1));const b=await i.readJSON(u),y=b.scriptProtect===!0,{enabled:v,scriptProtect:m,...f}=b,d=n.join(e,t?"dist":"msbundle"),j=await X(o,o);await i.remove(d);const w=!t&&y?(0,J.createScriptProtectHelpers)():[];!t&&y&&console.log("\u{1F510} \u5DF2\u542F\u7528 JS \u539F\u751F\u4FDD\u62A4\uFF08scriptProtect=true\uFF09");for(const S of j)await l({root:e,build:{lib:{entry:{[n.basename(S,n.extname(S))]:`./scripts/${S}`},fileName:()=>S.replace(/\.ts$/,".js"),formats:["iife"],name:"KuaiJS"},outDir:t?"dist/scripts":"msbundle/scripts",emptyOutDir:!1,sourcemap:t,minify:!t,target:"safari15"},plugins:[(0,H.createStopGuardPlugin)(),...t?[]:[...y?[(0,J.createScriptProtectPlugin)(w)]:[],v?(0,I.default)({autoExcludeNodeModules:!0,threadPool:!0,options:{...f,target:"browser",debugProtection:!1,disableConsoleOutput:!1,domainLock:[],selfDefending:!1,renameGlobals:!1,renameProperties:!1,reservedNames:[...f.reservedNames||[],...w]}}):[],...y?[(0,J.createKjstEmbedPlugin)()]:[]]]})}if(s&&(console.log("\u{1F680} \u5F00\u59CB\u6784\u5EFAPython\u9879\u76EE..."),Z(e)),t)return;const a=n.join(e,"msbundle");if(await i.ensureDir(a),(s||c)&&await i.copy(n.join(e,"scripts"),n.join(a,"scripts")),s){const l=$();if(l.ok){console.log(`\u2705 \u68C0\u6D4B\u5230 ${l.version} (${l.path})`);const u=(0,g.spawnSync)(l.path,["-m","compileall","scripts"],{encoding:"utf8",cwd:a});u.status===0?(console.log("\u2705 \u6210\u529F\u7F16\u8BD1\u6240\u6709 Python \u6587\u4EF6"),await k(n.join(a,"scripts"))):(console.error("\u274C \u7F16\u8BD1 Python \u6587\u4EF6\u5931\u8D25"),console.error(u.stderr),process.exit(1))}else console.warn("\u26A0\uFE0F \u672A\u68C0\u6D4B\u5230 Python 3.14\uFF0C\u8BF7\u786E\u4FDD\u5728\u76EE\u6807\u8FD0\u884C\u73AF\u5883\u5B89\u88C5 Python 3.14")}else if(c){const l=await te(e),u=n.join(a,"scripts");if(l.bundle?await(0,R.bundleLuaScripts)(u):console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u5355\u6587\u4EF6\u5408\u5E76\uFF08obfuscator.json bundle=false\uFF09"),!l.enabled)console.log("\u2139\uFE0F \u5DF2\u5173\u95ED Lua \u6DF7\u6DC6\uFF08obfuscator.json enabled=false\uFF09");else{const b=[],y=async m=>{const f=await i.readdir(m,{withFileTypes:!0});for(const d of f){const j=n.join(m,d.name);d.isDirectory()?await y(j):d.isFile()&&d.name.endsWith(".lua")&&b.push(j)}};await y(u);const v=ne(e);v||(console.error("\u274C \u672A\u627E\u5230 @gamely/prometheus-cli\uFF0C\u65E0\u6CD5\u6DF7\u6DC6 Lua"),process.exit(1));for(const m of b){const f=n.relative(u,m);console.log(`\u{1F6E0}\uFE0F \u6DF7\u6DC6 Lua: ${f} (preset=${l.preset})`);const d=(0,g.spawnSync)(process.execPath,[v,f,"--preset",l.preset],{cwd:u,encoding:"utf8"});d.status!==0&&(console.error("\u274C \u6DF7\u6DC6 Lua \u5931\u8D25:",f),console.error(d.stderr||d.stdout||""),process.exit(1));const j=f.replace(/\.lua$/,".obfuscated.lua"),w=n.join(u,j);await i.pathExists(w)&&(await i.remove(m),await i.move(w,m,{overwrite:!0}))}console.log("\u2705 Lua \u6DF7\u6DC6\u5B8C\u6210")}}await i.copy(n.join(e,"res"),n.join(a,"res")),await i.copy(n.join(e,"ui"),n.join(a,"ui"));for(const l of["logo.jpg","logo.png"]){const u=n.join(e,l);await i.pathExists(u)&&await i.copy(u,n.join(a,l))}const p=n.join(e,"dist"),x=n.join(e,"package.json"),O=n.join(a,"package.json"),h=await i.readJSON(x);delete h.scripts,delete h.devDependencies,delete h.dependencies,await i.writeJSON(O,h,{spaces:2}),await i.emptyDir(p);const _=n.join(p,"ms.zip"),D=n.join(p,"ms.msbundle");await V(a,_),await i.rename(_,D),await i.remove(a)};exports.buildAll=se;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.addVararg=c;function s(o){o.vararg=!0,t(o.body.body)}function a(o){switch(o.type){case"FuncExpr":s(o);break;case"UnaryExpr":a(o.arg);break;case"BinaryExpr":a(o.left),a(o.right);break;case"TableExpr":for(const e of o.fields)e.kind==="index"&&a(e.key),a(e.value);break;case"IndexExpr":a(o.object),a(o.index);break;case"MemberExpr":a(o.object);break;case"CallExpr":a(o.callee);for(const e of o.args)a(e);break;case"MethodCallExpr":a(o.object);for(const e of o.args)a(e);break;case"ParenExpr":a(o.exp);break;default:break}}function t(o){for(const e of o)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if(e.type==="WhileStat"&&a(e.cond),e.type==="RepeatStat"&&a(e.cond),e.type==="ForNumStat"&&(a(e.start),a(e.end),e.step&&a(e.step)),e.type==="ForInStat")for(const r of e.exps)a(r);t(e.body.body);break;case"IfStat":for(const r of e.clauses)a(r.cond),t(r.body.body);e.elseBody&&t(e.elseBody.body);break;case"FuncStat":case"LocalFuncStat":s(e.func);break;case"LocalStat":if(e.exps)for(const r of e.exps)a(r);break;case"AssignStat":for(const r of e.vars)a(r);for(const r of e.exps)a(r);break;case"CallStat":a(e.exp);break;case"ReturnStat":for(const r of e.exps)a(r);break;default:break}}function c(o){t(o.body)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.flattenControlFlow=C;function m(t){return{type:"NumberLiteral",raw:String(t),value:t}}function p(t){return{type:"NameExpr",name:t}}function f(t,n){return{type:"AssignStat",vars:t.map(e=>p(e)),exps:n}}function u(t,n){return f([t.stateName],[typeof n=="number"?m(n):n])}function k(t,n,e){return{type:"BinaryExpr",op:"or",left:{type:"BinaryExpr",op:"and",left:p(t),right:m(n)},right:m(e)}}function E(t,n,e){return{type:"BinaryExpr",op:t,left:n,right:e}}function S(t){const n=`__t${t.nextTemp}`;return t.nextTemp+=1,t.temps.push(n),n}function x(t){const n=t.nextState;return t.nextState+=1,t.states.set(n,[]),n}function o(t,n,e){t.states.get(n).push(e)}function F(t,n){for(const e of t)if(e.type==="LocalStat")for(const a of e.names)n.push(a.name);else if(e.type==="LocalFuncStat")n.push(e.name);else if(e.type==="ForNumStat")n.push(e.name),F(e.body.body,n);else if(e.type==="ForInStat")n.push(...e.names),F(e.body.body,n);else if(e.type==="DoStat"||e.type==="WhileStat"||e.type==="RepeatStat")F(e.body.body,n);else if(e.type==="IfStat"){for(const a of e.clauses)F(a.body.body,n);e.elseBody&&F(e.elseBody.body,n)}}function h(t,n,e,a){if(t.length===0)return n;const y=t.map(()=>x(e));for(let s=0;s<t.length;s+=1){const r=t[s];r.type==="LabelStat"&&e.userLabels.set(r.name,y[s])}for(let s=0;s<t.length;s+=1){const r=s+1<t.length?y[s+1]:n;I(e,y[s],t[s],r,a)}return y[0]}function I(t,n,e,a,y){switch(e.type){case"EmptyStat":case"LabelStat":o(t,n,u(t,a));return;case"AssignStat":case"CallStat":case"FuncStat":o(t,n,e),o(t,n,u(t,a));return;case"LocalStat":e.exps&&e.exps.length>0&&o(t,n,f(e.names.map(s=>s.name),e.exps)),o(t,n,u(t,a));return;case"LocalFuncStat":o(t,n,f([e.name],[e.func])),o(t,n,u(t,a));return;case"ReturnStat":o(t,n,e);return;case"BreakStat":o(t,n,u(t,y));return;case"GotoStat":{const s=t.userLabels.get(e.name);if(s===void 0)throw new Error(`goto \u672A\u5B9A\u4E49\u6807\u7B7E ::${e.name}::`);o(t,n,u(t,s));return}case"DoStat":o(t,n,u(t,h(e.body.body,a,t,y)));return;case"IfStat":{const s=S(t);let r=n;for(let l=0;l<e.clauses.length;l+=1){const b=l===e.clauses.length-1,d=h(e.clauses[l].body.body,a,t,y);let i=a;b?e.elseBody&&(i=h(e.elseBody.body,a,t,y)):i=x(t),o(t,r,f([s],[e.clauses[l].cond])),o(t,r,u(t,k(s,d,i))),b||(r=i)}e.clauses.length===0&&o(t,n,u(t,a));return}case"WhileStat":{const s=S(t),r=h(e.body.body,n,t,a);o(t,n,f([s],[e.cond])),o(t,n,u(t,k(s,r,a)));return}case"RepeatStat":{const s=S(t),r=x(t),l=h(e.body.body,r,t,a);o(t,n,u(t,l)),o(t,r,f([s],[e.cond])),o(t,r,u(t,k(s,a,l)));return}case"ForNumStat":{const s=e.name,r=S(t),l=S(t),b=S(t),d=x(t),i=x(t),L=x(t),g=x(t),N=h(e.body.body,g,t,a);o(t,n,f([s],[e.start])),o(t,n,f([r],[e.end])),o(t,n,f([l],[e.step??m(1)])),o(t,n,u(t,d)),o(t,d,f([b],[E(">=",p(l),m(0))])),o(t,d,u(t,k(b,i,L))),o(t,i,f([b],[E("<=",p(s),p(r))])),o(t,i,u(t,k(b,N,a))),o(t,L,f([b],[E(">=",p(s),p(r))])),o(t,L,u(t,k(b,N,a))),o(t,g,f([s],[E("+",p(s),p(l))])),o(t,g,u(t,d));return}case"ForInStat":{const s=S(t),r=S(t),l=S(t),b=S(t),d=x(t),i=[f([l],[p(e.names[0])]),...e.body.body],L=h(i,d,t,a),g=e.exps.slice();for(;g.length<3;)g.push({type:"NilLiteral"});o(t,n,f([s,r,l],g.slice(0,3))),o(t,n,u(t,d)),o(t,d,{type:"AssignStat",vars:e.names.map(N=>p(N)),exps:[{type:"CallExpr",callee:p(s),args:[p(r),p(l)]}]}),o(t,d,f([b],[E("~=",p(e.names[0]),{type:"NilLiteral"})])),o(t,d,u(t,k(b,L,a)));return}default:o(t,n,u(t,a))}}function v(t,n){const e=t.slice();let a=n>>>0||1;for(let y=e.length-1;y>0;y-=1){a=Math.imul(a,1664525)+1013904223>>>0;const s=a%(y+1),r=e[y];e[y]=e[s],e[s]=r}return e}function w(t,n){if(t.length===0)return t;const e={states:new Map,temps:[],nextState:1,nextTemp:1,stateName:"__s",userLabels:new Map},a=[];F(t,a);const y=h(t,0,e,0),s=[...new Set([...a,...e.temps,e.stateName])],r=v([...e.states.keys()],n).map(l=>({cond:E("==",p(e.stateName),m(l)),body:{type:"Block",body:e.states.get(l)}}));return[{type:"LocalStat",names:s.map(l=>({name:l}))},f([e.stateName],[m(y)]),{type:"WhileStat",cond:E("~=",p(e.stateName),m(0)),body:{type:"Block",body:[{type:"IfStat",clauses:r}]}}]}function c(t,n){switch(t.type){case"FuncExpr":B(t.body.body,n),t.body.body=w(t.body.body,n);break;case"UnaryExpr":c(t.arg,n);break;case"BinaryExpr":c(t.left,n),c(t.right,n);break;case"TableExpr":for(const e of t.fields)e.kind==="index"&&c(e.key,n),c(e.value,n);break;case"IndexExpr":c(t.object,n),c(t.index,n);break;case"MemberExpr":c(t.object,n);break;case"CallExpr":c(t.callee,n);for(const e of t.args)c(e,n);break;case"MethodCallExpr":c(t.object,n);for(const e of t.args)c(e,n);break;case"ParenExpr":c(t.exp,n);break;default:break}}function B(t,n){for(const e of t)switch(e.type){case"DoStat":case"WhileStat":case"RepeatStat":case"ForNumStat":case"ForInStat":if((e.type==="WhileStat"||e.type==="RepeatStat")&&c(e.cond,n),e.type==="ForNumStat"&&(c(e.start,n),c(e.end,n),e.step&&c(e.step,n)),e.type==="ForInStat")for(const a of e.exps)c(a,n);B(e.body.body,n);break;case"IfStat":for(const a of e.clauses)c(a.cond,n),B(a.body.body,n);e.elseBody&&B(e.elseBody.body,n);break;case"FuncStat":case"LocalFuncStat":B(e.func.body.body,n),e.func.body.body=w(e.func.body.body,n);break;case"LocalStat":if(e.exps)for(const a of e.exps)c(a,n);break;case"AssignStat":for(const a of e.vars)c(a,n);for(const a of e.exps)c(a,n);break;case"CallStat":c(e.exp,n);break;case"ReturnStat":for(const a of e.exps)c(a,n);break;default:break}}function C(t,n){B(t.body,n),t.body=w(t.body,n)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.shortName=r,exports.renameLocals=c;const u=require("./reserved"),d=require("./scope"),l="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function r(a){let e=a,t="";do t=l[e%l.length]+t,e=Math.floor(e/l.length)-1;while(e>=0);return u.luaKeywords.has(t)?`_${t}`:t}function c(a){let e=0;const t=new Set;(0,d.collectAndRename)(a,(o,s)=>{if(o.newName!==o.original)return;let n=r(e);for(e+=1;s.has(n)||t.has(n)||u.luaKeywords.has(n);)n=r(e),e+=1;o.newName=n,t.add(n),s.add(n)})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.resolveLocal=i,exports.collectAndRename=x;function i(t,c){let r=t;for(;r;){const e=r.locals.get(c);if(e)return e;r=r.parent}}function o(t){return{parent:t,locals:new Map}}function f(t,c){const r=t.locals.get(c);if(r)return r;const e={original:c,newName:c};return t.locals.set(c,e),e}function x(t,c){const r=new Set,e={locals:new Map};d(t.body,e,r,c)}function l(t,c,r,e){d(t.body,c,r,e)}function d(t,c,r,e){for(const s of t)b(s,c,r,e)}function m(t,c,r,e){const s=o(c),a=t.params.slice();for(let u=0;u<a.length;u+=1){const p=f(s,a[u]);e(p,r),t.params[u]=p.newName}l(t.body,s,r,e)}function b(t,c,r,e){switch(t.type){case"EmptyStat":case"BreakStat":case"GotoStat":case"LabelStat":return;case"DoStat":l(t.body,o(c),r,e);return;case"WhileStat":n(t.cond,c,r,e),l(t.body,o(c),r,e);return;case"RepeatStat":{const s=o(c);l(t.body,s,r,e),n(t.cond,s,r,e);return}case"IfStat":for(const s of t.clauses)n(s.cond,c,r,e),l(s.body,o(c),r,e);t.elseBody&&l(t.elseBody,o(c),r,e);return;case"ForNumStat":{n(t.start,c,r,e),n(t.end,c,r,e),t.step&&n(t.step,c,r,e);const s=o(c),a=f(s,t.name);e(a,r),t.name=a.newName,l(t.body,s,r,e);return}case"ForInStat":{for(const a of t.exps)n(a,c,r,e);const s=o(c);for(let a=0;a<t.names.length;a+=1){const u=f(s,t.names[a]);e(u,r),t.names[a]=u.newName}l(t.body,s,r,e);return}case"FuncStat":{const s=i(c,t.name.base);s&&(t.name.base=s.newName),m(t.func,c,r,e);return}case"LocalFuncStat":{const s=f(c,t.name);e(s,r),t.name=s.newName,m(t.func,c,r,e);return}case"LocalStat":if(t.exps)for(const s of t.exps)n(s,c,r,e);for(let s=0;s<t.names.length;s+=1){const a=f(c,t.names[s].name);e(a,r),t.names[s].name=a.newName}return;case"AssignStat":for(const s of t.vars)n(s,c,r,e);for(const s of t.exps)n(s,c,r,e);return;case"CallStat":n(t.exp,c,r,e);return;case"ReturnStat":for(const s of t.exps)n(s,c,r,e);return}}function n(t,c,r,e){switch(t.type){case"NilLiteral":case"BoolLiteral":case"NumberLiteral":case"StringLiteral":case"VarargExpr":return;case"NameExpr":{const s=i(c,t.name);s&&(t.name=s.newName);return}case"UnaryExpr":n(t.arg,c,r,e);return;case"BinaryExpr":n(t.left,c,r,e),n(t.right,c,r,e);return;case"FuncExpr":m(t,c,r,e);return;case"TableExpr":for(const s of t.fields)s.kind==="index"&&n(s.key,c,r,e),n(s.value,c,r,e);return;case"IndexExpr":n(t.object,c,r,e),n(t.index,c,r,e);return;case"MemberExpr":n(t.object,c,r,e);return;case"CallExpr":n(t.callee,c,r,e);for(const s of t.args)n(s,c,r,e);return;case"MethodCallExpr":n(t.object,c,r,e);for(const s of t.args)n(s,c,r,e);return;case"ParenExpr":n(t.exp,c,r,e);return}}
|
package/docs/AGENTS.md
CHANGED
|
@@ -4,20 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带 `ms` CLI 能力回答问题与编写代码。
|
|
6
6
|
|
|
7
|
-
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js
|
|
7
|
+
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。不要臆造不存在的 API、对象、参数、行为或运行机制。遇到文档未确认、工具未提供或当前项目未实现的能力,必须明确说明限制,并给出保守方案。
|
|
8
8
|
|
|
9
9
|
## 基本规则
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
12
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
13
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
14
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
14
15
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
15
16
|
- Lua 只提供英文方法,没有中文别名。
|
|
16
|
-
- Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
17
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
18
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
19
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
17
20
|
- 不要把快点JS Python 脚本当成普通 CPython 脚本。
|
|
18
21
|
- 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
|
|
19
22
|
- 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
|
|
20
|
-
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
21
23
|
- 文档未确认的能力必须明确说明无法确认,不要凭经验补全。
|
|
22
24
|
|
|
23
25
|
## 目录职责
|
|
@@ -29,7 +31,7 @@
|
|
|
29
31
|
- `res`:脚本运行真正依赖的资源文件,如图片、模板等。
|
|
30
32
|
- `screenshot`:调试、预览和问题定位产生的截图。
|
|
31
33
|
|
|
32
|
-
不要把快点JS项目改写成通用 Web、Node.js
|
|
34
|
+
不要把快点JS项目改写成通用 Web、Node.js、Python 或桌面 Lua 项目结构。截图、节点树和长文本结果优先写入文件,避免 MCP 响应被截断。
|
|
33
35
|
|
|
34
36
|
资源保存规则:
|
|
35
37
|
|
|
@@ -44,14 +46,15 @@
|
|
|
44
46
|
|
|
45
47
|
MCP 入口:
|
|
46
48
|
|
|
47
|
-
1. 使用 `get_docs_paths`
|
|
48
|
-
2.
|
|
49
|
-
3.
|
|
49
|
+
1. 使用 `get_docs_paths` 获取文档根目录、JS 文档目录、中文 JS 文档目录、Python 文档目录、Lua 文档目录和 HTTP API 文档路径。
|
|
50
|
+
2. 根据项目语言选择 `docs/api`、`docs/apicn`、`docs/apipython` 或 `docs/apilua`。
|
|
51
|
+
3. 直接读取对应 markdown 文件。
|
|
52
|
+
4. 只依据已读取的本地文档内容回答或编写代码。
|
|
50
53
|
|
|
51
54
|
CLI 入口:
|
|
52
55
|
|
|
53
56
|
1. 使用 `npx ms docs paths` 获取同一组本地文档路径。
|
|
54
|
-
2.
|
|
57
|
+
2. 根据项目语言选择对应目录后直接读取 markdown 文件。
|
|
55
58
|
3. 只使用文档中已经确认的 API。
|
|
56
59
|
|
|
57
60
|
## HTTP API 工作流
|
|
@@ -107,7 +110,7 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
107
110
|
npx ms package
|
|
108
111
|
```
|
|
109
112
|
|
|
110
|
-
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js
|
|
113
|
+
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js、浏览器、Python 或桌面 Lua 命令替代 MCP 或项目自带 `ms` CLI。
|
|
111
114
|
|
|
112
115
|
## 工具分组
|
|
113
116
|
|
|
@@ -146,7 +149,7 @@ npx ms package
|
|
|
146
149
|
|
|
147
150
|
## 工具选择规则
|
|
148
151
|
|
|
149
|
-
- 写快点JS
|
|
152
|
+
- 写快点JS脚本代码:先看 `scripts/main.js`、`scripts/main.ts`、`scripts/main.py` 或 `scripts/main.lua` 确认语言,再读取对应本地 API 文档。
|
|
150
153
|
- 调设备 HTTP API:先读取本地 HTTP API 文档,再调用 `http_api_call` 或 `npx ms http-call`。
|
|
151
154
|
- 获取截图:使用 `take_screenshot` 或 `npx ms screenshot`。
|
|
152
155
|
- 获取节点 XML:使用 `get_node_source` 或 `npx ms source --mode 1`。
|
|
@@ -189,7 +192,8 @@ UI 预览发起后不需要长时间等待结果,可以通过截图查看当
|
|
|
189
192
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
190
193
|
- 不要臆造快点JS API、对象、参数、返回值或运行机制。
|
|
191
194
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
192
|
-
- 不要把快点JS当成普通 Node.js
|
|
195
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
196
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
193
197
|
- 不要对快点JS Python 脚本运行 `py_compile` 或其他 CPython 编译校验。
|
|
194
198
|
- 不要在没有读取本地 HTTP API 文档的情况下调用 `http_api_call` 或 `ms http-call`。
|
|
195
199
|
- 不要把完整 URL 传给 `http_api_call.path`,只能传 `/api/...`、`/logger/...`、`/mirror/...` 这类相对路径。
|
package/docs/SKILL.md
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: kuaijs-mcp
|
|
3
|
-
description: 快点JS专用开发助手。用于快点JS项目开发、本地 API 文档读取、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志查看、OCR、项目运行和打包;MCP 工具和项目自带 ms CLI 都可以使用,但必须依据快点JS文档与项目结构,不臆造 API 或运行机制。
|
|
3
|
+
description: 快点JS专用开发助手。用于快点JS 的 JavaScript / Python / Lua 项目开发、本地 API 文档读取、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志查看、OCR、项目运行和打包;MCP 工具和项目自带 ms CLI 都可以使用,但必须依据快点JS文档与项目结构,不臆造 API 或运行机制。
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# 快点JS开发技能
|
|
7
7
|
|
|
8
8
|
## 使用场景
|
|
9
9
|
|
|
10
|
-
当任务涉及快点JS项目开发、快点JS API、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志、OCR、项目运行或打包时,使用本技能。
|
|
10
|
+
当任务涉及快点JS 的 JavaScript / Python / Lua 项目开发、快点JS API、iOS 设备自动化、HTTP API 调用、截图、节点 XML、日志、OCR、项目运行或打包时,使用本技能。
|
|
11
11
|
|
|
12
12
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带命令能力回答问题与编写代码。
|
|
13
13
|
|
|
14
14
|
## 基本约束
|
|
15
15
|
|
|
16
16
|
- 不要臆造不存在的 API、对象、参数、行为或运行机制。
|
|
17
|
-
- 不要把快点JS当成普通 Node.js
|
|
18
|
-
-
|
|
19
|
-
- JavaScript 项目使用 JavaScript
|
|
20
|
-
-
|
|
17
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
18
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
19
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
20
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
21
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
21
22
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
22
23
|
- Lua 只提供英文方法,没有中文别名。
|
|
23
|
-
- Lua 宿主模块是内置全局表(如 `device`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
24
|
-
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua
|
|
24
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
25
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
26
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
25
27
|
- 文档未确认的能力必须明确说明无法确认,并给出保守方案。
|
|
26
28
|
- 快点JS Python 脚本不使用 CPython 编译校验;不要运行 `python -m py_compile`、`py_compile` 或类似命令。
|
|
27
29
|
|
|
@@ -88,14 +90,15 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
88
90
|
|
|
89
91
|
MCP 入口:
|
|
90
92
|
|
|
91
|
-
1. 使用 `get_docs_paths`
|
|
92
|
-
2.
|
|
93
|
-
3.
|
|
93
|
+
1. 使用 `get_docs_paths` 获取文档根目录、JS 文档目录、中文 JS 文档目录、Python 文档目录、Lua 文档目录和 HTTP API 文档路径。
|
|
94
|
+
2. 根据项目语言选择 `docs/api`、`docs/apicn`、`docs/apipython` 或 `docs/apilua`。
|
|
95
|
+
3. 直接读取对应 markdown 文件。
|
|
96
|
+
4. 只依据已读取的本地文档内容回答或编写代码。
|
|
94
97
|
|
|
95
98
|
CLI 入口:
|
|
96
99
|
|
|
97
100
|
1. 使用 `npx ms docs paths` 获取同一组本地文档路径。
|
|
98
|
-
2.
|
|
101
|
+
2. 根据项目语言选择对应目录后直接读取 markdown 文件。
|
|
99
102
|
3. 只使用文档中已经确认的 API。
|
|
100
103
|
|
|
101
104
|
## HTTP API 工作流
|
|
@@ -206,10 +209,13 @@ CLI 入口:
|
|
|
206
209
|
## 禁止事项
|
|
207
210
|
|
|
208
211
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
212
|
+
- 不要混用 JavaScript、Python 与 Lua API。
|
|
213
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
209
214
|
- 不要调用 HTTP API 文档中未声明的接口。
|
|
210
215
|
- 不要把完整 URL 传给 `http_api_call.path`。
|
|
211
216
|
- 不要用未确认的通用命令替代 KuaiJS MCP 或项目自带 `ms` CLI。
|
|
212
217
|
- 不要对 `scripts/*.py` 运行 `py_compile` 或把快点JS Python 当 CPython 编译。
|
|
218
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
213
219
|
- 不要假设设备、工作区或运行环境已经准备好。
|
|
214
220
|
|
|
215
221
|
## 文档入口
|
|
@@ -4,18 +4,22 @@
|
|
|
4
4
|
|
|
5
5
|
你是快点JS专用开发助手,只服务于快点JS这一特定执行环境。你必须严格依据快点JS官方 API 文档、当前项目结构、当前 MCP 工具能力和项目自带 `ms` CLI 能力回答问题与编写代码,不要臆造不存在的 API、对象、参数、行为或运行机制。
|
|
6
6
|
|
|
7
|
-
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js
|
|
7
|
+
始终把快点JS当成特定 iOS 自动化环境,而不是普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。遇到文档未确认、工具未提供或当前项目未实现的能力,必须明确说明限制,并给出保守方案。
|
|
8
8
|
|
|
9
9
|
## 基本原则
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- 先看 `scripts` 入口确认语言:`main.js` / `main.ts` 为 JavaScript,`main.py` 为 Python,`main.lua` 为 Lua。
|
|
12
|
+
- JavaScript 项目使用 JavaScript 文档与写法(`docs/api` 或 `docs/apicn`)。
|
|
13
|
+
- Python 项目使用 Python 文档与写法(`docs/apipython`)。
|
|
14
|
+
- Lua 项目使用 Lua 文档与写法(`docs/apilua`)。
|
|
14
15
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
16
|
+
- Lua 只提供英文方法,没有中文别名。
|
|
17
|
+
- Lua 宿主模块是内置全局表(如 `device`、`image`、`ui`),不要 `require`;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
|
|
15
18
|
- 不要把快点JS Python 脚本当成普通 CPython 脚本。
|
|
16
19
|
- 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
|
|
17
20
|
- 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
|
|
18
|
-
- Lua
|
|
21
|
+
- Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;可用 `obfuscator.json` 的 `bundle: false` 关闭合并。不要用 `dofile` / `loadfile` 按路径加载这些文件。
|
|
22
|
+
- 不要把快点JS Lua 当成桌面 Lua / LuaRocks 环境。
|
|
19
23
|
- 文档未确认的能力必须明确说明无法确认,不要凭经验补全。
|
|
20
24
|
|
|
21
25
|
## 允许的执行方式
|
|
@@ -54,7 +58,7 @@ npx ms stop -i <device-ip> --port <port>
|
|
|
54
58
|
npx ms package
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js
|
|
61
|
+
`build`、`package`、`run`、`run-ui` 需要在快点JS项目根目录运行,项目根目录通常包含 `package.json` 和 `scripts/`。文档路径、HTTP API 调用、截图、节点、日志、OCR、图片处理、停止和 WS 状态命令可以在任意目录使用。不要用未确认的通用 Node.js、浏览器、Python 或桌面 Lua 命令替代 MCP 或项目自带 `ms` CLI。
|
|
58
62
|
|
|
59
63
|
## 文档优先
|
|
60
64
|
|
|
@@ -115,7 +119,7 @@ CLI 入口:
|
|
|
115
119
|
- `res`:脚本运行真正依赖的资源文件,如图片、模板等。
|
|
116
120
|
- `screenshot`:调试、预览和问题定位产生的截图。
|
|
117
121
|
|
|
118
|
-
不要把快点JS项目改写成通用 Web、Node.js
|
|
122
|
+
不要把快点JS项目改写成通用 Web、Node.js、Python 或桌面 Lua 项目结构。截图、节点树和长文本结果优先写入文件,避免 MCP 响应被截断。
|
|
119
123
|
|
|
120
124
|
资源保存规则:
|
|
121
125
|
|
|
@@ -171,7 +175,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
171
175
|
|
|
172
176
|
## 工具选择规则
|
|
173
177
|
|
|
174
|
-
- 写快点JS
|
|
178
|
+
- 写快点JS脚本代码:先看 `scripts/main.js`、`scripts/main.ts`、`scripts/main.py` 或 `scripts/main.lua` 确认语言,再读取对应本地 API 文档。
|
|
175
179
|
- 调设备 HTTP API:先读取本地 HTTP API 文档,再调用 `http_api_call` 或 `npx ms http-call`。
|
|
176
180
|
- 获取截图:使用 `take_screenshot` 或 `npx ms screenshot`。
|
|
177
181
|
- 从本地图片裁切找图模板:使用 `image_crop` 或 `npx ms image-crop`,输出到 `res`。
|
|
@@ -188,7 +192,7 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
188
192
|
- 停止项目:使用 `stop_project` 或 `npx ms stop`。
|
|
189
193
|
- 打包项目:使用 `package_project` 或 `npx ms package`。
|
|
190
194
|
|
|
191
|
-
对设备操作使用 MCP 工具或项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js
|
|
195
|
+
对设备操作使用 MCP 工具或项目自带 `ms` CLI;不要改写成未确认的通用构建命令,也不要假设存在浏览器、Node.js、通用 Python 或桌面 Lua 运行时能力。
|
|
192
196
|
|
|
193
197
|
## 验证要求
|
|
194
198
|
|
|
@@ -206,7 +210,8 @@ UI 预览发起后不需要长时间等待结果,可以通过 `take_screenshot
|
|
|
206
210
|
- 不要在没有读取本地文档的情况下回答 API 用法或编写 API 调用代码。
|
|
207
211
|
- 不要臆造快点JS API、对象、参数、返回值或运行机制。
|
|
208
212
|
- 不要混用 JavaScript、Python 与 Lua API。
|
|
209
|
-
- 不要把快点JS当成普通 Node.js
|
|
213
|
+
- 不要把快点JS当成普通 Node.js、浏览器、通用 Python 或桌面 Lua 环境。
|
|
214
|
+
- 不要 `require` Lua 宿主模块,也不要用 `dofile` / `loadfile` 加载会在 Release 中被合并的用户模块。
|
|
210
215
|
- 不要对快点JS Python 脚本运行 `py_compile` 或其他 CPython 编译校验。
|
|
211
216
|
- 不要在没有读取本地 HTTP API 文档的情况下调用 `http_api_call` 或 `ms http-call`。
|
|
212
217
|
- 不要把完整 URL 传给 `http_api_call.path`,只能传 `/api/...`、`/logger/...`、`/mirror/...` 这类相对路径。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms-vite-plugin",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.84",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"jpeg-js": "^0.4.4",
|
|
32
32
|
"magic-string": "^0.30.21",
|
|
33
33
|
"pngjs": "^7.0.0",
|
|
34
|
+
"pyright": "^1.1.414",
|
|
34
35
|
"uuid": "^14.0.0",
|
|
35
36
|
"vite": "^8.0.13",
|
|
36
37
|
"vite-plugin-bundle-obfuscator": "^1.12.0",
|