ozmoz 0.1.39 → 0.1.41

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/cli.cjs CHANGED
@@ -628,7 +628,7 @@ ${JSON.stringify(t||{},null,2)}
628
628
  \`\`\`
629
629
  `}function Me(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function Ze(e,t){let r=B(e),n=s.existsSync(a.join(e,"svro.schema.json"));(r.OZ_DB_KEY||n)&&(y("Cannot create project: an OZmoz project already exists in this folder."),u('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let i=(t||"").trim();i||(y('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let o=a.join(e,".ozmoz.lock");if(s.existsSync(o)){let c=!1;try{let h=Number(s.readFileSync(o,"utf8"));Date.now()-h>6e4&&(c=!0)}catch{c=!0}c||(y("A project creation is already running in this folder."),process.exit(1)),s.unlinkSync(o)}s.writeFileSync(o,String(Date.now()));let l=()=>{if(s.existsSync(o))try{s.unlinkSync(o)}catch{}};try{let c=process.env.FLEETBO_DEV_TOKEN;if(!c){let w=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(w))try{c=JSON.parse(s.readFileSync(w,"utf8")).devToken}catch{}}c||(l(),y('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),u(`[OZmoz] Creating project "${i}" on Cloud...`);let h=Me(i),m=[h,`${h.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${h.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],f=null,p=null;for(let w of m)try{let b=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:JSON.stringify({data:{name:i,keyApp:w}})}),v=await b.json();if(b.ok&&!v.error){f={keyApp:w,data:v.result?.data||v.data||{}};break}else p=v.error?.message||`HTTP ${b.status}`}catch(b){p=b.message}f||(l(),y(`Failed to create project on Cloud: ${p||"Unknown error"}`),process.exit(1));let g=f.data.bootstrapToken;await K(e,[`--keyApp=${f.keyApp}`,`--token=${g}`]);let E=a.join(e,"package.json");Y(e,E),await te(e,[]),u(`
630
630
  [OZmoz] Project "${i}" (${f.keyApp}) created and configured successfully.`),u(`AI AGENTS: do NOT stop here and do NOT ask the user to restart. Continue NOW in the same turn: scaffold the frontend if missing, run "npx ozmoz sync", read ozmoz_contract.md, write ALL views in trial mode (OZ_PROTOTYPE=true), then start the dev server and ask the user to validate.
631
- `)}finally{if(s.existsSync(o))try{s.unlinkSync(o)}catch{}}}async function Ue(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let O=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(O))try{t=JSON.parse(s.readFileSync(O,"utf8")).devToken}catch{}}let n=B(e).OZ_KEY_APP;(!n||!t)&&(y("Cannot update: project uninitialized or dev token missing."),process.exit(1));let i=s.existsSync(a.join(e,"src"))?a.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],c=0;function h(O){let d=[];try{d=s.readdirSync(O,{withFileTypes:!0})}catch{return}for(let z of d){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(z.name))continue;let S=a.join(O,z.name);if(z.isDirectory())h(S);else if(o.has(a.extname(z.name))&&!z.name.endsWith(".d.ts"))try{let T=s.statSync(S);if(T.size>3e5)continue;let F=s.readFileSync(S,"utf8");/oz\.|<oz-/i.test(F)&&(c+=T.size,l.push({name:a.relative(e,S).split(a.sep).join("/"),content:F}))}catch{}}}h(i);let m=C.find(O=>O.startsWith("--files=")),f=m?m.slice(8).split(",").map(O=>O.trim()).filter(Boolean):null;if(f&&f.length>0)for(let O of f){let d=a.resolve(e,O);if(s.existsSync(d)){let z=s.readFileSync(d,"utf8");c+=s.statSync(d).size,l.push({name:a.relative(e,d).split(a.sep).join("/"),content:z})}}else h(i);l.length===0&&(y("Cannot update: no components using oz.* found."),process.exit(1)),c>8*1024*1024&&(y("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let p=C.find(O=>O.startsWith("--rules=")),g=p?p.slice(8).trim():"",E=C.find(O=>O.startsWith("--reasoning=")),w=E?E.slice(12).trim().toLowerCase():void 0;w!=="standard"&&w!=="high"&&(y("Missing or invalid --reasoning=<standard|high>."),y("If you are an AI agent: ask the user which analysis depth they want (numbered [1]/[2] choice, recommended option first) before running this command, then pass --reasoning=standard or --reasoning=high accordingly. Never pick it yourself."),process.exit(1)),u(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let O,d,z;for(let S=1;S<=3&&(O=await fetch("https://updateprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({data:{keyApp:n,name:n,newViewFiles:l,oz_rules:g,reasoning:w}})}),d=await O.json().catch(()=>({})),z=d.result?.data||d.data||d,!(O.status<500||S===3));S++)u("\u2192 The modeling service is busy (attempt "+S+"/3). Retrying in 20s..."),await new Promise(T=>setTimeout(T,2e4));if(!O.ok||d.error||z.success===!1){let S=d.error?.message||z.warnings?.join(", ")||d.message||"Server error";y(`Update failed: ${S}`),process.exit(1)}u("\u2192 Cloud modeling response: "+JSON.stringify(d).slice(0,800))}catch(O){y(`Network error: ${O.message}`),process.exit(1)}u("\u2192 Structure modeled. Sealing into OZmoz SVRO Kernel...");let b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}),v=Date.now();for(let O=1;O<=5&&b.status===0;O++){let d=!1;try{let z=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8")),S=JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8"));d=Object.keys(z.collections||{}).length>0&&(S.sequences||[]).length>0}catch{}if(d)break;u("\u2192 Contract still empty, waiting for the cloud (attempt "+O+"/5, "+Math.round((Date.now()-v)/1e3)+"s elapsed)..."),await new Promise(z=>setTimeout(z,6e3)),b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e})}let N=!1,I=!1;try{let O=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8"));N=Object.keys(O.collections||{}).length>0,I=(JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8")).sequences||[]).length>0}catch{}b.status===0&&N&&I?u(`
631
+ `)}finally{if(s.existsSync(o))try{s.unlinkSync(o)}catch{}}}async function Ue(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let O=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(O))try{t=JSON.parse(s.readFileSync(O,"utf8")).devToken}catch{}}let n=B(e).OZ_KEY_APP;(!n||!t)&&(y("Cannot update: project uninitialized or dev token missing."),process.exit(1));let i=s.existsSync(a.join(e,"src"))?a.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],c=0;function h(O){let d=[];try{d=s.readdirSync(O,{withFileTypes:!0})}catch{return}for(let z of d){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(z.name))continue;let S=a.join(O,z.name);if(z.isDirectory())h(S);else if(o.has(a.extname(z.name))&&!z.name.endsWith(".d.ts"))try{let T=s.statSync(S);if(T.size>3e5)continue;let F=s.readFileSync(S,"utf8");/oz\.|<oz-/i.test(F)&&(c+=T.size,l.push({name:a.relative(e,S).split(a.sep).join("/"),content:F}))}catch{}}}let m=C.find(O=>O.startsWith("--files=")),f=m?m.slice(8).split(",").map(O=>O.trim()).filter(Boolean):null;if(f&&f.length>0)for(let O of f){let d=a.resolve(e,O);if(s.existsSync(d)){let z=s.readFileSync(d,"utf8");c+=s.statSync(d).size,l.push({name:a.relative(e,d).split(a.sep).join("/"),content:z})}}else h(i);l.length===0&&(y("Cannot update: no components using oz.* found."),process.exit(1)),c>8*1024*1024&&(y("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let p=C.find(O=>O.startsWith("--rules=")),g=p?p.slice(8).trim():"",E=C.find(O=>O.startsWith("--reasoning=")),w=E?E.slice(12).trim().toLowerCase():void 0;w!=="standard"&&w!=="high"&&(y("Missing or invalid --reasoning=<standard|high>."),y("If you are an AI agent: ask the user which analysis depth they want (numbered [1]/[2] choice, recommended option first) before running this command, then pass --reasoning=standard or --reasoning=high accordingly. Never pick it yourself."),process.exit(1)),u(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let O,d,z;for(let S=1;S<=3&&(O=await fetch("https://updateprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({data:{keyApp:n,name:n,newViewFiles:l,oz_rules:g,reasoning:w}})}),d=await O.json().catch(()=>({})),z=d.result?.data||d.data||d,!(O.status<500||S===3));S++)u("\u2192 The modeling service is busy (attempt "+S+"/3). Retrying in 20s..."),await new Promise(T=>setTimeout(T,2e4));if(!O.ok||d.error||z.success===!1){let S=d.error?.message||z.warnings?.join(", ")||d.message||"Server error";y(`Update failed: ${S}`),process.exit(1)}u("\u2192 Cloud modeling response: "+JSON.stringify(d).slice(0,800))}catch(O){y(`Network error: ${O.message}`),process.exit(1)}u("\u2192 Structure modeled. Sealing into OZmoz SVRO Kernel...");let b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}),v=Date.now();for(let O=1;O<=5&&b.status===0;O++){let d=!1;try{let z=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8")),S=JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8"));d=Object.keys(z.collections||{}).length>0&&(S.sequences||[]).length>0}catch{}if(d)break;u("\u2192 Contract still empty, waiting for the cloud (attempt "+O+"/5, "+Math.round((Date.now()-v)/1e3)+"s elapsed)..."),await new Promise(z=>setTimeout(z,6e3)),b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e})}let N=!1,I=!1;try{let O=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8"));N=Object.keys(O.collections||{}).length>0,I=(JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8")).sequences||[]).length>0}catch{}b.status===0&&N&&I?u(`
632
632
  [OZmoz] Contract locked into SVRO Kernel.
633
633
  `):b.status===0&&N&&!I?(y(`
634
634
  [OZmoz] Contract incomplete: the workflow is empty. Rerun the update before writing any code.