lindoai-cli 1.1.0 → 1.2.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.
- package/dist/index.cjs +281 -57
- package/dist/index.js +281 -57
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var tt=require('http'),k=require('fs'),M=require('path'),$e=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),url=require('url'),dt=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 tt__namespace=/*#__PURE__*/_interopNamespace(tt);var k__namespace=/*#__PURE__*/_interopNamespace(k);var M__namespace=/*#__PURE__*/_interopNamespace(M);var $e__namespace=/*#__PURE__*/_interopNamespace($e);var dt__namespace=/*#__PURE__*/_interopNamespace(dt);var kt=Object.defineProperty;var Ct=(o,e)=>()=>(o&&(e=o(o=0)),e);var _t=(o,e)=>{for(var n in e)kt(o,n,{get:e[n],enumerable:true});};var Pe={};_t(Pe,{LIVE_RELOAD_SCRIPT:()=>Te,injectLiveReload:()=>ot,startLivePreviewServer:()=>ao});function ot(o){let e=/<\/body>/i,n=o.match(e);return n&&n.index!==void 0?o.slice(0,n.index)+Te+o.slice(n.index):o+Te}function ao(o){return new Promise((e,n)=>{let t=M__namespace.resolve(o),i=new Set,a=null,l=100;function c(){for(let g of i)try{g.write(`data: reload
|
|
3
3
|
|
|
4
|
-
`);}catch{i.delete(
|
|
4
|
+
`);}catch{i.delete(g);}}function u(){a&&clearTimeout(a),a=setTimeout(()=>{c(),a=null;},l);}function b(g,w){let p=g.url||"/";if((g.method||"GET")!=="GET"){w.writeHead(405,{"Content-Type":"text/plain"}),w.end("Method Not Allowed");return}if(p==="/__live-reload"){w.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),w.write(`data: connected
|
|
5
5
|
|
|
6
|
-
`),i.add(
|
|
6
|
+
`),i.add(w),g.on("close",()=>{i.delete(w);});return}if(p==="/"||p==="/index.html"){try{let y=k__namespace.readFileSync(t,"utf-8"),f=ot(y);w.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),w.end(f);}catch(y){let f=y instanceof Error?y.message:"Unknown error";w.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),w.end(`<!DOCTYPE html>
|
|
7
7
|
<html>
|
|
8
8
|
<head><title>Error</title></head>
|
|
9
9
|
<body>
|
|
10
10
|
<h1>Error loading file</h1>
|
|
11
|
-
<p>${
|
|
11
|
+
<p>${f}</p>
|
|
12
12
|
</body>
|
|
13
|
-
</html>`);}return}
|
|
13
|
+
</html>`);}return}w.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),w.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
|
|
20
|
+
</html>`);}let v=tt__namespace.createServer(b),x=null;v.on("error",g=>{n(new Error(`Failed to start preview server: ${g.message}`));}),v.listen(0,"127.0.0.1",()=>{let g=v.address();if(!g||typeof g=="string"){n(new Error("Failed to get server address"));return}let w=g.port;try{x=k__namespace.watch(t,h=>{h==="change"&&u();}),x.on("error",h=>{console.error(`[Live Preview] File watcher error: ${h.message}`);});}catch(h){let y=h instanceof Error?h.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${y}`);}let p=()=>{x&&(x.close(),x=null),a&&(clearTimeout(a),a=null);for(let f of i)try{f.end();}catch{}i.clear();let h=M__namespace.join($e__namespace.tmpdir(),"lindoai-pages-preview.pid"),y=M__namespace.join($e__namespace.tmpdir(),"lindoai-pages-preview.port");try{k__namespace.existsSync(h)&&k__namespace.unlinkSync(h);}catch{}try{k__namespace.existsSync(y)&&k__namespace.unlinkSync(y);}catch{}v.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",p),process.on("SIGINT",p),e(w);});})}var Te,Ae=Ct(()=>{Te=`<script>
|
|
21
21
|
(function() {
|
|
22
22
|
var eventSource = new EventSource('/__live-reload');
|
|
23
23
|
eventSource.onmessage = function(event) {
|
|
@@ -29,19 +29,33 @@
|
|
|
29
29
|
console.log('[Live Reload] Connection lost, attempting to reconnect...');
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
-
</script>`;});var
|
|
33
|
-
`);let n=Array.from(e);return
|
|
34
|
-
`)}return String(o)}function
|
|
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){
|
|
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){
|
|
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){
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
</script>`;});var St="LINDO_API_KEY",Ot="LINDO_BASE_URL",It=".lindo",Ft="config.json",$t="https://api.lindo.ai";function Ge(){return M__namespace.join($e__namespace.homedir(),It)}function N(){return M__namespace.join(Ge(),Ft)}function be(){let o=N();try{if(k__namespace.existsSync(o)){let e=k__namespace.readFileSync(o,"utf-8");return JSON.parse(e)}}catch{}return {}}function Ye(o){let e=Ge(),n=N();k__namespace.existsSync(e)||k__namespace.mkdirSync(e,{recursive:true}),k__namespace.writeFileSync(n,JSON.stringify(o,null,2),"utf-8");}function _(){let o=be(),e=process.env[St]||o.apiKey,n=process.env[Ot]||o.baseUrl||$t;return {apiKey:e,baseUrl:n}}function ze(o){let e=be();e.apiKey=o,Ye(e);}function Ve(o,e){let n=be();switch(o){case "apiKey":n.apiKey=e;break;case "baseUrl":n.baseUrl=e;break;default:throw new Error(`Unknown configuration key: ${o}`)}Ye(n);}function Je(o){let e=_();switch(o){case "apiKey":return e.apiKey;case "baseUrl":return e.baseUrl;default:return}}function F(){return !!_().apiKey}var U={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Tt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function K(o,e){return Tt()?`${e}${o}${U.reset}`:o}function m(o){console.log(K(`\u2713 ${o}`,U.green));}function s(o){console.error(K(`\u2717 ${o}`,U.red));}function r(o){console.log(K(`\u2139 ${o}`,U.blue));}function Pt(o){return JSON.stringify(o,null,2)}function At(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 Et(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 l=i.padEnd(t),c=we(a);return `${K(l,U.cyan)} ${c}`}).join(`
|
|
34
|
+
`)}return String(o)}function Et(o,e){let n={};for(let l of o)n[l]=l.length;for(let l of e)if(typeof l=="object"&&l!==null){let c=l;for(let u of o){let b=we(c[u]);n[u]=Math.max(n[u],b.length);}}let t=o.map(l=>K(l.padEnd(n[l]),U.bold)).join(" "),i=o.map(l=>"-".repeat(n[l])).join(" "),a=e.map(l=>{if(typeof l=="object"&&l!==null){let c=l;return o.map(u=>we(c[u]).padEnd(n[u])).join(" ")}return String(l)});return [t,i,...a].join(`
|
|
35
|
+
`)}function we(o){return o==null?K("-",U.gray):typeof o=="boolean"?o?K("true",U.green):K("false",U.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"?Pt(o):At(o));}var Xe=["apiKey","baseUrl"];function ve(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((e,n)=>{Xe.includes(e)||(s(`Invalid configuration key: ${e}`),r(`Valid keys: ${Xe.join(", ")}`),process.exit(1));try{Ve(e,n),m(`Configuration saved: ${e}`),r(`Config file: ${N()}`);}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=Je(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"?ye(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=_(),t={apiKey:n.apiKey?ye(n.apiKey):"(not set)",baseUrl:n.baseUrl,configFile:N()};e.format==="json"?d({apiKey:n.apiKey?ye(n.apiKey):null,baseUrl:n.baseUrl,configFile:N()},e.format):d(t,e.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(N());}),o}function ye(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function xe(){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)=>{F()||(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=_(),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 l=await i.agents.run({agent_id:e,input:a,stream:n.stream});l.success?(m("Agent run completed"),d(l,n.format)):(s(`Agent run failed: ${l.error||"Unknown error"}`),d(l,n.format),process.exit(1));}catch(l){Nt(l);}}),o}function Nt(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 ke(){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=oe();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){ne(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=oe(),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?(m(`Workflow started: ${a.instance_id}`),d(a,n.format)):(s("Failed to start workflow"),d(a,n.format),process.exit(1));}catch(a){ne(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=oe();try{let i=await t.workflows.getStatus(e);d(i,n.format);}catch(i){ne(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=oe();try{r(`Pausing workflow: ${e}`);let i=await t.workflows.pause(e);i.success?m(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){ne(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=oe();try{r(`Resuming workflow: ${e}`);let i=await t.workflows.resume(e);i.success?m(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){ne(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=oe();try{r(`Terminating workflow: ${e}`);let i=await t.workflows.terminate(e);i.success?m(i.message):(s(i.message),process.exit(1)),d(i,n.format);}catch(i){ne(i);}}),o}function oe(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function ne(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 Ce(){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=L();try{let t=await n.workspace.get();d(t,e.format);}catch(t){R(t);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=L();try{let t=await n.workspace.getCredits();d(t,e.format);}catch(t){R(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=L();try{let t=await n.workspace.getClientCredits(e.client);d(t,e.format);}catch(t){R(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=L();try{let t=await n.workspace.update({workspace_name:e.name,workspace_language:e.language,webhook_url:e.webhook});t.success&&m("Workspace updated"),d(t,e.format);}catch(t){R(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=L();try{let t=await n.workspace.addTeamMember(e.email,e.role);t.success&&m("Team member added"),d(t,e.format);}catch(t){R(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=L();try{let t=await n.workspace.removeTeamMember(e.member);t.success&&m("Team member removed"),d(t,e.format);}catch(t){R(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=L(),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&&m("Integration added"),d(i,e.format);}catch(i){R(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=L();try{let t=await n.workspace.removeIntegration(e.type);t.success&&m("Integration removed"),d(t,e.format);}catch(t){R(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=L();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&&m("Whitelabel settings updated"),d(t,e.format);}catch(t){R(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=L();try{let t=await n.workspace.updateAppearance({primary_color:e.primary,secondary_color:e.secondary,theme_mode:e.mode});t.success&&m("Appearance settings updated"),d(t,e.format);}catch(t){R(t);}}),o}function L(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function R(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 _e(){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=Qe();try{let t=await n.analytics.getWorkspace({from:e.from,to:e.to});d(t,e.format);}catch(t){Ze(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=Qe();try{let t=await n.analytics.getWebsite({website_id:e.website,from:e.from,to:e.to});d(t,e.format);}catch(t){Ze(t);}}),o}function Qe(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function Ze(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 Se(){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=ae();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){se(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=ae();try{let t=await n.clients.create({email:e.email,website_limit:parseInt(e.limit,10)});if(t.success&&t.client)m(`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){se(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=ae();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)m("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){se(t);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async e=>{let n=ae();try{let t=await n.clients.delete(e.id);if(t.success)m("Client deleted");else if(s("Failed to delete client"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){se(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=ae();try{let t=await n.clients.createMagicLink(e.email);if(t.success)m("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){se(t);}}),o}function ae(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function se(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(){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=P();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){A(t);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.getDetails(e.id);d(t,e.format);}catch(t){A(t);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();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)m("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){A(t);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.updateSettings(e.id,{business_name:e.name,language:e.language,business_description:e.description});t.success&&m("Website settings updated"),d(t,e.format);}catch(t){A(t);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async e=>{let n=P();try{let t=await n.websites.delete(e.id);if(t.success)m("Website deleted");else if(s("Failed to delete website"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){A(t);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async e=>{let n=P();try{let t=await n.websites.assign({website_id:e.website,client_id:e.client});if(t.success)m("Website assigned to client");else if(s("Failed to assign website"),t.errors)for(let i of t.errors)s(` ${i}`);}catch(t){A(t);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.addDomain(e.id,e.domain);if(t.success&&(m("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){A(t);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.removeDomain(e.id);t.success&&m("Domain removed"),d(t,e.format);}catch(t){A(t);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P(),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&&m("Integration added"),d(i,e.format);}catch(i){A(i);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.removeIntegration(e.id,e.type);t.success&&m("Integration removed"),d(t,e.format);}catch(t){A(t);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.addTeamMember(e.id,e.email,e.role);t.success&&m("Team member added"),d(t,e.format);}catch(t){A(t);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async e=>{let n=P();try{let t=await n.websites.removeTeamMember(e.id,e.member);t.success&&m("Team member removed"),d(t,e.format);}catch(t){A(t);}}),o}function P(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function A(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 B(o){return new Promise(e=>{let n=$e.platform(),t;switch(n){case "darwin":t=`open "${o}"`;break;case "win32":t=`start "" "${o}"`;break;default:t=`xdg-open "${o}"`;break}child_process.exec(t,i=>{e(!i);});})}function oo(o){let e=o.filter(t=>!!(t&&t.trim()));return e.length===0?"":`https://fonts.googleapis.com/css2?family=${e.map(t=>`${t.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function le(o){let e=[o.font,o.title_font].filter(Boolean);if(e.length===0)return "";let n=oo(e);if(!n)return "";let t=o.font||o.title_font,i=o.title_font||o.font,a=`
|
|
39
|
+
<style>
|
|
40
|
+
/* Apply website fonts from theme */
|
|
41
|
+
body, main, .prose {
|
|
42
|
+
font-family: '${t}', system-ui, sans-serif !important;
|
|
43
|
+
}
|
|
44
|
+
h1, h2, h3, h4, h5, h6, .font-display, .font-serif {
|
|
45
|
+
font-family: '${i}', system-ui, serif !important;
|
|
46
|
+
}
|
|
47
|
+
</style>`;return `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
48
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
49
|
+
<link href="${n}" rel="stylesheet">${a}`}var no="_global_header0000",io="_global_footer0000";function et(o,e){let n=new RegExp(`<(\\w+)\\s+[^>]*lindo-section\\s*=\\s*["']${ro(e)}["'][^>]*>`,"i"),t=o.match(n);if(!t||t.index===void 0)return {section:void 0,remainingHtml:o};let i=t[1].toLowerCase(),a=t.index,l=a+t[0].length,c=1,u=new RegExp(`<${i}\\b`,"gi"),b=new RegExp(`</${i}>`,"gi"),v=`</${i}>`,x=o.slice(l),g=[],w=[],p;for(;(p=u.exec(x))!==null;)g.push(p.index+l);for(;(p=b.exec(x))!==null;)w.push(p.index+l);let h=[...g.map(O=>({pos:O,type:"open"})),...w.map(O=>({pos:O,type:"close"}))].sort((O,$)=>O.pos-$.pos),y=-1;for(let O of h)if(O.type==="open")c++;else if(c--,c===0){y=O.pos+v.length;break}if(y===-1)return {section:void 0,remainingHtml:o};let f=o.slice(a,y),C=o.slice(0,a),T=o.slice(y),I=(C+T).replace(/\n\s*\n\s*\n/g,`
|
|
50
|
+
|
|
51
|
+
`);return {section:f,remainingHtml:I}}function ro(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ie(o){let e=et(o,no),n=et(e.remainingHtml,io);return {globalHeader:e.section,globalFooter:n.section,mainContent:n.remainingHtml.trim()}}function Fe(o,e,n){let t=[];return e&&e.trim()&&t.push(e.trim()),o.trim()&&t.push(o.trim()),n&&n.trim()&&t.push(n.trim()),t.join(`
|
|
52
|
+
`)}var Q=M__namespace.join($e__namespace.tmpdir(),"lindoai-pages-preview.pid"),de=M__namespace.join($e__namespace.tmpdir(),"lindoai-pages-preview.port");function Re(){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=J();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(`
|
|
53
|
+
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){X(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=J();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(`
|
|
54
|
+
Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),console.log(` Name: ${i.name??"N/A"}`),console.log(` Path: ${i.path??"N/A"}`),console.log(` Status: ${i.status??"N/A"}`),console.log(` Published: ${i.publish_date?"Yes":"No"}`),console.log(` Created: ${i.created_date??"N/A"}`)):s("Page not found");}}catch(t){X(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=J();try{let t=await n.pages.unpublish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(m("Page unpublished successfully"),console.log(` Page ID: ${t.result?.page_id}`)):s("Failed to unpublish page");}catch(t){X(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=J();try{let t=await n.pages.deletePage(e.website,e.id);if(e.format==="json")d(t,"json");else if(t.success){if(m("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){X(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=J();try{r("Fetching website details...");let l=(await i.websites.getDetails(e)).result,c=l?.theme||{},u=l?.global_header||null,b=l?.global_footer||null,v=l?.custom_codes||{header:null,footer:null},x={font:c.font,title_font:c.title_font},g=t.title,w=`<!-- Hero Section -->
|
|
41
55
|
<section class="relative min-h-[80vh] flex items-center justify-center bg-gradient-to-br from-neutral-50 to-neutral-100 dark:from-neutral-900 dark:to-neutral-800">
|
|
42
56
|
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
|
43
57
|
<h1 class="text-4xl sm:text-5xl lg:text-6xl font-bold text-neutral-900 dark:text-white mb-6">
|
|
44
|
-
${
|
|
58
|
+
${g}
|
|
45
59
|
</h1>
|
|
46
60
|
<p class="text-lg sm:text-xl text-neutral-600 dark:text-neutral-300 mb-8 max-w-2xl mx-auto">
|
|
47
61
|
Start building your page by editing this template. Add sections, customize styles, and create something amazing.
|
|
@@ -113,24 +127,27 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
|
|
|
113
127
|
Contact Us
|
|
114
128
|
</a>
|
|
115
129
|
</div>
|
|
116
|
-
</section>`,
|
|
130
|
+
</section>`,p={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},h={page_title:g,meta_description:"",social_title:g,social_description:"",noindex:!1,nofollow:!1};r("Creating page...");let y=await i.pages.create(e,{html:w,path:n,settings:p,template_name:g,seo:h});y.success||(s("Failed to create page"),process.exit(1));let f=y.result.page_id;m(`Page created: ${f}`);let C=le(x),T=Fe(w,u??void 0,b??void 0),I={header:v.header||"",footer:v.footer||""},O=`<!DOCTYPE html>
|
|
117
131
|
<html class="dark" lang="en">
|
|
118
132
|
<head>
|
|
119
133
|
<meta charset="UTF-8">
|
|
120
134
|
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
|
|
121
135
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
122
136
|
|
|
123
|
-
<title>${
|
|
137
|
+
<title>${g}</title>
|
|
124
138
|
<meta name="description" content="">
|
|
125
139
|
|
|
126
|
-
<meta property="og:title" content="${
|
|
140
|
+
<meta property="og:title" content="${g}">
|
|
127
141
|
<meta property="og:description" content="">
|
|
128
142
|
<meta property="og:type" content="website">
|
|
129
143
|
|
|
130
144
|
<meta name="twitter:card" content="summary_large_image">
|
|
131
|
-
<meta name="twitter:title" content="${
|
|
145
|
+
<meta name="twitter:title" content="${g}">
|
|
132
146
|
<meta name="twitter:description" content="">
|
|
133
147
|
|
|
148
|
+
<!-- Google Fonts -->
|
|
149
|
+
${C}
|
|
150
|
+
|
|
134
151
|
<!-- Tailwind CSS v4 CDN for preview -->
|
|
135
152
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
136
153
|
|
|
@@ -139,13 +156,14 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${i.page_id}`),c
|
|
|
139
156
|
<script src="https://lnui.pages.dev/motion-animate.js"></script>
|
|
140
157
|
|
|
141
158
|
<!-- Page Custom Code (Header) -->
|
|
159
|
+
${I.header}
|
|
142
160
|
|
|
143
161
|
</head>
|
|
144
162
|
<body>
|
|
145
163
|
<!-- ========== MAIN CONTENT ========== -->
|
|
146
164
|
<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
165
|
|
|
148
|
-
${
|
|
166
|
+
${T}
|
|
149
167
|
|
|
150
168
|
</main>
|
|
151
169
|
<!-- ========== END MAIN CONTENT ========== -->
|
|
@@ -154,48 +172,52 @@ ${c}
|
|
|
154
172
|
<script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
|
|
155
173
|
|
|
156
174
|
<!-- Page Custom Code (Footer) -->
|
|
175
|
+
${I.footer}
|
|
157
176
|
</body>
|
|
158
|
-
</html
|
|
159
|
-
<html class="${
|
|
177
|
+
</html>`,$=M__namespace.resolve(t.file);k__namespace.writeFileSync($,O,"utf-8"),m(`HTML saved to ${$}`),await nt(),t.background?await it($):await rt($),console.log(""),r(`To save changes: lindoai pages update ${e} ${f} --html-file ${t.file}`);}catch(a){X(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=J();try{r("Fetching page HTML...");let a=await i.pages.getHtml(e,n);a.result||(s("Page not found"),process.exit(1));let l=a.result.html;l||(s("Page has no HTML content"),r("Make sure the page has been created with HTML content"),process.exit(1)),r("Fetching website details...");let u=(await i.websites.getDetails(e)).result,b=u?.theme||{},v=u?.global_header||null,x=u?.global_footer||null,g=u?.custom_codes||{header:null,footer:null},w=a.result.name||"Page",p=a.result.seo||{},h=a.result.settings||{},y=a.result.custom_codes||{},f={header:y.header||g.header||"",footer:y.footer||g.footer||""},C=h.theme||{},T=C.mode!=="Light",I=C.direction||"ltr",O=C.main_classes||"",$=C.animations_deactivated||!1,z={font:C.font||b.font,title_font:C.title_font||b.title_font},ee=le(z),te=Ie(l).mainContent,H=Fe(te,v??void 0,x??void 0),re=`<!DOCTYPE html>
|
|
178
|
+
<html class="${T?"dark":""}" lang="en">
|
|
160
179
|
<head>
|
|
161
180
|
<meta charset="UTF-8">
|
|
162
|
-
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1 ${
|
|
181
|
+
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1 ${p.noindex?"noindex":""} ${p.nofollow?"nofollow":""}">
|
|
163
182
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
164
183
|
|
|
165
|
-
<title>${
|
|
166
|
-
<meta name="description" content="${
|
|
184
|
+
<title>${p.page_title||w}</title>
|
|
185
|
+
<meta name="description" content="${p.meta_description||""}">
|
|
167
186
|
|
|
168
|
-
<meta property="og:title" content="${
|
|
169
|
-
<meta property="og:description" content="${
|
|
170
|
-
${
|
|
187
|
+
<meta property="og:title" content="${p.social_title||p.page_title||w}">
|
|
188
|
+
<meta property="og:description" content="${p.social_description||p.meta_description||""}">
|
|
189
|
+
${p.social_image?`<meta property="og:image" content="${p.social_image}">`:""}
|
|
171
190
|
<meta property="og:type" content="website">
|
|
172
|
-
${
|
|
191
|
+
${p.canonical_url?`<meta property="og:url" content="${p.canonical_url}">`:""}
|
|
173
192
|
|
|
174
193
|
<meta name="twitter:card" content="summary_large_image">
|
|
175
|
-
<meta name="twitter:title" content="${
|
|
176
|
-
<meta name="twitter:description" content="${
|
|
177
|
-
${
|
|
194
|
+
<meta name="twitter:title" content="${p.social_title||p.page_title||w}">
|
|
195
|
+
<meta name="twitter:description" content="${p.social_description||p.meta_description||""}">
|
|
196
|
+
${p.social_image?`<meta name="twitter:image" content="${p.social_image}">`:""}
|
|
197
|
+
|
|
198
|
+
<!-- Google Fonts -->
|
|
199
|
+
${ee}
|
|
178
200
|
|
|
179
201
|
<!-- Tailwind CSS v4 CDN for preview -->
|
|
180
202
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
181
203
|
|
|
182
|
-
${
|
|
204
|
+
${$?"":`
|
|
183
205
|
<!-- Motion for animations -->
|
|
184
206
|
<script src="https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js"></script>
|
|
185
207
|
<script src="https://lnui.pages.dev/motion-animate.js"></script>
|
|
186
208
|
`}
|
|
187
209
|
|
|
188
|
-
${
|
|
210
|
+
${p.canonical_url?`<link rel="canonical" href="${p.canonical_url}">`:""}
|
|
189
211
|
|
|
190
212
|
<!-- Page Custom Code (Header) -->
|
|
191
|
-
${
|
|
213
|
+
${f.header}
|
|
192
214
|
|
|
193
215
|
</head>
|
|
194
216
|
<body>
|
|
195
217
|
<!-- ========== MAIN CONTENT ========== -->
|
|
196
|
-
<main dir="${
|
|
218
|
+
<main dir="${I}" lindo-main-content id="content" role="main" class="${O}">
|
|
197
219
|
|
|
198
|
-
${
|
|
220
|
+
${H}
|
|
199
221
|
|
|
200
222
|
</main>
|
|
201
223
|
<!-- ========== END MAIN CONTENT ========== -->
|
|
@@ -204,9 +226,9 @@ ${c}
|
|
|
204
226
|
<script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
|
|
205
227
|
|
|
206
228
|
<!-- Page Custom Code (Footer) -->
|
|
207
|
-
${
|
|
229
|
+
${f.footer}
|
|
208
230
|
</body>
|
|
209
|
-
</html>`,
|
|
231
|
+
</html>`,W=M__namespace.resolve(t.file);k__namespace.writeFileSync(W,re,"utf-8"),m(`HTML saved to ${W}`),await nt(),t.background?await it(W):await rt(W);}catch(a){X(a);}}),o.command("update").description("Update a page from HTML file (note: global header/footer changes are page-specific only)").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("-f, --format <format>","Output format (json, table)","table").action(async(e,n,t)=>{let i=J();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=M__namespace.resolve(t.htmlFile);k__namespace.existsSync(a)||(s(`File not found: ${a}`),process.exit(1));let l=k__namespace.readFileSync(a,"utf-8");r(`Read ${l.length} bytes from ${a}`);let c=l.match(/<main[^>]*>([\s\S]*)<\/main>/i),u=c?c[1].trim():l;c&&r("Extracted content from <main> tag");let b=Ie(u),v=b.mainContent,x=b.globalHeader,g=b.globalFooter;x&&r("Detected global header section"),g&&r("Detected global footer section");let w=l.match(/<title>([^<]*)<\/title>/i),p=w?w[1].trim():void 0;p&&r(`Extracted page title: ${p}`);let h="",y="",f=l.match(/<!-- Page Custom Code \(Header\) -->\s*([\s\S]*?)\s*<\/head>/i);f&&f[1].trim()&&(h=f[1].trim(),r("Extracted header custom code"));let C=l.match(/<!-- Page Custom Code \(Footer\) -->\s*([\s\S]*?)\s*<\/body>/i);C&&C[1].trim()&&(y=C[1].trim(),r("Extracted footer custom code"));let T=l.match(/<html[^>]*class="([^"]*)"/i),I=T?T[1].includes("dark"):!0,O=l.match(/<main[^>]*>/i),$="ltr",z="";if(O){let Ke=O[0].match(/dir="([^"]*)"/i);Ke&&($=Ke[1]);let Be=O[0].match(/class="([^"]*)"/i);Be&&(z=Be[1]);}let ee=!l.includes("motion@latest"),V=l.match(/<meta\s+name="description"\s+content="([^"]*)"/i),te=l.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),H=l.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),re=l.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),W=l.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),wt=l.match(/noindex/i),yt=l.match(/nofollow/i),E={};p&&(E.page_title=p),V&&V[1]&&(E.meta_description=V[1]),te&&te[1]&&(E.social_title=te[1]),H&&H[1]&&(E.social_description=H[1]),re&&re[1]&&(E.social_image=re[1]),W&&W[1]&&(E.canonical_url=W[1]),E.noindex=!!wt,E.nofollow=!!yt,Object.keys(E).length>2&&r("Extracted SEO metadata");let pe=await i.pages.get(e,n);pe.result||(s("Page not found"),process.exit(1));let vt=pe.result.path,xt={...pe.result.settings||{},theme:{...pe.result.settings?.theme||{},mode:I?"Dark":"Light",direction:$,main_classes:z,animations_deactivated:ee},should_convert:!0},ue={};h&&(ue.header=h),y&&(ue.footer=y),r("Updating page...");let fe=await i.pages.publish(e,n,{html:v,path:vt,settings:xt,template_name:p,custom_codes:Object.keys(ue).length>0?ue:void 0,seo:Object.keys(E).length>0?E:void 0,global_header:x,global_footer:g});t.format==="json"?d(fe,"json"):fe.success?(m("Page updated successfully"),console.log(` Page ID: ${fe.result?.page_id}`)):s("Failed to update page");}catch(a){X(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"),Ee();return}try{process.kill(e,"SIGTERM"),m(`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}`);}Ee();}catch(e){e instanceof Error?s(e.message):s("An unexpected error occurred"),process.exit(1);}}),o}function J(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function X(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 Ee(){try{k__namespace.existsSync(Q)&&k__namespace.unlinkSync(Q);}catch{}try{k__namespace.existsSync(de)&&k__namespace.unlinkSync(de);}catch{}}async function nt(){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{}Ee();}}async function it(o){let e=M__namespace.resolve(o),n=`
|
|
210
232
|
const http = require('node:http');
|
|
211
233
|
const fs = require('node:fs');
|
|
212
234
|
const path = require('node:path');
|
|
@@ -326,9 +348,9 @@ ${c}
|
|
|
326
348
|
});
|
|
327
349
|
} catch {}
|
|
328
350
|
});
|
|
329
|
-
`,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let
|
|
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){
|
|
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){
|
|
351
|
+
`,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let c=0;c<50;c++)if(await new Promise(u=>setTimeout(u,100)),k__namespace.existsSync(de))try{if(i=parseInt(k__namespace.readFileSync(de,"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 B(a)||r(`Could not open browser. Visit: ${a}`),m("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 rt(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Ae(),Pe));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(de,n.toString(),"utf-8"),await B(t)||r(`Could not open browser. Visit: ${t}`),m("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 Z=M__namespace.join($e__namespace.tmpdir(),"lindoai-blogs-preview.pid"),me=M__namespace.join($e__namespace.tmpdir(),"lindoai-blogs-preview.port");function Ne(){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=G();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(`
|
|
352
|
+
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){Y(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=G();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(`
|
|
353
|
+
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){Y(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=G();try{let t=await n.blogs.publish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(m("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){Y(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=G();try{let t=await n.blogs.unpublish(e.website,e.id);e.format==="json"?d(t,"json"):t.success?(m("Blog unpublished successfully"),console.log(` Blog ID: ${t.result?.blog_id}`)):s("Failed to unpublish blog");}catch(t){Y(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=G();try{let t=await n.blogs.delete(e.website,e.id);if(e.format==="json")d(t,"json");else if(t.success){if(m("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){Y(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=G();try{r("Fetching blog content...");let a=await i.blogs.getHtml(e,n);a.result||(s("Blog not found"),process.exit(1));let l=a.result,c=await i.websites.getDetails(e);c.result||(s("Website not found"),process.exit(1));let u=c.result,b=u,v=b?.theme||{},x=b?.custom_codes||{header:null,footer:null},g={font:v.font,title_font:v.title_font},w=l.seo||{},p=l.blog_settings||{},h=l.blog_content||"<p>Start writing your blog content here...</p>",y=ct({seo:w,blogSettings:p,blogContent:h,websiteName:u.business_name||"Blog",blogPath:v.blog_path||"blog",websiteTheme:g,customCodes:{header:x.header||void 0,footer:x.footer||void 0}}),f=M__namespace.resolve(t.file);k__namespace.writeFileSync(f,y,"utf-8"),m(`HTML saved to ${f}`),await at(),t.background?await st(f):await lt(f),console.log(""),r(`To save changes: lindoai blogs update ${e} ${n} --html-file ${t.file}`);}catch(a){Y(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=G();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,l={},c={};if(t.mdFile){let p=M__namespace.resolve(t.mdFile);k__namespace.existsSync(p)||(s(`File not found: ${p}`),process.exit(1));let h=k__namespace.readFileSync(p,"utf-8");r(`Read ${h.length} bytes from ${p}`);let{content:y,frontmatter:f}=bo(h);a=wo(y),f.title&&(l.page_title=f.title),f.description&&(l.meta_description=f.description),f.image&&(l.social_image=f.image),f.author&&(c.author=f.author),f.excerpt&&(c.excerpt=f.excerpt),f.category&&(c.category=f.category),f.date&&(c.publish_date=f.date);}else {let p=M__namespace.resolve(t.htmlFile);k__namespace.existsSync(p)||(s(`File not found: ${p}`),process.exit(1));let h=k__namespace.readFileSync(p,"utf-8");r(`Read ${h.length} bytes from ${p}`);let y=h.match(/<article[^>]*class="[^"]*prose[^"]*"[^>]*>([\s\S]*?)<\/article>/i);a=y?y[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 f=h.match(/<title>([^<]*)<\/title>/i),C=h.match(/<meta\s+name="description"\s+content="([^"]*)"/i),T=h.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i);f&&(l.page_title=f[1].trim()),C&&(l.meta_description=C[1]),T&&(l.social_image=T[1]);let I=h.match(/id="blog-author-display"[^>]*>([\s\S]*?)<\/span>/i),O=h.match(/class="[^"]*bg-blue-500\/10[^"]*"[^>]*>([^<]*)</i),$=h.match(/class="[^"]*border-l-4 border-blue-500[^"]*"[^>]*>([\s\S]*?)<\/div>/i),z=h.match(/<time[^>]*>([^<]*)<\/time>/i),ee=h.match(/<span>(\d+\s*min\s*read)<\/span>/i),V=h.match(/<div class="aspect-video[^"]*"[^>]*>\s*<img[^>]*src="([^"]*)"/i);if(I){let H=I[1].replace(/<[^>]*>/g,"").trim();H&&(c.author=H);}O&&(c.category=O[1].trim()),$&&(c.excerpt=$[1].trim()),z&&(c.publish_date=z[1].trim()),ee&&(c.read_time=ee[1].trim()),V&&!l.social_image&&(l.social_image=V[1]),r("Extracted blog content and metadata");}let u=await i.blogs.get(e,n);u.result||(s("Blog not found"),process.exit(1));let b=u.result,v=b.path,x={page_title:l.page_title||b.seo?.page_title||"Untitled",meta_description:l.meta_description||b.seo?.meta_description,social_title:l.social_title||b.seo?.social_title,social_description:l.social_description||b.seo?.social_description,social_image:l.social_image||b.seo?.social_image},g={author:c.author||b.blog_settings?.author||"Anonymous",excerpt:c.excerpt||b.blog_settings?.excerpt,category:c.category||b.blog_settings?.category,publish_date:c.publish_date||b.blog_settings?.publish_date,read_time:c.read_time||b.blog_settings?.read_time,author_image:c.author_image||b.blog_settings?.author_image};r("Updating blog...");let w=await i.blogs.publish(e,n,{path:v,blog_content:a,seo:x,blog_settings:g});t.format==="json"?d(w,"json"):w.success?(m("Blog updated successfully"),console.log(` Blog ID: ${w.result?.blog_id}`)):s("Failed to update blog");}catch(a){Y(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=G();try{let a=await i.websites.getDetails(e);a.result||(s("Website not found"),process.exit(1));let l=a.result,c=l,u=c?.theme||{},b=c?.custom_codes||{header:null,footer:null},v={font:u.font,title_font:u.title_font},x=t.title,g=t.author,w=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}),p=`<h2>Introduction</h2>
|
|
332
354
|
<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
355
|
|
|
334
356
|
<h2>Getting Started</h2>
|
|
@@ -350,7 +372,7 @@ Blog Details:`),console.log("-------------"),console.log(` ID: ${i.blog_id}`),c
|
|
|
350
372
|
console.log(greet('World'));</code></pre>
|
|
351
373
|
|
|
352
374
|
<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>`,
|
|
375
|
+
<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>`,h={page_title:x,meta_description:`Read ${x} by ${g}`,social_title:x,social_description:`Read ${x} by ${g}`},y={author:g,excerpt:"A new blog post. Edit this excerpt to provide a summary of your content.",publish_date:w,read_time:"3 min read"};r("Creating blog...");let f=await i.blogs.create(e,{path:n,blog_content:p,seo:h,blog_settings:y});f.success||(s("Failed to create blog"),process.exit(1));let C=f.result.blog_id;m(`Blog created: ${C}`);let T=ct({seo:h,blogSettings:y,blogContent:p,websiteName:l.business_name||"Blog",blogPath:u.blog_path||"blog",websiteTheme:v,customCodes:{header:b.header||void 0,footer:b.footer||void 0}}),I=M__namespace.resolve(t.file);k__namespace.writeFileSync(I,T,"utf-8"),m(`HTML saved to ${I}`),await at(),t.background?await st(I):await lt(I),console.log(""),r(`To save changes: lindoai blogs update ${e} ${C} --html-file ${t.file}`);}catch(a){Y(a);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!k__namespace.existsSync(Z)){r("No preview server is running");return}let e=parseInt(k__namespace.readFileSync(Z,"utf-8").trim(),10);if(isNaN(e)){s("Invalid PID file"),De();return}try{process.kill(e,"SIGTERM"),m(`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}`);}De();}catch(e){e instanceof Error?s(e.message):s("An unexpected error occurred"),process.exit(1);}}),o}function G(){F()||(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=_();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function Y(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 De(){try{k__namespace.existsSync(Z)&&k__namespace.unlinkSync(Z);}catch{}try{k__namespace.existsSync(me)&&k__namespace.unlinkSync(me);}catch{}}async function at(){if(k__namespace.existsSync(Z)){try{let o=parseInt(k__namespace.readFileSync(Z,"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{}De();}}async function st(o){let e=M__namespace.resolve(o),n=`
|
|
354
376
|
const http = require('node:http');
|
|
355
377
|
const fs = require('node:fs');
|
|
356
378
|
const path = require('node:path');
|
|
@@ -470,7 +492,7 @@ console.log(greet('World'));</code></pre>
|
|
|
470
492
|
});
|
|
471
493
|
} catch {}
|
|
472
494
|
});
|
|
473
|
-
`,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let
|
|
495
|
+
`,t=child_process.spawn(process.execPath,["-e",n],{detached:true,stdio:"ignore"});t.unref();let i=null;for(let c=0;c<50;c++)if(await new Promise(u=>setTimeout(u,100)),k__namespace.existsSync(me))try{if(i=parseInt(k__namespace.readFileSync(me,"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 B(a)||r(`Could not open browser. Visit: ${a}`),m("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 lt(o){let{startLivePreviewServer:e}=await Promise.resolve().then(()=>(Ae(),Pe));r("Starting preview server...");let n=await e(o),t=`http://127.0.0.1:${n}/`;k__namespace.writeFileSync(Z,process.pid.toString(),"utf-8"),k__namespace.writeFileSync(me,n.toString(),"utf-8"),await B(t)||r(`Could not open browser. Visit: ${t}`),m("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 ho(o){return o?o.split(" ").map(e=>e.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function ct(o){let{seo:e,blogSettings:n,blogContent:t,websiteName:i,blogPath:a,websiteTheme:l,customCodes:c}=o,u=l?le(l):"";return `<!DOCTYPE html>
|
|
474
496
|
<html class="dark" lang="en">
|
|
475
497
|
<head>
|
|
476
498
|
<meta charset="UTF-8">
|
|
@@ -489,9 +511,15 @@ console.log(greet('World'));</code></pre>
|
|
|
489
511
|
<meta name="twitter:description" content="${e.social_description||e.meta_description||""}">
|
|
490
512
|
${e.social_image?`<meta name="twitter:image" content="${e.social_image}">`:""}
|
|
491
513
|
|
|
514
|
+
<!-- Google Fonts -->
|
|
515
|
+
${u}
|
|
516
|
+
|
|
492
517
|
<!-- Tailwind CSS v4 CDN for preview -->
|
|
493
518
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
494
519
|
|
|
520
|
+
<!-- Custom Code (Header) -->
|
|
521
|
+
${c?.header||""}
|
|
522
|
+
|
|
495
523
|
<style>
|
|
496
524
|
/* Required default styles for content */
|
|
497
525
|
blockquote, dd, dl, figure, h1, h2, h3, h4, h5, h6, hr, p, pre {
|
|
@@ -573,7 +601,7 @@ console.log(greet('World'));</code></pre>
|
|
|
573
601
|
<div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-neutral-400 mb-8">
|
|
574
602
|
<div class="flex items-center space-x-2">
|
|
575
603
|
<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
|
-
${
|
|
604
|
+
${ho(n.author||"Anonymous")}
|
|
577
605
|
</div>
|
|
578
606
|
<span id="blog-author-display" class="font-medium text-neutral-200">
|
|
579
607
|
${n.author||"Anonymous"}
|
|
@@ -646,11 +674,14 @@ console.log(greet('World'));</code></pre>
|
|
|
646
674
|
|
|
647
675
|
<!-- Config script -->
|
|
648
676
|
<script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
|
|
677
|
+
|
|
678
|
+
<!-- Custom Code (Footer) -->
|
|
679
|
+
${c?.footer||""}
|
|
649
680
|
</body>
|
|
650
|
-
</html>`}function
|
|
651
|
-
`)){let
|
|
681
|
+
</html>`}function bo(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(`
|
|
682
|
+
`)){let l=a.indexOf(":");if(l!==-1){let c=a.slice(0,l).trim(),u=a.slice(l+1).trim();(u.startsWith('"')&&u.endsWith('"')||u.startsWith("'")&&u.endsWith("'"))&&(u=u.slice(1,-1)),e[c]=u;}}}}return {content:n,frontmatter:e}}function wo(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
683
|
`).map(i=>{let a=i.trim();return a?a.startsWith("<")?i:`<p>${a}</p>`:""}).join(`
|
|
653
|
-
`),e=e.replace(/<p><\/p>/g,""),e}function
|
|
684
|
+
`),e=e.replace(/<p><\/p>/g,""),e}function mt(){return dt__namespace.randomBytes(32).toString("hex")}function pt(o,e){return o===e}function vo(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 xo(){return `<!DOCTYPE html>
|
|
654
685
|
<html lang="en">
|
|
655
686
|
<head>
|
|
656
687
|
<meta charset="UTF-8">
|
|
@@ -696,7 +727,7 @@ console.log(greet('World'));</code></pre>
|
|
|
696
727
|
<p>You can close this window and return to your terminal.</p>
|
|
697
728
|
</div>
|
|
698
729
|
</body>
|
|
699
|
-
</html>`}function
|
|
730
|
+
</html>`}function ge(o){return `<!DOCTYPE html>
|
|
700
731
|
<html lang="en">
|
|
701
732
|
<head>
|
|
702
733
|
<meta charset="UTF-8">
|
|
@@ -751,7 +782,7 @@ console.log(greet('World'));</code></pre>
|
|
|
751
782
|
<div class="error-message">${o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</div>
|
|
752
783
|
</div>
|
|
753
784
|
</body>
|
|
754
|
-
</html>`}function
|
|
785
|
+
</html>`}function ko(){return `<!DOCTYPE html>
|
|
755
786
|
<html lang="en">
|
|
756
787
|
<head>
|
|
757
788
|
<meta charset="UTF-8">
|
|
@@ -789,13 +820,13 @@ console.log(greet('World'));</code></pre>
|
|
|
789
820
|
<p>This endpoint is not available.</p>
|
|
790
821
|
</div>
|
|
791
822
|
</body>
|
|
792
|
-
</html>`}function
|
|
823
|
+
</html>`}function gt(){let o=null,e=null;function n(t,i){let a=t.url||"/",l=t.method||"GET",c=a==="/callback"||a.startsWith("/callback?");if(l!=="GET"||!c){i.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),i.end(ko());return}let u=vo(a);if(!e){i.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),i.end(ge("No pending authorization request"));return}let{expectedState:b,resolve:v,timeoutId:x}=e;if(clearTimeout(x),e=null,u.error){let g=u.message||u.error;i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(ge(g)),v({success:false,error:g});return}if(!u.state||!pt(u.state,b)){let g="State token mismatch - possible CSRF attack";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(ge(g)),v({success:false,error:g});return}if(!u.key){let g="No API key received";i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(ge(g)),v({success:false,error:g});return}i.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),i.end(xo()),v({success:true,apiKey:u.key});}return {async start(){return new Promise((t,i)=>{o=tt__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,c=`http://127.0.0.1:${l}/callback`;t({port:l,url:c});});})},waitForCallback(t,i){return new Promise(a=>{let l=setTimeout(()=>{e&&(e=null,a({success:false,error:"Login timed out waiting for authorization"}));},i);e={expectedState:t,resolve:a,timeoutId:l};})},async stop(){return new Promise(t=>{e&&(clearTimeout(e.timeoutId),e=null),o?o.close(()=>{o=null,t();}):t();})}}}var _o="https://app.lindo.ai",So=120;function Oo(o,e){let n=`http://127.0.0.1:${e}/callback`,t=new URLSearchParams({state:o,callback_url:n});return `${_o}/cli/authorize?${t.toString()}`}function Ue(){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(So)).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=gt(),l=false;try{r("Starting authentication flow...");let{port:c}=await a.start();l=!0;let u=mt(),b=Oo(u,c);i?(r("Opening browser for authorization..."),await B(b)||(r("Could not open browser automatically."),console.log(`
|
|
793
824
|
Please open this URL in your browser:`),console.log(`
|
|
794
|
-
${
|
|
825
|
+
${b}
|
|
795
826
|
`))):(console.log(`
|
|
796
827
|
Please open this URL in your browser:`),console.log(`
|
|
797
|
-
${
|
|
798
|
-
`)),r(`Waiting for authorization (timeout: ${n}s)...`);let
|
|
828
|
+
${b}
|
|
829
|
+
`)),r(`Waiting for authorization (timeout: ${n}s)...`);let v=await a.waitForCallback(u,t);v.success&&v.apiKey?(ze(v.apiKey),m("Successfully authenticated!"),r(`API key saved to: ${N()}`)):(s(v.error||"Authentication failed"),process.exit(1));}catch(c){s(c instanceof Error?c.message:"An unexpected error occurred"),process.exit(1);}finally{l&&await a.stop();}})}var Me=M__namespace.join($e__namespace.homedir(),".config","opencode","skills","lindoai"),bt=M__namespace.join(Me,"SKILL.md"),$o=`---
|
|
799
830
|
name: lindoai
|
|
800
831
|
description: Lindo AI CLI - Command-line interface for the Lindo API
|
|
801
832
|
---
|
|
@@ -869,6 +900,16 @@ lindoai pages update <website_id> <page_id> --html-file ./page.html
|
|
|
869
900
|
lindoai pages stop-preview
|
|
870
901
|
\`\`\`
|
|
871
902
|
|
|
903
|
+
### Important: Global Header/Footer Limitation
|
|
904
|
+
|
|
905
|
+
**Global header and footer sections cannot be updated via the CLI.** When you edit a page locally:
|
|
906
|
+
- The preview shows the website's global header/footer for visual context
|
|
907
|
+
- Any changes you make to global sections are saved with the page only
|
|
908
|
+
- Changes do NOT propagate to other pages or the website settings
|
|
909
|
+
- To update global header/footer across all pages, use the Lindo webapp
|
|
910
|
+
|
|
911
|
+
This is by design - global sections are website-wide settings managed through the webapp.
|
|
912
|
+
|
|
872
913
|
## Blog Management
|
|
873
914
|
|
|
874
915
|
### List Blogs
|
|
@@ -963,5 +1004,188 @@ lindoai config set baseUrl <value>
|
|
|
963
1004
|
3. **Run preview servers in background mode** (\`--background\`) to keep the terminal available.
|
|
964
1005
|
4. **Remember to stop preview servers** when done editing with \`stop-preview\`.
|
|
965
1006
|
5. **Use JSON format** (\`--format json\`) when you need to parse command output programmatically.
|
|
966
|
-
|
|
967
|
-
|
|
1007
|
+
|
|
1008
|
+
## Page Building Guidelines
|
|
1009
|
+
|
|
1010
|
+
### Structure Requirements
|
|
1011
|
+
|
|
1012
|
+
When building or editing Lindo pages, follow these structure requirements:
|
|
1013
|
+
|
|
1014
|
+
- **Output ONLY content HTML**: Generate only \`<header>\`, \`<section>\` elements, and \`<footer>\`
|
|
1015
|
+
- **NO document wrapper tags**: Do NOT include \`<!DOCTYPE html>\`, \`<html>\`, \`<head>\`, or \`<body>\` tags
|
|
1016
|
+
- **Unique section IDs**: Each section must have a unique id following the pattern: \`_block_name_###\` (e.g., \`_hero_001\`, \`_features_002\`)
|
|
1017
|
+
- **Semantic structure**: Use proper HTML5 semantic elements for accessibility
|
|
1018
|
+
|
|
1019
|
+
Example structure:
|
|
1020
|
+
\`\`\`html
|
|
1021
|
+
<header id="_header_001" class="...">
|
|
1022
|
+
<!-- Navigation content -->
|
|
1023
|
+
</header>
|
|
1024
|
+
|
|
1025
|
+
<section id="_hero_001" class="...">
|
|
1026
|
+
<!-- Hero content -->
|
|
1027
|
+
</section>
|
|
1028
|
+
|
|
1029
|
+
<section id="_features_002" class="...">
|
|
1030
|
+
<!-- Features content -->
|
|
1031
|
+
</section>
|
|
1032
|
+
|
|
1033
|
+
<footer id="_footer_001" class="...">
|
|
1034
|
+
<!-- Footer content -->
|
|
1035
|
+
</footer>
|
|
1036
|
+
\`\`\`
|
|
1037
|
+
|
|
1038
|
+
### Tailwind CSS v3.4 Usage
|
|
1039
|
+
|
|
1040
|
+
Lindo pages use Tailwind CSS v3.4 for styling:
|
|
1041
|
+
|
|
1042
|
+
- **Utility-first approach**: Use Tailwind utility classes for all styling
|
|
1043
|
+
- **No custom CSS**: Avoid writing custom CSS; use Tailwind utilities instead
|
|
1044
|
+
- **NO font family classes**: Do NOT use \`font-sans\`, \`font-serif\`, \`font-mono\`, or any \`font-[family]\` classes - fonts are managed by the theme system
|
|
1045
|
+
- **Responsive design**: Use responsive prefixes (\`sm:\`, \`md:\`, \`lg:\`, \`xl:\`, \`2xl:\`) for all breakpoints
|
|
1046
|
+
- **Dark mode support**: Always include dark mode variants using the \`dark:\` prefix
|
|
1047
|
+
- **Neutral shades**: Use neutral color shades for text and surfaces (e.g., \`text-neutral-900 dark:text-neutral-100\`)
|
|
1048
|
+
|
|
1049
|
+
Example:
|
|
1050
|
+
\`\`\`html
|
|
1051
|
+
<div class="px-4 py-8 md:px-8 lg:px-16 bg-white dark:bg-neutral-900">
|
|
1052
|
+
<h1 class="text-3xl md:text-4xl lg:text-5xl text-neutral-900 dark:text-white">
|
|
1053
|
+
Welcome
|
|
1054
|
+
</h1>
|
|
1055
|
+
</div>
|
|
1056
|
+
\`\`\`
|
|
1057
|
+
|
|
1058
|
+
### Animation System
|
|
1059
|
+
|
|
1060
|
+
Lindo uses a custom animation system with \`data-motion\` attributes for scroll-triggered animations:
|
|
1061
|
+
|
|
1062
|
+
**Available animation types:**
|
|
1063
|
+
- \`fade\` - Simple fade in
|
|
1064
|
+
- \`fade-up\` - Fade in while moving up
|
|
1065
|
+
- \`fade-down\` - Fade in while moving down
|
|
1066
|
+
- \`fade-left\` - Fade in while moving from left
|
|
1067
|
+
- \`fade-right\` - Fade in while moving from right
|
|
1068
|
+
- \`scale\` - Scale up while fading in
|
|
1069
|
+
- \`card\` - Card entrance animation
|
|
1070
|
+
- \`heading\` - Heading text animation
|
|
1071
|
+
- \`text\` - Body text animation
|
|
1072
|
+
- \`image\` - Image reveal animation
|
|
1073
|
+
- \`button\` - Button entrance animation
|
|
1074
|
+
|
|
1075
|
+
**Usage:**
|
|
1076
|
+
\`\`\`html
|
|
1077
|
+
<section data-motion="fade-up">
|
|
1078
|
+
<h2 data-motion="heading">Section Title</h2>
|
|
1079
|
+
<p data-motion="text">Section description text.</p>
|
|
1080
|
+
<img data-motion="image" src="..." alt="..." />
|
|
1081
|
+
<button data-motion="button">Click Me</button>
|
|
1082
|
+
</section>
|
|
1083
|
+
\`\`\`
|
|
1084
|
+
|
|
1085
|
+
**Animation delays:** Use \`data-motion-delay\` for staggered animations:
|
|
1086
|
+
\`\`\`html
|
|
1087
|
+
<div data-motion="fade-up" data-motion-delay="0">First item</div>
|
|
1088
|
+
<div data-motion="fade-up" data-motion-delay="100">Second item</div>
|
|
1089
|
+
<div data-motion="fade-up" data-motion-delay="200">Third item</div>
|
|
1090
|
+
\`\`\`
|
|
1091
|
+
|
|
1092
|
+
### Logo Requirements
|
|
1093
|
+
|
|
1094
|
+
When adding logos to pages, use the \`lindo-image-logo\` attribute:
|
|
1095
|
+
|
|
1096
|
+
**Logo types:**
|
|
1097
|
+
- \`full\` - Full logo (icon + text)
|
|
1098
|
+
- \`icon\` - Icon only
|
|
1099
|
+
- \`text\` - Text only
|
|
1100
|
+
|
|
1101
|
+
**Usage:**
|
|
1102
|
+
\`\`\`html
|
|
1103
|
+
<!-- Full logo -->
|
|
1104
|
+
<img lindo-image-logo="full" src="https://cdn.ln-cdn.com/image/placeholder-logo-full.png" alt="Logo" class="h-8" />
|
|
1105
|
+
|
|
1106
|
+
<!-- Icon only -->
|
|
1107
|
+
<img lindo-image-logo="icon" src="https://cdn.ln-cdn.com/image/placeholder-logo-icon.png" alt="Logo" class="h-8 w-8" />
|
|
1108
|
+
|
|
1109
|
+
<!-- Text only -->
|
|
1110
|
+
<img lindo-image-logo="text" src="https://cdn.ln-cdn.com/image/placeholder-logo-text.png" alt="Logo" class="h-6" />
|
|
1111
|
+
\`\`\`
|
|
1112
|
+
|
|
1113
|
+
**Important:**
|
|
1114
|
+
- Do NOT add text or brand names as logo alternatives
|
|
1115
|
+
- Always use the \`lindo-image-logo\` attribute for logos
|
|
1116
|
+
- The actual logo will be replaced with the website's configured logo
|
|
1117
|
+
|
|
1118
|
+
### Theme Guidelines
|
|
1119
|
+
|
|
1120
|
+
Follow these theme guidelines for consistent light and dark mode support:
|
|
1121
|
+
|
|
1122
|
+
**Light and Dark Mode:**
|
|
1123
|
+
- Every element must specify both light and dark styles
|
|
1124
|
+
- Use the \`dark:\` prefix for dark mode variants
|
|
1125
|
+
- Test both modes to ensure readability and contrast
|
|
1126
|
+
|
|
1127
|
+
**Color Palette:**
|
|
1128
|
+
- Use Tailwind's default color palette
|
|
1129
|
+
- Primary colors: Use brand colors from the theme
|
|
1130
|
+
- Text colors: \`text-neutral-900 dark:text-white\` for headings, \`text-neutral-600 dark:text-neutral-400\` for body text
|
|
1131
|
+
- Background colors: \`bg-white dark:bg-neutral-900\` for main backgrounds
|
|
1132
|
+
- Surface colors: \`bg-neutral-50 dark:bg-neutral-800\` for cards and elevated surfaces
|
|
1133
|
+
|
|
1134
|
+
**Gradients:**
|
|
1135
|
+
- Apply gradient backgrounds where appropriate for visual interest
|
|
1136
|
+
- Example: \`bg-gradient-to-br from-blue-500 to-purple-600\`
|
|
1137
|
+
|
|
1138
|
+
**Example with full theme support:**
|
|
1139
|
+
\`\`\`html
|
|
1140
|
+
<section class="py-16 bg-white dark:bg-neutral-900">
|
|
1141
|
+
<div class="container mx-auto px-4">
|
|
1142
|
+
<h2 class="text-3xl text-neutral-900 dark:text-white mb-4">
|
|
1143
|
+
Section Title
|
|
1144
|
+
</h2>
|
|
1145
|
+
<p class="text-neutral-600 dark:text-neutral-400 mb-8">
|
|
1146
|
+
Section description with proper contrast in both modes.
|
|
1147
|
+
</p>
|
|
1148
|
+
<div class="bg-neutral-50 dark:bg-neutral-800 rounded-lg p-6">
|
|
1149
|
+
<p class="text-neutral-700 dark:text-neutral-300">
|
|
1150
|
+
Card content with elevated surface.
|
|
1151
|
+
</p>
|
|
1152
|
+
</div>
|
|
1153
|
+
</div>
|
|
1154
|
+
</section>
|
|
1155
|
+
\`\`\`
|
|
1156
|
+
|
|
1157
|
+
### Core Rules
|
|
1158
|
+
|
|
1159
|
+
Follow these core rules when building pages:
|
|
1160
|
+
|
|
1161
|
+
1. **No font family classes**: Never use \`font-sans\`, \`font-serif\`, \`font-mono\`, or custom font classes. The theme system manages fonts.
|
|
1162
|
+
|
|
1163
|
+
2. **Responsive design is required**: All pages must be fully responsive. Use Tailwind's responsive prefixes:
|
|
1164
|
+
- Mobile first: Start with base styles
|
|
1165
|
+
- \`sm:\` - Small screens (640px+)
|
|
1166
|
+
- \`md:\` - Medium screens (768px+)
|
|
1167
|
+
- \`lg:\` - Large screens (1024px+)
|
|
1168
|
+
- \`xl:\` - Extra large screens (1280px+)
|
|
1169
|
+
- \`2xl:\` - 2X large screens (1536px+)
|
|
1170
|
+
|
|
1171
|
+
3. **Accessibility considerations**:
|
|
1172
|
+
- Use semantic HTML elements (\`<header>\`, \`<nav>\`, \`<main>\`, \`<section>\`, \`<footer>\`)
|
|
1173
|
+
- Include \`alt\` attributes on all images
|
|
1174
|
+
- Ensure sufficient color contrast (WCAG AA minimum)
|
|
1175
|
+
- Use proper heading hierarchy (h1 \u2192 h2 \u2192 h3)
|
|
1176
|
+
- Add \`aria-label\` attributes to interactive elements without visible text
|
|
1177
|
+
|
|
1178
|
+
4. **Image handling**:
|
|
1179
|
+
- Use responsive images with appropriate sizes
|
|
1180
|
+
- Include descriptive \`alt\` text
|
|
1181
|
+
- Use lazy loading for below-the-fold images: \`loading="lazy"\`
|
|
1182
|
+
|
|
1183
|
+
5. **Link handling**:
|
|
1184
|
+
- Use descriptive link text (avoid "click here")
|
|
1185
|
+
- External links should have \`target="_blank"\` and \`rel="noopener noreferrer"\`
|
|
1186
|
+
|
|
1187
|
+
6. **Container patterns**:
|
|
1188
|
+
- Use \`container mx-auto px-4\` for consistent content width
|
|
1189
|
+
- Apply consistent vertical padding: \`py-12 md:py-16 lg:py-20\`
|
|
1190
|
+
`;function To(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function Po(){try{return r("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function Ao(){k__namespace.existsSync(Me)||k__namespace.mkdirSync(Me,{recursive:true}),k__namespace.writeFileSync(bt,$o,"utf-8");}function We(){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=>{To()||(e.install?(Po()||(s("Failed to install OpenCode"),r("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),m("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{Ao(),r(`Skill file installed to: ${bt}`);}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 Ro="1.0.0";function Do(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(Ro,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(ve()),o.addCommand(xe()),o.addCommand(ke()),o.addCommand(Ce()),o.addCommand(_e()),o.addCommand(Se()),o.addCommand(Oe()),o.addCommand(Re()),o.addCommand(Ne()),o.addCommand(Ue()),o.addCommand(We()),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 jo(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 No(){let o=Do();try{await o.parseAsync(process.argv);}catch(e){throw e instanceof lindoai.AuthenticationError&&(jo(),process.exit(1)),e}}No().catch(o=>{o instanceof Error?s(`Unexpected error: ${o.message}`):s("An unexpected error occurred"),process.exit(1);});
|
|
1191
|
+
exports.createProgram=Do;
|