fleetbo-svro 1.0.48 → 1.0.50
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 +31 -29
- package/dist/fleetbo-mcp.js +73 -34
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Q=(e,o)=>()=>{try{return o||e((o={exports:{}}).exports,o),o.exports}catch(
|
|
3
|
-
`),
|
|
2
|
+
var Q=(e,o)=>()=>{try{return o||e((o={exports:{}}).exports,o),o.exports}catch(s){throw o=0,s}};var J=Q((ke,$)=>{var a=require("fs"),f=require("path"),Z=require("https"),{execSync:ee}=require("child_process"),te="\x1B[38;2;231;233;237m",oe="\x1B[31m",j="\x1B[0m";function y(e){console.log(` ${te}${e}${j}`)}function E(e){console.error(` ${oe}${e}${j}`)}function ne(e){let o={};return e.forEach(s=>{if(s.startsWith("--")){let[n,r]=s.slice(2).split("=");n&&r&&(o[n]=r)}}),o}function w(e,o){try{let s=JSON.parse(a.readFileSync(e,"utf8"));return!!(s.dependencies&&s.dependencies[o]||s.devDependencies&&s.devDependencies[o])}catch{return!1}}function se(e,o){try{return a.existsSync(f.join(e,"node_modules",o,"package.json"))}catch{return!1}}function re(e,o){if(a.existsSync(f.join(e,"pnpm-lock.yaml")))return"pnpm";if(a.existsSync(f.join(e,"yarn.lock")))return"yarn";if(a.existsSync(f.join(e,"bun.lockb")))return"bun";try{let s=JSON.parse(a.readFileSync(o,"utf8"));if(typeof s.packageManager=="string"){if(s.packageManager.startsWith("pnpm"))return"pnpm";if(s.packageManager.startsWith("yarn"))return"yarn";if(s.packageManager.startsWith("bun"))return"bun"}}catch{}return"npm"}function ie(e,o){if(!w(o,"fleetbo-svro")||!se(e,"fleetbo-svro")){let s=re(e,o),n={pnpm:"pnpm add fleetbo-svro",yarn:"yarn add fleetbo-svro",bun:"bun add fleetbo-svro",npm:"npm install fleetbo-svro"}[s];y(`\u2192 Installing fleetbo-svro into the project (detected: ${s})...`);try{ee(n,{cwd:e,stdio:"inherit"}),y("fleetbo-svro installed successfully!")}catch(r){E(`\u26A0\uFE0F Automatic installation failed: ${r.message}`),E(`\u{1F449} Please run '${n}' manually.`)}}}function le(e){let o=f.join(e,"svro.schema.json");if(a.existsSync(o))return;let s=new Date().toISOString(),n={createdAt:s,patchedAt:s,schemaVersion:1,collections:{}};a.writeFileSync(o,JSON.stringify(n,null,2)+`
|
|
3
|
+
`),y("\u2192 Created svro.schema.json at project root.")}function ae(e){let o=f.join(e,".env"),s=`
|
|
4
4
|
# Fleetbo UI Sandbox Mode
|
|
5
5
|
# true = Sandbox mode: simulates writes locally for fluid UI testing; no DB access and IDE alert.
|
|
6
6
|
# false = Strict production mode: enforces schema contracts and persists to DB
|
|
7
7
|
VITE_FLEETBO_PROTOTYPE=true
|
|
8
|
-
`;if(!a.existsSync(o))a.writeFileSync(o,
|
|
8
|
+
`;if(!a.existsSync(o))a.writeFileSync(o,s.trimStart()),y("\u2192 Created .env with VITE_FLEETBO_PROTOTYPE=true");else{let n=a.readFileSync(o,"utf8");!n.includes("VITE_FLEETBO_PROTOTYPE")&&!n.includes("FLEETBO_PROTOTYPE")&&(a.appendFileSync(o,s),y("\u2192 Injected VITE_FLEETBO_PROTOTYPE=true into existing .env"))}}function ce(e){let o=f.join(e,"src");if(!a.existsSync(o))return;let s=f.join(o,"fleetbo.d.ts");if(a.existsSync(s))return;let n=`/* eslint-disable */
|
|
9
9
|
/* prettier-ignore */
|
|
10
10
|
// @ts-nocheck
|
|
11
11
|
export {}
|
|
@@ -70,16 +70,16 @@ declare global {
|
|
|
70
70
|
'fleetbo-reference': FleetboProp;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
`;try{a.writeFileSync(
|
|
73
|
+
`;try{a.writeFileSync(s,n),y("\u2192 Created src/fleetbo.d.ts stub for instant IDE auto-completion.")}catch(r){E(`\u26A0\uFE0F Unable to create src/fleetbo.d.ts: ${r.message}`)}}function de(e){let o=f.join(e,"index.d.ts");a.existsSync(o)||y("\u2192 Verified index.d.ts presence.")}function pe(e){let o=["tsconfig.json","jsconfig.json"];for(let s of o){let n=f.join(e,s);if(a.existsSync(n)){let r=new Date;a.utimesSync(n,r,r);break}}}function ue(e){return new Promise((o,s)=>{let n=JSON.stringify({token:e}),r={hostname:"bootstrapproject-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(n)}},c=Z.request(r,t=>{let i="";t.on("data",l=>{i+=l}),t.on("end",()=>{if(t.statusCode>=200&&t.statusCode<300)try{o(JSON.parse(i))}catch{s(new Error("Invalid response received from Fleetbo server."))}else try{let l=JSON.parse(i);s(new Error(l.error||`Server error ${t.statusCode}`))}catch{s(new Error(`Server error ${t.statusCode}`))}})});c.on("error",t=>s(t)),c.write(n),c.end()})}async function be(e,o=[]){let s=f.join(e,".env");if(a.existsSync(s)&&a.readFileSync(s,"utf8").includes("VITE_FLEETBO_DB_KEY")){y("\u2192 Fleetbo environment variables already present in .env \u2014 skipping step.");return}let n=ne(o),r=n.keyApp,c=n.token||n.bootstrapToken,t=n.email||"";(!r||!c)&&(E("\u26A0\uFE0F Missing required parameters."),E("\u{1F449} Usage: npx fleetbo-svro init --keyApp=YOUR_KEY --token=YOUR_TOKEN"),process.exit(1)),y("\u2192 Exchanging bootstrap token for project keys...");let i;try{i=await ue(c)}catch(b){E(`\u26A0\uFE0F Token exchange failed: ${b.message}`),E("\u{1F449} The token may have expired (15 min limit) or was already used. Please regenerate one from the Fleetbo dashboard."),process.exit(1)}(!i.enterpriseId||!i.fleetboDBKey)&&(E("\u26A0\uFE0F Incomplete response from Fleetbo server."),process.exit(1));let l=i.facebookAppId||n.fbAppId||n.facebookAppId||"11967268204758",d=`
|
|
74
74
|
VITE_FLEETBO_DB_KEY=${i.fleetboDBKey}
|
|
75
75
|
VITE_FLEETBO_ENTERPRISE_ID=${i.enterpriseId}
|
|
76
|
-
VITE_FLEETBO_KEY_APP=${
|
|
76
|
+
VITE_FLEETBO_KEY_APP=${r}
|
|
77
77
|
${t?`VITE_FLEETBO_TESTER_EMAIL=${t}
|
|
78
78
|
`:""}VITE_FLEETBO_FACEBOOK_APP_ID=${l}
|
|
79
|
-
`;a.appendFileSync(
|
|
80
|
-
`),
|
|
81
|
-
`):
|
|
82
|
-
`+
|
|
79
|
+
`;a.appendFileSync(s,d),y(".env file updated successfully with Fleetbo keys!")}function L(e){let o=f.join(e,"svro.d.ts");if(a.existsSync(o))try{a.unlinkSync(o),y("\u2192 Removed legacy svro.d.ts from project root.")}catch{}}function _(e,o){if(process.env.FLEETBO_SKIP_TYPECHECK_SETUP)return;let s=f.join(e,"tsconfig.json"),n=f.join(e,"jsconfig.json"),r=a.existsSync(s)?s:n,c=!a.existsSync(r),t={};if(!c)try{t=JSON.parse(a.readFileSync(r,"utf8"))}catch{E(`\u26A0\uFE0F Unable to read ${f.basename(r)} (Invalid JSON).`);return}t.compilerOptions=t.compilerOptions||{};let i=!1,l=w(o,"react");c?(t.compilerOptions.checkJs=!0,t.compilerOptions.allowJs=!0,t.compilerOptions.target=t.compilerOptions.target||"ES2020",t.compilerOptions.module=t.compilerOptions.module||"ESNext",t.compilerOptions.moduleResolution=t.compilerOptions.moduleResolution||"bundler",t.include=["src/**/*"],i=!0):(t.compilerOptions.checkJs===void 0&&(t.compilerOptions.checkJs=!0,i=!0),t.compilerOptions.allowJs===void 0&&(t.compilerOptions.allowJs=!0,i=!0)),l&&t.compilerOptions.jsx===void 0&&(t.compilerOptions.jsx="react-jsx",i=!0),Array.isArray(t.compilerOptions.types)&&t.compilerOptions.types.includes("vite/client")&&(t.compilerOptions.types=t.compilerOptions.types.filter(d=>d!=="vite/client"),t.compilerOptions.types.length===0&&delete t.compilerOptions.types,i=!0,y(`\u2192 Removed legacy "vite/client" entry from ${f.basename(r)}.`)),i&&(a.writeFileSync(r,JSON.stringify(t,null,2)+`
|
|
80
|
+
`),y(`\u2192 Updated ${f.basename(r)}.`))}function U(e){let o=["src/app/layout.tsx","src/app/layout.jsx","app/layout.tsx","app/layout.jsx","src/pages/_app.tsx","src/pages/_app.jsx","pages/_app.tsx","pages/_app.jsx","src/main.tsx","src/main.jsx","src/main.ts","src/main.js","src/index.tsx","src/index.jsx","src/index.ts","src/index.js","src/App.tsx","src/App.jsx","src/App.vue","app.vue","src/routes/+layout.svelte","src/routes/+layout.ts","src/main.singletons.ts"];for(let s of o){let n=f.join(e,s);if(a.existsSync(n)){let r=a.readFileSync(n,"utf8");r.includes("fleetbo-svro")||(r.startsWith('"use client"')||r.startsWith("'use client'")?r=r.replace(/(['"]use client['"];?\r?\n)/,`$1import 'fleetbo-svro';
|
|
81
|
+
`):r=`import 'fleetbo-svro';
|
|
82
|
+
`+r,a.writeFileSync(n,r));return}}}function B(e,o){if(process.env.FLEETBO_SKIP_AUTOIMPORT_SETUP)return;let n=["vite.config.ts","vite.config.js","vite.config.mjs"].map(l=>f.join(e,l)).find(l=>a.existsSync(l));if(!n)return;let r;try{r=a.readFileSync(n,"utf8")}catch{return}let c="fleetbo-svro",t=r,i=`{
|
|
83
83
|
name: 'fleetbo-auto-runtime',
|
|
84
84
|
transform(code, id) {
|
|
85
85
|
if (!id.includes('node_modules') && !code.includes('fleetbo-svro') && /(src[\\\\/](main|index|App|root))\\.(jsx?|tsx?|vue|svelte)/i.test(id)) {
|
|
@@ -135,13 +135,13 @@ ${t?`VITE_FLEETBO_TESTER_EMAIL=${t}
|
|
|
135
135
|
AutoImport({
|
|
136
136
|
imports: [{ '${c}': ['Fleetbo', 'FleetboUI'] }],
|
|
137
137
|
dts: 'src/auto-imports.d.ts'
|
|
138
|
-
}),`;if(t=t.slice(0,d)+b+t.slice(d),!t.includes("import AutoImport")){let
|
|
139
|
-
`;if(
|
|
140
|
-
`+
|
|
141
|
-
`+i+t.slice(d)}}t!==
|
|
142
|
-
`),
|
|
138
|
+
}),`;if(t=t.slice(0,d)+b+t.slice(d),!t.includes("import AutoImport")){let h=[...t.matchAll(/^import .+;?$/gm)].pop(),T=`import AutoImport from 'unplugin-auto-import/vite';
|
|
139
|
+
`;if(h){let g=h.index+h[0].length;t=t.slice(0,g)+`
|
|
140
|
+
`+T+t.slice(g)}else t=T+t}}}if(!t.includes("fleetbo-auto-runtime")){let l=t.match(/plugins\s*:\s*\[/);if(l){let d=l.index+l[0].length;t=t.slice(0,d)+`
|
|
141
|
+
`+i+t.slice(d)}}t!==r&&a.writeFileSync(n,t)}function fe(e){let o=f.join(e,".vscode"),s=f.join(o,"settings.json");try{a.existsSync(o)||a.mkdirSync(o,{recursive:!0});let n={};if(a.existsSync(s))try{n=JSON.parse(a.readFileSync(s,"utf8"))}catch{n={}}n["workbench.colorCustomizations"]=n["workbench.colorCustomizations"]||{},n["workbench.colorCustomizations"]["editorInfo.foreground"]="#00feae",n["workbench.colorCustomizations"]["editorHint.foreground"]="#00feae",a.writeFileSync(s,JSON.stringify(n,null,2)+`
|
|
142
|
+
`),y("\u2192 Configured Fleetbo Cyan visual hints in .vscode/settings.json.")}catch{}}function me(e,o,s={}){let{skipSelfInstall:n=!1}=s,r=f.join(__dirname,"..");n||ie(e,o),le(e),ae(e),de(r),ce(e),fe(e),L(e),_(e,o),B(e,o),U(e)}$.exports={touchTsConfig:pe,log:y,logError:E,handleAuthAndEnv:be,detectDependency:w,cleanupLegacyRootDts:L,patchJsOrTsConfig:_,attemptViteAutoImportPatch:B,injectUniversalRuntime:U,runFullSetup:me}});var p=require("fs"),m=require("path"),H=require("https"),ge=require("http"),k=require("os"),{exec:ye}=require("child_process"),{runFullSetup:Fe,handleAuthAndEnv:he,touchTsConfig:Te,attemptViteAutoImportPatch:Ee,injectUniversalRuntime:Se}=J(),Oe="\x1B[34m",Pe="\x1B[31m",q="\x1B[0m";function u(e){console.log(`${Oe}${e}${q}`)}function O(e){console.error(`${Pe}${e}${q}`)}function ve(e){let o=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";ye(`${o} "${e}"`)}function xe(e){return new Promise((o,s)=>{let n=ge.createServer((r,c)=>{if(c.setHeader("Access-Control-Allow-Origin","*"),c.setHeader("Access-Control-Allow-Methods","GET, OPTIONS"),c.setHeader("Access-Control-Allow-Headers","Content-Type, Authorization"),c.setHeader("Access-Control-Allow-Private-Network","true"),r.method==="OPTIONS"){c.writeHead(204),c.end();return}let t=new URL(r.url,"http://127.0.0.1");if(t.pathname==="/callback"){let i=t.searchParams.get("token");if(!i){c.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),c.end("<h3>Error: Missing token.</h3>");return}let l=m.join(k.homedir(),".fleetbo");p.existsSync(l)||p.mkdirSync(l,{recursive:!0}),p.writeFileSync(m.join(l,"credentials.json"),JSON.stringify({devToken:i,updatedAt:new Date().toISOString()},null,2));let d=m.join(e,".env");if(p.existsSync(d)){let b=p.readFileSync(d,"utf8");b.includes("FLEETBO_DEV_TOKEN=")?b=b.replace(/FLEETBO_DEV_TOKEN=.*/g,`FLEETBO_DEV_TOKEN=${i}`):b+=`
|
|
143
143
|
FLEETBO_DEV_TOKEN=${i}
|
|
144
|
-
`,p.writeFileSync(d,b,"utf8")}c.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),c.end(`
|
|
144
|
+
`,p.writeFileSync(d,b,"utf8")}c.writeHead(200,{"Content-Type":"text/html; charset=utf-8",Connection:"close"}),c.end(`
|
|
145
145
|
<!DOCTYPE html>
|
|
146
146
|
<html>
|
|
147
147
|
<head><meta charset="utf-8"><title>Fleetbo CLI</title></head>
|
|
@@ -155,9 +155,9 @@ FLEETBO_DEV_TOKEN=${i}
|
|
|
155
155
|
`),u(`
|
|
156
156
|
[Fleetbo] Developer token received and stored successfully!`),u(`
|
|
157
157
|
Next step to connect your AI agents:`),u(` npx fleetbo-svro mcp (Configure Cursor, Windsurf, Claude Code, etc.)
|
|
158
|
-
`),n.close(()=>o())}});n.listen(0,"127.0.0.1",()=>{let c=`https://fleetbo.io/cli-auth?port=${n.address().port}`;u(`
|
|
159
|
-
[Fleetbo] Waiting for authentication...`),u(`If your browser does not open automatically, visit: ${c}`),ve(c)}),n.on("error",s
|
|
160
|
-
`).forEach(
|
|
158
|
+
`),typeof n.closeAllConnections=="function"&&n.closeAllConnections(),n.close(()=>o()),setTimeout(()=>o(),300)}});n.listen(0,"127.0.0.1",()=>{let c=`https://fleetbo.io/cli-auth?port=${n.address().port}`;u(`
|
|
159
|
+
[Fleetbo] Waiting for authentication...`),u(`If your browser does not open automatically, visit: ${c}`),ve(c)}),n.on("error",r=>s(r))})}function Ie(e,o){return new Promise((s,n)=>{let r=JSON.stringify({enterpriseID:e,schema:o}),c={hostname:"fleetbo-gatekeeper.fleetbo.workers.dev",path:"/sync-schema",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},t=H.request(c,i=>{let l="";i.on("data",d=>{l+=d}),i.on("end",()=>{i.statusCode>=200&&i.statusCode<300?s(JSON.parse(l)):n(new Error(`Edge sync failed with HTTP ${i.statusCode}`))})});t.on("error",i=>n(i)),t.write(r),t.end()})}function M(e){let o=m.join(e,".env");if(!p.existsSync(o))return{};let s=p.readFileSync(o,"utf8"),n={};return s.split(`
|
|
160
|
+
`).forEach(r=>{let[c,...t]=r.split("=");c&&t.length>0&&(n[c.trim()]=t.join("=").trim())}),n}function V(e,o){return new Promise((s,n)=>{let r=JSON.stringify({projectId:e,moduleName:o}),c={hostname:"getmodulecache-jqycakhlxa-uc.a.run.app",path:"/",method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(r)}},t=H.request(c,i=>{let l="";i.on("data",d=>{l+=d}),i.on("end",()=>{if(i.statusCode>=200&&i.statusCode<300)try{let d=JSON.parse(l);if(d.success&&d.found&&d.module){let b=d.module.code||d.module.mockCode;s(typeof b=="string"?JSON.parse(b):b)}else s(null)}catch{n(new Error(`Invalid JSON response for ${o}.`))}else n(new Error(`Server error ${i.statusCode} while fetching ${o}`))})});t.on("error",i=>n(i)),t.write(r),t.end()})}var C=process.argv.slice(2),I=C[0];function Ce(e,o){return`# LE CONTRAT DE DONN\xC9ES FLEETBO (FLEETBO DATA CONTRACT)
|
|
161
161
|
|
|
162
162
|
Ce document constitue le **Cahier des charges officiel et le Contrat bilat\xE9ral d'int\xE9grit\xE9** liant le code client (d\xE9veloppeur ou agent IA) et le moteur Data OS Fleetbo SVRO.
|
|
163
163
|
|
|
@@ -239,17 +239,19 @@ ${JSON.stringify(e||{},null,2)}
|
|
|
239
239
|
${JSON.stringify(o||{},null,2)}
|
|
240
240
|
\`\`\`
|
|
241
241
|
`}async function Ae(){let e=process.cwd(),o=m.join(e,"package.json");if(I==="init"||I==="doctor")u(`
|
|
242
|
-
[Fleetbo] Initializing and configuring Fleetbo...`),await he(e,C),
|
|
242
|
+
[Fleetbo] Initializing and configuring Fleetbo...`),await he(e,C),Fe(e,o),u(`
|
|
243
243
|
[Fleetbo] Configuration completed successfully!
|
|
244
244
|
`),u(`
|
|
245
245
|
Next step:`),u(` npx fleetbo-svro sync (Sync cloud schema & generate IDE types)
|
|
246
|
-
`);else if(I==="sync"){let
|
|
247
|
-
`),u("\u2192 Local svro.schema.json updated.")),
|
|
248
|
-
`),u("\u2192 Local svro.workflow.json updated."))}catch(
|
|
249
|
-
|
|
246
|
+
`);else if(I==="sync"){let s=C.includes("--dry-run");u(`[Fleetbo] Syncing schema...${s?" (dry-run)":""}`);let n=m.join(e,"svro.schema.json"),r=m.join(e,"svro.workflow.json"),c=m.join(e,"Fleetbo_contract.md"),t=m.join(__dirname,".."),i=m.join(t,"index.d.ts"),l=m.join(e,"src","fleetbo.d.ts"),b=M(e).VITE_FLEETBO_ENTERPRISE_ID,h=null,T=null;if(b)try{u("\u2192 Fetching latest contracts from Fleetbo Cloud..."),h=await V(b,"svro.schema.json"),h&&(p.writeFileSync(n,JSON.stringify(h,null,2)+`
|
|
247
|
+
`),u("\u2192 Local svro.schema.json updated.")),T=await V(b,"svro.workflow.json"),T&&(p.writeFileSync(r,JSON.stringify(T,null,2)+`
|
|
248
|
+
`),u("\u2192 Local svro.workflow.json updated."))}catch(S){O(`\u26A0\uFE0F Cloud fetch bypassed: ${S.message}. Using local file fallback.`)}else O("\u26A0\uFE0F VITE_FLEETBO_ENTERPRISE_ID missing in .env. Skipping cloud fetch.");let g=h;if(!g&&p.existsSync(n))try{g=JSON.parse(p.readFileSync(n,"utf8"))}catch{}g||(g={context:"Application en cours de mod\xE9lisation initiale.",collections:{}},p.writeFileSync(n,JSON.stringify(g,null,2)+`
|
|
249
|
+
`,"utf8"),u("\u2192 Initial blank svro.schema.json created."));let F=T;if(!F&&p.existsSync(r))try{F=JSON.parse(p.readFileSync(r,"utf8"))}catch{}F||(F={actors:{},sequences:[]},p.writeFileSync(r,JSON.stringify(F,null,2)+`
|
|
250
|
+
`,"utf8"),u("\u2192 Initial blank svro.workflow.json created."));let K=Ce(g,F);p.writeFileSync(c,K,"utf8"),u("\u2192 Fleetbo_contract.md successfully generated at project root.");try{let S=Object.keys(g.collections||{});if(b)try{await Ie(b,g),u("\u2192 Schema successfully sealed at Fleetbo Global Edge (O(1)).")}catch(P){O(`\u26A0\uFE0F Fleetbo Edge Shield sync warning: ${P.message}`)}let W=g.collections||{},N=Object.entries(W).map(([P,R])=>{let G=R.fields||R.schema||{},X=Object.entries(G).map(([z,A])=>{let x="any",v=String(typeof A=="string"?A:A.type||"").toLowerCase();return v==="string"||v==="text"||v==="media"?x="string":v==="number"?x="number":v==="boolean"||v==="toggle"?x="boolean":v==="array"&&(x="any[]"),` ${z}?:${x};`}).join(`
|
|
251
|
+
`);return` ${P}: {
|
|
250
252
|
${X}
|
|
251
253
|
};`}).join(`
|
|
252
|
-
`),D=
|
|
254
|
+
`),D=S.length>0?S.map(P=>`'${P}'`).join(" | "):"string",Y=`// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
253
255
|
|
|
254
256
|
export interface FleetboSchemaMap {
|
|
255
257
|
${N}
|
|
@@ -512,7 +514,7 @@ declare module 'svelte/elements' {
|
|
|
512
514
|
'fleetbo-reference': FleetboProp;
|
|
513
515
|
}
|
|
514
516
|
}
|
|
515
|
-
`;if(p.writeFileSync(i,Y),p.existsSync(m.dirname(l))){let
|
|
517
|
+
`;if(p.writeFileSync(i,Y),p.existsSync(m.dirname(l))){let P=`/* eslint-disable */
|
|
516
518
|
/* prettier-ignore */
|
|
517
519
|
// @ts-nocheck
|
|
518
520
|
// Generated by fleetbo-svro \u2014 Updated via fleetbo sync
|
|
@@ -646,9 +648,9 @@ declare module 'svelte/elements' {
|
|
|
646
648
|
'fleetbo-reference': FleetboProp;
|
|
647
649
|
}
|
|
648
650
|
}
|
|
649
|
-
`;p.writeFileSync(l,
|
|
650
|
-
[Fleetbo] Configuring MCP server for your environment...`);let n=M(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN||"";if(!n){let d=m.join(k.homedir(),".fleetbo","credentials.json");if(p.existsSync(d))try{n=JSON.parse(p.readFileSync(d,"utf8")).devToken||""}catch{}}let
|
|
651
|
-
`)},t=m.join(e,".cursor"),i=m.join(t,"mcp.json");c(i,"fleetbo-svro",
|
|
651
|
+
`;p.writeFileSync(l,P)}Te(e),Ee(e,o),Se(e),u(`[Fleetbo] Schema synced successfully (${S.length} collection(s)).`),s&&u("\u2192 [Dry-run] Schema is valid.")}catch(S){O(`Error during synchronization: ${S.message}`),process.exit(1)}}else if(I==="mcp"){if(!process.stdin.isTTY||C.includes("--run")){try{await import(`file://${m.join(__dirname,"fleetbo-mcp.js")}`)}catch(d){O(`Failed to start MCP server: ${d.message}`),process.exit(1)}return}u(`
|
|
652
|
+
[Fleetbo] Configuring MCP server for your environment...`);let n=M(e).FLEETBO_DEV_TOKEN||process.env.FLEETBO_DEV_TOKEN||"";if(!n){let d=m.join(k.homedir(),".fleetbo","credentials.json");if(p.existsSync(d))try{n=JSON.parse(p.readFileSync(d,"utf8")).devToken||""}catch{}}let r={command:"npx",args:["-y","fleetbo-svro","mcp","--run"],env:{FLEETBO_DEV_TOKEN:n}},c=(d,b,h)=>{let T=m.dirname(d);p.existsSync(T)||p.mkdirSync(T,{recursive:!0});let g={mcpServers:{}};if(p.existsSync(d))try{let F=JSON.parse(p.readFileSync(d,"utf8"));F&&typeof F=="object"&&!Array.isArray(F)&&(g=F)}catch{}g.mcpServers=g.mcpServers||{},g.mcpServers[b]=h,p.writeFileSync(d,JSON.stringify(g,null,2)+`
|
|
653
|
+
`)},t=m.join(e,".cursor"),i=m.join(t,"mcp.json");c(i,"fleetbo-svro",r),u("\u2192 Configured for Cursor (.cursor/mcp.json)");let l=m.join(k.homedir(),".codeium","windsurf","mcp_config.json");p.existsSync(m.dirname(l))&&(c(l,"fleetbo-svro",r),u("\u2192 Configured for Windsurf (~/.codeium/windsurf/mcp_config.json)")),u(`
|
|
652
654
|
Universal connection command for Claude Code and standalone agents:`),u(` claude mcp add fleetbo-svro -- npx -y fleetbo-svro mcp --run
|
|
653
655
|
`),n?u(`[Fleetbo] Agent ready! Your development environment now has access to Fleetbo MCP tools.
|
|
654
|
-
`):
|
|
656
|
+
`):O('\u26A0\uFE0F No developer token found. Run "npx fleetbo-svro login" or set FLEETBO_DEV_TOKEN in your .env file.'),process.exit(0)}else I==="login"?(await xe(e),process.exit(0)):(O('Unknown command. Usage: "npx fleetbo-svro init", "npx fleetbo-svro sync", "npx fleetbo-svro mcp" or "npx fleetbo-svro login"'),process.exit(1))}Ae().catch(e=>{O(`Fleetbo CLI Error: ${e.message}`),process.exit(1)});
|
package/dist/fleetbo-mcp.js
CHANGED
|
@@ -30,36 +30,72 @@ const CLOUD_RUN_REGION = "jqycakhlxa-uc.a.run.app";
|
|
|
30
30
|
// CONTRAT DE DONNÉES & DIRECTIVES STRICTES D'ARCHITECTURE FLEETBO SVRO
|
|
31
31
|
// ============================================================================
|
|
32
32
|
const FLEETBO_SYSTEM_GUIDELINES = `
|
|
33
|
-
#
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
🚨
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
# FLEETBO SVRO — CONSIGNES STRICTES POUR L'IA (SYSTEM INSTRUCTIONS)
|
|
34
|
+
|
|
35
|
+
================================================================================
|
|
36
|
+
🚨 PROTOCOLE UNIVERSEL FRONTEND ↔ ALEX AI : L'AUTORITÉ DU CONTRAT 🚨
|
|
37
|
+
================================================================================
|
|
38
|
+
1. LA SOURCE DE VÉRITÉ UNIQUE : « Fleetbo_contract.md »
|
|
39
|
+
- Dès l'entame de toute tâche, l'agent DOIT inspecter Fleetbo_contract.md.
|
|
40
|
+
- L'agent n'a le droit d'utiliser AUCUN champ, AUCUNE table et AUCUNE règle
|
|
41
|
+
qui ne soit pas explicitement formalisée dans Fleetbo_contract.md.
|
|
42
|
+
|
|
43
|
+
2. INTERDICTION DU MODE « SCHEMA-FIRST » / FLEETBO-FIRST :
|
|
44
|
+
- L'agent ne doit JAMAIS concevoir, imaginer ou modéliser un schéma BDD avant l'interface.
|
|
45
|
+
- En vibe-coding Fleetbo, c'est TOUJOURS l'interface UI qui dicte la structure de données.
|
|
46
|
+
- Le cycle est obligatoirement Frontend-First : UI d'abord ➔ inférence par Alex AI ➔ scellage.
|
|
47
|
+
|
|
48
|
+
3. SÉPARATION STRICTE DES RESPONSABILITÉS :
|
|
49
|
+
- Agent Frontend : gère exclusivement l'ergonomie, les composants d'affichage et l'UX.
|
|
50
|
+
- Alex AI : autorité exclusive sur la structure physique DDL, la sécurité ReBAC et la conformité.
|
|
51
|
+
- Zéro backend intermédiaire : N'écris AUCUN serveur Express, NestJS ou route REST fictive.
|
|
52
|
+
- Zero Import : L'objet Fleetbo et les balises <fleetbo-*> sont des composants globaux au runtime.
|
|
53
|
+
|
|
54
|
+
# WORKFLOW DE PRODUCTION UNIFIÉ FLEETBO SVRO (ZERO-BACKEND DATA OS)
|
|
55
|
+
|
|
56
|
+
## 🚀 Le Cycle de Production Unifié en 5 Étapes
|
|
57
|
+
|
|
58
|
+
### Étape 0 : Cadrage & Allocation Instantanée (Zéro LLM)
|
|
59
|
+
- L'agent appelle directement l'outil 'fleetbo_create_project' avec uniquement 'name' et 'keyApp'.
|
|
60
|
+
- Aucun schéma préalable n'est requis ni autorisé. Le Cloud réserve la base et retourne 'bootstrapToken'.
|
|
61
|
+
|
|
62
|
+
### Étape 1 : Amorçage Local & Contrat Initial Vierge
|
|
63
|
+
- Exécution obligatoire de la commande combinée à la racine :
|
|
64
|
+
npx fleetbo-svro init --keyApp=<KEY> --token=<TOKEN> && npx fleetbo-svro sync
|
|
65
|
+
- Effet immédiat :
|
|
66
|
+
1. Le runtime et les Web Components natifs sont injectés.
|
|
67
|
+
2. Le bac à sable est activé (VITE_FLEETBO_PROTOTYPE=true).
|
|
68
|
+
3. 'npx fleetbo-svro sync' télécharge le contrat initial vierge, génère 'Fleetbo_contract.md' et compile le typage global dans 'src/fleetbo.d.ts'.
|
|
69
|
+
- L'agent IA dispose alors de la bibliothèque complète pour prototyper l'UI sans inventer de backend.
|
|
70
|
+
|
|
71
|
+
### Étape 2 : Prototypage Visuel & Pré-câblage Direct Zero-Rewrite
|
|
72
|
+
- Écriture des vues UI (.jsx, .tsx, .vue) en appelant directement le SDK global (Fleetbo.getDocsG, Fleetbo.add...).
|
|
73
|
+
- L'Edge acquitte les mutations en mémoire vive sans altérer la base physique.
|
|
74
|
+
|
|
75
|
+
### Étape 3 : Modélisation Additive & Extraction Métier (Alex AI)
|
|
76
|
+
- L'agent transmet les fichiers UI et les contraintes métier via 'fleetbo_update_project'.
|
|
77
|
+
- Alex AI analyse les composants, extrait les entités et forge svro.schema.json et svro.workflow.json.
|
|
78
|
+
|
|
79
|
+
### Étape 4 : Scellage Edge, Typage Global & Contrat Markdown
|
|
80
|
+
- Exécution de :
|
|
81
|
+
npx fleetbo-svro sync
|
|
82
|
+
- Le schéma physique est scellé à l'Edge (rejet O(1) HTTP 422 de tout appel hors contrat).
|
|
83
|
+
- Génération physique de Fleetbo_contract.md à la racine et compilation des types TypeScript.
|
|
84
|
+
|
|
85
|
+
### Étape 5 : Bascule Live Instantanée
|
|
86
|
+
- Bascule dans le fichier .env :
|
|
87
|
+
VITE_FLEETBO_PROTOTYPE=false
|
|
88
|
+
- L'Edge ouvre les écritures physiques sur MongoDB Atlas sans toucher à une seule ligne de code front-end.
|
|
89
|
+
|
|
90
|
+
## 🛠️ SYNTAXE CANONIQUE DU SDK FLEETBO
|
|
51
91
|
- CREATE : await Fleetbo.add('collection', { name: String(n).trim(), price: Number(p) });
|
|
52
|
-
- READ
|
|
53
|
-
- READ
|
|
54
|
-
- READ
|
|
55
|
-
- UPDATE : await Fleetbo.update('collection',
|
|
56
|
-
- DELETE : await Fleetbo.delete('collection',
|
|
92
|
+
- READ (Tous) : const docs = await Fleetbo.getDocsG('collection');
|
|
93
|
+
- READ (Un seul) : const doc = await Fleetbo.getDoc('collection', id);
|
|
94
|
+
- READ (Utilisateur) : const docs = await Fleetbo.getDocsU('collection');
|
|
95
|
+
- UPDATE : await Fleetbo.update('collection', id, { price: Number(p) });
|
|
96
|
+
- DELETE : await Fleetbo.delete('collection', id);
|
|
57
97
|
- JOIN : await Fleetbo.join('orders', { innerJoin: { collection: 'users', on: ['userId', '==', 'id'], as: 'user' } });
|
|
58
98
|
- CLOUD FUNCTION : const res = await Fleetbo.call('$functionName', payload);
|
|
59
|
-
|
|
60
|
-
GESTION DE L'ENVIRONNEMENT (.env) :
|
|
61
|
-
- VITE_FLEETBO_PROTOTYPE=true : Mode bac à sable UI. L'Edge acquitte immédiatement sans toucher à la base physique.
|
|
62
|
-
- VITE_FLEETBO_PROTOTYPE=false : Mode strict live. L'Edge valide le contrat DDL et persiste sur MongoDB Atlas.
|
|
63
99
|
`;
|
|
64
100
|
|
|
65
101
|
const server = new Server(
|
|
@@ -117,7 +153,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
117
153
|
{
|
|
118
154
|
name: "fleetbo_create_project",
|
|
119
155
|
description:
|
|
120
|
-
"Étape
|
|
156
|
+
"Étape 0 OBLIGATOIRE du cycle Fleetbo : Alloue instantanément le projet dans le Cloud avec son nom et sa clé unique. RÈGLE STRICTE : Ne concevez AUCUN schéma DDL avant d'appeler cet outil. Le cycle Fleetbo impose de créer le projet vierge ici, d'initialiser en local (Étape 1), de coder directement les composants d'interface UI (Étape 2), puis d'appeler 'fleetbo_update_project' (Étape 3) pour laisser Alex AI inférer la base de données à partir du code UI.",
|
|
121
157
|
inputSchema: {
|
|
122
158
|
type: "object",
|
|
123
159
|
properties: {
|
|
@@ -277,6 +313,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
277
313
|
const proj = json.result?.data || json.data || {};
|
|
278
314
|
const resolvedId = proj.enterpriseId || proj.referenceId || proj.id;
|
|
279
315
|
|
|
316
|
+
// Commande chaînée : init + sync immédiat
|
|
317
|
+
const fullBootstrapCommand = `npx fleetbo-svro init --keyApp=${params.keyApp} --token=${proj.bootstrapToken} && npx fleetbo-svro sync`;
|
|
318
|
+
|
|
280
319
|
return {
|
|
281
320
|
content: [
|
|
282
321
|
{
|
|
@@ -284,16 +323,16 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
284
323
|
text: JSON.stringify(
|
|
285
324
|
{
|
|
286
325
|
status: "SUCCESS",
|
|
287
|
-
message: `Project "${params.name}" successfully created. Ready for modeling.`,
|
|
326
|
+
message: `Project "${params.name}" successfully created. Ready for bootstrap and modeling.`,
|
|
288
327
|
enterpriseID: resolvedId,
|
|
289
328
|
keyApp: params.keyApp,
|
|
290
329
|
bootstrapToken: proj.bootstrapToken,
|
|
291
|
-
commandInit:
|
|
330
|
+
commandInit: fullBootstrapCommand,
|
|
292
331
|
nextSteps: [
|
|
293
|
-
"1. Run commandInit in your terminal to
|
|
294
|
-
"2.
|
|
295
|
-
"3. Call 'fleetbo_update_project' with
|
|
296
|
-
"4. Run 'npx fleetbo-svro sync' to seal Edge and
|
|
332
|
+
"1. Run commandInit in your terminal to bootstrap local env, fetch initial contracts, and generate src/fleetbo.d.ts + Fleetbo_contract.md.",
|
|
333
|
+
"2. Inspect Fleetbo_contract.md and start writing UI views (.jsx/.tsx) using global Fleetbo.* and <fleetbo-*> tags directly.",
|
|
334
|
+
"3. Call 'fleetbo_update_project' with the UI view files to let Alex AI infer schemas and business rules.",
|
|
335
|
+
"4. Run 'npx fleetbo-svro sync' to seal the production Edge and update contracts.",
|
|
297
336
|
],
|
|
298
337
|
},
|
|
299
338
|
null,
|