lindoai-cli 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.cjs +400 -29
  2. package/dist/index.js +400 -29
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var Ee=require('http'),w=require('fs'),j=require('path'),de=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),url=require('url'),De=require('crypto');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 Ee__namespace=/*#__PURE__*/_interopNamespace(Ee);var w__namespace=/*#__PURE__*/_interopNamespace(w);var j__namespace=/*#__PURE__*/_interopNamespace(j);var de__namespace=/*#__PURE__*/_interopNamespace(de);var De__namespace=/*#__PURE__*/_interopNamespace(De);var Me=Object.defineProperty;var Be=(o,t)=>()=>(o&&(t=o(o=0)),t);var He=(o,t)=>{for(var n in t)Me(o,n,{get:t[n],enumerable:true});};var pe={};He(pe,{LIVE_RELOAD_SCRIPT:()=>me,injectLiveReload:()=>Le,startLivePreviewServer:()=>xt});function Le(o){let t=/<\/body>/i,n=o.match(t);return n&&n.index!==void 0?o.slice(0,n.index)+me+o.slice(n.index):o+me}function xt(o){return new Promise((t,n)=>{let e=j__namespace.resolve(o),i=new Set,a=null,l=100;function m(){for(let u of i)try{u.write(`data: reload
2
+ 'use strict';var Ye=require('http'),k=require('fs'),L=require('path'),ke=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),url=require('url'),ot=require('crypto');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 Ye__namespace=/*#__PURE__*/_interopNamespace(Ye);var k__namespace=/*#__PURE__*/_interopNamespace(k);var L__namespace=/*#__PURE__*/_interopNamespace(L);var ke__namespace=/*#__PURE__*/_interopNamespace(ke);var ot__namespace=/*#__PURE__*/_interopNamespace(ot);var ft=Object.defineProperty;var gt=(o,e)=>()=>(o&&(e=o(o=0)),e);var ht=(o,e)=>{for(var n in e)ft(o,n,{get:e[n],enumerable:true});};var _e={};ht(_e,{LIVE_RELOAD_SCRIPT:()=>Ce,injectLiveReload:()=>ze,startLivePreviewServer:()=>zt});function ze(o){let e=/<\/body>/i,n=o.match(e);return n&&n.index!==void 0?o.slice(0,n.index)+Ce+o.slice(n.index):o+Ce}function zt(o){return new Promise((e,n)=>{let t=L__namespace.resolve(o),i=new Set,a=null,c=100;function m(){for(let u of i)try{u.write(`data: reload
3
3
 
4
- `);}catch{i.delete(u);}}function p(){a&&clearTimeout(a),a=setTimeout(()=>{m(),a=null;},l);}function b(u,f){let S=u.url||"/";if((u.method||"GET")!=="GET"){f.writeHead(405,{"Content-Type":"text/plain"}),f.end("Method Not Allowed");return}if(S==="/__live-reload"){f.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),f.write(`data: connected
4
+ `);}catch{i.delete(u);}}function l(){a&&clearTimeout(a),a=setTimeout(()=>{m(),a=null;},c);}function f(u,h){let v=u.url||"/";if((u.method||"GET")!=="GET"){h.writeHead(405,{"Content-Type":"text/plain"}),h.end("Method Not Allowed");return}if(v==="/__live-reload"){h.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),h.write(`data: connected
5
5
 
6
- `),i.add(f),u.on("close",()=>{i.delete(f);});return}if(S==="/"||S==="/index.html"){try{let _=w__namespace.readFileSync(e,"utf-8"),G=Le(_);f.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),f.end(G);}catch(_){let G=_ instanceof Error?_.message:"Unknown error";f.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),f.end(`<!DOCTYPE html>
6
+ `),i.add(h),u.on("close",()=>{i.delete(h);});return}if(v==="/"||v==="/index.html"){try{let x=k__namespace.readFileSync(t,"utf-8"),w=ze(x);h.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),h.end(w);}catch(x){let w=x instanceof Error?x.message:"Unknown error";h.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),h.end(`<!DOCTYPE html>
7
7
  <html>
8
8
  <head><title>Error</title></head>
9
9
  <body>
10
10
  <h1>Error loading file</h1>
11
- <p>${G}</p>
11
+ <p>${w}</p>
12
12
  </body>
13
- </html>`);}return}f.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),f.end(`<!DOCTYPE html>
13
+ </html>`);}return}h.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),h.end(`<!DOCTYPE html>
14
14
  <html>
15
15
  <head><title>Not Found</title></head>
16
16
  <body>
17
17
  <h1>404 Not Found</h1>
18
18
  <p>The requested resource was not found.</p>
19
19
  </body>
20
- </html>`);}let g=Ee__namespace.createServer(b),v=null;g.on("error",u=>{n(new Error(`Failed to start preview server: ${u.message}`));}),g.listen(0,"127.0.0.1",()=>{let u=g.address();if(!u||typeof u=="string"){n(new Error("Failed to get server address"));return}let f=u.port;try{v=w__namespace.watch(e,k=>{k==="change"&&p();}),v.on("error",k=>{console.error(`[Live Preview] File watcher error: ${k.message}`);});}catch(k){let _=k instanceof Error?k.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${_}`);}let S=()=>{v&&(v.close(),v=null),a&&(clearTimeout(a),a=null);for(let G of i)try{G.end();}catch{}i.clear();let k=j__namespace.join(de__namespace.tmpdir(),"lindoai-pages-preview.pid"),_=j__namespace.join(de__namespace.tmpdir(),"lindoai-pages-preview.port");try{w__namespace.existsSync(k)&&w__namespace.unlinkSync(k);}catch{}try{w__namespace.existsSync(_)&&w__namespace.unlinkSync(_);}catch{}g.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",S),process.on("SIGINT",S),t(f);});})}var me,ue=Be(()=>{me=`<script>
20
+ </html>`);}let g=Ye__namespace.createServer(f),y=null;g.on("error",u=>{n(new Error(`Failed to start preview server: ${u.message}`));}),g.listen(0,"127.0.0.1",()=>{let u=g.address();if(!u||typeof u=="string"){n(new Error("Failed to get server address"));return}let h=u.port;try{y=k__namespace.watch(t,b=>{b==="change"&&l();}),y.on("error",b=>{console.error(`[Live Preview] File watcher error: ${b.message}`);});}catch(b){let x=b instanceof Error?b.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${x}`);}let v=()=>{y&&(y.close(),y=null),a&&(clearTimeout(a),a=null);for(let w of i)try{w.end();}catch{}i.clear();let b=L__namespace.join(ke__namespace.tmpdir(),"lindoai-pages-preview.pid"),x=L__namespace.join(ke__namespace.tmpdir(),"lindoai-pages-preview.port");try{k__namespace.existsSync(b)&&k__namespace.unlinkSync(b);}catch{}try{k__namespace.existsSync(x)&&k__namespace.unlinkSync(x);}catch{}g.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",v),process.on("SIGINT",v),e(h);});})}var Ce,Se=gt(()=>{Ce=`<script>
21
21
  (function() {
22
22
  var eventSource = new EventSource('/__live-reload');
23
23
  eventSource.onmessage = function(event) {
@@ -29,15 +29,184 @@
29
29
  console.log('[Live Reload] Connection lost, attempting to reconnect...');
30
30
  };
31
31
  })();
32
- </script>`;});var Ge="LINDO_API_KEY",Ye="LINDO_BASE_URL",Je=".lindo",Ve="config.json",ze="https://api.lindo.ai";function ke(){return j__namespace.join(de__namespace.homedir(),Je)}function T(){return j__namespace.join(ke(),Ve)}function ee(){let o=T();try{if(w__namespace.existsSync(o)){let t=w__namespace.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function Ie(o){let t=ke(),n=T();w__namespace.existsSync(t)||w__namespace.mkdirSync(t,{recursive:true}),w__namespace.writeFileSync(n,JSON.stringify(o,null,2),"utf-8");}function h(){let o=ee(),t=process.env[Ge]||o.apiKey,n=process.env[Ye]||o.baseUrl||ze;return {apiKey:t,baseUrl:n}}function Pe(o){let t=ee();t.apiKey=o,Ie(t);}function Fe(o,t){let n=ee();switch(o){case "apiKey":n.apiKey=t;break;case "baseUrl":n.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}Ie(n);}function _e(o){let t=h();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function C(){return !!h().apiKey}var $={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Qe(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function E(o,t){return Qe()?`${t}${o}${$.reset}`:o}function d(o){console.log(E(`\u2713 ${o}`,$.green));}function r(o){console.error(E(`\u2717 ${o}`,$.red));}function s(o){console.log(E(`\u2139 ${o}`,$.blue));}function Xe(o){return JSON.stringify(o,null,2)}function Ze(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 et(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,a])=>{let l=i.padEnd(e),m=te(a);return `${E(l,$.cyan)} ${m}`}).join(`
34
- `)}return String(o)}function et(o,t){let n={};for(let l of o)n[l]=l.length;for(let l of t)if(typeof l=="object"&&l!==null){let m=l;for(let p of o){let b=te(m[p]);n[p]=Math.max(n[p],b.length);}}let e=o.map(l=>E(l.padEnd(n[l]),$.bold)).join(" "),i=o.map(l=>"-".repeat(n[l])).join(" "),a=t.map(l=>{if(typeof l=="object"&&l!==null){let m=l;return o.map(p=>te(m[p]).padEnd(n[p])).join(" ")}return String(l)});return [e,i,...a].join(`
35
- `)}function te(o){return o==null?E("-",$.gray):typeof o=="boolean"?o?E("true",$.green):E("false",$.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function c(o,t){console.log(t==="json"?Xe(o):Ze(o));}var Ae=["apiKey","baseUrl"];function ne(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,n)=>{Ae.includes(t)||(r(`Invalid configuration key: ${t}`),s(`Valid keys: ${Ae.join(", ")}`),process.exit(1));try{Fe(t,n),d(`Configuration saved: ${t}`),s(`Config file: ${T()}`);}catch(e){r(`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=_e(t);if(e===void 0){n.format==="json"?c({key:t,value:null},n.format):s(`Configuration key '${t}' is not set`);return}if(n.format==="json")c({key:t,value:e},n.format);else {let i=t==="apiKey"?oe(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=h(),e={apiKey:n.apiKey?oe(n.apiKey):"(not set)",baseUrl:n.baseUrl,configFile:T()};t.format==="json"?c({apiKey:n.apiKey?oe(n.apiKey):null,baseUrl:n.baseUrl,configFile:T()},t.format):c(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(T());}),o}function oe(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function ie(){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)=>{C()||(r("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=h(),i=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),a;try{a=JSON.parse(n.input);}catch{r("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await i.agents.run({agent_id:t,input:a,stream:n.stream});l.success?(d("Agent run completed"),c(l,n.format)):(r(`Agent run failed: ${l.error||"Unknown error"}`),c(l,n.format),process.exit(1));}catch(l){rt(l);}}),o}function rt(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function re(){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=M();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?c(e.data,t.format):(r("Failed to list workflows"),process.exit(1));}catch(e){B(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=M(),i;try{i=JSON.parse(n.params);}catch{r("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${t}`);let a=await e.workflows.start({workflow_name:t,params:i});a.success?(d(`Workflow started: ${a.instance_id}`),c(a,n.format)):(r("Failed to start workflow"),c(a,n.format),process.exit(1));}catch(a){B(a);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n)=>{let e=M();try{let i=await e.workflows.getStatus(t);c(i,n.format);}catch(i){B(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=M();try{s(`Pausing workflow: ${t}`);let i=await e.workflows.pause(t);i.success?d(i.message):(r(i.message),process.exit(1)),c(i,n.format);}catch(i){B(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=M();try{s(`Resuming workflow: ${t}`);let i=await e.workflows.resume(t);i.success?d(i.message):(r(i.message),process.exit(1)),c(i,n.format);}catch(i){B(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=M();try{s(`Terminating workflow: ${t}`);let i=await e.workflows.terminate(t);i.success?d(i.message):(r(i.message),process.exit(1)),c(i,n.format);}catch(i){B(i);}}),o}function M(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function B(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function se(){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=I();try{let e=await n.workspace.get();c(e,t.format);}catch(e){P(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let n=I();try{let e=await n.workspace.getCredits();c(e,t.format);}catch(e){P(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=I();try{let e=await n.workspace.getClientCredits(t.client);c(e,t.format);}catch(e){P(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=I();try{let e=await n.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&d("Workspace updated"),c(e,t.format);}catch(e){P(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=I();try{let e=await n.workspace.addTeamMember(t.email,t.role);e.success&&d("Team member added"),c(e,t.format);}catch(e){P(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=I();try{let e=await n.workspace.removeTeamMember(t.member);e.success&&d("Team member removed"),c(e,t.format);}catch(e){P(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=I(),e;try{e=JSON.parse(t.config);}catch{r("Invalid JSON config"),process.exit(1);}try{let i=await n.workspace.addIntegration({integration_type:t.type,config:e});i.success&&d("Integration added"),c(i,t.format);}catch(i){P(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=I();try{let e=await n.workspace.removeIntegration(t.type);e.success&&d("Integration removed"),c(e,t.format);}catch(e){P(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=I();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&&d("Whitelabel settings updated"),c(e,t.format);}catch(e){P(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=I();try{let e=await n.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&d("Appearance settings updated"),c(e,t.format);}catch(e){P(e);}}),o}function I(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function P(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function ae(){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=Te();try{let e=await n.analytics.getWorkspace({from:t.from,to:t.to});c(e,t.format);}catch(e){$e(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=Te();try{let e=await n.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});c(e,t.format);}catch(e){$e(e);}}),o}function Te(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function $e(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function ce(){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=Y();try{let e=await n.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")c(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){J(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=Y();try{let e=await n.clients.create({email:t.email,website_limit:parseInt(t.limit,10)});if(e.success&&e.client)d(`Client created: ${e.client.record_id}`),c(e.client,t.format);else if(r("Failed to create client"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){J(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=Y();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)d("Client updated"),e.client&&c(e.client,t.format);else if(r("Failed to update client"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){J(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let n=Y();try{let e=await n.clients.delete(t.id);if(e.success)d("Client deleted");else if(r("Failed to delete client"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){J(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=Y();try{let e=await n.clients.createMagicLink(t.email);if(e.success)d("Magic link created"),c(e,t.format);else if(r("Failed to create magic link"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){J(e);}}),o}function Y(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function J(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function le(){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=O();try{let e=await n.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")c(e,"json");else {let i=e.result?.list??[];if(i.length>0){console.log(`
37
- Websites:`),console.log("---------");for(let a of i)console.log(` ID: ${a.website_id}`),console.log(` Name: ${a.website_name??"N/A"}`),console.log(` Domain: ${a.domain??"N/A"}`),console.log(` Activated: ${a.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??i.length}`);}else s("No websites found");}}catch(e){x(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=O();try{let e=await n.websites.getDetails(t.id);c(e,t.format);}catch(e){x(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=O();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)d("Website updated"),e.website&&c(e.website,t.format);else if(r("Failed to update website"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){x(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=O();try{let e=await n.websites.updateSettings(t.id,{business_name:t.name,language:t.language,business_description:t.description});e.success&&d("Website settings updated"),c(e,t.format);}catch(e){x(e);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async t=>{let n=O();try{let e=await n.websites.delete(t.id);if(e.success)d("Website deleted");else if(r("Failed to delete website"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){x(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=O();try{let e=await n.websites.assign({website_id:t.website,client_id:t.client});if(e.success)d("Website assigned to client");else if(r("Failed to assign website"),e.errors)for(let i of e.errors)r(` ${i}`);}catch(e){x(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=O();try{let e=await n.websites.addDomain(t.id,t.domain);if(e.success&&(d("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}`);}c(e,t.format);}catch(e){x(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=O();try{let e=await n.websites.removeDomain(t.id);e.success&&d("Domain removed"),c(e,t.format);}catch(e){x(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=O(),e;try{e=JSON.parse(t.config);}catch{r("Invalid JSON config"),process.exit(1);}try{let i=await n.websites.addIntegration(t.id,{integration_type:t.type,config:e});i.success&&d("Integration added"),c(i,t.format);}catch(i){x(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=O();try{let e=await n.websites.removeIntegration(t.id,t.type);e.success&&d("Integration removed"),c(e,t.format);}catch(e){x(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=O();try{let e=await n.websites.addTeamMember(t.id,t.email,t.role);e.success&&d("Team member added"),c(e,t.format);}catch(e){x(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=O();try{let e=await n.websites.removeTeamMember(t.id,t.member);e.success&&d("Team member removed"),c(e,t.format);}catch(e){x(e);}}),o}function O(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function x(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function L(o){return new Promise(t=>{let n=de.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);});})}var N=j__namespace.join(de__namespace.tmpdir(),"lindoai-pages-preview.pid"),z=j__namespace.join(de__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=D();try{let e=await n.pages.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")c(e,"json");else {let i=e.result;if(i?.list&&i.list.length>0){console.log(`
39
- Pages:`),console.log("------");for(let a of i.list)console.log(` ID: ${a.page_id}`),console.log(` Name: ${a.name??"N/A"}`),console.log(` Path: ${a.path??"N/A"}`),console.log(` Status: ${a.status??"N/A"}`),console.log(` Published: ${a.publish_date?new Date(a.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No pages found");}}catch(e){R(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=D();try{let e=await n.pages.get(t.website,t.id);if(t.format==="json")c(e,"json");else {let i=e.result;i?(console.log(`
40
- 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?new Date(i.publish_date*1e3).toISOString():"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):r("Page not found");}}catch(e){R(e);}}),o.command("publish").description("Publish 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=D();try{let e=await n.pages.publish(t.website,t.id);t.format==="json"?c(e,"json"):e.success?(d("Page published successfully"),console.log(` Page ID: ${e.result?.page_id}`),console.log(` Published at: ${e.result?.publish_date?new Date(e.result.publish_date*1e3).toISOString():"N/A"}`)):r("Failed to publish page");}catch(e){R(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=D();try{let e=await n.pages.unpublish(t.website,t.id);t.format==="json"?c(e,"json"):e.success?(d("Page unpublished successfully"),console.log(` Page ID: ${e.result?.page_id}`)):r("Failed to unpublish page");}catch(e){R(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=D();try{let e=await n.pages.delete(t.website,t.id);if(t.format==="json")c(e,"json");else if(e.success){if(d("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 r("Failed to delete page");}catch(e){R(e);}}),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=D();try{s("Fetching page details...");let a=await i.pages.get(t,n);a.result||(r("Page not found"),process.exit(1));let l=a.result.path,m=await i.websites.getDetails(t);m.result||(r("Website not found"),process.exit(1));let p=m.result.custom_domain||m.result.verified_domain||m.result.preview_url;p||(r("Could not determine website URL"),process.exit(1));let b=`https://${p}${l}`;s(`Fetching HTML from ${b}...`);let g=await fetch(b);g.ok||(r(`Failed to fetch page HTML: ${g.status} ${g.statusText}`),s("Make sure the page is published before editing"),process.exit(1));let v=await g.text(),u=j__namespace.resolve(e.file);w__namespace.writeFileSync(u,v,"utf-8"),d(`HTML saved to ${u}`),await Ft(),e.background?await _t(u):await At(u);}catch(a){R(a);}}),o.command("update").description("Update a page").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=D(),a=h();try{e.htmlFile||(r("--html-file option is required"),s("Usage: lindoai pages update <website_id> <page_id> --html-file <path>"),process.exit(1));let l=j__namespace.resolve(e.htmlFile);w__namespace.existsSync(l)||(r(`File not found: ${l}`),process.exit(1));let m=w__namespace.readFileSync(l,"utf-8");s(`Read ${m.length} bytes from ${l}`);let p=await i.pages.get(t,n);p.result||(r("Page not found"),process.exit(1));let b=p.result.path;s("Updating page...");let v=`${a.baseUrl||"https://api.lindo.ai"}/v1/workspace/website/${t}/pages/${n}/update`,f=await(await fetch(v,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({html:m,path:b})})).json();if(e.format==="json")c(f,"json");else if(f.success)d("Page updated successfully"),console.log(` Page ID: ${f.result?.page_id}`),f.result?.publish_date&&console.log(` Published at: ${new Date(f.result.publish_date*1e3).toISOString()}`);else if(r("Failed to update page"),f.errors)for(let S of f.errors)console.log(` ${S}`);}catch(l){R(l);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!w__namespace.existsSync(N)){s("No preview server is running");return}let t=parseInt(w__namespace.readFileSync(N,"utf-8").trim(),10);if(isNaN(t)){r("Invalid PID file"),fe();return}try{process.kill(t,"SIGTERM"),d(`Preview server (PID ${t}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):r(`Failed to stop preview server: ${n.message}`);}fe();}catch(t){t instanceof Error?r(t.message):r("An unexpected error occurred"),process.exit(1);}}),o}function D(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function R(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function fe(){try{w__namespace.existsSync(N)&&w__namespace.unlinkSync(N);}catch{}try{w__namespace.existsSync(z)&&w__namespace.unlinkSync(z);}catch{}}async function Ft(){if(w__namespace.existsSync(N)){try{let o=parseInt(w__namespace.readFileSync(N,"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{}fe();}}async function _t(o){let t=j__namespace.resolve(o),n=`
32
+ </script>`;});var bt="LINDO_API_KEY",wt="LINDO_BASE_URL",yt=".lindo",vt="config.json",xt="https://api.lindo.ai";function Me(){return L__namespace.join(ke__namespace.homedir(),yt)}function E(){return L__namespace.join(Me(),vt)}function pe(){let o=E();try{if(k__namespace.existsSync(o)){let e=k__namespace.readFileSync(o,"utf-8");return JSON.parse(e)}}catch{}return {}}function Ue(o){let e=Me(),n=E();k__namespace.existsSync(e)||k__namespace.mkdirSync(e,{recursive:true}),k__namespace.writeFileSync(n,JSON.stringify(o,null,2),"utf-8");}function C(){let o=pe(),e=process.env[bt]||o.apiKey,n=process.env[wt]||o.baseUrl||xt;return {apiKey:e,baseUrl:n}}function Ke(o){let e=pe();e.apiKey=o,Ue(e);}function We(o,e){let n=pe();switch(o){case "apiKey":n.apiKey=e;break;case "baseUrl":n.baseUrl=e;break;default:throw new Error(`Unknown configuration key: ${o}`)}Ue(n);}function He(o){let e=C();switch(o){case "apiKey":return e.apiKey;case "baseUrl":return e.baseUrl;default:return}}function S(){return !!C().apiKey}var j={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function kt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function D(o,e){return kt()?`${e}${o}${j.reset}`:o}function p(o){console.log(D(`\u2713 ${o}`,j.green));}function s(o){console.error(D(`\u2717 ${o}`,j.red));}function r(o){console.log(D(`\u2139 ${o}`,j.blue));}function Ct(o){return JSON.stringify(o,null,2)}function _t(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 St(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,a])=>{let c=i.padEnd(t),m=ue(a);return `${D(c,j.cyan)} ${m}`}).join(`
34
+ `)}return String(o)}function St(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 m=c;for(let l of o){let f=ue(m[l]);n[l]=Math.max(n[l],f.length);}}let t=o.map(c=>D(c.padEnd(n[c]),j.bold)).join(" "),i=o.map(c=>"-".repeat(n[c])).join(" "),a=e.map(c=>{if(typeof c=="object"&&c!==null){let m=c;return o.map(l=>ue(m[l]).padEnd(n[l])).join(" ")}return String(c)});return [t,i,...a].join(`
35
+ `)}function ue(o){return o==null?D("-",j.gray):typeof o=="boolean"?o?D("true",j.green):D("false",j.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function d(o,e){console.log(e==="json"?Ct(o):_t(o));}var qe=["apiKey","baseUrl"];function ge(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((e,n)=>{qe.includes(e)||(s(`Invalid configuration key: ${e}`),r(`Valid keys: ${qe.join(", ")}`),process.exit(1));try{We(e,n),p(`Configuration saved: ${e}`),r(`Config file: ${E()}`);}catch(t){s(`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=He(e);if(t===void 0){n.format==="json"?d({key:e,value:null},n.format):r(`Configuration key '${e}' is not set`);return}if(n.format==="json")d({key:e,value:t},n.format);else {let i=e==="apiKey"?fe(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=C(),t={apiKey:n.apiKey?fe(n.apiKey):"(not set)",baseUrl:n.baseUrl,configFile:E()};e.format==="json"?d({apiKey:n.apiKey?fe(n.apiKey):null,baseUrl:n.baseUrl,configFile:E()},e.format):d(t,e.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(E());}),o}function fe(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function he(){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)=>{S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let t=C(),i=new lindoai.LindoClient({apiKey:t.apiKey,baseUrl:t.baseUrl}),a;try{a=JSON.parse(n.input);}catch{s("Invalid JSON input"),r(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{r(`Running agent: ${e}`);let c=await i.agents.run({agent_id:e,input:a,stream:n.stream});c.success?(p("Agent run completed"),d(c,n.format)):(s(`Agent run failed: ${c.error||"Unknown error"}`),d(c,n.format),process.exit(1));}catch(c){Ft(c);}}),o}function Ft(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function be(){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=J();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?d(t.data,e.format):(s("Failed to list workflows"),process.exit(1));}catch(t){Q(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=J(),i;try{i=JSON.parse(n.params);}catch{s("Invalid JSON params"),r(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{r(`Starting workflow: ${e}`);let a=await t.workflows.start({workflow_name:e,params:i});a.success?(p(`Workflow started: ${a.instance_id}`),d(a,n.format)):(s("Failed to start workflow"),d(a,n.format),process.exit(1));}catch(a){Q(a);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n)=>{let t=J();try{let i=await t.workflows.getStatus(e);d(i,n.format);}catch(i){Q(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=J();try{r(`Pausing workflow: ${e}`);let i=await t.workflows.pause(e);i.success?p(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){Q(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=J();try{r(`Resuming workflow: ${e}`);let i=await t.workflows.resume(e);i.success?p(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){Q(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=J();try{r(`Terminating workflow: ${e}`);let i=await t.workflows.terminate(e);i.success?p(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){Q(i);}}),o}function J(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function Q(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function we(){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=P();try{let t=await n.workspace.get();d(t,e.format);}catch(t){F(t);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.workspace.getCredits();d(t,e.format);}catch(t){F(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=P();try{let t=await n.workspace.getClientCredits(e.client);d(t,e.format);}catch(t){F(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=P();try{let t=await n.workspace.update({workspace_name:e.name,workspace_language:e.language,webhook_url:e.webhook});t.success&&p("Workspace updated"),d(t,e.format);}catch(t){F(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=P();try{let t=await n.workspace.addTeamMember(e.email,e.role);t.success&&p("Team member added"),d(t,e.format);}catch(t){F(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=P();try{let t=await n.workspace.removeTeamMember(e.member);t.success&&p("Team member removed"),d(t,e.format);}catch(t){F(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=P(),t;try{t=JSON.parse(e.config);}catch{s("Invalid JSON config"),process.exit(1);}try{let i=await n.workspace.addIntegration({integration_type:e.type,config:t});i.success&&p("Integration added"),d(i,e.format);}catch(i){F(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=P();try{let t=await n.workspace.removeIntegration(e.type);t.success&&p("Integration removed"),d(t,e.format);}catch(t){F(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=P();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&&p("Whitelabel settings updated"),d(t,e.format);}catch(t){F(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=P();try{let t=await n.workspace.updateAppearance({primary_color:e.primary,secondary_color:e.secondary,theme_mode:e.mode});t.success&&p("Appearance settings updated"),d(t,e.format);}catch(t){F(t);}}),o}function P(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function F(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function ye(){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=Be();try{let t=await n.analytics.getWorkspace({from:e.from,to:e.to});d(t,e.format);}catch(t){Ge(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=Be();try{let t=await n.analytics.getWebsite({website_id:e.website,from:e.from,to:e.to});d(t,e.format);}catch(t){Ge(t);}}),o}function Be(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function Ge(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function ve(){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=te();try{let t=await n.clients.list({page:parseInt(e.page,10),search:e.search});if(e.format==="json")d(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 r("No clients found");}catch(t){oe(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=te();try{let t=await n.clients.create({email:e.email,website_limit:parseInt(e.limit,10)});if(t.success&&t.client)p(`Client created: ${t.client.record_id}`),d(t.client,e.format);else if(s("Failed to create client"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){oe(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=te();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)p("Client updated"),t.client&&d(t.client,e.format);else if(s("Failed to update client"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){oe(t);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async e=>{let n=te();try{let t=await n.clients.delete(e.id);if(t.success)p("Client deleted");else if(s("Failed to delete client"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){oe(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=te();try{let t=await n.clients.createMagicLink(e.email);if(t.success)p("Magic link created"),d(t,e.format);else if(s("Failed to create magic link"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){oe(t);}}),o}function te(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function oe(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function xe(){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=O();try{let t=await n.websites.list({page:parseInt(e.page,10),search:e.search});if(e.format==="json")d(t,"json");else {let i=t.result?.list??[];if(i.length>0){console.log(`
37
+ Websites:`),console.log("---------");for(let a of i)console.log(` ID: ${a.website_id}`),console.log(` Name: ${a.website_name??"N/A"}`),console.log(` Domain: ${a.domain??"N/A"}`),console.log(` Activated: ${a.activated??!1}`),console.log("");console.log(`Total: ${t.result?.total??i.length}`);}else r("No websites found");}}catch(t){I(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=O();try{let t=await n.websites.getDetails(e.id);d(t,e.format);}catch(t){I(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=O();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)p("Website updated"),t.website&&d(t.website,e.format);else if(s("Failed to update website"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){I(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=O();try{let t=await n.websites.updateSettings(e.id,{business_name:e.name,language:e.language,business_description:e.description});t.success&&p("Website settings updated"),d(t,e.format);}catch(t){I(t);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async e=>{let n=O();try{let t=await n.websites.delete(e.id);if(t.success)p("Website deleted");else if(s("Failed to delete website"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){I(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=O();try{let t=await n.websites.assign({website_id:e.website,client_id:e.client});if(t.success)p("Website assigned to client");else if(s("Failed to assign website"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){I(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=O();try{let t=await n.websites.addDomain(e.id,e.domain);if(t.success&&(p("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}`);}d(t,e.format);}catch(t){I(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=O();try{let t=await n.websites.removeDomain(e.id);t.success&&p("Domain removed"),d(t,e.format);}catch(t){I(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=O(),t;try{t=JSON.parse(e.config);}catch{s("Invalid JSON config"),process.exit(1);}try{let i=await n.websites.addIntegration(e.id,{integration_type:e.type,config:t});i.success&&p("Integration added"),d(i,e.format);}catch(i){I(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=O();try{let t=await n.websites.removeIntegration(e.id,e.type);t.success&&p("Integration removed"),d(t,e.format);}catch(t){I(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=O();try{let t=await n.websites.addTeamMember(e.id,e.email,e.role);t.success&&p("Team member added"),d(t,e.format);}catch(t){I(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=O();try{let t=await n.websites.removeTeamMember(e.id,e.member);t.success&&p("Team member removed"),d(t,e.format);}catch(t){I(t);}}),o}function O(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function R(o){return new Promise(e=>{let n=ke.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);});})}var H=L__namespace.join(ke__namespace.tmpdir(),"lindoai-pages-preview.pid"),ie=L__namespace.join(ke__namespace.tmpdir(),"lindoai-pages-preview.port");function $e(){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=K();try{let t=await n.pages.list(e.website,{page:parseInt(e.page,10),search:e.search});if(e.format==="json")d(t,"json");else {let i=t.result;if(i?.list&&i.list.length>0){console.log(`
39
+ Pages:`),console.log("------");for(let a of i.list)console.log(` ID: ${a.page_id}`),console.log(` Name: ${a.name??"N/A"}`),console.log(` Path: ${a.path??"N/A"}`),console.log(` Status: ${a.status??"N/A"}`),console.log(` Published: ${a.publish_date?"Yes":"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else r("No pages found");}}catch(t){W(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=K();try{let t=await n.pages.get(e.website,e.id);if(e.format==="json")d(t,"json");else {let i=t.result;i?(console.log(`
40
+ 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"}`)):s("Page not found");}}catch(t){W(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=K();try{let t=await n.pages.unpublish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(p("Page unpublished successfully"),console.log(` Page ID: ${t.result?.page_id}`)):s("Failed to unpublish page");}catch(t){W(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=K();try{let t=await n.pages.deletePage(e.website,e.id);if(e.format==="json")d(t,"json");else if(t.success){if(p("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 s("Failed to delete page");}catch(t){W(t);}}),o.command("create").description("Create a new page with 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=K();try{let a=t.title,c=`<!-- Hero Section -->
41
+ <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">
42
+ <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
43
+ <h1 class="text-4xl sm:text-5xl lg:text-6xl font-bold text-neutral-900 dark:text-white mb-6">
44
+ ${a}
45
+ </h1>
46
+ <p class="text-lg sm:text-xl text-neutral-600 dark:text-neutral-300 mb-8 max-w-2xl mx-auto">
47
+ Start building your page by editing this template. Add sections, customize styles, and create something amazing.
48
+ </p>
49
+ <div class="flex flex-col sm:flex-row gap-4 justify-center">
50
+ <a href="#features" class="inline-flex items-center justify-center px-6 py-3 bg-emerald-600 hover:bg-emerald-700 text-white font-medium rounded-lg transition">
51
+ Get Started
52
+ </a>
53
+ <a href="#contact" class="inline-flex items-center justify-center px-6 py-3 border border-neutral-300 dark:border-neutral-600 text-neutral-700 dark:text-neutral-200 font-medium rounded-lg hover:bg-neutral-100 dark:hover:bg-neutral-700 transition">
54
+ Learn More
55
+ </a>
56
+ </div>
57
+ </div>
58
+ </section>
59
+
60
+ <!-- Features Section -->
61
+ <section id="features" class="py-20 bg-white dark:bg-neutral-900">
62
+ <div class="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8">
63
+ <div class="text-center mb-16">
64
+ <h2 class="text-3xl sm:text-4xl font-bold text-neutral-900 dark:text-white mb-4">
65
+ Features
66
+ </h2>
67
+ <p class="text-lg text-neutral-600 dark:text-neutral-300 max-w-2xl mx-auto">
68
+ Discover what makes us different.
69
+ </p>
70
+ </div>
71
+ <div class="grid md:grid-cols-3 gap-8">
72
+ <div class="p-6 bg-neutral-50 dark:bg-neutral-800 rounded-xl">
73
+ <div class="w-12 h-12 bg-emerald-100 dark:bg-emerald-900 rounded-lg flex items-center justify-center mb-4">
74
+ <svg class="w-6 h-6 text-emerald-600 dark:text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
75
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
76
+ </svg>
77
+ </div>
78
+ <h3 class="text-xl font-semibold text-neutral-900 dark:text-white mb-2">Feature One</h3>
79
+ <p class="text-neutral-600 dark:text-neutral-300">Description of your first amazing feature goes here.</p>
80
+ </div>
81
+ <div class="p-6 bg-neutral-50 dark:bg-neutral-800 rounded-xl">
82
+ <div class="w-12 h-12 bg-emerald-100 dark:bg-emerald-900 rounded-lg flex items-center justify-center mb-4">
83
+ <svg class="w-6 h-6 text-emerald-600 dark:text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
84
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/>
85
+ </svg>
86
+ </div>
87
+ <h3 class="text-xl font-semibold text-neutral-900 dark:text-white mb-2">Feature Two</h3>
88
+ <p class="text-neutral-600 dark:text-neutral-300">Description of your second amazing feature goes here.</p>
89
+ </div>
90
+ <div class="p-6 bg-neutral-50 dark:bg-neutral-800 rounded-xl">
91
+ <div class="w-12 h-12 bg-emerald-100 dark:bg-emerald-900 rounded-lg flex items-center justify-center mb-4">
92
+ <svg class="w-6 h-6 text-emerald-600 dark:text-emerald-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
93
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"/>
94
+ </svg>
95
+ </div>
96
+ <h3 class="text-xl font-semibold text-neutral-900 dark:text-white mb-2">Feature Three</h3>
97
+ <p class="text-neutral-600 dark:text-neutral-300">Description of your third amazing feature goes here.</p>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </section>
102
+
103
+ <!-- Contact Section -->
104
+ <section id="contact" class="py-20 bg-neutral-50 dark:bg-neutral-800">
105
+ <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
106
+ <h2 class="text-3xl sm:text-4xl font-bold text-neutral-900 dark:text-white mb-4">
107
+ Get in Touch
108
+ </h2>
109
+ <p class="text-lg text-neutral-600 dark:text-neutral-300 mb-8">
110
+ Have questions? We'd love to hear from you.
111
+ </p>
112
+ <a href="mailto:hello@example.com" class="inline-flex items-center justify-center px-8 py-4 bg-emerald-600 hover:bg-emerald-700 text-white font-medium rounded-lg transition text-lg">
113
+ Contact Us
114
+ </a>
115
+ </div>
116
+ </section>`,m={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},l={page_title:a,meta_description:"",social_title:a,social_description:"",noindex:!1,nofollow:!1};r("Creating page...");let f=await i.pages.create(e,{html:c,path:n,settings:m,template_name:a,seo:l});f.success||(s("Failed to create page"),process.exit(1));let g=f.result.page_id;p(`Page created: ${g}`);let y=`<!DOCTYPE html>
117
+ <html class="dark" lang="en">
118
+ <head>
119
+ <meta charset="UTF-8">
120
+ <meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
121
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
122
+
123
+ <title>${a}</title>
124
+ <meta name="description" content="">
125
+
126
+ <meta property="og:title" content="${a}">
127
+ <meta property="og:description" content="">
128
+ <meta property="og:type" content="website">
129
+
130
+ <meta name="twitter:card" content="summary_large_image">
131
+ <meta name="twitter:title" content="${a}">
132
+ <meta name="twitter:description" content="">
133
+
134
+ <!-- Tailwind CSS v4 CDN for preview -->
135
+ <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
136
+
137
+ <!-- Motion for animations -->
138
+ <script src="https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js"></script>
139
+ <script src="https://lnui.pages.dev/motion-animate.js"></script>
140
+
141
+ <!-- Page Custom Code (Header) -->
142
+
143
+ </head>
144
+ <body>
145
+ <!-- ========== MAIN CONTENT ========== -->
146
+ <main dir="ltr" lindo-main-content id="content" role="main" class="bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100">
147
+
148
+ ${c}
149
+
150
+ </main>
151
+ <!-- ========== END MAIN CONTENT ========== -->
152
+
153
+ <!-- Config script -->
154
+ <script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
155
+
156
+ <!-- Page Custom Code (Footer) -->
157
+ </body>
158
+ </html>`,u=L__namespace.resolve(t.file);k__namespace.writeFileSync(u,y,"utf-8"),p(`HTML saved to ${u}`),await Ve(),t.background?await Je(u):await Qe(u),console.log(""),r(`To save changes: lindoai pages update ${e} ${g} --html-file ${t.file}`);}catch(a){W(a);}}),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=K();try{r("Fetching page HTML...");let a=await i.pages.getHtml(e,n);a.result||(s("Page not found"),process.exit(1));let c=a.result.html;c||(s("Page has no HTML content"),r("Make sure the page has been created with HTML content"),process.exit(1));let m=a.result.name||"Page",l=a.result.seo||{},f=a.result.settings||{},g=a.result.custom_codes||{},y=f.theme||{},u=y.mode!=="Light",h=y.direction||"ltr",v=y.main_classes||"",b=y.animations_deactivated||!1,x=`<!DOCTYPE html>
159
+ <html class="${u?"dark":""}" lang="en">
160
+ <head>
161
+ <meta charset="UTF-8">
162
+ <meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1 ${l.noindex?"noindex":""} ${l.nofollow?"nofollow":""}">
163
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
164
+
165
+ <title>${l.page_title||m}</title>
166
+ <meta name="description" content="${l.meta_description||""}">
167
+
168
+ <meta property="og:title" content="${l.social_title||l.page_title||m}">
169
+ <meta property="og:description" content="${l.social_description||l.meta_description||""}">
170
+ ${l.social_image?`<meta property="og:image" content="${l.social_image}">`:""}
171
+ <meta property="og:type" content="website">
172
+ ${l.canonical_url?`<meta property="og:url" content="${l.canonical_url}">`:""}
173
+
174
+ <meta name="twitter:card" content="summary_large_image">
175
+ <meta name="twitter:title" content="${l.social_title||l.page_title||m}">
176
+ <meta name="twitter:description" content="${l.social_description||l.meta_description||""}">
177
+ ${l.social_image?`<meta name="twitter:image" content="${l.social_image}">`:""}
178
+
179
+ <!-- Tailwind CSS v4 CDN for preview -->
180
+ <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
181
+
182
+ ${b?"":`
183
+ <!-- Motion for animations -->
184
+ <script src="https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js"></script>
185
+ <script src="https://lnui.pages.dev/motion-animate.js"></script>
186
+ `}
187
+
188
+ ${l.canonical_url?`<link rel="canonical" href="${l.canonical_url}">`:""}
189
+
190
+ <!-- Page Custom Code (Header) -->
191
+ ${g.header||""}
192
+
193
+ </head>
194
+ <body>
195
+ <!-- ========== MAIN CONTENT ========== -->
196
+ <main dir="${h}" lindo-main-content id="content" role="main" class="${v}">
197
+
198
+ ${c}
199
+
200
+ </main>
201
+ <!-- ========== END MAIN CONTENT ========== -->
202
+
203
+ <!-- Config script -->
204
+ <script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
205
+
206
+ <!-- Page Custom Code (Footer) -->
207
+ ${g.footer||""}
208
+ </body>
209
+ </html>`,w=L__namespace.resolve(t.file);k__namespace.writeFileSync(w,x,"utf-8"),p(`HTML saved to ${w}`),await Ve(),t.background?await Je(w):await Qe(w);}catch(a){W(a);}}),o.command("update").description("Update a page").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=K();try{t.htmlFile||(s("--html-file option is required"),r("Usage: lindoai pages update <website_id> <page_id> --html-file <path>"),process.exit(1));let a=L__namespace.resolve(t.htmlFile);k__namespace.existsSync(a)||(s(`File not found: ${a}`),process.exit(1));let c=k__namespace.readFileSync(a,"utf-8");r(`Read ${c.length} bytes from ${a}`);let m=c.match(/<main[^>]*>([\s\S]*)<\/main>/i),l=m?m[1].trim():c;m&&r("Extracted content from <main> tag");let f=c.match(/<title>([^<]*)<\/title>/i),g=f?f[1].trim():void 0;g&&r(`Extracted page title: ${g}`);let y="",u="",h=c.match(/<!-- Page Custom Code \(Header\) -->\s*([\s\S]*?)\s*<\/head>/i);h&&h[1].trim()&&(y=h[1].trim(),r("Extracted header custom code"));let v=c.match(/<!-- Page Custom Code \(Footer\) -->\s*([\s\S]*?)\s*<\/body>/i);v&&v[1].trim()&&(u=v[1].trim(),r("Extracted footer custom code"));let b=c.match(/<html[^>]*class="([^"]*)"/i),x=b?b[1].includes("dark"):!0,w=c.match(/<main[^>]*>/i),Z="ltr",ee="";if(w){let De=w[0].match(/dir="([^"]*)"/i);De&&(Z=De[1]);let Re=w[0].match(/class="([^"]*)"/i);Re&&(ee=Re[1]);}let ae=!c.includes("motion@latest"),B=c.match(/<meta\s+name="description"\s+content="([^"]*)"/i),G=c.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),Y=c.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),z=c.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),V=c.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),dt=c.match(/noindex/i),mt=c.match(/nofollow/i),$={};g&&($.page_title=g),B&&B[1]&&($.meta_description=B[1]),G&&G[1]&&($.social_title=G[1]),Y&&Y[1]&&($.social_description=Y[1]),z&&z[1]&&($.social_image=z[1]),V&&V[1]&&($.canonical_url=V[1]),$.noindex=!!dt,$.nofollow=!!mt,Object.keys($).length>2&&r("Extracted SEO metadata");let se=await i.pages.get(e,n);se.result||(s("Page not found"),process.exit(1));let pt=se.result.path,ut={...se.result.settings||{},theme:{...se.result.settings?.theme||{},mode:x?"Dark":"Light",direction:Z,main_classes:ee,animations_deactivated:ae},should_convert:!0},ce={};y&&(ce.header=y),u&&(ce.footer=u),r("Updating page...");let de=await i.pages.publish(e,n,{html:l,path:pt,settings:ut,template_name:g,custom_codes:Object.keys(ce).length>0?ce:void 0,seo:Object.keys($).length>0?$:void 0});t.format==="json"?d(de,"json"):de.success?(p("Page updated successfully"),console.log(` Page ID: ${de.result?.page_id}`)):s("Failed to update page");}catch(a){W(a);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!k__namespace.existsSync(H)){r("No preview server is running");return}let e=parseInt(k__namespace.readFileSync(H,"utf-8").trim(),10);if(isNaN(e)){s("Invalid PID file"),Oe();return}try{process.kill(e,"SIGTERM"),p(`Preview server (PID ${e}) stopped`);}catch(n){n.code==="ESRCH"?r("Preview server process not found (may have already stopped)"):s(`Failed to stop preview server: ${n.message}`);}Oe();}catch(e){e instanceof Error?s(e.message):s("An unexpected error occurred"),process.exit(1);}}),o}function K(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function W(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function Oe(){try{k__namespace.existsSync(H)&&k__namespace.unlinkSync(H);}catch{}try{k__namespace.existsSync(ie)&&k__namespace.unlinkSync(ie);}catch{}}async function Ve(){if(k__namespace.existsSync(H)){try{let o=parseInt(k__namespace.readFileSync(H,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),r(`Terminated existing preview server (PID ${o})`),await new Promise(e=>setTimeout(e,500));}catch{}}catch{}Oe();}}async function Je(o){let e=L__namespace.resolve(o),n=`
41
210
  const http = require('node:http');
42
211
  const fs = require('node:fs');
43
212
  const path = require('node:path');
@@ -57,7 +226,7 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
57
226
  })();
58
227
  </script>\`;
59
228
 
60
- const filePath = ${JSON.stringify(t)};
229
+ const filePath = ${JSON.stringify(e)};
61
230
  const pidFile = path.join(os.tmpdir(), 'lindoai-pages-preview.pid');
62
231
  const portFile = path.join(os.tmpdir(), 'lindoai-pages-preview.port');
63
232
  const sseClients = new Set();
@@ -157,9 +326,31 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
157
326
  });
158
327
  } catch {}
159
328
  });
160
- `,e=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});e.unref();let i=null;for(let m=0;m<50;m++)if(await new Promise(p=>setTimeout(p,100)),w__namespace.existsSync(z))try{if(i=parseInt(w__namespace.readFileSync(z,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(r("Failed to start preview server"),process.exit(1));let a=`http://127.0.0.1:${i}/`;await L(a)||s(`Could not open browser. Visit: ${a}`),d("Preview server started in background"),console.log(` URL: ${a}`),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 At(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(ue(),pe));s("Starting preview server...");let n=await t(o),e=`http://127.0.0.1:${n}/`;w__namespace.writeFileSync(N,process.pid.toString(),"utf-8"),w__namespace.writeFileSync(z,n.toString(),"utf-8"),await L(e)||s(`Could not open browser. Visit: ${e}`),d("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 q=j__namespace.join(de__namespace.tmpdir(),"lindoai-blogs-preview.pid"),Q=j__namespace.join(de__namespace.tmpdir(),"lindoai-blogs-preview.port");function ye(){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=U();try{let e=await n.blogs.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")c(e,"json");else {let i=e.result;if(i?.list&&i.list.length>0){console.log(`
161
- Blogs:`),console.log("------");for(let a of i.list)console.log(` ID: ${a.blog_id}`),console.log(` Name: ${a.name??"N/A"}`),console.log(` Path: ${a.path??"N/A"}`),console.log(` Status: ${a.status??"N/A"}`),console.log(` Published: ${a.publish_date?new Date(a.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else s("No blogs found");}}catch(e){K(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=U();try{let e=await n.blogs.get(t.website,t.id);if(t.format==="json")c(e,"json");else {let i=e.result;i?(console.log(`
162
- 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"}`)):r("Blog not found");}}catch(e){K(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=U();try{let e=await n.blogs.publish(t.website,t.id);t.format==="json"?c(e,"json"):e.success?(d("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"}`)):r("Failed to publish blog");}catch(e){K(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=U();try{let e=await n.blogs.unpublish(t.website,t.id);t.format==="json"?c(e,"json"):e.success?(d("Blog unpublished successfully"),console.log(` Blog ID: ${e.result?.blog_id}`)):r("Failed to unpublish blog");}catch(e){K(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=U();try{let e=await n.blogs.delete(t.website,t.id);if(t.format==="json")c(e,"json");else if(e.success){if(d("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 r("Failed to delete blog");}catch(e){K(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=U();try{s("Fetching blog details...");let a=await i.blogs.get(t,n);a.result||(r("Blog not found"),process.exit(1));let l=a.result.path,m=await i.websites.getDetails(t);m.result||(r("Website not found"),process.exit(1));let p=m.result.custom_domain||m.result.verified_domain||m.result.preview_url;p||(r("Could not determine website URL"),process.exit(1));let b=`https://${p}${l}`;s(`Fetching HTML from ${b}...`);let g=await fetch(b);g.ok||(r(`Failed to fetch blog HTML: ${g.status} ${g.statusText}`),s("Make sure the blog is published before editing"),process.exit(1));let v=await g.text(),u=j__namespace.resolve(e.file);w__namespace.writeFileSync(u,v,"utf-8"),d(`HTML saved to ${u}`),await Dt(),e.background?await Rt(u):await jt(u);}catch(a){K(a);}}),o.command("update").description("Update a blog").argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--html-file <path>","Path to local HTML file to upload").option("-f, --format <format>","Output format (json, table)","table").action(async(t,n,e)=>{let i=U(),a=h();try{e.htmlFile||(r("--html-file option is required"),s("Usage: lindoai blogs update <website_id> <blog_id> --html-file <path>"),process.exit(1));let l=j__namespace.resolve(e.htmlFile);w__namespace.existsSync(l)||(r(`File not found: ${l}`),process.exit(1));let m=w__namespace.readFileSync(l,"utf-8");s(`Read ${m.length} bytes from ${l}`);let p=await i.blogs.get(t,n);p.result||(r("Blog not found"),process.exit(1));let b=p.result.path;s("Updating blog...");let v=`${a.baseUrl||"https://api.lindo.ai"}/v1/workspace/website/${t}/blogs/${n}/update`,f=await(await fetch(v,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({html:m,path:b})})).json();if(e.format==="json")c(f,"json");else if(f.success)d("Blog updated successfully"),console.log(` Blog ID: ${f.result?.blog_id}`),f.result?.publish_date&&console.log(` Published at: ${new Date(f.result.publish_date*1e3).toISOString()}`);else if(r("Failed to update blog"),f.errors)for(let S of f.errors)console.log(` ${S}`);}catch(l){K(l);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!w__namespace.existsSync(q)){s("No preview server is running");return}let t=parseInt(w__namespace.readFileSync(q,"utf-8").trim(),10);if(isNaN(t)){r("Invalid PID file"),be();return}try{process.kill(t,"SIGTERM"),d(`Preview server (PID ${t}) stopped`);}catch(n){n.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):r(`Failed to stop preview server: ${n.message}`);}be();}catch(t){t instanceof Error?r(t.message):r("An unexpected error occurred"),process.exit(1);}}),o}function U(){C()||(r("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=h();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function K(o){o instanceof lindoai.AuthenticationError&&(r("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?r(o.message):r("An unexpected error occurred"),process.exit(1);}function be(){try{w__namespace.existsSync(q)&&w__namespace.unlinkSync(q);}catch{}try{w__namespace.existsSync(Q)&&w__namespace.unlinkSync(Q);}catch{}}async function Dt(){if(w__namespace.existsSync(q)){try{let o=parseInt(w__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{}be();}}async function Rt(o){let t=j__namespace.resolve(o),n=`
329
+ `,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let m=0;m<50;m++)if(await new Promise(l=>setTimeout(l,100)),k__namespace.existsSync(ie))try{if(i=parseInt(k__namespace.readFileSync(ie,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(s("Failed to start preview server"),process.exit(1));let a=`http://127.0.0.1:${i}/`;await R(a)||r(`Could not open browser. Visit: ${a}`),p("Preview server started in background"),console.log(` URL: ${a}`),console.log(` PID: ${t.pid}`),console.log(""),r("To update the page: lindoai pages update <website_id> <page_id> --html-file <path>"),r("To stop the server: lindoai pages stop-preview");}async function Qe(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Se(),_e));r("Starting preview server...");let n=await e(o),t=`http://127.0.0.1:${n}/`;k__namespace.writeFileSync(H,process.pid.toString(),"utf-8"),k__namespace.writeFileSync(ie,n.toString(),"utf-8"),await R(t)||r(`Could not open browser. Visit: ${t}`),p("Preview server started"),console.log(` URL: ${t}`),console.log(""),r("Press Ctrl+C to stop the server"),r("Edit the HTML file and save to see changes in the browser");}var q=L__namespace.join(ke__namespace.tmpdir(),"lindoai-blogs-preview.pid"),re=L__namespace.join(ke__namespace.tmpdir(),"lindoai-blogs-preview.port");function Te(){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=M();try{let t=await n.blogs.list(e.website,{page:parseInt(e.page,10),search:e.search});if(e.format==="json")d(t,"json");else {let i=t.result;if(i?.list&&i.list.length>0){console.log(`
330
+ Blogs:`),console.log("------");for(let a of i.list)console.log(` ID: ${a.blog_id}`),console.log(` Name: ${a.name??"N/A"}`),console.log(` Path: ${a.path??"N/A"}`),console.log(` Status: ${a.status??"N/A"}`),console.log(` Published: ${a.publish_date?new Date(a.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${i.total??i.list.length}`);}else r("No blogs found");}}catch(t){U(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=M();try{let t=await n.blogs.get(e.website,e.id);if(e.format==="json")d(t,"json");else {let i=t.result;i?(console.log(`
331
+ 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"}`)):s("Blog not found");}}catch(t){U(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=M();try{let t=await n.blogs.publish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(p("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"}`)):s("Failed to publish blog");}catch(t){U(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=M();try{let t=await n.blogs.unpublish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(p("Blog unpublished successfully"),console.log(` Blog ID: ${t.result?.blog_id}`)):s("Failed to unpublish blog");}catch(t){U(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=M();try{let t=await n.blogs.delete(e.website,e.id);if(e.format==="json")d(t,"json");else if(t.success){if(p("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 s("Failed to delete blog");}catch(t){U(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=M();try{r("Fetching blog content...");let a=await i.blogs.getHtml(e,n);a.result||(s("Blog not found"),process.exit(1));let c=a.result,m=await i.websites.getDetails(e);m.result||(s("Website not found"),process.exit(1));let l=m.result,f=c.seo||{},g=c.blog_settings||{},y=c.blog_content||"<p>Start writing your blog content here...</p>",u=tt({seo:f,blogSettings:g,blogContent:y,websiteName:l.business_name||"Blog",blogPath:l.theme?.blog_path||"blog"}),h=L__namespace.resolve(t.file);k__namespace.writeFileSync(h,u,"utf-8"),p(`HTML saved to ${h}`),await Xe(),t.background?await Ze(h):await et(h),console.log(""),r(`To save changes: lindoai blogs update ${e} ${n} --html-file ${t.file}`);}catch(a){U(a);}}),o.command("update").description("Update a blog from HTML file").argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--html-file <path>","Path to local HTML file").option("--md-file <path>","Path to local Markdown file").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=M();try{!t.htmlFile&&!t.mdFile&&(s("Either --html-file or --md-file option is required"),r("Usage: lindoai blogs update <website_id> <blog_id> --html-file <path>"),r(" or: lindoai blogs update <website_id> <blog_id> --md-file <path>"),process.exit(1));let a,c={},m={};if(t.mdFile){let v=L__namespace.resolve(t.mdFile);k__namespace.existsSync(v)||(s(`File not found: ${v}`),process.exit(1));let b=k__namespace.readFileSync(v,"utf-8");r(`Read ${b.length} bytes from ${v}`);let{content:x,frontmatter:w}=io(b);a=ro(x),w.title&&(c.page_title=w.title),w.description&&(c.meta_description=w.description),w.image&&(c.social_image=w.image),w.author&&(m.author=w.author),w.excerpt&&(m.excerpt=w.excerpt),w.category&&(m.category=w.category),w.date&&(m.publish_date=w.date);}else {let v=L__namespace.resolve(t.htmlFile);k__namespace.existsSync(v)||(s(`File not found: ${v}`),process.exit(1));let b=k__namespace.readFileSync(v,"utf-8");r(`Read ${b.length} bytes from ${v}`);let x=b.match(/<article[^>]*class="[^"]*prose[^"]*"[^>]*>([\s\S]*?)<\/article>/i);a=x?x[1].trim():"",a||(s("Could not extract blog content from HTML"),r('Make sure the blog content is inside <article class="...prose...">...</article>'),process.exit(1));let w=b.match(/<title>([^<]*)<\/title>/i),Z=b.match(/<meta\s+name="description"\s+content="([^"]*)"/i),ee=b.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i);w&&(c.page_title=w[1].trim()),Z&&(c.meta_description=Z[1]),ee&&(c.social_image=ee[1]);let ae=b.match(/id="blog-author-display"[^>]*>([^<]*)</i),B=b.match(/class="[^"]*bg-blue-500\/10[^"]*"[^>]*>([^<]*)</i),G=b.match(/class="[^"]*border-l-4 border-blue-500[^"]*"[^>]*>([\s\S]*?)<\/div>/i),Y=b.match(/<time[^>]*>([^<]*)<\/time>/i),z=b.match(/<span>(\d+\s*min\s*read)<\/span>/i),V=b.match(/<div class="aspect-video[^"]*"[^>]*>\s*<img[^>]*src="([^"]*)"/i);ae&&(m.author=ae[1].trim()),B&&(m.category=B[1].trim()),G&&(m.excerpt=G[1].trim()),Y&&(m.publish_date=Y[1].trim()),z&&(m.read_time=z[1].trim()),V&&!c.social_image&&(c.social_image=V[1]),r("Extracted blog content and metadata");}let l=await i.blogs.get(e,n);l.result||(s("Blog not found"),process.exit(1));let f=l.result,g=f.path,y={page_title:c.page_title||f.seo?.page_title||"Untitled",meta_description:c.meta_description||f.seo?.meta_description,social_title:c.social_title||f.seo?.social_title,social_description:c.social_description||f.seo?.social_description,social_image:c.social_image||f.seo?.social_image},u={author:m.author||f.blog_settings?.author||"Anonymous",excerpt:m.excerpt||f.blog_settings?.excerpt,category:m.category||f.blog_settings?.category,publish_date:m.publish_date||f.blog_settings?.publish_date,read_time:m.read_time||f.blog_settings?.read_time,author_image:m.author_image||f.blog_settings?.author_image};r("Updating blog...");let h=await i.blogs.publish(e,n,{path:g,blog_content:a,seo:y,blog_settings:u});t.format==="json"?d(h,"json"):h.success?(p("Blog updated successfully"),console.log(` Blog ID: ${h.result?.blog_id}`)):s("Failed to update blog");}catch(a){U(a);}}),o.command("create").description("Create a new blog with live preview").argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--title <title>","Blog title","New Blog Post").option("--author <author>","Author name","Anonymous").option("--file <path>","Output file path","./blog.html").option("--background","Run preview server in background").action(async(e,n,t)=>{let i=M();try{let a=await i.websites.getDetails(e);a.result||(s("Website not found"),process.exit(1));let c=a.result,m=t.title,l=t.author,f=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),g=`<h2>Introduction</h2>
332
+ <p>Welcome to your new blog post! This is a starter template to help you get started. Edit this content to create your own amazing blog post.</p>
333
+
334
+ <h2>Getting Started</h2>
335
+ <p>Here are some tips for writing great blog content:</p>
336
+ <ul>
337
+ <li>Start with a compelling introduction that hooks your readers</li>
338
+ <li>Break up your content with headings and subheadings</li>
339
+ <li>Use bullet points and numbered lists for easy scanning</li>
340
+ <li>Include relevant images to illustrate your points</li>
341
+ <li>End with a clear call-to-action or conclusion</li>
342
+ </ul>
343
+
344
+ <h2>Adding Code Examples</h2>
345
+ <p>If you're writing technical content, you can include code blocks:</p>
346
+ <pre><code>function greet(name) {
347
+ return \`Hello, \${name}!\`;
348
+ }
349
+
350
+ console.log(greet('World'));</code></pre>
351
+
352
+ <h2>Conclusion</h2>
353
+ <p>Now it's your turn! Replace this content with your own ideas and publish your blog post to share it with the world.</p>`,y={page_title:m,meta_description:`Read ${m} by ${l}`,social_title:m,social_description:`Read ${m} by ${l}`},u={author:l,excerpt:"A new blog post. Edit this excerpt to provide a summary of your content.",publish_date:f,read_time:"3 min read"};r("Creating blog...");let h=await i.blogs.create(e,{path:n,blog_content:g,seo:y,blog_settings:u});h.success||(s("Failed to create blog"),process.exit(1));let v=h.result.blog_id;p(`Blog created: ${v}`);let b=tt({seo:y,blogSettings:u,blogContent:g,websiteName:c.business_name||"Blog",blogPath:c.theme?.blog_path||"blog"}),x=L__namespace.resolve(t.file);k__namespace.writeFileSync(x,b,"utf-8"),p(`HTML saved to ${x}`),await Xe(),t.background?await Ze(x):await et(x),console.log(""),r(`To save changes: lindoai blogs update ${e} ${v} --html-file ${t.file}`);}catch(a){U(a);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!k__namespace.existsSync(q)){r("No preview server is running");return}let e=parseInt(k__namespace.readFileSync(q,"utf-8").trim(),10);if(isNaN(e)){s("Invalid PID file"),Pe();return}try{process.kill(e,"SIGTERM"),p(`Preview server (PID ${e}) stopped`);}catch(n){n.code==="ESRCH"?r("Preview server process not found (may have already stopped)"):s(`Failed to stop preview server: ${n.message}`);}Pe();}catch(e){e instanceof Error?s(e.message):s("An unexpected error occurred"),process.exit(1);}}),o}function M(){S()||(s("API key not configured"),r("Run: lindo config set apiKey <your-api-key>"),r("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=C();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function U(o){o instanceof lindoai.AuthenticationError&&(s("Authentication failed"),r("Your API key may be invalid or expired"),r("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?s(o.message):s("An unexpected error occurred"),process.exit(1);}function Pe(){try{k__namespace.existsSync(q)&&k__namespace.unlinkSync(q);}catch{}try{k__namespace.existsSync(re)&&k__namespace.unlinkSync(re);}catch{}}async function Xe(){if(k__namespace.existsSync(q)){try{let o=parseInt(k__namespace.readFileSync(q,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),r(`Terminated existing preview server (PID ${o})`),await new Promise(e=>setTimeout(e,500));}catch{}}catch{}Pe();}}async function Ze(o){let e=L__namespace.resolve(o),n=`
163
354
  const http = require('node:http');
164
355
  const fs = require('node:fs');
165
356
  const path = require('node:path');
@@ -179,7 +370,7 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
179
370
  })();
180
371
  </script>\`;
181
372
 
182
- const filePath = ${JSON.stringify(t)};
373
+ const filePath = ${JSON.stringify(e)};
183
374
  const pidFile = path.join(os.tmpdir(), 'lindoai-blogs-preview.pid');
184
375
  const portFile = path.join(os.tmpdir(), 'lindoai-blogs-preview.port');
185
376
  const sseClients = new Set();
@@ -279,7 +470,187 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
279
470
  });
280
471
  } catch {}
281
472
  });
282
- `,e=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});e.unref();let i=null;for(let m=0;m<50;m++)if(await new Promise(p=>setTimeout(p,100)),w__namespace.existsSync(Q))try{if(i=parseInt(w__namespace.readFileSync(Q,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(r("Failed to start preview server"),process.exit(1));let a=`http://127.0.0.1:${i}/`;await L(a)||s(`Could not open browser. Visit: ${a}`),d("Preview server started in background"),console.log(` URL: ${a}`),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 jt(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(ue(),pe));s("Starting preview server...");let n=await t(o),e=`http://127.0.0.1:${n}/`;w__namespace.writeFileSync(q,process.pid.toString(),"utf-8"),w__namespace.writeFileSync(Q,n.toString(),"utf-8"),await L(e)||s(`Could not open browser. Visit: ${e}`),d("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 Re(){return De__namespace.randomBytes(32).toString("hex")}function je(o,t){return o===t}function Ut(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 Kt(){return `<!DOCTYPE html>
473
+ `,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let m=0;m<50;m++)if(await new Promise(l=>setTimeout(l,100)),k__namespace.existsSync(re))try{if(i=parseInt(k__namespace.readFileSync(re,"utf-8").trim(),10),!isNaN(i))break}catch{}i||(s("Failed to start preview server"),process.exit(1));let a=`http://127.0.0.1:${i}/`;await R(a)||r(`Could not open browser. Visit: ${a}`),p("Preview server started in background"),console.log(` URL: ${a}`),console.log(` PID: ${t.pid}`),console.log(""),r("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),r("To stop the server: lindoai blogs stop-preview");}async function et(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Se(),_e));r("Starting preview server...");let n=await e(o),t=`http://127.0.0.1:${n}/`;k__namespace.writeFileSync(q,process.pid.toString(),"utf-8"),k__namespace.writeFileSync(re,n.toString(),"utf-8"),await R(t)||r(`Could not open browser. Visit: ${t}`),p("Preview server started"),console.log(` URL: ${t}`),console.log(""),r("Press Ctrl+C to stop the server"),r("Edit the HTML file and save to see changes in the browser");}function no(o){return o?o.split(" ").map(e=>e.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function tt(o){let{seo:e,blogSettings:n,blogContent:t,websiteName:i,blogPath:a}=o;return `<!DOCTYPE html>
474
+ <html class="dark" lang="en">
475
+ <head>
476
+ <meta charset="UTF-8">
477
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
478
+
479
+ <title>${e.page_title||"Blog Post"}</title>
480
+ <meta name="description" content="${e.meta_description||""}">
481
+
482
+ <meta property="og:title" content="${e.social_title||e.page_title||""}">
483
+ <meta property="og:description" content="${e.social_description||e.meta_description||""}">
484
+ ${e.social_image?`<meta property="og:image" content="${e.social_image}">`:""}
485
+ <meta property="og:type" content="article">
486
+
487
+ <meta name="twitter:card" content="summary_large_image">
488
+ <meta name="twitter:title" content="${e.social_title||e.page_title||""}">
489
+ <meta name="twitter:description" content="${e.social_description||e.meta_description||""}">
490
+ ${e.social_image?`<meta name="twitter:image" content="${e.social_image}">`:""}
491
+
492
+ <!-- Tailwind CSS v4 CDN for preview -->
493
+ <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
494
+
495
+ <style>
496
+ /* Required default styles for content */
497
+ blockquote, dd, dl, figure, h1, h2, h3, h4, h5, h6, hr, p, pre {
498
+ margin: revert;
499
+ }
500
+ menu, ol, ul {
501
+ list-style: revert;
502
+ margin: revert;
503
+ padding: revert;
504
+ }
505
+ /* Reading progress bar */
506
+ #reading-progress {
507
+ position: fixed;
508
+ top: 0;
509
+ left: 0;
510
+ width: 0%;
511
+ height: 3px;
512
+ background: linear-gradient(90deg, #3b82f6, #8b5cf6);
513
+ z-index: 1000;
514
+ transition: width 0.25s ease;
515
+ }
516
+ /* Custom scrollbar for dark mode */
517
+ .dark ::-webkit-scrollbar { width: 8px; }
518
+ .dark ::-webkit-scrollbar-track { background: #1f2937; }
519
+ .dark ::-webkit-scrollbar-thumb { background: #4b5563; border-radius: 4px; }
520
+ .dark ::-webkit-scrollbar-thumb:hover { background: #6b7280; }
521
+ </style>
522
+ </head>
523
+ <body>
524
+ <div class="bg-white dark:bg-neutral-950 text-gray-900 dark:text-neutral-100 font-sans antialiased min-h-screen">
525
+ <!-- Reading Progress Bar -->
526
+ <div id="reading-progress"></div>
527
+
528
+ <!-- Navigation -->
529
+ <nav class="fixed w-full top-0 z-50 bg-white/90 dark:bg-neutral-950/90 backdrop-blur-lg border-b border-gray-200 dark:border-neutral-800">
530
+ <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
531
+ <div class="flex justify-between items-center py-4">
532
+ <div class="flex items-center space-x-2">
533
+ <a href="/${a}" class="flex items-center space-x-2 text-gray-600 dark:text-neutral-300 hover:text-gray-900 dark:hover:text-white transition-colors">
534
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
535
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
536
+ </svg>
537
+ </a>
538
+ </div>
539
+ <div class="flex items-center space-x-4">
540
+ <button onclick="copyLink()" class="text-gray-500 dark:text-neutral-400 hover:text-green-500 dark:hover:text-green-400 transition-colors">
541
+ <svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
542
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path>
543
+ </svg>
544
+ </button>
545
+ <button onclick="toggleTheme()" class="text-gray-500 dark:text-neutral-400 hover:text-gray-900 dark:hover:text-white p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-neutral-800 transition-all hover:scale-110">
546
+ <svg class="w-5 h-5 hidden dark:block" fill="none" stroke="currentColor" viewBox="0 0 24 24">
547
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"></path>
548
+ </svg>
549
+ <svg class="w-5 h-5 block dark:hidden" fill="none" stroke="currentColor" viewBox="0 0 24 24">
550
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"></path>
551
+ </svg>
552
+ </button>
553
+ </div>
554
+ </div>
555
+ </div>
556
+ </nav>
557
+
558
+ <!-- Article Header -->
559
+ <header class="pt-24 pb-8 px-4 sm:px-6 lg:px-8">
560
+ <article class="max-w-4xl mx-auto">
561
+ ${n.category?`
562
+ <div class="mb-6">
563
+ <span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-500/10 text-blue-600 dark:text-blue-400 border border-blue-500/20">
564
+ ${n.category}
565
+ </span>
566
+ </div>
567
+ `:""}
568
+
569
+ <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">
570
+ ${e.page_title||"Untitled"}
571
+ </h1>
572
+
573
+ <div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-neutral-400 mb-8">
574
+ <div class="flex items-center space-x-2">
575
+ <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">
576
+ ${no(n.author||"Anonymous")}
577
+ </div>
578
+ <span id="blog-author-display" class="font-medium text-neutral-200">
579
+ ${n.author||"Anonymous"}
580
+ </span>
581
+ </div>
582
+ <span>\u2022</span>
583
+ <time>${n.publish_date||new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}</time>
584
+ <span>\u2022</span>
585
+ <span>${n.read_time||"4 min read"}</span>
586
+ </div>
587
+
588
+ ${e.social_image?`
589
+ <div class="aspect-video rounded-xl overflow-hidden mb-8">
590
+ <img src="${e.social_image}" alt="" class="w-full h-full object-cover">
591
+ </div>
592
+ `:""}
593
+
594
+ ${n.excerpt?`
595
+ <div class="text-xl text-gray-700 dark:text-neutral-300 leading-relaxed mb-8 italic border-l-4 border-blue-500 pl-6">
596
+ ${n.excerpt}
597
+ </div>
598
+ `:""}
599
+ </article>
600
+ </header>
601
+
602
+ <!-- Article Content -->
603
+ <main class="px-4 sm:px-6 lg:px-8 pb-16">
604
+ <article class="max-w-3xl mx-auto prose prose-lg prose-gray dark:prose-invert">
605
+ ${t}
606
+ </article>
607
+ </main>
608
+
609
+ <!-- Footer -->
610
+ <footer class="bg-gray-50 dark:bg-neutral-900 border-t border-gray-200 dark:border-neutral-800 py-8 px-4 sm:px-6 lg:px-8">
611
+ <div class="max-w-4xl mx-auto text-center">
612
+ <p class="text-gray-600 dark:text-neutral-400">&copy; ${new Date().getFullYear()}. ${i}.</p>
613
+ </div>
614
+ </footer>
615
+ </div>
616
+
617
+ <script>
618
+ function toggleTheme() {
619
+ const html = document.documentElement;
620
+ if (html.classList.contains('dark')) {
621
+ html.classList.remove('dark');
622
+ localStorage.setItem('theme', 'light');
623
+ } else {
624
+ html.classList.add('dark');
625
+ localStorage.setItem('theme', 'dark');
626
+ }
627
+ }
628
+ document.addEventListener('DOMContentLoaded', () => {
629
+ const savedTheme = localStorage.getItem('theme');
630
+ if (savedTheme === 'dark' || !savedTheme) {
631
+ document.documentElement.classList.add('dark');
632
+ }
633
+ });
634
+ window.addEventListener('scroll', () => {
635
+ const scrollTop = window.pageYOffset;
636
+ const docHeight = document.documentElement.scrollHeight - window.innerHeight;
637
+ const scrollPercent = (scrollTop / docHeight) * 100;
638
+ document.getElementById('reading-progress').style.width = scrollPercent + '%';
639
+ });
640
+ function copyLink() {
641
+ navigator.clipboard.writeText(window.location.href).then(() => {
642
+ alert('Link copied to clipboard!');
643
+ });
644
+ }
645
+ </script>
646
+
647
+ <!-- Config script -->
648
+ <script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
649
+ </body>
650
+ </html>`}function io(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 a of i.split(`
651
+ `)){let c=a.indexOf(":");if(c!==-1){let m=a.slice(0,c).trim(),l=a.slice(c+1).trim();(l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'"))&&(l=l.slice(1,-1)),e[m]=l;}}}}return {content:n,frontmatter:e}}function ro(o){let e=o;return 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(/```(\w*)\n([\s\S]*?)```/g,"<pre><code>$2</code></pre>"),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,"<ul>$&</ul>"),e=e.replace(/^\d+\. (.+)$/gm,"<li>$1</li>"),e=e.split(`
652
+ `).map(i=>{let a=i.trim();return a?a.startsWith("<")?i:`<p>${a}</p>`:""}).join(`
653
+ `),e=e.replace(/<p><\/p>/g,""),e}function nt(){return ot__namespace.randomBytes(32).toString("hex")}function it(o,e){return o===e}function so(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 co(){return `<!DOCTYPE html>
283
654
  <html lang="en">
284
655
  <head>
285
656
  <meta charset="UTF-8">
@@ -325,7 +696,7 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
325
696
  <p>You can close this window and return to your terminal.</p>
326
697
  </div>
327
698
  </body>
328
- </html>`}function X(o){return `<!DOCTYPE html>
699
+ </html>`}function le(o){return `<!DOCTYPE html>
329
700
  <html lang="en">
330
701
  <head>
331
702
  <meta charset="UTF-8">
@@ -380,7 +751,7 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
380
751
  <div class="error-message">${o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</div>
381
752
  </div>
382
753
  </body>
383
- </html>`}function Wt(){return `<!DOCTYPE html>
754
+ </html>`}function lo(){return `<!DOCTYPE html>
384
755
  <html lang="en">
385
756
  <head>
386
757
  <meta charset="UTF-8">
@@ -418,13 +789,13 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
418
789
  <p>This endpoint is not available.</p>
419
790
  </div>
420
791
  </body>
421
- </html>`}function Ue(){let o=null,t=null;function n(e,i){let a=e.url||"/",l=e.method||"GET",m=a==="/callback"||a.startsWith("/callback?");if(l!=="GET"||!m){i.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),i.end(Wt());return}let p=Ut(a);if(!t){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(X("No pending authorization request"));return}let{expectedState:b,resolve:g,timeoutId:v}=t;if(clearTimeout(v),t=null,p.error){let u=p.message||p.error;i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(X(u)),g({success:false,error:u});return}if(!p.state||!je(p.state,b)){let u="State token mismatch - possible CSRF attack";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(X(u)),g({success:false,error:u});return}if(!p.key){let u="No API key received";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(X(u)),g({success:false,error:u});return}i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(Kt()),g({success:true,apiKey:p.key});}return {async start(){return new Promise((e,i)=>{o=Ee__namespace.createServer(n),o.on("error",a=>{i(new Error(`Failed to start callback server: ${a.message}`));}),o.listen(0,"127.0.0.1",()=>{let a=o.address();if(!a||typeof a=="string"){i(new Error("Failed to get server address"));return}let l=a.port,m=`http://127.0.0.1:${l}/callback`;e({port:l,url:m});});})},waitForCallback(e,i){return new Promise(a=>{let l=setTimeout(()=>{t&&(t=null,a({success:false,error:"Login timed out waiting for authorization"}));},i);t={expectedState:e,resolve:a,timeoutId:l};})},async stop(){return new Promise(e=>{t&&(clearTimeout(t.timeoutId),t=null),o?o.close(()=>{o=null,e();}):e();})}}}var Mt="https://app.lindo.ai",Bt=120;function Ht(o,t){let n=`http://127.0.0.1:${t}/callback`,e=new URLSearchParams({state:o,callback_url:n});return `${Mt}/cli/authorize?${e.toString()}`}function ve(){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(Bt)).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,a=Ue(),l=false;try{s("Starting authentication flow...");let{port:m}=await a.start();l=!0;let p=Re(),b=Ht(p,m);i?(s("Opening browser for authorization..."),await L(b)||(s("Could not open browser automatically."),console.log(`
792
+ </html>`}function at(){let o=null,e=null;function n(t,i){let a=t.url||"/",c=t.method||"GET",m=a==="/callback"||a.startsWith("/callback?");if(c!=="GET"||!m){i.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),i.end(lo());return}let l=so(a);if(!e){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(le("No pending authorization request"));return}let{expectedState:f,resolve:g,timeoutId:y}=e;if(clearTimeout(y),e=null,l.error){let u=l.message||l.error;i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(le(u)),g({success:false,error:u});return}if(!l.state||!it(l.state,f)){let u="State token mismatch - possible CSRF attack";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(le(u)),g({success:false,error:u});return}if(!l.key){let u="No API key received";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(le(u)),g({success:false,error:u});return}i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(co()),g({success:true,apiKey:l.key});}return {async start(){return new Promise((t,i)=>{o=Ye__namespace.createServer(n),o.on("error",a=>{i(new Error(`Failed to start callback server: ${a.message}`));}),o.listen(0,"127.0.0.1",()=>{let a=o.address();if(!a||typeof a=="string"){i(new Error("Failed to get server address"));return}let c=a.port,m=`http://127.0.0.1:${c}/callback`;t({port:c,url:m});});})},waitForCallback(t,i){return new Promise(a=>{let c=setTimeout(()=>{e&&(e=null,a({success:false,error:"Login timed out waiting for authorization"}));},i);e={expectedState:t,resolve:a,timeoutId:c};})},async stop(){return new Promise(t=>{e&&(clearTimeout(e.timeoutId),e=null),o?o.close(()=>{o=null,t();}):t();})}}}var po="https://app.lindo.ai",uo=120;function fo(o,e){let n=`http://127.0.0.1:${e}/callback`,t=new URLSearchParams({state:o,callback_url:n});return `${po}/cli/authorize?${t.toString()}`}function Ae(){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(uo)).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,a=at(),c=false;try{r("Starting authentication flow...");let{port:m}=await a.start();c=!0;let l=nt(),f=fo(l,m);i?(r("Opening browser for authorization..."),await R(f)||(r("Could not open browser automatically."),console.log(`
422
793
  Please open this URL in your browser:`),console.log(`
423
- ${b}
794
+ ${f}
424
795
  `))):(console.log(`
425
796
  Please open this URL in your browser:`),console.log(`
426
- ${b}
427
- `)),s(`Waiting for authorization (timeout: ${n}s)...`);let g=await a.waitForCallback(p,e);g.success&&g.apiKey?(Pe(g.apiKey),d("Successfully authenticated!"),s(`API key saved to: ${T()}`)):(r(g.error||"Authentication failed"),process.exit(1));}catch(m){r(m instanceof Error?m.message:"An unexpected error occurred"),process.exit(1);}finally{l&&await a.stop();}})}var Ce=j__namespace.join(de__namespace.homedir(),".config","opencode","skills","lindoai"),qe=j__namespace.join(Ce,"SKILL.md"),Jt=`---
797
+ ${f}
798
+ `)),r(`Waiting for authorization (timeout: ${n}s)...`);let g=await a.waitForCallback(l,t);g.success&&g.apiKey?(Ke(g.apiKey),p("Successfully authenticated!"),r(`API key saved to: ${E()}`)):(s(g.error||"Authentication failed"),process.exit(1));}catch(m){s(m instanceof Error?m.message:"An unexpected error occurred"),process.exit(1);}finally{c&&await a.stop();}})}var Ee=L__namespace.join(ke__namespace.homedir(),".config","opencode","skills","lindoai"),lt=L__namespace.join(Ee,"SKILL.md"),bo=`---
428
799
  name: lindoai
429
800
  description: Lindo AI CLI - Command-line interface for the Lindo API
430
801
  ---
@@ -592,5 +963,5 @@ lindoai config set baseUrl <value>
592
963
  3. **Run preview servers in background mode** (\`--background\`) to keep the terminal available.
593
964
  4. **Remember to stop preview servers** when done editing with \`stop-preview\`.
594
965
  5. **Use JSON format** (\`--format json\`) when you need to parse command output programmatically.
595
- `;function Vt(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function zt(){try{return s("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function Qt(){w__namespace.existsSync(Ce)||w__namespace.mkdirSync(Ce,{recursive:true}),w__namespace.writeFileSync(qe,Jt,"utf-8");}function xe(){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=>{Vt()||(t.install?(zt()||(r("Failed to install OpenCode"),s("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),d("OpenCode installed successfully")):(r("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{Qt(),s(`Skill file installed to: ${qe}`);}catch(i){r(`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=>{r(`Failed to launch OpenCode: ${i.message}`),process.exit(1);}),e.on("close",i=>{process.exit(i??0);});})}var eo="1.0.0";function to(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(eo,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(ne()),o.addCommand(ie()),o.addCommand(re()),o.addCommand(se()),o.addCommand(ae()),o.addCommand(ce()),o.addCommand(le()),o.addCommand(he()),o.addCommand(ye()),o.addCommand(ve()),o.addCommand(xe()),o.exitOverride(t=>{throw t.code==="commander.help"&&process.exit(0),t.code==="commander.version"&&process.exit(0),t.code==="commander.missingArgument"&&(r(t.message),process.exit(1)),t.code==="commander.unknownCommand"&&(r(t.message),s('Run "lindo --help" for available commands'),process.exit(1)),t}),o}function oo(o){r("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 no(){let o=to();try{await o.parseAsync(process.argv);}catch(t){throw t instanceof lindoai.AuthenticationError&&(oo(),process.exit(1)),t}}no().catch(o=>{o instanceof Error?r(`Unexpected error: ${o.message}`):r("An unexpected error occurred"),process.exit(1);});
596
- exports.createProgram=to;
966
+ `;function wo(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function yo(){try{return r("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function vo(){k__namespace.existsSync(Ee)||k__namespace.mkdirSync(Ee,{recursive:true}),k__namespace.writeFileSync(lt,bo,"utf-8");}function Le(){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=>{wo()||(e.install?(yo()||(s("Failed to install OpenCode"),r("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),p("OpenCode installed successfully")):(s("OpenCode is not installed"),r(""),r("To install OpenCode, run one of the following:"),r(" lindoai agent --install"),r(" npm install -g opencode-ai@latest"),process.exit(1)));try{vo(),r(`Skill file installed to: ${lt}`);}catch(i){s(`Failed to install skill file: ${i instanceof Error?i.message:"Unknown error"}`),process.exit(1);}let n=[];e.model&&n.push("--model",e.model),r("Launching OpenCode...");let t=child_process.spawn("opencode",n,{stdio:"inherit",shell:true});t.on("error",i=>{s(`Failed to launch OpenCode: ${i.message}`),process.exit(1);}),t.on("close",i=>{process.exit(i??0);});})}var Co="1.0.0";function _o(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(Co,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(ge()),o.addCommand(he()),o.addCommand(be()),o.addCommand(we()),o.addCommand(ye()),o.addCommand(ve()),o.addCommand(xe()),o.addCommand($e()),o.addCommand(Te()),o.addCommand(Ae()),o.addCommand(Le()),o.exitOverride(e=>{throw e.code==="commander.help"&&process.exit(0),e.code==="commander.version"&&process.exit(0),e.code==="commander.missingArgument"&&(s(e.message),process.exit(1)),e.code==="commander.unknownCommand"&&(s(e.message),r('Run "lindo --help" for available commands'),process.exit(1)),e}),o}function So(o){s("Authentication failed"),r(""),r("Your API key may be invalid or expired."),r(""),r("To configure your API key:"),r(" 1. Run: lindo config set apiKey <your-api-key>"),r(" 2. Or set the LINDO_API_KEY environment variable"),r(""),r("To get an API key:"),r(" Visit https://app.lindo.ai/settings/api-keys");}async function Oo(){let o=_o();try{await o.parseAsync(process.argv);}catch(e){throw e instanceof lindoai.AuthenticationError&&(So(),process.exit(1)),e}}Oo().catch(o=>{o instanceof Error?s(`Unexpected error: ${o.message}`):s("An unexpected error occurred"),process.exit(1);});
967
+ exports.createProgram=_o;