ozmoz 0.1.22 → 0.1.25

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
@@ -1,33 +1,33 @@
1
1
  #!/usr/bin/env node
2
- var r=require("fs"),c=require("path"),W=require("https"),ne=require("http"),x=require("os"),{exec:oe,spawnSync:k}=require("child_process"),se=[c.join(__dirname,"..","scripts","setup-lib.cjs"),c.join(__dirname,"..","..","scripts","setup-lib.cjs"),c.join(__dirname,"scripts","setup-lib.cjs")],ie=se.find(r.existsSync)||c.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:q,handleAuthAndEnv:K,touchTsConfig:re,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce,writeBrowserConfig:le,patchAllowScripts:de}=require(ie),ue="\x1B[38;2;15;156;140m",pe="\x1B[31m",Y="\x1B[0m";function l(e){console.log(`${ue}${e}${Y}`)}function z(e){console.error(`${pe}${e}${Y}`)}var j="ozmoz",V=/<!--\s*(?:ozmoz|fleetbo|OZmoz):start[^>]*-->[\s\S]*?<!--\s*(?:ozmoz|fleetbo|OZmoz):end\s*-->/i,me="<!-- OZmoz:end -->",H="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",R={claude:"Claude Code",cursor:"Cursor",windsurf:"Windsurf",devin:"Devin",codex:"Codex CLI",gemini:"Gemini CLI",antigravity:"Antigravity CLI"},D={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 fe(){try{return JSON.parse(r.readFileSync(c.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}async function X(){let e=c.join(x.homedir(),".fleetbo","guidelines.json");try{l("[OZmoz] Fetching instructions from Cloud...");let o=await fetch("https://getagentdirectives-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:{}})});if(!o.ok)z("[OZmoz] Cloud error HTTP "+o.status);else{let s=await o.json(),t=s.result?.data||s.result||s.data;if(t&&t.protocol&&t.directives)return l("[OZmoz] Instructions loaded successfully."),r.existsSync(c.dirname(e))||r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,JSON.stringify(t,null,2),"utf8"),t;z("[OZmoz] Empty Cloud response.")}}catch(o){z("[OZmoz] Network error: "+o.message)}if(r.existsSync(e)){l("[OZmoz] Using local cache (~/.fleetbo/guidelines.json)");try{return JSON.parse(r.readFileSync(e,"utf8"))}catch{}}return{protocol:"",directives:"",version:"1.0.0"}}function J(e,o){return"<!-- ozmoz:start v"+e+` -->
3
- `+o.trim()+`
2
+ var r=require("fs"),c=require("path"),W=require("https"),ne=require("http"),w=require("os"),{exec:oe,spawnSync:j}=require("child_process"),se=[c.join(__dirname,"..","scripts","setup-lib.cjs"),c.join(__dirname,"..","..","scripts","setup-lib.cjs"),c.join(__dirname,"scripts","setup-lib.cjs")],ie=se.find(r.existsSync)||c.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:K,handleAuthAndEnv:q,touchTsConfig:re,attemptViteAutoImportPatch:ae,injectUniversalRuntime:ce,writeBrowserConfig:le,patchAllowScripts:de}=require(ie),ue="\x1B[38;2;15;156;140m",pe="\x1B[31m",Y="\x1B[0m";function d(e){console.log(e.replace(/OZmoz|\[|\]|→/g,t=>`${ue}${t}${Y}`))}function y(e){console.error(`${pe}${e}${Y}`)}var A="ozmoz",J=/<!--\s*(?:ozmoz|fleetbo|OZmoz):start[^>]*-->[\s\S]*?<!--\s*(?:ozmoz|fleetbo|OZmoz):end\s*-->/i,me="<!-- OZmoz:end -->",H="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",R={claude:"Claude Code",cursor:"Cursor",windsurf:"Windsurf",devin:"Devin",codex:"Codex CLI",gemini:"Gemini CLI",antigravity:"Antigravity CLI",copilot:"GitHub Copilot"},D={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 fe(){try{return JSON.parse(r.readFileSync(c.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}var he=Buffer.from("QUl6YVN5QUM1Uk94STNibklPMUR5TmZsTWhGUnJ0blItNDVwNFJF","base64").toString("utf8");function ge(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 ye(e,t){let s=await fetch(`https://securetoken.googleapis.com/v1/token?key=${he}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(t)}`});if(!s.ok)return null;let n=await s.json();return n.id_token?(r.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 Oe(){if(process.env.FLEETBO_DEV_TOKEN)return process.env.FLEETBO_DEV_TOKEN;try{let e=c.join(w.homedir(),".fleetbo","credentials.json");if(r.existsSync(e)){let t=JSON.parse(r.readFileSync(e,"utf8"));if(t.devToken&&!ge(t.devToken))return t.devToken;if(t.refreshToken)try{let s=await ye(e,t.refreshToken);if(s)return s}catch{}}}catch{}return null}async function X(){let e=c.join(w.homedir(),".fleetbo","guidelines.json"),t=await Oe();t||y('[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 s=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(!s.ok)y("[OZmoz] Cloud error HTTP "+s.status);else{let n=await s.json(),i=n.result?.data||n.result||n.data;if(i&&i.protocol&&i.directives)return d("[OZmoz] Instructions loaded successfully."),r.existsSync(c.dirname(e))||r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,JSON.stringify(i,null,2),"utf8"),i;y("[OZmoz] Empty Cloud response.")}}catch(s){y("[OZmoz] Network error: "+s.message)}if(r.existsSync(e)){d("[OZmoz] Using local cache (~/.fleetbo/guidelines.json)");try{return JSON.parse(r.readFileSync(e,"utf8"))}catch{}}return{protocol:"",directives:"",version:"1.0.0"}}function V(e,t){return"<!-- ozmoz:start v"+e+` -->
3
+ `+t.trim()+`
4
4
  `+me+`
5
- `}function he(e,o,s){let t=r.existsSync(e)?r.readFileSync(e,"utf8"):null,a,n;return t===null?(a="created",n=o):V.test(t)?(n=t.replace(V,()=>o.trimEnd()),a=n===t?"unchanged":"updated"):t.includes(H)?(a="migrated",n=o):(a="appended",n=t.replace(/\s*$/,`
5
+ `}function ze(e,t,s){let n=r.existsSync(e)?r.readFileSync(e,"utf8"):null,i,o;return n===null?(i="created",o=t):J.test(n)?(o=n.replace(J,()=>t.trimEnd()),i=o===n?"unchanged":"updated"):n.includes(H)?(i="migrated",o=t):(i="appended",o=n.replace(/\s*$/,`
6
6
 
7
- `)+o),!s&&a!=="unchanged"&&(a==="migrated"&&r.writeFileSync(e+".ozmoz-legacy.bak",t,"utf8"),r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,n,"utf8")),a}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(o=>r.existsSync(o))||c.resolve(__dirname,"ozmoz-mcp.js")}function Z(e,o){let s={command:process.execPath,args:[__filename,"mcp","--run"]},t={};if(r.existsSync(e))try{let n=JSON.parse(r.readFileSync(e,"utf8"));if(!n||typeof n!="object"||Array.isArray(n))return"invalid";t=n}catch{return"invalid"}let a=t.mcpServers&&t.mcpServers[j];return a&&JSON.stringify(a)===JSON.stringify(s)?"unchanged":(t.mcpServers=t.mcpServers||{},t.mcpServers[j]=s,o||(r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,JSON.stringify(t,null,2)+`
8
- `,"utf8")),a?"updated":"created")}function F(e){let o=process.platform==="win32"?"where":"which";return k(o,[e],{stdio:"ignore"}).status===0}function B(e,o,s){let t=k(e,o,{encoding:"utf8",timeout:s||3e4,shell:process.platform==="win32"});return{ok:t.status===0,out:(t.stdout||"")+(t.stderr||"")}}function ge(e,o,s){let t=e==="claude"?["--scope",s||"user"]:[],a=Q(),n=["mcp","add"].concat(t,[j,"--",process.execPath,a]),d=["mcp","remove",j].concat(t),i=e+" "+n.join(" ");if(!F(e))return{status:"manual",detail:i};if(o)return{status:"planned",detail:i};let p=B(e,["mcp","list"],6e4),u=p.ok?p.out.split(`
9
- `):[],m=u.find(v=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(v)),f=u.some(v=>/^\s*(?:fleetbo|fleetbo-svro):\s/.test(v));if(m&&m.includes("ozmoz@latest"))return{status:"unchanged",legacy:f};if(m&&!B(e,d).ok)return{status:"manual",detail:e+" "+d.join(" ")+" && "+i,legacy:f};let g=B(e,n);return g.ok?{status:m?"updated":"created",legacy:f}:{status:"failed",detail:i,message:g.out.trim().split(`
10
- `).slice(-2).join(" "),legacy:f}}function ye(e){let o={user:!1,local:!1,others:[]};try{let s=JSON.parse(r.readFileSync(c.join(x.homedir(),".claude.json"),"utf8")),t=i=>!!i&&typeof i=="object"&&/fleetbo-svro|ozmoz/.test(String(i.command||"")+" "+JSON.stringify(i.args||[])),a=(i,p)=>{!i||typeof i!="object"||Object.keys(i).forEach(u=>{u===j?o[p]=!0:t(i[u])&&o.others.push({name:u,where:p})})};a(s.mcpServers,"user");let n=e;try{n=r.realpathSync(e)}catch{}let d=s.projects||{};Array.from(new Set([e,n])).forEach(i=>a((d[i]||{}).mcpServers,"local"))}catch{}return o}function Oe(e){let o=ye(e);o.user&&l(" \u26A0\uFE0F A global (user-scope) '"+j+"' entry from a previous version also exists: the tools appear in every project. To keep them in OZmoz projects only: claude mcp remove "+j+" --scope user"),o.local&&l(" \u26A0\uFE0F A local-scope '"+j+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+j+" --scope local"),o.others.forEach(s=>{l(" \u26A0\uFE0F An old MCP entry named '"+s.name+"' ("+s.where+" scope) points to OZmoz/Fleetbo. Remove it: claude mcp remove "+s.name+" --scope "+s.where)})}function ze(e){let o=x.homedir(),s=t=>r.existsSync(t);return{claude:F("claude")||s(c.join(o,".claude")),cursor:s(c.join(e,".cursor"))||s(c.join(o,".cursor"))||F("cursor"),windsurf:s(c.join(o,".codeium","windsurf"))||s(c.join(e,".windsurf")),devin:s(c.join(e,".devin")),codex:F("codex")||s(c.join(o,".codex")),gemini:F("gemini")||s(c.join(o,".gemini")),antigravity:F("agy")||s(c.join(o,".antigravity"))||s(c.join(e,".antigravity"))}}var Se={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 ve(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function Ee(e,o,s){let t=ve(o),a=t?`The user already provided their project description and technical choices: "${t}".
7
+ `)+t),!s&&i!=="unchanged"&&(i==="migrated"&&r.writeFileSync(e+".ozmoz-legacy.bak",n,"utf8"),r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,o,"utf8")),i}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=>r.existsSync(t))||c.resolve(__dirname,"ozmoz-mcp.js")}function Z(e,t,s){let n=Object.assign({command:process.execPath,args:[__filename,"mcp","--run"]},s||{}),i={};if(r.existsSync(e))try{let l=JSON.parse(r.readFileSync(e,"utf8"));if(!l||typeof l!="object"||Array.isArray(l))return"invalid";i=l}catch{return"invalid"}let o=i.mcpServers&&i.mcpServers[A];return o&&JSON.stringify(o)===JSON.stringify(n)?"unchanged":(i.mcpServers=i.mcpServers||{},i.mcpServers[A]=n,t||(r.mkdirSync(c.dirname(e),{recursive:!0}),r.writeFileSync(e,JSON.stringify(i,null,2)+`
8
+ `,"utf8")),o?"updated":"created")}function F(e){let t=process.platform==="win32"?"where":"which";return j(t,[e],{stdio:"ignore"}).status===0}function B(e,t,s){let n=j(e,t,{encoding:"utf8",timeout:s||3e4,shell:process.platform==="win32"});return{ok:n.status===0,out:(n.stdout||"")+(n.stderr||"")}}function Se(e,t,s){let n=e==="claude"?["--scope",s||"user"]:[],i=Q(),o=["mcp","add"].concat(n,[A,"--",process.execPath,i]),l=["mcp","remove",A].concat(n),a=e+" "+o.join(" ");if(!F(e))return{status:"manual",detail:a};if(t)return{status:"planned",detail:a};let p=B(e,["mcp","list"],6e4),u=p.ok?p.out.split(`
9
+ `):[],m=u.find(v=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(v)),f=u.some(v=>/^\s*(?:fleetbo|fleetbo-svro):\s/.test(v));if(m&&m.includes("ozmoz@latest"))return{status:"unchanged",legacy:f};if(m&&!B(e,l).ok)return{status:"manual",detail:e+" "+l.join(" ")+" && "+a,legacy:f};let g=B(e,o);return g.ok?{status:m?"updated":"created",legacy:f}:{status:"failed",detail:a,message:g.out.trim().split(`
10
+ `).slice(-2).join(" "),legacy:f}}function ve(e){let t={user:!1,local:!1,others:[]};try{let s=JSON.parse(r.readFileSync(c.join(w.homedir(),".claude.json"),"utf8")),n=a=>!!a&&typeof a=="object"&&/fleetbo-svro|ozmoz/.test(String(a.command||"")+" "+JSON.stringify(a.args||[])),i=(a,p)=>{!a||typeof a!="object"||Object.keys(a).forEach(u=>{u===A?t[p]=!0:n(a[u])&&t.others.push({name:u,where:p})})};i(s.mcpServers,"user");let o=e;try{o=r.realpathSync(e)}catch{}let l=s.projects||{};Array.from(new Set([e,o])).forEach(a=>i((l[a]||{}).mcpServers,"local"))}catch{}return t}function Ee(e){let t=ve(e);t.user&&d(" \u26A0\uFE0F A global (user-scope) '"+A+"' entry from a previous version also exists: the tools appear in every project. To keep them in OZmoz projects only: claude mcp remove "+A+" --scope user"),t.local&&d(" \u26A0\uFE0F A local-scope '"+A+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+A+" --scope local"),t.others.forEach(s=>{d(" \u26A0\uFE0F An old MCP entry named '"+s.name+"' ("+s.where+" scope) points to OZmoz/Fleetbo. Remove it: claude mcp remove "+s.name+" --scope "+s.where)})}function Te(e){let t=w.homedir(),s=n=>r.existsSync(n);return{claude:F("claude")||s(c.join(t,".claude")),cursor:s(c.join(e,".cursor"))||s(c.join(t,".cursor"))||F("cursor"),windsurf:s(c.join(t,".codeium","windsurf"))||s(c.join(e,".windsurf")),devin:s(c.join(e,".devin")),codex:F("codex")||s(c.join(t,".codex")),gemini:F("gemini")||s(c.join(t,".gemini")),antigravity:F("agy")||s(c.join(t,".antigravity"))||s(c.join(e,".antigravity")),copilot:F("copilot")||s(c.join(t,".copilot"))}}var we={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 be(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function xe(e,t,s){let n=be(t),i=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.",n=null;try{let u=c.join(s,".env");if(r.existsSync(u)){let m=r.readFileSync(u,"utf8").match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);m&&(n=m[1].trim())}}catch{}let d=r.existsSync(c.join(s,"svro.schema.json")),i=r.existsSync(c.join(s,"index.html"))||r.existsSync(c.join(s,"package.json")),p=n||d?"This folder ALREADY contains an OZmoz project"+(n?" (OZ_DB_KEY="+n+")":"")+" \u2014 do NOT read .env or svro.schema.json yourself, do NOT call oz_create_project, and do NOT ask the starter questions (technology/description). State this in one plain sentence to the user \u2014 then ask what I want to work on now.":i?'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). "+a;return"Use OZmoz as the backend of my app. You are in the project folder ("+s+"). Follow your OZmoz local instructions (do NOT run bash commands or web searches to inspect instruction files, they are already active). "+p}function Te(){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 o=k("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(o.status!==0)return!1;let s=new Map;o.stdout.split(`
14
- `).forEach(a=>{let n=a.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);n&&s.set(Number(n[1]),{ppid:Number(n[2]),args:n[3]})});let t=process.ppid;for(let a=0;t>1&&a<20&&s.has(t);a++){let{ppid:n,args:d}=s.get(t);if(d.split(/\s+/).slice(0,2).some(p=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(p))||/@google\/gemini-cli|@anthropic-ai\/claude-code|@openai\/codex/.test(d))return!0;t=n}}catch{}return!1}function we(e){let o=process.platform==="win32"?"where":"which";return k(o,[e],{stdio:"ignore"}).status===0}function be(e,o){let s=o.slice(1).filter(m=>!m.startsWith("--")),t=(s[0]||"").toLowerCase(),a=s.slice(1).join(" "),n=Se[t];n||(z('Usage: npx ozmoz start <claude|gemini|codex> ["your app idea"]'),z('Cursor, Windsurf and Devin have no terminal agent to launch: run "npx ozmoz mcp --agent=<cursor|windsurf|devin>" instead.'),process.exit(1));let d=!1;try{d=!!JSON.parse(r.readFileSync(c.join(x.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}d||(l("[OZmoz] First use on this machine: sign in (your browser opens, approve once)."),k(process.execPath,[__filename,"login"],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(z('Sign-in did not complete. Run "npx ozmoz start '+t+'" again.'),process.exit(1))),k(process.execPath,[__filename,"mcp","--agent="+t],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(z("Could not configure "+n.bin+'. Run "npx ozmoz mcp --agent='+t+'" to see why.'),process.exit(1)),Te()&&(l(`
15
- [OZmoz] OZmoz is set up in this folder (instruction file + MCP server).`),l("[OZmoz] You are already inside an AI agent's shell, so no second agent is launched."),l('[OZmoz] NEXT: tell the user, in plain words, to quit this agent and start it again in this folder (or to run "npx -y ozmoz@latest start '+t+`" in a normal terminal), then to paste the message again. Do not run any other command.
16
- `),process.exit(0)),we(n.bin)||(z('"'+n.bin+'" is not installed or not in your PATH. Install it, then run: npx ozmoz start '+t),process.exit(1));let p=Ee(n.rules,a,e);l(`
17
- [OZmoz] Launching `+n.bin+` in this folder...
18
- `);let u=k(n.bin,n.launch(process.platform==="win32"?'"'+p+'"':p),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(u.status===null?1:u.status)}async function ee(e,o){let s=o.includes("--dry-run"),t=o.find(h=>h.startsWith("--agent=")),a=t&&t.slice(8).trim()?t.slice(8).split(",").map(h=>h.trim().toLowerCase()).filter(Boolean):null,n=null;if(a){n=a.includes("all")?Object.keys(R):a;let h=n.filter(E=>!R[E]);h.length&&(z("Unknown agent(s): "+h.join(", ")+". Valid values: "+Object.keys(R).join(", ")+", all."),process.exit(1))}let d=o.find(h=>h.startsWith("--scope=")),i=d?d.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(i)||(z("Unknown scope: "+i+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let p=ze(e),u=n||Object.keys(R).filter(h=>p[h]),m=fe();l(`
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;try{let u=c.join(s,".env");if(r.existsSync(u)){let m=r.readFileSync(u,"utf8").match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);m&&(o=m[1].trim())}}catch{}let l=r.existsSync(c.join(s,"svro.schema.json")),a=r.existsSync(c.join(s,"index.html"))||r.existsSync(c.join(s,"package.json")),p=o||l?"This folder ALREADY contains an OZmoz project"+(o?" (OZ_DB_KEY="+o+")":"")+" \u2014 the required key is already given above, so do NOT read .env or svro.schema.json yourself under any circumstance, even to verify or double-check. Do NOT call oz_create_project, and do NOT ask the starter questions (technology/description). State this in one plain sentence to the user \u2014 then ask what I want to work on now.":a?'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). "+i;return"Use OZmoz as the backend of my app. You are in the project folder ("+s+"). Follow your OZmoz local instructions (do NOT run bash commands or web searches to inspect instruction files, they are already active). "+p}function Ce(){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=j("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(t.status!==0)return!1;let s=new Map;t.stdout.split(`
14
+ `).forEach(i=>{let o=i.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);o&&s.set(Number(o[1]),{ppid:Number(o[2]),args:o[3]})});let n=process.ppid;for(let i=0;n>1&&i<20&&s.has(n);i++){let{ppid:o,args:l}=s.get(n);if(l.split(/\s+/).slice(0,2).some(p=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(p))||/@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 j(t,[e],{stdio:"ignore"}).status===0}function Ae(e,t){let s=t.slice(1).filter(m=>!m.startsWith("--")),n=(s[0]||"").toLowerCase(),i=s.slice(1).join(" "),o=we[n];o||(y('Usage: npx ozmoz start <claude|gemini|codex> ["your app idea"]'),y('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(r.readFileSync(c.join(w.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}l||(d("[OZmoz] First use on this machine: sign in (your browser opens, approve once)."),j(process.execPath,[__filename,"login"],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(y('Sign-in did not complete. Run "npx ozmoz start '+n+'" again.'),process.exit(1))),j(process.execPath,[__filename,"mcp","--agent="+n],{stdio:"inherit",cwd:e,env:Object.assign({},process.env,{FLEETBO_START:"1"})}).status!==0&&(y("Could not configure "+o.bin+'. Run "npx ozmoz mcp --agent='+n+'" to see why.'),process.exit(1)),Ce()&&(d(`
15
+ [OZmoz] OZmoz is set up in this folder (instruction file + MCP server).`),d("[OZmoz] You are already inside an AI agent's shell, so no second agent is launched."),d('[OZmoz] NEXT: tell the user, in plain words, to quit this agent and start it again in this folder (or to run "npx -y ozmoz@latest start '+n+`" in a normal terminal), then to paste the message again. Do not run any other command.
16
+ `),process.exit(0)),ke(o.bin)||(y('"'+o.bin+'" is not installed or not in your PATH. Install it, then run: npx ozmoz start '+n),process.exit(1));let p=xe(o.rules,i,e);d(`
17
+ [OZmoz] Launching `+o.bin+` in this folder...
18
+ `);let u=j(o.bin,o.launch(process.platform==="win32"?'"'+p+'"':p),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(u.status===null?1:u.status)}async function ee(e,t){let s=t.includes("--dry-run"),n=t.find(h=>h.startsWith("--agent=")),i=n&&n.slice(8).trim()?n.slice(8).split(",").map(h=>h.trim().toLowerCase()).filter(Boolean):null,o=null;if(i){o=i.includes("all")?Object.keys(R):i;let h=o.filter(E=>!R[E]);h.length&&(y("Unknown agent(s): "+h.join(", ")+". Valid values: "+Object.keys(R).join(", ")+", all."),process.exit(1))}let l=t.find(h=>h.startsWith("--scope=")),a=l?l.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(a)||(y("Unknown scope: "+a+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let p=Te(e),u=o||Object.keys(R).filter(h=>p[h]),m=fe();d(`
19
19
  [OZmoz] Configuring your AI agents`+(s?" (dry run: nothing is written)":"")+"...");let f=await X(),g=f.version||m,v=`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
20
20
 
21
21
  `+(f.directives||f.guidelines||"")+`
22
22
 
23
23
  ## PROTOCOLE DONN\xC9ES : QUI FAIT QUOI (AGENT FRONTEND \u2194 ALEX AI)
24
24
 
25
- `+(f.protocol||""),y=J(g,v),S=[["AGENTS.md",y],["GEMINI.md",y],["CLAUDE.md",J(g,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
26
- @AGENTS.md`)]],O=c.join(e,".cursorrules");if(r.existsSync(O)){let h=r.readFileSync(O,"utf8");(V.test(h)||h.includes(H))&&S.push([".cursorrules",y])}for(let h of S)l("\u2192 "+h[0]+": "+D[he(c.join(e,h[0]),h[1],s)]);for(let h of u){let E=R[h];if(h==="cursor")l("\u2192 "+E+" MCP (.cursor/mcp.json): "+D[Z(c.join(e,".cursor","mcp.json"),s)]);else if(h==="windsurf")l("\u2192 "+E+" MCP (~/.codeium/windsurf/mcp_config.json): "+D[Z(c.join(x.homedir(),".codeium","windsurf","mcp_config.json"),s)]);else if(h==="claude"&&i==="project"){let w=Z(c.join(e,".mcp.json"),s);l("\u2192 "+E+" MCP (.mcp.json, project scope): "+D[w]),(w==="created"||w==="updated")&&l(" 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)."),Oe(e)}else if(h==="gemini"){let w=[c.join(x.homedir(),".gemini","settings.json"),c.join(e,".gemini","settings.json"),c.join(e,".mcp.json")],T="unchanged";w.forEach($=>{let I=Z($,s);(I==="created"||I==="updated")&&(T=I)}),l("\u2192 "+E+" MCP (settings.json & .mcp.json): "+D[T])}else if(h==="claude"||h==="codex"||h==="antigravity"){let w=h==="antigravity"?"agy":h,T=ge(w,s,i);T.status==="manual"?l("\u2192 "+E+": '"+w+"' not found or not scriptable. Run manually: "+T.detail):T.status==="planned"?l("\u2192 "+E+" MCP: would run: "+T.detail):T.status==="failed"?z("\u2192 "+E+" MCP: registration failed ("+T.message+"). Run manually: "+T.detail):l("\u2192 "+E+" MCP"+(h==="claude"?" ("+i+" scope)":"")+": "+D[T.status]),T.legacy&&l(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+w+" mcp remove fleetbo")}else h==="devin"&&l("\u2192 "+E+": reads AGENTS.md. Devin runs in its own environment: add the Fleetbo MCP server from Devin's settings (not automated).")}!n&&u.length===0&&l("\u2192 No agent detected: instruction files were written; re-run with --agent=<name> to register the MCP server.");let C=!!(U(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),N=c.join(x.homedir(),".fleetbo","credentials.json");if(r.existsSync(N))try{C=C||!!JSON.parse(r.readFileSync(N,"utf8")).devToken}catch{}C||z('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||l(`
25
+ `+(f.protocol||""),O=V(g,v),S=[["AGENTS.md",O],["GEMINI.md",O],["CLAUDE.md",V(g,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
26
+ @AGENTS.md`)]],z=c.join(e,".cursorrules");if(r.existsSync(z)){let h=r.readFileSync(z,"utf8");(J.test(h)||h.includes(H))&&S.push([".cursorrules",O])}for(let h of S)d("\u2192 "+h[0]+": "+D[ze(c.join(e,h[0]),h[1],s)]);for(let h of u){let E=R[h];if(h==="cursor")d("\u2192 "+E+" MCP (.cursor/mcp.json): "+D[Z(c.join(e,".cursor","mcp.json"),s)]);else if(h==="windsurf")d("\u2192 "+E+" MCP (~/.codeium/windsurf/mcp_config.json): "+D[Z(c.join(w.homedir(),".codeium","windsurf","mcp_config.json"),s)]);else if(h==="copilot")d("\u2192 "+E+" MCP (~/.copilot/mcp-config.json): "+D[Z(c.join(w.homedir(),".copilot","mcp-config.json"),s,{type:"local",tools:["*"]})]);else if(h==="claude"&&a==="project"){let b=Z(c.join(e,".mcp.json"),s);d("\u2192 "+E+" MCP (.mcp.json, project scope): "+D[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)."),Ee(e)}else if(h==="gemini"){let b=[c.join(w.homedir(),".gemini","settings.json"),c.join(e,".gemini","settings.json"),c.join(e,".mcp.json")],T="unchanged";b.forEach($=>{let I=Z($,s);(I==="created"||I==="updated")&&(T=I)}),d("\u2192 "+E+" MCP (settings.json & .mcp.json): "+D[T])}else if(h==="claude"||h==="codex"||h==="antigravity"){let b=h==="antigravity"?"agy":h,T=Se(b,s,a);T.status==="manual"?d("\u2192 "+E+": '"+b+"' not found or not scriptable. Run manually: "+T.detail):T.status==="planned"?d("\u2192 "+E+" MCP: would run: "+T.detail):T.status==="failed"?y("\u2192 "+E+" MCP: registration failed ("+T.message+"). Run manually: "+T.detail):d("\u2192 "+E+" MCP"+(h==="claude"?" ("+a+" scope)":"")+": "+D[T.status]),T.legacy&&d(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+b+" mcp remove fleetbo")}else h==="devin"&&d("\u2192 "+E+": reads AGENTS.md. Devin runs in its own environment: add the Fleetbo 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=!!(U(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),N=c.join(w.homedir(),".fleetbo","credentials.json");if(r.existsSync(N))try{C=C||!!JSON.parse(r.readFileSync(N,"utf8")).devToken}catch{}C||y('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||d(`
27
27
  [OZmoz] Done. Restart your agent so it reloads the tools and instruction files.
28
- `)}function xe(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";oe(`${o} "${e}"`)}function Ce(e){return new Promise((o,s)=>{let t=ne.createServer((a,n)=>{if(n.setHeader("Access-Control-Allow-Origin","*"),n.setHeader("Access-Control-Allow-Methods","GET, OPTIONS"),n.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),n.setHeader("Access-Control-Allow-Private-Network","true"),a.method==="OPTIONS"){n.writeHead(204),n.end();return}let d=new URL(a.url,"http://127.0.0.1");if(d.pathname==="/callback"){let i=d.searchParams.get("token"),p=d.searchParams.get("refresh");if(!i){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end("<h3>Error: Missing token.</h3>");return}let u=c.join(x.homedir(),".fleetbo");r.existsSync(u)||r.mkdirSync(u,{recursive:!0}),r.writeFileSync(c.join(u,"credentials.json"),JSON.stringify({devToken:i,refreshToken:p||null,updatedAt:new Date().toISOString()},null,2));let m=c.join(e,".env");if(r.existsSync(m)){let f=r.readFileSync(m,"utf8");f.includes("FLEETBO_DEV_TOKEN=")?f=f.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${i}`):f+=`
29
- FLEETBO_DEV_TOKEN=${i}
30
- `,r.writeFileSync(m,f,"utf8")}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),n.end(`
28
+ `)}function je(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";oe(`${t} "${e}"`)}function _e(e){return new Promise((t,s)=>{let n=ne.createServer((i,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"),i.method==="OPTIONS"){o.writeHead(204),o.end();return}let l=new URL(i.url,"http://127.0.0.1");if(l.pathname==="/callback"){let a=l.searchParams.get("token"),p=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(w.homedir(),".fleetbo");r.existsSync(u)||r.mkdirSync(u,{recursive:!0}),r.writeFileSync(c.join(u,"credentials.json"),JSON.stringify({devToken:a,refreshToken:p||null,updatedAt:new Date().toISOString()},null,2));let m=c.join(e,".env");if(r.existsSync(m)){let f=r.readFileSync(m,"utf8");f.includes("FLEETBO_DEV_TOKEN=")?f=f.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${a}`):f+=`
29
+ FLEETBO_DEV_TOKEN=${a}
30
+ `,r.writeFileSync(m,f,"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>
@@ -45,28 +45,28 @@ FLEETBO_DEV_TOKEN=${i}
45
45
  </div>
46
46
  </body>
47
47
  </html>
48
- `),l(`
49
- [OZmoz] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(f=>r.existsSync(c.join(e,f)))&&(l(`
50
- Next step to connect your AI agents:`),l(` npx ozmoz mcp (Configure Claude Code, Cursor, Windsurf, Devin, Codex CLI, Gemini CLI)
51
- `)),typeof t.closeAllConnections=="function"&&t.closeAllConnections(),t.close(()=>o()),setTimeout(()=>o(),300)}});t.listen(0,"127.0.0.1",()=>{let n=`https://ozmoz.io/cli-auth?port=${t.address().port}`;l(`
52
- [OZmoz] Waiting for authentication...`),l(`If your browser does not open automatically, visit: ${n}`),xe(n);let d=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof t.closeAllConnections=="function"&&t.closeAllConnections()}catch{}t.close(),s(new Error(`Login timed out after ${Math.round(d/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},d).unref()}),t.on("error",a=>s(a))})}function Ae(e,o,s){return new Promise((t,a)=>{let n=JSON.stringify({enterpriseID:e,schema:o,workflow:s}),d={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)}},i=W.request(d,p=>{let u="";p.on("data",m=>{u+=m}),p.on("end",()=>{p.statusCode>=200&&p.statusCode<300?t(JSON.parse(u)):a(new Error(`Edge sync failed with HTTP ${p.statusCode}`))})});i.on("error",p=>a(p)),i.write(n),i.end()})}function U(e){let o=c.join(e,".env");if(!r.existsSync(o))return{};let s=r.readFileSync(o,"utf8"),t={};return s.split(`
53
- `).forEach(a=>{let[n,...d]=a.split("=");n&&d.length>0&&(t[n.trim()]=d.join("=").trim())}),t}function G(e,o){return new Promise((s,t)=>{let a=JSON.stringify({projectId:e,moduleName:o}),n={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a)}},d=W.request(n,i=>{let p="";i.on("data",u=>{p+=u}),i.on("end",()=>{if(i.statusCode>=200&&i.statusCode<300)try{let u=JSON.parse(p);if(u.success&&u.found&&u.module){let m=u.module.code||u.module.mockCode;s(typeof m=="string"?JSON.parse(m):m)}else s(null)}catch{t(new Error(`Invalid JSON response for ${o}.`))}else t(new Error(`Server error ${i.statusCode} while fetching ${o}`))})});d.on("error",i=>t(i)),d.write(a),d.end()})}var b=process.argv.slice(2),A=b[0],je=["id","_id","userId","author","dateCreated","createdAt","_schema_version"],te=e=>je.includes(e)||/^_/.test(e)||/^(created|updated|modified|deleted)(At|By)$/i.test(e);function M(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 ke(e){let o=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:o};let s=JSON.parse(JSON.stringify(e));return Object.entries(s.collections).forEach(([t,a])=>{let n=M(a);n&&Object.keys(n).forEach(d=>{te(d)&&n[d]&&typeof n[d]=="object"&&n[d].required===!0&&(n[d].required=!1,o.push(t+"."+d))})}),{schema:s,changed:o.length>0,notes:o}}function _e(e){let o=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),s=e&&(e.enum||e.values||e.options);return Array.isArray(s)&&s.length?JSON.stringify(s[0]):o==="number"||o==="integer"||o==="float"?"0":o==="boolean"||o==="toggle"?"false":o==="date"||o==="datetime"||o==="timestamp"?"new Date().toISOString()":o==="reference"?"'<id du document li\xE9>'":o==="media"?"null /* image/fichier : oz.addWithMedia */":o==="array"?"[]":"'\u2026'"}function Ne(e){let s=Object.entries(e&&e.collections||{}),t=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
48
+ `),d(`
49
+ [OZmoz] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(f=>r.existsSync(c.join(e,f)))&&(d(`
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
+ `)),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}`),je(o);let l=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),s(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",i=>s(i))})}function Ne(e,t,s){return new Promise((n,i)=>{let o=JSON.stringify({enterpriseID:e,schema:t,workflow:s}),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,p=>{let u="";p.on("data",m=>{u+=m}),p.on("end",()=>{p.statusCode>=200&&p.statusCode<300?n(JSON.parse(u)):i(new Error(`Edge sync failed with HTTP ${p.statusCode}`))})});a.on("error",p=>i(p)),a.write(o),a.end()})}function U(e){let t=c.join(e,".env");if(!r.existsSync(t))return{};let s=r.readFileSync(t,"utf8"),n={};return s.split(`
53
+ `).forEach(i=>{let[o,...l]=i.split("=");o&&l.length>0&&(n[o.trim()]=l.join("=").trim())}),n}function G(e,t){return new Promise((s,n)=>{let i=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(i)}},l=W.request(o,a=>{let p="";a.on("data",u=>{p+=u}),a.on("end",()=>{if(a.statusCode>=200&&a.statusCode<300)try{let u=JSON.parse(p);if(u.success&&u.found&&u.module){let m=u.module.code||u.module.mockCode;s(typeof m=="string"?JSON.parse(m):m)}else s(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(i),l.end()})}var x=process.argv.slice(2),k=x[0],Ie=["id","_id","userId","author","dateCreated","createdAt","_schema_version"],te=e=>Ie.includes(e)||/^_/.test(e)||/^(created|updated|modified|deleted)(At|By)$/i.test(e);function M(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 Pe(e){let t=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:t};let s=JSON.parse(JSON.stringify(e));return Object.entries(s.collections).forEach(([n,i])=>{let o=M(i);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:s,changed:t.length>0,notes:t}}function De(e){let t=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),s=e&&(e.enum||e.values||e.options);return Array.isArray(s)&&s.length?JSON.stringify(s[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 Fe(e){let s=Object.entries(e&&e.collections||{}),n=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
54
54
 
55
- `;t+=`### \u{1F194} Identifiants
56
- `,t+="* 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",t+="* N'envoie **jamais** `id` ni `_id` dans `oz.add` : `oz.add` renvoie `{ success, documentId }` (`documentId` = `_id`).\n",t+="* 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",t+="* `userId`, `createdAt` et les autres champs de tra\xE7abilit\xE9 sont renseign\xE9s par le moteur : ne les envoie pas.\n\n";let a=s.filter(([,n])=>M(n)&&Object.keys(M(n)).length>0);return a.length===0?t+`_Aucune collection scell\xE9e pour l'instant : les mod\xE8les appara\xEEtront apr\xE8s la mod\xE9lisation d'Alex._
57
- `:(a.forEach(([n,d])=>{let i=M(d),p=Object.entries(i).filter(([f])=>!te(f));t+="### `"+n+`\`
55
+ `;n+=`### \u{1F194} Identifiants
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 i=s.filter(([,o])=>M(o)&&Object.keys(M(o)).length>0);return i.length===0?n+`_Aucune collection scell\xE9e pour l'instant : les mod\xE8les appara\xEEtront apr\xE8s la mod\xE9lisation d'Alex._
57
+ `:(i.forEach(([o,l])=>{let a=M(l),p=Object.entries(a).filter(([f])=>!te(f));n+="### `"+o+`\`
58
58
 
59
59
  | Champ | Type | Obligatoire | Valeurs / remarques |
60
60
  |---|---|---|---|
61
- `,p.forEach(([f,g])=>{let v=typeof g=="string"?g:g&&g.type||"any",y=g&&(g.enum||g.values||g.options),S=Array.isArray(y)&&y.length?"parmi : "+y.map(O=>"`"+O+"`").join(", "):"";t+="| `"+f+"` | "+v+" | "+(g&&g.required===!0?"\u2705 oui":"non")+" | "+S+` |
62
- `});let u=p.filter(([,f])=>f&&f.required===!0),m=p.filter(([,f])=>!(f&&f.required===!0));t+="\nInsertion valide :\n```js\nawait oz.add('"+n+`', {
63
- `,u.forEach(([f,g])=>{t+=" "+f+": "+_e(g)+`,
64
- `}),m.length&&(t+=" // optionnels : "+m.map(([f])=>f).join(", ")+`
65
- `),t+=`}, {
66
- `,t+=" desc: 'Cr\xE9ation d\\'un \xE9l\xE9ment dans "+n+`',
67
- `,t+=` role: 'AUTHENTICATED' // ou 'ANONYMOUS', 'ADMIN'
68
- `,t+=` // guard: 'condition sur les donn\xE9es' (optionnel)
69
- `,t+="});\n```\n\n"}),t)}function Ie(e,o,s=""){let t=e?.context||o?.context||"No written specifications provided.";return`# THE OZMOZ DATA CONTRACT (SVRO DATA CONTRACT)
61
+ `,p.forEach(([f,g])=>{let v=typeof g=="string"?g:g&&g.type||"any",O=g&&(g.enum||g.values||g.options),S=Array.isArray(O)&&O.length?"parmi : "+O.map(z=>"`"+z+"`").join(", "):"";n+="| `"+f+"` | "+v+" | "+(g&&g.required===!0?"\u2705 oui":"non")+" | "+S+` |
62
+ `});let u=p.filter(([,f])=>f&&f.required===!0),m=p.filter(([,f])=>!(f&&f.required===!0));n+="\nInsertion valide :\n```js\nawait oz.add('"+o+`', {
63
+ `,u.forEach(([f,g])=>{n+=" "+f+": "+De(g)+`,
64
+ `}),m.length&&(n+=" // optionnels : "+m.map(([f])=>f).join(", ")+`
65
+ `),n+=`}, {
66
+ `,n+=" desc: 'Cr\xE9ation d\\'un \xE9l\xE9ment dans "+o+`',
67
+ `,n+=` role: 'AUTHENTICATED' // ou 'ANONYMOUS', 'ADMIN'
68
+ `,n+=` // guard: 'condition sur les donn\xE9es' (optionnel)
69
+ `,n+="});\n```\n\n"}),n)}function Le(e,t,s=""){let n=e?.context||t?.context||"No written specifications provided.";return`# THE OZMOZ DATA CONTRACT (SVRO DATA CONTRACT)
70
70
 
71
71
  ### \u{1F6A8} MANDATORY CODE RULES (READ BEFORE WRITING ANY VIEW)
72
72
  1. **Identifiers:** the database generates \`_id\` (string) for each document. Use \`doc._id\` for \`key={doc._id}\`, for \`oz.getDoc/update/delete\`, and to link two collections (store the linked document's \`_id\` in a field, e.g., \`playlistId\`). \`doc.id\` exists on read as an alias (same value), but the canonical reference is \`_id\`.
@@ -153,7 +153,7 @@ const updateStatus = async (orderId, newStatus) => {
153
153
  });
154
154
 
155
155
  if (!res.success) {
156
- console.error('[OZmoz SVRO] Edge Rejection:', res.error);
156
+ logError('[OZmoz SVRO] Edge Rejection: ' + (typeof res.error === 'string' ? res.error : JSON.stringify(res.error)));
157
157
  handleError(res.error);
158
158
  }
159
159
  };
@@ -189,11 +189,11 @@ const updateStatus = async (orderId, newStatus) => {
189
189
  ---
190
190
 
191
191
  ## \u{1F4CB} BUSINESS SPECIFICATIONS (PROJECT CONTEXT)
192
- ${t}
192
+ ${n}
193
193
 
194
194
  ---
195
195
 
196
- ${Ne(e)}
196
+ ${Fe(e)}
197
197
 
198
198
  ---
199
199
 
@@ -206,29 +206,29 @@ ${JSON.stringify(e||{},null,2)}
206
206
 
207
207
  ## \u2699\uFE0F GOVERNANCE AND WORKFLOW CONTRACT (svro.workflow.json)
208
208
  \`\`\`json
209
- ${JSON.stringify(o||{},null,2)}
209
+ ${JSON.stringify(t||{},null,2)}
210
210
  \`\`\`
211
- `}function Pe(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function De(e,o){let s=U(e),t=r.existsSync(c.join(e,"svro.schema.json"));(s.OZ_DB_KEY||t)&&(z("Cannot create project: an OZmoz project already exists in this folder."),l('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let a=(o||"").trim();a||(z('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let n=c.join(e,".ozmoz.lock");if(r.existsSync(n)){let i=!1;try{let p=Number(r.readFileSync(n,"utf8"));Date.now()-p>6e4&&(i=!0)}catch{i=!0}i||(z("A project creation is already running in this folder."),process.exit(1)),r.unlinkSync(n)}r.writeFileSync(n,String(Date.now()));let d=()=>{if(r.existsSync(n))try{r.unlinkSync(n)}catch{}};try{let i=process.env.FLEETBO_DEV_TOKEN;if(!i){let y=c.join(x.homedir(),".fleetbo","credentials.json");if(r.existsSync(y))try{i=JSON.parse(r.readFileSync(y,"utf8")).devToken}catch{}}i||(d(),z('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),l(`[OZmoz] Creating project "${a}" on Cloud...`);let p=Pe(a),u=[p,`${p.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${p.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],m=null,f=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 ${i}`},body:JSON.stringify({data:{name:a,keyApp:y}})}),O=await S.json();if(S.ok&&!O.error){m={keyApp:y,data:O.result?.data||O.data||{}};break}else f=O.error?.message||`HTTP ${S.status}`}catch(S){f=S.message}m||(d(),z(`Failed to create project on Cloud: ${f||"Unknown error"}`),process.exit(1));let g=m.data.bootstrapToken;await K(e,[`--keyApp=${m.keyApp}`,`--token=${g}`]);let v=c.join(e,"package.json");q(e,v),await ee(e,[]),l(`
212
- [OZmoz] Project "${a}" (${m.keyApp}) created and configured successfully.`),l(`Next step: scaffold the frontend if needed, then run "npx ozmoz sync".
213
- `)}finally{if(r.existsSync(n))try{r.unlinkSync(n)}catch{}}}async function Fe(e){let o=process.env.FLEETBO_DEV_TOKEN;if(!o){let y=c.join(x.homedir(),".fleetbo","credentials.json");if(r.existsSync(y))try{o=JSON.parse(r.readFileSync(y,"utf8")).devToken}catch{}}let t=U(e).OZ_KEY_APP;(!t||!o)&&(z("Cannot update: project uninitialized or dev token missing."),process.exit(1));let a=r.existsSync(c.join(e,"src"))?c.join(e,"src"):e,n=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),d=[],i=0;function p(y){let S=[];try{S=r.readdirSync(y,{withFileTypes:!0})}catch{return}for(let O of S){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(O.name))continue;let _=c.join(y,O.name);if(O.isDirectory())p(_);else if(n.has(c.extname(O.name))&&!O.name.endsWith(".d.ts"))try{let C=r.statSync(_);if(C.size>3e5)continue;let N=r.readFileSync(_,"utf8");/oz\.|<oz-/i.test(N)&&(i+=C.size,d.push({name:c.relative(e,_).split(c.sep).join("/"),content:N}))}catch{}}}p(a),d.length===0&&(z("Cannot update: no components using oz.* found."),process.exit(1)),i>8*1024*1024&&(z("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let u=b.find(y=>y.startsWith("--rules=")),m=u?u.slice(8).trim():"",f=b.find(y=>y.startsWith("--reasoning=")),g=f?f.slice(12).trim().toLowerCase():void 0;l(`[OZmoz] Sending ${d.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 ${o}`},body:JSON.stringify({data:{keyApp:t,name:t,newViewFiles:d,fleetbo_rules:m,reasoning:g}})}),S=await y.json();(!y.ok||S.error)&&(z(`Update failed: ${S.error?.message||S.message||"Server error"}`),process.exit(1))}catch(y){z(`Network error: ${y.message}`),process.exit(1)}l("\u2192 Structure modeled. Sealing into SVRO Kernel..."),k(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}).status===0?l(`
211
+ `}function Re(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 s=U(e),n=r.existsSync(c.join(e,"svro.schema.json"));(s.OZ_DB_KEY||n)&&(y("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 i=(t||"").trim();i||(y('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let o=c.join(e,".ozmoz.lock");if(r.existsSync(o)){let a=!1;try{let p=Number(r.readFileSync(o,"utf8"));Date.now()-p>6e4&&(a=!0)}catch{a=!0}a||(y("A project creation is already running in this folder."),process.exit(1)),r.unlinkSync(o)}r.writeFileSync(o,String(Date.now()));let l=()=>{if(r.existsSync(o))try{r.unlinkSync(o)}catch{}};try{let a=process.env.FLEETBO_DEV_TOKEN;if(!a){let O=c.join(w.homedir(),".fleetbo","credentials.json");if(r.existsSync(O))try{a=JSON.parse(r.readFileSync(O,"utf8")).devToken}catch{}}a||(l(),y('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),d(`[OZmoz] Creating project "${i}" on Cloud...`);let p=Re(i),u=[p,`${p.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${p.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],m=null,f=null;for(let O 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:i,keyApp:O}})}),z=await S.json();if(S.ok&&!z.error){m={keyApp:O,data:z.result?.data||z.data||{}};break}else f=z.error?.message||`HTTP ${S.status}`}catch(S){f=S.message}m||(l(),y(`Failed to create project on Cloud: ${f||"Unknown error"}`),process.exit(1));let g=m.data.bootstrapToken;await q(e,[`--keyApp=${m.keyApp}`,`--token=${g}`]);let v=c.join(e,"package.json");K(e,v),await ee(e,[]),d(`
212
+ [OZmoz] Project "${i}" (${m.keyApp}) created and configured successfully.`),d(`Next step: scaffold the frontend if needed, then run "npx ozmoz sync".
213
+ `)}finally{if(r.existsSync(o))try{r.unlinkSync(o)}catch{}}}async function Me(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let O=c.join(w.homedir(),".fleetbo","credentials.json");if(r.existsSync(O))try{t=JSON.parse(r.readFileSync(O,"utf8")).devToken}catch{}}let n=U(e).OZ_KEY_APP;(!n||!t)&&(y("Cannot update: project uninitialized or dev token missing."),process.exit(1));let i=r.existsSync(c.join(e,"src"))?c.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],a=0;function p(O){let S=[];try{S=r.readdirSync(O,{withFileTypes:!0})}catch{return}for(let z of S){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(z.name))continue;let _=c.join(O,z.name);if(z.isDirectory())p(_);else if(o.has(c.extname(z.name))&&!z.name.endsWith(".d.ts"))try{let C=r.statSync(_);if(C.size>3e5)continue;let N=r.readFileSync(_,"utf8");/oz\.|<oz-/i.test(N)&&(a+=C.size,l.push({name:c.relative(e,_).split(c.sep).join("/"),content:N}))}catch{}}}p(i),l.length===0&&(y("Cannot update: no components using oz.* found."),process.exit(1)),a>8*1024*1024&&(y("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let u=x.find(O=>O.startsWith("--rules=")),m=u?u.slice(8).trim():"",f=x.find(O=>O.startsWith("--reasoning=")),g=f?f.slice(12).trim().toLowerCase():void 0;g!=="standard"&&g!=="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)),d(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let 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,fleetbo_rules:m,reasoning:g}})}),S=await O.json();(!O.ok||S.error)&&(y(`Update failed: ${S.error?.message||S.message||"Server error"}`),process.exit(1))}catch(O){y(`Network error: ${O.message}`),process.exit(1)}d("\u2192 Structure modeled. Sealing into SVRO Kernel..."),j(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}).status===0?d(`
214
214
  [OZmoz] Contract successfully locked into SVRO Kernel.
215
- `):(z(`
215
+ `):(y(`
216
216
  [OZmoz] Kernel sync failed. Run "npx ozmoz sync" manually.
217
- `),process.exit(1))}async function Le(){let e=process.cwd(),o=c.join(e,"package.json");if(A==="init"||A==="doctor")l(`
218
- [OZmoz] Initializing and configuring OZmoz...`),await K(e,b),q(e,o),l(`
217
+ `),process.exit(1))}async function Ue(){let e=process.cwd(),t=c.join(e,"package.json");if(k==="init"||k==="doctor")d(`
218
+ [OZmoz] Initializing and configuring OZmoz...`),await q(e,x),K(e,t),d(`
219
219
  [OZmoz] Configuration completed successfully!
220
- `),l(`
221
- Next step:`),l(` npx ozmoz sync (Sync cloud schema & generate IDE types)
222
- `);else if(A==="sync"){let s=b.includes("--dry-run"),t=b.includes("--check-only");l(`[OZmoz] Syncing schema...${s?" (dry-run)":""}${t?" (check-only, no network)":""}`),s||le(e);let a=c.join(e,"svro.schema.json"),n=c.join(e,"svro.workflow.json"),d=c.join(e,"ozmoz_contract.md"),i=c.join(e,"src","ozmoz.d.ts"),u=U(e).OZ_ENTERPRISE_ID,m=null,f=null;if(t)l("\u2192 Mode check-only : Local contract used, no cloud fetch..");else if(u)try{l("\u2192 Fetching latest contracts from Cloud..."),m=await G(u,"svro.schema.json"),m&&(r.writeFileSync(a,JSON.stringify(m,null,2)+`
223
- `),l("\u2192 Local svro.schema.json updated.")),f=await G(u,"svro.workflow.json"),f&&(r.writeFileSync(n,JSON.stringify(f,null,2)+`
224
- `),l("\u2192 Local svro.workflow.json updated."))}catch(O){z(`\u26A0\uFE0F Cloud fetch bypassed: ${O.message}. Using local file fallback.`)}else z("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let g=m;if(!g&&r.existsSync(a))try{g=JSON.parse(r.readFileSync(a,"utf8"))}catch{}g||(g={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},r.writeFileSync(a,JSON.stringify(g,null,2)+`
225
- `,"utf8"),l("\u2192 Initial blank svro.schema.json created."));let v=f;if(!v&&r.existsSync(n))try{v=JSON.parse(r.readFileSync(n,"utf8"))}catch{}v||(v={actors:{},sequences:[]},r.writeFileSync(n,JSON.stringify(v,null,2)+`
226
- `,"utf8"),l("\u2192 Initial blank svro.workflow.json created."));{let O=ke(g);O.changed&&(g=O.schema,r.writeFileSync(a,JSON.stringify(g,null,2)+`
227
- `,"utf8"),l("\u2192 Managed by system, no longer required from your code: "+O.notes.join(", ")+"."))}let{protocol:y}=await X(),S=Ie(g,v,y);r.writeFileSync(d,S,"utf8"),l("\u2192 Contract markdown successfully generated at project root.");try{let O=Object.keys(g.collections||{});if(u&&!t)try{await Ae(u,g,v),l("\u2192 Schema successfully sealed into SVRO Kernel (O(1)).")}catch(h){z(`\u26A0\uFE0F Kernel Shield sync warning: ${h.message}`)}let _=g.collections||{},C=Object.entries(_).map(([h,E])=>{let w=E.fields||E.schema||{},T=Object.entries(w).map(([$,I])=>{let L="any",P=String(typeof I=="string"?I:I.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[]"),` ${$}?:${L};`}).join(`
220
+ `),d(`
221
+ Next step:`),d(` npx ozmoz sync (Sync cloud schema & generate IDE types)
222
+ `);else if(k==="sync"){let s=x.includes("--dry-run"),n=x.includes("--check-only");d(`[OZmoz] Syncing schema...${s?" (dry-run)":""}${n?" (check-only, no network)":""}`),s||le(e);let i=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=U(e).OZ_ENTERPRISE_ID,m=null,f=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..."),m=await G(u,"svro.schema.json"),m&&(r.writeFileSync(i,JSON.stringify(m,null,2)+`
223
+ `),d("\u2192 Local svro.schema.json updated.")),f=await G(u,"svro.workflow.json"),f&&(r.writeFileSync(o,JSON.stringify(f,null,2)+`
224
+ `),d("\u2192 Local svro.workflow.json updated."))}catch(z){y(`\u26A0\uFE0F Cloud fetch bypassed: ${z.message}. Using local file fallback.`)}else y("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let g=m;if(!g&&r.existsSync(i))try{g=JSON.parse(r.readFileSync(i,"utf8"))}catch{}g||(g={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},r.writeFileSync(i,JSON.stringify(g,null,2)+`
225
+ `,"utf8"),d("\u2192 Initial blank svro.schema.json created."));let v=f;if(!v&&r.existsSync(o))try{v=JSON.parse(r.readFileSync(o,"utf8"))}catch{}v||(v={actors:{},sequences:[]},r.writeFileSync(o,JSON.stringify(v,null,2)+`
226
+ `,"utf8"),d("\u2192 Initial blank svro.workflow.json created."));{let z=Pe(g);z.changed&&(g=z.schema,r.writeFileSync(i,JSON.stringify(g,null,2)+`
227
+ `,"utf8"),d("\u2192 Managed by system, no longer required from your code: "+z.notes.join(", ")+"."))}let{protocol:O}=await X(),S=Le(g,v,O);r.writeFileSync(l,S,"utf8"),d("\u2192 Contract markdown successfully generated at project root.");try{let z=Object.keys(g.collections||{});if(u&&!n)try{await Ne(u,g,v),d("\u2192 Schema successfully sealed into SVRO Kernel (O(1)).")}catch(h){y(`\u26A0\uFE0F Kernel Shield sync warning: ${h.message}`)}let _=g.collections||{},C=Object.entries(_).map(([h,E])=>{let b=E.fields||E.schema||{},T=Object.entries(b).map(([$,I])=>{let L="any",P=String(typeof I=="string"?I:I.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[]"),` ${$}?:${L};`}).join(`
228
228
  `);return` ${h}: {
229
229
  ${T}
230
230
  };`}).join(`
231
- `),N=O.length>0?O.map(h=>`'${h}'`).join(" | "):"string";if(r.existsSync(c.dirname(i))){let h=`/* eslint-disable */
231
+ `),N=z.length>0?z.map(h=>`'${h}'`).join(" | "):"string";if(r.existsSync(c.dirname(a))){let h=`/* eslint-disable */
232
232
  /* prettier-ignore */
233
233
  // @ts-nocheck
234
234
  // Generated by OZmoz \u2014 Updated via sync
@@ -364,12 +364,12 @@ declare module 'svelte/elements' {
364
364
  'oz-reference': OzProp;
365
365
  }
366
366
  }
367
- `;r.writeFileSync(i,h)}re(e),ae(e,o),ce(e),de(e),l(`[OZmoz] Schema synced successfully (${O.length} collection(s)).`),s&&l("\u2192 [Dry-run] Schema is valid.")}catch(O){z(`Error during synchronization: ${O.message}`),process.exit(1)}}else if(A==="create"){let s=b.slice(1).filter(t=>!t.startsWith("--")).join(" ");await De(e,s),process.exit(0)}else if(A==="update")await Fe(e),process.exit(0);else if(A==="mcp"){let s=b.includes("--run"),t=!1;if(!s&&!process.stdin.isTTY&&(s=await new Promise(a=>{let n=process.stdin,d=null,i=m=>{clearTimeout(d),n.removeListener("data",p),n.removeListener("end",u),n.removeListener("error",u),a(m)},p=m=>{n.pause(),n.unshift(m),t=!0,i(!0)},u=()=>i(!1);d=setTimeout(()=>{n.pause(),i(!1)},1500),n.on("data",p),n.once("end",u),n.once("error",u)})),s){try{await import(`file://${Q()}`),t&&process.stdin.resume()}catch(a){z(`Failed to start MCP server: ${a.message}`),process.exit(1)}return}await ee(e,b),process.exit(0)}else A==="login"?(await Ce(e),process.exit(0)):A==="start"?be(e,b):["--help","-h","help"].includes(A)?(l(`OZmoz CLI
367
+ `;r.writeFileSync(a,h)}re(e),ae(e,t),ce(e),de(e),d(`[OZmoz] Schema synced successfully (${z.length} collection(s)).`),s&&d("\u2192 [Dry-run] Schema is valid.")}catch(z){y(`Error during synchronization: ${z.message}`),process.exit(1)}}else if(k==="create"){let s=x.slice(1).filter(n=>!n.startsWith("--")).join(" ");await Ze(e,s),process.exit(0)}else if(k==="update")await Me(e),process.exit(0);else if(k==="mcp"){let s=x.includes("--run"),n=!1;if(!s&&!process.stdin.isTTY&&(s=await new Promise(i=>{let o=process.stdin,l=null,a=m=>{clearTimeout(l),o.removeListener("data",p),o.removeListener("end",u),o.removeListener("error",u),i(m)},p=m=>{o.pause(),o.unshift(m),n=!0,a(!0)},u=()=>a(!1);l=setTimeout(()=>{o.pause(),a(!1)},1500),o.on("data",p),o.once("end",u),o.once("error",u)})),s){try{await import(`file://${Q()}`),n&&process.stdin.resume()}catch(i){y(`Failed to start MCP server: ${i.message}`),process.exit(1)}return}await ee(e,x),process.exit(0)}else k==="login"?(await _e(e),process.exit(0)):k==="start"?Ae(e,x):["--help","-h","help"].includes(k)?(d(`OZmoz CLI
368
368
 
369
369
  Commands:
370
370
  login Authenticate this machine (opens the browser: approve once, the command exits by itself)
371
371
  mcp Connect your AI agent and write its instruction files (AGENTS.md, CLAUDE.md, GEMINI.md).
372
- --agent=claude,cursor,windsurf,devin,codex,gemini,antigravity|all
372
+ --agent=claude,cursor,windsurf,devin,codex,gemini,antigravity,copilot|all
373
373
  --scope=project|user|local
374
374
  --dry-run
375
375
  start Zero-friction launch for terminal agents: sign in once, configure, then start ready to work.
@@ -380,4 +380,4 @@ Commands:
380
380
 
381
381
  AI agents: to create a project, call the MCP tool "oz_create_project".
382
382
  To evolve schema/workflow from UI files, call the MCP tool "oz_update_project", then run "sync".
383
- `),process.exit(0)):(z('Unknown command. Run "npx ozmoz --help".'),process.exit(1))}Le().catch(e=>{z(`OZmoz CLI Error: ${e.message}`),process.exit(1)});
383
+ `),process.exit(0)):(y('Unknown command. Run "npx ozmoz --help".'),process.exit(1))}Ue().catch(e=>{y(`OZmoz CLI Error: ${e.message}`),process.exit(1)});