ozmoz 0.1.37 → 0.1.39
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 +51 -49
- package/dist/ozmoz-mcp.js +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var
|
|
2
|
+
var s=require("fs"),a=require("path"),W=require("https"),oe=require("http"),A=require("os"),{exec:re,spawnSync:_}=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(s.existsSync)||a.join(__dirname,"..","scripts","setup-lib.cjs"),{runFullSetup:Y,handleAuthAndEnv:K,touchTsConfig:ae,attemptViteAutoImportPatch:ce,injectUniversalRuntime:le,writeBrowserConfig:de,patchAllowScripts:ue}=require(ie),me=!!(process.stdout&&process.stdout.isTTY&&typeof process.stdout.hasColors=="function"&&process.stdout.hasColors(16777216)),pe=me?"\x1B[38;2;15;156;140m":"\x1B[36m",fe="\x1B[31m",q="\x1B[0m";function u(e){console.log(e.replace(/OZmoz|\[|\]|→/g,t=>`${pe}${t}${q}`))}function y(e){console.error(`${fe}${e}${q}`)}var x="ozmoz",G=/<!--\s*(?:ozmoz|fleetbo|OZmoz):start[^>]*-->[\s\S]*?<!--\s*(?:ozmoz|fleetbo|OZmoz):end\s*-->/i,he="<!-- OZmoz:end -->",H="# OZMOZ DATA OS \u2014 DIRECTIVES SYST\xC8ME",M={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 ge(){try{return JSON.parse(s.readFileSync(a.join(__dirname,"..","package.json"),"utf8")).version||"dev"}catch{return"dev"}}var ye=Buffer.from("QUl6YVN5QUM1Uk94STNibklPMUR5TmZsTWhGUnJ0blItNDVwNFJF","base64").toString("utf8");function Oe(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 ze(e,t){let r=await fetch(`https://securetoken.googleapis.com/v1/token?key=${ye}`,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:`grant_type=refresh_token&refresh_token=${encodeURIComponent(t)}`});if(!r.ok)return null;let n=await r.json();return n.id_token?(s.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 X(){if(process.env.FLEETBO_DEV_TOKEN)return process.env.FLEETBO_DEV_TOKEN;try{let e=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(e)){let t=JSON.parse(s.readFileSync(e,"utf8"));if(t.devToken&&!Oe(t.devToken))return t.devToken;if(t.refreshToken)try{let r=await ze(e,t.refreshToken);if(r)return r}catch{}}}catch{}return null}async function Q(){let e=a.join(A.homedir(),".fleetbo","guidelines.json"),t=await X();t||y('[OZmoz] Not logged in: run "npx ozmoz login" first to load the full instructions. Using local cache if available.');try{u("[OZmoz] Fetching instructions from Cloud...");let r=await fetch("https://getagentdirectives-jqycakhlxa-uc.a.run.app",{method:"POST",headers:Object.assign({"Content-Type":"application/json"},t?{Authorization:`Bearer ${t}`}:{}),body:JSON.stringify({data:{}})});if(!r.ok)y("[OZmoz] Cloud error HTTP "+r.status);else{let n=await r.json(),i=n.result?.data||n.result||n.data;if(i&&i.protocol&&i.directives)return u("[OZmoz] Instructions loaded successfully."),s.existsSync(a.dirname(e))||s.mkdirSync(a.dirname(e),{recursive:!0}),s.writeFileSync(e,JSON.stringify(i,null,2),"utf8"),i;y("[OZmoz] Empty Cloud response.")}}catch(r){y("[OZmoz] Network error: "+r.message)}if(s.existsSync(e)){u("[OZmoz] Using local cache (~/.fleetbo/guidelines.json)");try{return JSON.parse(s.readFileSync(e,"utf8"))}catch{}}return{protocol:"",directives:"",version:"1.0.0"}}function J(e,t){return"<!-- ozmoz:start v"+e+` -->
|
|
3
3
|
`+t.trim()+`
|
|
4
4
|
`+he+`
|
|
5
|
-
`}function ve(e,t,r){let n=
|
|
5
|
+
`}function ve(e,t,r){let n=s.existsSync(e)?s.readFileSync(e,"utf8"):null,i,o;return n===null?(i="created",o=t):G.test(n)?(o=n.replace(G,()=>t.trimEnd()),i=o===n?"unchanged":"updated"):n.includes(H)?(i="migrated",o=t):(i="appended",o=n.replace(/\s*$/,`
|
|
6
6
|
|
|
7
|
-
`)+t),!r&&
|
|
8
|
-
`,"utf8")),o?"updated":"created")}function
|
|
9
|
-
`):[],f=
|
|
10
|
-
`).slice(-2).join(" "),legacy:
|
|
7
|
+
`)+t),!r&&i!=="unchanged"&&(i==="migrated"&&s.writeFileSync(e+".ozmoz-legacy.bak",n,"utf8"),s.mkdirSync(a.dirname(e),{recursive:!0}),s.writeFileSync(e,o,"utf8")),i}function ee(){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(t=>s.existsSync(t))||a.resolve(__dirname,"ozmoz-mcp.js")}function Z(e,t,r){let n=Object.assign({command:process.execPath,args:[__filename,"mcp","--run"]},r||{}),i={};if(s.existsSync(e))try{let l=JSON.parse(s.readFileSync(e,"utf8"));if(!l||typeof l!="object"||Array.isArray(l))return"invalid";i=l}catch{return"invalid"}let o=i.mcpServers&&i.mcpServers[x];return o&&JSON.stringify(o)===JSON.stringify(n)?"unchanged":(i.mcpServers=i.mcpServers||{},i.mcpServers[x]=n,t||(s.mkdirSync(a.dirname(e),{recursive:!0}),s.writeFileSync(e,JSON.stringify(i,null,2)+`
|
|
8
|
+
`,"utf8")),o?"updated":"created")}function R(e){let t=process.platform==="win32"?"where":"which";return _(t,[e],{stdio:"ignore"}).status===0}function $(e,t,r){let n=_(e,t,{encoding:"utf8",timeout:r||3e4,shell:process.platform==="win32"});return{ok:n.status===0,out:(n.stdout||"")+(n.stderr||"")}}function Se(e,t,r){let n=e==="claude"?["--scope",r||"user"]:[],i=ee(),o=["mcp","add"].concat(n,[x,"--",process.execPath,i]),l=["mcp","remove",x].concat(n),c=e+" "+o.join(" ");if(!R(e))return{status:"manual",detail:c};if(t)return{status:"planned",detail:c};let h=$(e,["mcp","list"],6e4),m=h.ok?h.out.split(`
|
|
9
|
+
`):[],f=m.find(E=>/^[\s|│┃]*ozmoz(?![\w@-])/.test(E)),p=m.some(E=>/^\s*(?:fleetbo|ozmoz):\s/.test(E));if(f&&f.includes("ozmoz@latest"))return{status:"unchanged",legacy:p};if(f&&!$(e,l).ok)return{status:"manual",detail:e+" "+l.join(" ")+" && "+c,legacy:p};let g=$(e,o);return g.ok?{status:f?"updated":"created",legacy:p}:{status:"failed",detail:c,message:g.out.trim().split(`
|
|
10
|
+
`).slice(-2).join(" "),legacy:p}}function Ee(e){let t={user:!1,local:!1,others:[]};try{let r=JSON.parse(s.readFileSync(a.join(A.homedir(),".claude.json"),"utf8")),n=c=>!!c&&typeof c=="object"&&/ozmoz|ozmoz/.test(String(c.command||"")+" "+JSON.stringify(c.args||[])),i=(c,h)=>{!c||typeof c!="object"||Object.keys(c).forEach(m=>{m===x?t[h]=!0:n(c[m])&&t.others.push({name:m,where:h})})};i(r.mcpServers,"user");let o=e;try{o=s.realpathSync(e)}catch{}let l=r.projects||{};Array.from(new Set([e,o])).forEach(c=>i((l[c]||{}).mcpServers,"local"))}catch{}return t}function we(e){let t=Ee(e);t.user&&u(" \u26A0\uFE0F A global (user-scope) '"+x+"' entry from a previous version also exists: the tools appear in every project. To keep them in OZmoz projects only: claude mcp remove "+x+" --scope user"),t.local&&u(" \u26A0\uFE0F A local-scope '"+x+"' entry exists for this folder and takes precedence over .mcp.json. Remove it: claude mcp remove "+x+" --scope local"),t.others.forEach(r=>{u(" \u26A0\uFE0F An old MCP entry named '"+r.name+"' ("+r.where+" scope) points to OZmoz/OZmoz. Remove it: claude mcp remove "+r.name+" --scope "+r.where)})}function Te(e){let t=A.homedir(),r=n=>s.existsSync(n);return{claude:R("claude")||r(a.join(t,".claude")),cursor:r(a.join(e,".cursor"))||r(a.join(t,".cursor"))||R("cursor"),windsurf:r(a.join(t,".codeium","windsurf"))||r(a.join(e,".windsurf")),devin:r(a.join(e,".devin")),codex:R("codex")||r(a.join(t,".codex")),gemini:R("gemini")||r(a.join(t,".gemini")),antigravity:R("agy")||r(a.join(t,".antigravity"))||r(a.join(e,".antigravity")),copilot:R("copilot")||r(a.join(t,".copilot"))}}var be={claude:{bin:"claude",launch:e=>[e]},gemini:{bin:"gemini",launch:e=>["-i",e]},codex:{bin:"codex",launch:e=>[e]},antigravity:{bin:"agy",launch:e=>["-i",e]}};function Ae(e){return String(e||"").replace(/[^\p{L}\p{N} '.,:\-_]/gu," ").replace(/\s+/g," ").trim().slice(0,4e3)}function Ce(e,t,r){let n=Ae(t),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.",o=null,l=!0;try{let
|
|
14
|
-
`).forEach(
|
|
13
|
+
- Once the user answers, do NOT run exploratory bash commands. IMMEDIATELY call the MCP tool 'oz_create_project' with the application name.`:"Ask me the starter questions from your OZmoz instructions before installing anything: the technology first, then a one-sentence project description, one question at a time.",o=null,l=!0;try{let p=a.join(r,".env");if(s.existsSync(p)){let g=s.readFileSync(p,"utf8"),E=g.match(/^\s*OZ_DB_KEY\s*=\s*(.+?)\s*$/m);E&&(o=E[1].trim());let w=g.match(/^\s*OZ_PROTOTYPE\s*=\s*(.+?)\s*$/m);w&&(l=w[1].trim().toLowerCase()==="true")}}catch{}let c=s.existsSync(a.join(r,"svro.schema.json")),h=s.existsSync(a.join(r,"index.html"))||s.existsSync(a.join(r,"package.json")),m=l?"OZ_PROTOTYPE=true (mode essai / local sandbox)":"OZ_PROTOTYPE=false (mode r\xE9el / live database)",f=o||c?"This folder ALREADY contains an OZmoz project (OZ_DB_KEY="+o+", "+m+"). Do NOT call oz_create_project, and do NOT ask the starter questions. State this in one plain sentence to the user \u2014 then ask what I want to work on now.":h?'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 ("+r+`). Your OZmoz instructions are already loaded: they are in AGENTS.md / GEMINI.md at the project root and in the OZmoz MCP server (prompt "oz_contract_rules", tool "oz_get_contract"). Never try to read files inside an mcp/ folder or in the agent's own configuration folders, and do not run bash commands or web searches to look for them. If you do not have them in context, call the MCP tool "oz_get_contract" once before answering. `+f}function Ie(){let e=process.env;if(e.CLAUDECODE==="1"||e.GEMINI_CLI||e.CODEX_CLI||e.AI_AGENT||e.CURSOR_AGENT||e.ANTIGRAVITY_CLI)return!0;if(process.platform==="win32")return!1;try{let t=_("ps",["-A","-o","pid=,ppid=,args="],{encoding:"utf8"});if(t.status!==0)return!1;let r=new Map;t.stdout.split(`
|
|
14
|
+
`).forEach(i=>{let o=i.match(/^\s*(\d+)\s+(\d+)\s+(.*)$/);o&&r.set(Number(o[1]),{ppid:Number(o[2]),args:o[3]})});let n=process.ppid;for(let i=0;n>1&&i<20&&r.has(n);i++){let{ppid:o,args:l}=r.get(n);if(l.split(/\s+/).slice(0,2).some(h=>/(^|\/)(gemini|claude|codex|antigravity|agy)$/.test(h))||/@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 _(t,[e],{stdio:"ignore"}).status===0}function xe(e,t){let r=t.slice(1).filter(f=>!f.startsWith("--")),n=(r[0]||"").toLowerCase(),i=r.slice(1).join(" "),o=be[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(s.readFileSync(a.join(A.homedir(),".fleetbo","credentials.json"),"utf8")).devToken}catch{}l||(u("[OZmoz] First use on this machine: sign in (your browser opens, approve once)."),_(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))),_(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)),Ie()&&(u(`
|
|
15
15
|
[OZmoz] OZmoz is set up in this folder (instruction file + MCP server).
|
|
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 h=Ce(o.rules,
|
|
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 h=Ce(o.rules,i,e);u(`
|
|
17
17
|
[OZmoz] Launching `+o.bin+` in this folder...
|
|
18
|
-
`);let
|
|
19
|
-
[OZmoz] Configuring your AI agents`+(r?" (dry run: nothing is written)":"")+"...");let
|
|
18
|
+
`);let m=_(o.bin,o.launch(process.platform==="win32"?'"'+h+'"':h),{stdio:"inherit",cwd:e,shell:process.platform==="win32"});process.exit(m.status===null?1:m.status)}async function te(e,t){let r=t.includes("--dry-run"),n=t.find(d=>d.startsWith("--agent=")),i=n&&n.slice(8).trim()?n.slice(8).split(",").map(d=>d.trim().toLowerCase()).filter(Boolean):null,o=null;if(i){o=i.includes("all")?Object.keys(M):i;let d=o.filter(z=>!M[z]);d.length&&(y("Unknown agent(s): "+d.join(", ")+". Valid values: "+Object.keys(M).join(", ")+", all."),process.exit(1))}let l=t.find(d=>d.startsWith("--scope=")),c=l?l.slice(8).trim().toLowerCase():"project";["project","user","local"].includes(c)||(y("Unknown scope: "+c+". Valid values for Claude Code: project (default), user, local."),process.exit(1));let h=Te(e),m=o||Object.keys(M).filter(d=>h[d]),f=ge();u(`
|
|
19
|
+
[OZmoz] Configuring your AI agents`+(r?" (dry run: nothing is written)":"")+"...");let p=await Q(),g=p.version||f,E=`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
|
|
20
20
|
|
|
21
|
-
`+(
|
|
21
|
+
`+(p.directives||p.guidelines||"")+`
|
|
22
22
|
|
|
23
23
|
## PROTOCOLE DONN\xC9ES : QUI FAIT QUOI (AGENT FRONTEND \u2194 ALEX AI)
|
|
24
24
|
|
|
25
|
-
`+(
|
|
26
|
-
@AGENTS.md`)]],
|
|
25
|
+
`+(p.protocol||""),w=J(g,E),b=[["AGENTS.md",w],["GEMINI.md",w],["CLAUDE.md",J(g,`# OZMOZ DATA OS \u2014 DIRECTIVES AGENT
|
|
26
|
+
@AGENTS.md`)]],v=a.join(e,".cursorrules");if(s.existsSync(v)){let d=s.readFileSync(v,"utf8");(G.test(d)||d.includes(H))&&b.push([".cursorrules",w])}for(let d of b)u("\u2192 "+d[0]+": "+D[ve(a.join(e,d[0]),d[1],r)]);for(let d of m){let z=M[d];if(d==="cursor")u("\u2192 "+z+" MCP (.cursor/mcp.json): "+D[Z(a.join(e,".cursor","mcp.json"),r)]);else if(d==="windsurf")u("\u2192 "+z+" MCP (~/.codeium/windsurf/mcp_config.json): "+D[Z(a.join(A.homedir(),".codeium","windsurf","mcp_config.json"),r)]);else if(d==="copilot")u("\u2192 "+z+" MCP (~/.copilot/mcp-config.json): "+D[Z(a.join(A.homedir(),".copilot","mcp-config.json"),r,{type:"local",tools:["*"]})]);else if(d==="claude"&&c==="project"){let S=Z(a.join(e,".mcp.json"),r);u("\u2192 "+z+" MCP (.mcp.json, project scope): "+D[S]),(S==="created"||S==="updated")&&u(" Claude Code asks you to approve a project server the first time you launch it. Commit .mcp.json to share it with your team (it contains no token)."),we(e)}else if(d==="gemini"){let S=[a.join(A.homedir(),".gemini","settings.json"),a.join(e,".gemini","settings.json"),a.join(e,".mcp.json")],T="unchanged";S.forEach(F=>{let P=Z(F,r);(P==="created"||P==="updated")&&(T=P)}),u("\u2192 "+z+" MCP (settings.json & .mcp.json): "+D[T])}else if(d==="claude"||d==="codex"||d==="antigravity"){let S=d==="antigravity"?"agy":d,T=Se(S,r,c);T.status==="manual"?u("\u2192 "+z+": '"+S+"' not found or not scriptable. Run manually: "+T.detail):T.status==="planned"?u("\u2192 "+z+" MCP: would run: "+T.detail):T.status==="failed"?y("\u2192 "+z+" MCP: registration failed ("+T.message+"). Run manually: "+T.detail):u("\u2192 "+z+" MCP"+(d==="claude"?" ("+c+" scope)":"")+": "+D[T.status]),T.legacy&&u(" \u26A0\uFE0F An old MCP entry named 'fleetbo' exists. Remove it: "+S+" mcp remove fleetbo")}else d==="devin"&&u("\u2192 "+z+": reads AGENTS.md. Devin runs in its own environment: add the OZmoz MCP server from Devin's settings (not automated).")}!o&&m.length===0&&u("\u2192 No agent detected: instruction files were written; re-run with --agent=<name> to register the MCP server.");let I=!!(B(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN),O=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(O))try{I=I||!!JSON.parse(s.readFileSync(O,"utf8")).devToken}catch{}I||y('\u26A0\uFE0F No developer token found. Run "npx ozmoz login" once.'),process.env.FLEETBO_START||u(`
|
|
27
27
|
[OZmoz] Done.
|
|
28
|
-
`)}function
|
|
28
|
+
`)}function _e(e){let t=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";re(`${t} "${e}"`)}function Ne(e){return new Promise((t,r)=>{let n=oe.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 c=l.searchParams.get("token"),h=l.searchParams.get("refresh");if(!c){o.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),o.end("<h3>Error: Missing token.</h3>");return}let m=a.join(A.homedir(),".fleetbo");s.existsSync(m)||s.mkdirSync(m,{recursive:!0}),s.writeFileSync(a.join(m,"credentials.json"),JSON.stringify({devToken:c,refreshToken:h||null,updatedAt:new Date().toISOString()},null,2));let f=a.join(e,".env");if(s.existsSync(f)){let p=s.readFileSync(f,"utf8");p.includes("FLEETBO_DEV_TOKEN=")?p=p.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${c}`):p+=`
|
|
29
29
|
FLEETBO_DEV_TOKEN=${c}
|
|
30
|
-
`,
|
|
30
|
+
`,s.writeFileSync(f,p,"utf8")}o.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),o.end(`
|
|
31
31
|
<!DOCTYPE html>
|
|
32
32
|
<html>
|
|
33
33
|
<head>
|
|
@@ -45,28 +45,28 @@ FLEETBO_DEV_TOKEN=${c}
|
|
|
45
45
|
</div>
|
|
46
46
|
</body>
|
|
47
47
|
</html>
|
|
48
|
-
`),
|
|
49
|
-
[OZmoz] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(
|
|
50
|
-
Next step to connect your AI agents:`),
|
|
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}`;
|
|
52
|
-
[OZmoz] Waiting for authentication...`),
|
|
53
|
-
`).forEach(
|
|
48
|
+
`),u(`
|
|
49
|
+
[OZmoz] Developer token received and stored successfully!`),!process.env.FLEETBO_START&&!["AGENTS.md","CLAUDE.md","GEMINI.md"].some(p=>s.existsSync(a.join(e,p)))&&(u(`
|
|
50
|
+
Next step to connect your AI agents:`),u(` 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}`;u(`
|
|
52
|
+
[OZmoz] Waiting for authentication...`),u(`If your browser does not open automatically, visit: ${o}`),_e(o);let l=Number(process.env.FLEETBO_LOGIN_TIMEOUT_MS)||12e4;setTimeout(()=>{try{typeof n.closeAllConnections=="function"&&n.closeAllConnections()}catch{}n.close(),r(new Error(`Login timed out after ${Math.round(l/1e3)}s: browser approval not received. Run "npx ozmoz login" once more and approve in the browser.`))},l).unref()}),n.on("error",i=>r(i))})}async function Pe(e,t,r){let n=await X();return new Promise((i,o)=>{let l=JSON.stringify({enterpriseID:e,schema:t,workflow:r}),c={hostname:"api.ozmoz.io",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(l),...n?{Authorization:`Bearer ${n}`}:{}}},h=W.request(c,m=>{let f="";m.on("data",p=>{f+=p}),m.on("end",()=>{m.statusCode>=200&&m.statusCode<300?i(JSON.parse(f)):m.statusCode===401||m.statusCode===403?o(new Error('Please sign in first: run "npx ozmoz login".')):o(new Error(`Edge sync failed with HTTP ${m.statusCode}`))})});h.on("error",m=>o(m)),h.write(l),h.end()})}function B(e){let t=a.join(e,".env");if(!s.existsSync(t))return{};let r=s.readFileSync(t,"utf8"),n={};return r.split(`
|
|
53
|
+
`).forEach(i=>{let[o,...l]=i.split("=");o&&l.length>0&&(n[o.trim()]=l.join("=").trim())}),n}function V(e,t){return new Promise((r,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,c=>{let h="";c.on("data",m=>{h+=m}),c.on("end",()=>{if(c.statusCode>=200&&c.statusCode<300)try{let m=JSON.parse(h);if(m.success&&m.found&&m.module){let f=m.module.code||m.module.mockCode;r(typeof f=="string"?JSON.parse(f):f)}else r(null)}catch{n(new Error(`Invalid JSON response for ${t}.`))}else n(new Error(`Server error ${c.statusCode} while fetching ${t}`))})});l.on("error",c=>n(c)),l.write(i),l.end()})}var C=process.argv.slice(2),k=C[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 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 De(e){let t=[];if(!e||typeof e!="object"||!e.collections)return{schema:e,changed:!1,notes:t};let r=JSON.parse(JSON.stringify(e));return Object.entries(r.collections).forEach(([n,i])=>{let o=U(i);o&&Object.keys(o).forEach(l=>{ne(l)&&o[l]&&typeof o[l]=="object"&&o[l].required===!0&&(o[l].required=!1,t.push(n+"."+l))})}),{schema:r,changed:t.length>0,notes:t}}function Re(e){let t=String(typeof e=="string"?e:e&&e.type||"").toLowerCase(),r=e&&(e.enum||e.values||e.options);return Array.isArray(r)&&r.length?JSON.stringify(r[0]):t==="number"||t==="integer"||t==="float"?"0":t==="boolean"||t==="toggle"?"false":t==="date"||t==="datetime"||t==="timestamp"?"new Date().toISOString()":t==="reference"?"'<id du document li\xE9>'":t==="media"?"null /* image/fichier : oz.addWithMedia */":t==="array"?"[]":"'\u2026'"}function Fe(e){let r=Object.entries(e&&e.collections||{}),n=`## \u{1F4E5} CE QUE LE CODE DOIT ENVOYER (MOD\xC8LES D'\xC9CRITURE)
|
|
54
54
|
|
|
55
55
|
`;n+=`### \u{1F194} Identifiants
|
|
56
|
-
`,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
|
|
57
|
-
`:(
|
|
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=r.filter(([,o])=>U(o)&&Object.keys(U(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 c=U(l),h=Object.entries(c).filter(([p])=>!ne(p));n+="### `"+o+`\`
|
|
58
58
|
|
|
59
59
|
| Champ | Type | Obligatoire | Valeurs / remarques |
|
|
60
60
|
|---|---|---|---|
|
|
61
|
-
`,h.forEach(([
|
|
62
|
-
`});let
|
|
63
|
-
`,
|
|
64
|
-
`}),f.length&&(n+=" // optionnels : "+f.map(([
|
|
61
|
+
`,h.forEach(([p,g])=>{let E=typeof g=="string"?g:g&&g.type||"any",w=g&&(g.enum||g.values||g.options),b=Array.isArray(w)&&w.length?"parmi : "+w.map(v=>"`"+v+"`").join(", "):"";n+="| `"+p+"` | "+E+" | "+(g&&g.required===!0?"\u2705 oui":"non")+" | "+b+` |
|
|
62
|
+
`});let m=h.filter(([,p])=>p&&p.required===!0),f=h.filter(([,p])=>!(p&&p.required===!0));n+="\nInsertion valide :\n```js\nawait oz.add('"+o+`', {
|
|
63
|
+
`,m.forEach(([p,g])=>{n+=" "+p+": "+Re(g)+`,
|
|
64
|
+
`}),f.length&&(n+=" // optionnels : "+f.map(([p])=>p).join(", ")+`
|
|
65
65
|
`),n+=`}, {
|
|
66
66
|
`,n+=" desc: 'Cr\xE9ation d\\'un \xE9l\xE9ment dans "+o+`',
|
|
67
67
|
`,n+=` role: 'AUTHENTICATED' // ou 'ANONYMOUS', 'ADMIN'
|
|
68
68
|
`,n+=` // guard: 'condition sur les donn\xE9es' (optionnel)
|
|
69
|
-
`,n+="});\n```\n\n"}),n)}function
|
|
69
|
+
`,n+="});\n```\n\n"}),n)}function Le(e,t,r=""){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\`.
|
|
@@ -611,7 +611,7 @@ ${e?.context||t?.context||"No written specifications provided."}
|
|
|
611
611
|
|
|
612
612
|
---
|
|
613
613
|
|
|
614
|
-
${
|
|
614
|
+
${Fe(e)}
|
|
615
615
|
|
|
616
616
|
---
|
|
617
617
|
|
|
@@ -626,29 +626,31 @@ ${JSON.stringify({...e||{},context:void 0},null,2)}
|
|
|
626
626
|
\`\`\`json
|
|
627
627
|
${JSON.stringify(t||{},null,2)}
|
|
628
628
|
\`\`\`
|
|
629
|
-
`}function Me(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function Ze(e,t){let r=
|
|
630
|
-
[OZmoz] Project "${
|
|
631
|
-
`)}finally{if(
|
|
629
|
+
`}function Me(e){return String(e).toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]/g,"_").replace(/^_+|_+$/g,"").slice(0,30)||"app"}async function Ze(e,t){let r=B(e),n=s.existsSync(a.join(e,"svro.schema.json"));(r.OZ_DB_KEY||n)&&(y("Cannot create project: an OZmoz project already exists in this folder."),u('\u2192 Use "npx ozmoz sync" or evolve the existing contract instead.'),process.exit(1));let i=(t||"").trim();i||(y('Project name is required. Usage: npx ozmoz create "<name>"'),process.exit(1));let o=a.join(e,".ozmoz.lock");if(s.existsSync(o)){let c=!1;try{let h=Number(s.readFileSync(o,"utf8"));Date.now()-h>6e4&&(c=!0)}catch{c=!0}c||(y("A project creation is already running in this folder."),process.exit(1)),s.unlinkSync(o)}s.writeFileSync(o,String(Date.now()));let l=()=>{if(s.existsSync(o))try{s.unlinkSync(o)}catch{}};try{let c=process.env.FLEETBO_DEV_TOKEN;if(!c){let w=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(w))try{c=JSON.parse(s.readFileSync(w,"utf8")).devToken}catch{}}c||(l(),y('Missing developer token. Please run "npx ozmoz login" first.'),process.exit(1)),u(`[OZmoz] Creating project "${i}" on Cloud...`);let h=Me(i),m=[h,`${h.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`,`${h.slice(0,24)}_${Math.random().toString(36).slice(2,6)}`],f=null,p=null;for(let w of m)try{let b=await fetch("https://createprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${c}`},body:JSON.stringify({data:{name:i,keyApp:w}})}),v=await b.json();if(b.ok&&!v.error){f={keyApp:w,data:v.result?.data||v.data||{}};break}else p=v.error?.message||`HTTP ${b.status}`}catch(b){p=b.message}f||(l(),y(`Failed to create project on Cloud: ${p||"Unknown error"}`),process.exit(1));let g=f.data.bootstrapToken;await K(e,[`--keyApp=${f.keyApp}`,`--token=${g}`]);let E=a.join(e,"package.json");Y(e,E),await te(e,[]),u(`
|
|
630
|
+
[OZmoz] Project "${i}" (${f.keyApp}) created and configured successfully.`),u(`AI AGENTS: do NOT stop here and do NOT ask the user to restart. Continue NOW in the same turn: scaffold the frontend if missing, run "npx ozmoz sync", read ozmoz_contract.md, write ALL views in trial mode (OZ_PROTOTYPE=true), then start the dev server and ask the user to validate.
|
|
631
|
+
`)}finally{if(s.existsSync(o))try{s.unlinkSync(o)}catch{}}}async function Ue(e){let t=process.env.FLEETBO_DEV_TOKEN;if(!t){let O=a.join(A.homedir(),".fleetbo","credentials.json");if(s.existsSync(O))try{t=JSON.parse(s.readFileSync(O,"utf8")).devToken}catch{}}let n=B(e).OZ_KEY_APP;(!n||!t)&&(y("Cannot update: project uninitialized or dev token missing."),process.exit(1));let i=s.existsSync(a.join(e,"src"))?a.join(e,"src"):e,o=new Set([".jsx",".tsx",".vue",".svelte",".js",".ts",".html"]),l=[],c=0;function h(O){let d=[];try{d=s.readdirSync(O,{withFileTypes:!0})}catch{return}for(let z of d){if(/^(node_modules|\.git|dist|build|\.next|\.svelte-kit)$/.test(z.name))continue;let S=a.join(O,z.name);if(z.isDirectory())h(S);else if(o.has(a.extname(z.name))&&!z.name.endsWith(".d.ts"))try{let T=s.statSync(S);if(T.size>3e5)continue;let F=s.readFileSync(S,"utf8");/oz\.|<oz-/i.test(F)&&(c+=T.size,l.push({name:a.relative(e,S).split(a.sep).join("/"),content:F}))}catch{}}}h(i);let m=C.find(O=>O.startsWith("--files=")),f=m?m.slice(8).split(",").map(O=>O.trim()).filter(Boolean):null;if(f&&f.length>0)for(let O of f){let d=a.resolve(e,O);if(s.existsSync(d)){let z=s.readFileSync(d,"utf8");c+=s.statSync(d).size,l.push({name:a.relative(e,d).split(a.sep).join("/"),content:z})}}else h(i);l.length===0&&(y("Cannot update: no components using oz.* found."),process.exit(1)),c>8*1024*1024&&(y("Payload too large: total UI source files exceed 8 MB limit."),process.exit(1));let p=C.find(O=>O.startsWith("--rules=")),g=p?p.slice(8).trim():"",E=C.find(O=>O.startsWith("--reasoning=")),w=E?E.slice(12).trim().toLowerCase():void 0;w!=="standard"&&w!=="high"&&(y("Missing or invalid --reasoning=<standard|high>."),y("If you are an AI agent: ask the user which analysis depth they want (numbered [1]/[2] choice, recommended option first) before running this command, then pass --reasoning=standard or --reasoning=high accordingly. Never pick it yourself."),process.exit(1)),u(`[OZmoz] Sending ${l.length} component(s) to Cloud Engine for modeling...`);try{let O,d,z;for(let S=1;S<=3&&(O=await fetch("https://updateprojectlight-jqycakhlxa-uc.a.run.app",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t}`},body:JSON.stringify({data:{keyApp:n,name:n,newViewFiles:l,oz_rules:g,reasoning:w}})}),d=await O.json().catch(()=>({})),z=d.result?.data||d.data||d,!(O.status<500||S===3));S++)u("\u2192 The modeling service is busy (attempt "+S+"/3). Retrying in 20s..."),await new Promise(T=>setTimeout(T,2e4));if(!O.ok||d.error||z.success===!1){let S=d.error?.message||z.warnings?.join(", ")||d.message||"Server error";y(`Update failed: ${S}`),process.exit(1)}u("\u2192 Cloud modeling response: "+JSON.stringify(d).slice(0,800))}catch(O){y(`Network error: ${O.message}`),process.exit(1)}u("\u2192 Structure modeled. Sealing into OZmoz SVRO Kernel...");let b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e}),v=Date.now();for(let O=1;O<=5&&b.status===0;O++){let d=!1;try{let z=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8")),S=JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8"));d=Object.keys(z.collections||{}).length>0&&(S.sequences||[]).length>0}catch{}if(d)break;u("\u2192 Contract still empty, waiting for the cloud (attempt "+O+"/5, "+Math.round((Date.now()-v)/1e3)+"s elapsed)..."),await new Promise(z=>setTimeout(z,6e3)),b=_(process.execPath,[__filename,"sync"],{stdio:"inherit",cwd:e})}let N=!1,I=!1;try{let O=JSON.parse(s.readFileSync(a.join(e,"svro.schema.json"),"utf8"));N=Object.keys(O.collections||{}).length>0,I=(JSON.parse(s.readFileSync(a.join(e,"svro.workflow.json"),"utf8")).sequences||[]).length>0}catch{}b.status===0&&N&&I?u(`
|
|
632
632
|
[OZmoz] Contract locked into SVRO Kernel.
|
|
633
|
-
`):
|
|
633
|
+
`):b.status===0&&N&&!I?(y(`
|
|
634
|
+
[OZmoz] Contract incomplete: the workflow is empty. Rerun the update before writing any code.
|
|
635
|
+
`),process.exit(1)):b.status===0&&!N?(y(`
|
|
634
636
|
[OZmoz] Sync completed with 0 collections. Rerun with --reasoning=high.
|
|
635
637
|
`),process.exit(1)):(y(`
|
|
636
638
|
[OZmoz] Sync failed. Run "npx ozmoz sync".
|
|
637
|
-
`),process.exit(1))}async function Be(){let e=process.cwd(),t=a.join(e,"package.json");if(k==="init"||k==="doctor")
|
|
638
|
-
[OZmoz] Initializing and configuring OZmoz...`),await K(e,
|
|
639
|
+
`),process.exit(1))}async function Be(){let e=process.cwd(),t=a.join(e,"package.json");if(k==="init"||k==="doctor")u(`
|
|
640
|
+
[OZmoz] Initializing and configuring OZmoz...`),await K(e,C),Y(e,t),u(`
|
|
639
641
|
[OZmoz] Configuration completed successfully!
|
|
640
|
-
`),
|
|
641
|
-
Next step:`),
|
|
642
|
-
`);else if(k==="sync"){let r=
|
|
643
|
-
`),
|
|
644
|
-
`),
|
|
645
|
-
`,"utf8"),
|
|
646
|
-
`,"utf8"),
|
|
647
|
-
`,"utf8"),
|
|
642
|
+
`),u(`
|
|
643
|
+
Next step:`),u(` npx ozmoz sync (Sync cloud schema & generate IDE types)
|
|
644
|
+
`);else if(k==="sync"){let r=C.includes("--dry-run"),n=C.includes("--check-only");u(`[OZmoz] Syncing schema...${r?" (dry-run)":""}${n?" (check-only, no network)":""}`),r||de(e);let i=a.join(e,"svro.schema.json"),o=a.join(e,"svro.workflow.json"),l=a.join(e,"ozmoz_contract.md"),c=a.join(e,"src","ozmoz.d.ts"),m=B(e).OZ_ENTERPRISE_ID,f=null,p=null;if(n)u("\u2192 Mode check-only : Local contract used, no cloud fetch..");else if(m)try{u("\u2192 Fetching latest contracts from Cloud..."),f=await V(m,"svro.schema.json"),f&&(s.writeFileSync(i,JSON.stringify(f,null,2)+`
|
|
645
|
+
`),u("\u2192 Local svro.schema.json updated.")),p=await V(m,"svro.workflow.json"),p&&(s.writeFileSync(o,JSON.stringify(p,null,2)+`
|
|
646
|
+
`),u("\u2192 Local svro.workflow.json updated."))}catch(v){y(`\u26A0\uFE0F Cloud fetch bypassed: ${v.message}. Using local file fallback.`)}else y("\u26A0\uFE0F OZ_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let g=f;if(!g&&s.existsSync(i))try{g=JSON.parse(s.readFileSync(i,"utf8"))}catch{}g||(g={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},s.writeFileSync(i,JSON.stringify(g,null,2)+`
|
|
647
|
+
`,"utf8"),u("\u2192 Initial blank svro.schema.json created."));let E=p;if(!E&&s.existsSync(o))try{E=JSON.parse(s.readFileSync(o,"utf8"))}catch{}E||(E={actors:{},sequences:[]},s.writeFileSync(o,JSON.stringify(E,null,2)+`
|
|
648
|
+
`,"utf8"),u("\u2192 Initial blank svro.workflow.json created."));{let v=De(g);v.changed&&(g=v.schema,s.writeFileSync(i,JSON.stringify(g,null,2)+`
|
|
649
|
+
`,"utf8"),u("\u2192 Managed by system, no longer required from your code: "+v.notes.join(", ")+"."))}let{protocol:w}=await Q(),b=Le(g,E,w);s.writeFileSync(l,b,"utf8"),u("\u2192 Contract markdown successfully generated at project root.");try{let v=Object.keys(g.collections||{});if(m&&!n&&Object.keys(g.collections||{}).length>0)try{await Pe(m,g,E),u("\u2192 Schema successfully sealed into SVRO Kernel (O(1)).")}catch(d){y(`\u26A0\uFE0F Kernel Shield sync warning: ${d.message}`)}let N=g.collections||{},I=Object.entries(N).map(([d,z])=>{let S=z.fields||z.schema||{},T=Object.entries(S).map(([F,P])=>{let L="any",j=String(typeof P=="string"?P:P.type||"").toLowerCase();return j==="string"||j==="text"||j==="media"?L="string":j==="number"?L="number":j==="boolean"||j==="toggle"?L="boolean":j==="array"&&(L="any[]"),` ${F}?:${L};`}).join(`
|
|
648
650
|
`);return` ${d}: {
|
|
649
|
-
${
|
|
651
|
+
${T}
|
|
650
652
|
};`}).join(`
|
|
651
|
-
`),
|
|
653
|
+
`),O=v.length>0?v.map(d=>`'${d}'`).join(" | "):"string";if(s.existsSync(a.dirname(c))){let d=`/* eslint-disable */
|
|
652
654
|
/* prettier-ignore */
|
|
653
655
|
// @ts-nocheck
|
|
654
656
|
// Generated by OZmoz \u2014 Updated via sync
|
|
@@ -677,7 +679,7 @@ type OzProp = {
|
|
|
677
679
|
};
|
|
678
680
|
|
|
679
681
|
interface OzSchemaMap {
|
|
680
|
-
${
|
|
682
|
+
${I}
|
|
681
683
|
}
|
|
682
684
|
|
|
683
685
|
declare global {
|
|
@@ -693,7 +695,7 @@ declare global {
|
|
|
693
695
|
interface ImportMeta {
|
|
694
696
|
readonly env: ImportMetaEnv;
|
|
695
697
|
}
|
|
696
|
-
type KnownOzTables = ${
|
|
698
|
+
type KnownOzTables = ${O};
|
|
697
699
|
type OzTables = KnownOzTables | (string & { _ozPending?: never });
|
|
698
700
|
type OzData<T extends string> = T extends KnownOzTables
|
|
699
701
|
? Partial<OzSchemaMap[T]>
|
|
@@ -796,7 +798,7 @@ declare module 'svelte/elements' {
|
|
|
796
798
|
'oz-reference': OzProp;
|
|
797
799
|
}
|
|
798
800
|
}
|
|
799
|
-
`;
|
|
801
|
+
`;s.writeFileSync(c,d)}ae(e),ce(e,t),le(e),ue(e),u(` [OZmoz] Schema synced successfully (${v.length} collection(s)).`),r&&u("\u2192 [Dry-run] Schema is valid.")}catch(v){y(`Error during synchronization: ${v.message}`),process.exit(1)}}else if(k==="create"){let r=C.slice(1).filter(n=>!n.startsWith("--")).join(" ");await Ze(e,r),process.exit(0)}else if(k==="update")await Ue(e),process.exit(0);else if(k==="mcp"){let r=C.includes("--run"),n=!1;if(!r&&!process.stdin.isTTY&&(r=await new Promise(i=>{let o=process.stdin,l=null,c=f=>{clearTimeout(l),o.removeListener("data",h),o.removeListener("end",m),o.removeListener("error",m),i(f)},h=f=>{o.pause(),o.unshift(f),n=!0,c(!0)},m=()=>c(!1);l=setTimeout(()=>{o.pause(),c(!1)},1500),o.on("data",h),o.once("end",m),o.once("error",m)})),r){try{await import(`file://${ee()}`),n&&process.stdin.resume()}catch(i){y(`Failed to start MCP server: ${i.message}`),process.exit(1)}return}await te(e,C),process.exit(0)}else k==="login"?(await Ne(e),process.exit(0)):k==="start"?xe(e,C):["--help","-h","help"].includes(k)?(u(`OZmoz CLI
|
|
800
802
|
|
|
801
803
|
Commands:
|
|
802
804
|
login Authenticate this machine (opens the browser: approve once, the command exits by itself)
|
package/dist/ozmoz-mcp.js
CHANGED
|
@@ -79,7 +79,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
79
79
|
|
|
80
80
|
Wait for their reply (Enter/'ok' for the recommended one, '2' or the other mode's name for the alternate).`,u=String(t||n||"").trim();if(!u)throw new Error("STOP: 'modeReply' is required and was not provided. "+c+" Then call this tool again with the exact same arguments, plus 'modeReply' set to the user's literal reply.");let l=u.toLowerCase();if(l.includes("standard"))return"standard";if(l.includes("high"))return"high";if(/^(|ok|okay|d'accord|oui|yes|go|vas-?y|allez|sure|1|\[1\])$/i.test(l)||l===r)return r;if(l==="2"||l==="[2]"||l===o)return o;throw new Error("STOP: 'modeReply' is missing or could not be mapped to a mode. "+c+" Then call this tool again with the exact same arguments, plus 'modeReply' set to their literal reply. Never write 'modeReply' yourself without an actual user reply.")}async function nC(e){let t=`1. If needed, scaffold the frontend (do not overwrite existing files), then run commandInit.
|
|
81
81
|
2. Read 'ozmoz_contract.md', then IMMEDIATELY write the UI views in the same turn \u2014 do NOT stop or summarize progress before every view is written.
|
|
82
|
-
3. Once every view is written, start the dev server and ask the user to validate before calling 'oz_update_project'.`;try{let n=await fetch(`https://getagentdirectives-${Fh}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({data:{}})});if(!n.ok)return t;let i=await n.json(),r=i.result?.data||i.result||i.data;return typeof r?.createProjectNextSteps=="string"&&r.createProjectNextSteps.trim()?r.createProjectNextSteps:t}catch{return t}}var Bo=new Yc({name:"ozmoz-mcp",version:"1.0.0"},{capabilities:{tools:{},prompts:{}}});Bo.setRequestHandler(Ep,async()=>({prompts:[{name:"oz_contract_rules",description:"Loads strict architectural rules, invariants, and integrity directives for OZmoz SVRO."}]}));Bo.setRequestHandler(Zp,async e=>{if(e.params.name==="oz_contract_rules")return{description:"Official OZmoz SVRO architecture directives",messages:[{role:"user",content:{type:"text",text:mS}}]};throw new Error(`Unknown prompt: ${e.params.name}`)});Bo.setRequestHandler(Up,async()=>({tools:[{name:"oz_create_project",description:"Creates a NEW OZmoz Cloud project. Call this ONLY when starting a brand new application from scratch. DO NOT call it if the project is already initialized (OZ_DB_KEY present in .env, or svro.schema.json exists): use 'oz_update_project' instead. This tool is already authenticated and returns the exact next command to run: no shell command or filesystem search is needed before calling it, including this tool's own JSON definition file (e.g. under ~/.gemini/.../mcp/ozmoz/oz_create_project.json) \u2014 you already have this schema in context via the tool list. Only if it returns a missing-token error: run 'npx ozmoz login' once, wait for it to finish, then call this tool again.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Nom de l'application"},keyApp:{type:"string",description:"Slug unique (optionnel, auto-d\xE9duit si omis)"}},required:["name"]}},{name:"oz_update_project",description:"HARD STOP: call this tool ONLY after the user has explicitly approved the screens in a message that arrived AFTER you gave them the dev-server address (first sealing), or when they ask for a data change (later). NEVER in the same turn as writing UI code or asking for their approval: if they have not answered yet, ask and STOP. 'userApproval' must be their exact words. Models / updates the project's data contract (svro.schema.json + svro.workflow.json) from UI component files and business rules, additively. This is the ONLY way to evolve the contract: there is no shell command for it. Pass 'filePaths' (e.g. ['src/components/DeskList.jsx']); 'keyApp' is optional (read from .env). Do NOT read this tool's own JSON definition file from disk (e.g. under ~/.gemini/.../mcp/ozmoz/oz_update_project.json) before calling it \u2014 you already have this schema in context via the tool list; re-reading it wastes time and tokens for no new information. Before calling this tool, ask the user (like the framework question) which analysis depth they want for this modeling pass: briefly explain what this step does and what each mode costs, THEN show only the two options as a bare list (recommended option first) \u2014 and pass their LITERAL reply as 'modeReply' from your very first call. If you forget and call without it, the tool may fail and tell you to ask; that is a fallback, not the normal path. Afterwards run 'npx ozmoz sync' once.",inputSchema:{type:"object",properties:{keyApp:{type:"string",description:"Unique application key (e.g. coworking_prod). Optional: if omitted, it is read from OZ_KEY_APP in the project's .env."},name:{type:"string",description:"Application name"},userApproval:{type:"string",description:"The user's EXACT words authorizing this call: their approval of the screens, or their request to change the data. Never write it yourself."},rules:{type:"string",description:"New business rules, calculations, or state transitions."},reasoning:{type:"string",enum:["standard","high"],description:"DEPRECATED \u2014 ignored. Omit this."},modeReply:{type:"string",description:"MANDATORY \u2014 never omit it, never invent it. Before calling this tool, show the user a numbered [1]/[2] choice for the analysis depth (recommended option first, like you do for the framework question), wait for their reply, then pass their LITERAL reply here (empty/'ok'/'oui' for [1], '2' for [2])."},filePaths:{type:"array",items:{type:"string"},description:"Relative paths of ALL files that call oz.* or define data fields."},viewFiles:{type:"array",items:{type:"object",properties:{name:{type:"string"},content:{type:"string"}},required:["name","content"]},description:"View files already loaded in memory [{ name, content }]."}},required:["name","userApproval","modeReply"]}},{name:"oz_publish_function",description:"Deploys a private or public cloud utility function executed in a secure serverless environment.",inputSchema:{type:"object",properties:{enterpriseID:{type:"string",description:"Project enterpriseID infrastructure identifier"},functionName:{type:"string",description:"Function name (alphanumeric 3-40 chars, e.g. calculateTotal)"},code:{type:"string",description:"JS source code (e.g. async function calculateTotal(payload, oz) { ... })"},description:{type:"string",description:"Action documentation for the catalog and Alex AI"},isPublic:{type:"boolean",description:"true to publish to the global Marketplace, false for private function"}},required:["enterpriseID","functionName","code"]}},{name:"oz_get_contract",description:"Provides the official data contract, SDK directives, production lifecycle and canonical blueprint.",inputSchema:{type:"object",properties:{}}}]}));Bo.setRequestHandler(ao,async e=>{let{name:t,arguments:n}=e.params;if(t==="oz_get_contract")return{content:[{type:"text",text:mS}]};let i=await YR();if(!i)return{isError:!0,content:[{type:"text",text:"Error: FLEETBO_DEV_TOKEN missing. Run 'npx ozmoz login' ONCE, wait for it to finish (the developer approves in the browser), then call this tool again \u2014 no restart needed."}]};try{if(t==="oz_create_project"){let o=ot.object({name:ot.string().min(2),keyApp:ot.string().optional()}).parse(n),{keyApp:a,json:s}=await eC(o,async d=>{let f=await fetch(`https://createprojectlight-${Fh}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({data:{name:o.name,keyApp:d}})});return{res:f,json:await f.json()}}),c=s.result?.data||s.data||{},u=c.enterpriseId||c.referenceId||c.id,l=`npx ozmoz init --keyApp=${a} --token=${c.bootstrapToken} && npx ozmoz sync`;return{content:[{type:"text",text:JSON.stringify({status:"SUCCESS",message:`Project "${o.name}" successfully created. Ready for bootstrap and modeling.`,enterpriseID:u,keyApp:a,bootstrapToken:c.bootstrapToken,commandInit:l,directive:"Do NOT start any dev server yet. If the folder has no package.json, scaffold the frontend first (step 1), then run commandInit.",nextSteps:await nC(i)},null,2)}]}}if(t==="oz_update_project"){tC(n&&n.userApproval);let r=await rC(Gt.resolve(process.cwd()),n&&n.modeReply,n&&n.reasoning),o=KR(Gt.resolve(process.cwd()))||n?.keyApp?.trim();if(!o)throw new Error("keyApp not provided and OZ_KEY_APP not found in the project's .env. Pass 'keyApp' explicitly.");let{spawnSync:a}=await import("node:child_process"),{fileURLToPath:s}=await import("node:url"),c=Gt.dirname(s(import.meta.url)),l=[[Gt.join(c,"cli.cjs"),Gt.join(c,"cli.js")].find(fr.existsSync)||Gt.join(c,"cli.cjs"),"update",`--reasoning=${r}`];n?.rules&&l.push(`--rules=${n.rules}`),n?.filePaths&&Array.isArray(n.filePaths)&&l.push(`--files=${n.filePaths.join(",")}`);let d=a(process.execPath,l,{cwd:process.cwd(),stdio:"pipe",encoding:"utf8",env:process.env});if(d.status!==0){let f=(d.stderr||d.stdout||"").trim();throw new Error(`Modeling update failed via CLI: ${f||"Unknown execution error"}`)}return{content:[{type:"text",text:JSON.stringify({status:"SUCCESS",keyApp:o,message:"Alex AI a mod\xE9lis\xE9 le contrat \xE0 partir du contractDraft extrait localement et l'a scell\xE9 \xE0 l'Edge.",actionRequired:"none",directive:`1. La structure des donn\xE9es a \xE9t\xE9 extraite et scell\xE9e \xE0 l'Edge via cli.js.
|
|
82
|
+
3. Once every view is written, start the dev server and ask the user to validate before calling 'oz_update_project'.`;try{let n=await fetch(`https://getagentdirectives-${Fh}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify({data:{}})});if(!n.ok)return t;let i=await n.json(),r=i.result?.data||i.result||i.data;return typeof r?.createProjectNextSteps=="string"&&r.createProjectNextSteps.trim()?r.createProjectNextSteps:t}catch{return t}}var Bo=new Yc({name:"ozmoz-mcp",version:"1.0.0"},{capabilities:{tools:{},prompts:{}},instructions:'OZmoz: before anything else, call the tool "oz_get_contract" to load the directives. They are not stored in a local file.'});Bo.setRequestHandler(Ep,async()=>({prompts:[{name:"oz_contract_rules",description:"Loads strict architectural rules, invariants, and integrity directives for OZmoz SVRO."}]}));Bo.setRequestHandler(Zp,async e=>{if(e.params.name==="oz_contract_rules")return{description:"Official OZmoz SVRO architecture directives",messages:[{role:"user",content:{type:"text",text:mS}}]};throw new Error(`Unknown prompt: ${e.params.name}`)});Bo.setRequestHandler(Up,async()=>({tools:[{name:"oz_create_project",description:"Creates a NEW OZmoz Cloud project. Call this ONLY when starting a brand new application from scratch. DO NOT call it if the project is already initialized (OZ_DB_KEY present in .env, or svro.schema.json exists): use 'oz_update_project' instead. This tool is already authenticated and returns the exact next command to run: no shell command or filesystem search is needed before calling it, including this tool's own JSON definition file (e.g. under ~/.gemini/.../mcp/ozmoz/oz_create_project.json) \u2014 you already have this schema in context via the tool list. Only if it returns a missing-token error: run 'npx ozmoz login' once, wait for it to finish, then call this tool again.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Nom de l'application"},keyApp:{type:"string",description:"Slug unique (optionnel, auto-d\xE9duit si omis)"}},required:["name"]}},{name:"oz_update_project",description:"HARD STOP: call this tool ONLY after the user has explicitly approved the screens in a message that arrived AFTER you gave them the dev-server address (first sealing), or when they ask for a data change (later). NEVER in the same turn as writing UI code or asking for their approval: if they have not answered yet, ask and STOP. 'userApproval' must be their exact words. Models / updates the project's data contract (svro.schema.json + svro.workflow.json) from UI component files and business rules, additively. This is the ONLY way to evolve the contract: there is no shell command for it. Pass 'filePaths' (e.g. ['src/components/DeskList.jsx']); 'keyApp' is optional (read from .env). Do NOT read this tool's own JSON definition file from disk (e.g. under ~/.gemini/.../mcp/ozmoz/oz_update_project.json) before calling it \u2014 you already have this schema in context via the tool list; re-reading it wastes time and tokens for no new information. Before calling this tool, ask the user (like the framework question) which analysis depth they want for this modeling pass: briefly explain what this step does and what each mode costs, THEN show only the two options as a bare list (recommended option first) \u2014 and pass their LITERAL reply as 'modeReply' from your very first call. If you forget and call without it, the tool may fail and tell you to ask; that is a fallback, not the normal path. Afterwards run 'npx ozmoz sync' once.",inputSchema:{type:"object",properties:{keyApp:{type:"string",description:"Unique application key (e.g. coworking_prod). Optional: if omitted, it is read from OZ_KEY_APP in the project's .env."},name:{type:"string",description:"Application name"},userApproval:{type:"string",description:"The user's EXACT words authorizing this call: their approval of the screens, or their request to change the data. Never write it yourself."},rules:{type:"string",description:"New business rules, calculations, or state transitions."},reasoning:{type:"string",enum:["standard","high"],description:"DEPRECATED \u2014 ignored. Omit this."},modeReply:{type:"string",description:"MANDATORY \u2014 never omit it, never invent it. Before calling this tool, show the user a numbered [1]/[2] choice for the analysis depth (recommended option first, like you do for the framework question), wait for their reply, then pass their LITERAL reply here (empty/'ok'/'oui' for [1], '2' for [2])."},filePaths:{type:"array",items:{type:"string"},description:"Relative paths of ALL files that call oz.* or define data fields."},viewFiles:{type:"array",items:{type:"object",properties:{name:{type:"string"},content:{type:"string"}},required:["name","content"]},description:"View files already loaded in memory [{ name, content }]."}},required:["name","userApproval","modeReply"]}},{name:"oz_publish_function",description:"Deploys a private or public cloud utility function executed in a secure serverless environment.",inputSchema:{type:"object",properties:{enterpriseID:{type:"string",description:"Project enterpriseID infrastructure identifier"},functionName:{type:"string",description:"Function name (alphanumeric 3-40 chars, e.g. calculateTotal)"},code:{type:"string",description:"JS source code (e.g. async function calculateTotal(payload, oz) { ... })"},description:{type:"string",description:"Action documentation for the catalog and Alex AI"},isPublic:{type:"boolean",description:"true to publish to the global Marketplace, false for private function"}},required:["enterpriseID","functionName","code"]}},{name:"oz_get_contract",description:"Provides the official data contract, SDK directives, production lifecycle and canonical blueprint.",inputSchema:{type:"object",properties:{}}}]}));Bo.setRequestHandler(ao,async e=>{let{name:t,arguments:n}=e.params;if(t==="oz_get_contract")return{content:[{type:"text",text:mS}]};let i=await YR();if(!i)return{isError:!0,content:[{type:"text",text:"Error: FLEETBO_DEV_TOKEN missing. Run 'npx ozmoz login' ONCE, wait for it to finish (the developer approves in the browser), then call this tool again \u2014 no restart needed."}]};try{if(t==="oz_create_project"){let o=ot.object({name:ot.string().min(2),keyApp:ot.string().optional()}).parse(n),{keyApp:a,json:s}=await eC(o,async d=>{let f=await fetch(`https://createprojectlight-${Fh}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({data:{name:o.name,keyApp:d}})});return{res:f,json:await f.json()}}),c=s.result?.data||s.data||{},u=c.enterpriseId||c.referenceId||c.id,l=`npx ozmoz init --keyApp=${a} --token=${c.bootstrapToken} && npx ozmoz sync`;return{content:[{type:"text",text:JSON.stringify({status:"SUCCESS",message:`Project "${o.name}" successfully created. Ready for bootstrap and modeling.`,enterpriseID:u,keyApp:a,bootstrapToken:c.bootstrapToken,commandInit:l,directive:"Do NOT start any dev server yet. If the folder has no package.json, scaffold the frontend first (step 1), then run commandInit.",nextSteps:await nC(i)},null,2)}]}}if(t==="oz_update_project"){tC(n&&n.userApproval);let r=await rC(Gt.resolve(process.cwd()),n&&n.modeReply,n&&n.reasoning),o=KR(Gt.resolve(process.cwd()))||n?.keyApp?.trim();if(!o)throw new Error("keyApp not provided and OZ_KEY_APP not found in the project's .env. Pass 'keyApp' explicitly.");let{spawnSync:a}=await import("node:child_process"),{fileURLToPath:s}=await import("node:url"),c=Gt.dirname(s(import.meta.url)),l=[[Gt.join(c,"cli.cjs"),Gt.join(c,"cli.js")].find(fr.existsSync)||Gt.join(c,"cli.cjs"),"update",`--reasoning=${r}`];n?.rules&&l.push(`--rules=${n.rules}`),n?.filePaths&&Array.isArray(n.filePaths)&&l.push(`--files=${n.filePaths.join(",")}`);let d=a(process.execPath,l,{cwd:process.cwd(),stdio:"pipe",encoding:"utf8",env:process.env});if(d.status!==0){let f=(d.stderr||d.stdout||"").trim();throw new Error(`Modeling update failed via CLI: ${f||"Unknown execution error"}`)}return{content:[{type:"text",text:JSON.stringify({status:"SUCCESS",keyApp:o,message:"Alex AI a mod\xE9lis\xE9 le contrat \xE0 partir du contractDraft extrait localement et l'a scell\xE9 \xE0 l'Edge.",actionRequired:"none",directive:`1. La structure des donn\xE9es a \xE9t\xE9 extraite et scell\xE9e \xE0 l'Edge via cli.js.
|
|
83
83
|
2. MANDATORY PHASE 2 CONCLUSION: Present the sync summary, then ask the user inside this exact visual frame:
|
|
84
84
|
\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
|
|
85
85
|
\u{1F449} PASSAGE EN MODE Live (R\xC9EL) : Voulez-vous activer la base de donn\xE9es r\xE9elle (OZ_PROTOTYPE=false) ?
|