ozmoz 0.1.11 → 0.1.14

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