lindoai-cli 1.4.1 → 1.4.2

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/index.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var lt=require('http'),$=require('fs'),P=require('path'),je=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),Ae=require('cheerio'),url=require('url'),wt=require('crypto'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var lt__namespace=/*#__PURE__*/_interopNamespace(lt);var $__namespace=/*#__PURE__*/_interopNamespace($);var P__namespace=/*#__PURE__*/_interopNamespace(P);var je__namespace=/*#__PURE__*/_interopNamespace(je);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var wt__namespace=/*#__PURE__*/_interopNamespace(wt);var Ot=Object.defineProperty;var Ft=(o,e)=>()=>(o&&(e=o(o=0)),e);var Tt=(o,e)=>{for(var n in e)Ot(o,n,{get:e[n],enumerable:true});};var De={};Tt(De,{LIVE_RELOAD_SCRIPT:()=>Re,injectLiveReload:()=>ct,startLivePreviewServer:()=>mo});function ct(o){let e=/<\/body>/i,n=o.match(e);return n&&n.index!==void 0?o.slice(0,n.index)+Re+o.slice(n.index):o+Re}function mo(o){return new Promise((e,n)=>{let t=P__namespace.resolve(o),i=new Set,r=null,c=100;function a(){for(let m of i)try{m.write(`data: reload
2
+ 'use strict';var lt=require('http'),O=require('fs'),P=require('path'),Re=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),Ae=require('cheerio'),marked=require('marked'),url=require('url'),wt=require('crypto'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var lt__namespace=/*#__PURE__*/_interopNamespace(lt);var O__namespace=/*#__PURE__*/_interopNamespace(O);var P__namespace=/*#__PURE__*/_interopNamespace(P);var Re__namespace=/*#__PURE__*/_interopNamespace(Re);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var wt__namespace=/*#__PURE__*/_interopNamespace(wt);var Ft=Object.defineProperty;var Tt=(o,t)=>()=>(o&&(t=o(o=0)),t);var $t=(o,t)=>{for(var n in t)Ft(o,n,{get:t[n],enumerable:true});};var De={};$t(De,{LIVE_RELOAD_SCRIPT:()=>je,injectLiveReload:()=>ct,startLivePreviewServer:()=>mo});function ct(o){let t=/<\/body>/i,n=o.match(t);return n&&n.index!==void 0?o.slice(0,n.index)+je+o.slice(n.index):o+je}function mo(o){return new Promise((t,n)=>{let e=P__namespace.resolve(o),i=new Set,r=null,c=100;function a(){for(let m of i)try{m.write(`data: reload
3
3
 
4
4
  `);}catch{i.delete(m);}}function d(){r&&clearTimeout(r),r=setTimeout(()=>{a(),r=null;},c);}function p(m,w){let h=m.url||"/";if((m.method||"GET")!=="GET"){w.writeHead(405,{"Content-Type":"text/plain"}),w.end("Method Not Allowed");return}if(h==="/__live-reload"){w.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),w.write(`data: connected
5
5
 
6
- `),i.add(w),m.on("close",()=>{i.delete(w);});return}if(h==="/"||h==="/index.html"){try{let f=$__namespace.readFileSync(t,"utf-8"),k=ct(f);w.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),w.end(k);}catch(f){let k=f instanceof Error?f.message:"Unknown error";w.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),w.end(`<!DOCTYPE html>
6
+ `),i.add(w),m.on("close",()=>{i.delete(w);});return}if(h==="/"||h==="/index.html"){try{let u=O__namespace.readFileSync(e,"utf-8"),k=ct(u);w.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),w.end(k);}catch(u){let k=u instanceof Error?u.message:"Unknown error";w.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),w.end(`<!DOCTYPE html>
7
7
  <html>
8
8
  <head><title>Error</title></head>
9
9
  <body>
@@ -17,7 +17,7 @@
17
17
  <h1>404 Not Found</h1>
18
18
  <p>The requested resource was not found.</p>
19
19
  </body>
20
- </html>`);}let x=lt__namespace.createServer(p),g=null;x.on("error",m=>{n(new Error(`Failed to start preview server: ${m.message}`));}),x.listen(0,"127.0.0.1",()=>{let m=x.address();if(!m||typeof m=="string"){n(new Error("Failed to get server address"));return}let w=m.port;try{g=$__namespace.watch(t,u=>{u==="change"&&d();}),g.on("error",u=>{console.error(`[Live Preview] File watcher error: ${u.message}`);});}catch(u){let f=u instanceof Error?u.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${f}`);}let h=()=>{g&&(g.close(),g=null),r&&(clearTimeout(r),r=null);for(let k of i)try{k.end();}catch{}i.clear();let u=P__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.pid"),f=P__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.port");try{$__namespace.existsSync(u)&&$__namespace.unlinkSync(u);}catch{}try{$__namespace.existsSync(f)&&$__namespace.unlinkSync(f);}catch{}x.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",h),process.on("SIGINT",h),e(w);});})}var Re,Ue=Ft(()=>{Re=`<script>
20
+ </html>`);}let v=lt__namespace.createServer(p),g=null;v.on("error",m=>{n(new Error(`Failed to start preview server: ${m.message}`));}),v.listen(0,"127.0.0.1",()=>{let m=v.address();if(!m||typeof m=="string"){n(new Error("Failed to get server address"));return}let w=m.port;try{g=O__namespace.watch(e,f=>{f==="change"&&d();}),g.on("error",f=>{console.error(`[Live Preview] File watcher error: ${f.message}`);});}catch(f){let u=f instanceof Error?f.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${u}`);}let h=()=>{g&&(g.close(),g=null),r&&(clearTimeout(r),r=null);for(let k of i)try{k.end();}catch{}i.clear();let f=P__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.pid"),u=P__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.port");try{O__namespace.existsSync(f)&&O__namespace.unlinkSync(f);}catch{}try{O__namespace.existsSync(u)&&O__namespace.unlinkSync(u);}catch{}v.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",h),process.on("SIGINT",h),t(w);});})}var je,Ue=Tt(()=>{je=`<script>
21
21
  (function() {
22
22
  var eventSource = new EventSource('/__live-reload');
23
23
  eventSource.onmessage = function(event) {
@@ -29,29 +29,29 @@
29
29
  console.log('[Live Reload] Connection lost, attempting to reconnect...');
30
30
  };
31
31
  })();
32
- </script>`;});var Pt="LINDO_API_KEY",It="LINDO_BASE_URL",At=".lindo",Lt="config.json",Et="https://api.lindo.ai";function Ze(){return P__namespace.join(je__namespace.homedir(),At)}function q(){return P__namespace.join(Ze(),Lt)}function xe(){let o=q();try{if($__namespace.existsSync(o)){let e=$__namespace.readFileSync(o,"utf-8");return JSON.parse(e)}}catch{}return {}}function et(o){let e=Ze(),n=q();$__namespace.existsSync(e)||$__namespace.mkdirSync(e,{recursive:true}),$__namespace.writeFileSync(n,JSON.stringify(o,null,2),"utf-8");}function F(){let o=xe(),e=process.env[Pt]||o.apiKey,n=process.env[It]||o.baseUrl||Et;return {apiKey:e,baseUrl:n}}function tt(o){let e=xe();e.apiKey=o,et(e);}function ot(o,e){let n=xe();switch(o){case "apiKey":n.apiKey=e;break;case "baseUrl":n.baseUrl=e;break;default:throw new Error(`Unknown configuration key: ${o}`)}et(n);}function nt(o){let e=F();switch(o){case "apiKey":return e.apiKey;case "baseUrl":return e.baseUrl;default:return}}function T(){return !!F().apiKey}var B={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function jt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function K(o,e){return jt()?`${e}${o}${B.reset}`:o}function y(o){console.log(K(`\u2713 ${o}`,B.green));}function l(o){console.error(K(`\u2717 ${o}`,B.red));}function s(o){console.log(K(`\u2139 ${o}`,B.blue));}function Rt(o){return JSON.stringify(o,null,2)}function Dt(o){if(o==null)return "";if(Array.isArray(o)){if(o.length===0)return "No data";let e=new Set;for(let t of o)typeof t=="object"&&t!==null&&Object.keys(t).forEach(i=>e.add(i));if(e.size===0)return o.map(t=>String(t)).join(`
33
- `);let n=Array.from(e);return Ut(n,o)}if(typeof o=="object"){let n=Object.entries(o);if(n.length===0)return "No data";let t=Math.max(...n.map(([i])=>i.length));return n.map(([i,r])=>{let c=i.padEnd(t),a=ve(r);return `${K(c,B.cyan)} ${a}`}).join(`
34
- `)}return String(o)}function Ut(o,e){let n={};for(let c of o)n[c]=c.length;for(let c of e)if(typeof c=="object"&&c!==null){let a=c;for(let d of o){let p=ve(a[d]);n[d]=Math.max(n[d],p.length);}}let t=o.map(c=>K(c.padEnd(n[c]),B.bold)).join(" "),i=o.map(c=>"-".repeat(n[c])).join(" "),r=e.map(c=>{if(typeof c=="object"&&c!==null){let a=c;return o.map(d=>ve(a[d]).padEnd(n[d])).join(" ")}return String(c)});return [t,i,...r].join(`
35
- `)}function ve(o){return o==null?K("-",B.gray):typeof o=="boolean"?o?K("true",B.green):K("false",B.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function b(o,e){console.log(e==="json"?Rt(o):Dt(o));}var it=["apiKey","baseUrl"];function Ce(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((e,n)=>{it.includes(e)||(l(`Invalid configuration key: ${e}`),s(`Valid keys: ${it.join(", ")}`),process.exit(1));try{ot(e,n),y(`Configuration saved: ${e}`),s(`Config file: ${q()}`);}catch(t){l(`Failed to save configuration: ${t instanceof Error?t.message:String(t)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((e,n)=>{let t=nt(e);if(t===void 0){n.format==="json"?b({key:e,value:null},n.format):s(`Configuration key '${e}' is not set`);return}if(n.format==="json")b({key:e,value:t},n.format);else {let i=e==="apiKey"?ke(t):t;console.log(`${e}: ${i}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(e=>{let n=F(),t={apiKey:n.apiKey?ke(n.apiKey):"(not set)",baseUrl:n.baseUrl,configFile:q()};e.format==="json"?b({apiKey:n.apiKey?ke(n.apiKey):null,baseUrl:n.baseUrl,configFile:q()},e.format):b(t,e.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(q());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let t=F(),i=new lindoai.LindoClient({apiKey:t.apiKey,baseUrl:t.baseUrl}),r;try{r=JSON.parse(n.input);}catch{l("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${e}`);let c=await i.agents.run({agent_id:e,input:r,stream:n.stream});c.success?(y("Agent run completed"),b(c,n.format)):(l(`Agent run failed: ${c.error||"Unknown error"}`),b(c,n.format),process.exit(1));}catch(c){qt(c);}}),o}function qt(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Se(){let o=new commander.Command("workflows").description("Manage workflows");return o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=te();try{let t=await n.workflows.list({workflow_name:e.name,status:e.status,website_id:e.website,client_id:e.client,limit:parseInt(e.limit)});t.success?b(t.data,e.format):(l("Failed to list workflows"),process.exit(1));}catch(t){oe(t);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=te(),i;try{i=JSON.parse(n.params);}catch{l("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${e}`);let r=await t.workflows.start({workflow_name:e,params:i});r.success?(y(`Workflow started: ${r.instance_id}`),b(r,n.format)):(l("Failed to start workflow"),b(r,n.format),process.exit(1));}catch(r){oe(r);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=te();try{let i=await t.workflows.getStatus(e);b(i,n.format);}catch(i){oe(i);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=te();try{s(`Pausing workflow: ${e}`);let i=await t.workflows.pause(e);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=te();try{s(`Resuming workflow: ${e}`);let i=await t.workflows.resume(e);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=te();try{s(`Terminating workflow: ${e}`);let i=await t.workflows.terminate(e);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o}function te(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function oe(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function $e(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.get();b(t,e.format);}catch(t){U(t);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.getCredits();b(t,e.format);}catch(t){U(t);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.getClientCredits(e.client);b(t,e.format);}catch(t){U(t);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.update({workspace_name:e.name,workspace_language:e.language,webhook_url:e.webhook});t.success&&y("Workspace updated"),b(t,e.format);}catch(t){U(t);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.addTeamMember(e.email,e.role);t.success&&y("Team member added"),b(t,e.format);}catch(t){U(t);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.removeTeamMember(e.member);t.success&&y("Team member removed"),b(t,e.format);}catch(t){U(t);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D(),t;try{t=JSON.parse(e.config);}catch{l("Invalid JSON config"),process.exit(1);}try{let i=await n.workspace.addIntegration({integration_type:e.type,config:t});i.success&&y("Integration added"),b(i,e.format);}catch(i){U(i);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.removeIntegration(e.type);t.success&&y("Integration removed"),b(t,e.format);}catch(t){U(t);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.setupWhitelabel({domain:e.domain,subdomain_domain:e.subdomain,email_sender:e.emailSender,wl_client_register:e.enableRegister?!0:e.disableRegister?!1:void 0});t.success&&y("Whitelabel settings updated"),b(t,e.format);}catch(t){U(t);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=D();try{let t=await n.workspace.updateAppearance({primary_color:e.primary,secondary_color:e.secondary,theme_mode:e.mode});t.success&&y("Appearance settings updated"),b(t,e.format);}catch(t){U(t);}}),o}function D(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function U(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=rt();try{let t=await n.analytics.getWorkspace({from:e.from,to:e.to});b(t,e.format);}catch(t){at(t);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=rt();try{let t=await n.analytics.getWebsite({website_id:e.website,from:e.from,to:e.to});b(t,e.format);}catch(t){at(t);}}),o}function rt(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=le();try{let t=await n.clients.list({page:parseInt(e.page,10),search:e.search});if(e.format==="json")b(t,"json");else if(t.clients&&t.clients.length>0){console.log(`
36
- Clients:`),console.log("--------");for(let i of t.clients)console.log(` ID: ${i.record_id}`),console.log(` Email: ${i.email}`),console.log(` Website Limit: ${i.website_limit??"N/A"}`),console.log(` Suspended: ${i.suspended??!1}`),console.log("");console.log(`Total: ${t.total??t.clients.length}`);}else s("No clients found");}catch(t){ce(t);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=le();try{let t=await n.clients.create({email:e.email,website_limit:parseInt(e.limit,10)});if(t.success&&t.client)y(`Client created: ${t.client.record_id}`),b(t.client,e.format);else if(l("Failed to create client"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){ce(t);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=le();try{let t=await n.clients.update({client_id:e.id,website_limit:e.limit?parseInt(e.limit,10):void 0,suspended:e.suspend?!0:e.unsuspend?!1:void 0});if(t.success)y("Client updated"),t.client&&b(t.client,e.format);else if(l("Failed to update client"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){ce(t);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async e=>{let n=le();try{let t=await n.clients.delete(e.id);if(t.success)y("Client deleted");else if(l("Failed to delete client"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){ce(t);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=le();try{let t=await n.clients.createMagicLink(e.email);if(t.success)y("Magic link created"),b(t,e.format);else if(l("Failed to create magic link"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){ce(t);}}),o}function le(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function ce(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Te(){let o=new commander.Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.list({page:parseInt(e.page,10),search:e.search});if(e.format==="json")b(t,"json");else {let i=t.result?.list??[];if(i.length>0){console.log(`
37
- Websites:`),console.log("---------");for(let r of i)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${t.result?.total??i.length}`);}else s("No websites found");}}catch(t){A(t);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.getDetails(e.id);b(t,e.format);}catch(t){A(t);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.update({website_id:e.id,business_name:e.name,activated:e.activate?!0:e.deactivate?!1:void 0});if(t.success)y("Website updated"),t.website&&b(t.website,e.format);else if(l("Failed to update website"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){A(t);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.updateSettings(e.id,{business_name:e.name,language:e.language,business_description:e.description});t.success&&y("Website settings updated"),b(t,e.format);}catch(t){A(t);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async e=>{let n=I();try{let t=await n.websites.delete(e.id);if(t.success)y("Website deleted");else if(l("Failed to delete website"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){A(t);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async e=>{let n=I();try{let t=await n.websites.assign({website_id:e.website,client_id:e.client});if(t.success)y("Website assigned to client");else if(l("Failed to assign website"),t.errors)for(let i of t.errors)l(` ${i}`);}catch(t){A(t);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.addDomain(e.id,e.domain);if(t.success&&(y("Domain added"),t.result?.dns_records)){console.log(`
38
- DNS Records to configure:`);for(let i of t.result.dns_records)console.log(` ${i.record_type} ${i.host} -> ${i.value}`);}b(t,e.format);}catch(t){A(t);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.removeDomain(e.id);t.success&&y("Domain removed"),b(t,e.format);}catch(t){A(t);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I(),t;try{t=JSON.parse(e.config);}catch{l("Invalid JSON config"),process.exit(1);}try{let i=await n.websites.addIntegration(e.id,{integration_type:e.type,config:t});i.success&&y("Integration added"),b(i,e.format);}catch(i){A(i);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.removeIntegration(e.id,e.type);t.success&&y("Integration removed"),b(t,e.format);}catch(t){A(t);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.addTeamMember(e.id,e.email,e.role);t.success&&y("Team member added"),b(t,e.format);}catch(t){A(t);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=I();try{let t=await n.websites.removeTeamMember(e.id,e.member);t.success&&y("Team member removed"),b(t,e.format);}catch(t){A(t);}}),o}function I(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function A(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function G(o){return new Promise(e=>{let n=je.platform(),t;switch(n){case "darwin":t=`open "${o}"`;break;case "win32":t=`start "" "${o}"`;break;default:t=`xdg-open "${o}"`;break}child_process.exec(t,i=>{e(!i);});})}function so(o){let e=o.filter(t=>!!(t&&t.trim()));return e.length===0?"":`https://fonts.googleapis.com/css2?family=${e.map(t=>`${t.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function de(o){let e=[o.font,o.title_font].filter(Boolean);if(e.length===0)return "";let n=so(e);if(!n)return "";let t=o.font||o.title_font,i=o.title_font||o.font,r=`
32
+ </script>`;});var Pt="LINDO_API_KEY",It="LINDO_BASE_URL",At=".lindo",Lt="config.json",Et="https://api.lindo.ai";function Ze(){return P__namespace.join(Re__namespace.homedir(),At)}function q(){return P__namespace.join(Ze(),Lt)}function xe(){let o=q();try{if(O__namespace.existsSync(o)){let t=O__namespace.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function et(o){let t=Ze(),n=q();O__namespace.existsSync(t)||O__namespace.mkdirSync(t,{recursive:true}),O__namespace.writeFileSync(n,JSON.stringify(o,null,2),"utf-8");}function T(){let o=xe(),t=process.env[Pt]||o.apiKey,n=process.env[It]||o.baseUrl||Et;return {apiKey:t,baseUrl:n}}function tt(o){let t=xe();t.apiKey=o,et(t);}function ot(o,t){let n=xe();switch(o){case "apiKey":n.apiKey=t;break;case "baseUrl":n.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}et(n);}function nt(o){let t=T();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function $(){return !!T().apiKey}var B={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Rt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function K(o,t){return Rt()?`${t}${o}${B.reset}`:o}function y(o){console.log(K(`\u2713 ${o}`,B.green));}function l(o){console.error(K(`\u2717 ${o}`,B.red));}function s(o){console.log(K(`\u2139 ${o}`,B.blue));}function jt(o){return JSON.stringify(o,null,2)}function Dt(o){if(o==null)return "";if(Array.isArray(o)){if(o.length===0)return "No data";let t=new Set;for(let e of o)typeof e=="object"&&e!==null&&Object.keys(e).forEach(i=>t.add(i));if(t.size===0)return o.map(e=>String(e)).join(`
33
+ `);let n=Array.from(t);return Ut(n,o)}if(typeof o=="object"){let n=Object.entries(o);if(n.length===0)return "No data";let e=Math.max(...n.map(([i])=>i.length));return n.map(([i,r])=>{let c=i.padEnd(e),a=ve(r);return `${K(c,B.cyan)} ${a}`}).join(`
34
+ `)}return String(o)}function Ut(o,t){let n={};for(let c of o)n[c]=c.length;for(let c of t)if(typeof c=="object"&&c!==null){let a=c;for(let d of o){let p=ve(a[d]);n[d]=Math.max(n[d],p.length);}}let e=o.map(c=>K(c.padEnd(n[c]),B.bold)).join(" "),i=o.map(c=>"-".repeat(n[c])).join(" "),r=t.map(c=>{if(typeof c=="object"&&c!==null){let a=c;return o.map(d=>ve(a[d]).padEnd(n[d])).join(" ")}return String(c)});return [e,i,...r].join(`
35
+ `)}function ve(o){return o==null?K("-",B.gray):typeof o=="boolean"?o?K("true",B.green):K("false",B.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function b(o,t){console.log(t==="json"?jt(o):Dt(o));}var it=["apiKey","baseUrl"];function Ce(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,n)=>{it.includes(t)||(l(`Invalid configuration key: ${t}`),s(`Valid keys: ${it.join(", ")}`),process.exit(1));try{ot(t,n),y(`Configuration saved: ${t}`),s(`Config file: ${q()}`);}catch(e){l(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,n)=>{let e=nt(t);if(e===void 0){n.format==="json"?b({key:t,value:null},n.format):s(`Configuration key '${t}' is not set`);return}if(n.format==="json")b({key:t,value:e},n.format);else {let i=t==="apiKey"?ke(e):e;console.log(`${t}: ${i}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let n=T(),e={apiKey:n.apiKey?ke(n.apiKey):"(not set)",baseUrl:n.baseUrl,configFile:q()};t.format==="json"?b({apiKey:n.apiKey?ke(n.apiKey):null,baseUrl:n.baseUrl,configFile:q()},t.format):b(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(q());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=T(),i=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(n.input);}catch{l("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let c=await i.agents.run({agent_id:t,input:r,stream:n.stream});c.success?(y("Agent run completed"),b(c,n.format)):(l(`Agent run failed: ${c.error||"Unknown error"}`),b(c,n.format),process.exit(1));}catch(c){qt(c);}}),o}function qt(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Se(){let o=new commander.Command("workflows").description("Manage workflows");return o.command("list").description("List workflow logs").option("-n, --name <name>","Filter by workflow name").option("-s, --status <status>","Filter by status").option("-w, --website <id>","Filter by website ID").option("-c, --client <id>","Filter by client ID").option("-l, --limit <number>","Maximum number of results","50").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=te();try{let e=await n.workflows.list({workflow_name:t.name,status:t.status,website_id:t.website,client_id:t.client,limit:parseInt(t.limit)});e.success?b(e.data,t.format):(l("Failed to list workflows"),process.exit(1));}catch(e){oe(e);}}),o.command("start <workflow-name>").description("Start a workflow").option("-p, --params <json>","Workflow parameters as JSON string","{}").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=te(),i;try{i=JSON.parse(n.params);}catch{l("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${t}`);let r=await e.workflows.start({workflow_name:t,params:i});r.success?(y(`Workflow started: ${r.instance_id}`),b(r,n.format)):(l("Failed to start workflow"),b(r,n.format),process.exit(1));}catch(r){oe(r);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=te();try{let i=await e.workflows.getStatus(t);b(i,n.format);}catch(i){oe(i);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=te();try{s(`Pausing workflow: ${t}`);let i=await e.workflows.pause(t);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=te();try{s(`Resuming workflow: ${t}`);let i=await e.workflows.resume(t);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=te();try{s(`Terminating workflow: ${t}`);let i=await e.workflows.terminate(t);i.success?y(i.message):(l(i.message),process.exit(1)),b(i,n.format);}catch(i){oe(i);}}),o}function te(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function oe(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.get();b(e,t.format);}catch(e){U(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.getCredits();b(e,t.format);}catch(e){U(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.getClientCredits(t.client);b(e,t.format);}catch(e){U(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&y("Workspace updated"),b(e,t.format);}catch(e){U(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.addTeamMember(t.email,t.role);e.success&&y("Team member added"),b(e,t.format);}catch(e){U(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.removeTeamMember(t.member);e.success&&y("Team member removed"),b(e,t.format);}catch(e){U(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D(),e;try{e=JSON.parse(t.config);}catch{l("Invalid JSON config"),process.exit(1);}try{let i=await n.workspace.addIntegration({integration_type:t.type,config:e});i.success&&y("Integration added"),b(i,t.format);}catch(i){U(i);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.removeIntegration(t.type);e.success&&y("Integration removed"),b(e,t.format);}catch(e){U(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&y("Whitelabel settings updated"),b(e,t.format);}catch(e){U(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=D();try{let e=await n.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&y("Appearance settings updated"),b(e,t.format);}catch(e){U(e);}}),o}function D(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function U(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=rt();try{let e=await n.analytics.getWorkspace({from:t.from,to:t.to});b(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=rt();try{let e=await n.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});b(e,t.format);}catch(e){at(e);}}),o}function rt(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Te(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=le();try{let e=await n.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")b(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
36
+ Clients:`),console.log("--------");for(let i of e.clients)console.log(` ID: ${i.record_id}`),console.log(` Email: ${i.email}`),console.log(` Website Limit: ${i.website_limit??"N/A"}`),console.log(` Suspended: ${i.suspended??!1}`),console.log("");console.log(`Total: ${e.total??e.clients.length}`);}else s("No clients found");}catch(e){ce(e);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=le();try{let e=await n.clients.create({email:t.email,website_limit:parseInt(t.limit,10)});if(e.success&&e.client)y(`Client created: ${e.client.record_id}`),b(e.client,t.format);else if(l("Failed to create client"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){ce(e);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=le();try{let e=await n.clients.update({client_id:t.id,website_limit:t.limit?parseInt(t.limit,10):void 0,suspended:t.suspend?!0:t.unsuspend?!1:void 0});if(e.success)y("Client updated"),e.client&&b(e.client,t.format);else if(l("Failed to update client"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){ce(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let n=le();try{let e=await n.clients.delete(t.id);if(e.success)y("Client deleted");else if(l("Failed to delete client"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){ce(e);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=le();try{let e=await n.clients.createMagicLink(t.email);if(e.success)y("Magic link created"),b(e,t.format);else if(l("Failed to create magic link"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){ce(e);}}),o}function le(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function ce(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function $e(){let o=new commander.Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")b(e,"json");else {let i=e.result?.list??[];if(i.length>0){console.log(`
37
+ Websites:`),console.log("---------");for(let r of i)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??i.length}`);}else s("No websites found");}}catch(e){A(e);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.getDetails(t.id);b(e,t.format);}catch(e){A(e);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.update({website_id:t.id,business_name:t.name,activated:t.activate?!0:t.deactivate?!1:void 0});if(e.success)y("Website updated"),e.website&&b(e.website,t.format);else if(l("Failed to update website"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){A(e);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.updateSettings(t.id,{business_name:t.name,language:t.language,business_description:t.description});e.success&&y("Website settings updated"),b(e,t.format);}catch(e){A(e);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async t=>{let n=I();try{let e=await n.websites.delete(t.id);if(e.success)y("Website deleted");else if(l("Failed to delete website"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){A(e);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async t=>{let n=I();try{let e=await n.websites.assign({website_id:t.website,client_id:t.client});if(e.success)y("Website assigned to client");else if(l("Failed to assign website"),e.errors)for(let i of e.errors)l(` ${i}`);}catch(e){A(e);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.addDomain(t.id,t.domain);if(e.success&&(y("Domain added"),e.result?.dns_records)){console.log(`
38
+ DNS Records to configure:`);for(let i of e.result.dns_records)console.log(` ${i.record_type} ${i.host} -> ${i.value}`);}b(e,t.format);}catch(e){A(e);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.removeDomain(t.id);e.success&&y("Domain removed"),b(e,t.format);}catch(e){A(e);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I(),e;try{e=JSON.parse(t.config);}catch{l("Invalid JSON config"),process.exit(1);}try{let i=await n.websites.addIntegration(t.id,{integration_type:t.type,config:e});i.success&&y("Integration added"),b(i,t.format);}catch(i){A(i);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.removeIntegration(t.id,t.type);e.success&&y("Integration removed"),b(e,t.format);}catch(e){A(e);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.addTeamMember(t.id,t.email,t.role);e.success&&y("Team member added"),b(e,t.format);}catch(e){A(e);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.websites.removeTeamMember(t.id,t.member);e.success&&y("Team member removed"),b(e,t.format);}catch(e){A(e);}}),o}function I(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function A(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function G(o){return new Promise(t=>{let n=Re.platform(),e;switch(n){case "darwin":e=`open "${o}"`;break;case "win32":e=`start "" "${o}"`;break;default:e=`xdg-open "${o}"`;break}child_process.exec(e,i=>{t(!i);});})}function so(o){let t=o.filter(e=>!!(e&&e.trim()));return t.length===0?"":`https://fonts.googleapis.com/css2?family=${t.map(e=>`${e.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function de(o){let t=[o.font,o.title_font].filter(Boolean);if(t.length===0)return "";let n=so(t);if(!n)return "";let e=o.font||o.title_font,i=o.title_font||o.font,r=`
39
39
  <style>
40
40
  /* Apply website fonts from theme */
41
41
  body, main, .prose {
42
- font-family: '${t}', system-ui, sans-serif !important;
42
+ font-family: '${e}', system-ui, sans-serif !important;
43
43
  }
44
44
  h1, h2, h3, h4, h5, h6, .font-display, .font-serif {
45
45
  font-family: '${i}', system-ui, serif !important;
46
46
  }
47
47
  </style>`;return `<link rel="preconnect" href="https://fonts.googleapis.com">
48
48
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
49
- <link href="${n}" rel="stylesheet">${r}`}function st(o,e){let n=new RegExp(`<${e}\\b[^>]*>`,"gi"),t,i=null;for(;(t=n.exec(o))!==null;){let S=o.slice(0,t.index);if(lo(S)){i=t;break}}if(!i||i.index===void 0)return {section:void 0,remainingHtml:o};let r=i.index,c=r+i[0].length,a=`</${e}>`,d=o.slice(c),p=new RegExp(`<${e}\\b`,"gi"),x=new RegExp(`</${e}>`,"gi"),g=[],m=[],w;for(;(w=p.exec(d))!==null;)g.push(w.index+c);for(;(w=x.exec(d))!==null;)m.push(w.index+c);let h=[...g.map(S=>({pos:S,type:"open"})),...m.map(S=>({pos:S,type:"close"}))].sort((S,H)=>S.pos-H.pos),u=1,f=-1;for(let S of h)if(S.type==="open")u++;else if(u--,u===0){f=S.pos+a.length;break}if(f===-1)return {section:void 0,remainingHtml:o};let k=o.slice(r,f),v=o.slice(0,r),C=o.slice(f),O=(v+C).replace(/\n\s*\n\s*\n/g,`
49
+ <link href="${n}" rel="stylesheet">${r}`}function st(o,t){let n=new RegExp(`<${t}\\b[^>]*>`,"gi"),e,i=null;for(;(e=n.exec(o))!==null;){let S=o.slice(0,e.index);if(lo(S)){i=e;break}}if(!i||i.index===void 0)return {section:void 0,remainingHtml:o};let r=i.index,c=r+i[0].length,a=`</${t}>`,d=o.slice(c),p=new RegExp(`<${t}\\b`,"gi"),v=new RegExp(`</${t}>`,"gi"),g=[],m=[],w;for(;(w=p.exec(d))!==null;)g.push(w.index+c);for(;(w=v.exec(d))!==null;)m.push(w.index+c);let h=[...g.map(S=>({pos:S,type:"open"})),...m.map(S=>({pos:S,type:"close"}))].sort((S,H)=>S.pos-H.pos),f=1,u=-1;for(let S of h)if(S.type==="open")f++;else if(f--,f===0){u=S.pos+a.length;break}if(u===-1)return {section:void 0,remainingHtml:o};let k=o.slice(r,u),x=o.slice(0,r),C=o.slice(u),F=(x+C).replace(/\n\s*\n\s*\n/g,`
50
50
 
51
- `);return {section:k,remainingHtml:O}}function lo(o){let e=["section","header","footer"],n=0;for(let t of e){let i=new RegExp(`<${t}\\b`,"gi"),r=new RegExp(`</${t}>`,"gi"),c=(o.match(i)||[]).length,a=(o.match(r)||[]).length;n+=c-a;}return n===0}function fe(o){let e=st(o,"header"),n=st(e.remainingHtml,"footer");return {globalHeader:e.section,globalFooter:n.section,mainContent:n.remainingHtml.trim()}}function Pe(o,e,n){let t=[];return e&&e.trim()&&t.push(e.trim()),o.trim()&&t.push(o.trim()),n&&n.trim()&&t.push(n.trim()),t.join(`
52
- `)}function ne(o){return !(!o||o.startsWith("http://")||o.startsWith("https://")||o.startsWith("//")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("#"))}function ge(o){let e=o.toLowerCase().split(".").pop()||"",n=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],t=["mp4","webm","mov","avi","mkv","ogv"],i=["woff","woff2","ttf","otf","eot"];return n.includes(e)?"images":t.includes(e)?"videos":i.includes(e)?"fonts":"documents"}function ie(o){let e=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",bmp:"image/bmp",tiff:"image/tiff",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",ogv:"video/ogg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"}[e]||"application/octet-stream"}function co(o,e){let n=Ae__namespace.load(o),t=[],i=new Set;return n("img[src]").each((r,c)=>{let a=n(c).attr("src");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(e,a);$__namespace.existsSync(d)&&t.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:ge(a),contentType:ie(a)});}}),n("img[srcset]").each((r,c)=>{let a=n(c).attr("srcset");if(a){let d=a.split(",").map(p=>p.trim().split(/\s+/)[0]);for(let p of d)if(p&&ne(p)&&!i.has(p)){i.add(p);let x=P__namespace.resolve(e,p);$__namespace.existsSync(x)&&t.push({originalPath:p,absolutePath:x,fileName:P__namespace.basename(p),mediaType:ge(p),contentType:ie(p)});}}}),n("source[src]").each((r,c)=>{let a=n(c).attr("src");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(e,a);$__namespace.existsSync(d)&&t.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:ge(a),contentType:ie(a)});}}),n("video[poster]").each((r,c)=>{let a=n(c).attr("poster");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(e,a);$__namespace.existsSync(d)&&t.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:"images",contentType:ie(a)});}}),n('[style*="background"]').each((r,c)=>{let d=(n(c).attr("style")||"").match(/url\(['"]?([^'")\s]+)['"]?\)/);if(d&&d[1]){let p=d[1];if(ne(p)&&!i.has(p)){i.add(p);let x=P__namespace.resolve(e,p);$__namespace.existsSync(x)&&t.push({originalPath:p,absolutePath:x,fileName:P__namespace.basename(p),mediaType:ge(p),contentType:ie(p)});}}}),n('link[href][rel*="icon"]').each((r,c)=>{let a=n(c).attr("href");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(e,a);$__namespace.existsSync(d)&&t.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:"images",contentType:ie(a)});}}),t}async function Le(o,e,n,t,i,r){let c=co(o,e);if(c.length===0)return {html:o,uploadedCount:0,failedCount:0,urlMap:new Map,sourceFileUpdated:false};i?.(`Found ${c.length} local asset(s) to upload`);let a=new Map,d=0,p=0,x=10;for(let h=0;h<c.length;h+=x){let u=c.slice(h,h+x),f=u.map(k=>({file_base64:$__namespace.readFileSync(k.absolutePath).toString("base64"),file_name:k.fileName,media_type:k.mediaType,content_type:k.contentType}));try{if(f.length>1&&t.media.uploadBatch){let k=await t.media.uploadBatch(n,{files:f});for(let v=0;v<k.result.uploaded.length;v++){let C=k.result.uploaded[v],O=u[v];C.success?(a.set(O.originalPath,C.url),d++,i?.(`Uploaded: ${O.fileName} \u2192 ${C.url}`)):(p++,i?.(`Failed: ${O.fileName} - ${C.error}`));}}else for(let k=0;k<f.length;k++){let v=f[k],C=u[k];try{let O=await t.media.upload(n,v);a.set(C.originalPath,O.result.url),d++,i?.(`Uploaded: ${C.fileName} \u2192 ${O.result.url}`);}catch(O){p++,i?.(`Failed: ${C.fileName} - ${O instanceof Error?O.message:"Unknown error"}`);}}}catch{for(let v=0;v<f.length;v++){let C=f[v],O=u[v];try{let S=await t.media.upload(n,C);a.set(O.originalPath,S.result.url),d++,i?.(`Uploaded: ${O.fileName} \u2192 ${S.result.url}`);}catch(S){p++,i?.(`Failed: ${O.fileName} - ${S instanceof Error?S.message:"Unknown error"}`);}}}}let g=Ae__namespace.load(o);g("img[src]").each((h,u)=>{let f=g(u).attr("src");f&&a.has(f)&&g(u).attr("src",a.get(f));}),g("img[srcset]").each((h,u)=>{let f=g(u).attr("srcset");if(f){let k=f;for(let[v,C]of a)k=k.replace(new RegExp(Ie(v),"g"),C);g(u).attr("srcset",k);}}),g("source[src]").each((h,u)=>{let f=g(u).attr("src");f&&a.has(f)&&g(u).attr("src",a.get(f));}),g("video[poster]").each((h,u)=>{let f=g(u).attr("poster");f&&a.has(f)&&g(u).attr("poster",a.get(f));}),g('[style*="background"]').each((h,u)=>{let f=g(u).attr("style")||"";for(let[k,v]of a)f=f.replace(new RegExp(Ie(k),"g"),v);g(u).attr("style",f);}),g("link[href]").each((h,u)=>{let f=g(u).attr("href");f&&a.has(f)&&g(u).attr("href",a.get(f));});let m=g.html(),w=false;if(r&&d>0)try{let h=$__namespace.readFileSync(r,"utf-8"),u=h;for(let[f,k]of a)u=u.replace(new RegExp(Ie(f),"g"),k);u!==h&&($__namespace.writeFileSync(r,u,"utf-8"),w=!0,i?.(`Updated source file with CDN URLs: ${r}`));}catch(h){i?.(`Warning: Could not update source file: ${h instanceof Error?h.message:"Unknown error"}`);}return {html:m,uploadedCount:d,failedCount:p,urlMap:a,sourceFileUpdated:w}}function Ie(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ee(o,e){let n,t=o.match(/<main[^>]*>([\s\S]*)<\/main>/i),i=o.match(/<body[^>]*>([\s\S]*)<\/body>/i);t?n=t[1].trim():i?n=i[1].trim():n=o;let r=fe(n),c=r.mainContent,a=o.match(/<title>([^<]*)<\/title>/i),d=a?a[1].trim():e,p="",x="",g=o.match(/<!-- Page Custom Code \(Header\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Header\) -->/i);g&&g[1].trim()&&(p=g[1].trim());let m=o.match(/<!-- Page Custom Code \(Footer\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Footer\) -->/i);m&&m[1].trim()&&(x=m[1].trim());let w=o.match(/<html[^>]*class="([^"]*)"/i),h=w?w[1].includes("dark"):true,u=o.match(/<main[^>]*>/i),f="ltr",k="";if(u){let X=u[0].match(/dir="([^"]*)"/i);X&&(f=X[1]);let Xe=u[0].match(/class="([^"]*)"/i);Xe&&(k=Xe[1]);}let v=!o.includes("motion@latest"),C=o.match(/<meta\s+name="description"\s+content="([^"]*)"/i),O=o.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),S=o.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),H=o.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),R=o.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),be=o.match(/noindex/i),Ve=o.match(/nofollow/i),j={};d&&(j.page_title=d),C&&C[1]&&(j.meta_description=C[1]),O&&O[1]&&(j.social_title=O[1]),S&&S[1]&&(j.social_description=S[1]),H&&H[1]&&(j.social_image=H[1]),R&&R[1]&&(j.canonical_url=R[1]),j.noindex=!!be,j.nofollow=!!Ve;let ye={theme:{mode:h?"Dark":"Light",direction:f,main_classes:k,animations_deactivated:v},should_convert:true},ee=p||x?{}:void 0;return ee&&(p&&(ee.header=p),x&&(ee.footer=x)),{html:c,globalHeader:r.globalHeader,globalFooter:r.globalFooter,templateName:d,headerCode:p||void 0,footerCode:x||void 0,settings:ye,seo:j,customCodes:ee}}var Q=P__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.pid"),pe=P__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.port");function He(){let o=new commander.Command("pages").description("Page management operations");return o.command("list").description("List all pages for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=Y();try{let t=await n.pages.list(e.website,{page:parseInt(e.page,10),search:e.search});if(e.format==="json")b(t,"json");else {let i=t.result;if(i?.list&&i.list.length>0){console.log(`
53
- Pages:`),console.log("------");for(let r of i.list)console.log(` ID: ${r.page_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?"Yes":"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No pages found");}}catch(t){z(t);}}),o.command("get").description("Get details of a specific page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=Y();try{let t=await n.pages.get(e.website,e.id);if(e.format==="json")b(t,"json");else {let i=t.result;i?(console.log(`
54
- Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),console.log(` Name: ${i.name??"N/A"}`),console.log(` Path: ${i.path??"N/A"}`),console.log(` Status: ${i.status??"N/A"}`),console.log(` Published: ${i.publish_date?"Yes":"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):l("Page not found");}}catch(t){z(t);}}),o.command("unpublish").description("Unpublish a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=Y();try{let t=await n.pages.unpublish(e.website,e.id);e.format==="json"?b(t,"json"):t.success?(y("Page unpublished successfully"),console.log(` Page ID: ${t.result?.page_id}`)):l("Failed to unpublish page");}catch(t){z(t);}}),o.command("delete").description("Delete a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=Y();try{let t=await n.pages.deletePage(e.website,e.id);if(e.format==="json")b(t,"json");else if(t.success){if(y("Page deleted successfully"),console.log(` Page ID: ${t.result?.page_id}`),t.result?.warnings&&t.result.warnings.length>0){console.log(" Warnings:");for(let i of t.result.warnings)console.log(` - ${i}`);}}else l("Failed to delete page");}catch(t){z(t);}}),o.command("create-empty").description("Create a new empty page with starter template and live preview").argument("<website_id>","Website ID").argument("<path>","URL path for the page (e.g., /about-us)").option("--title <title>","Page title","New Page").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(e,n,t)=>{let i=Y();try{s("Fetching website details...");let c=(await i.websites.getDetails(e)).result,a=c?.theme||{},d=c?.global_header||null,p=c?.global_footer||null,x=c?.custom_codes||{header:null,footer:null},g={font:a.font,title_font:a.title_font},m=t.title,w=`<!-- Hero Section -->
51
+ `);return {section:k,remainingHtml:F}}function lo(o){let t=["section","header","footer"],n=0;for(let e of t){let i=new RegExp(`<${e}\\b`,"gi"),r=new RegExp(`</${e}>`,"gi"),c=(o.match(i)||[]).length,a=(o.match(r)||[]).length;n+=c-a;}return n===0}function ue(o){let t=st(o,"header"),n=st(t.remainingHtml,"footer");return {globalHeader:t.section,globalFooter:n.section,mainContent:n.remainingHtml.trim()}}function Pe(o,t,n){let e=[];return t&&t.trim()&&e.push(t.trim()),o.trim()&&e.push(o.trim()),n&&n.trim()&&e.push(n.trim()),e.join(`
52
+ `)}function ne(o){return !(!o||o.startsWith("http://")||o.startsWith("https://")||o.startsWith("//")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("#"))}function ge(o){let t=o.toLowerCase().split(".").pop()||"",n=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],e=["mp4","webm","mov","avi","mkv","ogv"],i=["woff","woff2","ttf","otf","eot"];return n.includes(t)?"images":e.includes(t)?"videos":i.includes(t)?"fonts":"documents"}function ie(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",bmp:"image/bmp",tiff:"image/tiff",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",ogv:"video/ogg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"}[t]||"application/octet-stream"}function co(o,t){let n=Ae__namespace.load(o),e=[],i=new Set;return n("img[src]").each((r,c)=>{let a=n(c).attr("src");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:ge(a),contentType:ie(a)});}}),n("img[srcset]").each((r,c)=>{let a=n(c).attr("srcset");if(a){let d=a.split(",").map(p=>p.trim().split(/\s+/)[0]);for(let p of d)if(p&&ne(p)&&!i.has(p)){i.add(p);let v=P__namespace.resolve(t,p);O__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:P__namespace.basename(p),mediaType:ge(p),contentType:ie(p)});}}}),n("source[src]").each((r,c)=>{let a=n(c).attr("src");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:ge(a),contentType:ie(a)});}}),n("video[poster]").each((r,c)=>{let a=n(c).attr("poster");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:"images",contentType:ie(a)});}}),n('[style*="background"]').each((r,c)=>{let d=(n(c).attr("style")||"").match(/url\(['"]?([^'")\s]+)['"]?\)/);if(d&&d[1]){let p=d[1];if(ne(p)&&!i.has(p)){i.add(p);let v=P__namespace.resolve(t,p);O__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:P__namespace.basename(p),mediaType:ge(p),contentType:ie(p)});}}}),n('link[href][rel*="icon"]').each((r,c)=>{let a=n(c).attr("href");if(a&&ne(a)&&!i.has(a)){i.add(a);let d=P__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:P__namespace.basename(a),mediaType:"images",contentType:ie(a)});}}),e}async function Le(o,t,n,e,i,r){let c=co(o,t);if(c.length===0)return {html:o,uploadedCount:0,failedCount:0,urlMap:new Map,sourceFileUpdated:false};i?.(`Found ${c.length} local asset(s) to upload`);let a=new Map,d=0,p=0,v=10;for(let h=0;h<c.length;h+=v){let f=c.slice(h,h+v),u=f.map(k=>({file_base64:O__namespace.readFileSync(k.absolutePath).toString("base64"),file_name:k.fileName,media_type:k.mediaType,content_type:k.contentType}));try{if(u.length>1&&e.media.uploadBatch){let k=await e.media.uploadBatch(n,{files:u});for(let x=0;x<k.result.uploaded.length;x++){let C=k.result.uploaded[x],F=f[x];C.success?(a.set(F.originalPath,C.url),d++,i?.(`Uploaded: ${F.fileName} \u2192 ${C.url}`)):(p++,i?.(`Failed: ${F.fileName} - ${C.error}`));}}else for(let k=0;k<u.length;k++){let x=u[k],C=f[k];try{let F=await e.media.upload(n,x);a.set(C.originalPath,F.result.url),d++,i?.(`Uploaded: ${C.fileName} \u2192 ${F.result.url}`);}catch(F){p++,i?.(`Failed: ${C.fileName} - ${F instanceof Error?F.message:"Unknown error"}`);}}}catch{for(let x=0;x<u.length;x++){let C=u[x],F=f[x];try{let S=await e.media.upload(n,C);a.set(F.originalPath,S.result.url),d++,i?.(`Uploaded: ${F.fileName} \u2192 ${S.result.url}`);}catch(S){p++,i?.(`Failed: ${F.fileName} - ${S instanceof Error?S.message:"Unknown error"}`);}}}}let g=Ae__namespace.load(o);g("img[src]").each((h,f)=>{let u=g(f).attr("src");u&&a.has(u)&&g(f).attr("src",a.get(u));}),g("img[srcset]").each((h,f)=>{let u=g(f).attr("srcset");if(u){let k=u;for(let[x,C]of a)k=k.replace(new RegExp(Ie(x),"g"),C);g(f).attr("srcset",k);}}),g("source[src]").each((h,f)=>{let u=g(f).attr("src");u&&a.has(u)&&g(f).attr("src",a.get(u));}),g("video[poster]").each((h,f)=>{let u=g(f).attr("poster");u&&a.has(u)&&g(f).attr("poster",a.get(u));}),g('[style*="background"]').each((h,f)=>{let u=g(f).attr("style")||"";for(let[k,x]of a)u=u.replace(new RegExp(Ie(k),"g"),x);g(f).attr("style",u);}),g("link[href]").each((h,f)=>{let u=g(f).attr("href");u&&a.has(u)&&g(f).attr("href",a.get(u));});let m=g.html(),w=false;if(r&&d>0)try{let h=O__namespace.readFileSync(r,"utf-8"),f=h;for(let[u,k]of a)f=f.replace(new RegExp(Ie(u),"g"),k);f!==h&&(O__namespace.writeFileSync(r,f,"utf-8"),w=!0,i?.(`Updated source file with CDN URLs: ${r}`));}catch(h){i?.(`Warning: Could not update source file: ${h instanceof Error?h.message:"Unknown error"}`);}return {html:m,uploadedCount:d,failedCount:p,urlMap:a,sourceFileUpdated:w}}function Ie(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ee(o,t){let n,e=o.match(/<main[^>]*>([\s\S]*)<\/main>/i),i=o.match(/<body[^>]*>([\s\S]*)<\/body>/i);e?n=e[1].trim():i?n=i[1].trim():n=o;let r=ue(n),c=r.mainContent,a=o.match(/<title>([^<]*)<\/title>/i),d=a?a[1].trim():t,p="",v="",g=o.match(/<!-- Page Custom Code \(Header\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Header\) -->/i);g&&g[1].trim()&&(p=g[1].trim());let m=o.match(/<!-- Page Custom Code \(Footer\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Footer\) -->/i);m&&m[1].trim()&&(v=m[1].trim());let w=o.match(/<html[^>]*class="([^"]*)"/i),h=w?w[1].includes("dark"):true,f=o.match(/<main[^>]*>/i),u="ltr",k="";if(f){let X=f[0].match(/dir="([^"]*)"/i);X&&(u=X[1]);let Xe=f[0].match(/class="([^"]*)"/i);Xe&&(k=Xe[1]);}let x=!o.includes("motion@latest"),C=o.match(/<meta\s+name="description"\s+content="([^"]*)"/i),F=o.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),S=o.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),H=o.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),j=o.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),be=o.match(/noindex/i),Ve=o.match(/nofollow/i),R={};d&&(R.page_title=d),C&&C[1]&&(R.meta_description=C[1]),F&&F[1]&&(R.social_title=F[1]),S&&S[1]&&(R.social_description=S[1]),H&&H[1]&&(R.social_image=H[1]),j&&j[1]&&(R.canonical_url=j[1]),R.noindex=!!be,R.nofollow=!!Ve;let ye={theme:{mode:h?"Dark":"Light",direction:u,main_classes:k,animations_deactivated:x},should_convert:true},ee=p||v?{}:void 0;return ee&&(p&&(ee.header=p),v&&(ee.footer=v)),{html:c,globalHeader:r.globalHeader,globalFooter:r.globalFooter,templateName:d,headerCode:p||void 0,footerCode:v||void 0,settings:ye,seo:R,customCodes:ee}}var Q=P__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.pid"),pe=P__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.port");function He(){let o=new commander.Command("pages").description("Page management operations");return o.command("list").description("List all pages for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=Y();try{let e=await n.pages.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")b(e,"json");else {let i=e.result;if(i?.list&&i.list.length>0){console.log(`
53
+ Pages:`),console.log("------");for(let r of i.list)console.log(` ID: ${r.page_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?"Yes":"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No pages found");}}catch(e){z(e);}}),o.command("get").description("Get details of a specific page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=Y();try{let e=await n.pages.get(t.website,t.id);if(t.format==="json")b(e,"json");else {let i=e.result;i?(console.log(`
54
+ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),console.log(` Name: ${i.name??"N/A"}`),console.log(` Path: ${i.path??"N/A"}`),console.log(` Status: ${i.status??"N/A"}`),console.log(` Published: ${i.publish_date?"Yes":"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):l("Page not found");}}catch(e){z(e);}}),o.command("unpublish").description("Unpublish a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=Y();try{let e=await n.pages.unpublish(t.website,t.id);t.format==="json"?b(e,"json"):e.success?(y("Page unpublished successfully"),console.log(` Page ID: ${e.result?.page_id}`)):l("Failed to unpublish page");}catch(e){z(e);}}),o.command("delete").description("Delete a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=Y();try{let e=await n.pages.deletePage(t.website,t.id);if(t.format==="json")b(e,"json");else if(e.success){if(y("Page deleted successfully"),console.log(` Page ID: ${e.result?.page_id}`),e.result?.warnings&&e.result.warnings.length>0){console.log(" Warnings:");for(let i of e.result.warnings)console.log(` - ${i}`);}}else l("Failed to delete page");}catch(e){z(e);}}),o.command("create-empty").description("Create a new empty page with starter template and live preview").argument("<website_id>","Website ID").argument("<path>","URL path for the page (e.g., /about-us)").option("--title <title>","Page title","New Page").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(t,n,e)=>{let i=Y();try{s("Fetching website details...");let c=(await i.websites.getDetails(t)).result,a=c?.theme||{},d=c?.global_header||null,p=c?.global_footer||null,v=c?.custom_codes||{header:null,footer:null},g={font:a.font,title_font:a.title_font},m=e.title,w=`<!-- Hero Section -->
55
55
  <section class="relative min-h-[80vh] flex items-center justify-center bg-gradient-to-br from-neutral-50 to-neutral-100 dark:from-neutral-900 dark:to-neutral-800">
56
56
  <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
57
57
  <h1 class="text-4xl sm:text-5xl lg:text-6xl font-bold text-neutral-900 dark:text-white mb-6">
@@ -127,7 +127,7 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
127
127
  Contact Us
128
128
  </a>
129
129
  </div>
130
- </section>`,h={theme:{mode:"Dark",direction:"ltr",main_classes:"bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100",animations_deactivated:!1},should_convert:!0},u={page_title:m,meta_description:"",social_title:m,social_description:"",noindex:!1,nofollow:!1};s("Creating page...");let f=await i.pages.create(e,{html:w,path:n,settings:h,template_name:m,seo:u});f.success||(l("Failed to create page"),process.exit(1));let k=f.result.page_id,v=f.result.published_url;y(`Page created: ${k}`),v&&console.log(` Published URL: ${v}`);let C=de(g),O=Pe(w,d??void 0,p??void 0),S={header:x.header||"",footer:x.footer||""},H=`<!DOCTYPE html>
130
+ </section>`,h={theme:{mode:"Dark",direction:"ltr",main_classes:"bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100",animations_deactivated:!1},should_convert:!0},f={page_title:m,meta_description:"",social_title:m,social_description:"",noindex:!1,nofollow:!1};s("Creating page...");let u=await i.pages.create(t,{html:w,path:n,settings:h,template_name:m,seo:f});u.success||(l("Failed to create page"),process.exit(1));let k=u.result.page_id,x=u.result.published_url;y(`Page created: ${k}`),x&&console.log(` Published URL: ${x}`);let C=de(g),F=Pe(w,d??void 0,p??void 0),S={header:v.header||"",footer:v.footer||""},H=`<!DOCTYPE html>
131
131
  <html class="dark" lang="en">
132
132
  <head>
133
133
  <meta charset="UTF-8">
@@ -164,7 +164,7 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
164
164
  <!-- ========== MAIN CONTENT ========== -->
165
165
  <main dir="ltr" lindo-main-content id="content" role="main" class="bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100">
166
166
 
167
- ${O}
167
+ ${F}
168
168
 
169
169
  </main>
170
170
  <!-- ========== END MAIN CONTENT ========== -->
@@ -176,7 +176,7 @@ ${O}
176
176
  ${S.footer}
177
177
  <!-- End Page Custom Code (Footer) -->
178
178
  </body>
179
- </html>`,R=P__namespace.resolve(t.file);$__namespace.writeFileSync(R,H,"utf-8"),y(`HTML saved to ${R}`),await dt(),t.background?await mt(R):await pt(R),console.log(""),s(`To save changes: lindoai pages update ${e} ${k} --html-file ${t.file}`);}catch(r){z(r);}}),o.command("edit").description("Edit a page with live preview").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(e,n,t)=>{let i=Y();try{s("Fetching page HTML...");let r=await i.pages.getHtml(e,n);r.result||(l("Page not found"),process.exit(1));let c=r.result.html;c||(l("Page has no HTML content"),s("Make sure the page has been created with HTML content"),process.exit(1)),s("Fetching website details...");let d=(await i.websites.getDetails(e)).result,p=d?.theme||{},x=d?.global_header||null,g=d?.global_footer||null,m=d?.custom_codes||{header:null,footer:null},w=r.result.name||"Page",h=r.result.seo||{},u=r.result.settings||{},f=r.result.custom_codes||{},k={header:f.header||m.header||"",footer:f.footer||m.footer||""},v=u.theme||{},C=v.mode!=="Light",O=v.direction||"ltr",S=v.main_classes||"",H=v.animations_deactivated||!1,R={font:v.font||p.font,title_font:v.title_font||p.title_font},be=de(R),j=fe(c).mainContent,ye=Pe(j,x??void 0,g??void 0),ee=`<!DOCTYPE html>
179
+ </html>`,j=P__namespace.resolve(e.file);O__namespace.writeFileSync(j,H,"utf-8"),y(`HTML saved to ${j}`),await dt(),e.background?await mt(j):await pt(j),console.log(""),s(`To save changes: lindoai pages update ${t} ${k} --html-file ${e.file}`);}catch(r){z(r);}}),o.command("edit").description("Edit a page with live preview").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(t,n,e)=>{let i=Y();try{s("Fetching page HTML...");let r=await i.pages.getHtml(t,n);r.result||(l("Page not found"),process.exit(1));let c=r.result.html;c||(l("Page has no HTML content"),s("Make sure the page has been created with HTML content"),process.exit(1)),s("Fetching website details...");let d=(await i.websites.getDetails(t)).result,p=d?.theme||{},v=d?.global_header||null,g=d?.global_footer||null,m=d?.custom_codes||{header:null,footer:null},w=r.result.name||"Page",h=r.result.seo||{},f=r.result.settings||{},u=r.result.custom_codes||{},k={header:u.header||m.header||"",footer:u.footer||m.footer||""},x=f.theme||{},C=x.mode!=="Light",F=x.direction||"ltr",S=x.main_classes||"",H=x.animations_deactivated||!1,j={font:x.font||p.font,title_font:x.title_font||p.title_font},be=de(j),R=ue(c).mainContent,ye=Pe(R,v??void 0,g??void 0),ee=`<!DOCTYPE html>
180
180
  <html class="${C?"dark":""}" lang="en">
181
181
  <head>
182
182
  <meta charset="UTF-8">
@@ -218,7 +218,7 @@ ${O}
218
218
  </head>
219
219
  <body>
220
220
  <!-- ========== MAIN CONTENT ========== -->
221
- <main dir="${O}" lindo-main-content id="content" role="main" class="${S}">
221
+ <main dir="${F}" lindo-main-content id="content" role="main" class="${S}">
222
222
 
223
223
  ${ye}
224
224
 
@@ -232,10 +232,10 @@ ${ye}
232
232
  ${k.footer}
233
233
  <!-- End Page Custom Code (Footer) -->
234
234
  </body>
235
- </html>`,X=P__namespace.resolve(t.file);$__namespace.writeFileSync(X,ee,"utf-8"),y(`HTML saved to ${X}`),await dt(),t.background?await mt(X):await pt(X);}catch(r){z(r);}}),o.command("update").description("Update a page from HTML file (note: global header/footer changes are page-specific only)").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("--upload-assets","Upload local images/assets to CDN before publishing").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=Y();try{t.htmlFile||(l("--html-file option is required"),s("Usage: lindoai pages update <website_id> <page_id> --html-file <path>"),process.exit(1));let r=P__namespace.resolve(t.htmlFile);$__namespace.existsSync(r)||(l(`File not found: ${r}`),process.exit(1));let c=$__namespace.readFileSync(r,"utf-8");if(s(`Read ${c.length} bytes from ${r}`),t.uploadAssets){let m=P__namespace.dirname(r);s("Processing local assets...");let w=await Le(c,m,e,i,h=>s(h),r);w.uploadedCount>0&&(c=w.html,y(`Uploaded ${w.uploadedCount} asset(s) to CDN`),w.failedCount>0&&s(`Warning: ${w.failedCount} asset(s) failed to upload`),w.sourceFileUpdated&&s("Source file updated with CDN URLs (prevents duplicate uploads)"));}let a=Ee(c);a.globalHeader&&s("Detected global header section"),a.globalFooter&&s("Detected global footer section"),a.templateName&&s(`Extracted page title: ${a.templateName}`),a.headerCode&&s("Extracted header custom code"),a.footerCode&&s("Extracted footer custom code"),Object.keys(a.seo).length>2&&s("Extracted SEO metadata");let d=await i.pages.get(e,n);d.result||(l("Page not found"),process.exit(1));let p=d.result.path,x={...d.result.settings||{},theme:{...d.result.settings?.theme||{},...a.settings.theme},should_convert:!0};s("Updating page...");let g=await i.pages.publish(e,n,{html:a.html,path:p,settings:x,template_name:a.templateName,custom_codes:a.customCodes,seo:Object.keys(a.seo).length>0?a.seo:void 0,global_header:a.globalHeader,global_footer:a.globalFooter});t.format==="json"?b(g,"json"):g.success?(y("Page updated successfully"),console.log(` Page ID: ${g.result?.page_id}`),g.result?.published_url&&console.log(` Published URL: ${g.result.published_url}`)):l("Failed to update page");}catch(r){z(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!$__namespace.existsSync(Q)){s("No preview server is running");return}let e=parseInt($__namespace.readFileSync(Q,"utf-8").trim(),10);if(isNaN(e)){l("Invalid PID file"),Ne();return}try{process.kill(e,"SIGTERM"),y(`Preview server (PID ${e}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):l(`Failed to stop preview server: ${n.message}`);}Ne();}catch(e){e instanceof Error?l(e.message):l("An unexpected error occurred"),process.exit(1);}}),o.command("create-with-content").description("Create pages from HTML files in a local folder with automatic asset upload").argument("<website_id>","Website ID").argument("<folder>","Path to folder containing HTML files").option("--path-prefix <prefix>","URL path prefix for pages (e.g., /blog)","").option("--dry-run","Show what would be created without actually creating").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=Y();try{let r=P__namespace.resolve(n);$__namespace.existsSync(r)||(l(`Folder not found: ${r}`),process.exit(1)),$__namespace.statSync(r).isDirectory()||(l(`Not a directory: ${r}`),process.exit(1));let d=$__namespace.readdirSync(r).filter(m=>m.endsWith(".html"));if(d.length===0&&(l("No HTML files found in folder"),process.exit(1)),s(`Found ${d.length} HTML file(s) to create`),t.dryRun){console.log(`
236
- Dry run - would create:`);for(let m of d){let w=m==="index.html"?t.pathPrefix||"/":`${t.pathPrefix}/${m.replace(".html","")}`;console.log(` ${m} \u2192 ${w}`);}return}let p=[];for(let m of d){let w=P__namespace.join(r,m),h=$__namespace.readFileSync(w,"utf-8");s(`
237
- Processing: ${m}`),s("Uploading local assets...");let u=await Le(h,r,e,i,v=>s(` ${v}`));u.uploadedCount>0&&(h=u.html,y(` Uploaded ${u.uploadedCount} asset(s)`));let f=Ee(h,m.replace(".html",""));f.globalHeader&&s(" Detected global header section"),f.globalFooter&&s(" Detected global footer section"),f.templateName&&s(` Extracted page title: ${f.templateName}`),f.headerCode&&s(" Extracted header custom code"),f.footerCode&&s(" Extracted footer custom code"),Object.keys(f.seo).length>2&&s(" Extracted SEO metadata");let k=m==="index.html"?t.pathPrefix||"/":`${t.pathPrefix}/${m.replace(".html","")}`;try{s(` Creating page at ${k}...`);let v=await i.pages.create(e,{html:f.html,path:k,template_name:f.templateName,seo:Object.keys(f.seo).length>0?f.seo:void 0,settings:f.settings,custom_codes:f.customCodes,global_header:f.globalHeader,global_footer:f.globalFooter});if(v.success){let C=v.result.published_url;y(` Created: ${m} \u2192 ${k} (${v.result.page_id})`),C&&console.log(` URL: ${C}`),p.push({file:m,pageId:v.result.page_id,success:!0});}else l(` Failed to create: ${m}`),p.push({file:m,success:!1,error:"API returned failure"});}catch(v){let C=v instanceof Error?v.message:"Unknown error";l(` Failed to create: ${m} - ${C}`),p.push({file:m,success:!1,error:C});}}console.log(`
238
- --- Summary ---`);let x=p.filter(m=>m.success).length,g=p.filter(m=>!m.success).length;if(t.format==="json")b({results:p,successCount:x,failCount:g},"json");else if(console.log(`Created: ${x}/${p.length} pages`),g>0){console.log(`Failed: ${g} pages`);for(let m of p.filter(w=>!w.success))console.log(` - ${m.file}: ${m.error}`);}}catch(r){z(r);}}),o}function Y(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function z(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Ne(){try{$__namespace.existsSync(Q)&&$__namespace.unlinkSync(Q);}catch{}try{$__namespace.existsSync(pe)&&$__namespace.unlinkSync(pe);}catch{}}async function dt(){if($__namespace.existsSync(Q)){try{let o=parseInt($__namespace.readFileSync(Q,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),s(`Terminated existing preview server (PID ${o})`),await new Promise(e=>setTimeout(e,500));}catch{}}catch{}Ne();}}async function mt(o){let e=P__namespace.resolve(o),n=`
235
+ </html>`,X=P__namespace.resolve(e.file);O__namespace.writeFileSync(X,ee,"utf-8"),y(`HTML saved to ${X}`),await dt(),e.background?await mt(X):await pt(X);}catch(r){z(r);}}),o.command("update").description("Update a page from HTML file (note: global header/footer changes are page-specific only)").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("--upload-assets","Upload local images/assets to CDN before publishing").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=Y();try{e.htmlFile||(l("--html-file option is required"),s("Usage: lindoai pages update <website_id> <page_id> --html-file <path>"),process.exit(1));let r=P__namespace.resolve(e.htmlFile);O__namespace.existsSync(r)||(l(`File not found: ${r}`),process.exit(1));let c=O__namespace.readFileSync(r,"utf-8");if(s(`Read ${c.length} bytes from ${r}`),e.uploadAssets){let m=P__namespace.dirname(r);s("Processing local assets...");let w=await Le(c,m,t,i,h=>s(h),r);w.uploadedCount>0&&(c=w.html,y(`Uploaded ${w.uploadedCount} asset(s) to CDN`),w.failedCount>0&&s(`Warning: ${w.failedCount} asset(s) failed to upload`),w.sourceFileUpdated&&s("Source file updated with CDN URLs (prevents duplicate uploads)"));}let a=Ee(c);a.globalHeader&&s("Detected global header section"),a.globalFooter&&s("Detected global footer section"),a.templateName&&s(`Extracted page title: ${a.templateName}`),a.headerCode&&s("Extracted header custom code"),a.footerCode&&s("Extracted footer custom code"),Object.keys(a.seo).length>2&&s("Extracted SEO metadata");let d=await i.pages.get(t,n);d.result||(l("Page not found"),process.exit(1));let p=d.result.path,v={...d.result.settings||{},theme:{...d.result.settings?.theme||{},...a.settings.theme},should_convert:!0};s("Updating page...");let g=await i.pages.publish(t,n,{html:a.html,path:p,settings:v,template_name:a.templateName,custom_codes:a.customCodes,seo:Object.keys(a.seo).length>0?a.seo:void 0,global_header:a.globalHeader,global_footer:a.globalFooter});e.format==="json"?b(g,"json"):g.success?(y("Page updated successfully"),console.log(` Page ID: ${g.result?.page_id}`),g.result?.published_url&&console.log(` Published URL: ${g.result.published_url}`)):l("Failed to update page");}catch(r){z(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!O__namespace.existsSync(Q)){s("No preview server is running");return}let t=parseInt(O__namespace.readFileSync(Q,"utf-8").trim(),10);if(isNaN(t)){l("Invalid PID file"),Ne();return}try{process.kill(t,"SIGTERM"),y(`Preview server (PID ${t}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):l(`Failed to stop preview server: ${n.message}`);}Ne();}catch(t){t instanceof Error?l(t.message):l("An unexpected error occurred"),process.exit(1);}}),o.command("create-with-content").description("Create pages from HTML files in a local folder with automatic asset upload").argument("<website_id>","Website ID").argument("<folder>","Path to folder containing HTML files").option("--path-prefix <prefix>","URL path prefix for pages (e.g., /blog)","").option("--dry-run","Show what would be created without actually creating").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=Y();try{let r=P__namespace.resolve(n);O__namespace.existsSync(r)||(l(`Folder not found: ${r}`),process.exit(1)),O__namespace.statSync(r).isDirectory()||(l(`Not a directory: ${r}`),process.exit(1));let d=O__namespace.readdirSync(r).filter(m=>m.endsWith(".html"));if(d.length===0&&(l("No HTML files found in folder"),process.exit(1)),s(`Found ${d.length} HTML file(s) to create`),e.dryRun){console.log(`
236
+ Dry run - would create:`);for(let m of d){let w=m==="index.html"?e.pathPrefix||"/":`${e.pathPrefix}/${m.replace(".html","")}`;console.log(` ${m} \u2192 ${w}`);}return}let p=[];for(let m of d){let w=P__namespace.join(r,m),h=O__namespace.readFileSync(w,"utf-8");s(`
237
+ Processing: ${m}`),s("Uploading local assets...");let f=await Le(h,r,t,i,x=>s(` ${x}`));f.uploadedCount>0&&(h=f.html,y(` Uploaded ${f.uploadedCount} asset(s)`));let u=Ee(h,m.replace(".html",""));u.globalHeader&&s(" Detected global header section"),u.globalFooter&&s(" Detected global footer section"),u.templateName&&s(` Extracted page title: ${u.templateName}`),u.headerCode&&s(" Extracted header custom code"),u.footerCode&&s(" Extracted footer custom code"),Object.keys(u.seo).length>2&&s(" Extracted SEO metadata");let k=m==="index.html"?e.pathPrefix||"/":`${e.pathPrefix}/${m.replace(".html","")}`;try{s(` Creating page at ${k}...`);let x=await i.pages.create(t,{html:u.html,path:k,template_name:u.templateName,seo:Object.keys(u.seo).length>0?u.seo:void 0,settings:u.settings,custom_codes:u.customCodes,global_header:u.globalHeader,global_footer:u.globalFooter});if(x.success){let C=x.result.published_url;y(` Created: ${m} \u2192 ${k} (${x.result.page_id})`),C&&console.log(` URL: ${C}`),p.push({file:m,pageId:x.result.page_id,success:!0});}else l(` Failed to create: ${m}`),p.push({file:m,success:!1,error:"API returned failure"});}catch(x){let C=x instanceof Error?x.message:"Unknown error";l(` Failed to create: ${m} - ${C}`),p.push({file:m,success:!1,error:C});}}console.log(`
238
+ --- Summary ---`);let v=p.filter(m=>m.success).length,g=p.filter(m=>!m.success).length;if(e.format==="json")b({results:p,successCount:v,failCount:g},"json");else if(console.log(`Created: ${v}/${p.length} pages`),g>0){console.log(`Failed: ${g} pages`);for(let m of p.filter(w=>!w.success))console.log(` - ${m.file}: ${m.error}`);}}catch(r){z(r);}}),o}function Y(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function z(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function Ne(){try{O__namespace.existsSync(Q)&&O__namespace.unlinkSync(Q);}catch{}try{O__namespace.existsSync(pe)&&O__namespace.unlinkSync(pe);}catch{}}async function dt(){if(O__namespace.existsSync(Q)){try{let o=parseInt(O__namespace.readFileSync(Q,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),s(`Terminated existing preview server (PID ${o})`),await new Promise(t=>setTimeout(t,500));}catch{}}catch{}Ne();}}async function mt(o){let t=P__namespace.resolve(o),n=`
239
239
  const http = require('node:http');
240
240
  const fs = require('node:fs');
241
241
  const path = require('node:path');
@@ -255,7 +255,7 @@ Processing: ${m}`),s("Uploading local assets...");let u=await Le(h,r,e,i,v=>s(`
255
255
  })();
256
256
  </script>\`;
257
257
 
258
- const filePath = ${JSON.stringify(e)};
258
+ const filePath = ${JSON.stringify(t)};
259
259
  const pidFile = path.join(os.tmpdir(), 'lindoai-pages-preview.pid');
260
260
  const portFile = path.join(os.tmpdir(), 'lindoai-pages-preview.port');
261
261
  const sseClients = new Set();
@@ -355,9 +355,9 @@ Processing: ${m}`),s("Uploading local assets...");let u=await Le(h,r,e,i,v=>s(`
355
355
  });
356
356
  } catch {}
357
357
  });
358
- `,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),$__namespace.existsSync(pe))try{if(i=parseInt($__namespace.readFileSync(pe,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(l("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${i}/`;await G(r)||s(`Could not open browser. Visit: ${r}`),y("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${t.pid}`),console.log(""),s("To update the page: lindoai pages update <website_id> <page_id> --html-file <path>"),s("To stop the server: lindoai pages stop-preview");}async function pt(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Ue(),De));s("Starting preview server...");let n=await e(o),t=`http://127.0.0.1:${n}/`;$__namespace.writeFileSync(Q,process.pid.toString(),"utf-8"),$__namespace.writeFileSync(pe,n.toString(),"utf-8"),await G(t)||s(`Could not open browser. Visit: ${t}`),y("Preview server started"),console.log(` URL: ${t}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}var Z=P__namespace.join(je__namespace.tmpdir(),"lindoai-blogs-preview.pid"),ue=P__namespace.join(je__namespace.tmpdir(),"lindoai-blogs-preview.port");function Be(){let o=new commander.Command("blogs").description("Blog management operations");return o.command("list").description("List all blogs for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=J();try{let t=await n.blogs.list(e.website,{page:parseInt(e.page,10),search:e.search});if(e.format==="json")b(t,"json");else {let i=t.result;if(i?.list&&i.list.length>0){console.log(`
359
- Blogs:`),console.log("------");for(let r of i.list)console.log(` ID: ${r.blog_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?new Date(r.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No blogs found");}}catch(t){V(t);}}),o.command("get").description("Get details of a specific blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=J();try{let t=await n.blogs.get(e.website,e.id);if(e.format==="json")b(t,"json");else {let i=t.result;i?(console.log(`
360
- Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),console.log(` Name: ${i.name??"N/A"}`),console.log(` Path: ${i.path??"N/A"}`),console.log(` Status: ${i.status??"N/A"}`),console.log(` Published: ${i.publish_date?new Date(i.publish_date*1e3).toISOString():"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):l("Blog not found");}}catch(t){V(t);}}),o.command("publish").description("Publish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=J();try{let t=await n.blogs.publish(e.website,e.id);e.format==="json"?b(t,"json"):t.success?(y("Blog published successfully"),console.log(` Blog ID: ${t.result?.blog_id}`),console.log(` Published at: ${t.result?.publish_date?new Date(t.result.publish_date*1e3).toISOString():"N/A"}`),t.result?.published_url&&console.log(` Published URL: ${t.result.published_url}`)):l("Failed to publish blog");}catch(t){V(t);}}),o.command("unpublish").description("Unpublish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=J();try{let t=await n.blogs.unpublish(e.website,e.id);e.format==="json"?b(t,"json"):t.success?(y("Blog unpublished successfully"),console.log(` Blog ID: ${t.result?.blog_id}`)):l("Failed to unpublish blog");}catch(t){V(t);}}),o.command("delete").description("Delete a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=J();try{let t=await n.blogs.delete(e.website,e.id);if(e.format==="json")b(t,"json");else if(t.success){if(y("Blog deleted successfully"),console.log(` Blog ID: ${t.result?.blog_id}`),t.result?.warnings&&t.result.warnings.length>0){console.log(" Warnings:");for(let i of t.result.warnings)console.log(` - ${i}`);}}else l("Failed to delete blog");}catch(t){V(t);}}),o.command("edit").description("Edit a blog with live preview").argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--file <path>","Output file path","./blog.html").option("--background","Run preview server in background").action(async(e,n,t)=>{let i=J();try{s("Fetching blog content...");let r=await i.blogs.getHtml(e,n);r.result||(l("Blog not found"),process.exit(1));let c=r.result,a=await i.websites.getDetails(e);a.result||(l("Website not found"),process.exit(1));let d=a.result,p=d,x=p?.theme||{},g=p?.custom_codes||{header:null,footer:null},m={font:x.font,title_font:x.title_font},w=c.seo||{},h=c.blog_settings||{},u=c.blog_content||"<p>Start writing your blog content here...</p>",f=_o({seo:w,blogSettings:h,blogContent:u,websiteName:d.business_name||"Blog",blogPath:x.blog_path||"blog",websiteTheme:m,customCodes:{header:g.header||void 0,footer:g.footer||void 0}}),k=P__namespace.resolve(t.file);$__namespace.writeFileSync(k,f,"utf-8"),y(`HTML saved to ${k}`),await xo(),t.background?await vo(k):await ko(k),console.log(""),s(`To save changes: lindoai blogs update ${e} ${n} --html-file ${t.file}`);}catch(r){V(r);}}),o.command("update").description(`Update and publish a blog post.
358
+ `,e=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});e.unref();let i=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),O__namespace.existsSync(pe))try{if(i=parseInt(O__namespace.readFileSync(pe,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(l("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${i}/`;await G(r)||s(`Could not open browser. Visit: ${r}`),y("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),s("To update the page: lindoai pages update <website_id> <page_id> --html-file <path>"),s("To stop the server: lindoai pages stop-preview");}async function pt(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ue(),De));s("Starting preview server...");let n=await t(o),e=`http://127.0.0.1:${n}/`;O__namespace.writeFileSync(Q,process.pid.toString(),"utf-8"),O__namespace.writeFileSync(pe,n.toString(),"utf-8"),await G(e)||s(`Could not open browser. Visit: ${e}`),y("Preview server started"),console.log(` URL: ${e}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}var Z=P__namespace.join(Re__namespace.tmpdir(),"lindoai-blogs-preview.pid"),fe=P__namespace.join(Re__namespace.tmpdir(),"lindoai-blogs-preview.port");function Be(){let o=new commander.Command("blogs").description("Blog management operations");return o.command("list").description("List all blogs for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=J();try{let e=await n.blogs.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")b(e,"json");else {let i=e.result;if(i?.list&&i.list.length>0){console.log(`
359
+ Blogs:`),console.log("------");for(let r of i.list)console.log(` ID: ${r.blog_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?new Date(r.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No blogs found");}}catch(e){V(e);}}),o.command("get").description("Get details of a specific blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=J();try{let e=await n.blogs.get(t.website,t.id);if(t.format==="json")b(e,"json");else {let i=e.result;i?(console.log(`
360
+ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),console.log(` Name: ${i.name??"N/A"}`),console.log(` Path: ${i.path??"N/A"}`),console.log(` Status: ${i.status??"N/A"}`),console.log(` Published: ${i.publish_date?new Date(i.publish_date*1e3).toISOString():"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):l("Blog not found");}}catch(e){V(e);}}),o.command("publish").description("Publish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=J();try{let e=await n.blogs.publish(t.website,t.id);t.format==="json"?b(e,"json"):e.success?(y("Blog published successfully"),console.log(` Blog ID: ${e.result?.blog_id}`),console.log(` Published at: ${e.result?.publish_date?new Date(e.result.publish_date*1e3).toISOString():"N/A"}`),e.result?.published_url&&console.log(` Published URL: ${e.result.published_url}`)):l("Failed to publish blog");}catch(e){V(e);}}),o.command("unpublish").description("Unpublish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=J();try{let e=await n.blogs.unpublish(t.website,t.id);t.format==="json"?b(e,"json"):e.success?(y("Blog unpublished successfully"),console.log(` Blog ID: ${e.result?.blog_id}`)):l("Failed to unpublish blog");}catch(e){V(e);}}),o.command("delete").description("Delete a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=J();try{let e=await n.blogs.delete(t.website,t.id);if(t.format==="json")b(e,"json");else if(e.success){if(y("Blog deleted successfully"),console.log(` Blog ID: ${e.result?.blog_id}`),e.result?.warnings&&e.result.warnings.length>0){console.log(" Warnings:");for(let i of e.result.warnings)console.log(` - ${i}`);}}else l("Failed to delete blog");}catch(e){V(e);}}),o.command("edit").description("Edit a blog with live preview").argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--file <path>","Output file path","./blog.html").option("--background","Run preview server in background").action(async(t,n,e)=>{let i=J();try{s("Fetching blog content...");let r=await i.blogs.getHtml(t,n);r.result||(l("Blog not found"),process.exit(1));let c=r.result,a=await i.websites.getDetails(t);a.result||(l("Website not found"),process.exit(1));let d=a.result,p=d,v=p?.theme||{},g=p?.custom_codes||{header:null,footer:null},m={font:v.font,title_font:v.title_font},w=c.seo||{},h=c.blog_settings||{},f=c.blog_content||"<p>Start writing your blog content here...</p>",u=So({seo:w,blogSettings:h,blogContent:f,websiteName:d.business_name||"Blog",blogPath:v.blog_path||"blog",websiteTheme:m,customCodes:{header:g.header||void 0,footer:g.footer||void 0}}),k=P__namespace.resolve(e.file);O__namespace.writeFileSync(k,u,"utf-8"),y(`HTML saved to ${k}`),await vo(),e.background?await ko(k):await Co(k),console.log(""),s(`To save changes: lindoai blogs update ${t} ${n} --html-file ${e.file}`);}catch(r){V(r);}}),o.command("update").description(`Update and publish a blog post.
361
361
 
362
362
  Content can be provided as Markdown (--md-file) or raw HTML (--html-file).
363
363
  Markdown files support frontmatter for metadata, but CLI flags always take priority.
@@ -387,7 +387,7 @@ Markdown frontmatter format:
387
387
  category: Tech
388
388
  date: January 15, 2025
389
389
  ---
390
- Your markdown content here...`).argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=J();try{!t.mdFile&&!t.htmlFile&&(l("Either --md-file or --html-file is required"),s("Usage: lindoai blogs update <website_id> <blog_id> --md-file <path> [options]"),process.exit(1));let r,c={},a={};if(t.mdFile){let u=P__namespace.resolve(t.mdFile);$__namespace.existsSync(u)||(l(`File not found: ${u}`),process.exit(1));let f=$__namespace.readFileSync(u,"utf-8");s(`Read ${f.length} bytes from ${u}`);let{content:k,frontmatter:v}=ut(f);r=ft(k),v.title&&(c.page_title=v.title),v.description&&(c.meta_description=v.description),v.image&&(c.social_image=v.image),v.author&&(a.author=v.author),v.excerpt&&(a.excerpt=v.excerpt),v.category&&(a.category=v.category),v.date&&(a.publish_date=v.date);}else {let u=P__namespace.resolve(t.htmlFile);$__namespace.existsSync(u)||(l(`File not found: ${u}`),process.exit(1)),r=$__namespace.readFileSync(u,"utf-8"),s(`Read ${r.length} bytes from ${u}`);}t.title&&(c.page_title=t.title),t.description&&(c.meta_description=t.description),t.socialImage&&(c.social_image=t.socialImage),t.author&&(a.author=t.author),t.excerpt&&(a.excerpt=t.excerpt),t.category&&(a.category=t.category),t.date&&(a.publish_date=t.date),t.readTime&&(a.read_time=t.readTime);let d=await i.blogs.get(e,n);d.result||(l("Blog not found"),process.exit(1));let p=d.result,x=p.path,g={page_title:c.page_title||p.seo?.page_title,meta_description:c.meta_description||p.seo?.meta_description,social_title:c.page_title||p.seo?.social_title,social_description:c.meta_description||p.seo?.social_description,social_image:c.social_image||p.seo?.social_image},m={author:a.author||p.blog_settings?.author,excerpt:a.excerpt||p.blog_settings?.excerpt,category:a.category||p.blog_settings?.category,publish_date:a.publish_date||p.blog_settings?.publish_date,read_time:a.read_time||p.blog_settings?.read_time,author_image:a.author_image||p.blog_settings?.author_image},w=[];g.page_title||w.push("--title"),g.social_image||w.push("--social-image"),m.author||w.push("--author"),m.excerpt||w.push("--excerpt"),m.category||w.push("--category"),w.length>0&&(l(`Missing required fields: ${w.join(", ")}`),s("These can be set via CLI flags or Markdown frontmatter."),s("If the blog already has these values, they will be preserved."),process.exit(1)),s("Updating blog...");let h=await i.blogs.publish(e,n,{path:x,blog_content:r,seo:g,blog_settings:m});t.format==="json"?b(h,"json"):h.success?(y("Blog updated successfully"),console.log(` Blog ID: ${h.result?.blog_id}`),h.result?.published_url&&console.log(` Published URL: ${h.result.published_url}`)):l("Failed to update blog");}catch(r){V(r);}}),o.command("create").description(`Create and publish a new blog post.
390
+ Your markdown content here...`).argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=J();try{!e.mdFile&&!e.htmlFile&&(l("Either --md-file or --html-file is required"),s("Usage: lindoai blogs update <website_id> <blog_id> --md-file <path> [options]"),process.exit(1));let r,c={},a={};if(e.mdFile){let f=P__namespace.resolve(e.mdFile);O__namespace.existsSync(f)||(l(`File not found: ${f}`),process.exit(1));let u=O__namespace.readFileSync(f,"utf-8");s(`Read ${u.length} bytes from ${f}`);let{content:k,frontmatter:x}=ft(u);r=ut(k),x.title&&(c.page_title=x.title),x.description&&(c.meta_description=x.description),x.image&&(c.social_image=x.image),x.author&&(a.author=x.author),x.excerpt&&(a.excerpt=x.excerpt),x.category&&(a.category=x.category),x.date&&(a.publish_date=x.date);}else {let f=P__namespace.resolve(e.htmlFile);O__namespace.existsSync(f)||(l(`File not found: ${f}`),process.exit(1)),r=O__namespace.readFileSync(f,"utf-8"),s(`Read ${r.length} bytes from ${f}`);}e.title&&(c.page_title=e.title),e.description&&(c.meta_description=e.description),e.socialImage&&(c.social_image=e.socialImage),e.author&&(a.author=e.author),e.excerpt&&(a.excerpt=e.excerpt),e.category&&(a.category=e.category),e.date&&(a.publish_date=e.date),e.readTime&&(a.read_time=e.readTime);let d=await i.blogs.get(t,n);d.result||(l("Blog not found"),process.exit(1));let p=d.result,v=p.path,g={page_title:c.page_title||p.seo?.page_title,meta_description:c.meta_description||p.seo?.meta_description,social_title:c.page_title||p.seo?.social_title,social_description:c.meta_description||p.seo?.social_description,social_image:c.social_image||p.seo?.social_image},m={author:a.author||p.blog_settings?.author,excerpt:a.excerpt||p.blog_settings?.excerpt,category:a.category||p.blog_settings?.category,publish_date:a.publish_date||p.blog_settings?.publish_date,read_time:a.read_time||p.blog_settings?.read_time,author_image:a.author_image||p.blog_settings?.author_image},w=[];g.page_title||w.push("--title"),g.social_image||w.push("--social-image"),m.author||w.push("--author"),m.excerpt||w.push("--excerpt"),m.category||w.push("--category"),w.length>0&&(l(`Missing required fields: ${w.join(", ")}`),s("These can be set via CLI flags or Markdown frontmatter."),s("If the blog already has these values, they will be preserved."),process.exit(1)),s("Updating blog...");let h=await i.blogs.publish(t,n,{path:v,blog_content:r,seo:g,blog_settings:m});e.format==="json"?b(h,"json"):h.success?(y("Blog updated successfully"),console.log(` Blog ID: ${h.result?.blog_id}`),h.result?.published_url&&console.log(` Published URL: ${h.result.published_url}`)):l("Failed to update blog");}catch(r){V(r);}}),o.command("create").description(`Create and publish a new blog post.
391
391
 
392
392
  Content can be provided as Markdown (--md-file) or raw HTML (--html-file).
393
393
  Markdown is converted to HTML before publishing. Frontmatter is supported for metadata.
@@ -419,7 +419,7 @@ Markdown frontmatter format:
419
419
  category: Tech
420
420
  date: January 15, 2025
421
421
  ---
422
- Your markdown content here...`).argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=J();try{!t.mdFile&&!t.htmlFile&&(l("Either --md-file or --html-file is required"),s("Usage: lindoai blogs create <website_id> <path> --md-file <path> [options]"),process.exit(1));let r,c={},a={};if(t.mdFile){let m=P__namespace.resolve(t.mdFile);$__namespace.existsSync(m)||(l(`File not found: ${m}`),process.exit(1));let w=$__namespace.readFileSync(m,"utf-8");s(`Read ${w.length} bytes from ${m}`);let{content:h,frontmatter:u}=ut(w);r=ft(h),u.title&&(c.page_title=u.title),u.description&&(c.meta_description=u.description),u.image&&(c.social_image=u.image),u.author&&(a.author=u.author),u.excerpt&&(a.excerpt=u.excerpt),u.category&&(a.category=u.category),u.date&&(a.publish_date=u.date);}else {let m=P__namespace.resolve(t.htmlFile);$__namespace.existsSync(m)||(l(`File not found: ${m}`),process.exit(1)),r=$__namespace.readFileSync(m,"utf-8"),s(`Read ${r.length} bytes from ${m}`);}t.title&&(c.page_title=t.title),t.description&&(c.meta_description=t.description),t.socialImage&&(c.social_image=t.socialImage),t.author&&(a.author=t.author),t.excerpt&&(a.excerpt=t.excerpt),t.category&&(a.category=t.category),t.date&&(a.publish_date=t.date),t.readTime&&(a.read_time=t.readTime),a.publish_date||(a.publish_date=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}));let d=[];c.page_title||d.push("--title"),c.social_image||d.push("--social-image"),a.author||d.push("--author"),a.excerpt||d.push("--excerpt"),a.category||d.push("--category"),d.length>0&&(l(`Missing required fields: ${d.join(", ")}`),s("Set these via CLI flags or Markdown frontmatter."),process.exit(1));let p={page_title:c.page_title,meta_description:c.meta_description||c.page_title,social_title:c.page_title,social_description:c.meta_description||c.page_title,social_image:c.social_image},x={author:a.author,excerpt:a.excerpt,category:a.category,publish_date:a.publish_date,read_time:a.read_time};s("Creating blog...");let g=await i.blogs.create(e,{path:n,blog_content:r,seo:p,blog_settings:x});t.format==="json"?b(g,"json"):g.success?(y("Blog created successfully"),console.log(` Blog ID: ${g.result?.blog_id}`),g.result?.published_url&&console.log(` Published URL: ${g.result.published_url}`)):l("Failed to create blog");}catch(r){V(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!$__namespace.existsSync(Z)){s("No preview server is running");return}let e=parseInt($__namespace.readFileSync(Z,"utf-8").trim(),10);if(isNaN(e)){l("Invalid PID file"),We();return}try{process.kill(e,"SIGTERM"),y(`Preview server (PID ${e}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):l(`Failed to stop preview server: ${n.message}`);}We();}catch(e){e instanceof Error?l(e.message):l("An unexpected error occurred"),process.exit(1);}}),o}function J(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function V(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function We(){try{$__namespace.existsSync(Z)&&$__namespace.unlinkSync(Z);}catch{}try{$__namespace.existsSync(ue)&&$__namespace.unlinkSync(ue);}catch{}}async function xo(){if($__namespace.existsSync(Z)){try{let o=parseInt($__namespace.readFileSync(Z,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),s(`Terminated existing preview server (PID ${o})`),await new Promise(e=>setTimeout(e,500));}catch{}}catch{}We();}}async function vo(o){let e=P__namespace.resolve(o),n=`
422
+ Your markdown content here...`).argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=J();try{!e.mdFile&&!e.htmlFile&&(l("Either --md-file or --html-file is required"),s("Usage: lindoai blogs create <website_id> <path> --md-file <path> [options]"),process.exit(1));let r,c={},a={};if(e.mdFile){let m=P__namespace.resolve(e.mdFile);O__namespace.existsSync(m)||(l(`File not found: ${m}`),process.exit(1));let w=O__namespace.readFileSync(m,"utf-8");s(`Read ${w.length} bytes from ${m}`);let{content:h,frontmatter:f}=ft(w);r=ut(h),f.title&&(c.page_title=f.title),f.description&&(c.meta_description=f.description),f.image&&(c.social_image=f.image),f.author&&(a.author=f.author),f.excerpt&&(a.excerpt=f.excerpt),f.category&&(a.category=f.category),f.date&&(a.publish_date=f.date);}else {let m=P__namespace.resolve(e.htmlFile);O__namespace.existsSync(m)||(l(`File not found: ${m}`),process.exit(1)),r=O__namespace.readFileSync(m,"utf-8"),s(`Read ${r.length} bytes from ${m}`);}e.title&&(c.page_title=e.title),e.description&&(c.meta_description=e.description),e.socialImage&&(c.social_image=e.socialImage),e.author&&(a.author=e.author),e.excerpt&&(a.excerpt=e.excerpt),e.category&&(a.category=e.category),e.date&&(a.publish_date=e.date),e.readTime&&(a.read_time=e.readTime),a.publish_date||(a.publish_date=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}));let d=[];c.page_title||d.push("--title"),c.social_image||d.push("--social-image"),a.author||d.push("--author"),a.excerpt||d.push("--excerpt"),a.category||d.push("--category"),d.length>0&&(l(`Missing required fields: ${d.join(", ")}`),s("Set these via CLI flags or Markdown frontmatter."),process.exit(1));let p={page_title:c.page_title,meta_description:c.meta_description||c.page_title,social_title:c.page_title,social_description:c.meta_description||c.page_title,social_image:c.social_image},v={author:a.author,excerpt:a.excerpt,category:a.category,publish_date:a.publish_date,read_time:a.read_time};s("Creating blog...");let g=await i.blogs.create(t,{path:n,blog_content:r,seo:p,blog_settings:v});e.format==="json"?b(g,"json"):g.success?(y("Blog created successfully"),console.log(` Blog ID: ${g.result?.blog_id}`),g.result?.published_url&&console.log(` Published URL: ${g.result.published_url}`)):l("Failed to create blog");}catch(r){V(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!O__namespace.existsSync(Z)){s("No preview server is running");return}let t=parseInt(O__namespace.readFileSync(Z,"utf-8").trim(),10);if(isNaN(t)){l("Invalid PID file"),We();return}try{process.kill(t,"SIGTERM"),y(`Preview server (PID ${t}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):l(`Failed to stop preview server: ${n.message}`);}We();}catch(t){t instanceof Error?l(t.message):l("An unexpected error occurred"),process.exit(1);}}),o}function J(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function V(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function We(){try{O__namespace.existsSync(Z)&&O__namespace.unlinkSync(Z);}catch{}try{O__namespace.existsSync(fe)&&O__namespace.unlinkSync(fe);}catch{}}async function vo(){if(O__namespace.existsSync(Z)){try{let o=parseInt(O__namespace.readFileSync(Z,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),s(`Terminated existing preview server (PID ${o})`),await new Promise(t=>setTimeout(t,500));}catch{}}catch{}We();}}async function ko(o){let t=P__namespace.resolve(o),n=`
423
423
  const http = require('node:http');
424
424
  const fs = require('node:fs');
425
425
  const path = require('node:path');
@@ -439,7 +439,7 @@ Markdown frontmatter format:
439
439
  })();
440
440
  </script>\`;
441
441
 
442
- const filePath = ${JSON.stringify(e)};
442
+ const filePath = ${JSON.stringify(t)};
443
443
  const pidFile = path.join(os.tmpdir(), 'lindoai-blogs-preview.pid');
444
444
  const portFile = path.join(os.tmpdir(), 'lindoai-blogs-preview.port');
445
445
  const sseClients = new Set();
@@ -539,24 +539,24 @@ Markdown frontmatter format:
539
539
  });
540
540
  } catch {}
541
541
  });
542
- `,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),$__namespace.existsSync(ue))try{if(i=parseInt($__namespace.readFileSync(ue,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(l("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${i}/`;await G(r)||s(`Could not open browser. Visit: ${r}`),y("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${t.pid}`),console.log(""),s("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),s("To stop the server: lindoai blogs stop-preview");}async function ko(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Ue(),De));s("Starting preview server...");let n=await e(o),t=`http://127.0.0.1:${n}/`;$__namespace.writeFileSync(Z,process.pid.toString(),"utf-8"),$__namespace.writeFileSync(ue,n.toString(),"utf-8"),await G(t)||s(`Could not open browser. Visit: ${t}`),y("Preview server started"),console.log(` URL: ${t}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}function Co(o){return o?o.split(" ").map(e=>e.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function _o(o){let{seo:e,blogSettings:n,blogContent:t,websiteName:i,blogPath:r,websiteTheme:c,customCodes:a}=o,d=c?de(c):"";return `<!DOCTYPE html>
542
+ `,e=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});e.unref();let i=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),O__namespace.existsSync(fe))try{if(i=parseInt(O__namespace.readFileSync(fe,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(l("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${i}/`;await G(r)||s(`Could not open browser. Visit: ${r}`),y("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),s("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),s("To stop the server: lindoai blogs stop-preview");}async function Co(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ue(),De));s("Starting preview server...");let n=await t(o),e=`http://127.0.0.1:${n}/`;O__namespace.writeFileSync(Z,process.pid.toString(),"utf-8"),O__namespace.writeFileSync(fe,n.toString(),"utf-8"),await G(e)||s(`Could not open browser. Visit: ${e}`),y("Preview server started"),console.log(` URL: ${e}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}function _o(o){return o?o.split(" ").map(t=>t.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function So(o){let{seo:t,blogSettings:n,blogContent:e,websiteName:i,blogPath:r,websiteTheme:c,customCodes:a}=o,d=c?de(c):"";return `<!DOCTYPE html>
543
543
  <html class="dark" lang="en">
544
544
  <head>
545
545
  <meta charset="UTF-8">
546
546
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
547
547
 
548
- <title>${e.page_title||"Blog Post"}</title>
549
- <meta name="description" content="${e.meta_description||""}">
548
+ <title>${t.page_title||"Blog Post"}</title>
549
+ <meta name="description" content="${t.meta_description||""}">
550
550
 
551
- <meta property="og:title" content="${e.social_title||e.page_title||""}">
552
- <meta property="og:description" content="${e.social_description||e.meta_description||""}">
553
- ${e.social_image?`<meta property="og:image" content="${e.social_image}">`:""}
551
+ <meta property="og:title" content="${t.social_title||t.page_title||""}">
552
+ <meta property="og:description" content="${t.social_description||t.meta_description||""}">
553
+ ${t.social_image?`<meta property="og:image" content="${t.social_image}">`:""}
554
554
  <meta property="og:type" content="article">
555
555
 
556
556
  <meta name="twitter:card" content="summary_large_image">
557
- <meta name="twitter:title" content="${e.social_title||e.page_title||""}">
558
- <meta name="twitter:description" content="${e.social_description||e.meta_description||""}">
559
- ${e.social_image?`<meta name="twitter:image" content="${e.social_image}">`:""}
557
+ <meta name="twitter:title" content="${t.social_title||t.page_title||""}">
558
+ <meta name="twitter:description" content="${t.social_description||t.meta_description||""}">
559
+ ${t.social_image?`<meta name="twitter:image" content="${t.social_image}">`:""}
560
560
 
561
561
  <!-- Google Fonts -->
562
562
  ${d}
@@ -642,13 +642,13 @@ Markdown frontmatter format:
642
642
  `:""}
643
643
 
644
644
  <h1 class="text-3xl sm:text-4xl lg:text-5xl font-bold font-display leading-tight mb-6 text-gray-900 dark:text-neutral-100">
645
- ${e.page_title||"Untitled"}
645
+ ${t.page_title||"Untitled"}
646
646
  </h1>
647
647
 
648
648
  <div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-neutral-400 mb-8">
649
649
  <div class="flex items-center space-x-2">
650
650
  <div id="blog-author-avatar" class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white text-xs font-semibold">
651
- ${Co(n.author||"Anonymous")}
651
+ ${_o(n.author||"Anonymous")}
652
652
  </div>
653
653
  <span id="blog-author-display" class="font-medium text-neutral-200">
654
654
  ${n.author||"Anonymous"}
@@ -660,9 +660,9 @@ Markdown frontmatter format:
660
660
  <span>${n.read_time||"4 min read"}</span>
661
661
  </div>
662
662
 
663
- ${e.social_image?`
663
+ ${t.social_image?`
664
664
  <div class="aspect-video rounded-xl overflow-hidden mb-8">
665
- <img src="${e.social_image}" alt="" class="w-full h-full object-cover">
665
+ <img src="${t.social_image}" alt="" class="w-full h-full object-cover">
666
666
  </div>
667
667
  `:""}
668
668
 
@@ -677,7 +677,7 @@ Markdown frontmatter format:
677
677
  <!-- Article Content -->
678
678
  <main class="px-4 sm:px-6 lg:px-8 pb-16">
679
679
  <article class="max-w-3xl mx-auto prose prose-lg prose-gray dark:prose-invert">
680
- ${t}
680
+ ${e}
681
681
  </article>
682
682
  </main>
683
683
 
@@ -725,17 +725,8 @@ Markdown frontmatter format:
725
725
  <!-- Custom Code (Footer) -->
726
726
  ${a?.footer||""}
727
727
  </body>
728
- </html>`}function ut(o){let e={},n=o;if(o.startsWith("---")){let t=o.indexOf("---",3);if(t!==-1){let i=o.slice(3,t).trim();n=o.slice(t+3).trim();for(let r of i.split(`
729
- `)){let c=r.indexOf(":");if(c!==-1){let a=r.slice(0,c).trim(),d=r.slice(c+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),e[a]=d;}}}}return {content:n,frontmatter:e}}function ft(o){let e=o;return e=e.replace(/```(\w*)\n([\s\S]*?)```/g,"<pre><code>$2</code></pre>"),e=e.replace(/^(\|.+\|)\n(\|[\s\-:|]+\|)\n((?:\|.+\|\n?)+)/gm,(i,r,c,a)=>{let d=r.split("|").filter(x=>x.trim()).map(x=>`<th>${x.trim()}</th>`).join(""),p=a.trim().split(`
730
- `).map(x=>`<tr>${x.split("|").filter(m=>m.trim()).map(m=>`<td>${m.trim()}</td>`).join("")}</tr>`).join(`
731
- `);return `<table>
732
- <thead><tr>${d}</tr></thead>
733
- <tbody>
734
- ${p}
735
- </tbody>
736
- </table>`}),e=e.replace(/^---$/gm,"<hr>"),e=e.replace(/^###### (.+)$/gm,"<h6>$1</h6>"),e=e.replace(/^##### (.+)$/gm,"<h5>$1</h5>"),e=e.replace(/^#### (.+)$/gm,"<h4>$1</h4>"),e=e.replace(/^### (.+)$/gm,"<h3>$1</h3>"),e=e.replace(/^## (.+)$/gm,"<h2>$1</h2>"),e=e.replace(/^# (.+)$/gm,"<h1>$1</h1>"),e=e.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),e=e.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(.+?)\*/g,"<em>$1</em>"),e=e.replace(/`([^`]+)`/g,"<code>$1</code>"),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2">$1</a>'),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1">'),e=e.replace(/^- (.+)$/gm,"<li>$1</li>"),e=e.replace(/(<li>.*<\/li>\n?)+/g,i=>`<ul>${i}</ul>`),e=e.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),e=e.split(`
737
- `).map(i=>{let r=i.trim();return r?r.startsWith("<")?i:`<p>${r}</p>`:""}).join(`
738
- `),e=e.replace(/<p><\/p>/g,""),e}function gt(o){let e=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",pdf:"application/pdf",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf"}[e]||"application/octet-stream"}function ht(o){let e=o.toLowerCase().split(".").pop()||"",n=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],t=["mp4","webm","mov","avi","mkv"],i=["woff","woff2","ttf","otf","eot"];return n.includes(e)?"images":t.includes(e)?"videos":i.includes(e)?"fonts":"documents"}function Ke(){let o=new commander.Command("media").description("Media upload operations");return o.command("upload").description("Upload a single media file to website CDN").argument("<website_id>","Website ID").argument("<file_path>","Path to the file to upload").option("-t, --type <type>","Media type (images, videos, documents, fonts)").option("-n, --name <name>","Override file name for CDN").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=bt();try{let r=P__namespace.resolve(n);$__namespace.existsSync(r)||(l(`File not found: ${r}`),process.exit(1));let c=t.name||P__namespace.basename(r),d=$__namespace.readFileSync(r).toString("base64"),p=t.type||ht(c),x=gt(c);s(`Uploading ${c} (${p}) to website ${e}...`);let g=await i.media.upload(e,{file_base64:d,file_name:c,media_type:p,content_type:x});y(`Uploaded: ${g.result.url}`),b(g.result,t.format);}catch(r){yt(r);}}),o.command("upload-batch").description("Upload multiple media files to website CDN (max 20)").argument("<website_id>","Website ID").argument("<file_paths...>","Paths to files to upload").option("-t, --type <type>","Media type override for all files").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=bt();try{n.length>20&&(l("Maximum 20 files per batch upload"),process.exit(1));let r=n.map(a=>{let d=P__namespace.resolve(a);$__namespace.existsSync(d)||(l(`File not found: ${d}`),process.exit(1));let p=P__namespace.basename(d),g=$__namespace.readFileSync(d).toString("base64"),m=t.type||ht(p),w=gt(p);return {file_base64:g,file_name:p,media_type:m,content_type:w}});s(`Uploading ${r.length} file(s) to website ${e}...`);let c=await i.media.uploadBatch(e,{files:r});y(`Uploaded ${c.result.successful} of ${c.result.total} files`),c.result.failed>0&&s(`${c.result.failed} file(s) failed`),b(c.result,t.format);}catch(r){yt(r);}}),o}function bt(){T()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function yt(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function xt(){return wt__namespace.randomBytes(32).toString("hex")}function vt(o,e){return o===e}function To(o){try{let e=o.startsWith("http")?o:`http://localhost${o}`,t=new url.URL(e).searchParams;return {key:t.get("key")??void 0,state:t.get("state")??void 0,error:t.get("error")??void 0,message:t.get("message")??void 0}}catch{return {}}}function Po(){return `<!DOCTYPE html>
728
+ </html>`}function ft(o){let t={},n=o;if(o.startsWith("---")){let e=o.indexOf("---",3);if(e!==-1){let i=o.slice(3,e).trim();n=o.slice(e+3).trim();for(let r of i.split(`
729
+ `)){let c=r.indexOf(":");if(c!==-1){let a=r.slice(0,c).trim(),d=r.slice(c+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),t[a]=d;}}}}return {content:n,frontmatter:t}}function ut(o){return marked.marked.parse(o,{async:false})}function gt(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",pdf:"application/pdf",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf"}[t]||"application/octet-stream"}function ht(o){let t=o.toLowerCase().split(".").pop()||"",n=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],e=["mp4","webm","mov","avi","mkv"],i=["woff","woff2","ttf","otf","eot"];return n.includes(t)?"images":e.includes(t)?"videos":i.includes(t)?"fonts":"documents"}function Ke(){let o=new commander.Command("media").description("Media upload operations");return o.command("upload").description("Upload a single media file to website CDN").argument("<website_id>","Website ID").argument("<file_path>","Path to the file to upload").option("-t, --type <type>","Media type (images, videos, documents, fonts)").option("-n, --name <name>","Override file name for CDN").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=bt();try{let r=P__namespace.resolve(n);O__namespace.existsSync(r)||(l(`File not found: ${r}`),process.exit(1));let c=e.name||P__namespace.basename(r),d=O__namespace.readFileSync(r).toString("base64"),p=e.type||ht(c),v=gt(c);s(`Uploading ${c} (${p}) to website ${t}...`);let g=await i.media.upload(t,{file_base64:d,file_name:c,media_type:p,content_type:v});y(`Uploaded: ${g.result.url}`),b(g.result,e.format);}catch(r){yt(r);}}),o.command("upload-batch").description("Upload multiple media files to website CDN (max 20)").argument("<website_id>","Website ID").argument("<file_paths...>","Paths to files to upload").option("-t, --type <type>","Media type override for all files").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=bt();try{n.length>20&&(l("Maximum 20 files per batch upload"),process.exit(1));let r=n.map(a=>{let d=P__namespace.resolve(a);O__namespace.existsSync(d)||(l(`File not found: ${d}`),process.exit(1));let p=P__namespace.basename(d),g=O__namespace.readFileSync(d).toString("base64"),m=e.type||ht(p),w=gt(p);return {file_base64:g,file_name:p,media_type:m,content_type:w}});s(`Uploading ${r.length} file(s) to website ${t}...`);let c=await i.media.uploadBatch(t,{files:r});y(`Uploaded ${c.result.successful} of ${c.result.total} files`),c.result.failed>0&&s(`${c.result.failed} file(s) failed`),b(c.result,e.format);}catch(r){yt(r);}}),o}function bt(){$()||(l("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=T();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function yt(o){o instanceof lindoai.AuthenticationError&&(l("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?l(o.message):l("An unexpected error occurred"),process.exit(1);}function xt(){return wt__namespace.randomBytes(32).toString("hex")}function vt(o,t){return o===t}function Po(o){try{let t=o.startsWith("http")?o:`http://localhost${o}`,e=new url.URL(t).searchParams;return {key:e.get("key")??void 0,state:e.get("state")??void 0,error:e.get("error")??void 0,message:e.get("message")??void 0}}catch{return {}}}function Io(){return `<!DOCTYPE html>
739
730
  <html lang="en">
740
731
  <head>
741
732
  <meta charset="UTF-8">
@@ -836,7 +827,7 @@ ${p}
836
827
  <div class="error-message">${o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</div>
837
828
  </div>
838
829
  </body>
839
- </html>`}function Io(){return `<!DOCTYPE html>
830
+ </html>`}function Ao(){return `<!DOCTYPE html>
840
831
  <html lang="en">
841
832
  <head>
842
833
  <meta charset="UTF-8">
@@ -874,13 +865,13 @@ ${p}
874
865
  <p>This endpoint is not available.</p>
875
866
  </div>
876
867
  </body>
877
- </html>`}function Ct(){let o=null,e=null;function n(t,i){let r=t.url||"/",c=t.method||"GET",a=r==="/callback"||r.startsWith("/callback?");if(c!=="GET"||!a){i.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),i.end(Io());return}let d=To(r);if(!e){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(he("No pending authorization request"));return}let{expectedState:p,resolve:x,timeoutId:g}=e;if(clearTimeout(g),e=null,d.error){let m=d.message||d.error;i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),x({success:false,error:m});return}if(!d.state||!vt(d.state,p)){let m="State token mismatch - possible CSRF attack";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),x({success:false,error:m});return}if(!d.key){let m="No API key received";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),x({success:false,error:m});return}i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(Po()),x({success:true,apiKey:d.key});}return {async start(){return new Promise((t,i)=>{o=lt__namespace.createServer(n),o.on("error",r=>{i(new Error(`Failed to start callback server: ${r.message}`));}),o.listen(0,"127.0.0.1",()=>{let r=o.address();if(!r||typeof r=="string"){i(new Error("Failed to get server address"));return}let c=r.port,a=`http://127.0.0.1:${c}/callback`;t({port:c,url:a});});})},waitForCallback(t,i){return new Promise(r=>{let c=setTimeout(()=>{e&&(e=null,r({success:false,error:"Login timed out waiting for authorization"}));},i);e={expectedState:t,resolve:r,timeoutId:c};})},async stop(){return new Promise(t=>{e&&(clearTimeout(e.timeoutId),e=null),o?o.close(()=>{o=null,t();}):t();})}}}var Lo="https://app.lindo.ai",Eo=120;function jo(o,e){let n=`http://127.0.0.1:${e}/callback`,t=new URLSearchParams({state:o,callback_url:n});return `${Lo}/cli/authorize?${t.toString()}`}function Ge(){return new commander.Command("login").description("Authenticate via browser to configure your API key").option("-t, --timeout <seconds>","Timeout in seconds for the login flow",String(Eo)).option("--no-browser","Display the authorization URL without opening the browser").action(async e=>{let n=parseInt(e.timeout,10),t=n*1e3,i=e.browser,r=Ct(),c=false;try{s("Starting authentication flow...");let{port:a}=await r.start();c=!0;let d=xt(),p=jo(d,a);i?(s("Opening browser for authorization..."),await G(p)||(s("Could not open browser automatically."),console.log(`
868
+ </html>`}function Ct(){let o=null,t=null;function n(e,i){let r=e.url||"/",c=e.method||"GET",a=r==="/callback"||r.startsWith("/callback?");if(c!=="GET"||!a){i.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),i.end(Ao());return}let d=Po(r);if(!t){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(he("No pending authorization request"));return}let{expectedState:p,resolve:v,timeoutId:g}=t;if(clearTimeout(g),t=null,d.error){let m=d.message||d.error;i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),v({success:false,error:m});return}if(!d.state||!vt(d.state,p)){let m="State token mismatch - possible CSRF attack";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),v({success:false,error:m});return}if(!d.key){let m="No API key received";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(he(m)),v({success:false,error:m});return}i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(Io()),v({success:true,apiKey:d.key});}return {async start(){return new Promise((e,i)=>{o=lt__namespace.createServer(n),o.on("error",r=>{i(new Error(`Failed to start callback server: ${r.message}`));}),o.listen(0,"127.0.0.1",()=>{let r=o.address();if(!r||typeof r=="string"){i(new Error("Failed to get server address"));return}let c=r.port,a=`http://127.0.0.1:${c}/callback`;e({port:c,url:a});});})},waitForCallback(e,i){return new Promise(r=>{let c=setTimeout(()=>{t&&(t=null,r({success:false,error:"Login timed out waiting for authorization"}));},i);t={expectedState:e,resolve:r,timeoutId:c};})},async stop(){return new Promise(e=>{t&&(clearTimeout(t.timeoutId),t=null),o?o.close(()=>{o=null,e();}):e();})}}}var Eo="https://app.lindo.ai",Ro=120;function jo(o,t){let n=`http://127.0.0.1:${t}/callback`,e=new URLSearchParams({state:o,callback_url:n});return `${Eo}/cli/authorize?${e.toString()}`}function Ge(){return new commander.Command("login").description("Authenticate via browser to configure your API key").option("-t, --timeout <seconds>","Timeout in seconds for the login flow",String(Ro)).option("--no-browser","Display the authorization URL without opening the browser").action(async t=>{let n=parseInt(t.timeout,10),e=n*1e3,i=t.browser,r=Ct(),c=false;try{s("Starting authentication flow...");let{port:a}=await r.start();c=!0;let d=xt(),p=jo(d,a);i?(s("Opening browser for authorization..."),await G(p)||(s("Could not open browser automatically."),console.log(`
878
869
  Please open this URL in your browser:`),console.log(`
879
870
  ${p}
880
871
  `))):(console.log(`
881
872
  Please open this URL in your browser:`),console.log(`
882
873
  ${p}
883
- `)),s(`Waiting for authorization (timeout: ${n}s)...`);let x=await r.waitForCallback(d,t);x.success&&x.apiKey?(tt(x.apiKey),y("Successfully authenticated!"),s(`API key saved to: ${q()}`)):(l(x.error||"Authentication failed"),process.exit(1));}catch(a){l(a instanceof Error?a.message:"An unexpected error occurred"),process.exit(1);}finally{c&&await r.stop();}})}var Ye=P__namespace.join(je__namespace.homedir(),".config","opencode","skills","lindoai"),$t=P__namespace.join(Ye,"SKILL.md"),Uo=`---
874
+ `)),s(`Waiting for authorization (timeout: ${n}s)...`);let v=await r.waitForCallback(d,e);v.success&&v.apiKey?(tt(v.apiKey),y("Successfully authenticated!"),s(`API key saved to: ${q()}`)):(l(v.error||"Authentication failed"),process.exit(1));}catch(a){l(a instanceof Error?a.message:"An unexpected error occurred"),process.exit(1);}finally{c&&await r.stop();}})}var Ye=P__namespace.join(Re__namespace.homedir(),".config","opencode","skills","lindoai"),Ot=P__namespace.join(Ye,"SKILL.md"),No=`---
884
875
  name: lindoai
885
876
  description: Lindo AI CLI - Command-line interface for the Lindo API
886
877
  ---
@@ -1241,5 +1232,5 @@ Follow these core rules when building pages:
1241
1232
  6. **Container patterns**:
1242
1233
  - Use \`container mx-auto px-4\` for consistent content width
1243
1234
  - Apply consistent vertical padding: \`py-12 md:py-16 lg:py-20\`
1244
- `;function No(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function Mo(){try{return s("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function Ho(){$__namespace.existsSync(Ye)||$__namespace.mkdirSync(Ye,{recursive:true}),$__namespace.writeFileSync($t,Uo,"utf-8");}function Je(){return new commander.Command("agent").description("Launch an AI agent that understands all CLI commands").option("--install","Install OpenCode if not already installed").option("--model <model>","Specify the model to use with OpenCode").action(async e=>{No()||(e.install?(Mo()||(l("Failed to install OpenCode"),s("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),y("OpenCode installed successfully")):(l("OpenCode is not installed"),s(""),s("To install OpenCode, run one of the following:"),s(" lindoai agent --install"),s(" npm install -g opencode-ai@latest"),process.exit(1)));try{Ho(),s(`Skill file installed to: ${$t}`);}catch(i){l(`Failed to install skill file: ${i instanceof Error?i.message:"Unknown error"}`),process.exit(1);}let n=[];e.model&&n.push("--model",e.model),s("Launching OpenCode...");let t=child_process.spawn("opencode",n,{stdio:"inherit",shell:true});t.on("error",i=>{l(`Failed to launch OpenCode: ${i.message}`),process.exit(1);}),t.on("close",i=>{process.exit(i??0);});})}var Ko=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),Go=Ko("../package.json"),Yo=Go.version;function zo(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(Yo,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(Ce()),o.addCommand(_e()),o.addCommand(Se()),o.addCommand($e()),o.addCommand(Oe()),o.addCommand(Fe()),o.addCommand(Te()),o.addCommand(He()),o.addCommand(Be()),o.addCommand(Ke()),o.addCommand(Ge()),o.addCommand(Je()),o.exitOverride(e=>{throw e.code==="commander.help"&&process.exit(0),e.code==="commander.version"&&process.exit(0),e.code==="commander.missingArgument"&&(l(e.message),process.exit(1)),e.code==="commander.unknownCommand"&&(l(e.message),s('Run "lindo --help" for available commands'),process.exit(1)),e}),o}function Jo(o){l("Authentication failed"),s(""),s("Your API key may be invalid or expired."),s(""),s("To configure your API key:"),s(" 1. Run: lindo config set apiKey <your-api-key>"),s(" 2. Or set the LINDO_API_KEY environment variable"),s(""),s("To get an API key:"),s(" Visit https://app.lindo.ai/settings/api-keys");}async function Vo(){let o=zo();try{await o.parseAsync(process.argv);}catch(e){throw e instanceof lindoai.AuthenticationError&&(Jo(),process.exit(1)),e}}Vo().catch(o=>{o instanceof Error?l(`Unexpected error: ${o.message}`):l("An unexpected error occurred"),process.exit(1);});
1245
- exports.createProgram=zo;
1235
+ `;function Mo(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function Ho(){try{return s("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function Wo(){O__namespace.existsSync(Ye)||O__namespace.mkdirSync(Ye,{recursive:true}),O__namespace.writeFileSync(Ot,No,"utf-8");}function Je(){return new commander.Command("agent").description("Launch an AI agent that understands all CLI commands").option("--install","Install OpenCode if not already installed").option("--model <model>","Specify the model to use with OpenCode").action(async t=>{Mo()||(t.install?(Ho()||(l("Failed to install OpenCode"),s("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),y("OpenCode installed successfully")):(l("OpenCode is not installed"),s(""),s("To install OpenCode, run one of the following:"),s(" lindoai agent --install"),s(" npm install -g opencode-ai@latest"),process.exit(1)));try{Wo(),s(`Skill file installed to: ${Ot}`);}catch(i){l(`Failed to install skill file: ${i instanceof Error?i.message:"Unknown error"}`),process.exit(1);}let n=[];t.model&&n.push("--model",t.model),s("Launching OpenCode...");let e=child_process.spawn("opencode",n,{stdio:"inherit",shell:true});e.on("error",i=>{l(`Failed to launch OpenCode: ${i.message}`),process.exit(1);}),e.on("close",i=>{process.exit(i??0);});})}var Go=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),Yo=Go("../package.json"),zo=Yo.version;function Jo(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(zo,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(Ce()),o.addCommand(_e()),o.addCommand(Se()),o.addCommand(Oe()),o.addCommand(Fe()),o.addCommand(Te()),o.addCommand($e()),o.addCommand(He()),o.addCommand(Be()),o.addCommand(Ke()),o.addCommand(Ge()),o.addCommand(Je()),o.exitOverride(t=>{throw t.code==="commander.help"&&process.exit(0),t.code==="commander.version"&&process.exit(0),t.code==="commander.missingArgument"&&(l(t.message),process.exit(1)),t.code==="commander.unknownCommand"&&(l(t.message),s('Run "lindo --help" for available commands'),process.exit(1)),t}),o}function Vo(o){l("Authentication failed"),s(""),s("Your API key may be invalid or expired."),s(""),s("To configure your API key:"),s(" 1. Run: lindo config set apiKey <your-api-key>"),s(" 2. Or set the LINDO_API_KEY environment variable"),s(""),s("To get an API key:"),s(" Visit https://app.lindo.ai/settings/api-keys");}async function Xo(){let o=Jo();try{await o.parseAsync(process.argv);}catch(t){throw t instanceof lindoai.AuthenticationError&&(Vo(),process.exit(1)),t}}Xo().catch(o=>{o instanceof Error?l(`Unexpected error: ${o.message}`):l("An unexpected error occurred"),process.exit(1);});
1236
+ exports.createProgram=Jo;