ozmoz 0.1.32 → 0.1.33

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.
Files changed (2) hide show
  1. package/dist/cli.cjs +32 -32
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -1,33 +1,33 @@
1
1
  #!/usr/bin/env node
2
- var i=require("fs"),c=require("path"),W=require("https"),ne=require("http"),T=require("os"),{exec:oe,spawnSync:x}=require("child_process"),re=[c.join(__dirname,"..","scripts","setup-lib.cjs"),c.join(__dirname,"..","..","scripts","setup-lib.cjs"),c.join(__dirname,"scripts","setup-lib.cjs")],se=re.find(i.existsSync)||c.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:Y,handleAuthAndEnv:K,touchTsConfig:ie,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce,writeBrowserConfig:le,patchAllowScripts:de}=require(se),ue=!!(process.stdout&&process.stdout.isTTY&&typeof process.stdout.hasColors=="function"&&process.stdout.hasColors(16777216)),pe=ue?"\x1B[38;2;15;156;140m":"\x1B[36m",me="\x1B[31m",q="\x1B[0m";function d(e){console.log(e.replace(/OZmoz|\[|\]|→/g,t=>`${pe}${t}${q}`))}function O(e){console.error(`${me}${e}${q}`)}var k="ozmoz",G=/<!--\s*(?:ozmoz|fleetbo|OZmoz):start[^>]*-->[\s\S]*?<!--\s*(?:ozmoz|fleetbo|OZmoz):end\s*-->/i,fe="<!-- OZmoz:end -->",H="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",F={claude:"Claude Code",cursor:"Cursor",windsurf:"Windsurf",devin:"Devin",codex:"Codex CLI",gemini:"Gemini CLI",antigravity:"Antigravity CLI",copilot:"GitHub Copilot"},j={created:"created",updated:"updated",unchanged:"already up to date",appended:"OZmoz block appended (your own content was kept)",migrated:"old file replaced (backup: <file>.ozmoz-legacy.bak)",invalid:"skipped: the file is not valid JSON, fix or delete it first"};function he(){try{return JSON.parse(i.readFileSync(c.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}var ge=Buffer.from("QUl6YVN5QUM1Uk94STNibklPMUR5TmZsTWhGUnJ0blItNDVwNFJF","base64").toString("utf8");function ye(e){try{let t=JSON.parse(Buffer.from(e.split(".")[1],"base64url").toString("utf8"));return typeof t.exp=="number"&&t.exp*1e3<Date.now()+6e4}catch{return!1}}async function Oe(e,t){let r=await fetch(`https://securetoken.googleapis.com/v1/token?key=${ge}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(t)}`});if(!r.ok)return null;let n=await r.json();return n.id_token?(i.writeFileSync(e,JSON.stringify({devToken:n.id_token,refreshToken:n.refresh_token||t,updatedAt:new Date().toISOString()},null,2)),n.id_token):null}async function ze(){if(process.env.FLEETBO_DEV_TOKEN)return process.env.FLEETBO_DEV_TOKEN;try{let e=c.join(T.homedir(),".fleetbo","credentials.json");if(i.existsSync(e)){let t=JSON.parse(i.readFileSync(e,"utf8"));if(t.devToken&&!ye(t.devToken))return t.devToken;if(t.refreshToken)try{let r=await Oe(e,t.refreshToken);if(r)return r}catch{}}}catch{}return null}async function X(){let e=c.join(T.homedir(),".fleetbo","guidelines.json"),t=await ze();t||O('[OZmoz] Not logged in: run "npx ozmoz login" first to load the full instructions. Using local cache if available.');try{d("[OZmoz] Fetching instructions from Cloud...");let r=await fetch("https://getagentdirectives-jqycakhlxa-uc.a.run.app",{method:"POST",headers:Object.assign({"Content-Type":"application/json"},t?{Authorization:`Bearer ${t}`}:{}),body:JSON.stringify({data:{}})});if(!r.ok)O("[OZmoz] Cloud error HTTP "+r.status);else{let n=await r.json(),s=n.result?.data||n.result||n.data;if(s&&s.protocol&&s.directives)return d("[OZmoz] Instructions loaded successfully."),i.existsSync(c.dirname(e))||i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,JSON.stringify(s,null,2),"utf8"),s;O("[OZmoz] Empty Cloud response.")}}catch(r){O("[OZmoz] Network error: "+r.message)}if(i.existsSync(e)){d("[OZmoz] Using local cache (~/.fleetbo/guidelines.json)");try{return JSON.parse(i.readFileSync(e,"utf8"))}catch{}}return{protocol:"",directives:"",version:"1.0.0"}}function V(e,t){return"<!-- ozmoz:start v"+e+` -->
2
+ var i=require("fs"),c=require("path"),W=require("https"),ne=require("http"),b=require("os"),{exec:oe,spawnSync:N}=require("child_process"),re=[c.join(__dirname,"..","scripts","setup-lib.cjs"),c.join(__dirname,"..","..","scripts","setup-lib.cjs"),c.join(__dirname,"scripts","setup-lib.cjs")],se=re.find(i.existsSync)||c.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:Y,handleAuthAndEnv:K,touchTsConfig:ie,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce,writeBrowserConfig:le,patchAllowScripts:de}=require(se),ue=!!(process.stdout&&process.stdout.isTTY&&typeof process.stdout.hasColors=="function"&&process.stdout.hasColors(16777216)),pe=ue?"\x1B[38;2;15;156;140m":"\x1B[36m",me="\x1B[31m",q="\x1B[0m";function d(e){console.log(e.replace(/OZmoz|\[|\]|→/g,t=>`${pe}${t}${q}`))}function O(e){console.error(`${me}${e}${q}`)}var x="ozmoz",G=/<!--\s*(?:ozmoz|fleetbo|OZmoz):start[^>]*-->[\s\S]*?<!--\s*(?:ozmoz|fleetbo|OZmoz):end\s*-->/i,fe="<!-- OZmoz:end -->",H="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",F={claude:"Claude Code",cursor:"Cursor",windsurf:"Windsurf",devin:"Devin",codex:"Codex CLI",gemini:"Gemini CLI",antigravity:"Antigravity CLI",copilot:"GitHub Copilot"},j={created:"created",updated:"updated",unchanged:"already up to date",appended:"OZmoz block appended (your own content was kept)",migrated:"old file replaced (backup: <file>.ozmoz-legacy.bak)",invalid:"skipped: the file is not valid JSON, fix or delete it first"};function he(){try{return JSON.parse(i.readFileSync(c.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}var ge=Buffer.from("QUl6YVN5QUM1Uk94STNibklPMUR5TmZsTWhGUnJ0blItNDVwNFJF","base64").toString("utf8");function ye(e){try{let t=JSON.parse(Buffer.from(e.split(".")[1],"base64url").toString("utf8"));return typeof t.exp=="number"&&t.exp*1e3<Date.now()+6e4}catch{return!1}}async function Oe(e,t){let r=await fetch(`https://securetoken.googleapis.com/v1/token?key=${ge}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(t)}`});if(!r.ok)return null;let n=await r.json();return n.id_token?(i.writeFileSync(e,JSON.stringify({devToken:n.id_token,refreshToken:n.refresh_token||t,updatedAt:new Date().toISOString()},null,2)),n.id_token):null}async function ze(){if(process.env.FLEETBO_DEV_TOKEN)return process.env.FLEETBO_DEV_TOKEN;try{let e=c.join(b.homedir(),".fleetbo","credentials.json");if(i.existsSync(e)){let t=JSON.parse(i.readFileSync(e,"utf8"));if(t.devToken&&!ye(t.devToken))return t.devToken;if(t.refreshToken)try{let r=await Oe(e,t.refreshToken);if(r)return r}catch{}}}catch{}return null}async function X(){let e=c.join(b.homedir(),".fleetbo","guidelines.json"),t=await ze();t||O('[OZmoz] Not logged in: run "npx ozmoz login" first to load the full instructions. Using local cache if available.');try{d("[OZmoz] Fetching instructions from Cloud...");let r=await fetch("https://getagentdirectives-jqycakhlxa-uc.a.run.app",{method:"POST",headers:Object.assign({"Content-Type":"application/json"},t?{Authorization:`Bearer ${t}`}:{}),body:JSON.stringify({data:{}})});if(!r.ok)O("[OZmoz] Cloud error HTTP "+r.status);else{let n=await r.json(),s=n.result?.data||n.result||n.data;if(s&&s.protocol&&s.directives)return d("[OZmoz] Instructions loaded successfully."),i.existsSync(c.dirname(e))||i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,JSON.stringify(s,null,2),"utf8"),s;O("[OZmoz] Empty Cloud response.")}}catch(r){O("[OZmoz] Network error: "+r.message)}if(i.existsSync(e)){d("[OZmoz] Using local cache (~/.fleetbo/guidelines.json)");try{return JSON.parse(i.readFileSync(e,"utf8"))}catch{}}return{protocol:"",directives:"",version:"1.0.0"}}function V(e,t){return"<!-- ozmoz:start v"+e+` -->
3
3
  `+t.trim()+`
4
4
  `+fe+`
5
5
  `}function ve(e,t,r){let n=i.existsSync(e)?i.readFileSync(e,"utf8"):null,s,o;return n===null?(s="created",o=t):G.test(n)?(o=n.replace(G,()=>t.trimEnd()),s=o===n?"unchanged":"updated"):n.includes(H)?(s="migrated",o=t):(s="appended",o=n.replace(/\s*$/,`
6
6
 
7
- `)+t),!r&&s!=="unchanged"&&(s==="migrated"&&i.writeFileSync(e+".ozmoz-legacy.bak",n,"utf8"),i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,o,"utf8")),s}function Q(){return[c.join(__dirname,"ozmoz-mcp.js"),c.join(__dirname,"..","bin","ozmoz-mcp.js"),c.join(__dirname,"bin","ozmoz-mcp.js"),c.join(__dirname,"..","src","bin","ozmoz-mcp.js")].find(t=>i.existsSync(t))||c.resolve(__dirname,"ozmoz-mcp.js")}function M(e,t,r){let n=Object.assign({command:process.execPath,args:[__filename,"mcp","--run"]},r||{}),s={};if(i.existsSync(e))try{let l=JSON.parse(i.readFileSync(e,"utf8"));if(!l||typeof l!="object"||Array.isArray(l))return"invalid";s=l}catch{return"invalid"}let o=s.mcpServers&&s.mcpServers[k];return o&&JSON.stringify(o)===JSON.stringify(n)?"unchanged":(s.mcpServers=s.mcpServers||{},s.mcpServers[k]=n,t||(i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,JSON.stringify(s,null,2)+`
8
- `,"utf8")),o?"updated":"created")}function R(e){let t=process.platform==="win32"?"where":"which";return x(t,[e],{stdio:"ignore"}).status===0}function $(e,t,r){let n=x(e,t,{encoding:"utf8",timeout:r||3e4,shell:process.platform==="win32"});return{ok:n.status===0,out:(n.stdout||"")+(n.stderr||"")}}function Se(e,t,r){let n=e==="claude"?["--scope",r||"user"]:[],s=Q(),o=["mcp","add"].concat(n,[k,"--",process.execPath,s]),l=["mcp","remove",k].concat(n),a=e+" "+o.join(" ");if(!R(e))return{status:"manual",detail:a};if(t)return{status:"planned",detail:a};let m=$(e,["mcp","list"],6e4),u=m.ok?m.out.split(`
9
- `):[],f=u.find(v=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(v)),p=u.some(v=>/^\s*(?:fleetbo|ozmoz):\s/.test(v));if(f&&f.includes("ozmoz@latest"))return{status:"unchanged",legacy:p};if(f&&!$(e,l).ok)return{status:"manual",detail:e+" "+l.join(" ")+" && "+a,legacy:p};let h=$(e,o);return h.ok?{status:f?"updated":"created",legacy:p}:{status:"failed",detail:a,message:h.out.trim().split(`
10
- `).slice(-2).join(" "),legacy:p}}function Ee(e){let t={user:!1,local:!1,others:[]};try{let r=JSON.parse(i.readFileSync(c.join(T.homedir(),".claude.json"),"utf8")),n=a=>!!a&&typeof a=="object"&&/ozmoz|ozmoz/.test(String(a.command||"")+" "+JSON.stringify(a.args||[])),s=(a,m)=>{!a||typeof a!="object"||Object.keys(a).forEach(u=>{u===k?t[m]=!0:n(a[u])&&t.others.push({name:u,where:m})})};s(r.mcpServers,"user");let o=e;try{o=i.realpathSync(e)}catch{}let l=r.projects||{};Array.from(new Set([e,o])).forEach(a=>s((l[a]||{}).mcpServers,"local"))}catch{}return t}function we(e){let t=Ee(e);t.user&&d(" \u26A0\uFE0F A global (user-scope) '"+k+"' entry from a previous version also exists: the tools appear in every project. To keep them in OZmoz projects only: claude mcp remove "+k+" --scope user"),t.local&&d(" \u26A0\uFE0F A local-scope '"+k+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+k+" --scope local"),t.others.forEach(r=>{d(" \u26A0\uFE0F An old MCP entry named '"+r.name+"' ("+r.where+" scope) points to OZmoz/OZmoz. Remove it: claude mcp remove "+r.name+" --scope "+r.where)})}function Te(e){let t=T.homedir(),r=n=>i.existsSync(n);return{claude:R("claude")||r(c.join(t,".claude")),cursor:r(c.join(e,".cursor"))||r(c.join(t,".cursor"))||R("cursor"),windsurf:r(c.join(t,".codeium","windsurf"))||r(c.join(e,".windsurf")),devin:r(c.join(e,".devin")),codex:R("codex")||r(c.join(t,".codex")),gemini:R("gemini")||r(c.join(t,".gemini")),antigravity:R("agy")||r(c.join(t,".antigravity"))||r(c.join(e,".antigravity")),copilot:R("copilot")||r(c.join(t,".copilot"))}}var be={claude:{bin:"claude",launch:e=>[e]},gemini:{bin:"gemini",launch:e=>["-i",e]},codex:{bin:"codex",launch:e=>[e]},antigravity:{bin:"agy",launch:e=>["-i",e]}};function Ae(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function Ce(e,t,r){let n=Ae(t),s=n?`The user already provided their project description and technical choices: "${n}".
7
+ `)+t),!r&&s!=="unchanged"&&(s==="migrated"&&i.writeFileSync(e+".ozmoz-legacy.bak",n,"utf8"),i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,o,"utf8")),s}function Q(){return[c.join(__dirname,"ozmoz-mcp.js"),c.join(__dirname,"..","bin","ozmoz-mcp.js"),c.join(__dirname,"bin","ozmoz-mcp.js"),c.join(__dirname,"..","src","bin","ozmoz-mcp.js")].find(t=>i.existsSync(t))||c.resolve(__dirname,"ozmoz-mcp.js")}function M(e,t,r){let n=Object.assign({command:process.execPath,args:[__filename,"mcp","--run"]},r||{}),s={};if(i.existsSync(e))try{let l=JSON.parse(i.readFileSync(e,"utf8"));if(!l||typeof l!="object"||Array.isArray(l))return"invalid";s=l}catch{return"invalid"}let o=s.mcpServers&&s.mcpServers[x];return o&&JSON.stringify(o)===JSON.stringify(n)?"unchanged":(s.mcpServers=s.mcpServers||{},s.mcpServers[x]=n,t||(i.mkdirSync(c.dirname(e),{recursive:!0}),i.writeFileSync(e,JSON.stringify(s,null,2)+`
8
+ `,"utf8")),o?"updated":"created")}function R(e){let t=process.platform==="win32"?"where":"which";return N(t,[e],{stdio:"ignore"}).status===0}function $(e,t,r){let n=N(e,t,{encoding:"utf8",timeout:r||3e4,shell:process.platform==="win32"});return{ok:n.status===0,out:(n.stdout||"")+(n.stderr||"")}}function Se(e,t,r){let n=e==="claude"?["--scope",r||"user"]:[],s=Q(),o=["mcp","add"].concat(n,[x,"--",process.execPath,s]),l=["mcp","remove",x].concat(n),a=e+" "+o.join(" ");if(!R(e))return{status:"manual",detail:a};if(t)return{status:"planned",detail:a};let m=$(e,["mcp","list"],6e4),u=m.ok?m.out.split(`
9
+ `):[],h=u.find(v=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(v)),p=u.some(v=>/^\s*(?:fleetbo|ozmoz):\s/.test(v));if(h&&h.includes("ozmoz@latest"))return{status:"unchanged",legacy:p};if(h&&!$(e,l).ok)return{status:"manual",detail:e+" "+l.join(" ")+" && "+a,legacy:p};let g=$(e,o);return g.ok?{status:h?"updated":"created",legacy:p}:{status:"failed",detail:a,message:g.out.trim().split(`
10
+ `).slice(-2).join(" "),legacy:p}}function Ee(e){let t={user:!1,local:!1,others:[]};try{let r=JSON.parse(i.readFileSync(c.join(b.homedir(),".claude.json"),"utf8")),n=a=>!!a&&typeof a=="object"&&/ozmoz|ozmoz/.test(String(a.command||"")+" "+JSON.stringify(a.args||[])),s=(a,m)=>{!a||typeof a!="object"||Object.keys(a).forEach(u=>{u===x?t[m]=!0:n(a[u])&&t.others.push({name:u,where:m})})};s(r.mcpServers,"user");let o=e;try{o=i.realpathSync(e)}catch{}let l=r.projects||{};Array.from(new Set([e,o])).forEach(a=>s((l[a]||{}).mcpServers,"local"))}catch{}return t}function we(e){let t=Ee(e);t.user&&d(" \u26A0\uFE0F A global (user-scope) '"+x+"' entry from a previous version also exists: the tools appear in every project. To keep them in OZmoz projects only: claude mcp remove "+x+" --scope user"),t.local&&d(" \u26A0\uFE0F A local-scope '"+x+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+x+" --scope local"),t.others.forEach(r=>{d(" \u26A0\uFE0F An old MCP entry named '"+r.name+"' ("+r.where+" scope) points to OZmoz/OZmoz. Remove it: claude mcp remove "+r.name+" --scope "+r.where)})}function Te(e){let t=b.homedir(),r=n=>i.existsSync(n);return{claude:R("claude")||r(c.join(t,".claude")),cursor:r(c.join(e,".cursor"))||r(c.join(t,".cursor"))||R("cursor"),windsurf:r(c.join(t,".codeium","windsurf"))||r(c.join(e,".windsurf")),devin:r(c.join(e,".devin")),codex:R("codex")||r(c.join(t,".codex")),gemini:R("gemini")||r(c.join(t,".gemini")),antigravity:R("agy")||r(c.join(t,".antigravity"))||r(c.join(e,".antigravity")),copilot:R("copilot")||r(c.join(t,".copilot"))}}var be={claude:{bin:"claude",launch:e=>[e]},gemini:{bin:"gemini",launch:e=>["-i",e]},codex:{bin:"codex",launch:e=>[e]},antigravity:{bin:"agy",launch:e=>["-i",e]}};function Ae(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function Ce(e,t,r){let n=Ae(t),s=n?`The user already provided their project description and technical choices: "${n}".
11
11
  - Check if the framework (e.g. React, Vue) is already specified.
12
12
  - If it is, DO NOT ask a generic "what tech do you want" question. Acknowledge their choice naturally (e.g. "J'ai bien not\xE9 que vous souhaitez utiliser React...") and only ask for the missing precision (TypeScript vs JavaScript) in a single friendly confirmation, or proceed directly if obvious.
13
- - Once the user answers, do NOT run exploratory bash commands. IMMEDIATELY call the MCP tool 'oz_create_project' with the application name.`:"Ask me the starter questions from your OZmoz instructions before installing anything: the technology first, then a one-sentence project description, one question at a time.",o=null,l=!0;try{let p=c.join(r,".env");if(i.existsSync(p)){let h=i.readFileSync(p,"utf8"),v=h.match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);v&&(o=v[1].trim());let y=h.match(/^\s*OZ_PROTOTYPE\s*=\s*(.+?)\s*$/m);y&&(l=y[1].trim().toLowerCase()==="true")}}catch{}let a=i.existsSync(c.join(r,"svro.schema.json")),m=i.existsSync(c.join(r,"index.html"))||i.existsSync(c.join(r,"package.json")),u=l?"OZ_PROTOTYPE=true (mode essai / local sandbox)":"OZ_PROTOTYPE=false (mode r\xE9el / live database)",f=o||a?"This folder ALREADY contains an OZmoz project (OZ_DB_KEY="+o+", "+u+"). Do NOT call oz_create_project, and do NOT ask the starter questions. State this in one plain sentence to the user \u2014 then ask what I want to work on now.":m?'This folder does NOT have an OZmoz project yet, but a frontend project ALREADY exists here \u2014 do NOT run "npm create vite" or scaffold a new frontend. Skip the technology question and ask me only for a one-sentence project description, then call oz_create_project directly.':"This folder does NOT contain an OZmoz project yet (no .env, no svro.schema.json). "+s;return"Use OZmoz as the backend of my app. You are in the project folder ("+r+"). Follow your OZmoz local instructions (do NOT run bash commands or web searches to inspect instruction files, they are already active). "+f}function Ie(){let e=process.env;if(e.CLAUDECODE==="1"||e.GEMINI_CLI||e.CODEX_CLI||e.AI_AGENT||e.CURSOR_AGENT||e.ANTIGRAVITY_CLI)return!0;if(process.platform==="win32")return!1;try{let t=x("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(t.status!==0)return!1;let r=new Map;t.stdout.split(`
14
- `).forEach(s=>{let o=s.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);o&&r.set(Number(o[1]),{ppid:Number(o[2]),args:o[3]})});let n=process.ppid;for(let s=0;n>1&&s<20&&r.has(n);s++){let{ppid:o,args:l}=r.get(n);if(l.split(/\s+/).slice(0,2).some(m=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(m))||/@google\/gemini-cli|@anthropic-ai\/claude-code|@openai\/codex/.test(l))return!0;n=o}}catch{}return!1}function ke(e){let t=process.platform==="win32"?"where":"which";return x(t,[e],{stdio:"ignore"}).status===0}function xe(e,t){let r=t.slice(1).filter(f=>!f.startsWith("--")),n=(r[0]||"").toLowerCase(),s=r.slice(1).join(" "),o=be[n];o||(O('Usage: npx ozmoz start <claude|gemini|codex> ["your app idea"]'),O('Cursor, Windsurf, Devin and GitHub Copilot have no terminal agent to launch: run "npx ozmoz mcp --agent=<cursor|windsurf|devin|copilot>" instead.'),process.exit(1));let l=!1;try{l=!!JSON.parse(i.readFileSync(c.join(T.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}l||(d("[OZmoz] First use on this machine: sign in (your browser opens, approve once)."),x(process.execPath,[__filename,"login"],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(O('Sign-in did not complete. Run "npx ozmoz start '+n+'" again.'),process.exit(1))),x(process.execPath,[__filename,"mcp","--agent="+n],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(O("Could not configure "+o.bin+'. Run "npx ozmoz mcp --agent='+n+'" to see why.'),process.exit(1)),Ie()&&(d(`
13
+ - Once the user answers, do NOT run exploratory bash commands. IMMEDIATELY call the MCP tool 'oz_create_project' with the application name.`:"Ask me the starter questions from your OZmoz instructions before installing anything: the technology first, then a one-sentence project description, one question at a time.",o=null,l=!0;try{let p=c.join(r,".env");if(i.existsSync(p)){let g=i.readFileSync(p,"utf8"),v=g.match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);v&&(o=v[1].trim());let S=g.match(/^\s*OZ_PROTOTYPE\s*=\s*(.+?)\s*$/m);S&&(l=S[1].trim().toLowerCase()==="true")}}catch{}let a=i.existsSync(c.join(r,"svro.schema.json")),m=i.existsSync(c.join(r,"index.html"))||i.existsSync(c.join(r,"package.json")),u=l?"OZ_PROTOTYPE=true (mode essai / local sandbox)":"OZ_PROTOTYPE=false (mode r\xE9el / live database)",h=o||a?"This folder ALREADY contains an OZmoz project (OZ_DB_KEY="+o+", "+u+"). Do NOT call oz_create_project, and do NOT ask the starter questions. State this in one plain sentence to the user \u2014 then ask what I want to work on now.":m?'This folder does NOT have an OZmoz project yet, but a frontend project ALREADY exists here \u2014 do NOT run "npm create vite" or scaffold a new frontend. Skip the technology question and ask me only for a one-sentence project description, then call oz_create_project directly.':"This folder does NOT contain an OZmoz project yet (no .env, no svro.schema.json). "+s;return"Use OZmoz as the backend of my app. You are in the project folder ("+r+"). Follow your OZmoz local instructions (do NOT run bash commands or web searches to inspect instruction files, they are already active). "+h}function Ie(){let e=process.env;if(e.CLAUDECODE==="1"||e.GEMINI_CLI||e.CODEX_CLI||e.AI_AGENT||e.CURSOR_AGENT||e.ANTIGRAVITY_CLI)return!0;if(process.platform==="win32")return!1;try{let t=N("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(t.status!==0)return!1;let r=new Map;t.stdout.split(`
14
+ `).forEach(s=>{let o=s.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);o&&r.set(Number(o[1]),{ppid:Number(o[2]),args:o[3]})});let n=process.ppid;for(let s=0;n>1&&s<20&&r.has(n);s++){let{ppid:o,args:l}=r.get(n);if(l.split(/\s+/).slice(0,2).some(m=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(m))||/@google\/gemini-cli|@anthropic-ai\/claude-code|@openai\/codex/.test(l))return!0;n=o}}catch{}return!1}function ke(e){let t=process.platform==="win32"?"where":"which";return N(t,[e],{stdio:"ignore"}).status===0}function xe(e,t){let r=t.slice(1).filter(h=>!h.startsWith("--")),n=(r[0]||"").toLowerCase(),s=r.slice(1).join(" "),o=be[n];o||(O('Usage: npx ozmoz start <claude|gemini|codex> ["your app idea"]'),O('Cursor, Windsurf, Devin and GitHub Copilot have no terminal agent to launch: run "npx ozmoz mcp --agent=<cursor|windsurf|devin|copilot>" instead.'),process.exit(1));let l=!1;try{l=!!JSON.parse(i.readFileSync(c.join(b.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}l||(d("[OZmoz] First use on this machine: sign in (your browser opens, approve once)."),N(process.execPath,[__filename,"login"],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(O('Sign-in did not complete. Run "npx ozmoz start '+n+'" again.'),process.exit(1))),N(process.execPath,[__filename,"mcp","--agent="+n],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(O("Could not configure "+o.bin+'. Run "npx ozmoz mcp --agent='+n+'" to see why.'),process.exit(1)),Ie()&&(d(`
15
15
  [OZmoz] OZmoz is set up in this folder (instruction file + MCP server).
16
16
  `),process.exit(0)),ke(o.bin)||(O('"'+o.bin+'" is not installed or not in your PATH. Install it, then run: npx ozmoz start '+n),process.exit(1));let m=Ce(o.rules,s,e);d(`
17
17
  [OZmoz] Launching `+o.bin+` in this folder...
18
- `);let u=x(o.bin,o.launch(process.platform==="win32"?'"'+m+'"':m),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(u.status===null?1:u.status)}async function ee(e,t){let r=t.includes("--dry-run"),n=t.find(g=>g.startsWith("--agent=")),s=n&&n.slice(8).trim()?n.slice(8).split(",").map(g=>g.trim().toLowerCase()).filter(Boolean):null,o=null;if(s){o=s.includes("all")?Object.keys(F):s;let g=o.filter(E=>!F[E]);g.length&&(O("Unknown agent(s): "+g.join(", ")+". Valid values: "+Object.keys(F).join(", ")+", all."),process.exit(1))}let l=t.find(g=>g.startsWith("--scope=")),a=l?l.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(a)||(O("Unknown scope: "+a+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let m=Te(e),u=o||Object.keys(F).filter(g=>m[g]),f=he();d(`
19
- [OZmoz] Configuring your AI agents`+(r?" (dry run: nothing is written)":"")+"...");let p=await X(),h=p.version||f,v=`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
18
+ `);let u=N(o.bin,o.launch(process.platform==="win32"?'"'+m+'"':m),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(u.status===null?1:u.status)}async function ee(e,t){let r=t.includes("--dry-run"),n=t.find(f=>f.startsWith("--agent=")),s=n&&n.slice(8).trim()?n.slice(8).split(",").map(f=>f.trim().toLowerCase()).filter(Boolean):null,o=null;if(s){o=s.includes("all")?Object.keys(F):s;let f=o.filter(E=>!F[E]);f.length&&(O("Unknown agent(s): "+f.join(", ")+". Valid values: "+Object.keys(F).join(", ")+", all."),process.exit(1))}let l=t.find(f=>f.startsWith("--scope=")),a=l?l.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(a)||(O("Unknown scope: "+a+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let m=Te(e),u=o||Object.keys(F).filter(f=>m[f]),h=he();d(`
19
+ [OZmoz] Configuring your AI agents`+(r?" (dry run: nothing is written)":"")+"...");let p=await X(),g=p.version||h,v=`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
20
20
 
21
21
  `+(p.directives||p.guidelines||"")+`
22
22
 
23
23
  ## PROTOCOLE DONN\xC9ES : QUI FAIT QUOI (AGENT FRONTEND \u2194 ALEX AI)
24
24
 
25
- `+(p.protocol||""),y=V(h,v),S=[["AGENTS.md",y],["GEMINI.md",y],["CLAUDE.md",V(h,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
26
- @AGENTS.md`)]],z=c.join(e,".cursorrules");if(i.existsSync(z)){let g=i.readFileSync(z,"utf8");(G.test(g)||g.includes(H))&&S.push([".cursorrules",y])}for(let g of S)d("\u2192 "+g[0]+": "+j[ve(c.join(e,g[0]),g[1],r)]);for(let g of u){let E=F[g];if(g==="cursor")d("\u2192 "+E+" MCP (.cursor/mcp.json): "+j[M(c.join(e,".cursor","mcp.json"),r)]);else if(g==="windsurf")d("\u2192 "+E+" MCP (~/.codeium/windsurf/mcp_config.json): "+j[M(c.join(T.homedir(),".codeium","windsurf","mcp_config.json"),r)]);else if(g==="copilot")d("\u2192 "+E+" MCP (~/.copilot/mcp-config.json): "+j[M(c.join(T.homedir(),".copilot","mcp-config.json"),r,{type:"local",tools:["*"]})]);else if(g==="claude"&&a==="project"){let b=M(c.join(e,".mcp.json"),r);d("\u2192 "+E+" MCP (.mcp.json, project scope): "+j[b]),(b==="created"||b==="updated")&&d(" Claude Code asks you to approve a project server the first time you launch it. Commit .mcp.json to share it with your team (it contains no token)."),we(e)}else if(g==="gemini"){let b=[c.join(T.homedir(),".gemini","settings.json"),c.join(e,".gemini","settings.json"),c.join(e,".mcp.json")],w="unchanged";b.forEach(B=>{let P=M(B,r);(P==="created"||P==="updated")&&(w=P)}),d("\u2192 "+E+" MCP (settings.json & .mcp.json): "+j[w])}else if(g==="claude"||g==="codex"||g==="antigravity"){let b=g==="antigravity"?"agy":g,w=Se(b,r,a);w.status==="manual"?d("\u2192 "+E+": '"+b+"' not found or not scriptable. Run manually: "+w.detail):w.status==="planned"?d("\u2192 "+E+" MCP: would run: "+w.detail):w.status==="failed"?O("\u2192 "+E+" MCP: registration failed ("+w.message+"). Run manually: "+w.detail):d("\u2192 "+E+" MCP"+(g==="claude"?" ("+a+" scope)":"")+": "+j[w.status]),w.legacy&&d(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+b+" mcp remove fleetbo")}else g==="devin"&&d("\u2192 "+E+": reads AGENTS.md. Devin runs in its own environment: add the OZmoz MCP server from Devin's settings (not automated).")}!o&&u.length===0&&d("\u2192 No agent detected: instruction files were written; re-run with --agent=<name> to register the MCP server.");let C=!!(Z(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),_=c.join(T.homedir(),".fleetbo","credentials.json");if(i.existsSync(_))try{C=C||!!JSON.parse(i.readFileSync(_,"utf8")).devToken}catch{}C||O('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||d(`
25
+ `+(p.protocol||""),S=V(g,v),z=[["AGENTS.md",S],["GEMINI.md",S],["CLAUDE.md",V(g,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
26
+ @AGENTS.md`)]],y=c.join(e,".cursorrules");if(i.existsSync(y)){let f=i.readFileSync(y,"utf8");(G.test(f)||f.includes(H))&&z.push([".cursorrules",S])}for(let f of z)d("\u2192 "+f[0]+": "+j[ve(c.join(e,f[0]),f[1],r)]);for(let f of u){let E=F[f];if(f==="cursor")d("\u2192 "+E+" MCP (.cursor/mcp.json): "+j[M(c.join(e,".cursor","mcp.json"),r)]);else if(f==="windsurf")d("\u2192 "+E+" MCP (~/.codeium/windsurf/mcp_config.json): "+j[M(c.join(b.homedir(),".codeium","windsurf","mcp_config.json"),r)]);else if(f==="copilot")d("\u2192 "+E+" MCP (~/.copilot/mcp-config.json): "+j[M(c.join(b.homedir(),".copilot","mcp-config.json"),r,{type:"local",tools:["*"]})]);else if(f==="claude"&&a==="project"){let A=M(c.join(e,".mcp.json"),r);d("\u2192 "+E+" MCP (.mcp.json, project scope): "+j[A]),(A==="created"||A==="updated")&&d(" Claude Code asks you to approve a project server the first time you launch it. Commit .mcp.json to share it with your team (it contains no token)."),we(e)}else if(f==="gemini"){let A=[c.join(b.homedir(),".gemini","settings.json"),c.join(e,".gemini","settings.json"),c.join(e,".mcp.json")],w="unchanged";A.forEach(B=>{let D=M(B,r);(D==="created"||D==="updated")&&(w=D)}),d("\u2192 "+E+" MCP (settings.json & .mcp.json): "+j[w])}else if(f==="claude"||f==="codex"||f==="antigravity"){let A=f==="antigravity"?"agy":f,w=Se(A,r,a);w.status==="manual"?d("\u2192 "+E+": '"+A+"' not found or not scriptable. Run manually: "+w.detail):w.status==="planned"?d("\u2192 "+E+" MCP: would run: "+w.detail):w.status==="failed"?O("\u2192 "+E+" MCP: registration failed ("+w.message+"). Run manually: "+w.detail):d("\u2192 "+E+" MCP"+(f==="claude"?" ("+a+" scope)":"")+": "+j[w.status]),w.legacy&&d(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+A+" mcp remove fleetbo")}else f==="devin"&&d("\u2192 "+E+": reads AGENTS.md. Devin runs in its own environment: add the OZmoz MCP server from Devin's settings (not automated).")}!o&&u.length===0&&d("\u2192 No agent detected: instruction files were written; re-run with --agent=<name> to register the MCP server.");let C=!!(Z(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),_=c.join(b.homedir(),".fleetbo","credentials.json");if(i.existsSync(_))try{C=C||!!JSON.parse(i.readFileSync(_,"utf8")).devToken}catch{}C||O('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||d(`
27
27
  [OZmoz] Done.
28
- `)}function Ne(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";oe(`${t} "${e}"`)}function _e(e){return new Promise((t,r)=>{let n=ne.createServer((s,o)=>{if(o.setHeader("Access-Control-Allow-Origin","*"),o.setHeader("Access-Control-Allow-Methods","GET, OPTIONS"),o.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),o.setHeader("Access-Control-Allow-Private-Network","true"),s.method==="OPTIONS"){o.writeHead(204),o.end();return}let l=new URL(s.url,"http://127.0.0.1");if(l.pathname==="/callback"){let a=l.searchParams.get("token"),m=l.searchParams.get("refresh");if(!a){o.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),o.end("<h3>Error: Missing token.</h3>");return}let u=c.join(T.homedir(),".fleetbo");i.existsSync(u)||i.mkdirSync(u,{recursive:!0}),i.writeFileSync(c.join(u,"credentials.json"),JSON.stringify({devToken:a,refreshToken:m||null,updatedAt:new Date().toISOString()},null,2));let f=c.join(e,".env");if(i.existsSync(f)){let p=i.readFileSync(f,"utf8");p.includes("FLEETBO_DEV_TOKEN=")?p=p.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${a}`):p+=`
28
+ `)}function Ne(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";oe(`${t} "${e}"`)}function _e(e){return new Promise((t,r)=>{let n=ne.createServer((s,o)=>{if(o.setHeader("Access-Control-Allow-Origin","*"),o.setHeader("Access-Control-Allow-Methods","GET, OPTIONS"),o.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),o.setHeader("Access-Control-Allow-Private-Network","true"),s.method==="OPTIONS"){o.writeHead(204),o.end();return}let l=new URL(s.url,"http://127.0.0.1");if(l.pathname==="/callback"){let a=l.searchParams.get("token"),m=l.searchParams.get("refresh");if(!a){o.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),o.end("<h3>Error: Missing token.</h3>");return}let u=c.join(b.homedir(),".fleetbo");i.existsSync(u)||i.mkdirSync(u,{recursive:!0}),i.writeFileSync(c.join(u,"credentials.json"),JSON.stringify({devToken:a,refreshToken:m||null,updatedAt:new Date().toISOString()},null,2));let h=c.join(e,".env");if(i.existsSync(h)){let p=i.readFileSync(h,"utf8");p.includes("FLEETBO_DEV_TOKEN=")?p=p.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${a}`):p+=`
29
29
  FLEETBO_DEV_TOKEN=${a}
30
- `,i.writeFileSync(f,p,"utf8")}o.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),o.end(`
30
+ `,i.writeFileSync(h,p,"utf8")}o.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),o.end(`
31
31
  <!DOCTYPE html>
32
32
  <html>
33
33
  <head>
@@ -49,8 +49,8 @@ FLEETBO_DEV_TOKEN=${a}
49
49
  [OZmoz] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(p=>i.existsSync(c.join(e,p)))&&(d(`
50
50
  Next step to connect your AI agents:`),d(` npx ozmoz mcp (Configure Claude Code, Cursor, Windsurf, Devin, Codex CLI, Gemini CLI, Antigravity CLI, GitHub Copilot)
51
51
  `)),typeof n.closeAllConnections=="function"&&n.closeAllConnections(),n.close(()=>t()),setTimeout(()=>t(),300)}});n.listen(0,"127.0.0.1",()=>{let o=`https://ozmoz.io/cli-auth?port=${n.address().port}`;d(`
52
- [OZmoz] Waiting for authentication...`),d(`If your browser does not open automatically, visit: ${o}`),Ne(o);let l=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),r(new Error(`Login timed out after ${Math.round(l/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},l).unref()}),n.on("error",s=>r(s))})}function Pe(e,t,r){return new Promise((n,s)=>{let o=JSON.stringify({enterpriseID:e,schema:t,workflow:r}),l={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(o)}},a=W.request(l,m=>{let u="";m.on("data",f=>{u+=f}),m.on("end",()=>{m.statusCode>=200&&m.statusCode<300?n(JSON.parse(u)):s(new Error(`Edge sync failed with HTTP ${m.statusCode}`))})});a.on("error",m=>s(m)),a.write(o),a.end()})}function Z(e){let t=c.join(e,".env");if(!i.existsSync(t))return{};let r=i.readFileSync(t,"utf8"),n={};return r.split(`
53
- `).forEach(s=>{let[o,...l]=s.split("=");o&&l.length>0&&(n[o.trim()]=l.join("=").trim())}),n}function J(e,t){return new Promise((r,n)=>{let s=JSON.stringify({projectId:e,moduleName:t}),o={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},l=W.request(o,a=>{let m="";a.on("data",u=>{m+=u}),a.on("end",()=>{if(a.statusCode>=200&&a.statusCode<300)try{let u=JSON.parse(m);if(u.success&&u.found&&u.module){let f=u.module.code||u.module.mockCode;r(typeof f=="string"?JSON.parse(f):f)}else r(null)}catch{n(new Error(`Invalid JSON response for ${t}.`))}else n(new Error(`Server error ${a.statusCode} while fetching ${t}`))})});l.on("error",a=>n(a)),l.write(s),l.end()})}var A=process.argv.slice(2),I=A[0],De=["id","_id","userId","author","dateCreated","createdAt","_schema_version"],te=e=>De.includes(e)||/^_/.test(e)||/^(created|updated|modified|deleted)(At|By)$/i.test(e);function U(e){return!e||typeof e!="object"?null:e.fields&&typeof e.fields=="object"?e.fields:e.schema&&typeof e.schema=="object"?e.schema:null}function je(e){let t=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:t};let r=JSON.parse(JSON.stringify(e));return Object.entries(r.collections).forEach(([n,s])=>{let o=U(s);o&&Object.keys(o).forEach(l=>{te(l)&&o[l]&&typeof o[l]=="object"&&o[l].required===!0&&(o[l].required=!1,t.push(n+"."+l))})}),{schema:r,changed:t.length>0,notes:t}}function Re(e){let t=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),r=e&&(e.enum||e.values||e.options);return Array.isArray(r)&&r.length?JSON.stringify(r[0]):t==="number"||t==="integer"||t==="float"?"0":t==="boolean"||t==="toggle"?"false":t==="date"||t==="datetime"||t==="timestamp"?"new Date().toISOString()":t==="reference"?"'<id du document li\xE9>'":t==="media"?"null /* image/fichier : oz.addWithMedia */":t==="array"?"[]":"'\u2026'"}function Le(e){let r=Object.entries(e&&e.collections||{}),n=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
52
+ [OZmoz] Waiting for authentication...`),d(`If your browser does not open automatically, visit: ${o}`),Ne(o);let l=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),r(new Error(`Login timed out after ${Math.round(l/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},l).unref()}),n.on("error",s=>r(s))})}function De(e,t,r){return new Promise((n,s)=>{let o=JSON.stringify({enterpriseID:e,schema:t,workflow:r}),l={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(o)}},a=W.request(l,m=>{let u="";m.on("data",h=>{u+=h}),m.on("end",()=>{m.statusCode>=200&&m.statusCode<300?n(JSON.parse(u)):s(new Error(`Edge sync failed with HTTP ${m.statusCode}`))})});a.on("error",m=>s(m)),a.write(o),a.end()})}function Z(e){let t=c.join(e,".env");if(!i.existsSync(t))return{};let r=i.readFileSync(t,"utf8"),n={};return r.split(`
53
+ `).forEach(s=>{let[o,...l]=s.split("=");o&&l.length>0&&(n[o.trim()]=l.join("=").trim())}),n}function J(e,t){return new Promise((r,n)=>{let s=JSON.stringify({projectId:e,moduleName:t}),o={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(s)}},l=W.request(o,a=>{let m="";a.on("data",u=>{m+=u}),a.on("end",()=>{if(a.statusCode>=200&&a.statusCode<300)try{let u=JSON.parse(m);if(u.success&&u.found&&u.module){let h=u.module.code||u.module.mockCode;r(typeof h=="string"?JSON.parse(h):h)}else r(null)}catch{n(new Error(`Invalid JSON response for ${t}.`))}else n(new Error(`Server error ${a.statusCode} while fetching ${t}`))})});l.on("error",a=>n(a)),l.write(s),l.end()})}var I=process.argv.slice(2),k=I[0],Pe=["id","_id","userId","author","dateCreated","createdAt","_schema_version"],te=e=>Pe.includes(e)||/^_/.test(e)||/^(created|updated|modified|deleted)(At|By)$/i.test(e);function U(e){return!e||typeof e!="object"?null:e.fields&&typeof e.fields=="object"?e.fields:e.schema&&typeof e.schema=="object"?e.schema:null}function je(e){let t=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:t};let r=JSON.parse(JSON.stringify(e));return Object.entries(r.collections).forEach(([n,s])=>{let o=U(s);o&&Object.keys(o).forEach(l=>{te(l)&&o[l]&&typeof o[l]=="object"&&o[l].required===!0&&(o[l].required=!1,t.push(n+"."+l))})}),{schema:r,changed:t.length>0,notes:t}}function Re(e){let t=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),r=e&&(e.enum||e.values||e.options);return Array.isArray(r)&&r.length?JSON.stringify(r[0]):t==="number"||t==="integer"||t==="float"?"0":t==="boolean"||t==="toggle"?"false":t==="date"||t==="datetime"||t==="timestamp"?"new Date().toISOString()":t==="reference"?"'<id du document li\xE9>'":t==="media"?"null /* image/fichier : oz.addWithMedia */":t==="array"?"[]":"'\u2026'"}function Le(e){let r=Object.entries(e&&e.collections||{}),n=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
54
54
 
55
55
  `;n+=`### \u{1F194} Identifiants
56
56
  `,n+="* OZmoz attribue lui-m\xEAme `_id` (cha\xEEne) \xE0 chaque document. Utilise `doc._id` partout ; \xE0 la lecture, `doc.id` existe comme alias de `_id` (m\xEAme valeur), en prototype comme en production, mais la r\xE9f\xE9rence est `_id`.\n",n+="* N'envoie **jamais** `id` ni `_id` dans `oz.add` : `oz.add` renvoie `{ success, documentId }` (`documentId` = `_id`).\n",n+="* Pour lire, modifier ou supprimer un document : `oz.getDoc(table, doc._id)`, `oz.update(table, doc._id, {\u2026})`, `oz.delete(table, doc._id)`. Pour relier deux collections, stocke le `_id` du document li\xE9 dans un champ (ex. `playlistId`).\n",n+="* `userId`, `createdAt` et les autres champs de tra\xE7abilit\xE9 sont renseign\xE9s par le moteur : ne les envoie pas.\n\n";let s=r.filter(([,o])=>U(o)&&Object.keys(U(o)).length>0);return s.length===0?n+`_Aucune collection scell\xE9e pour l'instant : les mod\xE8les appara\xEEtront apr\xE8s la mod\xE9lisation d'Alex._
@@ -58,10 +58,10 @@ Next step to connect your AI agents:`),d(` npx ozmoz mcp (Configure Claude C
58
58
 
59
59
  | Champ | Type | Obligatoire | Valeurs / remarques |
60
60
  |---|---|---|---|
61
- `,m.forEach(([p,h])=>{let v=typeof h=="string"?h:h&&h.type||"any",y=h&&(h.enum||h.values||h.options),S=Array.isArray(y)&&y.length?"parmi : "+y.map(z=>"`"+z+"`").join(", "):"";n+="| `"+p+"` | "+v+" | "+(h&&h.required===!0?"\u2705 oui":"non")+" | "+S+` |
62
- `});let u=m.filter(([,p])=>p&&p.required===!0),f=m.filter(([,p])=>!(p&&p.required===!0));n+="\nInsertion valide :\n```js\nawait oz.add('"+o+`', {
63
- `,u.forEach(([p,h])=>{n+=" "+p+": "+Re(h)+`,
64
- `}),f.length&&(n+=" // optionnels : "+f.map(([p])=>p).join(", ")+`
61
+ `,m.forEach(([p,g])=>{let v=typeof g=="string"?g:g&&g.type||"any",S=g&&(g.enum||g.values||g.options),z=Array.isArray(S)&&S.length?"parmi : "+S.map(y=>"`"+y+"`").join(", "):"";n+="| `"+p+"` | "+v+" | "+(g&&g.required===!0?"\u2705 oui":"non")+" | "+z+` |
62
+ `});let u=m.filter(([,p])=>p&&p.required===!0),h=m.filter(([,p])=>!(p&&p.required===!0));n+="\nInsertion valide :\n```js\nawait oz.add('"+o+`', {
63
+ `,u.forEach(([p,g])=>{n+=" "+p+": "+Re(g)+`,
64
+ `}),h.length&&(n+=" // optionnels : "+h.map(([p])=>p).join(", ")+`
65
65
  `),n+=`}, {
66
66
  `,n+=" desc: 'Cr\xE9ation d\\'un \xE9l\xE9ment dans "+o+`',
67
67
  `,n+=` role: 'AUTHENTICATED' // ou 'ANONYMOUS', 'ADMIN'
@@ -525,7 +525,7 @@ const handleDelete = async (docId) => {
525
525
  ---
526
526
 
527
527
  ### \u{1F9ED} DATA PROTOCOL: WHO DOES WHAT (FRONTEND AGENT \u2194 ALEX AI)
528
- The full "who does what" protocol is in AGENTS.md (already in your context) and applies unchanged.
528
+ The full "who does what" protocol is in AGENTS.md (GEMINI.md for Gemini). It should already be in your context; if it is not, read that file now, before writing any code.
529
529
 
530
530
  ---
531
531
 
@@ -626,27 +626,27 @@ ${JSON.stringify({...e||{},context:void 0},null,2)}
626
626
  \`\`\`json
627
627
  ${JSON.stringify(t||{},null,2)}
628
628
  \`\`\`
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 Ue(e,t){let r=Z(e),n=i.existsSync(c.join(e,"svro.schema.json"));(r.OZ_DB_KEY||n)&&(O("Cannot create project: an OZmoz project already exists in this folder."),d('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let s=(t||"").trim();s||(O('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let o=c.join(e,".ozmoz.lock");if(i.existsSync(o)){let a=!1;try{let m=Number(i.readFileSync(o,"utf8"));Date.now()-m>6e4&&(a=!0)}catch{a=!0}a||(O("A project creation is already running in this folder."),process.exit(1)),i.unlinkSync(o)}i.writeFileSync(o,String(Date.now()));let l=()=>{if(i.existsSync(o))try{i.unlinkSync(o)}catch{}};try{let a=process.env.FLEETBO_DEV_TOKEN;if(!a){let y=c.join(T.homedir(),".fleetbo","credentials.json");if(i.existsSync(y))try{a=JSON.parse(i.readFileSync(y,"utf8")).devToken}catch{}}a||(l(),O('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),d(`[OZmoz] Creating project "${s}" on Cloud...`);let m=Me(s),u=[m,`${m.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${m.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],f=null,p=null;for(let y of u)try{let S=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({data:{name:s,keyApp:y}})}),z=await S.json();if(S.ok&&!z.error){f={keyApp:y,data:z.result?.data||z.data||{}};break}else p=z.error?.message||`HTTP ${S.status}`}catch(S){p=S.message}f||(l(),O(`Failed to create project on Cloud: ${p||"Unknown error"}`),process.exit(1));let h=f.data.bootstrapToken;await K(e,[`--keyApp=${f.keyApp}`,`--token=${h}`]);let v=c.join(e,"package.json");Y(e,v),await ee(e,[]),d(`
630
- [OZmoz] Project "${s}" (${f.keyApp}) created and configured successfully.`),d(`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(i.existsSync(o))try{i.unlinkSync(o)}catch{}}}async function Ze(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let y=c.join(T.homedir(),".fleetbo","credentials.json");if(i.existsSync(y))try{t=JSON.parse(i.readFileSync(y,"utf8")).devToken}catch{}}let n=Z(e).OZ_KEY_APP;(!n||!t)&&(O("Cannot update: project uninitialized or dev token missing."),process.exit(1));let s=i.existsSync(c.join(e,"src"))?c.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],a=0;function m(y){let S=[];try{S=i.readdirSync(y,{withFileTypes:!0})}catch{return}for(let z of S){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(z.name))continue;let N=c.join(y,z.name);if(z.isDirectory())m(N);else if(o.has(c.extname(z.name))&&!z.name.endsWith(".d.ts"))try{let C=i.statSync(N);if(C.size>3e5)continue;let _=i.readFileSync(N,"utf8");/oz\.|<oz-/i.test(_)&&(a+=C.size,l.push({name:c.relative(e,N).split(c.sep).join("/"),content:_}))}catch{}}}m(s),l.length===0&&(O("Cannot update: no components using oz.* found."),process.exit(1)),a>8*1024*1024&&(O("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let u=A.find(y=>y.startsWith("--rules=")),f=u?u.slice(8).trim():"",p=A.find(y=>y.startsWith("--reasoning=")),h=p?p.slice(12).trim().toLowerCase():void 0;h!=="standard"&&h!=="high"&&(O("Missing or invalid --reasoning=<standard|high>."),O("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)),d(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let y=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:f,reasoning:h}})}),S=await y.json();(!y.ok||S.error)&&(O(`Update failed: ${S.error?.message||S.message||"Server error"}`),process.exit(1))}catch(y){O(`Network error: ${y.message}`),process.exit(1)}d("\u2192 Structure modeled. Sealing into SVRO Kernel..."),x(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}).status===0?d(`
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 Ue(e,t){let r=Z(e),n=i.existsSync(c.join(e,"svro.schema.json"));(r.OZ_DB_KEY||n)&&(O("Cannot create project: an OZmoz project already exists in this folder."),d('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let s=(t||"").trim();s||(O('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let o=c.join(e,".ozmoz.lock");if(i.existsSync(o)){let a=!1;try{let m=Number(i.readFileSync(o,"utf8"));Date.now()-m>6e4&&(a=!0)}catch{a=!0}a||(O("A project creation is already running in this folder."),process.exit(1)),i.unlinkSync(o)}i.writeFileSync(o,String(Date.now()));let l=()=>{if(i.existsSync(o))try{i.unlinkSync(o)}catch{}};try{let a=process.env.FLEETBO_DEV_TOKEN;if(!a){let S=c.join(b.homedir(),".fleetbo","credentials.json");if(i.existsSync(S))try{a=JSON.parse(i.readFileSync(S,"utf8")).devToken}catch{}}a||(l(),O('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),d(`[OZmoz] Creating project "${s}" on Cloud...`);let m=Me(s),u=[m,`${m.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${m.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],h=null,p=null;for(let S of u)try{let z=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`},body:JSON.stringify({data:{name:s,keyApp:S}})}),y=await z.json();if(z.ok&&!y.error){h={keyApp:S,data:y.result?.data||y.data||{}};break}else p=y.error?.message||`HTTP ${z.status}`}catch(z){p=z.message}h||(l(),O(`Failed to create project on Cloud: ${p||"Unknown error"}`),process.exit(1));let g=h.data.bootstrapToken;await K(e,[`--keyApp=${h.keyApp}`,`--token=${g}`]);let v=c.join(e,"package.json");Y(e,v),await ee(e,[]),d(`
630
+ [OZmoz] Project "${s}" (${h.keyApp}) created and configured successfully.`),d(`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(i.existsSync(o))try{i.unlinkSync(o)}catch{}}}async function Ze(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let z=c.join(b.homedir(),".fleetbo","credentials.json");if(i.existsSync(z))try{t=JSON.parse(i.readFileSync(z,"utf8")).devToken}catch{}}let n=Z(e).OZ_KEY_APP;(!n||!t)&&(O("Cannot update: project uninitialized or dev token missing."),process.exit(1));let s=i.existsSync(c.join(e,"src"))?c.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],a=0;function m(z){let y=[];try{y=i.readdirSync(z,{withFileTypes:!0})}catch{return}for(let T of y){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(T.name))continue;let C=c.join(z,T.name);if(T.isDirectory())m(C);else if(o.has(c.extname(T.name))&&!T.name.endsWith(".d.ts"))try{let _=i.statSync(C);if(_.size>3e5)continue;let f=i.readFileSync(C,"utf8");/oz\.|<oz-/i.test(f)&&(a+=_.size,l.push({name:c.relative(e,C).split(c.sep).join("/"),content:f}))}catch{}}}m(s),l.length===0&&(O("Cannot update: no components using oz.* found."),process.exit(1)),a>8*1024*1024&&(O("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let u=I.find(z=>z.startsWith("--rules=")),h=u?u.slice(8).trim():"",p=I.find(z=>z.startsWith("--reasoning=")),g=p?p.slice(12).trim().toLowerCase():void 0;g!=="standard"&&g!=="high"&&(O("Missing or invalid --reasoning=<standard|high>."),O("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)),d(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let z=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:h,reasoning:g}})}),y=await z.json();(!z.ok||y.error)&&(O(`Update failed: ${y.error?.message||y.message||"Server error"}`),process.exit(1))}catch(z){O(`Network error: ${z.message}`),process.exit(1)}d("\u2192 Structure modeled. Sealing into OZmoz SVRO Kernel...");let v=N(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}),S=Date.now();for(let z=1;z<=5&&v.status===0;z++){let y=!0;try{let T=JSON.parse(i.readFileSync(c.join(e,"svro.schema.json"),"utf8"));y=Object.keys(T.collections||{}).length>0}catch{}if(y)break;d("\u2192 Contract still empty, waiting for the cloud (attempt "+z+"/5, "+Math.round((Date.now()-S)/1e3)+"s elapsed)..."),Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,6e3),v=N(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e})}v.status===0?d(`
632
632
  [OZmoz] Contract successfully locked into SVRO Kernel.
633
633
  `):(O(`
634
634
  [OZmoz] Kernel sync failed. Run "npx ozmoz sync" manually.
635
- `),process.exit(1))}async function Be(){let e=process.cwd(),t=c.join(e,"package.json");if(I==="init"||I==="doctor")d(`
636
- [OZmoz] Initializing and configuring OZmoz...`),await K(e,A),Y(e,t),d(`
635
+ `),process.exit(1))}async function Be(){let e=process.cwd(),t=c.join(e,"package.json");if(k==="init"||k==="doctor")d(`
636
+ [OZmoz] Initializing and configuring OZmoz...`),await K(e,I),Y(e,t),d(`
637
637
  [OZmoz] Configuration completed successfully!
638
638
  `),d(`
639
639
  Next step:`),d(` npx ozmoz sync (Sync cloud schema & generate IDE types)
640
- `);else if(I==="sync"){let r=A.includes("--dry-run"),n=A.includes("--check-only");d(`[OZmoz] Syncing schema...${r?" (dry-run)":""}${n?" (check-only, no network)":""}`),r||le(e);let s=c.join(e,"svro.schema.json"),o=c.join(e,"svro.workflow.json"),l=c.join(e,"ozmoz_contract.md"),a=c.join(e,"src","ozmoz.d.ts"),u=Z(e).OZ_ENTERPRISE_ID,f=null,p=null;if(n)d("\u2192 Mode check-only : Local contract used, no cloud fetch..");else if(u)try{d("\u2192 Fetching latest contracts from Cloud..."),f=await J(u,"svro.schema.json"),f&&(i.writeFileSync(s,JSON.stringify(f,null,2)+`
640
+ `);else if(k==="sync"){let r=I.includes("--dry-run"),n=I.includes("--check-only");d(`[OZmoz] Syncing schema...${r?" (dry-run)":""}${n?" (check-only, no network)":""}`),r||le(e);let s=c.join(e,"svro.schema.json"),o=c.join(e,"svro.workflow.json"),l=c.join(e,"ozmoz_contract.md"),a=c.join(e,"src","ozmoz.d.ts"),u=Z(e).OZ_ENTERPRISE_ID,h=null,p=null;if(n)d("\u2192 Mode check-only : Local contract used, no cloud fetch..");else if(u)try{d("\u2192 Fetching latest contracts from Cloud..."),h=await J(u,"svro.schema.json"),h&&(i.writeFileSync(s,JSON.stringify(h,null,2)+`
641
641
  `),d("\u2192 Local svro.schema.json updated.")),p=await J(u,"svro.workflow.json"),p&&(i.writeFileSync(o,JSON.stringify(p,null,2)+`
642
- `),d("\u2192 Local svro.workflow.json updated."))}catch(z){O(`\u26A0\uFE0F Cloud fetch bypassed: ${z.message}. Using local file fallback.`)}else O("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let h=f;if(!h&&i.existsSync(s))try{h=JSON.parse(i.readFileSync(s,"utf8"))}catch{}h||(h={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},i.writeFileSync(s,JSON.stringify(h,null,2)+`
642
+ `),d("\u2192 Local svro.workflow.json updated."))}catch(y){O(`\u26A0\uFE0F Cloud fetch bypassed: ${y.message}. Using local file fallback.`)}else O("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let g=h;if(!g&&i.existsSync(s))try{g=JSON.parse(i.readFileSync(s,"utf8"))}catch{}g||(g={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},i.writeFileSync(s,JSON.stringify(g,null,2)+`
643
643
  `,"utf8"),d("\u2192 Initial blank svro.schema.json created."));let v=p;if(!v&&i.existsSync(o))try{v=JSON.parse(i.readFileSync(o,"utf8"))}catch{}v||(v={actors:{},sequences:[]},i.writeFileSync(o,JSON.stringify(v,null,2)+`
644
- `,"utf8"),d("\u2192 Initial blank svro.workflow.json created."));{let z=je(h);z.changed&&(h=z.schema,i.writeFileSync(s,JSON.stringify(h,null,2)+`
645
- `,"utf8"),d("\u2192 Managed by system, no longer required from your code: "+z.notes.join(", ")+"."))}let{protocol:y}=await X(),S=Fe(h,v,y);i.writeFileSync(l,S,"utf8"),d("\u2192 Contract markdown successfully generated at project root.");try{let z=Object.keys(h.collections||{});if(u&&!n)try{await Pe(u,h,v),d("\u2192 Schema successfully sealed into SVRO Kernel (O(1)).")}catch(g){O(`\u26A0\uFE0F Kernel Shield sync warning: ${g.message}`)}let N=h.collections||{},C=Object.entries(N).map(([g,E])=>{let b=E.fields||E.schema||{},w=Object.entries(b).map(([B,P])=>{let L="any",D=String(typeof P=="string"?P:P.type||"").toLowerCase();return D==="string"||D==="text"||D==="media"?L="string":D==="number"?L="number":D==="boolean"||D==="toggle"?L="boolean":D==="array"&&(L="any[]"),` ${B}?:${L};`}).join(`
646
- `);return` ${g}: {
644
+ `,"utf8"),d("\u2192 Initial blank svro.workflow.json created."));{let y=je(g);y.changed&&(g=y.schema,i.writeFileSync(s,JSON.stringify(g,null,2)+`
645
+ `,"utf8"),d("\u2192 Managed by system, no longer required from your code: "+y.notes.join(", ")+"."))}let{protocol:S}=await X(),z=Fe(g,v,S);i.writeFileSync(l,z,"utf8"),d("\u2192 Contract markdown successfully generated at project root.");try{let y=Object.keys(g.collections||{});if(u&&!n)try{await De(u,g,v),d("\u2192 Schema successfully sealed into SVRO Kernel (O(1)).")}catch(f){O(`\u26A0\uFE0F Kernel Shield sync warning: ${f.message}`)}let T=g.collections||{},C=Object.entries(T).map(([f,E])=>{let A=E.fields||E.schema||{},w=Object.entries(A).map(([B,D])=>{let L="any",P=String(typeof D=="string"?D:D.type||"").toLowerCase();return P==="string"||P==="text"||P==="media"?L="string":P==="number"?L="number":P==="boolean"||P==="toggle"?L="boolean":P==="array"&&(L="any[]"),` ${B}?:${L};`}).join(`
646
+ `);return` ${f}: {
647
647
  ${w}
648
648
  };`}).join(`
649
- `),_=z.length>0?z.map(g=>`'${g}'`).join(" | "):"string";if(i.existsSync(c.dirname(a))){let g=`/* eslint-disable */
649
+ `),_=y.length>0?y.map(f=>`'${f}'`).join(" | "):"string";if(i.existsSync(c.dirname(a))){let f=`/* eslint-disable */
650
650
  /* prettier-ignore */
651
651
  // @ts-nocheck
652
652
  // Generated by OZmoz \u2014 Updated via sync
@@ -794,7 +794,7 @@ declare module 'svelte/elements' {
794
794
  'oz-reference': OzProp;
795
795
  }
796
796
  }
797
- `;i.writeFileSync(a,g)}ie(e),ae(e,t),ce(e),de(e),d(`[OZmoz] Schema synced successfully (${z.length} collection(s)).`),r&&d("\u2192 [Dry-run] Schema is valid.")}catch(z){O(`Error during synchronization: ${z.message}`),process.exit(1)}}else if(I==="create"){let r=A.slice(1).filter(n=>!n.startsWith("--")).join(" ");await Ue(e,r),process.exit(0)}else if(I==="update")await Ze(e),process.exit(0);else if(I==="mcp"){let r=A.includes("--run"),n=!1;if(!r&&!process.stdin.isTTY&&(r=await new Promise(s=>{let o=process.stdin,l=null,a=f=>{clearTimeout(l),o.removeListener("data",m),o.removeListener("end",u),o.removeListener("error",u),s(f)},m=f=>{o.pause(),o.unshift(f),n=!0,a(!0)},u=()=>a(!1);l=setTimeout(()=>{o.pause(),a(!1)},1500),o.on("data",m),o.once("end",u),o.once("error",u)})),r){try{await import(`file://${Q()}`),n&&process.stdin.resume()}catch(s){O(`Failed to start MCP server: ${s.message}`),process.exit(1)}return}await ee(e,A),process.exit(0)}else I==="login"?(await _e(e),process.exit(0)):I==="start"?xe(e,A):["--help","-h","help"].includes(I)?(d(`OZmoz CLI
797
+ `;i.writeFileSync(a,f)}ie(e),ae(e,t),ce(e),de(e),d(`[OZmoz] Schema synced successfully (${y.length} collection(s)).`),r&&d("\u2192 [Dry-run] Schema is valid.")}catch(y){O(`Error during synchronization: ${y.message}`),process.exit(1)}}else if(k==="create"){let r=I.slice(1).filter(n=>!n.startsWith("--")).join(" ");await Ue(e,r),process.exit(0)}else if(k==="update")await Ze(e),process.exit(0);else if(k==="mcp"){let r=I.includes("--run"),n=!1;if(!r&&!process.stdin.isTTY&&(r=await new Promise(s=>{let o=process.stdin,l=null,a=h=>{clearTimeout(l),o.removeListener("data",m),o.removeListener("end",u),o.removeListener("error",u),s(h)},m=h=>{o.pause(),o.unshift(h),n=!0,a(!0)},u=()=>a(!1);l=setTimeout(()=>{o.pause(),a(!1)},1500),o.on("data",m),o.once("end",u),o.once("error",u)})),r){try{await import(`file://${Q()}`),n&&process.stdin.resume()}catch(s){O(`Failed to start MCP server: ${s.message}`),process.exit(1)}return}await ee(e,I),process.exit(0)}else k==="login"?(await _e(e),process.exit(0)):k==="start"?xe(e,I):["--help","-h","help"].includes(k)?(d(`OZmoz CLI
798
798
 
799
799
  Commands:
800
800
  login Authenticate this machine (opens the browser: approve once, the command exits by itself)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ozmoz",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "SDK and CLI for the oz.* data API and the <oz-*> web components.",
5
5
  "license": "UNLICENSED",
6
6
  "keywords": [